@toclocoinc/lattice-grid 1.80.0 → 1.81.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 +6 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +4 -4
- package/docs/THEMING.md +6 -3
- 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 +1 -1
- package/docs/api/dashboard.html +1 -1
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +1 -1
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +1 -1
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/leaflet.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/presets.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +1 -1
- package/docs/api-detail.html +4 -4
- package/docs/warnings.json +1 -1
- package/lattice-grid.d.ts +1 -1
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- package/lattice-grid.min.css +1 -1
- package/lattice-grid.min.js +3 -3
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +2 -2
- package/modules/ai.min.cjs +2 -2
- package/modules/ai.min.js +2 -2
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +2 -2
- package/modules/alarms.min.cjs +2 -2
- package/modules/alarms.min.js +2 -2
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +1 -1
- package/modules/chart-calendar.min.cjs +1 -1
- package/modules/chart-calendar.min.js +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +1 -1
- package/modules/chart-choropleth.min.cjs +1 -1
- package/modules/chart-choropleth.min.js +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexbin.min.cjs +1 -1
- package/modules/chart-hexbin.min.js +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +1 -1
- package/modules/chart-hexmap.min.cjs +1 -1
- package/modules/chart-hexmap.min.js +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +2 -2
- package/modules/charts.min.cjs +2 -2
- package/modules/charts.min.js +2 -2
- package/modules/dashboard.d.ts +1 -1
- package/modules/dashboard.esm.min.js +2 -2
- package/modules/dashboard.min.cjs +2 -2
- package/modules/dashboard.min.js +2 -2
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +2 -2
- package/modules/data-router.min.cjs +2 -2
- package/modules/data-router.min.js +2 -2
- package/modules/deckgl.d.ts +1 -1
- package/modules/deckgl.esm.min.js +2 -2
- package/modules/deckgl.min.cjs +2 -2
- package/modules/deckgl.min.js +2 -2
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +1 -1
- package/modules/devtools.min.cjs +1 -1
- package/modules/devtools.min.js +1 -1
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +2 -2
- package/modules/dhtmlx-compat.min.cjs +2 -2
- package/modules/dhtmlx-compat.min.js +2 -2
- package/modules/gantt.d.ts +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/leaflet.d.ts +1 -1
- package/modules/leaflet.esm.min.js +2 -2
- package/modules/leaflet.min.cjs +2 -2
- package/modules/leaflet.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +1 -1
- package/modules/mock-socket.min.cjs +1 -1
- package/modules/mock-socket.min.js +1 -1
- package/modules/presets/antd5.css +23 -0
- package/modules/presets/bootstrap5.css +46 -5
- package/modules/presets/fluent2.css +31 -4
- package/modules/presets/material3.css +53 -5
- package/modules/presets.d.ts +1 -1
- package/modules/presets.esm.min.js +2 -2
- package/modules/presets.min.cjs +2 -2
- package/modules/presets.min.js +2 -2
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +2 -2
- package/modules/tabs.min.cjs +2 -2
- package/modules/tabs.min.js +2 -2
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +3 -3
- package/modules/webcomponent.min.cjs +3 -3
- package/modules/webcomponent.min.js +3 -3
- package/package.json +1 -1
package/modules/htmx.min.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.81.0, htmx module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
(function(hr){"use strict";var Kn=Object.create(null),Wn=Object.create(null);function xe(e,G){Kn[e]=G}function Ln(e){var G=Wn[e];if(G)return G;var Q=Object.create(null);Wn[e]=Q;var L=Kn[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(Q,Ln),Q}xe("packages/core/src/internal/util.js",function(e,G){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const Q="1.80.0";async function L(){return Q}const B="1.80.0",F=new Set,W=2e3;function X(ne){if(F.add(ne),F.size>W){const ae=F.values().next().value;ae!==void 0&&F.delete(ae)}}const H=[],V=500;function K(ne,ae,de){H.push({key:ne,level:ae,message:de.map(ie=>typeof ie=="string"?ie:D(ie)).join(" "),at:Date.now()}),H.length>V&&H.shift()}function D(ne){if(ne instanceof Error)return ne.message;try{return JSON.stringify(ne)}catch{return String(ne)}}function v(){return H.map(ne=>({...ne}))}function O(ne){if(ne.length===0||typeof ne[0]!="string")return ne;const ae=ne[0].replace(/^\[lattice\]\s*/,"");return ae===ne[0]?ne:[ae,...ne.slice(1)]}function y(ne,...ae){if(F.has(ne))return;X(ne);const de=O(ae);K(ne,"warn",de),console.warn("[lattice]",...de)}function u(ne,...ae){if(F.has(ne))return;X(ne);const de=O(ae);K(ne,"info",de),console.info("[lattice]",...de)}function a(){F.clear(),H.length=0}function s(ne,ae){const de=new Error(`[lattice] ${ne}`);throw ae!==void 0&&(de.cause=ae),de}function n(ne,ae){ne||s(ae)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ne){return ne!==null&&typeof ne=="object"&&!Array.isArray(ne)}function o(ne){return typeof ne=="function"}function f(ne){return ne==null}function c(ne){return ne==null||ne===""}function i(ne){return typeof ne!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ne))?!0:!!(ne.prototype&&Object.getOwnPropertyNames(ne.prototype).length>1)}const g=new Map;function d(ne){let ae=g.get(ne);if(ae)return ae;if(!ne.includes("."))ae=de=>de?.[ne];else{const de=ne.split("."),ie=de.length;ae=oe=>{let ce=oe;for(let fe=0;fe<ie;fe++){if(ce==null)return;ce=ce[de[fe]]}return ce}}return g.set(ne,ae),ae}const h=new Map;function l(ne){let ae=h.get(ne);if(ae)return ae;if(!ne.includes("."))ae=(de,ie)=>{de!=null&&(de[ne]=ie)};else{const de=ne.split("."),ie=de.length-1;ae=(oe,ce)=>{let fe=oe;for(let ke=0;ke<ie;ke++){if(fe==null)return;const Re=de[ke];fe[Re]==null&&(fe[Re]={}),fe=fe[Re]}fe!=null&&(fe[de[ie]]=ce)}}return h.set(ne,ae),ae}function m(ne,ae){return d(ae)(ne)}function w(ne,ae,de){l(ae)(ne,de)}function k(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).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(/^./,de=>de.toUpperCase()):""}const p={"&":"&","<":"<",">":">",'"':""","'":"'"};function b(ne){const ae=ne==null?"":String(ne);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,de=>p[de]):ae}function E(ne){return String(ne).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function T(ne,ae,de){if(ne!==void 0)return ne===!0?{enabled:!0,...de}:ne===!1?{enabled:!1}:r(ne)?ne:{[ae]:ne,enabled:!0}}function P(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(ne,ae){if(!r(ne))return r(ae)?{...ae}:ae;if(!r(ae))return ae===void 0?ne:ae;const de={...ne};for(const ie of Object.keys(ae)){if(x.has(ie))continue;const oe=ae[ie];oe!==void 0&&(de[ie]=r(oe)&&r(de[ie])?C(de[ie],oe):oe)}return de}function A(ne,ae){if(!r(ne)||!r(ae)||ne===ae)return ae;const de=Object.create(Object.getPrototypeOf(ne));return Object.assign(de,ne,ae),de}class j{#e;#t=new Map;#n;constructor(ae=256,de=null){this.#e=ae,this.#n=de}get size(){return this.#t.size}get max(){return this.#e}set max(ae){this.#e=ae,this.#r()}has(ae){return this.#t.has(ae)}get(ae){const de=this.#t;if(!de.has(ae))return;const ie=de.get(ae);return de.delete(ae),de.set(ae,ie),ie}peek(ae){return this.#t.get(ae)}set(ae,de){const ie=this.#t;return ie.has(ae)&&ie.delete(ae),ie.set(ae,de),this.#r(),de}delete(ae){const de=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(de,ae),de}clear(){if(this.#n)for(const[ae,de]of this.#t)this.#n(de,ae);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const ae=this.#t;for(;ae.size>this.#e;){const de=ae.keys().next().value,ie=ae.get(de);ae.delete(de),this.#n&&this.#n(ie,de)}}}const $=new Map;function z(ne,ae){const de=`${ne||""}|${ae?JSON.stringify(ae):""}`;let ie=$.get(de);return ie||(ie=new Intl.Collator(ne||void 0,{numeric:!0,sensitivity:"variant",...ae}),$.set(de,ie)),ie}function M(ne,ae){if(ne===ae)return 0;if(ne==null)return 1;if(ae==null)return-1;if(typeof ne=="number"&&typeof ae=="number")return Number.isNaN(ne)?Number.isNaN(ae)?0:1:Number.isNaN(ae)||ne<ae?-1:ne>ae?1:0;const de=String(ne),ie=String(ae);return de<ie?-1:de>ie?1:0}function R(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const S=typeof requestAnimationFrame=="function";function I(ne){return S?requestAnimationFrame(ne):setTimeout(()=>ne(R()),16)}function q(ne){ne!=null&&(S?cancelAnimationFrame(ne):clearTimeout(ne))}function Z(ne){let ae=null,de=null;const ie=()=>{ae=null;const ce=de;de=null,ne(...ce||[])},oe=(...ce)=>{de=ce,ae===null&&(ae=I(ie))};return oe.cancel=()=>{q(ae),ae=null,de=null},oe.flush=()=>{ae!==null&&(q(ae),ie())},oe}function _(ne,ae){let de=null,ie=null;const oe=()=>{if(de=null,ie===null)return;const ke=ie;ie=null,ne(...ke),ce()},ce=()=>{de=setTimeout(oe,ae),typeof de?.unref=="function"&&de.unref()},fe=(...ke)=>{de===null?(ne(...ke),ce()):(ie=ke,clearTimeout(de),ce())};return fe.flush=()=>{if(de!==null&&clearTimeout(de),de=null,ie===null)return;const ke=ie;ie=null,ne(...ke)},fe.cancel=()=>{de!==null&&clearTimeout(de),de=null,ie=null},fe.pending=()=>de!==null||ie!==null,fe}function J(ne,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ne,{timeout:ae}):setTimeout(()=>ne({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function te(ne="l"){return`${ne}${(++ee).toString(36)}`}}),xe("packages/core/src/formatting/rules.js",function(e,G){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return E}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function H(T,P){const x=Number(T),C=Number(P);if(T!==null&&T!==""&&P!==null&&P!==""&&Number.isFinite(x)&&Number.isFinite(C))return x<C?-1:x>C?1:0;const j=String(T??"").toLowerCase(),$=String(P??"").toLowerCase();return j<$?-1:j>$?1:0}function V(T){return T==null||T===""}function K(T,P){if(!P||typeof P!="object")return!1;const{op:x}=P,C=P.value,A=P.value2;switch(x){case"blank":return V(T);case"notBlank":return!V(T);case"true":return T===!0;case"false":return T===!1;default:break}if(V(T))return!1;switch(x){case"eq":return H(T,C)===0;case"ne":return H(T,C)!==0;case"gt":return H(T,C)>0;case"gte":return H(T,C)>=0;case"lt":return H(T,C)<0;case"lte":return H(T,C)<=0;case"between":return H(T,C)>=0&&H(T,A)<=0;case"outside":return H(T,C)<0||H(T,A)>0;case"contains":return String(T).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function D(T,P,x){const C=q=>{const Z=String(q).replace("#",""),_=Z.length===3?Z.split("").map(J=>J+J).join(""):Z;return[0,2,4].map(J=>parseInt(_.slice(J,J+2),16)||0)},[A,j,$]=C(T),[z,M,R]=C(P),S=Math.max(0,Math.min(1,x)),I=(q,Z)=>Math.round(q+(Z-q)*S);return`#${[I(A,z),I(j,M),I($,R)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function v(T){const P=[];for(const z of T||[]){if(z==null||z==="")continue;const M=z instanceof Date?z.getTime():Number(z);Number.isFinite(M)&&P.push(M)}if(!P.length)return null;P.sort((z,M)=>z-M);let x=0,C=0,A=0;for(const z of P){x++;const M=z-C;C+=M/x,A+=M*(z-C)}const j=O(P,.25),$=O(P,.75);return{n:P.length,min:P[0],max:P[P.length-1],mean:C,stddev:P.length>1?Math.sqrt(A/(P.length-1)):0,median:O(P,.5),q1:j,q3:$,iqr:$-j,sorted:P}}function O(T,P){if(!T.length)return 0;const x=(T.length-1)*Math.max(0,Math.min(1,P)),C=Math.floor(x),A=Math.ceil(x);return C===A?T[C]:T[C]+(x-C)*(T[A]-T[C])}function y(T){for(const P of Array.isArray(T)?T:[])if(!(!P||typeof P!="object")&&(P.when&&W.includes(P.when.op)||P.scale&&P.scale.from||P.dataBar&&!(Number.isFinite(Number(P.dataBar.min))&&Number.isFinite(Number(P.dataBar.max)))||P.iconSet&&!Array.isArray(P.iconSet.thresholds)))return!0;return!1}function u(T,P){const x=Number(T.value),C=A=>O(P.sorted,A);switch(T.op){case"topPercent":{const A=a(x,10);return{op:"gte",value:C(1-A)}}case"bottomPercent":{const A=a(x,10);return{op:"lte",value:C(A)}}case"topN":{const A=Math.max(1,Math.floor(x)||1),j=Math.max(0,P.sorted.length-A);return{op:"gte",value:P.sorted[j]}}case"bottomN":{const A=Math.max(1,Math.floor(x)||1),j=Math.min(P.sorted.length-1,A-1);return{op:"lte",value:P.sorted[j]}}case"aboveMean":return{op:"gt",value:P.mean};case"belowMean":return{op:"lt",value:P.mean};case"aboveMedian":return{op:"gt",value:P.median};case"belowMedian":return{op:"lt",value:P.median};case"zAbove":return P.stddev?{op:"gte",value:P.mean+(Number.isFinite(x)?x:2)*P.stddev}:null;case"zBelow":return P.stddev?{op:"lte",value:P.mean-(Number.isFinite(x)?x:2)*P.stddev}:null;case"outlier":{const A=(Number.isFinite(x)&&x>0?x:1.5)*P.iqr;return P.iqr?{op:"outside",value:P.q1-A,value2:P.q3+A}:null}default:return null}}function a(T,P){const x=Number.isFinite(T)?T:P,C=x>1?x/100:x;return Math.max(0,Math.min(1,C))}function s(T,P){if(T.from==="minmax")return{...T,min:P.min,max:P.max};if(T.from==="quantile")return{...T,min:O(P.sorted,a(Number(T.low),5)),max:O(P.sorted,a(Number(T.high),95))};if(T.from==="stddev"){const x=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:P.mean-x*P.stddev,max:P.mean+x*P.stddev}}return T}function n(T,P){const x=Array.isArray(T)?T:[];return!P||!P.n?x.map(C=>C&&y([C])?{...C,enabled:!1}:C):x.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:s(C.scale,P)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,P)};if(C.iconSet)return{...C,iconSet:r(C.iconSet,P)};if(!C.when||!W.includes(C.when.op))return C;const A=u(C.when,P);return A?{...C,when:A}:{...C,enabled:!1}})}function t(T,P){const x=Number.isFinite(Number(T.min))?Number(T.min):void 0,C=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(x!==void 0&&C!==void 0)return{...T,min:x,max:C};if(T.from==="quantile")return{...T,min:x??O(P.sorted,a(Number(T.low),5)),max:C??O(P.sorted,a(Number(T.high),95))};if(T.from==="stddev"){const A=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:x??P.mean-A*P.stddev,max:C??P.mean+A*P.stddev}}return{...T,min:x??P.min,max:C??P.max}}function r(T,P){if(Array.isArray(T.thresholds))return T;const x=o(T),C=[];for(let A=1;A<x;A++)C.push(O(P.sorted,A/x));return{...T,thresholds:C}}function o(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const P=l[T.set];return P?P.length:3}function f(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function c(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function i(T,P){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${P==="up"?"8,2 14,13 2,13":P==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function g(T,P){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${P*16} 16">`;for(let A=0;A<P;A++){const j=A<T?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${A*16},0)" d="${x}" fill="${j}"/>`}return`${C}</svg>`}const d=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),h=Object.freeze([c("#d13438"),c("#f5a623"),c("#2e9e44")]),l=Object.freeze({arrows:d,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(T=>g(T,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?f(String(C)):String(C));const P=T.set||"arrows";if(P==="ratings"){const C=o(T),A=[];for(let j=1;j<=C;j++)A.push(f(g(j,C)));return A}const x=l[P];return x?x.map(f):(B(`iconSet:${P}`,`unknown icon set '${P}'; falling back to arrows.`),d.map(f))}function k(T){const P=Number(T.min),C=Number(T.max)-P,A=T.colour||T.color||"#5b9bd5",j=T.negativeColour||T.negativeColor||"#d13438",$=T.direction==="rtl"?"left":"right",z=R=>Math.max(0,Math.min(1,(R-P)/C))*100,M=C?Math.max(0,Math.min(100,(0-P)/C*100)):0;return R=>{if(V(R))return null;const S=Number(R);if(!Number.isFinite(S)||!C)return null;const I=z(S),q=Math.min(I,M),Z=Math.max(I,M),_=S>=0?A:j;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${_} ${q}%, ${_} ${Z}%, transparent ${Z}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function p(T){const P=w(T),x=T.reverse?[...P].reverse():P,C=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),A=Number.isFinite(Number(T.size))?Number(T.size):16,j=T.set==="ratings"?A*o(T):A;return $=>{if(V($))return null;const z=Number($);if(!Number.isFinite(z))return null;let M=0;for(const S of C)z>=S&&M++;const R=x[Math.min(M,x.length-1)];return R?{backgroundImage:R,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${j}px ${A}px`,paddingLeft:`${j+4}px`}:null}}function b(T){const P=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],x=Number(T.min),C=Number(T.max),A=C-x,j=P.length-1,$=[];for(let M=0;M<=j;M++)$.push(j?M/j:0);const z=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(P.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${P.length} were given, so "mid" was ignored.`);else if(Number.isFinite(z)&&A&&z>Math.min(x,C)&&z<Math.max(x,C)){const M=j/2,R=Math.max(0,Math.min(1,(z-x)/A));for(let S=0;S<=j;S++)$[S]=S<=M?M?S/M*R:R:R+(S-M)/(j-M)*(1-R)}else Number.isFinite(z)&&B("formatting.scale.mid.range",`a scale's "mid" (${z}) is outside its min..max range, so it was ignored.`);return M=>{const R=Number(M);if(!Number.isFinite(R)||!A)return null;const S=Math.max(0,Math.min(1,(R-x)/A));let I=0;for(;I<j-1&&S>$[I+1];)I++;const q=$[I+1]-$[I],Z=q>0?(S-$[I])/q:0;return{background:D(P[I],P[I+1],Math.max(0,Math.min(1,Z)))}}}function E(T,P=null){const x=y(T)?n(T,P):T,C=(Array.isArray(x)?x:[]).filter(j=>j&&typeof j=="object");if(!C.length)return()=>null;const A=C.map(j=>j.scale?{scale:b(j.scale),enabled:j.enabled!==!1}:j.dataBar?{scale:k(j.dataBar),enabled:j.enabled!==!1}:j.iconSet?{scale:p(j.iconSet),enabled:j.enabled!==!1}:{when:j.when,style:j.style,stop:j.stopIfTrue!==!1,enabled:j.enabled!==!1});return j=>{const $=j?j.value:void 0;let z=null;for(const M of A){if(!M.enabled)continue;if(M.scale){const S=M.scale($);S&&(z={...z||{},...S});continue}if(!K($,M.when))continue;const R=L(M.style)?M.style(j):M.style;if(R&&(z={...z||{},...R}),M.stop)break}return z}}}),xe("packages/core/src/formula/parse.js",function(e,G){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",L="str",B="ref",F="name",W="op",X="end",H=["<=",">=","<>","!="],V="+-*/^%(),<>=";class K extends Error{constructor(o,f){super(o),this.name="FormulaError",this.at=f}}function D(r){const o=[];let f=0;for(;f<r.length;){const c=r[f];if(c===" "||c===" "||c===`
|
|
6
|
+
(function(hr){"use strict";var Kn=Object.create(null),Wn=Object.create(null);function xe(e,G){Kn[e]=G}function Ln(e){var G=Wn[e];if(G)return G;var Q=Object.create(null);Wn[e]=Q;var L=Kn[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(Q,Ln),Q}xe("packages/core/src/internal/util.js",function(e,G){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const Q="1.81.0";async function L(){return Q}const B="1.81.0",F=new Set,W=2e3;function X(ne){if(F.add(ne),F.size>W){const ae=F.values().next().value;ae!==void 0&&F.delete(ae)}}const H=[],V=500;function K(ne,ae,de){H.push({key:ne,level:ae,message:de.map(ie=>typeof ie=="string"?ie:D(ie)).join(" "),at:Date.now()}),H.length>V&&H.shift()}function D(ne){if(ne instanceof Error)return ne.message;try{return JSON.stringify(ne)}catch{return String(ne)}}function v(){return H.map(ne=>({...ne}))}function O(ne){if(ne.length===0||typeof ne[0]!="string")return ne;const ae=ne[0].replace(/^\[lattice\]\s*/,"");return ae===ne[0]?ne:[ae,...ne.slice(1)]}function y(ne,...ae){if(F.has(ne))return;X(ne);const de=O(ae);K(ne,"warn",de),console.warn("[lattice]",...de)}function u(ne,...ae){if(F.has(ne))return;X(ne);const de=O(ae);K(ne,"info",de),console.info("[lattice]",...de)}function a(){F.clear(),H.length=0}function s(ne,ae){const de=new Error(`[lattice] ${ne}`);throw ae!==void 0&&(de.cause=ae),de}function n(ne,ae){ne||s(ae)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ne){return ne!==null&&typeof ne=="object"&&!Array.isArray(ne)}function o(ne){return typeof ne=="function"}function f(ne){return ne==null}function c(ne){return ne==null||ne===""}function i(ne){return typeof ne!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ne))?!0:!!(ne.prototype&&Object.getOwnPropertyNames(ne.prototype).length>1)}const g=new Map;function d(ne){let ae=g.get(ne);if(ae)return ae;if(!ne.includes("."))ae=de=>de?.[ne];else{const de=ne.split("."),ie=de.length;ae=oe=>{let ce=oe;for(let fe=0;fe<ie;fe++){if(ce==null)return;ce=ce[de[fe]]}return ce}}return g.set(ne,ae),ae}const h=new Map;function l(ne){let ae=h.get(ne);if(ae)return ae;if(!ne.includes("."))ae=(de,ie)=>{de!=null&&(de[ne]=ie)};else{const de=ne.split("."),ie=de.length-1;ae=(oe,ce)=>{let fe=oe;for(let ke=0;ke<ie;ke++){if(fe==null)return;const Re=de[ke];fe[Re]==null&&(fe[Re]={}),fe=fe[Re]}fe!=null&&(fe[de[ie]]=ce)}}return h.set(ne,ae),ae}function m(ne,ae){return d(ae)(ne)}function w(ne,ae,de){l(ae)(ne,de)}function k(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).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(/^./,de=>de.toUpperCase()):""}const p={"&":"&","<":"<",">":">",'"':""","'":"'"};function b(ne){const ae=ne==null?"":String(ne);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,de=>p[de]):ae}function E(ne){return String(ne).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function T(ne,ae,de){if(ne!==void 0)return ne===!0?{enabled:!0,...de}:ne===!1?{enabled:!1}:r(ne)?ne:{[ae]:ne,enabled:!0}}function P(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(ne,ae){if(!r(ne))return r(ae)?{...ae}:ae;if(!r(ae))return ae===void 0?ne:ae;const de={...ne};for(const ie of Object.keys(ae)){if(x.has(ie))continue;const oe=ae[ie];oe!==void 0&&(de[ie]=r(oe)&&r(de[ie])?C(de[ie],oe):oe)}return de}function A(ne,ae){if(!r(ne)||!r(ae)||ne===ae)return ae;const de=Object.create(Object.getPrototypeOf(ne));return Object.assign(de,ne,ae),de}class j{#e;#t=new Map;#n;constructor(ae=256,de=null){this.#e=ae,this.#n=de}get size(){return this.#t.size}get max(){return this.#e}set max(ae){this.#e=ae,this.#r()}has(ae){return this.#t.has(ae)}get(ae){const de=this.#t;if(!de.has(ae))return;const ie=de.get(ae);return de.delete(ae),de.set(ae,ie),ie}peek(ae){return this.#t.get(ae)}set(ae,de){const ie=this.#t;return ie.has(ae)&&ie.delete(ae),ie.set(ae,de),this.#r(),de}delete(ae){const de=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(de,ae),de}clear(){if(this.#n)for(const[ae,de]of this.#t)this.#n(de,ae);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const ae=this.#t;for(;ae.size>this.#e;){const de=ae.keys().next().value,ie=ae.get(de);ae.delete(de),this.#n&&this.#n(ie,de)}}}const $=new Map;function z(ne,ae){const de=`${ne||""}|${ae?JSON.stringify(ae):""}`;let ie=$.get(de);return ie||(ie=new Intl.Collator(ne||void 0,{numeric:!0,sensitivity:"variant",...ae}),$.set(de,ie)),ie}function M(ne,ae){if(ne===ae)return 0;if(ne==null)return 1;if(ae==null)return-1;if(typeof ne=="number"&&typeof ae=="number")return Number.isNaN(ne)?Number.isNaN(ae)?0:1:Number.isNaN(ae)||ne<ae?-1:ne>ae?1:0;const de=String(ne),ie=String(ae);return de<ie?-1:de>ie?1:0}function R(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const S=typeof requestAnimationFrame=="function";function I(ne){return S?requestAnimationFrame(ne):setTimeout(()=>ne(R()),16)}function q(ne){ne!=null&&(S?cancelAnimationFrame(ne):clearTimeout(ne))}function Z(ne){let ae=null,de=null;const ie=()=>{ae=null;const ce=de;de=null,ne(...ce||[])},oe=(...ce)=>{de=ce,ae===null&&(ae=I(ie))};return oe.cancel=()=>{q(ae),ae=null,de=null},oe.flush=()=>{ae!==null&&(q(ae),ie())},oe}function _(ne,ae){let de=null,ie=null;const oe=()=>{if(de=null,ie===null)return;const ke=ie;ie=null,ne(...ke),ce()},ce=()=>{de=setTimeout(oe,ae),typeof de?.unref=="function"&&de.unref()},fe=(...ke)=>{de===null?(ne(...ke),ce()):(ie=ke,clearTimeout(de),ce())};return fe.flush=()=>{if(de!==null&&clearTimeout(de),de=null,ie===null)return;const ke=ie;ie=null,ne(...ke)},fe.cancel=()=>{de!==null&&clearTimeout(de),de=null,ie=null},fe.pending=()=>de!==null||ie!==null,fe}function J(ne,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ne,{timeout:ae}):setTimeout(()=>ne({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function te(ne="l"){return`${ne}${(++ee).toString(36)}`}}),xe("packages/core/src/formatting/rules.js",function(e,G){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return E}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function H(T,P){const x=Number(T),C=Number(P);if(T!==null&&T!==""&&P!==null&&P!==""&&Number.isFinite(x)&&Number.isFinite(C))return x<C?-1:x>C?1:0;const j=String(T??"").toLowerCase(),$=String(P??"").toLowerCase();return j<$?-1:j>$?1:0}function V(T){return T==null||T===""}function K(T,P){if(!P||typeof P!="object")return!1;const{op:x}=P,C=P.value,A=P.value2;switch(x){case"blank":return V(T);case"notBlank":return!V(T);case"true":return T===!0;case"false":return T===!1;default:break}if(V(T))return!1;switch(x){case"eq":return H(T,C)===0;case"ne":return H(T,C)!==0;case"gt":return H(T,C)>0;case"gte":return H(T,C)>=0;case"lt":return H(T,C)<0;case"lte":return H(T,C)<=0;case"between":return H(T,C)>=0&&H(T,A)<=0;case"outside":return H(T,C)<0||H(T,A)>0;case"contains":return String(T).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function D(T,P,x){const C=q=>{const Z=String(q).replace("#",""),_=Z.length===3?Z.split("").map(J=>J+J).join(""):Z;return[0,2,4].map(J=>parseInt(_.slice(J,J+2),16)||0)},[A,j,$]=C(T),[z,M,R]=C(P),S=Math.max(0,Math.min(1,x)),I=(q,Z)=>Math.round(q+(Z-q)*S);return`#${[I(A,z),I(j,M),I($,R)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function v(T){const P=[];for(const z of T||[]){if(z==null||z==="")continue;const M=z instanceof Date?z.getTime():Number(z);Number.isFinite(M)&&P.push(M)}if(!P.length)return null;P.sort((z,M)=>z-M);let x=0,C=0,A=0;for(const z of P){x++;const M=z-C;C+=M/x,A+=M*(z-C)}const j=O(P,.25),$=O(P,.75);return{n:P.length,min:P[0],max:P[P.length-1],mean:C,stddev:P.length>1?Math.sqrt(A/(P.length-1)):0,median:O(P,.5),q1:j,q3:$,iqr:$-j,sorted:P}}function O(T,P){if(!T.length)return 0;const x=(T.length-1)*Math.max(0,Math.min(1,P)),C=Math.floor(x),A=Math.ceil(x);return C===A?T[C]:T[C]+(x-C)*(T[A]-T[C])}function y(T){for(const P of Array.isArray(T)?T:[])if(!(!P||typeof P!="object")&&(P.when&&W.includes(P.when.op)||P.scale&&P.scale.from||P.dataBar&&!(Number.isFinite(Number(P.dataBar.min))&&Number.isFinite(Number(P.dataBar.max)))||P.iconSet&&!Array.isArray(P.iconSet.thresholds)))return!0;return!1}function u(T,P){const x=Number(T.value),C=A=>O(P.sorted,A);switch(T.op){case"topPercent":{const A=a(x,10);return{op:"gte",value:C(1-A)}}case"bottomPercent":{const A=a(x,10);return{op:"lte",value:C(A)}}case"topN":{const A=Math.max(1,Math.floor(x)||1),j=Math.max(0,P.sorted.length-A);return{op:"gte",value:P.sorted[j]}}case"bottomN":{const A=Math.max(1,Math.floor(x)||1),j=Math.min(P.sorted.length-1,A-1);return{op:"lte",value:P.sorted[j]}}case"aboveMean":return{op:"gt",value:P.mean};case"belowMean":return{op:"lt",value:P.mean};case"aboveMedian":return{op:"gt",value:P.median};case"belowMedian":return{op:"lt",value:P.median};case"zAbove":return P.stddev?{op:"gte",value:P.mean+(Number.isFinite(x)?x:2)*P.stddev}:null;case"zBelow":return P.stddev?{op:"lte",value:P.mean-(Number.isFinite(x)?x:2)*P.stddev}:null;case"outlier":{const A=(Number.isFinite(x)&&x>0?x:1.5)*P.iqr;return P.iqr?{op:"outside",value:P.q1-A,value2:P.q3+A}:null}default:return null}}function a(T,P){const x=Number.isFinite(T)?T:P,C=x>1?x/100:x;return Math.max(0,Math.min(1,C))}function s(T,P){if(T.from==="minmax")return{...T,min:P.min,max:P.max};if(T.from==="quantile")return{...T,min:O(P.sorted,a(Number(T.low),5)),max:O(P.sorted,a(Number(T.high),95))};if(T.from==="stddev"){const x=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:P.mean-x*P.stddev,max:P.mean+x*P.stddev}}return T}function n(T,P){const x=Array.isArray(T)?T:[];return!P||!P.n?x.map(C=>C&&y([C])?{...C,enabled:!1}:C):x.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:s(C.scale,P)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,P)};if(C.iconSet)return{...C,iconSet:r(C.iconSet,P)};if(!C.when||!W.includes(C.when.op))return C;const A=u(C.when,P);return A?{...C,when:A}:{...C,enabled:!1}})}function t(T,P){const x=Number.isFinite(Number(T.min))?Number(T.min):void 0,C=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(x!==void 0&&C!==void 0)return{...T,min:x,max:C};if(T.from==="quantile")return{...T,min:x??O(P.sorted,a(Number(T.low),5)),max:C??O(P.sorted,a(Number(T.high),95))};if(T.from==="stddev"){const A=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:x??P.mean-A*P.stddev,max:C??P.mean+A*P.stddev}}return{...T,min:x??P.min,max:C??P.max}}function r(T,P){if(Array.isArray(T.thresholds))return T;const x=o(T),C=[];for(let A=1;A<x;A++)C.push(O(P.sorted,A/x));return{...T,thresholds:C}}function o(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const P=l[T.set];return P?P.length:3}function f(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function c(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function i(T,P){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${P==="up"?"8,2 14,13 2,13":P==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function g(T,P){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${P*16} 16">`;for(let A=0;A<P;A++){const j=A<T?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${A*16},0)" d="${x}" fill="${j}"/>`}return`${C}</svg>`}const d=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),h=Object.freeze([c("#d13438"),c("#f5a623"),c("#2e9e44")]),l=Object.freeze({arrows:d,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(T=>g(T,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?f(String(C)):String(C));const P=T.set||"arrows";if(P==="ratings"){const C=o(T),A=[];for(let j=1;j<=C;j++)A.push(f(g(j,C)));return A}const x=l[P];return x?x.map(f):(B(`iconSet:${P}`,`unknown icon set '${P}'; falling back to arrows.`),d.map(f))}function k(T){const P=Number(T.min),C=Number(T.max)-P,A=T.colour||T.color||"#5b9bd5",j=T.negativeColour||T.negativeColor||"#d13438",$=T.direction==="rtl"?"left":"right",z=R=>Math.max(0,Math.min(1,(R-P)/C))*100,M=C?Math.max(0,Math.min(100,(0-P)/C*100)):0;return R=>{if(V(R))return null;const S=Number(R);if(!Number.isFinite(S)||!C)return null;const I=z(S),q=Math.min(I,M),Z=Math.max(I,M),_=S>=0?A:j;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${_} ${q}%, ${_} ${Z}%, transparent ${Z}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function p(T){const P=w(T),x=T.reverse?[...P].reverse():P,C=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),A=Number.isFinite(Number(T.size))?Number(T.size):16,j=T.set==="ratings"?A*o(T):A;return $=>{if(V($))return null;const z=Number($);if(!Number.isFinite(z))return null;let M=0;for(const S of C)z>=S&&M++;const R=x[Math.min(M,x.length-1)];return R?{backgroundImage:R,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${j}px ${A}px`,paddingLeft:`${j+4}px`}:null}}function b(T){const P=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],x=Number(T.min),C=Number(T.max),A=C-x,j=P.length-1,$=[];for(let M=0;M<=j;M++)$.push(j?M/j:0);const z=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(P.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${P.length} were given, so "mid" was ignored.`);else if(Number.isFinite(z)&&A&&z>Math.min(x,C)&&z<Math.max(x,C)){const M=j/2,R=Math.max(0,Math.min(1,(z-x)/A));for(let S=0;S<=j;S++)$[S]=S<=M?M?S/M*R:R:R+(S-M)/(j-M)*(1-R)}else Number.isFinite(z)&&B("formatting.scale.mid.range",`a scale's "mid" (${z}) is outside its min..max range, so it was ignored.`);return M=>{const R=Number(M);if(!Number.isFinite(R)||!A)return null;const S=Math.max(0,Math.min(1,(R-x)/A));let I=0;for(;I<j-1&&S>$[I+1];)I++;const q=$[I+1]-$[I],Z=q>0?(S-$[I])/q:0;return{background:D(P[I],P[I+1],Math.max(0,Math.min(1,Z)))}}}function E(T,P=null){const x=y(T)?n(T,P):T,C=(Array.isArray(x)?x:[]).filter(j=>j&&typeof j=="object");if(!C.length)return()=>null;const A=C.map(j=>j.scale?{scale:b(j.scale),enabled:j.enabled!==!1}:j.dataBar?{scale:k(j.dataBar),enabled:j.enabled!==!1}:j.iconSet?{scale:p(j.iconSet),enabled:j.enabled!==!1}:{when:j.when,style:j.style,stop:j.stopIfTrue!==!1,enabled:j.enabled!==!1});return j=>{const $=j?j.value:void 0;let z=null;for(const M of A){if(!M.enabled)continue;if(M.scale){const S=M.scale($);S&&(z={...z||{},...S});continue}if(!K($,M.when))continue;const R=L(M.style)?M.style(j):M.style;if(R&&(z={...z||{},...R}),M.stop)break}return z}}}),xe("packages/core/src/formula/parse.js",function(e,G){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",L="str",B="ref",F="name",W="op",X="end",H=["<=",">=","<>","!="],V="+-*/^%(),<>=";class K extends Error{constructor(o,f){super(o),this.name="FormulaError",this.at=f}}function D(r){const o=[];let f=0;for(;f<r.length;){const c=r[f];if(c===" "||c===" "||c===`
|
|
7
7
|
`||c==="\r"){f++;continue}if(c>="0"&&c<="9"){f=O(r,f,o);continue}if(c==="."&&r[f+1]>="0"&&r[f+1]<="9"){f=O(r,f,o);continue}if(c==='"'||c==="'"){f=y(r,f,o);continue}if(c==="["){const g=r.indexOf("]",f+1);if(g<0)throw new K("a [column reference] was opened and never closed",f);o.push({kind:B,value:r.slice(f+1,g).trim(),at:f}),f=g+1;continue}if(v(c)){f=u(r,f,o);continue}const i=r.slice(f,f+2);if(H.includes(i)){o.push({kind:W,value:i==="!="?"<>":i,at:f}),f+=2;continue}if(V.includes(c)){o.push({kind:W,value:c,at:f}),f++;continue}throw new K(`unexpected character ${JSON.stringify(c)}`,f)}return o.push({kind:X,value:null,at:r.length}),o}function v(r){return/[A-Za-z_À-]/.test(r)}function O(r,o,f){let c=o,i=!1;for(;c<r.length;){const g=r[c];if(g>="0"&&g<="9"){c++;continue}if(g==="."&&!i){i=!0,c++;continue}if((g==="e"||g==="E")&&/[0-9+-]/.test(r[c+1]||"")){for(c+=2;c<r.length&&r[c]>="0"&&r[c]<="9";)c++;break}break}return f.push({kind:Q,value:Number(r.slice(o,c)),at:o}),c}function y(r,o,f){const c=r[o];let i=o+1,g="";for(;i<r.length;){if(r[i]===c){if(r[i+1]===c){g+=c,i+=2;continue}return f.push({kind:L,value:g,at:o}),i+1}g+=r[i],i++}throw new K("a string was opened and never closed",o)}function u(r,o,f){let c=o;for(;c<r.length&&/[A-Za-z0-9_.À-]/.test(r[c]);)c++;const i=r.slice(o,c);let g=c;for(;g<r.length&&r[g]===" ";)g++;return f.push({kind:r[g]==="("?F:B,value:i,at:o}),c}const a={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function s(r){const o=String(r??"").replace(/^\s*=/,"");if(!o.trim())throw new K("the formula is empty");const f=D(o);let c=0;const i=()=>f[c],g=()=>f[c++],d=b=>{const E=i();if(E.kind!==W||E.value!==b)throw new K(`expected ${JSON.stringify(b)}`,E.at);c++},h=b=>{let E=l();for(;;){const T=i();if(T.kind!==W)break;const P=a[T.value];if(!P||P<b)break;c++;const x=h(T.value==="^"?P:P+1);E={kind:"bin",op:T.value,left:E,right:x}}return E},l=()=>{const b=i();return b.kind===W&&(b.value==="-"||b.value==="+")?(c++,{kind:"unary",op:b.value,arg:l()}):m()},m=()=>{let b=w();for(;i().kind===W&&i().value==="%";)c++,b={kind:"unary",op:"%",arg:b};return b},w=()=>{const b=g();if(b.kind===Q)return{kind:"num",value:b.value};if(b.kind===L)return{kind:"str",value:b.value};if(b.kind===B)return{kind:"ref",name:b.value};if(b.kind===F){d("(");const E=[];if(!(i().kind===W&&i().value===")"))for(;;){if(E.push(h(1)),i().kind===W&&i().value===","){c++;continue}break}return d(")"),{kind:"call",name:String(b.value).toUpperCase(),args:E}}if(b.kind===W&&b.value==="("){const E=h(1);return d(")"),E}throw b.kind===X?new K("the formula ends unexpectedly",b.at):new K(`unexpected ${JSON.stringify(b.value)}`,b.at)},k=h(1),p=i();if(p.kind!==X)throw new K(`unexpected ${JSON.stringify(p.value)}: is an operator missing?`,p.at);return k}function n(r){const o=new Set,f=c=>{if(!(!c||typeof c!="object")){if(c.kind==="ref"){o.add(String(c.name));return}if(c.kind==="bin"){f(c.left),f(c.right);return}if(c.kind==="unary"){f(c.arg);return}if(c.kind==="call")for(const i of c.args)f(i)}};return f(r),[...o]}function t(r){return typeof r=="string"&&/^\s*=/.test(r)&&r.trim()!=="="}}),xe("packages/core/src/formula/evaluate.js",function(e,G){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const L=G("packages/core/src/formula/parse.js").FormulaError;function B(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const u=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new L(`${JSON.stringify(y)} is not a number`);return u}function F(y){return y==null?"":String(y)}function W(y){if(typeof y=="boolean")return y;if(y==null||y==="")return!1;if(typeof y=="number")return y!==0;const u=String(y).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function X(y){const u=[];for(const a of y){if(Array.isArray(a)){for(const s of a)s!=null&&s!==""&&u.push(B(s));continue}a==null||a===""||u.push(B(a))}return u}function H(y,u){const a=10**u,s=y*a;return Math.sign(s)*Math.round(Math.abs(s)+Number.EPSILON*Math.abs(s))/a}function V(y,u){if(!y.length)return 0;const a=y.slice().sort((r,o)=>r-o),s=(a.length-1)*Math.min(1,Math.max(0,u)),n=Math.floor(s),t=Math.ceil(s);return n===t?a[n]:a[n]+(s-n)*(a[t]-a[n])}function K(y,u){let a=0,s=0,n=0;for(const r of y){a++;const o=r-s;s+=o/a,n+=o*(r-s)}const t=u?a-1:a;return t>0?Math.sqrt(n/t):0}const D={SUM:y=>X(y).reduce((u,a)=>u+a,0),AVERAGE:y=>{const u=X(y);return u.length?u.reduce((a,s)=>a+s,0)/u.length:0},MIN:y=>{const u=X(y);return u.length?Math.min(...u):0},MAX:y=>{const u=X(y);return u.length?Math.max(...u):0},COUNT:y=>X(y).length,PRODUCT:y=>X(y).reduce((u,a)=>u*a,1),ROUND:y=>H(B(y[0]),y.length>1?B(y[1]):0),ROUNDDOWN:y=>{const u=10**(y.length>1?B(y[1]):0),a=B(y[0])*u;return(a<0?Math.ceil(a):Math.floor(a))/u},ROUNDUP:y=>{const u=10**(y.length>1?B(y[1]):0),a=B(y[0])*u;return(a<0?Math.floor(a):Math.ceil(a))/u},ABS:y=>Math.abs(B(y[0])),FLOOR:y=>Math.floor(B(y[0])),CEILING:y=>Math.ceil(B(y[0])),SQRT:y=>Math.sqrt(B(y[0])),POWER:y=>B(y[0])**B(y[1]),MOD:y=>{const u=B(y[1]);if(u===0)throw new L("MOD by zero");return(B(y[0])%u+u)%u},IF:y=>W(y[0])?y[1]:y.length>2?y[2]:!1,AND:y=>y.every(W),OR:y=>y.some(W),NOT:y=>!W(y[0]),COALESCE:y=>y.find(u=>u!=null&&u!=="")??null,CONCAT:y=>y.map(F).join(""),LEN:y=>F(y[0]).length,UPPER:y=>F(y[0]).toUpperCase(),LOWER:y=>F(y[0]).toLowerCase(),TRIM:y=>F(y[0]).trim(),LEFT:y=>F(y[0]).slice(0,y.length>1?B(y[1]):1),RIGHT:y=>{const u=y.length>1?B(y[1]):1;return u<=0?"":F(y[0]).slice(-u)},MEDIAN:y=>V(X(y),.5),PERCENTILE:y=>{const u=B(y[y.length-1]);return V(X(y.slice(0,-1)),u>1?u/100:u)},QUARTILE1:y=>V(X(y),.25),QUARTILE3:y=>V(X(y),.75),STDEV:y=>K(X(y),!0),STDEVP:y=>K(X(y),!1),VAR:y=>{const u=K(X(y),!0);return u*u},VARP:y=>{const u=K(X(y),!1);return u*u},COUNTDISTINCT:y=>{const u=new Set;for(const a of y){const s=Array.isArray(a)?a:[a];for(const n of s)n!=null&&n!==""&&u.add(n)}return u.size},IQR:y=>{const u=X(y);return V(u,.75)-V(u,.25)}};D.AVG=D.AVERAGE,D.CEIL=D.CEILING,D.POW=D.POWER,D.STDEVS=D.STDEV,D.PERCENTILEINC=D.PERCENTILE;function v(y,u){const a=Number(y),s=Number(u);if(y!==null&&y!==""&&u!==null&&u!==""&&Number.isFinite(a)&&Number.isFinite(s))return a<s?-1:a>s?1:0;const t=F(y).toLowerCase(),r=F(u).toLowerCase();return t<r?-1:t>r?1:0}function O(y,u={}){const a=typeof u.lookup=="function"?u.lookup:null,s=u.functions?{...D,...u.functions}:D,n=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!a)throw new L(`there is no column called ${JSON.stringify(t.name)} here`);const r=a(String(t.name));if(r===void 0)throw new L(`there is no column called ${JSON.stringify(t.name)}`);return r}case"unary":{if(t.op==="%")return B(n(t.arg))/100;const r=B(n(t.arg));return t.op==="-"?-r:r}case"bin":{const r=t.op;if(r==="=")return v(n(t.left),n(t.right))===0;if(r==="<>")return v(n(t.left),n(t.right))!==0;if(r==="<")return v(n(t.left),n(t.right))<0;if(r==="<=")return v(n(t.left),n(t.right))<=0;if(r===">")return v(n(t.left),n(t.right))>0;if(r===">=")return v(n(t.left),n(t.right))>=0;const o=B(n(t.left)),f=B(n(t.right));if(r==="+")return o+f;if(r==="-")return o-f;if(r==="*")return o*f;if(r==="^")return o**f;if(r==="/"){if(f===0)throw new L("division by zero");return o/f}throw new L(`unknown operator ${JSON.stringify(r)}`)}case"call":{const r=s[t.name];if(typeof r!="function")throw new L(`there is no function called ${t.name}`);return r(t.args.map(n),u)}default:throw new L("the formula could not be read")}};return n(y)}}),xe("packages/core/src/formula/index.js",function(e,G){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return v}});const Q=G("packages/core/src/formula/parse.js"),L=Q.parseFormula,B=Q.referencesOf,F=Q.looksLikeFormula,W=Q.FormulaError,X=Q.tokenise,H=G("packages/core/src/formula/evaluate.js"),V=H.evaluateAst,K=H.FUNCTIONS;function D(O){const{grid:y,row:u,data:a}=O||{},s=f=>String(f).toLowerCase().replace(/[\s_-]/g,""),n=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],t=y&&y.permissions,r=t&&typeof t.isReadable=="function"?f=>t.isReadable(f):()=>!0,o=new Set;for(const f of n)r(f)||(o.add(s(f.id)),f.field&&o.add(s(f.field)),f.title&&o.add(s(f.title)));return f=>{const c=s(f);if(o.has(c))throw new W(`"${f}" cannot be read`);for(const i of n)if(s(i.id)===c||i.field&&s(i.field)===c||i.title&&s(i.title)===c)return u&&y.rows&&typeof y.rows.value=="function"?y.rows.value(u.key,i.id):a?a[i.field||i.id]:void 0;if(a&&typeof a=="object"){for(const i of Object.keys(a))if(s(i)===c){if(!r(i))throw new W(`"${f}" cannot be read`);return a[i]}}}}function v(O,y={}){try{const u=L(O);return{ok:!0,value:V(u,{lookup:D(y),functions:y.formulaFunctions}),references:B(u)}}catch(u){return{ok:!1,error:u instanceof W?u.message:"the formula could not be read",at:u instanceof W?u.at:void 0}}}}),xe("packages/core/src/defaults.js",function(e,G){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return K}});const Q=G("packages/core/src/internal/util.js"),L=Q.isObject,B=Q.merge,F=Q.warnOnce;let W=null;class X extends Error{}function H(D,v=new Set){if(Array.isArray(D)){if(v.has(D))throw new X;v.add(D);const y=D.map(u=>H(u,v));return v.delete(D),y}if(!L(D)||Object.getPrototypeOf(D)!==Object.prototype&&Object.getPrototypeOf(D)!==null)return D;if(v.has(D))throw new X;v.add(D);const O={};for(const[y,u]of Object.entries(D))O[y]=H(u,v);return v.delete(D),O}function V(D){if(D===void 0)return H(W??{});if(D===null)return W=null,{};if(!L(D))return F("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(D)?"an array":typeof D}. The call was ignored and the defaults are unchanged.`),H(W??{});try{W=H(D)}catch(v){if(!(v instanceof X))throw v;return F("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),H(W??{})}return H(W)}function K(D){return W===null?D:B(H(W),D)}}),xe("packages/core/src/events/names.js",function(e,G){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return B}});const Q=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),L=new Set(Q);function B(F){return F==="*"||L.has(F)}}),xe("packages/core/src/events/bus.js",function(e,G){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return u}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.uid,F=Q.DEV,X=G("packages/core/src/events/names.js").isKnownEvent,H="*";function V(a,s){!F||X(s)||L(`bus.unknown:${s}`,`${a}('${s}') 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 K=new Set(["api","user","init","ai"]),D=new WeakMap;function v(a){let s=D.get(a);return s||(s=B("h"),D.set(a,s)),s}function O(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(a){if(!a||typeof a!="object")return{};const s={};for(const[n,t]of Object.entries(a))n!=="grid"&&(t==null?s[n]=String(t):Array.isArray(t)?s[n]=`[${t.length}]`:typeof t=="object"?s[n]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?s[n]="[function]":s[n]=String(t).slice(0,60));return s}class u{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(s=null){this.#i=s}attach(s){this.#i=s}get grid(){return this.#i}get destroyed(){return this.#s}on(s,n){if(typeof n!="function")return L(`bus.handler:${s}`,`on('${s}') needs a function; ignored.`),()=>{};V("on",s);let t=this.#e.get(s);return t||(t=[],this.#e.set(s,t)),t.push(n),()=>this.off(s,n)}once(s,n){if(typeof n!="function")return L(`bus.handler:${s}`,`once('${s}') needs a function; ignored.`),()=>{};V("once",s);const t=r=>{this.off(s,n),n(r)};return this.#o.set(n,t),this.on(s,t)}off(s,n){if(n===void 0){this.#e.delete(s);return}const t=this.#e.get(s);if(!t)return;const r=this.#o.get(n),o=r&&t.includes(r)?r:n,f=t.indexOf(o);f>=0&&t.splice(f,1),r&&o===r&&this.#o.delete(n),t.length===0&&this.#e.delete(s)}count(s){const n=this.#e.get(s),t=s===H?null:this.#e.get(H);return(n?n.length:0)+(t?t.length:0)}#a(s,n,t,r,o){this.#n.push({type:s,origin:n,listeners:(r?r.length:0)+(o?o.length:0),payload:y(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(s,n){this.#t=!!s,Number.isFinite(n)&&n>0&&(this.#r=Math.floor(n)),s||(this.#n=[])}eventLog(){return this.#n.map(s=>({...s}))}clearEventLog(){this.#n=[]}counts(){const s={};for(const[n,t]of this.#e)s[n]=t.length;return s}emit(s,n,t){const r=t??(n&&n.origin),o=K.has(r)?r:"api",f={...n||null,type:s,origin:o,grid:this.#i};if(this.#s)return f;const c=this.#e.get(s),i=s===H?void 0:this.#e.get(H);if(this.#t&&this.#a(s,o,n,c,i),!c&&!i)return f;const g=this.#t?O():0;this.#l++;try{c&&this.#u(c.slice(),f,s),i&&this.#u(i.slice(),f,H)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=O()-g)}return f}emitBefore(s,n,t){const r=t??(n&&n.origin),o=K.has(r)?r:"user";let f=!1,c=null;const i=w=>{f=!0,w!=null&&c===null&&(c=String(w))},g={...n||null,type:s,origin:o,grid:this.#i,get defaultPrevented(){return f},get reason(){return c},preventDefault(w){i(w)}};if(this.#s)return!0;const d=this.#e.get(s);this.#t&&this.#a(s,o,n,d,void 0);const h=d?d.slice():[];if(h.length===0)return!0;const l=()=>(f&&c===null&&(c="prevented"),f&&n&&typeof n=="object"&&(n.reason=c),!f),m=[];for(const w of h)try{const k=w(g);k&&typeof k.then=="function"?m.push(k):k===!1&&i("prevented")}catch(k){i("error"),L(`bus.beforeThrow:${s}:${v(w)}`,`a '${s}' before-handler threw; the action was cancelled.`,k)}return m.length===0?l():Promise.allSettled(m).then(w=>{for(const k of w)k.status==="rejected"?(i("error"),L(`bus.beforeReject:${s}`,`a '${s}' before-handler rejected; the action was cancelled.`,k.reason)):k.value===!1&&i("prevented");return l()})}#u(s,n,t){for(let r=0;r<s.length;r++)try{s[r](n)}catch(o){L(`bus.throw:${t}:${v(s[r])}`,`a '${t}' handler threw; other handlers were unaffected.`,o)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),xe("packages/core/src/registry/licence.js",function(e,G){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return F}}),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 O}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return E}});const L=G("packages/core/src/internal/util.js").warnOnce,B="lattice-grid",F=1,W="LG1",X=64,H="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",K=(()=>{const T=new Int16Array(128).fill(-1);for(let P=0;P<V.length;P++)T[V.charCodeAt(P)]=P;return T[43]=62,T[47]=63,T})();function D(T){if(typeof T!="string")return null;let P="";for(let z=0;z<T.length;z++){const M=T.charCodeAt(z);if(M!==61){if(M>127||K[M]<0)return null;P+=T[z]}}const x=P.length;if(x%4===1)return null;const C=new Uint8Array(Math.floor(x*3/4));let A=0,j=0,$=0;for(let z=0;z<x;z++)A=A<<6|K[P.charCodeAt(z)],j+=6,j>=8&&(j-=8,C[$++]=A>>j&255);return $===C.length?C:C.subarray(0,$)}function v(T){let P="",x=0;for(;x+2<T.length;x+=3){const A=T[x]<<16|T[x+1]<<8|T[x+2];P+=V[A>>18&63]+V[A>>12&63]+V[A>>6&63]+V[A&63]}const C=T.length-x;if(C===1){const A=T[x]<<16;P+=V[A>>18&63]+V[A>>12&63]}else if(C===2){const A=T[x]<<16|T[x+1]<<8;P+=V[A>>18&63]+V[A>>12&63]+V[A>>6&63]}return P}function O(T){const P=new Uint8Array(T.length);for(let x=0;x<T.length;x++)P[x]=T.charCodeAt(x)&127;return P}function y(T){if(typeof TextDecoder=="function")return new TextDecoder().decode(T);let P="";for(let x=0;x<T.length;x++)P+=String.fromCharCode(T[x]);return P}function u(T){const P={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof T=="string"?T:""};if(typeof T!="string"||T.length===0)return{...P,reason:"missing"};const x=T.trim(),C=x.split(".");if(C.length!==3)return P;const[A,j,$]=C;if(A!==W)return{...P,reason:"prefix"};const z=D(j),M=D($);if(!z||!M)return P;let R;try{R=JSON.parse(y(z))}catch{return P}return R===null||typeof R!="object"?P:{ok:!0,reason:null,product:typeof R.p=="string"?R.p:null,issuedTo:typeof R.t=="string"?R.t:null,expires:typeof R.e=="string"?R.e:null,features:Array.isArray(R.f)?R.f.slice():[],deployments:Array.isArray(R.d)?R.d.slice():[],version:typeof R.v=="number"?R.v:0,message:O(j),signature:M,raw:x}}function a(T,P){if(!T)return!1;const x=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(T)?`${T}T23:59:59.999Z`:T);return Number.isNaN(x)?!0:P>x}let s=null,n=null,t=null;function r(){const T=globalThis.crypto;return T&&T.subtle?T.subtle:null}async function o(T){if(s&&n===T)return s;const P=r();if(!P)return null;const x=D(T);if(!x)return null;try{const C=await P.importKey("raw",x,{name:"Ed25519"},!1,["verify"]);return s=C,n=T,C}catch{return null}}async function f(){return t!==null||(t=await o(H)!==null),t}async function c(T,P={}){const x=P.warn!==!1,C=P.product||B,A=P.publicKey||H,j=P.now??Date.now(),$=u(T);if(!$.ok){const q=$.reason==="missing"?"missing":"malformed";return x&&L(`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 z={product:$.product||void 0,issuedTo:$.issuedTo||void 0,expires:$.expires||void 0};if($.product!==C)return x&&L("licence.product",`licence key is for '${$.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...z,reason:"product"};if(a($.expires,j))return x&&L("licence.expired",`licence expired on ${$.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...z,reason:"expired"};const M=P.host??g(),R=$.deployments||[];if(R.length&&M&&!i(M)&&!d(M,R))return x&&L("licence.domain",`licence key is not valid for ${M}; it covers ${R.join(", ")}. The grid will render with a watermark.`),{valid:!1,...z,reason:"domain"};const S=await o(A);if(!S){const q=!!$.signature&&$.signature.length===X;return x&&L("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,...z,reason:"unverified"}:{valid:!1,...z,reason:"signature"}}let I=!1;try{I=await r().verify({name:"Ed25519"},S,$.signature,$.message)}catch{I=!1}return I?{valid:!0,...z}:(x&&L("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...z,reason:"signature"})}function i(T){const P=String(T??g()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!P||P==="localhost"||P.endsWith(".localhost")||P==="::1"||P==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(P)}function g(){const T=globalThis.location;return T&&typeof T.hostname=="string"?T.hostname:null}function d(T,P){const x=h(T);return!x||!Array.isArray(P)?!1:P.some(C=>{const A=h(C);if(!A)return!1;if(A==="*")return!0;if(A.startsWith("*.")){const j=A.slice(2);return x===j||x.endsWith(`.${j}`)}return x===A})}function h(T){return String(T??"").trim().toLowerCase().replace(/\.$/,"")}class l{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(P={}){this.#o=P}set(P){this.#e=typeof P=="string"?P.trim():"";const x=u(this.#e);return this.#t=x.ok?{valid:!a(x.expires,Date.now())&&x.product===(this.#o.product||B),product:x.product||void 0,issuedTo:x.issuedTo||void 0,expires:x.expires||void 0,reason:"pending"}:{valid:!1,reason:x.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const P=this.#e;return this.#n=c(P,this.#o).then(x=>{if(this.#e===P){this.#t=x;for(const C of this.#i)C(x)}return x}),this.#n}onSettled(P){return this.#i.add(P),()=>this.#i.delete(P)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!i(this.#r)}setHost(P){this.#r=P}state(){return this.#t.valid?"licensed":i(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const m=new l;function w(T){return m.set(T)}function k(){return m.info()}function p(){return m.watermark()}function b(){return m.state()}function E(){return m}}),xe("packages/core/src/registry/registry.js",function(e,G){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.isFunction,F=Q.DEV,W=G("packages/core/src/registry/licence.js"),X=W.LicenceHolder,H=W.sharedLicence,V=["renderer","editor","filter","dataType","totalFn","pipe","component"],K=["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(o={}){for(const f of V)this.#t.set(f,new Map);this.#o=o.holder||H(),this.#s=o.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),o.licence&&this.setLicence(o.licence)}registerModules(o,f={}){f.licence&&this.setLicence(f.licence),f.grid!==void 0&&(this.#s=f.grid);const c=Array.isArray(o)?o:[o],i=[];for(const g of c){if(!g||typeof g!="object"||typeof g.name!="string"||!g.name){L("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(g.name)){F&&this.#c(this.#e.get(g.name),g);continue}if(!B(g.install)){L(`registry.module.install:${g.name}`,`module '${g.name}' has no install() and was ignored.`);continue}const d={registry:this,grid:this.#s};try{g.install(d)}catch(h){L(`registry.module.throw:${g.name}`,`module '${g.name}' threw during install; it was not registered.`,h);continue}this.#e.set(g.name,g);for(const h of v(g))this.#n.add(h);i.push(g.name),this.#d({reason:"module",name:g.name,capabilities:this.capabilities(),regions:u(g)})}return i}unregisterModule(o){const f=this.#e.get(o);if(!f)return!1;if(B(f.uninstall))try{f.uninstall({registry:this,grid:this.#s})}catch(c){L(`registry.module.uninstall:${o}`,`module '${o}' threw during uninstall.`,c)}return this.#e.delete(o),this.#u(),this.#d({reason:"unmodule",name:o,capabilities:this.capabilities(),regions:u(f)}),!0}modules(){return[...this.#e.values()]}has(o){return this.#e.has(o)}#u(){this.#n.clear();for(const o of this.#e.values())for(const f of v(o))this.#n.add(f)}#c(o,f){!o||o===f||O(o,f)||L(`registry.module.reconfigure:${f.name}`,`module '${f.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(o){return this.#n.has(o)}onChange(o){return B(o)?(this.#r.add(o),this.#a.set(o,this.#s),()=>{this.#r.delete(o),this.#a.delete(o)}):()=>{}}#d(o){for(const f of[...this.#r])try{f(o)}catch(c){L("registry.onChange.throw","a registry change handler threw.",c)}}register(o,f,c){const i=this.#t.get(o);if(!i){L(`registry.kind:${o}`,`unknown registry kind '${o}'; expected one of ${V.join(", ")}.`);return}if(!f||typeof f!="string"){L(`registry.name:${o}`,`register('${o}', ...) needs a name.`);return}i.has(f)&&i.get(f)!==c&&L(`registry.replace:${o}:${f}`,`'${f}' was already registered as a ${o} and has been replaced.`),i.set(f,c),this.#d({reason:"register",name:f,kind:o,capabilities:this.capabilities(),regions:a(o)})}registerAll(o,f){if(f)for(const c of Object.keys(f))this.register(o,c,f[c])}get(o,f){const c=this.#t.get(o);return c?c.get(f):void 0}names(o){const f=this.#t.get(o);return f?[...f.keys()]:[]}#f(o,f){const c=this.#t.get(o).get(f);return c!==void 0?c:this.#t.get("component").get(f)}renderer(o){return this.#f("renderer",o)}editor(o){return this.#f("editor",o)}filter(o){return this.#f("filter",o)}dataType(o){return this.get("dataType",o)}totalFn(o){return this.get("totalFn",o)}pipe(o){return this.get("pipe",o)}setLicence(o){return this.#o.set(o)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(o){o!=null&&(this.#l.add(o),this.#s=o)}detach(o){if(o!=null){this.#l.delete(o);for(const[f,c]of[...this.#a])c===o&&(this.#r.delete(f),this.#a.delete(f));if(this.#s===o){const f=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=f}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(o){if(o!=null){this.detach(o);return}for(const f of[...this.#e.keys()])this.unregisterModule(f);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function v(r){const o=r.capabilities,f=Array.isArray(o)?o.filter(c=>typeof c=="string"):[];return[r.name,...f]}function O(r,o){return r.install!==o.install||r.uninstall!==o.uninstall||(r.version||"")!==(o.version||"")?!1:y(v(r),v(o))&&y(u(r),u(o))}function y(r,o){const f=new Set(r),c=new Set(o);if(f.size!==c.size)return!1;for(const i of f)if(!c.has(i))return!1;return!0}function u(r){const o=r.regions;return!Array.isArray(o)||o.length===0?["all"]:o.filter(f=>K.includes(f))}function a(r){switch(r){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const s=new D;function n(){return s}function t(r,o={}){return s.registerModules(r,o)}}),xe("packages/core/src/format/number.js",function(e,G){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const L=G("packages/core/src/internal/util.js").isNil;function B(F,W){const X=F||{},H=X.locale||W||void 0,V=X.style||"decimal",K=typeof X.scale=="number"?X.scale:1,D=X.nullDisplay??"",v=X.zeroDisplay,O=X.prefix||"",y=X.suffix||"",u=X.negative||"minus",a=X.signed===!0,s={style:V,notation:X.notation||"standard"};V==="currency"&&(s.currency=X.currency||"USD",X.currencyDisplay&&(s.currencyDisplay=X.currencyDisplay)),typeof X.decimals=="number"?(s.minimumFractionDigits=X.decimals,s.maximumFractionDigits=X.decimals):(typeof X.minDecimals=="number"&&(s.minimumFractionDigits=X.minDecimals),typeof X.maxDecimals=="number"&&(s.maximumFractionDigits=X.maxDecimals),s.minimumFractionDigits>(s.maximumFractionDigits??20)&&(s.maximumFractionDigits=s.minimumFractionDigits)),X.thousandsSeparator===!1&&(s.useGrouping=!1),s.notation==="compact"&&(s.compactDisplay=X.compactDisplay||"short");const n=new Intl.NumberFormat(H,s),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,r=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let o=",",f=".";if(t||r)for(const l of n.formatToParts(12345.6))l.type==="group"?o=l.value:l.type==="decimal"&&(f=l.value);const c=l=>{let m=l;return t&&(m=m.split(o).join("")),r&&(m=m.split(f).join("")),t&&(m=m.split("").join(t)),r&&(m=m.split("").join(r)),m},i=!!(t||r),g=O!==""&&V==="currency",d=l=>{let m;if(g){const w=n.formatToParts(l);let k=!1;m="";for(const p of w)m+=p.value,!k&&p.type==="currency"&&(m+=O,k=!0);k||(m=O+m)}else m=O+n.format(l);return i&&(m=c(m)),m+y},h=l=>{if(L(l)||l==="")return D;const m=typeof l=="number"?l:Number(l);if(Number.isNaN(m))return D;const w=K===1?m:m*K;return w===0&&v!==void 0?v:w<0?u==="parentheses"?`(${d(-w)})`:u==="suffix"?`${d(-w)}-`:d(w):a&&w>0?`+${d(w)}`:d(w)};return h.negativeClass=X.negativeClass||null,h.spec=X,h}}),xe("packages/core/src/format/date.js",function(e,G){"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 O}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return n}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.warnOnce,F=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(t){const r=[];let o=0,f="";const c=()=>{f&&(r.push({token:null,text:f}),f="")};for(;o<t.length;){const i=t[o];if(i==="'"){if(t[o+1]==="'"){f+="'",o+=2;continue}const d=t.indexOf("'",o+1);if(d===-1){f+=t.slice(o+1),o=t.length;continue}f+=t.slice(o+1,d),o=d+1;continue}const g=F.find(d=>t.startsWith(d,o));if(g){c(),r.push({token:g,text:g}),o+=g.length;continue}/[A-Za-z]/.test(i)&&B(`date.pattern.token:${i}`,`the date pattern "${t}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${F.join(" ")}.`),f+=i,o+=1}return c(),r}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function H(t){if(L(t)||t==="")return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t=="number")return Number.isNaN(t)?null:new Date(t);if(typeof t=="string"){const r=X.exec(t.trim());if(r){const[,f,c,i,g="0",d="0",h="0"]=r;return new Date(+f,+c-1,+i,+g,+d,+h)}const o=new Date(t);return Number.isNaN(o.getTime())?null:o}return null}function V(t,r){return String(t).padStart(r,"0")}function K(t){if(!t)return f=>({year:f.getFullYear(),month:f.getMonth()+1,day:f.getDate(),hour:f.getHours(),minute:f.getMinutes(),second:f.getSeconds(),ms:f.getMilliseconds(),weekday:f.getDay()});const r=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),o={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return f=>{const c={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:f.getMilliseconds(),weekday:0};for(const i of r.formatToParts(f))switch(i.type){case"year":c.year=Number(i.value);break;case"month":c.month=Number(i.value);break;case"day":c.day=Number(i.value);break;case"hour":c.hour=Number(i.value)%24;break;case"minute":c.minute=Number(i.value);break;case"second":c.second=Number(i.value);break;case"weekday":c.weekday=o[i.value]??0;break;default:break}return c}}function D(t,r,o){const f=W(t),c=K(o),i=new Set(f.filter(m=>m.token).map(m=>m.token)),g=i.has("MMM")?new Intl.DateTimeFormat(r,{month:"short",timeZone:o}):null,d=i.has("MMMM")?new Intl.DateTimeFormat(r,{month:"long",timeZone:o}):null,h=i.has("EEE")?new Intl.DateTimeFormat(r,{weekday:"short",timeZone:o}):null,l=i.has("EEEE")?new Intl.DateTimeFormat(r,{weekday:"long",timeZone:o}):null;return m=>{const w=c(m);let k="";for(const p of f){if(!p.token){k+=p.text;continue}switch(p.token){case"yyyy":k+=V(w.year,4);break;case"yy":k+=V(w.year%100,2);break;case"MMMM":k+=d.format(m);break;case"MMM":k+=g.format(m);break;case"MM":k+=V(w.month,2);break;case"M":k+=String(w.month);break;case"dd":k+=V(w.day,2);break;case"d":k+=String(w.day);break;case"EEEE":k+=l.format(m);break;case"EEE":k+=h.format(m);break;case"HH":k+=V(w.hour,2);break;case"H":k+=String(w.hour);break;case"hh":k+=V(w.hour%12===0?12:w.hour%12,2);break;case"h":k+=String(w.hour%12===0?12:w.hour%12);break;case"mm":k+=V(w.minute,2);break;case"m":k+=String(w.minute);break;case"ss":k+=V(w.second,2);break;case"s":k+=String(w.second);break;case"SSS":k+=V(w.ms,3);break;case"a":k+=w.hour<12?"AM":"PM";break;default:k+=p.text;break}}return k}}const v=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function O(t,r){const o=t||{},f=o.locale||r||void 0,c=o.nullDisplay??"",i=o.timeZone;let g;if(o.pattern)g=D(o.pattern,f,i);else if(o.dateStyle||o.timeStyle){const w={timeZone:i};o.dateStyle&&(w.dateStyle=o.dateStyle),o.timeStyle&&(w.timeStyle=o.timeStyle);const k=new Intl.DateTimeFormat(f,w);g=p=>k.format(p)}else{const w=new Intl.DateTimeFormat(f,{dateStyle:"medium",timeZone:i});g=k=>w.format(k)}const d=o.relative?new Intl.RelativeTimeFormat(f,{numeric:"auto"}):null,l=(typeof o.relative=="object"&&o.relative?o.relative.threshold??7:7)*24*36e5,m=(w,k)=>{const p=H(w);if(!p)return c;if(d){const b=k&&typeof k.now=="number"?k.now:Date.now(),E=p.getTime()-b;if(Math.abs(E)<l){for(const[T,P]of v)if(Math.abs(E)>=P||T==="second")return d.format(Math.round(E/P),T)}}return g(p)};return m.spec=o,m}function y(t){if(L(t)||t==="")return null;if(typeof t=="string"){const f=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(f)return f[1];const c=H(t);return c?y(c):null}const r=H(t);if(!r)return null;const o=f=>String(f).padStart(2,"0");return`${r.getFullYear()}-${o(r.getMonth()+1)}-${o(r.getDate())}`}function u(t,r){if(L(t)||t==="")return null;if(typeof t=="string"){const f=t.trim();if(a.test(f)){const g=H(f);return g?s(g,r):null}const c=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(f);if(c){const[,g,d,h,l]=c;return`${g}T${d}:${h}${l&&l!=="00"?`:${l}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(f))return`${f}T00:00`;const i=H(f);return i?u(i):null}const o=H(t);return o?s(o,r):null}const a=/(?:Z|[+-]\d{2}:?\d{2})$/i;function s(t,r){const o=g=>String(g).padStart(2,"0");if(r)try{const g=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((l,m)=>(m.type!=="literal"&&(l[m.type]=m.value),l),{}),d=g.hour==="24"?"00":g.hour,h=Number(g.second);return`${g.year}-${g.month}-${g.day}T${d}:${g.minute}`+(h?`:${g.second}`:"")}catch{}const f=`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`,c=t.getSeconds(),i=`${o(t.getHours())}:${o(t.getMinutes())}${c?`:${o(c)}`:""}`;return`${f}T${i}`}function n(t,r){const o=L(t)||t===""?null:String(t),f=L(r)||r===""?null:String(r);return o===null?f===null?0:1:f===null||o<f?-1:o>f?1:0}}),xe("packages/core/src/format/boolean.js",function(e,G){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},F={true:"◉",false:"◯",null:""};function W(H){if(L(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const V=String(H).trim().toLowerCase();return V==="true"||V==="yes"||V==="y"||V==="1"?!0:V==="false"||V==="no"||V==="n"||V==="0"?!1:null}function X(H,V){const K=H||{},D=K.display||"text",v=K.trueLabel??"Yes",O=K.falseLabel??"No",y=K.nullLabel??"";let u=v,a=O;const s=y;D==="checkbox"?(u=B.true,a=B.false):D==="switch"?(u=F.true,a=F.false):D==="icon"&&(u=K.trueIcon??v,a=K.falseIcon??O);const n=t=>{const r=W(t);return r===null?s:r?u:a};return n.display=D,n.labels={true:v,false:O,null:y},n.locale=V,n.spec=K,n}}),xe("packages/core/src/format/text.js",function(e,G){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return F}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.titleCase;function F(W,X){const H=W||{},V=H.locale||X||void 0,K=H.nullDisplay??"",D=H.emptyDisplay??"",v=H.transform||"none",O=typeof H.truncate=="number"?{chars:H.truncate}:H.truncate||null,y=O?O.chars:0,u=O?O.ellipsis??"…":"",a=n=>{switch(v){case"upper":return V?n.toLocaleUpperCase(V):n.toUpperCase();case"lower":return V?n.toLocaleLowerCase(V):n.toLowerCase();case"title":return B(n);default:return n}},s=n=>{if(L(n))return K;let t=typeof n=="string"?n:String(n);return t===""?D:(v!=="none"&&(t=a(t)),y>0&&t.length>y&&(t=t.slice(0,y)+u),t)};return s.spec=H,s}}),xe("packages/core/src/format/mask.js",function(e,G){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return X}});const Q=new Set(["0","#","?",",","."]),L="\0";function B(V){const K=[];let D="",v=!1;for(let O=0;O<V.length;O++){const y=V[O];if(y==="\\"){D+=y+(V[O+1]??""),O+=1;continue}if(y==='"'){v=!v,D+=y;continue}if(y===";"&&!v){K.push(D),D="";continue}D+=y}return K.push(D),K}function F(V){let K="",D="",v="",O=1,y=!1,u=!1;const a=g=>{u?D+=g:K+=g};for(let g=0;g<V.length;g++){const d=V[g];if(d==="\\"){a(V[g+1]??""),g+=1;continue}if(d==='"'){const h=V.indexOf('"',g+1);a(h===-1?V.slice(g+1):V.slice(g+1,h)),g=h===-1?V.length:h;continue}if(d==="%"){O*=100,a("%");continue}if(d==="@"){y=!0,a("\0");continue}if(Q.has(d)){v+=d,u=!0;continue}a(d)}let s=-1;for(let g=v.length-1;g>=0;g--){const d=v[g];if(d==="0"||d==="#"||d==="?"){s=g;break}}let n=!1,t="";for(let g=0;g<v.length;g++){const d=v[g];if(d===","){g>s?O/=1e3:n=!0;continue}t+=d}const r=t.indexOf("."),o=r===-1?t:t.slice(0,r),f=r===-1?"":t.slice(r+1);let c=0;for(const g of o)g==="0"&&(c+=1);let i=0;for(const g of f)g==="0"&&(i+=1);return{prefix:K,suffix:D,minInt:c,minDec:i,maxDec:f.length,grouping:n,scale:O,hasNumber:s!==-1,isText:y}}function W(V,K){const D=new Intl.NumberFormat(K,{minimumIntegerDigits:Math.max(V.minInt,1),minimumFractionDigits:V.minDec,maximumFractionDigits:Math.max(V.maxDec,V.minDec),useGrouping:V.grouping}),{prefix:v,suffix:O,scale:y,hasNumber:u}=V;return a=>{if(!u)return v+O;const s=y===1?a:a*y;return v+D.format(s)+O}}function X(V,K){const v=B(String(V)).map(F),O=v.map(t=>W(t,K)),y=0,u=v.length>1?1:-1,a=v.length>2?2:-1,s=v.length>3?3:-1,n=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const r=Number(t);if(Number.isNaN(r))return s===-1?String(t):(v[s].prefix+v[s].suffix).split("\0").join(String(t));t=r}return t===0&&a!==-1?O[a](0):t<0&&u!==-1?O[u](-t):O[y](t)};return n.spec={mask:V},{format:n,ooxml:H(String(V))}}function H(V){return V.trim()}}),xe("packages/core/src/format/shorthand.js",function(e,G){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const Q=["currency","number","percent","date","boolean","text","relative"],L=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function F(V){return typeof V!="string"||V===""||X(V)?!1:L.test(V)}function W(V){return typeof V!="string"||V===""||X(V)?!1:B.test(V)}function X(V){const K=V.indexOf(":"),D=K===-1?V:V.slice(0,K);return Q.includes(D)?D:null}function H(V){const K=X(V);if(!K)return null;const D=V.indexOf(":"),v=D===-1?"":V.slice(D+1),O=v===""?[]:v.split(":");switch(K){case"currency":{const y={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(y.decimals=Number(O[1])),y}case"number":{const y={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(y.decimals=Number(O[0])),y}case"percent":{const y={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(y.decimals=Number(O[0])),y}case"date":return{type:"date",pattern:v||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const y=v.split("/"),u={type:"boolean",display:"text"};return y[0]!==void 0&&y[0]!==""&&(u.trueLabel=y[0]),y[1]!==void 0&&y[1]!==""&&(u.falseLabel=y[1]),y[2]!==void 0&&(u.nullLabel=y[2]),u}case"text":{const y={type:"text"};return O[0]&&(y.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(y.truncate=Number(O[1])),y}default:return null}}}),xe("packages/core/src/format/index.js",function(e,G){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return k}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.isObject,F=Q.warnOnce,W=G("packages/core/src/format/number.js"),X=W.compileNumber,H=G("packages/core/src/format/date.js"),V=H.compileDate,K=H.scanPattern,D=G("packages/core/src/format/boolean.js"),v=D.compileBoolean,O=G("packages/core/src/format/text.js"),y=O.compileText,u=G("packages/core/src/format/mask.js"),a=u.compileMask,s=G("packages/core/src/format/shorthand.js"),n=s.parseShorthand,t=s.looksLikeMask,r=s.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 O.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return u.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return u.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return u.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return s.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return s.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return s.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),f=new Set(["type","locale"]),c={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},i=new Set(["number","date","boolean","text"]);function g(T,P){const x=T.type;if(x===void 0||i.has(x)||!o.has(String(x)))return;const C=P?`"${P}"`:"with no id";F(`format:unknown-style-key:${P||""}:${x}`,`column ${C} has format: { type: "${x}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${x}" instead?`)}function d(T,P,x){const C=c[P],A=x?`"${x}"`:"with no id";for(const j of T){if(f.has(j)||C.has(j))continue;const $=Object.keys(c).find(z=>z!==P&&c[z].has(j));$?F(`format:inapplicable:${x||""}:${j}`,`column ${A} has format key "${j}", which applies to a ${$} column, not the ${P} column it was applied to; it is ignored.`):F(`format:unknown:${x||""}:${j}`,`column ${A} has an unrecognised format key "${j}" for its ${P} format; it is ignored.`)}}function h(T){if(T.type==="number"||T.type==="date"||T.type==="boolean"||T.type==="text")return!0;const P=o.has(String(T.style));return!!(T.pattern||T.dateStyle||T.timeStyle||T.relative||T.timeZone||T.trueLabel||T.falseLabel||T.display||T.trueIcon||T.falseIcon||T.transform||T.truncate||T.emptyDisplay||P||T.currency||T.decimals!==void 0||T.minDecimals!==void 0||T.maxDecimals!==void 0||T.notation||T.negative||T.scale!==void 0||T.prefix||T.suffix||T.zeroDisplay!==void 0)}function l(T,P){if(T.type==="number"||T.type==="date"||T.type==="boolean"||T.type==="text")return T.type;if(T.pattern||T.dateStyle||T.timeStyle||T.relative||T.timeZone)return"date";if(T.trueLabel||T.falseLabel||T.display||T.trueIcon||T.falseIcon)return"boolean";if(T.transform||T.truncate||T.emptyDisplay)return"text";if(T.style||T.currency||T.decimals!==void 0||T.minDecimals!==void 0||T.maxDecimals!==void 0||T.notation||T.negative||T.scale!==void 0||T.prefix||T.suffix||T.zeroDisplay!==void 0)return"number";const x=P&&P.base;return x==="number"?"number":x==="date"||x==="dateString"?"date":x==="boolean"?"boolean":"text"}function m(T,P=null,x=void 0,C=void 0,A=void 0){if(T==null||T==="")return null;const j=B(T)?Object.keys(T):null;if(typeof T=="function"){const M=(R,S)=>String(T({...S||{},value:R,locale:x})??"");return M.ooxml=P&&P.excel||"General",M}if(typeof T=="string"){if(t(T)){const{format:R,ooxml:S}=a(T,x);return R.ooxml=S,R}const M=n(T)||(r(T)?{type:"date",pattern:T}:null);return M?m(M,P,x,C,A):(F(`format:${T}`,`unrecognised format string "${T}"; the value will be stringified`),null)}if(!B(T))return F("format:shape","format must be a spec object or a string; ignoring",T),null;if(P&&L(P.format)&&!h(T)||P&&L(P.format)&&Array.isArray(P.formatPatterns)&&T.type===void 0)return null;const $=l(T,P);$==="date"&&C&&T.timeZone===void 0&&(T={...T,timeZone:C}),g(T,A),d(j||Object.keys(T),$,A);let z;switch($){case"number":z=X(T,x);break;case"date":z=V(T,x);break;case"boolean":z=v(T,x);break;default:z=y(T,x);break}return z.ooxml=k(T,$,x,P),z.kind=$,z}const w={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 k(T,P,x=void 0,C=null){if(P==="date"){if(T.pattern){let M="";for(const R of K(T.pattern))M+=R.token?w[R.token]??R.text:R.text;return M}return C&&C.excel||"yyyy-mm-dd"}if(P==="boolean")return"General";if(P==="text")return"@";if(T.notation==="compact"||T.notation==="scientific")return"General";const A=typeof T.decimals=="number"?T.decimals:typeof T.minDecimals=="number"?T.minDecimals:T.style==="currency"?2:0;let $=`${T.thousandsSeparator===!1?"":"#,#"}#0${A>0?`.${"0".repeat(A)}`:""}`,z="";return T.style==="currency"&&(z+=p(E(T.currency||"USD",x))),T.prefix&&(z+=p(T.prefix)),$=z+$,T.style==="percent"&&($=`${$}%`),T.suffix&&($+=p(T.suffix)),T.negative==="parentheses"?`${$};(${$})`:T.negative==="suffix"?`${$};${$}-`:$}function p(T){return`"${String(T).split('"').join("")}"`}const b=new Map;function E(T,P){const x=`${T}|${P||""}`;let C=b.get(x);if(C!==void 0)return C;C=T;try{const j=new Intl.NumberFormat(P,{style:"currency",currency:T}).formatToParts(0).find($=>$.type==="currency");j&&(C=j.value)}catch{}return b.set(x,C),C}}),xe("packages/core/src/columns/types/temporal.js",function(e,G){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Qe}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.isFunction,F=G("packages/core/src/format/date.js"),W=F.toDate,X=F.compilePattern,H=F.compileDate,V=F.toIsoDateTime,K=F.compareIso,D=864e5,v=Object.freeze({}),O=1e3,y=60*O,u=60*y,a=24*u,s=7*a,n=new WeakMap;function t(Te,_e){const Ke=Te&&Te.locale||"",tt=Te&&Te.column;if(!tt)return Ke?{locale:Ke}:v;const it=n.get(tt);if(it&&it.locale===Ke)return it.bag;const ht=tt.typeOptions||tt[_e]||(r(tt.format)?tt.format:null),yt={...ht||v,locale:ht&&ht.locale||Ke||void 0};return n.set(tt,{locale:Ke,bag:yt}),yt}function r(Te){return Te!==null&&typeof Te=="object"&&!Array.isArray(Te)&&!(Te instanceof Date)}function o(Te,_e){const Ke=Te===null||Number.isNaN(Te)?null:Te,tt=_e===null||Number.isNaN(_e)?null:_e;return Ke===null?tt===null?0:1:tt===null||Ke<tt?-1:Ke>tt?1:0}const f=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,c=/^(\d{3,6})$/;function i(Te,_e,Ke,tt){return!(Te>=0&&Te<=23)||!(_e>=0&&_e<=59)||!(Ke>=0&&Ke<=59)||!(tt>=0&&tt<=999)?null:Te*u+_e*y+Ke*O+tt}function g(Te){if(L(Te))return null;const _e=String(Te).trim();if(_e==="")return null;const Ke=c.exec(_e);if(Ke){const Ct=Ke[1];if(Ct.length===5)return null;const Tt=Ct.length===3?1:2;return i(Number(Ct.slice(0,Tt)),Number(Ct.slice(Tt,Tt+2)),Number(Ct.slice(Tt+2,Tt+4)||0),0)}const tt=f.exec(_e);if(!tt)return null;let it=Number(tt[1]);const ht=Number(tt[2]||0),yt=Number(tt[3]||0),St=tt[4]?Number(tt[4].padEnd(3,"0")):0,At=tt[5]?tt[5][0].toLowerCase():null;if(At){if(it<1||it>12)return null;it=it%12,At==="p"&&(it+=12)}return i(it,ht,yt,St)}function d(Te){return L(Te)||Te===""?null:typeof Te=="number"?Number.isFinite(Te)?(Te%a+a)%a:null:Te instanceof Date?Number.isNaN(Te.getTime())?null:Te.getHours()*u+Te.getMinutes()*y+Te.getSeconds()*O+Te.getMilliseconds():g(Te)}const h=new Map;function l(Te){const _e=Te.pattern||"",Ke=Te.timeStyle||(Te.seconds?"medium":"short"),tt=`${Te.locale||""}|${_e}|${Ke}`;let it=h.get(tt);if(it)return it;if(_e)it=X(_e,Te.locale||void 0,"UTC");else{const ht=new Intl.DateTimeFormat(Te.locale||void 0,{timeStyle:Ke,timeZone:"UTC"});it=yt=>ht.format(yt)}return h.set(tt,it),it}function m(Te,_e){const Ke=_e||v;if(Te==null||typeof Te!="number"||!Number.isFinite(Te))return Ke.nullDisplay??"";const tt=(Te%a+a)%a;return l(Ke)(new Date(tt))}function w(Te){return Te instanceof Date?!Number.isNaN(Te.getTime()):typeof Te=="number"?Number.isFinite(Te)&&Te>=0&&Te<a:typeof Te!="string"||!Te.includes(":")?!1:g(Te)!==null}function k(Te){const _e=d(Te);return _e==null?"":m(_e,{pattern:_e%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const p=new Map;function b(Te){const _e=Te||"";let Ke=p.get(_e);return Ke||(Ke=new Intl.DateTimeFormat("en-GB",{timeZone:Te||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),p.set(_e,Ke)),Ke}function E(Te,_e){const Ke={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const tt of b(_e).formatToParts(new Date(Te)))tt.type==="year"?Ke.year=Number(tt.value):tt.type==="month"?Ke.month=Number(tt.value):tt.type==="day"?Ke.day=Number(tt.value):tt.type==="hour"?Ke.hour=Number(tt.value)%24:tt.type==="minute"?Ke.minute=Number(tt.value):tt.type==="second"&&(Ke.second=Number(tt.value));return Ke}function T(Te,_e){const Ke=E(Te,_e);return Date.UTC(Ke.year,Ke.month-1,Ke.day,Ke.hour,Ke.minute,Ke.second,0)-Math.floor(Te/1e3)*1e3}function P(Te,_e){const Ke=Te.hour||0,tt=Te.minute||0,it=Te.second||0,ht=Te.ms||0;if(!_e)return new Date(Te.year,Te.month-1,Te.day,Ke,tt,it,ht).getTime();const yt=Date.UTC(Te.year,Te.month-1,Te.day,Ke,tt,it,ht);let St=yt-T(yt,_e);return St=yt-T(St,_e),St}const x=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function A(Te,_e){if(L(Te))return null;const Ke=String(Te).trim();if(Ke==="")return null;const tt=_e&&_e.timeZone||void 0;if(!x.test(Ke)){const it=C.exec(Ke);if(it){const ht=(it[4]||"").trim(),yt=ht===""?0:g(ht);if(yt===null)return null;const St=P({year:Number(it[1]),month:Number(it[2]),day:Number(it[3]),hour:Math.floor(yt/u),minute:Math.floor(yt/y)%60,second:Math.floor(yt/O)%60,ms:yt%O},tt);return Number.isNaN(St)?null:new Date(St)}}return W(Ke)}function j(Te){if(typeof Te=="number")return Number.isFinite(Te)?Te:null;const _e=W(Te);return _e?_e.getTime():null}const $=new Map;function z(Te){const _e=[Te.locale||"",Te.pattern||"",Te.dateStyle||"",Te.timeStyle||"",Te.timeZone||"",Te.seconds?"1":""].join("|");let Ke=$.get(_e);if(Ke)return Ke;const tt=Te.pattern?{type:"date",pattern:Te.pattern,timeZone:Te.timeZone}:{type:"date",dateStyle:Te.dateStyle||"medium",timeStyle:Te.timeStyle||(Te.seconds?"medium":"short"),timeZone:Te.timeZone};return Ke=H(tt,Te.locale||void 0),$.set(_e,Ke),Ke}function M(Te,_e){const Ke=_e||v,tt=j(Te);return tt==null?Ke.nullDisplay??"":z(Ke)(tt)}function R(Te){return Te instanceof Date?!Number.isNaN(Te.getTime()):typeof Te!="string"||!C.test(Te.trim())?!1:A(Te)!==null}const S=Object.freeze([{key:"w",ms:s,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:a,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:y,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:O,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"]}]),I=new Map;for(const Te of S)for(const _e of Te.names)I.set(_e,Te);const q=Object.freeze(S.filter(Te=>Te.key!=="w")),Z=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,_=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ee(Te){const _e=Te&&Te.defaultUnit?I.get(String(Te.defaultUnit).toLowerCase()):null;return _e?_e.ms:y}function te(Te){return(Te&&Te.defaultUnit?I.get(String(Te.defaultUnit).toLowerCase()):null)||I.get("m")}function ne(Te,_e){if(L(Te))return null;let Ke=String(Te).trim().toLowerCase();if(Ke==="")return null;let tt=1;if(Ke[0]==="-"?(tt=-1,Ke=Ke.slice(1).trim()):Ke[0]==="+"&&(Ke=Ke.slice(1).trim()),Ke==="")return null;const it=J.exec(Ke);if(it){const At=it[3]!==void 0,Ct=Number(it[1])*u+Number(it[2])*y+(At?Number(it[3])*O:0)+(it[4]?Number(it[4].padEnd(3,"0")):0);return tt*Ct}if(_.test(Ke))return Math.round(tt*Number(Ke)*ee(_e||v));let ht=Ke,yt=0,St=0;for(;ht!=="";){const At=Z.exec(ht);if(!At)return null;const Ct=I.get(At[2]);if(!Ct)return null;yt+=Number(At[1])*Ct.ms,ht=ht.slice(At[0].length),St++}return St===0?null:Math.round(tt*yt)}function ae(Te){return L(Te)||Te===""?null:typeof Te=="number"?Number.isFinite(Te)?Te:null:ne(Te)}const de=new Map;function ie(Te,_e,Ke){const tt=`${Ke||""}|${_e.intl}`;let it=de.get(tt);if(it===void 0){try{it=new Intl.NumberFormat(Ke||void 0,{style:"unit",unit:_e.intl,unitDisplay:"long"})}catch{it=null}de.set(tt,it)}return it?it.format(Te):`${Te} ${Te===1?_e.long[0]:_e.long[1]}`}function oe(Te,_e){return String(Te).padStart(_e,"0")}function ce(Te,_e){const Ke=_e||v;if(Te==null||typeof Te!="number"||!Number.isFinite(Te))return Ke.nullDisplay??"";const tt=Ke.style||"short",it=Te<0;let ht=Math.round(Math.abs(Te));const yt=it?"-":"";if(ht===0&&Ke.zeroDisplay!=null)return Ke.zeroDisplay;if(tt==="clock"){const Tt=Math.floor(ht/u),It=Math.floor(ht/y)%60,zt=Math.floor(ht/O)%60;return`${yt}${oe(Tt,2)}:${oe(It,2)}:${oe(zt,2)}`}if(ht===0){const Tt=te(Ke);return tt==="long"?ie(0,Tt,Ke.locale):`0${Tt.key}`}const St=Ke.weeks===!0?S:q,At=typeof Ke.maxUnits=="number"&&Ke.maxUnits>0?Ke.maxUnits:Ke.maxUnits===void 0?2:1/0,Ct=[];for(const Tt of St){if(Ct.length>=At)break;const It=Math.floor(ht/Tt.ms);It!==0&&(ht-=It*Tt.ms,Ct.push(tt==="long"?ie(It,Tt,Ke.locale):`${It}${Tt.key}`))}return yt+Ct.join(" ")}function fe(Te){if(typeof Te!="string")return!1;const _e=Te.trim();return _e===""||J.test(_e)||!/[a-z]/i.test(_e)?!1:ne(_e)!==null}const ke=Date.UTC(1899,11,30),Re=new Map;function Ee(Te,_e){const Ke=Te||"";let tt=Re.get(Ke);tt||(tt=new Intl.DateTimeFormat("en-GB",{timeZone:Te||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Re.set(Ke,tt));const it=typeof _e=="number"?_e:Date.now();for(const ht of tt.formatToParts(new Date(it)))if(ht.type==="timeZoneName")return ht.value;return""}function Fe(Te){if(Te)return Te;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ye(Te,_e){const Ke=Fe(Te),tt=Ee(Te,_e);return tt?`${Ke} (${tt})`:Ke}function he(Te,_e){if(Te&&Te.timeZone)return Te.timeZone;const Ke=_e&&_e.grid;return(Ke&&B(Ke.get)?Ke.get("timeZone"):void 0)||void 0}function Se(Te,_e){const Ke=_e||v,tt=j(Te);if(tt==null)return Ke.nullDisplay??"";const it=z(Ke)(tt);if(!Ke.showOrigin)return it;const ht=Ke.originZone;return ht?ht===(Ke.timeZone||Fe(Ke.timeZone))?it:`${it} (${ye(ht,tt)})`:`${it} (no origin recorded)`}function Ce(Te,_e,Ke,tt){if(_e==="instant"||!_e)return Te;const it=E(Te,Ke);if(_e==="month")return P({year:it.year,month:it.month,day:1},Ke);if(_e==="week"){const ht=tt>=1&&tt<=7?tt:1,St=((new Date(Date.UTC(it.year,it.month-1,it.day)).getUTCDay()+6)%7+1-ht+7)%7,At=new Date(Date.UTC(it.year,it.month-1,it.day-St));return P({year:At.getUTCFullYear(),month:At.getUTCMonth()+1,day:At.getUTCDate()},Ke)}return P({year:it.year,month:it.month,day:it.day},Ke)}function Ie(Te,_e){const Ke=Te&&Te.group,tt=Ke&&Ke.granularity||"day";if(tt==="instant")return null;const it=Ke&&Ke.weekStart;return ht=>typeof ht=="number"?Ce(ht,tt,_e,it):ht}const ze={time:{base:"number",storage:"float64",matches:w,format:Te=>m(d(Te.value),t(Te,"time")),parse:Te=>g(Te.text),compare:(Te,_e)=>o(d(Te),d(_e)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Te=>{const _e=d(Te);return _e===null?null:_e/D},toStorage:Te=>d(Te),toClipboard:k,fromClipboard:g},datetime:{base:"dateString",storage:"dictionary",matches:R,format:Te=>M(Te.value,t(Te,"datetime")),parse:Te=>V(A(Te.text,t(Te,"datetime"))??Te.text),compare:K,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Te,_e)=>V(Te,_e&&_e.timeZone),toClipboard:Te=>L(Te)?"":String(Te),fromClipboard:Te=>V(Te)},duration:{base:"number",storage:"float64",matches:fe,format:Te=>ce(ae(Te.value),t(Te,"duration")),parse:Te=>ne(Te.text,t(Te,"duration")),compare:(Te,_e)=>o(ae(Te),ae(_e)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Te=>{const _e=ae(Te);return _e===null?null:_e/D},toStorage:Te=>ae(Te),toClipboard:Te=>ce(ae(Te),{style:"short",maxUnits:-1}),fromClipboard:Te=>ne(Te)},timestamp:{base:"number",storage:"float64",format:Te=>{const _e=t(Te,"timestamp");return Se(Te.value,{..._e,timeZone:he(_e,Te)})},parse:Te=>{const _e=t(Te,"timestamp"),Ke=A(Te.text,{timeZone:he(_e,Te)});return Ke?Ke.getTime():null},compare:(Te,_e)=>o(j(Te),j(_e)),groupProjector:(Te,_e)=>Ie(Te,_e),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Te,_e)=>{const Ke=j(Te);if(Ke==null)return null;const tt=E(Ke,_e&&_e.timeZone||void 0);return(Date.UTC(tt.year,tt.month-1,tt.day,tt.hour,tt.minute,tt.second)-ke)/D},toStorage:Te=>j(Te),toClipboard:Te=>{const _e=j(Te);return _e==null?"":new Date(_e).toISOString()},fromClipboard:Te=>j(Te)}},Ye=["datetime","time","duration"],Qe=ze}),xe("packages/core/src/columns/types/network.js",function(e,G){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.Lru,F=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(j){if(L(j))return null;if(typeof j=="string")return H(j);const $=Number(j);return Number.isFinite($)?$<0?$<-2147483648?null:$>>>0:$>F?null:Math.trunc($)>>>0:null}function H(j){if(L(j))return null;const $=String(j).trim();if($==="")return null;const z=W.exec($);if(!z)return null;let M=0;for(let R=1;R<=4;R++){const S=z[R];if(S.length>1&&S.charCodeAt(0)===48)return null;const I=Number(S);if(I>255)return null;M=M*256+I}return M}function V(j){const $=X(j);return $===null?"":`${$>>>24&255}.${$>>>16&255}.${$>>>8&255}.${$&255}`}function K(j){return typeof j=="string"&&H(j)!==null}function D(j,$){const z=X(j),M=X($);return z===null?M===null?0:1:M===null||z<M?-1:z>M?1:0}const v=64,O=F*v+32,y=/^(?:0|[1-9]\d?)$/;function u(j,$){return j*v+$}function a(j){if(L(j))return null;if(typeof j=="string"){const M=s(j);return M===null?null:a(M)}if(typeof j=="object"){const M=X(j.address),R=Number(j.prefix);return M===null||!Number.isInteger(R)||R<0||R>32?null:{address:M,prefix:R}}const $=Number(j);if(!Number.isInteger($)||$<0||$>O)return null;const z=$%v;return z>32?null:{address:($-z)/v,prefix:z}}function s(j){if(L(j))return null;const $=String(j).trim();if($==="")return null;const z=$.indexOf("/");if(z<0)return null;const M=H($.slice(0,z));if(M===null)return null;const R=$.slice(z+1).trim();if(!y.test(R))return null;const S=Number(R);return S>32?null:u(M,S)}function n(j){const $=a(j);return $?`${V($.address)}/${$.prefix}`:""}function t(j){return typeof j=="string"&&s(j)!==null}function r(j,$){const z=a(j),M=a($);return z?M?z.address!==M.address?z.address<M.address?-1:1:z.prefix-M.prefix:-1:M?1:0}function o(j){return j===0?0:4294967295<<32-j>>>0}function f(j){const $=a(j);return $?($.address&o($.prefix))>>>0:null}function c(j){const $=a(j);return $?($.address&o($.prefix)|~o($.prefix)>>>0)>>>0:null}function i(j){const $=a(j);return $?2**(32-$.prefix):null}function g(j){const $=a(j);return $?$.prefix===32?1:$.prefix===31?2:2**(32-$.prefix)-2:null}function d(j,$){const z=a(j);if(!z)return!1;const M=X($);if(M===null)return!1;const R=o(z.prefix);return(M&R)>>>0===(z.address&R)>>>0}function h(j,$){const z=f(j),M=f($);return z===null||M===null?!1:z<=c($)&&M<=c(j)}const l=/^[0-9a-fA-F]{1,4}$/,m=new B(512);function w(j){if(L(j))return null;let $=String(j).trim();if($==="")return null;const z=$.indexOf("%");if(z>=0&&($=$.slice(0,z)),$==="")return null;if($.indexOf(".")>=0){const Z=$.lastIndexOf(":");if(Z<0)return null;const _=H($.slice(Z+1));if(_===null)return null;$=`${$.slice(0,Z+1)}${(_>>>16&65535).toString(16)}:${(_&65535).toString(16)}`}const M=$.split("::");if(M.length>2)return null;const R=k(M[0]);if(R===null)return null;if(M.length===1)return R.length===8?R:null;const S=k(M[1]);if(S===null)return null;const I=8-R.length-S.length;if(I<1)return null;const q=R.slice();for(let Z=0;Z<I;Z++)q.push(0);for(const Z of S)q.push(Z);return q}function k(j){if(j==="")return[];const $=[];for(const z of j.split(":")){if(!l.test(z))return null;$.push(parseInt(z,16))}return $}function p(j){if(typeof j!="string")return w(j);if(m.has(j))return m.get(j);const $=w(j);return m.set(j,$),$}function b(j){if(j[0]===0&&j[1]===0&&j[2]===0&&j[3]===0&&j[4]===0&&j[5]===65535)return`::ffff:${V((j[6]<<16|j[7])>>>0)}`;let $=-1,z=0,M=-1,R=0;for(let q=0;q<8;q++)j[q]===0?(M<0?(M=q,R=1):R++,R>z&&(z=R,$=M)):(M=-1,R=0);if(z<2)return j.map(q=>q.toString(16)).join(":");const S=j.slice(0,$).map(q=>q.toString(16)).join(":"),I=j.slice($+z).map(q=>q.toString(16)).join(":");return`${S}::${I}`}function E(j){const $=w(j);return $===null?null:b($)}function T(j){return E(j)??""}function P(j){return typeof j=="string"&&j.indexOf(":")>=0&&w(j)!==null}function x(j,$){const z=p(j),M=p($);if(!z)return M?1:0;if(!M)return-1;for(let R=0;R<8;R++)if(z[R]!==M[R])return z[R]<M[R]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:K,parse:j=>H(j.text),compare:D,format:j=>V(j.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:j=>X(j),toClipboard:j=>V(j),fromClipboard:j=>H(j)},cidr:{base:"number",storage:"float64",matches:t,parse:j=>s(j.text),compare:r,format:j=>n(j.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:j=>{const $=a(j);return $===null?null:u($.address,$.prefix)},toClipboard:j=>n(j),fromClipboard:j=>s(j)},ipv6:{base:"text",storage:"dictionary",matches:P,parse:j=>E(j.text),compare:x,format:j=>T(j.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:j=>E(j),toClipboard:j=>T(j),fromClipboard:j=>E(j)}}),A=C}),xe("packages/core/src/i18n/catalogue.js",function(e,G){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return L}});const Q=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.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.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","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.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.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"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.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.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"}),L=Object.freeze(Object.keys(Q))}),xe("packages/core/src/i18n/format.js",function(e,G){"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 O}});const L=G("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,F=new Map,W=new Map;function X(y){const u=y||"";if(F.has(u))return F.get(u);let a=null;try{a=new Intl.PluralRules(y||void 0)}catch{a=null}return F.set(u,a),a}function H(y,u,a="conjunction"){const s=Array.isArray(y)?y.filter(r=>r!=null&&r!==""):[];if(s.length===0)return"";if(s.length===1)return String(s[0]);const n=`${u||""}|${a}`;let t=W.get(n);if(t===void 0){try{t=new Intl.ListFormat(u||void 0,{style:"long",type:a})}catch{t=null}W.set(n,t)}return t?t.format(s.map(String)):s.map(String).join(", ")}function V(y,u){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(y)}function K(y,u,a){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const s=u&&typeof u.count=="number"?u.count:null;if(s===null)return y.other??"";const n=X(a),t=n?n.select(s):s===1?"one":"other";return y[t]??y.other??""}function D(y,u={},a){const s=K(y,u,a);return s?s.replace(B,(n,t)=>Object.prototype.hasOwnProperty.call(u,t)?V(u[t],a):n):""}function v(y,u,a="en-GB"){return typeof y=="string"&&y?y:typeof u=="string"&&u?u:a}function O(y,u){const a=y?y[u]:void 0;return a==null||L(a)?u:a}}),xe("packages/core/src/i18n/index.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return s}});const Q=G("packages/core/src/i18n/catalogue.js"),L=Q.EN_GB,B=Q.MESSAGE_KEYS,F=G("packages/core/src/i18n/format.js"),W=F.formatMessage,X=F.formatList,H=F.lookup,V=F.resolveLocale,K=G("packages/core/src/internal/util.js"),D=K.isFunction,v=K.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Q.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return Q.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return F.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return F.resolveLocale}});const O="en-GB";class y{#e=O;#t=L;constructor(t={}){this.configure(t)}configure(t={}){this.#e=V(t.locale,t.declared,O);const r=t.messages;if(!r||typeof r!="object"){this.#t=L;return}const o=Object.keys(r).filter(f=>!(f in L));o.length&&v(`i18n:unknown:${o[0]}`,`message keys not in the catalogue and so ignored: ${o.slice(0,5).join(", ")}${o.length>5?`, and ${o.length-5} more`:""}`),this.#t={...L,...r}}get locale(){return this.#e}t(t,r){return W(H(this.#t,t),r||{},this.#e)}list(t,r){return X(t,this.#e,r)}number(t,r){const o=Number(t);return Number.isFinite(o)?o.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const u=new y;function a(n){return n instanceof y?n:new y(n||{})}function s(n){const t=n&&typeof n=="object"?n:{},r=B.filter(f=>{const c=t[f];return c==null||c===""||D(c)}),o=Object.keys(t).filter(f=>!(f in L));return{missing:r,unknown:o}}}),xe("packages/core/src/columns/types/structured.js",function(e,G){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return X}}),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 a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.isObject,W=G("packages/core/src/i18n/index.js").defaultMessages,X=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(n,t){const r=t||{},o=r.emptyDisplay??X.emptyDisplay;if(L(n)||n==="")return o;const c=[...typeof r.char=="string"&&r.char!==""?r.char:X.char][0]||X.char,i=r.fixedLength??X.fixedLength,g=Number.isFinite(r.length)&&Number(r.length)>0?Math.floor(Number(r.length)):X.length,d=typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?String(n):null;let h=0;if(d!==null){const l=Number.isFinite(r.lastVisible)?Math.floor(Number(r.lastVisible)):X.lastVisible,m=[...d];if(h=l>0&&l<m.length?l:0,h>0){const w=m.slice(m.length-h).join(""),k=Math.max(1,(i?g:m.length)-h);return c.repeat(k)+w}return c.repeat(i?g:Math.max(1,m.length))}return c.repeat(g)}const V=48;function K(n){try{const t=JSON.stringify(n);return t===void 0?null:t}catch{return null}}function D(n,t){if(L(n))return"";const r=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):V;if(typeof n=="string")return n.length>r?`${n.slice(0,r-1)}…`:n;if(typeof n!="object")return String(n);const o=K(n);if(o!==null&&o.length<=r)return o;if(Array.isArray(n)){const c=n.length;return`[${W.t("count.items",{count:c})}]`}const f=Object.keys(n).length;return`{${W.t("count.keys",{count:f})}}`}function v(n,t){if(n==null)return"null";const r=typeof n;if(r==="number"||r==="boolean"||r==="bigint")return String(n);if(r==="string")return JSON.stringify(n);if(r!=="object")return JSON.stringify(String(n));const o=t||new WeakSet;return o.has(n)?'"[circular]"':(o.add(n),n instanceof Date?JSON.stringify(n.toISOString()):Array.isArray(n)?`[${n.map(i=>v(i,o)).join(",")}]`:`{${Object.keys(n).sort().map(i=>`${JSON.stringify(i)}:${v(n[i],o)}`).join(",")}}`)}function O(n,t){if(L(n))return L(t)?0:1;if(L(t))return-1;const r=v(n),o=v(t);return r<o?-1:r>o?1:0}function y(n){if(L(n))return null;const t=String(n);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function u(n){const t=n&&n.cell&&n.cell.props;return B(t)?t:{}}const a=Object.freeze({json:{base:"object",storage:"object",format:n=>D(n&&n.value,u(n&&n.column)),parse:n=>y(n&&n.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:n=>{if(L(n))return"";if(typeof n=="string")return n;try{const t=JSON.stringify(n,null,2);return t===void 0?String(n):t}catch{return String(n)}},fromClipboard:n=>y(n)},secret:{base:"text",storage:"object",format:n=>H(n&&n.value,u(n&&n.column)),parse:n=>{const t=n&&n.text;return L(t)||String(t)===""?null:String(t)},compare:(n,t)=>{const r=L(n)||n==="",o=L(t)||t==="";return r===o?0:r?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:n=>H(n),fromClipboard:n=>L(n)||String(n)===""?null:String(n)}}),s=a}),xe("packages/core/src/columns/types/unit.js",function(e,G){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),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 O}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.warnOnce;function F(R,S,I,q){return Object.freeze({symbol:R,factor:S,aliases:Object.freeze(I||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(R,S,I,q){return F(R,S,I,q)}const X=Object.freeze({data:Object.freeze([F("B",1,["byte","bytes"]),F("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),F("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),F("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),F("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),F("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),F("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),F("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),F("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),F("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([F("bps",1,["bit","bits","bit/s","b/s"]),F("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),F("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),F("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),F("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([F("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),F("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),F("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),F("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),F("in",.0254,["inch","inches"],{auto:!1}),F("ft",.3048,["foot","feet"],{auto:!1}),F("yd",.9144,["yard","yards"],{auto:!1}),F("m",1,["metre","metres","meter","meters"]),F("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),F("mi",1609.344,["mile","miles"],{auto:!1}),F("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([F("mg",.001,["milligram","milligrams"]),F("g",1,["gram","grams"]),F("oz",28.349523125,["ounce","ounces"],{auto:!1}),F("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),F("kg",1e3,["kilogram","kilograms"]),F("st",6350.29318,["stone"],{auto:!1}),F("t",1e6,["tonne","tonnes","ton"],{auto:!1}),F("ton (US)",907184.74,["ton","shortton"],{auto:!1}),F("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([F("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),F("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),F("ms",.001,["msec","msecs","millisecond","milliseconds"]),F("s",1,["sec","secs","second","seconds"]),F("m",60,["min","mins","minute","minutes"]),F("h",3600,["hr","hrs","hour","hours"]),F("d",86400,["day","days"])]),speed:Object.freeze([F("mm/s",.001,["millimetre/s","millimeter/s"]),F("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),F("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),F("mph",.44704,["mile/h","miles/h"],{auto:!1}),F("kn",1852/3600,["knot","knots"],{auto:!1}),F("m/s",1,["metre/s","meter/s","mps"]),F("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([F("mm/s²",.001,["mm/s2"]),F("ft/s²",.3048,["ft/s2"],{auto:!1}),F("m/s²",1,["m/s2","metre/s2","meter/s2"]),F("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([F("mm²",1e-6,["mm2"]),F("cm²",1e-4,["cm2"]),F("in²",64516e-8,["in2","sqin"],{auto:!1}),F("ft²",.09290304,["ft2","sqft"],{auto:!1}),F("yd²",.83612736,["yd2","sqyd"],{auto:!1}),F("m²",1,["m2","sqm"]),F("ha",1e4,["hectare","hectares"],{auto:!1}),F("ac",4046.8564224,["acre","acres"],{auto:!1}),F("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([F("µL",1e-6,["ul","microlitre","microliter"]),F("mL",.001,["millilitre","milliliter"]),F("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),F("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),F("L",1,["litre","litres","liter","liters"]),F("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),F("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),F("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),F("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([F("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),F("J",1,["joule","joules"]),F("cal",4.184,["calorie","calories"],{auto:!1}),F("kJ",1e3,["kilojoule","kilojoules"]),F("BTU",1055.05585262,["btu"],{auto:!1}),F("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),F("MJ",1e6,["megajoule","megajoules"]),F("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),F("GJ",1e9,["gigajoule","gigajoules"]),F("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([F("mW",.001,["milliwatt","milliwatts"]),F("W",1,["watt","watts"]),F("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),F("kW",1e3,["kilowatt","kilowatts"]),F("hp",745.6998715822702,["horsepower"],{auto:!1}),F("MW",1e6,["megawatt","megawatts"]),F("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([F("mN",.001,["millinewton","millinewtons"]),F("N",1,["newton","newtons"]),F("lbf",4.4482216152605,["poundforce"],{auto:!1}),F("kgf",9.80665,["kilogramforce"],{auto:!1}),F("kN",1e3,["kilonewton","kilonewtons"]),F("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([F("Pa",1,["pascal","pascals"]),F("mbar",100,["millibar"],{auto:!1}),F("inH₂O",249.0889,["inh2o"],{auto:!1}),F("mmHg",133.322387415,["torr"],{auto:!1}),F("kPa",1e3,["kilopascal","kilopascals"]),F("inHg",3386.388640341,["inhg"],{auto:!1}),F("psi",6894.757293168361,["lbf/in2"],{auto:!1}),F("bar",1e5,[],{auto:!1}),F("atm",101325,["atmosphere","atmospheres"],{auto:!1}),F("MPa",1e6,["megapascal","megapascals"]),F("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([F("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),F("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),F("kN·m",1e3,["knm","kn.m"],{auto:!1}),F("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([F("kg/m³",1,["kg/m3"]),F("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),F("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),F("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([F("L/min",1/6e4,["lpm","l/min"],{auto:!1}),F("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),F("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),F("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),F("cfm",.0004719474432,["ft3/min"],{auto:!1}),F("L/s",.001,["lps","l/s"],{auto:!1}),F("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([F("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),F("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),F("mrad",.001,["milliradian","milliradians"],{auto:!1}),F("mil",Math.PI/3200,["nato-mil"],{auto:!1}),F("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),F("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),F("rad",1,["radian","radians"]),F("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([F("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),F("rad/s",1,["radps","radians/s"]),F("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),F("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([F("ppt",1e-12,["partspertrillion"],{auto:!1}),F("ppb",1e-9,["partsperbillion"]),F("ppm",1e-6,["partspermillion"]),F("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),F("‰",.001,["permille","permil"],{auto:!1}),F("%",.01,["pct","percent"]),F("×",1,["x","ratio","times"])]),molarity:Object.freeze([F("pM",1e-12,["picomolar","picomolarity"]),F("nM",1e-9,["nanomolar","nanomolarity"]),F("µM",1e-6,["um-molar","micromolar","micromolarity"]),F("mM",.001,["millimolar","millimolarity"]),F("M",1,["molar","mol/l","mol/L","molarity"]),F("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([F("mg/s",1e-6,["milligrams/s"]),F("g/s",.001,["grams/s"]),F("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),F("kg/s",1,["kilograms/s","kgps"]),F("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),F("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),F("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([F("µPa·s",1e-6,["upas","micropascalsecond"]),F("cP",.001,["centipoise"],{auto:!1}),F("mPa·s",.001,["mpas","millipascalsecond"]),F("P",.1,["poise"],{auto:!1}),F("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([F("cSt",1e-6,["centistokes","centistoke"]),F("mm²/s",1e-6,["mm2/s"],{auto:!1}),F("St",1e-4,["stokes","stoke"],{auto:!1}),F("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([F("mW/(m·K)",.001,["mw/mk"]),F("W/(m·K)",1,["w/mk","wmk"]),F("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),F("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([F("J/(kg·K)",1,["j/kgk","jkgk"]),F("kJ/(kg·K)",1e3,["kj/kgk"]),F("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([F("nSv/h",1e-9,["nsvh"]),F("µSv/h",1e-6,["usv/h","usvh"]),F("mSv/h",.001,["msvh"]),F("Sv/h",1,["svh"]),F("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),H=Symbol("ambiguous"),V=new Map,K=new Map;function D(R,S){const I=String(R||"").trim();if(!I)throw new Error("[lattice] a unit system needs a name");if(X[I]||K.has(I))throw new Error(`[lattice] unit system "${I}" already exists`);const q=[...S||[]];if(!q.length)throw new Error(`[lattice] unit system "${I}" has no units`);if(!q.some(_=>_.factor===1))throw new Error(`[lattice] unit system "${I}" has no base unit (none with factor 1)`);const Z=new Set;for(const _ of q){if(Z.has(_.symbol))throw new Error(`[lattice] unit system "${I}" declares "${_.symbol}" twice`);Z.add(_.symbol)}return K.set(I,Object.freeze(q)),V.delete(I),I}function v(){return[...Object.keys(X),...K.keys()]}function O(R){const S=y(R);return S?S.units:[]}function y(R){const S=String(R||""),I=V.get(S);if(I!==void 0)return I;const q=X[S]||K.get(S);if(!q)return V.set(S,null),null;const Z=Object.freeze([...q].sort((ne,ae)=>ne.factor-ae.factor)),_=new Map,J=new Map,ee=(ne,ae)=>{const de=_.get(ne);de===void 0?_.set(ne,ae):de!==ae&&_.set(ne,H)};for(const ne of Z){ee(ne.symbol.toLowerCase(),ne);for(const ae of ne.aliases)ee(ae.toLowerCase(),ne);if(ne.prefix){const ae=J.get(ne.prefix)||[];ae.push(ne),J.set(ne.prefix,ae)}}const te={units:Z,byToken:_,byPrefix:J,decimal:Z.filter(ne=>!ne.binary&&ne.auto),binary:Z.some(ne=>ne.binary)?Z.filter(ne=>(ne.binary||ne.factor===1)&&ne.auto):null};return V.set(S,te),te}function u(R,S){return S&&R.binary||R.decimal}function a(R,S){const I=y(R);if(!I||L(S))return null;const q=I.units.find(_=>_.symbol===String(S));if(q)return q;const Z=I.byToken.get(String(S).trim().toLowerCase());return Z&&Z!==H?Z:null}const s=new WeakMap;function n(R){const S=R||{};if(typeof S=="object"&&S!==null){const _=s.get(S);if(_!==void 0)return _}const I=S.system||"data",q=y(I);let Z=null;if(!q)B(`unit:system:${I}`,`unknown unit system "${I}"; known systems are ${v().join(", ")}`);else{let _=S.unit?a(I,S.unit):null;_||(S.unit&&B(`unit:unit:${I}:${S.unit}`,`unknown unit "${S.unit}" in system "${I}"; falling back to ${q.units[0].symbol}`),_=q.units.find(J=>J.factor===1)||q.units[0]),Z={index:q,base:_,binary:S.binary===!0}}return typeof S=="object"&&S!==null&&s.set(S,Z),Z}const t=new WeakMap;function r(R,S){if(!R||!S||!Array.isArray(R.compound)||R.compound.length===0)return null;const I=t.get(R);if(I!==void 0)return I;const q=new Set,Z=[];for(const J of R.compound){const ee=a(R.system||"data",J);if(!ee){B(`unit:compound:${R.system}:${J}`,`unknown compound unit "${J}" in system "${R.system||"data"}"; ignoring it`);continue}q.has(ee.symbol)||(q.add(ee.symbol),Z.push(ee))}Z.sort((J,ee)=>ee.factor-J.factor);const _=Z.length>=2?Z:null;return t.set(R,_),_}function o(R,S,I){return S===I||S.factor===I.factor?R:R*S.factor/I.factor}const f=new Map;function c(R){const S=R||"",I=f.get(S);if(I)return I;const q={group:",",decimal:"."};try{for(const Z of new Intl.NumberFormat(R||void 0).formatToParts(12345.6))Z.type==="group"?q.group=Z.value:Z.type==="decimal"&&(q.decimal=Z.value)}catch{}return f.set(S,q),q}const i=/[\s ]/g,g=/^[+-]?[\d '’ .,]*(?:[eE][+-]?\d+)?/,d=/^[^\d+\-(.,\s]+\s*/,h=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function l(R,S){const{group:I,decimal:q}=c(S);let Z=String(R).replace(i,"");if(Z==="")return null;const _=q?Z.indexOf(q):-1;if(I&&I!==q){if(_>=0&&Z.indexOf(I,_+q.length)>=0)return null;Z=Z.split(I).join("")}if(q&&q!=="."&&(Z=Z.split(q).join(".")),!h.test(Z))return null;const J=Number(Z);return Number.isFinite(J)?J:null}function m(R,S,I){const q=String(R).trim().replace(/\.$/,"");if(q==="")return null;const Z=S.units.find(ae=>ae.symbol===q);if(Z)return Z;const _=q.toLowerCase(),J=S.byToken.get(_);if(J===H)return null;if(J)return J;const ee=S.byPrefix.get(_);if(!ee||!ee.length)return null;const te=u(S,I),ne=ee.filter(ae=>te.includes(ae));return ne.length===1?ne[0]:null}function w(R,S,I,q){let Z=R,_=0,J=!1,ee=!1;for(;Z!=="";){const te=g.exec(Z)[0];if(te==="")return null;const ne=l(te,q&&q.locale);if(ne===null)return null;Z=Z.slice(te.length).trim();const ae=Z.search(/[+-]?[\d]/),de=(ae>=0?Z.slice(0,ae):Z).trim();if(Z=ae>=0?Z.slice(ae).trim():"",de===""){if(J)return null;ee=!0,_+=o(ne,I[0],S.base)}else{const ie=m(de,S.index,S.binary);if(!ie)return null;_+=o(ne,ie,S.base)}if(J=!0,ee&&Z!=="")return null}return J?_:null}function k(R,S){if(L(R))return null;if(typeof R=="number")return Number.isFinite(R)?R:null;const I=n(S);if(!I)return null;let q=String(R).trim();if(q==="")return null;let Z=!1;q.startsWith("(")&&q.endsWith(")")&&(Z=!0,q=q.slice(1,-1).trim());const _=r(S,I);if(_){q.startsWith("-")&&(Z=!0,q=q.slice(1).trim());const oe=w(q,I,_,S);return oe===null?null:Z?-oe:oe}let J=null;const ee=d.exec(q);if(ee&&ee[0]){const oe=m(ee[0].trim(),I.index,I.binary);oe&&(J=oe,q=q.slice(ee[0].length).trim())}const te=g.exec(q)[0],ne=l(te,S&&S.locale);if(ne===null)return null;const ae=q.slice(te.length).trim();if(J&&ae!=="")return null;const de=J||(ae===""?I.base:m(ae,I.index,I.binary));if(!de)return null;const ie=o(ne,de,I.base);return Z?-ie:ie}const p=new Map;function b(R,S,I,q){const Z=`${R||""}|${S}|${I}|${q?1:0}`;let _=p.get(Z);return _||(_=new Intl.NumberFormat(R||void 0,{minimumFractionDigits:S,maximumFractionDigits:I,useGrouping:q}),p.set(Z,_)),_}function E(R,S){if(!Number.isFinite(R)||R===0)return Math.max(0,S-1);const I=Math.floor(Math.log10(Math.abs(R)));return Math.min(20,Math.max(0,S-1-I))}function T(R,S){if(!Number.isFinite(R)||R===0)return R;const I=Math.ceil(Math.log10(Math.abs(R))),q=10**(S-I);return Math.round(R*q)/q}function P(R,S,I){if(!I||I===S.base.symbol)return S.base;if(I!=="auto")return x(S,I);if(R===0||!Number.isFinite(R))return S.base;const q=Math.abs(R)*S.base.factor,Z=u(S.index,S.binary);let _=Z[0];for(const te of Z)q>=te.factor&&(_=te);if(q>=_.factor)return _;let J=_;for(const te of S.index.units)te.binary!==S.binary&&te.factor!==1||te.factor<=q&&te.factor>(J===_?0:J.factor)&&(J=te);if(J!==_)return J;let ee=_;for(const te of S.index.units)te.binary!==S.binary&&te.factor!==1||te.factor<ee.factor&&(ee=te);return ee.factor<S.base.factor?ee:S.base}function x(R,S){const I=R.index.units.find(Z=>Z.symbol===S);if(I)return I;const q=R.index.byToken.get(String(S).toLowerCase());return q&&q!==H?q:(B(`unit:display:${S}`,`unknown display unit "${S}"; rendering in ${R.base.symbol}`),R.base)}function C(R,S,I,q){const Z=R<0;let _=Math.abs(R)*S.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,ee=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),te=q.space??" ",ne=[];for(let de=0;de<I.length;de++){const ie=I[de],oe=de===I.length-1;let ce=oe?_/ie.factor:Math.floor(_/ie.factor);if(_-=ce*ie.factor,oe){const ke=10**ee;ce=Math.round(ce*ke)/ke+0}const fe=oe?b(q.locale,J,ee,q.group!==!1):b(q.locale,0,0,q.group!==!1);ne.push(`${fe.format(ce)}${te}${ie.symbol}`)}const ae=ne.join(" ");return Z?`-${ae}`:ae}function A(R,S){const I=S||{},q=I.nullDisplay??"";if(L(R)||R==="")return q;const Z=typeof R=="number"?R:Number(R);if(!Number.isFinite(Z))return q;const _=n(I);if(!_)return String(Z);const J=r(I,_);if(J)return C(Z,_,J,I);const ee=typeof I.significantFigures=="number"&&I.significantFigures>0?I.significantFigures:0,te=ee?T(Z,ee):Z,ne=P(te,_,I.display),ae=o(te,_.base,ne);let de=typeof I.decimals=="number"?I.decimals:I.minDecimals??0,ie=typeof I.decimals=="number"?I.decimals:I.maxDecimals??Math.max(de,2);ee&&(de=E(ae,ee),ie=de);const oe=b(I.locale,de,ie,I.group!==!1).format(ae),ce=I.space??" ";return I.placement==="prefix"?`${ne.symbol}${I.space??""}${oe}`:`${oe}${ce}${ne.symbol}`}function j(R,S){const I=L(R)||Number.isNaN(R)?null:Number(R),q=L(S)||Number.isNaN(S)?null:Number(S);return I===null||Number.isNaN(I)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||I<q?-1:I>q?1:0}function $(R){const S=typeof R.decimals=="number"&&R.decimals>0?`.${"0".repeat(R.decimals)}`:"";return`${typeof R.decimals=="number"?`#,##0${S}`:"#,##0.##"}" ${R.symbol}"`}function z(R){const S={system:"data",...R||{}},I=n(S),q=I?I.base.symbol:String(S.unit||""),Z=Object.freeze({...S,unit:q}),_=Object.freeze({...Z,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Z.locale||"",Z]]),ee=te=>{const ne=te||"";let ae=J.get(ne);return ae||(ae=Object.freeze({...Z,locale:te||void 0}),J.set(ne,ae)),ae};return{base:"number",extends:"number",storage:"float64",unitConfig:Z,format:te=>A(te.value,te.locale?ee(te.locale):Z),parse:te=>k(te.text,te.locale?ee(te.locale):Z),compare:j,defaults:{filter:"number",editor:"unit",align:"end",total:S.total||"sum"},...S.totals?{totals:S.totals}:{},excel:S.excel||$({decimals:S.decimals,symbol:q}),toStorage:te=>typeof te=="number"?Number.isFinite(te)?te:null:typeof te=="string"?k(te,Z):L(te)?null:k(String(te),Z),toClipboard:te=>A(te,_),fromClipboard:te=>k(te,Z)}}const M=z}),xe("packages/core/src/columns/types/engineering.js",function(e,G){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const L=G("packages/core/src/internal/util.js").isNil,F=G("packages/core/src/columns/types/unit.js").createUnitType;function W(V){const K=2*Math.PI/V;return D=>{let v=0,O=0,y=0;for(const a of D||[]){if(L(a))continue;const s=Number(a);Number.isFinite(s)&&(v+=Math.cos(s*K),O+=Math.sin(s*K),y+=1)}return!y||Math.hypot(v,O)/y<1e-12?null:(Math.atan2(O,v)/K%V+V)%V}}function X(V){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(V)}}}const H=Object.freeze({metres:F({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:F({system:"length",unit:"mm",maxDecimals:2}),kilometres:F({system:"length",unit:"km",maxDecimals:3}),grams:F({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:F({system:"mass",unit:"kg",maxDecimals:3}),tonnes:F({system:"mass",unit:"t",maxDecimals:3}),seconds:F({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:F({system:"duration",unit:"ms",maxDecimals:3}),hours:F({system:"duration",unit:"h",maxDecimals:2}),speed:F({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:F({system:"speed",unit:"km/h",maxDecimals:1}),mph:F({system:"speed",unit:"mph",maxDecimals:1}),knots:F({system:"speed",unit:"kn",maxDecimals:1}),acceleration:F({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:F({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:F({system:"area",unit:"ha",maxDecimals:4}),volume:F({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:F({system:"volume",unit:"m³",maxDecimals:3}),energy:F({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:F({system:"energy",unit:"kWh",maxDecimals:2}),power:F({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:F({system:"power",unit:"kW",maxDecimals:2}),force:F({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:F({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:F({system:"pressure",unit:"bar",maxDecimals:3}),psi:F({system:"pressure",unit:"psi",maxDecimals:1}),torque:F({system:"torque",unit:"N·m",maxDecimals:2}),density:F({system:"density",unit:"kg/m³",maxDecimals:2}),flow:F({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:F({system:"flow",unit:"L/min",maxDecimals:1}),radians:F({system:"angle",unit:"rad",maxDecimals:4,totals:X(2*Math.PI)}),degrees:F({system:"angle",unit:"°",maxDecimals:2,totals:X(360)}),rpm:F({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:F({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:F({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:F({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:F({system:"fraction",unit:"bp",maxDecimals:1}),molarity:F({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:F({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:F({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:F({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:F({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:F({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:F({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:F({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),xe("packages/core/src/columns/types/si.js",function(e,G){"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 V}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=G("packages/core/src/columns/types/unit.js"),L=Q.defineUnit,B=Q.registerUnitSystem,F=Q.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})]),X=Object.freeze(["p","n","µ","m","","k","M","G"]);function H(O){const y=String(O.base),u=new Set([...O.prefixes||X,""]),a=[];for(const s of W){if(!u.has(s.symbol))continue;const n=`${s.symbol}${y}`,t=[];if(O.name){t.push(`${s.name}${O.name}`,`${s.name}${O.name}s`);const r=s.name.slice(-1);if(r&&O.name.startsWith(r)){const o=`${s.name.slice(0,-1)}${O.name}`;t.push(o,`${o}s`)}}s.symbol==="µ"&&t.push(`u${y}`),s.factor===1&&O.aliases&&t.push(...O.aliases),a.push(L(n,s.factor,t))}for(const s of O.extra||[])a.push(s);return a}function V(O,y){const u=H(y);return B(O,u)}function K(O,y,u){return V(O,y),F({system:O,unit:y.base,display:"auto",maxDecimals:3,...u||{}})}const D=Object.freeze({voltage:K("voltage",{base:"V",name:"volt"}),current:K("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:K("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:K("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:K("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:K("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[L("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),L("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:K("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:K("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[L("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:K("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:K("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:K("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:K("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:K("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:K("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:K("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[L("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:K("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),v=K}),xe("packages/core/src/columns/types/temperature.js",function(e,G){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const L=G("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:a=>a+273.15,fromKelvin:a=>a-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:a=>(a+459.67)*(5/9),fromKelvin:a=>a*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:a=>a,fromKelvin:a=>a}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:a=>a*(5/9),fromKelvin:a=>a*(9/5)})});function F(a){if(L(a))return null;const s=String(a).trim();if(s==="")return null;for(const[t,r]of Object.entries(B))if(s===t||s===r.symbol)return{key:t,scale:r};const n=s.toLowerCase();for(const[t,r]of Object.entries(B))if(r.aliases.includes(n))return{key:t,scale:r};return null}function W(a,s,n){const t=F(s),r=F(n);return!t||!r||!Number.isFinite(Number(a))?null:t.key===r.key?Number(a):r.scale.fromKelvin(t.scale.toKelvin(Number(a)))}const X=new Map;function H(a,s,n){const t=`${a||""}|${s}|${n}`;let r=X.get(t);return r||(r=new Intl.NumberFormat(a||void 0,{minimumFractionDigits:s,maximumFractionDigits:n}),X.set(t,r)),r}function V(a,s){const n=s||{},t=n.nullDisplay??"";if(L(a)||a==="")return t;const r=Number(a);if(!Number.isFinite(r))return t;const o=F(n.scale||"C");if(!o)return String(r);const f=F(n.display||n.scale||"C")||o,c=f.key===o.key?r:f.scale.fromKelvin(o.scale.toKelvin(r)),i=typeof n.decimals=="number"?n.decimals:null,g=i??n.minDecimals??0,d=i??n.maxDecimals??1;return`${H(n.locale,g,d).format(c)}${n.space??" "}${f.scale.symbol}`}const K=/^[+-]?[\d\s., ]*\d/;function D(a,s){const n=String(a).trim();if(n==="")return null;const t=new Intl.NumberFormat(s||void 0).formatToParts(1.1).find(c=>c.type==="decimal")?.value||".",r=t===","?".":",",o=n.split(r).join("").split(/[\s ]/).join("").replace(t,"."),f=Number(o);return Number.isFinite(f)?f:null}function v(a,s){if(L(a))return null;const n=s||{},t=F(n.scale||"C");if(!t)return null;if(typeof a=="number")return Number.isFinite(a)?a:null;let r=String(a).trim();if(r==="")return null;let o=!1;r.startsWith("(")&&r.endsWith(")")&&(o=!0,r=r.slice(1,-1).trim());const f=K.exec(r);if(!f)return null;const c=D(f[0],n.locale);if(c===null)return null;const i=r.slice(f[0].length).trim();if(i==="")return o?-c:c;const g=F(i);if(!g)return null;const d=g.key===t.key?c:t.scale.fromKelvin(g.scale.toKelvin(c));return o?-d:d}function O(a){const s=Object.freeze({scale:"C",...a||{}}),t=(F(s.scale)||F("C")).scale.symbol,r=Object.freeze({...s,display:s.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),o=new Map([[s.locale||"",s]]),f=c=>{const i=c||"";let g=o.get(i);return g||(g=Object.freeze({...s,locale:c||void 0}),o.set(i,g)),g};return{base:"number",extends:"number",storage:"float64",temperatureConfig:s,format:c=>V(c.value,c.locale?f(c.locale):s),parse:c=>v(c.text,c.locale?f(c.locale):s),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:s.excel||`#,##0${typeof s.decimals=="number"&&s.decimals>0?`.${"0".repeat(s.decimals)}`:".#"}" ${t}"`,toStorage:c=>typeof c=="number"?Number.isFinite(c)?c:null:typeof c=="string"?v(c,s):L(c)?null:v(String(c),s),toClipboard:c=>V(c,r),fromClipboard:c=>v(c,s)}}const y=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),u=O}),xe("packages/core/src/columns/types/radix.js",function(e,G){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Q=G("packages/core/src/internal/util.js"),L=Q.isNil,B=Q.warnOnce,F=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),W=Object.freeze({2:1,8:3,16:4}),X=Object.freeze({2:"0b",8:"0o",16:"0x"}),H=Object.freeze({2:4,8:3,16:2}),V=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),K=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,O=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),u=new WeakSet,a=new WeakMap,s=new Map,n=new WeakMap,t=new WeakMap,r=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function o(A){if(A==null)return 16;const j=typeof A=="string"?A.toLowerCase():A,$=F[j];return $||(B(`radix:base:${String(A)}`,`unsupported radix ${String(A)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function f(A,j){return Math.ceil(A/W[j])}function c(A,j){if(!A)return j?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!j)return{min:0,max:2**A-1};const $=2**(A-1);return{min:-$,max:$-1}}function i(A){return K[A]||"hexadecimal"}function g(A){if(typeof A=="string"){const j=r[A];return j||B(`radix:preset:${A}`,`unknown radix preset "${A}"; known presets are ${Object.keys(r).join(", ")}`),{...j||{}}}if(A&&typeof A.preset=="string"){const j=r[A.preset];return j||B(`radix:preset:${A.preset}`,`unknown radix preset "${A.preset}"; known presets are ${Object.keys(r).join(", ")}`),{...j||{},...A}}return A||{}}function d(A){const j=g(A),$=o(j.radix),z=W[$];let M=null;if(j.bitWidth!==void 0&&j.bitWidth!==null&&j.bitWidth!==!1){const te=Number(j.bitWidth);y.includes(te)?M=te:B(`radix:width:${String(j.bitWidth)}`,`unsupported bitWidth ${String(j.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let R=j.signed!==!1;!R&&M===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),M=32);const S=j.prefix===void 0||j.prefix===!0?X[$]:j.prefix===!1?"":String(j.prefix);let I=0;j.pad===!0?I=M?f(M,$):0:typeof j.pad=="number"&&j.pad>0&&(I=Math.floor(j.pad));let q=0;j.group===!0?q=H[$]:typeof j.group=="number"&&j.group>0&&(q=Math.floor(j.group));const Z=c(M,R),_=typeof j.min=="number"?Math.max(Z.min,j.min):Z.min,J=typeof j.max=="number"?Math.min(Z.max,j.max):Z.max,ee=Object.freeze({radix:$,bits:z,prefix:S,uppercase:j.uppercase!==!1,pad:I,group:q,groupSeparator:typeof j.groupSeparator=="string"?j.groupSeparator:" ",bitWidth:M,signed:R,min:_,max:J<_?_:J,nullDisplay:typeof j.nullDisplay=="string"?j.nullDisplay:"",name:i($)});return u.add(ee),ee}function h(A){if(A&&u.has(A))return A;if(typeof A=="string"){let j=s.get(A);return j||(j=d(A),s.set(A,j)),j}if(A&&typeof A=="object"){let j=a.get(A);return j||(j=d(A),a.set(A,j)),j}return h("hex")}function l(A){return A<0?-Math.round(-A):Math.round(A)}function m(A,j,$){if(j<=0||A.length<=j)return A;const z=A.length%j||j,M=[A.slice(0,z)];for(let R=z;R<A.length;R+=j)M.push(A.slice(R,R+j));return M.join($)}function w(A){const j=h(A),{radix:$,prefix:z,uppercase:M,pad:R,group:S,groupSeparator:I,signed:q,bitWidth:Z,nullDisplay:_}=j,J=Z?2**Z:0,ee=te=>{if(L(te)||te==="")return _;const ne=typeof te=="number"?te:Number(te);if(!Number.isFinite(ne))return _;const ae=l(ne);let de="",ie=ae;ae<0&&(q?(de="-",ie=-ae):ie=(ae%J+J)%J);let oe=ie.toString($);return oe=M?oe.toUpperCase():oe.toLowerCase(),R>0&&oe.length<R&&(oe=oe.padStart(R,"0")),S>0&&(oe=m(oe,S,I)),de+z+oe};return ee.options=j,ee}function k(A,j){const $=h(j);let z=n.get($);return z||(z=w($),n.set($,z)),z(A)}function p(A){const j=h(A),{radix:$,groupSeparator:z,signed:M,min:R,max:S}=j,I=V[$],q=Z=>{if(L(Z))return{ok:!0,value:null,reason:"blank"};let _=String(Z);if(z&&z!==""&&(_=_.split(z).join("")),_=_.replace(v,""),_==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((_[0]==="-"||_[0]==="+")&&(J=_[0]==="-",_=_.slice(1)),_==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[ne,ae]of D){const de=ne.exec(_);if(!de)continue;const ie=_.slice(de[0].length);if(ie==="")break;if(!V[ae].test(ie))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ie,ae);break}if(ee===null)if(I.test(_))ee=parseInt(_,$);else if(O.test(_))ee=Number(_);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const te=l(J?-ee:ee);return!M&&te<0?{ok:!1,value:te,reason:"negative"}:te<R||te>S?{ok:!1,value:te,reason:"range"}:{ok:!0,value:te,reason:"ok"}};return q.options=j,q}function b(A,j){const $=h(j);let z=t.get($);return z||(z=p($),t.set($,z)),z(A)}function E(A,j){const $=b(A,j);return $.ok?$.value:null}function T(A,j){const $=L(A)||Number.isNaN(A)?null:Number(A),z=L(j)||Number.isNaN(j)?null:Number(j);return $===null?z===null?0:1:z===null||$<z?-1:$>z?1:0}function P(A){const j=A.min>=-2147483648&&A.max<=2147483647;return A.bitWidth&&j?"int32":"float64"}function x(A){const j=d(A),$=w(j),z=p(j);return{base:"number",extends:"number",storage:P(j),matches:null,format:M=>$(M.value),parse:M=>{const R=z(M.text);return R.ok?R.value:null},compare:T,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:M=>$(M),fromClipboard:M=>{const R=z(M);return R.ok?R.value:null},radix:j,formatValue:$,parseText:z}}const C=x}),xe("packages/core/src/columns/types/aggregable.js",function(e,G){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const L=G("packages/core/src/internal/util.js").isNil;function B(D){const v=[];for(const O of D||[]){if(L(O))continue;const y=Number(O);Number.isFinite(y)&&v.push(y)}return v}function F(D){return v=>{const O=B(v);if(!O.length)return null;let y=0;for(const u of O)y+=10**(u/D);return D*Math.log10(y)}}function W(D){return v=>{const O=B(v);if(!O.length)return null;let y=0;for(const u of O)y+=10**(u/D);return D*Math.log10(y/O.length)}}function X(D,v){const O=v&&v.column,u=(O&&O.typeOptions||{}).weight,a=v&&v.valueAt;if(!u||typeof a!="function")return null;let s=0,n=0;for(let t=0;t<D.length;t++){if(L(D[t]))continue;const r=Number(D[t]);if(!Number.isFinite(r))continue;const o=a(u,t);if(L(o))continue;const f=Number(o);!Number.isFinite(f)||f<=0||(s+=r*f,n+=f)}return n===0?null:s/n}function H(D={}){const v=D.factor===20?20:10,O=typeof D.suffix=="string"?D.suffix:"",y=Number.isInteger(D.decimals)?D.decimals:1;return{base:"number",storage:"float64",name:D.name||"logarithmic",format:u=>{const a=u&&u.value;return L(a)||!Number.isFinite(Number(a))?"":`${Number(a).toFixed(y)}${O}`},parse:u=>{const a=String((u&&u.text)??"").replace(O,"").trim();if(!a)return null;const s=Number(a);return Number.isFinite(s)?s:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:F(v),avg:W(v)}}}}function V(D={}){const v=Number.isInteger(D.decimals)?D.decimals:1,O=D.percent===!0;return{base:"number",storage:"float64",name:D.name||"ratio",format:y=>{const u=y&&y.value;return L(u)||!Number.isFinite(Number(u))?"":O?`${Number(u).toFixed(v)}%`:Number(u).toFixed(v)},parse:y=>{const u=String((y&&y.text)??"").replace("%","").trim();if(!u)return null;const a=Number(u);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const K=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:V({name:"ratio"}),percentRate:V({name:"percentRate",percent:!0})})}),xe("packages/core/src/columns/types/currency.js",function(e,G){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const L=G("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function F(c){if(L(c))return null;const i=String(c).trim().toUpperCase();return i===""?null:i}function W(c){if(L(c))return null;if(typeof c=="object"&&!Array.isArray(c)){const i=Number(c.amount),g=F(c.code);return!g||!Number.isFinite(i)?null:{amount:i,code:g}}if(Array.isArray(c)&&c.length===2){const i=Number(c[0]),g=F(c[1]);return!g||!Number.isFinite(i)?null:{amount:i,code:g}}return null}const X=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:"₪"}),V=/[+-]?[\d\s., ]*\d/;function K(c,i){const g=String(c).trim();if(g==="")return null;const d=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",h=d===","?".":",",l=g.split(h).join("").split(/[\s ]/).join("").replace(d,"."),m=Number(l);return Number.isFinite(m)?m:null}function D(c,i){const g=i||{},d=F(g.code);if(L(c))return null;const h=W(c);if(h)return h;if(typeof c=="number")return Number.isFinite(c)&&d?{amount:c,code:d}:null;let l=String(c).trim();if(l==="")return null;let m=!1;l.startsWith("(")&&l.endsWith(")")&&(m=!0,l=l.slice(1,-1).trim());let w=null;for(const[P,x]of Object.entries(X)){if(l.startsWith(P)){w=x,l=l.slice(P.length).trim();break}if(l.endsWith(P)){w=x,l=l.slice(0,-P.length).trim();break}}const k=V.exec(l);if(!k)return null;const p=K(k[0],g.locale);if(p===null)return null;const b=(l.slice(0,k.index)+" "+l.slice(k.index+k[0].length)).trim();!w&&b!==""&&(w=F(b));const E=w||d;return E?{amount:m?-p:p,code:E}:null}function v(c,i){if(typeof c=="function")return(g,d)=>{if(g===d)return 1;const h=c(g,d);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(c&&typeof c=="object"){const g=c;return(d,h)=>{if(d===h)return 1;const l=Number(g[d]),m=Number(g[h]);return!Number.isFinite(l)||!Number.isFinite(m)||l<=0||m<=0?null:m/l}}return(g,d)=>g===d?1:null}function O(c,i,g){if(!c)return null;if(c.code===i)return c.amount;const d=g(c.code,i);return d===null?null:c.amount*d}const y=new Map;function u(c,i,g){const d=`${c||""}|${i}|${g??""}`;let h=y.get(d);if(!h){const l={style:"currency",currency:i};typeof g=="number"&&(l.minimumFractionDigits=g,l.maximumFractionDigits=g);try{h={fmt:new Intl.NumberFormat(c||void 0,l),currency:!0}}catch{h={fmt:new Intl.NumberFormat(c||void 0,typeof g=="number"?{minimumFractionDigits:g,maximumFractionDigits:g}:{}),currency:!1}}y.set(d,h)}return h}function a(c,i){const g=i||{},d=g.nullDisplay??"",h=W(c);if(!h)return d;const l=F(g.display)||h.code;let m=h.amount,w=h.code;if(l!==h.code){const b=g.rateFn||v(g.rates,g.rateBase),E=O(h,l,b);if(E===null)return`${g.missingRate??B} ${h.code}→${l}`;m=E,w=l}const{fmt:k,currency:p}=u(g.locale,w,g.decimals);return p?k.format(m):`${k.format(m)} ${w}`}function s(c){const i=W(c);return i?`${i.amount} ${i.code}`:""}function n(c){const i=c||{},g=F(i.display),d=i.rateFn||v(i.rates,i.rateBase);return(h,l)=>{const m=W(h),w=W(l);if(!m&&!w)return 0;if(!m)return 1;if(!w)return-1;if(g){const k=O(m,g,d),p=O(w,g,d);if(k!==null&&p!==null)return k===p?0:k<p?-1:1}return m.code===w.code?m.amount===w.amount?0:m.amount<w.amount?-1:1:m.code<w.code?-1:1}}function t(c){const i=c||{},g=(h,l)=>{const m=[];for(const E of h||[]){const T=W(E);T&&m.push(T)}if(!m.length)return null;if(new Set(m.map(E=>E.code)).size===1){const E=m[0].code;return{amount:l(m.map(T=>T.amount)),code:E}}const k=F(i.display);if(!k)return`${i.missingRate??B}: mixed currencies, no display currency set`;const p=i.rateFn||v(i.rates,i.rateBase),b=[];for(const E of m){const T=O(E,k,p);if(T===null)return`${i.missingRate??B}: ${E.code}→${k}`;b.push(T)}return{amount:l(b),code:k}},d=h=>h.reduce((l,m)=>l+m,0);return{sum:h=>g(h,d),avg:h=>g(h,l=>d(l)/l.length),min:h=>g(h,l=>Math.min(...l)),max:h=>g(h,l=>Math.max(...l))}}function r(c){const i=Object.freeze({code:"USD",...c||{}}),g=v(i.rates,i.rateBase),d=Object.freeze({...i,rateFn:g}),h=t(d),l=n(d),m=new Map([[i.locale||"",d]]),w=b=>{const E=b||"";let T=m.get(E);return T||(T=Object.freeze({...d,locale:b||void 0}),m.set(E,T)),T},k=H[F(i.display||i.code)]||"",p=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:d,format:b=>a(b.value,b.locale?w(b.locale):d),parse:b=>D(b.text,b.locale?w(b.locale):d),compare:l,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:i.excel||(k?`"${k}"#,##0${p}`:`#,##0${p}`),toStorage:b=>{const E=W(b);return E||(typeof b=="string"||typeof b=="number"?D(b,d):null)},toClipboard:b=>s(b),fromClipboard:b=>D(b,d)}}const o=Object.freeze({currency:r({code:"USD"}),usd:r({code:"USD"}),eur:r({code:"EUR"}),gbp:r({code:"GBP"}),jpy:r({code:"JPY",decimals:0})}),f=r}),xe("packages/core/src/columns/types/index.js",function(e,G){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return P}});const Q=G("packages/core/src/columns/types/temporal.js"),L=Q.TEMPORAL_TYPES,B=G("packages/core/src/columns/types/network.js"),F=B.NETWORK_TYPES,W=G("packages/core/src/columns/types/structured.js"),X=W.STRUCTURED_TYPES,H=G("packages/core/src/columns/types/unit.js"),V=H.createUnitType,K=H.UNIT_SYSTEMS,D=H.parseUnit,v=H.formatUnit,O=H.registerUnitSystem,y=H.unitSystemNames,u=H.unitsOf,a=H.defineUnit,s=G("packages/core/src/columns/types/engineering.js"),n=s.ENGINEERING_TYPES,t=G("packages/core/src/columns/types/si.js"),r=t.SI_TYPES,o=t.createSiType,f=t.createSiSystem,c=t.siUnits,i=t.SI_PREFIXES,g=G("packages/core/src/columns/types/temperature.js"),d=g.TEMPERATURE_TYPES,h=g.createTemperatureType,l=g.convertTemperature,m=g.formatTemperature,w=g.parseTemperature,k=g.TEMPERATURE_SCALES,p=G("packages/core/src/columns/types/radix.js"),b=p.createRadixType,E=p.RADIX_PRESETS,T=p.parseRadix,P=p.formatRadix,x=G("packages/core/src/columns/types/aggregable.js"),C=x.AGGREGABLE_TYPES,A=G("packages/core/src/columns/types/currency.js"),j=A.CURRENCY_TYPES,$=A.createCurrencyType,z=A.parseMoney,M=A.formatMoney,R=A.convertMoney,S=A.toMoney,I=A.rateFunction,q=A.moneyComparator,Z=A.normaliseCode,_=A.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return s.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return s.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return g.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return g.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return g.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return g.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return g.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return g.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return A.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return A.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return A.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return A.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return A.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return A.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return A.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return A.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return A.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return A.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Q.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return B.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return W.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return x.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return x.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return Q.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return Q.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return Q.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return Q.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return Q.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return B.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return B.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return B.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return B.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return B.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return B.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return B.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return B.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return B.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return W.summariseJson}});const J=Object.freeze({...L,...F,...X,...C,hex:b(E.hex),hex8:b(E.hex8),hex16:b(E.hex16),hex32:b(E.hex32),binary:b(E.binary),binary8:b(E.binary8),octal:b(E.octal),bytes:V({system:"data",unit:"B",display:"auto"}),megabytes:V({system:"data",unit:"MB"}),gigabytes:V({system:"data",unit:"GB"}),bitrate:V({system:"bitrate",unit:"Mbps"}),gigabits:V({system:"bitrate",unit:"Gbps"}),...n,...r,...d,...j});{const ee=new Set;for(const te of[L,F,X,C,n,r,d,j])for(const ne of Object.keys(te)){if(ee.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);ee.add(ne)}}}),xe("packages/core/src/compute/handle.js",function(e,G){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=G("packages/core/src/internal/util.js"),L=Q.collator,B=Q.defaultCompare,F=Q.warnOnce;function W(r){const o=new Uint32Array(r);for(let f=0;f<r;f++)o[f]=f;return o}function X(r,o){if(o&&typeof o.count=="number")return o.count;if(!r)return 0;if(typeof r.count=="number")return r.count;if(typeof r.length=="number")return r.length;const f=r.values;return r.kind==="multi"&&r.offsets?Math.max(0,r.offsets.length-1):f?r.kind==="bitset"?typeof f.size=="number"?f.size:r.presence&&typeof r.presence.size=="number"?r.presence.size:(F(`count:${r.id}`,`column "${r.id}" is bitset-backed with no declared row count; assuming ${f.length*8}`),f.length*8):f.length:r.presence&&typeof r.presence.size=="number"?r.presence.size:0}const H=new WeakMap;function V(r){const o=r.constructor;if(!o)return"unknown";const f=H.get(o);if(f)return f;let c="unknown";try{let i=null;typeof o.from=="function"?i=o.from([!1,!0]):(i=new o(8),i.set(1));const g=i&&i.words;g&&g.length&&(g[0]===2?c="lsb":g[0]===64&&(c="msb"))}catch{c="unknown"}return H.set(o,c),c}function K(r){if(!r)return()=>0;const o=r instanceof Uint8Array?r:r.words;if(o instanceof Uint8Array){const f=r instanceof Uint8Array?"lsb":V(r);if(f==="lsb")return c=>o[c>>>3]>>>(c&7)&1;if(f==="msb")return c=>o[c>>>3]>>>7-(c&7)&1}return typeof r.get=="function"?f=>r.get(f)?1:0:()=>0}function D(r){return!r||!r.presence?null:K(r.presence)}function v(r){return r?typeof r.size=="number"?r.size:typeof r.values=="function"?r.values().length:0:0}function O(r,o){return r?typeof r.valueOf=="function"?r.valueOf(o):typeof r.values=="function"?r.values()[o]:null:null}function y(r,o){const f=r.offsets,c=r.values;if(!f||!c)return[];const i=f[o],g=f[o+1];if(!(g>i))return[];const d=r.dict,h=new Array(g-i);for(let l=i;l<g;l++)h[l-i]=d?O(d,c[l]):c[l];return h}function u(r){if(!r)return()=>{};const o=r.values,f=D(r),c=r.kind;if(c==="dictionary"){const i=r.dict;return f?g=>f(g)?O(i,o[g]):null:g=>O(i,o[g])}if(c==="bitset"){const i=K(o);return f?g=>f(g)?i(g)===1:null:g=>i(g)===1}if(c==="multi")return f?i=>f(i)?y(r,i):null:i=>y(r,i);if(!o&&typeof r.get=="function"){const i=r.get.bind(r);return g=>{const d=i(g);return d===void 0?null:d}}return f?i=>{if(!f(i))return null;const g=o[i];return g===void 0?null:g}:i=>{const g=o[i];return g===void 0?null:g}}function a(r,o){if(r<o)return-1;if(r>o)return 1;if(r===o){const i=Object.is(r,-0),g=Object.is(o,-0);return i===g?0:i?-1:1}const f=Number.isNaN(r),c=Number.isNaN(o);return f&&c?0:f?1:-1}function s(r){const o=L(r);return(f,c)=>{if(f===c)return 0;const i=typeof f,g=typeof c;if(i==="string"&&g==="string")return o.compare(f,c);if(i==="number"&&g==="number")return a(f,c);if(i==="boolean"&&g==="boolean")return f===c?0:f?1:-1;if(f instanceof Date||c instanceof Date){const d=f instanceof Date?f.getTime():Number(f),h=c instanceof Date?c.getTime():Number(c);return a(d,h)}return B(f,c)}}function n(r,o){if(r&&typeof r.ranks=="function")return r.ranks(o);const f=r&&typeof r.values=="function"?r.values():[],c=f.length,i=s(o),g=new Array(c);for(let h=0;h<c;h++)g[h]=h;g.sort((h,l)=>i(f[h],f[l])||h-l);const d=new Uint32Array(c);for(let h=0;h<c;h++)d[g[h]]=h;return d}function t(r){return r==null||typeof r=="number"&&Number.isNaN(r)}}),xe("packages/core/src/compute/filter.js",function(e,G){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return Z}});const Q=G("packages/core/src/internal/util.js"),L=Q.isBlank,B=Q.toArray,F=Q.warnOnce,X=G("packages/core/src/format/date.js").toIsoDate,H=G("packages/core/src/compute/handle.js"),V=H.bitReader,K=H.dictSize,D=H.dictValue,v=H.presenceReader,O=H.valueComparator,y=H.valueReader,u=/^\d{4}-\d{2}-\d{2}$/,a="\0null\0";function s(_,J){const ee=_&&_.pool;if(ee){const te=ee.mask||ee.acquireMask||ee.acquire||ee.take;if(typeof te=="function"){const ne=te.call(ee,J);if(ne&&ne.length>=J)return ne}}return new Uint8Array(J)}function n(_,J){const ee=_&&_.pool;if(!ee||!J)return;const te=ee.release||ee.releaseMask||ee.free||ee.recycle;typeof te=="function"&&te.call(ee,J)}function t(_,J,ee){return _.fill(ee,0,J),_}function r(_){return _==null||typeof _=="number"&&Number.isNaN(_)}function o(_,J){if(_==null)return _;if(J==="number")return typeof _=="number"?_:Number(_);if(J==="date"||J==="dateString"){const ee=X(_);return ee===null?f(_):ee}return J==="boolean"?typeof _=="boolean"?_:_==="true"||_===1?!0:_==="false"||_===0?!1:!!_:_}function f(_){return _ instanceof Date?_.getTime():typeof _=="number"?_:Date.parse(String(_))}function c(_){return typeof _=="number"?_:_ instanceof Date?_.getTime():_==null||_===""?NaN:Number(_)}function i(_,J){const ee=typeof _=="string"?_:String(_);return J?ee:ee.toLowerCase()}function g(_,J){return _==null?a:typeof _=="string"?J?_:_.toLowerCase():_ instanceof Date?_.getTime():_}function d(_,J,ee){const te=new Set;for(const ne of B(_)){const ae=o(ne,ee);te.add(g(ae,J)),typeof ae=="string"&&ae!==""&&Number.isFinite(Number(ae))?te.add(Number(ae)):typeof ae=="number"&&Number.isFinite(ae)&&te.add(g(String(ae),J))}return te}function h(_,J,ee){if(_==null||J===null||J===void 0)return _==null&&J==null;const te=typeof _,ne=typeof J;return te==="string"&&ne==="string"?ee?_===J:_.toLowerCase()===J.toLowerCase():_ instanceof Date||J instanceof Date?f(_)===f(J):te==="number"&&ne==="number"?_===J||Number.isNaN(_)&&Number.isNaN(J):te==="number"&&ne==="string"?_===Number(J):te==="string"&&ne==="number"?Number(_)===J:te==="boolean"||ne==="boolean"?_===J:Array.isArray(_)&&Array.isArray(J)?_.length===J.length&&_.every((ae,de)=>h(ae,J[de],ee)):_===J}function l(_,J){try{if(_ instanceof RegExp){const ee=_.flags.replace(/[gy]/g,"");return new RegExp(_.source,J||ee.includes("i")?ee:`${ee}i`)}return new RegExp(String(_),J?"":"i")}catch(ee){return F(`regex:${String(_)}`,`filter operator "matches" received an invalid pattern: ${String(_)}`,ee),null}}function m(_,J){const ee=w(_,J),te=_&&_.type;return te!=="date"&&te!=="dateString"?ee:ne=>ee(typeof ne=="string"&&u.test(ne)?ne:X(ne)??ne)}function w(_,J){const ee=_&&_.op,te=!!(_&&_.caseSensitive),ne=_&&_.type,ae=O(J),de=ie=>oe=>!ie(oe);switch(ee){case"eq":{const ie=o(_.value,ne);return oe=>h(oe,ie,te)}case"ne":{const ie=o(_.value,ne);return oe=>!h(oe,ie,te)}case"lt":case"lte":case"gt":case"gte":{const ie=o(_.value,ne);if(r(ie))return()=>!1;const oe=ee==="lt"?-1:ee==="lte"?0:ee==="gt"?1:2;return ce=>{if(r(ce))return!1;const fe=ae(ce,ie);return oe===-1?fe<0:oe===0?fe<=0:oe===1?fe>0:fe>=0}}case"between":case"notBetween":{const ie=B(_.value),oe=o(ie[0],ne),ce=o(ie[1],ne),fe=_.bounds||"[]",ke=fe.charAt(0)!=="(",Re=fe.charAt(1)!==")";if(r(oe)||r(ce))return ee==="between"?()=>!1:()=>!0;const Ee=Fe=>{if(r(Fe))return!1;const ye=ae(Fe,oe),he=ae(Fe,ce);return(ke?ye>=0:ye>0)&&(Re?he<=0:he<0)};return ee==="between"?Ee:de(Ee)}case"in":case"notIn":{const ie=d(_.value,te,ne),oe=ce=>ie.has(g(ce,te));return ee==="in"?oe:de(oe)}case"contains":case"notContains":{const ie=i(o(_.value,ne),te),oe=ce=>ce==null?!1:i(ce,te).includes(ie);return ee==="contains"?oe:de(oe)}case"startsWith":{const ie=i(o(_.value,ne),te);return oe=>oe==null?!1:i(oe,te).startsWith(ie)}case"endsWith":{const ie=i(o(_.value,ne),te);return oe=>oe==null?!1:i(oe,te).endsWith(ie)}case"matches":{const ie=l(_.value,te);return ie?oe=>oe==null?!1:ie.test(String(oe)):()=>!1}case"blank":return ie=>L(ie)||Array.isArray(ie)&&ie.length===0;case"notBlank":return ie=>!(L(ie)||Array.isArray(ie)&&ie.length===0);case"containsAny":case"containsNone":{const ie=d(_.value,te,ne),oe=ce=>{const fe=ce==null?[]:B(ce);for(let ke=0;ke<fe.length;ke++)if(ie.has(g(fe[ke],te)))return!0;return!1};return ee==="containsAny"?oe:de(oe)}case"containsAll":{const ie=B(_.value).map(oe=>g(o(oe,ne),te));return oe=>{const ce=oe==null?[]:B(oe);if(ie.length===0)return!0;const fe=new Set(ce.map(ke=>g(ke,te)));for(let ke=0;ke<ie.length;ke++)if(!fe.has(ie[ke]))return!1;return!0}}default:{const ie=Z(ee);return ie?ie.compile(_.value):(F(`op:${String(ee)}`,`unknown filter operator "${String(ee)}"; the condition is refused rather than matching every row`),()=>!1)}}}function k(_,J,ee){return m(J,ee)(_)}const p=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),b=new Set(["containsAny","containsAll","containsNone"]);function E(_,J,ee){const te=_&&_.op,ne=p[te]||te,ae=m({..._,op:ne,type:J.type},ee),de=J.items,ie=oe=>{const ce=de(oe);if(!ce)return!1;for(let fe=0;fe<ce.length;fe++)if(ae(ce[fe]))return!0;return!1};return p[te]?oe=>!ie(oe):ie}function T(_,J,ee,te){const ne=v(_);if(ne){const ie=J?1:0;for(let oe=0;oe<te;oe++)ee[oe]=ne(oe)===ie?1:0;return ee}const ae=_.kind;if(ae==="float64"||ae==="int32"||ae==="bitset")return t(ee,te,J?1:0);const de=y(_);for(let ie=0;ie<te;ie++){const oe=de(ie),ce=L(oe)||Array.isArray(oe)&&oe.length===0;ee[ie]=ce===J?0:1}return ee}function P(_,J,ee,te){const ne=_.dict,ae=K(ne),de=new Uint8Array(ae);for(let fe=0;fe<ae;fe++)de[fe]=J(D(ne,fe))?1:0;const ie=_.values,oe=v(_);if(!oe){for(let fe=0;fe<te;fe++)ee[fe]=de[ie[fe]];return ee}const ce=J(null)?1:0;for(let fe=0;fe<te;fe++)ee[fe]=oe(fe)===1?de[ie[fe]]:ce;return ee}function x(_,J,ee,te){const ne=V(_.values),ae=J(!0)?1:0,de=J(!1)?1:0,ie=v(_);if(!ie){for(let ce=0;ce<te;ce++)ee[ce]=ne(ce)===1?ae:de;return ee}const oe=J(null)?1:0;for(let ce=0;ce<te;ce++)ee[ce]=ie(ce)===0?oe:ne(ce)===1?ae:de;return ee}function C(_,J,ee,te,ne){const ae=_.values,de=J.type,ie=J.op;let oe=!0;switch(ie){case"eq":case"ne":{const fe=c(o(J.value,de)),ke=typeof J.value=="number"&&Number.isNaN(J.value),Re=ie==="ne"?1:0;if(ke)for(let Ee=0;Ee<ne;Ee++)te[Ee]=(Number.isNaN(ae[Ee])?1:0)^Re;else for(let Ee=0;Ee<ne;Ee++)te[Ee]=(ae[Ee]===fe?1:0)^Re;break}case"lt":{const fe=c(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]<fe?1:0;break}case"lte":{const fe=c(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]<=fe?1:0;break}case"gt":{const fe=c(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]>fe?1:0;break}case"gte":{const fe=c(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]>=fe?1:0;break}case"between":case"notBetween":{const fe=B(J.value),ke=c(o(fe[0],de)),Re=c(o(fe[1],de)),Ee=J.bounds||"[]",Fe=Ee.charAt(0)!=="(",ye=Ee.charAt(1)!==")",he=ie==="notBetween"?1:0;if(Fe&&ye)for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>=ke&ae[Se]<=Re?1:0)^he;else if(Fe)for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>=ke&ae[Se]<Re?1:0)^he;else if(ye)for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>ke&ae[Se]<=Re?1:0)^he;else for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>ke&ae[Se]<Re?1:0)^he;break}case"in":case"notIn":{const fe=new Set;for(const Re of B(J.value)){const Ee=c(o(Re,de));Number.isNaN(Ee)||fe.add(Ee)}const ke=ie==="notIn"?1:0;for(let Re=0;Re<ne;Re++)te[Re]=(fe.has(ae[Re])?1:0)^ke;break}default:oe=!1;break}if(!oe)return!1;const ce=v(_);if(ce){const fe=ee(null)?1:0;for(let ke=0;ke<ne;ke++)ce(ke)===0&&(te[ke]=fe)}return!0}function A(_,J,ee,te){const ne=y(_);for(let ae=0;ae<te;ae++)ee[ae]=J(ne(ae))?1:0;return ee}function j(_,J,ee){const te=J.count|0,ne=ee||s(J,te);if(!_)return t(ne,te,1);const ae=typeof J.handle=="function"?J.handle(_.col):void 0,de=typeof J.custom=="function"?J.custom:null;if(!ae){if(de){for(let fe=0;fe<te;fe++)ne[fe]=de(_,fe)?1:0;return ne}return F(`filter:col:${String(_.col)}`,`filter references unknown column "${String(_.col)}"; the condition is refused rather than matching every row`),t(ne,te,0)}const ie=_.op;if(ie==="blank"||ie==="notBlank")return T(ae,ie==="notBlank",ne,te);const oe=typeof J.itemwise=="function"?J.itemwise(_.col):null;if(oe&&!Z(ie)&&!b.has(ie))return A(ae,E(_,oe,J.locale),ne,te);const ce=m(_,J.locale);switch(ae.kind){case"dictionary":return P(ae,ce,ne,te);case"bitset":return x(ae,ce,ne,te);case"float64":case"int32":return C(ae,_,ce,ne,te)?ne:A(ae,ce,ne,te);default:return A(ae,ce,ne,te)}}function $(_,J,ee){if(!_)return t(s(J,ee),ee,1);if(Array.isArray(_.conditions)){const te=_.conditions.filter(de=>de!=null),ne=_.op==="or"?"or":_.op==="not"?"not":"and";if(te.length===0)return t(s(J,ee),ee,1);const ae=$(te[0],J,ee);for(let de=1;de<te.length;de++){const ie=$(te[de],J,ee);if(ne==="or")for(let oe=0;oe<ee;oe++)ae[oe]|=ie[oe];else for(let oe=0;oe<ee;oe++)ae[oe]&=ie[oe];n(J,ie)}if(ne==="not")for(let de=0;de<ee;de++)ae[de]^=1;return ae}return j(_,J,s(J,ee))}function z(_,J){return $(_,J,J.count|0)}function M(_,J){if(!_||!J)return _||null;const ee=_;if(Array.isArray(ee.conditions)){if((ee.op==="or"?"or":ee.op==="not"?"not":"and")!=="and")return R(ee,J)?null:_;const ne=[];for(const ae of ee.conditions){const de=M(ae,J);de&&ne.push(de)}return ne.length?{...ee,op:"and",conditions:ne}:null}return ee.col===J?null:_}function R(_,J){if(!_||typeof _!="object")return!1;const ee=_;if(ee.col===J)return!0;if(Array.isArray(ee.conditions)){for(const te of ee.conditions)if(R(te,J))return!0}return!1}function S(_,J,ee){if(ee&&ee.length>=J){let de=0;for(let ie=0;ie<J;ie++)_[ie]&&(ee[de++]=ie);return ee.subarray(0,de)}let te=0;for(let de=0;de<J;de++)te+=_[de]?1:0;const ne=new Uint32Array(te);let ae=0;for(let de=0;de<J;de++)_[de]&&(ne[ae++]=de);return ne}const I=new Map;function q(_){if(!(!_||typeof _!="object"))for(const[J,ee]of Object.entries(_))ee&&typeof ee.compile=="function"&&I.set(J,ee)}function Z(_){return typeof _=="string"?I.get(_):void 0}}),xe("packages/core/src/columns/datatypes.js",function(e,G){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return j}});const Q=G("packages/core/src/internal/util.js"),L=Q.collator,B=Q.defaultCompare,F=Q.isNil,W=Q.isObject,X=Q.isFunction,H=Q.fail,V=Q.titleCase,K=G("packages/core/src/format/date.js"),D=K.toDate,v=K.toIsoDate,O=K.compareIso,u=G("packages/core/src/format/boolean.js").toTriState,s=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=G("packages/core/src/formula/index.js"),t=n.evaluateFormula,r=n.looksLikeFormula,f=G("packages/core/src/compute/filter.js").declareOperators,c=/^\d{4}-\d{2}-\d{2}$/;function i($){return $.getHours()===0&&$.getMinutes()===0&&$.getSeconds()===0&&$.getMilliseconds()===0}const g=new Map;function d($){const z=$||"",M=g.get(z);if(M)return M;const R={group:",",decimal:"."};try{for(const S of new Intl.NumberFormat($||void 0).formatToParts(12345.6))S.type==="group"?R.group=S.value:S.type==="decimal"&&(R.decimal=S.value)}catch{}return g.set(z,R),R}const h=/\d\s*[*/^]\s*[\d.(]/;function l($,z){if(F($))return null;let M=String($).trim();if(M===""||M.startsWith("=")||h.test(M))return null;let R=1;M.startsWith("(")&&M.endsWith(")")&&(R=-1,M=M.slice(1,-1));const S=M.endsWith("%"),{group:I,decimal:q}=d(z);if(M=M.replace(/[\s\u00a0\u202f\u2009']/g,""),I&&I!=="."&&I!==","&&(M=M.split(I).join("")),M=M.replace(/[^0-9eE+\-.,]/g,""),q===","?M=M.split(".").join("").replace(",","."):M=M.split(",").join(""),M===""||M==="-"||M==="+")return null;const Z=Number(M);return Number.isNaN(Z)?null:R*(S?Z/100:Z)}function m($,z){const M=F($)||Number.isNaN($)?null:Number($),R=F(z)||Number.isNaN(z)?null:Number(z);return M===null?R===null?0:1:R===null||M<R?-1:M>R?1:0}function w($,z){const M=u($),R=u(z);return M===null?R===null?0:1:R===null?-1:M===R?0:M?1:-1}function k($,z){const M=D($),R=D(z);if(!M)return R?1:0;if(!R)return-1;const S=M.getTime(),I=R.getTime();return S<I?-1:S>I?1:0}const p=new Map;function b($){const z=D($.value);if(!z)return"";const M=$.locale||"";let R=p.get(M);return R||(R=new Intl.DateTimeFormat($.locale||void 0,{dateStyle:"medium"}),p.set(M,R)),R.format(z)}const E={boolean:{base:"boolean",storage:"bitset",matches:$=>typeof $=="boolean",parse:$=>u($.text),compare:w,format:$=>u($.value)===null?"":u($.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:$=>u($)===null?"":String(u($)),fromClipboard:$=>u($)},number:{base:"number",storage:"float64",matches:$=>typeof $=="number"&&!Number.isNaN($),parse:$=>{if(r($.text)){const z=t($.text,$);if(!z.ok)return null;const M=Number(z.value);return Number.isFinite(M)?M:null}return l($.text,$.locale)},compare:m,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:$=>F($)?"":String($),fromClipboard:($,z)=>l($,z&&z.locale)},date:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&c.test($)&&!Number.isNaN(Date.parse($))||$ instanceof Date&&!Number.isNaN($.getTime())&&i($),parse:$=>v($.text),compare:O,format:b,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>v($),toClipboard:$=>F($)?"":String($),fromClipboard:$=>v($)},dateString:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&c.test($)&&!Number.isNaN(Date.parse($)),parse:$=>v($.text),compare:O,format:b,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>v($),toClipboard:$=>F($)?"":String($),fromClipboard:$=>v($)},text:{base:"text",storage:"dictionary",matches:$=>typeof $=="string",parse:$=>$.text===""?null:String($.text),compare:($,z)=>F($)?F(z)?0:1:F(z)?-1:L().compare(String($),String(z)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},image:{base:"text",storage:"dictionary",parse:$=>$.text===""||$.text==null?null:String($.text).trim(),compare:($,z)=>F($)?F(z)?0:1:F(z)?-1:L().compare(String($),String(z)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},lookup:{base:"text",storage:"dictionary",parse:$=>{if($.text===""||$.text==null)return null;const z=$.column&&$.column.lookup,M=z&&X(z.options)?z.options():null;if(!M)return $.text;const R=String($.text),S=M.find(Z=>String(Z.id)===R);if(S)return S.id;const I=R.trim().toLowerCase(),q=M.find(Z=>String(Z.label).toLowerCase()===I);return q?q.id:$.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:$=>F($)?"":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:($,z)=>B($,z),format:$=>{const z=$.value;if(F(z))return"";if(typeof z=="string")return z;try{return JSON.stringify(z)}catch{return String(z)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:$=>F($)?"":typeof $=="string"?$:JSON.stringify($),fromClipboard:$=>$}},T=["boolean","number","date","dateString","datetime","text","object"];function P($,z,M,R){const S=M.get($);if(S)return S;R.includes($)&&H(`circular data type extends chain: ${[...R,$].join(" → ")}`);const I=z[$];I||H(`unknown data type "${$}"`);let q=null;I.extends&&(q=P(I.extends,z,M,[...R,$]));const Z={...q||{},...I,name:$,defaults:{...q&&q.defaults||{},...I.defaults||{}}};return Z.base||(Z.base=q&&q.base||"text"),Z.storage||(Z.storage=q&&q.storage||"object"),M.set($,Z),Z}function x($,z){const M={...E,...s};if(z&&typeof z.dataType=="function"&&typeof z.names=="function")for(const S of z.names("dataType")){const I=z.dataType(S);I&&(M[S]=I)}if(W($))for(const[S,I]of Object.entries($))M[S]=I;const R=new Map;for(const S of T)P(S,M,R,[]);P("lookup",M,R,[]);for(const S of Object.keys(M))P(S,M,R,[]);for(const S of R.values())f(S.operators);return R}function C($,z){if($.base==="text"&&(!$.compare||$.compare===E.text.compare)){const M=L(z);return(R,S)=>F(R)?F(S)?0:1:F(S)?-1:M.compare(String(R),String(S))}return $.compare||B}function A($,z){return z?$.multiStorage||"multi":$.storage||"object"}function j($){return V(String($).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),xe("packages/core/src/columns/infer.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return X}});const Q=G("packages/core/src/internal/util.js"),L=Q.infoOnce,B=Q.isNil,F=100;function W(H,V,K={}){const D=K.sampleSize??F,v=[];for(let O=0;O<H.length&&v.length<D;O++){const y=H[O];B(y)||typeof y=="number"&&Number.isNaN(y)||v.push(y)}if(v.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[O,y]of V){if(typeof y.matches!="function")continue;let u=!0;for(let a=0;a<v.length;a++)if(!y.matches(v[a])){u=!1;break}if(u)return{type:O,unanimous:!0,sampled:v.length}}return K.quiet||L(`infer:${K.colId||"?"}`,`column "${K.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 X(H,V,K,D,v={}){const O=v.sampleSize??F,y=[];for(let u=0;u<V.length&&y.length<O;u++){const a=K(V[u]);B(a)||typeof a=="number"&&Number.isNaN(a)||y.push(a)}return W(y,D,{...v,colId:H}).type}}),xe("packages/core/src/columns/graph.js",function(e,G){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return D}});const Q=G("packages/core/src/internal/util.js"),L=Q.DEV,B=Q.fail,F=Q.isFunction,W=Q.warnOnce,X="*";function H(v){const O=v.value||{};if(!F(O.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const u=O.pure!==!1;return O.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:u}:Array.isArray(O.deps)?{computed:!0,wholeRow:!1,deps:O.deps.slice(),pure:u}:(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:u})}function V(v){const O=new Map;for(const g of v)O.set(g.id,g);const y=new Map,u=new Map,a=new Set,s=new Set,n=new Set,t=new Set;for(const g of v){const d=H(g);if(!d.computed){y.set(g.id,[]);continue}s.add(g.id),(d.pure?n:t).add(g.id),d.wholeRow&&a.add(g.id);const h=[],l=[];for(const m of d.deps)(O.has(m)?h:l).push(m);y.set(g.id,h),l.length&&u.set(g.id,l)}for(const g of n)for(const d of y.get(g))t.has(d)&&B(`pure computed column "${g}" depends on impure column "${d}". Mark it \`value.pure: false\` or make the dependency pure.`);const r=[],o=new Map,f=[],c=g=>{const d=o.get(g);if(d!=="done"){if(d==="open"){const h=f.indexOf(g);B(`circular column dependency: ${[...f.slice(h),g].join(" → ")}`)}o.set(g,"open"),f.push(g);for(const h of y.get(g)||[])O.has(h)&&c(h);f.pop(),o.set(g,"done"),r.push(g)}};for(const g of v)c(g.id);const i=new Map;for(const g of v)i.set(g.id,[]);for(const g of v)for(const d of y.get(g.id)||[]){const h=i.get(d);h&&!h.includes(g.id)&&h.push(g.id)}if(a.size)for(const g of v){if(s.has(g.id))continue;const d=i.get(g.id);for(const h of a)d.includes(h)||d.push(h)}return{order:r,dependents:i,pure:n,impure:t,computed:s,deps:y,wholeRow:a,external:u,index:O}}function K(v,O){const y=Array.isArray(O)?O:[O],u=new Set,a=[...y];for(;a.length;){const s=a.shift();for(const n of v.dependents.get(s)||[])u.has(n)||(u.add(n),a.push(n))}for(const s of y)u.delete(s);return v.order.filter(s=>u.has(s))}function D(v,O,y){if(!L)return v;const u=O instanceof Set?O:new Set(O);return new Proxy(v,{get(a,s){return typeof s=="string"&&!u.has(s)&&!Object.hasOwn(a,s)&&W(`undeclared:${y}:${s}`,`computed column "${y}" read undeclared dependency "${s}". Add it to \`value.deps\` or the value will go stale.`),a[s]}})}}),xe("packages/core/src/model/rowkey.js",function(e,G){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return a}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.pathGetter,F=Q.isFunction,W=Q.isBlank,X=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],H="";function V(s){if(s===null)return"\0n";if(s===void 0)return"\0u";const n=typeof s;if(n==="string")return s;if(n==="number"||n==="bigint"||n==="boolean")return String(s);if(s instanceof Date)return`\0d${s.getTime()}`;try{return`\0o${JSON.stringify(s)}`}catch{return"\0o?"}}function K(s){if(s.length===1)return V(s[0]);let n="";for(let t=0;t<s.length;t++)t&&(n+=H),n+=V(s[t]);return n}function D(s,n={}){const t=n.warn!==!1;if(F(s)){const r=s;return{stable:!0,fields:[],disabled:[],key(o,f){try{const c=r(o);return Array.isArray(c)?K(c):V(c)}catch(c){return L("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",c),`#${f??-1}`}},keyEmpty(o){try{const f=r(o);return Array.isArray(f)?f.length===0||f.some(W):W(f)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(s)&&s.length>0){const r=s.filter(c=>typeof c=="string"),o=r.map(c=>B(c)),f=o.length;return{stable:!0,fields:r,disabled:[],key(c){const i=new Array(f);for(let g=0;g<f;g++)i[g]=o[g](c);return K(i)},keyEmpty(c){for(let i=0;i<f;i++)if(W(o[i](c)))return!0;return!1},missingFields(c){const i=[];for(let g=0;g<f;g++)W(o[g](c))&&i.push(r[g]);return i}}}if(typeof s=="string"&&s.length>0){const r=B(s);return{stable:!0,fields:[s],disabled:[],key(o){return V(r(o))},keyEmpty(o){return W(r(o))},missingFields(o){return W(r(o))?[s]:[]}}}return t&&L("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${X.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:X.slice(),key(r,o){if(r===null||typeof r!="object")return`#${o??0}:${String(r)}`;let f=v.get(r);return f===void 0&&(f=`#${O++}`,v.set(r,f)),f}}}const v=new WeakMap;let O=0;function y(s,n){if(!s||s.stable===!1||!F(s.keyEmpty)||!Array.isArray(n)||n.length===0)return;let t=0,r=null,o;for(let g=0;g<n.length;g++){const d=n[g];s.keyEmpty(d)&&(t++,r===null&&(r=F(s.missingFields)?s.missingFields(d):[],o=d))}if(t===0)return;const f=s.fields.length?s.fields.join(","):"(function)",c=r&&r.length?r.join(", "):s.fields.length?s.fields.join(", "):"the rowKey function",i=o!==null&&typeof o=="object"?Object.keys(o).join(", ")||"(no fields)":String(o);L(`rowKey.emptyValue:${f}`,`rowKey ${c} is missing on ${t} of ${n.length} rows; the first such row has: ${i}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function u(s){return K(s)}function a(s){return s.split(H)}}),xe("packages/core/src/columns/lookup.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return s}});const Q=G("packages/core/src/internal/util.js"),L=Q.collator,B=Q.defaultCompare,F=Q.isFunction,W=Q.isNil,X=Q.warnOnce,V=G("packages/core/src/model/rowkey.js").compositeKey,K=", ",D="";function v(n,t,r,o){if(n===null||typeof n!="object")return{id:n,label:n==null?"":String(n)};const f=n[t],c=n[r],i={id:f,label:c==null?String(f??""):String(c)};n.disabled&&(i.disabled=!0),n.variant&&(i.variant=n.variant),n.icon&&(i.icon=n.icon);const g=o?n[o]:n.group;return g!==void 0&&(i.group=g),i}function O(n,t,r=0,o=[],f=[]){for(const c of n||[]){const i=c&&typeof c=="object"?c[t]:null;if(f.push({raw:c,depth:r,path:o}),Array.isArray(i)&&i.length){const g=String(c&&typeof c=="object"?c.label??c.name??c.id??"":c);O(i,t,r+1,[...o,g],f)}}return f}function y(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&F(n.router&&n.router.subscribe)}class u{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#f=new Map;constructor(t,r={}){this.#e=t||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=L(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??K}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(t){this.#n=t,this.#c=L(t)}#h(t){const r=this.#e,o=r.valueKey||"id",f=r.labelKey||"label",c=r.childrenKey||"children";this.#o=O(t,c).map(i=>{const g=v(i.raw,o,f,r.groupKey);return i.depth&&(g.depth=i.depth,g.path=i.path),g}),this.#i=new Map,this.#s=new Map,this.#o.forEach((i,g)=>{this.#i.set(i.id,i),this.#s.set(i.id,g)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const t=this.#e.options;if(Array.isArray(t)||t===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(y(t))return this.#u=this.#p(t),this.#u;if(!F(t))return X(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let r;try{r=t()}catch(o){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),this.#u=Promise.resolve([]),this.#u}return!r||!F(r.then)?(this.#h(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(o=>(this.#h(o),this.#r&&this.#r(this),this.#o),o=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const r=this.#e,o=r.valueKey||"id",f=r.labelKey||"label",c=r.groupKey,i=F(t.map)?t.map:null,g=h=>v(i?i(h):h,o,f,c).id,d=h=>this.#m(h,i,o,f,c);return t.router.subscribe(t.predicate,d,{rowKey:g}),this.#d=()=>{F(t.router.detach)&&t.router.detach(d)},this.#a="ready",Promise.resolve(this.#o)}#m(t,r,o,f,c){const i=t&&t.add||[],g=t&&t.update||[],d=t&&t.remove||[];if(!(!i.length&&!g.length&&!d.length)){for(const h of i)this.#g(h,r,o,f,c);for(const h of g)this.#g(h,r,o,f,c);for(const h of d){if(!this.#f.has(h))continue;const l=this.#f.get(h);this.#f.delete(h),this.#i.delete(l);const m=this.#o.findIndex(w=>w.id===l);m>=0&&this.#o.splice(m,1)}this.#s=new Map(this.#o.map((h,l)=>[h.id,l])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,r,o,f,c){const i=v(r?r(t):t,o,f,c);this.#f.set(V([i.id]),i.id);const g=this.#o.findIndex(d=>d.id===i.id);g>=0?this.#o[g]=i:this.#o.push(i),this.#i.set(i.id,i)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,r){const o=this.#e;if(!F(o.search)){const i=String(t||"").toLowerCase();return Promise.resolve(i===""?this.#o:this.#o.filter(g=>g.label.toLowerCase().includes(i)))}const f=o.valueKey||"id",c=o.labelKey||"label";return Promise.resolve(o.search(t,r)).then(i=>(i||[]).map(g=>v(g,f,c,o.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(W(t)||t==="")return"";const r=this.#i.get(t);if(r)return r.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||X(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(t)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const o=this.#e.unknownLabel;return F(o)?String(o(t)??""):typeof o=="string"?o:String(t)}text(t){if(this.multiple){const r=a(t);return r.length===0?"":r.map(o=>this.label(o)).join(this.separator)}return this.label(t)}dictionary(){return this.#o.map(t=>t.id)}sorted(){const t=this.sortBy;if(t==="optionOrder"||t==="count")return this.#o.slice();if(t==="value")return this.#o.slice().sort((o,f)=>B(o.id,f.id));const r=this.#c;return this.#o.slice().sort((o,f)=>r.compare(o.label,f.label))}comparator(){const t=this.sortBy,r=this.multiple,o=this.#c,f=this.#s;if(r&&t==="count")return(i,g)=>a(i).length-a(g).length;const c=r?i=>a(i)[0]:i=>i;return t==="value"?(i,g)=>B(c(i),c(g)):t==="optionOrder"?(i,g)=>{const d=f.has(c(i))?f.get(c(i)):Number.MAX_SAFE_INTEGER,h=f.has(c(g))?f.get(c(g)):Number.MAX_SAFE_INTEGER;return d-h}:(i,g)=>{const d=c(i),h=c(g);return W(d)?W(h)?0:1:W(h)?-1:o.compare(this.label(d),this.label(h))}}groupKey(t){return this.multiple?a(t).map(o=>String(o)).sort().join(D):W(t)?"":String(t)}countValues(t){return this.multiple?a(t).length:W(t)?0:1}contains(t,r,o){const f=this.multiple?a(t):W(t)?[]:[t],c=Array.isArray(r)?r:[r];switch(o){case"containsAll":return c.every(i=>f.includes(i));case"containsNone":return!c.some(i=>f.includes(i));default:return c.some(i=>f.includes(i))}}exportText(t,r="label"){return r==="value"?this.multiple?a(t).join(this.separator):W(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:o=>t?a(o).includes(r.id):o===r.id}))}}function a(n){return Array.isArray(n)?n:W(n)||n===""?[]:[n]}function s(n,t={}){const r=n.lookup;if(!r)return null;const o=new u(r,{colId:n.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&o.load(),o}}),xe("packages/core/src/columns/value.js",function(e,G){"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 O}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const Q=G("packages/core/src/internal/util.js"),L=Q.getPath,B=Q.isFunction,F=Q.isNil,W=Q.Lru,X=Q.warnOnce,V=G("packages/core/src/columns/graph.js").depsProxy,K="\0";function D(n,t={}){const r=t.locale,o=t.grid??null,f=t.context,c=n.value&&n.value.format,i=n.formatter||null,g=n.dataType&&n.dataType.format,d=n.lookup||null,h=(l,m,w)=>({value:l,data:w,row:m,column:n,colId:n.id,grid:o,context:f,locale:r});if(B(c))return(l,m,w)=>{const k=c(h(l,m,w));return k==null?"":String(k)};if(i){if(d){const l=i.kind==="text";return(m,w,k)=>i(l?d.text(m):m,h(m,w,k))}return(l,m,w)=>i(l,h(l,m,w))}return B(g)?(l,m,w)=>{const k=g(h(l,m,w));return k==null?"":String(k)}:d?l=>d.text(l):l=>F(l)?"":typeof l=="string"?l:String(l)}function v(n,t){!n||!n.value||n.value.pure!==!1||X(`impure:${t}:${n.id}`,`column "${n.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class O{#e;#t;#n;#r;#o;#i;#s=new W(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(r=>[r.id,r])),this.#t=t.graph,this.#n=t.grid??null,this.#r=t.context,this.#i=t.stored||null,this.#o=t.rowKey||y}get graph(){return this.#t}setGraph(t){this.#t=t,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(t){if(this.#s.size===0)return;const r=t&&t.rows?new Set([...t.rows].map(String)):null,o=t&&t.columns?[...t.columns]:null;if(!r&&!o){this.#s.clear();return}const f=o?this.#l(o):null;for(const c of[...this.#s.keys()]){const i=String(c).split(K);i.length===3&&(r&&!r.has(i[0])||f&&!f.has(i[2])||this.#s.delete(c))}}#l(t){const r=new Set,o=this.#t,f=[...t];for(;f.length;){const c=f.pop();if(!r.has(c)){r.add(c);for(const i of o?o.dependents.get(c)||[]:[])f.push(i)}}return r}value(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return;if(!f.computed)return this.#u(f,r,o);if(f.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(f.id))return this.#i.get(f.id,o.physical);if(f.volatile)return this.compute(f,r,o);if(f.value.pure===!1)return this.compute(f,r,o);const c=`${this.#a(r,o)}${K}${f.id}`;if(this.#s.has(c))return this.#s.get(c);const i=this.compute(f,r,o);return this.#s.set(c,i),i}#a(t,r){return`${this.#o(t,r)}${K}${u(t)}`}#u(t,r,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,o.physical);if(t.field)return t.read?t.read(r):L(r,t.field)}compute(t,r,o){const f=this.#t,c=f&&f.wholeRow.has(t.id);let i;if(c)i=r??{};else{i={};const d=f&&f.deps.get(t.id)||[];for(const l of d)i[l]=this.value(l,r,o);const h=f&&f.external.get(t.id)||[];for(const l of h)i[l]=L(r,l);i=V(i,[...d,...h],t.id)}const g={data:r,row:o,column:t,grid:this.#n,context:this.#r};return t.value.compute(i,g)}values(t,r){const o={},f=this.#t?this.#t.order:[...this.#e.keys()];for(const c of f)o[c]=this.value(c,t,r);return o}text(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;return f?f.formatValue(this.value(f,r,o),o,r):""}key(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";const c=this.value(f,r,o);return B(f.value.key)?String(f.value.key(this.#c(f,c,r,o))):f.lookup?f.lookup.groupKey(c):F(c)?"":String(c)}quickFilterText(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";if(B(f.value.quickFilterText)){const c=this.value(f,r,o);return String(f.value.quickFilterText(this.#c(f,c,r,o))??"")}return this.text(f,r,o)}#c(t,r,o,f){return{value:r,data:o,row:f,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,r,o,f){const c=typeof t=="string"?this.#e.get(t):t;if(!c)return r;const i={text:r,value:this.value(c,o,f),data:o,row:f,column:c,grid:this.#n,context:this.#r,locale:this.#n&&B(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&B(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return B(c.value.parse)?c.value.parse(i):c.dataType&&B(c.dataType.parse)?c.dataType.parse(i):r}validate(t,r,o,f,c){const i=typeof t=="string"?this.#e.get(t):t;if(!i||!B(i.edit.validate))return!0;const g=i.edit.validate({value:r,oldValue:o,data:f,row:c,column:i,grid:this.#n,context:this.#r});return g===!0||g===void 0?!0:String(g)}apply(t,r,o,f){const c=typeof t=="string"?this.#e.get(t):t;if(!c)return!1;const i=this.value(c,o,f);if(B(c.value.apply)){const g=c.value.apply({value:r,oldValue:i,data:o,row:f,column:c,grid:this.#n,context:this.#r});return this.#d(c,o,f),g!==!1}return c.field?i===r?!1:(c.write(o,r),this.#d(c,o,f),!0):(X(`apply:${c.id}`,`column "${c.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,r,o,f){const c=typeof t=="string"?this.#e.get(t):t;if(!c)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const i=this.value(c,o,f),g=this.parse(c,r,o,f),d=this.validate(c,g,i,o,f);if(d!==!0)return{ok:!1,value:g,oldValue:i,changed:!1,error:d};const h=this.apply(c,g,o,f);return{ok:!0,value:g,oldValue:i,changed:h}}#d(t,r,o){if(this.#s.size===0)return;const f=this.#a(r,o);this.#s.delete(`${f}${K}${t.id}`);for(const c of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${f}${K}${c}`)}}function y(n,t){return t&&t.key!=null?String(t.key):u(n)}function u(n){if(n&&typeof n=="object"){let t=a.get(n);return t===void 0&&(t=`#${s++}`,a.set(n,t)),t}return String(n)}const a=new WeakMap;let s=0}),xe("packages/core/src/model/shadow.js",function(e,G){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const L=G("packages/core/src/internal/util.js").warnOnce,B=2e5,F=20,W=1e3,X=50;function H(g){return Math.min(W,Math.max(X,Math.floor(g)))}const V=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),K=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,O=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),a=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 s(g,d){if(!d)return null;const h=Number.isFinite(Number(d.lower))?Number(d.lower):null,l=Number.isFinite(Number(d.upper))?Number(d.upper):null;if(h===null&&l===null||!Number.isFinite(g))return null;if(h!==null&&g<h||l!==null&&g>l)return y.FAIL;const m=Number.isFinite(Number(d.warnLower))?Number(d.warnLower):null,w=Number.isFinite(Number(d.warnUpper))?Number(d.warnUpper):null;return m!==null&&g<m||w!==null&&g>w?y.WARN:y.PASS}function n(g,d,h){if(!d||typeof d!="object")return null;if(d.kind!=="time")return d.kind!==void 0&&L(`shadow.history.window.kind:${g}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${d.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 l=d.minutes!=null?Number(d.minutes)*6e4:Number(d.span);if(!(l>0))return L(`shadow.history.window.span:${g}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const m=Math.max(2,Math.floor(h)||F);return{span:l,bucketMs:Math.max(1,Math.floor(l/m))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#f=new Map;#h=null;#p=null;#m=null;constructor(d){this.#e=d.colId,this.#a=Math.max(2,d.depth||F),this.#u=Math.max(1,d.max||B),this.#c=d.now||(()=>Date.now()),this.#d=n(this.#e,d.historyWindow,this.#a),this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(d,h){const l=c(h);if(l===null)return;if(!this.#n.has(d)){this.#p=null,this.#m=null,this.#g(),this.#t.set(d,l),this.#n.set(d,l),this.#r.set(d,0),this.#o.set(d,this.#c()),this.#i.set(d,[l]),this.#d&&this.#f.set(d,[l]),this.#s.set(d,0);return}const m=this.#n.get(d);if(m===l)return;this.#p=null,this.#m=null,this.#n.set(d,l),this.#r.set(d,(this.#r.get(d)||0)+1),this.#o.set(d,this.#c());const w=this.#i.get(d)||[];w.push(l),w.length>this.#a&&w.splice(0,w.length-this.#a),this.#i.set(d,w);const k=Math.sign(l-m),p=this.#s.get(d)||0;this.#s.set(d,Math.sign(p)===k?p+k:k)}#g(){if(this.#n.size<this.#u)return;const d=this.#n.keys().next().value;d!==void 0&&(this.#t.delete(d),this.#n.delete(d),this.#r.delete(d),this.#o.delete(d),this.#i.delete(d),this.#f.delete(d),this.#s.delete(d),this.#l++)}rebase(){for(const[d,h]of this.#n)this.#t.set(d,h);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#f.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}retain(d){const h=d instanceof Set?d:new Set(d);let l=0;for(const m of[...this.#n.keys()])h.has(m)||(this.#t.delete(m),this.#n.delete(m),this.#r.delete(m),this.#o.delete(m),this.#i.delete(m),this.#f.delete(m),this.#s.delete(m),l++);return l&&(this.#p=null,this.#m=null),l}advanceHistoryWindow(d=this.#c()){const h=this.#d;if(!h)return 0;const l=Math.floor(d/h.bucketMs),m=l-this.#h;if(!(m>0))return 0;const w=Math.min(m,this.#a);for(const[k,p]of this.#f){const b=this.#n.get(k);for(let E=0;E<w;E++)p.push(b);p.length>this.#a&&p.splice(0,p.length-this.#a)}return this.#h=l,m}read(d,h,l,m){switch(d){case"updates":return this.#r.has(h)?this.#r.get(h):0;case"updatedAt":{const w=this.#o.get(h);return w===void 0?null:new Date(w)}case"sinceUpdate":{const w=this.#o.get(h);return w===void 0?null:this.#c()-w}case"firstValue":return this.#t.has(h)?this.#t.get(h):null;case"delta":return this.#n.has(h)?this.#n.get(h)-this.#t.get(h):null;case"deltaPercent":{if(!this.#n.has(h))return null;const w=this.#t.get(h);return w?(this.#n.get(h)-w)/Math.abs(w)*100:null}case"rate":{const w=this.#i.get(h),k=this.#o.get(h);if(!w||w.length<2||k===void 0)return null;const p=this.#c()-k,b=w[w.length-1]-w[w.length-2];return p>0?b/p*1e3:b}case"history":return this.#d?this.#f.has(h)?[...this.#f.get(h)]:null:this.#i.has(h)?[...this.#i.get(h)]:null;case"streak":return this.#s.has(h)?this.#s.get(h):0;case"specStatus":return this.#n.has(h)?s(this.#n.get(h),m):null;default:return u.includes(d)?this.#k(d,h,l,m):null}}#y(d){if(d){if(this.#m&&this.#m.only===d)return this.#m.view;const h=this.#w(d);return this.#m={only:d,view:h},h}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(d){const h=[];for(const[x,C]of this.#n)d&&!d.has(x)||h.push(C);const l=h.sort((x,C)=>x-C);let m=0,w=0,k=0,p=0;for(const x of l){p+=x,m++;const C=x-w;w+=C/m,k+=C*(x-w)}const b=[];for(const[x,C]of this.#t)d&&!d.has(x)||b.push(C);const E=m?r(l):0,T=l.map(x=>Math.abs(x-E)).sort((x,C)=>x-C),P=m?r(T):0;return{sorted:l,baseline:b.sort((x,C)=>x-C),sum:p,mean:m?w:0,sd:m>1?Math.sqrt(k/(m-1)):0,median:E,mad:P}}#k(d,h,l,m){if(!this.#n.has(h)||l&&!l.has(h))return null;const w=this.#n.get(h),k=this.#y(l),p=k.sorted.length;if(!p)return null;switch(d){case"rank":return p-f(k.sorted,w)+1;case"rankAsc":return o(k.sorted,w)+1;case"rankChange":{if(!this.#t.has(h)||!k.baseline.length)return null;const b=k.baseline.length-f(k.baseline,this.#t.get(h))+1,E=p-f(k.sorted,w)+1;return b-E}case"percentile":return f(k.sorted,w)/p*100;case"quartile":{const b=f(k.sorted,w)/p;return Math.min(4,Math.max(1,Math.ceil(b*4)))}case"zScore":return k.sd?(w-k.mean)/k.sd:null;case"anomalyScore":return k.mad?v*(w-k.median)/k.mad:null;case"anomalyFlag":{if(!k.mad)return null;const b=m&&Number.isFinite(Number(m.threshold))?Number(m.threshold):O;return Math.abs(v*(w-k.median)/k.mad)>b}case"shareOfTotal":return k.sum?w/k.sum*100:null;default:return null}}}function r(g){const d=g.length;if(!d)return 0;const h=(d-1)*.5,l=Math.floor(h),m=Math.ceil(h);return l===m?g[l]:g[l]+(h-l)*(g[m]-g[l])}function o(g,d){let h=0,l=g.length;for(;h<l;){const m=h+l>>1;g[m]<d?h=m+1:l=m}return h}function f(g,d){let h=0,l=g.length;for(;h<l;){const m=h+l>>1;g[m]<=d?h=m+1:l=m}return h}function c(g){if(g==null||g==="")return null;if(g instanceof Date){const h=g.getTime();return Number.isFinite(h)?h:null}const d=typeof g=="number"?g:Number(g);return Number.isFinite(d)?d:null}function i(g){const d=[];for(const h of g||[]){const l=h.shadow;if(!l)continue;const m=typeof l=="string"?{kind:l}:l,w=m.kind;V.includes(w)&&(K.includes(w)||D.includes(w)||d.push({colId:h.id||h.field,of:m.of||h.field||h.id,kind:w,depth:m.depth,historyWindow:w==="history"?m.window:void 0}))}return d}}),xe("packages/core/src/columns/model.js",function(e,G){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ne}});const Q=G("packages/core/src/internal/util.js"),L=Q.expand,B=Q.fail,F=Q.getPath,W=Q.humanise,X=Q.isFunction,H=Q.isObject,V=Q.merge,K=Q.pathGetter,D=Q.pathSetter,v=Q.toArray,O=Q.uid,y=Q.warnOnce,a=G("packages/core/src/format/index.js").compileFormat,s=G("packages/core/src/columns/datatypes.js"),n=s.comparatorFor,t=s.createTypeRegistry,r=s.storageKind,o=G("packages/core/src/columns/infer.js"),f=o.inferColumnType,c=o.DEFAULT_SAMPLE,i=G("packages/core/src/columns/graph.js"),g=i.buildGraph,d=i.affectedBy,l=G("packages/core/src/columns/lookup.js").createLookup,m=G("packages/core/src/columns/value.js"),w=m.compileDisplay,k=m.ValuePipeline,p=m.warnImpureUse,E=G("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,T=Object.freeze({geometry:"geometry",list:"list"}),P={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},x={centre:"center"},C=new Set(["start","center","end","left","right"]);function A(de){if(typeof de!="string")return;const ie=de.toLowerCase();return x[ie]?x[ie]:C.has(ie)?ie:void 0}function j(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 z(de){if(!H(de))return{};const ie={...de},oe=(ce,fe)=>{if(de[ce]===void 0)return;const ke=L(de[ce],fe);ke&&$.includes(ce)&&!H(de[ce])&&delete ke.enabled,ie[ce]=ke};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 M(de,ie){const oe={...de||{}},ce=H(ie)&&H(ie.layout)&&ie.layout.width!==void 0;return oe.fit==="content"&&!ce&&delete oe.width,oe}const R=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","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"]),S=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function I(de,ie,oe,ce){const fe=oe==="columnGroup"?"column group":"column";for(const ke of Object.keys(de))ie.has(ke)||y(`${oe}.unknown:${ke}`,`'${ke}' is not a configuration key this grid recognises, so it had no effect on ${fe} "${ce}". Check the spelling against the reference.`)}function q(de,ie){const oe=ie&&X(de.defaultsFor)?de.defaultsFor(ie):null,ce={...de.defaults||{},...H(oe)?oe:{}},fe={};return ce.align&&(fe.align=ce.align,fe.cell={align:ce.align},fe.header={align:ce.align}),ce.filter&&(fe.filter=ce.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ce.filter}),ce.editor&&(fe.edit=ce.editor==="none"?{editor:null}:{editor:ce.editor}),ce.total&&(fe.total=ce.total),ce.render&&(fe.cell={...fe.cell||{},render:ce.render}),de.export&&(fe.export={...de.export}),fe}function Z(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 ce=oe.trim();ce&&!ie.includes(ce)&&ie.push(ce)}return ie}class _{#e=new Map;#t=[];#n=[];#r;#o;#i;#s;#l;#a;#u(ie,oe,ce){const fe=this.#c(ie,oe,ce);if(typeof fe!="string"||!this.#d)return fe??null;const ke=oe&&oe.totals&&oe.totals.implement;if(ke&&X(ke[fe])){const Ee=ke[fe];return Ee.totalName=fe,Ee}const Re=this.#d.totalFn?.(fe);return X(Re)?Re:fe}#c(ie,oe,ce){if(typeof ie!="string")return ie;const fe=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(fe)||fe.includes(ie))return ie;const ke=fe.length?fe.join(", "):"none";return B(`column "${ce}" is typed ${oe.name||"a type"}, for which the total "${ie}" is not meaningful. Supported: ${ke}. Aggregating it anyway would produce a confident wrong number.`),ie}#d;#f;#h;#p;#m;#g;#y=!1;#w;#k;constructor(ie={}){this.#o=z(ie.columnDefaults||{}),this.#i=ie.columnPresets||{},this.#l=ie.locale,this.#s=ie.timeZone,this.#a=j(ie.verticalAlign),this.#d=ie.registry||null,this.#f=ie.grid||null,this.#h=ie.context,this.#w=ie.sampleSize??c,this.#k=ie.onChange||null,this.#g=X(ie.rowKey)?ie.rowKey:void 0,this.#r=t(ie.dataTypes,this.#d);const{leaves:oe,groups:ce}=ne(ie.columns||[]);this.#n=ce;for(const fe of oe){const ke=this.#b(fe.def,null);if(ke.groupPath=fe.path,this.#e.has(ke.id)){y(`columns.duplicate:${ke.id}`,`two columns resolve to the id '${ke.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}fe.column=ke,this.#e.set(ke.id,ke),this.#t.push(ke.id)}this.#S(ie.stored||null)}#b(ie,oe){I(ie,R,"column",ie.id||ie.field||"(unnamed)");const ce=z(ie),fe=v(ie.preset),ke=fe.map(Qe=>{const Te=this.#i[Qe];return Te?z(Te):(y(`preset:${Qe}`,`unknown column preset "${Qe}"; ignoring`),{})}),Re=this.#P(ce,ke,oe),Ee=this.#r.get(Re)||this.#r.get("text");if(!this.#r.has(Re)&&ie.type){const Qe=T[Re];y(`type:${Re}`,`unknown data type "${Re}"; falling back to "text"`+(Qe?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Qe}'.`:""))}const Fe=X(Ee.items)?this.#j(ce,ke,ie.id||ie.field||"(unnamed)"):null;let ye=P;ye=V(ye,this.#o),ie.type!==!1&&(ye=V(ye,q(Ee,Fe)));for(const Qe of ke)ye=V(ye,Qe);ye=V(ye,ce);const he=ye.edit;he&&he.editor&&he.enabled!==!0&&!X(he.enabled)&&(ie.edit||{}).editor&&y(`column.editor-not-enabled:${ie.id||ie.field}`,`column '${ie.id||ie.field}' names the editor '${he.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Se=ie.id||ie.field||O("col");if(ie.shadow&&!X(ye.value&&ye.value.compute)){const Qe=typeof ie.shadow=="string"?{kind:ie.shadow}:ie.shadow,Te=Qe.of||ie.field||Se,_e=E.includes(Qe.kind),Ke=_e?Qe.model||Qe:null,tt=_e&&Ke?[...Array.isArray(Ke.predictors)?Ke.predictors:[],Ke.response].filter(Boolean):null;ye.value={...ye.value||{},deps:tt&&tt.length?tt:Qe.orderBy&&Qe.orderBy!==Te?[Te,Qe.orderBy]:[Te],pure:!1,compute:(it,ht)=>{const yt=ht.grid&&ht.grid.statistics;if(!yt)return null;const St=ht.row&&ht.row.key||yt.keyOf(ht.data);if(!St)return null;if(_e){if(!X(yt.fitShadow))return null;const At=Qe.model?{...Qe.model,threshold:Qe.threshold}:Qe;return yt.fitShadow(Qe.kind,St,At)}return yt.shadow(Te,Qe.kind,St,Qe.scope,Qe)}}}if(ie.running&&!X(ye.value&&ye.value.compute)){const Qe=typeof ie.running=="string"?{kind:ie.running}:ie.running,Te=Qe.of||ie.field||Se;ye.value={...ye.value||{},deps:[Te],pure:!1,compute:(_e,Ke)=>{const tt=Ke.grid&&Ke.grid.statistics;if(!tt||!X(tt.running))return null;const it=Ke.row&&Ke.row.key||tt.keyOf(Ke.data);return it?tt.running(Te,Qe.kind||"total",it):null}},ie.sort===void 0&&(ye.sort={...ye.sort||{},enabled:!1})}const Ce=ie.field??(X(ye.value&&ye.value.compute)?null:ie.id??null),Ie=X(ye.value&&ye.value.compute),ze={id:Se,field:Ce,shadow:ie.shadow||null,running:ie.running||null,spec:ie.spec||null,validation:ie.validation||null,volatile:!!(ie.shadow||ie.running),title:ye.title??W(Ce||Se),type:Ee.name,dataType:Ee,itemType:Fe,nullable:ye.nullable!==!1,align:A(ce.cell&&ce.cell.align||ce.align||ye.cell&&ye.cell.align||ye.align||Ee.defaults&&Ee.defaults.align)||"start",verticalAlign:j(ce.cell&&ce.cell.verticalAlign||ce.verticalAlign||ye.cell&&ye.cell.verticalAlign||ye.verticalAlign)||this.#a,rowSpan:X(ye.rowSpan)?ye.rowSpan:null,colSpan:X(ye.colSpan)?ye.colSpan:null,value:{pure:!0,...ye.value||{}},cell:{...ye.cell||{}},edit:{...ye.edit||{}},sort:{...ye.sort||{}},filter:{...ye.filter||{}},group:{enabled:!1,index:-1,explode:!1,...ye.group||{}},pivot:{enabled:!1,index:-1,...ye.pivot||{}},total:this.#u(ye.total,Ee,ie.id||ie.field||"(unnamed)"),groupTotal:ye.groupTotal===void 0?null:this.#u(ye.groupTotal,Ee,ie.id||ie.field||"(unnamed)"),grandTotal:ye.grandTotal===void 0?null:this.#u(ye.grandTotal,Ee,ie.id||ie.field||"(unnamed)"),tags:Z(ye.tags),typeOptions:ye.typeOptions??null,...H(ye[Re])?{[Re]:ye[Re]}:{},layout:M(ye.layout,ce),header:{...ye.header||{}},contextMenu:ye.contextMenu===void 0?null:ye.contextMenu,facet:{...ye.facet||{}},export:{...ye.export||{}},allowGroup:ye.allowGroup!==!1,allowPivot:ye.allowPivot!==!1,allowTotal:ye.allowTotal!==!1,quickFilter:ye.quickFilter!==!1,def:ie,format:ye.format,presets:fe,inferred:oe!=null&&!ie.type,computed:Ie,diff:ie.diff===void 0?void 0:!!ie.diff,read:Ce?K(Ce):null,write:Ce?D(Ce):null};ze.cell.align=A(ce.cell&&ce.cell.align)||ze.align,ze.header.align=A(ce.header&&ce.header.align)||ze.align;const Ye=ye.lookup||null;return ze.lookup=Ye?l({id:Se,lookup:Ye},{locale:this.#l,onChange:()=>{this.#k&&this.#k("lookup",{colId:Se})}}):null,ze.group.explode&&ze.lookup&&ze.lookup.multiple&&y(`explode:${Se}`,`column "${Se}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#O(ze),ze}#O(ie){ie.formatter=a(ie.format,ie.dataType,this.#l,this.#s,ie.id),ie.formatValue=w(ie,{locale:this.#l,grid:this.#f,context:this.#h}),ie.itemCompare=ie.itemType?n(ie.itemType,this.#l):null,ie.compare=X(ie.value.compare)?ie.value.compare:ie.lookup?ie.lookup.comparator():X(ie.dataType.compareFor)?ie.dataType.compareFor(ie):n(ie.dataType,this.#l),ie.excel=ie.formatter&&ie.formatter.ooxml||ie.dataType&&ie.dataType.excel||"General",ie.storeKind=r(ie.dataType,!!(ie.lookup&&ie.lookup.multiple))}#j(ie,oe,ce){let fe=H(ie.typeOptions)?ie.typeOptions:null;for(let Fe=oe.length-1;!fe&&Fe>=0;Fe--)H(oe[Fe].typeOptions)&&(fe=oe[Fe].typeOptions);!fe&&H(this.#o.typeOptions)&&(fe=this.#o.typeOptions);const ke=fe&&fe.of!==void 0?fe.of:"text",Re=typeof ke=="string"?this.#r.get(ke):void 0;return Re&&!X(Re.items)&&Re.storage!=="object"?Re:(y(`type:of:${String(ke)}`,`column "${ce}" names "${String(ke)}" as its item type (typeOptions.of), which is not ${Re?"a scalar data type":"a known data type"}; its items are read as text.`),this.#r.get("text"))}#P(ie,oe,ce){if(ie.type===!1)return"text";if(ie.type)return ie.type;for(let fe=oe.length-1;fe>=0;fe--)if(oe[fe].type)return oe[fe].type;if(this.#o.type)return this.#o.type;if(ie.shadow){const fe=typeof ie.shadow=="string"?ie.shadow:ie.shadow.kind;if(fe==="fitInfluence")return"boolean";if(fe==="fitPredicted"||fe==="fitResidual"||fe==="fitStdResidual"||fe==="fitLeverage"||fe==="fitCooksD"||fe==="tsTrend"||fe==="tsSeasonal"||fe==="tsResidual"||fe==="tsCoverage"||fe==="tsSmoothed"||fe==="tsSmoothingAlpha"||fe==="tsSmoothingBeta")return"number"}return ce||(ie.lookup?"lookup":"text")}#S(ie){const oe=this.all();this.#p=g(oe),this.#m?this.#m.setGraph(this.#p):this.#m=new k({columns:this.#e,graph:this.#p,grid:this.#f,context:this.#h,stored:ie||null,rowKey:this.#g});const ce=this.#m;for(const fe of oe)fe.getValue=(ke,Re)=>ce.value(fe,ke,Re)}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 ce=[];for(const fe of oe)Array.isArray(fe.columns)?ce.push({...fe,columns:ie(fe.columns)}):fe.column&&ce.push(fe.column);return ce};return ie(this.#n)}graph(){return this.#p}pipeline(){return this.#m}types(){return this.#r}affectedBy(ie){return d(this.#p,ie)}value(ie,oe,ce){return this.#m.value(ie,oe,ce)}text(ie,oe,ce){return this.#m.text(ie,oe,ce)}checkImpure(ie,oe){p(this.#e.get(ie),oe)}setLocale(ie){this.#l=ie;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(ie),this.#O(oe);this.#k&&this.#k("locale",{locale:ie})}infer(ie){const oe={};if(this.#y||!Array.isArray(ie)||ie.length===0)return oe;this.#y=!0;let ce=!1;for(const fe of this.all()){const ke=fe.def;if(ke.type!==void 0||!fe.field||fe.computed||fe.lookup||this.#M(fe))continue;const Re=fe.read||(ye=>F(ye,fe.field)),Ee=f(fe.id,ie,Re,this.#r,{sampleSize:this.#w});if(Ee===fe.type)continue;oe[fe.id]=Ee;const Fe=this.#b(ke,Ee);Fe.groupPath=fe.groupPath,Fe.layout={...Fe.layout,...J(fe.layout)},this.#e.set(fe.id,Fe),ae(this.#n,fe.id,Fe),ce=!0}return ce&&this.#S(null),oe}redecorate(ie,oe,ce={}){const fe=this.#e.get(ie);if(!fe){y(`redecorate:${ie}`,`columns.decorate('${ie}', …): no column with id '${ie}'.`);return}const ke=fe.def||{},Re={...H(ke.cell)?ke.cell:{}};Re.decoration=oe??void 0,ce&&"variant"in ce&&(Re.variant=ce.variant);const Ee={...ke,cell:Re},Fe=this.#b(Ee,fe.type);return Fe.groupPath=fe.groupPath,Fe.layout={...Fe.layout,...J(fe.layout)},fe.lookup&&fe.lookup!==Fe.lookup&&X(fe.lookup.destroy)&&fe.lookup.destroy(),this.#e.set(ie,Fe),ae(this.#n,ie,Fe),this.#S(null),this.#k&&this.#k("decorate",{colId:ie}),Fe}destroy(){for(const ie of this.#e.values())ie.lookup&&X(ie.lookup.destroy)&&ie.lookup.destroy()}#M(ie){for(const oe of ie.presets){const ce=this.#i[oe];if(ce&&ce.type)return!0}return!!this.#o.type}#A(ie){return!ie.computed&&X(ie.dataType&&ie.dataType.toStorage)}storeReader(ie){if(ie.computed)return oe=>this.#m.value(ie,oe,null);if(this.#A(ie)){const oe=ie.dataType.toStorage,ce={timeZone:ie.timeZone||this.#s,colId:ie.id,itemType:ie.itemType||null};return fe=>oe(ie.read(fe),ce)}return ie.read}storeValue(ie,oe){if(!(!ie||ie.computed)&&X(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 ce=this.storeReader(oe);let fe=null;!oe.computed&&!this.#A(oe)&&typeof oe.field=="string"&&!oe.lookup&&(fe=oe.field);const ke={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:ce};fe!==null&&(ke.field=fe),oe.lookup&&(ke.dictionary=oe.lookup.dictionary()),ie.push(ke)}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?ee(ie.cell.decoration):void 0,variant:ie.cell&&ie.cell.variant!=null?ee(ie.cell.variant):void 0}))}applyState(ie,oe={}){const ce={applied:[],skipped:[]},fe=Array.isArray(ie)?ie:ie&&ie.columns||[],ke=!Array.isArray(ie)&&ie&&ie.columnOrder||null;for(const Ee of fe){if(!Ee||!Ee.id){ce.skipped.push({key:"?",reason:"no id"});continue}let Fe=this.#e.get(Ee.id);if(!Fe){ce.skipped.push({key:Ee.id,reason:"unknown column"});continue}if(Object.hasOwn(Ee,"decoration")||Object.hasOwn(Ee,"variant")){const ye=Fe.cell?Fe.cell.decoration:void 0,he=Ee.decoration??null,Se=Object.hasOwn(Ee,"variant"),Ce=Se&&!te(Fe.cell?Fe.cell.variant:void 0,Ee.variant);(!te(ye,he)||Ce)&&(this.redecorate(Ee.id,he,Se?{variant:Ee.variant??void 0}:{}),Fe=this.#e.get(Ee.id)||Fe)}Ee.width!=null&&(Fe.layout.width=Ee.width),Ee.flex!=null&&(Fe.layout.flex=Ee.flex),Ee.hidden!=null&&(Fe.layout.hidden=!!Ee.hidden),Ee.pin!==void 0&&(Fe.layout.pin=Ee.pin),Ee.sort!==void 0&&(Fe.sort.direction=Ee.sort),Ee.sortIndex!=null&&(Fe.sort.order=Ee.sortIndex),Ee.groupIndex!=null&&(Fe.group.enabled=!0,Fe.group.index=Ee.groupIndex),Ee.pivotIndex!=null&&(Fe.pivot.enabled=!0,Fe.pivot.index=Ee.pivotIndex),Ee.total!==void 0&&(Fe.total=Ee.total),Ee.groupTotal!==void 0&&(Fe.groupTotal=Ee.groupTotal),Ee.grandTotal!==void 0&&(Fe.grandTotal=Ee.grandTotal),ce.applied.push(Ee.id)}const Re=ke||(oe&&oe.keepOrder?[]:fe.map(Ee=>Ee&&Ee.id).filter(Boolean));if(Re.length){const Ee=Re.filter(ye=>this.#e.has(ye)),Fe=this.#t.filter(ye=>!Ee.includes(ye));this.#t=[...Ee,...Fe]}return this.#k&&this.#k("state",ce),ce}move(ie,oe){this.#E(ie,oe)&&(this.#L(),this.#k&&this.#k("move",{id:ie,to:oe}))}reorder(ie){const oe={applied:[],skipped:[]},ce=[];let fe=0;for(const ke of Array.isArray(ie)?ie:[]){const Re=fe++;this.#E(ke,Re)&&(oe.applied.push(ke),ce.push({id:ke,to:Re}))}if(!ce.length)return oe;if(this.#L(),this.#k)for(const ke of ce)this.#k("move",ke);return oe}#E(ie,oe){const ce=this.#t.indexOf(ie);if(ce===-1||Math.max(0,Math.min(Number(oe)||0,this.#t.length-1))===ce)return!1;const ke=this.#e.get(ie);if(ke.layout.movable===!1||ke.layout.lockPosition)return y(`move:${ie}`,`column "${ie}" is not movable; the move was ignored`),!1;const Re=this.#R(ie,oe);return Re?(y(`move.married:${Re}`,`band "${Re}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(ce,1),this.#t.splice(Math.max(0,Math.min(oe,this.#t.length)),0,ie),!0)}#R(ie,oe){if(!this.#n||!this.#n.length)return null;const ce=this.#t.filter(Ee=>Ee!==ie),fe=Math.max(0,Math.min(oe,ce.length)),ke=(Ee,Fe)=>{if(Array.isArray(Ee.columns)){for(const he of Ee.columns)ke(he,Fe);return Fe}const ye=Ee.column?Ee.column.id:Ee.id;return ye&&Fe.push(ye),Fe},Re=Ee=>{for(const Fe of Ee){if(!Array.isArray(Fe.columns))continue;if(Fe.marryChildren===!0){const he=ke(Fe,[]),Se=he.includes(ie),Ce=he.map(Ie=>ce.indexOf(Ie)).filter(Ie=>Ie>=0);if(Ce.length){const Ie=Math.min(...Ce),ze=Math.max(...Ce);if(Se?fe<Ie||fe>ze+1:fe>Ie&&fe<=ze)return Fe.id}}const ye=Re(Fe.columns);if(ye)return ye}return null};return Re(this.#n)}#L(){const ie=new Map(this.#t.map((fe,ke)=>[fe,ke])),oe=fe=>{if(!Array.isArray(fe.columns)){const Re=fe.column?fe.column.id:fe.id;return ie.has(Re)?ie.get(Re):1/0}let ke=1/0;for(const Re of fe.columns)ke=Math.min(ke,oe(Re));return ke},ce=fe=>{fe.sort((ke,Re)=>oe(ke)-oe(Re));for(const ke of fe)Array.isArray(ke.columns)&&ce(ke.columns)};ce(this.#n)}#x(ie){const oe=ce=>{for(let fe=0;fe<ce.length;fe++){const ke=ce[fe];if(Array.isArray(ke.columns)){const Re=oe(ke.columns);if(Re)return Re}else if(ke.column&&ke.column.id===ie)return ce.splice(fe,1)[0]}return null};return oe(this.#n)}#I(ie){const oe=[];for(let ce=ie.length-1;ce>=0;ce--){const fe=ie[ce];Array.isArray(fe.columns)&&(oe.push(...this.#I(fe.columns)),fe.columns.length===0&&(oe.push(fe.id),ie.splice(ce,1)))}return oe}#z(){const ie=(oe,ce)=>{for(const fe of oe)Array.isArray(fe.columns)?ie(fe.columns,[...ce,fe.id]):fe.column&&(fe.column.groupPath=ce)};ie(this.#n,[])}#$(ie){const oe=new Set(ie),ce=this.#t.filter(Ee=>oe.has(Ee));if(!ce.length)return;const fe=Math.min(...ce.map(Ee=>this.#t.indexOf(Ee))),ke=this.#t.slice(0,fe).filter(Ee=>!oe.has(Ee)),Re=this.#t.slice(fe).filter(Ee=>!oe.has(Ee));this.#t=[...ke,...ce,...Re]}#N(ie){const oe=[],ce=fe=>{if(Array.isArray(fe.columns))for(const ke of fe.columns)ce(ke);else fe.column&&oe.push(fe.column.id)};return ce(ie),oe}#H(ie){const oe=ce=>{for(const fe of ce){if(!Array.isArray(fe.columns))continue;if(fe.id===ie)return{node:fe,parent:ce};const ke=oe(fe.columns);if(ke)return ke}return null};return oe(this.#n)}groupColumns(ie,oe={}){const ce=v(ie).filter(Fe=>this.#e.has(Fe));if(!ce.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Fe of ce)if(this.#e.get(Fe).layout.lockPosition)return y(`columns.group.locked:${Fe}`,`column "${Fe}" is position-locked and cannot be grouped.`),null;const fe=oe.groupId?this.#H(oe.groupId):null;if(oe.groupId&&!fe)return y(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let ke=null;if(!fe&&oe.id!=null&&(ke=String(oe.id),this.#H(ke)||this.#e.has(ke)))return y(`columns.group.idtaken:${ke}`,`band id "${ke}" is already in use; nothing was grouped.`),null;const Re=ce.map(Fe=>this.#x(Fe)).filter(Boolean);if(!Re.length)return null;let Ee;if(fe)fe.node.columns.push(...Re),Ee=fe.node.id;else{const Fe={id:ke||O("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Re},ye=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(ye,0,Fe),Ee=Fe.id}return this.#I(this.#n),this.#$(ce),this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"formed",groupId:Ee,ids:ce}),Ee}ungroupColumn(ie){const oe=this.#e.get(ie);if(!oe){y(`columns.ungroup.unknown:${ie}`,`no column "${ie}" to ungroup.`);return}const ce=oe.groupPath||[];if(!ce.length)return;const fe=ce[ce.length-1],ke=this.#H(fe);if(!ke)return;const Re=this.#x(ie);if(!Re)return;const Ee=ke.parent.indexOf(ke.node);ke.parent.splice(Ee+1,0,Re);const Fe=this.#I(this.#n),ye=this.#N(ke.node);if(ye.length){this.#$(ye);const he=Math.max(...ye.map(Ce=>this.#t.indexOf(Ce))),Se=this.#t.filter(Ce=>Ce!==ie);Se.splice(he+1,0,ie),this.#t=Se}this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"removed",id:ie,dissolved:Fe})}renameGroup(ie,oe){const ce=this.#H(ie);if(!ce){y(`columns.group.rename:${ie}`,`no band "${ie}" to rename.`);return}ce.node.title=String(oe??""),this.#k&&this.#k("columngroup",{action:"renamed",groupId:ie,title:ce.node.title})}dissolveGroup(ie){const oe=this.#H(ie);if(!oe){y(`columns.group.dissolve:${ie}`,`no band "${ie}" to dissolve.`);return}const ce=oe.parent.indexOf(oe.node);oe.parent.splice(ce,1,...oe.node.columns),this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"dissolved",groupId:ie})}moveGroup(ie,oe){const ce=this.#H(ie);if(!ce){y(`columns.group.move:${ie}`,`no band "${ie}" to move.`);return}const fe=ce.parent,ke=fe.indexOf(ce.node);ke!==-1&&(fe.splice(ke,1),fe.splice(Math.max(0,Math.min(oe,fe.length)),0,ce.node),this.#B(),this.#z(),this.#k&&this.#k("columngroup",{action:"moved",groupId:ie,to:oe}))}#B(){const ie=[],oe=fe=>{for(const ke of fe)Array.isArray(ke.columns)?oe(ke.columns):ke.column&&ie.push(ke.column.id)};oe(this.#n);const ce=new Set(ie);this.#t=[...ie,...this.#t.filter(fe=>!ce.has(fe))]}groupTree(){const ie=ce=>ce.map(fe=>Array.isArray(fe.columns)?{id:fe.id,title:fe.title||"",collapsible:!!fe.collapsible,openByDefault:fe.openByDefault!==!1,columns:ie(fe.columns)}:fe.column?fe.column.id:null).filter(fe=>fe!==null),oe=ie(this.#n);return oe.some(ce=>ce&&typeof ce=="object")?oe:[]}applyGroupTree(ie){if(!Array.isArray(ie))return;const oe=new Set,ce=ke=>{const Re=[];for(const Ee of ke)if(Ee&&typeof Ee=="object"&&Array.isArray(Ee.columns)){const Fe=ce(Ee.columns);if(!Fe.length)continue;Re.push({id:Ee.id||O("grp"),title:Ee.title||"",collapsible:Ee.collapsible===!0,openByDefault:Ee.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Fe})}else if(typeof Ee=="string"){const Fe=this.#e.get(Ee);Fe&&!oe.has(Ee)&&(oe.add(Ee),Re.push({column:Fe,path:[]}))}return Re},fe=ce(ie);for(const ke of this.#t){if(oe.has(ke))continue;const Re=this.#e.get(ke);Re&&fe.push({column:Re,path:[]})}this.#n=fe,this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"applied"})}show(ie){this.#W(ie,!1)}hide(ie){this.#W(ie,!0)}#W(ie,oe){const ce=[];for(const fe of v(ie)){const ke=this.#e.get(fe);if(ke){if(oe&&ke.layout.lockVisible){y(`lockVisible:${fe}`,`column "${fe}" is \`layout.lockVisible\` and cannot be hidden`);continue}ke.layout.hidden!==oe&&(ke.layout.hidden=oe,ce.push(fe))}}ce.length&&this.#k&&this.#k("visible",{ids:ce,hidden:oe})}pin(ie,oe){const ce=this.#e.get(ie);ce&&(ce.layout.pin=oe??null,this.#k&&this.#k("pin",{id:ie,side:ce.layout.pin}))}resize(ie,oe){const ce=this.#e.get(ie);if(!ce)return;if(ce.layout.resizable===!1){y(`resize:${ie}`,`column "${ie}" is not resizable; the resize was ignored`);return}const fe=ce.layout.min??0,ke=ce.layout.max;let Re=Math.max(fe,oe);ke!=null&&(Re=Math.min(ke,Re)),ce.layout.width=Re,ce.layout.flex=0,this.#k&&this.#k("resize",{id:ie,width:Re})}}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 ee(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 te(de,ie){const oe=de??null,ce=ie??null;if(oe===ce)return!0;if(oe===null||ce===null)return!1;if(typeof oe!="object"||typeof ce!="object")return oe===ce;try{return JSON.stringify(oe)===JSON.stringify(ce)}catch{return!1}}function ne(de){const ie=[],oe=(fe,ke)=>{const Re=[];for(const Ee of fe){if(!H(Ee)){B("a column definition must be an object");continue}if(Array.isArray(Ee.columns)){I(Ee,S,"columnGroup",Ee.title||Ee.id||"(unnamed)");const Fe={id:Ee.id||O("grp"),title:Ee.title||"",collapsible:Ee.collapsible===!0,openByDefault:Ee.openByDefault!==!1,showWhen:Ee.showWhen||"always",marryChildren:Ee.marryChildren===!0,header:Ee.header||{},def:Ee,columns:[]};Fe.columns=oe(Ee.columns,[...ke,Fe.id]),Re.push(Fe)}else{const Fe={def:Ee,path:ke};ie.push(Fe),Re.push(Fe)}}return Re},ce=oe(de,[]);return{leaves:ie,groups:ce}}function ae(de,ie,oe){for(const ce of de){if(ce.columns){if(ae(ce.columns,ie,oe))return!0;continue}if(ce.column&&ce.column.id===ie)return ce.column=oe,!0}return!1}}),xe("packages/core/src/columns/autogroup.js",function(e,G){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return H}});const L=G("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",F=240,W=.5;function X(V){const{columns:K,groupBy:D}=V,v=D.map(u=>K.get(u)).filter(Boolean),O=v.length?v.map(u=>u.title||u.id).join(" > "):"Group",y=V.config&&V.config.autoGroupColumnWidth||F;return{id:B,field:null,title:O,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:V.config&&V.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(u,a){return a&&a.group?a.groupValue:null},formatValue(u,a){if(!a||!a.group)return"";if(a.grandTotal)return V.config&&V.config.grandTotalLabel||"Total";const s=v[Math.min(a.level||0,v.length-1)];return s&&typeof s.formatValue=="function"?s.formatValue(u,a):u==null?"":String(u)}}}function H(V,K,D){!V.length||D<100||K<D*W||L(`grouping.cardinality:${V.join(",")}`,`grouping by ${V.join(", ")} produced ${K} 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.`)}}),xe("packages/core/src/columns/selectcolumn.js",function(e,G){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q="__lattice_select",L=44;function B(W){const X=W.selection||{},H=W.config&&W.config.selectionColumnWidth||L;return{id:Q,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width: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:X.headerCheckbox===!0,def:{},getValue(V,K){return K?K.selected:!1},formatValue(){return""}}}const F=B}),xe("packages/core/src/columns/rownumbercolumn.js",function(e,G){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const L=G("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",F=40,W=9,X=22;function H(D){const v=String(Math.max(1,Math.trunc(Math.abs(D))||1)).length;return Math.max(F,v*W+X)}function V(D){const v=D.rowNumbers,O=v&&typeof v=="object"?v:{},y=Number.isFinite(O.start)?O.start:1,u=Number.isFinite(O.width)?O.width:H((D.maxNumber||0)+y),a=L(D.rank)?D.rank:()=>null;return{id:B,field:null,title:typeof O.title=="string"?O.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:u,min:u,max:u,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(s,n){const t=a(n);return t==null?null:t-1+y},formatValue(s){return s==null?"":String(s)}}}const K=V}),xe("packages/core/src/model/detail.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,F=240,W=10;function X(K){if(!K)return null;const D=K===!0?{}:K;return D.enabled===!1?null:!L(D.rows)&&!D.render?(B("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:D.render||null,config:D.config||null,rows:L(D.rows)?D.rows:null,height:D.height??F,cacheLimit:Number.isFinite(D.cacheLimit)?Math.max(0,D.cacheLimit):W,isMaster:L(D.isMaster)?D.isMaster:null,target:D.target||null,onCreate:L(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=L(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 L(v)?Number(v(D))||F:v==="auto"?F:Number(v)||F}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||!L(D))return;let v=!1;for(const O of[...this.#t])D(O)||(this.#t.delete(O),v=!0);v&&this.#o()}signature(){return`${this.#r}`}set(D){this.#t.clear();const v=Array.isArray(D)?D:[];for(const O of this.inline?v:v.slice(0,1))this.#t.add(O);this.#o()}#o(){this.#r++,this.#n()}}const V=H}),xe("packages/core/src/compute/special.js",function(e,G){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return K}}),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 u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return s}});const Q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),L=3e-12,B=1e-300;function F(n){if(n<.5)return Math.log(Math.PI/Math.sin(Math.PI*n))-F(1-n);const t=n-1;let r=.9999999999998099;const o=t+7.5;for(let f=0;f<Q.length;f++)r+=Q[f]/(t+f+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(o)-o+Math.log(r)}function W(n,t,r){const o=n+t,f=n+1,c=n-1;let i=1,g=1-o*r/f;Math.abs(g)<B&&(g=B),g=1/g;let d=g;for(let h=1;h<=300;h++){const l=2*h;let m=h*(t-h)*r/((c+l)*(n+l));g=1+m*g,Math.abs(g)<B&&(g=B),i=1+m/i,Math.abs(i)<B&&(i=B),g=1/g,d*=g*i,m=-(n+h)*(o+h)*r/((n+l)*(f+l)),g=1+m*g,Math.abs(g)<B&&(g=B),i=1+m/i,Math.abs(i)<B&&(i=B),g=1/g;const w=g*i;if(d*=w,Math.abs(w-1)<L)break}return d}function X(n,t,r){if(!(n>0)||!(t>0)||!Number.isFinite(r))return Number.NaN;if(r<=0)return 0;if(r>=1)return 1;const o=Math.exp(F(n+t)-F(n)-F(t)+n*Math.log(r)+t*Math.log(1-r));return r<(n+1)/(n+t+2)?o*W(n,t,r)/n:1-o*W(t,n,1-r)/t}function H(n){if(!(n>0)||!(n<1))return n===0?-1/0:n===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],o=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],f=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],c=.02425;let i,g,d;n<c?(i=Math.sqrt(-2*Math.log(n)),d=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((f[0]*i+f[1])*i+f[2])*i+f[3])*i+1)):n<=1-c?(i=n-.5,g=i*i,d=(((((t[0]*g+t[1])*g+t[2])*g+t[3])*g+t[4])*g+t[5])*i/(((((r[0]*g+r[1])*g+r[2])*g+r[3])*g+r[4])*g+1)):(i=Math.sqrt(-2*Math.log(1-n)),d=-(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((f[0]*i+f[1])*i+f[2])*i+f[3])*i+1));const l=(.5*V(-d/Math.SQRT2)-n)*Math.sqrt(2*Math.PI)*Math.exp(d*d/2);return d-l/(1+d*l/2)}function V(n){const t=Math.abs(n),r=2/(2+t),o=4*r-2,f=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let c=0,i=0,g;for(let h=f.length-1;h>0;h--)g=i,i=o*i-c+f[h],c=g;const d=r*Math.exp(-t*t+.5*(f[0]+o*i)-c);return n>=0?d:2-d}function K(n){return .5*V(-n/Math.SQRT2)}function D(n,t){if(!(t>0)||!Number.isFinite(n))return Number.NaN;const r=.5*X(t/2,.5,t/(t+n*n));return n>0?1-r:r}function v(n,t){if(!(n>0)||!(n<1)||!(t>0))return Number.NaN;if(t>1e7)return H(n);let r=-1e4,o=1e4,f=H(n);const c=F(t/2)+F(.5)-F((t+1)/2);for(let i=0;i<60;i++){const g=D(f,t);g<n?r=f:o=f;const d=Math.exp(-((t+1)/2)*Math.log(1+f*f/t)-c)/Math.sqrt(t),h=d>0?(g-n)/d:0;if(Math.abs(h)<1e-12)break;const l=f-h;if(f=l>r&&l<o&&Number.isFinite(l)?l:(r+o)/2,o-r<1e-12)break}return f}function O(n,t){let r=n,o=1/n,f=o;for(let c=0;c<300&&(r+=1,f*=t/r,o+=f,!(Math.abs(f)<Math.abs(o)*L));c++);return o*Math.exp(-t+n*Math.log(t)-F(n))}function y(n,t){let r=t+1-n,o=1/B,f=1/r,c=f;for(let i=1;i<=300;i++){const g=-i*(i-n);r+=2,f=g*f+r,Math.abs(f)<B&&(f=B),o=r+g/o,Math.abs(o)<B&&(o=B),f=1/f;const d=f*o;if(c*=d,Math.abs(d-1)<L)break}return Math.exp(-t+n*Math.log(t)-F(n))*c}function u(n,t){return!(n>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<n+1?O(n,t):1-y(n,t)}function a(n,t){return t>0?u(t/2,n/2):Number.NaN}function s(n,t){const r=a(n,t);return Number.isNaN(r)?Number.NaN:Math.min(1,Math.max(0,1-r))}}),xe("packages/core/src/compute/linalg.js",function(e,G){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return X}});function Q(H){const V=H.length,K=Array.from({length:V},()=>new Array(V).fill(0));for(let D=0;D<V;D++)for(let v=0;v<=D;v++){let O=H[D][v];for(let y=0;y<v;y++)O-=K[D][y]*K[v][y];if(D===v){if(!(O>0))return null;K[D][v]=Math.sqrt(O)}else K[D][v]=O/K[v][v]}return K}function L(H,V){const K=H.length,D=new Array(K).fill(0);for(let O=0;O<K;O++){let y=V[O];for(let u=0;u<O;u++)y-=H[O][u]*D[u];D[O]=y/H[O][O]}const v=new Array(K).fill(0);for(let O=K-1;O>=0;O--){let y=D[O];for(let u=O+1;u<K;u++)y-=H[u][O]*v[u];v[O]=y/H[O][O]}return v}function B(H){const V=H.length,K=Array.from({length:V},()=>new Array(V).fill(0));for(let D=0;D<V;D++){const v=new Array(V).fill(0);v[D]=1;const O=L(H,v);for(let y=0;y<V;y++)K[y][D]=O[y]}return K}function F(H,V,K){const D=H.length,v=D?H[0].length:0,O=Array.from({length:v},()=>new Array(v).fill(0)),y=new Array(v).fill(0);for(let u=0;u<D;u++){const a=K?K[u]:1,s=H[u];for(let n=0;n<v;n++){const t=a*s[n];y[n]+=t*V[u];for(let r=n;r<v;r++)O[n][r]+=t*s[r]}}for(let u=0;u<v;u++)for(let a=0;a<u;a++)O[u][a]=O[a][u];return{xtwx:O,xtwy:y}}function W(H,V){return H.map(K=>K.reduce((D,v,O)=>D+v*V[O],0))}function X(H,V){let K=0;for(let D=0;D<H.length;D++){let v=0;for(let O=0;O<H.length;O++)v+=V[D][O]*H[O];K+=H[D]*v}return K}}),xe("packages/core/src/compute/sketch.js",function(e,G){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return K}}),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 O}});class Q{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(u){if(!Number.isFinite(u))return;this.#e++;const a=u-this.#t;this.#t+=a/this.#e,this.#n+=a*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const a=this.#e+u.#e,s=u.#t-this.#t;this.#t+=s*(u.#e/a),this.#n+=u.#n+s*s*(this.#e*u.#e/a),this.#e=a}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class L{#e=[];#t=0;#n;#r;constructor(u,a=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=a}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const a=Math.floor(this.#r()*this.#t);a<this.#n&&(this.#e[a]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const a of this.#e)u+=a;return u/this.#e.length}quantile(u){const a=this.#e.length;if(!a)return null;const s=this.#e.slice().sort((o,f)=>o-f);if(a===1)return s[0];const n=(a-1)*Math.min(1,Math.max(0,u)),t=Math.floor(n),r=Math.ceil(n);return t===r?s[t]:s[t]+(n-t)*(s[r]-s[t])}}function B(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function F(y){if(typeof y=="number"){const s=new DataView(new ArrayBuffer(8));return s.setFloat64(0,y===0?0:y),B(s.getUint32(0)^s.getUint32(4))}const u=typeof y=="string"?y:String(y);let a=2166136261;for(let s=0;s<u.length;s++)a^=u.charCodeAt(s),a=Math.imul(a,16777619);return B(a)}class W{#e;#t;#n;constructor(u=14){const a=Math.floor(u);if(a<4||a>16)throw new RangeError("HLL precision must be 4..16");this.#e=a,this.#t=1<<a,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const a=1<<Math.floor(u),s=1.04/Math.sqrt(a);return Object.freeze({kind:"probabilistic",metric:"relative",value:s,statement:`distinct count within ~${(s*100).toFixed(2)}% relative standard error (m=${a} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(u){const a=F(u),s=a&this.#t-1,n=a>>>this.#e|1<<32-this.#e;let t=1,r=n;for(;(r&1)===0;)t++,r>>>=1;t>this.#n[s]&&(this.#n[s]=t)}count(){const u=this.#t,a=32-this.#e,s=new Float64Array(a+2);for(let r=0;r<u;r++)s[this.#n[r]]++;let n=u*V(1-s[a+1]/u);for(let r=a;r>=1;r--)n=.5*(n+s[r]);n+=u*H(s[0]/u);const t=X*u*u/n;return Math.round(t)}}const X=.5/Math.log(2);function H(y){if(y===1)return 1/0;let u=1,a=y,s;do y*=y,s=a,a+=y*u,u+=u;while(a!==s);return a}function V(y){if(y===0||y===1)return 0;let u=1,a=1-y,s;do y=Math.sqrt(y),s=a,u*=.5,a-=(1-y)**2*u;while(a!==s);return a/3}class K{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const a=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:a,statement:`each count overestimates the truth by at most N/m = ${a.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const a=this.#e.get(u);if(a){a.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let s,n=1/0;for(const[t,r]of this.#e)r.count<n&&(n=r.count,s=t);this.#e.delete(s),this.#e.set(u,{count:n+1,error:n})}top(u=this.#t){return[...this.#e.entries()].map(([s,n])=>({item:s,count:n.count,error:n.error})).sort((s,n)=>n.count-s.count).slice(0,Math.max(0,Math.floor(u)))}}class D{#e;#t=[[]];#n=0;#r;#o;constructor(u=200,a=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=a,this.#o=2/3}static errorBoundFor(u=200){const a=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:a,statement:`queried quantile's true rank within ~${(a*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return D.errorBoundFor(this.#e)}get count(){return this.#n}#i(u){const s=this.#t.length-1-u,n=Math.ceil(this.#e*this.#o**s);return Math.max(2,n)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(u){const a=this.#t[u];a.sort((t,r)=>t-r),u+1>=this.#t.length&&this.#t.push([]);const s=this.#t[u+1],n=this.#r()<.5?0:1;for(let t=n;t<a.length;t+=2)s.push(a[t]);this.#t[u]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const u=[];for(let a=0;a<this.#t.length;a++){const s=1<<a;for(const n of this.#t[a])u.push({v:n,w:s})}return u}quantile(u){const a=this.#l();if(!a.length)return null;a.sort((r,o)=>r.v-o.v);let s=0;for(const r of a)s+=r.w;const n=Math.min(1,Math.max(0,u))*s;let t=0;for(const r of a)if(t+=r.w,t>=n)return r.v;return a[a.length-1].v}rank(u){let a=0;for(let s=0;s<this.#t.length;s++){const n=1<<s;for(const t of this.#t[s])t<=u&&(a+=n)}return a}}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"})}),O={Welford:Q,Reservoir:L,HyperLogLog:W,SpaceSaving:K,KLL:D,hash32:F,SKETCH_BOUNDS:v}}),xe("packages/core/src/compute/statistics.js",function(e,G){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return I}}),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 fe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return St}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return nt}});const Q=G("packages/core/src/compute/handle.js"),L=Q.presenceReader,B=Q.valueReader,F=G("packages/core/src/compute/special.js"),W=F.studentTQuantile,X=F.studentT,H=F.normalQuantile,V=F.normalCdf,K=F.chiSquareUpperTail,D=G("packages/core/src/compute/linalg.js"),v=D.cholesky,O=D.choleskySolve,y=D.choleskyInverse,u=D.normalEquations,a=D.quadForm,n=G("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,r=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),o=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:n.distinct}),median:Object.freeze({sketch:"KLL",bound:n.median}),p25:Object.freeze({sketch:"KLL",bound:n.p25}),p75:Object.freeze({sketch:"KLL",bound:n.p75}),p90:Object.freeze({sketch:"KLL",bound:n.p90}),p95:Object.freeze({sketch:"KLL",bound:n.p95}),p99:Object.freeze({sketch:"KLL",bound:n.p99}),iqr:Object.freeze({sketch:"KLL",bound:n.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK})});function f(ge){const we=ge==="sum"||ge==="avg"||ge==="countValues"||ge==="min"||ge==="max"?"maintained":Object.prototype.hasOwnProperty.call(r,ge)?r[ge]:null,ve=Object.prototype.hasOwnProperty.call(o,ge)?o[ge]:null;return{stat:ge,exact:we,approximate:ve}}function c(ge,we){const ve=we.length,je=new Float64Array(ve);let Le=0;if(ge&&(ge.kind==="float64"||ge.kind==="int32")){const Ae=ge.values,Ne=L(ge);for(let De=0;De<ve;De++){const qe=we[De];if(Ne&&Ne(qe)!==1)continue;const ot=Ae[qe];Number.isNaN(ot)||(je[Le++]=ot)}return je.subarray(0,Le)}const Me=B(ge);for(let Ae=0;Ae<ve;Ae++){const Ne=Me(we[Ae]);if(Ne==null||Ne==="")continue;const De=typeof Ne=="number"?Ne:Number(Ne);Number.isFinite(De)&&(je[Le++]=De)}return je.subarray(0,Le)}function i(ge,we){const ve=new Map,je=B(ge);let Le=0;for(let Me=0;Me<we.length;Me++){const Ae=je(we[Me]);if(Ae==null||Ae===""||typeof Ae=="number"&&Number.isNaN(Ae))continue;const Ne=typeof Ae=="object"?String(Ae):Ae;ve.set(Ne,(ve.get(Ne)||0)+1),Le++}const me=[...ve.values()].sort((Me,Ae)=>Ae-Me);return{counts:me,total:Le,distinct:me.length}}function g(ge){return ge.total>0?ge.counts.map(we=>we/ge.total):[]}function d(ge,we){const ve=i(ge,we);if(!ve.total)return null;let je=0;for(const Le of g(ve))je+=Le*Le;return je}function h(ge,we){const ve=i(ge,we);if(!ve.total)return null;let je=0;for(const Le of g(ve))Le>0&&(je-=Le*Math.log2(Le));return je}function l(ge,we){const ve=i(ge,we);if(!ve.total||ve.distinct<2)return ve.total?1:null;let je=0;for(const Le of g(ve))Le>0&&(je-=Le*Math.log2(Le));return je/Math.log2(ve.distinct)}function m(ge,we,ve=3){const je=i(ge,we);if(!je.total)return null;const Le=Math.max(1,Math.floor(ve));let me=0;for(let Me=0;Me<Math.min(Le,je.counts.length);Me++)me+=je.counts[Me];return me/je.total}function w(ge,we){const ve=c(ge,we),je=ve.length;if(!je)return null;const Le=ve.slice().sort();if(Le[0]<0)return null;let me=0,Me=0;for(let Ae=0;Ae<je;Ae++)me+=Le[Ae],Me+=(Ae+1)*Le[Ae];return me===0?0:2*Me/(je*me)-(je+1)/je}function k(ge){let we=0,ve=0,je=0;for(let Le=0;Le<ge.length;Le++){const me=ge[Le];we++;const Me=me-ve;ve+=Me/we,je+=Me*(me-ve)}return{n:we,mean:ve,m2:je}}function p(ge,we){const ve=ge.length;if(!ve)return NaN;if(ve===1)return ge[0];const je=(ve-1)*Math.min(1,Math.max(0,we)),Le=Math.floor(je),me=Math.ceil(je);return Le===me?ge[Le]:ge[Le]+(je-Le)*(ge[me]-ge[Le])}function b(ge,we){if(!ge.length)return NaN;const ve=ge.slice().sort();return p(ve,we)}function E(ge,we){const ve=B(ge);let je=0,Le=0,me=0;for(let Me=0;Me<we.length;Me++){const Ae=ve(we[Me]);if(Ae==null||Ae==="")continue;const Ne=String(Ae).toUpperCase();Ne==="PASS"?je++:Ne==="FAIL"?Le++:Ne==="WARN"&&me++}return{pass:je+me,fail:Le,warn:me,judged:je+me+Le}}const T=Object.freeze({hhi:(ge,we)=>d(ge,we),entropy:(ge,we)=>h(ge,we),evenness:(ge,we)=>l(ge,we),top3Share:(ge,we)=>m(ge,we,3),top10Share:(ge,we)=>m(ge,we,10),gini:(ge,we)=>w(ge,we),trimmedMean:(ge,we)=>j(c(ge,we),.1),winsorizedMean:(ge,we)=>$(c(ge,we),.1),robustOutliers:(ge,we)=>z(c(ge,we),3.5),jarqueBera:(ge,we)=>M(c(ge,we)),variance:(ge,we)=>{const{n:ve,m2:je}=k(c(ge,we));return ve>1?je/(ve-1):null},varianceP:(ge,we)=>{const{n:ve,m2:je}=k(c(ge,we));return ve>0?je/ve:null},stddev:(ge,we)=>{const{n:ve,m2:je}=k(c(ge,we));return ve>1?Math.sqrt(je/(ve-1)):null},stddevP:(ge,we)=>{const{n:ve,m2:je}=k(c(ge,we));return ve>0?Math.sqrt(je/ve):null},median:(ge,we)=>{const ve=c(ge,we);return ve.length?b(ve,.5):null},p25:(ge,we)=>{const ve=c(ge,we);return ve.length?b(ve,.25):null},p75:(ge,we)=>{const ve=c(ge,we);return ve.length?b(ve,.75):null},p90:(ge,we)=>{const ve=c(ge,we);return ve.length?b(ve,.9):null},p95:(ge,we)=>{const ve=c(ge,we);return ve.length?b(ve,.95):null},p99:(ge,we)=>{const ve=c(ge,we);return ve.length?b(ve,.99):null},iqr:(ge,we)=>{const ve=c(ge,we);if(!ve.length)return null;const je=ve.slice().sort();return p(je,.75)-p(je,.25)},mad:(ge,we)=>{const ve=c(ge,we);if(!ve.length)return null;const je=b(ve,.5),Le=new Float64Array(ve.length);for(let me=0;me<ve.length;me++)Le[me]=Math.abs(ve[me]-je);return b(Le,.5)},range:(ge,we)=>{const ve=c(ge,we);if(!ve.length)return null;let je=1/0,Le=-1/0;for(let me=0;me<ve.length;me++)ve[me]<je&&(je=ve[me]),ve[me]>Le&&(Le=ve[me]);return Le-je},distinct:(ge,we)=>{const ve=B(ge),je=new Set;for(let Le=0;Le<we.length;Le++){const me=ve(we[Le]);me==null||me===""||je.add(me instanceof Date?me.getTime():me)}return je.size},mode:(ge,we)=>{const ve=B(ge),je=new Map;for(let Me=0;Me<we.length;Me++){const Ae=ve(we[Me]);if(Ae==null||Ae==="")continue;const Ne=Ae instanceof Date?Ae.getTime():Ae;je.set(Ne,(je.get(Ne)||0)+1)}let Le=null,me=1;for(const[Me,Ae]of je)Ae>me&&(me=Ae,Le=Me);return Le},skewness:(ge,we)=>{const ve=c(ge,we),{n:je,mean:Le,m2:me}=k(ve);if(je<3||me<=0)return null;const Me=Math.sqrt(me/(je-1));let Ae=0;for(let Ne=0;Ne<ve.length;Ne++)Ae+=((ve[Ne]-Le)/Me)**3;return je/((je-1)*(je-2))*Ae},kurtosis:(ge,we)=>{const ve=c(ge,we),{n:je,mean:Le,m2:me}=k(ve);if(je<4||me<=0)return null;const Me=Math.sqrt(me/(je-1));let Ae=0;for(let qe=0;qe<ve.length;qe++)Ae+=((ve[qe]-Le)/Me)**4;const Ne=je*(je+1)/((je-1)*(je-2)*(je-3)),De=3*(je-1)**2/((je-2)*(je-3));return Ne*Ae-De},geomean:(ge,we)=>{const ve=c(ge,we);if(!ve.length)return null;let je=0;for(let Le=0;Le<ve.length;Le++){if(ve[Le]<=0)return null;je+=Math.log(ve[Le])}return Math.exp(je/ve.length)},harmean:(ge,we)=>{const ve=c(ge,we);if(!ve.length)return null;let je=0;for(let Le=0;Le<ve.length;Le++){if(ve[Le]===0)return null;je+=1/ve[Le]}return ve.length/je},sumSquares:(ge,we)=>{const ve=c(ge,we);let je=0;for(let Le=0;Le<ve.length;Le++)je+=ve[Le]*ve[Le];return je},passRate:(ge,we)=>{const{pass:ve,judged:je}=E(ge,we);return je?ve/je:null},failureCount:(ge,we)=>E(ge,we).fail}),P=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function x(ge,we,ve){const je=B(ge),Le=B(we);let me=0,Me=0;for(let Ae=0;Ae<ve.length;Ae++){const Ne=ve[Ae],De=Number(je(Ne)),qe=Number(Le(Ne));!Number.isFinite(De)||!Number.isFinite(qe)||(me+=De*qe,Me+=qe)}return Me===0?null:me/Me}function C(ge,we,ve){const je=B(ge);let Le=null,me=ve?-1/0:1/0;for(let Me=0;Me<we.length;Me++){const Ae=we[Me],Ne=Number(je(Ae));Number.isFinite(Ne)&&(ve?Ne>me:Ne<me)&&(me=Ne,Le=Ae)}return Le}function A(ge,we,ve){const je=B(ge),Le=B(we);let me=0,Me=0,Ae=0,Ne=0,De=0,qe=0;for(let st=0;st<ve.length;st++){const wt=ve[st],ct=Number(je(wt)),pt=Number(Le(wt));!Number.isFinite(ct)||!Number.isFinite(pt)||(me++,Me+=ct,Ae+=pt,Ne+=ct*ct,De+=pt*pt,qe+=ct*pt)}if(me<2)return null;const ot=me*qe-Me*Ae,ut=Math.sqrt((me*Ne-Me*Me)*(me*De-Ae*Ae));if(ut===0)return null;const dt=ot/ut;return Math.max(-1,Math.min(1,dt))}function j(ge,we=.1){const ve=ge.length;if(!ve)return null;const je=Array.from(ge).sort((Ae,Ne)=>Ae-Ne),Le=Math.floor(ve*Math.min(.49,Math.max(0,we))),me=je.slice(Le,ve-Le);if(!me.length)return p(je,.5);let Me=0;for(const Ae of me)Me+=Ae;return Me/me.length}function $(ge,we=.1){const ve=ge.length;if(!ve)return null;const je=Array.from(ge).sort((Ne,De)=>Ne-De),Le=Math.floor(ve*Math.min(.49,Math.max(0,we))),me=je[Le],Me=je[ve-1-Le];let Ae=0;for(const Ne of je)Ae+=Math.min(Me,Math.max(me,Ne));return Ae/ve}function z(ge,we=3.5){if(!ge.length)return null;const je=Array.from(ge).sort((Ne,De)=>Ne-De),Le=p(je,.5),me=je.map(Ne=>Math.abs(Ne-Le)).sort((Ne,De)=>Ne-De),Me=p(me,.5);if(Me===0)return null;let Ae=0;for(const Ne of je)Math.abs(.6745*(Ne-Le)/Me)>we&&Ae++;return Ae}function M(ge){const we=ge.length;if(we<8)return null;let ve=0;for(const Ne of ge)ve+=Ne;ve/=we;let je=0,Le=0,me=0;for(const Ne of ge){const De=Ne-ve;je+=De*De,Le+=De*De*De,me+=De*De*De*De}if(je/=we,Le/=we,me/=we,je===0)return null;const Me=Le/je**1.5,Ae=me/(je*je)-3;return we/6*(Me*Me+Ae*Ae/4)}function R(ge,we,ve){const je=[];let Le=0;for(let Ne=0;Ne<ge.length;Ne++){const De=Number(ge[Ne]),qe=Number(we[Ne]);!Number.isFinite(De)||!Number.isFinite(qe)||qe<=0||(je.push([De,qe]),Le+=qe)}if(!je.length||Le<=0)return null;if(je.sort((Ne,De)=>Ne[0]-De[0]),je.length===1)return je[0][0];const me=[];let Me=0;for(const[,Ne]of je)me.push((Me+Ne/2)/Le),Me+=Ne;const Ae=Math.max(0,Math.min(1,ve));if(Ae<=me[0])return je[0][0];if(Ae>=me[me.length-1])return je[je.length-1][0];for(let Ne=1;Ne<me.length;Ne++){if(Ae>me[Ne])continue;const De=me[Ne]-me[Ne-1],qe=De>0?(Ae-me[Ne-1])/De:0;return je[Ne-1][0]+(je[Ne][0]-je[Ne-1][0])*qe}return je[je.length-1][0]}function S(ge,we,ve){const je=B(ge),Le=B(we),me=new Float64Array(ve.length),Me=new Float64Array(ve.length);let Ae=0;for(let Ne=0;Ne<ve.length;Ne++){const De=ve[Ne],qe=Number(je(De)),ot=Number(Le(De));!Number.isFinite(qe)||!Number.isFinite(ot)||(me[Ae]=qe,Me[Ae]=ot,Ae++)}return{xs:me.subarray(0,Ae),ys:Me.subarray(0,Ae),n:Ae}}function I(ge,we,ve,je=!1){const{xs:Le,ys:me,n:Me}=S(ge,we,ve);if(Me<2)return null;let Ae=0,Ne=0;for(let qe=0;qe<Me;qe++)Ae+=Le[qe],Ne+=me[qe];Ae/=Me,Ne/=Me;let De=0;for(let qe=0;qe<Me;qe++)De+=(Le[qe]-Ae)*(me[qe]-Ne);return De/(je?Me:Me-1)}function q(ge,we,ve){const{xs:je,ys:Le,n:me}=S(ge,we,ve);if(me<2)return null;let Me=0,Ae=0;for(let ct=0;ct<me;ct++)Me+=je[ct],Ae+=Le[ct];Me/=me,Ae/=me;let Ne=0,De=0,qe=0;for(let ct=0;ct<me;ct++){const pt=je[ct]-Me,jt=Le[ct]-Ae;Ne+=pt*pt,De+=pt*jt,qe+=jt*jt}if(Ne===0)return null;const ot=De/Ne,ut=Ae-ot*Me,dt=qe===0?1:Math.max(0,Math.min(1,De*De/(Ne*qe))),st=Math.max(0,qe-ot*De),wt=me>2?Math.sqrt(st/(me-2)/Ne):0;return{slope:ot,intercept:ut,r2:dt,stdError:wt,n:me}}const Z=new Set(["ols","wls","robust"]),_=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ee=1.345;function te(ge,we,ve){const{xtwx:je,xtwy:Le}=u(ge,we,ve),me=v(je);if(!me)return null;const Me=O(me,Le),Ae=y(me),Ne=ne(ge,Me),De=we.map((qe,ot)=>qe-Ne[ot]);return{beta:Me,cov:Ae,fitted:Ne,residuals:De}}function ne(ge,we){return ge.map(ve=>ve.reduce((je,Le,me)=>je+Le*we[me],0))}function ae(ge,we){const ve=ge.length,je=ge.map(De=>De[we]),Le=ge.map(De=>[1,...De.filter((qe,ot)=>ot!==we)]),me=te(Le,je,null);if(!me)return 1;const Me=je.reduce((De,qe)=>De+qe,0)/ve;let Ae=0,Ne=0;for(let De=0;De<ve;De++)Ae+=me.residuals[De]**2,Ne+=(je[De]-Me)**2;return Ne===0?1:Math.max(0,Math.min(1,1-Ae/Ne))}function de(ge){const we=[...ge].sort((Le,me)=>Le-me),ve=ie(we),je=ge.map(Le=>Math.abs(Le-ve)).sort((Le,me)=>Le-me);return ie(je)/.6745}function ie(ge){const we=ge.length;if(!we)return 0;const ve=Math.floor(we/2);return we%2?ge[ve]:(ge[ve-1]+ge[ve])/2}function oe(ge,we,ve={}){const je=ve.method||"ols";if(J.has(je))throw new Error(`[lattice] regression method "${je}" is out of scope; use ols, wls or robust.`);if(_.has(je))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Z.has(je))throw new Error(`[lattice] unknown regression method "${je}"; use ols, wls or robust.`);const Le=Array.isArray(we)?we.length:0,me=Le&&Array.isArray(ge[0])?ge[0].length:0,Me=me+1;if(!(Le>Me))return null;for(let Pt=0;Pt<Le;Pt++){if(!Number.isFinite(we[Pt])||!Array.isArray(ge[Pt])||ge[Pt].length!==me)return null;for(let Ft=0;Ft<me;Ft++)if(!Number.isFinite(ge[Pt][Ft]))return null}let Ae=null;if(je==="wls"){if(Ae=ve.weights,!Array.isArray(Ae)||Ae.length!==Le)return null;for(let Pt=0;Pt<Le;Pt++)if(!(Ae[Pt]>0)||!Number.isFinite(Ae[Pt]))return null}const Ne=ge.map(Pt=>[1,...Pt]);let De,qe=null;if(je==="robust"){if(De=te(Ne,we,null),!De)return null;for(let Pt=0;Pt<50;Pt++){const Ft=de(De.residuals);if(!(Ft>0))break;const Dt=De.residuals.map(Zt=>{const Xt=Math.abs(Zt/Ft);return Xt<=ee?1:ee/Xt}),Gt=te(Ne,we,Dt);if(!Gt)return null;const Yt=Gt.beta.reduce((Zt,Xt,nn)=>Math.max(Zt,Math.abs(Xt-De.beta[nn])),0);if(De=Gt,qe=Dt,Yt<1e-10)break}}else if(De=te(Ne,we,Ae),!De)return null;const ot=je==="robust"?qe:Ae,{beta:ut,cov:dt,fitted:st,residuals:wt}=De;let ct=0,pt=0,jt=0;for(let Pt=0;Pt<Le;Pt++){const Ft=ot?ot[Pt]:1;ct+=Ft*wt[Pt]**2,pt+=Ft,jt+=Ft*we[Pt]}const He=jt/pt;let lt=0;for(let Pt=0;Pt<Le;Pt++){const Ft=ot?ot[Pt]:1;lt+=Ft*(we[Pt]-He)**2}const rt=Le-Me,vt=ct/rt,Nt=lt===0?1:Math.max(0,Math.min(1,1-ct/lt)),$t=1-(1-Nt)*(Le-1)/rt,gt=Array.isArray(ve.names)&&ve.names.length===me?ve.names:ge[0].map((Pt,Ft)=>`x${Ft+1}`),Rt=At(ve.confidence),Bt=rt>0?W(1-(1-Rt)/2,rt):1/0,Qt=ut.map((Pt,Ft)=>{const Dt=Math.sqrt(Math.max(0,vt*dt[Ft][Ft])),Gt=Dt>0?Pt/Dt:Pt===0?0:1/0,Yt=Number.isFinite(Gt)?2*(1-X(Math.abs(Gt),rt)):0,Zt=Number.isFinite(Bt)?Bt*Dt:null;return{name:Ft===0?"(intercept)":gt[Ft-1],estimate:Pt,stdError:Dt,t:Gt,p:Math.max(0,Math.min(1,Yt)),lower:Zt===null?null:Pt-Zt,upper:Zt===null?null:Pt+Zt}}),hn=new Array(Le),sn=new Array(Le);for(let Pt=0;Pt<Le;Pt++){const Ft=ot?ot[Pt]:1,Dt=Math.max(0,Math.min(1,Ft*a(Ne[Pt],dt)));hn[Pt]=Dt;const Gt=(1-Dt)**2;sn[Pt]=Gt>0&&vt>0?wt[Pt]**2/(Me*vt)*(Dt/Gt):null}const cn=ge[0].map((Pt,Ft)=>{if(me<2)return 1;const Dt=ae(ge,Ft);return Dt>=1?1/0:1/(1-Dt)});let _t=null;{const Pt=wt.map(Dt=>Dt*Dt),Ft=te(Ne,Pt,null);if(Ft){const Dt=Pt.reduce((Jt,un)=>Jt+un,0)/Le;let Gt=0,Yt=0;for(let Jt=0;Jt<Le;Jt++)Gt+=Ft.residuals[Jt]**2,Yt+=(Pt[Jt]-Dt)**2;const Zt=Yt===0?0:Math.max(0,Math.min(1,1-Gt/Yt)),Xt=Le*Zt,nn=K(Xt,me);_t={statistic:Xt,df:me,p:nn,heteroscedastic:nn<.05}}}let Wt=null;if(me===1){const Pt=ge.map((Ft,Dt)=>Dt).sort((Ft,Dt)=>ge[Ft][0]-ge[Dt][0]);Wt={confidence:Rt,points:Pt.map(Ft=>{const Dt=Ne[Ft],Gt=Math.sqrt(Math.max(0,vt*a(Dt,dt)));return{x:ge[Ft][0],yhat:st[Ft],lower:st[Ft]-Bt*Gt,upper:st[Ft]+Bt*Gt}})}}return{method:je,coefficients:Qt,r2:Nt,adjR2:$t,n:Le,df:rt,sigma2:vt,fitted:st,residuals:wt,leverage:hn,cooksD:sn,vif:cn,heteroscedasticity:_t,band:Wt,weights:ot?[...ot]:null}}function ce(ge){const we=ge.length,ve=Array.from({length:we},(me,Me)=>Me).sort((me,Me)=>ge[me]-ge[Me]),je=new Float64Array(we);let Le=0;for(;Le<we;){let me=Le;for(;me+1<we&&ge[ve[me+1]]===ge[ve[Le]];)me++;const Me=(Le+me)/2+1;for(let Ae=Le;Ae<=me;Ae++)je[ve[Ae]]=Me;Le=me+1}return je}const fe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(ge){const we=[.01,.05,.1],ve=[fe["1%"],fe["5%"],fe["10%"]];if(ge<=ve[0]){const me=(Math.log(we[1])-Math.log(we[0]))/(ve[1]-ve[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(we[0])+me*(ge-ve[0]))))}if(ge>=ve[2]){const me=(Math.log(we[2])-Math.log(we[1]))/(ve[2]-ve[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(we[2])+me*(ge-ve[2]))))}const je=ge<ve[1]?0:1,Le=(ge-ve[je])/(ve[je+1]-ve[je]);return Math.exp(Math.log(we[je])+Le*(Math.log(we[je+1])-Math.log(we[je])))}function Re(ge,we,ve,je){const Le=ve-je,me=je+3,Me=new Array(Le),Ae=new Array(Le);let Ne=!0,De=je;for(let st=0;st<Le;st++){const wt=je+st,ct=new Float64Array(me);ct[0]=1,ct[1]=st+1,ct[2]=ge[wt];for(let pt=1;pt<=je;pt++)ct[2+pt]=we[wt-pt];for(let pt=1;pt<me;pt++)Number.isFinite(ct[pt])||(De=Math.min(De,pt-3));Me[st]=ct,Ae[st]=we[wt],Number.isFinite(Ae[st])||(Ne=!1)}if(!Ne)return 0;const{xtwx:qe,xtwy:ot}=u(Me,Ae,null);let ut=0,dt=1/0;for(let st=0;st<=De;st++){const wt=st+3;if(!(Le>wt))continue;const ct=new Array(wt);for(let Nt=0;Nt<wt;Nt++)ct[Nt]=qe[Nt].slice(0,wt);const pt=v(ct);if(!pt)continue;const jt=O(pt,ot.slice(0,wt));let He=0;for(let Nt=0;Nt<Le;Nt++){const $t=Me[Nt];let gt=0;for(let Rt=0;Rt<wt;Rt++)gt+=$t[Rt]*jt[Rt];He+=(Ae[Nt]-gt)**2}const rt=He/(Le-wt)*(Le-wt);if(!(rt>0))continue;const vt=Le*Math.log(rt/Le)+2*wt;vt<dt&&(dt=vt,ut=st)}return ut}function Ee(ge,we={}){const ve=[];for(let dt=0;dt<ge.length;dt++){const st=Number(ge[dt]);Number.isFinite(st)&&ve.push(st)}const je=ve.length,Le=je-1;if(je<8||Le<6)return null;const me=new Array(Le);for(let dt=0;dt<Le;dt++)me[dt]=ve[dt+1]-ve[dt];let Me=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.ceil(12*(je/100)**.25);Me=Math.max(0,Math.min(Me,Math.floor((Le-5)/2)));const Ae=(dt,st)=>{const wt=[],ct=[];for(let pt=st;pt<Le;pt++){const jt=[pt-st+1,ve[pt]];for(let He=1;He<=dt;He++)jt.push(me[pt-He]);wt.push(jt),ct.push(me[pt])}return oe(wt,ct,{method:"ols"})},Ne=Re(ve,me,Le,Me),De=Ae(Ne,Ne);if(!De||!De.coefficients[2])return null;const qe=De.coefficients[2].t,ot=ke(qe),ut=qe<fe["5%"];return{statistic:qe,usedLag:Ne,nobs:Le-Ne,criticalValues:{...fe},pValue:ot,pApproximate:!0,stationary:ut,verdict:ut?"stationary":"non-stationary",regression:"ct"}}function Fe(ge,we={}){const ve=[];for(let ut=0;ut<ge.length;ut++){const dt=Number(ge[ut]);Number.isFinite(dt)&&ve.push(dt)}const je=ve.length;if(je<3)return null;let Le=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.min(10,je-1);Le=Math.max(1,Math.min(Le,je-1));let me=0;for(const ut of ve)me+=ut;me/=je;const Me=ve.map(ut=>ut-me);let Ae=0;for(const ut of Me)Ae+=ut*ut;Ae/=je;const Ne=new Array(Le+1).fill(0);Ne[0]=1;for(let ut=1;ut<=Le;ut++){let dt=0;for(let st=ut;st<je;st++)dt+=Me[st]*Me[st-ut];Ne[ut]=Ae>0?dt/je/Ae:0}const De=new Array(Le+1).fill(0);De[0]=1;let qe=[];for(let ut=1;ut<=Le;ut++){let dt=Ne[ut];for(let pt=1;pt<ut;pt++)dt-=qe[pt-1]*Ne[ut-pt];let st=1;for(let pt=1;pt<ut;pt++)st-=qe[pt-1]*Ne[pt];const wt=st!==0?dt/st:0,ct=new Array(ut);for(let pt=1;pt<ut;pt++)ct[pt-1]=qe[pt-1]-wt*qe[ut-1-pt];ct[ut-1]=wt,De[ut]=wt,qe=ct}const ot=1.96/Math.sqrt(je);return{acf:Ne,pacf:De,bounds:{upper:ot,lower:-ot},n:je,nlags:Le,approximate:!0}}function ye(ge,we,ve){const{xs:je,ys:Le,n:me}=S(ge,we,ve);if(me<2)return null;const Me=ce(je),Ae=ce(Le);let Ne=0,De=0;for(let dt=0;dt<me;dt++)Ne+=Me[dt],De+=Ae[dt];Ne/=me,De/=me;let qe=0,ot=0,ut=0;for(let dt=0;dt<me;dt++){const st=Me[dt]-Ne,wt=Ae[dt]-De;qe+=st*wt,ot+=st*st,ut+=wt*wt}return ot===0||ut===0?null:Math.max(-1,Math.min(1,qe/Math.sqrt(ot*ut)))}function he(ge,we,ve){const{xs:je,ys:Le,n:me}=S(ge,we,ve);if(me<2||me>t)return null;let Me=0,Ae=0,Ne=0,De=0;for(let ut=0;ut<me;ut++)for(let dt=ut+1;dt<me;dt++){const st=Math.sign(je[ut]-je[dt]),wt=Math.sign(Le[ut]-Le[dt]),ct=st*wt;ct>0?Me++:ct<0?Ae++:st===0&&wt===0||(st===0?Ne++:De++)}const qe=Me+Ae+De,ot=Me+Ae+Ne;return qe===0||ot===0?null:(Me-Ae)/Math.sqrt(qe*ot)}function Se(ge,we={}){const ve=ge.length;if(ve<2)return null;const je=ge[0],Le=ge[ve-1],me=[];for(let pt=1;pt<ve;pt++){const jt=ge[pt-1];jt!==0&&me.push((ge[pt]-jt)/Math.abs(jt))}let Me=null;if(me.length>1){let pt=0;for(const He of me)pt+=He;pt/=me.length;let jt=0;for(const He of me)jt+=(He-pt)**2;Me=Math.sqrt(jt/(me.length-1))}const Ae=Number(we.periodsPerYear)>0?Number(we.periodsPerYear):null;let Ne=ge[0],De=0,qe=0,ot=0,ut=0;for(let pt=1;pt<ve;pt++){if(ge[pt]>Ne){Ne=ge[pt],De=pt;continue}if(Ne<=0)continue;const jt=(Ne-ge[pt])/Ne;jt>qe&&(qe=jt,ot=De,ut=pt)}let dt=null;if(ve>2){let pt=0;for(let lt=0;lt<ve;lt++)pt+=ge[lt];pt/=ve;let jt=0,He=0;for(let lt=0;lt<ve;lt++){const rt=ge[lt]-pt;He+=rt*rt,lt>0&&(jt+=rt*(ge[lt-1]-pt))}dt=He>0?jt/He:null}let st=0,wt=0;for(const pt of me)pt>0?st++:pt<0&&wt++;let ct=null;if(je>0&&Le>0){const pt=(Le/je)**(1/(ve-1))-1;ct=Ae?(1+pt)**Ae-1:pt}return{n:ve,first:je,last:Le,change:Le-je,changePercent:je===0?null:(Le-je)/Math.abs(je)*100,volatility:Me,annualisedVolatility:Me!==null&&Ae?Me*Math.sqrt(Ae):null,growth:ct,maxDrawdown:qe,maxDrawdownFrom:ot,maxDrawdownTo:ut,autocorrelation:dt,upDays:st,downDays:wt}}const Ce=1.128,Ie=3.267;function ze(ge){const we=ge.length;if(we<2)return null;const ve=[];for(let Le=1;Le<we;Le++)ve.push(Math.abs(ge[Le]-ge[Le-1]));const je=ve.reduce((Le,me)=>Le+me,0)/ve.length;return{ranges:ve,centre:je,upper:Ie*je,lower:0}}function Ye(ge){const we=ge.length;if(we<2)return null;let ve=0;for(let Le=1;Le<we;Le++)ve+=Math.abs(ge[Le]-ge[Le-1]);const je=ve/(we-1);return{sigma:je/Ce,meanRange:je}}function Qe(ge,we){const ve=ge.length;if(ve<2||!we)return null;const je=Number.isFinite(Number(we.lower))?Number(we.lower):null,Le=Number.isFinite(Number(we.upper))?Number(we.upper):null;if(je===null&&Le===null)return null;let me=0;for(let st=0;st<ve;st++)me+=ge[st];me/=ve;let Me=0;for(let st=0;st<ve;st++)Me+=(ge[st]-me)**2;const Ae=Math.sqrt(Me/(ve-1)),Ne=Ye(ge),De=Ne?Ne.sigma:null,qe=st=>{if(!st||st<=0)return{index:null,k:null};const ct=je!==null&&Le!==null?(Le-je)/(6*st):null,pt=Le!==null?(Le-me)/(3*st):1/0,jt=je!==null?(me-je)/(3*st):1/0;return{index:ct,k:Math.min(pt,jt)}},ot=qe(De),ut=qe(Ae);let dt=0;for(let st=0;st<ve;st++){if(je!==null&&ge[st]<je){dt++;continue}Le!==null&&ge[st]>Le&&dt++}return{n:ve,mean:me,lower:je,upper:Le,target:Number.isFinite(Number(we.target))?Number(we.target):null,sigmaWithin:De,sigmaOverall:Ae,cp:ot.index,cpk:ot.k,pp:ut.index,ppk:ut.k,outOfSpec:dt,defectRate:ve?dt/ve:null}}function Te(ge){const we=ge.length;if(we<2)return null;const ve=Ye(ge);if(!ve||!(ve.sigma>0))return null;let je=0;for(let Le=0;Le<we;Le++)je+=ge[Le];return je/=we,{centre:je,sigma:ve.sigma,upper:je+3*ve.sigma,lower:je-3*ve.sigma}}function _e(ge,we){if(!we||!(we.sigma>0))return[];const ve=ge.length,{centre:je,sigma:Le}=we,me=Ae=>(ge[Ae]-je)/Le,Me=[];for(let Ae=0;Ae<ve;Ae++){if(Math.abs(me(Ae))>3&&Me.push({index:Ae,rule:1,description:"beyond three sigma"}),Ae>=2)for(const Ne of[1,-1]){let De=0;for(let qe=Ae-2;qe<=Ae;qe++)me(qe)*Ne>2&&De++;if(De>=2){Me.push({index:Ae,rule:2,description:"two of three past two sigma"});break}}if(Ae>=4)for(const Ne of[1,-1]){let De=0;for(let qe=Ae-4;qe<=Ae;qe++)me(qe)*Ne>1&&De++;if(De>=4){Me.push({index:Ae,rule:3,description:"four of five past one sigma"});break}}if(Ae>=7)for(const Ne of[1,-1]){let De=!0;for(let qe=Ae-7;qe<=Ae;qe++)if(me(qe)*Ne<=0){De=!1;break}if(De){Me.push({index:Ae,rule:4,description:"eight in a row on one side"});break}}}return Me}function Ke(ge,we){if(!we||!(we.sigma>0))return[];const ve=ge.length,{centre:je,sigma:Le}=we,me=Ne=>(ge[Ne]-je)/Le,Me=(Ne,De,qe,ot)=>{for(const ut of[1,-1]){let dt=0;for(let st=Ne;st<=De;st++)me(st)*ut>qe&&dt++;if(dt>=ot)return!0}return!1},Ae=[];for(let Ne=0;Ne<ve;Ne++){if(Math.abs(me(Ne))>3&&Ae.push({index:Ne,rule:1,description:"beyond three sigma"}),Ne>=8)for(const De of[1,-1]){let qe=!0;for(let ot=Ne-8;ot<=Ne;ot++)if(me(ot)*De<=0){qe=!1;break}if(qe){Ae.push({index:Ne,rule:2,description:"nine in a row on one side"});break}}if(Ne>=5)for(const De of[1,-1]){let qe=!0;for(let ot=Ne-4;ot<=Ne;ot++)if((ge[ot]-ge[ot-1])*De<=0){qe=!1;break}if(qe){Ae.push({index:Ne,rule:3,description:De>0?"six rising":"six falling"});break}}if(Ne>=13){let De=!0;for(let qe=Ne-12;qe<=Ne;qe++){const ot=ge[qe]-ge[qe-1],ut=ge[qe+1<=Ne?qe+1:qe]-ge[qe];if(qe+1>Ne)break;if(ot===0||ut===0||ot>0==ut>0){De=!1;break}}De&&Ae.push({index:Ne,rule:4,description:"fourteen alternating"})}if(Ne>=2&&Me(Ne-2,Ne,2,2)&&Ae.push({index:Ne,rule:5,description:"two of three past two sigma"}),Ne>=4&&Me(Ne-4,Ne,1,4)&&Ae.push({index:Ne,rule:6,description:"four of five past one sigma"}),Ne>=14){let De=!0;for(let qe=Ne-14;qe<=Ne;qe++)if(Math.abs(me(qe))>=1){De=!1;break}De&&Ae.push({index:Ne,rule:7,description:"fifteen within one sigma"})}if(Ne>=7){let De=!0;for(let qe=Ne-7;qe<=Ne;qe++)if(Math.abs(me(qe))<=1){De=!1;break}De&&Ae.push({index:Ne,rule:8,description:"eight beyond one sigma"})}}return Ae}const tt=Object.freeze(["westernElectric","nelson"]);function it(ge,we,ve="westernElectric"){return String(ve)==="nelson"?Ke(ge,we):_e(ge,we)}function ht(ge,we,ve){let je=0;for(let Le=0;Le<ge.length;Le++)(ge[Le]<we||ge[Le]>ve)&&je++;return je}function yt(ge,we,ve,je=20){const Le=ge.length;if(!Le)return[];const me=ge[0],Me=ge[Le-1];if(Me===me)return[{from:me,to:Me,count:Le}];const Ae=ve-we,Ne=1.5*Ae;let De=Ae>0?Math.max(me,we-Ne):me,qe=Ae>0?Math.min(Me,ve+Ne):Me;qe>De||(De=me,qe=Me);const ot=Ae>0?2*Ae/Math.cbrt(Le):(qe-De)/(Math.ceil(Math.log2(Le))+1),ut=ot>0?Math.min(je,Math.max(1,Math.ceil((qe-De)/ot))):1,dt=(qe-De)/ut,st=[];for(let wt=0;wt<ut;wt++)st.push({from:De+wt*dt,to:De+(wt+1)*dt,count:0});for(let wt=0;wt<Le;wt++){const ct=Math.min(ut-1,Math.max(0,Math.floor((ge[wt]-De)/dt)));st[ct].count++}return st[0].from=me,st[ut-1].to=Me,st}const St=.95;function At(ge){const we=Number(ge);return Number.isFinite(we)&&we>0&&we<1?we:St}function Ct(ge,we=St){const ve=ge.length;if(ve<2)return null;let je=0;for(let qe=0;qe<ve;qe++)je+=ge[qe];const Le=je/ve;let me=0;for(let qe=0;qe<ve;qe++){const ot=ge[qe]-Le;me+=ot*ot}const Me=Math.sqrt(me/(ve-1)),Ae=At(we),De=W(1-(1-Ae)/2,ve-1)*Me/Math.sqrt(ve);return{mean:Le,lower:Le-De,upper:Le+De,margin:De,n:ve,confidence:Ae}}function Tt(ge,we,ve=St){const je=Number(ge),Le=Number(we);if(!(Le>0)||!(je>=0)||je>Le)return null;const me=At(ve),Me=H(1-(1-me)/2),Ae=je/Le,Ne=Me*Me,De=1+Ne/Le,qe=(Ae+Ne/(2*Le))/De,ot=Me/De*Math.sqrt(Ae*(1-Ae)/Le+Ne/(4*Le*Le));return{proportion:Ae,lower:Math.max(0,qe-ot),upper:Math.min(1,qe+ot),n:Le,confidence:me}}function It(ge,we=St){if(!ge||!(ge.n>2)||!Number.isFinite(ge.stdError))return null;const ve=At(we),Le=W(1-(1-ve)/2,ge.n-2)*ge.stdError;return{slope:ge.slope,lower:ge.slope-Le,upper:ge.slope+Le,margin:Le,confidence:ve}}function zt(ge,we,ve=St){const je=Number(ge),Le=Number(we);if(!Number.isFinite(je)||!(Le>1))return null;const me=At(ve),Ae=H(1-(1-me)/2)*Math.sqrt(1/(9*Le)+je*je/(2*(Le-1)));return{index:je,lower:je-Ae,upper:je+Ae,margin:Ae,n:Le,confidence:me}}function Xe(ge,we){return!ge||!(ge.sd>0)||!Number.isFinite(we)||!Number.isFinite(ge.mean)?null:(we-ge.mean)/ge.sd}function Ge(ge){return Number.isFinite(ge)?Math.min(1,Math.max(0,2*V(Math.abs(ge)/2)-1)):0}function se(ge,we){const ve=new Map,je=B(ge);let Le=0;for(let me=0;me<we.length;me++){const Me=je(we[me]);if(Me==null||Me===""||typeof Me=="number"&&Number.isNaN(Me))continue;const Ae=Me instanceof Date?Me.getTime():typeof Me=="object"?String(Me):Me;ve.set(Ae,(ve.get(Ae)||0)+1),Le++}return{map:ve,total:Le}}function pe(ge,we,ve,je){if(!(we>0)||!(je>0))return null;let Le=0;const me=new Set(ge.keys());for(const Me of ve.keys())me.add(Me);for(const Me of me){const Ae=(ge.get(Me)||0)/we,Ne=(ve.get(Me)||0)/je;Le+=Math.abs(Ae-Ne)}return Le/2}const be=10;function Ue(ge,we,ve){if(ve&&ve.numeric){const Ae=c(ge,we),{n:Ne,mean:De}=k(Ae),qe=Ne>0?Xe({mean:ve.mean,sd:ve.sd},De):null;return{measure:"standardizedMeanDifference",magnitude:qe,distance:qe===null?0:Ge(qe),direction:qe===null?0:Math.sign(qe),subsetN:Ne,populationN:ve.n||0,reliable:Ne>=be}}const{map:Le,total:me}=se(ge,we),Me=pe(Le,me,ve.map,ve.total);return{measure:"categoricalTotalVariation",magnitude:Me,distance:Me===null?0:Me,direction:0,subsetN:me,populationN:ve.total||0,reliable:me>=be}}function Ve(ge,we){if(ge&&(ge.kind==="float64"||ge.kind==="int32"))return!0;const ve=B(ge);let je=0,Le=0;for(let me=0;me<we.length&&je<200;me++){const Me=ve(we[me]);if(Me==null||Me==="")continue;if(Me instanceof Date)return!1;je++;const Ae=typeof Me=="number"?Me:Number(Me);Number.isFinite(Ae)&&Le++}return je===0?!1:Le/je>=.9}function nt(ge,we){if(Ve(ge,we)){const Le=c(ge,we),{n:me,mean:Me,m2:Ae}=k(Le);return{numeric:!0,mean:Me,sd:me>0?Math.sqrt(Ae/me):0,n:me}}const{map:ve,total:je}=se(ge,we);return{numeric:!1,map:ve,total:je}}}),xe("packages/core/src/compute/total.js",function(e,G){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,F=G("packages/core/src/compute/handle.js"),W=F.presenceReader,X=F.valueComparator,H=F.valueReader,V=G("packages/core/src/compute/statistics.js"),K=V.STAT_FNS,D=V.STAT_LABELS;function v(k){return!!k&&(k.kind==="float64"||k.kind==="int32")}function O(k,p){const b=p.length;let E=0;if(v(k)){const P=k.values,x=W(k);if(!x){for(let C=0;C<b;C++){const A=P[p[C]];Number.isNaN(A)||(E+=A)}return E}for(let C=0;C<b;C++){const A=p[C];if(x(A)===1){const j=P[A];Number.isNaN(j)||(E+=j)}}return E}const T=H(k);for(let P=0;P<b;P++){const x=f(T(p[P]));x!==null&&(E+=x)}return E}O.kernel=!0;function y(k,p){const b=p.length;let E=0;if(v(k)){const P=k.values,x=W(k);if(!x){for(let C=0;C<b;C++)Number.isNaN(P[p[C]])||E++;return E}for(let C=0;C<b;C++){const A=p[C];x(A)===1&&!Number.isNaN(P[A])&&E++}return E}const T=H(k);for(let P=0;P<b;P++){const x=T(p[P]);x!=null&&!(typeof x=="number"&&Number.isNaN(x))&&E++}return E}y.kernel=!0;function u(k,p){return p.length}u.kernel=!0;function a(k,p){const b=y(k,p);return b===0?null:O(k,p)/b}a.kernel=!0;function s(k,p,b,E){const T=p.length;if(v(k)){const A=k.values,j=W(k);let $=null;if(!j){for(let z=0;z<T;z++){const M=A[p[z]];Number.isNaN(M)||($===null||(b<0?M<$:M>$))&&($=M)}return $}for(let z=0;z<T;z++){const M=p[z];if(j(M)===0)continue;const R=A[M];Number.isNaN(R)||($===null||(b<0?R<$:R>$))&&($=R)}return $}const P=H(k),x=X(E);let C=null;for(let A=0;A<T;A++){const j=P(p[A]);j==null||typeof j=="number"&&Number.isNaN(j)||(C===null||(b<0?x(j,C)<0:x(j,C)>0))&&(C=j)}return C}function n(k,p,b){return s(k,p,-1,b&&b.locale)}n.kernel=!0;function t(k,p,b){return s(k,p,1,b&&b.locale)}t.kernel=!0;function r(k,p){return p.length===0?null:H(k)(p[0])}r.kernel=!0;function o(k,p){return p.length===0?null:H(k)(p[p.length-1])}o.kernel=!0;function f(k){if(typeof k=="number")return Number.isNaN(k)?null:k;if(k==null||k===""||typeof k=="boolean")return null;if(k instanceof Date)return k.getTime();const p=Number(k);return Number.isNaN(p)?null:p}const c={sum:O,min:n,max:t,avg:a,count:u,first:r,last:o,countValues:y,...K},i=Object.freeze({...D,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function g(k){return k?typeof k=="string"?i[k]||k:"Total":""}const d=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function h(k){const p=k&&k.dataType&&k.dataType.totals&&k.dataType.totals.supported;if(Array.isArray(p))return p.slice();const b=d.filter(E=>E in c);for(const E of Object.keys(c))b.includes(E)||b.push(E);return b}function l(k,p){return typeof p!="string"?!0:h(k).includes(p)}function m(k,p){const b=H(k),E=[];for(let T=0;T<p.length;T++){const P=b(p[T]);P!=null&&E.push(P)}return E}function w(k,p,b,E){const T=p||[];if(typeof b=="string"){const P=c[b];return P?P(k,T,E):(B(`total:${b}`,`unknown total function "${b}"; register it in config.totalFns`),null)}return L(b)?b.kernel===!0?b(k,T,E):b(m(k,T),E||{}):null}}),xe("packages/core/src/compute/windowed.js",function(e,G){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(V,K=0,D=Date.now){if(V!=="count"&&V!=="time"&&V!=="session")throw new RangeError(`unknown window kind: ${V}`);if((V==="count"||V==="time")&&!(K>0))throw new RangeError(`a ${V} window needs a positive span`);this.#e=V,this.#t=Math.floor(K),this.#r=D,this.#o=D()}get size(){return this.#n.length}push(V,K=this.#r()){Number.isFinite(V)&&(this.#n.push({t:K,v:V}),this.#i(K))}#i(V){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const K=V-this.#t;for(;this.#n.length&&this.#n[0].t<K;)this.#n.shift()}}spec(){const V=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:V,size:this.#n.length}}values(){return this.#n.map(V=>V.v)}aggregate(){const V=this.spec();if(!this.#n.length)return{over:V,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const K=new L;let D=0,v=1/0,O=-1/0;for(const{v:y}of this.#n)D+=y,y<v&&(v=y),y>O&&(O=y),K.add(y);return{over:V,count:this.#n.length,sum:D,mean:K.mean(),min:v,max:O,variance:K.variance(),stddev:K.stddev()}}reduce(V){const K=this.aggregate(),D={sum:K.sum,avg:K.mean,mean:K.mean,min:K.min,max:K.max,count:K.count,variance:K.variance,stddev:K.stddev};if(!(V in D))throw new RangeError(`unknown windowed aggregate: ${V}`);return{value:D[V],over:K.over}}}const F=Object.freeze(["count","time","session"]);function W(H,V=Date.now){const K=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new B(H.kind,K,V)}const X={Window:B,WINDOW_KINDS:F,openWindow:W}}),xe("packages/core/src/compute/rolling.js",function(e,G){"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 V}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return K}}),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 a}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const L=G("packages/core/src/compute/windowed.js").openWindow,F=G("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function X(i,g,d,h){if(i.kind==="count"){const l=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,g/l),partial:g<l}}if(i.kind==="time"){const l=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(l>0))return{coverage:1,partial:!1};const m=d-h;return{coverage:Math.min(1,m/l),partial:m<l}}return{coverage:null,partial:!1}}function H(i,g){const d=L(g),h=new Map,l=i.length?i[0].at:0;for(let m=0;m<i.length;m++){const{key:w,at:k,value:p}=i[m];Number.isFinite(p)&&d.push(p,k);const b=d.aggregate(),E=X(g,b.count,k,l);w!=null&&h.set(String(w),{sum:b.sum,avg:b.mean,min:b.min,max:b.max,count:b.count,coverage:E.coverage,partial:E.partial})}return h}function V(i){const g=new Map;let d=0;for(const{key:h,value:l}of i)Number.isFinite(l)&&(d+=l),h!=null&&g.set(String(h),d);return g}function K(i,g=1){const d=new Map,h=Math.max(1,Math.floor(g));for(let l=0;l<i.length;l++){const{key:m,value:w}=i[l];if(m==null)continue;const k=l>=h?i[l-h].value:null,p=Number.isFinite(w)?w:null,b=Number.isFinite(k)?k:null;d.set(String(m),p!==null&&b!==null?p-b:null)}return d}const D=4096;function v(i){let g=i>>>0;return()=>{g+=1831565813;let d=g;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function O(i,g){const d=i.length;if(d===1)return i[0];const h=(d-1)*g,l=Math.floor(h),m=Math.ceil(h);return l===m?i[l]:i[l]+(h-l)*(i[m]-i[l])}function y(i,g,d={}){const h=Math.min(1,Math.max(0,d.q==null?.5:d.q)),l=Math.max(1,Math.floor(d.cap==null?D:d.cap)),m=v(d.seed==null?2654435769:d.seed),w=new Map,k=i.length?i[0].at:0;if(g.kind==="session"){const b=new F(200,m);let E=0;for(const{key:T,value:P}of i)Number.isFinite(P)&&(b.add(P),E++),T!=null&&w.set(String(T),{value:E?b.quantile(h):null,approx:E>0,count:E,coverage:null,partial:!1});return w}const p=L(g);for(const{key:b,at:E,value:T}of i){Number.isFinite(T)&&p.push(T,E);const P=p.values(),x=P.length;let C=null,A=!1;if(x)if(x<=l)C=O([...P].sort(($,z)=>$-z),h);else{const $=new F(200,m);for(const z of P)$.add(z);C=$.quantile(h),A=!0}const j=X(g,x,E,k);b!=null&&w.set(String(b),{value:C,approx:A,count:x,coverage:j.coverage,partial:j.partial})}return w}function u(i,g){const d=i.length,h=new Array(d).fill(null),l=Math.floor(g/2),m=g%2===0;for(let w=0;w<d;w++){if(w-l<0||w+l>=d)continue;let k=0,p=!0;if(m)for(let b=-l;b<=l;b++){const E=i[w+b];if(!Number.isFinite(E)){p=!1;break}k+=b===-l||b===l?E*.5:E}else for(let b=-l;b<=l;b++){const E=i[w+b];if(!Number.isFinite(E)){p=!1;break}k+=E}p&&(h[w]=k/g)}return h}function a(i,g){const d=new Map,h=Math.floor(Number(g&&g.period));if(!(h>=2))return d;const l=g&&g.model==="multiplicative",m=i.length,w=i.map(A=>Number.isFinite(A.value)?A.value:null),k=u(w,h),p=new Array(m).fill(null);for(let A=0;A<m;A++){const j=k[A],$=w[A];j===null||$===null||(l?j!==0&&(p[A]=$/j):p[A]=$-j)}const b=new Array(h).fill(0),E=new Array(h).fill(0);for(let A=0;A<m;A++){if(p[A]===null)continue;const j=A%h;b[j]+=p[A],E[j]+=1}const T=l?1:0,P=b.map((A,j)=>E[j]?A/E[j]:T),x=P.reduce((A,j)=>A+j,0)/h,C=l?P.map(A=>x!==0?A/x:1):P.map(A=>A-x);for(let A=0;A<m;A++){const{key:j}=i[A];if(j==null)continue;const $=k[A],z=C[A%h],M=w[A];let R=null;$!==null&&M!==null&&(R=l?$*z!==0?M/($*z):null:M-$-z),d.set(String(j),{trend:$,seasonal:M===null?null:z,residual:R,coverage:$===null?0:1,partial:$===null})}return d}function s(i,g,d,h=80){const l=(Math.sqrt(5)-1)/2;let m=g,w=d,k=w-l*(w-m),p=m+l*(w-m),b=i(k),E=i(p);for(let T=0;T<h;T++)b<E?(w=p,p=k,E=b,k=w-l*(w-m),b=i(k)):(m=k,k=p,b=E,p=m+l*(w-m),E=i(p));return(m+w)/2}const n=1e-4,t=1-1e-4;function r(i,g){const d=i.length,h=new Array(d).fill(null),l=new Array(d).fill(null);let m=null,w=0;for(let k=0;k<d;k++){const p=i[k];if(!Number.isFinite(p)){m!==null&&(l[k]=m,h[k]=m);continue}if(m===null){m=p,l[k]=p,h[k]=p;continue}l[k]=m,w+=(p-m)**2,m=g*p+(1-g)*m,h[k]=m}return{smoothed:h,fitted:l,sse:w}}function o(i,g,d){const h=i.length,l=new Array(h).fill(null),m=new Array(h).fill(null);let w=null,k=null,p=0;for(let b=0;b<h;b++){const E=i[b];if(!Number.isFinite(E)){w!==null&&(w+=k,l[b]=w);continue}if(w===null){w=E,l[b]=E;continue}if(k===null){k=E-w;const x=w+k;m[b]=x,p+=(E-x)**2;const C=w;w=g*E+(1-g)*(C+k),k=d*(w-C)+(1-d)*k,l[b]=w;continue}const T=w+k;m[b]=T,p+=(E-T)**2;const P=w;w=g*E+(1-g)*(P+k),k=d*(w-P)+(1-d)*k,l[b]=w}return{smoothed:l,fitted:m,sse:p}}function f(i,g={}){const d=new Map,h=g.method==="holt",l=i.map(T=>Number.isFinite(T.value)?T.value:null),m=l.filter(T=>T!==null).length,w=T=>Math.min(t,Math.max(n,T)),k=()=>{for(const{key:T}of i)T!=null&&d.set(String(T),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return d};if(m<(h?2:1))return k();let p=Number.isFinite(g.alpha)?w(g.alpha):null,b=h&&Number.isFinite(g.beta)?w(g.beta):null;if(h){if(p===null||b===null){let T=p===null?.5:p,P=b===null?.5:b;for(let x=0;x<6;x++)p===null&&(T=s(C=>o(l,C,P).sse,n,t)),b===null&&(P=s(C=>o(l,T,C).sse,n,t));p=p===null?T:p,b=b===null?P:b}}else p===null&&(p=s(T=>r(l,T).sse,n,t));const E=h?o(l,p,b):r(l,p);for(let T=0;T<i.length;T++){const{key:P}=i[T];P!=null&&d.set(String(P),{smoothed:E.smoothed[T],fitted:E.fitted[T],alpha:p,beta:h?b:null,sse:E.sse})}return d}const c={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:D,rollingWindow:H,rollingQuantile:y,cumulativeToDate:V,periodOverPeriod:K,seasonalDecompose:a,exponentialSmoothing:f}}),xe("packages/core/src/compute/compare.js",function(e,G){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const Q=G("packages/core/src/compute/statistics.js"),L=Q.numbers,B=Q.moments,F=Q.frequencyMap,W=Q.categoricalDistance,X=Q.normalTotalVariation,H=Q.isNumericColumn,V=Q.SUBSET_RELIABILITY_FLOOR,K=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function D(a,s){if(!a||!s||!(a.n>0)||!(s.n>0)||!Number.isFinite(a.mean)||!Number.isFinite(s.mean))return null;const n=(a.n*a.sd*a.sd+s.n*s.sd*s.sd)/(a.n+s.n);return n>0?(a.mean-s.mean)/Math.sqrt(n):null}function v(a,s){const n=L(a,s),{n:t,mean:r,m2:o}=B(n),f=t>0?Math.sqrt(o/t):0;return{mean:r,sd:f,n:t}}function O(a,s,n,t){return H(a,s)&&H(n,t)}function y(a,s,n,t){if(O(a,s,n,t)){const c=v(a,s),i=v(n,t),g=D(c,i);return{measure:K.numeric,magnitude:g,distance:g===null?0:X(g),direction:g===null?0:Math.sign(g),nA:c.n,nB:i.n,reliable:c.n>=V&&i.n>=V}}const r=F(a,s),o=F(n,t),f=W(r.map,r.total,o.map,o.total);return{measure:K.categorical,magnitude:f,distance:f===null?0:f,direction:0,nA:r.total,nB:o.total,reliable:r.total>=V&&o.total>=V}}function u(a,s,n={}){const t=new Set(a.columns),r=new Set(s.columns),o=a.columns.filter(d=>r.has(d)),f=Array.isArray(n.columns)&&n.columns.length?o.filter(d=>n.columns.includes(d)):o,c=a.indices(),i=s.indices(),g=[];for(const d of f){const h=a.handle(d),l=s.handle(d);if(!h||!l)continue;const m=y(h,c,l,i);g.push({column:d,name:a.name&&a.name(d)||s.name&&s.name(d)||d,measure:m.measure,magnitude:m.magnitude,distance:m.distance,direction:m.direction,nA:m.nA,nB:m.nB,reliable:m.reliable})}return g.sort((d,h)=>h.distance-d.distance||Math.abs(h.magnitude||0)-Math.abs(d.magnitude||0)),{ranked:g,nA:c.length,nB:i.length,unmatched:{onlyA:a.columns.filter(d=>!r.has(d)),onlyB:s.columns.filter(d=>!t.has(d))},measures:K}}}),xe("packages/core/src/compute/anomaly.js",function(e,G){"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 X}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c}});const L=G("packages/core/src/compute/statistics.js").quantileSorted,F=G("packages/core/src/compute/special.js").logGamma,W=.6745,X=3.5,H=1.5,V=.975,K=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function D(i){if(!i.length)return null;const d=Array.from(i,Number).sort((w,k)=>w-k),h=L(d,.5),l=d.map(w=>Math.abs(w-h)).sort((w,k)=>w-k),m=L(l,.5);return{median:h,mad:m}}function v(i,g={}){const d=Number.isFinite(g.threshold)?g.threshold:X,h=i.length,l=new Array(h).fill(null),m=new Array(h).fill(!1),w=[];for(let b=0;b<h;b++){const E=Number(i[b]);Number.isFinite(E)&&w.push(E)}if(!w.length)return{median:null,mad:null,threshold:d,scores:l,flags:m,flagged:0};const k=D(w);if(k.mad===0)return{median:k.median,mad:0,threshold:d,scores:l,flags:m,flagged:0};let p=0;for(let b=0;b<h;b++){const E=Number(i[b]);if(!Number.isFinite(E))continue;const T=W*(E-k.median)/k.mad;l[b]=T,Math.abs(T)>d&&(m[b]=!0,p++)}return{median:k.median,mad:k.mad,threshold:d,scores:l,flags:m,flagged:p}}function O(i,g={}){const d=Number.isFinite(g.k)?g.k:H,h=[];for(let p=0;p<i.length;p++){const b=Number(i[p]);Number.isFinite(b)&&h.push(b)}if(!h.length)return null;const l=h.sort((p,b)=>p-b),m=L(l,.25),w=L(l,.75),k=w-m;return{q1:m,q3:w,iqr:k,lower:m-d*k,upper:w+d*k,k:d}}function y(i,g){if(g<=0)return 0;const d=F(i);if(g<i+1){let b=i,E=1/i,T=E;for(let P=0;P<1e3&&(b+=1,T*=g/b,E+=T,!(Math.abs(T)<Math.abs(E)*1e-15));P++);return E*Math.exp(-g+i*Math.log(g)-d)}const h=1e-300;let l=g+1-i,m=1/h,w=1/l,k=w;for(let b=1;b<1e3;b++){const E=-b*(b-i);l+=2,w=E*w+l,Math.abs(w)<h&&(w=h),m=l+E/m,Math.abs(m)<h&&(m=h),w=1/w;const T=w*m;if(k*=T,Math.abs(T-1)<1e-15)break}return 1-Math.exp(-g+i*Math.log(g)-d)*k}function u(i,g){return i<=0?0:y(g/2,i/2)}function a(i,g=V){if(!(g>0)||!(g<1))return NaN;let d=0,h=Math.max(1,i);for(;u(h,i)<g;)h*=2;for(let l=0;l<200;l++){const m=(d+h)/2;if(u(m,i)<g?d=m:h=m,h-d<1e-10)break}return(d+h)/2}function s(i){const g=i.length,d=i.map((h,l)=>{const m=h.slice();for(let w=0;w<g;w++)m.push(l===w?1:0);return m});for(let h=0;h<g;h++){let l=h;for(let w=h+1;w<g;w++)Math.abs(d[w][h])>Math.abs(d[l][h])&&(l=w);if(Math.abs(d[l][h])<1e-12)return null;if(l!==h){const w=d[l];d[l]=d[h],d[h]=w}const m=d[h][h];for(let w=0;w<2*g;w++)d[h][w]/=m;for(let w=0;w<g;w++){if(w===h)continue;const k=d[w][h];if(k!==0)for(let p=0;p<2*g;p++)d[w][p]-=k*d[h][p]}}return d.map(h=>h.slice(g))}function n(i,g){const d=i.length,h=new Array(g).fill(0);for(const w of i)for(let k=0;k<g;k++)h[k]+=w[k];for(let w=0;w<g;w++)h[w]/=d;const l=Array.from({length:g},()=>new Array(g).fill(0));for(const w of i)for(let k=0;k<g;k++){const p=w[k]-h[k];for(let b=k;b<g;b++)l[k][b]+=p*(w[b]-h[b])}const m=d>1?d-1:1;for(let w=0;w<g;w++)for(let k=w;k<g;k++)l[w][k]/=m,l[k][w]=l[w][k];return{mean:h,cov:l}}function t(i,g={}){const d=Number.isFinite(g.p)?g.p:V,h=Number.isFinite(g.ridge)?g.ridge:1e-6,l=i.length;if(!l)return null;const m=i[0].length;if(!m)return null;const w=new Array(l).fill(null),k=new Array(l).fill(null),p=new Array(l).fill(!1),b=[],E=[];for(let z=0;z<l;z++){const M=i[z];let R=M.length===m;const S=new Array(m);for(let I=0;R&&I<m;I++){const q=Number(M[I]);Number.isFinite(q)?S[I]=q:R=!1}R&&(b.push(z),E.push(S))}const T=m,P=a(T,d);if(E.length<=m)return{center:[],df:T,cutoff:P,singular:!0,used:E.length,distances:w,squared:k,flags:p,flagged:0};const{mean:x,cov:C}=n(E,m);let A=s(C),j=!1;if(!A){j=!0;let z=0;for(let S=0;S<m;S++)z+=C[S][S];const M=z/m*h||h,R=C.map((S,I)=>S.map((q,Z)=>I===Z?q+M:q));if(A=s(R),!A)return{center:x,df:T,cutoff:P,singular:!0,used:E.length,distances:w,squared:k,flags:p,flagged:0}}let $=0;for(let z=0;z<E.length;z++){const M=E[z],R=new Array(m);for(let q=0;q<m;q++)R[q]=M[q]-x[q];let S=0;for(let q=0;q<m;q++){let Z=0;for(let _=0;_<m;_++)Z+=A[q][_]*R[_];S+=R[q]*Z}S<0&&(S=0);const I=b[z];k[I]=S,w[I]=Math.sqrt(S),S>P&&(p[I]=!0,$++)}return{center:x,df:T,cutoff:P,singular:j,used:E.length,distances:w,squared:k,flags:p,flagged:$}}const r=20,o=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function f(i,g={}){const d=g.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(g.windowLen)&&g.windowLen>=1?Math.floor(g.windowLen):r,l=Number.isFinite(g.threshold)?g.threshold:X,m=Number.isFinite(g.k)?g.k:H,w=Number.isFinite(g.minPeriods)&&g.minPeriods>=1?Math.floor(g.minPeriods):h,k=i.length,p=new Array(k).fill(null),b=new Array(k).fill(!1);let E=0;for(let T=0;T<k;T++){const P=Number(i[T]);if(!Number.isFinite(P))continue;const x=Math.max(0,T-h+1),C=[];for(let A=x;A<=T;A++){const j=Number(i[A]);Number.isFinite(j)&&C.push(j)}if(!(C.length<w))if(d==="rollingIqr"){const A=O(C,{k:m});if(!A)continue;(P<A.lower||P>A.upper)&&(b[T]=!0,E++)}else{const A=D(C);if(!A||A.mad===0)continue;const j=W*(P-A.median)/A.mad;p[T]=j,Math.abs(j)>l&&(b[T]=!0,E++)}}return{method:d,windowLen:h,minPeriods:w,threshold:l,k:m,scores:p,flags:b,flagged:E}}function c(i={}){const g=i||{},d=g.field;if(typeof d!="string"||!d)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=g.method||"modifiedZScore";if(!(K.includes(h)||o.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const m=typeof g.orderBy=="string"?g.orderBy:null,w=g.latest===!0,k=o.includes(h),p=b=>Number(b==null?NaN:b[d]);return b=>{const E=Array.isArray(b)?b.slice():[...b];m&&E.sort((A,j)=>{const $=A?.[m],z=j?.[m];return $===z?0:$==null?-1:z==null?1:$<z?-1:1});const T=E.map(p);let P,x;if(k)({flags:P,scores:x}=f(T,{method:h,windowLen:g.windowLen,threshold:g.threshold,k:g.k,minPeriods:g.minPeriods}));else if(h==="iqr"){const A=O(T,{k:g.k});P=T.map(j=>A?Number.isFinite(j)&&(j<A.lower||j>A.upper):!1),x=T.map(()=>null)}else({flags:P,scores:x}=v(T,{threshold:g.threshold}));if(w){const A=P.length-1;return A<0||!P[A]?!1:{method:h,field:d,flagged:[{row:E[A],score:x[A]}]}}const C=[];for(let A=0;A<P.length;A++)P[A]&&C.push({row:E[A],score:x[A]});return C.length?{method:h,field:d,flagged:C}:!1}}}),xe("packages/core/src/compute/forecast.js",function(e,G){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=G("packages/core/src/compute/special.js"),L=Q.normalQuantile,B=Q.studentTQuantile,W=G("packages/core/src/internal/util.js").warnOnce,X=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,V=1-1e-4;function K(g){const d=[];for(let h=0;h<g.length;h++){const l=g[h];if(l!==null&&typeof l=="object"){const m=Number.isFinite(l.at)?l.at:h,w=Number.isFinite(l.value)?l.value:null;d.push({at:m,value:w})}else d.push({at:h,value:Number.isFinite(l)?Number(l):null})}return d}function D(g){const d=g.filter(k=>k.value!==null),h=d[0],l=d[d.length-1],m=l.at-h.at,w=d.length>1&&m>0?m/(d.length-1):1;return{lastAt:l.at,step:w}}function v(g){return Math.min(V,Math.max(H,g))}function O(g,d=H,h=V,l=80){const m=(Math.sqrt(5)-1)/2;let w=d,k=h,p=k-m*(k-w),b=w+m*(k-w),E=g(p),T=g(b);for(let P=0;P<l;P++)E<T?(k=b,b=p,T=E,p=k-m*(k-w),E=g(p)):(w=p,p=b,E=T,b=w+m*(k-w),T=g(b));return(w+k)/2}function y(g,d){let h=null,l=0,m=0;for(let w=0;w<g.length;w++){const k=g[w];if(k!==null){if(h===null){h=k;continue}l+=(k-h)**2,m+=1,h=d*k+(1-d)*h}}return{level:h,sse:l,m}}function u(g,d,h){let l=null,m=null,w=0,k=0;for(let p=0;p<g.length;p++){const b=g[p];if(b===null){l!==null&&m!==null&&(l+=m);continue}if(l===null){l=b;continue}m===null&&(m=b-l);const E=l+m;w+=(b-E)**2,k+=1;const T=l;l=d*b+(1-d)*(T+m),m=h*(l-T)+(1-h)*m}return{level:l,trend:m,sse:w,m:k}}function a(g,d,h,l,m){const w=g.length;if(w<2*d)return null;const k=j=>{let $=0,z=0;for(let M=j;M<j+d&&M<w;M++)g[M]!==null&&($+=g[M],z+=1);return z?$/z:null},p=k(0),b=k(d);if(p===null||b===null)return null;let E=p,T=(b-p)/d;const P=new Array(d).fill(0);for(let j=0;j<d;j++)P[j]=g[j]===null?0:g[j]-E;const x=P.reduce((j,$)=>j+$,0)/d;for(let j=0;j<d;j++)P[j]-=x;let C=0,A=0;for(let j=d;j<w;j++){const $=j%d,z=P[$],M=g[j];if(M===null){E+=T;continue}const R=E+T+z;C+=(M-R)**2,A+=1;const S=E;E=h*(M-z)+(1-h)*(E+T),T=l*(E-S)+(1-l)*T,P[$]=m*(M-E)+(1-m)*z}return{level:E,trend:T,season:P,phase:(w-1)%d,sse:C,count:A}}function s(g,d,h){let l=1;for(const w of d)l+=w*w;const m=Math.sqrt(g*l);return{se:m,margin:h*m}}function n(g,d={}){if(!g||typeof g.length!="number"||g.length===0)return null;const h=X.includes(d.method)?d.method:"linear",l=Math.max(1,Math.floor(Number(d.horizon)||1)),m=Number.isFinite(d.confidence)&&d.confidence>0&&d.confidence<1?d.confidence:.95,w=1-(1-m)/2,k=K(g),p=k.map(C=>C.value),b=p.filter(C=>C!==null),E=b.length,{lastAt:T,step:P}=E?D(k):{lastAt:0,step:1},x=C=>T+C*P;return h==="linear"?t(k,E,l,m,w,x):h==="movingAverage"?r(b,E,l,m,w,d,x):h==="ses"?o(p,E,l,m,w,d,x):h==="holt"?f(p,E,l,m,w,d,x):c(p,E,l,m,w,d,x)}function t(g,d,h,l,m,w){if(d<2)return null;let k=0,p=0;for(const M of g)M.value!==null&&(k+=M.at,p+=M.value);k/=d,p/=d;let b=0,E=0,T=0;for(const M of g){if(M.value===null)continue;const R=M.at-k,S=M.value-p;b+=R*R,E+=R*S,T+=S*S}if(b===0)return null;const P=E/b,x=p-P*k,C=T===0?1:Math.max(0,Math.min(1,E*E/(b*T))),A=Math.max(0,T-P*E),j=d>2?Math.sqrt(A/(d-2)):null,$=d>2?B(m,d-2):null,z=[];for(let M=1;M<=h;M++){const R=w(M),S=x+P*R;let I=null,q=null,Z=null,_=null,J=null;if(j!==null){const ee=1/d+(R-k)**2/b,te=j*Math.sqrt(1+ee),ne=j*Math.sqrt(ee);J=te,I=S-$*te,q=S+$*te,Z=S-$*ne,_=S+$*ne}z.push({step:M,at:R,mean:S,lower:I,upper:q,lowerMean:Z,upperMean:_,se:J})}return{method:"linear",horizon:h,confidence:l,n:d,sigma:j,r2:C,params:{slope:P,intercept:x},points:z}}function r(g,d,h,l,m,w,k){if(d<1)return null;const p=Math.max(1,Math.min(d,Math.floor(Number(w.windowLen)||d))),b=g.slice(d-p);let E=0;for(const j of b)E+=j;const T=E/p;let P=null,x=null;if(p>1){let j=0;for(const z of b)j+=(z-T)**2;P=Math.sqrt(j/(p-1))*Math.sqrt(1+1/p),x=B(m,p-1)}const C=P===null?null:x*P,A=[];for(let j=1;j<=h;j++)A.push({step:j,at:k(j),mean:T,lower:C===null?null:T-C,upper:C===null?null:T+C,se:P});return{method:"movingAverage",horizon:h,confidence:l,n:d,sigma:P===null?null:P,params:{windowLen:p},points:A}}function o(g,d,h,l,m,w,k){if(d<1)return null;let p=Number.isFinite(w.alpha)?v(w.alpha):null;p===null&&(p=O(x=>y(g,x).sse));const b=y(g,p),E=L(m),T=b.m>0?b.sse/b.m:null,P=[];for(let x=1;x<=h;x++){const C=b.level;let A=null,j=null,$=null;if(T!==null){const z=[];for(let R=1;R<x;R++)z.push(p);const M=s(T,z,E);$=M.se,A=C-M.margin,j=C+M.margin}P.push({step:x,at:k(x),mean:C,lower:A,upper:j,se:$})}return{method:"ses",horizon:h,confidence:l,n:d,sigma:T===null?null:Math.sqrt(T),params:{alpha:p},points:P}}function f(g,d,h,l,m,w,k){if(d<2)return null;let p=Number.isFinite(w.alpha)?v(w.alpha):null,b=Number.isFinite(w.beta)?v(w.beta):null;if(p===null||b===null){let A=p===null?.5:p,j=b===null?.5:b;for(let $=0;$<6;$++)p===null&&(A=O(z=>u(g,z,j).sse)),b===null&&(j=O(z=>u(g,A,z).sse));p=p===null?A:p,b=b===null?j:b}const E=u(g,p,b),T=L(m),P=E.m>0?E.sse/E.m:null,x=p*b,C=[];for(let A=1;A<=h;A++){const j=E.level+A*E.trend;let $=null,z=null,M=null;if(P!==null){const R=[];for(let I=1;I<A;I++)R.push(p+I*x);const S=s(P,R,T);M=S.se,$=j-S.margin,z=j+S.margin}C.push({step:A,at:k(A),mean:j,lower:$,upper:z,se:M})}return{method:"holt",horizon:h,confidence:l,n:d,sigma:P===null?null:Math.sqrt(P),params:{alpha:p,beta:b},points:C}}function c(g,d,h,l,m,w,k){const p=Math.floor(Number(w.period));if(!(p>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(d<2*p)return null;let b=Number.isFinite(w.alpha)?v(w.alpha):null,E=Number.isFinite(w.beta)?v(w.beta):null,T=Number.isFinite(w.gamma)?v(w.gamma):null;const P=(M,R,S)=>{const I=a(g,p,M,R,S);return I?I.sse:1/0};if(b===null||E===null||T===null){let M=b===null?.5:b,R=E===null?.5:E,S=T===null?.5:T;for(let I=0;I<8;I++)b===null&&(M=O(q=>P(q,R,S))),E===null&&(R=O(q=>P(M,q,S))),T===null&&(S=O(q=>P(M,R,q)));b=b===null?M:b,E=E===null?R:E,T=T===null?S:T}const x=a(g,p,b,E,T);if(!x)return null;const C=L(m),A=x.count>0?x.sse/x.count:null,j=b*E,$=T*(1-b),z=[];for(let M=1;M<=h;M++){const R=x.season[(x.phase+M)%p],S=x.level+M*x.trend+R;let I=null,q=null,Z=null;if(A!==null){const _=[];for(let ee=1;ee<M;ee++)_.push(b+ee*j+(ee%p===0?$:0));const J=s(A,_,C);Z=J.se,I=S-J.margin,q=S+J.margin}z.push({step:M,at:k(M),mean:S,lower:I,upper:q,se:Z})}return{method:"holtWinters",horizon:h,confidence:l,n:d,sigma:A===null?null:Math.sqrt(A),params:{alpha:b,beta:E,gamma:T,period:p},points:z}}const i={FORECAST_METHODS:X,forecast:n}}),xe("packages/core/src/compute/hypothesis.js",function(e,G){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const L=G("packages/core/src/internal/util.js").warnOnce,F=G("packages/core/src/compute/handle.js").valueReader,W=G("packages/core/src/compute/statistics.js"),X=W.numbers,H=W.moments,V=W.frequencyMap,K=W.categoricalDistance,D=W.isNumericColumn,v=W.jarqueBera,O=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,a=G("packages/core/src/compute/compare.js").pooledStandardMeanDifference,s=G("packages/core/src/compute/special.js"),n=s.studentT,t=s.studentTQuantile,r=s.normalCdf,o=s.normalQuantile,f=s.chiSquareUpperTail,c=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,g=2e6;function d(A){const j=Number(A);return Number.isFinite(j)&&j>0&&j<1?j:.95}function h(A){const{n:j,mean:$,m2:z}=H(A);return{mean:$,sd:j>0?Math.sqrt(z/j):0,n:j}}function l(A,j){const $=A.length;if($<2)return 0;let z=0;for(let M=0;M<$;M++){const R=A[M]-j;z+=R*R}return z/($-1)}function m(A,j){return{name:"pooledStandardMeanDifference",value:a(h(A),h(j))}}function w(A,j,$){const z=A.length,M=j.length;if(z<2||M<2)return null;const R=d($),{mean:S}=H(A),{mean:I}=H(j),q=l(A,S),Z=l(j,I),_=q/z+Z/M;if(!(_>0))return null;const J=Math.sqrt(_),ee=(S-I)/J,te=q/z*(q/z)/(z-1),ne=Z/M*(Z/M)/(M-1),ae=_*_/(te+ne),de=Math.min(1,Math.max(0,2*(1-n(Math.abs(ee),ae)))),ie=S-I,oe=t(1-(1-R)/2,ae)*J;return{test:c.WELCH,statistic:ee,statisticName:"t",df:ae,pValue:de,interval:{estimate:ie,lower:ie-oe,upper:ie+oe,confidence:R,method:"welch-t (difference of means)"},effectSize:m(A,j),nA:z,nB:M,reliable:z>=y&&M>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function k(A){const j=A.length;if(j===0)return Number.NaN;const $=j>>1;return j%2?A[$]:(A[$-1]+A[$])/2}function p(A,j,$){const z=A.length,M=j.length,R=z*M;if(R===0||R>g)return null;const S=new Float64Array(R);let I=0;for(let te=0;te<z;te++)for(let ne=0;ne<M;ne++)S[I++]=A[te]-j[ne];S.sort();const q=k(S),Z=Math.sqrt(z*M*(z+M+1)/12),_=o(1-(1-$)/2);let J=Math.round(R/2-_*Z);J>=0||(J=0);const ee=Math.floor((R-1)/2);return J>ee&&(J=ee),{estimate:q,lower:S[J],upper:S[R-1-J],confidence:$,method:"hodges-lehmann (normal approximation)"}}function b(A,j,$){const z=A.length,M=j.length;if(z<1||M<1)return null;const R=d($),S=z+M,I=new Array(S);for(let de=0;de<z;de++)I[de]={v:A[de],g:0};for(let de=0;de<M;de++)I[z+de]={v:j[de],g:1};I.sort((de,ie)=>de.v-ie.v);let q=0,Z=0,_=0;for(;_<S;){let de=_;for(;de<S&&I[de].v===I[_].v;)de++;const ie=de-_,oe=(_+1+de)/2;for(let ce=_;ce<de;ce++)I[ce].g===0&&(q+=oe);Z+=ie*ie*ie-ie,_=de}const J=q-z*(z+1)/2,ee=z*M/2,te=z*M/12*(S+1-Z/(S*(S-1)));let ne=1;if(te>0){const de=Math.max(0,Math.abs(J-ee)-.5);ne=Math.min(1,2*r(-de/Math.sqrt(te)))}const ae=p(A,j,R);return{test:c.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:ne,interval:ae,effectSize:m(A,j),nA:z,nB:M,reliable:z>=y&&M>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function E(A,j,$,z,M){const R=O(A,j,M),S=O($,z,M);if(!R||!S)return null;const I=R.proportion-S.proportion,q=I-Math.sqrt((R.proportion-R.lower)**2+(S.upper-S.proportion)**2),Z=I+Math.sqrt((R.upper-R.proportion)**2+(S.proportion-S.lower)**2);return{lower:q,upper:Z}}function T(A,j,$,z,M,R={}){if(!(j>0)||!(z>0))return null;const S=new Set([...A.keys(),...$.keys()]),I=S.size;if(I<2)return null;const q=j+z;let Z=0;for(const ne of S){const ae=A.get(ne)||0,de=$.get(ne)||0,ie=ae+de,oe=j*ie/q,ce=z*ie/q;oe>0&&(Z+=(ae-oe)*(ae-oe)/oe),ce>0&&(Z+=(de-ce)*(de-ce)/ce)}const _=I-1,J=f(Z,_);let ee=null;R.category!==void 0&&S.has(R.category)?ee=R.category:I===2&&([ee]=[...S]);let te=null;if(ee!==null){const ne=E(A.get(ee)||0,j,$.get(ee)||0,z,d(M));ne&&(te={estimate:(A.get(ee)||0)/j-($.get(ee)||0)/z,lower:ne.lower,upper:ne.upper,confidence:d(M),method:"newcombe (difference in this category's share)",category:ee})}return{test:c.CHI_SQUARE,statistic:Z,statisticName:"chiSquare",df:_,pValue:J,interval:te,effectSize:{name:"categoricalTotalVariation",value:K(A,j,$,z)},nA:j,nB:z,reliable:j>=y&&z>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function P(A){return A==null||A===""||typeof A=="number"&&Number.isNaN(A)?null:A instanceof Date?A.getTime():typeof A=="object"?String(A):A}function x(A,j,$){if($===c.WELCH||$===c.MANN_WHITNEY)return{test:$,chosenBy:"override",reason:`caller override: ${$}`};const z=v(A),M=v(j),R=z===null?null:Math.exp(-z/2),S=M===null?null:Math.exp(-M/2);return R!==null&&R<i||S!==null&&S<i?{test:c.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:c.WELCH,chosenBy:"auto",reason:R!==null||S!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(A,j,$,z={}){if(!A||!j)return null;const M=d(z.confidence),R=F(j);let S;if(Array.isArray(z.groups)&&z.groups.length===2)S=[P(z.groups[0]),P(z.groups[1])];else{const{map:de}=V(j,$),ie=[...de.entries()].sort((oe,ce)=>ce[1]-oe[1]).slice(0,2).map(oe=>oe[0]);if(ie.length<2)return L("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;S=ie}const[I,q]=S;if(I===null||q===null||I===q)return L("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Z=[],_=[];for(let de=0;de<$.length;de++){const ie=P(R($[de]));ie===I?Z.push($[de]):ie===q&&_.push($[de])}if(Z.length===0||_.length===0)return L("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=z.test&&z.test!=="auto"?String(z.test):null,ee=D(A,Z.concat(_));let te,ne,ae;if(J===c.CHI_SQUARE||!J&&!ee){ne=J?"override":"auto",ae=J?"caller override: chiSquare":"column family: categorical";const de=V(A,Z),ie=V(A,_);te=T(de.map,de.total,ie.map,ie.total,M,{category:z.category})}else{if((J===c.WELCH||J===c.MANN_WHITNEY)&&!ee)return L("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const de=X(A,Z),ie=X(A,_),oe=x(de,ie,J);ne=oe.chosenBy,ae=oe.reason,te=oe.test===c.MANN_WHITNEY?b(de,ie,M):w(de,ie,M)}return te?{...te,chosenBy:ne,reason:ae,groups:[I,q]}:(L("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),xe("packages/core/src/columns/detailcolumn.js",function(e,G){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q="__lattice_detail",L=36;function B(W){const X=W.config&&W.config.detailColumnWidth||L;return{id:Q,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:X,min:X,max:X,pin: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,V){return!!(V&&V.expanded)},formatValue(){return""}}}const F=B}),xe("packages/core/src/columns/treecolumn.js",function(e,G){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",F=260;function W(H){const V=H.tree||{},K=H.config&&H.config.treeColumnWidth||F,D=()=>(H.columns&&L(H.columns.visible)?H.columns.visible():[]).find(u=>!u.generated)||null,v=(y,u)=>{if(u&&u.group)return u.groupValue;if(L(V.label))return V.label(y,u);if(typeof V.label=="string")return y==null?null:y[V.label];const a=D();return a&&L(a.getValue)?a.getValue(y,u):null},O=()=>{if(V.title)return V.title;const y=typeof V.label=="string"?H.columns&&L(H.columns.get)?H.columns.get(V.label):null:D();return y&&(y.title||y.id)||"Hierarchy"};return{id:B,get title(){return O()},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:K,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,u){return v(y,u)},formatValue(y,u){if(u&&u.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(y==null)return"";if(!V.label){const a=D();if(a&&L(a.formatValue))return a.formatValue(y,u)}return String(y)}}}const X=W}),xe("packages/core/src/columns/pivotcolumns.js",function(e,G){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const L=G("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",F=500;function W(K){const{pivot:D,valueColumns:v,config:O}=K,y=D&&D.paths||[],u=K.separator||O&&O.pivot&&O.pivot.separator||" | ",a=O&&O.pivot&&O.pivot.maxColumns||F;if(!y.length||!v.length)return{tree:[],leaves:[],error:null};const s=X(O),n=y.length*v.length+(s?v.length:0);if(n>a){const o=`pivot would generate ${n} columns, above the limit of ${a}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return L(`pivot.maxColumns:${n}`,o),{tree:[],leaves:[],error:o}}const t=[],r=[];for(const o of y){const f=[];for(const c of v){const i=V(o,c,u);f.push(i),r.push(i)}f.length===1?(f[0].title=String(o),t.push(f[0])):t.push({id:`${B}:group:${o}`,title:String(o),columns:f,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(s){const o=v.map(c=>H(c,O));r.push(...o);const f=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(o.length===1)o[0].title=f,s==="before"?t.unshift(o[0]):t.push(o[0]);else{const c={id:`${B}:group:__totals`,title:f,columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};s==="before"?t.unshift(c):t.push(c)}}return{tree:t,leaves:r,error:null}}function X(K){const D=K&&K.pivot&&K.pivot.groupTotals;return D==="before"||D==="after"?D:null}function H(K,D){return{id:`${B}:__total${D&&D.pivot&&D.pivot.separator||" | "}${K.id}`,field:null,title:K.title||K.id,type:K.type,dataType:K.dataType,nullable:!0,align:K.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:K.id,total:!0},value:{pure:!0},cell:{align:K.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:K.total,lookup:null,layout:{width:K.layout&&K.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,O){const y=O&&O.totals;return y&&Object.hasOwn(y,K.id)?y[K.id]:null},formatValue(v,O){return v==null?"":K.formatValue?K.formatValue(v,O):String(v)}}}function V(K,D,v){return{id:`${B}:${K}${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:K,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(O,y){return O==null?"":D.formatValue?D.formatValue(O,y):String(O)}}}}),xe("packages/core/src/compute/group.js",function(e,G){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const Q=G("packages/core/src/compute/handle.js"),L=Q.dictSize,B=Q.identity,F=Q.presenceReader,W=Q.rowCount,X=Q.valueReader,H="",V="\0",K=1<<20;function D(y,u,a,s){const n=y.length,t=y.map(g=>X(g)),r=Array.isArray(s)&&s.some(Boolean),o=r?t.map((g,d)=>s[d]?h=>s[d](g(h)):g):t;if(!r&&n>0&&y.every(g=>g&&g.kind==="dictionary"&&g.dict)){const g=y.map(h=>L(h.dict)+1);let d=1;for(let h=0;h<n;h++)d*=g[h];if(d<=Number.MAX_SAFE_INTEGER){const h=y.map(k=>k.values),l=y.map(k=>F(k)),m=k=>{let p=0;for(let b=0;b<n;b++){const E=l[b],T=E&&E(k)===0?g[b]-1:h[b][k];p=p*g[b]+T}return p},w=new Float64Array(a);for(let k=0;k<a;k++)w[k]=m(u[k]);return{packed:w,strings:null,product:d,readers:o,keyOf:m}}}const c=g=>{let d="";for(let h=0;h<n;h++){const l=o[h](g);d+=(h===0?"":H)+(l==null?V:String(l))}return d},i=new Array(a);for(let g=0;g<a;g++)i[g]=c(u[g]);return{packed:null,strings:i,product:1/0,readers:o,keyOf:c}}function v(y,u,a,s){const n=new Uint32Array(s+1);for(let f=0;f<a;f++)n[u[f]+1]++;for(let f=0;f<s;f++)n[f+1]+=n[f];const t=new Uint32Array(a),r=n.slice(0,s);for(let f=0;f<a;f++)t[r[u[f]]++]=y[f];const o=new Array(s);for(let f=0;f<s;f++)o[f]=t.subarray(n[f],n[f+1]);return o}function O(y,u,a={}){const s=y||[],n=u||B(W(s[0],a)),t=n.length;if(s.length===0||t===0)return{keys:[],buckets:[]};const{packed:r,strings:o,product:f,readers:c}=D(s,n,t,a.project),i=new Uint32Array(t);let g=0,d=null;if(r&&f<=Math.max(1024,Math.min(K,t*4))){const w=f,k=new Int32Array(w).fill(-1);for(let p=0;p<t;p++)k[r[p]]=0;for(let p=0;p<w;p++)k[p]===0&&(k[p]=g++);for(let p=0;p<t;p++)i[p]=k[r[p]];d=new Float64Array(g);for(let p=0;p<w;p++)k[p]>=0&&(d[k[p]]=p)}else if(r){const w=new Map;for(let k=0;k<t;k++){const p=r[k];let b=w.get(p);b===void 0&&(b=g++,w.set(p,b)),i[k]=b}d=new Float64Array(g);for(const[k,p]of w)d[p]=k}else{const w=new Map;for(let k=0;k<t;k++){const p=o[k];let b=w.get(p);b===void 0&&(b=g++,w.set(p,b)),i[k]=b}}const h=v(n,i,t,g),l=new Array(g);for(let w=0;w<g;w++){const k=h[w][0],p=new Array(c.length);for(let b=0;b<c.length;b++)p[b]=c[b](k);l[w]=p}const m={keys:l,buckets:h};return d&&(m.packed=d),m}}),xe("packages/core/src/compute/pivot.js",function(e,G){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const L=G("packages/core/src/internal/util.js").warnOnce,F=G("packages/core/src/compute/handle.js").valueComparator,X=G("packages/core/src/compute/group.js").packKeys,V=G("packages/core/src/compute/total.js").total,K="|",D="/",v=2e3;function O(f,c,i){return`${f}${K}${c}${K}${i}`}function y(f,c){let i="";for(let g=0;g<f.length;g++){const d=f[g];i+=(g===0?"":c)+(d==null?"":String(d))}return i}function u(f,c,i={}){const g=i.separator||D,d=c.length,{keyOf:h,readers:l}=X(f,c,0),m=new Map,w=[],k=[];for(let C=0;C<d;C++){const A=c[C],j=h(A);if(m.has(j))continue;m.set(j,w.length),k.push(j);const $=new Array(l.length);for(let z=0;z<l.length;z++)$[z]=l[z](A);w.push($)}const p=F(i.locale),b=w.map((C,A)=>A);b.sort((C,A)=>{const j=w[C],$=w[A];for(let z=0;z<j.length;z++){const M=a(j[z],$[z],p);if(M!==0)return M}return C-A});const E=new Array(b.length),T=new Array(b.length),P=new Map;for(let C=0;C<b.length;C++){const A=b[C];E[C]=w[A],T[C]=y(w[A],g),P.set(k[A],C)}return{keys:E,paths:T,idOf:C=>{const A=P.get(h(C));return A===void 0?-1:A}}}function a(f,c,i){const g=f==null,d=c==null;return g||d?g&&d?0:g?1:-1:i(f,c)}function s(f){const c=f.values||f.totals||[];if(c.length&&typeof c[0]=="object"&&c[0]!==null)return c.filter(h=>h&&h.handle);const i=typeof f.handle=="function"?f.handle:null;if(!i)return c.length&&L("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 g=typeof f.totalOf=="function"?f.totalOf:null,d=[];for(const h of c){const l=i(h);l&&d.push({colId:h,handle:l,fn:g?g(h):"sum"})}return d}function n(f,c,i){if(Array.isArray(f)){const g=i||{};return{...g,pivotHandles:f,order:c||null,groups:g.groups||null}}return f||{}}function t(f,c,i){const g=n(f,c,i),d=g.separator||D,h=s(g),l=g.maxColumns===void 0?v:g.maxColumns,m=g.groups&&g.groups.buckets?g.groups:null,w=m?m.buckets:[g.order||new Uint32Array(0)],k=g.groupPaths||(m?m.keys.map(j=>y(j,d)):[""]),p=o(w),{keys:b,paths:E,idOf:T}=u(g.pivotHandles||[],p,g),P=E.length*Math.max(1,h.length),x=r(E,h,d);if(l&&P>l){const j=new Map;return{keys:b,paths:E,fields:x,groupPaths:k,columns:P,values:j,cells:j,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${l}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:l}}}const C=new Map,A=E.length;for(let j=0;j<w.length;j++){const $=w[j],z=k[j]===void 0?"":k[j],M=$.length;if(M===0)continue;const R=new Int32Array(M),S=new Uint32Array(A+1);for(let Z=0;Z<M;Z++){const _=T($[Z]);R[Z]=_,_>=0&&S[_+1]++}for(let Z=0;Z<A;Z++)S[Z+1]+=S[Z];const I=new Uint32Array(M),q=S.slice(0,A);for(let Z=0;Z<M;Z++){const _=R[Z];_>=0&&(I[q[_]++]=$[Z])}for(let Z=0;Z<A;Z++){const _=S[Z],J=S[Z+1];if(J===_)continue;const ee=I.subarray(_,J);for(let te=0;te<h.length;te++){const ne=h[te],ae=V(ne.handle,ee,ne.fn,g.totalContext||{locale:g.locale});C.set(O(z,E[Z],ne.colId),ae)}}}return{keys:b,paths:E,fields:x,groupPaths:k,columns:P,values:C,cells:C,error:null}}function r(f,c,i){if(c.length===0)return f.slice();const g=[];for(const d of f)for(const h of c)g.push(`${d}${i}${h.colId}`);return g}function o(f){if(f.length===1)return f[0]||new Uint32Array(0);let c=0;for(const d of f)c+=d?d.length:0;const i=new Uint32Array(c);let g=0;for(const d of f)!d||d.length===0||(i.set(d,g),g+=d.length);return i}}),xe("packages/core/src/store/bitset.js",function(e,G){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return L}});const Q=8;class L{static#e=new Uint8Array(256);static{for(let F=1;F<256;F++)L.#e[F]=L.#e[F>>1]+(F&1)}#t;#n;constructor(F=0){const W=Math.max(0,F|0);this.#n=W,this.#t=new Uint8Array(Math.ceil(W/Q))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(F){return F<0||F>=this.#n?0:this.#t[F>>3]>>(F&7)&1}set(F){return F>=0&&F<this.#n&&(this.#t[F>>3]|=1<<(F&7)),this}clear(F){return F>=0&&F<this.#n&&(this.#t[F>>3]&=~(1<<(F&7))),this}assign(F,W){return W?this.set(F):this.clear(F)}fill(F=!1){return this.#t.fill(F?255:0),F&&this.#r(),this}grow(F){const W=Math.max(0,F|0);if(W<=this.#n)return this;const X=Math.ceil(W/Q);if(X>this.#t.length){const H=new Uint8Array(X);H.set(this.#t),this.#t=H}return this.#n=W,this}count(){const F=this.#t,W=L.#e;let X=0;for(let H=0;H<F.length;H++)X+=W[F[H]];return X}and(F){const W=F instanceof L?F.words:F,X=this.#t,H=Math.min(X.length,W.length);for(let V=0;V<H;V++)X[V]&=W[V];for(let V=H;V<X.length;V++)X[V]=0;return this}or(F){const W=F instanceof L?F.words:F,X=this.#t,H=Math.min(X.length,W.length);for(let V=0;V<H;V++)X[V]|=W[V];return this}not(){const F=this.#t;for(let W=0;W<F.length;W++)F[W]=~F[W]&255;return this.#r(),this}clone(){const F=new L(this.#n);return F.words.set(this.#t.subarray(0,F.words.length)),F}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const F=this.#n&7;if(F===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<F)-1)}static from(F){const W=Array.isArray(F)?F:Array.from(F),X=new L(W.length);for(let H=0;H<W.length;H++)W[H]&&X.set(H);return X}}}),xe("packages/core/src/store/dictionary.js",function(e,G){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return F}});const Q=G("packages/core/src/internal/util.js"),L=Q.collator,B=Q.defaultCompare;class F{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(X=[]){this.#e=[];for(let H=0;H<X.length;H++){const V=X[H];this.#t.has(V)||(this.#t.set(V,this.#e.length),this.#e.push(V))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let X=this.#e.length*8;for(let H=0;H<this.#e.length;H++){const V=this.#e[H];typeof V=="string"&&(X+=V.length*2),X+=16}return X}codeOf(X){const H=this.#t.get(X);if(H!==void 0)return H;const V=this.#e.length;return this.#e.push(X),this.#t.set(X,V),this.#n++,V}lookup(X){const H=this.#t.get(X);return H===void 0?-1:H}has(X){return this.#t.has(X)}valueOf(X){return this.#e[X]}values(){return this.#e}ranks(X){const H=X||"";if(this.#r&&this.#o===this.#n&&this.#i===H)return this.#r;const V=this.#e.length,K=new Array(V);for(let y=0;y<V;y++)K[y]=y;const D=L(X).compare,v=this.#e;K.sort((y,u)=>this.#s(v[y],v[u],D));const O=new Uint32Array(V);for(let y=0;y<V;y++)O[K[y]]=y;return this.#r=O,this.#o=this.#n,this.#i=H,O}#s(X,H,V){return typeof X=="string"&&typeof H=="string"?V(X,H):B(X,H)}}}),xe("packages/core/src/store/multivalue.js",function(e,G){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return Q}});class Q{#e;#t;#n=0;#r=0;constructor(B={}){const F=Math.max(1,B.rows??16),W=Math.max(1,B.values??F);this.#e=new Int32Array(W),this.#t=new Uint32Array(F+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(B){return B<0||B>=this.#n?0:this.#t[B+1]-this.#t[B]}at(B){return B<0||B>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[B],this.#t[B+1])}has(B,F){if(B<0||B>=this.#n)return!1;const W=this.#e,X=this.#t[B+1];for(let H=this.#t[B];H<X;H++)if(W[H]===F)return!0;return!1}hasAny(B,F){for(let W=0;W<F.length;W++)if(this.has(B,F[W]))return!0;return!1}hasAll(B,F){for(let W=0;W<F.length;W++)if(!this.has(B,F[W]))return!1;return!0}hasNone(B,F){return!this.hasAny(B,F)}push(B){const F=this.#n,W=B.length;this.#o(F+1),this.#i(this.#r+W);const X=this.#r;for(let H=0;H<W;H++)this.#e[X+H]=B[H]|0;return this.#r+=W,this.#n=F+1,this.#t[F]=X,this.#t[F+1]=this.#r,F}write(B,F){if(B===this.#n){this.push(F);return}if(B<0||B>this.#n)return;const W=this.#t[B],X=this.#t[B+1],H=F.length;if(X-W===H){for(let V=0;V<H;V++)this.#e[W+V]=F[V]|0;return}this.#s(B,F)}compact(B,F,W){const X=this.#e,H=this.#t,V=this.#n,K=new Int32Array(Math.max(1,this.#r)),D=new Uint32Array(F+1);let v=0;for(let O=0;O<V;O++){if(B[O]===W)continue;const y=H[O],u=H[O+1];D[B[O]]=v;for(let a=y;a<u;a++)K[v++]=X[a];D[B[O]+1]=v}this.#e=K,this.#t=D,this.#n=F,this.#r=v}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(B){if(B+1<=this.#t.length)return;let F=this.#t.length-1;for(;F<B;)F=F*2||16;const W=new Uint32Array(F+1);W.set(this.#t),this.#t=W}#i(B){if(B<=this.#e.length)return;let F=this.#e.length;for(;F<B;)F=F*2||16;const W=new Int32Array(F);W.set(this.#e),this.#e=W}#s(B,F){const W=this.#e,X=this.#t,H=this.#n,V=F.length-(X[B+1]-X[B]),K=new Int32Array(Math.max(1,this.#r+V)),D=new Uint32Array(X.length);let v=0;for(let O=0;O<H;O++){if(D[O]=v,O===B)for(let y=0;y<F.length;y++)K[v++]=F[y]|0;else for(let y=X[O];y<X[O+1];y++)K[v++]=W[y];D[O+1]=v}this.#e=K,this.#t=D,this.#r=v}}}),xe("packages/core/src/compute/sort.js",function(e,G){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return A}});const Q=G("packages/core/src/compute/handle.js"),L=Q.bitReader,B=Q.dictRanks,F=Q.dictSize,W=Q.identity,X=Q.isMissing,H=Q.presenceReader,V=Q.rowCount,K=Q.valueComparator,D=Q.valueReader,v=new Uint32Array(0),O=new ArrayBuffer(8),y=new Float64Array(O),u=new Uint32Array(O),a=(y[0]=-1,(u[1]&2147483648)!==0?1:0),s=a===1?0:1;function n($,z){y[0]=$;let M=u[a],R=u[s];(M&2147483648)!==0?(M=~M>>>0,R=~R>>>0):M=(M^2147483648)>>>0,z[0]=R,z[1]=M}function t($,z,M,R){if(R<2)return $;const S=new Uint32Array(256*8);for(let ne=0;ne<R;ne++){const ae=z[ne],de=M[ne];S[ae&255]++,S[256+(ae>>>8&255)]++,S[512+(ae>>>16&255)]++,S[768+(ae>>>24&255)]++,S[1024+(de&255)]++,S[1280+(de>>>8&255)]++,S[1536+(de>>>16&255)]++,S[1792+(de>>>24&255)]++}let I=$,q=z,Z=M,_=new Uint32Array(R),J=new Uint32Array(R),ee=new Uint32Array(R);const te=new Uint32Array(256);for(let ne=0;ne<8;ne++){const ae=ne<<8,de=(ne&3)<<3,ie=ne>=4;let oe=!1;for(let ke=0;ke<256;ke++)if(S[ae+ke]===R){oe=!0;break}if(oe)continue;let ce=0;for(let ke=0;ke<256;ke++)te[ke]=ce,ce+=S[ae+ke];for(let ke=0;ke<R;ke++){const Re=q[ke],Ee=Z[ke],Fe=(ie?Ee:Re)>>>de&255,ye=te[Fe]++;_[ye]=I[ke],J[ye]=Re,ee[ye]=Ee}let fe=I;I=_,_=fe,fe=q,q=J,J=fe,fe=Z,Z=ee,ee=fe}return I}function r($,z,M){if(M<2)return $;const R=new Uint32Array(256*4);for(let J=0;J<M;J++){const ee=z[J];R[ee&255]++,R[256+(ee>>>8&255)]++,R[512+(ee>>>16&255)]++,R[768+(ee>>>24&255)]++}let S=$,I=z,q=new Uint32Array(M),Z=new Uint32Array(M);const _=new Uint32Array(256);for(let J=0;J<4;J++){const ee=J<<8,te=J<<3;let ne=!1;for(let ie=0;ie<256;ie++)if(R[ee+ie]===M){ne=!0;break}if(ne)continue;let ae=0;for(let ie=0;ie<256;ie++)_[ie]=ae,ae+=R[ee+ie];for(let ie=0;ie<M;ie++){const oe=I[ie],ce=_[oe>>>te&255]++;q[ce]=S[ie],Z[ce]=oe}let de=S;S=q,q=de,de=I,I=Z,Z=de}return S}function o($,z,M,R){const S=new Uint32Array(R+1);for(let Z=0;Z<M;Z++)S[z[Z]]++;let I=0;for(let Z=0;Z<=R;Z++){const _=S[Z];S[Z]=I,I+=_}const q=new Uint32Array(M);for(let Z=0;Z<M;Z++)q[S[z[Z]]++]=$[Z];return q}function f($,z,M,R){return M<2?$:R<=65536||R<=M*2?o($,z,M,R):r($,z,M)}function c($,z){return $.length===z&&$.byteOffset===0?$:Uint32Array.prototype.slice.call($,0,z)}function i($,z,M=!1){const R=z||W($.length),S=R.length;if(S<2)return Uint32Array.from(R);const I=new Uint32Array(S),q=new Uint32Array(S),Z=new Uint32Array(S),_=new Uint32Array(S),J=new Uint32Array(2);let ee=0,te=0;for(let de=0;de<S;de++){const ie=R[de],oe=$[ie];if(Number.isNaN(oe)){_[te++]=ie;continue}n(oe,J),M?(q[ee]=~J[0]>>>0,Z[ee]=~J[1]>>>0):(q[ee]=J[0],Z[ee]=J[1]),I[ee++]=ie}const ne=t(I.subarray(0,ee),q.subarray(0,ee),Z.subarray(0,ee),ee);if(te===0)return c(ne,ee);const ae=new Uint32Array(S);return ae.set(ne.subarray(0,ee),0),ae.set(_.subarray(0,te),ee),ae}function g($,z,M=!1){const R=z||W($.length),S=R.length;if(S<2)return Uint32Array.from(R);const I=Uint32Array.from(R),q=new Uint32Array(S);for(let Z=0;Z<S;Z++){const _=($[I[Z]]^2147483648)>>>0;q[Z]=M?~_>>>0:_}return c(r(I,q,S),S)}function d($,z,M={}){const R=z||W(V($,M)),S=R.length;if(S<2)return Uint32Array.from(R);const I=B($.dict,M.locale),q=$.values,Z=H($),_=Math.max(F($.dict),I.length),J=_,ee=Uint32Array.from(R),te=new Uint32Array(S),ne=!!M.descending;for(let ae=0;ae<S;ae++){const de=ee[ae];let ie=Z&&Z(de)===0?J:I[q[de]];ie===void 0&&(ie=J),te[ae]=ne?J-ie:ie}return c(f(ee,te,S,_+1),S)}function h($,z,M){const R=z.length;let S=Uint32Array.from(z);if(R<2)return S;let I=new Uint32Array(R);for(let q=1;q<R;q<<=1){for(let _=0;_<R;_+=q<<1){const J=Math.min(_+q,R),ee=Math.min(_+(q<<1),R);let te=_,ne=J,ae=_;for(;te<J&&ne<ee;)I[ae++]=M($[S[te]],$[S[ne]])<=0?S[te++]:S[ne++];for(;te<J;)I[ae++]=S[te++];for(;ne<ee;)I[ae++]=S[ne++]}const Z=S;S=I,I=Z}return S}function l($,z,M){const R=L($.values),S=z.length,I=new Uint32Array(S),q=M?1:0;let Z=0;for(let _=0;_<S;_++)R(z[_])===q&&(I[Z++]=z[_]);for(let _=0;_<S;_++)R(z[_])!==q&&(I[Z++]=z[_]);return I}function m($,z){const M=$.values,R=$.kind;if((R==="object"||R===void 0)&&(Array.isArray(M)||ArrayBuffer.isView(M))&&!$.presence)return M;const I=D($),q=new Array(V($)||0);for(let Z=0;Z<z.length;Z++){const _=z[Z];q[_]=I(_)}return q}function w($,z){for(let M=0;M<z.length;M++)if(typeof $[z[M]]!="string")return!1;return!0}function k($,z,M,R,S){const I=$.length,q=Uint32Array.from($);if(I<2||R<1)return q;const Z=new Uint32Array(I),_=R-1;for(let J=0;J<I;J++){const ee=M[z[J]];Z[J]=S?_-ee:ee}return c(f(q,Z,I,R),I)}function p($,z,M){const R=K(M),S=new Array(z);for(let q=0;q<z;q++)S[q]=q;S.sort((q,Z)=>R($[q],$[Z])||q-Z);const I=new Uint32Array(z);for(let q=0;q<z;q++)I[S[q]]=q;return I}function b($,z,M){const R=z.length,S=new Map,I=[],q=new Uint32Array(R);for(let J=0;J<R;J++){const ee=$[z[J]];let te=S.get(ee);te===void 0&&(te=I.length,S.set(ee,te),I.push(ee)),q[J]=te}const Z=I.length,_=p(I,Z,M.locale);return k(z,q,_,Z,!!M.descending)}function E($,z,M){const R=m($,z);if(z.length>=2&&w(R,z)){const q=$.stringRank;return q&&q.version===$.version&&q.usable(z,R,M.locale)?q.sort(z,M):b(R,z,M)}const S=K(M.locale),I=M.descending?(q,Z)=>S(Z,q):S;return h(R,z,I)}function T($,z,M){const R=m($,z),S=M.compare,q=!!M.descending?(Z,_)=>-S(Z,_,void 0,void 0,!0):(Z,_)=>S(Z,_,void 0,void 0,!1);return h(R,z,q)}function P($,z){const M=z.length,R=H($),S=$.values,I=$.kind==="float64"&&!!S,q=$.kind==="object"||$.kind==="multi"||$.kind===void 0;if(!R&&!I&&!q)return{present:z,absent:v};const Z=new Uint32Array(M),_=new Uint32Array(M);let J=0,ee=0;if(R&&I)for(let te=0;te<M;te++){const ne=z[te];R(ne)===1&&!Number.isNaN(S[ne])?Z[J++]=ne:_[ee++]=ne}else if(I&&!R)for(let te=0;te<M;te++){const ne=z[te];Number.isNaN(S[ne])?_[ee++]=ne:Z[J++]=ne}else if(R&&!q)for(let te=0;te<M;te++){const ne=z[te];R(ne)===1?Z[J++]=ne:_[ee++]=ne}else{const te=D($);for(let ne=0;ne<M;ne++){const ae=z[ne];X(te(ae))?_[ee++]=ae:Z[J++]=ae}}return ee===0?{present:z,absent:v}:{present:Z.subarray(0,J),absent:_.subarray(0,ee)}}function x($,z,M){if(z.length===0)return $;const R=new Uint32Array($.length+z.length);return M?(R.set(z,0),R.set($,z.length)):(R.set($,0),R.set(z,$.length)),R}function C($,z,M={}){const R=z||W(V($,M));if(!$||R.length<2)return Uint32Array.from(R);const{present:S,absent:I}=P($,R);if(S.length===0)return Uint32Array.from(R);const q=!!M.descending;let Z;if(typeof M.compare=="function")Z=T($,S,M);else switch($.kind){case"float64":Z=i($.values,S,q);break;case"int32":Z=g($.values,S,q);break;case"dictionary":Z=d($,S,M);break;case"bitset":Z=l($,S,q);break;default:Z=E($,S,M);break}return x(Z,I,!!M.nullsFirst)}function A($,z,M,R={}){const S=z||[],I=S.length&&(S[0].handle||j($,S[0].col))||$&&$[0];let q=M||W(V(I,R));for(let Z=S.length-1;Z>=0;Z--){const _=S[Z],J=_.handle||j($,_.col)||$&&$[Z];J&&(q=C(J,q,{descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,locale:_.locale!==void 0?_.locale:R.locale,compare:_.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function j($,z){if(!(!$||z===void 0)){for(let M=0;M<$.length;M++)if($[M]&&$[M].id===z)return $[M]}}}),xe("packages/core/src/store/stringrank.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const Q=G("packages/core/src/compute/sort.js"),L=Q.collateStringRanks,B=Q.rankSortStrings,F=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=F){this.#s=H>0?H:F,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 V=this.#e;for(let K=0;K<V.length;K++)H+=V[K].length*2+24;return H}#d(H,V){const K=this.#t.get(H);if(K!==void 0)return K;if(this.#l)return-1;if(V&&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,V){const K=V|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(K);for(let D=0;D<K;D++){const v=H[D],O=typeof v=="string"?this.#d(v,!1):-1;this.#n[D]=O<0?0:O}this.#r=K}append(H,V,K){const D=(V|0)+(K|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=V|0;v<D;v++){const O=H[v],y=typeof O=="string"?this.#d(O,!0):-1;this.#n[v]=y<0?0:y}this.#r=Math.max(this.#r,D)}ranks(H){const V=H||"";if(this.#a&&this.#u===this.#o&&this.#c===V)return this.#a;const K=L(this.#e,this.#e.length,H);return this.#a=K,this.#u=this.#o,this.#c=V,K}usable(H,V,K){if(this.#l||this.#e.length===0)return!1;const D=this.#n,v=this.#e,O=this.#r;for(let y=0;y<H.length;y++){const u=H[y];if(u>=O||v[D[u]]!==V[u])return!1}return!0}sort(H,V){const K=this.ranks(V.locale),D=this.#e.length,v=H.length,O=new Uint32Array(v),y=this.#n;for(let u=0;u<v;u++)O[u]=y[H[u]];return B(H,O,K,D,!!V.descending)}}}),xe("packages/core/src/store/columnstore.js",function(e,G){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return d}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.isFunction,F=Q.pathGetter,X=G("packages/core/src/store/bitset.js").Bitset,V=G("packages/core/src/store/dictionary.js").Dictionary,D=G("packages/core/src/store/multivalue.js").MultiValue,O=G("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,u=1024,a=5e3,s=.2,n=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(h){return h==null}function r(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(typeof h=="boolean")return h?1:0;const l=Number(h);return Number.isNaN(l)&&typeof h=="string"?Date.parse(h):l}function o(h){const l=r(h);return Number.isFinite(l)?l|0:0}function f(h){return t(h)?[]:Array.isArray(h)?h:[h]}function c(h,l){switch(h.kind){case"float64":case"int32":return h.buf[l];case"bitset":return h.bits.get(l)===1;case"dictionary":return h.dict.valueOf(h.buf[l]);case"multi":{const m=h.mv.at(l),w=new Array(m.length);for(let k=0;k<m.length;k++)w[k]=h.dict.valueOf(m[k]);return w}default:return h.buf[l]}}function i(h,l){switch(h.kind){case"float64":case"int32":return h.values[l];case"bitset":return(h.values[l>>3]&1<<(l&7))!==0;case"dictionary":return(h.table||[])[h.values[l]];case"multi":{const m=h.offsets[l],w=h.offsets[l+1],k=h.table||[],p=new Array(w-m);for(let b=m;b<w;b++)p[b-m]=k[h.values[b]];return p}default:return h.values[l]}}class g{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#y=0;#w=0;#k=null;#b=null;#O=!1;constructor(l,m){this.#e=l.id;const w=n.has(l.kind)?l.kind:"object";l.kind&&!n.has(l.kind)&&L(`store.kind.${l.id}`,`column "${l.id}" declares unknown storage kind "${l.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=l.nullable!==!1,this.#s=l.dictionary??null,this.#i=m,this.#o=B(l.read)?l.read:F(l.field||l.id),this.#h=l.stringRankIndex!=="off",this.#p=typeof l.stringRankMaxDistinct=="number"?l.stringRankMaxDistinct:0,this.#k=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.#O?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#E().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#E().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const l=this.values,m=this.#i.physical();if(!l||m===0)return null;if(this.#f===null){if(typeof l[0]!="string")return null;const w=new O(this.#j());return w.build(l,m),w.version=this.#w,this.#f=w,this.#m=this.#w,w.capped?null:w}return this.#f.length<m&&this.#f.append(l,this.#f.length,m-this.#f.length),this.#f.version=this.#w,this.#m=this.#w,this.#f.capped?null:this.#f}#j(){return this.#p}#P(){this.#f=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#w}get bytes(){let l=0;return this.#a&&(l+=this.#a.byteLength??this.#a.length*8),this.#u&&(l+=this.#u.bytes),this.#c&&(l+=this.#c.bytes),this.#g&&(l+=this.#g.bytes),this.#d&&(l+=this.#d.bytes),this.#k&&(l+=this.#k.size*24),l}get(l){if(!this.#O&&!(l<0||l>=this.#i.physical())){if(!this.#l)return this.#A(l);if(this.#r&&this.#g.get(l)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[l];case"bitset":return this.#u.get(l)===1;case"dictionary":return this.#d.valueOf(this.#a[l]);case"multi":{const m=this.#c.at(l),w=new Array(m.length);for(let k=0;k<m.length;k++)w[k]=this.#d.valueOf(m[k]);return w}default:return this.#a[l]}}}set(l,m){this.#O||(this.#l?this.#M(l,m):this.#k.set(l,m===void 0?null:m),this.#f&&this.#P(),this.#w++)}read(l){return this.#o(l)}appendColumn(l,m,w){if(this.#O||w<=0)return;if(!this.#l){this.#w++;return}const k=this.#o,p=this.#r,b=this.#g;let E=!1;switch(this.#t){case"float64":{const T=this.#a;for(let P=0;P<w;P++){const x=k(l[P]);if(typeof x=="number"){p&&b.set(m+P),T[m+P]=x;continue}const C=x==null;p?b.assign(m+P,!C):C&&(E=!0),T[m+P]=C?NaN:r(x)}break}case"int32":{const T=this.#a;for(let P=0;P<w;P++){const x=k(l[P]),C=x==null;p?b.assign(m+P,!C):C&&(E=!0),T[m+P]=C?0:o(x)}break}case"bitset":{const T=this.#u;for(let P=0;P<w;P++){const x=k(l[P]),C=x==null;p?b.assign(m+P,!C):C&&(E=!0),T.assign(m+P,!C&&!!x)}break}case"dictionary":{const T=this.#a,P=this.#d;for(let x=0;x<w;x++){const C=k(l[x]),A=C==null;p?b.assign(m+x,!A):A&&(E=!0),T[m+x]=A?0:P.codeOf(C)}break}case"multi":{const T=this.#c,P=this.#d;for(let x=0;x<w;x++){const C=k(l[x]),A=C==null;p?b.assign(m+x,!A):A&&(E=!0);const j=f(C),$=new Array(j.length);for(let z=0;z<j.length;z++)$[z]=P.codeOf(j[z]);T.write(m+x,$)}break}default:{const T=this.#a;for(let P=0;P<w;P++){const x=k(l[P]),C=x==null;p?b.assign(m+P,!C):C&&(E=!0),T[m+P]=C?null:x}break}}E&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,m,w),this.#f.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(l,m,w){if(this.#O||w<=0||!l)return;if(!this.#l){this.#w++;return}const k=this.#g,p=l.presence;if(k)if(p)for(let E=0;E<w;E++)k.assign(m+E,(p[E>>3]&1<<(E&7))!==0);else for(let E=0;E<w;E++)k.set(m+E);const b=l.kind===this.#t;if(b&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(l.values,m),this.#w++;return}if(b&&this.#t==="bitset"){const E=l.values;for(let T=0;T<w;T++)this.#u.assign(m+T,(E[T>>3]&1<<(T&7))!==0);this.#w++;return}if(b&&this.#t==="dictionary"){const E=l.table||[],T=new Uint32Array(E.length);for(let A=0;A<E.length;A++)T[A]=this.#d.codeOf(E[A]);const P=l.values,x=this.#a,C=k;for(let A=0;A<w;A++){if(C&&(p&&(p[A>>3]&1<<(A&7))===0)){x[m+A]=0;continue}x[m+A]=T[P[A]]??0}this.#w++;return}if(b&&this.#t==="multi"){const E=l.table||[],T=new Uint32Array(E.length);for(let C=0;C<E.length;C++)T[C]=this.#d.codeOf(E[C]);const P=l.values,x=l.offsets;for(let C=0;C<w;C++){const A=x[C],j=x[C+1],$=new Array(j-A);for(let z=A;z<j;z++)$[z-A]=T[P[z]]??0;this.#c.write(m+C,$)}this.#w++;return}for(let E=0;E<w;E++){const T=p?(p[E>>3]&1<<(E&7))===0:l.kind==="object"?l.values[E]===null:!1;this.#M(m+E,T?null:i(l,E))}this.#w++}touch(){this.#w++}columnarise(l,m){if(this.#l||this.#O)return;const w=new Array(m);for(let k=0;k<m;k++)w[k]=this.#A(k);this.#t=this.#n,this.#l=!0,this.#S(l);for(let k=0;k<m;k++)this.#M(k,w[k]);this.#k.clear(),this.#b=null,this.#P(),this.#w++}grow(l){if(!(!this.#l||this.#O||l<=this.#y)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#a.constructor(l);m.set(this.#a),this.#a=m;break}case"bitset":this.#u.grow(l);break;case"multi":break;default:this.#a.length=l;break}this.#g&&this.#g.grow(l),this.#y=l,this.#w++}}convert(l){if(this.#O||!n.has(l)||(this.#n=l,!this.#l||l===this.#t))return!1;const m={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),k=this.#g;this.#t=l,this.#S(this.#y);for(let p=0;p<w;p++){const b=k!==null&&k.get(p)===0;b&&l!=="multi"||this.#M(p,b?null:c(m,p))}return this.#P(),this.#w++,!0}compact(l,m,w){if(!this.#O){if(this.#P(),!this.#l){const k=this.#k;if(k.size){const p=new Map;for(const[b,E]of k)l[b]!==y&&p.set(l[b],E);this.#k=p}this.#b=null,this.#w++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const k=this.#a;for(let p=0;p<m;p++)l[p]!==y&&(k[l[p]]=k[p]);if(this.#t==="object")for(let p=w;p<m;p++)k[p]=void 0;break}case"bitset":{const k=this.#u;for(let p=0;p<m;p++)l[p]!==y&&k.assign(l[p],k.get(p)===1);for(let p=w;p<m;p++)k.clear(p);break}case"multi":this.#c.compact(l,w,y);break;default:break}if(this.#g){const k=this.#g;for(let p=0;p<m;p++)l[p]!==y&&k.assign(l[p],k.get(p)===1);for(let p=w;p<m;p++)k.clear(p)}this.#w++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#f=null,this.#k=new Map,this.#b=null,this.#y=0,this.#w++)}#S(l){const m=Math.max(1,l);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(m);break;case"int32":this.#a=new Int32Array(m);break;case"bitset":this.#u=new X(m);break;case"dictionary":this.#a=new Uint32Array(m),this.#d=this.#d??new V(this.#s??[]);break;case"multi":this.#c=new D({rows:m,values:m}),this.#d=this.#d??new V(this.#s??[]);break;default:this.#a=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new X(m)),this.#y=m}#M(l,m){const w=t(m);switch(this.#r?this.#g.assign(l,!w):w&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[l]=w?NaN:r(m);break;case"int32":this.#a[l]=w?0:o(m);break;case"bitset":this.#u.assign(l,!w&&!!m);break;case"dictionary":this.#a[l]=w?0:this.#d.codeOf(m);break;case"multi":{const k=f(m),p=new Array(k.length);for(let b=0;b<k.length;b++)p[b]=this.#d.codeOf(k[b]);this.#c.write(l,p);break}default:this.#a[l]=w?null:m;break}}#A(l){if(this.#k.has(l))return this.#k.get(l);const m=this.#o(this.#i.rowAt(l));return m===void 0?null:m}#E(){if(this.#b&&this.#b.version===this.#w)return this.#b;const l=this.#i.physical(),m=new Array(l),w=this.#r?new X(l):null;for(let k=0;k<l;k++){const p=this.#A(k);m[k]=p,w&&!t(p)&&w.set(k)}return this.#b={version:this.#w,values:m,presence:w},this.#b}}class d{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new X(0);#u=!1;#c=!0;#d;#f;#h;#p=!1;constructor(l,m={}){this.#e=Array.isArray(l)?l:[],this.#f=Math.max(1,m.initialCapacity??u),this.#c=m.retainSource!==!1,this.#d=this.#c?m.columnarBelow??a:0,this.#h=m.compactRatio??s;const w={rowAt:k=>this.#r[k],physical:()=>this.#o};for(const k of this.#e){if(!k||!k.id)continue;if(this.#t.has(k.id)){L(`store.dup.${k.id}`,`duplicate column id "${k.id}" in the store schema; ignoring the second`);continue}const p=new g(k,w);this.#t.set(k.id,p),this.#n.push(p)}this.#d<=0&&this.#y()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let l=this.#a.bytes+this.#r.length*8;for(const m of this.#n)l+=m.bytes;return l}append(l){const m=this.#o;if(this.#p||!l)return{from:m,to:m};const w=l.length|0;if(w===0)return{from:m,to:m};if(this.#c)for(let p=0;p<w;p++)this.#r[m+p]=l[p];if(this.#o=m+w,this.#s+=w,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#y();else for(const p of this.#n)p.touch();return{from:m,to:this.#o}}this.#m(this.#o);const k=this.#n;for(let p=0;p<k.length;p++)k[p].appendColumn(l,m,w);return{from:m,to:this.#o}}appendPacked(l,m){const w=this.#o;if(this.#p||!l)return{from:w,to:w};const k=l.count|0;if(k===0)return{from:w,to:w};if(this.#c&&m)for(let b=0;b<k;b++)this.#r[w+b]=m[b];this.#o=w+k,this.#s+=k,this.#a.grow(this.#o),this.#u||this.#y(),this.#m(this.#o);const p=new Map;for(const b of l.columns)p.set(b.id,b);for(const b of this.#n){const E=p.get(b.id);E?b.appendPacked(E,w,k):b.grow(this.#i)}return{from:w,to:this.#o}}source(l){if(this.#c)return this.#r[l];if(!(l<0||l>=this.#o))return this.#g(l)}setSource(l,m){this.#p||l<0||l>=this.#o||this.#c&&(this.#r[l]=m)}get(l,m){const w=this.#t.get(l);return w?w.get(m):void 0}set(l,m,w){if(this.#p||m<0||m>=this.#o)return;const k=this.#t.get(l);if(!k){L(`store.set.${l}`,`set() on unknown column "${l}"`);return}k.set(m,w)}remove(l){return this.#p||l<0||l>=this.#o||this.#a.get(l)===1?!1:(this.#a.set(l),this.#l++,this.#s--,!0)}live(l){return l<0||l>=this.#o?!1:this.#a.get(l)===0}compact(l={}){if(this.#p||this.#l===0||!l.force&&this.#l/this.#o<this.#h)return null;const m=this.#o,w=new Uint32Array(m);let k=0;for(let p=0;p<m;p++)w[p]=this.#a.get(p)===1?y:k++;for(const p of this.#n)p.compact(w,m,k);if(this.#c){const p=this.#r;for(let b=0;b<m;b++)w[b]!==y&&(p[w[b]]=p[b]);p.length=k}return this.#o=k,this.#s=k,this.#l=0,this.#a=new X(Math.max(this.#i,k)),w}column(l){return this.#t.get(l)}columns(){return this.#n.slice()}liveIndices(){const l=new Uint32Array(this.#s);if(this.#l===0){for(let w=0;w<this.#o;w++)l[w]=w;return l}let m=0;for(let w=0;w<this.#o;w++)this.#a.get(w)===0&&(l[m++]=w);return l}convert(l,m){const w=this.#t.get(l);return w?w.convert(m):!1}destroy(){if(!this.#p){this.#p=!0;for(const l of this.#n)l.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#m(l){if(l<=this.#i)return;let m=this.#i||this.#f;for(;m<l;)m*=2;for(const w of this.#n)w.grow(m);this.#a.grow(m),this.#i=m}#g(l){const m={};for(const w of this.#n)m[w.id]=w.get(l);return m}#y(){if(this.#u)return;let l=this.#f;for(;l<this.#o;)l*=2;this.#u=!0,this.#i=l,this.#a.grow(l);for(const m of this.#n)m.columnarise(l,this.#o)}}}),xe("packages/core/src/store/pool.js",function(e,G){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const Q=64,L=8;function B(H){let V=Q;for(;V<H;)V*=2;return V}class F{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(V={}){this.#n=V.limit??L}get bytes(){return this.#r}mask(V){const K=new Uint8Array(this.#i(V),0,V);return K.fill(0),K}indices(V){return new Uint32Array(this.#i(V*4),0,V)}release(V){if(!V||!V.buffer)return!1;const K=V.buffer;if(!this.#t.has(K))return!1;this.#t.delete(K),this.#o.released++;const D=K.byteLength;let v=this.#e.get(D);return v||this.#e.set(D,v=[]),v.length>=this.#n||(v.push(K),this.#r+=D),!0}releaseAll(V){for(const K of V)this.release(K)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(V){const K=B(V),D=this.#e.get(K);this.#o.acquired++;let v;return D&&D.length?(v=D.pop(),this.#r-=K,this.#o.reused++):v=new ArrayBuffer(K),this.#t.add(v),v}}function W(){return X??=new F,X}let X=null}),xe("packages/core/src/compute/sortspec.js",function(e,G){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function Q(X){return{locale:X===void 0?void 0:String(X),numeric:!0,sensitivity:"variant"}}function L(X){return!!X&&typeof X.compare!="function"}function B(X){if(!X)return!0;for(let H=0;H<X.length;H++)if(!L(X[H]))return!1;return!0}function F(X,H){const V=X.col!==void 0?X.col:X.handle&&X.handle.id,K=X.locale!==void 0?X.locale:H;return{col:V,descending:X.descending!==void 0?!!X.descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,collation:Q(K)}}function W(X,H){const V=X||[],K=new Array(V.length);for(let D=0;D<V.length;D++)K[D]=F(V[D],H);return K}}),xe("packages/core/src/compute/facet.js",function(e,G){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return K}}),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 O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const Q=G("packages/core/src/compute/handle.js"),L=Q.presenceReader,B=Q.valueReader,F=Q.dictSize,W=Q.dictValue,X=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),V=20,K=50,D=1e4;function v(p,b){if(!p)return"none";const E=b;if(E&&(E.multi===!0||typeof E.items=="function"))return"category";const T=b&&b.base;if(T==="date"||T==="datetime"||T==="time"||T==="dateString")return"date";switch(p.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return T==="number"?"numeric":T==="boolean"?"boolean":T==="text"?"category":"none"}}function O(p){const b=p.values,E=p.kind;if((E==="float64"||E==="int32")&&b)return P=>b[P];const T=B(p);return P=>y(T(P))}function y(p){if(typeof p=="number")return p;if(p instanceof Date)return p.getTime();if(p==null||p==="")return NaN;if(typeof p=="boolean")return p?1:0;if(typeof p=="string"){const b=Number(p);if(Number.isFinite(b))return b;const E=Date.parse(p);return Number.isFinite(E)?E:NaN}return NaN}function u(p,b,E,T=K){if(!p)return{cardinality:0,exact:!0};if(p.dict)return{cardinality:F(p.dict),exact:!0};if(p.kind==="bitset")return{cardinality:2,exact:!0};const P=B(p),x=b?b.length:E,C=new Set;for(let A=0;A<x;A++){const j=P(b?b[A]:A);if(j!=null&&(C.add(j),C.size>T))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const a=36e5,s=864e5;function n(p,b=V){const E=Number.isFinite(p)&&p>0?p:0,T=Math.max(1,b)*2;return E/a<=T?"hour":E/s<=T?"day":E/(7*s)<=T?"week":E/(30*s)<=T?"month":E/(91*s)<=T?"quarter":"year"}function t(p,b){if(!Number.isFinite(p))return NaN;const E=new Date(p);switch(b){case"hour":return E.setMinutes(0,0,0),E.getTime();case"day":return E.setHours(0,0,0,0),E.getTime();case"week":{E.setHours(0,0,0,0);const T=(E.getDay()+6)%7;return E.setDate(E.getDate()-T),E.getTime()}case"month":return E.setDate(1),E.setHours(0,0,0,0),E.getTime();case"quarter":return E.setMonth(Math.floor(E.getMonth()/3)*3,1),E.setHours(0,0,0,0),E.getTime();default:return E.setMonth(0,1),E.setHours(0,0,0,0),E.getTime()}}function r(p,b){const E=new Date(p);switch(b){case"hour":E.setHours(E.getHours()+1);break;case"day":E.setDate(E.getDate()+1);break;case"week":E.setDate(E.getDate()+7);break;case"month":E.setMonth(E.getMonth()+1);break;case"quarter":E.setMonth(E.getMonth()+3);break;default:E.setFullYear(E.getFullYear()+1);break}return E.getTime()}function o(p,b,E){const T=O(p),P=L(p),x=b?b.length:E;let C=1/0,A=-1/0,j=0,$=0;for(let z=0;z<x;z++){const M=b?b[z]:z;if(P&&!P(M)){j++;continue}const R=T(M);if(!Number.isFinite(R)){j++;continue}R<C&&(C=R),R>A&&(A=R),$++}return{min:C,max:A,nulls:j,finite:$}}function f(p,b,E,T){const P=O(p),x=L(p),C=b?b.length:E,A=C>T?C/T:1,j=[];for(let z=0;z<C;z+=A){const M=b?b[Math.floor(z)]:Math.floor(z);if(x&&!x(M))continue;const R=P(M);Number.isFinite(R)&&j.push(R)}const $=Float64Array.from(j);return $.sort(),$}function c(p,b,E,T={}){const P=T.kind||v(p,T.type);return P==="none"||!p?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?i(p,b,E):P==="category"?g(p,b,E,T):d(p,b,E,P,T)}function i(p,b,E){const T=L(p);let P=0;if(T){const C=b?b.length:E;for(let A=0;A<C;A++)T(b?b[A]:A)||P++}const x=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&x.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:x}}function g(p,b,E,T){const P=T.cardinalityLimit??K,{cardinality:x}=u(p,b,E,P);if(x>P&&(T.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:x};const C=B(p),A=b?b.length:E,j=new Map;let $=0;for(let I=0;I<A;I++){const q=C(b?b[I]:I);if(q==null||q===""){$++;continue}if(Array.isArray(q)){if(!q.length){$++;continue}for(const Z of q)j.set(Z,(j.get(Z)||0)+1);continue}j.set(q,(j.get(q)||0)+1)}let z=[...j.entries()];T.order==="alpha"?z.sort((I,q)=>String(I[0]).localeCompare(String(q[0]))):z.sort((I,q)=>q[1]-I[1]);let M=0,R=0;if(z.length>P){R=z.length-P;for(let I=P;I<z.length;I++)M+=z[I][1];z=z.slice(0,P)}const S=z.map(([I])=>({value:I,label:String(I)}));return M>0&&S.push({remainder:!0,label:`Other (${R} values)`}),$>0&&S.push({null:!0,label:"Empty"}),{kind:"category",buckets:S,cardinality:x}}function d(p,b,E,T,P){const{min:x,max:C,nulls:A,finite:j}=o(p,b,E);if(!j)return{kind:T,buckets:A?[{null:!0,label:"Empty"}]:[],empty:!0};const $=Math.max(1,Math.floor(P.buckets||V));let z=[];if(T==="date"){const R=H.includes(P.granularity)?P.granularity:n(C-x,$);let S=t(x,R);for(;S<=C&&z.length<4096;){const I=r(S,R);if(!(I>S))break;z.push({from:S,to:I}),S=I}return{kind:T,buckets:h(z,A),granularity:R}}const M=X.includes(P.strategy)?P.strategy:"equal";if(M==="quantile"){const R=f(p,b,E,D);if(R.length){const S=[R[0]];for(let I=1;I<$;I++){const q=R[Math.min(R.length-1,Math.floor(I/$*R.length))];q>S[S.length-1]&&S.push(q)}S.push(C);for(let I=0;I<S.length-1;I++)z.push({from:S[I],to:S[I+1]})}}else if(M==="log"&&x>0){const R=Math.log10(x),I=(Math.log10(C)-R)/$||1;for(let q=0;q<$;q++)z.push({from:10**(R+q*I),to:10**(R+(q+1)*I)})}if(!z.length){const R=(C-x)/$||1;for(let S=0;S<$;S++)z.push({from:x+S*R,to:x+(S+1)*R})}return z[z.length-1].to=C,{kind:T,buckets:h(z,A),strategy:M,min:x,max:C}}function h(p,b){return b>0?[...p,{null:!0,label:"Empty"}]:p}function l(p,b,E,T,P){const x=T&&T.buckets||[],C=P&&P.length>=x.length?P.subarray(0,x.length):new Uint32Array(x.length);if(C.fill(0),!p||!x.length)return C;const A=x.length-1,j=!!x[A]&&x[A].null===!0,$=b?b.length:E;if(T.kind==="boolean"){const I=B(p);for(let q=0;q<$;q++){const Z=I(b?b[q]:q);if(Z==null){j&&C[A]++;continue}C[Z?1:0]++}return C}if(T.kind==="category"){const I=new Map;for(let _=0;_<x.length;_++)!x[_].null&&!x[_].remainder&&I.set(x[_].value,_);const q=x.findIndex(_=>_.remainder),Z=B(p);for(let _=0;_<$;_++){const J=Z(b?b[_]:_);if(J==null||J===""){j&&C[A]++;continue}if(Array.isArray(J)){if(!J.length){j&&C[A]++;continue}for(const te of J){const ne=I.get(te);ne!==void 0?C[ne]++:q>=0&&C[q]++}continue}const ee=I.get(J);ee!==void 0?C[ee]++:q>=0&&C[q]++}return C}const z=j?x.length-1:x.length,M=new Float64Array(z+1);for(let I=0;I<z;I++)M[I]=x[I].from;M[z]=z?x[z-1].to:0;const R=O(p),S=L(p);for(let I=0;I<$;I++){const q=b?b[I]:I;if(S&&!S(q)){j&&C[A]++;continue}const Z=R(q);if(!Number.isFinite(Z)){j&&C[A]++;continue}const _=m(M,z,Z);_>=0&&C[_]++}return C}function m(p,b,E){if(!b||E<p[0])return-1;if(E>=p[b])return E===p[b]?b-1:-1;let T=0,P=b-1;for(;T<P;){const x=T+P+1>>>1;E>=p[x]?T=x:P=x-1}return T}function w(p,b,E,T={}){const P=T.bounds||c(p,T.boundsIndices??b,E,T);return{bounds:P,counts:l(p,b,E,P)}}const k=w}),xe("packages/core/src/compute/pivotmatrix.js",function(e,G){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const L=G("packages/core/src/compute/handle.js").valueComparator,F=G("packages/core/src/compute/total.js").total,X=G("packages/core/src/compute/group.js").packKeys,H=G("packages/core/src/compute/pivot.js"),V=H.joinPath,K=H.DEFAULT_PATH_SEPARATOR,D=H.DEFAULT_MAX_COLUMNS,v="";function O(r,o,f={}){const c=f.separator||K,i=r||[],g=o instanceof Uint32Array?o:Uint32Array.from(o||[]),d=g.length;if(i.length===0)return{tuples:[[]],paths:[v],buckets:[g]};const{keyOf:h,readers:l}=X(i,g,0),m=new Map,w=[],k=[],p=[];for(let C=0;C<d;C++){const A=g[C],j=h(A);let $=m.get(j);if($===void 0){$=w.length,m.set(j,$),k.push(j);const z=new Array(l.length);for(let M=0;M<l.length;M++)z[M]=l[M](A);w.push(z),p.push([])}p[$].push(A)}const b=L(f.locale),E=w.map((C,A)=>A);E.sort((C,A)=>{const j=w[C],$=w[A];for(let z=0;z<j.length;z++){const M=y(j[z],$[z],b);if(M!==0)return M}return C-A});const T=new Array(E.length),P=new Array(E.length),x=new Array(E.length);for(let C=0;C<E.length;C++){const A=E[C];T[C]=w[A],P[C]=V(w[A],c),x[C]=Uint32Array.from(p[A])}return{tuples:T,paths:P,buckets:x}}function y(r,o,f){const c=r==null,i=o==null;return c||i?c&&i?0:c?1:-1:f(r,o)}function u(r,o,f){const c=[];for(let i=0;i<r.length;i++)f.has(r[i])&&c.push(r[i]);return Uint32Array.from(c)}function a(r,o,f,c){return{value:o.length?F(r,o,f,c):null,leaves:o,count:o.length}}function s(r){const o=r&&r.opts||{},f=o.separator||K,c=o.totalContext||{locale:o.locale},i=(r.measures||[]).filter(P=>P&&P.handle),g=r.leaves instanceof Uint32Array?r.leaves:Uint32Array.from(r.leaves||[]),d=O(r.rowHandles||[],g,{...o,separator:f}),h=O(r.columnHandles||[],g,{...o,separator:f}),l=o.maxColumns===void 0?D:o.maxColumns,m=h.paths.length*Math.max(1,i.length),w=new Map;if(l&&m>l)return{rowAxis:d,columnAxis:h,measures:i.map(P=>({colId:P.colId,fn:P.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${l}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:l}};const k=new Map,p=new Map,b=new Map,E=new Map,T=h.buckets.map(P=>new Set(P));for(let P=0;P<h.paths.length;P++){const x=h.buckets[P],C=h.paths[P];for(const A of i)b.set(t(C,A.colId),a(A.handle,x,A.fn,c))}for(let P=0;P<d.paths.length;P++){const x=d.buckets[P],C=d.paths[P];for(const A of i)p.set(t(C,A.colId),a(A.handle,x,A.fn,c));for(let A=0;A<h.paths.length;A++){const j=u(x,h.buckets[A],T[A]);if(j.length===0)continue;const $=h.paths[A];for(const z of i)k.set(n(C,$,z.colId),a(z.handle,j,z.fn,c))}}for(const P of i)E.set(P.colId,a(P.handle,g,P.fn,c));return{rowAxis:d,columnAxis:h,measures:i.map(P=>({colId:P.colId,fn:P.fn})),body:k,rowMargin:p,columnMargin:b,grand:E,columns:m,error:null}}function n(r,o,f){return`${r}\0${o}\0${f}`}function t(r,o){return`${r}\0${o}`}}),xe("packages/core/src/compute/reference.js",function(e,G){"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 u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return s}});const L=G("packages/core/src/internal/util.js").getPath,B=G("packages/core/src/compute/handle.js"),F=B.isMissing,W=B.valueComparator,H=G("packages/core/src/compute/filter.js").testValue,V="",K="\0";function D(r,o){const f=o.includes(".")?L(r,o):r?.[o];return f===void 0?null:f}function v(r,o,f={}){const c=o||[];let i=r.map((g,d)=>d);if(c.length===0)return i;for(let g=c.length-1;g>=0;g--)i=O(r,i,c[g],f);return i}function O(r,o,f,c){const i=f.locale!==void 0?f.locale:c.locale,g=W(i),d=f.descending!==void 0?!!f.descending:f.dir==="desc",h=[],l=[];for(const k of o){const p=D(r[k],f.col);F(p)?l.push(k):h.push(k)}const m=new Map;for(let k=0;k<h.length;k++)m.set(h[k],k);const w=(k,p)=>{const b=D(r[k],f.col),E=D(r[p],f.col);let T;return typeof f.compare=="function"?(T=f.compare(b,E,r[k],r[p],d),d&&(T=-T)):T=d?g(E,b):g(b,E),T!==0?T:m.get(k)-m.get(p)};return h.sort(w),f.nullsFirst?l.concat(h):h.concat(l)}function y(r,o,f={}){const c=[];for(let i=0;i<r.length;i++)u(r[i],o,f,i)&&c.push(i);return c}function u(r,o,f,c){if(!o)return!0;if(Array.isArray(o.conditions)){const i=o.conditions.filter(d=>d!=null);if(i.length===0)return!0;if(o.op==="or")return i.some(d=>u(r,d,f,c));const g=i.every(d=>u(r,d,f,c));return o.op==="not"?!g:g}return o.col===void 0&&typeof f.custom=="function"?!!f.custom(o,r,c):H(D(r,o.col),o,f.locale)}function a(r,o,f,c){const i=f||r.map((l,m)=>m),g=new Map,d=[],h=[];for(const l of i){const m=o.map((p,b)=>{const E=D(r[l],p);return c&&c[b]?c[b](E):E}),w=m.map(p=>p==null?K:String(p)).join(V);let k=g.get(w);k===void 0&&(k=d.length,g.set(w,k),d.push(m),h.push([])),h[k].push(l)}return{keys:d,buckets:h}}function s(r,o,f={}){const c=W(f.locale),i=r.filter(d=>!F(d)),g=i.map(n).filter(d=>d!==null);switch(o){case"count":return r.length;case"countValues":return i.length;case"sum":return g.reduce((d,h)=>d+h,0);case"avg":return i.length===0?null:g.reduce((d,h)=>d+h,0)/i.length;case"min":return i.length===0?null:i.reduce((d,h)=>c(h,d)<0?h:d);case"max":return i.length===0?null:i.reduce((d,h)=>c(h,d)>0?h:d);case"first":return r.length===0?null:t(r[0]);case"last":return r.length===0?null:t(r[r.length-1]);default:return null}}function n(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isNaN(o)?null:o}function t(r){return r===void 0?null:r}}),xe("packages/core/src/compute/index.js",function(e,G){"use strict";const Q=G("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return Q.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return Q.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return Q.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return Q.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return Q.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return Q.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return Q.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return Q.rankSortStrings}});const L=G("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return L.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return L.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L.describeSort}});const B=G("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return B.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return B.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return B.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return B.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return B.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return B.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return B.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return B.mentionsColumn}});const F=G("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return F.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return F.packKeys}});const W=G("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 X=G("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return X.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return X.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return X.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return X.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return X.collectValues}});const H=G("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 V=G("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return V.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return V.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return V.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return V.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return V.GRAND_PATH}});const K=G("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return K.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return K.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return K.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return K.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return K.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return K.referenceValue}});const D=G("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=G("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 O=G("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const y=G("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return y.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return y.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return y.maintenanceOf}});const u=G("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const a=G("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return a.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return a.forecast}})}),xe("packages/core/src/source/rows.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return K}}),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 u}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.isFunction,F=32,W="\0";function X(a){return new H(a)}class H{#e;#t;constructor(s){this.#e=B(s&&s.rowKey)?s.rowKey:null;const n=s&&s.config?s.config.rowHeight:void 0;this.#t=typeof n=="number"||B(n)?n:F}get keyed(){return this.#e!==null}keyOf(s,n){if(this.#e){const t=this.#e(s);if(t!=null)return String(t)}else L("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${n}`}heightOf(s){return B(this.#t)?Number(this.#t(s))||F:this.#t}leaf(s,n,t=0,r=null){const o={key:this.keyOf(s,n),data:s,level:t,parent:r,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:n};return o.height=this.heightOf(o),o}group(s){const n={key:y(s.keyPath||s.path),data:null,level:s.level,parent:s.parent||null,children:[],group:!0,expanded:s.expanded!==!1,leafCount:s.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:s.column,groupValue:s.value,groupPath:s.path,hasChildren:s.hasChildren!==!1};return s.totals&&(n.totals=s.totals),n.height=this.heightOf(n),n}footer(s){const n={key:`${s.key}${W}footer`,data:null,level:s.level,parent:s,group:!0,footer:!0,expanded:!1,leafCount:s.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:s.groupColumn,groupValue:s.groupValue,groupPath:s.groupPath,hasChildren:!1,totals:s.totals};return n.height=this.heightOf(n),n}detail(s,n){return{key:`${s.key}${W}detail`,data:s.data,level:s.level+1,parent:s,group:!1,detail:!0,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:s.key}}grandTotal(s,n){const t={key:`${W}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:n,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:s};return t.height=this.heightOf(t),t}skeleton(s,n=0,t=!1){const r={key:`${W}pending${W}${s}`,data:null,level:n,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:s,selected:!1,physical:null,pending:!0};return t&&(r.loadError=!0),r.height=this.heightOf(r),r}}function V(a,s,n,t){return{key:`${W}pinned${W}${n}${W}${s}`,data:a,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:n}}function K(a,s){return new Proxy([],{get(n,t,r){if(t==="length")return a();if(typeof t=="string"){const o=Number(t);if(Number.isInteger(o)&&o>=0)return s(o)}return Reflect.get(n,t,r)},has(n,t){if(typeof t=="string"){const r=Number(t);if(Number.isInteger(r)&&r>=0)return r<a()}return Reflect.has(n,t)}})}function D(a){return a==null?"":String(a)}const v="";function O(a){if(a==null)return v;const s=String(a);return s.startsWith(v)?v+s:s}function y(a){const s=a||[];let n="g";for(let t=0;t<s.length;t++)n+=W+O(s[t]);return n}function u(a){const s=new Array(a.length),n=[];for(let t=0;t<a.length;t++)n.push(a[t]),s[t]=y(n);return s}}),xe("packages/core/src/source/handles.js",function(e,G){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce;class F{#e;#t;#n;#r=new Map;#o=0;constructor(H,V,K){this.#e=H,this.#t=V,this.#n=L(K)?K:()=>!1}get store(){const H=this.#e.store;return H&&L(H.column)?H:null}invalidate(){this.#o++}handle(H){const V=this.store;if(V){const O=V.column(H);if(O)return O}const K=this.#r.get(H);if(K&&K.builtAt===this.#o)return K.handle;const D=this.#i(H);if(!D)return;if(V&&this.#n()){B(`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 V=this.#e.columns;return V&&L(V.get)?V.get(H):void 0}#s(H){const V=this.#t()||[],K=V.length,D=new Array(K),v=L(H.getValue)?y=>H.getValue(y):y=>y?.[H.field||H.id];for(let y=0;y<K;y++)D[y]=V[y]===void 0?void 0:v(V[y]);const O=this.#o;return{id:H.id,kind:"object",nullable:!1,values:D,presence:null,dict:null,offsets:null,get(y){return D[y]},version:O}}}function W(X,H,V){return new F(X,H,V)}}),xe("packages/core/src/compute/incremental.js",function(e,G){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const L=G("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),F=Object.freeze(["float64"]),W=1e15;function X(D,v){return typeof D!="string"||!B.includes(D)?!1:!!v&&F.includes(v.kind)}function H(D){if(D==null)return null;const v=L(D);return Number.isNaN(v)?null:v}class V{#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 O=0;O<v.length;O++){const y=H(v[O]);y!==null&&this.#u(y)}this.#s=!0}seedColumn(v,O,y){this.#a();for(let u=0;u<y.length;u++){const a=y[u];if(O&&O(a)===0)continue;const s=v[a];Number.isNaN(s)||this.#u(s)}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 O=this.#t+v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-O+v:v-O+this.#t,this.#t=O,this.#r++,v<this.#o&&(this.#o=v),v>this.#i&&(this.#i=v)}#c(v){const O=this.#t-v;this.#n+=Math.abs(this.#t)>=Math.abs(v)?this.#t-O-v:-v-O+this.#t,this.#t=O,this.#r--}update(v,O){if(!this.#s)return!1;const y=H(v),u=H(O);return y===null&&u===null?!0:y!==null&&!Number.isFinite(y)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?y===null||u===null?!1:this.#e==="min"?u<this.#o?(this.#o=u,!0):y>this.#o:u>this.#i?(this.#i=u,!0):y<this.#i:Math.abs(this.#t)>W?!1:(y!==null&&this.#c(y),u!==null&&this.#u(u),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const K=V}),xe("packages/core/src/source/filterwire.js",function(e,G){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return b}});const L=G("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",F="source.where.pageRelative";function W(P,x){!Array.isArray(P)||!P.length||L(F,`filters.where (${P.join(", ")}) runs over the rows the ${x} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function X(P){const x=(P||{}).config;!x||!x.hostFilter||L(B,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function V(P,x){L(`${H}:${P}`,`filters.where("${P}") is registered but the ${x} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const K="source.where.overThreshold";function D(P,x,C,A){!Array.isArray(P)||!P.length||L(`${K}:${x}`,`filters.where (${P.join(", ")}) is not applied to the ${x} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${A.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 O(P){let x=v.get(P);return x||(x=new Intl.DateTimeFormat("en-US",{timeZone:P,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),v.set(P,x)),x}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(P,x){const C=O(x).formatToParts(new Date(P)),A={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const j of C)j.type==="year"?A.y=+j.value:j.type==="month"?A.m=+j.value:j.type==="day"?A.d=+j.value:j.type==="hour"?A.h=+j.value%24:j.type==="minute"?A.mi=+j.value:j.type==="second"&&(A.s=+j.value);return A}function a(P,x){const C=u(P,x);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(P/1e3)*1e3}function s(P,x,C,A){const j=Date.UTC(P,x-1,C),$=j-a(j,A);return j-a($,A)}function n(P,x,C){const A=new Date(Date.UTC(P.y,P.m-1,P.d+x));return s(A.getUTCFullYear(),A.getUTCMonth()+1,A.getUTCDate(),C)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(P,x){if(typeof P!="string")return null;const C=P.trim().toLowerCase().replace(/[\s_-]+/g,""),A=/^last(\d*|n)days?$/.exec(C);if(A){const j=A[1]==="n"?"":A[1],$=Number(j||x);return!Number.isFinite($)||$<=0?null:{kind:"lastNDays",n:Math.floor($)}}switch(C){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function o(P,x={}){const C=r(P,x.n);if(!C)return null;const A=x.tz||y(),j=x.now instanceof Date?x.now.getTime():typeof x.now=="number"?x.now:Date.now(),$=u(j,A),z=s($.y,$.m,$.d,A),M=n($,1,A);let R=z,S=M;switch(C.kind){case"today":break;case"yesterday":R=n($,-1,A),S=z;break;case"lastNDays":S=x.includeToday?M:z,R=n($,x.includeToday?-(C.n-1):-C.n,A);break;case"thisWeek":{const I=Number.isFinite(x.weekStartsOn)?Number(x.weekStartsOn):1,Z=(new Date(Date.UTC($.y,$.m-1,$.d)).getUTCDay()-I+7)%7;R=n($,-Z,A),S=n($,-Z+7,A);break}case"thisMonth":R=s($.y,$.m,1,A),S=s($.m===12?$.y+1:$.y,$.m===12?1:$.m+1,1,A);break;case"thisQuarter":case"quarterToDate":{const I=Math.floor(($.m-1)/3)*3+1;R=s($.y,I,1,A),S=C.kind==="quarterToDate"?M:I===10?s($.y+1,1,1,A):s($.y,I+3,1,A);break}case"thisYear":case"yearToDate":R=s($.y,1,1,A),S=C.kind==="yearToDate"?M:s($.y+1,1,1,A);break;default:return null}return{from:new Date(R).toISOString(),to:new Date(S).toISOString(),bounds:"[)",tz:A,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function f(P){if(!P||typeof P!="object")return null;const x=P.value;if(x&&typeof x=="object"&&!Array.isArray(x)&&"relative"in x)return{token:String(x.relative),n:typeof x.n=="number"?x.n:void 0};if(P.op==="relative"&&typeof P.value=="string")return{token:P.value,n:void 0};const C=P.meta;return C&&typeof C.relative=="string"&&P.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function c(){return`Known tokens: ${t.filter(x=>x!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(P){const x=f(P);return x?r(x.token,x.n)!==null:!1}function g(P,x={}){const C=f(P);if(!C)return P;const A=o(C.token,{...x,n:C.n});return A?{...P,type:P.type||"date",op:"between",value:[A.from,A.to],bounds:P.bounds||A.bounds,meta:{...P.meta||{},relative:A.relative,tz:A.tz}}:(L(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,c()),P)}function d(P){return!!P&&typeof P=="object"&&Array.isArray(P.conditions)}function h(P,x){if(P){if(d(P)){for(const C of P.conditions)h(C,x);return}x(P)}}function l(P,x){if(!P)return null;if(!d(P))return x(P);const C=P;let A=!1;const j=[];for(const $ of C.conditions){const z=l($,x);z!==$&&(A=!0),z&&j.push(z)}return!A&&j.length===C.conditions.length?P:j.length?{...C,conditions:j}:null}function m(P){if(!P)return null;if(!d(P))return P;const x=P,C=[];for(const A of x.conditions){const j=m(A);j&&C.push(j)}return C.length?{op:x.op,conditions:C}:null}function w(P){const x=m(P);return x?d(x)&&x.op==="and"?x:{op:"and",conditions:[x]}:null}function k(P){const x=(P||[]).filter(Boolean);return x.length?{op:"and",conditions:x}:null}function p(P,x={}){const C=l(P,A=>g(A,x));return w(C)}function b(P){const x=E(P.filters??null);return JSON.stringify([x,P.sort??null,P.quick??"",P.groupBy??null,P.pivotBy??null,T(P.context)])}function E(P){if(!P)return null;if(d(P)){const A=P;return{op:A.op,conditions:A.conditions.map(E)}}const x=P,C=x.meta&&typeof x.meta.relative=="string"?x.meta.relative:f(x)?.token;return{col:x.col,op:x.op,bounds:x.bounds??null,caseSensitive:x.caseSensitive??!1,value:C?`rel:${C}`:x.value??null}}function T(P){if(P==null)return null;try{return JSON.parse(JSON.stringify(P))}catch{return L("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),xe("packages/core/src/source/tree.js",function(e,G){"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 V}}),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 O}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,F="",W="\0tree:";function X(u,a){return{physical:u,key:a,level:0,children:[],value:void 0}}function H(u,a){const s=[],n=new Map;for(let t=0;t<u.length;t++){const r=u[t],o=a.pathOf(r),f=Array.isArray(o)?o.map(i=>String(i)):[];if(!f.length){const i=X(r,a.keyOf(r));s.push(i);continue}let c=null;for(let i=0;i<f.length;i++){const g=f.slice(0,i+1).join(F),d=i===f.length-1;let h=n.get(g);h&&d&&h.physical===-1&&(h.physical=r,h.key=a.keyOf(r)),h||(h=X(d?r:-1,d?a.keyOf(r):W+g),h.level=i,h.value=f[i],n.set(g,h),c?c.children.push(h):s.push(h)),c=h}}return{roots:s,nodes:n}}function V(u,a){const s=new Map,n=[];for(let f=0;f<u.length;f++){const c=u[f],i=a.keyOf(c),g=X(c,i);s.set(i,g);const d=a.parentOf(c);d!=null&&d!==""&&n.push({node:g,parent:String(d)})}let t=null;const r=new Map;for(const{node:f,parent:c}of n){const i=s.get(c);if(i){r.set(f.key,i);continue}a.orphans&&a.orphans!=="root"&&(t||(t=X(-1,`${W}orphans`),t.value=a.orphans),r.set(f.key,t))}const o=[];for(const f of s.values()){const c=r.get(f.key);c?c.children.push(f):o.push(f)}return t&&t.children.length&&o.push(t),{roots:K(o,s,a.orphans,t),nodes:s}}function K(u,a,s,n){const t=new Set,r=[...u];for(;r.length;){const g=r.pop();if(!t.has(g.key)){t.add(g.key);for(const d of g.children)r.push(d)}}const o=[];for(const g of a.values())t.has(g.key)||o.push(g);if(!o.length)return u;const f=!!s&&s!=="root";B("tree.cycle",`tree.parentKey produced ${o.length} row(s) inside a parent cycle; `+(f?`they are shown under "${s}".`:"they are shown at the root."));for(const g of o)g.children=g.children.filter(d=>t.has(d.key));if(!f)return[...u,...o];let c=n;const i=[...u];return c||(c=X(-1,`${W}orphans`),c.value=s,i.push(c)),c.children.push(...o),i}function D(u){let a=0;const s=(n,t)=>{for(const r of n)r.level=t,t>a&&(a=t),r.children.length&&s(r.children,t+1)};return s(u,0),a}function v(u,a){if(!u||typeof u!="object")return null;const s=u.path,n=u.parentKey,t=L(u.hasChildren)?r=>!!u.hasChildren(a.dataAt(r)):null;if(L(s))return{mode:"path",pathOf:r=>s(a.dataAt(r)),keyOf:a.keyOf,declaresChildren:t};if(n!=null){const r=L(n)?n:o=>o?.[n];return{mode:"parentKey",parentOf:o=>r(a.dataAt(o)),keyOf:a.keyOf,orphans:u.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function O(u,a){const s=a.mode==="path"?H(u,a):V(u,a),n=D(s.roots);return{...s,depth:n}}function y(u,a){const s=new Map,n=t=>{for(let r=0;r<t.length;r++){const o=t[r];if(o.physical>=0){const f=a?a(o.physical):!1,c=f&&o.children.length===0;s.set(o.physical,{level:o.level,posinset:r+1,setsize:t.length,hasChildren:o.children.length>0||f,lazy:c})}o.children.length&&n(o.children)}};return n(u),s}}),xe("packages/core/src/source/memory.js",function(e,G){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return M}});const Q=G("packages/core/src/internal/util.js"),L=Q.Lru,B=Q.warnOnce,F=Q.fail,W=Q.isFunction,X=Q.defaultCompare,H=Q.mergeRow,V=G("packages/core/src/source/rows.js"),K=V.createRowFactory,D=V.groupKey,v=V.groupPathElement,O=V.groupPrefixKeys,y=V.lazyRowView,a=G("packages/core/src/source/handles.js").createHandleProvider,s=G("packages/core/src/compute/incremental.js"),n=s.RunningTotal,t=s.isIncremental,o=G("packages/core/src/compute/handle.js").presenceReader,f=G("packages/core/src/source/filterwire.js"),c=f.querySignature,i=f.mapConditions,g=f.resolveRelativeCondition,d=G("packages/core/src/source/tree.js"),h=d.buildTree,l=d.resolveTree,m=d.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),k=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function p(R){const S=R&&typeof R=="object"?R.reason:null;return typeof S=="string"&&k.includes(S)}const b=Object.freeze([]);function E(R,S){if(!R)return null;const I=S==="grand"?R.grandTotal:R.groupTotal;return I??R.total}function T(R){return!!R&&!R.running}function P(R){if(R)return R.value&&W(R.value.compare)?R.value.compare:W(R.compare)?R.compare:void 0}function x(R){const S=R&&R.dataType;return!S||!W(S.items)?null:{items:S.items,type:R.itemType&&R.itemType.name||"text"}}function C(R){return!!R&&(typeof R=="object"||typeof R=="function")&&W(R.then)}const A=new Uint32Array(0),j=4096;function $(R,S){return new M(R,S)}function z(R,S){if(S==="regex")try{const I=new RegExp(R,"iu");return q=>I.test(q)}catch{return I=>I.includes(R)}if(S==="fuzzy"){const I=[...R].filter(q=>q!==" ");return I.length?q=>{let Z=0;for(let _=0;_<q.length&&Z<I.length;_++)q[_]===I[Z]&&Z++;return Z===I.length}:()=>!0}if(S==="words"){const I=R.split(/\s+/).filter(Boolean);return I.length?q=>I.every(Z=>q.includes(Z)):()=>!0}return I=>I.includes(R)}class M{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#f=new Map;#h;#p=null;#m=M.#g();static#g(){return{slots:[],groupHeadings:b,unnumbered:b,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#y=new Map;#w=null;#k=new Map;#b=-1;#O=[];#j=new Map;#P=-1;#S=[];#M=null;#A=null;#E=null;#R=null;#L=null;#x=null;#I=null;#z=null;#$=Symbol("unset");#N=new Map;#H=null;get#B(){return this.#m.slots}set#B(S){this.#m.slots=S}get#W(){return this.#m.inlineLeaves}set#W(S){this.#m.inlineLeaves=S}get#ie(){return this.#m.groupHeadings}set#ie(S){this.#m.groupHeadings=S}get#re(){return this.#m.unnumbered}set#re(S){this.#m.unnumbered=S}get#le(){return this.#m.pivot}set#le(S){this.#m.pivot=S}constructor(S,I){this.#t=S||{mode:"memory"},this.#e=I||{};const q=this.#e.config||{};this.#n=this.#t.rows||q.rows||[],this.#i=K(this.#e),this.#s=a(this.#e,()=>this.#n,()=>this.#r),this.#h=new L(Number(q.rowCacheSize)||j);for(const Z of w)this.#l.set(Z,{key:null,result:null,id:0,computed:!1})}count(){this.#X();const S=this.#ue();return S?S.length:this.#B.length}#ue(){const S=Number(this.#V("pageSize",0))||0;if(S<=0)return null;const I=this.#B.length,q=Math.max(1,Math.ceil(I/S)),_=Math.min(Math.max(0,Number(this.#V("page",0))||0),q-1)*S;return{offset:_,length:Math.max(0,Math.min(S,I-_))}}pageInfo(){this.#X();const S=Number(this.#V("pageSize",0))||0,I=this.#B.length;if(S<=0)return{page:0,pageSize:0,total:I,pageCount:1};const q=Math.max(1,Math.ceil(I/S));return{page:Math.min(Math.max(0,Number(this.#V("page",0))||0),q-1),pageSize:S,total:I,pageCount:q}}totalCount(){return this.#Me().length}matchCount(){return this.#X(),this.#m.matchCount}at(S){this.#X();const I=this.#ue();if(I)return S<0||S>=I.length?void 0:this.#He(I.offset+S,S);if(!(S<0||S>=this.#B.length))return this.#He(S,S)}byKey(S){this.#X(),this.#p||this.#_();const I=this.#p.get(S);if(I!==void 0)return this.#Ne(I);for(let q=0;q<this.#B.length;q++){const Z=this.#B[q];if(typeof Z!="number"&&Z&&Z.key===S)return this.#He(q)}}loaded(S){return S>=0&&S<this.count()}hint(S,I){}display(){return this.#X(),this.#H||(this.#H=this.#xt()),this.#H}invalidateQuickText(){this.#N.clear(),this.invalidate("filter")}invalidate(S){const I=w.indexOf(S);I<0&&F(`unknown pipeline stage "${S}"; expected one of ${w.join(", ")}`);for(let q=I;q<w.length;q++){const Z=this.#l.get(w[q]);Z.key=null,Z.computed=!1}this.#H=null}apply(S){const I=[],q={added:[],updated:[],removed:[],rejected:I};if(!S)return q;let Z=!1;const _=new Set;if(S.remove&&S.remove.length)for(const J of S.remove){const ee=this.#D(J);if(ee===void 0){I.push({operation:"remove",id:this.#q(J),reason:"unknown-id"});continue}q.removed.push(this.#i.keyOf(this.#r?this.#$e(ee):this.#n[ee],ee)),this.#r||(this.#n[ee]=void 0),this.#h.delete(ee),this.#N.delete(ee),Z=!0}if(S.update&&S.update.length){const J=this.#k.size||this.#Te()?this.#st():null,ee=this.#j.size?this.#nt():null,te=ee&&ee.length?this.#st():null;for(const ne of S.update){const ae=this.#D(ne);if(ae===void 0){I.push({operation:"update",id:this.#te(ne),reason:"unknown-id"});continue}const de=this.#r?this.#o&&this.#o.has(ae)?this.#o.get(ae):this.#$e(ae):this.#n[ae],ie=H(de,ne);for(const oe of this.#Pe(de,ie))_.add(oe);if(this.#r||(this.#n[ae]=ie),J&&this.#Pt(J,ae,de,ie),te&&this.#Ge(ee,te,ae,de,ie),this.#p){const oe=this.#i.keyOf(de,ae),ce=this.#i.keyOf(ie,ae);oe!==ce&&(this.#p.delete(oe),this.#p.set(ce,ae))}this.#h.delete(ae),this.#N.delete(ae),q.updated.push(this.#Ne(ae))}}if(S.add&&S.add.length&&this.#r){typeof S.at=="number"&&S.at<this.#et()&&(this.#h.clear(),this.#N.clear()),this.#p=null;for(const J of S.add){const ee=this.#K(this.#te(J));ee!==void 0&&q.added.push(this.#Ne(ee))}Z=!0}else if(S.add&&S.add.length){const J=typeof S.at=="number"?S.at:this.#n.length,ee=this.#n.length;let te=S.add===this.#n?S.add.slice():S.add;if(this.#i.keyed){const ne=[];for(const ae of te){const de=this.#te(ae);if(this.#D(de)!==void 0){I.push({operation:"add",id:de,reason:"duplicate-id"});continue}ne.push(ae)}ne.length!==te.length&&(te=ne)}if(!te.length)return q;if(J>=ee)for(let ne=0;ne<te.length;ne++)this.#n.push(te[ne]);else this.#n.splice(J,0,...te),this.#h.clear(),this.#N.clear();for(let ne=0;ne<te.length;ne++)q.added.push(this.#Ne(J>=ee?ee+ne:J+ne));Z=!0}return this.#u++,Z&&(this.#p=null,this.#ye()),this.#s.invalidate(),this.#H=null,Z||this.#me(_)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#qe("rows:changed",{companion:!0,added:q.added.length,updated:q.updated.length,removed:q.removed.length}),this.#o=null,q}groupHeadingsAt(S){this.#X();const I=this.#ie;if(!I.length||!Number.isInteger(S)||S<0)return b;let q=0,Z=I.length-1,_=-1;for(;q<=Z;){const ee=q+Z>>1;I[ee].at<=S?(_=ee,q=ee+1):Z=ee-1}if(_<0)return b;const J=[];for(let ee=I[_].row;ee;ee=ee.parent)J.push(ee);return J.reverse(),J}unnumberedRowCount(S){this.#X();const I=this.#re;if(!I.length||!Number.isInteger(S)||S<0)return 0;let q=0,Z=I.length-1,_=-1;for(;q<=Z;){const J=q+Z>>1;I[J].at<=S?(_=J,q=J+1):Z=J-1}return _+1}moveRow(S,I){if(this.#r)return B("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const q=this.#n;if(!Number.isInteger(S)||!Number.isInteger(I)||S<0||S>=q.length)return!1;const Z=Math.max(0,Math.min(q.length-1,I));if(Z===S)return!1;const[_]=q.splice(S,1);return q.splice(Z,0,_),this.#u++,this.#c++,this.#p=null,this.#h.clear(),this.#N.clear(),this.#ye(),this.#s.invalidate(),this.#H=null,this.invalidate("filter"),this.#qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(S){this.#he(),this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#ye(),this.#s.invalidate(),this.invalidate("filter"),this.#qe("model:changed",{reason:"reload"})}destroy(){this.#he(),this.#h.clear(),this.#N.clear(),this.#p=null,this.#B=[],this.#W=null,this.#H=null,this.#ye();for(const S of w)this.#l.set(S,{key:null,result:null,id:0,computed:!1})}#he(){for(const{controller:S}of this.#y.values())try{S.abort()}catch{}this.#y.clear()}setRows(S){this.#n=S||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#ye(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(S){this.#o=S||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#N.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const S=this.#e.store;if(!S||!W(S.source))return this.#n;const I=S.physical||0,q=new Array(I);for(let Z=0;Z<I;Z++)q[Z]=S.live&&!S.live(Z)?void 0:S.source(Z);return q}#we(){const S=this.#V("detail",null);return!S||!W(S.isOpen)||S.inline===!1?null:S}#pe(){const S=(this.#e.config||{}).tree;return this.#$!==S&&(this.#$=S,this.#z=l(S,{dataAt:I=>this.#$e(I),keyOf:I=>this.#i.keyOf(this.#$e(I),I)})),this.#z}#be(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#be())return null;this.#X();const S=this.#m.grand;return S?this.#i.grandTotal(S,this.#C(this.#m.grandLeaves)):null}pivot(){return this.#X(),this.#le}pivotMatrix(){this.#X();const S=this.#m.groupLeaves,I=(this.#e.compute||{}).pivotMatrix;if(!W(I))return null;const q=this.#V("groupBy",[]),Z=this.#V("pivotBy",[]);if(!q.length&&!Z.length)return null;const _=this.#st().map(ee=>({colId:ee.id,handle:this.#s.handle(ee.id),fn:E(ee,"group")})).filter(ee=>ee.handle&&ee.fn),J=this.#e.config||{};return I({rowHandles:q.map(ee=>this.#s.handle(ee)).filter(Boolean),columnHandles:Z.map(ee=>this.#s.handle(ee)).filter(Boolean),measures:_,leaves:S||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(S){const I=[];if(!S)return I;for(let q=0;q<S.length;q++){const Z=this.#Ne(S[q]);Z&&Z.key!=null&&I.push(String(Z.key))}return I}leavesOf(S){this.#X();const I=this.#l.get("group"),q=I&&I.result;if(!q||!q.nodes)return[];const Z=q.nodes.get(S);if(!Z)return[];const _=[],J=ee=>{const te=ee.row&&ee.row.children;if(te&&te.length){for(const ne of te){const ae=q.nodes.get(ne.key);ae&&J(ae)}return}if(ee.leaves)for(let ne=0;ne<ee.leaves.length;ne++)_.push(this.#Ne(ee.leaves[ne]))};return J(Z),_}#q(S){return typeof S=="string"?S:this.#te(S)}#te(S){try{return this.#i.keyOf(S,-1)}catch{return"(unkeyed)"}}#D(S){if(typeof S=="string")return this.#K(S);if(this.#i.keyed){const q=this.#i.keyOf(S,-1),Z=this.#K(q);if(Z!==void 0)return Z}if(this.#r)return;const I=this.#n.indexOf(S);return I>=0?I:void 0}#K(S){return this.#p||this.#_(),this.#p.get(S)}#_(){this.#p=new Map;const S=this.#et(),I=this.#e.store,q=I&&W(I.live)?Z=>I.live(Z):null;for(let Z=0;Z<S;Z++){if(q&&!q(Z))continue;const _=this.#$e(Z);_!==void 0&&this.#p.set(this.#i.keyOf(_,Z),Z)}}#Pe(S,I){const q=[];for(const Z of this.#oe())this.#Ue(Z)&&this.#ne(Z,S,I,new Set)&&q.push(Z);return q}#ne(S,I,q,Z){if(Z.has(S))return!1;Z.add(S);const _=this.#Ue(S);if(!_)return!1;const J=_.value&&_.value.deps;return Array.isArray(J)&&J.length?J.some(ee=>this.#ne(String(ee),I,q,Z)):W(_.getValue)?!Object.is(_.getValue(I),_.getValue(q)):!1}#oe(){const S=new Set;for(const q of this.#V("sort",[]))S.add(q.col);for(const q of this.#V("groupBy",[]))S.add(q);const I=q=>{if(q){if(Array.isArray(q.conditions)){q.conditions.forEach(I);return}q.col&&S.add(q.col)}};return I(this.#V("filters",null)),[...S]}#me(S){if(!S.size)return!1;if(this.#V("quick",""))return!0;for(const I of this.#oe())if(S.has(I))return!0;return!1}#X(){if(!this.#a){this.#a=!0;try{this.#ke()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#ke(){const S=this.#Z("filter",()=>this.#de(),()=>this.#je()),I=this.#ce(S),q=this.#Z("group",()=>this.#Ie(),()=>this.#dt(I)),Z=this.#Z("total",()=>this.#We(),()=>this.#tt(q));this.#Z("pivot",()=>this.#Ve(),()=>this.#vt(q)),this.#Z("flatten",()=>this.#Ee(),()=>this.#Ct(q)),this.#Le(q,Z)}#ce(S){const I=this.#l.get("sort"),q=this.#v();if(I.computed&&I.key===q&&!this.#y.has("sort"))return I.result;const Z=this.#y.get("sort");return Z&&Z.key===q?I.result:I.result&&this.#G(S)?(this.#T(S,q),I.result):this.#Z("sort",()=>q,()=>this.#De(S))}#se(){if(this.#w===null){const S=this.#e.pipelineWorker,I=W(S)?S():null;this.#w=I||!1}return this.#w||null}#Ce(){const S=this.#V("sort",[]);if(!Array.isArray(S)||!S.length)return null;const I=(this.#e.config||{}).locale,q=[],Z=[];for(const _ of S){const J=this.#Ue(_.col);if(J&&J.running)continue;if(J&&J.value&&W(J.value.compare))return null;const ee=this.#s.handle(_.col);if(!ee)return null;q.push({col:_.col,descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,locale:I}),Z.push(ee)}return q.length?{entries:q,handles:Z,locale:I}:null}#G(S){if(this.#fe())return!1;const I=this.#se();if(!I)return!1;const q=Number(I.threshold);return Number.isFinite(q)&&S.length<q?!1:!!this.#Ce()}#T(S,I){const q=this.#se(),Z=q&&this.#Ce();if(!Z){this.#Z("sort",()=>I,()=>this.#De(S));return}const _=new AbortController;this.#y.set("sort",{key:I,controller:_});const J=Z.entries.length===1?q.sortColumn(Z.handles[0],S,{descending:Z.entries[0].descending,nullsFirst:Z.entries[0].nullsFirst,locale:Z.locale,signal:_.signal,key:"sort"}):q.sortMulti(Z.handles,Z.entries.map((ee,te)=>({...ee,handle:Z.handles[te]})),S,{signal:_.signal,key:"sort"});if(!C(J)){this.#y.delete("sort"),this.#Z("sort",()=>I,()=>J);return}J.then(ee=>this.#U(I,ee),ee=>this.#ae("sort",I,ee))}#U(S,I){const q=this.#y.get("sort");if(!(!q||q.key!==S)){if(this.#v()!==S){this.#y.delete("sort");return}this.#y.delete("sort"),this.#Z("sort",()=>S,()=>I),this.#H=null,this.#X(),this.#qe("model:changed",{reason:k[0]})}}#ae(S,I,q){const Z=this.#y.get(S);if(!(!Z||Z.key!==I)&&(this.#y.delete(S),!(q&&q.name==="AbortError")&&S==="sort"&&this.#v()===I)){const _=this.#Z("filter",()=>this.#de(),()=>this.#je());this.#Z("sort",()=>I,()=>this.#De(_)),this.#H=null,this.#X(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",q),this.#qe("model:changed",{reason:k[1]})}}#Le(S,I){const q=S&&S.leaves?S.leaves.length:this.#m.slots.length;this.#m.matchCount=q,this.#m.grand=I&&I.grand||null,this.#m.grandLeaves=S&&S.leaves?S.leaves.length:0,this.#m.groupLeaves=S&&S.leaves?S.leaves:null}#Z(S,I,q){const Z=this.#l.get(S),_=I();return Z.computed&&Z.key===_||(Z.result=q(),Z.key=_,Z.computed=!0,Z.id++,S==="flatten"&&(this.#H=null)),Z.result}#Y(S){return this.#l.get(S).id}#de(){const S=(this.#e.config||{}).hostFilter,I=S&&W(S.active)&&S.active()?1:0,q=this.#V("where",null),Z=q?q.version:0,_=this.#lt("filter.sig",`${this.#kt()}`,()=>c({filters:this.#V("filters",null),quick:this.#V("quick",""),quickMode:this.#V("quickMode","contains")}));return`${this.#c}|${_}|${I}|${Z}`}#v(){const S=this.#fe();return`${this.#Y("filter")}|${JSON.stringify(this.#V("sort",[]))}`+(S?`|manual:${S.version}`:"")}#fe(){const S=this.#V("rowOrder",null);return S&&Array.isArray(S.keys)?S:null}#Oe(S,I){this.#p||this.#_();const q=this.#p,Z=this.#et(),_=I.keys.length,J=new Float64Array(Z);for(let ee=0;ee<Z;ee++)J[ee]=_+ee;for(let ee=0;ee<_;ee++){const te=q.get(I.keys[ee]);te!==void 0&&(J[te]=ee)}return Uint32Array.from(S).sort((ee,te)=>J[ee]-J[te])}orderedKeys(){this.#p||this.#_();const S=this.#p,I=new Map;for(const[ee,te]of S)I.set(te,ee);const q=Uint32Array.from([...I.keys()]).sort(),Z=this.#fe(),_=Z?this.#Oe(q,Z):this.#De(q),J=new Array(_.length);for(let ee=0;ee<_.length;ee++)J[ee]=I.get(_[ee]);return J}#Ie(){return`${this.#Y("sort")}|${JSON.stringify(this.#V("groupBy",[]))}`}#We(){const S=this.#Je()?"f":"a",I=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#Y("group")}|${JSON.stringify(this.#V("totals",[]))}|${S}${I}|${this.#u}`}#Ve(){return`${this.#Y("group")}|${JSON.stringify(this.#V("pivotBy",[]))}`}#Ee(){const I=this.#Xe()||!this.#be()?this.#Y("total"):"x",q=`${this.#kt()}`,Z=this.#lt("flatten.keys",q,()=>{const J=this.#V("expanded",null);return J?[...J].sort().join(""):"*"}),_=this.#lt("flatten.detail",q,()=>{const J=this.#V("detail",null);return J&&W(J.signature)?J.signature():""});return`${I}|${this.#Y("pivot")}|${Z}|${_}`}#Xe(){const S=this.#V("groupBy",[]);return Array.isArray(S)&&S.length>0}stageState(){const S=[];for(const[I,q]of this.#l){const Z=q.result;S.push({stage:I,materialised:!!q.computed,bytes:Z&&typeof Z.byteLength=="number"?Z.byteLength:null,rows:Z&&typeof Z.length=="number"?Z.length:null,rebuilds:q.id})}return S}facetIndices(S){return this.#je(S||null)}facetRows(S){const I=this.facetIndices(S),q=[];for(let Z=0;Z<I.length;Z++){const _=this.#Ne(I[Z]);_&&q.push(_)}return q}invalidateRows(){this.#h.clear(),this.#N.clear(),this.#H=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Me()}filteredIndices(){const S=this.#l.get("filter");if(S&&S.computed&&S.key===this.#de())return S.result||this.#Me();this.#X();const I=this.#l.get("filter");return(I&&I.computed?I.result:null)||this.#Me()}unfilteredRows(){const S=this.#Me(),I=[];for(let q=0;q<S.length;q++){const Z=this.#Ne(S[q]);Z&&I.push(Z)}return I}#je(S=null){const I=this.#Me(),q=this.#V("filters",null),Z=S?this.#Ke("pruneColumn")(q,S):q,_=this.#Et(Z),J=String(this.#V("quick","")||"").trim().toLowerCase(),ee=J?z(J,String(this.#V("quickMode","contains")||"contains")):null,te=(this.#e.config||{}).hostFilter,ne=!!(te&&W(te.active)&&te.active()),ae=this.#V("where",null),de=!!(ae&&ae.active);if(!_&&!J&&!ne&&!de)return I;let ie=null;_&&(ie=this.#Ke("evaluateFilters")(_,{handle:ke=>this.#s.handle(ke),count:this.#et(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:ke=>x(this.#Ue(ke))}));const oe=new Uint32Array(I.length);let ce=0;for(let fe=0;fe<I.length;fe++){const ke=I[fe];if(!(ie&&!ie[ke])&&!(ee&&!this.#ht(ke,ee))){if(ne||de){const Re=this.#Ne(ke);if(ne&&!te.passes(Re)||de&&!ae.passes(Re.data,Re.key))continue}oe[ce++]=ke}}if(ie){const fe=(this.#e.compute||{}).releaseMask;W(fe)&&fe({pool:this.#e.pool},ie)}return oe.subarray(0,ce)}handleFor(S){return this.#s.handle(S)}#De(S){const I=this.#fe();if(I)return this.#Oe(S,I);const q=this.#V("sort",[]).filter(J=>{const ee=this.#Ue(J.col);return!ee||!ee.running?!0:(B(`source.sort.running.${J.col}`,`sort ignores "${J.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!q.length)return S;const Z=(this.#e.config||{}).locale;if(q.length===1){const J=q[0],ee=this.#s.handle(J.col);if(!ee)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),S;const te=this.#Ue(J.col);return this.#Ke("sortColumn")(ee,S,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:Z,compare:P(te)})}const _=[];for(const J of q){const ee=this.#s.handle(J.col);if(!ee){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}_.push({handle:ee,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:Z,compare:P(this.#Ue(J.col))})}return _.length?this.#Ke("sortMulti")(_.map(J=>J.handle),_,S):S}#dt(S){const I=this.#V("groupBy",[]),q=this.#pe();if(q&&!I.length){const fe=h(S,q);return this.#x=m(fe.roots,q.declaresChildren),{roots:null,leaves:S,nodes:new Map,tree:fe}}if(this.#x=null,q&&I.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!I.length)return{roots:null,leaves:S,nodes:new Map};const Z=(this.#e.config||{}).timeZone,_=[],J=[];let ee=!1;for(const fe of I){const ke=this.#s.handle(fe);if(!ke){B(`source.group.${fe}`,`grouping ignores unknown column "${fe}".`);continue}_.push(ke);const Re=this.#Ue(fe),Ee=Re&&Re.dataType;if(Ee&&W(Ee.groupProjector)){const Fe=Re.typeOptions&&Re.typeOptions.timeZone||Re.timeZone||Z||void 0,ye=Ee.groupProjector(Re,Fe);J.push(ye||null),ye&&(ee=!0)}else J.push(null)}if(!_.length)return{roots:null,leaves:S,nodes:new Map};const{keys:te,buckets:ne}=this.#Ke("groupByColumns")(_,S,{locale:(this.#e.config||{}).locale,project:ee?J:void 0}),ae=this.#V("pivotBy",[]).length>0,de=[],ie=new Map;for(let fe=0;fe<ne.length;fe++){const ke=te[fe];let Re=null;const Ee=[];for(let Fe=0;Fe<ke.length;Fe++){Ee.push(v(ke[Fe]));const ye=D(Ee),he=Fe===ke.length-1;let Se=ie.get(ye);if(!Se){const Ce=this.#i.group({path:[...Ee],column:I[Fe],value:ke[Fe],level:Fe,parent:Re,expanded:ae&&he?!1:this.#pt(ye,{key:ye,column:I[Fe],value:ke[Fe],level:Fe,path:[...Ee]}),hasChildren:!(ae&&he)});Se={row:Ce,leaves:null},ie.set(ye,Se),Re?Re.children.push(Ce):de.push(Ce)}Se.row.leafCount+=ne[fe].length,Fe===ke.length-1&&(Se.leaves=ne[fe]),Re=Se.row}}const oe=this.#V("sort",[])||[],ce=(fe,ke)=>{if(!fe||fe.length<2){if(fe)for(const ye of fe)ce(ye.children,ke+1);return}const Re=I[ke],Ee=oe.find(ye=>ye.col===Re),Fe=Ee&&Ee.dir==="desc"?-1:1;fe.sort((ye,he)=>Fe*X(ye.groupValue,he.groupValue));for(const ye of fe)ce(ye.children,ke+1)};return ce(de,0),{roots:de,leaves:S,nodes:ie,keys:te,buckets:ne}}#_e(S,I){const q=new Map,Z=new Map,_=J=>{const ee=J.physical>=0?[J.physical]:[];for(const te of J.children)ee.push(..._(te));if(J.children.length){const te=this.#at(I,Uint32Array.from(ee),null);J.physical>=0?q.set(J.physical,te):Z.set(J.key,te)}return ee};for(const J of S.roots)_(J);return{byPhysical:q,byKey:Z}}#tt(S){const I=this.#st();if(!I.length)return this.#A=null,this.#E=null,{grand:null};const q={id:this.#Y("group"),columns:I.map(oe=>oe.id).join("")},Z=this.#A&&this.#A.id===q.id&&this.#A.columns===q.columns,_=this.#Te()&&Z?this.#M:null,J=_?I.filter(oe=>_.has(oe.id)):I,ee=Z?this.#E:null,te=this.#Je()?null:this.#ze(),ne=this.#ge(I),ae=oe=>{const ce=S.nodes.get(oe.key);let fe=ce&&ce.leaves?ce.leaves:null;if(oe.children&&oe.children.length){const Ee=oe.children.map(ae);let Fe=0;for(const Se of Ee)Fe+=Se.length;const ye=new Uint32Array(Fe);let he=0;for(const Se of Ee)ye.set(Se,he),he+=Se.length;fe=ye}fe=fe||new Uint32Array(0);const ke=te?te.get(oe.key)||A:fe,Re=this.#ft(oe,_?J:I,ke,ne);return oe.totals=_?{...oe.totals,...Re}:Re,fe};if(S.roots&&J.length)for(const oe of S.roots)ae(oe);if(this.#I=S.tree?this.#_e(S.tree,I):null,this.#A=q,this.#M=this.#Te()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#E=null,{grand:null};const ie=te?this.#rt():S.leaves;return this.#E=this.#Q(I,ie,_,ee),{grand:this.#E}}#Q(S,I,q,Z){const _={},J=this.#Y("group");J!==this.#b&&(this.#xe(),this.#b=J);const ee=this.#O;this.#O=[];for(const te of S){if(!T(te))continue;const ne=this.#s.handle(te.id);if(!ne)continue;const ae=E(te,"grand");if(!t(ae,ne)){if(q&&!q.has(te.id)&&Z&&te.id in Z){_[te.id]=Z[te.id];continue}_[te.id]=this.#at([te],I,null,"grand")[te.id];continue}let de=this.#k.get(te.id);if((!de||de.fn!==ae)&&(de=new n(ae),this.#k.set(te.id,de)),de.valid){let ie=!0;for(const oe of ee)if(oe.colId===te.id&&!de.update(oe.before,oe.after)){ie=!1;break}if(ie){_[te.id]=de.value();continue}de.invalidate()}de.seedColumn(ne.values,o(ne),I),_[te.id]=de.valid?de.value():this.#at([te],I,null,"grand")[te.id]}return _}#ge(S){const I=this.#Y("group");I!==this.#P&&(this.#j.clear(),this.#P=I);const q=new Map;for(const _ of S){if(!T(_))continue;const J=this.#s.handle(_.id),ee=E(_,"group");t(ee,J)&&q.set(_.id,{fn:ee})}if(!q.size)return this.#S.length=0,q;const Z=this.#S;this.#S=[];for(const _ of Z){const{beforeKeys:J,afterKeys:ee,colDeltas:te}=_,ne=J.length?new Set(J):null,ae=ee.length?new Set(ee):null;for(const{colId:de,before:ie,after:oe}of te)if(q.has(de)){for(const ce of J)ae&&ae.has(ce)||this.#Ae(ce,de,ie,null);for(const ce of ee)ne&&ne.has(ce)||this.#Ae(ce,de,null,oe);for(const ce of J)ae&&!ae.has(ce)||this.#Ae(ce,de,ie,oe)}}return q}#Ae(S,I,q,Z){const _=this.#j.get(S),J=_&&_.get(I);!J||!J.valid||J.update(q,Z)||J.invalidate()}#ft(S,I,q,Z){if(!Z||!Z.size)return this.#at(I,q,S);const _={};let J=null,ee=this.#j.get(S.key);for(const te of I){const ne=Z.get(te.id);if(!ne){(J||(J=[])).push(te);continue}const ae=this.#s.handle(te.id);if(!ae)continue;ee||(ee=new Map,this.#j.set(S.key,ee));let de=ee.get(te.id);if((!de||de.fn!==ne.fn)&&(de=new n(ne.fn),ee.set(te.id,de)),de.valid||de.seedColumn(ae.values,o(ae),q),de.valid){_[te.id]=de.value();continue}(J||(J=[])).push(te)}return J&&Object.assign(_,this.#at(J,q,S)),_}#Pt(S,I,q,Z){const _=!this.#Je()||this.#wt(I);for(const J of S){const ee=J.getValue;if(!W(ee))continue;const te=ee(q),ne=ee(Z);Object.is(te,ne)||(this.#M&&this.#M.add(J.id),_&&this.#k.has(J.id)&&this.#O.push({colId:J.id,before:te,after:ne}))}}#nt(){const S=this.#V("groupBy",[]),I=[];for(const q of S){const Z=this.#Ue(q);Z&&I.push(Z)}return I}#Qe(S,I){const q=new Array(S.length);for(let Z=0;Z<S.length;Z++){const _=S[Z].getValue;q[Z]=v(W(_)?_(I):void 0)}return q}#Ge(S,I,q,Z,_){if(this.#Je()&&!this.#wt(q))return;const J=O(this.#Qe(S,Z)),ee=O(this.#Qe(S,_)),te=J.length!==ee.length||J.some((ae,de)=>ae!==ee[de]),ne=[];for(const ae of I){const de=ae.getValue;if(!W(de))continue;const ie=de(Z),oe=de(_);!te&&Object.is(ie,oe)||ne.push({colId:ae.id,before:ie,after:oe})}!ne.length&&!te||this.#S.push({beforeKeys:J,afterKeys:ee,colDeltas:ne})}#wt(S){const I=this.#l.get("filter"),q=I&&I.computed?I.result:null;if(!q)return!0;let Z=0,_=q.length-1;for(;Z<=_;){const J=Z+_>>1,ee=q[J];if(ee===S)return!0;ee<S?Z=J+1:_=J-1}return!1}#Je(){return(this.#e.config||{}).totalFilteredOnly!==!1}#C(S){return this.#Je()?S:this.#rt().length}#rt(){return(!this.#R||this.#R.version!==this.#c)&&(this.#R={version:this.#c,indices:this.#Me()}),this.#R.indices}#ze(){const S=this.#V("groupBy",[]),I=`${this.#c}|${JSON.stringify(S)}`;if(this.#L&&this.#L.key===I)return this.#L.map;const q=new Map,Z=[];for(const _ of S){const J=this.#s.handle(_);J&&Z.push(J)}if(Z.length){const _=this.#rt(),{keys:J,buckets:ee}=this.#Ke("groupByColumns")(Z,_,{locale:(this.#e.config||{}).locale}),te=new Map;for(let ne=0;ne<ee.length;ne++){const ae=J[ne],de=[];for(let ie=0;ie<ae.length;ie++){de.push(v(ae[ie]));const oe=D(de);let ce=te.get(oe);ce||(ce=[],te.set(oe,ce));for(let fe=0;fe<ee[ne].length;fe++)ce.push(ee[ne][fe])}}for(const[ne,ae]of te)q.set(ne,Uint32Array.from(ae))}return this.#L={key:I,map:q},q}#Te(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#ye(){this.#xe(),this.#it(),this.#M=null,this.#A=null,this.#E=null}#xe(){this.#k.clear(),this.#O.length=0,this.#b=-1}#it(){this.#j.clear(),this.#S.length=0,this.#P=-1}#vt(S){const I=this.#V("pivotBy",[]);if(!I.length)return this.#le=null,null;const q=(this.#e.compute||{}).pivot;if(!W(q))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#le=null,null;const Z=I.map(J=>this.#s.handle(J)).filter(Boolean),_=this.#st();return this.#le=q(Z,S.leaves,{groups:S.keys&&S.buckets?{keys:S.keys,buckets:S.buckets}:null,totals:_.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>E(_.find(ee=>ee.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#le}#Ct(S){const I=this.#l.get("total").result,q=!!(this.#e.config||{}).groupFooter,Z=this.#we();if(S.tree)return this.#ot(S,I,Z);if(!S.roots&&!Z){if(I&&I.grand&&!this.#be()){const ae=this.#i.grandTotal(I.grand,this.#C(S.leaves.length));if(this.#W===S.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=ae;else{const de=Array.from(S.leaves);de.push(ae),this.#B=de,this.#W=S.leaves}this.#re=[{at:this.#B.length-1}]}else this.#W=null,this.#B=S.leaves,this.#re=b;return this.#ie=b,this.#B}const _=[],J=[],ee=[],te=ae=>{if(_.push(ae),!Z)return;const de=this.#Ne(ae);!de||!Z.isOpen(de.key)||(de.master=!0,de.expanded=!0,ee.push({at:_.length}),_.push(this.#i.detail(de,Z.heightOf(de))))};if(!S.roots){for(let ae=0;ae<S.leaves.length;ae++)te(S.leaves[ae]);return I&&I.grand&&!this.#be()&&(ee.push({at:_.length}),_.push(this.#i.grandTotal(I.grand,this.#C(S.leaves.length)))),this.#W=null,this.#ie=b,this.#re=ee.length?ee:b,this.#B=_,_}const ne=(ae,de,ie)=>{if(ae.expanded=ae.hasChildren===!1?!1:this.#pt(ae.key,{key:ae.key,column:ae.groupColumn,value:ae.groupValue,level:ae.level,path:ae.groupPath}),ae.posinset=de+1,ae.setsize=ie,J.push({at:_.length,row:ae}),ee.push({at:_.length}),_.push(ae),!!ae.expanded){if(ae.children&&ae.children.length)for(let oe=0;oe<ae.children.length;oe++)ne(ae.children[oe],oe,ae.children.length);else{const oe=S.nodes.get(ae.key),ce=oe&&oe.leaves?oe.leaves:null;if(ce)for(let fe=0;fe<ce.length;fe++)te(ce[fe])}q&&ae.totals&&(ee.push({at:_.length}),_.push(this.#i.footer(ae)))}};for(let ae=0;ae<S.roots.length;ae++)ne(S.roots[ae],ae,S.roots.length);return I&&I.grand&&!this.#be()&&(ee.push({at:_.length}),_.push(this.#i.grandTotal(I.grand,this.#C(S.leaves.length)))),this.#ie=J,this.#re=ee,this.#B=_,_}#Me(){const S=this.#e.store;if(S&&W(S.liveIndices))return S.liveIndices();const I=new Uint32Array(this.#n.length);let q=0;for(let Z=0;Z<this.#n.length;Z++)this.#n[Z]!==void 0&&(I[q++]=Z);return I.subarray(0,q)}#et(){const S=this.#e.store;return S&&typeof S.physical=="number"?S.physical:this.#n.length}#$e(S){const I=this.#e.store;return I&&W(I.source)?I.source(S):this.#n[S]}#He(S,I=S){const q=this.#B[S];if(typeof q!="number")return q.index=I,q;const Z=this.#Ne(q);return Z.index=I,Z}#Ne(S){let I=this.#h.get(S);I||(I=this.#i.leaf(this.#$e(S),S),this.#h.set(S,I));const q=this.#x?this.#x.get(S):null;if(q){I.level=q.level,I.posinset=q.posinset,I.setsize=q.setsize,I.hasChildren=q.hasChildren,I.expanded=q.hasChildren&&!q.lazy&&this.#pt(I.key);const Z=this.#I?this.#I.byPhysical.get(S):void 0;Z?I.totals=Z:I.totals&&(I.totals=null)}else I.hasChildren&&(I.level=0,I.hasChildren=!1,I.expanded=!1,I.posinset=void 0,I.setsize=void 0);return I}#ot(S,I,q){const Z=[],_=[],J=te=>{if(te.leafCount!==void 0)return te.leafCount;let ne=te.physical>=0?1:0;for(const ae of te.children)ne+=J(ae);return te.leafCount=ne,ne},ee=te=>{const ne=this.#pt(te.key);if(te.physical>=0){if(Z.push(te.physical),q&&q.isOpen(this.#Ne(te.physical).key)){const ae=this.#Ne(te.physical);_.push({at:Z.length}),Z.push(this.#i.detail(ae,q.heightOf(ae)))}}else Z.push(this.#i.group({path:[te.key],column:null,value:te.value,level:te.level,parent:null,expanded:ne,hasChildren:te.children.length>0,leafCount:J(te),totals:this.#I?this.#I.byKey.get(te.key):void 0}));if(ne)for(const ae of te.children)ee(ae)};for(const te of S.tree.roots)ee(te);return I&&I.grand&&!this.#be()&&(_.push({at:Z.length}),Z.push(this.#i.grandTotal(I.grand,this.#C(S.leaves.length)))),this.#W=null,this.#ie=b,this.#re=_.length?_:b,this.#B=Z,Z}#xt(){return y(()=>this.count(),S=>this.at(S))}#ht(S,I){let q=this.#N.get(S);if(q===void 0){const Z=this.#$e(S),_=this.#ut(),J=[],ee=this.#e.columnHidden;for(const te of _){if(te.quickFilter===!1||W(ee)&&ee(te.id))continue;const ne=te.value&&W(te.value.quickFilterText)?te.value.quickFilterText({value:void 0,data:Z,row:null,column:te,colId:te.id,grid:null,context:this.#V("context",null)}):null,ae=ne??(W(te.formatValue)?te.formatValue(W(te.getValue)?te.getValue(Z):void 0):"");ae!=null&&ae!==""&&J.push(String(ae))}q=J.join(" ").toLowerCase(),this.#N.set(S,q)}return I(q)}#st(){const S=this.#V("totals",[]),I=S&&S.length?new Set(S):null;return this.#ut().filter(q=>I?I.has(q.id):!!(q.total||q.groupTotal||q.grandTotal))}#at(S,I,q,Z="group"){const _={},J=(this.#e.compute||{}).total;for(const ee of S){if(!T(ee))continue;const te=this.#s.handle(ee.id);if(!te)continue;const ne=E(ee,Z);if(ne)if(W(ne)){const ae=new Array(I.length);for(let de=0;de<I.length;de++)ae[de]=te.get(I[de]);_[ee.id]=ne(ae,{row:q,column:ee,grid:this.#e.grid||null,context:this.#V("context",null),valueAt:(de,ie)=>{const oe=this.#s.handle(de);return oe&&ie>=0&&ie<I.length?oe.get(I[ie]):null}})}else W(J)&&(_[ee.id]=J(te,I,ne))}return _}#Et(S){if(!S)return S;const I=this.#e.config||{},q={tz:I.timeZone,weekStartsOn:I.weekStartsOn};return i(S,Z=>{const _=g(Z,q);if(_&&_.type)return _;const J=this.#Ue(_&&_.col),ee=J&&(J.dataType?.base||J.type);return ee?{..._,type:ee}:_})}#pt(S,I){const q=this.#V("expanded",null);return q?W(q.has)?q.has(S,I):Array.prototype.includes.call(q,S):!0}#V(S,I){if(S==="context"||!W(this.#e.stateVersion))return this.#mt(S,I);const q=this.#Be(S),Z=this.#d.get(S);if(Z&&Z.version===q)return Z.value;const _=this.#mt(S,I);return this.#d.set(S,{version:q,value:_}),_}#mt(S,I){const q=this.#e.state;if(q&&W(q[S])){const Z=q[S]();return Z??I}return I}#kt(){const S=this.#e.stateVersion;return W(S)?S():0}#Tt(){const S=this.#e.columnsVersion,I=this.#e.permissionsVersion;return`${W(S)?S():0}|${W(I)?I():0}`}#Be(S){return S==="totals"?this.#Tt():`${this.#kt()}`}#lt(S,I,q){if(!W(this.#e.stateVersion))return q();const Z=this.#f.get(S);if(Z&&Z.version===I)return Z.key;const _=q();return this.#f.set(S,{version:I,key:_}),_}#Ke(S){const I=(this.#e.compute||{})[S];return W(I)||F(`ctx.compute.${S} is required by the memory source pipeline`),I}#ut(){const S=this.#e.columns;return S&&W(S.all)?S.all():[]}#Ue(S){const I=this.#e.columns;return I&&W(I.get)?I.get(S):void 0}#qe(S,I){const q=this.#e.emit;W(q)&&q(S,I)}}}),xe("packages/core/src/source/abort.js",function(e,G){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class Q extends Error{constructor(H,V="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${V}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class L{#e;constructor(H,V,K,D){this.#e=H,this.key=V,this.controller=K,this.signal=K.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 Q(this.key,H)),this.#e.settle(this)}}class B{#e=new Map;#t=0;begin(H="",V="superseded"){const K=this.#e.get(H);K&&!K.signal.aborted&&K.controller.abort(new Q(H,V));const D=new L(this,H,new AbortController,++this.#t);return this.#e.set(H,D),D}tokenFor(H){return this.#e.get(H)}pending(H=""){const V=this.#e.get(H);return!!V&&!V.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",V="superseded"){const K=this.#e.get(H);K&&K.abort(V)}abortAll(H="superseded"){for(const V of[...this.#e.values()])V.abort(H);this.#e.clear()}}function F(){return new B}function W(X){if(!X||typeof X!="object")return!1;const H=X;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),xe("packages/core/src/source/blockcache.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return F}});const Q=100,L=32;class B{constructor(X){this.id=X,this.rows=null,this.state="pending",this.token=null,this.error=null}}class F{#e=new Map;#t;#n;#r=0;#o=-1;constructor(X={}){this.#t=Math.max(1,Math.floor(Number(X.pageSize)||Q)),this.#n=Math.max(1,Math.floor(Number(X.maxCachedPages)||L))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(X){return Math.floor(X/this.#t)}rangeOf(X){return{start:X*this.#t,end:(X+1)*this.#t}}has(X){return this.#e.has(X)}pending(X){const H=this.#e.get(X);return!!H&&H.state==="pending"}loaded(X){const H=this.#e.get(X);return!!H&&H.state==="loaded"}begin(X,H){let V=this.#e.get(X);return V||(V=new B(X)),V.state="pending",V.token=H,V.error=null,this.#i(X,V),V}fill(X,H){const V=this.#e.get(X)||new B(X);V.rows=H,V.state="loaded",V.token=null,this.#i(X,V)}failed(X,H){const V=this.#e.get(X)||new B(X);V.state="error",V.error=H,V.token=null,this.#i(X,V)}delete(X){return this.#e.delete(X)}rowAt(X){const H=this.blockOf(X),V=this.#e.get(H);if(!(!V||V.state!=="loaded"||!V.rows))return this.#i(H,V),V.rows[X-H*this.#t]}rowLoaded(X){const H=this.blockOf(X),V=this.#e.get(H);return!!V&&V.state==="loaded"&&!!V.rows&&X-H*this.#t<V.rows.length}erroredAt(X){const H=this.#e.get(this.blockOf(X));return!!H&&H.state==="error"}loadedExtent(){let X=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const V=H.id*this.#t+H.rows.length;V>X&&(X=V)}return X}fillOf(X){const H=this.#e.get(X);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(X,H){this.#r=this.blockOf(Math.max(0,X)),this.#o=this.blockOf(Math.max(0,H))}evict(){const X=[];if(this.#e.size<=this.#n)return X;for(const[H,V]of this.#e){if(this.#e.size-X.length<=this.#n)break;H>=this.#r&&H<=this.#o||V.state!=="pending"&&X.push(H)}for(const H of X)this.#e.delete(H);return X}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(X,H){this.#e.delete(X),this.#e.set(X,H)}}}),xe("packages/core/src/source/pagewindow.js",function(e,G){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return Q}});function Q(L,B,F,W){const X=Math.floor(Number(L)||0);if(X<=0)return null;const H=Math.max(0,Math.floor(Number(B)||0)),V=Math.max(0,Math.floor(Number(F)||0));if(W){const K=Math.max(1,Math.ceil(V/X)),D=Math.min(H,K-1),v=D*X;return{page:D,pageSize:X,offset:v,length:Math.max(0,Math.min(X,V-v)),pageCount:K,total:V}}return{page:H,pageSize:X,offset:H*X,length:X,pageCount:Math.max(H+2,Math.ceil(V/X)),total:null}}}),xe("packages/core/src/source/paged.js",function(e,G){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return i}});const Q=G("packages/core/src/internal/util.js"),L=Q.Lru,B=Q.isFunction,F=Q.warnOnce,W=Q.settleDebounce,X=G("packages/core/src/source/abort.js"),H=X.createAbortScope,V=X.isAbortError,K=G("packages/core/src/source/blockcache.js"),D=K.BlockCache,v=K.DEFAULT_PAGE_SIZE,O=K.DEFAULT_MAX_CACHED_PAGES,u=G("packages/core/src/source/rows.js").createRowFactory,a=G("packages/core/src/source/filterwire.js"),s=a.wireFilters,n=a.querySignature,t=a.warnHostFilterNotApplied,o=G("packages/core/src/source/pagewindow.js").pageWindow,f=120;function c(g,d){return new i(g,d)}class i{mode="paged";#e;#t;#n;#r=H();#o;#i;#s=new Map;#l=null;#a=!1;#u=0;#c="";#d={start:0,end:0};#f;#h=!1;#p=0;#m="";constructor(d,h){this.#e=d||{mode:"paged"},this.#t=h||{},this.#n=new D({pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||O}),this.#o=u(this.#t),this.#i=new L(this.#n.pageSize*4),this.#f=W((l,m)=>this.#k(l,m),f),this.#c=this.#S(),B(this.#e.fetch)||F("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const d=this.#y();return d?d.length:this.#g()}#g(){if(this.#j(),this.#l!==null)return this.#l;const d=Math.max(this.#u,this.#n.loadedExtent());return this.#a?d:d+this.#n.pageSize}matchCount(){return this.#g()}totalCount(){return this.#g()}pageInfo(){const d=this.#y();if(!d){const h=this.#g();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:d.page,pageSize:d.pageSize,total:d.total,pageCount:d.pageCount,counting:d.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const d=this.#g(),h=o(this.#A("pageSize",0),this.#A("page",0),d,this.exact());if(!h)return this.#m="",null;const l=`${this.#p}:${h.offset}:${h.length}`;if(l!==this.#m&&!this.#h&&(this.#m=l,h.length>0)){const m=h.offset+h.length-1;this.#d={start:h.offset,end:m},this.#k(h.offset,m)}return h}at(d){const h=this.#y();if(h){if(d<0||d>=h.length)return;const l=this.#w(h.offset+d);return l&&(l.index=d),l}return this.#w(d)}#w(d){if(d<0||d>=this.#g())return;const h=this.#i.get(d);if(h&&(h.data!==null||!this.#n.rowLoaded(d)))return h;const l=this.#n.rowAt(d);if(l===void 0){const w=this.#o.skeleton(d,0,this.#n.erroredAt(d));return this.#i.set(d,w),w}const m=this.#o.leaf(l,d);return m.index=d,this.#i.set(d,m),this.#s.set(m.key,d),m}byKey(d){const h=this.#s.get(d);return h===void 0?void 0:this.#w(h)}loaded(d){const h=this.#y();return h?d>=0&&d<h.length&&this.#n.rowLoaded(h.offset+d):this.#n.rowLoaded(d)}hint(d,h){if(this.#h)return;const l=this.#j();let m=Math.max(0,Math.floor(d)),w=Math.max(m,Math.floor(h));const k=this.#y();if(k){if(k.length===0)return;m=k.offset,w=k.offset+k.length-1}this.#d={start:m,end:w},this.#n.protect(m,w);for(const p of this.#n.evict())this.#O(p);this.#f(m,w),l&&this.#f.flush()}#k(d,h){if(this.#h)return;this.#n.protect(d,h);const l=this.#n.blockOf(d),m=this.#n.blockOf(h);for(let w=l;w<=m&&!(this.#l!==null&&w*this.#n.pageSize>=this.#l);w++)this.#n.has(w)||this.#b(w)}apply(d){const h={added:[],updated:[],removed:[]};if(!d)return h;if(d.update)for(const l of d.update){const m=this.#o.keyOf(l,-1),w=this.#s.get(m);if(w===void 0)continue;const k=this.#o.leaf(l,w);k.index=w,this.#i.set(w,k),h.updated.push(k)}return(d.add&&d.add.length||d.remove&&d.remove.length)&&this.reload(),h}reload(d){this.#P("reload"),this.#f.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#h=!0,this.#f.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#b(d){if(!B(this.#e.fetch))return;const h=this.#r.begin(`block:${d}`);this.#n.begin(d,h);const{start:l,end:m}=this.#n.rangeOf(d),w=this.#c;try{const k=await this.#e.fetch({range:{start:l,end:m},sort:this.#A("sort",[]),filters:s(this.#A("filters",null),this.#M()),quick:this.#A("quick","")||void 0,context:this.#A("context",null),signal:h.signal});if(!h.current||w!==this.#c||this.#h)return;h.settle();const p=k&&k.rows||[];this.#n.fill(d,p);for(let E=0;E<p.length;E++)this.#i.delete(l+E);const b=k&&typeof k.total=="number"?k.total:k&&typeof k.count=="number"?k.count:null;b!==null?(this.#l=b,this.#a=!0):p.length<this.#n.pageSize?(this.#a=!0,this.#l=l+p.length):this.#u=Math.max(this.#u,l+p.length),this.#E("model:changed",{reason:"page",block:d,from:l,to:l+p.length}),this.#E("rows:changed",{companion:!0,reason:"page",block:d,from:l,to:l+p.length})}catch(k){if(h.settle(),V(k))return;this.#n.failed(d,k);for(let p=l;p<m;p++)this.#i.delete(p);this.#E("model:changed",{reason:"page-error",block:d,range:{start:l,end:m}}),this.#E("source:error",{error:k,block:d,range:{start:l,end:m}})}}#O(d){const{start:h,end:l}=this.#n.rangeOf(d);for(let m=h;m<l;m++){const w=this.#i.peek(m);w&&this.#s.delete(w.key),this.#i.delete(m)}}#j(){const d=this.#S();return d===this.#c?!1:(this.#c=d,this.#P("query"),!0)}#P(d){this.#r.abortAll(d),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=!1,this.#u=0,this.#p++,this.#E("model:changed",{reason:d})}#S(){return n({filters:this.#A("filters",null),sort:this.#A("sort",[]),quick:this.#A("quick",""),context:this.#A("context",null)})}#M(){const d=this.#t.config||{};return{tz:d.timeZone,weekStartsOn:d.weekStartsOn}}#A(d,h){const l=this.#t.state;if(l&&B(l[d])){const m=l[d]();return m??h}return h}#E(d,h){const l=this.#t.emit;B(l)&&l(d,h)}}}),xe("packages/core/src/source/aggregates.js",function(e,G){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return K}});const Q=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function L(){const D=new Set;for(const[v,O]of Object.entries(Q))O.pushable&&D.add(v);return D}function B(D,v,O){let y=D.split("%c").join(v);return O!==void 0&&(y=y.split("%w").join(O)),y}function F(D){const v=D||{},O=v.default==="engine"||v.default==="engine-if-identical"?v.default:"client",y={};if(v.overrides&&typeof v.overrides=="object")for(const[u,a]of Object.entries(v.overrides))(a==="engine"||a==="client")&&(y[u]=a);return{default:O,overrides:y}}function W(D,v){const O=Q[D];if(!O||!O.pushable)return"client";const y=v.overrides[D];return y==="engine"||y==="client"?y:v.default==="client"?"client":v.default==="engine-if-identical"?O.class==="identical"?"engine":"client":"engine"}function X(D,v){const O=F(v),y=[],u=[];for(const a of D||[]){const s=Q[a.fn],n=W(a.fn,O),t={id:a.id,col:a.col,fn:a.fn,class:s?s.class:"fallback"};a.weight!==void 0&&(t.weight=a.weight),a.params!==void 0&&(t.params=a.params),n==="engine"?y.push(t):(t.reason=s&&!s.pushable?s.note||"the engine cannot express this stat":"client by config",u.push(t))}return{engine:y,client:u,config:O}}const H=/^[A-Za-z_][A-Za-z0-9_$]*$/;function V(D,v=[]){return(D||[]).every(y=>{if(typeof y=="string")return H.test(y);if(!y||typeof y!="object")return!1;const u=y;return Array.isArray(v)&&v.includes(u.bucket)&&typeof u.col=="string"&&H.test(u.col)&&typeof u.size=="number"&&Number.isFinite(u.size)&&u.size>0})}function K(){return Object.entries(Q).map(([D,v])=>({stat:D,class:v.class,sql:v.sql?B(v.sql,"col",v.twoColumn?"weight":void 0):"",note:v.note||(v.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),xe("packages/core/src/source/pushdown.js",function(e,G){"use strict";Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return R}});const Q=G("packages/core/src/internal/util.js"),L=Q.defaultCompare,B=Q.isFunction,F=Q.toArray,W=Q.warnOnce,X=G("packages/core/src/source/filterwire.js"),H=X.isGroup,V=X.warnWherePageRelative,K=X.warnWhereOverThreshold,D=G("packages/core/src/source/aggregates.js"),v=D.resolveAggregatePlan,O=D.groupKeysPushable,y=D.STAT_PUSHDOWN,a=G("packages/core/src/source/abort.js").SupersededError;function s(S){const I=S&&S.signal;if(!I||!I.aborted)return;const q=I.reason;throw q instanceof Error?q:new a("","superseded before it was sent")}const n=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function t(S){if(!S||typeof S!="object")return!1;const I=S.returning==="row"||S.returning==="key"?S.returning:"none";return{append:S.append===!0,update:S.update===!0,delete:S.delete===!0,returning:I}}function r(S,I){if(!S||typeof I!="string")return;if(!I.includes("."))return S[I];let q=S;for(const Z of I.split(".")){if(q===null||typeof q!="object")return;q=q[Z]}return q}function o(S){if(S===!0)return!0;if(!S||typeof S!="object")return!1;const I=S;return I.enabled===!1?!1:I.enabled===!0||B(I.commit)}function f(S){const I={...n,...S||{}};return I.operators=new Set(I.operators||[]),I.mutate=t(I.mutate),I}function c(S,I){return!S||!S.op||!I.operators.size?!1:I.operators.has(S.op)}function i(S,I){if(!S)return{pushed:null,residual:null};if(!I.filter)return{pushed:null,residual:S};if(I.filter==="term"){if(H(S)){const J=S.conditions||[];if(String(S.op)!=="and")return{pushed:null,residual:S};const ee=J.findIndex(ne=>!H(ne)&&c(ne,I));if(ee<0)return{pushed:null,residual:S};const te=J.filter((ne,ae)=>ae!==ee);return{pushed:J[ee],residual:te.length?{op:"and",conditions:te}:null}}return c(S,I)?{pushed:S,residual:null}:{pushed:null,residual:S}}if(!H(S))return c(S,I)?{pushed:S,residual:null}:{pushed:null,residual:S};if(String(S.op)!=="and")return(S.conditions||[]).every(ee=>H(ee)?i(ee,I).residual===null:c(ee,I))?{pushed:S,residual:null}:{pushed:null,residual:S};const q=[],Z=[];for(const J of S.conditions||[]){if(H(J)){if(I.filter==="flat"){Z.push(J);continue}const ee=i(J,I);ee.pushed&&q.push(ee.pushed),ee.residual&&Z.push(ee.residual);continue}(c(J,I)?q:Z).push(J)}const _=J=>J.length===0?null:J.length===1?J[0]:{op:"and",conditions:J};return{pushed:_(q),residual:_(Z)}}const g="__lattice_leaves";function d(S){return S.aggregates?S.aggregates instanceof Set?S.aggregates:new Set(F(S.aggregates)):new Set}function h(S){const I=d(S);return I.size?I.has("count")?S.filter!=="tree"||!S.operators||!S.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function l(S,I,q,Z,_,J,ee){const te=Array.isArray(S.groupBy)?S.groupBy:[],ne=Array.isArray(S.groupPath)?S.groupPath:[],ae=Array.isArray(S.groupValues)?S.groupValues:null;if(!I.group){const de=h(I);if(de)return de}return O(te)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Z?_?J?"a host `where` predicate can only run in the browser, over rows the engine grouped":ee?"fullDataset holds the whole matching set, so the grid groups it itself":!ae||ae.length!==ne.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const m="pushdown:pivot-unsupported",w="pushdown:group-unsupported",k=Symbol("lattice.remote.ungroupedLevel");function p(S,I,q,Z,_,J){const ee=Array.isArray(S.pivotBy)?S.pivotBy:[],te=Array.isArray(S.groupBy)?S.groupBy:[],ne=Array.isArray(S.groupPath)?S.groupPath:[],ae=Array.isArray(S.groupValues)?S.groupValues:null;return I.pivot?O(ee)?te.length&&!O(te)?"a grouping key is not a plain column the engine can name in a GROUP BY":q.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":Z?_?J?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ae||ae.length!==ne.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function b(S,I,q=!1){const Z=i(S.filters||null,I),_=[];Z.residual&&_.push("filter");const J=S.sort||[],ee=J.length===0||I.sort==="multi"&&J.length>=1||I.sort==="single"&&J.length===1;!ee&&J.length&&_.push("sort");const te=S.quick?String(S.quick):"",ne=!te||!!I.quick;ne||_.push("quick");const ae=S.where&&S.where.active?S.where:null;ae&&_.push("where");const de={filters:Z.residual,sort:ee?null:J,quick:ne?"":te,where:ae},ie=!!q,oe=Array.isArray(S.groupBy)&&S.groupBy.length>0,ce=oe?l(S,I,Z,ee,ne,ae,ie):"",fe=S.pivotMode!==!1&&Array.isArray(S.pivotBy)&&S.pivotBy.length>0,ke=fe?p(S,I,Z,ee,ne,ae):"",Re=fe&&ke==="";fe&&!Re&&_.push("pivot");const Ee=fe?Re&&oe:oe&&ce==="";oe&&!fe&&!Ee&&_.push("group");const Fe=(Ee||Re)&&Array.isArray(S.groupValues)?S.groupValues.length:0,ye=Ee||fe?!1:ie||!!(de.filters||de.sort||de.quick||de.where)||!I.range;return{pushed:{...S,filters:Z.pushed,sort:ee?J:[],quick:ne?te:"",range:ye?null:S.range},residual:de,needsAll:ye,unpushed:_,full:ie,grouped:Ee,groupLevel:Fe,groupReason:fe?"":ce,pivoted:Re,pivotReason:ke}}function E(S){const I=Array.isArray(S.totals)?S.totals:[],q=S.totalFns&&typeof S.totalFns=="object"?S.totalFns:{},Z=[],_=[];for(const J of I){const ee=String(J),te=typeof q[ee]=="string"?q[ee]:null,ne=te?y[te]:null;te?!ne||!ne.pushable||!ne.sql?_.push({id:ee,fn:te,class:ne?ne.class:"fallback",reason:ne&&ne.note?ne.note:`the pushdown map cannot express "${te}"`}):ne.twoColumn?_.push({id:ee,fn:te,class:ne.class,reason:`"${te}" reduces two columns, and a grouped request carries no weight column`}):Z.push({id:ee,col:ee,fn:te,class:ne.class}):_.push({id:ee,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Z,client:_}}const T=Object.freeze({items:S=>S==null?[]:Array.isArray(S)?S:[S]});function P(S,I,q){if(!I)return S;let Z=S;if(I.filters&&B(q.evaluateFilters)){const _=Z,J={count:Z.length,handle:ne=>({id:ne,get:ae=>r(_[ae],ne)}),itemwise:ne=>_.some(ae=>Array.isArray(r(ae,ne)))?T:null},ee=q.evaluateFilters(I.filters,J),te=[];for(let ne=0;ne<Z.length;ne++)ee[ne]&&te.push(Z[ne]);Z=te}if(I.where&&I.where.active&&(I.whole||V(I.where.names,"pushdown"),Z=Z.filter(_=>I.where.passes(_))),I.quick){const _=I.quick.toLowerCase();Z=Z.filter(J=>{if(!J||typeof J!="object")return!1;for(const ee of Object.values(J))if(ee!=null&&String(ee).toLowerCase().includes(_))return!0;return!1})}if(I.sort&&I.sort.length&&B(q.sortMulti)){const _=[...new Set(I.sort.map(ne=>ne.col))],J=Z,ee=_.map(ne=>({id:ne,get:ae=>r(J[ae],ne)})),te=q.sortMulti(ee,I.sort.map(ne=>({col:ne.col,dir:ne.dir})),Uint32Array.from({length:Z.length},(ne,ae)=>ae),{});Z=Array.from(te,ne=>J[ne])}return Z}function x(S){return JSON.stringify({filters:S.filters||null,sort:S.sort||[],quick:S.quick||"",groupBy:S.groupBy||[],groupPath:S.groupPath||[],context:S.context??null})}function C(S){if(!S||typeof S!="object")return 16;let I="";try{I=JSON.stringify(S)}catch{return 200}return I.length*2+64}function A(S){const I=S||{};return{enabled:!!I.enabled,maxRows:Number.isFinite(I.maxRows)?I.maxRows:1e6,maxBytesEstimate:Number.isFinite(I.maxBytesEstimate)?I.maxBytesEstimate:512*1024*1024}}const j=5e4;function $(S){return Number.isFinite(S)&&S>=0?S:j}function z(S){return!!S&&B(S.then)}async function M(S){if(!S||S.total!==void 0||!z(S.pendingTotal))return S;const I=await S.pendingTotal,{pendingTotal:q,...Z}=S;return typeof I=="number"?{...Z,total:I}:Z}function R(S={}){const I=S.adapter;if(!I||!B(I.execute))return W("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...S,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=f(I.capabilities),Z=I.capabilities&&Object.getOwnPropertyDescriptor(I.capabilities,"operators");Z&&B(Z.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(I.capabilities.operators||[]),set:()=>{}});const _=I.name||"adapter";let J=null;const ee=()=>B(I.ready)?(J||(J=Promise.resolve(I.ready()).then(()=>{Object.assign(q,f(I.capabilities))},Xe=>{throw J=null,Xe})),J):null,te=A(S.fullDataset),ne=!!S.allowPartialResults,ae=$(S.whereRowLimit);let de=null;const ie=S.aggregates;let oe=null,ce=null,fe=null,ke=null,Re=null,Ee,Fe=null,ye=0,he=null;const Se=()=>!te.enabled||!oe?null:(he!==oe.key&&(ye++,he=oe.key),{rows:oe.rows,version:ye}),Ce=async Xe=>{const Ge=Xe.where&&Xe.where.active?Xe.where:null;if(!Ge)return{request:Xe,probe:null};const{where:se,...pe}=Xe,be=b(pe,q,te.enabled);if(be.needsAll)return{request:Xe,probe:null};const Ue=x(be.pushed);let Ve=null;return(!de||de.key!==Ue)&&(q.total?(s(Xe),Ve=await M(await I.execute(be.pushed,Xe)),de={key:Ue,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):de={key:Ue,size:null}),de.size!==null&&de.size<ae?{request:Xe,probe:null}:(K(Ge.names,_,de.size,ae),{request:pe,probe:Ve})},Ie=async(Xe,Ge)=>{Fe=null;const se=E(Xe.pushed);fe={engine:se.engine,client:se.client,groupBy:Xe.pushed.groupBy},se.client.length&&W(`source.pushdown.group.totals.${_}.${se.client.map(Ue=>Ue.id).join(".")}`,`the ${_} adapter cannot compute the group subtotal for ${se.client.map(Ue=>`"${Ue.id}" (${Ue.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const pe=await I.executeGroupLevel(Xe.pushed,se.engine,Ge)||{};let be=pe.rows||[];return!q.range&&Ge.range&&(be=be.slice(Ge.range.start,Ge.range.end)),Te(pe),pe.total===void 0?{rows:be}:{rows:be,total:pe.total}},ze=new Map,Ye=64,Qe=async(Xe,Ge)=>{Fe=null;const se=Xe.pushed,pe=se.groupBy,be=Array.isArray(se.groupValues)?se.groupValues:[],Ue=be.length,Ve=[...se.filters?[se.filters]:[],...pe.slice(0,Ue).map((ct,pt)=>({col:ct,op:"eq",value:be[pt]===void 0?null:be[pt],caseSensitive:!0}))],nt=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},ge=Ge.range?Ge.range.start:0;if(Ue>=pe.length){const ct={...se,filters:nt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},pt=await M(await I.execute(ct,Ge))||{};let jt=pt.rows||[];return!q.range&&Ge.range&&(jt=jt.slice(Ge.range.start,Ge.range.end)),typeof pt.total=="number"?{rows:jt,total:pt.total}:{rows:jt}}const we=pe[Ue],ve=E(se),je=d(q),Le=ve.engine.filter(ct=>je.has(ct.fn)),me=[...ve.engine.filter(ct=>!je.has(ct.fn)).map(ct=>({id:ct.id,fn:ct.fn,class:ct.class,reason:`the ${_} adapter does not compute "${ct.fn}"`})),...ve.client];fe={engine:Le,client:me,groupBy:pe},me.length&&W(`source.pushdown.group.totals.${_}.${me.map(ct=>ct.id).join(".")}`,`the ${_} adapter cannot compute the group subtotal for ${me.map(ct=>`"${ct.id}" (${ct.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Me=[...Le.map(ct=>({id:ct.id,col:ct.col,fn:ct.fn})),{id:g,col:we,fn:"count"}],Ae={...se,filters:nt,range:null},Ne=JSON.stringify([x(Ae),be,we,Me]);let De=ge>0?ze.get(Ne):void 0;if(!De){for(De=Promise.resolve(I.executeGroupedAggregates(Ae,[we],Me)),ze.delete(Ne),ze.set(Ne,De);ze.size>Ye;)ze.delete(ze.keys().next().value);De.catch(()=>{ze.get(Ne)===De&&ze.delete(Ne)})}const qe=await De||[];s(Ge);const ot=ct=>{const pt={};for(const jt of Le)pt[jt.id]=ct?ct[jt.id]:void 0;return pt},ut=(se.sort||[]).find(ct=>ct&&ct.col===we),dt=ut&&ut.dir==="desc"?-1:1,st=qe.filter(ct=>ct&&ct.level===1).map(ct=>({[we]:ct.keys[0]===void 0?null:ct.keys[0],leafCount:Number(ct.values&&ct.values[g])||0,totals:ot(ct.values)})).sort((ct,pt)=>dt*L(ct[we],pt[we]));if(Ue===0){const ct=qe.find(jt=>jt&&jt.level===0),pt=ct?Number(ct.values&&ct.values[g]):NaN;Te({matchCount:Number.isFinite(pt)?pt:st.reduce((jt,He)=>jt+He.leafCount,0),...ct?{grand:ot(ct.values)}:{}})}const wt=Ge.range?Ge.range.end:st.length;return{rows:st.slice(ge,wt),total:st.length}},Te=Xe=>{typeof Xe.matchCount=="number"&&(ke=Xe.matchCount,Re=Xe.grand?{totals:Xe.grand,leafCount:Xe.matchCount}:null,Ee===void 0&&B(I.unfilteredCount)&&(Ee=null,Promise.resolve(I.unfilteredCount()).then(Ge=>{Ee=typeof Ge=="number"?Ge:null}).catch(Ge=>{W(`source.pushdown.group.unfiltered.${_}`,`the ${_} adapter could not count the unfiltered set (${Ge&&Ge.message?Ge.message:Ge}), so "N of M" falls back to the display count for its denominator.`)})))},_e=async(Xe,Ge)=>{Fe=null;const se=E(Xe.pushed);fe={engine:se.engine,client:se.client,groupBy:Xe.pushed.groupBy,pivotBy:Xe.pushed.pivotBy},se.client.length&&W(`source.pushdown.pivot.totals.${_}.${se.client.map(nt=>nt.id).join(".")}`,`the ${_} adapter cannot compute the pivot cells for ${se.client.map(nt=>`"${nt.id}" (${nt.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const pe=await I.executePivotLevel(Xe.pushed,se.engine,Ge)||{};let be=pe.rows||[];!q.range&&Ge.range&&(be=be.slice(Ge.range.start,Ge.range.end)),Te(pe);const Ue=pe.pivot&&typeof pe.pivot=="object"?pe.pivot:{},Ve={cells:Array.isArray(Ue.cells)?Ue.cells:[],...Array.isArray(Ue.axis)?{axis:Ue.axis}:{}};return pe.total===void 0?{rows:be,pivot:Ve}:{rows:be,total:pe.total,pivot:Ve}},Ke=Xe=>{W(`source.pushdown.pivot.${_}.${Xe}`,`pushdown:pivot-unsupported: the ${_} adapter cannot pivot this query because ${Xe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Ge=new Error(`[lattice] ${m}: the ${_} adapter cannot pivot this query because ${Xe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Ge.code=m,Ge.reason=Xe,Ge},tt=(Xe,Ge)=>{const se={key:Ge,state:"pending",value:null};return Fe=se,Xe.then(pe=>(Fe===se&&(Fe={key:Ge,state:"settled",value:typeof pe=="number"?pe:null}),pe),pe=>{throw Fe===se&&(Fe={key:Ge,state:"failed",value:null}),pe})},it=async Xe=>{const Ge=ee();Ge&&await Ge;const pe=Xe&&Xe.pivotMode!==!1&&Array.isArray(Xe.pivotBy)&&Xe.pivotBy.length>0?{request:Xe,probe:null}:await Ce(Xe);s(Xe);let be=b(pe.request,q,te.enabled);if(q.group&&be.grouped&&!be.pivoted&&!B(I.executeGroupLevel)&&(W(`source.pushdown.group.method.${_}`,`the ${_} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),be=b(pe.request,{...q,group:!1,aggregates:null},te.enabled)),be.pivoted&&!B(I.executePivotLevel)&&(be=b(pe.request,{...q,pivot:!1},te.enabled),be.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),be.grouped&&!be.pivoted&&!q.group&&!B(I.executeGroupedAggregates)&&(W(`source.pushdown.group.aggregates.method.${_}`,`the ${_} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),be=b(pe.request,{...q,aggregates:null},te.enabled)),ce=be,be.pivoted)return _e(be,Xe);if(be.pivotReason&&Ke(be.pivotReason),be.grouped)return q.group?Ie(be,Xe):Qe(be,Xe);const Ve=!!be.groupReason&&!be.full;Ve?W(`source.pushdown.group-unsupported.${_}.${be.groupReason}`,`pushdown:group-unsupported: the ${_} adapter was not asked to group this query because ${be.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):be.groupReason&&W(`source.pushdown.group.${_}.${be.groupReason}`,`the ${_} adapter was not asked to group this query because ${be.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const nt=Me=>Ve?{...Me,[k]:!0}:Me;if(!be.needsAll){const Me=pe.probe||await I.execute(be.pushed,Xe),Ae=Me.rows||[];return z(Me.pendingTotal)&&Me.total===void 0?nt({rows:Ae,pendingTotal:tt(Me.pendingTotal,x(be.pushed))}):(Fe=null,!q.total&&Me.total===void 0?nt({rows:Ae}):nt({rows:Ae,total:Me.total??Ae.length}))}be.unpushed.length&&W(`source.pushdown.residual.${_}.${be.unpushed.join(".")}`,`the ${_} adapter cannot push ${be.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ge=x(be.pushed);if(!oe||oe.key!==ge){const Me=await M(await I.execute(be.pushed,Xe));Fe=null;const Ae=Me.rows||[];if(be.full){const Ne=typeof Me.total=="number"?Math.max(Me.total,Ae.length):Ae.length;if(Ne>te.maxRows)throw new Error(`[lattice] fullDataset refused: the ${_} adapter's matching set is ${Ne.toLocaleString()} rows, past the configured maxRows of ${te.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const De=Ae.length*C(Ae[0]);if(De>te.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${_} adapter's matching set is an estimated ${Math.round(De/(1024*1024)).toLocaleString()} MB across ${Ae.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(te.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Me.total=="number"&&Ae.length<Me.total){const Ne=!!(be.residual.filters||be.residual.quick||be.residual.sort&&be.residual.sort.length);if(Ne&&!ne)throw new Error(`[lattice] the ${_} adapter returned ${Ae.length} of ${Me.total} matching rows when asked for the whole result, and the query has residual ${be.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);Ne?W(`source.pushdown.partial.residual.${_}`,`the ${_} adapter returned ${Ae.length} of ${Me.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):W(`source.pushdown.partial.${_}`,`the ${_} adapter returned ${Ae.length} of ${Me.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}oe={key:ge,rows:Ae,total:typeof Me.total=="number"?Me.total:null}}let we=be;if(be.residual.where){const Me=oe.total??oe.rows.length;if(Me>=ae){K(be.residual.where.names,_,Me,ae);const{where:Ae,...Ne}=pe.request;we=b(Ne,q,te.enabled),ce=we}}const ve=oe.total!==null&&oe.rows.length>=oe.total,je=P(oe.rows,{...we.residual,whole:ve},S.compute||{}),Le=Xe.range?Xe.range.start:0,me=Xe.range?Xe.range.end:je.length;return nt({rows:je.slice(Le,me),total:je.length})},ht=async(Xe,Ge)=>{const se=ee();se&&await se;const pe=b(Xe,q,te.enabled);ce=pe;const be=v(Ge,ie),Ue=Array.isArray(Xe.groupBy)?Xe.groupBy:[],Ve=Ue.length>0,nt=!pe.residual.filters&&!pe.residual.quick,ge=!Ve||O(Ue,q.buckets);let we=be.engine,ve=be.client;if(q.aggregates&&we.length){const Me=q.aggregates instanceof Set?q.aggregates:new Set(F(q.aggregates)),Ae=we.filter(Ne=>!Me.has(Ne.fn));Ae.length&&(we=we.filter(Ne=>Me.has(Ne.fn)),ve=[...Ae.map(Ne=>({...Ne,reason:`the ${_} adapter does not compute "${Ne.fn}"`})),...ve])}const je=Me=>{ve=[...we.map(Ae=>({...Ae,reason:Me})),...ve],we=[]};we.length&&!nt?je(pe.residual.quick&&!pe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):we.length&&!ge&&je("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Le={},me;return we.length&&(B(Ve?I.executeGroupedAggregates:I.executeAggregates)?Ve?me=await I.executeGroupedAggregates(pe.pushed,Ue,we)||[]:Le=await I.executeAggregates(pe.pushed,we)||{}:(W(`source.pushdown.aggregates.${_}${Ve?".grouped":""}`,`the ${_} adapter cannot compute ${Ve?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),je(`adapter cannot compute ${Ve?"grouped ":""}aggregates`))),fe={engine:we,client:ve,...Ve?{groupBy:Ue}:{}},{values:Le,engine:we,client:ve,...me!==void 0?{groups:me}:{}}},yt=o(S.edit),St=S.edit&&typeof S.edit=="object"&&B(S.edit.commit);let At=S.edit;if(yt&&!St)if(q.mutate&&q.mutate.update){const Xe=Ge=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${_} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const se={kind:"update",key:String(Ge.key),patch:{[Ge.colId]:Ge.value}};return I.mutate(se,Ge.request||{})};At={...S.edit===!0?{}:S.edit,commit:Xe}}else W(`source.pushdown.readonly.${_}`,`edit is enabled but the ${_} adapter declares mutate: ${q.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const Ct=yt&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:(Xe,Ge)=>I.mutate(Xe,Ge||{})}:null,Tt=async Xe=>{const Ge=ee();Ge&&await Ge;const{range:se,signal:pe,export:be,...Ue}=Xe||{},Ve={...Ue,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:b(Ve,q,te.enabled),signal:pe}};async function*It(Xe,Ge={}){const{plan:se,signal:pe}=await Tt(Xe),be=Math.max(1,Math.floor(Number(Ge.pageSize))||5e3),Ue={signal:pe,stream:!0};if(!se.needsAll)for(let ge=0;;ge+=be){s(Ue);const we=await I.execute({...se.pushed,range:{start:ge,end:ge+be}},Ue);we&&z(we.pendingTotal)&&we.pendingTotal.then(null,()=>{});const ve=we&&we.rows||[];if(ve.length&&(yield ve),ve.length<be)return}s(Ue);const Ve=await M(await I.execute({...se.pushed,range:void 0},Ue)),nt=P(Ve&&Ve.rows||[],{...se.residual,whole:!0},S.compute||{});for(let ge=0;ge<nt.length;ge+=be)yield nt.slice(ge,ge+be)}return{...S,edit:At,rowMutate:Ct,mode:"remote",fetch:it,aggregate:ht,countMatching:async Xe=>{const{plan:Ge,signal:se}=await Tt(Xe);if(!Ge.needsAll&&q.total){s({signal:se});const be=await M(await I.execute({...Ge.pushed,range:{start:0,end:0}},{signal:se}));if(be&&typeof be.total=="number")return be.total}let pe=0;for await(const be of It(Xe))pe+=be.length;return pe},streamMatching:It,lastPlan:()=>ce?{...ce,...fe?{aggregates:fe}:{},...Fe?{total:{deferred:!0,state:Fe.state,value:Fe.value}}:{}}:null,fullFrame:Se,counts:()=>({match:ke,total:Ee??null,pending:!!Fe&&Fe.state==="pending"}),grandTotals:()=>Re}}}),xe("packages/core/src/source/remote.js",function(e,G){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return C}});const Q=G("packages/core/src/internal/util.js"),L=Q.Lru,B=Q.isFunction,F=Q.warnOnce,W=Q.settleDebounce,X=G("packages/core/src/source/abort.js"),H=X.createAbortScope,V=X.isAbortError,K=G("packages/core/src/source/blockcache.js"),D=K.BlockCache,v=K.DEFAULT_PAGE_SIZE,O=K.DEFAULT_MAX_CACHED_PAGES,y=G("packages/core/src/source/rows.js"),u=y.createRowFactory,a=y.groupKey,s=G("packages/core/src/source/filterwire.js"),n=s.wireFilters,t=s.querySignature,r=s.warnHostFilterNotApplied,f=G("packages/core/src/source/pagewindow.js").pageWindow,i=G("packages/core/src/source/memory.js").MemorySource,d=G("packages/core/src/compute/handle.js").valueComparator,h=G("packages/core/src/compute/pivot.js"),l=h.pivotKey,m=h.joinPath,w=h.DEFAULT_PATH_SEPARATOR,p=G("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,b=1,E=120;function T(A,j,$){for(let z=0;z<Math.max(A.length,j.length);z++){const M=A[z],R=j[z],S=M==null,I=R==null;if(S||I){if(S&&I)continue;return S?1:-1}const q=$(M,R);if(q!==0)return q}return 0}function P(A,j){return new C(A,j)}class x{constructor(j,$,z,M){this.path=j,this.keyPath=M||j,this.values=[],this.level=$,this.key=a(this.keyPath),this.cache=new D(z),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null,this.flat=!1}}class C{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=H();#l;#a;#u=new Map;#c=[];#d=null;#f="";#h;#p=!1;#m=0;#g="";#y=null;#w=-1;constructor(j,$){this.#e=j||{mode:"remote"},this.#t=$||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#R(),this.unfilteredIndices=()=>this.#L(),this.handleFor=S=>this.#x(S),this.display=()=>this.#I(),this.grandTotalRow=()=>this.#$(),this.unfilteredRows=()=>this.#B(),this.facetIndices=S=>this.#z(S));const z=this.#e.counts;B(z)&&(this.matchCount=()=>this.#N("match"),this.totalCount=()=>this.#N("total"));const M=this.#e.grandTotals;B(M)&&(this.grandTotalRow=()=>this.#H());const R=this.#e;B(R.countMatching)&&B(R.streamMatching)&&(this.selectionQuery=()=>this.#W(),this.countMatching=S=>R.countMatching(S),this.streamMatching=(S,I)=>R.streamMatching(S,I),this.loadedRows=()=>this.#ie(),this.resident=()=>this.#A()!==null),this.#n={pageSize:this.#e.pageSize||v,maxCachedPages:this.#e.maxCachedPages||O},this.#l=u(this.#t),this.#a=new L(this.#n.pageSize*4),this.#h=W((S,I)=>this.#S(S,I),E),this.#r=new x([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#f=this.#me(),B(this.#e.fetch)||F("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Ce()}count(){const j=this.#O();return j?j.length:this.#k()}#k(){const j=this.#A();return j?j.count():(this.#ne(),this.#q(this.#r))}#b(){if(this.#A())return!0;const j=$=>{if($.count===null&&!$.complete)return!1;for(const z of $.children.values())if(this.#X(z.key)&&!j(z))return!1;return!0};return j(this.#r)}pageInfo(){const j=this.#O(),$=this.totalPending();if(!j){const z=this.#k();return{page:0,pageSize:0,total:this.#b()?z:null,pageCount:1,counting:$}}return{page:j.page,pageSize:j.pageSize,total:j.total,pageCount:j.pageCount,counting:$||j.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#O(){const j=this.#k(),$=f(this.#T("pageSize",0),this.#T("page",0),j,this.#b());if(!$)return this.#g="",null;const z=`${this.#m}:${$.offset}:${$.length}`;return z!==this.#g&&!this.#p&&(this.#g=z,$.length>0&&!this.#A()&&this.#S($.offset,$.offset+$.length-1)),$}at(j){const $=this.#O();if($){if(j<0||j>=$.length)return;const z=this.#j($.offset+j);return z&&(z.index=j),z}return this.#j(j)}#j(j){const $=this.#A();if($)return $.at(j);if(this.#ne(),j<0||j>=this.#k())return;const z=this.#D(this.#r,j);if(!z)return;const M=this.#K(z.node,z.local);return M&&(M.index=j),M||this.#l.skeleton(j,z.node.level,z.node.cache.erroredAt(z.local))}byKey(j){const $=this.#A();if($)return $.byKey(j);const z=this.#u.get(j);if(!z)return;const M=z.lastIndexOf(":"),R=this.#o.get(z.slice(0,M));return R&&this.#K(R,Number(z.slice(M+1)))||void 0}loaded(j){const $=this.#O();if($){if(j<0||j>=$.length)return!1;j+=$.offset}const z=this.#A();if(z)return z.loaded(j);if(j<0||j>=this.#k())return!1;const M=this.#D(this.#r,j);return!!M&&M.node.cache.rowLoaded(M.local)}hint(j,$){if(this.#p)return;const z=this.#ne();let M=Math.max(0,Math.floor(j)),R=Math.max(M,Math.floor($));const S=this.#O();if(S){if(S.length===0)return;M=S.offset,R=S.offset+S.length-1}for(const[I,q]of this.#P(M,R)){I.cache.protect(q.min,q.max);for(const Z of I.cache.evict())this.#Pe(I,Z)}this.#h(M,R),z&&this.#h.flush()}#P(j,$){const z=this.#k(),M=new Map;for(let R=j;R<=$&&R<z;R++){const S=this.#D(this.#r,R);if(!S)continue;const I=M.get(S.node);I?(I.min=Math.min(I.min,S.local),I.max=Math.max(I.max,S.local)):M.set(S.node,{min:S.local,max:S.local})}return M.size||M.set(this.#r,{min:j,max:j}),M}#S(j,$){if(!this.#p)for(const[z,M]of this.#P(j,$)){z.cache.protect(M.min,M.max);const R=z.cache.blockOf(M.min),S=z.cache.blockOf(M.max);for(let I=R;I<=S&&!(z.count!==null&&I*z.cache.pageSize>=z.count);I++)z.cache.has(I)||this.#le(z,I)}}apply(j){const $={added:[],updated:[],removed:[]};if(!j)return $;if(j.update)for(const z of j.update){const M=this.#u.get(this.#l.keyOf(z,-1));if(!M)continue;this.#a.delete(M);const R=M.lastIndexOf(":"),S=this.#o.get(M.slice(0,R));if(!S)continue;const I=Number(M.slice(R+1)),q=S.cache.blockOf(I);if(!S.cache.loaded(q))continue;const{start:Z}=S.cache.rangeOf(q),_=[];for(let ee=Z;ee<Z+S.cache.pageSize;ee++){const te=S.cache.rowAt(ee);if(te===void 0)break;_.push(ee===I?z:te)}S.cache.fill(q,_);const J=this.#K(S,I);J&&$.updated.push(J)}return(j.add&&j.add.length||j.remove&&j.remove.length)&&this.reload({keepExpanded:!0}),$}reload(j){this.#s.abortAll("reload"),this.#h.cancel(),j&&j.keepExpanded===!1&&this.#i.clear(),this.#oe(),this.#U("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#oe(),this.#o.clear(),this.#i.clear(),this.#y&&B(this.#y.destroy)&&this.#y.destroy(),this.#y=null}expand(j){this.#i.has(j)||(this.#i.add(j),this.#U("group:toggled",{key:j,expanded:!0}),this.#U("model:changed",{reason:"expand",key:j}))}collapse(j){this.#i.delete(j)&&(this.#U("group:toggled",{key:j,expanded:!1}),this.#U("model:changed",{reason:"collapse",key:j}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#ne();const j=this.#d;if(!j||!j.keys.size||!this.#T("pivotBy",[]).length)return null;if(!j.result){const $=d((this.#t.config||{}).locale),z=[...j.keys.entries()].sort((R,S)=>T(R[1],S[1],$)),M=z.map(([R])=>R);j.result={keys:z.map(([,R])=>R),paths:M,fields:this.#pe(M),groupPaths:[],columns:M.length*Math.max(1,this.#ke().length),values:j.cells,cells:j.cells,error:null}}return j.result}invalidateHandles(){this.#y&&(B(this.#y.invalidateHandles)&&this.#y.invalidateHandles(),B(this.#y.invalidate)&&this.#y.invalidate("filter"))}#M(){const j=this.#e.fullFrame;return B(j)?j():null}#A(){const j=this.#M();return j?(this.#y||(this.#y=new i({mode:"memory"},this.#E())),j.version!==this.#w&&(this.#y.setRows(j.rows),this.#w=j.version),this.#y):null}#E(){const j=this.#t,$=j.state||{};return{...j,state:{...$,page:()=>0,pageSize:()=>0}}}#R(){const j=this.#A();return j?j.filteredIndices():new Uint32Array(0)}#L(){const j=this.#A();return j?j.unfilteredIndices():new Uint32Array(0)}#x(j){const $=this.#A();return $?$.handleFor(j):void 0}#I(){const j=this.#A();return j?j.display():[]}#z(j){const $=this.#A();return $&&B($.facetIndices)?$.facetIndices(j):new Uint32Array(0)}#$(){const j=this.#A();return j&&B(j.grandTotalRow)?j.grandTotalRow():null}#N(j){const $=this.#A();if($){const S=j==="match"?$.matchCount:$.totalCount;if(B(S))return S.call($)}const z=this.#e.counts,M=B(z)?z():null,R=M?M[j]:null;return typeof R=="number"?R:this.#k()}#H(){const j=this.#A();if(j&&B(j.grandTotalRow))return j.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const z=this.#e.grandTotals,M=B(z)?z():null;return!M||!M.totals?null:this.#l.grandTotal(M.totals,M.leafCount||0)}#B(){const j=this.#A();if(j&&B(j.unfilteredRows))return j.unfilteredRows();const $=[],z=this.count();for(let M=0;M<z;M++){const R=this.at(M);R&&$.push(R)}return $}#W(){const j=this.#T("quick",""),$={protocol:b,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:n(this.#T("filters",null),this.#G()),sort:this.#T("sort",[]),context:this.#T("context",null)};j&&($.quick=j);const z=this.#T("where",null);return z&&z.active&&($.where=z),$}#ie(){const j=this.#T("groupBy",[]).length,$=[];for(const z of this.#o.values())if(!(z.level!==j&&!z.flat))for(const M of z.cache.ids()){if(!z.cache.loaded(M))continue;const{start:R,end:S}=z.cache.rangeOf(M);for(let I=R;I<S&&z.cache.rowLoaded(I);I++){const q=this.#K(z,I);q&&!q.group&&$.push(q)}}return $}#re(j,$,z){const{start:M,end:R}=j.cache.rangeOf($),S=this.#T("groupBy",[]),I=this.#T("pivotBy",[]),q=this.#T("quick",""),Z=this.#ke(),_={protocol:b,range:{start:M,end:R},groupPath:j.path,groupValues:j.values,groupBy:S,totals:Z,totalFns:this.#ce(Z),pivotBy:I,pivotMode:I.length>0,filters:n(this.#T("filters",null),this.#G()),sort:this.#T("sort",[]),context:this.#T("context",null),signal:z};q&&(_.quick=q);const J=this.#T("where",null);return J&&J.active&&(_.where=J),_}async#le(j,$){if(!B(this.#e.fetch))return;const z=this.#s.begin(`${j.key}:${$}`);j.cache.begin($,z);const M=this.#f,{start:R}=j.cache.rangeOf($);try{const S=await this.#e.fetch(this.#re(j,$,z.signal));if(!z.current||M!==this.#f||this.#p)return;z.settle();const I=S&&S.rows||[];if(!!(S&&S[p])&&!j.flat){j.flat=!0,j.children.clear();for(const[J,ee]of[...this.#u])ee.startsWith(`${j.key}:`)&&(this.#a.delete(ee),this.#u.delete(J))}j.cache.fill($,I);for(let J=0;J<I.length;J++)this.#a.delete(`${j.key}:${R+J}`);const Z=S&&typeof S.count=="number"?S.count:S&&typeof S.total=="number"?S.total:null,_=S&&B(S.pendingTotal?.then)?S.pendingTotal:null;Z!==null?(j.count=Z,j.complete=!0):I.length<j.cache.pageSize?(j.count=R+I.length,j.complete=!0):_&&(j.counting=!0),S&&Array.isArray(S.pivotFields)&&this.#he(S.pivotFields),S&&S.pivot&&typeof S.pivot=="object"&&this.#be(S.pivot),this.#U("model:changed",{reason:"page",groupPath:j.path,block:$}),this.#U("rows:changed",{companion:!0,reason:"page",groupPath:j.path,block:$}),_&&this.#ue(j,_,M)}catch(S){if(z.settle(),V(S))return;j.cache.failed($,S);const{end:I}=j.cache.rangeOf($);for(let q=R;q<I;q++)this.#a.delete(`${j.key}:${q}`);this.#U("model:changed",{reason:"page-error",groupPath:j.path,block:$}),this.#U("source:error",{error:S,groupPath:j.path,block:$})}}async#ue(j,$,z){let M;try{M=await $}catch(R){if(z!==this.#f||this.#p)return;j.counting=!1,V(R)||this.#U("source:error",{error:R,groupPath:j.path});return}z!==this.#f||this.#p||(j.counting=!1,typeof M=="number"&&(j.count=M,j.complete=!0,this.#U("source:total",{total:M,groupPath:j.path}),this.#U("model:changed",{reason:"total",count:M,groupPath:j.path})))}totalPending(){return this.#r.counting===!0}#he(j){j.length===this.#c.length&&j.every(($,z)=>$===this.#c[z])||(this.#c=j,this.#U("column:pivoted",{pivotFields:j,remote:!0}))}#we(){const j=this.#t.config||{};return j.pivot&&j.pivot.separator||w}#pe(j){const $=this.#we(),z=this.#ke();if(!z.length)return j.slice();const M=[];for(const R of j)for(const S of z)M.push(`${R}${$}${S}`);return M}#be(j){const $=this.#we();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const z=this.#d;let M=!1;const R=I=>{const q=Array.isArray(I)?I:[I],Z=m(q,$);return z.keys.has(Z)||(z.keys.set(Z,q),M=!0),Z},S=this.#T("groupBy",[]).length>0;for(const I of Array.isArray(j.axis)?j.axis:[])R(I);for(const I of Array.isArray(j.cells)?j.cells:[]){if(!I||typeof I!="object")continue;const q=R(I.pivot);if(S&&!(Array.isArray(I.group)&&I.group.length))continue;const Z=m(Array.isArray(I.group)?I.group:[],$);for(const[_,J]of Object.entries(I.values||{}))z.cells.set(l(Z,q,_),J)}z.result=null,M&&this.#he((this.pivot()||{fields:[]}).fields)}#q(j){let $=this.#te(j);for(const z of j.children.values())this.#X(z.key)&&($+=this.#q(z));return $}#te(j){if(j.count!==null)return j.count;const $=j.cache.loadedExtent();return j.complete?$:j.row&&j.row.leafCount>0?j.level>=this.#T("groupBy",[]).length?Math.max($,j.row.leafCount):$===0?1:Math.min($+j.cache.pageSize,Math.max($,j.row.leafCount)):$+j.cache.pageSize}#D(j,$){let z=$,M=0;const R=[...j.children.entries()].filter(([,I])=>this.#X(I.key)).sort((I,q)=>I[0]-q[0]);for(const[I,q]of R){const Z=I-M+1;if(z<Z)return{node:j,local:M+z};z-=Z,M=I+1;const _=this.#q(q);if(z<_)return this.#D(q,z);z-=_}const S=this.#te(j);return M+z<S?{node:j,local:M+z}:null}#K(j,$){const z=`${j.key}:${$}`,M=this.#a.get(z);if(M)return M;const R=j.cache.rowAt($);if(R===void 0)return null;const S=this.#T("groupBy",[]);let I;if(j.level<S.length&&!j.flat){const q=S[j.level],Z=this.#d!==null&&j.level===S.length-1&&this.#T("pivotBy",[]).length>0,_=this.#se(R,q),J=_==null,ee=[...j.path,J?"":String(_)],te=[...j.keyPath,J?null:String(_)];if(I=this.#l.group({path:ee,keyPath:te,column:q,value:_,level:j.level,parent:j.row,leafCount:Number(R.leafCount)||0,expanded:Z?!1:this.#X(a(te)),...Z?{hasChildren:!1}:{}}),I.totals=this.#_(R),I.data=R,!Z){let ne=this.#o.get(I.key);ne?ne.row=I:(ne=new x(ee,j.level+1,this.#n,te),ne.row=I,this.#o.set(ne.key,ne)),ne.values=[...j.values,_],j.children.set($,ne)}}else I=this.#l.leaf(R,$,j.level,j.row);return this.#a.set(z,I),this.#u.set(I.key,z),I}#_(j){const $=j||{};if($.totals&&typeof $.totals=="object")return $.totals;const z={};for(const M of this.#ke())Object.hasOwn($,M)&&(z[M]=$[M]);return z}#Pe(j,$){const{start:z,end:M}=j.cache.rangeOf($);for(let R=z;R<M;R++){const S=`${j.key}:${R}`,I=this.#a.peek(S);I&&this.#u.delete(I.key),this.#a.delete(S)}}#ne(){const j=this.#me();return j===this.#f?!1:(this.#f=j,this.#s.abortAll("query"),this.#oe(),this.#U("model:changed",{reason:"query"}),!0)}#oe(){for(const j of this.#o.values())j.cache.clear(),j.count=null,j.complete=!1,j.counting=!1,j.children.clear(),j.flat=!1;this.#a.clear(),this.#u.clear(),this.#m++,this.#d=null}#me(){const j=this.#T("where",null);return`${t({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),groupBy:this.#T("groupBy",[]),pivotBy:this.#T("pivotBy",[]),context:this.#T("context",null)})}|${j?j.version:0}`}#X(j){const $=this.#T("expanded",null);return $?B($.has)?$.has(j):Array.prototype.includes.call($,j):this.#i.has(j)}#ke(){const j=this.#T("totals",[]);if(j&&j.length)return[...j];const $=this.#t.columns;return!$||!B($.all)?[]:$.all().filter(z=>!!z.total).map(z=>z.id)}#ce(j){const $=this.#t.columns,z={};if(!$||!B($.get))return z;for(const M of j){const R=$.get(M);if(!R)continue;const S=R.groupTotal!=null?R.groupTotal:R.total;typeof S=="string"&&(z[M]=S)}return z}#se(j,$){const z=this.#t.columns,M=z&&B(z.get)?z.get($):void 0;return M&&B(M.getValue)?M.getValue(j):j?.[$]}#Ce(){r(this.#t)}#G(){const j=this.#t.config||{};return{tz:j.timeZone,weekStartsOn:j.weekStartsOn}}#T(j,$){const z=this.#t.state;if(z&&B(z[j])){const M=z[j]();return M??$}return $}#U(j,$){const z=this.#t.emit;B(z)&&z(j,$)}}}),xe("packages/core/src/source/gapbuffer.js",function(e,G){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return L}});const Q=64;class L{#e;#t=0;#n=0;constructor(F=Q){this.#e=new Uint32Array(Math.max(1,F)),this.#n=this.#e.length}static from(F,W=Q){const X=new L(F.length+Math.max(1,W));return X.#e.set(F,0),X.#t=F.length,X.#n=X.#e.length,X}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(F){return F<0||F>=this.length?0:F<this.#t?this.#e[F]:this.#e[F+(this.#n-this.#t)]}insert(F,W){const X=F<0?0:F>this.length?this.length:F;this.#r(X),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(F){this.insert(this.length,F)}removeAt(F){return!Number.isInteger(F)||F<0||F>=this.length?!1:(this.#r(F),this.#n++,!0)}toArray(){const F=new Uint32Array(this.length);return F.set(this.#e.subarray(0,this.#t),0),F.set(this.#e.subarray(this.#n),this.#t),F}clear(){this.#t=0,this.#n=this.#e.length}#r(F){if(F!==this.#t)if(F<this.#t){const W=this.#t-F;this.#e.copyWithin(this.#n-W,F,this.#t),this.#t=F,this.#n-=W}else{const W=F-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=F,this.#n+=W}}#o(){const F=this.#e.length-this.#n,W=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+Q));W.set(this.#e.subarray(0,this.#t),0),W.set(this.#e.subarray(this.#n),W.length-F),this.#e=W,this.#n=W.length-F}}}),xe("packages/core/src/store/ingest.js",function(e,G){"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 O}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return n}});const Q=G("packages/core/src/internal/util.js"),L=Q.now,B=Q.nextFrame,F=Q.infoOnce,W=Q.warnOnce,X=Q.isFunction,H=Q.pathGetter,K=G("packages/core/src/store/columnstore.js").ColumnStore,D=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function v(t,r={}){if(r.multi)return"multi";if(t.length===0)return"object";let o=0,f=0,c=0,i=0,g=0;for(let h=0;h<t.length;h++){const l=t[h];typeof l=="number"?o++:typeof l=="boolean"?f++:typeof l=="string"?c++:l instanceof Date?i++:Array.isArray(l)&&g++}const d=t.length;return o===d?"float64":f===d?"bitset":i===d?"float64":c===d?"text":g===d?"multi":"object"}function O(t,r,o){return r<=0||t<o*r?"dictionary":"object"}function y(t,r,o){const f=new Map,c=new Map;for(const b of t){if(b.computed)continue;const E=X(b.read)?b.read:H(b.field||b.id);c.set(b.id,E),f.set(b.id,E)}const i=r?.order??[],g=r?.fns??{},d=r?.deps??{},h=r?.wrapDeps??null,l=i.filter(b=>X(g[b])),m=l.some(b=>d[b]==="*");let w=new WeakMap;const k=b=>{const E={};if(m)for(const[T,P]of c)E[T]=P(b);for(const T of l){const P=d[T];let x;if(P==="*")x=E;else{x={};const C=P||[];for(let A=0;A<C.length;A++){const j=C[A];x[j]=j in E?E[j]:c.get(j)?.(b)}}E[T]=g[T](h?h(x,T):x,{data:b,row:null,column:null,grid:null,context:o})}return E},p=b=>{if(b===null||typeof b!="object"&&typeof b!="function")return k(b);let E=w.get(b);return E===void 0&&(E=k(b),w.set(b,E)),E};for(const b of l)f.set(b,E=>p(E)[b]);return{readers:f,reset(){w=new WeakMap}}}class u{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(r,o){this.spec=r,this.read=o,this.kind="object",this.inferred=!1,this.nullable=r.nullable!==!1}}class a{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(r,o={},f={}){this.#e=Array.isArray(r)?r:Array.from(r||[]),this.#i={...D,...f};const c=o.columns??[];this.#r=y(c,o.computed??null,o.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(c,o.computed??null),this.#n=new K(this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const r=L(),{chunkMs:o,chunkRows:f}=this.#i,c=this.#e.length;do{const i=Math.min(this.#o+f,c);this.#n.append(this.#e.slice(this.#o,i)),this.#d(this.#o,i),this.#o=i,this.#r.reset(),this.#h(!1)}while(this.#o<c&&L()-r<o);return this.#a+=L()-r,this.#i.onProgress?.({loaded:this.#o,total:c}),this.#o>=c?(this.#h(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,read:r.read,dictionary:r.spec.dictionary})),decisions:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,inferred:r.inferred,distinct:r.candidate||r.change?this.#f(r):null,change:r.change,reason:r.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(r,o){const f=this.#e,c=Math.min(this.#i.sampleSize,f.length),i=this.#i.dictionaryRatio,g=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const d of r){if(!d||!d.id)continue;if(d.computed&&(d.pure===!1||o&&!g.has(d.id))){W(`ingest.impure.${d.id}`,`column "${d.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(d.id)??(X(d.read)?d.read:H(d.field||d.id)),l=new u(d,h);if(d.kind)l.kind=d.kind,l.reason="declared by the caller";else if(d.dictionary)l.kind=d.multi?"multi":"dictionary",l.reason="value table supplied (lookup column)";else{const m=[];for(let k=0;k<c&&m.length<this.#i.sampleSize;k++){const p=h(f[k]);p!=null&&m.push(p)}l.inferred=!0;const w=v(m,{multi:d.multi});if(w==="text"){const k=new Set(m).size;l.kind=O(k,m.length,i),l.candidate=this.#u,l.reason=`sampled ${k} distinct in ${m.length}`}else l.kind=w,l.reason=`inferred from ${m.length} sampled values`,w==="object"&&m.length&&F(`ingest.mixed.${d.id}`,`column "${d.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);l.kind==="object"&&l.candidate&&(l.distinct=new Set(m))}this.#t.push(l)}}#d(r,o){const f=this.#e;for(const c of this.#t){if(!c.candidate||!c.distinct)continue;const i=c.distinct;for(let g=r;g<o;g++){const d=c.read(f[g]);d!=null&&i.add(d)}}}#f(r){if(r.distinct)return r.distinct.size;const o=this.#n.column(r.spec.id);return o?.dict?o.dict.size:0}#h(r){const o=this.#i.dictionaryRatio,f=this.#e.length;for(const c of this.#t){if(!c.candidate)continue;const i=this.#f(c);if(c.kind==="dictionary"&&i>=o*f){const g=this.#n.column(c.spec.id);c.distinct=new Set(g?.dict?g.dict.values():[]),this.#n.convert(c.spec.id,"object"),c.kind="object",c.change="demoted",c.reason=`${i} distinct values is at or above ${o*100}% of ${f} rows`;continue}if(c.kind==="object"&&i>=o*f){c.candidate=!1,c.distinct=null,c.reason=`${i} distinct values is at or above ${o*100}% of ${f} rows`;continue}r&&c.kind==="object"&&i<o*f&&(this.#n.convert(c.spec.id,"dictionary"),c.kind="dictionary",c.change=c.change==="demoted"?null:"promoted",c.reason=`${i} distinct values is below ${o*100}% of ${f} rows`,c.distinct=null),r&&(c.candidate=!1)}}}async function s(t,r={},o={}){const f=new a(t,r,o),c=o.scheduler?.frame??B;for(;f.slice();)await new Promise(i=>{c(i)});return f.result()}function n(t,r={},o={}){const f=new a(t,r,{...o,chunkMs:1/0});for(;f.slice(););return f.result()}}),xe("packages/core/src/store/columnpack.js",function(e,G){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return a}});const L=G("packages/core/src/internal/util.js").pathGetter,B=G("packages/core/src/store/ingest.js"),F=B.inferKind,W=B.decideText,X=B.INGEST_DEFAULTS,V=G("packages/core/src/store/columnstore.js").toFloat,K=new Set(["float64","int32","bitset","dictionary","object","multi"]);function D(s){if(!Array.isArray(s)||s.length===0)return!1;for(const n of s)if(!n||typeof n.id!="string"||typeof n.field!="string"||n.field===""||n.kind&&!K.has(n.kind))return!1;return!0}function v(s){const n=V(s);return Number.isFinite(n)?n|0:0}function O(s){return s==null?[]:Array.isArray(s)?s:[s]}function y(s,n,t,r){if(s.kind)return s.kind;const o=[];for(let i=0;i<n.length&&o.length<X.sampleSize;i++){const g=n[i];g!=null&&o.push(g)}const f=F(o,{multi:s.multi});if(f!=="text")return f;const c=new Set(o).size;return W(c,o.length,r)}function u(s,n,t={}){const r=n.length|0,o=t.dictionaryRatio??X.dictionaryRatio,f=[];for(const c of s){const i=L(c.field||c.id),g=c.nullable!==!1,d=new Array(r);for(let k=0;k<r;k++){const p=i(n[k]);d[k]=p===void 0?null:p}const h=y(c,d,r,o),l=g?new Uint8Array(r+7>>3):null,m=k=>{l&&(l[k>>3]|=1<<(k&7))};let w;switch(h){case"float64":{const k=new Float64Array(r);for(let p=0;p<r;p++){const b=d[p],E=b===null;E||m(p),k[p]=E?NaN:V(b)}w={id:c.id,kind:h,nullable:g,values:k,presence:l,offsets:null,table:null};break}case"int32":{const k=new Int32Array(r);for(let p=0;p<r;p++){const b=d[p],E=b===null;E||m(p),k[p]=E?0:v(b)}w={id:c.id,kind:h,nullable:g,values:k,presence:l,offsets:null,table:null};break}case"bitset":{const k=new Uint8Array(r+7>>3);for(let p=0;p<r;p++){const b=d[p],E=b===null;E||m(p),!E&&b&&(k[p>>3]|=1<<(p&7))}w={id:c.id,kind:h,nullable:g,values:k,presence:l,offsets:null,table:null};break}case"dictionary":{const k=new Uint32Array(r),p=[],b=new Map;for(let E=0;E<r;E++){const T=d[E];if(T===null){k[E]=0;continue}m(E);let P=b.get(T);P===void 0&&(P=p.length,p.push(T),b.set(T,P)),k[E]=P}w={id:c.id,kind:h,nullable:g,values:k,presence:l,offsets:null,table:p};break}case"multi":{const k=[],p=new Map,b=new Uint32Array(r+1),E=[];for(let T=0;T<r;T++){const P=d[T];b[T]=E.length,P===null||m(T);const C=O(P);for(let A=0;A<C.length;A++){const j=C[A];let $=p.get(j);$===void 0&&($=k.length,k.push(j),p.set(j,$)),E.push($)}}b[r]=E.length,w={id:c.id,kind:h,nullable:g,values:Int32Array.from(E),presence:l,offsets:b,table:k};break}default:{const k=new Array(r);for(let p=0;p<r;p++){const b=d[p];b!==null&&m(p),k[p]=b}w={id:c.id,kind:"object",nullable:g,values:k,presence:l,offsets:null,table:null};break}}f.push(w)}return{count:r,columns:f}}function a(s){const n=[];if(!s||!Array.isArray(s.columns))return n;const t=r=>{ArrayBuffer.isView(r)&&r.buffer&&!n.includes(r.buffer)&&n.push(r.buffer)};for(const r of s.columns)t(r.values),t(r.presence),t(r.offsets);return n}}),xe("packages/core/src/source/stream.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return P}});const Q=G("packages/core/src/internal/util.js"),L=Q.Lru,B=Q.isFunction,F=Q.now,W=Q.nextFrame,X=Q.cancelFrame,H=Q.whenIdle,V=Q.defaultCompare,K=Q.warnOnce,D=Q.infoOnce,v=Q.getPath,O=G("packages/core/src/source/abort.js"),y=O.createAbortScope,u=O.isAbortError,a=G("packages/core/src/source/rows.js"),s=a.createRowFactory,n=a.lazyRowView,r=G("packages/core/src/source/gapbuffer.js").GapBuffer,f=G("packages/core/src/source/memory.js").createMemorySource,i=G("packages/core/src/source/filterwire.js").querySignature,d=G("packages/core/src/store/columnpack.js").isPortableSchema,h=25e4,l=Symbol("lattice.stream.storeBacked"),m=8,w=.1,k=1e3,p=50;function b(x){return Math.min(k,Math.max(p,Math.floor(x/4)))}function E(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const C=x.trim();if(!C)return NaN;const A=Date.parse(C);return Number.isNaN(A)?Number(C):A}return NaN}function T(x,C){return new P(x,C)}class P{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;#f=0;#h=0;#p=0;#m=0;#g=null;#y=null;#w=null;#k=!1;#b=!1;#O=!1;#j=!1;#P="";#S=0;#M=0;#A=0;#E=null;#R=1/0;#L=!1;#x=null;#I=null;#z=null;#$=null;#N=!1;#H=0;#B=0;#W=!1;constructor(C,A){this.#e=C||{mode:"stream"},this.#t=A||{},this.#s=s(this.#t),this.#l=new L(4096),this.#P=this.#Q();const j=(this.#t.config||{}).ingest;this.#N=!!j&&j.retainSource===!1,B(this.#e.open)||K("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.#$=setInterval(()=>{this.#j||this.reload()},$),this.#$&&B(this.#$.unref)&&this.#$.unref()),this.#re()}#ie(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#re(){const C=this.#ie();if(!C)return;const A=this.#e.ageBy;B(A)?this.#I=A:typeof A=="string"&&A?this.#I=j=>v(j,A):this.#I=null,this.#E=[],this.#x=setInterval(()=>{this.#j||this.#le()&&(this.#ce(),this.#fe())},b(C)),this.#x&&B(this.#x.unref)&&this.#x.unref()}#le(){const C=this.#ie();return!C||!this.#E?!1:this.#L?!0:this.#R<Date.now()-C*(1+w)}#ue(C,A){if(!this.#E)return;const j=this.#I?E(this.#I(A)):Date.now();this.#E[C]=j,Number.isNaN(j)||(j<this.#R&&(this.#R=j),j<Date.now()-this.#ie()&&(this.#L=!0))}#he(){return this.#ge("groupBy",[]).length>0?!0:!!this.#ge("pivotMode",!1)&&this.#ge("pivotBy",[]).length>0}#we(){if(this.#g||this.#j)return;const C=this.#he();if(C&&!this.#y){this.#y=f({mode:"memory",rows:this.#n},this.#pe()),this.#k=!1;return}!C&&this.#y&&(this.#y.destroy(),this.#y=null)}#pe(){if(this.#w)return this.#w;const C=this,A={liveIndices:()=>C.#be(),live:j=>C.#n[j]!==void 0,source:j=>C.#Ee(j),get physical(){return C.#n.length}};return this.#N&&(A.column=j=>{const $=C.#t.store;return $&&B($.column)?$.column(j):void 0}),this.#w=Object.create(this.#t,{store:{value:A,enumerable:!0,configurable:!0}}),this.#w}#be(){const C=new Uint32Array(this.#n.length);let A=0;for(let j=0;j<this.#n.length;j++)this.#n[j]!==void 0&&(C[A++]=j);return C.subarray(0,A)}#q(){return this.#g?this.#g:this.#y?(this.#k&&(this.#k=!1,this.#y.setRows(this.#n)),this.#y):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#we(),this.#y&&this.#y.invalidate(C),(C==="filter"||C==="sort")&&this.#T()}count(){const C=this.#q();return C?C.count():this.#r?this.#r.length:this.#S}matchCount(){const C=this.#q();return C&&B(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const C=this.#q();return C&&B(C.totalCount)?C.totalCount():this.#S}unfilteredRows(){const C=this.#q();if(C&&B(C.unfilteredRows))return C.unfilteredRows();const A=[];for(let j=0;j<this.#n.length;j++){if(!this.#n[j])continue;const $=this.#je(j);$&&A.push($)}return A}at(C){const A=this.#q();if(A)return A.at(C);if(C<0||C>=this.count())return;const j=this.#r?this.#r.at(C):C,$=this.#je(j);return $.index=C,$}byKey(C){const A=this.#q();if(A)return A.byKey(C);const j=this.#a.get(C);return j===void 0?void 0:this.#je(j)}leavesOf(C){const A=this.#q();return A&&B(A.leavesOf)?A.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,A){if(this.#g){this.#g.hint(C,A);return}this.#te(),this.#p=Math.max(0,Math.floor(C))}#te(){this.#j||this.#Q()===this.#P||this.reload()}display(){const C=this.#q();return C?C.display():n(()=>this.count(),A=>this.at(A))}apply(C){if(this.#g)return this.#g.apply(C);const A={added:[],updated:[],removed:[]};if(!C)return A;if(C.update){let j=!1;for(const $ of C.update){const z=this.#a.get(this.#s.keyOf($,-1));if(z===void 0)continue;const M=this.#Le(z);this.#N?this.#Xe(z,$):this.#n[z]=$,this.#l.delete(z),this.#Z(z,M),this.#E&&(this.#ue(z,$),j=!0),this.#k=!0,A.updated.push(this.#je(z))}j&&this.#ce()}if(C.add&&C.add.length){const j=this.#X(C.add);for(const $ of j)A.added.push(this.#je($))}return C.remove&&C.remove.length&&K("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#fe(),A}reload(C){this.#u.abortAll("reload"),this.#tt(),this.#y&&(this.#y.destroy(),this.#y=null),this.#k=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#M=0,this.#A=0,this.#E&&(this.#E=[]),this.#R=1/0,this.#L=!1,this.#b=!1,this.#O=!1,this.#c={loaded:0,estimated:void 0},this.#P=this.#Q(),this.#Ae("model:changed",{reason:"reload"}),this.start()}destroy(){this.#j=!0,this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#E=null,this.#u.abortAll("destroyed"),this.#tt(),this.#d!==null&&(this.#Ve(this.#d),this.#d=null),this.#y&&(this.#y.destroy(),this.#y=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#j||!B(this.#e.open))return;this.#O=!0;const C=this.#u.begin("stream");this.#T(),this.#we();let A;try{A=this.#e.open({sort:this.#ge("sort",[]),filters:this.#ge("filters",null),quick:this.#ge("quick","")||void 0,context:this.#ge("context",null),signal:C.signal})}catch($){this.#Ae("source:error",{error:$});return}const j=B(A[Symbol.asyncIterator])?A[Symbol.asyncIterator]():A[Symbol.iterator]();this.#z=j;try{for(;;){const $=await j.next();if(!C.current||this.#j)return;if($.done){this.#v();return}if(await this.#D($.value,C),!C.current||this.#j)return;if($.value&&$.value.done){this.#v();return}if(await this.#Oe(),!C.current||this.#j)return}}catch($){if(u($))return;this.#Ae("source:error",{error:$})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#b,live:this.#S,evicted:this.#M}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#q();C&&(B(C.invalidateHandles)&&C.invalidateHandles(),B(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#H,inline:this.#B,storeBacked:this.#N}}#D(C,A){if(!C)return;const j=C.rows;if(j&&j.length&&this.#_(j))return this.#ne(C,A);const $=F();j&&j.length&&(this.#X(j),this.#B++),this.#K(C),this.#h+=F()-$,this.#fe()}#K(C){this.#c.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#c.estimated=C.progress.estimated)}#_(C){if(this.#W||this.#g)return!1;const A=this.#oe();if(!A)return!1;const j=this.#t.store;if(!j||!B(j.appendPacked))return!1;const $=this.#me();return!$||!d($)?(this.#W=!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):C.length<A.threshold?!1:!this.#Pe(C)}#Pe(C){if(!this.#s.keyed)return!1;const A=new Set;for(let j=0;j<C.length;j++){const $=this.#s.keyOf(C[j],this.#n.length+j);if($!=null){if(A.has($)||this.#a.has($))return!0;A.add($)}}return!1}async#ne(C,A){const j=C.rows,$=this.#oe(),z=this.#me();let M;try{M=await $.columnize(z,j,{key:"ingest:stream",signal:A&&A.signal})}catch(Z){if(u(Z)||(K("source.stream.columnize","worker columnization failed; columnizing on the main thread",Z),this.#W=!0,A&&(!A.current||this.#j)))return;this.#X(j),this.#B++,this.#K(C),this.#fe();return}if(A&&(!A.current||this.#j))return;const R=this.#t.store,S=this.#N?void 0:j,{from:I}=R.appendPacked(M,S),q=M.count|0;for(let Z=0;Z<q;Z++){const _=I+Z,J=j[Z],ee=this.#s.keyed?this.#s.keyOf(J,_):null;if(this.#n[_]=this.#N?l:J,this.#S++,this.#ue(_,J),ee!==null&&this.#a.set(ee,_),!this.#r||!this.#U(_))continue;const te=this.#Y(_);this.#r.insert(te,_),te<=this.#p&&this.#m++}this.#k=!0,this.#ce(),this.#H++,this.#K(C),this.#fe()}#oe(){const C=this.#t.ingestWorker;return B(C)?C():null}#me(){const C=this.#t.storeSchema;return B(C)?C():null}#X(C){const A=[],j=this.#t.store,$=new Array(C.length),z=[],M=new Set;for(let S=0;S<C.length;S++){const I=this.#s.keyed?this.#s.keyOf(C[S],this.#n.length+z.length):null;$[S]=I,!(I!==null&&(this.#a.has(I)||M.has(I)))&&(I!==null&&M.add(I),z.push(C[S]))}let R=z.length&&j&&B(j.append)?j.append(z).from:this.#n.length;for(let S=0;S<C.length;S++){const I=C[S],q=$[S];if(q!==null&&this.#a.has(q)){const J=this.#a.get(q),ee=this.#Le(J);this.#N||(this.#n[J]=I,j&&B(j.setSource)&&j.setSource(J,I)),this.#Xe(J,I),this.#l.delete(J),this.#ue(J,I),this.#Z(J,ee);continue}const Z=R++;if(this.#n[Z]=this.#N?l:I,this.#S++,this.#ue(Z,I),q!==null&&this.#a.set(q,Z),A.push(Z),!this.#r||!this.#U(Z))continue;const _=this.#Y(Z);this.#r.insert(_,Z),_<=this.#p&&this.#m++}return this.#k=!0,this.#ce(),A}#ke(C){const A=this.#n[C];let j=!1;if(this.#r){const R=this.#G(C);R>=0&&R<=this.#p&&(j=!0)}else C<=this.#p&&(j=!0);const $=A===l?this.#Ee(C):A,z=this.#s.keyed?this.#s.keyOf($,C):null;z!==null&&this.#a.get(z)===C&&this.#a.delete(z),this.#n[C]=void 0,this.#E&&(this.#E[C]=NaN),this.#l.delete(C);const M=this.#t.store;return M&&B(M.remove)&&M.remove(C),this.#S--,j}#ce(){let C=0,A=0;const j=this.#Ce();C+=j.dropped,A+=j.aboveAnchor;const $=this.#se();C+=$.dropped,A+=$.aboveAnchor,C&&(this.#k=!0,this.#M+=C,this.#T(),this.#m-=A,this.#Ae("stream:evicted",{evicted:C,total:this.#M,live:this.#S}))}#se(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#S<=C)return{dropped:0,aboveAnchor:0};const A=Math.max(1,Math.floor(C*(1-w)));let j=0,$=0;for(;this.#S>A&&this.#A<this.#n.length;){const z=this.#A++;this.#n[z]!==void 0&&(this.#ke(z)&&$++,j++)}return{dropped:j,aboveAnchor:$}}#Ce(){const C=this.#ie();if(!C||!this.#E||!this.#le())return{dropped:0,aboveAnchor:0};const A=Date.now()-C;let j=0,$=0,z=1/0;for(let M=this.#A;M<this.#n.length;M++){if(this.#n[M]===void 0)continue;const R=this.#E[M];if(!(Number.isNaN(R)||R===void 0)){if(R>=A){R<z&&(z=R);continue}this.#ke(M)&&$++,j++}}for(this.#R=z,this.#L=!1;this.#A<this.#n.length&&this.#n[this.#A]===void 0;)this.#A++;return{dropped:j,aboveAnchor:$}}#G(C){if(!this.#r)return C;for(let A=0;A<this.#r.length;A++)if(this.#r.at(A)===C)return A;return-1}#T(){this.#o=this.#ge("sort",[]),this.#i=this.#ge("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#ie()>0,A=this.#ge("where",null),j=(this.#t.config||{}).hostFilter,$=!!(A&&A.active)||!!(j&&B(j.active)&&j.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#ge("quick","")||$)){this.#r=null;return}this.#r=new r(Math.max(64,this.#n.length+64));for(let M=0;M<this.#n.length;M++)this.#n[M]!==void 0&&this.#U(M)&&this.#r.insert(this.#Y(M),M)}#U(C){const A=this.#Ee(C);if(this.#i&&!this.#ae(this.#i,A))return!1;const j=String(this.#ge("quick","")||"").toLowerCase();if(j&&!this.#dt(A).includes(j))return!1;const $=(this.#t.config||{}).hostFilter;if($&&B($.active)&&$.active()&&!$.passes(this.#je(C)))return!1;const z=this.#ge("where",null);if(z&&z.active){const M=this.#je(C);if(!z.passes(M.data,M.key))return!1}return!0}#ae(C,A){if(!C)return!0;const j=C;if(Array.isArray(j.conditions))return j.op==="or"?j.conditions.some(M=>this.#ae(M,A)):j.op==="not"?!j.conditions.some(M=>this.#ae(M,A)):j.conditions.every(M=>this.#ae(M,A));const $=C,z=(this.#t.compute||{}).testValue;return B(z)?!!z(this.#De(A,$.col),$,(this.#t.config||{}).locale):(K("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Le(C){if(!this.#r)return-1;if(!this.#o.length)return this.#G(C);let A=0,j=this.#r.length;for(;A<j;){const $=A+j>>>1;this.#de(this.#r.at($),C)<0?A=$+1:j=$}for(let $=A;$<this.#r.length;$++){const z=this.#r.at($);if(z===C)return $;if(this.#de(z,C)>0)break}return this.#G(C)}#Z(C,A){if(!this.#r||!this.#o.length)return;const j=this.#U(C);if(A>=0&&this.#r.at(A)===C)this.#r.removeAt(A),A<=this.#p&&this.#m--;else if(A>=0)return;if(!j)return;const $=this.#Y(C);this.#r.insert($,C),$<=this.#p&&this.#m++}#Y(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let A=0,j=this.#r.length;for(;A<j;){const $=A+j>>>1;this.#de(C,this.#r.at($))<0?j=$:A=$+1}return A}#de(C,A){const j=this.#Ee(C),$=this.#Ee(A);for(const z of this.#o){const M=this.#_e(z.col),R=this.#De(j,z.col),S=this.#De($,z.col),q=(M&&M.value&&B(M.value.compare)?M.value.compare:V)(R,S);if(q!==0)return z.dir==="desc"?-q:q}return 0}#v(){this.#b=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:h;!this.#N&&this.#n.length<C&&(this.#g=f({mode:"memory",rows:this.#n},this.#t),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#y&&(this.#y.destroy(),this.#y=null)),this.#fe(),this.#Ae("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#fe(){this.#d!==null||this.#j||(this.#d=this.#We(()=>{this.#d=null,this.#f++;const C=this.#m;this.#m=0,this.#h=0,this.#Ae("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#f}),this.#Ae("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#Ae("rows:changed",{companion:!0,reason:"stream"})}))}#Oe(){return this.#f===0||this.#h<this.#Ie()?Promise.resolve():(this.#h=0,new Promise(C=>{const A=(this.#t.scheduler||{}).idle;B(A)?A(()=>C()):H(()=>C())}))}#Ie(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:m}#We(C){const A=this.#t.scheduler||{};return B(A.frame)?A.frame(C):W(C)}#Ve(C){const A=this.#t.scheduler||{};B(A.cancel)?A.cancel(C):X(C)}#Ee(C){const A=this.#n[C];if(A!==void 0&&A!==l)return A;if(A===void 0)return;const j=this.#t.store;return j&&B(j.source)?j.source(C):void 0}#Xe(C,A){const j=this.#t.store;if(!j||!B(j.set))return;const $=this.#me();if(Array.isArray($))for(const z of $){if(!z||!z.id)continue;const M=B(z.read)?z.read:R=>v(R,z.field||z.id);j.set(z.id,C,M(A))}}#je(C){let A=this.#l.get(C);return A||(A=this.#s.leaf(this.#Ee(C),C),this.#l.set(C,A)),A}#De(C,A){const j=this.#_e(A);return j&&B(j.getValue)?j.getValue(C):C?.[A]}#dt(C){const A=this.#t.columns,j=A&&B(A.all)?A.all():[],$=[];for(const z of j){const M=B(z.getValue)?z.getValue(C):void 0;M!=null&&M!==""&&$.push(String(M))}return $.join(" ").toLowerCase()}#_e(C){const A=this.#t.columns;return A&&B(A.get)?A.get(C):void 0}#tt(){const C=this.#z;if(this.#z=null,C&&B(C.return))try{C.return()}catch{}}#Q(){return i({context:this.#ge("context",null)})}#ge(C,A){const j=this.#t.state;if(j&&B(j[C])){const $=j[C]();return $??A}return A}#Ae(C,A){const j=this.#t.emit;B(j)&&j(C,A)}}}),xe("packages/core/src/source/url.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return v}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.isObject,F=Q.isFunction,W=Q.getPath,H=G("packages/core/src/source/abort.js").isAbortError,V=500,K=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),D=Symbol("lattice.url.skip");function v(d,h={}){const l=B(h)?h:{},m=F(l.fetch)?l.fetch:typeof globalThis<"u"&&F(globalThis.fetch)?globalThis.fetch:null,w=l.format==="json"||l.format==="ndjson"?l.format:void 0,k=typeof l.rowsPath=="string"&&l.rowsPath?l.rowsPath:void 0,p=F(l.map)?l.map:void 0,b=B(l.headers)?l.headers:void 0,E=Number.isFinite(l.batchSize)&&l.batchSize>0?Math.floor(l.batchSize):V,T=l.lenient===!0,P=Number.isFinite(l.poll)&&l.poll>0?Math.floor(l.poll):void 0,x=typeof d=="string"&&d.length>0;x||L("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(j={}){if(!x)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const $=j&&j.signal;let z;try{z=await m(d,b?{signal:$,headers:b}:{signal:$})}catch(S){throw H(S)?S:new Error(`[lattice] createUrlSource: request to ${d} failed — ${S&&S.message||S}`)}if(!z||!z.ok){const S=z?z.status:"no response";throw new Error(`[lattice] createUrlSource: ${S} for ${d}`)}const M=O(d,w,z),R=z.body&&F(z.body.getReader)?z.body.getReader():null;try{if(!R){const q=await z.text();(M||a(q,d))==="ndjson"?yield*f(null,null,q,0,z,d,E,T):yield*o(q,d,k,p);return}const S=new TextDecoder("utf-8");if(M==="json"){yield*o(await r(R,S,""),d,k,p);return}if(M==="ndjson"){yield*f(R,S,"",0,z,d,E,T);return}const I=await s(R,S,d);I.format==="json"?yield*o(await r(R,S,I.seed),d,k,p):yield*f(R,S,I.seed,I.bytes,z,d,E,T)}finally{if(R&&F(R.cancel))try{await R.cancel()}catch{}}}const A={mode:"stream",open:C,autoStart:l.autoStart!==!1};return P!==void 0&&(A.poll=P),Number.isFinite(l.maxRows)&&(A.maxRows=l.maxRows),Number.isFinite(l.maxAge)&&(A.maxAge=l.maxAge),(typeof l.ageBy=="string"||F(l.ageBy))&&(A.ageBy=l.ageBy),Number.isFinite(l.coalesceMs)&&(A.coalesceMs=l.coalesceMs),Number.isFinite(l.promoteToMemoryBelow)&&(A.promoteToMemoryBelow=l.promoteToMemoryBelow),A}function O(d,h,l){if(h)return h;const m=y(d);if(m)return m;const w=l&&l.headers&&F(l.headers.get)?l.headers.get("content-type"):null;return u(w)}function y(d){const h=String(d).split(/[?#]/)[0].toLowerCase();if(h.endsWith(".ndjson")||h.endsWith(".jsonl"))return"ndjson";if(h.endsWith(".json"))return"json"}function u(d){if(!d)return;const h=d.split(";")[0].trim().toLowerCase();if(K.has(h))return"ndjson";if(h==="application/json"||h==="text/json"||h.endsWith("+json"))return"json"}function a(d,h){const l=d.replace(/^\s+/,""),m=n(l);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${h} — pass opts.format: 'json' | 'ndjson'.`);return m}async function s(d,h,l){let m="",w=0;for(;;){const{value:p,done:b}=await d.read();if(p&&(w+=p.byteLength,m+=h.decode(p,{stream:!0})),b){m+=h.decode();break}const E=m.replace(/^\s+/,"");if(E){if(E[0]==="[")return{format:"json",seed:m,bytes:w};if(E[0]!=="{"||m.indexOf(`
|
|
8
8
|
`)!==-1)break}}const k=n(m.replace(/^\s+/,""));if(k==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${l} — pass opts.format: 'json' | 'ndjson'.`);return{format:k,seed:m,bytes:w}}function n(d){if(!d||d[0]==="[")return"json";if(d[0]!=="{")return"error";const h=d.indexOf(`
|
|
9
9
|
`);if(h===-1)return"json";let l=d.slice(0,h);return l.endsWith("\r")&&(l=l.slice(0,-1)),t(l)?"ndjson":"json"}function t(d){try{return JSON.parse(d),!0}catch{return!1}}async function r(d,h,l){let m=l;for(;;){const{value:w,done:k}=await d.read();if(w&&(m+=h.decode(w,{stream:!0})),k)break}return m+=h.decode(),m}function*o(d,h,l,m){let w;try{w=JSON.parse(d)}catch(p){throw new Error(`[lattice] createUrlSource: ${h} is not valid JSON — ${p.message}`)}let k=l!==void 0?W(w,l):w;if(m&&(k=m(k)),!Array.isArray(k)){const p=l!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${h} did not resolve to an array${p}.`)}yield{rows:k,progress:{loaded:k.length,estimated:k.length}}}async function*f(d,h,l,m,w,k,p,b){const E=g(w);let T=l||"",P=m||0,x=0,C=0,A=[];function*j(){let z;for(;(z=T.indexOf(`
|
|
@@ -54,6 +54,6 @@ ${ee}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
|
|
|
54
54
|
`,w),T=l.slice(b,E),P=T.split(`
|
|
55
55
|
`);let x=0;const C=P.map(A=>{if(!d)return x+=k.length,k+A;if(A.startsWith(k))return x-=k.length,A.slice(k.length);const j=A.replace(/^[ \t]/,"");return x-=A.length-j.length,j}).join(`
|
|
56
56
|
`);return C===T?!1:(h.value=l.slice(0,b)+C+l.slice(E),this.#r(Math.max(b,m+(d?-k.length:k.length)),Math.max(b,w+x)),this.revalidate(),!0)}#r(d,h){const l=this.input;l&&(l.selectionStart=d,l.selectionEnd=h===void 0?d:h,H(l.setSelectionRange)&&l.setSelectionRange(l.selectionStart,l.selectionEnd))}format(d){const h=this.input;if(!h||this.language!=="json")return!1;const l=s(h.value);if(!l.ok)return this.revalidate(),!1;if(l.value===null&&h.value.trim()==="")return!1;try{const m=JSON.stringify(l.value,null,d===void 0?this.indent:d);return m===void 0?!1:(h.value=m,this.#r(m.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const d=this.input?this.input.value:"",h=o(d,this.language);this.lastResult=h;const l=this.errorNode;return l&&(l.textContent=h.ok?"":f(h),l.classList.toggle(v.errorOn,!h.ok)),this.input&&(h.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),h.ok||!l?this.input.removeAttribute("aria-errormessage"):(l.id||(l.id=V("lat-err")),this.input.setAttribute("aria-errormessage",l.id))),h}text(){return this.input?this.input.value:""}readValue(){const d=this.text();if(d.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return d;const l=s(d);return l.ok?l.value:d}checkValue(d){if(this.props.allowInvalid===!0)return!0;const h=this.revalidate();return h.ok?!0:f(h)}toClipboard(){return this.text()}fromClipboard(d){const h=d==null?"":String(d);return this.input&&(this.input.value=h),this.revalidate(),h.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:h}:{ok:!0,value:D(h)}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const i=c}),xe("packages/dom/src/editors/unit.js",function(e,G){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,H=G("packages/core/src/internal/util.js").isFunction,V=G("packages/core/src/columns/types/unit.js"),K=V.parseUnit,D=V.formatUnit,v=V.findUnit;function O(a,s){return D(a,s)}class y extends L{input=null;hint=null;opts=null;#e=[];buildOptions(){const s=this.props,n=this.params.column&&this.params.column.dataType||null,t=n&&n.unitConfig||{};return{system:s.system||t.system||"data",unit:s.unit??t.unit,binary:s.binary===!0||s.binary===void 0&&t.binary===!0,display:s.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const s=this.props;this.opts=this.buildOptions();const n=this.symbol(),t=`${this.id}-unit`,r=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:s.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?t:null}});r.value=O(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const o=typeof s.step=="number"?s.step:0;return o>0&&this.#e.push(W(r,"keydown",f=>{f.key==="ArrowUp"?(H(f.preventDefault)&&f.preventDefault(),this.nudge(o)):f.key==="ArrowDown"&&(H(f.preventDefault)&&f.preventDefault(),this.nudge(-o))})),this.hint=F(this.doc,"span",{class:`${B.editor}__suffix`,text:n,attrs:{id:t,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${B.editor}__unit`,children:[r,this.hint]})}symbol(){const s=v(this.opts.system,this.opts.unit);return s?s.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const s=this.input;s&&!this.params.key&&this.props.selectOnFocus!==!1&&H(s.select)&&s.select()}nudge(s){const n=K(this.input?this.input.value:"",this.opts);let t=(n??0)+s;const{min:r,max:o}=this.props;typeof r=="number"&&t<r&&(t=r),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=O(t,this.opts))}readValue(){const s=this.input?this.input.value:"";if(String(s).trim()==="")return null;const n=K(s,this.opts);if(n===null)return NaN;if(this.mode()!=="clamp")return n;const{min:t,max:r}=this.props;let o=n;return typeof t=="number"&&o<t&&(o=t),typeof r=="number"&&o>r&&(o=r),o}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(s){if(s===null)return!0;if(typeof s!="number"||Number.isNaN(s)){const n=this.symbol();return n?`Enter a value such as 10 ${n}`:"Enter a value"}if(this.mode()==="reject"){const{min:n,max:t}=this.props;if(typeof n=="number"&&s<n)return`Must be ${this.describe(n)} or more`;if(typeof t=="number"&&s>t)return`Must be ${this.describe(t)} or less`}return!0}describe(s){return D(s,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return D(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(s){const n=s==null?"":String(s);if(n.trim()==="")return{ok:!0,value:null};const t=K(n,this.opts),r=t===null?NaN:t,o=this.checkValue(r);return o!==!0?{ok:!1,message:o}:{ok:!0,value:r}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const u=y}),xe("packages/dom/src/editors/radix.js",function(e,G){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,X=G("packages/core/src/internal/util.js"),H=X.isFunction,V=X.uid,K=G("packages/core/src/columns/types/radix.js"),D=K.compileRadixFormat,v=K.compileRadixParse,O=K.normaliseRadixOptions,y=K.radixRange,u=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),a=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),s=new Map;function n(f){const c=f||"";let i=s.get(c);if(i)return i;try{i=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0})}catch{i={format:g=>String(g)}}return s.set(c,i),i}function t(f,c){const i=c||{},g={};if(f){for(const h of a)f[h]!==void 0&&(g[h]=f[h]);const d=y(f.bitWidth??null,f.signed!==!1);typeof f.min=="number"&&f.min>d.min&&(g.min=f.min),typeof f.max=="number"&&f.max<d.max&&(g.max=f.max)}for(const d of a)i[d]!==void 0&&(g[d]=i[d]);return typeof i.min=="number"&&(g.min=i.min),typeof i.max=="number"&&(g.max=i.max),O(g)}class r extends L{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const c=this.params.column&&this.params.column.dataType;this.options=t(c&&c.radix||null,this.props),this.format=D(this.options),this.parse=v(this.options);const i=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});i.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(i.value=this.params.key),this.input=i;const g=F(this.doc,"span",{class:u.hint,attrs:{"aria-live":"polite"}});this.hint=g,this.#e.push(W(i,"input",()=>this.refresh())),this.#e.push(W(i,"keydown",h=>this.#n(h)));const d=F(this.doc,"div",{class:u.root,children:[i,g]});return this.refresh(),d}focusTarget(){return this.input}attached(){super.attached();const c=this.input;c&&!this.params.key&&this.props.selectOnFocus!==!1&&H(c.select)&&c.select()}#t(c){return c.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(c)}#n(c){const i=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;c.key==="ArrowUp"?(H(c.preventDefault)&&c.preventDefault(),this.nudge(i)):c.key==="ArrowDown"&&(H(c.preventDefault)&&c.preventDefault(),this.nudge(-i))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(c){const{min:i,max:g}=this.options;return c<i?i:c>g?g:c}evaluate(){const c=this.input?String(this.input.value):"";if(c.trim()==="")return{value:null,message:null};const i=this.parse(c);return i.ok?{value:this.mode()==="clamp"?this.clamp(i.value):i.value,message:null}:this.mode()==="clamp"&&typeof i.value=="number"&&(i.reason==="range"||i.reason==="negative")?{value:this.clamp(i.value),message:null}:{value:NaN,message:this.messageFor(i.reason)}}messageFor(c){const i=this.options;return c==="negative"?`This column holds an unsigned ${i.bitWidth}-bit pattern; enter ${this.format(0)} or more`:c==="range"?`Must be between ${this.format(i.min)} and ${this.format(i.max)}`:`Enter a ${i.name} value, e.g. ${this.format(i.radix===2?5:26)}`}refresh(){const{value:c,message:i}=this.evaluate();if(this.input&&this.input.classList&&(i?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",i?"true":"false"),i&&this.hint?(this.hint.id||(this.hint.id=V("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(i){this.hint.textContent=i,this.hint.classList&&this.hint.classList.add(u.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(u.hintInvalid),this.hint.textContent=c===null?"":`= ${n(this.params.locale).format(c)}`}}nudge(c){if(!this.input)return;const i=this.parse(this.input.value);let g;typeof i.value=="number"?g=i.value:typeof this.params.value=="number"?g=this.params.value:g=0,this.input.value=this.format(this.clamp(g+c)),this.refresh()}readValue(){return this.evaluate().value}checkValue(c){return c===null?!0:typeof c!="number"||Number.isNaN(c)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&c<0?this.messageFor("negative"):this.mode()==="reject"&&(c<this.options.min||c>this.options.max)?this.messageFor("range"):!0}toClipboard(){const c=this.readValue();return c===null||Number.isNaN(c)?this.input?String(this.input.value):"":this.format(c)}fromClipboard(c){const i=c==null?"":String(c);if(i.trim()==="")return{ok:!0,value:null};const g=this.parse(i);let d;if(g.ok)d=g.value;else if(this.mode()==="clamp"&&typeof g.value=="number"&&(g.reason==="range"||g.reason==="negative"))d=this.clamp(g.value);else return{ok:!1,message:this.messageFor(g.reason)};const h=this.checkValue(d);return h!==!0?{ok:!1,message:h}:{ok:!0,value:d}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const o=r}),xe("packages/dom/src/editors/segmented.js",function(e,G){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,X=Q.keyOf,H=Q.normaliseLookup,V=Q.documentFor,K=Q.lookupFor,v=G("packages/dom/src/editors/select.js").SelectEditor,y=G("packages/core/src/internal/util.js").isFunction,a=G("packages/dom/src/cell/icons.js").createIcon,s=6;class n extends L{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(f){const c=f||{},i=t(c),g=K(c,i,{colId:c.column&&(c.column.id||c.column.field)}),d=Number(i.max??s),h=g.options().length;if(Number.isFinite(d)&&h>d){const l=new v;l.init(c),this.#e=l,this.params=c,this.doc=V(c),this.props=i,this.lookup=g,this.popup=l.popup;return}super.init(c),(!this.lookup||!this.lookup.options().length)&&(this.lookup=g)}usesFallback(){return this.#e!==null}build(){const f=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const c=F(f,"div",{class:`${B.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let i=0;i<this.options.length;i++)c.appendChild(this.buildSegment(this.options[i],i));return this.props.allowClear===!0&&c.appendChild(this.buildClear()),this.#t.push(W(c,"keydown",i=>this.onKeyDown(i))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),c}buildSegment(f,c){const i=this.doc,g=F(i,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":c,"data-variant":f.variant??null,"aria-disabled":f.disabled===!0?"true":null}});return f.icon&&g.appendChild(a(i,f.icon,{className:B.icon})),g.appendChild(F(i,"span",{class:`${B.editor}__segment-label`,text:f.label})),this.#t.push(W(g,"mousedown",d=>{d&&y(d.preventDefault)&&d.preventDefault(),f.disabled!==!0&&(this.focused=c,this.select(c,{commit:!0}))})),this.segments.push(g),g}buildClear(){const f=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(f,"mousedown",c=>{c&&y(c.preventDefault)&&c.preventDefault(),this.clearSelection()})),f}indexOf(f){if(f==null)return-1;const c=X(f);for(let i=0;i<this.options.length;i++)if(X(this.options[i].id)===c)return i;return-1}paint(){for(let f=0;f<this.segments.length;f++){const c=f===this.indexOf(this.selected),i=this.segments[f];i.setAttribute("aria-checked",c?"true":"false"),i.setAttribute("tabindex",f===this.focused?"0":"-1"),i.classList.toggle(`${B.editor}__segment--active`,c),i.classList.toggle(`${B.editor}__segment--disabled`,this.options[f].disabled===!0)}}select(f,c){const i=this.options[f];!i||i.disabled===!0||(this.selected=i.id,this.paint(),c&&c.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(f){const c=this.segments.length;if(!c)return;let i=this.focused;for(let g=0;g<c;g++)if(i=(i+f+c)%c,this.options[i].disabled!==!0){this.focusAt(i);return}}focusAt(f){if(f<0||f>=this.segments.length)return;this.focused=f,this.paint();const c=this.segments[f];c&&y(c.focus)&&c.focus()}edgeIndex(f){const c=this.options.length;for(let i=0;i<c;i++){const g=f===1?i:c-1-i;if(this.options[g].disabled!==!0)return g}return-1}onKeyDown(f){const c=()=>{y(f.preventDefault)&&f.preventDefault()};switch(f.key){case"ArrowRight":case"ArrowDown":c(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":c(),this.moveFocus(-1);break;case"Home":c(),this.focusAt(this.edgeIndex(1));break;case"End":c(),this.focusAt(this.edgeIndex(-1));break;case"Enter":c(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":c(),this.select(this.focused);break;case"Escape":c(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(c(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(f)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(f)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const f=this.indexOf(this.selected);return this.segments[f>=0?f:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const f=this.lookup.ready();!f||!y(f.then)||f.then(()=>{if(!super.element()||this.options.length)return;const c=super.element();this.options=this.lookup.options();for(let i=0;i<this.options.length;i++)c.appendChild(this.buildSegment(this.options[i],i));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(f){return this.#e?this.#e.validate(f):super.validate(f)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(f){return this.#e?this.#e.fromClipboard(f):super.fromClipboard(f)}destroy(){for(const f of this.#t)f();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(o){return{...o.column&&o.column.edit&&o.column.edit.props||{},...o.props||{}}}const r=n}),xe("packages/dom/src/editors/rating.js",function(e,G){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,H=G("packages/dom/src/cell/icons.js").createIcon,V=G("packages/dom/src/cell/renderers/rating.js"),K=V.ratingFills,D=V.fillState,v=V.ratingText,O=V.clampRating,y=V.DEFAULT_RATING_ICON,u=V.DEFAULT_RATING_MAX,s=G("packages/core/src/internal/util.js").isFunction;class n extends L{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const f=Math.floor(Number(this.props.max??u));return Number.isFinite(f)&&f>0?f:u}step(){return this.props.allowHalf===!0?.5:1}build(){const f=this.doc,c=this.max();this.rating=t(this.params.value,c,this.props.allowHalf===!0);const i=F(f,"div",{class:`${B.editor}__rating`}),g=F(f,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(c),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let h=0;h<c;h++)g.appendChild(this.buildItem(h));i.appendChild(g),this.slider=g;const d=F(f,"span",{class:`${B.editor}__rating-value`});return i.appendChild(d),this.readout=d,this.props.allowClear===!0&&i.appendChild(this.buildClear()),this.#e.push(W(g,"keydown",h=>this.onKeyDown(h))),this.props.hoverPreview!==!1&&this.#e.push(W(g,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),c)),this.paint(),i}buildItem(f){const c=this.doc,i=String(this.props.icon??y),g=F(c,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[H(c,i,{className:B.icon})]}),d=F(c,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":f,"data-icon":i,"aria-hidden":"true"},children:[H(c,i,{className:B.icon}),g]});return this.fills.push(g),this.#e.push(W(d,"mousedown",h=>{h&&s(h.preventDefault)&&h.preventDefault(),this.setRating(this.ratingAt(f,h),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(d,"mousemove",h=>{const l=this.ratingAt(f,h);l!==this.preview&&(this.preview=l,this.paint())})),this.items.push(d),d}buildClear(){const f=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(f,"mousedown",c=>{c&&s(c.preventDefault)&&c.preventDefault(),this.setRating(null)})),f}ratingAt(f,c){if(this.props.allowHalf!==!0)return f+1;const i=this.items[f],g=i&&Number(i.offsetWidth),d=c&&Number(c.offsetX);return!Number.isFinite(g)||g<=0||!Number.isFinite(d)?f+1:d*2<g?f+.5:f+1}focusTarget(){return this.slider}setRating(f,c){this.rating=f===null?null:O(f,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),c&&c.commit&&this.commit()}nudge(f){const c=this.rating===null?0:this.rating;this.setRating(c+f)}paint(){const f=this.max(),c=this.props.allowHalf===!0,i=this.preview===null?this.rating:this.preview,g=K(i===null?0:i,f,{allowHalf:c});for(let l=0;l<this.items.length;l++){const m=D(g[l]);this.items[l].setAttribute("data-fill",m),this.items[l].classList.toggle(`${B.editor}__rating-item--filled`,m!=="empty"),this.fills[l]&&this.fills[l].style.setProperty("--lat-rating-fill",`${(g[l]*100).toFixed(2)}%`)}const d=i===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:v(i),max:f}),h=this.slider;h&&(h.setAttribute("aria-valuenow",i===null?"0":String(i)),h.setAttribute("aria-valuetext",d),h.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=d)}onKeyDown(f){const c=()=>{s(f.preventDefault)&&f.preventDefault()},i=this.step();if(/^[0-9]$/.test(f.key)){c(),this.setRating(Math.min(Number(f.key),this.max()));return}switch(f.key){case"ArrowRight":case"ArrowUp":c(),this.nudge(i);break;case"ArrowLeft":case"ArrowDown":c(),this.nudge(-i);break;case"Home":c(),this.setRating(0);break;case"End":c(),this.setRating(this.max());break;case"Enter":c(),this.commit();break;case"Escape":c(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(c(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(f){if(f==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof f!="number"||!Number.isFinite(f))return"Enter a rating";const c=this.max();return f<0?"Must be 0 or more":f>c?`Must be ${c} or less`:this.props.allowHalf!==!0&&!Number.isInteger(f)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":v(this.rating)}fromClipboard(f){const c=String(f??"").trim();if(c==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const i=Number(c);if(!Number.isFinite(i))return{ok:!1,message:`"${c}" is not a rating`};const g=this.checkValue(i);return g!==!0?{ok:!1,message:g}:{ok:!0,value:i}}destroy(){for(const f of this.#e)f();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(o,f,c){if(o==null||o==="")return null;const i=Number(o);return Number.isFinite(i)?O(i,f,c,!1):null}const r=n}),xe("packages/dom/src/editors/slider.js",function(e,G){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,X=G("packages/dom/src/editors/number.js"),H=X.parseNumberText,V=X.presentNumber,D=G("packages/core/src/internal/util.js").isFunction,v=0,O=100;class y extends L{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const r=Number(this.props.min??v);return Number.isFinite(r)?r:v}max(){const r=Number(this.props.max??O);return Number.isFinite(r)?r:O}step(){const r=Number(this.props.step??1);return Number.isFinite(r)&&r>0?r:1}build(){const r=this.doc,o=this.min(),f=this.max(),c=this.step(),i=s(this.props.marks);this.marks=i,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const g=F(r,"div",{class:`${B.editor}__slider`});this.root=g;const d=F(r,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(o),max:String(f),step:String(c),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:i.length?`${this.id}-marks`:null}});if(this.range=d,g.appendChild(d),i.length){const l=F(r,"datalist",{attrs:{id:`${this.id}-marks`}}),m=F(r,"div",{class:`${B.editor}__slider-marks`});for(const w of i){l.appendChild(F(r,"option",{attrs:{value:String(w.value),label:w.label}}));const k=F(r,"span",{class:`${B.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});k.style&&D(k.style.setProperty)&&k.style.setProperty("--lat-slider-mark",`${(u(w.value,o,f)*100).toFixed(2)}%`),m.appendChild(k)}g.appendChild(l),g.appendChild(m)}const h=F(r,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=h,g.appendChild(h),this.props.showValue!==!1){const l=F(r,"span",{class:`${B.editor}__slider-value`});g.appendChild(l),this.readout=l}return this.#e.push(W(d,"input",()=>this.setAmount(Number(d.value),"range"))),this.#e.push(W(d,"change",()=>this.setAmount(Number(d.value),"range"))),this.#e.push(W(d,"keydown",l=>this.onKeyDown(l))),this.#e.push(W(h,"input",()=>this.onFieldInput())),this.#e.push(W(h,"change",()=>this.paint())),this.#e.push(W(h,"keydown",l=>this.onKeyDown(l))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(h.value=this.params.key,this.onFieldInput()),this.paint(),g}focusTarget(){return this.field}attached(){super.attached();const r=this.field;r&&!this.params.key&&this.props.selectOnFocus!==!1&&D(r.select)&&r.select()}snap(r){if(!Number.isFinite(r))return this.min();const o=this.min(),f=this.max(),c=this.step(),i=Math.min(Math.max(r,o),f),g=o+Math.round((i-o)/c)*c,d=a(c),h=d>0?Number(g.toFixed(d)):Math.round(g);return Math.min(Math.max(h,o),f)}setAmount(r,o){this.amount=r===null?null:this.snap(r),this.paint(o)}onFieldInput(){const r=this.field?String(this.field.value):"";if(r.trim()===""){this.amount=null,this.paint("field");return}const o=H(r,this.params.locale);if(o===null||Number.isNaN(o)){this.paint("field");return}this.setAmount(o,"field")}paint(r){const o=this.min(),f=this.max(),c=this.amount,i=c===null?o:c;this.range&&r!=="range"&&(this.range.value=String(i)),this.field&&r!=="field"&&(this.field.value=c===null?"":V(c,this.props));const g=this.root;g&&g.style&&D(g.style.setProperty)&&g.style.setProperty("--lat-slider-pos",`${(u(i,o,f)*100).toFixed(2)}%`),g&&g.setAttribute&&g.setAttribute("data-empty",c===null?"true":"false");const d=this.labelFor(c);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",d),this.readout&&(this.readout.textContent=d)}labelFor(r){if(r===null)return String(this.props.emptyLabel??"");const o=this.marks.find(c=>c.value===r),f=V(r,this.props);return o&&o.label!==f?`${f} (${o.label})`:f}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.field?String(this.field.value):"";if(r.trim()==="")return null;const o=H(r,this.params.locale);return o===null||Number.isNaN(o)?NaN:this.snap(o)}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof r!="number"||Number.isNaN(r)?"Enter a number":r<this.min()?`Must be ${this.min()} or more`:r>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(r){const o=String(r??"").trim();if(o==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const f=H(o,this.params.locale);if(f===null||Number.isNaN(f))return{ok:!1,message:"Enter a number"};const c=this.snap(f),i=this.checkValue(c);return i!==!0?{ok:!1,message:i}:{ok:!0,value:c}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function u(t,r,o){const f=o-r;return!Number.isFinite(f)||f===0?0:Math.min(1,Math.max(0,(Number(t)-r)/f))}function a(t){if(!Number.isFinite(t))return 0;const r=String(t),o=r.indexOf("e");if(o>=0){const c=r.slice(0,o),i=c.indexOf("."),g=i<0?0:c.length-i-1;return Math.min(15,Math.max(0,g-Number(r.slice(o+1))))}const f=r.indexOf(".");return f<0?0:Math.min(15,r.length-f-1)}function s(t){if(!t)return[];const r=[];if(Array.isArray(t)){for(const o of t){if(o&&typeof o=="object"){const c=Number(o.value);Number.isFinite(c)&&r.push({value:c,label:String(o.label??c)});continue}const f=Number(o);Number.isFinite(f)&&r.push({value:f,label:String(f)})}return r}if(typeof t=="object")for(const[o,f]of Object.entries(t)){const c=Number(o);Number.isFinite(c)&&r.push({value:c,label:String(f)})}return r}const n=y}),xe("packages/dom/src/editors/colour.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,X=G("packages/dom/src/cell/renderers/colour.js"),H=X.normaliseColour,V=X.parseColour,D=G("packages/core/src/internal/util.js").isFunction,v=Object.freeze(["neutral","info","success","warning","danger","accent"]),O=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(r){if(r==null)return null;if(typeof r=="object"){const c=r,i=y(c.token??c.value??c.colour??c.color);return i?{...i,label:c.label==null?i.label:String(c.label)}:null}const o=String(r).trim();if(o==="")return null;const f=H(o);return f?{token:null,hex:f,label:f}:Object.hasOwn(O,o)?{token:o,hex:O[o],label:o}:null}function u(r,o){const f=r&&r.ownerDocument,c=f&&f.defaultView;if(!c||!D(c.getComputedStyle))return null;try{const i=c.getComputedStyle(r);return!i||!D(i.getPropertyValue)?null:H(String(i.getPropertyValue(`--lattice-variant-${o}-solid`)).trim())}catch{return null}}class a extends L{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const o=this.doc;this.swatches=s(this.props.swatches);const f=F(o,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=F(o,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),f.appendChild(this.preview),this.swatches.length){const i=F(o,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let g=0;g<this.swatches.length;g++)i.appendChild(this.buildSwatch(this.swatches[g],g));f.appendChild(i)}this.native=F(o,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),f.appendChild(this.native),this.hex=F(o,"input",{class:`${B.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),f.appendChild(this.hex),this.props.allowClear===!0&&f.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",i=>this.onKeyDown(i))),this.#e.push(W(f,"keydown",i=>this.onKeyDown(i)));const c=H(this.params.value,{alpha:this.alpha()});return this.hex.value=c===null?this.params.value==null?"":String(this.params.value):c,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),f}buildSwatch(o,f){const c=F(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":o.label,"data-index":f,"data-variant":o.token}});return o.token||n(c,o.hex),this.#e.push(W(c,"mousedown",i=>{i&&D(i.preventDefault)&&i.preventDefault(),this.setColour(this.swatches[f].hex)})),this.buttons.push(c),c}buildClear(){const o=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(o,"mousedown",f=>{f&&D(f.preventDefault)&&f.preventDefault(),this.setColour(null)})),o}focusTarget(){return this.hex}attached(){super.attached();for(let o=0;o<this.swatches.length;o++){const f=this.swatches[o];if(!f.token)continue;const c=u(this.buttons[o]||this.element(),f.token);c&&(f.hex=c)}this.paint()}setColour(o){const f=o===null?null:H(o,{alpha:this.alpha()});this.hex&&(this.hex.value=f===null?"":f),this.paint()}current(){const o=this.hex?String(this.hex.value).trim():"";return o===""?null:H(o,{alpha:this.alpha()})}paint(){const o=this.current(),f=o===null?null:o.slice(0,7);n(this.preview,f),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",o===null?"true":"false"),this.native&&(this.native.value=f===null?"#000000":f);for(let c=0;c<this.buttons.length;c++){const i=o!==null&&this.swatches[c].hex.toLowerCase()===o.toLowerCase();this.buttons[c].setAttribute("aria-checked",i?"true":"false"),this.buttons[c].classList.toggle(`${B.editor}__colour-swatch--selected`,i),this.swatches[c].token||n(this.buttons[c],this.swatches[c].hex)}}onKeyDown(o){if(o.key==="Escape"){D(o.preventDefault)&&o.preventDefault(),this.cancel();return}if(o.key==="Enter"){D(o.preventDefault)&&o.preventDefault(),this.commit();return}o.key==="Tab"&&this.commit()}readValue(){const o=this.hex?String(this.hex.value).trim():"";if(o==="")return null;const f=H(o,{alpha:this.alpha()});return f===null?o:f}checkValue(o){if(o==null||o==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const f=V(o);return f?!this.alpha()&&f.a<1?"This column does not accept transparency":!0:`"${String(o)}" is not a colour`}toClipboard(){const o=this.current();return o===null?"":o}fromClipboard(o){const f=String(o??"").trim();if(f==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const c=H(f,{alpha:this.alpha()});if(c===null)return{ok:!1,message:`"${f}" is not a colour`};const i=this.checkValue(c);return i!==!0?{ok:!1,message:i}:{ok:!0,value:c}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function s(r){const o=Array.isArray(r)&&r.length?r:r===!1?[]:v,f=[];for(const c of o){const i=y(c);i&&f.push(i)}return f}function n(r,o){const f=r&&r.style;if(f){if(o===null){D(f.removeProperty)&&f.removeProperty("--lat-swatch");return}D(f.setProperty)&&f.setProperty("--lat-swatch",o)}}const t=a}),xe("packages/dom/src/editors/treeselect.js",function(e,G){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const L=G("packages/dom/src/editors/select.js").SelectEditorBase,F=G("packages/dom/src/cell/icons.js").createIcon,W=G("packages/dom/src/editors/common.js"),X=W.CLS,H=W.el,V=W.on,K=W.clear,D=W.keyOf,v=W.rawOptions,O=W.lookupKey,y=G("packages/core/src/internal/util.js"),u=y.isFunction,a=y.isObject,s="\0";class n extends L{static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const o=super.build();return o.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),o}initSelection(){this.rebuild(),this.selected=this.params.value??null;const o=this.nodeById(this.selected);if(o)for(let f=o.parent;f;f=f.parent)this.expanded.add(f.key)}rebuild(){const o=v(this.params,this.props),f=this.props.keys||{},c=f.value||O(this.params,"valueKey")||"id",i=f.label||O(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const g of o){if(!a(g)){this.addNode(null,String(g??""),g,null);continue}Array.isArray(g.path)&&g.path.length?this.addByPath(g,c,i):this.addByChildren(g,null,c,i)}if(this.props.defaultExpanded===!0)for(const g of this.nodes.keys())this.expanded.add(g)}addNode(o,f,c,i){const g=o?`${o.key}${s}${f}`:f;let d=this.nodes.get(g);return d?d.id===void 0&&c!==void 0&&(d.id=c):(d={id:c,label:f,key:g,parent:o,children:[],depth:o?o.depth+1:0,disabled:!1},this.nodes.set(g,d),(o?o.children:this.roots).push(d)),i&&(i.disabled===!0&&(d.disabled=!0),i.icon!==void 0&&(d.icon=i.icon),i.variant!==void 0&&(d.variant=i.variant)),d}addByPath(o,f,c){const i=o.path;let g=null;for(let d=0;d<i.length;d++){const h=d===i.length-1,l=String(i[d]),m=h&&o[c]!=null?String(o[c]):l,w=this.addNode(g,l,h?o[f]:void 0,h?o:null);h&&(w.label=m),g=w}}addByChildren(o,f,c,i){const g=o[c],d=o[i]!=null?String(o[i]):String(g??""),h=this.addNode(f,d,g,o),l=Array.isArray(o.children)?o.children:[];for(const m of l)a(m)?this.addByChildren(m,h,c,i):this.addNode(h,String(m??""),m,null)}nodeById(o){if(o==null)return;const f=D(o);for(const c of this.nodes.values())if(c.id!==void 0&&D(c.id)===f)return c}filterOptions(o){const f=String(o||"").trim().toLowerCase(),c=f!=="";this.matched=c?this.computeMatches(f):new Set;const i=[],g=d=>{for(const h of d)c&&!this.matched.has(h.key)||(i.push(h),h.children.length&&(c||this.expanded.has(h.key))&&g(h.children))};return g(this.roots),i}computeMatches(o){const f=new Set,c=i=>{let g=i.label.toLowerCase().includes(o);for(const d of i.children)c(d)&&(g=!0);return g&&f.add(i.key),g};for(const i of this.roots)c(i);return f}repaint(o){if(this.refreshOptions(),!o||!this.list)return;const f=this.visible.findIndex(c=>c.key===o);f>=0&&this.list.setActive(f)}isBranch(o){return!!o&&o.children.length>0}isSelectable(o){return!o||o.disabled||o.id===void 0||o.id===null?!1:!(this.leavesOnly&&this.isBranch(o))}setExpanded(o,f){this.isBranch(o)&&(f?this.expanded.add(o.key):this.expanded.delete(o.key),this.repaint(o.key))}choose(o){if(o){if(!this.isSelectable(o)){this.isBranch(o)&&this.setExpanded(o,!this.expanded.has(o.key));return}this.selected=o.id,this.input&&(this.input.value=""),this.query="",this.repaint(o.key),this.paintDisplay(),this.commit()}}isSelected(o){return this.selected!=null&&o&&o.id!==void 0&&D(o.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(o){if(o==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const f=this.nodeById(o);return f&&this.isSelectable(f)?!0:f?`"${f.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(o)}" is not a valid option`}renderOption(o,f,c){K(f),f.setAttribute("role","treeitem"),f.setAttribute("aria-level",String(o.depth+1)),f.setAttribute("data-depth",String(o.depth));const i=H(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<o.depth;w++)i.appendChild(H(this.doc,"span",{class:"lat-tree__guide"}));f.appendChild(i);const g=this.isBranch(o),d=g&&(this.expanded.has(o.key)||this.query.trim()!==""),h=g?d?"chevronDown":"chevronRight":"blank",l=H(this.doc,"span",{class:g?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[F(this.doc,h,{className:X.icon})],attrs:{"data-icon":g?h:null,"aria-hidden":"true"}});g&&V(l,"mousedown",w=>{u(w.preventDefault)&&w.preventDefault(),u(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(o,!this.expanded.has(o.key))}),f.appendChild(l),o.icon&&f.appendChild(F(this.doc,o.icon,{className:X.icon})),f.appendChild(H(this.doc,"span",{class:`${X.option}__label`,text:o.label})),o.variant?f.setAttribute("data-variant",o.variant):f.removeAttribute("data-variant"),g?f.setAttribute("aria-expanded",d?"true":"false"):f.removeAttribute("aria-expanded");const m=this.isSelected(o);f.classList.toggle(X.optionSelected,m),f.classList.toggle(X.optionDisabled,!this.isSelectable(o)),f.classList.toggle("lat-tree__row--branch",g),f.setAttribute("aria-selected",m?"true":"false"),this.isSelectable(o)?f.removeAttribute("aria-disabled"):f.setAttribute("aria-disabled","true")}paintDisplay(){const o=this.display;if(!o)return;if(K(o),this.selected==null){o.removeAttribute("data-variant");return}const f=this.nodeById(this.selected);if(!f){o.appendChild(H(this.doc,"span",{text:String(this.selected)}));return}f.icon&&o.appendChild(F(this.doc,f.icon,{className:X.icon})),o.appendChild(H(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(f)})),f.variant?o.setAttribute("data-variant",f.variant):o.removeAttribute("data-variant")}pathLabel(o){const f=[];for(let c=o;c;c=c.parent)f.unshift(c.label);return f.join(String(this.props.pathSeparator??" / "))}onKeyDown(o){const f=this.list,c=f&&f.active>=0?this.visible[f.active]:null;switch(o.key){case"ArrowRight":{if(u(o.preventDefault)&&o.preventDefault(),!c)return;this.isBranch(c)&&!this.expanded.has(c.key)?this.setExpanded(c,!0):this.isBranch(c)&&f&&f.setActive(Math.min(this.visible.length-1,f.active+1));return}case"ArrowLeft":{if(u(o.preventDefault)&&o.preventDefault(),!c)return;this.isBranch(c)&&this.expanded.has(c.key)?this.setExpanded(c,!1):c.parent&&this.focusNode(c.parent.key);return}case"Home":u(o.preventDefault)&&o.preventDefault(),f&&this.visible.length&&f.setActive(0);return;case"End":u(o.preventDefault)&&o.preventDefault(),f&&this.visible.length&&f.setActive(this.visible.length-1);return;default:super.onKeyDown(o)}}focusNode(o){if(!this.list)return;const f=this.visible.findIndex(c=>c.key===o);f>=0&&this.list.setActive(f)}acceptHighlight(o){const f=this.list,c=f&&f.active>=0?this.visible[f.active]:null;if(!c){o&&o.commit&&this.commit();return}if(this.isSelectable(c)){this.choose(c);return}this.isBranch(c)?this.setExpanded(c,!this.expanded.has(c.key)):o&&o.commit&&this.commit()}moveHighlight(o){const f=this.list;if(!f)return;let c=f.active;for(let i=0;i<this.visible.length;i++){if(c+=o,c<0||c>=this.visible.length)return;if(!this.visible[c].disabled){f.setActive(c);return}}}}const t=n}),xe("packages/dom/src/editors/objectpicker.js",function(e,G){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const L=G("packages/dom/src/editors/select.js").SelectEditorBase,B=G("packages/dom/src/editors/common.js"),F=B.CLS,W=B.el,X=B.on,H=B.clear,V=B.keyOf,K=B.debounce,D=B.rawOptions,v=B.optionSource,O=B.lookupSearch,y=B.lookupKey,u=G("packages/core/src/internal/util.js"),a=u.isFunction,s=u.isObject,n=u.getPath,r=G("packages/dom/src/cell/icons.js").createIcon;class o extends L{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const h=super.build();if(h.classList.add("lat-objectpicker"),a(this.props.search)&&!(this.lookup&&this.lookup.search)){const l=Number(this.props.searchDebounce)||200;this.#n=K(m=>this.runRemoteSearch(String(m)),l)}return h}onQuery(h){super.onQuery(h),this.#n&&this.#n(h)}initSelection(){const h=D(this.params,this.props).map(l=>this.toOption(l));(h.length||!this.all.length)&&(this.all=h),this.selected=this.params.value??null}toOption(h){if(!s(h)){const b=h==null?"":String(h);return{id:h,label:b,secondary:"",avatar:"",initials:c(b),disabled:!1,raw:{}}}const l=this.props.valueKey||y(this.params,"valueKey")||"id",m=this.props.labelKey||y(this.params,"labelKey")||"label",w=f(h,this.props.template??m,""),k=f(h,this.props.secondary,""),p=f(h,this.props.avatar,"");return{id:h[l],label:w||String(h[l]??""),secondary:k,avatar:p,initials:c(w||String(h[l]??"")),disabled:h.disabled===!0,icon:h.icon,variant:h.variant,raw:h}}attached(){if(super.attached(),this.#t||this.all.length)return;const h=v(this.params,this.props);a(h)&&(this.#t=!0,Promise.resolve(h()).then(l=>{!this.element()||!Array.isArray(l)||(this.all=l.map(m=>this.toOption(m)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(h){const l=String(h||"").trim().toLowerCase();if(l==="")return this.all;const m=i(this.props.searchFields);return this.all.filter(w=>{if(!m)return w.label.toLowerCase().includes(l)||w.secondary.toLowerCase().includes(l);for(const k of m){const p=a(k)?k(w.raw):n(w.raw,k);if(p!=null&&String(p).toLowerCase().includes(l))return!0}return!1})}async runRemoteSearch(h){const l=O(this.params,this.props);if(!l)return;this.#e&&this.#e.abort();const m=new AbortController;this.#e=m;try{const w=await l(h,m.signal);if(m.signal.aborted||this.#e!==m)return;this.refreshOptions(Array.isArray(w)?w.map(k=>this.toOption(k)):[])}catch(w){if(!m.signal.aborted)throw w}finally{this.#e===m&&(this.#e=null)}}choose(h){!h||h.disabled||(this.selected=h.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(h){return this.selected!=null&&h!=null&&V(h.id)===V(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(h){if(h==null)return;const l=V(h);return this.all.find(m=>V(m.id)===l)}checkValue(h){return h==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(h)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(h)}" is not a valid option`}renderOption(h,l,m){H(l),l.appendChild(this.buildAvatar(h));const w=W(this.doc,"span",{class:"lat-object__text"});w.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:h.label})),h.secondary&&w.appendChild(W(this.doc,"span",{class:"lat-object__secondary",text:h.secondary})),l.appendChild(w),h.icon&&l.appendChild(r(this.doc,h.icon,{className:F.icon})),h.variant?l.setAttribute("data-variant",h.variant):l.removeAttribute("data-variant");const k=this.isSelected(h);l.classList.add("lat-object__row"),l.classList.toggle(F.optionSelected,k),l.classList.toggle(F.optionDisabled,h.disabled===!0),l.setAttribute("aria-selected",k?"true":"false"),h.disabled?l.setAttribute("aria-disabled","true"):l.removeAttribute("aria-disabled")}buildAvatar(h){const l=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!h.avatar)return l.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),l.setAttribute("data-fallback","initials"),l;const m=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:h.avatar,alt:"",loading:"lazy",decoding:"async"}});return X(m,"error",()=>{m.parentNode===l&&(l.removeChild(m),l.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),l.setAttribute("data-fallback","initials"))}),l.appendChild(m),l}paintDisplay(){const h=this.display;if(!h)return;if(H(h),this.selected==null){h.removeAttribute("data-variant");return}const l=this.optionById(this.selected);if(!l){h.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}h.appendChild(this.buildAvatar(l)),h.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:l.label})),l.variant?h.setAttribute("data-variant",l.variant):h.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function f(d,h,l){if(h==null)return l;const m=a(h)?h(d):n(d,String(h));return m==null?l:String(m)}function c(d){const h=String(d||"").trim().split(/\s+/).filter(w=>w!=="");if(!h.length)return"";const l=[...h[0]][0]||"";if(h.length===1)return l.toUpperCase();const m=[...h[h.length-1]][0]||"";return(l+m).toUpperCase()}function i(d){if(d==null)return null;const l=(Array.isArray(d)?d:[d]).filter(m=>typeof m=="string"||a(m));return l.length?l:null}const g=o}),xe("packages/dom/src/editors/iconpicker.js",function(e,G){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.VirtualList,W=Q.el,X=Q.on,H=Q.clear,V=G("packages/dom/src/cell/icons.js"),K=V.createIcon,D=V.iconNames,O=G("packages/core/src/internal/util.js").isFunction;class y extends L{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const n=this.props;this.columns=Math.max(1,Math.floor(Number(n.columns)||8)),this.names=u(n.icons),this.selected=this.params.value==null?null:String(this.params.value);const t=W(this.doc,"div",{class:["lat-iconpicker",`${B.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${B.editor}__display`}),this.input=W(this.doc,"input",{class:B.input,attrs:{type:"text",autocomplete:"off",placeholder:n.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new F({document:this.doc,itemHeight:Number(n.rowHeight)||34,height:Number(n.listHeight)||204,renderItem:(r,o,f)=>this.renderRow(r,o,f)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),n.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(X(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(X(this.input,"keydown",r=>this.onKeyDown(r))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),t}buildClearButton(){const n=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(X(n,"mousedown",t=>{O(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),n}focusTarget(){return this.input}onQuery(n){this.query=n,this.refreshIcons()}refreshIcons(){const n=this.query.trim().toLowerCase();this.matches=n===""?this.names.slice():this.names.filter(r=>r.toLowerCase().includes(n)),this.rows=[];for(let r=0;r<this.matches.length;r+=this.columns)this.rows.push(this.matches.slice(r,r+this.columns));const t=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=t>=0?t:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(n){return n<0?-1:Math.floor(n/this.columns)}moveCursor(n){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+n));return this.setCursor(t)}setCursor(n){return this.cursor=n,this.list&&this.list.setActive(this.rowOf(n)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(n,t,r){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let o=t.__latIconCells;if(!o){o=[],H(t);for(let f=0;f<this.columns;f++){const c=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});X(c,"mousedown",i=>{O(i.preventDefault)&&i.preventDefault();const g=c.getAttribute("data-icon");g&&this.choose(g)}),t.appendChild(c),o.push(c)}t.__latIconCells=o}for(let f=0;f<o.length;f++){const c=o[f],i=n[f];if(i===void 0){c.setAttribute("aria-hidden","true"),c.removeAttribute("data-icon"),c.removeAttribute("title"),c.removeAttribute("aria-label"),c.classList.add("lat-iconpicker__cell--empty"),c.classList.remove("lat-iconpicker__cell--active"),c.classList.remove("lat-iconpicker__cell--selected"),c.__latIconName!==void 0&&(H(c),c.__latIconName=void 0);continue}const g=r*this.columns+f;c.removeAttribute("aria-hidden"),c.classList.remove("lat-iconpicker__cell--empty"),c.setAttribute("data-icon",i),c.setAttribute("title",i),c.setAttribute("aria-label",i),c.__latIconName!==i&&(H(c),c.appendChild(K(this.doc,i,{className:B.icon})),c.__latIconName=i);const d=this.selected===i;c.classList.toggle("lat-iconpicker__cell--active",g===this.cursor),c.classList.toggle("lat-iconpicker__cell--selected",d),c.setAttribute("aria-selected",d?"true":"false")}}paintDisplay(){const n=this.display;if(n){if(H(n),this.selected==null){n.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}n.appendChild(K(this.doc,this.selected,{className:B.icon})),n.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(n){this.selected=n;const t=this.matches.indexOf(n);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(n))?!0:`"${String(n)}" is not a known icon name`}onKeyDown(n){const t=()=>{O(n.preventDefault)&&n.preventDefault()};switch(n.key){case"ArrowRight":t(),this.moveCursor(1);return;case"ArrowLeft":t(),this.moveCursor(-1);return;case"ArrowDown":t(),this.moveCursor(this.columns);return;case"ArrowUp":t(),this.moveCursor(-this.columns);return;case"PageDown":t(),this.moveCursor(this.columns*5);return;case"PageUp":t(),this.moveCursor(-this.columns*5);return;case"Home":t(),this.setCursor(this.matches.length?0:-1);return;case"End":t(),this.setCursor(this.matches.length-1);return;case"Enter":{t();const r=this.cursorName();r&&this.choose(r);return}case"Escape":t(),this.cancel();return;case"Tab":{const r=this.cursorName();r&&(this.selected=r),this.commit();return}default:break}}destroy(){for(const n of this.off)n();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function u(s){const n=D();if(Array.isArray(s)&&s.length){const t=new Set(n);return s.map(r=>String(r)).filter(r=>t.has(r))}return n.filter(t=>t!=="blank")}const a=y}),xe("packages/dom/src/editors/temperature.js",function(e,G){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,H=G("packages/core/src/internal/util.js").isFunction,V=G("packages/core/src/columns/types/temperature.js"),K=V.formatTemperature,D=V.parseTemperature,v=V.findScale;function O(a,s){return K(a,{...s,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends L{input=null;hint=null;opts=null;#e=[];buildOptions(){const s=this.params.column&&this.params.column.dataType||null,n=s&&s.temperatureConfig||{};return{scale:this.props.scale||n.scale||"C",locale:this.params.locale}}build(){const s=this.props;this.opts=this.buildOptions();const n=v(this.opts.scale),t=n?n.scale.symbol:"",r=`${this.id}-scale`,o=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:s.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?r:null}});o.value=O(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(o.value=this.params.key),this.input=o;const f=typeof s.step=="number"?s.step:0;return f>0&&this.#e.push(W(o,"keydown",c=>{c.key==="ArrowUp"?(H(c.preventDefault)&&c.preventDefault(),this.nudge(f)):c.key==="ArrowDown"&&(H(c.preventDefault)&&c.preventDefault(),this.nudge(-f))})),this.hint=F(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:r,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${B.editor}__unit`,children:[o,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const s=this.input;s&&!this.params.key&&this.props.selectOnFocus!==!1&&H(s.select)&&s.select()}nudge(s){const n=D(this.input?this.input.value:"",this.opts);let t=(n??0)+s;const{min:r,max:o}=this.props;typeof r=="number"&&t<r&&(t=r),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=O(t,this.opts))}readValue(){const s=this.input?String(this.input.value).trim():"";if(s==="")return null;const n=D(s,this.opts);return n===null?Number.NaN:n}checkValue(s){if(s===null)return!0;if(typeof s!="number"||Number.isNaN(s))return"Enter a temperature";const{min:n,max:t}=this.props;return typeof n=="number"&&s<n?`Must be ${n} or more`:typeof t=="number"&&s>t?`Must be ${t} or less`:!0}destroy(){for(const s of this.#e)s();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const u=y}),xe("packages/dom/src/editors/currency.js",function(e,G){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=G("packages/dom/src/editors/common.js"),L=Q.BaseEditor,B=Q.CLS,F=Q.el,W=Q.on,H=G("packages/core/src/internal/util.js").isFunction,V=G("packages/core/src/columns/types/currency.js"),K=V.parseMoney,D=V.toMoney,v=V.normaliseCode,O=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(s){const n=D(s);return n?String(n.amount):""}class u extends L{input=null;picker=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.currencyConfig||{},r=D(this.params.value),o=v(this.props.code)||r&&r.code||v(t.code)||"USD";let f=this.props.codes||t.codes||O;return f=f.map(c=>v(c)).filter(Boolean),f.includes(o)||(f=[o,...f]),{code:o,codes:f,locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});t.value=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const r=F(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const o of this.opts.codes){const f=F(this.doc,"option",{text:o,attrs:{value:o}});o===this.opts.code&&(f.selected=!0),r.appendChild(f)}return this.picker=r,F(this.doc,"div",{class:`${B.editor}__unit`,children:[t,r]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&H(n.select)&&n.select()}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=this.picker?this.picker.value:this.opts.code,r=K(n,{...this.opts,code:t});return r===null?Number.NaN:r}checkValue(n){if(n===null)return!0;if(!n||typeof n!="object"||!Number.isFinite(n.amount))return"Enter an amount";const t=n.amount,{min:r,max:o}=this.props;return typeof r=="number"&&t<r?`Must be ${r} or more`:typeof o=="number"&&t>o?`Must be ${o} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const a=u}),xe("packages/dom/src/editors/index.js",function(e,G){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return _}}),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 ce}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return fe}});const L=G("packages/dom/src/editors/text.js").TextEditor,F=G("packages/dom/src/editors/textarea.js").TextareaEditor,X=G("packages/dom/src/editors/number.js").NumberEditor,V=G("packages/dom/src/editors/date.js").DateEditor,D=G("packages/dom/src/editors/checkbox.js").CheckboxEditor,O=G("packages/dom/src/editors/select.js").SelectEditor,u=G("packages/dom/src/editors/multiselect.js").MultiSelectEditor,s=G("packages/dom/src/editors/time.js").TimeEditor,t=G("packages/dom/src/editors/datetime.js").DateTimeEditor,o=G("packages/dom/src/editors/duration.js").DurationEditor,c=G("packages/dom/src/editors/ipaddress.js").IpAddressEditor,g=G("packages/dom/src/editors/password.js").PasswordEditor,h=G("packages/dom/src/editors/code.js").CodeEditor,m=G("packages/dom/src/editors/unit.js").UnitEditor,k=G("packages/dom/src/editors/radix.js").RadixEditor,b=G("packages/dom/src/editors/segmented.js").SegmentedEditor,T=G("packages/dom/src/editors/rating.js").RatingEditor,x=G("packages/dom/src/editors/slider.js").SliderEditor,A=G("packages/dom/src/editors/colour.js").ColourEditor,$=G("packages/dom/src/editors/treeselect.js").TreeSelectEditor,M=G("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,S=G("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=G("packages/dom/src/editors/temperature.js").TemperatureEditor,_=G("packages/dom/src/editors/currency.js").CurrencyEditor,J=G("packages/core/src/internal/util.js"),ee=J.isCtor,te=J.isFunction,ne=J.warnOnce,ae=G("packages/dom/src/editors/common.js");for(const ke of Object.keys(ae))ke!=="default"&&Object.defineProperty(e,ke,{enumerable:!0,get:function(){return ae[ke]}});const de=Object.freeze({text:L,textarea:F,number:X,date:V,checkbox:D,select:O,multiSelect:u,temperature:q,currency:_,time:s,datetime:t,duration:o,ipaddress:c,password:g,code:h,unit:m,radix:k,slider:x,rating:T,segmented:b,treeSelect:$,objectPicker:M,iconPicker:S,colour:A}),ie=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function oe(ke,Re){const Ee=ke&&ke.edit&&ke.edit.editor,Fe=Re&&Re.editors||{},ye=!!(ke&&ke.lookup&&ke.lookup.multiple);if(ee(Ee)||te(Ee))return Ee;if(typeof Ee=="string"){if(ye&&Ee==="select")return u;const Ce=Fe[Ee]||de[Ee];if(Ce)return Ce;ne(`editor:missing:${Ee}`,`unknown editor "${Ee}"; falling back to the data type default`)}const he=ke&&ke.type||"text";if(he==="lookup"||ke&&ke.lookup)return ye?u:O;const Se=ie[he];return Se&&(Fe[Se]||de[Se])||null}function ce(ke,Re){const Ee=oe(ke.column||{},Re);if(!Ee)return null;const Fe=new Ee;return Fe.init(ke),te(Fe.cancelBeforeStart)&&Fe.cancelBeforeStart()===!0?(te(Fe.destroy)&&Fe.destroy(),null):Fe}const fe=de}),xe("packages/dom/src/ui/statusbar.js",function(e,G){"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 O}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.documentFor,F=Q.el,W=Q.clear,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/core/src/internal/util.js").isFunction;function D(d){let h=0,l=0,m=0,w=null,k=null;for(const p of d||[]){if(p==null||p==="")continue;h++;const b=typeof p=="number"?p:Number(p);Number.isFinite(b)&&(l++,m+=b,(w===null||b<w)&&(w=b),(k===null||b>k)&&(k=b))}return{count:h,numericCount:l,sum:l?m:null,min:w,max:k,avg:l?m/l:null}}class v{root=null;valueNode=null;init(h){this.ctx=h,this.doc=h.document,this.root=F(this.doc,"div",{class:`${L.statusBar}__panel`,attrs:{"data-align":h.align||"end"}}),h.label&&this.root.appendChild(F(this.doc,"span",{class:`${L.statusBar}__label`,text:h.label})),this.valueNode=F(this.doc,"span",{class:`${L.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(h,l){const m=this.ctx&&this.ctx.messages;return(m&&K(m.t)?m:H).t(h,l)}element(){return this.root}refresh(){const h=this.read();this.valueNode&&this.valueNode.textContent!==h&&(this.valueNode.textContent=h)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class O extends v{read(){const h=this.ctx.host||{},l=K(h.totalRowCount)?h.totalRowCount():0;if(l==null)return this.t("status.counting");const m=K(h.rowCount)?h.rowCount():l,w=this.ctx.noun,k=p=>w===void 0?this.t("count.rows",{count:p}):`${f(p,this.ctx.locale)}${w?` ${w}`:""}`;return m===l?this.t("status.total",{rows:k(l)}):this.t("status.shownOfTotal",{shown:f(m,this.ctx.locale),total:k(l)})}}class y extends v{read(){const h=this.ctx.host||{},l=K(h.selectedAcrossSource)?h.selectedAcrossSource():null;if(l)return typeof l.count=="number"?this.t("status.selectedAcrossSource",{count:l.count}):this.t("status.selectedAcrossSourceCounting");const m=K(h.selectedCount)?h.selectedCount():0;return m?this.t("status.selected",{count:m}):""}}class u extends v{read(){const h=this.ctx.host||{},l=K(h.rangeValues)?h.rangeValues():[],m=D(l);if(!m.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],k=[];for(const p of w){if(p==="count"){k.push(this.t("status.count",{count:m.count}));continue}const b=m[p];b!==null&&k.push(`${this.t(`status.stat.${p}`)} ${i(b,this.ctx.locale)}`)}return k.join(" ")}}class a extends v{read(){const h=this.ctx.host||{},l=K(h.progress)?h.progress():null;if(!l)return"";const{loaded:m,estimated:w,done:k}=l;if(k)return"";if(!w)return this.t("status.loading",{count:m||0});const p=Math.min(100,Math.round((m||0)/w*100));return this.t("status.loadingOf",{loaded:m||0,total:w,percent:p})}}class s extends v{read(){const h=this.ctx.host||{},l=K(h.updateStats)?h.updateStats():null;return l?l.paused?l.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:l.pending})}):this.t("status.paused"):l.coalescedTotal?this.t("status.coalesced",{count:l.coalescedTotal}):"":""}}class n extends v{read(){const h=this.ctx.host||{},l=K(h.hiddenUnresolved)?h.hiddenUnresolved():0;return l?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:l})}):""}}const t=Object.freeze({rowCount:O,selectedCount:y,aggregation:u,progress:a,updates:s,comments:n});class r{panels=[];root=null;init(h){const l=h||{};this.doc=B(l),this.host=l.host||{},this.messages=l.messages||null,this.root=F(this.doc,"div",{class:L.statusBar,attrs:{role:"status","aria-live":"polite"}});const m=l.registry||{},w=Array.isArray(l.panels)&&l.panels.length?l.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const k of w){const p=typeof k=="string"?k:k.name,b=typeof k=="function"?k:m[p]||t[p];if(!b)continue;const E=new b;E.init({document:this.doc,host:this.host,locale:l.locale,messages:this.messages,...typeof k=="object"?k.props||{}:{}}),this.panels.push({name:String(p||"panel"),panel:E}),this.root.appendChild(E.element())}this.refresh()}element(){return this.root}addPanel(h,l,m){const w=new l;return w.init({document:this.doc,host:this.host,messages:this.messages,...m||{}}),this.panels.push({name:h,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(h){const l=this.panels.findIndex(k=>k.name===h);if(l<0)return!1;const[m]=this.panels.splice(l,1),w=m.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),K(m.panel.destroy)&&m.panel.destroy(),!0}refresh(){for(const h of this.panels)h.panel.refresh()}destroy(){for(const h of this.panels)K(h.panel.destroy)&&h.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const o=new Map;function f(d,h){const l=h||"";let m=o.get(l);return m||(m=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0}),o.set(l,m)),m.format(Number(d)||0)}const c=new Map;function i(d,h){const l=h||"";let m=c.get(l);return m||(m=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:3}),c.set(l,m)),m.format(Number(d)||0)}const g=r}),xe("packages/dom/src/ui/contextmenu.js",function(e,G){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.documentFor,F=Q.el,W=Q.on,X=Q.clear,V=G("packages/core/src/internal/util.js").isFunction,D=G("packages/dom/src/renderer/direction.js").isRtlElement,O=G("packages/dom/src/cell/icons.js").renderIconInto;function y(t,r){const o=[];for(const f of t||[]){const c=V(f)?f(r):f;if(c==null||c===!1)continue;if(c==="separator"){o.push({separator:!0});continue}if(typeof c=="string"){o.push({name:c});continue}const i=c,g=i.subMenu||i.children;g?o.push({...i,subMenu:y(g,r)}):o.push(i)}return o.filter((f,c,i)=>f.separator?c===0||c===i.length-1?!1:!i[c-1].separator:!0)}class u{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(r){const o=r||{};this.doc=B(o),this.host=o.host||this.doc.body,this.ctx=o.ctx||{},this.onClose=o.onClose||null,this.parent=o.parent||null}place(r){const o=this.host,f=V(o.getBoundingClientRect)?o.getBoundingClientRect():{left:0,top:0},c=V(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},i=this.doc.defaultView||{innerWidth:0,innerHeight:0},g=i.innerWidth||0,d=i.innerHeight||0;let h=r.x||0,l=r.y||0;const m=D(o);if(r.anchor&&V(r.anchor.getBoundingClientRect)){const p=r.anchor.getBoundingClientRect();r.placement==="below"?(h=m?p.right-c.width:p.left,l=p.bottom):(h=m?p.left-c.width:p.right,l=p.top)}else m&&(h-=c.width);const w={left:Math.max(0,f.left||0),top:Math.max(0,f.top||0),right:Math.min(g||1/0,(f.left||0)+(f.width||1/0)),bottom:Math.min(d||1/0,(f.top||0)+(f.height||1/0))};h+c.width>w.right&&(h-=c.width),h<w.left&&(h=w.left),l+c.height>w.bottom&&(l-=c.height),l<w.top&&(l=w.top);const k=w.bottom-l;c.height>k&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(k))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(h-f.left+(o.scrollLeft||0))}px`,this.root.style.top=`${Math.round(l-f.top+(o.scrollTop||0))}px`}show(r){return this.hide(),r.ctx&&(this.ctx={...this.ctx||{},...r.ctx}),this.items=y(r.items,this.ctx),this.returnFocus=r.returnFocus||null,this.anchor=r.anchor&&V(r.anchor.setAttribute)&&r.anchor.getAttribute&&r.anchor.getAttribute("aria-haspopup")?r.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=F(this.doc,"div",{class:L.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((o,f)=>{if(o.separator){this.root.appendChild(F(this.doc,"div",{class:L.menuSeparator,attrs:{role:"separator"}}));return}const c=F(this.doc,"div",{class:[L.menuItem,o.cssClass||""],attrs:{role:o.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":o.disabled?"true":null,"aria-checked":o.checked===void 0?null:String(o.checked===!0),"aria-haspopup":o.subMenu?"true":null,"aria-expanded":o.subMenu?"false":null,"data-index":f}});if(o.icon!=null&&o.icon!==""){const g=F(this.doc,"span",{class:L.icon});O(g,o.icon,`menu:${o.name||f}`),c.appendChild(g)}c.appendChild(F(this.doc,"span",{class:`${L.menuItem}__label`,text:o.name||""})),o.shortcut&&c.appendChild(F(this.doc,"span",{class:`${L.menuItem}__shortcut`,text:o.shortcut})),o.subMenu&&c.appendChild(F(this.doc,"span",{class:`${L.menuItem}__arrow`,text:"›"}));const i=this.itemNodes.length;this.off.push(W(c,"click",()=>this.invoke(i))),this.off.push(W(c,"mouseenter",()=>{this.focus(i),o.subMenu?this.openSubMenu(i):this.closeChild()})),this.itemNodes.push(c),this.root.appendChild(c)}),this.host.appendChild(this.root),this.place(r),this.open=!0,this.off.push(W(this.root,"keydown",o=>this.onKeyDown(o))),V(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=o=>{this.root&&!s(this.root,o.target)&&!(this.child&&this.child.root&&s(this.child.root,o.target))&&this.hide()},!0)),V(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let r=0;r<this.itemNodes.length;r++)if(!this.itemAt(r).disabled)return r;return-1}itemAt(r){const o=this.itemNodes[r];return o?this.items[Number(o.getAttribute("data-index"))]||{}:{}}focus(r){if(r<0||r>=this.itemNodes.length)return;const o=this.itemNodes[this.focused];o&&o.classList.remove(`${L.menuItem}--focused`),this.focused=r;const f=this.itemNodes[r];f.classList.add(`${L.menuItem}--focused`),V(f.focus)&&f.focus(),V(f.scrollIntoView)&&f.scrollIntoView({block:"nearest",inline:"nearest"})}move(r){const o=this.itemNodes.length;if(!o)return;let f=this.focused;for(let c=0;c<o;c++)if(f=(f+r+o)%o,!this.itemAt(f).disabled){this.focus(f);return}}invoke(r){const o=this.itemAt(r);if(!(!o||o.disabled)){if(o.subMenu){this.openSubMenu(r);return}V(o.action)&&o.action({...this.ctx,item:o}),this.hideRoot()}}openSubMenu(r){const o=this.itemAt(r);o.subMenu&&(this.closeChild(),this.child=new u({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:o.subMenu,anchor:this.itemNodes[r]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(r){switch(r.key){case"ArrowDown":a(r),this.move(1);break;case"ArrowUp":a(r),this.move(-1);break;case"Home":a(r),this.focus(this.firstEnabled());break;case"End":a(r),this.focus(this.itemNodes.length-1);break;case"ArrowRight":a(r),this.openSubMenu(this.focused);break;case"ArrowLeft":a(r),this.parent&&(this.hide(),V(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":a(r),this.invoke(this.focused);break;case"Escape":a(r),this.hideRoot();break;default:r.key&&r.key.length===1&&this.jumpTo(r.key);break}}jumpTo(r){const o=r.toLowerCase(),f=this.itemNodes.length;for(let c=1;c<=f;c++){const i=(this.focused+c+f)%f,g=this.itemAt(i);if(!g.disabled&&(g.name||"").toLowerCase().startsWith(o)){this.focus(i);return}}}hideRoot(){let r=this;for(;r.parent;)r=r.parent;r.hide()}hide(){this.closeChild();for(const r of this.off)r();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&V(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&V(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,V(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function a(t){V(t.preventDefault)&&t.preventDefault(),V(t.stopPropagation)&&t.stopPropagation()}function s(t,r){let o=r;for(;o;){if(o===t)return!0;o=o.parentNode}return!1}const n=u}),xe("packages/dom/src/viewpicker.js",function(e,G){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=G("packages/dom/src/editors/common.js"),L=Q.documentFor,B=Q.el,F=Q.on,W=Q.clear,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/core/src/internal/util.js").isFunction,v=G("packages/dom/src/cell/icons.js").createIcon,O=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(n,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(n,t)}init(n){this.messages=n&&n.messages||n&&n.grid&&n.grid.messages||H;const t=n||{};this.doc=L(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:O.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const n=this.root;if(!n)return;for(const c of this.off)c();this.off.length=0,W(n),this.diffs=new Map;const t=this.views(),r=t.filter(c=>c.builtin),o=t.filter(c=>!c.builtin);r.length&&(n.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),r.length)),n.appendChild(this.buildList(r))),n.appendChild(this.buildHead(String(this.props.title||"Saved views"),o.length)),o.length?n.appendChild(this.buildList(o)):n.appendChild(B(this.doc,"p",{class:O.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const f=this.buildFoot();f&&n.appendChild(f)}buildList(n){const t=B(this.doc,"div",{class:O.list,attrs:{role:"list"}});for(const r of n)t.appendChild(this.buildItem(r));return t}views(){const n=K(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?n:n.slice().sort((t,r)=>String(t.name||"").localeCompare(String(r.name||"")))}activeId(){return K(this.host.activeId)?this.host.activeId():null}buildHead(n,t){return B(this.doc,"div",{class:O.head,children:[B(this.doc,"span",{class:O.title,text:String(n)}),B(this.doc,"span",{class:O.count,text:String(t)})]})}buildItem(n){const t=String(n.id),r=this.activeId()===t,o=K(this.host.canEdit)?this.host.canEdit(n)!==!1:!0,f=B(this.doc,"div",{class:[O.item,r?O.itemActive:"",this.editing===t?O.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":n.shared?"true":"false"}});if(this.editing===t)return f.appendChild(this.buildRenameRow(n)),f;const c=B(this.doc,"button",{class:O.apply,attrs:{type:"button","aria-current":r?"true":null,title:[r?`${n.name} is applied`:`Apply ${n.name}`,n.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:O.name,text:String(n.name||"")}),n.isDefault?this.buildBadges(n):null].filter(Boolean)});K(this.host.apply)?this.off.push(F(c,"click",()=>this.applyView(t))):c.setAttribute("disabled",""),n.description&&c.appendChild(B(this.doc,"span",{class:O.description,text:String(n.description)}));const i=this.buildDiff(t,r);return i&&c.appendChild(i),f.appendChild(c),n.builtin||f.appendChild(this.confirming===t?this.buildConfirm(n):this.buildActions(n,o)),f}buildBadges(n){const t=B(this.doc,"span",{class:O.badges});return n.isDefault&&t.appendChild(B(this.doc,"span",{class:[O.badge,O.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(n,t){if(this.props.showDiff!==!0||!K(this.host.diff))return null;const r=this.diffOf(n);if(!r)return null;if(!r.changed)return B(this.doc,"span",{class:[O.diff,O.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const o=u(r);return o.length?B(this.doc,"span",{class:O.diff,text:o.join(" · ")}):null}diffOf(n){if(!K(this.host.diff))return null;if(this.diffs.has(n))return this.diffs.get(n);let t=null;try{t=this.host.diff(n)}catch{t=null}return this.diffs.set(n,t),t}buildActions(n,t){const r=String(n.id),o=B(this.doc,"span",{class:O.actions});if(t&&K(this.host.rename)&&o.appendChild(this.buildAction("Rename",`Rename ${n.name}`,()=>{this.editing=r,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),n.isDefault&&K(this.host.clearDefault)?o.appendChild(this.buildAction("Unset default",`Stop applying ${n.name} at load`,()=>{this.host.clearDefault(r),this.refresh()},"pin")):!n.isDefault&&K(this.host.setDefault)&&o.appendChild(this.buildAction("Make default",`Apply ${n.name} when the grid loads`,()=>{this.host.setDefault(r),this.refresh()},"pin")),K(this.host.export)&&o.appendChild(this.buildAction("Share",`Export ${n.name}`,()=>this.host.export(r),"share")),t&&K(this.host.remove)){const f=this.buildAction("Delete",`Delete ${n.name}`,()=>{this.confirming=r,this.refresh()},"trash");f.classList.add(O.actionDanger),o.appendChild(f)}return o}buildConfirm(n){const t=String(n.id),r=B(this.doc,"span",{class:O.confirm});r.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:n.name})}));const o=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:n.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return o.classList.add(O.actionDanger),r.appendChild(o),r.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),r}buildRenameRow(n){const t=String(n.id),r=B(this.doc,"span",{class:O.confirm}),o=B(this.doc,"input",{class:O.input,attrs:{type:"text","aria-label":`New name for ${n.name}`}});o.value=String(n.name||""),this.input=o;const f=()=>{const i=String(o.value||"").trim();this.editing=null,i&&i!==n.name&&this.host.rename(t,i),this.refresh()},c=()=>{this.editing=null,this.refresh()};return this.off.push(F(o,"keydown",i=>{i.key==="Enter"?f():i.key==="Escape"&&c()})),r.appendChild(o),r.appendChild(this.buildAction("Save","Save the new name",f)),r.appendChild(this.buildAction("Cancel","Leave the name alone",c)),r}buildFoot(){if(this.props.allowSave===!1||!K(this.host.saveAs))return null;const n=B(this.doc,"div",{class:O.foot}),t=B(this.doc,"input",{class:O.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const r=()=>{const f=String(t.value||"").trim();if(!f){K(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(f),this.refresh()};this.off.push(F(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push(F(t,"keydown",f=>{f.key==="Enter"&&r()}));const o=B(this.doc,"button",{class:O.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(F(o,"click",r)),n.appendChild(t),n.appendChild(o),n}buildAction(n,t,r,o){const f=B(this.doc,"button",{class:O.action,text:o?null:n,attrs:{type:"button",title:t,"aria-label":t,"data-action":n}});return o&&f.appendChild(v(this.doc,o,{className:O.actionIcon})),this.off.push(F(f,"click",r)),f}applyView(n){this.confirming=null,this.host.apply(n),this.refresh()}focusInput(){const n=this.input;n&&K(n.focus)&&n.focus(),n&&K(n.select)&&n.select()}destroy(){for(const n of this.off)n();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function u(s,n=3){if(!s||!s.changed)return[];const t=s.counts||{},r=[],o=(f,c,i)=>{f&&r.push((f===1?c:i).replace("%",String(f)))};if(o(t.columnsHidden,"hides % column","hides % columns"),o(t.columnsShown,"shows % column","shows % columns"),o(t.columnsMoved,"moves % column","moves % columns"),o(t.columnsPinned,"repins % column","repins % columns"),o(t.columnsResized,"resizes % column","resizes % columns"),s.filters&&s.filters.changed){const f=t.filterColumns||0;r.push(f?`changes ${f} filter${f===1?"":"s"}`:"changes the filter")}return s.quick&&s.quick.changed&&r.push("changes the search"),s.sort&&s.sort.changed&&r.push("changes the sort"),s.group&&s.group.changed&&r.push("changes the grouping"),s.pivot&&s.pivot.changed&&r.push("changes the pivot"),o(t.columnsTotalled,"changes % total","changes % totals"),s.pagination&&s.pagination.changed&&r.push("changes the page size"),r.length<=n?r:[...r.slice(0,n),`and ${r.length-n} more`]}const a=y}),xe("packages/dom/src/ui/panelbase.js",function(e,G){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return X}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.el,W=G("packages/core/src/i18n/index.js").defaultMessages;class X{root=null;off=[];init(V){this.ctx=V,this.doc=V.document,this.host=V.host||{},this.props=V.props||{},this.root=B(this.doc,"div",{class:`${L.panel}__body`}),this.refresh()}t(V,K){const D=this.host||{};if(typeof D.t=="function")return D.t(V,K);const v=this.ctx||{};if(v.messages&&typeof v.messages.t=="function")return v.messages.t(V,K);const O=v.grid;return(O&&O.messages?O.messages:W).t(V,K)}element(){return this.root}refresh(){}destroy(){for(const V of this.off)V();this.off.length=0,this.root=null}}}),xe("packages/dom/src/formattingpanel.js",function(e,G){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.documentFor,F=Q.el,W=Q.on,X=Q.clear,V=G("packages/core/src/internal/util.js").isFunction,D=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,v=G("packages/core/src/formatting/rules.js"),O=v.compileRules,y=v.summariseColumn,u=v.needsDistribution,a=v.DISTRIBUTION_LABELS,s="*",n=8,t=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),r=Object.freeze([{op:"topPercent",label:a.topPercent,values:1},{op:"bottomPercent",label:a.bottomPercent,values:1},{op:"topN",label:a.topN,values:1},{op:"bottomN",label:a.bottomN,values:1},{op:"aboveMean",label:a.aboveMean,values:0},{op:"belowMean",label:a.belowMean,values:0},{op:"aboveMedian",label:a.aboveMedian,values:0},{op:"belowMedian",label:a.belowMedian,values:0},{op:"zAbove",label:a.zAbove,values:1},{op:"zBelow",label:a.zBelow,values:1},{op:"outlier",label:a.outlier,values:0}]),o=Object.freeze([...t,...r]),f=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),c=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),i=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function g(w){const k=o.find(p=>p.op===w);return k?k.values:1}function d(w){if(!w)return"";if(w.scale){const{min:E,max:T,from:P}=w.scale;if(Number.isFinite(E)&&Number.isFinite(T))return`Colour scale, ${E} to ${T}`;const x=i.find(C=>C.from===P);return x?`Colour scale ${x.label}`:"Colour scale"}const k=w.when||{},p=o.find(E=>E.op===k.op),b=p?p.label:k.op;return!p||p.values===0?`Value ${b}`:p.values===2?`Value ${b} ${k.value} and ${k.value2}`:`Value ${b} ${k.value}`}class h extends D{scope=s;mode="condition";refresh(){const k=this.root;if(k){for(const p of this.off)p();this.off.length=0,X(k),k.appendChild(this.#o()),k.appendChild(this.#i()),k.appendChild(this.#l())}}#e(){const k=V(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:s,title:"All columns"},...k]}#t(){return V(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(k){if(!V(this.host.columnSamples))return[];const p=this.host.columnSamples(k);return Array.isArray(p)?p:[...p||[]]}#r(k,p,b){const E=u(k)?y(p):null;return O(k,E)({value:b})}#o(){const k=F(this.doc,"div",{class:`${L.panel}__row`});k.appendChild(F(this.doc,"label",{class:`${L.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const b of this.#e()){const E=F(this.doc,"option",{text:b.title,attrs:{value:b.id}});b.id===this.scope&&E.setAttribute("selected","selected"),p.appendChild(E)}return p.value=this.scope,this.off.push(W(p,"change",()=>{this.scope=p.value||s,this.refresh()})),k.appendChild(p),k}#i(){const k=F(this.doc,"ul",{class:`${L.panel}__list`}),p=this.#t();if(!p.length)return k.appendChild(F(this.doc,"li",{class:`${L.panel}__empty`,text:this.t("formatting.noRules")})),k;p.forEach((T,P)=>{const x=F(this.doc,"li",{class:`${L.panel}__item`,attrs:{"data-rule":T.id}}),C=F(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${d(T)}`}});C.checked=T.enabled!==!1,this.off.push(W(C,"change",()=>{this.#c("updateRule",this.scope,T.id,{enabled:C.checked})})),x.appendChild(C);const A=F(this.doc,"span",{class:`${L.panel}__swatch`}),j=T.style||{};if(j.background&&A.style&&A.style.setProperty)A.style.setProperty("background",String(j.background));else if(T.scale&&T.scale.colours&&A.style&&A.style.setProperty){const R=T.scale.colours;A.style.setProperty("background",`linear-gradient(90deg, ${R[0]}, ${R[R.length-1]})`)}x.appendChild(A),x.appendChild(F(this.doc,"span",{class:`${L.panel}__text`,text:d(T)}));const $=F(this.doc,"button",{class:`${L.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...P===0?{disabled:"disabled"}:{}}});this.off.push(W($,"click",()=>this.#c("moveRule",this.scope,T.id,P-1))),x.appendChild($);const z=F(this.doc,"button",{class:`${L.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...P===p.length-1?{disabled:"disabled"}:{}}});this.off.push(W(z,"click",()=>this.#c("moveRule",this.scope,T.id,P+1))),x.appendChild(z);const M=F(this.doc,"button",{class:`${L.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${d(T)}`}});this.off.push(W(M,"click",()=>this.#c("removeRule",this.scope,T.id))),x.appendChild(M),k.appendChild(x)});const b=this.#s(p);b&&k.appendChild(b);const E=F(this.doc,"button",{class:`${L.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(E,"click",()=>this.#c("clearRules",this.scope))),k.appendChild(E),k}#s(k){const p=this.#n(this.scope);if(!p.length)return null;const b=k.filter(T=>T.enabled!==!1);if(!b.length)return null;const E=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const T of p.slice(0,n)){const P=this.#r(b,p,T),x=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(T)});P&&x.style&&x.style.setProperty&&(P.background&&x.style.setProperty("background",String(P.background)),P.color&&x.style.setProperty("color",String(P.color))),E.appendChild(x)}return E}#l(){const k=F(this.doc,"div",{class:`${L.panel}__form`}),p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return p.appendChild(F(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),p.appendChild(F(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),p.value=this.mode,this.off.push(W(p,"change",()=>{this.mode=p.value==="scale"?"scale":"condition",this.refresh()})),k.appendChild(p),this.mode==="scale"?k.appendChild(this.#u()):k.appendChild(this.#a()),k}#a(){const k=F(this.doc,"div",{class:`${L.panel}__form`}),p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),b=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const M of t)b.appendChild(F(this.doc,"option",{text:M.label,attrs:{value:M.op}}));p.appendChild(b);const E=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const M of r)E.appendChild(F(this.doc,"option",{text:M.label,attrs:{value:M.op}}));p.appendChild(E),p.value="gt",k.appendChild(p);const T=F(this.doc,"input",{class:`${L.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),P=F(this.doc,"input",{class:`${L.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});k.appendChild(T),k.appendChild(P);const x=()=>{const M=g(p.value);T.style.setProperty("display",M>=1?"":"none"),P.style.setProperty("display",M>=2?"":"none"),$()};this.off.push(W(p,"change",x));const C=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const M of f)C.appendChild(F(this.doc,"option",{text:M.name,attrs:{value:M.name}}));C.value=f[0].name,k.appendChild(C);const A=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});k.appendChild(A);const j=()=>{const M=f.find(I=>I.name===C.value)||f[0],R=g(p.value),S={op:p.value};return R>=1&&(S.value=T.value),R>=2&&(S.value2=P.value),{when:S,style:{background:M.background,color:M.color}}},$=()=>{X(A);const M=this.#n(this.scope);if(M.length)for(const R of M.slice(0,n)){const S=this.#r([j()],M,R),I=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(R)});S&&I.style&&I.style.setProperty&&(S.background&&I.style.setProperty("background",String(S.background)),S.color&&I.style.setProperty("color",String(S.color))),A.appendChild(I)}};this.off.push(W(T,"input",$)),this.off.push(W(P,"input",$)),this.off.push(W(C,"change",$)),x();const z=F(this.doc,"button",{class:`${L.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(z,"click",()=>{this.#c("addRule",this.scope,j()),T.value="",P.value=""})),k.appendChild(z),k}#u(){const k=F(this.doc,"div",{class:`${L.panel}__form`}),p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of c)p.appendChild(F(this.doc,"option",{text:C.name,attrs:{value:C.name}}));p.value=c[0].name,k.appendChild(p);const b=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of i)b.appendChild(F(this.doc,"option",{text:C.label,attrs:{value:C.from}}));b.value=i[0].from,k.appendChild(b);const E=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});k.appendChild(E);const T=()=>{const C=c.find(A=>A.name===p.value)||c[0];return{scale:{from:b.value,colours:[...C.colours]}}},P=()=>{X(E);const C=this.#n(this.scope);if(C.length)for(const A of C.slice(0,n)){const j=this.#r([T()],C,A),$=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(A)});j&&j.background&&$.style&&$.style.setProperty&&$.style.setProperty("background",String(j.background)),E.appendChild($)}};this.off.push(W(p,"change",P)),this.off.push(W(b,"change",P)),P();const x=F(this.doc,"button",{class:`${L.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(x,"click",()=>{this.#c("addRule",this.scope,T())})),k.appendChild(x),k}#c(k,...p){V(this.host[k])&&this.host[k](...p),this.refresh()}}function l(w={}){const k=new h;return k.init({document:B(w),host:w.host||{}}),k}const m=h}),xe("packages/dom/src/statisticspanel.js",function(e,G){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return u}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.el,F=Q.on,W=Q.clear,H=G("packages/core/src/internal/util.js").isFunction,K=G("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"}]),O=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(a){if(a==null||!Number.isFinite(a))return"—";if(Number.isInteger(a))return String(a);const s=Math.abs(a);return s!==0&&(s<.001||s>=1e7)?a.toExponential(2):String(Number(a.toPrecision(4)))}class u extends K{column=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const s=this.root;if(!s)return;for(const o of this.off)o();this.off.length=0,W(s);const n=this.#e();if(!n.length){s.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("stats.noColumns")}));return}n.some(o=>o.id===this.column)||(this.column=n[0].id),s.appendChild(this.#t(n));const t=H(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!t||!t.present){s.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("stats.noValues")}));return}if(s.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("stats.filtered",{count:t.rows})})),Array.isArray(t.topValues)){s.appendChild(this.#o(t,v)),s.appendChild(this.#i(t.topValues));return}s.appendChild(this.#o(t));for(const o of O){const f=this.#n(o);f&&s.appendChild(f)}const r=this.#r();r&&s.appendChild(r),t.histogram&&t.histogram.length>1&&s.appendChild(this.#s(t.histogram))}#t(s){const n=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const t of s){const r=B(this.doc,"option",{text:t.title,attrs:{value:t.id,selected:t.id===this.column?!0:null}});n.appendChild(r)}return n.value=this.column,this.off.push(F(n,"change",()=>{this.column=n.value,this.refresh()})),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t("stats.column")}),n]})}#n(s){const n=this.host.reduceColumn;if(!H(n)||!this.column)return null;const t=[];for(const f of s.kernels){const c=n(this.column,f);c==null||Number.isNaN(c)||t.push([f,c])}if(!t.length)return null;const r=this.doc.createElement("div");r.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t(s.label)}));const o=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const[f,c]of t)o.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(`total.${f}`)})),o.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:typeof c=="number"?y(c):String(c)}));return r.appendChild(o),r}#r(){const s=this.host.columnCapability;if(!H(s)||!this.column)return null;const n=s(this.column);if(!n)return null;const t=this.doc.createElement("div");t.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.section.capability")}));const r=B(this.doc,"dl",{class:`${L.panel}__stats`}),o=[["stats.cp",n.cp,null],["stats.cpk",n.cpk,n.interval],["stats.pp",n.pp,null],["stats.ppk",n.ppk,n.intervalPp],["stats.outOfSpec",n.outOfSpec,null]];for(const[f,c,i]of o){if(c==null)continue;r.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(f)}));const g=[B(this.doc,"span",{text:y(c)})];i&&Number.isFinite(i.lower)&&g.push(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${y(i.lower)} – ${y(i.upper)}`,attrs:{title:`${Math.round(i.confidence*100)}%`}})),r.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:g}))}return t.appendChild(r),t}#o(s,n=D){const t=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const r of n){const o=s[r.key];t.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(r.label)})),t.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:r.kind==="count"?String(o??0):y(o)}))}return t}#i(s){const n=this.doc.createElement("div");n.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.topValues")}));const t=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const r of s)t.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:String(r.value)})),t.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:[B(this.doc,"span",{text:String(r.count)}),B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${Math.round(r.share*100)}%`})]}));return n.appendChild(t),n}#s(s){const n=s.reduce((r,o)=>Math.max(r,o.count),0)||1,t=B(this.doc,"div",{class:`${L.panel}__histogram`});t.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.distribution")}));for(const r of s){const o=B(this.doc,"div",{class:`${L.panel}__bar`,style:{width:`${r.count?Math.max(2,r.count/n*100):0}%`}});t.appendChild(B(this.doc,"div",{class:`${L.panel}__bin`,attrs:{title:this.t("stats.bin",{count:r.count,from:y(r.from),to:y(r.to)})},children:[o]}))}return t}}}),xe("packages/dom/src/regressionpanel.js",function(e,G){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.el,F=Q.clear,X=G("packages/core/src/internal/util.js").isFunction,V=G("packages/dom/src/ui/panelbase.js").ToolPanelBase;function K(O,y=4){const u=Number(O);return Number.isFinite(u)?u.toFixed(y):u===1/0?"∞":"—"}class D extends V{#e(){const y=this.props||{};if(Array.isArray(y.predictors)&&y.predictors.length&&y.response)return y;const u=this.ctx&&this.ctx.grid,a=u&&X(u.get)?u.get("regression"):null;return a&&Array.isArray(a.predictors)&&a.response?a:null}refresh(){const y=this.root;if(!y)return;F(y);const u=this.#e();if(!u){y.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.noModel")}));return}const a=X(this.host.regressionModel)?this.host.regressionModel(u):null;if(!a){y.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("regression.observations",{count:a.n})})),y.appendChild(this.#t(a)),y.appendChild(this.#n(a));const s=this.#r(a,u);s&&y.appendChild(s),y.appendChild(this.#o(a))}#t(y){const u=B(this.doc,"dl",{class:`${L.panel}__stats`}),a=(s,n)=>{u.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-label`,text:s})),u.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:n}))};return a(this.t("regression.r2"),K(y.r2,4)),a(this.t("regression.adjR2"),K(y.adjR2,4)),u}#n(y){const u=B(this.doc,"div",{class:`${L.panel}__section`});u.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.coefficients")}));const a=B(this.doc,"table",{class:`${L.panel}__coef-table`}),s=B(this.doc,"tr");for(const n of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])s.appendChild(B(this.doc,"th",{text:this.t(n)}));a.appendChild(s);for(const n of y.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:n.name})),t.appendChild(B(this.doc,"td",{text:`${K(n.estimate)} ± ${K(n.stdError)}`})),t.appendChild(B(this.doc,"td",{text:K(n.stdError)})),t.appendChild(B(this.doc,"td",{text:K(n.t,3)})),t.appendChild(B(this.doc,"td",{text:K(n.p,4)})),a.appendChild(t)}return u.appendChild(a),u}#r(y,u){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const a=B(this.doc,"div",{class:`${L.panel}__section`});a.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.vif")}));const s=B(this.doc,"dl",{class:`${L.panel}__stats`});return y.vif.forEach((n,t)=>{s.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-label`,text:u.predictors[t]})),s.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:K(n,3)}))}),a.appendChild(s),a}#o(y){const u=y.heteroscedasticity,a=B(this.doc,"div",{class:`${L.panel}__section`});return a.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.heteroscedasticity")})),u?(a.appendChild(B(this.doc,"p",{class:`${L.panel}__flag`,attrs:{"data-heteroscedastic":u.heteroscedastic?"true":"false"},text:this.t(u.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:K(u.statistic,3),p:K(u.p,4)})})),a):(a.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.cannotFit")})),a)}}const v=D}),xe("packages/dom/src/comparepanel.js",function(e,G){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return O}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.el,F=Q.on,W=Q.clear,H=G("packages/core/src/internal/util.js").isFunction,K=G("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 u=Math.abs(y);return u!==0&&(u<.001||u>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class O extends K{first=null;second=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const u=this.root;if(!u)return;for(const t of this.off)t();this.off.length=0,W(u);const a=this.#e();if(a.length<2){u.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("compare.needTwo")}));return}a.some(t=>t.id===this.first)||(this.first=a[0].id),(!a.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(a.find(t=>t.id!==this.first)||a[0]).id),u.appendChild(this.#t("compare.first",a,this.first,t=>{this.first=t,this.second===t&&(this.second=(a.find(r=>r.id!==t)||a[0]).id),this.refresh()})),u.appendChild(this.#t("compare.second",a,this.second,t=>{this.second=t,this.first===t&&(this.first=(a.find(r=>r.id!==t)||a[0]).id),this.refresh()}));const s=H(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!s||!s.n){u.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("compare.noPairs")}));return}u.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("compare.pairs",{count:s.n})}));const n=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const t of D){const r=s[t.key];r!=null&&(n.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(t.label)})),n.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:v(r)})))}u.appendChild(n)}#t(u,a,s,n){const t=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const r of a)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===s?!0:null}}));return t.value=s,this.off.push(F(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t(u)}),t]})}}}),xe("packages/dom/src/insightspanel.js",function(e,G){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return O}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.el,F=Q.on,W=Q.clear,H=G("packages/core/src/internal/util.js").isFunction,K=G("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 u=Math.abs(y);return u!==0&&(u<.001||u>=1e7)?y.toExponential(2):String(Number(y.toPrecision(4)))}class O extends K{column=null;by=null;#e(){return H(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const u=this.root;if(!u)return;for(const o of this.off)o();this.off.length=0,W(u);const a=this.#e();if(!a.length){u.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.empty")}));return}const s=this.#t();s&&u.appendChild(s);const n=this.#n();n&&u.appendChild(n),u.appendChild(this.#o(a));const t=this.#s();t&&u.appendChild(t);const r=this.#u();r&&u.appendChild(r)}#t(){if(!H(this.host.subsetVsPopulation))return null;const u=this.host.subsetVsPopulation();if(!u)return null;const a=this.#c("insights.subset");return u.filtered?(a.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("stats.filtered",{count:u.subsetN})})),a.appendChild(this.#r(u.ranked)),a):(a.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.noFilter")})),a)}#n(){const u=this.props&&this.props.other;if(!u||!H(this.host.datasetVsDataset))return null;let a;try{a=this.host.datasetVsDataset(u)}catch{return null}if(!a||!a.ranked)return null;const s=this.#c("insights.dataset");return s.appendChild(this.#r(a.ranked)),s}#r(u){const a=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const s of u||[]){const n=B(this.doc,"dt",{class:`${L.panel}__stat-name`});n.appendChild(B(this.doc,"span",{text:String(s.name??s.column)})),n.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:String(s.measure||"")}));const t=B(this.doc,"dd",{class:`${L.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:v(s.magnitude)})),s.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:this.t("insights.smallSample")})),a.appendChild(n),a.appendChild(t)}return a}#o(u){const a=this.#c("insights.groups");u.some(n=>n.id===this.column)||(this.column=u[0].id),(!u.some(n=>n.id===this.by)||this.by===this.column)&&(this.by=(u.find(n=>n.id!==this.column)||u[0]).id),a.appendChild(this.#d("stats.column",u,this.column,n=>{this.column=n,this.by===n&&(this.by=(u.find(t=>t.id!==n)||u[0]).id),this.refresh()})),a.appendChild(this.#d("insights.by",u,this.by,n=>{this.by=n,this.column===n&&(this.column=(u.find(t=>t.id!==n)||u[0]).id),this.refresh()}));const s=H(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return s?(a.appendChild(this.#i(s)),a):(a.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.needGroups")})),a)}#i(u){const a=B(this.doc,"dl",{class:`${L.panel}__stats`});Array.isArray(u.groups)&&u.groups.length===2&&this.#a(a,"insights.groups",`${u.groups[0]} · ${u.groups[1]}`),this.#a(a,"insights.test",String(u.method||u.test||""));const s=u.effectSize||{};this.#a(a,"insights.effect",`${s.name||""} ${v(s.value)}`.trim());const n=u.interval;let t="—";if(n&&Number.isFinite(n.lower)&&Number.isFinite(n.upper)){const o=Number.isFinite(n.confidence)?` (${Math.round(n.confidence*100)}%)`:"";t=`${v(n.lower)} – ${v(n.upper)}${o}`}const r=this.#a(a,"insights.interval",t);return n&&n.method&&r.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:String(n.method)})),Number.isFinite(u.pValue)&&this.#a(a,"insights.pValue",v(u.pValue)),a}#s(){if(!H(this.host.anomalies))return null;let u;try{u=this.host.anomalies()}catch{return null}if(!u)return null;const a=this.#c("insights.anomalies");a.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("insights.anomalyCount",{count:u.flagged||0,n:u.n||0})}));const s=B(this.doc,"dl",{class:`${L.panel}__stats`});this.#a(s,"insights.anomalyMethod",String(u.method||""));const n=this.#l(u);n!==null&&this.#a(s,"insights.anomalyThreshold",v(n)),a.appendChild(s);const t=(u.rows||[]).map(r=>({name:r.rowKey!=null?String(r.rowKey):`#${r.index}`,measure:(r.why||[]).map(o=>o.name||o.column).join(", "),magnitude:r.score}));return a.appendChild(this.#r(t)),a}#l(u){if(u.method==="mahalanobis")return Number.isFinite(u.cutoff)?u.cutoff:null;if(u.method==="iqr")return Number.isFinite(u.k)?u.k:null;const a=Array.isArray(u.columns)?u.columns[0]:null;return a&&Number.isFinite(a.threshold)?a.threshold:null}#a(u,a,s){u.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(a)}));const n=B(this.doc,"dd",{class:`${L.panel}__stat-value`});return n.appendChild(B(this.doc,"span",{text:s})),u.appendChild(n),n}#u(){if(!H(this.host.columnCapability)||!this.column)return null;const u=this.host.columnCapability(this.column);if(!u)return null;const a=this.#c("stats.section.capability"),s=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const n of D){const t=u[n.field];if(t==null)continue;s.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(n.key)}));const r=[B(this.doc,"span",{text:v(t)})],o=n.interval?u[n.interval]:null;o&&Number.isFinite(o.lower)&&r.push(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${v(o.lower)} – ${v(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),s.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:r}))}return a.appendChild(s),a}#c(u){const a=this.doc.createElement("div");return a.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t(u)})),a}#d(u,a,s,n){const t=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const r of a)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===s?!0:null}}));return t.value=s,this.off.push(F(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t(u)}),t]})}}}),xe("packages/dom/src/ui/toolpanel.js",function(e,G){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.cssEscape,F=Q.documentFor,W=Q.el,X=Q.on,H=Q.clear,K=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js"),v=D.isFunction,O=D.nextFrame,y=G("packages/dom/src/cell/icons.js"),u=y.createIcon,a=y.updateIcon,s=y.icon,t=G("packages/dom/src/viewpicker.js").ViewPicker,o=G("packages/dom/src/formattingpanel.js").FormattingPanel,c=G("packages/dom/src/statisticspanel.js").StatisticsPanel,g=G("packages/dom/src/regressionpanel.js").RegressionPanel,h=G("packages/dom/src/comparepanel.js").ComparePanel,m=G("packages/dom/src/insightspanel.js").InsightsPanel,k=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,b=G("packages/core/src/compute/total.js").TOTAL_LABELS;class E extends k{dragging=null;refresh(){const R=this.root;if(!R)return;for(const _ of this.off)_();this.off.length=0,H(R);const S=W(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(X(S,"input",()=>{this.query=S.value,this.paintList()})),R.appendChild(S),R.appendChild(this.buildZone("group","Row groups")),R.appendChild(this.buildZone("values","Grouped row calculation")),R.appendChild(this.buildZone("pivot","Pivot"));const I=W(this.doc,"div",{class:`${L.panel}__heading`});I.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),Z=W(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(X(q,"click",()=>{const _=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.showColumns)&&this.host.showColumns(_),this.refresh()})),this.off.push(X(Z,"click",()=>{const _=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);v(this.host.hideColumns)&&this.host.hideColumns(_),this.refresh()})),I.appendChild(q),I.appendChild(Z),R.appendChild(I),this.list=W(this.doc,"div",{class:`${L.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),R.appendChild(this.list),this.paintList()}columns(){const R=this.host;return v(R.columns)?R.columns()||[]:R.columns&&v(R.columns.all)?R.columns.all():[]}paintList(){const R=this.list;if(!R)return;H(R);const S=String(this.query||"").trim().toLowerCase();for(const I of this.columns()){const q=String(I.title||I.id||"");if(S&&!q.toLowerCase().includes(S))continue;const Z=W(this.doc,"div",{class:`${L.panel}__column`,attrs:{"data-col":I.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});Z.appendChild(W(this.doc,"span",{class:`${L.panel}__grip`,attrs:{"aria-hidden":"true"}}));const _=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});_.checked=!(I.layout&&I.layout.hidden),I.layout&&I.layout.lockVisible&&_.setAttribute("disabled",""),this.off.push(X(_,"change",()=>this.setVisible(I.id,_.checked))),Z.appendChild(_),Z.appendChild(W(this.doc,"span",{text:q})),Z.setAttribute("tabindex","0"),Z.setAttribute("role","listitem"),this.off.push(X(Z,"keydown",J=>this.onRowKey(J,I))),this.off.push(X(Z,"dragstart",()=>{this.dragging=I.id})),this.off.push(X(Z,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(Z,"dragover",J=>{if(!this.dragging||this.dragging===I.id)return;v(J.preventDefault)&&J.preventDefault();const ee=z(J,Z);Z.setAttribute("data-drop",ee?"before":"after")})),this.off.push(X(Z,"dragleave",()=>Z.removeAttribute("data-drop"))),this.off.push(X(Z,"drop",J=>{v(J.preventDefault)&&J.preventDefault();const ee=this.dragging;this.dragging=null,this.clearDropMark(),!(!ee||ee===I.id)&&this.moveColumn(ee,I.id,z(J,Z))})),R.appendChild(Z)}}onRowKey(R,S){const I=R&&R.key,q=E.zoneKeys[String(I).toLowerCase()];if(q&&!R.ctrlKey&&!R.metaKey&&!R.altKey){v(R.preventDefault)&&R.preventDefault(),this.toggleZone(q,S);return}if(I!=="ArrowUp"&&I!=="ArrowDown")return;const Z=I==="ArrowUp",_=this.columns().map(de=>de.id),J=_.indexOf(S.id);if(J<0)return;if(v(R.preventDefault)&&R.preventDefault(),!R.shiftKey){const de=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ie=de.findIndex(ce=>ce.getAttribute("data-col")===S.id),oe=de[ie+(Z?-1:1)];oe&&v(oe.focus)&&oe.focus();return}const ee=S.layout&&(S.layout.movable===!1||S.layout.lockPosition),te=String(S.title||S.id||"");if(ee){this.announce(this.t("a11y.panel.cannotMove",{column:te}),{repeat:!0});return}const ne=_[J+(Z?-1:1)];if(!ne){this.announce(this.t(Z?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:te}),{repeat:!0});return}this.moveColumn(S.id,ne,Z),this.announce(this.t("a11y.panel.moved",{column:te,at:Z?J:J+2,of:_.length}),{repeat:!0});const ae=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(S.id)}"]`):null;ae&&v(ae.focus)&&ae.focus()}toggleZone(R,S){const I=this.titleOf(S.id),q=this.t(E.zoneLabel[R]||"panel.zone.group");if(this.zoneColumns(R).includes(S.id)){this.dropFromZone(R,S.id),this.announce(this.t("a11y.panel.removedFrom",{column:I,list:q}),{repeat:!0}),this.restoreFocus(S.id);return}if(this.addToZone(R,S.id)){this.announce(this.t("a11y.panel.addedTo",{column:I,list:q}),{repeat:!0}),this.restoreFocus(S.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:I,list:q}),{repeat:!0})}restoreFocus(R){const S=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(R)}"]`):null;S&&v(S.focus)&&S.focus()}announce(R,S){const I=this.host||{};v(I.announce)&&I.announce(R,S)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const R of this.list.querySelectorAll("[data-drop]"))R.removeAttribute("data-drop")}moveColumn(R,S,I){const q=this.host||{};v(q.moveColumn)&&(q.moveColumn(R,S,I),this.refresh())}buildZone(R,S){const I=W(this.doc,"div",{class:`${L.panel}__zone`,attrs:{"data-zone":R,role:"group","aria-label":S}});I.appendChild(W(this.doc,"div",{class:`${L.panel}__zoneTitle`,text:S}));const q=this.zoneColumns(R);let Z=E.zoneAbout[R]||"";R==="values"&&q.length&&!this.zoneColumns("group").length&&(Z+=" Add a row group to see them."),Z&&I.appendChild(W(this.doc,"div",{class:`${L.panel}__zoneAbout`,text:Z}));const _=W(this.doc,"div",{class:`${L.panel}__zoneBody`});q.length||_.appendChild(W(this.doc,"span",{class:`${L.panel}__zoneHint`,text:this.t(E.zoneHint[R]||"panel.zoneHint.any")})),R==="values"&&_.classList.add(`${L.panel}__zoneBody--rows`);for(const J of q){const ee=W(this.doc,"span",{class:[L.chip,R==="values"?`${L.chip}--row`:""]});if(ee.appendChild(W(this.doc,"span",{class:`${L.chip}__label`,text:this.titleOf(J)})),R==="values"&&v(this.host.setValueAggregation)){const ne=v(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",ae=W(this.doc,"select",{class:`${L.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const de of E.aggregations)ae.appendChild(W(this.doc,"option",{text:this.t(`total.${de.name}`),attrs:{value:de.name,selected:de.name===ne?"":null}}));ae.value=ne,this.off.push(X(ae,"change",()=>{this.host.setValueAggregation(J,ae.value),this.refresh()})),ee.appendChild(ae)}const te=W(this.doc,"button",{class:L.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(te,"click",()=>this.dropFromZone(R,J))),ee.appendChild(te),_.appendChild(ee)}return this.off.push(X(I,"dragover",J=>{v(J.preventDefault)&&J.preventDefault(),I.setAttribute("data-over","true")})),this.off.push(X(I,"dragleave",()=>I.removeAttribute("data-over"))),this.off.push(X(I,"drop",J=>{v(J.preventDefault)&&J.preventDefault(),I.removeAttribute("data-over"),this.dragging&&this.addToZone(R,this.dragging)})),I.appendChild(_),I}static aggregations=Object.freeze(Object.keys(b).map(R=>({name:R})));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(R){const S=E.zoneApi[R],I=this.host;return S&&v(I[S.read])?I[S.read]()||[]:[]}titleOf(R){const S=this.columns().find(I=>I.id===R);return String(S&&(S.title||S.id)||R)}addToZone(R,S){const I=E.zoneApi[R],q=this.columns().find(_=>_.id===S);if(!I||!q||q[I.permission]===!1||!v(this.host[I.write]))return!1;const Z=this.zoneColumns(R);return Z.includes(S)?!1:(this.host[I.write]([...Z,S]),this.refresh(),!0)}dropFromZone(R,S){const I=E.zoneApi[R];return!I||!v(this.host[I.write])?!1:(this.host[I.write](this.zoneColumns(R).filter(q=>q!==S)),this.refresh(),!0)}setVisible(R,S){const I=this.host;S&&v(I.showColumns)?I.showColumns([R]):!S&&v(I.hideColumns)&&I.hideColumns([R])}}class T extends k{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 R=this.root;if(!R)return;for(const ee of this.off)ee();this.off.length=0,H(R);const S=this.host,I=(v(S.columns)?S.columns():[]).filter(ee=>!(ee.filter&&ee.filter.enabled===!1));if(!v(S.filterFor))return;const q=I.filter(ee=>this.isFiltered(ee.id));R.appendChild(this.buildSearch()),R.appendChild(this.buildSummary(q.length,I.length));const Z=this.query.trim().toLowerCase(),_=Z?I.filter(ee=>String(ee.title||ee.id).toLowerCase().includes(Z)):I;if(!_.length){R.appendChild(W(this.doc,"p",{class:`${L.panel}__empty`,text:Z?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${L.panel}__filters`});for(const ee of _)J.appendChild(this.buildSection(ee));R.appendChild(J)}isFiltered(R){const S=this.host;return v(S.isFiltered)?S.isFiltered(R)===!0:!1}buildSearch(){const R=W(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return R.value=this.query,this.off.push(X(R,"input",()=>{this.query=R.value||"",this.refresh();const S=this.root&&this.root.querySelector?this.root.querySelector(`.${L.panel}__search`):null;S&&v(S.focus)&&S.focus()})),R}buildSummary(R,S){const I=W(this.doc,"div",{class:`${L.panel}__filterSummary`});if(I.appendChild(W(this.doc,"span",{class:`${L.panel}__filterCount`,text:R?this.t("panel.filterSummaryActive",{active:R,total:S}):this.t("panel.filterSummaryNone",{total:S}),attrs:{"data-active":R?"true":"false"}})),!R)return I;const q=W(this.doc,"button",{class:`${L.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(X(q,"click",()=>{v(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),I.appendChild(q),I}buildSection(R){const S=R.id,I=String(R.title||S),q=this.isFiltered(S),Z=this.open.has(S),_=W(this.doc,"section",{class:`${L.panel}__filter`,attrs:{"data-col":S,"data-filtered":q?"true":null}}),J=W(this.doc,"button",{class:`${L.panel}__filterTitle`,attrs:{type:"button","aria-expanded":Z?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:I})},children:[u(this.doc,Z?"chevronDown":"chevronRight",{className:`${L.panel}__twisty`}),W(this.doc,"span",{class:`${L.panel}__filterName`,text:I})]});q&&J.appendChild(W(this.doc,"span",{class:`${L.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ee=W(this.doc,"div",{class:`${L.panel}__filterBody`,style:{display:Z?"":"none"}}),te=()=>{if(ee.firstChild)return;const ne=this.host.filterFor(S);ne&&v(ne.element)&&ee.appendChild(ne.element())};if(this.off.push(X(J,"click",()=>{const ne=this.open.has(S);ne?this.open.delete(S):this.open.add(S),J.setAttribute("aria-expanded",ne?"false":"true"),ee.style.display=ne?"none":"";const ae=J.firstElementChild;ae&&a(ae,ne?"chevronRight":"chevronDown"),ne||te()})),_.appendChild(J),q){const ne=W(this.doc,"button",{class:`${L.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:I}),title:this.t("panel.clearFilter")},children:[u(this.doc,"close",{className:L.icon})]});this.off.push(X(ne,"click",ae=>{v(ae.stopPropagation)&&ae.stopPropagation(),v(this.host.clearFilter)&&this.host.clearFilter(S),this.refresh()})),_.appendChild(ne)}return _.appendChild(ee),Z&&te(),_}}class P extends k{refresh(){const R=this.root;if(!R)return;if(this.box){const Z=v(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==Z&&(this.box.value=Z),this.paintCount();return}for(const Z of this.off)Z();this.off.length=0,H(R);const S=v(this.host.quickFilter)?this.host.quickFilter():"",I=W(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});I.value=S||"",this.off.push(X(I,"input",()=>{v(this.host.setQuickFilter)&&this.host.setQuickFilter(I.value),this.paintCount()})),R.appendChild(I),this.box=I;const q=W(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(X(q,"click",()=>{I.value="",v(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),v(I.focus)&&I.focus()})),R.appendChild(q),this.count=W(this.doc,"p",{class:`${L.panel}__count`}),R.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){O(()=>{this.box&&v(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const R=v(this.host.rowCount)?this.host.rowCount():null,S=v(this.host.totalRowCount)?this.host.totalRowCount():null;if(R===null||S===null){this.count.textContent="";return}this.count.textContent=R===S?this.t("count.rows",{count:S}):this.t("panel.rowsOf",{shown:R,total:S})}}const x=Object.freeze({columns:E,filters:T,views:t,quick:P,formatting:o,statistics:c,regression:g,compare:h,insights:m}),C=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),A=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class j{panels=[];actions=[];root=null;openPanel=null;off=[];t(R,S){return(this.messages&&typeof this.messages.t=="function"?this.messages:K).t(R,S)}init(R){const S=R||{};this.doc=F(S),this.host=S.host||{},this.messages=S.messages||S.grid&&S.grid.messages||K,this.icons=S.icons===void 0?S.side==="left":!!S.icons,this.side=S.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[L.panel,`${L.panel}--${this.side}`,this.icons?`${L.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${L.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${L.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:`${L.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const Z of Array.isArray(S.actions)?S.actions:[])this.registerAction(Z);const I=S.registry||{},q=Array.isArray(S.panels)&&S.panels.length?S.panels:["columns","filters"];for(const Z of q){const _=typeof Z=="string"?Z:Z.name,J=typeof Z=="function"?Z:I[_]||x[_];J&&this.registerPanel(String(_),J,typeof Z=="object"?Z:{})}S.openPanel&&this.show(S.openPanel)}registerPanel(R,S,I){const q=new S;q.init({document:this.doc,host:this.host,props:I&&I.props||{}});const Z=I&&I.title||R,_=I&&I.icon||R,J=W(this.doc,"button",{class:`${L.panel}__tab`,text:this.icons?null:Z,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":R,title:this.icons?Z:null,"aria-label":this.icons?Z:null}});return this.icons&&J.appendChild(u(this.doc,_,{className:`${L.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(R))),this.tabs.appendChild(J),this.panels.push({name:R,title:Z,panel:q}),q}registerAction(R){if(!R||!R.name)return null;if(R.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${L.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const S=W(this.doc,"button",{class:`${L.panel}__action`,text:this.icons?null:v(R.title)?String(R.title()):R.title,attrs:{type:"button","data-action":R.name,title:v(R.title)?null:R.title,"aria-label":v(R.title)?null:R.title}});if(this.icons){const Z=(v(R.icon)?R.icon():R.icon)||(s(R.name)?R.name:"blank");S.appendChild(u(this.doc,Z,{className:`${L.panel}__icon`})),S.setAttribute("data-icon",Z)}const I=X(S,"click",()=>{v(R.enabled)&&!R.enabled()||(v(R.run)&&R.run(),this.paintActions())});return this.off.push(I),this.actionGroup.appendChild(S),this.actions.push({...R,button:S,offClick:I}),this.paintActions(),S}removeAction(R){const S=this.actions.findIndex(q=>q.name===R);if(S<0)return!1;const I=this.actions[S];return v(I.offClick)&&I.offClick(),I.button&&I.button.parentNode&&I.button.parentNode.removeChild(I.button),this.actions.splice(S,1),!0}paintActions(){for(const R of this.actions){if(!R.button)continue;const S=v(R.enabled)?!!R.enabled():!0;if(R.button.disabled=!S,R.button.setAttribute("aria-disabled",S?"false":"true"),v(R.active)&&R.button.setAttribute("aria-pressed",R.active()?"true":"false"),v(R.title)){const I=String(R.title());R.button.setAttribute("title",I),R.button.setAttribute("aria-label",I),!this.icons&&R.button.textContent!==I&&(R.button.textContent=I)}if(this.icons&&v(R.icon)){const I=String(R.icon());R.button.getAttribute("data-icon")!==I&&(H(R.button),R.button.appendChild(u(this.doc,I,{className:`${L.panel}__icon`})),R.button.setAttribute("data-icon",I))}}}show(R){const S=this.panels.find(I=>I.name===R);return S?(H(this.body),v(S.panel.refresh)&&S.panel.refresh(),this.body.appendChild(S.panel.element()),this.openPanel=R,this.paintTabs(),v(S.panel.focus)&&S.panel.focus(),!0):!1}hide(){H(this.body),this.openPanel=null,this.paintTabs()}toggle(R){this.openPanel===R?this.hide():this.show(R)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let R=0;R<this.tabs.childNodes.length;R++){const S=this.tabs.childNodes[R];S&&S.setAttribute&&S.setAttribute("aria-selected",S.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const R=this.panels.find(S=>S.name===this.openPanel);R&&v(R.panel.refresh)&&!this.#e(R.panel)&&R.panel.refresh(),this.paintActions()}#e(R){const S=this.doc&&this.doc.activeElement;if(!S||S===this.doc.body)return!1;const I=v(R.element)?R.element():null;return!!(I&&v(I.contains)&&I.contains(S))}destroy(){for(const R of this.off)R();this.off.length=0;for(const R of this.panels)v(R.panel.destroy)&&R.panel.destroy();this.panels=[],this.root=null}}const $=j;function z(M,R){if(!R.getBoundingClientRect||typeof M.clientY!="number")return!0;const S=R.getBoundingClientRect();return M.clientY<S.top+S.height/2}}),xe("packages/dom/src/ui/groupbyzone.js",function(e,G){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return O}});const L=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=G("packages/dom/src/editors/common.js"),F=B.CLS,W=B.el,X=B.on,H=B.clear,V=B.cssEscape,D=G("packages/core/src/internal/util.js").isFunction,v="text/x-lattice-col";class O extends L{dragging=null;#e=[];init(u){this.ctx=u,this.doc=u.document,this.host=u.host||{},this.props=u.props||{},this.root=W(this.doc,"div",{class:F.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const u=this.host;return D(u.columns)?u.columns()||[]:u.columns&&D(u.columns.all)?u.columns.all():[]}groups(){return D(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(u){D(this.host.setGroupBy)&&this.host.setGroupBy(u)}titleOf(u){const a=this.columns().find(s=>s.id===u);return String(a&&(a.title||a.id)||u)}canGroup(u){const a=this.columns().find(s=>s.id===u);return!!a&&a.allowGroup!==!1&&!a.generated}announce(u,a){D(this.host.announce)&&this.host.announce(u,a)}refresh(){const u=this.root;if(!u)return;for(const n of this.off)n();this.off.length=0,H(u),u.appendChild(W(this.doc,"span",{class:F.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const a=this.groups(),s=W(this.doc,"div",{class:F.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});a.length||s.appendChild(W(this.doc,"span",{class:F.groupZoneHint,text:this.t("groupZone.hint")})),a.forEach((n,t)=>s.appendChild(this.#t(n,t,a.length))),u.appendChild(s),this.chips=s,u.appendChild(this.#i(a)),this.off.push(X(u,"dragover",n=>{this.dragging==null&&!this.#l(n)||(D(n.preventDefault)&&n.preventDefault(),u.setAttribute("data-over","true"))})),this.off.push(X(u,"dragleave",()=>u.removeAttribute("data-over"))),this.off.push(X(u,"drop",n=>{D(n.preventDefault)&&n.preventDefault(),u.removeAttribute("data-over");const t=this.#l(n)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(u,a,s){const n=this.titleOf(u),t=W(this.doc,"div",{class:[F.chip,F.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":u,"aria-label":this.t("groupZone.chip",{column:n,at:a+1,of:s})}});t.appendChild(W(this.doc,"span",{class:F.groupZoneChipText,text:n}));const r=W(this.doc,"button",{class:F.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:n})}});return this.off.push(X(r,"click",()=>this.#r(u))),t.appendChild(r),this.off.push(X(t,"dragstart",o=>{this.dragging=u,o.dataTransfer&&D(o.dataTransfer.setData)&&o.dataTransfer.setData(v,u)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",o=>{const f=this.#l(o)||this.dragging;f==null||f===u||D(o.preventDefault)&&o.preventDefault()})),this.off.push(X(t,"drop",o=>{const f=this.#l(o)||this.dragging;f!=null&&(D(o.preventDefault)&&o.preventDefault(),D(o.stopPropagation)&&o.stopPropagation(),this.#o(f,a))})),this.off.push(X(t,"keydown",o=>this.#n(o,u,a))),t}#n(u,a,s){const n=u&&u.key,t=this.groups();if(n==="Delete"||n==="Backspace"){D(u.preventDefault)&&u.preventDefault(),this.#r(a,t,s);return}const r=n==="ArrowLeft"||n==="ArrowUp",o=n==="ArrowRight"||n==="ArrowDown",f=n==="Home",c=n==="End";if(!r&&!o&&!f&&!c)return;if(D(u.preventDefault)&&u.preventDefault(),u.shiftKey&&(r||o)){const d=s+(r?-1:1);if(d<0||d>=t.length){this.announce(this.t(r?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(a)}),{repeat:!0});return}const h=t.slice();h.splice(s,1),h.splice(d,0,a),this.setGroups(h),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(a),at:d+1,of:h.length}),{repeat:!0}),this.#a(a);return}let i=s+(r?-1:o?1:0);f&&(i=0),c&&(i=t.length-1);const g=t[i];g&&this.#a(g)}#r(u,a=this.groups(),s=a.indexOf(u)){const n=this.titleOf(u);this.setGroups(a.filter(r=>r!==u)),this.announce(this.t("a11y.panel.removedFrom",{column:n,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(s,t.length-1)]):this.#u()}#o(u,a){if(!this.canGroup(u)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0});return}const s=this.groups(),n=s.indexOf(u),t=s.slice();n>=0&&(t.splice(n,1),n<a&&(a-=1)),t.splice(Math.max(0,Math.min(a,t.length)),0,u),this.setGroups(t);const r=t.indexOf(u);this.announce(this.t(n>=0?"a11y.panel.moved":"a11y.panel.addedTo",n>=0?{column:this.titleOf(u),at:r+1,of:t.length}:{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(u)}#i(u){const a=new Set(u),s=W(this.doc,"label",{class:F.groupZoneAdd}),n=W(this.doc,"select",{class:F.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});n.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())a.has(t.id)||!this.canGroup(t.id)||n.appendChild(W(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(n,"change",()=>{const t=n.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=n,s.appendChild(n),s}#s(){for(const a of this.#e)a();this.#e.length=0;const u=this.props&&this.props.header;if(!(!u||!D(u.querySelectorAll)))for(const a of u.querySelectorAll("[data-col]")){const s=D(a.getAttribute)?a.getAttribute("data-col"):null;!s||!this.canGroup(s)||(D(a.setAttribute)&&a.setAttribute("draggable","true"),this.#e.push(X(a,"dragstart",n=>{this.dragging=s,n.dataTransfer&&D(n.dataTransfer.setData)&&n.dataTransfer.setData(v,s)})),this.#e.push(X(a,"dragend",()=>{this.dragging=null})))}}#l(u){const a=u&&u.dataTransfer;if(a&&D(a.getData)){const s=a.getData(v);if(s)return s}return null}#a(u){const a=this.chips&&D(this.chips.querySelector)?this.chips.querySelector(`[data-col="${V(u)}"]`):null;a&&D(a.focus)&&a.focus()}#u(){this.adderSelect&&D(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const u of this.#e)u();this.#e.length=0,super.destroy()}}}),xe("packages/dom/src/ui/tooltip.js",function(e,G){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.documentFor,F=Q.el,W=Q.on,X=Q.clear,V=G("packages/core/src/internal/util.js").isFunction;class K{root=null;init(y){this.doc=y.document,this.root=F(this.doc,"div",{class:`${L.tooltip}__text`}),this.update(y.content)}update(y){if(!this.root)return;const u=y==null?"":String(y);this.root.textContent!==u&&(this.root.textContent=u)}element(){return this.root}destroy(){this.root=null}}class D{root=null;component=null;timer=null;target=null;off=[];constructor(y){const u=y||{};this.doc=B(u),this.host=u.host||this.doc.body,this.delay=u.delay??400,this.hideDelay=u.hideDelay??0,this.components={text:K,...u.components||{}}}show(y){this.cancelTimer();const u=y.delay??this.delay;if(!u){this.showNow(y);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(y)},u)}showNow(y){const u=y.component||"text",a=typeof u=="function"?u:this.components[u]||K;return this.root||(this.root=F(this.doc,"div",{class:L.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==a?(this.component&&V(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new a,this.componentCtor=a,this.component.init({document:this.doc,content:y.content,...y.props||{}}),this.root.appendChild(this.component.element())):V(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||!V(this.target.getBoundingClientRect))return;const y=this.target.getBoundingClientRect(),u=this.doc.defaultView||{};this.root.style.left=`${y.left+(u.scrollX||0)}px`,this.root.style.top=`${y.bottom+(u.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(y,u,a){const s=()=>this.show({target:y,content:u(),...a||{}}),n=()=>this.hide(),t=[W(y,"mouseenter",s),W(y,"mouseleave",n),W(y,"focus",s),W(y,"blur",n)],r=()=>{for(const o of t)o()};return this.off.push(r),r}destroy(){this.hide();for(const y of this.off)y();this.off.length=0,this.component&&V(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const v=D}),xe("packages/dom/src/ui/pagination.js",function(e,G){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.documentFor,F=Q.el,W=Q.on,X=Q.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction;function v(u){const a=Math.max(1,Number(u.pageSize)||100),s=u.total==null?null:Math.max(0,Number(u.total)),n=s==null?null:Math.max(1,Math.ceil(s/a)),t=Math.max(0,n==null?Number(u.page)||0:Math.min(Number(u.page)||0,n-1)),r=s===0?0:t*a+1,o=s==null?(t+1)*a:Math.min(s,(t+1)*a);return{page:t,pageSize:a,pageCount:n,from:r,to:o,first:t===0,last:n==null?u.hasMore!==!0:t>=n-1,total:s}}class O{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(a){const s=a||{};this.doc=B(s),this.host=s.host||{},this.pageSize=Number(s.pageSize)||100;const n=Array.isArray(s.pageSizes)&&s.pageSizes.length?[...s.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!n.includes(this.pageSize)&&n.push(this.pageSize),this.pageSizes=n.sort((t,r)=>t-r),this.page=Number(s.page)||0,this.total=s.total===void 0?null:s.total,this.locale=s.locale,this.messages=s.messages||null,this.onChange=s.onChange||null,this.root=F(this.doc,"nav",{class:L.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(a,s){const n=this.messages;return(n&&typeof n.t=="function"?n:V).t(a,s)}element(){return this.root}model(){return v({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(a){a.total!==void 0&&(this.total=a.total),a.counting!==void 0&&(this.counting=a.counting===!0),a.hasMore!==void 0&&(this.hasMore=a.hasMore===!0),a.page!==void 0&&(this.page=Number(a.page)||0),this.paint()}goTo(a){const s=this.page;this.page=a;const n=this.model();return this.page=n.page,this.paint(),this.page!==s&&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 a=this.model();return a.pageCount==null?this.page:this.goTo(a.pageCount-1)}setPageSize(a){const s=this.page*this.pageSize;this.pageSize=Math.max(1,Number(a)||1),this.page=Math.floor(s/this.pageSize),this.paint(),D(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const a=this.root;if(!a)return;for(const i of this.off)i();this.off.length=0,X(a);const s=this.model(),n=F(this.doc,"select",{class:`${L.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const i of this.pageSizes)n.appendChild(F(this.doc,"option",{text:String(i),attrs:{value:i}}));n.value=String(this.pageSize),this.off.push(W(n,"change",()=>this.setPageSize(Number(n.value)))),a.appendChild(n);const t=s.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:s.from,to:s.to}):this.t("pagination.summary",{from:s.from,to:s.to,total:s.total});a.appendChild(F(this.doc,"span",{class:`${L.pagination}__summary`,text:t}));const r=(i,g,d,h)=>{const l=F(this.doc,"button",{class:`${L.pagination}__button`,text:i,attrs:{type:"button","aria-label":h,disabled:d?"":null}});return d||this.off.push(W(l,"click",g)),l};a.appendChild(r("«",()=>this.goTo(0),s.first,this.t("pagination.first"))),a.appendChild(r("‹",()=>this.previous(),s.first,this.t("pagination.previous")));const o=F(this.doc,"span",{class:`${L.pagination}__page`});o.appendChild(F(this.doc,"span",{text:`${this.t("pagination.page")} `}));const f=F(this.doc,"input",{class:`${L.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":s.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:s.pageCount}),size:String(Math.max(2,String(s.pageCount??s.page+1).length))}});f.value=String(s.page+1);const c=()=>{const i=parseInt(String(f.value).trim(),10);if(!Number.isFinite(i)){f.value=String(this.model().page+1);return}this.goTo(i-1)};this.off.push(W(f,"keydown",i=>{i.key==="Enter"?(c(),i.preventDefault?.()):i.key==="Escape"?(f.value=String(this.model().page+1),f.blur?.()):i.stopPropagation?.()})),this.off.push(W(f,"blur",()=>c())),this.off.push(W(f,"focus",()=>f.select?.())),o.appendChild(f),s.pageCount!=null&&o.appendChild(F(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:s.pageCount})}`})),a.appendChild(o),a.appendChild(r("›",()=>this.next(),s.last,this.t("pagination.next"))),a.appendChild(r("»",()=>this.last(),s.last||s.pageCount==null,this.t("pagination.last")))}destroy(){for(const a of this.off)a();this.off.length=0,this.root=null}}const y=O}),xe("packages/dom/src/ui/overlay.js",function(e,G){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=G("packages/dom/src/editors/common.js"),L=Q.CLS,B=Q.documentFor,F=Q.el,W=Q.clear,H=G("packages/core/src/internal/util.js").isFunction,K=G("packages/core/src/i18n/index.js").defaultMessages;function D(s,n){const t=s&&s.grid&&s.grid.messages;return(t&&H(t.t)?t:K).t(n)}class v{root=null;init(n){this.doc=n.document,this.root=F(this.doc,"div",{class:`${L.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[F(this.doc,"span",{class:`${L.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),F(this.doc,"span",{class:`${L.overlay}__message`,text:n.message||D(n,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class O{root=null;init(n){this.doc=n.document,this.root=F(this.doc,"div",{class:`${L.overlay}__empty`,attrs:{role:"status"},children:[F(this.doc,"span",{class:`${L.overlay}__message`,text:n.message||D(n,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:v,empty:O});class u{root=null;slot=null;component=null;current=null;init(n){const t=n||{};this.doc=B(t),this.components={...y,...t.components||{}},this.root=F(this.doc,"div",{class:L.overlay,attrs:{"data-open":"false"}}),this.slot=F(this.doc,"div",{class:`${L.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(n,t){const r=typeof n=="function"?n:this.components[n];return r?(this.hide(),this.component=new r,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof n=="string"?n:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&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(n,t){this.components[n]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const a=u}),xe("packages/dom/src/ui/index.js",function(e,G){"use strict";const Q=G("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return Q.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return Q.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return Q.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return Q.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return Q.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return Q.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return Q.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return Q.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return Q.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return Q.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return Q.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return Q.formatNumber}});const L=G("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return L.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return L.resolveMenuItems}});const B=G("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return B.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return B.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return B.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return B.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return B.toolPanels}});const F=G("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return F.GroupByZone}});const W=G("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 X=G("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return X.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return X.pageModel}});const H=G("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}})}),xe("packages/dom/src/ui/celltooltip.js",function(e,G){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=G("packages/dom/src/editors/common.js"),L=Q.documentFor,B=Q.el,F=Q.on,W=Q.clear,X=G("packages/core/src/internal/util.js"),H=X.isFunction,V=X.warnOnce,D=G("packages/dom/src/cell/sanitise.js").sanitiseHtml,O=G("packages/dom/src/detailhost.js").insideDetail,u=G("packages/dom/src/renderer/renderer.js").displayIndexOf,a=G("packages/dom/src/renderer/viewport.js"),s=a.CLASS,n=a.NAMESPACE,r=G("packages/dom/src/themeof.js").carryTheme,o={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},f=400,c=140,i=6;let g=0;class d{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h=[];#p=!1;constructor(m){const w=m||{};this.#e=w.grid,this.#t=w.host,this.#n=w.viewport,this.#r=L(w),g+=1,this.#s=`lat-cell-tooltip-${g}`}mount(){const m=this.#n&&this.#n.root;if(!m||!H(m.addEventListener))return;const w=this.#e.on("cell:mouseover",b=>this.#w(b));H(w)&&this.#h.push(w);const k=this.#e.on("cell:mouseout",()=>this.#j());H(k)&&this.#h.push(k),this.#h.push(F(m,"focusin",b=>this.#k(b))),this.#h.push(F(m,"focusout",()=>this.#j())),this.#h.push(F(this.#r,"keydown",b=>this.#b(b),!0));const p=this.#r.defaultView;p&&H(p.addEventListener)&&this.#h.push(F(p,"scroll",()=>this.hide(),!0))}#m(){const m=H(this.#e.get)?this.#e.get("tooltip"):null,w=m&&typeof m=="object"?m:{},k=Number.isFinite(w.delay)&&w.delay>=0?Number(w.delay):f,p=w.maxWidth;return{delay:k,hideDelay:c,maxWidth:typeof p=="number"&&Number.isFinite(p)?`${p}px`:typeof p=="string"&&p?p:null}}#g(m){const w=m&&m.cell?m.cell.tooltip:null;return!w||typeof w!="object"||Array.isArray(w)||!H(w.render)&&!H(w.mount)?null:w}#y(m){if(!m||!H(m.closest))return null;const w=m.closest(`.${s.row}`);if(!w)return null;const k=u(w);if(k<0)return null;const p=this.#t.rowAt(k);if(!p)return null;const b=m.getAttribute("data-col");if(!b)return null;const E=this.#t.columns.get(b);return E?{row:p,key:p.key,index:k,colId:b,column:E,value:this.#t.cellValue?this.#t.cellValue(p,E):void 0,text:this.#t.cellText?this.#t.cellText(p,E):"",cell:m,grid:this.#e}:null}#w(m){const w=m&&m.target;if(!this.#g(m&&m.column)){this.#j();return}this.#O(w)}#k(m){const w=m&&m.target;if(!w||!H(w.closest)||O(w,this.#n.root))return;const k=w.closest(`.${s.cell}`);if(!k||k!==w){this.#j();return}const p=k.getAttribute("data-col"),b=p?this.#t.columns.get(p):null;if(!this.#g(b)){this.#j();return}this.#O(k)}#b(m){!m||m.key!=="Escape"||m.defaultPrevented||this.#l&&(H(m.preventDefault)&&m.preventDefault(),this.hide())}#O(m){if(this.#p||!m||(this.#x(),this.#l&&this.#a===m))return;this.#L();const{delay:w}=this.#m();if(!w){this.#A(m);return}this.#d=setTimeout(()=>{this.#d=null,this.#A(m)},w)}#j(){if(this.#L(),!this.#l||this.#f!==null)return;const{hideDelay:m}=this.#m();this.#f=setTimeout(()=>{this.#f=null,this.hide()},m)}#P(){if(this.#o)return this.#o;const m=this.#r,w=B(m,"div",{class:[n,o.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(m,"div",{class:o.body}),w.appendChild(this.#i),this.#h.push(F(w,"mouseenter",()=>this.#x())),this.#h.push(F(w,"mouseleave",()=>this.#j()));const k=m.body;return k&&H(k.appendChild)&&k.appendChild(w),this.#o=w,w}#S(m,w){const k=this.#i;if(W(k),m==null||m==="")return!1;if(typeof m=="string")return k.textContent=m,!0;if(typeof m=="object"){if(typeof m.nodeType=="number")return k.appendChild(m),!0;const p=m;if(typeof p.html=="string")return k.innerHTML=D(p.html),!0;if(p.title!==void 0||p.rows!==void 0||p.note!==void 0)return this.#M(p),!0}return V(`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}#M(m){const w=this.#r,k=this.#i,p=E=>E==null?"":String(E);m.title!==void 0&&m.title!==null&&m.title!==""&&k.appendChild(B(w,"div",{class:o.title,text:p(m.title)}));const b=Array.isArray(m.rows)?m.rows:[];if(b.length){const E=B(w,"div",{class:o.rows});for(const T of b){if(!T||typeof T!="object")continue;const P=B(w,"div",{class:o.row});P.appendChild(B(w,"span",{class:o.label,text:p(T.label)})),P.appendChild(B(w,"span",{class:o.value,text:p(T.value)})),E.appendChild(P)}k.appendChild(E)}m.note!==void 0&&m.note!==null&&m.note!==""&&k.appendChild(B(w,"div",{class:o.note,text:p(m.note)}))}#A(m){if(this.#p)return;const w=this.#y(m);if(!w){this.hide();return}const k=this.#g(w.column);if(!k){this.hide();return}this.hide();const p=this.#P();r(p,this.#n&&this.#n.root);let b;if(H(k.render))try{b=k.render(w)}catch(P){V(`tooltip-render:${w.colId}`,`Column '${w.colId}' cell.tooltip render threw; no tooltip was shown.`,P);return}const E=this.#S(b,w.colId);if(H(k.mount))try{k.mount(this.#i,w),this.#u=k}catch(P){V(`tooltip-mount:${w.colId}`,`Column '${w.colId}' cell.tooltip mount threw; the tooltip was closed.`,P),this.hide();return}else if(!E)return;const{maxWidth:T}=this.#m();T&&(p.style.maxWidth=T),this.#a=m,this.#l=!0,p.setAttribute("data-open","true"),this.#E(m),this.#R(m)}#E(m){if(!H(m.setAttribute))return;const w=H(m.getAttribute)?m.getAttribute("aria-describedby"):null;this.#c={cell:m,previous:w},m.setAttribute("aria-describedby",w?`${w} ${this.#s}`:this.#s)}#R(m){const w=this.#o;if(!w||!H(m.getBoundingClientRect))return;const k=this.#r.defaultView;if(!k)return;const p=m.getBoundingClientRect(),b=H(w.getBoundingClientRect)?w.getBoundingClientRect():{width:0,height:0},E=k.innerWidth||0,T=k.innerHeight||0,P=b.width||0,x=b.height||0;let C=p.bottom+i;const A=p.top-i-x;C+x>T-i&&A>=i&&(C=A),T&&(C=Math.max(i,Math.min(C,Math.max(i,T-x-i))));let j=p.left;E&&(j=Math.min(j,Math.max(i,E-P-i))),j=Math.max(i,j),w.style.left=`${Math.round(j)}px`,w.style.top=`${Math.round(C)}px`}hide(){if(this.#L(),this.#x(),!this.#l)return;if(this.#l=!1,this.#u&&H(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(w){V("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 m=this.#c;m&&H(m.cell.setAttribute)&&(m.previous?m.cell.setAttribute("aria-describedby",m.previous):H(m.cell.removeAttribute)&&m.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#L(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#x(){this.#f!==null&&(clearTimeout(this.#f),this.#f=null)}destroy(){this.hide(),this.#p=!0;for(const m of this.#h)m();this.#h.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=d}),xe("packages/dom/src/platform.js",function(e,G){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Q}});function Q(){const L=globalThis.navigator,B=String(L&&(L.userAgentData?.platform||L.platform)||"");return/mac|iphone|ipad/i.test(B)}}),xe("packages/dom/src/columnmenu.js",function(e,G){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/dom/src/platform.js").macLike,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/dom/src/ui/contextmenu.js").ContextMenu,D=G("packages/core/src/compute/total.js"),v=D.aggregatesFor,O=D.totalLabel,y=10,u=150;function a(k,p){const b=(ee,te)=>(k&&k.messages?k.messages:H).t(ee,te),E=k.columns.get(p);if(!E)return[];const T=k.sort.get(),P=T.find(ee=>ee.col===p),x=E.layout&&E.layout.pin,C=k.state.get().group||[],A=C.includes(p);if(E.generated&&Array.isArray(E.groupedIds))return r(k,E,C);const j=!E.sort||E.sort.enabled!==!1,$=!E.filter||E.filter.enabled!==!1,z=[];j&&z.push({name:b("menu.sortAscending"),icon:"↑",disabled:P&&P.dir==="asc",action:()=>k.sort.set([{col:p,dir:"asc"}])},{name:b("menu.sortDescending"),icon:"↓",disabled:P&&P.dir==="desc",action:()=>k.sort.set([{col:p,dir:"desc"}])},{name:b("menu.clearSort"),disabled:!P,action:()=>k.sort.set(T.filter(ee=>ee.col!==p))},{separator:!0}),$&&z.push({name:b("menu.filterEllipsis"),action:()=>k.emit("column:filter:open",{colId:p})},{separator:!0}),z.push({name:b("menu.columnStatistics"),action:()=>k.emit("column:profile:open",{colId:p})},{separator:!0}),z.push({name:b("menu.pinColumn"),children:[{name:b("menu.pinStart"),disabled:x==="start",action:()=>k.columns.pin(p,"start")},{name:b("menu.pinEnd"),disabled:x==="end",action:()=>k.columns.pin(p,"end")},{name:b("menu.unpin"),disabled:!x,action:()=>k.columns.pin(p,null)}]});const M=!(E.layout&&(E.layout.movable===!1||E.layout.lockPosition)),R=!(E.layout&&E.layout.resizable===!1),S=ee=>{const te=k.columns.get(ee);return Number(te&&te.layout&&te.layout.width)||u},I=k.columns.visible().filter(ee=>!ee.generated).map(ee=>ee.id),q=I.indexOf(p);if(z.push({name:b("menu.sizeToFit"),action:()=>k.columns.autoSize(p)},{name:b("menu.sizeAllToFit"),action:()=>k.columns.fit()},{name:b("menu.width"),disabled:!R,children:[{name:b("menu.narrower"),disabled:!R,action:()=>k.columns.resize(p,Math.max(1,S(p)-y))},{name:b("menu.wider"),disabled:!R,action:()=>k.columns.resize(p,S(p)+y)},{name:b("menu.autosize"),disabled:!R,action:()=>k.columns.autoSize(p)}]},{separator:!0},{name:b("menu.moveColumn"),disabled:!M,children:[{name:b("menu.moveLeft"),disabled:!M||q<=0,action:()=>k.columns.move(p,Math.max(0,q-1))},{name:b("menu.moveRight"),disabled:!M||q<0||q>=I.length-1,action:()=>k.columns.move(p,Math.min(I.length-1,q+1))},{name:b("menu.moveToStart"),disabled:!M||q<=0,action:()=>k.columns.move(p,0)},{name:b("menu.moveToEnd"),disabled:!M||q<0||q>=I.length-1,action:()=>k.columns.move(p,I.length-1)}]},{separator:!0}),E.allowGroup!==!1&&z.push({name:b(A?"menu.ungroup":"menu.groupBy"),action:()=>k.columns.group(A?C.filter(ee=>ee!==p):[...C,p])}),C.length&&z.push({name:b("menu.expandAll"),action:()=>k.rows.expandAll()},{name:b("menu.collapseAll"),action:()=>k.rows.collapseAll()}),L(k.columns.groupColumns)){const ee=E.groupPath||[],te=ee.length?ee[ee.length-1]:null,ne=[{name:b("columngroup.group"),disabled:I.length<2||q<0,action:()=>{const ae=I[q+1]??I[q-1];if(!ae)return;const de=(k.columns.get(ae)||{}).groupPath||[],ie=de.length?de[de.length-1]:null;ie?k.columns.groupColumns([p],{groupId:ie}):k.columns.groupColumns([p,ae],{title:b("columngroup.newGroup")})}}];te&&ne.push({name:b("columngroup.dissolve"),action:()=>k.columns.dissolveGroup(te)}),z.push({separator:!0},...ne)}const Z=k.state&&L(k.state.get)?k.state.get().pivot:null,_=Z&&Z.columns||[],J=_.includes(p);if(E.allowPivot!==!1&&z.push({name:b(J?"menu.unpivot":"menu.pivotBy"),action:()=>k.columns.pivot(J?_.filter(ee=>ee!==p):[..._,p])}),E.allowTotal!==!1)if(L(k.get)&&k.get("aggregateChooser")===!0)z.push(s(k,E,b));else{const te=!!E.total;z.push({name:b(te?"menu.stopTotalling":"menu.totalColumn"),action:()=>k.columns.setTotal(p,te?null:"sum")})}return z.push({name:b("menu.hideColumn"),disabled:E.layout&&E.layout.lockVisible===!0,action:()=>k.columns.hide(p)}),z}function s(k,p,b){const E=p.id,T=typeof p.total=="string"?p.total:null,P=[{name:b("menu.aggregateNone"),checked:!p.total,action:()=>k.columns.setTotal(E,null)},{separator:!0},...v(p).map(x=>({name:O(x),checked:T===x,action:()=>k.columns.setTotal(E,x)})),{separator:!0},n(k,p,b,"group",b("menu.aggregateGroup")),n(k,p,b,"grand",b("menu.aggregateGrand"))];return{name:b("menu.aggregate"),children:P}}function n(k,p,b,E,T){const P=p.id,x=E==="grand"?p.grandTotal:p.groupTotal,C=typeof x=="string"?x:null,A=[{name:b("menu.aggregateSame"),checked:x==null,action:()=>k.columns.setTotal(P,null,{scope:E})},{separator:!0},...v(p).map(j=>({name:O(j),checked:C===j,action:()=>k.columns.setTotal(P,j,{scope:E})}))];return{name:T,children:A}}function t(k,p){const b=(C,A)=>(k&&k.messages?k.messages:H).t(C,A),E=k.columns.get(p);if(!E)return[];const T=k.redaction,P=!!(T&&T.has(p)),x=[];return T&&(x.push({name:b(P?"menu.stopRedacting":"menu.redactColumn"),action:()=>T.toggle(p)}),(T.list().length>1||T.active&&!P)&&x.push({name:b("menu.stopRedactingAll"),action:()=>T.clear()}),x.push({separator:!0})),x.push({name:b("menu.hideColumn"),disabled:E.layout&&E.layout.lockVisible===!0,action:()=>k.columns.hide(p)}),x}function r(k,p,b){const E=(A,j)=>(k&&k.messages?k.messages:H).t(A,j),T=b[0],P=k.sort.get(),x=T?P.find(A=>A.col===T):null,C=[];T&&C.push({name:E("menu.sortGroupsAscending"),icon:"↑",disabled:x&&x.dir==="asc",action:()=>k.sort.set([{col:T,dir:"asc"}])},{name:E("menu.sortGroupsDescending"),icon:"↓",disabled:x&&x.dir==="desc",action:()=>k.sort.set([{col:T,dir:"desc"}])},{separator:!0},{name:E("menu.filterGroups"),action:()=>k.emit("column:filter:open",{colId:p.id})},{separator:!0}),C.push({name:E("menu.expandAll"),action:()=>k.rows.expandAll()},{name:E("menu.collapseAll"),action:()=>k.rows.collapseAll()},{separator:!0});for(const A of b){const j=k.columns.get(A);C.push({name:`Remove "${j&&j.title||A}" from grouping`,action:()=>k.columns.group(b.filter($=>$!==A))})}return C.push({name:E("menu.clearGrouping"),disabled:!b.length,action:()=>k.columns.group([])}),C}function o(){const k=globalThis.navigator&&globalThis.navigator.clipboard;return!!(k&&typeof k.readText=="function")}function f(k){return L(k.get)&&k.get("edit")===!1?!1:(k.columns&&L(k.columns.visible)?k.columns.visible():[]).some(b=>{const E=b&&b.edit;return E?E.enabled===void 0||L(E.enabled)?!0:E.enabled!==!1:!1})}function c(k,p){if(L(k.get)&&k.get("edit")===!1)return!1;const b=p&&p.edit;return b?b.enabled===void 0||L(b.enabled)?!0:b.enabled!==!1:!1}const i=new Set(["number","currency","percent","integer"]);function g(k){const p=L(k.get)?k.get("rangeChart"):void 0;return p?L(p)?{enabled:!0,handler:p}:p&&typeof p=="object"&&L(p.onChart)?{enabled:!0,handler:p.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function d(k){const p=k.selection&&L(k.selection.ranges)?k.selection.ranges():[];if(!Array.isArray(p)||!p.length)return null;const b=p[p.length-1],E=L(k.columns.visible)?k.columns.visible():[],T=new Set(E.filter(P=>P&&i.has(P.type)).map(P=>P.id));return(b.columns||[]).some(P=>T.has(P))?b:null}function h(k,p){const b=(_,J)=>(k&&k.messages?k.messages:H).t(_,J),{colId:E,row:T}=p,P=k.selection.keys().length,x=k.selection.cells().length,C=(k.state&&L(k.state.get)?k.state.get().group:null)||[],A=k.ranges||null,j=W()?"Cmd":"Ctrl",$=()=>x||P||0,z=_=>k.columns&&L(k.columns.get)?k.columns.get(_):null,M=L(k.selection.cells)?k.selection.cells():[],R=[...new Set(M.map(_=>_&&_.colId).filter(Boolean))];!R.length&&E&&R.push(E);const S=R.length?R.some(_=>c(k,z(_))):f(k),I=E?c(k,z(E)):!1,q=g(k),Z=q.enabled?d(k):null;return[{name:x>1?`Copy ${x} cells`:b("menu.copy"),shortcut:`${j}+C`,disabled:!$(),action:()=>A&&x?A.copy():k.export.clipboard({rows:P?"selected":"range"})},{name:b("menu.copyWithHeaders"),disabled:!$(),action:()=>k.export.clipboard({headers:!0,rows:P?"selected":"range"})},...E==null?[]:[{name:b("menu.paste"),shortcut:`${j}+V`,disabled:!A||!S||!o(),action:()=>A&&A.paste()},{separator:!0},{name:b("menu.clearCells",{count:x||1}),shortcut:"Delete",disabled:!A||!S||!x,action:()=>A&&A.clear()},{name:b("menu.fillDown"),shortcut:`${j}+D`,disabled:!A||!S||x<2,action:()=>A&&A.fillDown()}],...Z&&q.handler?[{name:"Chart selection",action:()=>q.handler(k,Z)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>k.export.csv({rows:"visible",download:!0})},{name:`Export ${P} selected row${P===1?"":"s"} to CSV`,disabled:!P,action:()=>k.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>k.export.excel({rows:"visible",download:!0})},{name:`Export ${P} selected row${P===1?"":"s"} to Excel`,disabled:!P,action:()=>k.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>k.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>k.export.print()},...k.importer&&L(k.importer.openFile)?[{name:b("menu.importCsv"),action:()=>k.importer.openFile()}]:[],{separator:!0},...C.length?[{name:b("menu.expandAll"),action:()=>k.rows.expandAll()},{name:b("menu.collapseAll"),action:()=>k.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!P,action:()=>k.selection.clear()},...L(k.get)&&k.get("rowDelete")===!0?[{name:b("menu.deleteRow",{count:P||1}),disabled:!P&&!T,action:()=>k.edit.deleteRows(P?void 0:T?T.key:void 0)}]:[],...E==null?[]:[{name:"Edit cell",disabled:!T||!E||!I,action:()=>T&&E&&k.edit.start(T.key,E)}]]}function l(k,p,b,E){if(k==null)return{items:p,spoke:!1,suppress:!1};if(k===!1)return{items:p,spoke:!0,suppress:!0};if(k===!0)return{items:p,spoke:!0,suppress:!1};if(Array.isArray(k))return{items:[...p,...k],spoke:!0,suppress:!1};if(L(k)){const T=k(b,p);return{items:Array.isArray(T)?T:p,spoke:!0,suppress:!1}}return B(`menu-layer:${E}`,`${E} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof k}. Ignoring it.`),{items:p,spoke:!1,suppress:!1}}function m(k,p,b){let E=Array.isArray(k)?k:[],T=!1;for(const P of p){if(!P)continue;const x=l(P.layer,E,b,P.where);E=x.items,x.spoke&&(T=x.suppress)}return T?null:E}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(p){this.#n=p.grid,this.#e=p.cellMenu!==!1,this.#t=p.headerMenu!==!1,this.#i=L(p.items)?p.items:null,this.#s=L(p.headerItems)?p.headerItems:null,this.#r=new K({document:p.document,host:p.host,ctx:{grid:p.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",p=>{const b=String(p.colId),E=this.#c(b,a(this.#n,b));E.length&&this.#r.show({items:E,ctx:this.#u(b),anchor:p.element,placement:"below",returnFocus:p.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",p=>{const b=String(p.colId),E=this.#c(b,t(this.#n,b));E.length&&this.#r.show({items:E,ctx:this.#u(b),x:p.x,y:p.y,returnFocus:p.element})})),this.#o.push(this.#n.on("cell:contextmenu",p=>{const b=p.event;this.#e&&b&&L(b.preventDefault)&&b.preventDefault();const E=this.#l(p),T=h(this.#n,E),P=m(T,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(E.column),where:`column '${E.colId}' contextMenu`}],E);!P||!P.length||(!this.#e&&b&&L(b.preventDefault)&&b.preventDefault(),this.#r.show({items:P,ctx:E,x:b?b.clientX:void 0,y:b?b.clientY:void 0}))}))}#l(p){const b=this.#n.columns,E=p.column||(p.colId!=null&&b&&L(b.get)?b.get(p.colId):void 0),T=p.row,P=this.#n.rows,x=p.key!==void 0?p.key:T?T.key:void 0;return{key:x,colId:p.colId,value:p.value!==void 0||x===void 0||p.colId==null?p.value:P&&L(P.value)?P.value(x,p.colId):void 0,row:T,data:T?T.data:void 0,column:E,index:p.index!==void 0?p.index:p.rowIndex,grid:this.#n}}#a(p){if(!(!p||p.contextMenu===void 0||p.contextMenu===null))return p.contextMenu}#u(p){return{colId:p,column:this.#n.columns.get(p),grid:this.#n}}#c(p,b){return this.#s?m(b,[{layer:this.#s,where:"columnMenu"}],this.#u(p))||[]:b}destroy(){for(const p of this.#o)p();this.#o=[],this.#r.destroy()}}}),xe("packages/dom/src/shortcutshelp.js",function(e,G){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return O}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/renderer/keyboard.js"),X=W.groupedShortcuts,H=W.SHORTCUT_IDS,K=G("packages/dom/src/platform.js").macLike,D="lat-shortcuts",v='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class O{#e;#t;#n=null;#r=null;#o=[];constructor(u){this.#e=u.grid,this.#t=u.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(u,a){const s=this.#e;return(s&&s.messages?s.messages:F).t(u,a)}#s(u){const a=H[u.combo];if(!a)return u.meaning;const s=`shortcut.${a}`,n=this.#i(s);return n===s?u.meaning:n}mount(){const u=this.#t.viewport?.root;if(!u||!L(u.addEventListener))return;const a=s=>{if(this.open||s.key!=="?")return;const n=s.target,t=n&&n.tagName;t==="INPUT"||t==="TEXTAREA"||n&&n.isContentEditable||(s.preventDefault(),s.stopPropagation(),this.show())};u.addEventListener("keydown",a,!0),this.#o.push(()=>u.removeEventListener("keydown",a,!0))}show(){const u=this.#l();if(!u)return;const a=u.ownerDocument;this.#r=a&&a.activeElement,u.style.display="",L(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const u=this.#r;this.#r=null,u&&L(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const u=this.#t.viewport?.overlays,a=u?.ownerDocument;if(!u||!a?.createElement)return null;const s=a.createElement("div");s.className=D,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("tabindex","-1");const n=`${D}-title`;s.setAttribute("aria-labelledby",n);const t=a.createElement("div");t.className=`${D}__head`;const r=a.createElement("h2");r.className=`${D}__title`,r.id=n,r.textContent=this.#i("shortcuts.title");const o=a.createElement("button");o.className=`${D}__close`,o.type="button",o.setAttribute("aria-label",this.#i("shortcuts.close")),o.textContent="×",t.appendChild(r),t.appendChild(o),s.appendChild(t);const f=a.createElement("div");f.className=`${D}__body`;for(const i of X())i.items.length&&f.appendChild(this.#a(a,i));s.appendChild(f);const c=a.createElement("p");return c.className=`${D}__hint`,c.textContent=this.#i("shortcuts.hint"),s.appendChild(c),u.appendChild(s),this.#n=s,this.#u(s,o),s}#a(u,a){const s=u.createElement("section");s.className=`${D}__group`;const n=u.createElement("h3");n.className=`${D}__group-title`,n.textContent=this.#i(a.messageKey),s.appendChild(n);const t=u.createElement("dl");t.className=`${D}__list`;const r=K();for(const o of a.items){const f=u.createElement("dt");f.className=`${D}__keys`,o.alternatives.forEach((i,g)=>{if(g>0){const d=u.createElement("span");d.className=`${D}__or`,d.textContent=this.#i("shortcuts.or"),f.appendChild(d)}i.forEach((d,h)=>{h>0&&f.appendChild(u.createTextNode("+"));const l=u.createElement("kbd");l.textContent=r&&d==="Ctrl"?this.#i("shortcuts.key.cmd"):d,f.appendChild(l)})});const c=u.createElement("dd");c.className=`${D}__meaning`,c.textContent=this.#s(o),t.appendChild(f),t.appendChild(c)}return s.appendChild(t),s}#u(u,a){const s=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const r=[...u.querySelectorAll(v)];if(!r.length){t.preventDefault();return}const o=r[0],f=r[r.length-1],c=u.ownerDocument.activeElement;t.shiftKey&&(c===o||c===u)?(t.preventDefault(),f.focus()):!t.shiftKey&&c===f&&(t.preventDefault(),o.focus())},n=t=>{t.preventDefault?.(),this.hide()};u.addEventListener("keydown",s),a.addEventListener("click",n),this.#o.push(()=>{u.removeEventListener("keydown",s),a.removeEventListener("click",n)})}destroy(){for(const u of this.#o)u();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),xe("packages/dom/src/rowreorder.js",function(e,G){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return s}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/renderer/renderer.js").displayIndexOf,H="lat-rowdrag",V="lat-rowdrag-marker",K="lat-rowdrag-lifted",D="lat-manual-order",v=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),O=4,y=new Set;function u(n){if(!n)return null;const t=n===!0?{}:typeof n=="object"?n:null;return t?{send:t.send!==!1,receive:t.receive!==!1,mode:t.mode==="copy"?"copy":"move",group:typeof t.group=="string"?t.group:null}:null}function a(n){return n===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!n||typeof n!="object"?null:{column:typeof n.column=="string"?n.column:null,manualOrder:n.manualOrder===!0,betweenGroups:n.betweenGroups===!0}}class s{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(t){this.#e=t.grid,this.#t=t.renderer,this.#n=t.document,this.#r=a(t.grid.get("rowReorder")),this.#o=u(t.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(t){if(!this.#o||!this.#o.receive)return!1;const r=t&&t.transfer;return!r||!r.send?!1:r.group===this.#o.group}get transfer(){return this.#o}#u(t,r){const o=this.#e;return(o&&o.messages?o.messages:F).t(t,r)}#c(t,r){const o=this.#t&&this.#t.announce;L(o)&&o.call(this.#t,t,r)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(r=>!r.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),r=this.#t.viewport?.root;if(!t||!r)return;const o=r.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const f of o){if(f.querySelector(`.${H}`))continue;const c=f.parentNode;if(c&&L(c.getAttribute)&&c.getAttribute("data-pinned"))continue;const i=this.#n.createElement("span");i.className=H,i.setAttribute("data-role","row-drag"),i.setAttribute("aria-hidden","true"),i.setAttribute("title",this.#u("a11y.reorder.grab")),i.textContent="⠿",f.insertBefore(i,f.firstChild||null)}this.#h(r,t)}#f(){const t=this.#e.rowOrder;return!!(t&&L(t.manual)&&t.manual())}#h(t,r){const o=this.#f();if(L(t.setAttribute)&&(o?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const f=t.querySelector(`.lat-header-cell[data-col="${r}"]`);if(!f)return;let c=f.querySelector(`.${D}`);c||(c=this.#n.createElement("button"),c.className=D,c.setAttribute("type","button"),c.setAttribute("data-role","manual-order"),c.setAttribute("tabindex","-1"),c.textContent=this.#u("rowOrder.button"),c.addEventListener("click",g=>{g.stopPropagation?.(),this.toggleManual()}),c.addEventListener("pointerdown",g=>g.stopPropagation?.()),f.insertBefore(c,f.firstChild||null)),c.setAttribute("aria-pressed",o?"true":"false");const i=this.#u(o?"rowOrder.exit":"rowOrder.enter");c.setAttribute("title",i),c.setAttribute("aria-label",i)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const r=this.#f()?t.exit():t.enter({origin:"user"}),o=f=>{f&&f.reason&&this.#c(this.#u(v[f.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};r&&L(r.then)?r.then(o):o(r)}mount(){if(!this.active)return;y.add(this);const t=this.#t.viewport?.root;if(!t||!L(t.addEventListener))return;const r=g=>this.#p(g),o=g=>this.#m(g),f=()=>this.#g(),c=g=>this.#M(g);if(t.addEventListener("pointerdown",r),t.addEventListener("keydown",c),L(this.#e.on)){let g=this.#f();this.#a.push(this.#e.on("state:changed",d=>{!d||!Array.isArray(d.sections)||!d.sections.includes("rowOrder")||this.#f()!==g&&(g=this.#f(),this.#c(this.#u(g?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const i=this.#n.defaultView||this.#n;i.addEventListener?.("pointermove",o),i.addEventListener?.("pointerup",f),this.#a.push(()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("keydown",c),i.removeEventListener?.("pointermove",o),i.removeEventListener?.("pointerup",f)})}#p(t){const r=t.target;if(!r||!L(r.closest)||!r.closest('[data-role="row-drag"]'))return;const o=r.closest(".lat-row"),f=o?X(o):-1;if(f<0)return;const c=this.#e.rows.get(f);if(!c||c.group)return;const i=this.#L();if(i&&!(this.#o&&this.#o.send)){this.#c(this.#u(i),{repeat:!0});return}t.preventDefault?.(),this.#i={key:c.key,from:f,at:f,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const r=this.#i;if(!r)return;if(!r.armed){if(Math.abs(t.clientX-r.x)+Math.abs(t.clientY-r.y)<O)return;r.armed=!0,this.#I(r),r.over=this,this.#e.emit("rowDrag:started",this.#y(r,this,r.from,r.key),"user")}this.#l&&this.#z(t.clientX,t.clientY);const o=this.#S(t.clientX,t.clientY);if(r.target=o,o!==this){this.#H(),o&&o.accepts(this)?(o.showDropTarget(t.clientX,t.clientY),r.hit=o.hitAt(t.clientX,t.clientY)):r.hit=null,this.#k(r,o),this.#b(r,o,r.hit?r.hit.at:null,r.hit?r.hit.overKey:null);return}const f=this.#x(t.clientX,t.clientY);if(this.#k(r,o),f<0){this.#b(r,this,null,null);return}r.at=f,this.#N(f);const c=this.#e.rows.get(f);this.#b(r,this,f,c?c.key:null)}#g(){const t=this.#i;this.#i=null,this.#H(),this.#$();for(const f of y)f.hideDropTarget();if(!t||(this.#O(t),!t.armed))return;const r=t.target;if(this.#e.emit("rowDrag:ended",this.#w(t),"user"),r&&r!==this){this.#P(t,r);return}if(t.at===t.from)return;const o=this.#L();if(o){this.#c(this.#u(o),{repeat:!0});return}this.#E(t.key,t.at)}#y(t,r,o,f){const c=this.#e.rows.byKey(t.key);return{key:t.key,data:c?c.data:null,over:r?r.grid:null,at:o,overKey:f}}#w(t){const r=t.target||null;if(r&&r!==this){if(!r.accepts(this))return{...this.#y(t,r,null,null),dropped:!1};const o=t.hit||{at:r.grid.rows.count(),overKey:null};return{...this.#y(t,r,o.at,o.overKey),dropped:!0}}if(r===this){const o=this.#e.rows.get(t.at);return{...this.#y(t,this,t.at,o?o.key:null),dropped:t.at!==t.from&&this.#L()===null}}return{...this.#y(t,null,null,null),dropped:!1}}#k(t,r){if(t.over===r)return;const o=t.over;t.over=r,o&&(this.#O(t),this.#e.emit("rowDrag:left",this.#y(t,o,null,null),"user"))}#b(t,r,o,f){t.pending={over:r,at:o,overKey:f},t.frame===null&&(t.frame=this.#j(()=>{t.frame=null;const c=t.pending;t.pending=null,!(!c||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#y(t,c.over,c.at,c.overKey),"user")}))}#O(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#j(t){const r=this.#n.defaultView||globalThis;if(L(r.requestAnimationFrame)){const f=r.requestAnimationFrame(t);return()=>{L(r.cancelAnimationFrame)&&r.cancelAnimationFrame(f)}}const o=setTimeout(t,16);return()=>clearTimeout(o)}#P(t,r){if(!r.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const o=this.#e.rows.byKey(t.key);if(!o)return;const f=this.#o.mode,c=t.key,i=t.hit||{at:r.grid.rows.count(),overKey:null};let g=null;const d=r.receive(o.data,i.at,{overKey:i.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(c),onCancel:l=>{g=l}}),h=l=>{if(l!==!0){const m=l===!1?"a11y.transfer.refused":g==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(m),{repeat:!0});return}f==="move"?(this.#e.rows.apply({remove:[c]}),this.#e.emit("row:sent",{key:c,data:o.data,mode:f})):this.#e.emit("row:copied",{key:c,data:o.data,mode:f}),this.#c(this.#u(f==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};d&&L(d.then)?d.then(h):h(d)}receive(t,r,o={}){const f=this.#e,c=t&&typeof t=="object"?{...t}:t,i=o.overKey??null,g=o.source||null,d=L(o.onCancel)?o.onCancel:null,h=()=>{const p=f.rows.totalCount(),b=f.rows.apply({add:[c],at:Math.max(0,r||0)}),E=f.rows.totalCount()>p;return E&&f.emit("row:received",{data:c,at:r,overKey:i,rejected:b?.rejected||[]}),E},l=()=>{if(i!==null){const p=f.rows.get(r);if(!p||p.key!==i)return!1}else r=f.rows.count();return!L(o.revalidate)||o.revalidate()},m=L(f.rendererHost)?f.rendererHost():null;if(!m||!L(m.gateBefore))return h();const w=d?f.on("rowReceive:cancelled",p=>d(p.reason)):null,k=m.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:c,at:r,overKey:i,source:g,origin:"user"},h,l);return w&&(k&&L(k.then)?k.then(w,w):w()),k}hitAt(t,r){const o=this.#x(t,r);if(o<0)return{at:this.#e.rows.count(),overKey:null};const f=this.#e.rows.get(o);return{at:o,overKey:f?f.key:null}}showDropTarget(t,r){const o=this.root;o&&L(o.setAttribute)&&o.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&L(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#S(t,r){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=o&&L(o.closest)?o.closest(".lattice"):null;if(!f)return null;for(const c of y)if(c.root===f)return c;return null}#M(t){if(!t.altKey||!t.shiftKey)return;if(this.#r&&this.#r.manualOrder&&(t.code==="KeyM"||t.key==="M"||t.key==="m")){t.preventDefault?.(),t.stopPropagation?.(),this.toggleManual();return}const r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!r)return;const o=this.#n.activeElement,f=o&&L(o.closest)?o.closest(".lat-row"):null,c=f?X(f):-1;if(c<0)return;t.preventDefault?.(),t.stopPropagation?.();const i=this.#L();if(i){this.#c(this.#u(i),{repeat:!0});return}const g=this.#e.rows.get(c);!g||g.group||this.#E(g.key,this.#A(c,r))}#A(t,r){const o=this.#e;if(r>0||!L(o.rows.groupHeadings))return t+r;const f=new Set(o.rows.groupHeadings(t).map(i=>i.key));let c=t+r;for(;c>=0;){const i=o.rows.get(c);if(!i||!f.has(i.key))break;c+=r}return c<0?t:c}#E(t,r){const o=this.#e.rows.count(),f=Math.max(0,Math.min(o-1,r)),c=this.#e.rows.move(t,f,{origin:"user"});c&&L(c.then)?c.then(i=>this.#R(i,o)):this.#R(c,o)}#R(t,r){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const o=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,f=o?this.#u("a11y.reorder.vetoedBecause",{reason:o}):this.#u(v[t.reason]||"a11y.reorder.refused");this.#c(f,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const o=t.regrouped.map(f=>String(f.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:o}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:r}),{repeat:!0})}#L(){const t=this.#e,r=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return r.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#f()&&!r.betweenGroups)return"a11y.reorder.grouped";const o=t.filters.get();return o&&Object.keys(o).length?"a11y.reorder.filtered":null}#x(t,r){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=o&&L(o.closest)?o.closest(".lat-row"):null;return!f||L(f.getAttribute)&&f.getAttribute("data-pinned")?-1:X(f)}#I(t){const r=this.root,o=r&&L(r.querySelector)?r.querySelector(`.lat-row[data-index="${t.from}"]`):null;o&&L(o.classList?.add)&&o.classList.add(K);const f=this.#n.body;if(!f||!L(f.appendChild))return;const c=this.#d(),i=c&&L(this.#e.rows?.text)&&this.#e.rows.text(t.key,c)||this.#u("a11y.reorder.grab"),g=r&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(r):null,d=(l,m)=>g&&g.getPropertyValue(l).trim()||m,h=this.#n.createElement("div");h.textContent=String(i),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${d("--lattice-space","4px")} calc(${d("--lattice-space","4px")} * 2)`,`border-radius:${d("--lattice-radius-sm",d("--lattice-radius","4px"))}`,`border:${d("--lattice-border-width","1px")} solid ${d("--lattice-border-strong","#0003")}`,`background:${d("--lattice-background","#fff")}`,`color:${d("--lattice-foreground","#000")}`,`box-shadow:${d("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${d("--lattice-font-size","13px")} ${d("--lattice-font-family","system-ui, sans-serif")}`].join(";"),f.appendChild(h),this.#l=h}#z(t,r){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(r)+16}px)`)}#$(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,r=t&&L(t.querySelectorAll)?t.querySelectorAll(`.${K}`):[];for(const o of r)o.classList.remove(K)}#N(t){const r=this.#t.viewport?.overlays;if(!r)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=V,r.appendChild(this.#s));const o=this.#t.viewport.root,f=o.querySelector(`.lat-row[data-index="${t}"]`)||o.querySelectorAll(".lat-row")[0];if(!f||!L(f.getBoundingClientRect))return;const c=f.getBoundingClientRect(),i=o.getBoundingClientRect(),g=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((g?c.bottom:c.top)-i.top)}px`}#H(){this.#s&&(this.#s.style.display="none")}destroy(){y.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#O(this.#i),this.#i=null,this.#$(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),xe("packages/dom/src/alignedgrids.js",function(e,G){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function F(H){return(H||[]).map(V=>({id:V.id,width:V.width,flex:V.flex,hidden:V.hidden,pin:V.pin===void 0?null:V.pin}))}class W{#e=new Set;#t=new Map;#n=!1;add(V){if(!V||this.#e.has(V))return;this.#e.add(V);const K=[];for(const v of B)K.push(V.on(v,()=>this.#r(V)));K.push(V.on("scroll",v=>this.#i(V,v))),K.push(V.on("destroy",()=>this.remove(V))),this.#t.set(V,K);const[D]=this.#e;D!==V&&this.#o(V,F(D.columns.state()))}remove(V){const K=this.#t.get(V);if(K)for(const D of K)D();this.#t.delete(V),this.#e.delete(V)}get size(){return this.#e.size}destroy(){for(const V of[...this.#e])this.remove(V)}#r(V){if(this.#n)return;const K=F(V.columns.state());this.#n=!0;try{for(const D of this.#e)D!==V&&this.#o(D,K)}finally{this.#n=!1}}#o(V,K){if(!V.columns||!L(V.columns.apply))return;const D=new Map((V.columns.state()||[]).map(O=>[O.id,O])),v=[];for(const O of K){const y=D.get(O.id);y&&(v.push({...y,...O}),D.delete(O.id))}for(const O of D.values())v.push(O);V.columns.apply(v)}#i(V,K){if(this.#n)return;const D=K&&typeof K.left=="number"?K.left:null;if(D!==null){this.#n=!0;try{for(const v of this.#e)v!==V&&v.scroll?.to?.({left:D})}finally{this.#n=!1}}}}function X(H){const V=new W;for(const K of H||[])V.add(K);return V}}),xe("packages/dom/src/columntagbar.js",function(e,G){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return H}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function X(K){if(!K)return null;const D=K===!0?{}:typeof K=="object"?K: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=X(D.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(D,v){const O=this.#e;return(O&&O.messages?O.messages:F).t(D,v)}mount(){if(!this.active)return;const D=this.#t.viewport,v=D?.root;if(!v||!L(v.insertBefore))return;const O=this.#n.createElement("div");O.className=W,O.setAttribute("role","toolbar"),O.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 u=this.#n.createElement("select");u.className=`${W}__select`,this.#r.multiple&&u.setAttribute("multiple","");const a=`${W}-select-${Math.abs(V(String(v.className)))}`;u.id=a,y.setAttribute("for",a),O.appendChild(y),O.appendChild(u),v.insertBefore(O,D.header||v.firstChild),this.#o=O,this.#i=u;const s=()=>{const t=this.#r.multiple?[...u.selectedOptions||[]].map(r=>r.value).filter(Boolean):u.value?[u.value]:[];this.#e.columns.showTagged(t),this.#u(t)};u.addEventListener("change",s),this.#l.push(()=>u.removeEventListener("change",s));const n=this.#e.on("model:changed",()=>this.refresh());this.#l.push(n),this.refresh()}#u(D){const v=this.#t&&this.#t.announce;if(!L(v))return;const O=D.length?D.join(", "):this.#a("tags.all");v.call(this.#t,this.#a("tags.showing",{tag:O}))}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 O=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 u=this.#n.createElement("option");u.value=y,u.textContent=y,O.includes(y)&&(u.selected=!0),this.#i.appendChild(u)}this.#r.multiple||(this.#i.value=O.length?O[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 V(K){let D=0;for(let v=0;v<K.length;v++)D=D*31+K.charCodeAt(v)|0;return D}}),xe("packages/dom/src/anomalychip.js",function(e,G){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return K}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function X(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 V(D,v){return D?Array.isArray(D.conditions)?D.conditions.some(O=>V(O,v)):D.col===v&&D.op==="eq"&&D.value===!0:!1}class K{#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=X(v.grid.get("anomalySummary"))}get active(){return this.#r!==null}#f(v,O){const y=this.#e;return(y&&y.messages?y.messages:F).t(v,O)}#h(){const v=this.#r&&this.#r.column;let O=null;for(const y of this.#e.columns.all()){const u=H(y.shadow);if(!u||u.kind!=="anomalyFlag")continue;const a=u.of||y.field||y.id;if(v){if(y.id===v||a===v)return this.#d=y.id,y}else O||(O=y,this.#d=y.id)}return v?null:O}#p(){if(!this.#d||!L(this.#e.rows&&this.#e.rows.forEach))return 0;let v=0;try{this.#e.rows.forEach(O=>{!O||O.group||O.key==null||this.#e.rows.value(O.key,this.#d)===!0&&v++})}catch{return 0}return v}mount(){if(!this.active)return;const v=this.#t.viewport,O=v&&v.root;if(!O||!L(O.insertBefore))return;const y=this.#n.createElement("div");y.className=W,y.setAttribute("role","status");const u=this.#n.createElement("button");u.className=`${W}__button`,u.setAttribute("type","button"),u.setAttribute("aria-pressed","false"),y.appendChild(u),O.insertBefore(y,v.header||O.firstChild),this.#o=y,this.#i=u;const a=()=>this.toggle();u.addEventListener("click",a),this.#s.push(()=>u.removeEventListener("click",a));for(const s of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(s,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#m()}#m(){if(!this.#d)return;this.#u=this.#e.filters.get();const v={col:this.#d,op:"eq",value:!0},O=this.#u?{op:"and",conditions:[this.#u,v]}:v;this.#l=!0,this.#a=!0;try{this.#e.filters.set(O)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#h()){this.#o.style.display="none";return}if(this.#l&&!V(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#y(this.#c,!0);return}const O=this.#p();if(this.#c=O,!O){this.#o.style.display="none";return}this.#y(O,!1)}#y(v,O){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",O?"true":"false"),this.#i.setAttribute("aria-pressed",O?"true":"false");const y=this.#r&&this.#r.label,u=O?this.#f("anomaly.chipActive",{count:v}):y||this.#f("anomaly.chip",{count:v});this.#i.textContent=u}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}}}),xe("packages/dom/src/rowform.js",function(e,G){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return o}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,H=G("packages/core/src/model/rowkey.js").createRowKey,K=G("packages/dom/src/editors/index.js").createEditor,v=G("packages/dom/src/renderer/renderer.js").displayIndexOf,y=G("packages/dom/src/themeof.js").themeOf,u="lat-rowform",a='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function s(f){if(!f)return null;const c=f===!0?{}:typeof f=="object"?f:null;if(!c)return null;const i=L(c.load)?c.load:null,g=Array.isArray(c.fields)&&c.fields.length?c.fields:null;return{timeout:r(c.timeout),container:c.container??null,mode:c.container?"inline":c.mode==="dialog"?"dialog":"drawer",load:i,create:L(c.create)?c.create:null,fields:g,title:c.title??null,width:typeof c.width=="string"?c.width:null,trigger:c.trigger===!1?"none":"dblclick"}}function n(f,c){const i=L(f)?f():f;return i?typeof i=="string"?c&&L(c.querySelector)?c.querySelector(i):null:i&&L(i.appendChild)?i:null:null}const t=2e3;function r(f){return f===!1||f===0?0:typeof f!="number"||!Number.isFinite(f)||f<=0?t:f}class o{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#f=null;#h=0;#p=null;#m=!1;#g=[];constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.document,this.#r=c.registry||null,this.#o=s(c.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#y(c,i){const g=this.#e;return(g&&g.messages?g.messages:W).t(c,i)}mount(){if(!this.active)return;const c=this.#t.viewport?.root;if(!c||!L(c.addEventListener)||this.#o.trigger==="none")return;const i=g=>{const d=g.target;if(!d||!L(d.closest)||d.closest(".lat-editor-host, .lat-editor--popup"))return;const h=d.closest(".lat-row"),l=h?v(h):-1;if(l<0)return;const m=this.#e.rows.get(l);!m||m.group||m.detail||(g.preventDefault?.(),g.stopPropagation?.(),this.openRow(m.key))};c.addEventListener("dblclick",i,!0),this.#g.push(()=>c.removeEventListener("dblclick",i,!0))}openRow(c){const i=this.#e.rows.byKey(c);if(!i)return!1;const g=this.#P();if(!g)return!1;this.#a=i,this.#u=!1,this.#j(),this.#f=this.#n.activeElement,g.style.display="",this.#N(g),this.#M(i);const d=this.#o.load;if(!d)this.#z(i.data);else{this.#L();const h=++this.#h;this.#A(h,l=>{this.#x(new Error(`Loading the record timed out after ${l}ms`),c,"form.loadTimeout")}),Promise.resolve().then(()=>d({row:i,data:i.data,key:c,grid:this.#e})).then(l=>{h!==this.#h||!this.open||(this.#R(),this.#z(l||i.data))}).catch(l=>{h!==this.#h||!this.open||(this.#R(),this.#x(l,c))})}return L(g.focus)&&g.focus(),this.#e.emit("form:opened",{key:c,row:i}),!0}openNew(c){const i=this.#P();if(!i)return!1;this.#h+=1,this.#R(),this.#a=null,this.#u=!0,this.#j(),this.open||(this.#f=this.#n.activeElement),i.style.display="",this.#N(i);const g=i.querySelector(`.${u}__title`);return g&&(g.textContent=this.#y("form.newTitle")),this.#z(c&&typeof c=="object"?{...c}:{}),L(i.focus)&&i.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#h+=1,this.#R(),this.#he(),this.#i.style.display="none";const c=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#j();const i=this.#f;this.#f=null,i&&L(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:c})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const c=this.#a?this.#a.key:null,i={},g={},d=[],h=[];for(const l of this.#d){const m=L(l.editor.commit)?l.editor.commit():{ok:!0,value:void 0};if(!m.ok)return this.#W(l,m.message),!1;if(i[l.field]=m.value,l.readOnly){h.push(l.field);continue}const w=l.initial;Object.is(w,m.value)||(g[l.field]=m.value,l.colId?d.push({key:c,colId:l.colId,value:m.value}):h.push(l.field))}return this.#u?this.#w(i):(d.length&&this.#e.edit.setCells(d,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:c,values:i,changed:g,unmapped:h}),this.close(),!0)}#w(c){const i=this.#d.filter(h=>!h.colId).map(h=>h.field),g=this.#o.create;if(!g)return this.#k(c)?(this.#b(c,c,i),!0):(B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#j(),this.#E(!1);const d=++this.#h;return this.#A(d,h=>{this.#O(new Error(`Adding the record timed out after ${h}ms`),c,!0)}),Promise.resolve().then(()=>g(c)).then(h=>{if(!(d!==this.#h||!this.open)){if(this.#R(),!this.#k(h)){B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#O(new Error("rowForm.create answered with a row that carries no row key"),c,!1);return}this.#b(h,c,i)}}).catch(h=>{d!==this.#h||!this.open||(this.#R(),this.#O(h,c,!1))}),!0}#k(c){if(!c||typeof c!="object")return!1;const i=H(this.#e.get("rowKey"),{warn:!1});return!i||i.stable===!1?!1:L(i.keyEmpty)?!i.keyEmpty(c):!0}#b(c,i,g){const d=this.#e,h=d.rows.apply({add:[c]}),l=h&&Array.isArray(h.added)?h.added[0]:null;if(!l){this.#O(new Error("The new row could not be added"),i,!1);return}const m=l.key;d.emit("form:saved",{key:m,values:i,changed:i,unmapped:g,created:!0}),this.close();const w=d.get("selection");(typeof w=="string"?w!=="none":w&&typeof w=="object"&&w.mode!=="none")&&d.selection&&L(d.selection.set)&&d.selection.set([m]),d.scroll&&L(d.scroll.toRow)&&d.scroll.toRow(m)}#O(c,i,g){this.#E(!0),this.#j();const d=this.#n.createElement("div");d.className=`${u}__failure`;const h=this.#n.createElement("p");h.className=`${u}__note ${u}__note--error`,h.setAttribute("role","alert"),h.textContent=this.#y("form.createFailed");const l=this.#n.createElement("button");l.className=`${u}__retry`,l.type="button",l.textContent=this.#y("form.retry"),l.addEventListener("click",()=>this.save()),d.appendChild(h),d.appendChild(l),L(this.#s.insertBefore)?this.#s.insertBefore(d,this.#s.firstChild):this.#s.appendChild(d),this.#c=d,this.#e.emit("form:error",{key:null,error:c,timedOut:g,created:!0})}#j(){const c=this.#c;this.#c=null,c&&c.parentNode&&c.parentNode.removeChild(c)}#P(){if(this.#i)return this.#i;const c=this.#t.viewport?.overlays,i=this.#n||c?.ownerDocument;if(!i?.createElement)return null;const g=n(this.#o.container,i),d=g||c;if(!d)return null;this.#o.container&&!g&&B("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!g;const h=i.createElement("div"),l=this.#m?"lattice ":"";h.className=`${l}${u} ${u}--${this.#m?"inline":this.#o.mode}`,h.setAttribute("role",this.#m?"region":"dialog"),this.#m||h.setAttribute("aria-modal","true"),h.setAttribute("tabindex","-1"),this.#o.width&&h.style.setProperty("--lattice-rowform-width",this.#o.width);const m=`${u}-title`;h.setAttribute("aria-labelledby",m);const w=i.createElement("div");w.className=`${u}__head`;const k=i.createElement("h2");k.className=`${u}__title`,k.id=m,w.appendChild(k);const p=i.createElement("div");p.className=`${u}__body`;const b=i.createElement("div");b.className=`${u}__foot`;const E=i.createElement("button");E.className=`${u}__cancel`,E.type="button",E.textContent=this.#y("form.cancel");const T=i.createElement("button");return T.className=`${u}__save`,T.type="button",T.textContent=this.#y("form.save"),b.appendChild(E),b.appendChild(T),h.appendChild(w),h.appendChild(p),h.appendChild(b),d.appendChild(h),this.#i=h,this.#s=p,this.#l=T,this.#S(h,T,E),h}#S(c,i,g){const d=m=>{if(m.stopPropagation(),m.key==="Escape"){m.preventDefault(),this.close();return}if(m.key!=="Tab"||this.#m)return;const w=[...c.querySelectorAll(a)];if(!w.length){m.preventDefault();return}const k=w[0],p=w[w.length-1],b=c.ownerDocument.activeElement;m.shiftKey&&(b===k||b===c)?(m.preventDefault(),p.focus()):!m.shiftKey&&b===p&&(m.preventDefault(),k.focus())},h=m=>{m.preventDefault?.(),this.save()},l=m=>{m.preventDefault?.(),this.close()};c.addEventListener("keydown",d),i.addEventListener("click",h),g.addEventListener("click",l),this.#g.push(()=>{c.removeEventListener("keydown",d),i.removeEventListener("click",h),g.removeEventListener("click",l)})}#M(c){const i=this.#i.querySelector(`.${u}__title`);if(!i)return;const g=this.#o.title;L(g)?i.textContent=String(g({row:c,data:c.data})??""):typeof g=="string"?i.textContent=g:i.textContent=this.#y("form.title")}#A(c,i){this.#R();const g=this.#o.timeout;if(!g)return;const d=this.#n.defaultView||globalThis;L(d.setTimeout)&&(this.#p=d.setTimeout(()=>{this.#p=null,!(c!==this.#h||!this.open)&&(this.#h+=1,i(g))},g))}#E(c){this.#l&&(this.#l.disabled=!c,c?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#R(){if(this.#p===null)return;const c=this.#n.defaultView||globalThis;L(c.clearTimeout)&&c.clearTimeout(this.#p),this.#p=null}#L(){this.#he(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${u}__note`,c.setAttribute("role","status"),c.textContent=this.#y("form.loading"),this.#s.appendChild(c)}#x(c,i,g="form.loadFailed"){this.#he(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const d=this.#n.createElement("p");d.className=`${u}__note ${u}__note--error`,d.setAttribute("role","alert"),d.textContent=this.#y(g);const h=this.#n.createElement("button");h.className=`${u}__retry`,h.type="button",h.textContent=this.#y("form.retry"),h.addEventListener("click",()=>this.openRow(i)),this.#s.appendChild(d),this.#s.appendChild(h),this.#e.emit("form:error",{key:i,error:c,timedOut:g==="form.loadTimeout"})}#I(){return this.#o.fields?this.#o.fields.map(c=>typeof c=="string"?{field:c}:c):this.#e.columns.all().filter(c=>!c.generated&&c.field).map(c=>({field:c.field,label:c.title,colId:c.id}))}#z(c){this.#he(),this.#E(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const i=c&&typeof c=="object"?c:{};for(const g of this.#I()){const d=g.field;if(!d)continue;const h=g.colId?this.#e.columns.get(g.colId):this.#ue(d),l=Object.hasOwn(i,d)?i[d]:null,m=this.#n.createElement("div");m.className=`${u}__field`;const w=this.#n.createElement("label");w.className=`${u}__label`,w.textContent=String(g.label??(h&&h.title)??d);const k=this.#n.createElement("div");k.className=`${u}__control`,m.appendChild(w),m.appendChild(k),this.#s.appendChild(m);const p={field:d,colId:h?h.id:null,editor:null,initial:l,opener:null,wrap:m,readOnly:!1},E=!!(h&&(h.computed||h.generated))?null:K({grid:this.#e,column:this.#le(g,h,d),colId:h?h.id:d,row:this.#a,data:i,value:l,text:l==null?"":String(l),locale:this.#e.get("locale"),props:g.props||h&&h.edit&&h.edit.props,lookup:g.lookup||h&&h.lookup,document:this.#n,cell:k,overlay:this.#H(),stop:()=>this.#ie(p)},this.#r);if(!E){p.readOnly=!0,p.colId=null,p.editor={commit:()=>({ok:!0,value:p.initial})},this.#$(k,h,l),this.#d.push(p);continue}p.editor=E;try{L(E.value)&&(p.initial=E.value())}catch{}if(this.#d.push(p),E.popup===!0)this.#B(k,p);else{const T=L(E.element)?E.element():null;T&&k.appendChild(T)}}this.#d.length||B("rowform:no-fields","rowForm has no fields to show; the form opened with no controls. Check rowForm.fields, or the grid's columns when fields is absent.")}#$(c,i,g){const d=this.#n.createElement("div");d.className=`${u}__static`,d.setAttribute("aria-readonly","true");let h="";try{const l=i&&i.dataType&&i.dataType.format;L(l)&&(h=l({value:g,column:i,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{h=""}(h===""||h==null)&&(h=g==null?"":String(g)),d.textContent=h,c.appendChild(d)}#N(c){if(!this.#m)return;const i=this.#t.viewport?.root;if(!(!i||!L(i.getAttribute)))for(const g of["data-theme","data-density","dir"]){const d=g==="data-theme"?y(i):i.getAttribute(g);d?c.setAttribute(g,d):L(c.removeAttribute)&&c.removeAttribute(g)}}#H(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#B(c,i){const g=this.#n.createElement("button");g.className=`${u}__opener`,g.type="button",i.opener=g,this.#re(i);const d=()=>{L(i.editor.attached)&&i.editor.attached()};g.addEventListener("click",d),this.#g.push(()=>g.removeEventListener("click",d)),c.appendChild(g)}#W(c,i){const g=c.wrap;g&&L(g.scrollIntoView)&&g.scrollIntoView({block:"nearest"});const d=c.opener||(L(c.editor.focusTarget)?c.editor.focusTarget():null);d&&L(d.focus)&&d.focus();const h=this.#t&&this.#t.announce;L(h)&&i&&h.call(this.#t,String(i))}#ie(c){if(!c.opener||!c.editor)return;const i=L(c.editor.popupHandle)?c.editor.popupHandle():null;i&&L(i.hide)&&i.hide(),this.#re(c),L(c.opener.focus)&&c.opener.focus()}#re(c){if(!c.opener)return;let i="";try{const d=c.colId?this.#e.columns.get(c.colId):null,h=d&&d.dataType&&d.dataType.format;L(h)&&(i=h({value:L(c.editor.value)?c.editor.value():null,column:d,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&L(c.editor.toClipboard)&&(i=c.editor.toClipboard())}catch{i=""}const g=i===""||i==null;c.opener.textContent=g?this.#y("form.choose"):String(i),c.opener.classList.toggle(`${u}__opener--empty`,g)}#le(c,i,g){const d=c.editor||c.type||c.lookup||c.props,h={...i&&i.edit?i.edit:{},enabled:!0};return c.editor&&(h.editor=c.editor),c.props&&(h.props=c.props),i&&!d?{...i,edit:h}:{...i||{id:g,field:g},type:c.type||i&&i.type||"text",lookup:c.lookup||i&&i.lookup||void 0,edit:h}}#ue(c){for(const i of this.#e.columns.all())if(!i.generated&&i.field===c)return i;return null}#he(){for(const c of this.#d)L(c.editor.destroy)&&c.editor.destroy();this.#d=[]}destroy(){this.#h+=1,this.#R(),this.#he();for(const c of this.#g)c();this.#g=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),xe("packages/dom/src/toolpanelmount.js",function(e,G){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return C}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,F=G("packages/dom/src/ui/toolpanel.js"),W=F.ToolPanel,X=F.toolPanels,H=F.toolPanelTitles,V=F.toolPanelIcons,K=G("packages/dom/src/filters/index.js"),D=K.createFilter,v=K.filterFor,y=G("packages/dom/src/filters/text.js").TextFilter,u=G("packages/dom/src/filters/engineset.js"),a=u.EngineSetFilter,s=u.VALUE_LIMIT,n=G("packages/dom/src/editors/common.js"),t=n.CLS,r=n.documentFor,o=n.scannableRows,f=n.el,c=G("packages/dom/src/filtermenu.js"),i=c.mergeColumnFilter,g=c.branchFor,d=c.valueSource,h=c.isSetFilter,l=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 m(A,j,$){const z=f(A,"div",{class:`${t.panel}__filterRefusal`});return z.appendChild(f(A,"div",{class:`${t.filter}__note`,text:$,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),z.appendChild(j.element()),{get:()=>j.get(),set:M=>j.set(M),active:()=>j.active(),...L(j.clear)?{clear:()=>j.clear()}:{},destroy:()=>j.destroy(),element:()=>z}}function w(A){const{grid:j,container:$}=A||{};if(!j)throw new Error("[lattice] mountPanel needs a grid");if(!$||!$.appendChild)throw new Error("[lattice] mountPanel needs a container element");const z=L(A.panel)?A.panel:X[String(A.panel)];if(!z)throw new Error(`[lattice] unknown panel "${A.panel}"; known panels are ${Object.keys(X).join(", ")}`);const M=$.ownerDocument||r($),R=x(j,M,A.announce),S=new z;S.init({document:M,host:R,grid:j,props:A.props||{}});const I=S.element();$.appendChild(I);const q=[];for(const Z of l)L(j.on)&&q.push(j.on(Z,()=>S.refresh()));return{element:I,refresh(){S.refresh()},destroy(){for(const Z of q)Z();q.length=0,L(S.destroy)&&S.destroy(),I&&I.parentNode&&I.parentNode.removeChild(I)}}}const k=260,p=30,b=`${t.panel}-dock`;function E(A,j,$){if(!A||!L(A.set))return;const z=g($.filters.get(),j)||null,M=L(A.get)&&(!L(A.active)||A.active())&&A.get()||null;JSON.stringify(M)!==JSON.stringify(z)&&(z?A.set(z):L(A.clear)?A.clear():A.set(null))}function T(A,j){if(A==="insights"){const M=j&&L(j.get)?j.get("insights"):null;return{other:(M&&typeof M=="object"?M:{}).compareWith||null}}if(A!=="views")return{};const $=j&&L(j.get)?j.get("views"):null,z=$&&typeof $=="object"?$:{};return{allowSave:z.allowSave!==!1,showDiff:z.showDiff===!0,builtinTitle:z.builtinTitle,savedTitle:z.savedTitle}}function P(A){const j=A.pagination&&L(A.pagination.get)?A.pagination.get():null;return j&&Number.isFinite(j.total)?j.total:A.rows.count()}function x(A,j,$){const z=new Map;return{announce(M,R){L($)&&$(M,R)},t(M,R){return A.messages.t(M,R)},grid:A,document:j,columns:()=>A.columns.all(),showColumns:M=>A.columns.show(M),hideColumns:M=>A.columns.hide(M),groupBy:()=>A.state.get().group||[],setGroupBy:M=>A.columns.group(M),pivotBy:()=>(A.state.get().pivot||{}).columns||[],setPivotBy:M=>A.columns.pivot(M),valueColumns:()=>A.columns.all().filter(M=>M.total).map(M=>M.id),setValueColumns:M=>A.columns.totals(M),valueAggregation(M){const R=A.columns.get(M);return!R||!R.total?"sum":typeof R.total=="string"?R.total:"custom"},setValueAggregation(M,R){A.columns.setTotal(M,R)},quickFilter:()=>A.state.get().quick||"",setQuickFilter:M=>A.filters.quick(M),rowCount:()=>P(A),totalRowCount:()=>L(A.rows.totalCount)?A.rows.totalCount():A.rows.count(),formattableColumns:()=>A.columns.visible().filter(M=>!M.generated).map(M=>({id:M.id,title:String(M.title??M.id)})),formattingRules:M=>A.formatting.list(M),columnSamples:M=>{let R=M;if(!R||R==="*"){const q=A.columns.visible().find(Z=>!Z.generated);R=q?q.id:null}if(!R)return[];const S=[],I=new Set;for(const q of o(A)){const Z=A.rows.value(q.key,R);if(Z==null||Z==="")continue;const _=typeof Z=="object"?S.length:Z;if(!I.has(_)&&(I.add(_),S.push(Z),S.length>=24))break}return S},profilableColumns:()=>A.columns.visible().filter(M=>!M.generated).map(M=>({id:M.id,title:String(M.title??M.id)})),columnProfile:M=>A.statistics.profile(M),reduceColumn:(M,R)=>A.statistics.reduce(M,R),columnCapability:M=>A.statistics.capability(M),regressionModel:M=>L(A.statistics.regressionModel)?A.statistics.regressionModel(M):null,insightsColumns:()=>A.columns.visible().filter(M=>!M.generated).map(M=>({id:M.id,title:String(M.title??M.id),type:M.type})),subsetVsPopulation:()=>A.statistics.subsetVsPopulation(),datasetVsDataset:M=>A.statistics.datasetVsDataset(M),compareGroups:(M,R)=>A.statistics.compareGroups(M,R),anomalies:M=>A.statistics.anomalies(M||{}),compareColumns:(M,R)=>{if(!M||!R||M===R)return null;const S=A.statistics.regression(M,R);return{n:S?S.n:0,pearson:A.statistics.correlation(M,R),spearman:A.statistics.spearman(M,R),kendall:A.statistics.kendall(M,R),covariance:A.statistics.covariance(M,R),slope:S?S.slope:null,intercept:S?S.intercept:null,r2:S?S.r2:null,stdError:S?S.stdError:null,weighted:A.statistics.weightedAverage(M,R)}},addRule:(M,R)=>A.formatting.add(M,R),removeRule:(M,R)=>A.formatting.remove(M,R),updateRule:(M,R,S)=>A.formatting.update(M,R,S),moveRule:(M,R,S)=>A.formatting.move(M,R,S),clearRules:M=>A.formatting.clear(M),views:()=>A.views.list(),activeId:()=>A.views.activeId,apply:M=>{A.views.apply(M)},saveAs:M=>A.views.save(M),rename:(M,R)=>A.views.rename(M,R),setDefault:M=>A.views.setDefault(M),clearDefault:()=>A.views.setDefault(null),remove:M=>A.views.remove(M),export:M=>A.views.export(M),diff:M=>A.views.diff(M),moveColumn(M,R,S){const I=A.columns.all().map(J=>J.id),q=I.indexOf(M),Z=I.indexOf(R);if(q<0||Z<0)return;let _=S?Z:Z+1;q<_&&(_-=1),_!==q&&A.columns.move(M,_)},isFiltered(M){return g(A.filters.get(),M)!==null},clearFilter(M){A.filters.set(i(A.filters.get(),M,null));const R=z.get(M);R&&L(R.clear)?R.clear():R&&L(R.set)&&R.set(null)},clearAllFilters(){A.filters.set(null);for(const M of z.values())L(M.clear)?M.clear():L(M.set)&&M.set(null)},filterFor(M){if(z.has(M))return E(z.get(M),M,A),z.get(M);const R=A.columns.get(M);if(!R)return null;const S=R.filter&&R.filter.props&&R.filter.props.values,I=d(A),q=I?A.config().context??null:null,Z=I?te=>I.columnValues(M,{...te||{},context:q}):null,_={grid:A,column:R,colId:M,type:R.type,locale:A.get("locale"),props:{...R.filter&&R.filter.props,values:S||(R.lookup?void 0:I?()=>Z({limit:s}).then(te=>te&&te.supported?te.values.map(ne=>ne.value):[]):()=>A.columns.distinct(M)),...I?{valueList:!1}:{}},lookup:R.lookup,document:j,value:te=>A.rows.value(te.row&&te.row.key,M),rows:I?()=>[]:R.lookup?void 0:()=>o(A),changed:()=>{const ne=(L(J.active)?J.active():!0)&&L(J.get)?J.get():null;A.filters.set(i(A.filters.get(),M,ne||null))},fetchValues:Z};let J=null;const ee=I&&!S&&!R.lookup?v(R):null;if(ee&&h(ee)){const te=I.columnValuesRefusal(M);if(te){const ne=new y;ne.init({..._,props:{..._.props,valueList:!1}}),J=m(j,ne,A.messages.t("filter.valuesUnsupported",{column:R.title||M})),B(`filter:values-unsupported:${M}`,`the filter on column "${M}" cannot list its values: ${te}. It offers the text condition editor instead.`)}else J=new a,J.init(_)}else J=D(_);return J&&(E(J,M,A),z.set(M,J)),J},destroyFilters(){for(const M of z.values())L(M.destroy)&&M.destroy();z.clear()}}}class C{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(j){this.#e=j.grid,this.#t=j.document,this.#n=j.root,this.#o=x(j.grid,j.document,j.announce);const z=(j.panels||["columns","filters"]).map(M=>X[M]?{name:M,title:H[M]?j.grid.messages.t(H[M]):M,icon:V[M]||M,Ctor:X[M],props:T(M,j.grid)}:(B(`toolpanel:${M}`,`unknown tool panel "${M}"`),null)).filter(Boolean);this.#l=j.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:j.document,host:this.#o,grid:j.grid,panels:z,actions:j.actions,icons:j.icons,side:this.#l,openPanel:j.openPanel})}mount(){const j=this.#t.createElement("div");j.className=`${b} ${b}--${this.#l}`,j.appendChild(this.#r.element()),this.#n.appendChild(j),this.#i=j;const $=this.#r.show.bind(this.#r),z=this.#r.hide.bind(this.#r);this.#r.show=M=>{const R=$(M);return this.#h(),R},this.#r.hide=()=>{z(),this.#h()};for(const M of[...l,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(M,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",M=>{this.#u=!0;const R=M&&M.options&&Array.isArray(M.options.chrome)?M.options.chrome:[];this.#c=R.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",M=>{const R=M&&M.colId,S=this.#r.panels.find(I=>I.name==="statistics");S&&R!=null&&(S.panel.column=String(R)),this.open("statistics")})),this.#h()}open(j){this.#r.show(j),this.#h()}close(){this.#r.hide(),this.#h()}toggle(j){this.#r.toggle(j),this.#h()}addAction(j){if(!(!j||!j.name)&&!this.#r.actions.some($=>$.name===j.name)){if(this.#r.registerAction(j),this.#a&&!j.annotation){const $=this.#r.actions.find(z=>z.name===j.name);$&&this.#f($.button)}else!this.#a&&j.annotation&&this.#u&&!this.#c&&this.#d();this.#h()}}removeAction(j){this.#r.removeAction(j)&&this.#h()}presentOnly(){return this.#a?!0:this.#r.actions.some(j=>j.annotation&&j.button)?(this.#d(),!0):!1}#d(){const j=this.#r;this.#a={hidden:[],reopen:j.openPanel||null},this.#a.reopen&&j.hide(),this.#f(j.body);for(const $ of[...j.tabs?.children||[]])$!==j.actionGroup&&this.#f($);for(const $ of[...j.actionGroup?.children||[]]){const z=j.actions.find(M=>M.button===$);(!z||!z.annotation)&&this.#f($)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#h()}presentRestore(){const j=this.#a;if(!j)return!1;this.#a=null;for(const $ of j.hidden)$.el&&$.el.style&&($.el.style.display=$.display);return j.reopen&&this.#r.show(j.reopen),this.#h(),!0}#f(j){if(!j||!j.style||!this.#a)return;const $=j.style.display||"";$!=="none"&&(j.style.display="none",this.#a.hidden.push({el:j,display:$}))}#h(){if(!this.#i)return;const j=!!this.#r.openPanel;this.#i.setAttribute("data-open",j?"true":"false"),this.#i.style.width=j?`${k}px`:"";const $=`${j?k:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?$:"",this.#n.style.paddingRight=this.#l==="left"?"":$,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?$:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":$)}#p(){const j=this.#r&&L(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,$=j&&(j.offsetWidth||j.getBoundingClientRect?.().width)||0;return $>0?Math.ceil($):p}destroy(){for(const j of this.#s)j();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=""}}}),xe("packages/dom/src/celledit.js",function(e,G){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return y}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/dom/src/editors/index.js").createEditor,X=G("packages/dom/src/editors/common.js"),H=X.CLS,V=X.markInvalid,K=X.isEditable,v=G("packages/dom/src/detailhost.js").insideDetail,O=`${H.editor}-host`;class y{#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",g=>this.open(g))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,r=this.#e.get("edit"),o=r&&typeof r=="object"&&r.start||"double",f=g=>{if(v(g.target,t))return;const d=u(g.target,k=>k.getAttribute&&k.getAttribute("data-col"));if(!d)return;const h=u(d,k=>k.getAttribute&&k.getAttribute("data-key"));if(!h)return;const l=this.#e.rows.byKey(h.getAttribute("data-key"));if(!l||l.group)return;const m=d.getAttribute("data-col"),w=this.#e.columns.get(m);!w||!w.edit||!w.edit.enabled||this.#e.edit.start(l.key,m)},c=o==="key"?null:o==="single"?"click":"dblclick";c&&(t.addEventListener(c,f),this.#u.push(()=>t.removeEventListener(c,f)));const i=g=>{!this.#i||!this.#l||this.#p(g.target)||this.commit()};this.#t.addEventListener("mousedown",i,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",i,!0))}get target(){return this.#l}open(t){this.close();const r=t.key||t.row&&t.row.key,o=t.colId;if(!r||!o)return;const f=this.#e.columns.get(o),c=this.#e.rows.byKey(r);if(!f||!c||!K({column:f,edit:f.edit,row:c,value:this.#e.rows.value(r,o),grid:this.#e}))return;const i=this.#w(r,o);if(this.#c=i,!i){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const g=this.#e.permissions,d=!!(g&&L(g.isSecret)&&g.isSecret(o)),h=W({grid:this.#e,column:f,colId:o,row:c,data:c.data,value:d?null:this.#e.rows.value(r,o),text:d?"":this.#e.rows.text(r,o),locale:this.#e.get("locale"),props:f.edit&&f.edit.props,lookup:f.lookup,document:this.#t,cell:i,overlay:this.#n.viewport.overlays,onCommit:w=>this.#h({value:w,key:r,colId:o}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:w=>{this.#d||this.#e.edit.stop(w)}},this.#r);if(!h){B(`celledit.noeditor:${o}`,`column "${o}" has no editor.`);return}this.#i=h,this.#s=i,this.#l={key:r,colId:o},this.#d=!1,this.#a=this.#y(i);const l=h.element();h.popup?(this.#n.viewport.overlays.appendChild(l),a(l,i,this.#n.viewport.root)):i.replaceChildren(l),i.classList.add(O),L(h.attached)&&h.attached(),s(l);const m=w=>this.#f(w);l.addEventListener("keydown",m),this.#u.push(()=>l.removeEventListener("keydown",m))}#f(t){const r=t.key;if(r!=="Enter"&&r!=="Tab"&&r!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),r==="Escape"){this.#e.edit.stop(!0);return}const o=r==="Enter"?this.#m(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&o&&this.#e.edit.start(o.key,o.colId)}#h(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(L(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:r}=this.#l;if(L(this.#i.value)){const o=this.#i.value();if(L(this.#i.validate)){const f=this.#i.validate(o);if(f!==!0){if(V(this.#c,f),L(this.#i.focusTarget)){const c=this.#i.focusTarget();c&&L(c.focus)&&c.focus()}return!1}V(this.#c,null)}this.#h({value:o,key:t,colId:r})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#p(t){if(!t)return!1;const r=L(this.#i.element)?this.#i.element():null;if(r&&L(r.contains)&&r.contains(t))return!0;const o=this.#c;return!!(o&&L(o.contains)&&o.contains(t))}#m(t){if(!this.#l||this.#a<0)return null;for(let r=this.#a+t;r>=0&&r<this.#e.rows.count();r+=t){const o=this.#e.rows.get(r);if(o&&!o.group)return{key:o.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const r=this.#e.columns.visible(),o=r.findIndex(f=>f.id===this.#l.colId);for(let f=o+t;f>=0&&f<r.length;f+=t){const c=r[f];if(c.edit&&c.edit.enabled)return{key:this.#l.key,colId:c.id}}return null}#y(t){const r=u(t,f=>f.getAttribute&&f.getAttribute("data-index"));if(!r)return-1;const o=Number(r.getAttribute("data-index"));return Number.isFinite(o)?o:-1}#w(t,r){const o=this.#n.viewport.root;if(!o||!o.querySelectorAll)return null;for(const f of o.querySelectorAll(`[data-col="${r}"]`)){const c=u(f,i=>i.getAttribute&&i.getAttribute("data-key"));if(c&&c.getAttribute("data-key")===t)return f}return null}close(){this.#c&&V(this.#c,null);const t=this.#k();if(this.#i&&L(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(O),this.#o&&L(this.#o.releaseCell)){const r=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,r)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#b(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}#k(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const r=this.#i&&L(this.#i.element)?this.#i.element():null,o=f=>!!f&&L(f.contains)&&f.contains(t);return o(r)||o(this.#s)}#b(t){const o=L(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;o&&L(o.focus)&&o.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function u(n,t){let r=n;for(;r;){if(t(r))return r;r=r.parentNode}return null}function a(n,t,r){if(!L(t.getBoundingClientRect))return;const o=t.getBoundingClientRect(),f=r.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(o.top-f.top)}px`,n.style.minWidth=`${Math.round(o.width)}px`,n.style.left=`${Math.round(o.left-f.left)}px`;const c=n.offsetWidth||Math.round(o.width),i=Math.round(o.left-f.left)+c-Math.round(f.width);i>0&&(n.style.left=`${Math.max(0,Math.round(o.left-f.left)-i)}px`)}function s(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;L(t.focus)&&t.focus(),L(t.select)&&t.select()}}),xe("packages/dom/src/editbar.js",function(e,G){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return K}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/dom/src/editors/index.js").createEditor,V=`${G("packages/dom/src/editors/common.js").CLS.editor}-bar`;class K{#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,O=v.createElement("div");O.className=V;const y=v.createElement("span");y.className=`${V}__ref`,y.textContent="";const u=v.createElement("div");u.className=`${V}__slot`;const a=v.createElement("span");a.className=`${V}__readonly`,O.appendChild(y),O.appendChild(u),this.#n.insertBefore(O,this.#n.firstChild),this.#r=O,this.#o=y,this.#i=u,this.#l=a;for(const s of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(s,n=>this.#h(n)))}bind(v,O){const y=this.#e.columns.get(O),u=v?this.#e.rows.byKey(v):null;this.#a=u&&y&&!u.group?{key:v,colId:O}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#f(),!this.#a){this.#o.textContent="";return}const{key:v,colId:O}=this.#a,y=this.#e.columns.get(O);if(!y)return;if(this.#o.textContent=y.title||O,!!!(y.edit&&y.edit.enabled)){this.#l.textContent=this.#e.rows.text(v,O),this.#i.appendChild(this.#l);return}const a=this.#e.rows.byKey(v);if(!a)return;const s=W({grid:this.#e,column:y,colId:O,row:a,data:a.data,value:this.#e.rows.value(v,O),text:this.#e.rows.text(v,O),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:f=>f?this.cancel():this.commit(!0)});if(!s){B(`editbar.noeditor:${O}`,`column "${O}" has no editor.`),this.#l.textContent=this.#e.rows.text(v,O),this.#i.appendChild(this.#l);return}this.#s=s;const n=s.element();s.popup?(this.#l.textContent=this.#e.rows.text(v,O),this.#i.appendChild(this.#l)):this.#i.appendChild(n),L(s.attached)&&s.attached();const t=f=>this.#p(f),r=()=>{this.#u=!0},o=[n,this.#i];for(const f of o)f.addEventListener("keydown",t),f.addEventListener("input",r),f.addEventListener("change",r);this.#c=()=>{for(const f of o)f.removeEventListener("keydown",t),f.removeEventListener("input",r),f.removeEventListener("change",r)}}#f(){this.#c&&(this.#c(),this.#c=null),this.#s&&L(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#h(v){if(v&&v.colId&&(v.key||v.row&&v.row.key)){this.bind(v.key||v.row.key,v.colId);return}this.refresh()}#p(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:O,colId:y}=this.#a;if(!this.#s||!L(this.#s.value))return!1;const u=this.#s.value();return this.#u=!1,this.#e.edit.start(O,y),this.#e.edit.stop(!1,{value:u,key:O,colId:y}),this.refresh(),!0}destroy(){this.#f();for(const v of this.#d)v();this.#d=[],this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),xe("packages/dom/src/pastepreview.js",function(e,G){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return D}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),X=W.el,H=W.clear,V="lat-pastepreview",K='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(O){this.#e=O.grid,this.#t=O.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(O,y){const u=this.#e;return(u&&u.messages?u.messages:F).t(O,y)}#d(O){const y=`paste.preview.reason.${O}`,u=this.#c(y);return u===y?O:u}#f(O){return O==null||O===""?"":String(O)}#h(O,y){const u=this.#e.columns&&L(this.#e.columns.get)?this.#e.columns.get(y):null;return`${u&&(u.title||u.headerName)||y} · ${O}`}show(O,y){const u=this.#w();if(!u)return!1;this.#l=y&&y.onConfirm,this.#a=y&&y.onCancel||null;const a=O&&O.changes||[],s=O&&O.rejected||[],n=a.filter(r=>r.changed);this.#p(n,s);const t=u.ownerDocument;return this.#s=t&&t.activeElement,u.style.display="",L(u.focus)&&u.focus(),this.#b(this.#c("a11y.paste.previewOpened",{count:n.length,changes:n.length,rejected:s.length}),{repeat:!0}),!0}#p(O,y){const u=this.#r.ownerDocument;H(this.#r);const a=X(u,"p",{class:`${V}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:O.length,changes:O.length,rejected:y.length})});if(this.#r.appendChild(a),!O.length&&!y.length){this.#r.appendChild(X(u,"p",{class:`${V}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!O.length;return}this.#o.disabled=!O.length,O.length&&(this.#r.appendChild(X(u,"h3",{class:`${V}__heading`,text:this.#c("paste.preview.changesHeading",{count:O.length})})),this.#r.appendChild(this.#m(u,O))),y.length&&(this.#r.appendChild(X(u,"h3",{class:`${V}__heading ${V}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:y.length})})),this.#r.appendChild(this.#g(u,y)))}#m(O,y){const u=X(O,"tr",{children:[X(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),a=y.map(s=>X(O,"tr",{children:[X(O,"th",{attrs:{scope:"row"},text:this.#h(s.key,s.colId)}),X(O,"td",{class:`${V}__old`,text:this.#f(s.oldValue)}),X(O,"td",{class:`${V}__new`,text:this.#f(s.newValue)})]}));return X(O,"table",{class:`${V}__table`,children:[X(O,"thead",{children:[u]}),X(O,"tbody",{children:a})]})}#g(O,y){const u=X(O,"tr",{children:[X(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),a=y.map(s=>X(O,"tr",{children:[X(O,"th",{attrs:{scope:"row"},text:this.#h(s.key,s.colId)}),X(O,"td",{class:`${V}__reason`,text:this.#d(s.reason)})]}));return X(O,"table",{class:`${V}__table ${V}__table--rejected`,children:[X(O,"thead",{children:[u]}),X(O,"tbody",{children:a})]})}confirm(){const O=this.#l;this.#y(),L(O)&&O()}cancel(){const O=this.#a;this.#y(),this.#b(this.#c("a11y.paste.cancelled"),{repeat:!0}),L(O)&&O()}#y(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const O=this.#s;this.#s=null,O&&L(O.focus)&&O.focus()}#w(){if(this.#n)return this.#n;const O=this.#t.viewport&&this.#t.viewport.overlays,y=O&&O.ownerDocument;if(!O||!y||!L(y.createElement))return null;const u=`${V}-title`,a=X(y,"h2",{class:`${V}__title`,attrs:{id:u},text:this.#c("paste.preview.title")}),s=X(y,"div",{class:`${V}__body`}),n=X(y,"button",{class:`${V}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=X(y,"button",{class:`${V}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),r=X(y,"div",{class:`${V}__foot`,children:[t,n]}),o=X(y,"div",{class:V,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":u},children:[X(y,"div",{class:`${V}__head`,children:[a]}),s,r]});return O.appendChild(o),this.#n=o,this.#r=s,this.#o=n,this.#i=t,this.#k(o,n,t),o}#k(O,y,u){const a=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const r=[...O.querySelectorAll(K)].filter(i=>!i.disabled);if(!r.length){t.preventDefault();return}const o=r[0],f=r[r.length-1],c=O.ownerDocument.activeElement;t.shiftKey&&(c===o||c===O)?(t.preventDefault(),f.focus()):!t.shiftKey&&c===f&&(t.preventDefault(),o.focus())},s=t=>{t&&L(t.preventDefault)&&t.preventDefault(),this.confirm()},n=t=>{t&&L(t.preventDefault)&&t.preventDefault(),this.cancel()};O.addEventListener("keydown",a),y.addEventListener("click",s),u.addEventListener("click",n),this.#u.push(()=>{O.removeEventListener("keydown",a),y.removeEventListener("click",s),u.removeEventListener("click",n)})}#b(O,y){const u=this.#t&&this.#t.announce;L(u)&&u.call(this.#t,O,y)}destroy(){for(const O of this.#u)O();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}}}),xe("packages/dom/src/rangeselect.js",function(e,G){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/core/src/model/selection.js"),X=W.extendSeries,H=W.resolveSelectionConfig,V=G("packages/dom/src/renderer/textentry.js"),K=V.isTextEntry,D=V.isFindBarControl,O=G("packages/dom/src/pastepreview.js").PastePreview,y=G("packages/dom/src/columnmenu.js"),u=y.chartableRange,a=y.rangeChartConfig,s="lat-cell--range",n="lat-cell--range-edge",t=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),r=3;class o{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document,this.#a=i.preview||null}mount(){const i=this.#t.viewport.root,g=m=>this.#c(m),d=m=>this.#d(m),h=()=>this.#f(),l=m=>this.#h(m);i.addEventListener("pointerdown",g),this.#n.addEventListener("pointermove",d),this.#n.addEventListener("pointerup",h),i.addEventListener("keydown",l),this.#o.push(()=>{i.removeEventListener("pointerdown",g),this.#n.removeEventListener("pointermove",d),this.#n.removeEventListener("pointerup",h),i.removeEventListener("keydown",l)});for(const m of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(m,()=>this.paint()));this.paint()}#c(i){if(i.button!==0)return;const g=i.target;if(!g||!L(g.closest))return;if(this.#r=!1,g.closest('[data-role="fill-handle"]')){if(this.#E())return;this.#i={mode:"fill",fromX:i.clientX,fromY:i.clientY,armed:!0};return}if(g.closest('[data-role="row-drag"]'))return;const d=this.#N(g);if(!d)return;if(i.shiftKey&&this.#e.selection.corner()){const l=this.#A(d);this.#e.selection.extendRange(l.rowIndex,l.colId),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!0};return}const h=this.#M(d);this.#u=h,this.#e.selection.startRange(h.rowIndex,h.colId,{additive:i.ctrlKey||i.metaKey}),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!1}}#d(i){const g=this.#i;if(!g)return;if(!g.armed){if(Math.abs(i.clientX-g.fromX)+Math.abs(i.clientY-g.fromY)<r)return;g.armed=!0}const d=this.#H(i.clientX,i.clientY);if(!d)return;if(g.mode==="fill"){this.#l=d,this.paint();return}const h=this.#A(d);this.#e.selection.extendRange(h.rowIndex,h.colId)}#f(){const i=this.#i;if(this.#i=null,!!i){if(i.mode==="fill"&&this.#l){const g=this.#l;this.#l=null,this.fillTo(g.rowIndex)}this.#l=null,this.paint()}}#h(i){if(this.#x()||D(i.target)||K(i.target))return;const g=i.ctrlKey||i.metaKey,d=i.key;if(g&&(d==="c"||d==="C")){this.copy(),i.preventDefault();return}if(g&&(d==="v"||d==="V")){this.paste(),i.preventDefault();return}if(g&&(d==="d"||d==="D")){this.fillDown(),i.preventDefault();return}if(d==="Delete"||d==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),i.preventDefault();return}this.clear(),i.preventDefault();return}if(i.altKey&&d==="F1"){this.chartSelection()&&i.preventDefault();return}if(!i.shiftKey)return;const h={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[d];if(!h)return;if(g){const P=this.#$();if(!P)return;if(!this.#r){const $=this.#M(P);this.#u=$,this.#e.selection.startRange($.rowIndex,$.colId,{additive:!0}),this.#r=!0}const x=this.#e.columns.visible().map($=>$.id),C=x.indexOf(P.colId),A=this.#e.selection.corner()||{row:P.rowIndex,colId:P.colId},j=this.#A({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,A.row+h[0])),colId:x[Math.min(x.length-1,Math.max(0,(C<0?0:C)+h[1]))]});this.#e.selection.extendRange(j.rowIndex,j.colId),i.preventDefault();return}this.#r=!1;const l=this.#e.selection.corner(),m=this.#$(),w=l||m;if(!w)return;if(!l&&m){const P=this.#M(m);this.#u=P,this.#e.selection.startRange(P.rowIndex,P.colId)}const k=this.#e.columns.visible().map(P=>P.id),p=k.indexOf(w.colId??w.colId),b=k[Math.min(k.length-1,Math.max(0,p+h[1]))],E=Math.min(this.#e.rows.count()-1,Math.max(0,(l?l.row:m.rowIndex)+h[0])),T=this.#A({rowIndex:E,colId:b});this.#e.selection.extendRange(T.rowIndex,T.colId),i.preventDefault()}async copy(){const i=this.#e.export.rangeText();if(!i)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const g=globalThis.navigator&&globalThis.navigator.clipboard;if(!g||!L(g.writeText))return!1;try{return await g.writeText(i),this.#e.emit("clipboard:copy",{text:i,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:i,ok:!1,rows:"range"},"user"),!1}}async paste(){const i=globalThis.navigator&&globalThis.navigator.clipboard;if(!i||!L(i.readText))return 0;let g="";try{g=await i.readText()}catch{return 0}return this.pasteText(g)}pasteText(i){if(!i)return 0;const g=this.#e.selection.cells(),d=g.length?g[0]:this.#k();if(!d)return 0;const h=g.length>1?{rows:new Set(g.map(l=>l.key)).size,columns:new Set(g.map(l=>l.colId)).size}:void 0;if(this.#p()){const l=this.#e.edit.previewPaste(d,i,h);if(l.changes.length+l.rejected.length>1)return this.#m().show(l,{onConfirm:()=>this.#g(d,i,h)}),0}return this.#g(d,i,h)}#p(){const i=this.#e.edit;return!!(i&&i.pastePreview&&L(i.previewPaste))}#m(){return this.#a||(this.#a=new O({grid:this.#e,renderer:this.#t})),this.#a}#g(i,g,d){const h=this.#e.edit.pasteInto(i,g,d);return this.#w(h?this.#y("a11y.range.written",{count:h}):this.#y("a11y.range.refused"),{repeat:!0}),h}#y(i,g){const d=this.#e;return(d&&d.messages?d.messages:F).t(i,g)}#w(i,g){const d=this.#t&&this.#t.announce;L(d)&&d.call(this.#t,i,g)}#k(){const i=this.#$();if(!i)return null;const g=this.#e.rows.get(i.rowIndex);return g?{key:g.key,colId:i.colId}:null}clear(){const i=this.#e.selection.cells();return i.length?this.#e.edit.setCells(i.map(g=>({...g,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const i=this.#e.selection.cells();if(i.length<2)return 0;const g=[...new Set(i.map(l=>l.key))];if(g.length<2)return 0;const d=g[0],h=[];for(const{key:l,colId:m}of i)l!==d&&h.push({key:l,colId:m,value:this.#e.rows.value(d,m)});return this.#e.edit.setCells(h)}chartSelection(){const i=a(this.#e);if(!i.handler)return!1;const g=u(this.#e);return g?(i.handler(this.#e,g),!0):!1}fillTo(i){if(this.#e.selection.ranges().length>1)return 0;const g=this.#e.selection.cells();if(!g.length)return 0;const d=[...new Set(g.map(b=>b.key))],h=[...new Set(g.map(b=>b.colId))],l=this.#z(d[d.length-1]);if(l<0||i<=l)return 0;const m=[];for(let b=l+1;b<=i;b++){const E=this.#e.rows.get(b);if(!E)break;m.push(E)}if(!m.length)return 0;const w=[];for(const b of h){const E=d.map(P=>this.#e.rows.value(P,b)),T=this.#b(E,m,b);for(let P=0;P<m.length;P++)w.push({key:m[P].key,colId:b,value:T[P]})}const k=this.#e.edit.setCells(w),p=this.#e.selection.corner();return p&&this.#e.selection.extendRange(i,p.colId),k}#b(i,g,d){const h=this.#e.get("selection"),l=h&&typeof h=="object"?h.fill:void 0;if(L(l)){const m=this.#e.columns.get(d),w=g.map(p=>({row:p,column:m})),k=l({source:i,target:w,direction:"down"});if(Array.isArray(k)&&k.length===g.length)return k}return X(i,g.length)}paint(){const i=this.#t.viewport.root;if(!i||!i.querySelectorAll)return;const g=this.#e.selection,d=g.ranges().length>0,h=this.#l;for(const l of i.querySelectorAll("[data-col]")){const m=l.getAttribute("data-col"),w=l.parentNode,k=l.getAttribute?l.getAttribute("data-index"):null,p=k!==null&&k!==""?k:w&&w.getAttribute?w.getAttribute("data-index"):null;if(p===null||p==="")continue;const b=Number(p);if(!Number.isFinite(b)||b<0)continue;const E=d&&g.inRange(b,m),T=!!h&&this.#O(b,m,h);l.classList.toggle(s,E||T);const P=E||T?this.#j(b,m,g):null;l.classList.toggle(n,!!P&&P.any);for(const[x,C]of Object.entries(t))l.classList.toggle(C,!!P&&P[x])}this.#P()}#O(i,g,d){const h=this.#e.selection.cells();if(!h.length||!new Set(h.map(w=>w.colId)).has(g))return!1;const m=this.#z([...new Set(h.map(w=>w.key))].pop());return i>m&&i<=d.rowIndex}#j(i,g,d){const h=this.#e.columns.visible().map(p=>p.id),l=h.indexOf(g),m=l>0?h[l-1]:null,w=l>=0&&l<h.length-1?h[l+1]:null,k={top:!d.inRange(i-1,g),bottom:!d.inRange(i+1,g),left:!m||!d.inRange(i,m),right:!w||!d.inRange(i,w)};return k.any=k.top||k.bottom||k.left||k.right,k}#P(){const i=this.#e.selection.corner(),g=this.#t.viewport.overlays;if(!g)return;if(!i||this.#L()===!1||this.#e.selection.ranges().length>1||this.#E()){this.#s&&(this.#s.style.display="none");return}const d=this.#B(i.row,i.colId);if(!d||!L(d.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.#y("a11y.fillHandle")),g.appendChild(this.#s));const h=d.getBoundingClientRect(),l=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const w=this.#t.viewport.rtl===!0?h.left:h.right;this.#s.style.left=`${Math.round(w-l.left)-4}px`,this.#s.style.top=`${Math.round(h.bottom-l.top)-4}px`}#S(i){const g=this.#t;return!i||typeof g.spanAt!="function"?null:g.spanAt(i.rowIndex,i.colId)}#M(i){const g=this.#S(i);return g?{rowIndex:g.row,colId:g.columnId}:i}#A(i){const g=this.#S(i);if(!g)return i;const d=this.#u,h=!!d&&d.rowIndex>=g.row+g.rows,l=this.#R(),m=d?l.indexOf(d.colId):-1,w=m>=0&&m>=g.col+g.cols;return{rowIndex:h?g.row:g.row+g.rows-1,colId:w?g.columnId:g.endColumnId}}#E(){const i=this.#e.selection.corner();if(!i)return!1;const g=this.#S({rowIndex:i.row,colId:i.colId});return!!g&&(g.rows>1||g.cols>1)}#R(){const i=this.#e.columns;return i&&L(i.visible)?i.visible().map(g=>g.id):[]}#L(){return H(this.#e.get("selection")).fillHandle}#x(){const i=this.#t.viewport.root;return!!(i&&i.querySelector&&i.querySelector(".lat-editor-host, .lat-editor--popup"))}#I(){const i=this.#e.selection.cells();return i.length?i[0]:null}#z(i){for(let g=0;g<this.#e.rows.count();g++){const d=this.#e.rows.get(g);if(d&&d.key===i)return g}return-1}#$(){const i=this.#t.viewport.root,g=i&&i.querySelector?i.querySelector('[data-col][tabindex="0"]'):null;return g?this.#N(g):null}#N(i){if(!i||!L(i.closest))return null;const g=i.closest("[data-col]");if(!g||!g.classList.contains("lat-cell"))return null;const d=g.closest("[data-index]");if(!d)return null;const h=Number(d.getAttribute("data-index"));return!Number.isFinite(h)||h<0?null:{rowIndex:h,colId:g.getAttribute("data-col")}}#H(i,g){const d=this.#n.elementFromPoint?this.#n.elementFromPoint(i,g):null;return d?this.#N(d):null}#B(i,g){const d=this.#t.viewport.root;if(!d||!d.querySelectorAll)return null;for(const h of d.querySelectorAll(`[data-col="${g}"]`)){const l=h.closest?h.closest("[data-index]"):null;if(l&&Number(l.getAttribute("data-index"))===i)return h}return null}destroy(){for(const i of this.#o)i();this.#o=[],this.#s&&L(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&L(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const f=o}),xe("packages/dom/src/importer.js",function(e,G){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return o}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/core/src/import/index.js"),X=W.parseDelimited,H=W.inferColumns,V=W.mapRecords,K=W.readXlsx,D=W.looksLikeXlsx,v=G("packages/dom/src/editors/common.js"),O=v.el,y=v.clear,u=v.on,s=G("packages/dom/src/renderer/textentry.js").isTextEntry,n="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class o{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#n=c.document;const i=c.settings&&typeof c.settings=="object"?c.settings:{};this.#r={file:i.file!==!1,drop:i.drop!==!1,paste:i.paste!==!1,mode:i.mode==="replace"?"replace":"append"},this.#u()}#u(){const c=this.#t&&this.#t.viewport?this.#t.viewport.root:null;c&&(this.#r.drop&&(this.#o.push(u(c,"dragover",i=>{i.dataTransfer&&[...i.dataTransfer.types||[]].includes("Files")&&(i.preventDefault(),c.classList.add("lat-import--dropzone"))})),this.#o.push(u(c,"dragleave",()=>c.classList.remove("lat-import--dropzone"))),this.#o.push(u(c,"drop",i=>{c.classList.remove("lat-import--dropzone");const g=i.dataTransfer&&i.dataTransfer.files&&i.dataTransfer.files[0];g&&(i.preventDefault(),this.#c(g))}))),this.#r.paste&&this.#o.push(u(c,"paste",i=>{if(s(i.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const g=i.clipboardData&&i.clipboardData.getData("text/plain");!g||!g.includes(`
|
|
57
|
-
`)||(i.preventDefault(),this.fromText(g))})))}openFile(){const c=O(this.#n,"input",{attrs:{type:"file",accept:r}});c.style.display="none",this.#o.push(u(c,"change",()=>{const i=c.files&&c.files[0];i&&this.#c(i),c.parentNode&&c.parentNode.removeChild(c)})),this.#n.body.appendChild(c),c.click()}#c(c){if(L(c.arrayBuffer)){c.arrayBuffer().then(g=>{const d=new Uint8Array(g);if(D(d)){this.fromXlsx(d,c.name);return}this.fromText(new TextDecoder().decode(d),c.name)});return}if(L(c.text)){c.text().then(g=>this.fromText(g,c.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),c.name),i.readAsText(c)}async fromXlsx(c,i){const{header:g,rows:d}=await K(c);if(!g.length)return;const h=H(g,d,{columns:this.#e.columns.all()}),l=d.filter(m=>m.length!==g.length).length;this.#l={rows:d,columns:h,delimiter:null,name:i,warnings:l?[`${l} row(s) do not have ${g.length} columns`]:[]},this.#d()}fromText(c,i){const{header:g,rows:d,delimiter:h}=X(c);if(!g.length)return;const l=H(g,d,{columns:this.#e.columns.all()}),m=d.filter(w=>w.length!==g.length).length;this.#l={rows:d,columns:l,delimiter:h,name:i,warnings:m?[`${m} row(s) do not have ${g.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const c=this.#i.querySelector(t);c&&L(c.focus)&&c.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(c,i){const g=this.#t&&this.#t.announce;L(g)&&g.call(this.#t,c,i)}#h(c,i){return(this.#e&&this.#e.messages?this.#e.messages:F).t(c,i)}#p(){const c=this.#n,i=O(c,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),g=O(c,"div",{class:`${n}__panel`});g.appendChild(O(c,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=O(c,"div",{class:`${n}__body`}),g.appendChild(this.#s);const d=O(c,"div",{class:`${n}__footer`}),h=O(c,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),l=O(c,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(u(h,"click",()=>this.close())),this.#o.push(u(l,"click",()=>this.#g())),d.appendChild(h),d.appendChild(l),g.appendChild(d),i.appendChild(g),this.#o.push(u(i,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const k=[...i.querySelectorAll(t)].filter(E=>!E.hidden);if(!k.length)return;const p=k[0],b=k[k.length-1];w.shiftKey&&this.#n.activeElement===p?(w.preventDefault(),b.focus()):!w.shiftKey&&this.#n.activeElement===b&&(w.preventDefault(),p.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const c=this.#n,i=y(this.#s),{rows:g,columns:d,name:h,warnings:l}=this.#l;i.appendChild(O(c,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:g.length,name:h||this.#h("import.clipboard")})}));for(const E of l)i.appendChild(O(c,"p",{class:`${n}__warning`,text:E}));const m=this.#e.columns.all().map(E=>E.field||E.id).filter(Boolean),w=O(c,"table",{class:`${n}__map`}),k=O(c,"tr",{});for(const E of["import.colSource","import.colField","import.colType"])k.appendChild(O(c,"th",{text:this.#h(E)}));w.appendChild(k),d.forEach((E,T)=>{const P=O(c,"tr",{});P.appendChild(O(c,"td",{text:E.source}));const x=O(c,"select",{attrs:{"data-col":String(T),"aria-label":this.#h("import.mapLabel",{source:E.source})}});x.appendChild(O(c,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const A of m)x.appendChild(O(c,"option",{text:A,attrs:{value:A,selected:A===E.field?!0:null}}));E.field&&!m.includes(E.field)&&x.appendChild(O(c,"option",{text:E.field,attrs:{value:E.field,selected:!0}}));const C=O(c,"td",{});C.appendChild(x),P.appendChild(C),P.appendChild(O(c,"td",{class:`${n}__type`,text:E.type})),w.appendChild(P)}),i.appendChild(w);const p=O(c,"div",{class:`${n}__mode`}),b=O(c,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});b.appendChild(O(c,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),b.appendChild(O(c,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),p.appendChild(O(c,"label",{text:this.#h("import.modeLabel")})),p.appendChild(b),i.appendChild(p)}#g(){const{rows:c,columns:i}=this.#l;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));i[w]&&m.value!==void 0&&m.value!==null&&(i[w].field=m.value)}const g=this.#i.querySelector("select[data-mode]"),d=g?g.value:void 0,h=d==="replace"||d==="append"?d:this.#r.mode,l=V(c,i);this.#e.import.apply(l,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:l.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&L(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const c of this.#o)c();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),xe("packages/dom/src/historybar.js",function(e,G){"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 O}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),X=W.el,H=W.on,V=W.clear,K=W.documentFor,D="lat-history";class v{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,a){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(u,a)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||F;const a=u||{};if(this.doc=K(a),this.host=a.host||{},this.props=a.props||{},this.root=X(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 s=X(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(s,"click",()=>this.toggle())),this.root.appendChild(s),this.toggleButton=s,this.menu=X(this.doc,"div",{class:`${D}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,a,s){const n=X(this.doc,"button",{class:`${D}__${u}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${D}__glyph`,text:s,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${D}__label`,text:a})]});return this.off.push(H(n,"click",()=>{const t=this.host[u];L(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,a=L(u.canUndo)?u.canUndo():!1,s=L(u.canRedo)?u.canRedo():!1,n=L(u.peek)?u.peek("undo"):null,t=L(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",a,n),this.#t(this.redoButton,"redo",s,t),this.open&&this.#n()}#t(u,a,s,n){if(!u)return;u.disabled=!s;const t=a==="undo",r=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${D}__label`);o&&(o.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;u.setAttribute("title",s?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",s?f:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;V(u);const a=L(this.host.list)?this.host.list():[];if(!a.length){u.appendChild(X(this.doc,"p",{class:`${D}__empty`,text:this.t("history.empty")}));return}a.forEach((s,n)=>{const t=X(this.doc,"button",{class:`${D}__item`,attrs:{type:"button",role:"menuitem","data-type":s.type,"data-undone":s.undone?"true":null},children:[X(this.doc,"span",{class:`${D}__kind`,text:s.type}),X(this.doc,"span",{class:`${D}__text`,text:s.label||s.type})]});this.off.push(H(t,"click",()=>{const r=n+1;for(let o=0;o<r;o++)L(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&L(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const O=v}),xe("packages/dom/src/diffpaint.js",function(e,G){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",V="lat-cell--added-column";class K{#e;#t;#n=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){for(const y of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(y,()=>this.paint()));this.paint()}paint(){const y=this.#t.viewport.root;if(!y||!y.querySelectorAll)return;const u=this.#e.diff,a=u&&u.enabled;for(const s of y.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key"),t=a?u.statusOf(n):"unchanged";for(const o of Object.values(X))s.classList.remove(o);a&&X[t]&&s.classList.add(X[t]),s.setAttribute("data-diff",a?t:"");const r=a&&t==="changed";for(const o of s.querySelectorAll("[data-col]")){const f=o.getAttribute("data-col");if(o.classList.remove(H,V),o.removeAttribute("data-before"),!r)continue;const c=u.cellStatus(n,f);if(c==="changed"){o.classList.add(H);const i=this.#r(u,n,f);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else c==="added-column"&&o.classList.add(V)}}}#r(y,u,a){const s=this.#e,n=s&&s.columns,t=n&&L(n.get)?n.get(a):null,r=s&&s.permissions;if(t&&r&&L(r.isSecret)&&r.isSecret(t))return null;const o=y.before(u,a);if(o==null)return this.#o("diff.empty");if(!t||!L(t.formatValue))return String(o);const f=L(y.beforeRow)?y.beforeRow(u):void 0,i={...(s.rows&&L(s.rows.byKey)?s.rows.byKey(u):null)||{},data:f===void 0?{}:f};try{const g=t.formatValue(o,i,i.data);return g==null?"":String(g)}catch(g){return B(`diff-before-format:${a}`,`the formatter for column "${a}" threw while formatting a previous value, so the diff hover shows the raw one.`,g),String(o)}}#o(y,u){const a=this.#e;return(a&&a.messages?a.messages:W).t(y,u)}destroy(){for(const u of this.#n)u();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const u of y.querySelectorAll("[data-key]")){for(const a of Object.values(X))u.classList.remove(a);u.removeAttribute("data-diff")}for(const u of y.querySelectorAll("[data-col]"))u.classList.remove(H,V),u.removeAttribute("data-before")}}}function D(O){return!!(O&&O.diff&&(L(O.diff)||typeof O.diff=="object"))}const v=K}),xe("packages/dom/src/highlightpaint.js",function(e,G){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",F="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const V=()=>{this.#o=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):L(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const K=this.#l();if(K){K.sweep();for(const D of V.querySelectorAll("[data-key]")){const v=D.getAttribute("data-key");for(const O of D.querySelectorAll("[data-col]")){const y=K.active?K.colourFor(v,O.getAttribute("data-col")):null;y?(O.classList.add(B),O.style.setProperty(F,y)):O.classList.contains(B)&&(O.classList.remove(B),O.style.removeProperty(F))}}this.#s(K)}}#s(V){this.#r!==null&&L(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const K=V.nextExpiry;if(!Number.isFinite(K)||!L(this.#i.setTimeout))return;const D=Math.max(0,K-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},D)}#l(){const V=this.#e.highlight;return V&&L(V.model)?V.model():null}destroy(){this.#r!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const K of this.#n)K();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const K of V.querySelectorAll(`.${B}`))K.classList.remove(B),K.style.removeProperty(F)}}const X=W}),xe("packages/dom/src/findpaint.js",function(e,G){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",F="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const V=()=>{this.#r=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):L(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const K=this.#e.find;if(!K||!L(K.stateFor))return;const D=L(K.model)?K.model():null,v=!!D&&D.active;if(!v&&!this.#o)return;let O=!1;for(const y of V.querySelectorAll("[data-key]")){const u=y.getAttribute("data-key");for(const a of y.querySelectorAll("[data-col]")){const s=v?K.stateFor(u,a.getAttribute("data-col")):null;s?(O=!0,a.classList.add(B),a.classList.toggle(F,s==="current")):a.classList.contains(B)&&a.classList.remove(B,F)}}this.#o=O}destroy(){for(const K of this.#n)K();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll)){for(const K of V.querySelectorAll(`.${B}`))K.classList.remove(B,F);this.#o=!1}}}const X=W}),xe("packages/dom/src/findbar.js",function(e,G){"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 u}});const Q=G("packages/dom/src/editors/common.js"),L=Q.el,B=Q.on,W=G("packages/dom/src/renderer/textentry.js").isTextEntry,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/core/src/internal/util.js").isFunction,D="lat-find",v=12,O=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!1;#p=!1;#m=null;#g=[];#y=null;#w=null;#k=!1;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#n=s.document||s.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=s.settings&&typeof s.settings=="object"?s.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(s,n){const t=this.#e;return(t&&t.messages&&K(t.messages.t)?t.messages:H).t(s,n)}mount(){const s=this.#O();if(!s)return;s.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),s.attachDriver({run:()=>this.#E()});const n=this.#t.viewport?.root;if(n&&K(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const o=r.target;if(this.#s&&o===this.#s){r.preventDefault(),r.stopPropagation(),K(this.#s.select)&&this.#s.select();return}W(o)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#P())),this.#g.push(this.#e.on("column:visible",()=>this.#P()))}show(s){const n=this.#j();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#b(),this.#O().setOpen(!0),s!=null&&(this.#s.value=String(s),this.#M()),this.#s.focus(),K(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#z();const s=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#b()),s&&(s.clear(),s.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&K(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(K(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;K(o.focus)&&o.focus()}search(){this.#M()}destroy(){this.#k=!0,this.#z();for(const n of this.#g)n();this.#g=[];const s=this.#O();s&&(s.attachUi(null),s.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#b(){const s=this.#t;s&&K(s.invalidate)&&s.invalidate("size")}#O(){const s=this.#e&&this.#e.find;return s&&K(s.model)?s.model():null}#j(){if(this.#i)return this.#i;const s=this.#t.viewport,n=s?.root,t=this.#n;if(!n||!t||!K(n.insertBefore))return null;const r=L(t,"div",{class:D,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=L(t,"input",{class:`${D}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=L(t,"span",{class:`${D}__count`,attrs:{"aria-hidden":"true"}}),this.#a=L(t,"span",{class:`${D}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=L(t,"span",{class:`${D}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=L(t,"button",{class:`${D}__nav ${D}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=L(t,"button",{class:`${D}__nav ${D}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=L(t,"button",{class:`${D}__toggle ${D}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=L(t,"button",{class:`${D}__toggle ${D}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=L(t,"select",{class:`${D}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const c=L(t,"button",{class:`${D}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=L(t,"div",{class:`${D}__options`,children:[this.#c,this.#d,this.#f]});for(const d of[this.#s,this.#l,this.#a,this.#u,o,f,c,i])r.appendChild(d);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),this.#M()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#M()})),this.#g.push(B(this.#f,"change",()=>{const d=this.#f.value;this.#m=d?String(d):null,this.#M()})),this.#g.push(B(c,"click",()=>this.hide()));const g=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),this.hide();return}d.key==="Enter"&&d.target===this.#s&&(d.preventDefault(),d.stopPropagation(),this.#y!==null&&(this.#x(),this.#M()),d.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",g),this.#g.push(()=>r.removeEventListener("keydown",g)),r.style.display="none",n.insertBefore(r,s.header||n.firstChild),this.#i=r,this.#P(),r}#P(){const s=this.#f;if(!s)return;const n=this.#n;for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(L(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&K(t.visible)?t.visible():[];let o=!1;for(const f of r){if(!f||f.id===void 0)continue;const c=String(f.id);s.appendChild(L(n,"option",{text:f.title||c,attrs:{value:c}})),c===this.#m&&(o=!0)}o||(this.#m=null),s.value=this.#m||""}#S(){const s=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):O;if(this.#x(),s===0||!K(this.#r.setTimeout)){this.#M();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#M()},s)}#M(){const s=this.#O();if(!s||this.#k)return;const n=this.#s?this.#s.value:"";if(!n){this.#I(),s.clear();return}s.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#A()}),this.#E()}#A(){const s=this.#t&&this.#t.window,n=s&&Number.isFinite(s.first)?s.first:0;return Math.max(0,n)}#E(){if(this.#w!==null||this.#k)return;const s=()=>{this.#w=null,this.#R()};K(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(s):K(this.#r.setTimeout)?this.#w=this.#r.setTimeout(s,0):s()}#R(){const s=this.#O();!s||this.#k||!s.active||(s.stale&&s.rescan({from:this.#A()}),!s.complete&&(s.step(v)||this.#E()))}#L(){if(!this.#i||this.#k)return;const s=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(s.total===0?(t=s.complete?this.t("find.none"):this.t("find.searching"),r=s.complete?"none":"searching"):(t=this.t(s.complete?"find.count":"find.countPartial",{current:s.current,total:s.total}),r=s.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const o=n&&s.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",n?s.complete&&(this.#u.textContent=s.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:s.current,count:s.total})):this.#u.textContent=""}#x(){this.#y!==null&&K(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#I(){this.#w!==null&&(K(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):K(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#z(){this.#x(),this.#I()}}const u=y}),xe("packages/dom/src/redactpaint.js",function(e,G){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q="lat-cell--redacted",L="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const H=this.#e.redaction;if(!H)return;const V=H.active;for(const K of X.querySelectorAll(`.${L}[data-col]`))V&&H.has(K.getAttribute("data-col"))?K.classList.add(Q):K.classList.contains(Q)&&K.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const F=B}),xe("packages/dom/src/validationpaint.js",function(e,G){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function F(H,V){let K=H;for(;K;){if(V(K))return K;K=K.parentNode}return null}class W{#e;#t;#n=[];constructor(V){this.#e=V.grid,this.#t=V.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const V of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(V,()=>this.paint()));this.paint()}#r(V){const K=F(V,D=>D.getAttribute&&D.getAttribute("data-key")!==null);return K?K.getAttribute("data-key"):null}paint(){const V=this.#e.validation;if(!V||!V.active)return;const K=this.#t.viewport?.root;if(!(!K||!K.querySelectorAll))for(const D of K.querySelectorAll(`.${B}[data-col]`)){const v=D.getAttribute("data-col"),O=this.#r(D),y=O?V.errorFor(O,v):null;L(D,y?y.message:null)}}destroy(){for(const V of this.#n)V();this.#n=[]}}const X=W}),xe("packages/dom/src/presentation.js",function(e,G){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/dom/src/renderer/textentry.js").isTextEntry,X=G("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",V="lat-presenting--changing",K="lat-presenting__progress",D="lat-cell--dimmed",v=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class O{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),this.#r.push(this.#e.on("presentation:view",s=>this.#a(s))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&L(this.#n.watch)&&this.#r.push(this.#n.watch(s=>{s||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const a=this.#t.viewport?.root;if(a&&L(a.addEventListener)){const s=n=>this.#l(n);a.addEventListener("keydown",s),this.#r.push(()=>a.removeEventListener("keydown",s))}}#l(a){const s=this.#e.presentation;if(!s?.active)return;const n=a.ctrlKey||a.metaKey,t=a.key;if(t==="Escape"&&!this.#n){a.defaultPrevented||(s.stop(),a.preventDefault?.());return}if(n){t==="="||t==="+"?(s.nudge(1),a.preventDefault?.()):t==="-"||t==="_"?(s.nudge(-1),a.preventDefault?.()):t==="0"&&(s.setScale(1.5),a.preventDefault?.());return}if(!s.views.length||F(a.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(s.step(1),a.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(s.step(-1),a.preventDefault?.()):t==="Home"?(s.goTo(0),a.preventDefault?.()):t==="End"?(s.goTo(s.views.length-1),a.preventDefault?.()):(t==="r"||t==="R")&&(s.reset(),a.preventDefault?.())}#a(a){!a||!a.viewId||(this.#u(),this.#e.views?.apply?.(a.viewId),this.#c(a))}#u(){const a=this.#t.viewport?.root;a?.classList&&(a.classList.remove(V),a.offsetWidth,a.classList.add(V))}#c(a){const s=this.#t.viewport?.overlays;if(!s||!this.#e.presentation.views.length)return;const n=s.ownerDocument;if(!n?.createElement)return;if(!this.#i){const o=n.createElement("div");o.className=K,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),s.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(a.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(a.index||0)+1} / ${a.count||0}`:`${(a.index||0)+1} / ${a.count||0}`}#d(){if(this.#o){this.#h();return}const a=!!(this.#n&&this.#n.active());this.#n&&!a&&this.#n.enter();const s=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of v){if(s.has(r)||r==="toolPanel"&&this.#k())continue;const o=this.#b(r);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",n.push(o))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:a,hidden:n},this.#t.viewport?.root?.classList?.add(H),this.#h(),this.#m()}#f(){const a=this.#o;this.#o=null;const s=this.#t.viewport?.root;if(s?.classList?.remove(H),s?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),s?.classList?.remove(V),this.#p(),a){const n=this.#e.toolPanel;n&&L(n.presentRestore)&&n.presentRestore();for(const t of a.hidden)t.style.display="";this.#n&&!a.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const a=this.#t.viewport?.root;!a||!a.style||(a.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const a=this.#t.viewport?.root;if(!a?.querySelectorAll)return;const s=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=s&&s.keys.length?new Set(s.keys):null,t=s&&s.colIds.length?new Set(s.colIds):null;for(const r of a.querySelectorAll("[data-key]")){const o=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!s||o&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(D):f.classList.add(D)}}#m(){this.#g();const a=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(a)||a<=0||!this.#e.presentation.views.length)return;const s=this.#t.viewport?.root?.ownerDocument?.defaultView;s?.setInterval&&(this.#s=s.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,a)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const a=this.#e.element;return!a||!L(a.querySelector)?null:a.querySelector(`.${X.statusBar}`)}#w(a){const s=a.children||[];for(const n of s)if(!n.style||n.style.display!=="none")return!1;return!0}#k(){const a=this.#e.toolPanel;return!!(a&&L(a.presentOnly)&&a.presentOnly())}#b(a){const s=this.#e.element;if(!s||!L(s.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[a];return n?s.querySelector(n):null}destroy(){this.#o&&this.#f();for(const a of this.#r)a();this.#r=[]}}const y=O}),xe("packages/dom/src/capture.js",function(e,G){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const L=G("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(K,D,v){const O=v.getComputedStyle(K),y=D.style;if(y)for(let u=0;u<O.length;u++){const a=O[u];B.has(a)||y.setProperty(a,O.getPropertyValue(a),O.getPropertyPriority(a))}}function W(K,D,v){if(F(K,D,v),K.tagName==="CANVAS"&&L(K.toDataURL))try{const u=K.toDataURL("image/png"),a=D.style;a&&(a.setProperty("background-image",`url(${u})`),a.setProperty("background-size","100% 100%"),a.setProperty("background-repeat","no-repeat"))}catch{}const O=K.children||[],y=D.children||[];for(let u=0;u<O.length&&u<y.length;u++)W(O[u],y[u],v)}function X(K,D){if(!K||K.startsWith("data:")||K.startsWith("blob:"))return!0;try{return new URL(K,D).origin===D}catch{return!0}}async function H(K,D={}){const v=K.ownerDocument,O=v?.defaultView;if(!O||typeof O.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=K.getBoundingClientRect(),u=Math.max(1,Math.ceil(y.width)),a=Math.max(1,Math.ceil(y.height)),s=Math.max(.1,Number(D.scale)||2),n=O.location?.origin||"";for(const g of K.querySelectorAll("img")){const d=g.getAttribute("src")||"";if(!X(d,n))throw new Error(`capture refused: the image at ${d} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=K.cloneNode(!0);W(K,t,O),t.style.width=`${u}px`,t.style.height=`${a}px`,t.style.margin="0";const r=new O.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${a}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new O.Image;await new Promise((g,d)=>{f.onload=()=>g(void 0),f.onerror=()=>d(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const c=v.createElement("canvas");c.width=Math.round(u*s),c.height=Math.round(a*s);const i=c.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=D.background||O.getComputedStyle(K).backgroundColor||"#ffffff",i.fillRect(0,0,c.width,c.height),i.drawImage(f,0,0,c.width,c.height),new Promise((g,d)=>{c.toBlob(h=>h?g({blob:h,width:c.width,height:c.height}):d(new Error("capture produced no image")),D.type||"image/png",D.quality)})}const V=H}),xe("packages/dom/src/annotate.js",function(e,G){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.uid,F=Q.warnOnce,X=G("packages/dom/src/renderer/direction.js").signedX,H=Object.freeze(["pen","arrow","rect","highlight","erase"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),K=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),v=14,O="system-ui, -apple-system, sans-serif";function y(h,l){if(!h||typeof h!="object")return null;const m=K[h.type];if(!m)return null;const w=typeof h.id=="string"&&h.id?h.id:B("mark"),k=Array.isArray(h.points)?h.points:[],p=[];for(const E of k){const T=Number(E&&E.x),P=Number(E&&E.y);Number.isFinite(T)&&Number.isFinite(P)&&p.push({x:T,y:P})}const b=typeof h.colour=="string"&&h.colour?h.colour:l;if(m==="text"){const E=typeof h.text=="string"?h.text:"";if(!p.length||!E)return null;const T={id:w,tool:m,colour:b,points:[p[0]],text:E,region:u(h.region)},P=Number(h.fontSize);return Number.isFinite(P)&&P>0&&(T.fontSize=P),typeof h.background=="string"&&h.background&&(T.background=h.background),T}return p.length<2?null:{id:w,tool:m,colour:b,points:p,region:u(h.region)}}function u(h){return h==="start"||h==="end"?h:"centre"}function a(h){const l={id:h.id,type:D[h.tool]||h.tool,colour:h.colour,points:h.points.map(m=>({x:m.x,y:m.y}))};return(h.region==="start"||h.region==="end")&&(l.region=h.region),h.tool==="text"&&(l.text=h.text,h.fontSize!==void 0&&(l.fontSize=h.fontSize),h.background!==void 0&&(l.background=h.background)),l}const s="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,l){return{id:h,count:l,valueOf(){return this.count}}}const o=10;function f(h,l,m){const w=m.x-l.x,k=m.y-l.y,p=w*w+k*k;let b=p?((h.x-l.x)*w+(h.y-l.y)*k)/p:0;b=Math.max(0,Math.min(1,b));const E=l.x+b*w,T=l.y+b*k;return Math.hypot(h.x-E,h.y-T)}function c(h){const l=h.points;if(!l.length)return null;if(h.tool==="text"){const b=h.fontSize||v,E=(h.text||"").length*b*.6;return{x1:l[0].x,y1:l[0].y,x2:l[0].x+E,y2:l[0].y+b*1.2}}let m=1/0,w=1/0,k=-1/0,p=-1/0;for(const b of l)m=Math.min(m,b.x),w=Math.min(w,b.y),k=Math.max(k,b.x),p=Math.max(p,b.y);return{x1:m,y1:w,x2:k,y2:p}}function i(h,l){const m=c(h);if(!m)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(l.x>=m.x1&&l.x<=m.x2&&l.y>=m.y1&&l.y<=m.y2)return 0;if(h.tool==="text")return 1/0}const w=h.points;if(h.tool==="rect"){const p=[{x:m.x1,y:m.y1},{x:m.x2,y:m.y1},{x:m.x2,y:m.y2},{x:m.x1,y:m.y2}];let b=1/0;for(let E=0;E<4;E++)b=Math.min(b,f(l,p[E],p[(E+1)%4]));return b}if(w.length===1)return Math.hypot(l.x-w[0].x,l.y-w[0].y);let k=1/0;for(let p=0;p<w.length-1;p++)k=Math.min(k,f(l,w[p],w[p+1]));return k}class g{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#u=Array.isArray(l.seed)?l.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(l){const m=y(l,this.#i);return m?(m.durable=!0,this.#s.push(m),this.#M(),this.redraw(),this.#R(),r(m.id,this.#s.length)):(F("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(a)}remove(l){const m=this.#s.findIndex(w=>w.id===l);return m<0?(F("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${l}".`),!1):(this.#s.splice(m,1),this.#c===l&&(this.#c=null),this.redraw(),this.#R(),!0)}replaceAll(l){const m=Array.isArray(l)?l:[];this.#s=m.map(w=>y(w,this.#i)).filter(Boolean);for(const w of this.#s)w.durable=!0;this.#s.length&&this.#M(),this.redraw(),this.#R()}#d(){const l=this.#t.viewport?.root;if(!l||!L(l.addEventListener))return;const m=w=>{if(!(!this.#o||!w)){if(w.key==="Escape"){this.use(null),w.preventDefault?.();return}if(this.#o==="erase"){if(w.key==="Tab"){this.#f(w);return}(w.key==="Delete"||w.key==="Backspace")&&this.#h(w)}}};l.addEventListener("keydown",m,!0),this.#a.push(()=>l.removeEventListener("keydown",m,!0))}#f(l){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}l.preventDefault?.();const m=this.#c?this.#s.findIndex(p=>p.id===this.#c):-1,w=l.shiftKey?-1:1,k=m<0?w>0?0:this.#s.length-1:(m+w+this.#s.length)%this.#s.length;this.#c=this.#s[k].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:k+1,of:this.#s.length})}#h(l){if(!this.#c)return;l.preventDefault?.();const m=this.#c;this.remove(m),this.#x("a11y.annotate.erased")}#p(){const l=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!l||!L(l.matchMedia))return;let m=null;const w=()=>{const k=l.devicePixelRatio||1;let p;try{p=l.matchMedia(`(resolution: ${k}dppx)`)}catch{return}m=p;const b=()=>{this.redraw(),w()};L(p.addEventListener)?p.addEventListener("change",b,{once:!0}):L(p.addListener)&&p.addListener(b)};w(),this.#a.push(()=>{m=null})}use(l,m={}){const w=!!m.colour&&l===this.#o;m.colour&&(this.#i=String(m.colour));const k=l&&H.includes(l)?l:null;this.#o=k&&k===this.#o&&!w?null:k,this.#o!=="erase"&&(this.#c=null);const p=this.#o?this.#M():this.#n;return p&&(p.style.pointerEvents=this.#o?"auto":"none",p.style.cursor=this.#o?"crosshair":""),this.#R(),this.#o}undo(){const l=this.#s.pop();return l&&this.#c===l.id&&(this.#c=null),this.redraw(),this.#R(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#R())}#m(){const l=this.#s.filter(m=>m.durable);l.length!==this.#s.length&&(this.#s=l,this.redraw(),this.#R())}redraw(){!this.#n&&this.#s.length&&this.#M();const l=this.#n,m=this.#r;if(!l||!m)return;this.#A();const{left:w,top:k}=this.#S();m.clearRect(0,0,l.width,l.height);const p=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const E=p.filter(T=>u(T.region)===b);if(E.length){m.save(),this.#g(m,b),m.translate((b==="centre"?-w:0)||0,-k||0);for(const T of E)this.#b(m,T),T.id===this.#c&&this.#j(m,T);m.restore()}}}#g(l,m="centre"){const w=this.#n,k=this.#t.viewport?.bodyViewport;if(!L(w?.getBoundingClientRect)||!L(k?.getBoundingClientRect))return;const p=w.getBoundingClientRect(),b=k.getBoundingClientRect();if(!b.width||!b.height)return;const E=this.#y(m,b);E&&(l.beginPath(),l.rect(E.left-p.left,b.top-p.top,E.width,b.height),l.clip())}#y(l,m){const w=P=>{if(!L(P?.getBoundingClientRect))return null;const x=P.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},k=w(this.#t.viewport?.bodyStart),p=w(this.#t.viewport?.bodyEnd);if(l==="start")return k;if(l==="end")return p;let b=m.left,E=m.left+m.width;const T=m.left+m.width/2;for(const P of[k,p]){if(!P)continue;const x=P.left+P.width;P.left+P.width/2<T?b=Math.max(b,x):E=Math.min(E,P.left)}return E>b?{left:b,width:E-b}:null}#w(l){for(const[m,w]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!L(w?.getBoundingClientRect))continue;const k=w.getBoundingClientRect();if(k&&k.width>0&&l>=k.left&&l<k.left+k.width)return m}return"centre"}#k(l){const m=this.#t.viewport?.bodyViewport;if(!L(m?.getBoundingClientRect))return!0;const w=m.getBoundingClientRect();return!w.width||!w.height?!0:l.clientX>=w.left&&l.clientX<=w.right&&l.clientY>=w.top&&l.clientY<=w.bottom}#b(l,m){const w=m.points;if(!w.length)return;const k=this.#e.presentation?.scale||1;l.lineWidth=(n[m.tool]||3)*k,l.strokeStyle=m.colour,l.fillStyle=m.colour,l.lineCap="round",l.lineJoin="round",l.globalAlpha=m.tool==="highlight"?.32:1;const p=w[0],b=w[w.length-1];if(m.tool==="text"){const E=(m.fontSize||v)*k;l.font=`${E}px ${O}`,l.textBaseline="top";const T=m.text||"";if(m.background){let P=T.length*E*.6;if(typeof l.measureText=="function"){const x=l.measureText(T);x&&Number.isFinite(x.width)&&(P=x.width)}l.fillStyle=m.background,l.fillRect(p.x-E*.15,p.y-E*.1,P+E*.3,E*1.2)}l.fillStyle=m.colour,l.fillText(T,p.x,p.y),l.globalAlpha=1;return}if(m.tool==="rect")l.strokeRect(p.x,p.y,b.x-p.x,b.y-p.y);else if(m.tool==="arrow")l.beginPath(),l.moveTo(p.x,p.y),l.lineTo(b.x,b.y),l.stroke(),this.#O(l,p,b,l.lineWidth);else{l.beginPath(),l.moveTo(p.x,p.y);for(let E=1;E<w.length;E++)l.lineTo(w[E].x,w[E].y);l.stroke()}l.globalAlpha=1}#O(l,m,w,k){const p=Math.atan2(w.y-m.y,w.x-m.x),b=Math.max(8,k*3);l.beginPath(),l.moveTo(w.x,w.y),l.lineTo(w.x-b*Math.cos(p-Math.PI/7),w.y-b*Math.sin(p-Math.PI/7)),l.lineTo(w.x-b*Math.cos(p+Math.PI/7),w.y-b*Math.sin(p+Math.PI/7)),l.closePath(),l.fill()}#j(l,m){const w=c(m);if(!w||!L(l.strokeRect))return;const k=6;l.save(),l.setLineDash?.([4,3]),l.strokeStyle="#1a73e8",l.lineWidth=2,l.globalAlpha=1,l.strokeRect(w.x1-k,w.y1-k,w.x2-w.x1+k*2,w.y2-w.y1+k*2),l.restore()}#P(l,m){const w=this.#e.presentation?.scale||1,k=o*w;for(let p=this.#s.length-1;p>=0;p--){const b=this.#s[p];if(u(b.region)===m&&i(b,l)<=k)return b}return null}#S(){const l=L(this.#t.scrollPosition)?this.#t.scrollPosition():null,m=this.#t.viewport?.rtl===!0;return{left:X(l?.left||0,m),top:l?.top||0}}#M(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,m=l?.ownerDocument;if(!l||!m?.createElement)return null;const w=m.createElement("canvas");return w.className=s,w.style.position="absolute",w.style.inset="0",w.style.pointerEvents="none",l.appendChild(w),this.#n=w,this.#r=w.getContext?w.getContext("2d"):null,this.#A(),this.#E(w),w}#A(){const l=this.#n,m=this.#t.viewport?.root;if(!l||!m?.getBoundingClientRect)return;const w=m.getBoundingClientRect(),p=l.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(w.width*p)),E=Math.max(1,Math.round(w.height*p));l.width===b&&l.height===E||(l.width=b,l.height=E,l.style&&(l.style.width=`${Math.max(1,w.width)}px`,l.style.height=`${Math.max(1,w.height)}px`),this.#r?.setTransform(p,0,0,p,0,0))}#E(l){const m=(E,T="centre")=>{const P=l.getBoundingClientRect(),{left:x,top:C}=this.#S();return{x:E.clientX-P.left+(T==="centre"?x:0),y:E.clientY-P.top+C}},w=E=>{if(!this.#o||!this.#k(E))return;const T=this.#w(E.clientX);if(this.#o==="erase"){const P=this.#P(m(E,T),T);P&&(this.remove(P.id),this.#x("a11y.annotate.erased")),E.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[m(E,T)],region:T},l.setPointerCapture?.(E.pointerId),E.preventDefault?.()},k=E=>{if(!this.#l)return;const T=m(E,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(T),this.redraw()},p=E=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,l.releasePointerCapture?.(E.pointerId),this.redraw(),this.#R())},b=E=>{if(!this.#o)return;const T=this.#t.viewport?.bodyViewport;if(!T)return;let P=!1;E.deltaY&&typeof T.scrollTop=="number"&&(T.scrollTop+=E.deltaY,P=!0),E.deltaX&&typeof T.scrollLeft=="number"&&(T.scrollLeft+=E.deltaX,P=!0),P&&E.preventDefault?.()};l.addEventListener("pointerdown",w),l.addEventListener("pointermove",k),l.addEventListener("pointerup",p),l.addEventListener("pointercancel",p),l.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{l.removeEventListener("pointerdown",w),l.removeEventListener("pointermove",k),l.removeEventListener("pointerup",p),l.removeEventListener("pointercancel",p),l.removeEventListener("wheel",b)})}#R(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(l,m){const w=this.#e.messages;return w&&L(w.t)?w.t(l,m):l}#x(l,m){this.#t.announce?.(this.#L(l,m),{repeat:!0})}destroy(){for(const l of this.#a)l();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const d=g}),xe("packages/dom/src/timelinebar.js",function(e,G){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function X(D){if(!Number.isFinite(D)||D<1e3)return"now";const v=Math.round(D/1e3);if(v<60)return`${v}s ago`;const O=Math.round(v/60);return O<60?`${O}m ago`:`${Math.round(O/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 V{#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,O=v.depth,y=v.position;this.#r.max=String(Math.max(1,O)),this.#r.value=String(Math.max(0,O-y)),this.#r.disabled=O===0;const u=v.at(),a=v.live;this.#o&&(this.#o.textContent=a?this.#l("timeline.live"):X(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",a?"true":"false")),this.#i&&(this.#i.textContent=O===0?this.#l("timeline.recording"):H(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",a?"true":"false")}#l(v,O){const y=this.#e;return(y&&y.messages?y.messages:F).t(v,O)}#a(){if(this.#n)return;const v=this.#t.viewport?.overlays,O=v?.ownerDocument;if(!v||!O?.createElement)return;const y=O.createElement("div");y.className=W;const u=O.createElement("span");u.className=`${W}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const a=O.createElement("input");a.className=`${W}__range`,a.type="range",a.min="0",a.step="1",a.setAttribute("aria-label",this.#l("timeline.scrub"));const s=O.createElement("span");s.className=`${W}__clock`;const n=O.createElement("button");n.className=`${W}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(u),y.appendChild(a),y.appendChild(s),y.appendChild(n),v.appendChild(y),this.#n=y,this.#r=a,this.#o=u,this.#i=s;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(a.value))};a.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const o=f=>f.stopPropagation();a.addEventListener("keydown",o),this.#s.push(()=>{a.removeEventListener("input",t),n.removeEventListener("click",r),a.removeEventListener("keydown",o)})}#u(){this.#n&&(L(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 K=V}),xe("packages/dom/src/commentpaint.js",function(e,G){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",V="lat-cell--commented",K="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 u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const a=[];for(const s of u.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key");if(n){a.push(n);for(const t of s.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),o=y.at(n,r),f=!!(o&&o.count);t.classList.toggle(V,f),t.classList.toggle(K,f&&o.unresolved>0),this.#i(t,o,r)}}}(a.length!==this.#r.length||a.some((s,n)=>s!==this.#r[n]))&&(this.#r=a,y.request(a))}#o(y,u){const a=this.#e;return(a&&a.messages?a.messages:F).t(y,u)}#i(y,u,a){if(!u||!u.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const s=u.count,n=u.unresolved,t=this.#o("count.comments",{count:s});y.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const y=this.#t.viewport?.root;if(!y||!L(y.addEventListener))return;const u=s=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=s.target&&L(s.target.closest)?s.target.closest("[data-col]"):null;if(!t||!t.classList.contains(V)||!this.#l(t,s))return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.stopPropagation(),s.preventDefault(),n.open(o,t.getAttribute("data-col")))},a=s=>{const n=this.#e.comments;if(!n||!n.enabled||!s.altKey||s.key!=="m"&&s.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&L(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.preventDefault(),s.stopPropagation(),n.open(o,t.getAttribute("data-col")))};y.addEventListener("click",u,!0),y.addEventListener("keydown",a,!0),this.#n.push(()=>{y.removeEventListener("click",u,!0),y.removeEventListener("keydown",a,!0)})}#l(y,u){if(!L(y.getBoundingClientRect))return!1;const a=y.getBoundingClientRect(),s=Math.max(14,Math.min(24,a.height*.6));return(X(y)?u.clientX<=a.left+s:u.clientX>=a.right-s)&&u.clientY<=a.top+s}destroy(){for(const y of this.#n)y();this.#n=[]}}const v=D}),xe("packages/dom/src/presencepaint.js",function(e,G){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/editors/common.js").cssEscape,V=G("packages/core/src/model/presence.js").CURSOR_LABEL_MS,K="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 u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,a=>this.#l(u,a)));this.#a(),this.paint()}}#l(y,u){if(this.#f(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const s=u&&u.peer;s&&(this.#r.textContent=this.#h(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:s.name}))}#a(){const y=this.#t.viewport?.overlays,u=y?.ownerDocument;if(!y||!u?.createElement)return;const a=this.#e.get("presence")||{},s=u.createElement("span");if(s.className=`${K}__live`,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),y.appendChild(s),this.#r=s,a.roster===!1)return;const n=u.createElement("div");n.className=K,a.roster&&a.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",y.appendChild(n),this.#n=n}paint(){const y=this.#e.presence,u=this.#t.viewport?.root;if(!y||!y.enabled||!u?.querySelectorAll)return;this.#d(u);const a=y.peers(),s=[...a].sort((n,t)=>n.at-t.at);for(const n of s)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const o of t.columns||[])this.#c(u,r,o,n,"range");for(const n of s)n.cursor&&this.#c(u,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of s)n.editing&&this.#c(u,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(a)}#u(y){if(this.#s!==null)return;const u=y.filter(n=>n.cursorFresh);if(!u.length)return;const s=Math.max(...u.map(n=>n.cursorAt||0))+V-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,s))}#c(y,u,a,s,n){const t=y.querySelector(`[data-key="${X(u)}"]`),r=t&&t.querySelector(`[data-col="${X(a)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",s.colour),r.setAttribute("data-peer-name",s.name),r.setAttribute("data-peer-initial",s.initials||(s.name||"?").slice(0,1).toUpperCase()),s.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&s.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${a}`))}#d(y){if(this.#o.size){for(const u of y.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const y=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const s of u){const n=y.createElement("button");n.className=`${K}__peer`,n.type="button",n.style.setProperty("--lat-peer",s.colour),n.toggleAttribute("data-idle",!!s.idle),n.toggleAttribute("data-hidden",!!s.hidden);let t="presence.peer";s.hidden?t="presence.peerHidden":s.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:s.name}));const r=y.createElement("span");r.className=`${K}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=s.initials||(s.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const o=y.createElement("span");o.className=`${K}__name`,o.textContent=s.name,n.appendChild(o),n.addEventListener("click",()=>this.#e.presence.jumpTo(s.id)),this.#n.appendChild(n)}const a=u.filter(s=>s.hidden).length;if(a){const s=y.createElement("span");s.className=`${K}__hidden`,s.textContent=this.#h("presence.hidden",{count:a}),this.#n.appendChild(s)}}announceRefusal(y){if(!this.#r)return;const u=y&&y.name?y.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:u})}#h(y,u){const a=this.#e;return(a&&a.messages?a.messages:F).t(y,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const v=D}),xe("packages/dom/src/commentpanel.js",function(e,G){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/editors/common.js").cssEscape,V=G("packages/core/src/model/comments.js").parseCellKey,K="lat-comments",D=/^(https?:|mailto:)/i,v='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function O(s,n){if(!Number.isFinite(s))return"";const t=Math.max(0,Math.round((n-s)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function y(s,n,t,r){n.textContent="";const o=String(t??"");if(!r){n.textContent=o;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let c=0,i=f.exec(o);for(;i;){i.index>c&&n.appendChild(s.createTextNode(o.slice(c,i.index)));const g=i[0];if(g.startsWith("*")){const d=s.createElement("em");d.textContent=g.slice(1,-1),n.appendChild(d)}else if(g.startsWith("`")){const d=s.createElement("code");d.textContent=g.slice(1,-1),n.appendChild(d)}else{const d=g.indexOf("]("),h=g.slice(1,d),l=g.slice(d+2,-1);if(D.test(l)){const m=s.createElement("a");m.href=l,m.textContent=h,m.rel="noopener noreferrer",m.target="_blank",n.appendChild(m)}else n.appendChild(s.createTextNode(h))}c=i.index+g.length,i=f.exec(o)}c<o.length&&n.appendChild(s.createTextNode(o.slice(c)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#b()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#b(),this.#o&&L(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&L(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=V(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${K}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const o=r.querySelector(`[data-key="${X(n)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:F).t(n,t)}#p(n){const t=n.createElement("div");t.className=K,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${K}__head`;const o=n.createElement("div");o.className=`${K}__title`,r.appendChild(o);const f=n.createElement("button");f.className=`${K}__resolve`,f.type="button",r.appendChild(f);const c=n.createElement("button");c.className=`${K}__close`,c.type="button",c.setAttribute("aria-label",this.#h("comments.close")),c.textContent="×",r.appendChild(c);const i=n.createElement("div");i.className=`${K}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const g=n.createElement("form");g.className=`${K}__composer`;const d=n.createElement("textarea");d.className=`${K}__input`,d.rows=2,d.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${K}__send`,h.type="submit",h.textContent=this.#h("comments.post"),g.appendChild(d),g.appendChild(h),t.appendChild(r),t.appendChild(i),t.appendChild(g),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=d,this.#m=o,this.#g=f;const l=p=>{p.preventDefault();const b=String(d.value||"").trim();b&&(d.value="",this.#e.comments.add(b))},m=()=>this.#e.comments.close(),w=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},k=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.#e.comments.close();return}if(p.key!=="Tab")return;const b=[...t.querySelectorAll(v)].filter(x=>x.offsetParent!==null||x===d);if(!b.length)return;const E=b[0],T=b[b.length-1],P=t.ownerDocument.activeElement;p.shiftKey&&P===E?(p.preventDefault(),T.focus()):!p.shiftKey&&P===T&&(p.preventDefault(),E.focus())};g.addEventListener("submit",l),c.addEventListener("click",m),f.addEventListener("click",w),t.addEventListener("keydown",k),this.#l.push(()=>{g.removeEventListener("submit",l),c.removeEventListener("click",m),f.removeEventListener("click",w),t.removeEventListener("keydown",k)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},o=Date.now(),f=n.openKey,{rowId:c,field:i}=V(f),g=this.#e.columns.get(i),d=this.#e.rows.byKey(c),h=L(r.rowLabel)&&d?r.rowLabel(d):c;if(this.#m.textContent=this.#h("comments.cellTitle",{column:g&&(g.title??g.id)||i,row:h}),this.#g.textContent=this.#y()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const l=n.thread||[];if(!l.length){this.#d(this.#h("comments.empty"));return}const m=d&&g?g.getValue(d.data,d):void 0;for(const w of l)this.#r.appendChild(this.#k(t,w,o,m,r))}#k(n,t,r,o,f){const c=n.createElement("article");c.className=`${K}__item`,t.pending&&c.setAttribute("data-pending","true"),t.resolved&&c.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${K}__meta`;const g=n.createElement("span");g.className=`${K}__author`,g.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),i.appendChild(g);const d=n.createElement("time");d.className=`${K}__time`;const h=O(t.at,r);d.textContent=t.edited?this.#h("comments.edited",{time:h}):h,i.appendChild(d),c.appendChild(i);const l=n.createElement("div");if(l.className=`${K}__body`,y(n,l,t.body,!!f.markdown),c.appendChild(l),t.value!==void 0&&!Object.is(t.value,o)){const k=n.createElement("p");k.className=`${K}__moved`,k.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(o)}),c.appendChild(k)}const m=t.can||{},w=k=>m[k]!==!1;if(w("edit")||w("delete")){const k=n.createElement("div");if(k.className=`${K}__actions`,w("delete")){const p=n.createElement("button");p.type="button",p.className=`${K}__action`,p.textContent=this.#h("comments.delete"),p.addEventListener("click",()=>this.#e.comments.remove(t.id)),k.appendChild(p)}c.appendChild(k)}return c}#b(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:o}=V(t),f=this.#f(r,o)||this.#i,c=this.#t.viewport?.root;if(!f||!c||!L(f.getBoundingClientRect))return;const i=f.getBoundingClientRect(),g=c.getBoundingClientRect(),d=this.#n.getBoundingClientRect();let h=i.bottom-g.top+4;h+d.height>g.height&&i.top-g.top>d.height&&(h=i.top-g.top-d.height-4);let l=i.left-g.left;l+d.width>g.width&&(l=Math.max(0,g.width-d.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,l)}px`;const m=i.bottom<g.top||i.top>g.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const a=u}),xe("packages/dom/src/watermark.js",function(e,G){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),X=W.el,H=W.on,V="lat-watermark",K="https://www.latticegrid.dev",D=["br","bl","tl","tr"],v=4e3;class O{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(a){this.#e=a.grid,this.#t=a.document,this.#n=a.element,this.#i=a.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),L(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const a=this.#e.licence&&this.#e.licence.ready;a&&L(a.then)&&a.then(()=>this.refresh(),()=>this.refresh())}refresh(){const a=this.#d();a&&!this.#r?(this.#f(),this.#u()):!a&&this.#r&&(this.#h(),this.#c())}#a(){const a=this.#i;if(!a||!L(a.matchMedia))return!1;try{return!!a.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),L(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%D.length,this.#h(),this.#f(),this.#u()},v)))}#c(){this.#l!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const a=this.#e.licence;return!!(a&&L(a.watermark)&&a.watermark())}#f(){const a=X(this.#t,"a",{class:`${V}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:K,target:"_blank",rel:"noopener noreferrer"}});this.#r=X(this.#t,"div",{class:`${V} ${V}--${D[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a]}),this.#o.push(H(this.#r,"pointerdown",s=>{L(s.stopPropagation)&&s.stopPropagation()})),this.#n&&L(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const a of this.#o)a();this.#o=[],this.#h()}}const y=O}),xe("packages/dom/src/maximise.js",function(e,G){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.isFunction,F=G("packages/dom/src/editors/common.js"),W=F.el,X=F.on,V=G("packages/dom/src/themeof.js").themeOf,K="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",O="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(s){this.#e=s.element,this.#t=s.document,this.#n=B(s.onChange)?s.onChange:null,this.#r=B(s.captureScroll)?s.captureScroll:null,this.#o=B(s.restoreScroll)?s.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const s=this.#e.parentNode;if(!s||!this.#t.body)return L("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:O}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?V(s):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),s.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,c]of Object.entries(D))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=c;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(K),this.#t.body.classList&&this.#t.body.classList.add(v),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const s=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,o]of Object.entries(this.#a))this.#e.style[r]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(K),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(v),s&&this.#o&&this.#o(s),this.#s&&this.#s(),this.#s=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(s){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;s(),t&&B(t.focus)&&t.focus()}#f(s){!s||s.key!=="Escape"||s.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const s of this.#l)s(this.active())}watch(s){return B(s)?(this.#l.add(s),()=>this.#l.delete(s)):()=>{}}destroy(){this.exit()}}const u=y}),xe("packages/dom/src/promptbar.js",function(e,G){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=G("packages/dom/src/editors/common.js"),L=Q.documentFor,B=Q.el,F=Q.on,W=Q.clear,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/core/src/internal/util.js").isFunction,D=G("packages/core/src/ai/schema.js"),v=D.describeGrid,O=D.promptText,y=G("packages/core/src/ai/intent.js"),u=y.applyPlan,a=y.buildPrompt,s=y.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#y="idle";#w=0;#k=!1;#b=[];t(c,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(c,i)}init(c={}){this.messages=c&&c.messages||c&&c.grid&&c.grid.messages||H,this.#e=L(c),this.#t=c.grid||null,this.#n=K(c.ask)?c.ask:null,this.#r=c.schemaOptions||{},this.#o=c.context,this.#i={onPlan:K(c.onPlan)?c.onPlan:null,onApply:K(c.onApply)?c.onApply:null,onError:K(c.onError)?c.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(c)}element(){return this.#s}refresh(){this.#k||!this.#s||this.#y!=="busy"&&this.#M()}destroy(){this.#k=!0,this.#w++;for(const c of this.#b)c();this.#b.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(c){if(this.#k||this.#y==="busy")return null;const i=String(c??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const g=++this.#w;this.#j("busy"),this.#A("Thinking…");let d;try{const h=v(this.#t,this.#r),l=O(h);if(d=await this.#n({prompt:i,schema:h,schemaText:l,message:a(i,l),context:this.#o}),this.#k||g!==this.#w)return null;const m=s(d,h);return this.#P(m),m}catch(h){return this.#k||g!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#E(h instanceof Error?h.message:String(h))),null}}apply(){const c=this.#g;if(this.#k||!c||!c.ok)return null;const i=this.#t?.ai,g=K(i?.apply)?i.apply(c):u(c,this.#t);return this.#i.onApply&&this.#i.onApply(g,c),this.#M(),this.#l&&(this.#l.value=""),g.failed.length?this.#E(`Applied ${g.applied.length}; ${g.failed.map(d=>`${d.type} failed: ${d.reason}`).join("; ")}`):this.#A(`Applied: ${c.describe()}`),g}discard(){this.#k||(this.#M(),this.#A("Discarded."))}#O(c){const i=this.#e,g=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:c.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":c.label||"Ask about this grid",autocomplete:"off"}}),this.#b.push(F(this.#l,"keydown",h=>{const l=h&&h.key;l==="Enter"?(K(h.preventDefault)&&h.preventDefault(),this.ask()):l==="Escape"&&this.#g&&(K(h.preventDefault)&&h.preventDefault(),this.discard())})),g.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#b.push(F(this.#a,"click",()=>{this.ask()})),g.appendChild(this.#a),this.#s.appendChild(g),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const d=B(i,"div",{class:`${n}__buttons`});this.#f=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#b.push(F(this.#f,"click",()=>{this.apply()})),this.#b.push(F(this.#h,"click",()=>{this.discard()})),d.appendChild(this.#f),d.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(d),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#j(c){if(this.#y=c,!this.#s)return;this.#s.setAttribute("data-state",c);const i=c==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,c!=="preview"),o(this.#m,c!=="error")}#P(c){const i=c;if(this.#i.onPlan&&this.#i.onPlan(c),!i.ok){this.#g=null;const g=i.rejected.length?i.rejected.map(d=>d.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${g}`);return}this.#g=c,this.#A(""),this.#c&&(this.#c.textContent=i.describe()),this.#S(i.rejected),this.#j("preview")}#S(c){const i=this.#d;if(i){W(i),o(i,!c.length);for(const g of c.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:g.reason}));c.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:c.length-6})}))}}#M(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#A(c){this.#p&&(this.#p.textContent=c)}#E(c){this.#g=null,this.#A(""),this.#m&&(this.#m.textContent=c),this.#j("error")}}function r(f,c){f&&(f.disabled=c,c?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function o(f,c){f&&(f.hidden=c,c?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),xe("packages/dom/src/stat.js",function(e,G){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return c}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.isObject,F=Q.warnOnce,X=G("packages/core/src/source/derive.js").reduceValues,V=G("packages/core/src/source/memory.js").isPipelineSettle,D=G("packages/core/src/i18n/index.js").defaultMessages,O=G("packages/dom/src/cell/icons.js").renderIconInto,y={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",a=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),s=Object.freeze({direction:"flat",change:null,percent:null});function n(l,m){if(!Number.isFinite(l)||!Number.isFinite(m))return s;const w=l-m,k=w>0?"up":w<0?"down":"flat",p=m===0?null:w/Math.abs(m)*100;return{direction:k,change:w,percent:p}}function t(l,m){return l==="flat"||m==="neither"?"flat":l===m?"good":"bad"}function r(l,m,w=null){if(L(m)){const P=m(l,w);return P==="good"||P==="warn"||P==="bad"?P:null}if(!B(m))return null;const k=typeof l=="number"&&Number.isFinite(l)?l:null;if(k===null)return null;const p=Number.isFinite(Number(m.good))?Number(m.good):null,b=Number.isFinite(Number(m.warn))?Number(m.warn):null,E=String(m.direction||"up")==="down",T=P=>E?k<=P:k>=P;return p!==null&&T(p)?"good":b!==null&&T(b)?"warn":p===null&&b===null?null:"bad"}function o(l){return!(L(l.value)||l.value!==void 0&&!B(l.value))}function f(l){return!l||!l.rows||!L(l.rows.totalCount)?!0:l.rows.totalCount()>0}function c(l){const m=B(l)?l:{},w=m.grid||null,k=d(m.container,w);if(!k)return F("stat.container","createStat needs a `container`: an element or a selector."),h();const p=k.ownerDocument||(typeof document>"u"?null:document);if(!p)return F("stat.document","createStat needs a document; it draws DOM."),h();const b=p.createElement("div");b.className=["lattice",y.root,m.class].filter(Boolean).join(" "),b.setAttribute("role","group");const E=p.createElement("div");E.className=y.title;const T=p.createElement("div");T.className=y.value;const P=p.createElement("div");P.className=y.interval;const x=p.createElement("div");x.className=y.delta;const C=p.createElement("div");C.className=y.footer;const A=p.createElement("div");if(A.className=y.note,A.hidden=!0,m.icon!=null&&m.icon!==""){const ee=p.createElement("span");ee.className=y.icon,ee.setAttribute("aria-hidden","true"),O(ee,m.icon,`stat:${m.title||"stat"}`),b.appendChild(ee);const te=p.createElement("div");te.className=y.body,te.appendChild(E),te.appendChild(T),te.appendChild(A),te.appendChild(P),te.appendChild(x),te.appendChild(C),b.appendChild(te)}else b.appendChild(E),b.appendChild(T),b.appendChild(A),b.appendChild(P),b.appendChild(x),b.appendChild(C);k.appendChild(b);let $=null;const z=[];let M=!1;function R(){if(L(m.value))return m.value(w);if(m.value!==void 0&&!B(m.value))return m.value;const ee=B(m.value)?m.value:m,te=ee.of,ne=ee.fn||"sum",ae=ee.show;return w?ne==="count"?I().length:te?ae?q(String(te),String(ne),String(ae)):S()==="filtered"&&w.statistics&&L(w.statistics.reduce)?w.statistics.reduce(String(te),String(ne)):X(I().map(de=>g(de,String(te))),String(ne)):null:null}function S(){return String(m.scope||"filtered")}function I(){if(!w||!w.rows)return[];const ee=S();if(ee==="all"){const ne=[];return L(w.rows.forEachAll)&&w.rows.forEachAll(ae=>{ae.group||ne.push(i(ae))}),ne}if(ee==="selected")return(w.selection&&L(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(i);const te=[];return L(w.rows.forEach)&&w.rows.forEach(ne=>{ne.group||te.push(i(ne))}),te}function q(ee,te,ne){if(te!=="min"&&te!=="max")return F(`stat.show.${te}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${te}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ae=null,de=null;for(const ie of I()){const oe=Number(g(ie,ee));Number.isFinite(oe)&&(ae===null||(te==="max"?oe>ae:oe<ae))&&(ae=oe,de=ie)}return de===null?null:g(de,ne)}function Z(ee){if(L(m.format))return String(m.format(ee,w));if(ee==null)return m.empty??"—";const te=B(m.value)?m.value:m,ne=te.show||te.of;if((te.show?!0:a.has(String(te.fn||"sum")))&&w&&ne&&L(w.columns?.get)){const de=w.columns.get(String(ne));if(de&&L(de.formatValue))return de.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(m.decimals??2):String(ee)}function _(ee){return ee?(w&&w.messages||D).t(`stat.tone.${ee}`):""}function J(){if(M)return;const ee=R(),te=o(m)&&!!w&&!f(w),ne=te?null:ee,ae=L(m.baseline)?m.baseline(w):m.baseline;$=ne,E.textContent=m.title??"",E.hidden=!m.title,T.textContent=Z(ne),A.hidden=!te,te&&(A.textContent=w.messages.t("stat.noData"));const de=te||ae===void 0||ae===null?s:n(typeof ne=="number"?ne:null,Number(ae)),ie=t(de.direction,m.goodWhen||"up");if(x.hidden=de.change===null,de.change!==null){const ke=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Re=de.percent===null?Z(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;x.textContent=`${ke} ${Re}`,x.setAttribute("data-tone",ie),x.setAttribute("data-direction",de.direction)}const oe=L(m.interval)?m.interval(ne,w):null,ce=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);P.hidden=!ce,ce&&(P.textContent=`${Z(oe.lower)} – ${Z(oe.upper)}`,Number.isFinite(oe.confidence)&&P.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const fe=te?u:m.bands?r(ne,m.bands,w):null;fe?b.setAttribute("data-tone",fe):b.removeAttribute("data-tone"),C.textContent=L(m.footer)?String(m.footer(ne,w)):m.footer??"",C.hidden=!C.textContent,b.setAttribute("aria-label",[m.title,T.textContent,te?A.textContent:"",ce?P.textContent:"",de.change===null?"":x.textContent,de.change===null?"":_(ie),C.textContent].filter(Boolean).join(", "))}if(w&&L(w.on)&&m.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const te=ne=>{ee==="model:changed"&&!V(ne)||J()};w.on(ee,te),z.push(()=>L(w.off)&&w.off(ee,te))}return J(),{element:()=>b,value:()=>$,refresh:J,destroy(){M=!0;for(const ee of z)try{ee()}catch{}z.length=0,b.remove()}}}function i(l){return B(l)&&"data"in l?l.data:l}function g(l,m){if(!B(l))return;if(!m.includes("."))return l[m];let w=l;for(const k of m.split(".")){if(!B(w))return;w=w[k]}return w}function d(l,m){if(l&&typeof l=="object")return l;if(typeof l!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(l):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),xe("packages/dom/src/kpistrip.js",function(e,G){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isObject,F=G("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:V,document:K,kpis:D}){this.#e=V,this.#t=K,this.#n=Array.isArray(D)?D.filter(L):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const K=this.#t.createElement("div");K.className=`lattice ${W.band}`,K.setAttribute("role","group"),K.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=K;for(const D of this.#n){const v=F({...D,grid:this.#e,container:K});this.#o.push(v)}}destroy(){for(const V of this.#o)try{V.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),xe("packages/dom/src/createGrid.js",function(e,G){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const L=G("packages/core/src/index.js").createHeadlessGrid,F=G("packages/core/src/defaults.js").applyDefaults,X=G("packages/core/src/export/download.js").downloadBlob,H=G("packages/core/src/internal/util.js"),V=H.fail,K=H.isFunction,D=H.warnOnce,O=G("packages/dom/src/localviews.js").createLocalViewStorage,u=G("packages/dom/src/renderer/index.js").DomRenderer,s=G("packages/dom/src/cell/index.js").createCellLayer,n=G("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=G("packages/dom/src/editors/index.js").editors,i=G("packages/dom/src/filters/index.js").filters,g=G("packages/dom/src/ui/index.js"),d=g.StatusBar,h=g.TooltipManager,l=g.Pagination,m=g.GroupByZone,k=G("packages/dom/src/ui/celltooltip.js").CellTooltips,b=G("packages/dom/src/filtermenu.js").FilterMenu,T=G("packages/dom/src/columnmenu.js").ColumnMenu,x=G("packages/dom/src/shortcutshelp.js").ShortcutsHelp,A=G("packages/dom/src/rowreorder.js").RowReorder,$=G("packages/dom/src/alignedgrids.js").AlignedGrids,M=G("packages/dom/src/columntagbar.js").ColumnTagBar,S=G("packages/dom/src/anomalychip.js").AnomalyChip,q=G("packages/dom/src/rowform.js").RowForm,Z=G("packages/dom/src/toolpanelmount.js"),_=Z.ToolPanelDock,J=Z.panelHost,te=G("packages/dom/src/celledit.js").CellEditController,ae=G("packages/dom/src/editbar.js").EditBar,ie=G("packages/dom/src/rangeselect.js").RangeController,ce=G("packages/core/src/model/selection.js").resolveSelectionConfig,ke=G("packages/dom/src/importer.js").ImportController,Ee=G("packages/dom/src/historybar.js").HistoryBar,ye=G("packages/dom/src/diffpaint.js").DiffPainter,Se=G("packages/dom/src/detailhost.js").DetailHost,Ie=G("packages/dom/src/highlightpaint.js").HighlightPainter,Ye=G("packages/dom/src/findpaint.js").FindPainter,Te=G("packages/dom/src/findbar.js").FindBar,Ke=G("packages/dom/src/redactpaint.js").RedactionPainter,it=G("packages/dom/src/validationpaint.js").ValidationPainter,yt=G("packages/dom/src/presentation.js").PresentationController,At=G("packages/dom/src/capture.js").captureElement,Tt=G("packages/dom/src/annotate.js").AnnotationLayer,zt=G("packages/dom/src/timelinebar.js").TimelineBar,Ge=G("packages/dom/src/commentpaint.js").CommentPainter,pe=G("packages/dom/src/presencepaint.js").PresencePainter,Ue=G("packages/dom/src/commentpanel.js").CommentPanel,nt=G("packages/dom/src/watermark.js").Watermark,we=G("packages/dom/src/maximise.js").Maximiser,je=G("packages/dom/src/promptbar.js").PromptBar,me=G("packages/dom/src/kpistrip.js").KpiStrip;function Me(He,lt,rt){const vt=lt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?He(vt):He(lt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const Ae=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ne=2e3;function De(He,lt,rt,vt){const Nt=lt.annotate===!0?qe(He,vt):[];if(lt.actions===!1)return[];if(lt.actions===void 0&<.side!=="left")return Nt;const $t=Array.isArray(lt.actions)?lt.actions:Ae,gt=(Bt,Qt)=>He.messages.t(Bt,Qt),Rt={undo:{name:"undo",title:()=>Me(gt,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>Me(gt,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>gt("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:lt.exportName})},excel:{name:"excel",title:()=>gt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:lt.exportName})},clipboard:{name:"clipboard",title:()=>gt("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>gt("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return gt("toolbar.pause");const Bt=He.updates.stats().pending;return Bt?gt("toolbar.applyHeld",{count:Bt}):gt("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>gt("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>gt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete Rt.maximise,$t.map(Bt=>Bt==="-"?{name:"-",separator:!0}:typeof Bt=="string"?Rt[Bt]:!Bt||typeof Bt!="object"||!Bt.name?null:{...Bt,run:K(Bt.run)?()=>Bt.run({grid:He,keys:He.selection&&K(He.selection.keys)?He.selection.keys():[],cells:He.selection&&K(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(Nt)}function qe(He,lt){const rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},vt=($t,gt)=>He.messages.t($t,gt),Nt=["pen","arrow","rect","highlight","erase"].map($t=>({name:$t,title:()=>vt(`toolbar.annotate.${$t}`),icon:rt[$t],run:()=>He.annotate?.use($t),active:()=>He.annotate?.tool===$t,annotation:!0}));return Nt.push(ot(He,vt,lt)),Nt}function ot(He,lt,rt){return{name:"clearAll",title:()=>lt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>ut(He,lt,rt)}}function ut(He,lt,rt){const vt=He.toolPanel;if(!vt)return;const Nt=gt=>rt?.announce?.(lt(gt),{repeat:!0});vt.removeAction("clearAll");const $t=()=>{vt.removeAction("clearAllConfirm"),vt.removeAction("clearAllKeep"),vt.addAction(ot(He,lt,rt))};vt.addAction({name:"clearAllConfirm",title:()=>lt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),$t(),Nt("a11y.annotate.cleared")}}),vt.addAction({name:"clearAllKeep",title:()=>lt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>$t()}),Nt("a11y.annotate.confirmClear")}const dt=["pen","arrow","rect","highlight","erase","clearAll"];function st(He){let lt=null;return{rowCount:()=>{if(K(He.rows.matchCount))return He.rows.matchCount();const rt=He.pagination&&K(He.pagination.get)?He.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:He.rows.count()},totalRowCount:()=>K(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{lt||(lt=K(He.rendererHost)?He.rendererHost():{});const rt=K(lt.selectionSummary)?lt.selectionSummary():null;return rt&&rt.predicate?{count:rt.count}:null},selectedCount:()=>{const rt=He.selection&&He.selection.keys?He.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=He.selection;return!rt||!K(rt.cells)?[]:rt.cells().map(({key:vt,colId:Nt})=>He.rows.value(vt,Nt))},hiddenUnresolved:()=>K(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>K(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function wt(He,lt){for(const[rt,vt]of Object.entries(f||{}))He.register("editor",rt,vt);for(const[rt,vt]of Object.entries(i||{}))He.register("filter",rt,vt);for(const[rt,vt]of Object.entries(lt.components||{}))He.register("component",rt,vt);for(const[rt,vt]of Object.entries(lt.pipes||{}))He.register("pipe",rt,vt);for(const[rt,vt]of Object.entries(lt.totalFns||{}))He.register("totalFn",rt,vt)}function ct(He,lt,rt,vt,Nt,$t){const gt=[],Rt=lt.viewport;let Bt=null;if(rt.maximise!==!1&&(Bt=new we({element:$t,document:vt,onChange:()=>lt.invalidate("all"),captureScroll:()=>lt.scrollState(),restoreScroll:at=>lt.restoreScroll(at)}),He.maximise=Bt,gt.push(()=>Bt.destroy())),rt.statusBar){const at=typeof rt.statusBar=="object"?rt.statusBar:{},bt=new d;bt.init({document:vt,host:st(He),panels:at.panels,registry:at.registry,locale:He.get("locale"),messages:He.messages}),Rt.statusBar.appendChild(bt.element());const Mt=()=>{const en=Rt.statusBar.offsetHeight||Rt.statusBar.getBoundingClientRect?.().height||0;Rt.root.style.setProperty("--lattice-status-height",`${Math.ceil(en)}px`)},Ht=()=>{bt.refresh(),Mt()},Kt=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(en=>He.on(en,Ht));Ht(),Mt(),gt.push(()=>{for(const en of Kt)en();Rt.root.style.removeProperty("--lattice-status-height"),bt.destroy?.()})}const Qt=ce(rt.selection);if(Qt.ranges){const at=new ie({grid:He,renderer:lt,document:vt});at.mount(),He.ranges=at,gt.push(()=>at.destroy())}if(rt.import){const at=new ke({grid:He,renderer:lt,document:vt,settings:typeof rt.import=="object"?rt.import:{}});He.importer=at,gt.push(()=>at.destroy())}if(rt.historyBar){const at=typeof rt.historyBar=="object"?rt.historyBar.element:null,bt=new Ee;bt.init({document:vt,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Ht=>He.history.peek(Ht),list:()=>He.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(at||Rt.root).appendChild(bt.element());const Mt=[He.on("history:changed",()=>bt.refresh())];He.historyBar=bt,gt.push(()=>{for(const Ht of Mt)Ht();bt.destroy()})}if(rt.diff){const at=new ye({grid:He,renderer:lt});at.mount(),He.diffPainter=at,gt.push(()=>at.destroy())}if(rt.ai&&K(rt.ai.ask)){const at=new je;at.init({document:vt,grid:He,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const bt=rt.ai.element||Rt.root;bt===Rt.root?bt.insertBefore(at.element(),bt.firstChild):bt.appendChild(at.element()),He.promptBar=at,gt.push(()=>at.destroy())}if(rt.groupPanel){const at=typeof rt.groupPanel=="object"?rt.groupPanel:{},bt=new m;bt.init({document:vt,grid:He,host:J(He,vt,(Mt,Ht)=>lt.announce?.(Mt,Ht)),props:{header:Rt.header,hint:at.hint}}),Rt.root.insertBefore(bt.element(),Rt.header),He.groupPanel=bt;for(const Mt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])K(He.on)&>.push(He.on(Mt,()=>bt.refresh()));gt.push(()=>bt.destroy())}if(rt.kpis){const at=new me({grid:He,document:vt,kpis:rt.kpis});at.active&&(at.mount(),Rt.root.insertBefore(at.element(),Rt.header),He.kpiStrip=at,gt.push(()=>at.destroy()))}if(rt.toolPanel){const at=typeof rt.toolPanel=="object"?rt.toolPanel:{},bt=new _({grid:He,document:vt,root:Rt.root,panels:at.panels,openPanel:at.openPanel,side:at.side,icons:at.icons,actions:De(He,at,Bt,lt),announce:(Mt,Ht)=>lt.announce?.(Mt,Ht)});bt.mount(),He.toolPanel=bt,gt.push(()=>bt.destroy()),at.annotate===void 0&&(gt.push(He.on("presentation:started",()=>{for(const Mt of qe(He,lt))bt.addAction(Mt)})),gt.push(He.on("presentation:ended",()=>{for(const Mt of dt)bt.removeAction(Mt)})))}if(!!rt.pagination&&(()=>{const at=typeof rt.pagination=="object"?rt.pagination:{};return He.pagination.set({pageSize:Number(at.pageSize)||100}),He.pagination.get().pageSize>0})()){const at=typeof rt.pagination=="object"?rt.pagination:{},bt=new l;bt.init({document:vt,pageSize:at.pageSize,pageSizes:at.pageSizes,page:at.page,total:at.total,locale:He.get("locale"),messages:He.messages,onChange:({page:Kt,pageSize:en})=>He.pagination.set({page:Kt,pageSize:en})});const Mt=()=>{const Kt=He.pagination.get();bt.total=Kt.total,bt.counting=Kt.counting===!0,bt.hasMore=Kt.total==null&&Kt.pageCount>Kt.page+1,bt.page=Kt.page,bt.paint()};He.pagination.set({pageSize:bt.pageSize}),Mt();const Ht=["rows:changed","filter:changed","model:changed"].map(Kt=>He.on(Kt,Mt));Rt.statusBar.appendChild(bt.element()),gt.push(()=>{for(const Kt of Ht)Kt();bt.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const at=new ae({grid:He,document:vt,root:Rt.root});at.mount(),He.editBar=at,gt.push(()=>at.destroy())}else{const at=new te({grid:He,document:vt,renderer:lt,registry:Nt,cellLayer:lt.cellLayer});at.mount(),gt.push(()=>at.destroy())}const cn=new b({grid:He,document:vt,layer:Rt.overlays,registry:Nt});cn.mount(),gt.push(()=>cn.destroy());const _t=new T({grid:He,document:vt,host:Rt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:K(rt.contextMenu)?rt.contextMenu:void 0,headerItems:K(rt.columnMenu)?rt.columnMenu:void 0});if(_t.mount(),gt.push(()=>_t.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const at=new $;at.add(He);for(const bt of rt.alignedGrids)bt&&bt!==He&&at.add(bt);gt.push(()=>at.destroy())}const Wt=new q({grid:He,renderer:lt,document:vt,registry:Nt});Wt.active&&(Wt.mount(),gt.push(()=>Wt.destroy())),Object.defineProperty(He,"form",{configurable:!0,value:Object.freeze({open(at){return Wt.active?Wt.openRow(at):!1},openNew(at){return Wt.active?Wt.openNew(at):(D("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){Wt.active&&Wt.close()},save(){return Wt.active?Wt.save():!1},isOpen(){return Wt.active?Wt.open:!1}})}),gt.push(()=>{delete He.form}),Object.defineProperty(He,"icons",{configurable:!0,value:Object.freeze({get(at){const bt=t(at);return bt?{viewBox:bt.viewBox,paths:bt.paths.slice(),paint:bt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),gt.push(()=>{delete He.icons});const Pt=new M({grid:He,renderer:lt,document:vt});Pt.active&&(Pt.mount(),gt.push(()=>Pt.destroy()));const Ft=new S({grid:He,renderer:lt,document:vt});Ft.active&&(Ft.mount(),gt.push(()=>Ft.destroy()));const Dt=new A({grid:He,renderer:lt,document:vt});if(Dt.active){Dt.mount(),Dt.paint();const at=He.on("render:done",()=>Dt.paint());gt.push(()=>{at(),Dt.destroy()})}if(rt.shortcuts!==!1){const at=new x({grid:He,renderer:lt});at.mount(),gt.push(()=>at.destroy())}const Gt=new Ie({grid:He,renderer:lt,window:vt.defaultView||void 0});Gt.mount(),gt.push(()=>Gt.destroy());const Yt=new Ye({grid:He,renderer:lt,window:vt.defaultView||void 0});if(Yt.mount(),gt.push(()=>Yt.destroy()),rt.find!==!1){const at=new Te({grid:He,renderer:lt,document:vt,settings:rt.find});at.mount(),gt.push(()=>at.destroy())}const Zt=new Ke({grid:He,renderer:lt});Zt.mount(),gt.push(()=>Zt.destroy());const Xt=new it({grid:He,renderer:lt});Xt.mount(),gt.push(()=>Xt.destroy());const nn=new yt({grid:He,renderer:lt,maximiser:Bt});nn.mount(),gt.push(()=>nn.destroy());const Jt=new zt({grid:He,renderer:lt});Jt.mount(),gt.push(()=>Jt.destroy()),rt.environment||He.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let un=null;for(const[at,bt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])gt.push(He.on(at,()=>{un=bt}));gt.push(He.on("render:done",at=>{He.diagnostics.render(un||at.cause,at.phases),un=null}));const an=vt.defaultView;if(an&&K(an.requestAnimationFrame)){let at=an.requestAnimationFrame(function bt(Mt){He.diagnostics.frame(Mt),at=an.requestAnimationFrame(bt)});gt.push(()=>{K(an.cancelAnimationFrame)&&an.cancelAnimationFrame(at)})}const gn=new pe({grid:He,renderer:lt});if(gn.mount(),gt.push(()=>gn.destroy()),gt.push(He.on("presence:lockRefused",at=>gn.announceRefusal(at.peer))),He.presence&&He.presence.enabled){for(const Mt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])gt.push(He.on(Mt,()=>He.presence.publish()));let at="";gt.push(He.on("render:done",()=>{const Mt=lt.focusState&<.focusState(),Ht=Mt?`${Mt.rowKey}${Mt.colId}`:"";Ht!==at&&(at=Ht,He.presence.publish())}));const bt=$t.ownerDocument;if(bt&&K(bt.addEventListener)){const Mt=()=>He.presence.setPaused(bt.visibilityState==="hidden");bt.addEventListener("visibilitychange",Mt),Mt(),gt.push(()=>bt.removeEventListener("visibilitychange",Mt))}}const yn=new Ge({grid:He,renderer:lt});yn.mount(),gt.push(()=>yn.destroy());const bn=new Ue({grid:He,renderer:lt});bn.mount(),gt.push(()=>bn.destroy()),gt.push(He.on("facet:computed",()=>lt.refreshHeader?.())),Qt&&Qt.headerCheckbox===!0&>.push(He.on("selection:changed",()=>lt.refreshHeader?.())),gt.push(He.on("facet:expanded",()=>lt.invalidate("columns"))),gt.push(He.on("model:changed",()=>lt.invalidate("rows")));const qt=(at,bt)=>lt.announce?.(at,bt),pn=He.messages,Ut=(at,bt)=>pn.t(at,bt),mn=at=>Ut("count.rows",{count:at});gt.push(He.on("sort:changed",()=>{const at=He.sort.get();if(!at.length){qt(Ut("a11y.sort.cleared"));return}const bt=at.map(Mt=>{const Ht=He.columns.get(Mt.col);return Ut("a11y.sort.column",{column:Ht&&Ht.title||Mt.col,direction:Ut(Mt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});qt(Ut("a11y.sort.by",{columns:pn.list(bt)}))})),gt.push(He.on("filter:changed",()=>{const at=He.rows.matchCount?He.rows.matchCount():He.rows.count(),bt=He.rows.totalCount?He.rows.totalCount():at;qt(at===bt?Ut("a11y.filter.cleared",{rows:mn(bt)}):Ut("a11y.filter.applied",{shown:mn(at),total:mn(bt)}))})),gt.push(He.on("selection:changed",()=>{const at=He.selection.keys().length;qt(at===0?Ut("a11y.selection.cleared"):Ut("a11y.selection.count",{count:at}))})),gt.push(He.on("group:toggled",at=>{const bt=He.rows.byKey?He.rows.byKey(at.key):null,Mt=(bt&&(bt.groupLabel??bt.groupValue))??at.key;qt(Ut(at.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Mt,rows:mn(He.rows.count())}))})),gt.push(He.on("column:grouped",at=>{const bt=Array.isArray(at.columns)?at.columns:[];if(!bt.length){qt(Ut("a11y.group.cleared"));return}const Mt=bt.map(Ht=>{const Kt=He.columns.get(Ht);return Kt&&Kt.title||Ht});qt(Ut("a11y.group.by",{columns:pn.list(Mt)}))})),gt.push(He.on("page:changed",at=>{const bt=Number(at.size)||0,Mt=Number(at.total)||0,Ht=bt>0?Math.max(1,Math.ceil(Mt/bt)):1;qt(Ut("a11y.page.position",{page:(Number(at.page)||0)+1,pages:Ht}))}));let rn={added:0,removed:0},on=null;const Pn=()=>{on=null;const at=[];rn.added&&at.push(Ut("count.rowsAdded",{count:rn.added})),rn.removed&&at.push(Ut("count.rowsRemoved",{count:rn.removed})),rn={added:0,removed:0},at.length&&qt(pn.list(at))};gt.push(He.on("rows:changed",at=>{if(!at||typeof at.added!="number")return;const bt=Number(at.added)||0,Mt=Number(at.removed)||0;!bt&&!Mt||(rn.added+=bt,rn.removed+=Mt,on||(on=setTimeout(Pn,Ne)))})),gt.push(()=>{on&&clearTimeout(on)}),gt.push(He.on("rows:paused",()=>{on&&(clearTimeout(on),on=null),rn={added:0,removed:0},qt(Ut("a11y.updates.paused"),{repeat:!0})})),gt.push(He.on("rows:resumed",()=>qt(Ut("a11y.updates.resumed"),{repeat:!0})));let dn={count:0,first:null},fn=null;const _n=()=>{fn=null;const{count:at,first:bt}=dn;if(dn={count:0,first:null},!at||!bt)return;const Mt=He.columns.get(bt.colId),Ht=Mt&&Mt.title||bt.colId,Kt=bt.reason?Ut("a11y.edit.reason",{reason:bt.reason}):"";if(at===1){const en=bt.restored===void 0||bt.restored===null||bt.restored===""?Ut("value.empty"):String(bt.restored);qt(Ut("a11y.edit.refusedOne",{column:Ht,value:en,reason:Kt}),{repeat:!0});return}qt(Ut("a11y.edit.refusedMany",{count:at,reason:Kt}),{repeat:!0})};gt.push(He.on("cell:reverted",at=>{!at||!at.applied||(dn.count+=1,dn.first||(dn.first=at),fn||(fn=setTimeout(_n,150)))})),gt.push(()=>{fn&&clearTimeout(fn)}),gt.push(He.on("history:applied",at=>{const bt=!!(at&&at.direction==="redo"),Mt=at&&at.step&&at.step.label;qt(Mt?Ut(bt?"a11y.history.redo":"a11y.history.undo",{label:Mt}):Ut(bt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const wn=new Tt({grid:He,renderer:lt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});wn.mount(),gt.push(()=>wn.destroy()),He.annotate=wn,He.capture=async(at={})=>{const{blob:bt,width:Mt,height:Ht}=await At(lt.viewport.root,at);return(at.download===!0||at.download!==!1&&at.fileName)&&X(bt,at.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Mt,height:Ht,bytes:bt.size,mimeType:bt.type,fileName:at.fileName||null},"api"),bt};const vn=new nt({grid:He,document:vt,element:Rt.overlays,window:vt.defaultView||void 0});vn.mount(),gt.push(()=>vn.destroy());const Cn=new h({grid:He,document:vt,element:Rt.overlays});Cn.mount?.(),gt.push(()=>Cn.destroy?.());const En=new k({grid:He,host:He.rendererHost(),viewport:Rt,document:vt});return En.mount(),gt.push(()=>En.destroy()),gt}function pt(He){const lt=[],rt=vt=>{if(vt&&(vt.__lattice&<.push(vt),vt.children))for(const Nt of vt.children)rt(Nt)};return rt(He),lt}function jt(He,lt={}){(!He||typeof He!="object"||!("appendChild"in He))&&V("createGrid needs a host element as its first argument."),lt=F(lt);const rt=He.ownerDocument||(typeof document<"u"?document:null);rt||V("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const vt=rt.documentElement&&rt.documentElement.lang,Nt=!lt.licence&&K(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,$t={...lt};if(!lt.locale&&vt&&($t.locale=vt),Nt&&($t.licence=Nt),lt.views&<.views.local)if(lt.views.storage)D("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const _t=lt.views.local===!0?{}:lt.views.local;$t.views={...lt.views,storage:O(_t)}}const gt=L($t),Rt=gt.rendererHost();Rt.document=rt,wt(Rt.registry,lt),Rt.cellLayer=s(Rt),Rt.detailHost=new Se({grid:gt,document:He.ownerDocument||globalThis.document,createGrid:(_t,Wt)=>jt(_t,Wt)});const Bt=new u(He,Rt),Qt=gt.on("detail:toggled",()=>{Rt.detailHost.syncTarget(),Rt.detailHost.prune()}),hn=gt.on("config:changed",_t=>{_t&&_t.key==="detail"&&Rt.detailHost.reconfigure()});gt.on("destroy",()=>{Qt(),hn(),Rt.detailHost.destroy()}),Rt.detailHost.syncTarget(),gt.attachRenderer(Bt),Bt.mount();const sn=ct(gt,Bt,lt,rt,Rt.registry,He),cn=gt.destroy.bind(gt);return gt.destroy=()=>{for(const _t of sn)try{_t()}catch{}He.__lattice===gt&&(He.__lattice=null),cn()},He.__lattice=gt,gt}}),xe("packages/dom/src/hydrate.js",function(e,G){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return s}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,H=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,K=G("packages/dom/src/createGrid.js").createGrid,D=new Set([...Object.keys(W),...Object.keys(H)]);function v(n,t){for(const r of n.children)if(r.tagName===t.toUpperCase())return r;return null}function O(n,t){const r=[];for(const o of n.children)o.tagName===t.toUpperCase()&&r.push(o);return r}function y(n,t){const r=L(n.getAttribute)?n.getAttribute("data-field"):null;return r||String(n.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${t}`}function u(n){const t=n.trim();if(t==="")return null;if(t==="true"||t==="false")return t==="true";const r=Number(t);return Number.isFinite(r)&&t!==""?r:t}function a(n){const t=v(n,"thead"),r=v(t||n,"tr"),f=(r?O(r,"th").length?O(r,"th"):O(r,"td"):[]).map((d,h)=>{const l=y(d,h),m={id:l,field:l,title:String(d.textContent||"").trim()||l},w=L(d.getAttribute)?d.getAttribute("data-type"):null;w&&(D.has(w)?m.type=w:B(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${l}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const k=L(d.getAttribute)?d.getAttribute("data-format"):null;return k&&(m.format=k),m}),c=v(n,"tbody"),g=(c?O(c,"tr"):O(n,"tr").filter(d=>d!==r)).map((d,h)=>{const l=O(d,"td"),w={__row:(L(d.getAttribute)?d.getAttribute("data-id"):null)||`row${h}`};return f.forEach((k,p)=>{w[k.field]=l[p]?u(String(l[p].textContent||"")):null}),w});return{columns:f,rows:g}}function s(n,t={}){const{columns:r,rows:o}=a(n),f=n.ownerDocument.createElement("div");return n.parentNode.insertBefore(f,n),n.parentNode.removeChild(n),K(f,{rowKey:"__row",columns:r,rows:o,...t,columns:t.columns!==void 0?t.columns:r,rows:t.rows!==void 0?t.rows:o})}}),xe("packages/dom/src/autoinit.js",function(e,G){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return D}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/dom/src/createGrid.js").createGrid,X=G("packages/dom/src/hydrate.js").hydrateTable;function H(v,O){const y=[];return L(v.hasAttribute)&&v.hasAttribute(O)&&y.push(v),L(v.querySelectorAll)&&y.push(...v.querySelectorAll(`[${O}]`)),y}function V(v){const O=v.parentNode;if(!O||!O.children)return null;const y=[...O.children],u=y.indexOf(v),a=[y[u+1],y[u-1]];for(const s of a)if(s&&s.tagName==="SCRIPT"&&L(s.getAttribute)&&s.hasAttribute("data-lattice-config"))return s;return null}function K(v){const O=V(v);if(!O)return{};try{return JSON.parse(O.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function D(v){const O=v||(typeof document<"u"?document:null);if(!O)return[];const y=[];for(const u of H(O,"data-lattice-grid")){if(u.__lattice)continue;const a=K(u);y.push(u.tagName==="TABLE"?X(u,a):F(u,a))}return y}}),xe("packages/modules/htmx/controller.js",function(e,G){"use strict";Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return F}});const L=G("packages/core/src/internal/util.js").isFunction;function B(W,X){if(!W||!L(X))return 0;let H=0;for(const V of X(W))V.__lattice&&L(V.__lattice.destroy)&&(V.__lattice.destroy(),H+=1);return H}function F(W,X){return!W||!L(X)?[]:X(W)}}),xe("packages/modules/htmx/history.js",function(e,G){"use strict";Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return V}});const L=G("packages/core/src/internal/util.js").isFunction,B=G("packages/core/src/model/state.js"),F=B.serialiseState,W=B.restoreState;function X(K,D){const v=[];return K&&(L(K.hasAttribute)&&K.hasAttribute(D)&&v.push(K),L(K.querySelectorAll)&&v.push(...K.querySelectorAll(`[${D}]`))),v}function H(K,D){if(!K||!L(D))return 0;let v=0;for(const O of D(K))!O.__lattice||!L(O.setAttribute)||(O.setAttribute("data-lattice-state",F(O.__lattice)),v+=1);return v}function V(K,D){if(!K)return 0;const v=X(K,"data-lattice-grid").filter(y=>!y.__lattice);for(const y of v)for(;y.firstChild;)y.removeChild(y.firstChild);v.length&&L(D)&&D(K);let O=0;for(const y of X(K,"data-lattice-state")){const u=L(y.getAttribute)?y.getAttribute("data-lattice-state"):null;!u||!y.__lattice||(W(y.__lattice,u),O+=1)}return O}}),xe("packages/modules/htmx/rowmodel.js",function(e,G){"use strict";Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return D}});const Q=G("packages/dom/src/hydrate.js"),L=Q.coerceCell,B=Q.childTags,F=Q.firstChildTag,W=5e3;function X(v,O={}){const y=v.pagination.get(),u=O.limit??(y.pageSize||100);return{offset:O.offset??(y.page??0)*u,limit:u,sort:JSON.stringify(v.sort.get()),filters:JSON.stringify(v.filters.get())}}function H(v,O){let y;if(v.tagName==="TR")y=[v];else{const u=F(v,"tbody")||v;y=B(u,"tr").length?B(u,"tr"):B(v,"tr")}return y.map((u,a)=>{const s=B(u,"td"),t={__row:(typeof u.getAttribute=="function"?u.getAttribute("data-id"):null)||`row${a}`};return O.forEach((r,o)=>{t[r.field]=s[o]?L(String(s[o].textContent||"")):null}),t})}function V(v){const O=JSON.parse(v);return Array.isArray(O)?{rows:O,total:void 0}:{rows:O.rows||[],total:O.total}}function K(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,O){if(/json/i.test(v.contentType||""))return V(v.text);const u=H(v.fragment,O);return K(u.length),{rows:u,total:void 0}}}),xe("packages/modules/htmx/oob.js",function(e,G){"use strict";Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return W}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/modules/htmx/rowmodel.js").rowsFromFragment;function W(X,H={}){const V=H.doc||(typeof document<"u"?document:null);if(!V||!L(V.addEventListener))return()=>{};const K=D=>{const v=D.detail,O=v&&v.target,y=O&&L(O.getAttribute)?O.getAttribute("data-lattice-row"):null;if(!y||!v.fragment)return;const u=H.columns||X.columns.visible().map(s=>({field:s.field||s.id})),[a]=F(v.fragment,u);a&&(delete a.__row,X.rows.apply({update:[{...a,[X.get("rowKey")]:y}]})),v.shouldSwap=!1};return V.addEventListener("htmx:oobBeforeSwap",K),()=>V.removeEventListener("htmx:oobBeforeSwap",K)}}),xe("packages/modules/htmx/servermode.js",function(e,G){"use strict";Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return D}});const L=G("packages/core/src/internal/util.js").isFunction,B=G("packages/modules/htmx/rowmodel.js"),F=B.queryParams,W=B.ingestResponse,X="lattice:query-changed";function H(v,O){const y=v.createElement("tbody");if(L(v.createRange)){const u=v.createRange();u.selectNodeContents(y),y.appendChild(u.createContextualFragment(O))}return y}function V(v,O,y={}){const u=O.ownerDocument;let a=!1;const s=i=>{i.target!==O||!i.detail||!i.detail.parameters||Object.assign(i.detail.parameters,F(v,y))},n=i=>{i.target===O&&(a=!0)},t=i=>{if(a=!1,i.target!==O)return;const g=i.detail&&i.detail.xhr&&i.detail.xhr.status,d=g?`Could not load rows (server responded ${g}).`:"Could not load rows, the request failed to reach the server.";v.overlay.show("empty",d)},r=i=>{if(i.target!==O||(a=!1,i.detail&&(i.detail.shouldSwap=!1),!i.detail||!i.detail.xhr||i.detail.isError))return;const{xhr:g}=i.detail,d=L(g.getResponseHeader)&&g.getResponseHeader("Content-Type")||"",h=i.detail.serverResponse??g.responseText??"",l=y.columns||v.columns.visible().map(k=>({field:k.field||k.id})),m=/json/i.test(d)?null:H(u,h),{rows:w}=W({contentType:d,text:h,fragment:m},l);v.rows.load(w)},o=()=>{if(a&&L(O.dispatchEvent)){const g=u.defaultView&&u.defaultView.CustomEvent;O.dispatchEvent(g?new g("htmx:abort"):{type:"htmx:abort",bubbles:!0})}const i=globalThis.htmx;i&&L(i.trigger)&&i.trigger(O,X)};u.addEventListener("htmx:configRequest",s),u.addEventListener("htmx:beforeRequest",n),u.addEventListener("htmx:beforeSwap",r),u.addEventListener("htmx:responseError",t),u.addEventListener("htmx:sendError",t);const f=v.on("sort:changed",o),c=v.on("filter:changed",o);return()=>{u.removeEventListener("htmx:configRequest",s),u.removeEventListener("htmx:beforeRequest",n),u.removeEventListener("htmx:beforeSwap",r),u.removeEventListener("htmx:responseError",t),u.removeEventListener("htmx:sendError",t),f(),c()}}const K="lattice:scroll-near-end";function D(v,O,y={}){const u=O.ownerDocument,a=y.threshold??20;let s=!1,n=!1;const t=p=>{p.target!==O||!p.detail||!p.detail.parameters||Object.assign(p.detail.parameters,F(v,{...y,offset:v.rows.count()}))},r=p=>{p.target===O&&(s=!0)},o=p=>{p.target===O&&(s=!1)},f=p=>{if(p.target!==O||(s=!1,p.detail&&(p.detail.shouldSwap=!1),!p.detail||!p.detail.xhr||p.detail.isError))return;const{xhr:b}=p.detail,E=L(b.getResponseHeader)&&b.getResponseHeader("Content-Type")||"",T=p.detail.serverResponse??b.responseText??"",P=y.columns||v.columns.visible().map(A=>({field:A.field||A.id})),x=/json/i.test(E)?null:H(u,T),{rows:C}=W({contentType:E,text:T,fragment:x},P);if(!C.length){n=!0;return}v.rows.apply({add:C})},c=()=>{n=!1},i=()=>{if(s||n)return;const p=globalThis.htmx;p&&L(p.trigger)&&p.trigger(O,K)};let g=!1;const d=()=>{g=!0},h=({last:p})=>{g&&(g=!1,(v.rows.count()===0||p>=v.rows.count()-1-a)&&i())};u.addEventListener("htmx:configRequest",t),u.addEventListener("htmx:beforeRequest",r),u.addEventListener("htmx:beforeSwap",f),u.addEventListener("htmx:responseError",o),u.addEventListener("htmx:sendError",o);const l=v.on("render:done",h),m=v.on("scroll",d),w=v.on("sort:changed",c),k=v.on("filter:changed",c);return()=>{u.removeEventListener("htmx:configRequest",t),u.removeEventListener("htmx:beforeRequest",r),u.removeEventListener("htmx:beforeSwap",f),u.removeEventListener("htmx:responseError",o),u.removeEventListener("htmx:sendError",o),l(),m(),w(),k()}}}),xe("packages/modules/htmx/index.js",function(e,G){"use strict";Object.defineProperty(e,"attach",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const L=G("packages/core/src/internal/util.js").isFunction,B=G("packages/dom/src/createGrid.js"),F=B.gridElementsWithin,W=G("packages/dom/src/autoinit.js"),X=W.autoInit,H=G("packages/modules/htmx/controller.js"),V=H.destroyWithin,K=H.initWithin,D=G("packages/modules/htmx/history.js"),v=D.saveStateWithin,O=D.restoreStateWithin;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return B.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return B.gridElementsWithin}});const y=G("packages/dom/src/hydrate.js");Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return y.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return y.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}});const u=G("packages/core/src/model/state.js");Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return u.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return u.restoreState}});const a=G("packages/core/src/index.js");Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return a.createHeadlessGrid}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return a.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return a.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return a.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return a.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return a.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return a.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return a.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return a.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return a.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return a.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return a.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return a.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return a.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return a.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return a.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return a.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return a.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return a.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return a.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return a.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return a.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return a.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return a.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return a.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return a.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return a.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return a.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return a.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return a.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return a.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return a.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return a.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return a.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return a.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return a.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return a.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return a.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return a.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return a.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return a.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return a.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return a.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return a.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return a.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return a.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return a.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return a.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return a.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return a.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return a.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return a.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return a.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return a.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return a.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return a.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return a.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return a.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return a.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return a.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return a.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return a.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return a.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return a.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return a.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return a.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return a.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return a.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return a.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return a.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return a.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return a.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return a.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return a.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return a.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return a.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return a.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return a.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return a.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return a.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return a.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return a.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return a.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return a.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return a.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return a.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return a.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return a.WINDOW_KINDS}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return a.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return a.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return a.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return a.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return a.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return a.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return a.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return a.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return a.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return a.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return a.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return a.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return a.createStreamSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return a.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return a.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return a.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return a.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return a.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return a.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return a.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return a.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return a.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return a.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return a.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return a.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return a.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return a.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return a.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return a.filtersToSql}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return a.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return a.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return a.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return a.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return a.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return a.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return a.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return a.STATE_VERSION}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return a.VERSION}});const s=G("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return s.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return s.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return s.toneOf}});const n=G("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return n.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return n.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return n.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 t=G("packages/modules/htmx/oob.js");Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return t.driveOobUpdates}});const r=G("packages/modules/htmx/servermode.js");Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return r.driveServerMode}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return r.driveInfiniteScroll}}),Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return r.QUERY_CHANGED_EVENT}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return r.SCROLL_NEAR_END_EVENT}});const o=G("packages/modules/htmx/rowmodel.js");Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return o.queryParams}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return o.rowsFromFragment}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return o.rowsFromJson}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return o.ingestResponse}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return o.warnIfLargeHtmlPayload}}),Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return o.HTML_ROW_WARNING_THRESHOLD}});function f(i){const g=i||(typeof document<"u"?document:null);if(!g||!L(g.addEventListener))return()=>{};const d=w=>V(w.target,F),h=w=>K(w.detail&&w.detail.elt||w.target,X),l=w=>{v(w.detail&&w.detail.historyElt||g,F)},m=w=>{w.detail&&w.detail.cacheMiss||O(g,X)};return g.addEventListener("htmx:beforeCleanupElement",d),g.addEventListener("htmx:load",h),g.addEventListener("htmx:beforeHistorySave",l),g.addEventListener("htmx:historyRestore",m),()=>{g.removeEventListener("htmx:beforeCleanupElement",d),g.removeEventListener("htmx:load",h),g.removeEventListener("htmx:beforeHistorySave",l),g.removeEventListener("htmx:historyRestore",m)}}f();const c=f});try{Ln("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 Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return oe}});const fe="1.80.0";async function he(){return fe}const Q="1.80.0",z=new Set,ne=2e3;function _(w){if(z.add(w),z.size>ne){const v=z.values().next().value;v!==void 0&&z.delete(v)}}const T=[],K=500;function ie(w,v,Z){T.push({key:w,level:v,message:Z.map(x=>typeof x=="string"?x:J(x)).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 le(){return T.map(w=>({...w}))}function ue(w){if(w.length===0||typeof w[0]!="string")return w;const v=w[0].replace(/^\\[lattice\\]\\s*/,"");return v===w[0]?w:[v,...w.slice(1)]}function W(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"warn",Z),console.warn("[lattice]",...Z)}function L(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"info",Z),console.info("[lattice]",...Z)}function Y(){z.clear(),T.length=0}function ee(w,v){const Z=new Error(`[lattice] ${w}`);throw v!==void 0&&(Z.cause=v),Z}function C(w,v){w||ee(v)}const A=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function s(w){return typeof w=="function"}function u(w){return w==null}function f(w){return w==null||w===""}function l(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const t=new Map;function a(w){let v=t.get(w);if(v)return v;if(!w.includes("."))v=Z=>Z?.[w];else{const Z=w.split("."),x=Z.length;v=de=>{let we=de;for(let ge=0;ge<x;ge++){if(we==null)return;we=we[Z[ge]]}return we}}return t.set(w,v),v}const m=new Map;function e(w){let v=m.get(w);if(v)return v;if(!w.includes("."))v=(Z,x)=>{Z!=null&&(Z[w]=x)};else{const Z=w.split("."),x=Z.length-1;v=(de,we)=>{let ge=de;for(let pe=0;pe<x;pe++){if(ge==null)return;const Te=Z[pe];ge[Te]==null&&(ge[Te]={}),ge=ge[Te]}ge!=null&&(ge[Z[x]]=we)}}return m.set(w,v),v}function d(w,v){return a(v)(w)}function h(w,v,Z){e(v)(w,Z)}function r(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(/^./,Z=>Z.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(w){const v=w==null?"":String(w);return/[&<>"\']/.test(v)?v.replace(/[&<>"\']/g,Z=>n[Z]):v}function g(w){return String(w).replace(/\\w\\S*/g,v=>v[0].toUpperCase()+v.slice(1).toLowerCase())}function M(w,v,Z){if(w!==void 0)return w===!0?{enabled:!0,...Z}:w===!1?{enabled:!1}:i(w)?w:{[v]:w,enabled:!0}}function N(w){return w==null?[]:Array.isArray(w)?w:[w]}const G=Object.freeze(new Set(["__proto__","constructor","prototype"]));function F(w,v){if(!i(w))return i(v)?{...v}:v;if(!i(v))return v===void 0?w:v;const Z={...w};for(const x of Object.keys(v)){if(G.has(x))continue;const de=v[x];de!==void 0&&(Z[x]=i(de)&&i(Z[x])?F(Z[x],de):de)}return Z}function R(w,v){if(!i(w)||!i(v)||w===v)return v;const Z=Object.create(Object.getPrototypeOf(w));return Object.assign(Z,w,v),Z}class X{#t;#e=new Map;#n;constructor(v=256,Z=null){this.#t=v,this.#n=Z}get size(){return this.#e.size}get max(){return this.#t}set max(v){this.#t=v,this.#r()}has(v){return this.#e.has(v)}get(v){const Z=this.#e;if(!Z.has(v))return;const x=Z.get(v);return Z.delete(v),Z.set(v,x),x}peek(v){return this.#e.get(v)}set(v,Z){const x=this.#e;return x.has(v)&&x.delete(v),x.set(v,Z),this.#r(),Z}delete(v){const Z=this.#e.get(v);return this.#e.delete(v)&&this.#n&&this.#n(Z,v),Z}clear(){if(this.#n)for(const[v,Z]of this.#e)this.#n(Z,v);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const v=this.#e;for(;v.size>this.#t;){const Z=v.keys().next().value,x=v.get(Z);v.delete(Z),this.#n&&this.#n(x,Z)}}}const E=new Map;function S(w,v){const Z=`${w||""}|${v?JSON.stringify(v):""}`;let x=E.get(Z);return x||(x=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...v}),E.set(Z,x)),x}function U(w,v){if(w===v)return 0;if(w==null)return 1;if(v==null)return-1;if(typeof w=="number"&&typeof v=="number")return Number.isNaN(w)?Number.isNaN(v)?0:1:Number.isNaN(v)||w<v?-1:w>v?1:0;const Z=String(w),x=String(v);return Z<x?-1:Z>x?1:0}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const $=typeof requestAnimationFrame=="function";function re(w){return $?requestAnimationFrame(w):setTimeout(()=>w(H()),16)}function te(w){w!=null&&($?cancelAnimationFrame(w):clearTimeout(w))}function ae(w){let v=null,Z=null;const x=()=>{v=null;const we=Z;Z=null,w(...we||[])},de=(...we)=>{Z=we,v===null&&(v=re(x))};return de.cancel=()=>{te(v),v=null,Z=null},de.flush=()=>{v!==null&&(te(v),x())},de}function p(w,v){let Z=null,x=null;const de=()=>{if(Z=null,x===null)return;const pe=x;x=null,w(...pe),we()},we=()=>{Z=setTimeout(de,v),typeof Z?.unref=="function"&&Z.unref()},ge=(...pe)=>{Z===null?(w(...pe),we()):(x=pe,clearTimeout(Z),we())};return ge.flush=()=>{if(Z!==null&&clearTimeout(Z),Z=null,x===null)return;const pe=x;x=null,w(...pe)},ge.cancel=()=>{Z!==null&&clearTimeout(Z),Z=null,x=null},ge.pending=()=>Z!==null||x!==null,ge}function B(w,v=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:v}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let q=0;function oe(w="l"){return`${w}${(++q).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 ne}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),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 ue}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.isFunction,z=1,ne=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),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?ie(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ie(s){return Array.isArray(s)?s:Q(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 le{#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 l=0;l<u.length;l++){let t=u[l];for(;t;)t&=t-1,f++}return f}}class ue{#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 l=this.#t.length;return this.#t.push(u),this.#e.set(u,l),this.#n++,l}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",l=this.#r.get(f);if(l&&l.version===this.#n)return l.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 c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),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 W(s){if(s==null)return null;const u=s.presence?new le(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ue(s.dict):null,l=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(l[e]):l[e];case"bitset":return(l[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(l[n]):l[n];return r}default:return l[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:l,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]=W(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let l=0;l<s.length;l++)if(s[l].length>=f){const t=s.splice(l,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let l=0;l<u.length;l++)if(u[l].length>=f)return u.splice(l,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=l=>{if(!ee(l))return;const t=l.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 l of s)f(l);return u}if(typeof s=="object")for(const l of Object.keys(s)){const t=s[l];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function A(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 l of s)if(!A(l,u+1))return!1;return!0}for(const l of Object.keys(s))if(!A(s[l],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 l=f.conditions;if(Array.isArray(l))for(const t of l)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 ne=Math.max(0,z|0);this.#n=ne,this.#e=new Uint8Array(Math.ceil(ne/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,ne){return ne?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const ne=Math.max(0,z|0);if(ne<=this.#n)return this;const _=Math.ceil(ne/fe);if(_>this.#e.length){const T=new Uint8Array(_);T.set(this.#e),this.#e=T}return this.#n=ne,this}count(){const z=this.#e,ne=he.#t;let _=0;for(let T=0;T<z.length;T++)_+=ne[z[T]];return _}and(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]&=ne[K];for(let K=T;K<_.length;K++)_[K]=0;return this}or(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]|=ne[K];return this}not(){const z=this.#e;for(let ne=0;ne<z.length;ne++)z[ne]=~z[ne]&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 ne=this.#n>>3;ne<this.#e.length&&(this.#e[ne]&=(1<<z)-1)}static from(z){const ne=Array.isArray(z)?z:Array.from(z),_=new he(ne.length);for(let T=0;T<ne.length;T++)ne[T]&&_.set(T);return _}}}),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,Q=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let T=0;T<_.length;T++){const K=_[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 _=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(_+=K.length*2),_+=16}return _}codeOf(_){const T=this.#e.get(_);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(_),this.#e.set(_,K),this.#n++,K}lookup(_){const T=this.#e.get(_);return T===void 0?-1:T}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const T=_||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,ie=new Array(K);for(let W=0;W<K;W++)ie[W]=W;const J=he(_).compare,le=this.#t;ie.sort((W,L)=>this.#h(le[W],le[L],J));const ue=new Uint32Array(K);for(let W=0;W<K;W++)ue[ie[W]]=W;return this.#r=ue,this.#i=this.#n,this.#s=T,ue}#h(_,T,K){return typeof _=="string"&&typeof T=="string"?K(_,T):Q(_,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(Q={}){const z=Math.max(1,Q.rows??16),ne=Math.max(1,Q.values??z);this.#t=new Int32Array(ne),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(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,z){if(Q<0||Q>=this.#n)return!1;const ne=this.#t,_=this.#e[Q+1];for(let T=this.#e[Q];T<_;T++)if(ne[T]===z)return!0;return!1}hasAny(Q,z){for(let ne=0;ne<z.length;ne++)if(this.has(Q,z[ne]))return!0;return!1}hasAll(Q,z){for(let ne=0;ne<z.length;ne++)if(!this.has(Q,z[ne]))return!1;return!0}hasNone(Q,z){return!this.hasAny(Q,z)}push(Q){const z=this.#n,ne=Q.length;this.#i(z+1),this.#s(this.#r+ne);const _=this.#r;for(let T=0;T<ne;T++)this.#t[_+T]=Q[T]|0;return this.#r+=ne,this.#n=z+1,this.#e[z]=_,this.#e[z+1]=this.#r,z}write(Q,z){if(Q===this.#n){this.push(z);return}if(Q<0||Q>this.#n)return;const ne=this.#e[Q],_=this.#e[Q+1],T=z.length;if(_-ne===T){for(let K=0;K<T;K++)this.#t[ne+K]=z[K]|0;return}this.#h(Q,z)}compact(Q,z,ne){const _=this.#t,T=this.#e,K=this.#n,ie=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let le=0;for(let ue=0;ue<K;ue++){if(Q[ue]===ne)continue;const W=T[ue],L=T[ue+1];J[Q[ue]]=le;for(let Y=W;Y<L;Y++)ie[le++]=_[Y];J[Q[ue]+1]=le}this.#t=ie,this.#e=J,this.#n=z,this.#r=le}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<Q;)z=z*2||16;const ne=new Uint32Array(z+1);ne.set(this.#e),this.#e=ne}#s(Q){if(Q<=this.#t.length)return;let z=this.#t.length;for(;z<Q;)z=z*2||16;const ne=new Int32Array(z);ne.set(this.#t),this.#t=ne}#h(Q,z){const ne=this.#t,_=this.#e,T=this.#n,K=z.length-(_[Q+1]-_[Q]),ie=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(_.length);let le=0;for(let ue=0;ue<T;ue++){if(J[ue]=le,ue===Q)for(let W=0;W<z.length;W++)ie[le++]=z[W]|0;else for(let W=_[ue];W<_[ue+1];W++)ie[le++]=ne[W];J[ue+1]=le}this.#t=ie,this.#e=J,this.#r=le}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return A}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare,z=fe.warnOnce;function ne(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(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 l=null;typeof s.from=="function"?l=s.from([!1,!0]):(l=new s(8),l.set(1));const t=l&&l.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function ie(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:ie(i.presence)}function le(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ue(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function W(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const l=u[s],t=u[s+1];if(!(t>l))return[];const a=i.dict,m=new Array(t-l);for(let e=l;e<t;e++)m[e-l]=a?ue(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 l=i.dict;return u?t=>u(t)?ue(l,s[t]):null:t=>ue(l,s[t])}if(f==="bitset"){const l=ie(s);return u?t=>u(t)?l(t)===1:null:t=>l(t)===1}if(f==="multi")return u?l=>u(l)?W(i,l):null:l=>W(i,l);if(!s&&typeof i.get=="function"){const l=i.get.bind(i);return t=>{const a=l(t);return a===void 0?null:a}}return u?l=>{if(!u(l))return null;const t=s[l];return t===void 0?null:t}:l=>{const t=s[l];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const l=Object.is(i,-0),t=Object.is(s,-0);return l===t?0:l?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const l=typeof u,t=typeof f;if(l==="string"&&t==="string")return s.compare(u,f);if(l==="number"&&t==="number")return Y(u,f);if(l==="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 Y(a,m)}return Q(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,l=ee(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>l(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 A(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 l}}),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 R}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,Q=fe.dictRanks,z=fe.dictSize,ne=fe.identity,_=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,ie=fe.valueComparator,J=fe.valueReader,le=new Uint32Array(0),ue=new ArrayBuffer(8),W=new Float64Array(ue),L=new Uint32Array(ue),Y=(W[0]=-1,(L[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function C(E,S){W[0]=E;let U=L[Y],H=L[ee];(U&2147483648)!==0?(U=~U>>>0,H=~H>>>0):U=(U^2147483648)>>>0,S[0]=H,S[1]=U}function A(E,S,U,H){if(H<2)return E;const $=new Uint32Array(256*8);for(let w=0;w<H;w++){const v=S[w],Z=U[w];$[v&255]++,$[256+(v>>>8&255)]++,$[512+(v>>>16&255)]++,$[768+(v>>>24&255)]++,$[1024+(Z&255)]++,$[1280+(Z>>>8&255)]++,$[1536+(Z>>>16&255)]++,$[1792+(Z>>>24&255)]++}let re=E,te=S,ae=U,p=new Uint32Array(H),B=new Uint32Array(H),q=new Uint32Array(H);const oe=new Uint32Array(256);for(let w=0;w<8;w++){const v=w<<8,Z=(w&3)<<3,x=w>=4;let de=!1;for(let pe=0;pe<256;pe++)if($[v+pe]===H){de=!0;break}if(de)continue;let we=0;for(let pe=0;pe<256;pe++)oe[pe]=we,we+=$[v+pe];for(let pe=0;pe<H;pe++){const Te=te[pe],Le=ae[pe],Be=(x?Le:Te)>>>Z&255,ze=oe[Be]++;p[ze]=re[pe],B[ze]=Te,q[ze]=Le}let ge=re;re=p,p=ge,ge=te,te=B,B=ge,ge=ae,ae=q,q=ge}return re}function i(E,S,U){if(U<2)return E;const H=new Uint32Array(256*4);for(let B=0;B<U;B++){const q=S[B];H[q&255]++,H[256+(q>>>8&255)]++,H[512+(q>>>16&255)]++,H[768+(q>>>24&255)]++}let $=E,re=S,te=new Uint32Array(U),ae=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const q=B<<8,oe=B<<3;let w=!1;for(let x=0;x<256;x++)if(H[q+x]===U){w=!0;break}if(w)continue;let v=0;for(let x=0;x<256;x++)p[x]=v,v+=H[q+x];for(let x=0;x<U;x++){const de=re[x],we=p[de>>>oe&255]++;te[we]=$[x],ae[we]=de}let Z=$;$=te,te=Z,Z=re,re=ae,ae=Z}return $}function s(E,S,U,H){const $=new Uint32Array(H+1);for(let ae=0;ae<U;ae++)$[S[ae]]++;let re=0;for(let ae=0;ae<=H;ae++){const p=$[ae];$[ae]=re,re+=p}const te=new Uint32Array(U);for(let ae=0;ae<U;ae++)te[$[S[ae]]++]=E[ae];return te}function u(E,S,U,H){return U<2?E:H<=65536||H<=U*2?s(E,S,U,H):i(E,S,U)}function f(E,S){return E.length===S&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,S)}function l(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=new Uint32Array($),te=new Uint32Array($),ae=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let q=0,oe=0;for(let Z=0;Z<$;Z++){const x=H[Z],de=E[x];if(Number.isNaN(de)){p[oe++]=x;continue}C(de,B),U?(te[q]=~B[0]>>>0,ae[q]=~B[1]>>>0):(te[q]=B[0],ae[q]=B[1]),re[q++]=x}const w=A(re.subarray(0,q),te.subarray(0,q),ae.subarray(0,q),q);if(oe===0)return f(w,q);const v=new Uint32Array($);return v.set(w.subarray(0,q),0),v.set(p.subarray(0,oe),q),v}function t(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=Uint32Array.from(H),te=new Uint32Array($);for(let ae=0;ae<$;ae++){const p=(E[re[ae]]^2147483648)>>>0;te[ae]=U?~p>>>0:p}return f(i(re,te,$),$)}function a(E,S,U={}){const H=S||ne(K(E,U)),$=H.length;if($<2)return Uint32Array.from(H);const re=Q(E.dict,U.locale),te=E.values,ae=T(E),p=Math.max(z(E.dict),re.length),B=p,q=Uint32Array.from(H),oe=new Uint32Array($),w=!!U.descending;for(let v=0;v<$;v++){const Z=q[v];let x=ae&&ae(Z)===0?B:re[te[Z]];x===void 0&&(x=B),oe[v]=w?B-x:x}return f(u(q,oe,$,p+1),$)}function m(E,S,U){const H=S.length;let $=Uint32Array.from(S);if(H<2)return $;let re=new Uint32Array(H);for(let te=1;te<H;te<<=1){for(let p=0;p<H;p+=te<<1){const B=Math.min(p+te,H),q=Math.min(p+(te<<1),H);let oe=p,w=B,v=p;for(;oe<B&&w<q;)re[v++]=U(E[$[oe]],E[$[w]])<=0?$[oe++]:$[w++];for(;oe<B;)re[v++]=$[oe++];for(;w<q;)re[v++]=$[w++]}const ae=$;$=re,re=ae}return $}function e(E,S,U){const H=he(E.values),$=S.length,re=new Uint32Array($),te=U?1:0;let ae=0;for(let p=0;p<$;p++)H(S[p])===te&&(re[ae++]=S[p]);for(let p=0;p<$;p++)H(S[p])!==te&&(re[ae++]=S[p]);return re}function d(E,S){const U=E.values,H=E.kind;if((H==="object"||H===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!E.presence)return U;const re=J(E),te=new Array(K(E)||0);for(let ae=0;ae<S.length;ae++){const p=S[ae];te[p]=re(p)}return te}function h(E,S){for(let U=0;U<S.length;U++)if(typeof E[S[U]]!="string")return!1;return!0}function r(E,S,U,H,$){const re=E.length,te=Uint32Array.from(E);if(re<2||H<1)return te;const ae=new Uint32Array(re),p=H-1;for(let B=0;B<re;B++){const q=U[S[B]];ae[B]=$?p-q:q}return f(u(te,ae,re,H),re)}function n(E,S,U){const H=ie(U),$=new Array(S);for(let te=0;te<S;te++)$[te]=te;$.sort((te,ae)=>H(E[te],E[ae])||te-ae);const re=new Uint32Array(S);for(let te=0;te<S;te++)re[$[te]]=te;return re}function c(E,S,U){const H=S.length,$=new Map,re=[],te=new Uint32Array(H);for(let B=0;B<H;B++){const q=E[S[B]];let oe=$.get(q);oe===void 0&&(oe=re.length,$.set(q,oe),re.push(q)),te[B]=oe}const ae=re.length,p=n(re,ae,U.locale);return r(S,te,p,ae,!!U.descending)}function g(E,S,U){const H=d(E,S);if(S.length>=2&&h(H,S)){const te=E.stringRank;return te&&te.version===E.version&&te.usable(S,H,U.locale)?te.sort(S,U):c(H,S,U)}const $=ie(U.locale),re=U.descending?(te,ae)=>$(ae,te):$;return m(H,S,re)}function M(E,S,U){const H=d(E,S),$=U.compare,te=!!U.descending?(ae,p)=>-$(ae,p,void 0,void 0,!0):(ae,p)=>$(ae,p,void 0,void 0,!1);return m(H,S,te)}function N(E,S){const U=S.length,H=T(E),$=E.values,re=E.kind==="float64"&&!!$,te=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!H&&!re&&!te)return{present:S,absent:le};const ae=new Uint32Array(U),p=new Uint32Array(U);let B=0,q=0;if(H&&re)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1&&!Number.isNaN($[w])?ae[B++]=w:p[q++]=w}else if(re&&!H)for(let oe=0;oe<U;oe++){const w=S[oe];Number.isNaN($[w])?p[q++]=w:ae[B++]=w}else if(H&&!te)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1?ae[B++]=w:p[q++]=w}else{const oe=J(E);for(let w=0;w<U;w++){const v=S[w];_(oe(v))?p[q++]=v:ae[B++]=v}}return q===0?{present:S,absent:le}:{present:ae.subarray(0,B),absent:p.subarray(0,q)}}function G(E,S,U){if(S.length===0)return E;const H=new Uint32Array(E.length+S.length);return U?(H.set(S,0),H.set(E,S.length)):(H.set(E,0),H.set(S,E.length)),H}function F(E,S,U={}){const H=S||ne(K(E,U));if(!E||H.length<2)return Uint32Array.from(H);const{present:$,absent:re}=N(E,H);if($.length===0)return Uint32Array.from(H);const te=!!U.descending;let ae;if(typeof U.compare=="function")ae=M(E,$,U);else switch(E.kind){case"float64":ae=l(E.values,$,te);break;case"int32":ae=t(E.values,$,te);break;case"dictionary":ae=a(E,$,U);break;case"bitset":ae=e(E,$,te);break;default:ae=g(E,$,U);break}return G(ae,re,!!U.nullsFirst)}function R(E,S,U,H={}){const $=S||[],re=$.length&&($[0].handle||X(E,$[0].col))||E&&E[0];let te=U||ne(K(re,H));for(let ae=$.length-1;ae>=0;ae--){const p=$[ae],B=p.handle||X(E,p.col)||E&&E[ae];B&&(te=F(B,te,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:H.locale,compare:p.compare}))}return te instanceof Uint32Array?te:Uint32Array.from(te)}function X(E,S){if(!(!E||S===void 0)){for(let U=0;U<E.length;U++)if(E[U]&&E[U].id===S)return E[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 ne}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,Q=fe.rankSortStrings,z=1e5;class ne{#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 ie=0;ie<K.length;ie++)T+=K[ie].length*2+24;return T}#a(T,K){const ie=this.#e.get(T);if(ie!==void 0)return ie;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 ie=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ie);for(let J=0;J<ie;J++){const le=T[J],ue=typeof le=="string"?this.#a(le,!1):-1;this.#n[J]=ue<0?0:ue}this.#r=ie}append(T,K,ie){const J=(K|0)+(ie|0);if(J>this.#n.length){const le=new Uint32Array(J);le.set(this.#n.subarray(0,this.#r)),this.#n=le}for(let le=K|0;le<J;le++){const ue=T[le],W=typeof ue=="string"?this.#a(ue,!0):-1;this.#n[le]=W<0?0:W}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 ie=he(this.#t,this.#t.length,T);return this.#o=ie,this.#c=this.#i,this.#l=K,ie}usable(T,K,ie){if(this.#u||this.#t.length===0)return!1;const J=this.#n,le=this.#t,ue=this.#r;for(let W=0;W<T.length;W++){const L=T[W];if(L>=ue||le[J[L]]!==K[L])return!1}return!0}sort(T,K){const ie=this.ranks(K.locale),J=this.#t.length,le=T.length,ue=new Uint32Array(le),W=this.#n;for(let L=0;L<le;L++)ue[L]=W[T[L]];return Q(T,ue,ie,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return W}}),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,Q=fe.isFunction,z=fe.pathGetter,_=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,ue=me("packages/core/src/store/stringrank.js").StringRankIndex,W=4294967295,L=1024,Y=5e3,ee=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function A(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 A(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 l(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 c=d;c<h;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const 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=Q(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 ue(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,c=this.#m;let g=!1;switch(this.#e){case"float64":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]);if(typeof G=="number"){n&&c.set(d+N),M[d+N]=G;continue}const F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?NaN:i(G)}break}case"int32":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?0:s(G)}break}case"bitset":{const M=this.#c;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M.assign(d+N,!F&&!!G)}break}case"dictionary":{const M=this.#o,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0),M[d+G]=R?0:N.codeOf(F)}break}case"multi":{const M=this.#l,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0);const X=u(F),E=new Array(X.length);for(let S=0;S<X.length;S++)E[S]=N.codeOf(X[S]);M.write(d+G,E)}break}default:{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=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 c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let M=0;M<h;M++)this.#c.assign(d+M,(g[M>>3]&1<<(M&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],M=new Uint32Array(g.length);for(let R=0;R<g.length;R++)M[R]=this.#a.codeOf(g[R]);const N=e.values,G=this.#o,F=r;for(let R=0;R<h;R++){if(F&&(n&&(n[R>>3]&1<<(R&7))===0)){G[d+R]=0;continue}G[d+R]=M[N[R]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],M=new Uint32Array(g.length);for(let F=0;F<g.length;F++)M[F]=this.#a.codeOf(g[F]);const N=e.values,G=e.offsets;for(let F=0;F<h;F++){const R=G[F],X=G[F+1],E=new Array(X-R);for(let S=R;S<X;S++)E[S-R]=M[N[S]]??0;this.#l.write(d+F,E)}this.#f++;return}for(let g=0;g<h;g++){const M=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,M?null:l(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 c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?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[c,g]of r)e[c]!==W&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==W&&(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]!==W&&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,W);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==W&&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 _(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 _(d)),this.#p=d}#A(e,d){const h=A(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 c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);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 _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!A(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 _(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??Y:0,this.#w=d.compactRatio??ee;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 c=0;c<r;c++)this.#r[h+c]=d[c];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 c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,h,r):c.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?W:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)h[c]!==W&&(n[h[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(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 le}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,Q=fe.nextFrame,z=fe.infoOnce,ne=fe.warnOnce,_=fe.isFunction,T=fe.pathGetter,ie=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function le(A,i={}){if(i.multi)return"multi";if(A.length===0)return"object";let s=0,u=0,f=0,l=0,t=0;for(let m=0;m<A.length;m++){const e=A[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?l++:Array.isArray(e)&&t++}const a=A.length;return s===a?"float64":u===a?"bitset":l===a?"float64":f===a?"text":t===a?"multi":"object"}function ue(A,i,s){return i<=0||A<s*i?"dictionary":"object"}function W(A,i,s){const u=new Map,f=new Map;for(const c of A){if(c.computed)continue;const g=_(c.read)?c.read:T(c.field||c.id);f.set(c.id,g),u.set(c.id,g)}const l=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=l.filter(c=>_(t[c])),d=e.some(c=>a[c]==="*");let h=new WeakMap;const r=c=>{const g={};if(d)for(const[M,N]of f)g[M]=N(c);for(const M of e){const N=a[M];let G;if(N==="*")G=g;else{G={};const F=N||[];for(let R=0;R<F.length;R++){const X=F[R];G[X]=X in g?g[X]:f.get(X)?.(c)}}g[M]=t[M](m?m(G,M):G,{data:c,row:null,column:null,grid:null,context:s})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=h.get(c);return g===void 0&&(g=r(c),h.set(c,g)),g};for(const c of e)u.set(c,g=>n(g)[c]);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 Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=W(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ie(this.#e.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.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 l=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,l)),this.#a(this.#i,l),this.#i=l,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),l=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))){ne(`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)??(_(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=le(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=ue(r,d.length,l),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 l=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&l.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 l=this.#d(f);if(f.kind==="dictionary"&&l>=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=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&l>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&l<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${l} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(A,i={},s={}){const u=new Y(A,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(l=>{f(l)});return u.result()}function C(A,i={},s={}){const u=new Y(A,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 Y}});const he=me("packages/core/src/internal/util.js").pathGetter,Q=me("packages/core/src/store/ingest.js"),z=Q.inferKind,ne=Q.decideText,_=Q.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,ie=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const C of ee)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!ie.has(C.kind))return!1;return!0}function le(ee){const C=K(ee);return Number.isFinite(C)?C|0:0}function ue(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function W(ee,C,A,i){if(ee.kind)return ee.kind;const s=[];for(let l=0;l<C.length&&s.length<_.sampleSize;l++){const t=C[l];t!=null&&s.push(t)}const u=z(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return ne(f,s.length,i)}function L(ee,C,A={}){const i=C.length|0,s=A.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const l=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=l(C[r]);a[r]=n===void 0?null:n}const m=W(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 c=a[n],g=c===null;g||d(n),r[n]=g?NaN:K(c)}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 c=a[n],g=c===null;g||d(n),r[n]=g?0:le(c)}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 c=a[n],g=c===null;g||d(n),!g&&c&&(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=[],c=new Map;for(let g=0;g<i;g++){const M=a[g];if(M===null){r[g]=0;continue}d(g);let N=c.get(M);N===void 0&&(N=n.length,n.push(M),c.set(M,N)),r[g]=N}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let M=0;M<i;M++){const N=a[M];c[M]=g.length,N===null||d(M);const F=ue(N);for(let R=0;R<F.length;R++){const X=F[R];let E=n.get(X);E===void 0&&(E=r.length,r.push(X),n.set(X,E)),g.push(E)}}c[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=a[n];c!==null&&d(n),r[n]=c}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 Y(ee){const C=[];if(!ee||!Array.isArray(ee.columns))return C;const A=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of ee.columns)A(i.values),A(i.presence),A(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 Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ne}});function fe(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function he(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let T=0;T<_.length;T++)if(!he(_[T]))return!1;return!0}function z(_,T){const K=_.col!==void 0?_.col:_.handle&&_.handle.id,ie=_.locale!==void 0?_.locale:T;return{col:K,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:fe(ie)}}function ne(_,T){const K=_||[],ie=new Array(K.length);for(let J=0;J<K.length;J++)ie[J]=z(K[J],T);return ie}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),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 ue}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return W}}),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,Q=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(A){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<A.length;){const l=A[s];if(l==="\'"){if(A[s+1]==="\'"){u+="\'",s+=2;continue}const a=A.indexOf("\'",s+1);if(a===-1){u+=A.slice(s+1),s=A.length;continue}u+=A.slice(s+1,a),s=a+1;continue}const t=z.find(a=>A.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(l)&&Q(`date.pattern.token:${l}`,`the date pattern "${A}" contains \'${l}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=l,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(A){if(he(A)||A==="")return null;if(A instanceof Date)return Number.isNaN(A.getTime())?null:A;if(typeof A=="number")return Number.isNaN(A)?null:new Date(A);if(typeof A=="string"){const i=_.exec(A.trim());if(i){const[,u,f,l,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+l,+t,+a,+m)}const s=new Date(A);return Number.isNaN(s.getTime())?null:s}return null}function K(A,i){return String(A).padStart(i,"0")}function ie(A){if(!A)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:A,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 l of i.formatToParts(u))switch(l.type){case"year":f.year=Number(l.value);break;case"month":f.month=Number(l.value);break;case"day":f.day=Number(l.value);break;case"hour":f.hour=Number(l.value)%24;break;case"minute":f.minute=Number(l.value);break;case"second":f.second=Number(l.value);break;case"weekday":f.weekday=s[l.value]??0;break;default:break}return f}}function J(A,i,s){const u=ne(A),f=ie(s),l=new Set(u.filter(d=>d.token).map(d=>d.token)),t=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=l.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 le=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ue(A,i){const s=A||{},u=s.locale||i||void 0,f=s.nullDisplay??"",l=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,l);else if(s.dateStyle||s.timeStyle){const h={timeZone:l};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:l});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 c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[M,N]of le)if(Math.abs(g)>=N||M==="second")return a.format(Math.round(g/N),M)}}return t(n)};return d.spec=s,d}function W(A){if(he(A)||A==="")return null;if(typeof A=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(A.trim());if(u)return u[1];const f=T(A);return f?W(f):null}const i=T(A);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(A,i){if(he(A)||A==="")return null;if(typeof A=="string"){const u=A.trim();if(Y.test(u)){const t=T(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,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 l=T(u);return l?L(l):null}const s=T(A);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(A,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(A).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=`${A.getFullYear()}-${s(A.getMonth()+1)}-${s(A.getDate())}`,f=A.getSeconds(),l=`${s(A.getHours())}:${s(A.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${l}`}function C(A,i){const s=he(A)||A===""?null:String(A),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 X}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ae}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,Q=fe.toArray,z=fe.warnOnce,_=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,ie=T.dictSize,J=T.dictValue,le=T.presenceReader,ue=T.valueComparator,W=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(p,B){const q=p&&p.pool;if(q){const oe=q.mask||q.acquireMask||q.acquire||q.take;if(typeof oe=="function"){const w=oe.call(q,B);if(w&&w.length>=B)return w}}return new Uint8Array(B)}function C(p,B){const q=p&&p.pool;if(!q||!B)return;const oe=q.release||q.releaseMask||q.free||q.recycle;typeof oe=="function"&&oe.call(q,B)}function A(p,B,q){return p.fill(q,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 q=_(p);return q===null?u(p):q}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 l(p,B){const q=typeof p=="string"?p:String(p);return B?q:q.toLowerCase()}function t(p,B){return p==null?Y:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,q){const oe=new Set;for(const w of Q(p)){const v=s(w,q);oe.add(t(v,B)),typeof v=="string"&&v!==""&&Number.isFinite(Number(v))?oe.add(Number(v)):typeof v=="number"&&Number.isFinite(v)&&oe.add(t(String(v),B))}return oe}function m(p,B,q){if(p==null||B===null||B===void 0)return p==null&&B==null;const oe=typeof p,w=typeof B;return oe==="string"&&w==="string"?q?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):oe==="number"&&w==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):oe==="number"&&w==="string"?p===Number(B):oe==="string"&&w==="number"?Number(p)===B:oe==="boolean"||w==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((v,Z)=>m(v,B[Z],q)):p===B}function e(p,B){try{if(p instanceof RegExp){const q=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||q.includes("i")?q:`${q}i`)}return new RegExp(String(p),B?"":"i")}catch(q){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,q),null}}function d(p,B){const q=h(p,B),oe=p&&p.type;return oe!=="date"&&oe!=="dateString"?q:w=>q(typeof w=="string"&&L.test(w)?w:_(w)??w)}function h(p,B){const q=p&&p.op,oe=!!(p&&p.caseSensitive),w=p&&p.type,v=ue(B),Z=x=>de=>!x(de);switch(q){case"eq":{const x=s(p.value,w);return de=>m(de,x,oe)}case"ne":{const x=s(p.value,w);return de=>!m(de,x,oe)}case"lt":case"lte":case"gt":case"gte":{const x=s(p.value,w);if(i(x))return()=>!1;const de=q==="lt"?-1:q==="lte"?0:q==="gt"?1:2;return we=>{if(i(we))return!1;const ge=v(we,x);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const x=Q(p.value),de=s(x[0],w),we=s(x[1],w),ge=p.bounds||"[]",pe=ge.charAt(0)!=="(",Te=ge.charAt(1)!==")";if(i(de)||i(we))return q==="between"?()=>!1:()=>!0;const Le=Be=>{if(i(Be))return!1;const ze=v(Be,de),Ke=v(Be,we);return(pe?ze>=0:ze>0)&&(Te?Ke<=0:Ke<0)};return q==="between"?Le:Z(Le)}case"in":case"notIn":{const x=a(p.value,oe,w),de=we=>x.has(t(we,oe));return q==="in"?de:Z(de)}case"contains":case"notContains":{const x=l(s(p.value,w),oe),de=we=>we==null?!1:l(we,oe).includes(x);return q==="contains"?de:Z(de)}case"startsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).startsWith(x)}case"endsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).endsWith(x)}case"matches":{const x=e(p.value,oe);return x?de=>de==null?!1:x.test(String(de)):()=>!1}case"blank":return x=>he(x)||Array.isArray(x)&&x.length===0;case"notBlank":return x=>!(he(x)||Array.isArray(x)&&x.length===0);case"containsAny":case"containsNone":{const x=a(p.value,oe,w),de=we=>{const ge=we==null?[]:Q(we);for(let pe=0;pe<ge.length;pe++)if(x.has(t(ge[pe],oe)))return!0;return!1};return q==="containsAny"?de:Z(de)}case"containsAll":{const x=Q(p.value).map(de=>t(s(de,w),oe));return de=>{const we=de==null?[]:Q(de);if(x.length===0)return!0;const ge=new Set(we.map(pe=>t(pe,oe)));for(let pe=0;pe<x.length;pe++)if(!ge.has(x[pe]))return!1;return!0}}default:{const x=ae(q);return x?x.compile(p.value):(z(`op:${String(q)}`,`unknown filter operator "${String(q)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,q){return d(B,q)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,q){const oe=p&&p.op,w=n[oe]||oe,v=d({...p,op:w,type:B.type},q),Z=B.items,x=de=>{const we=Z(de);if(!we)return!1;for(let ge=0;ge<we.length;ge++)if(v(we[ge]))return!0;return!1};return n[oe]?de=>!x(de):x}function M(p,B,q,oe){const w=le(p);if(w){const x=B?1:0;for(let de=0;de<oe;de++)q[de]=w(de)===x?1:0;return q}const v=p.kind;if(v==="float64"||v==="int32"||v==="bitset")return A(q,oe,B?1:0);const Z=W(p);for(let x=0;x<oe;x++){const de=Z(x),we=he(de)||Array.isArray(de)&&de.length===0;q[x]=we===B?0:1}return q}function N(p,B,q,oe){const w=p.dict,v=ie(w),Z=new Uint8Array(v);for(let ge=0;ge<v;ge++)Z[ge]=B(J(w,ge))?1:0;const x=p.values,de=le(p);if(!de){for(let ge=0;ge<oe;ge++)q[ge]=Z[x[ge]];return q}const we=B(null)?1:0;for(let ge=0;ge<oe;ge++)q[ge]=de(ge)===1?Z[x[ge]]:we;return q}function G(p,B,q,oe){const w=K(p.values),v=B(!0)?1:0,Z=B(!1)?1:0,x=le(p);if(!x){for(let we=0;we<oe;we++)q[we]=w(we)===1?v:Z;return q}const de=B(null)?1:0;for(let we=0;we<oe;we++)q[we]=x(we)===0?de:w(we)===1?v:Z;return q}function F(p,B,q,oe,w){const v=p.values,Z=B.type,x=B.op;let de=!0;switch(x){case"eq":case"ne":{const ge=f(s(B.value,Z)),pe=typeof B.value=="number"&&Number.isNaN(B.value),Te=x==="ne"?1:0;if(pe)for(let Le=0;Le<w;Le++)oe[Le]=(Number.isNaN(v[Le])?1:0)^Te;else for(let Le=0;Le<w;Le++)oe[Le]=(v[Le]===ge?1:0)^Te;break}case"lt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<ge?1:0;break}case"lte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>ge?1:0;break}case"gte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>=ge?1:0;break}case"between":case"notBetween":{const ge=Q(B.value),pe=f(s(ge[0],Z)),Te=f(s(ge[1],Z)),Le=B.bounds||"[]",Be=Le.charAt(0)!=="(",ze=Le.charAt(1)!==")",Ke=x==="notBetween"?1:0;if(Be&&ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<=Te?1:0)^Ke;else if(Be)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<Te?1:0)^Ke;else if(ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<=Te?1:0)^Ke;else for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<Te?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Te of Q(B.value)){const Le=f(s(Te,Z));Number.isNaN(Le)||ge.add(Le)}const pe=x==="notIn"?1:0;for(let Te=0;Te<w;Te++)oe[Te]=(ge.has(v[Te])?1:0)^pe;break}default:de=!1;break}if(!de)return!1;const we=le(p);if(we){const ge=q(null)?1:0;for(let pe=0;pe<w;pe++)we(pe)===0&&(oe[pe]=ge)}return!0}function R(p,B,q,oe){const w=W(p);for(let v=0;v<oe;v++)q[v]=B(w(v))?1:0;return q}function X(p,B,q){const oe=B.count|0,w=q||ee(B,oe);if(!p)return A(w,oe,1);const v=typeof B.handle=="function"?B.handle(p.col):void 0,Z=typeof B.custom=="function"?B.custom:null;if(!v){if(Z){for(let ge=0;ge<oe;ge++)w[ge]=Z(p,ge)?1:0;return w}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),A(w,oe,0)}const x=p.op;if(x==="blank"||x==="notBlank")return M(v,x==="notBlank",w,oe);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ae(x)&&!c.has(x))return R(v,g(p,de,B.locale),w,oe);const we=d(p,B.locale);switch(v.kind){case"dictionary":return N(v,we,w,oe);case"bitset":return G(v,we,w,oe);case"float64":case"int32":return F(v,p,we,w,oe)?w:R(v,we,w,oe);default:return R(v,we,w,oe)}}function E(p,B,q){if(!p)return A(ee(B,q),q,1);if(Array.isArray(p.conditions)){const oe=p.conditions.filter(Z=>Z!=null),w=p.op==="or"?"or":p.op==="not"?"not":"and";if(oe.length===0)return A(ee(B,q),q,1);const v=E(oe[0],B,q);for(let Z=1;Z<oe.length;Z++){const x=E(oe[Z],B,q);if(w==="or")for(let de=0;de<q;de++)v[de]|=x[de];else for(let de=0;de<q;de++)v[de]&=x[de];C(B,x)}if(w==="not")for(let Z=0;Z<q;Z++)v[Z]^=1;return v}return X(p,B,ee(B,q))}function S(p,B){return E(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const q=p;if(Array.isArray(q.conditions)){if((q.op==="or"?"or":q.op==="not"?"not":"and")!=="and")return H(q,B)?null:p;const w=[];for(const v of q.conditions){const Z=U(v,B);Z&&w.push(Z)}return w.length?{...q,op:"and",conditions:w}:null}return q.col===B?null:p}function H(p,B){if(!p||typeof p!="object")return!1;const q=p;if(q.col===B)return!0;if(Array.isArray(q.conditions)){for(const oe of q.conditions)if(H(oe,B))return!0}return!1}function $(p,B,q){if(q&&q.length>=B){let Z=0;for(let x=0;x<B;x++)p[x]&&(q[Z++]=x);return q.subarray(0,Z)}let oe=0;for(let Z=0;Z<B;Z++)oe+=p[Z]?1:0;const w=new Uint32Array(oe);let v=0;for(let Z=0;Z<B;Z++)p[Z]&&(w[v++]=Z);return w}const re=new Map;function te(p){if(!(!p||typeof p!="object"))for(const[B,q]of Object.entries(p))q&&typeof q.compile=="function"&&re.set(B,q)}function ae(p){return typeof p=="string"?re.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 ue}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,Q=fe.identity,z=fe.presenceReader,ne=fe.rowCount,_=fe.valueReader,T="",K="\\0",ie=1<<20;function J(W,L,Y,ee){const C=W.length,A=W.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?A.map((t,a)=>ee[a]?m=>ee[a](t(m)):t):A;if(!i&&C>0&&W.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=W.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=W.map(r=>r.values),e=W.map(r=>z(r)),d=r=>{let n=0;for(let c=0;c<C;c++){const g=e[c],M=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+M}return n},h=new Float64Array(Y);for(let r=0;r<Y;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},l=new Array(Y);for(let t=0;t<Y;t++)l[t]=f(L[t]);return{packed:null,strings:l,product:1/0,readers:s,keyOf:f}}function le(W,L,Y,ee){const C=new Uint32Array(ee+1);for(let u=0;u<Y;u++)C[L[u]+1]++;for(let u=0;u<ee;u++)C[u+1]+=C[u];const A=new Uint32Array(Y),i=C.slice(0,ee);for(let u=0;u<Y;u++)A[i[L[u]]++]=W[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=A.subarray(C[u],C[u+1]);return s}function ue(W,L,Y={}){const ee=W||[],C=L||Q(ne(ee[0],Y)),A=C.length;if(ee.length===0||A===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(ee,C,A,Y.project),l=new Uint32Array(A);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ie,A*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<A;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<A;n++)l[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<A;r++){const n=i[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<A;r++){const n=s[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}}const m=le(C,l,A,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let c=0;c<f.length;c++)n[c]=f[c](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 _}}),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 ie}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return W}}),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 A}}),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,Q=fe.valueReader,z=fe.dictSize,ne=fe.dictValue,_=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,ie=50,J=1e4;function le(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const M=c&&c.base;if(M==="date"||M==="datetime"||M==="time"||M==="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 M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function ue(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return N=>c[N];const M=Q(n);return N=>W(M(N))}function W(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,c,g,M=ie){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 N=Q(n),G=c?c.length:g,F=new Set;for(let R=0;R<G;R++){const X=N(c?c[R]:R);if(X!=null&&(F.add(X),F.size>M))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Y=36e5,ee=864e5;function C(n,c=K){const g=Number.isFinite(n)&&n>0?n:0,M=Math.max(1,c)*2;return g/Y<=M?"hour":g/ee<=M?"day":g/(7*ee)<=M?"week":g/(30*ee)<=M?"month":g/(91*ee)<=M?"quarter":"year"}function A(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const M=(g.getDay()+6)%7;return g.setDate(g.getDate()-M),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,c,g){const M=ue(n),N=he(n),G=c?c.length:g;let F=1/0,R=-1/0,X=0,E=0;for(let S=0;S<G;S++){const U=c?c[S]:S;if(N&&!N(U)){X++;continue}const H=M(U);if(!Number.isFinite(H)){X++;continue}H<F&&(F=H),H>R&&(R=H),E++}return{min:F,max:R,nulls:X,finite:E}}function u(n,c,g,M){const N=ue(n),G=he(n),F=c?c.length:g,R=F>M?F/M:1,X=[];for(let S=0;S<F;S+=R){const U=c?c[Math.floor(S)]:Math.floor(S);if(G&&!G(U))continue;const H=N(U);Number.isFinite(H)&&X.push(H)}const E=Float64Array.from(X);return E.sort(),E}function f(n,c,g,M={}){const N=M.kind||le(n,M.type);return N==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:N==="boolean"?l(n,c,g):N==="category"?t(n,c,g,M):a(n,c,g,N,M)}function l(n,c,g){const M=he(n);let N=0;if(M){const F=c?c.length:g;for(let R=0;R<F;R++)M(c?c[R]:R)||N++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return N>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,c,g,M){const N=M.cardinalityLimit??ie,{cardinality:G}=L(n,c,g,N);if(G>N&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=Q(n),R=c?c.length:g,X=new Map;let E=0;for(let re=0;re<R;re++){const te=F(c?c[re]:re);if(te==null||te===""){E++;continue}if(Array.isArray(te)){if(!te.length){E++;continue}for(const ae of te)X.set(ae,(X.get(ae)||0)+1);continue}X.set(te,(X.get(te)||0)+1)}let S=[...X.entries()];M.order==="alpha"?S.sort((re,te)=>String(re[0]).localeCompare(String(te[0]))):S.sort((re,te)=>te[1]-re[1]);let U=0,H=0;if(S.length>N){H=S.length-N;for(let re=N;re<S.length;re++)U+=S[re][1];S=S.slice(0,N)}const $=S.map(([re])=>({value:re,label:String(re)}));return U>0&&$.push({remainder:!0,label:`Other (${H} values)`}),E>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,c,g,M,N){const{min:G,max:F,nulls:R,finite:X}=s(n,c,g);if(!X)return{kind:M,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(N.buckets||K));let S=[];if(M==="date"){const H=T.includes(N.granularity)?N.granularity:C(F-G,E);let $=A(G,H);for(;$<=F&&S.length<4096;){const re=i($,H);if(!(re>$))break;S.push({from:$,to:re}),$=re}return{kind:M,buckets:m(S,R),granularity:H}}const U=_.includes(N.strategy)?N.strategy:"equal";if(U==="quantile"){const H=u(n,c,g,J);if(H.length){const $=[H[0]];for(let re=1;re<E;re++){const te=H[Math.min(H.length-1,Math.floor(re/E*H.length))];te>$[$.length-1]&&$.push(te)}$.push(F);for(let re=0;re<$.length-1;re++)S.push({from:$[re],to:$[re+1]})}}else if(U==="log"&&G>0){const H=Math.log10(G),re=(Math.log10(F)-H)/E||1;for(let te=0;te<E;te++)S.push({from:10**(H+te*re),to:10**(H+(te+1)*re)})}if(!S.length){const H=(F-G)/E||1;for(let $=0;$<E;$++)S.push({from:G+$*H,to:G+($+1)*H})}return S[S.length-1].to=F,{kind:M,buckets:m(S,R),strategy:U,min:G,max:F}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,M,N){const G=M&&M.buckets||[],F=N&&N.length>=G.length?N.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const R=G.length-1,X=!!G[R]&&G[R].null===!0,E=c?c.length:g;if(M.kind==="boolean"){const re=Q(n);for(let te=0;te<E;te++){const ae=re(c?c[te]:te);if(ae==null){X&&F[R]++;continue}F[ae?1:0]++}return F}if(M.kind==="category"){const re=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&re.set(G[p].value,p);const te=G.findIndex(p=>p.remainder),ae=Q(n);for(let p=0;p<E;p++){const B=ae(c?c[p]:p);if(B==null||B===""){X&&F[R]++;continue}if(Array.isArray(B)){if(!B.length){X&&F[R]++;continue}for(const oe of B){const w=re.get(oe);w!==void 0?F[w]++:te>=0&&F[te]++}continue}const q=re.get(B);q!==void 0?F[q]++:te>=0&&F[te]++}return F}const S=X?G.length-1:G.length,U=new Float64Array(S+1);for(let re=0;re<S;re++)U[re]=G[re].from;U[S]=S?G[S-1].to:0;const H=ue(n),$=he(n);for(let re=0;re<E;re++){const te=c?c[re]:re;if($&&!$(te)){X&&F[R]++;continue}const ae=H(te);if(!Number.isFinite(ae)){X&&F[R]++;continue}const p=d(U,S,ae);p>=0&&F[p]++}return F}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let M=0,N=c-1;for(;M<N;){const G=M+N+1>>>1;g>=n[G]?M=G:N=G-1}return M}function h(n,c,g,M={}){const N=M.bounds||f(n,M.boundsIndices??c,g,M);return{bounds:N,counts:e(n,c,g,N)}}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 _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,Q=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const A=C-1;let i=.9999999999998099;const s=A+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(A+u+1);return .5*Math.log(2*Math.PI)+(A+.5)*Math.log(s)-s+Math.log(i)}function ne(C,A,i){const s=C+A,u=C+1,f=C-1;let l=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(A-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t,a*=t*l,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t;const h=t*l;if(a*=h,Math.abs(h-1)<he)break}return a}function _(C,A,i){if(!(C>0)||!(A>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+A)-z(C)-z(A)+C*Math.log(i)+A*Math.log(1-i));return i<(C+1)/(C+A+2)?s*ne(C,A,i)/C:1-s*ne(A,C,1-i)/A}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const A=[-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 l,t,a;C<f?(l=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1)):C<=1-f?(l=C-.5,t=l*l,a=(((((A[0]*t+A[1])*t+A[2])*t+A[3])*t+A[4])*t+A[5])*l/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(l=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+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 A=Math.abs(C),i=2/(2+A),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,l=0,t;for(let m=u.length-1;m>0;m--)t=l,l=s*l-f+u[m],f=t;const a=i*Math.exp(-A*A+.5*(u[0]+s*l)-f);return C>=0?a:2-a}function ie(C){return .5*K(-C/Math.SQRT2)}function J(C,A){if(!(A>0)||!Number.isFinite(C))return Number.NaN;const i=.5*_(A/2,.5,A/(A+C*C));return C>0?1-i:i}function le(C,A){if(!(C>0)||!(C<1)||!(A>0))return Number.NaN;if(A>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(A/2)+z(.5)-z((A+1)/2);for(let l=0;l<60;l++){const t=J(u,A);t<C?i=u:s=u;const a=Math.exp(-((A+1)/2)*Math.log(1+u*u/A)-f)/Math.sqrt(A),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 ue(C,A){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=A/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-A+C*Math.log(A)-z(C))}function W(C,A){let i=A+1-C,s=1/Q,u=1/i,f=u;for(let l=1;l<=300;l++){const t=-l*(l-C);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-A+C*Math.log(A)-z(C))*f}function L(C,A){return!(C>0)||!(A>=0)||!Number.isFinite(A)?Number.NaN:A===0?0:A<C+1?ue(C,A):1-W(C,A)}function Y(C,A){return A>0?L(A/2,C/2):Number.NaN}function ee(C,A){const i=Y(C,A);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 Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function fe(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let le=0;le<=J;le++){let ue=T[J][le];for(let W=0;W<le;W++)ue-=ie[J][W]*ie[le][W];if(J===le){if(!(ue>0))return null;ie[J][le]=Math.sqrt(ue)}else ie[J][le]=ue/ie[le][le]}return ie}function he(T,K){const ie=T.length,J=new Array(ie).fill(0);for(let ue=0;ue<ie;ue++){let W=K[ue];for(let L=0;L<ue;L++)W-=T[ue][L]*J[L];J[ue]=W/T[ue][ue]}const le=new Array(ie).fill(0);for(let ue=ie-1;ue>=0;ue--){let W=J[ue];for(let L=ue+1;L<ie;L++)W-=T[L][ue]*le[L];le[ue]=W/T[ue][ue]}return le}function Q(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const le=new Array(K).fill(0);le[J]=1;const ue=he(T,le);for(let W=0;W<K;W++)ie[W][J]=ue[W]}return ie}function z(T,K,ie){const J=T.length,le=J?T[0].length:0,ue=Array.from({length:le},()=>new Array(le).fill(0)),W=new Array(le).fill(0);for(let L=0;L<J;L++){const Y=ie?ie[L]:1,ee=T[L];for(let C=0;C<le;C++){const A=Y*ee[C];W[C]+=A*K[L];for(let i=C;i<le;i++)ue[C][i]+=A*ee[i]}}for(let L=0;L<le;L++)for(let Y=0;Y<L;Y++)ue[L][Y]=ue[Y][L];return{xtwx:ue,xtwy:W}}function ne(T,K){return T.map(ie=>ie.reduce((J,le,ue)=>J+le*K[ue],0))}function _(T,K){let ie=0;for(let J=0;J<T.length;J++){let le=0;for(let ue=0;ue<T.length;ue++)le+=K[J][ue]*T[ue];ie+=T[J]*le}return ie}}),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 ne}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ue}});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 Y=L-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(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 Y=this.#t+L.#t,ee=L.#e-this.#e;this.#e+=ee*(L.#t/Y),this.#n+=L.#n+ee*ee*(this.#t*L.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const 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,Y=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Y of this.#t)L+=Y;return L/this.#t.length}quantile(L){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const C=(Y-1)*Math.min(1,Math.max(0,L)),A=Math.floor(C),i=Math.ceil(C);return A===i?ee[A]:ee[A]+(C-A)*(ee[i]-ee[A])}}function Q(W){return W^=W>>>16,W=Math.imul(W,2246822507),W^=W>>>13,W=Math.imul(W,3266489909),W^=W>>>15,W>>>0}function z(W){if(typeof W=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,W===0?0:W),Q(ee.getUint32(0)^ee.getUint32(4))}const L=typeof W=="string"?W:String(W);let Y=2166136261;for(let ee=0;ee<L.length;ee++)Y^=L.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class ne{#t;#e;#n;constructor(L=14){const Y=Math.floor(L);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Y=1<<Math.floor(L),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return ne.errorBoundFor(this.#t)}add(L){const Y=z(L),ee=Y&this.#e-1,C=Y>>>this.#t|1<<32-this.#t;let A=1,i=C;for(;(i&1)===0;)A++,i>>>=1;A>this.#n[ee]&&(this.#n[ee]=A)}count(){const L=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<L;i++)ee[this.#n[i]]++;let C=L*K(1-ee[Y+1]/L);for(let i=Y;i>=1;i--)C=.5*(C+ee[i]);C+=L*T(ee[0]/L);const A=_*L*L/C;return Math.round(A)}}const _=.5/Math.log(2);function T(W){if(W===1)return 1/0;let L=1,Y=W,ee;do W*=W,ee=Y,Y+=W*L,L+=L;while(Y!==ee);return Y}function K(W){if(W===0||W===1)return 0;let L=1,Y=1-W,ee;do W=Math.sqrt(W),ee=Y,L*=.5,Y-=(1-W)**2*L;while(Y!==ee);return Y/3}class ie{#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 Y=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Y=this.#t.get(L);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let ee,C=1/0;for(const[A,i]of this.#t)i.count<C&&(C=i.count,ee=A);this.#t.delete(ee),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([ee,C])=>({item:ee,count:C.count,error:C.error})).sort((ee,C)=>C.count-ee.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Y=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Y,this.#i=2/3}static errorBoundFor(L=200){const Y=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const ee=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**ee);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 Y=this.#e[L];Y.sort((A,i)=>A-i),L+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[L+1],C=this.#r()<.5?0:1;for(let A=C;A<Y.length;A+=2)ee.push(Y[A]);this.#e[L]=[];for(let A=0;A<this.#e.length;A++)if(this.#e[A].length>=this.#s(A)){this.#h(A);return}}#u(){const L=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const C of this.#e[Y])L.push({v:C,w:ee})}return L}quantile(L){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const C=Math.min(1,Math.max(0,L))*ee;let A=0;for(const i of Y)if(A+=i.w,A>=C)return i.v;return Y[Y.length-1].v}rank(L){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const C=1<<ee;for(const A of this.#e[ee])A<=L&&(Y+=C)}return Y}}const le=Object.freeze({distinct:ne.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"})}),ue={Welford:fe,Reservoir:he,HyperLogLog:ne,SpaceSaving:ie,KLL:J,hash32:z,SKETCH_BOUNDS:le}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return A}}),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 l}}),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 c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return N}}),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 R}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return te}}),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 Le}}),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 Ee}}),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,Q=fe.valueReader,z=me("packages/core/src/compute/special.js"),ne=z.studentTQuantile,_=z.studentT,T=z.normalQuantile,K=z.normalCdf,ie=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),le=J.cholesky,ue=J.choleskySolve,W=J.choleskyInverse,L=J.normalEquations,Y=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,A=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 se=0;se<y;se++){const ce=j[se];if(D&&D(ce)!==1)continue;const Oe=I[ce];Number.isNaN(Oe)||(O[k++]=Oe)}return O.subarray(0,k)}const V=Q(b);for(let I=0;I<y;I++){const D=V(j[I]);if(D==null||D==="")continue;const se=typeof D=="number"?D:Number(D);Number.isFinite(se)&&(O[k++]=se)}return O.subarray(0,k)}function l(b,j){const y=new Map,O=Q(b);let k=0;for(let V=0;V<j.length;V++){const I=O(j[V]);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 P=[...y.values()].sort((V,I)=>I-V);return{counts:P,total:k,distinct:P.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=l(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=l(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=l(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=l(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let P=0;for(let V=0;V<Math.min(k,O.counts.length);V++)P+=O.counts[V];return P/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 P=0,V=0;for(let I=0;I<O;I++)P+=k[I],V+=(I+1)*k[I];return P===0?0:2*V/(O*P)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const P=b[k];j++;const V=P-y;y+=V/j,O+=V*(P-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),P=Math.ceil(O);return k===P?b[k]:b[k]+(O-k)*(b[P]-b[k])}function c(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=Q(b);let O=0,k=0,P=0;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&P++}return{pass:O+P,fail:k,warn:P,judged:O+P+k}}const M=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)=>X(f(b,j),.1),winsorizedMean:(b,j)=>E(f(b,j),.1),robustOutliers:(b,j)=>S(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?c(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?c(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?c(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?c(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?c(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?c(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=c(y,.5),k=new Float64Array(y.length);for(let P=0;P<y.length;P++)k[P]=Math.abs(y[P]-O);return c(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let P=0;P<y.length;P++)y[P]<O&&(O=y[P]),y[P]>k&&(k=y[P]);return k-O},distinct:(b,j)=>{const y=Q(b),O=new Set;for(let k=0;k<j.length;k++){const P=y(j[k]);P==null||P===""||O.add(P instanceof Date?P.getTime():P)}return O.size},mode:(b,j)=>{const y=Q(b),O=new Map;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,P=1;for(const[V,I]of O)I>P&&(P=I,k=V);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<3||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/V)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<4||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let ce=0;ce<y.length;ce++)I+=((y[ce]-k)/V)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),se=3*(O-1)**2/((O-2)*(O-3));return D*I-se},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}),N=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=Q(b),k=Q(j);let P=0,V=0;for(let I=0;I<y.length;I++){const D=y[I],se=Number(O(D)),ce=Number(k(D));!Number.isFinite(se)||!Number.isFinite(ce)||(P+=se*ce,V+=ce)}return V===0?null:P/V}function F(b,j,y){const O=Q(b);let k=null,P=y?-1/0:1/0;for(let V=0;V<j.length;V++){const I=j[V],D=Number(O(I));Number.isFinite(D)&&(y?D>P:D<P)&&(P=D,k=I)}return k}function R(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0,I=0,D=0,se=0,ce=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)||(P++,V+=Pe,I+=ye,D+=Pe*Pe,se+=ye*ye,ce+=Pe*ye)}if(P<2)return null;const Oe=P*ce-V*I,ke=Math.sqrt((P*D-V*V)*(P*se-I*I));if(ke===0)return null;const je=Oe/ke;return Math.max(-1,Math.min(1,je))}function X(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))),P=O.slice(k,y-k);if(!P.length)return n(O,.5);let V=0;for(const I of P)V+=I;return V/P.length}function E(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,se)=>D-se),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O[k],V=O[y-1-k];let I=0;for(const D of O)I+=Math.min(V,Math.max(P,D));return I/y}function S(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,se)=>D-se),k=n(O,.5),P=O.map(D=>Math.abs(D-k)).sort((D,se)=>D-se),V=n(P,.5);if(V===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/V)>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,P=0;for(const D of b){const se=D-y;O+=se*se,k+=se*se*se,P+=se*se*se*se}if(O/=j,k/=j,P/=j,O===0)return null;const V=k/O**1.5,I=P/(O*O)-3;return j/6*(V*V+I*I/4)}function H(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const se=Number(b[D]),ce=Number(j[D]);!Number.isFinite(se)||!Number.isFinite(ce)||ce<=0||(O.push([se,ce]),k+=ce)}if(!O.length||k<=0)return null;if(O.sort((D,se)=>D[0]-se[0]),O.length===1)return O[0][0];const P=[];let V=0;for(const[,D]of O)P.push((V+D/2)/k),V+=D;const I=Math.max(0,Math.min(1,y));if(I<=P[0])return O[0][0];if(I>=P[P.length-1])return O[O.length-1][0];for(let D=1;D<P.length;D++){if(I>P[D])continue;const se=P[D]-P[D-1],ce=se>0?(I-P[D-1])/se:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*ce}return O[O.length-1][0]}function $(b,j,y){const O=Q(b),k=Q(j),P=new Float64Array(y.length),V=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const se=y[D],ce=Number(O(se)),Oe=Number(k(se));!Number.isFinite(ce)||!Number.isFinite(Oe)||(P[I]=ce,V[I]=Oe,I++)}return{xs:P.subarray(0,I),ys:V.subarray(0,I),n:I}}function re(b,j,y,O=!1){const{xs:k,ys:P,n:V}=$(b,j,y);if(V<2)return null;let I=0,D=0;for(let ce=0;ce<V;ce++)I+=k[ce],D+=P[ce];I/=V,D/=V;let se=0;for(let ce=0;ce<V;ce++)se+=(k[ce]-I)*(P[ce]-D);return se/(O?V:V-1)}function te(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;let V=0,I=0;for(let Pe=0;Pe<P;Pe++)V+=O[Pe],I+=k[Pe];V/=P,I/=P;let D=0,se=0,ce=0;for(let Pe=0;Pe<P;Pe++){const ye=O[Pe]-V,ve=k[Pe]-I;D+=ye*ye,se+=ye*ve,ce+=ve*ve}if(D===0)return null;const Oe=se/D,ke=I-Oe*V,je=ce===0?1:Math.max(0,Math.min(1,se*se/(D*ce))),be=Math.max(0,ce-Oe*se),Ae=P>2?Math.sqrt(be/(P-2)/D):0;return{slope:Oe,intercept:ke,r2:je,stdError:Ae,n:P}}const ae=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),q=1.345;function oe(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),P=le(O);if(!P)return null;const V=ue(P,k),I=W(P),D=w(b,V),se=j.map((ce,Oe)=>ce-D[Oe]);return{beta:V,cov:I,fitted:D,residuals:se}}function w(b,j){return b.map(y=>y.reduce((O,k,P)=>O+k*j[P],0))}function v(b,j){const y=b.length,O=b.map(se=>se[j]),k=b.map(se=>[1,...se.filter((ce,Oe)=>Oe!==j)]),P=oe(k,O,null);if(!P)return 1;const V=O.reduce((se,ce)=>se+ce,0)/y;let I=0,D=0;for(let se=0;se<y;se++)I+=P.residuals[se]**2,D+=(O[se]-V)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function Z(b){const j=[...b].sort((k,P)=>k-P),y=x(j),O=b.map(k=>Math.abs(k-y)).sort((k,P)=>k-P);return x(O)/.6745}function x(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(!ae.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,P=k&&Array.isArray(b[0])?b[0].length:0,V=P+1;if(!(k>V))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==P)return null;for(let Ne=0;Ne<P;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 se,ce=null;if(O==="robust"){if(se=oe(D,j,null),!se)return null;for(let Me=0;Me<50;Me++){const Ne=Z(se.residuals);if(!(Ne>0))break;const Re=se.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=q?1:q/We}),Ce=oe(D,j,Re);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-se.beta[Je])),0);if(se=Ce,ce=Re,Ve<1e-10)break}}else if(se=oe(D,j,I),!se)return null;const Oe=O==="robust"?ce:I,{beta:ke,cov:je,fitted:be,residuals:Ae}=se;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[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=Oe?Oe[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-V,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===P?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?ne(1-(1-He)/2,De):1/0,Lt=ke.map((Me,Ne)=>{const Re=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Re>0?Me/Re:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-_(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Re:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Re,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=Oe?Oe[Me]:1,Re=Math.max(0,Math.min(1,Ne*Y(D[Me],je)));dt[Me]=Re;const Ce=(1-Re)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(V*qe)*(Re/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(P<2)return 1;const Re=v(b,Ne);return Re>=1?1/0:1/(1-Re)});let gt=null;{const Me=Ae.map(Re=>Re*Re),Ne=oe(D,Me,null);if(Ne){const Re=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]-Re)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=ie(We,P);gt={statistic:We,df:P,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(P===1){const Me=b.map((Ne,Re)=>Re).sort((Ne,Re)=>b[Ne][0]-b[Re][0]);bt={confidence:He,points:Me.map(Ne=>{const Re=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Y(Re,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:Oe?[...Oe]:null}}function we(b){const j=b.length,y=Array.from({length:j},(P,V)=>V).sort((P,V)=>b[P]-b[V]),O=new Float64Array(j);let k=0;for(;k<j;){let P=k;for(;P+1<j&&b[y[P+1]]===b[y[k]];)P++;const V=(k+P)/2+1;for(let I=k;I<=P;I++)O[y[I]]=V;k=P+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const P=(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])+P*(b-y[0]))))}if(b>=y[2]){const P=(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])+P*(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 Te(b,j,y,O){const k=y-O,P=O+3,V=new Array(k),I=new Array(k);let D=!0,se=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(P);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<P;ye++)Number.isFinite(Pe[ye])||(se=Math.min(se,ye-3));V[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:ce,xtwy:Oe}=L(V,I,null);let ke=0,je=1/0;for(let be=0;be<=se;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=ce[Ue].slice(0,Ae);const ye=le(Pe);if(!ye)continue;const ve=ue(ye,Oe.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=V[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,ke=be)}return ke}function Le(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 P=new Array(k);for(let je=0;je<k;je++)P[je]=y[je+1]-y[je];let V=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);V=Math.max(0,Math.min(V,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(P[ye-Fe]);Ae.push(ve),Pe.push(P[ye])}return de(Ae,Pe,{method:"ols"})},D=Te(y,P,k,V),se=I(D,D);if(!se||!se.coefficients[2])return null;const ce=se.coefficients[2].t,Oe=pe(ce),ke=ce<ge["5%"];return{statistic:ce,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:Oe,pApproximate:!0,stationary:ke,verdict:ke?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let ke=0;ke<b.length;ke++){const je=Number(b[ke]);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 P=0;for(const ke of y)P+=ke;P/=O;const V=y.map(ke=>ke-P);let I=0;for(const ke of V)I+=ke*ke;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let ke=1;ke<=k;ke++){let je=0;for(let be=ke;be<O;be++)je+=V[be]*V[be-ke];D[ke]=I>0?je/O/I:0}const se=new Array(k+1).fill(0);se[0]=1;let ce=[];for(let ke=1;ke<=k;ke++){let je=D[ke];for(let ye=1;ye<ke;ye++)je-=ce[ye-1]*D[ke-ye];let be=1;for(let ye=1;ye<ke;ye++)be-=ce[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(ke);for(let ye=1;ye<ke;ye++)Pe[ye-1]=ce[ye-1]-Ae*ce[ke-1-ye];Pe[ke-1]=Ae,se[ke]=Ae,ce=Pe}const Oe=1.96/Math.sqrt(O);return{acf:D,pacf:se,bounds:{upper:Oe,lower:-Oe},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;const V=we(O),I=we(k);let D=0,se=0;for(let je=0;je<P;je++)D+=V[je],se+=I[je];D/=P,se/=P;let ce=0,Oe=0,ke=0;for(let je=0;je<P;je++){const be=V[je]-D,Ae=I[je]-se;ce+=be*Ae,Oe+=be*be,ke+=Ae*Ae}return Oe===0||ke===0?null:Math.max(-1,Math.min(1,ce/Math.sqrt(Oe*ke)))}function Ke(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2||P>A)return null;let V=0,I=0,D=0,se=0;for(let ke=0;ke<P;ke++)for(let je=ke+1;je<P;je++){const be=Math.sign(O[ke]-O[je]),Ae=Math.sign(k[ke]-k[je]),Pe=be*Ae;Pe>0?V++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:se++)}const ce=V+I+se,Oe=V+I+D;return ce===0||Oe===0?null:(V-I)/Math.sqrt(ce*Oe)}function Ee(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],P=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&P.push((b[ye]-ve)/Math.abs(ve))}let V=null;if(P.length>1){let ye=0;for(const Fe of P)ye+=Fe;ye/=P.length;let ve=0;for(const Fe of P)ve+=(Fe-ye)**2;V=Math.sqrt(ve/(P.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],se=0,ce=0,Oe=0,ke=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],se=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>ce&&(ce=ve,Oe=se,ke=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 P)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:V,annualisedVolatility:V!==null&&I?V*Math.sqrt(I):null,growth:Pe,maxDrawdown:ce,maxDrawdownFrom:Oe,maxDrawdownTo:ke,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,P)=>k+P,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 P=0;for(let be=0;be<y;be++)P+=b[be];P/=y;let V=0;for(let be=0;be<y;be++)V+=(b[be]-P)**2;const I=Math.sqrt(V/(y-1)),D=xe(b),se=D?D.sigma:null,ce=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-P)/(3*be):1/0,ve=O!==null?(P-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},Oe=ce(se),ke=ce(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:P,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:se,sigmaOverall:I,cp:Oe.index,cpk:Oe.k,pp:ke.index,ppk:ke.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,P=I=>(b[I]-O)/k,V=[];for(let I=0;I<y;I++){if(Math.abs(P(I))>3&&V.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let se=0;for(let ce=I-2;ce<=I;ce++)P(ce)*D>2&&se++;if(se>=2){V.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let se=0;for(let ce=I-4;ce<=I;ce++)P(ce)*D>1&&se++;if(se>=4){V.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let se=!0;for(let ce=I-7;ce<=I;ce++)if(P(ce)*D<=0){se=!1;break}if(se){V.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return V}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=D=>(b[D]-O)/k,V=(D,se,ce,Oe)=>{for(const ke of[1,-1]){let je=0;for(let be=D;be<=se;be++)P(be)*ke>ce&&je++;if(je>=Oe)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(P(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const se of[1,-1]){let ce=!0;for(let Oe=D-8;Oe<=D;Oe++)if(P(Oe)*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const se of[1,-1]){let ce=!0;for(let Oe=D-4;Oe<=D;Oe++)if((b[Oe]-b[Oe-1])*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:3,description:se>0?"six rising":"six falling"});break}}if(D>=13){let se=!0;for(let ce=D-12;ce<=D;ce++){const Oe=b[ce]-b[ce-1],ke=b[ce+1<=D?ce+1:ce]-b[ce];if(ce+1>D)break;if(Oe===0||ke===0||Oe>0==ke>0){se=!1;break}}se&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&V(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&V(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let se=!0;for(let ce=D-14;ce<=D;ce++)if(Math.abs(P(ce))>=1){se=!1;break}se&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let se=!0;for(let ce=D-7;ce<=D;ce++)if(Math.abs(P(ce))<=1){se=!1;break}se&&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 P=b[0],V=b[k-1];if(V===P)return[{from:P,to:V,count:k}];const I=y-j,D=1.5*I;let se=I>0?Math.max(P,j-D):P,ce=I>0?Math.min(V,y+D):V;ce>se||(se=P,ce=V);const Oe=I>0?2*I/Math.cbrt(k):(ce-se)/(Math.ceil(Math.log2(k))+1),ke=Oe>0?Math.min(O,Math.max(1,Math.ceil((ce-se)/Oe))):1,je=(ce-se)/ke,be=[];for(let Ae=0;Ae<ke;Ae++)be.push({from:se+Ae*je,to:se+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(ke-1,Math.max(0,Math.floor((b[Ae]-se)/je)));be[Pe].count++}return be[0].from=P,be[ke-1].to=V,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 ce=0;ce<y;ce++)O+=b[ce];const k=O/y;let P=0;for(let ce=0;ce<y;ce++){const Oe=b[ce]-k;P+=Oe*Oe}const V=Math.sqrt(P/(y-1)),I=Qe(j),se=ne(1-(1-I)/2,y-1)*V/Math.sqrt(y);return{mean:k,lower:k-se,upper:k+se,margin:se,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 P=Qe(y),V=T(1-(1-P)/2),I=O/k,D=V*V,se=1+D/k,ce=(I+D/(2*k))/se,Oe=V/se*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,ce-Oe),upper:Math.min(1,ce+Oe),n:k,confidence:P}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=ne(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 P=Qe(y),I=T(1-(1-P)/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:P}}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=Q(b);let k=0;for(let P=0;P<j.length;P++){const V=O(j[P]);if(V==null||V===""||typeof V=="number"&&Number.isNaN(V))continue;const I=V instanceof Date?V.getTime():typeof V=="object"?String(V):V;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 P=new Set(b.keys());for(const V of y.keys())P.add(V);for(const V of P){const I=(b.get(V)||0)/j,D=(y.get(V)||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:se}=r(I),ce=D>0?lt({mean:y.mean,sd:y.sd},se):null;return{measure:"standardizedMeanDifference",magnitude:ce,distance:ce===null?0:at(ce),direction:ce===null?0:Math.sign(ce),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:P}=_e(b,j),V=ft(k,P,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:V,distance:V===null?0:V,direction:0,subsetN:P,populationN:y.total||0,reliable:P>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=Q(b);let O=0,k=0;for(let P=0;P<j.length&&O<200;P++){const V=y(j[P]);if(V==null||V==="")continue;if(V instanceof Date)return!1;O++;const I=typeof V=="number"?V:Number(V);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:P,mean:V,m2:I}=r(k);return{numeric:!0,mean:V,sd:P>0?Math.sqrt(I/P):0,n:P}}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 l}}),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,Q=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),ne=z.presenceReader,_=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),ie=K.STAT_FNS,J=K.STAT_LABELS;function le(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ue(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++){const R=N[n[F]];Number.isNaN(R)||(g+=R)}return g}for(let F=0;F<c;F++){const R=n[F];if(G(R)===1){const X=N[R];Number.isNaN(X)||(g+=X)}}return g}const M=T(r);for(let N=0;N<c;N++){const G=u(M(n[N]));G!==null&&(g+=G)}return g}ue.kernel=!0;function W(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++)Number.isNaN(N[n[F]])||g++;return g}for(let F=0;F<c;F++){const R=n[F];G(R)===1&&!Number.isNaN(N[R])&&g++}return g}const M=T(r);for(let N=0;N<c;N++){const G=M(n[N]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}W.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Y(r,n){const c=W(r,n);return c===0?null:ue(r,n)/c}Y.kernel=!0;function ee(r,n,c,g){const M=n.length;if(le(r)){const R=r.values,X=ne(r);let E=null;if(!X){for(let S=0;S<M;S++){const U=R[n[S]];Number.isNaN(U)||(E===null||(c<0?U<E:U>E))&&(E=U)}return E}for(let S=0;S<M;S++){const U=n[S];if(X(U)===0)continue;const H=R[U];Number.isNaN(H)||(E===null||(c<0?H<E:H>E))&&(E=H)}return E}const N=T(r),G=_(g);let F=null;for(let R=0;R<M;R++){const X=N(n[R]);X==null||typeof X=="number"&&Number.isNaN(X)||(F===null||(c<0?G(X,F)<0:G(X,F)>0))&&(F=X)}return F}function C(r,n,c){return ee(r,n,-1,c&&c.locale)}C.kernel=!0;function A(r,n,c){return ee(r,n,1,c&&c.locale)}A.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:ue,min:C,max:A,avg:Y,count:L,first:i,last:s,countValues:W,...ie},l=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"?l[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 c=a.filter(g=>g in f);for(const g of Object.keys(f))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=T(r),g=[];for(let M=0;M<n.length;M++){const N=c(n[M]);N!=null&&g.push(N)}return g}function h(r,n,c,g){const M=n||[];if(typeof c=="string"){const N=f[c];return N?N(r,M,g):(Q(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,M,g):c(d(r,M),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,_=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,ie="|",J="/",le=2e3;function ue(u,f,l){return`${u}${ie}${f}${ie}${l}`}function W(u,f){let l="";for(let t=0;t<u.length;t++){const a=u[t];l+=(t===0?"":f)+(a==null?"":String(a))}return l}function L(u,f,l={}){const t=l.separator||J,a=f.length,{keyOf:m,readers:e}=_(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const R=f[F],X=m(R);if(d.has(X))continue;d.set(X,h.length),r.push(X);const E=new Array(e.length);for(let S=0;S<e.length;S++)E[S]=e[S](R);h.push(E)}const n=z(l.locale),c=h.map((F,R)=>R);c.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=Y(X[S],E[S],n);if(U!==0)return U}return F-R});const g=new Array(c.length),M=new Array(c.length),N=new Map;for(let F=0;F<c.length;F++){const R=c[F];g[F]=h[R],M[F]=W(h[R],t),N.set(r[R],F)}return{keys:g,paths:M,idOf:F=>{const R=N.get(m(F));return R===void 0?-1:R}}}function Y(u,f,l){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:l(u,f)}function ee(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 l=typeof u.handle=="function"?u.handle:null;if(!l)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=l(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,l){if(Array.isArray(u)){const t=l||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function A(u,f,l){const t=C(u,f,l),a=t.separator||J,m=ee(t),e=t.maxColumns===void 0?le: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(X=>W(X,a)):[""]),n=s(h),{keys:c,paths:g,idOf:M}=L(t.pivotHandles||[],n,t),N=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&N>e){const X=new Map;return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${N} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:N,maxColumns:e}}}const F=new Map,R=g.length;for(let X=0;X<h.length;X++){const E=h[X],S=r[X]===void 0?"":r[X],U=E.length;if(U===0)continue;const H=new Int32Array(U),$=new Uint32Array(R+1);for(let ae=0;ae<U;ae++){const p=M(E[ae]);H[ae]=p,p>=0&&$[p+1]++}for(let ae=0;ae<R;ae++)$[ae+1]+=$[ae];const re=new Uint32Array(U),te=$.slice(0,R);for(let ae=0;ae<U;ae++){const p=H[ae];p>=0&&(re[te[p]++]=E[ae])}for(let ae=0;ae<R;ae++){const p=$[ae],B=$[ae+1];if(B===p)continue;const q=re.subarray(p,B);for(let oe=0;oe<m.length;oe++){const w=m[oe],v=K(w.handle,q,w.fn,t.totalContext||{locale:t.locale});F.set(ue(S,g[ae],w.colId),v)}}}return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:F,cells:F,error:null}}function i(u,f,l){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${l}${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 l=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(l.set(a,t),t+=a.length);return l}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,_=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,ie=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,le="";function ue(i,s,u={}){const f=u.separator||ie,l=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(l.length===0)return{tuples:[[]],paths:[le],buckets:[t]};const{keyOf:m,readers:e}=_(l,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const R=t[F],X=m(R);let E=d.get(X);if(E===void 0){E=h.length,d.set(X,E),r.push(X);const S=new Array(e.length);for(let U=0;U<e.length;U++)S[U]=e[U](R);h.push(S),n.push([])}n[E].push(R)}const c=he(u.locale),g=h.map((F,R)=>R);g.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=W(X[S],E[S],c);if(U!==0)return U}return F-R});const M=new Array(g.length),N=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const R=g[F];M[F]=h[R],N[F]=K(h[R],f),G[F]=Uint32Array.from(n[R])}return{tuples:M,paths:N,buckets:G}}function W(i,s,u){const f=i==null,l=s==null;return f||l?f&&l?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let l=0;l<i.length;l++)u.has(i[l])&&f.push(i[l]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ie,f=s.totalContext||{locale:s.locale},l=(i.measures||[]).filter(N=>N&&N.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ue(i.rowHandles||[],t,{...s,separator:u}),m=ue(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,l.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.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,c=new Map,g=new Map,M=m.buckets.map(N=>new Set(N));for(let N=0;N<m.paths.length;N++){const G=m.buckets[N],F=m.paths[N];for(const R of l)c.set(A(F,R.colId),Y(R.handle,G,R.fn,f))}for(let N=0;N<a.paths.length;N++){const G=a.buckets[N],F=a.paths[N];for(const R of l)n.set(A(F,R.colId),Y(R.handle,G,R.fn,f));for(let R=0;R<m.paths.length;R++){const X=L(G,m.buckets[R],M[R]);if(X.length===0)continue;const E=m.paths[R];for(const S of l)r.set(C(F,E,S.colId),Y(S.handle,X,S.fn,f))}}for(const N of l)g.set(N.colId,Y(N.handle,t,N.fn,f));return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function A(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 le}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const he=me("packages/core/src/internal/util.js").getPath,Q=me("packages/core/src/compute/handle.js"),z=Q.isMissing,ne=Q.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",ie="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function le(i,s,u={}){const f=s||[];let l=i.map((t,a)=>a);if(f.length===0)return l;for(let t=f.length-1;t>=0;t--)l=ue(i,l,f[t],u);return l}function ue(i,s,u,f){const l=u.locale!==void 0?u.locale:f.locale,t=ne(l),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 c=J(i[r],u.col),g=J(i[n],u.col);let M;return typeof u.compare=="function"?(M=u.compare(c,g,i[r],i[n],a),a&&(M=-M)):M=a?t(g,c):t(c,g),M!==0?M:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function W(i,s,u={}){const f=[];for(let l=0;l<i.length;l++)L(i[l],s,u,l)&&f.push(l);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const l=s.conditions.filter(a=>a!=null);if(l.length===0)return!0;if(s.op==="or")return l.some(a=>L(i,a,u,f));const t=l.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 Y(i,s,u,f){const l=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of l){const d=s.map((n,c)=>{const g=J(i[e],n);return f&&f[c]?f[c](g):g}),h=d.map(n=>n==null?ie: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 ee(i,s,u={}){const f=ne(u.locale),l=i.filter(a=>!z(a)),t=l.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return l.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return l.length===0?null:t.reduce((a,m)=>a+m,0)/l.length;case"min":return l.length===0?null:l.reduce((a,m)=>f(m,a)<0?m:a);case"max":return l.length===0?null:l.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:A(i[0]);case"last":return i.length===0?null:A(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 A(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 Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(K,ie=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(ie>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(ie),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,ie=this.#r()){Number.isFinite(K)&&(this.#n.push({t:ie,v:K}),this.#s(ie))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ie=K-this.#e;for(;this.#n.length&&this.#n[0].t<ie;)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 ie=new he;let J=0,le=1/0,ue=-1/0;for(const{v:W}of this.#n)J+=W,W<le&&(le=W),W>ue&&(ue=W),ie.add(W);return{over:K,count:this.#n.length,sum:J,mean:ie.mean(),min:le,max:ue,variance:ie.variance(),stddev:ie.stddev()}}reduce(K){const ie=this.aggregate(),J={sum:ie.sum,avg:ie.mean,mean:ie.mean,min:ie.min,max:ie.max,count:ie.count,variance:ie.variance,stddev:ie.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:ie.over}}}const z=Object.freeze(["count","time","session"]);function ne(T,K=Date.now){const ie=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new Q(T.kind,ie,K)}const _={Window:Q,WINDOW_KINDS:z,openWindow:ne}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),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 ie}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return A}}),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,ne=.6745,_=3.5,T=1.5,K=.975,ie=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(l){if(!l.length)return null;const a=Array.from(l,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 le(l,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,m=l.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let c=0;c<m;c++){const g=Number(l[c]);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 c=0;c<m;c++){const g=Number(l[c]);if(!Number.isFinite(g))continue;const M=ne*(g-r.median)/r.mad;e[c]=M,Math.abs(M)>a&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function ue(l,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<l.length;n++){const c=Number(l[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),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 W(l,t){if(t<=0)return 0;const a=z(l);if(t<l+1){let c=l,g=1/l,M=g;for(let N=0;N<1e3&&(c+=1,M*=t/c,g+=M,!(Math.abs(M)<Math.abs(g)*1e-15));N++);return g*Math.exp(-t+l*Math.log(t)-a)}const m=1e-300;let e=t+1-l,d=1/m,h=1/e,r=h;for(let c=1;c<1e3;c++){const g=-c*(c-l);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 M=h*d;if(r*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-t+l*Math.log(t)-a)*r}function L(l,t){return l<=0?0:W(t/2,l/2)}function Y(l,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,l);for(;L(m,l)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,l)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function ee(l){const t=l.length,a=l.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(l,t){const a=l.length,m=new Array(t).fill(0);for(const h of l)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 l)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(h[c]-m[c])}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 A(l,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=l.length;if(!e)return null;const d=l[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),c=[],g=[];for(let S=0;S<e;S++){const U=l[S];let H=U.length===d;const $=new Array(d);for(let re=0;H&&re<d;re++){const te=Number(U[re]);Number.isFinite(te)?$[re]=te:H=!1}H&&(c.push(S),g.push($))}const M=d,N=Y(M,a);if(g.length<=d)return{center:[],df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let R=ee(F),X=!1;if(!R){X=!0;let S=0;for(let $=0;$<d;$++)S+=F[$][$];const U=S/d*m||m,H=F.map(($,re)=>$.map((te,ae)=>re===ae?te+U:te));if(R=ee(H),!R)return{center:G,df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let E=0;for(let S=0;S<g.length;S++){const U=g[S],H=new Array(d);for(let te=0;te<d;te++)H[te]=U[te]-G[te];let $=0;for(let te=0;te<d;te++){let ae=0;for(let p=0;p<d;p++)ae+=R[te][p]*H[p];$+=H[te]*ae}$<0&&($=0);const re=c[S];r[re]=$,h[re]=Math.sqrt($),$>N&&(n[re]=!0,E++)}return{center:G,df:M,cutoff:N,singular:X,used:g.length,distances:h,squared:r,flags:n,flagged:E}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(l,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:_,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=l.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let M=0;M<r;M++){const N=Number(l[M]);if(!Number.isFinite(N))continue;const G=Math.max(0,M-m+1),F=[];for(let R=G;R<=M;R++){const X=Number(l[R]);Number.isFinite(X)&&F.push(X)}if(!(F.length<h))if(a==="rollingIqr"){const R=ue(F,{k:d});if(!R)continue;(N<R.lower||N>R.upper)&&(c[M]=!0,g++)}else{const R=J(F);if(!R||R.mad===0)continue;const X=ne*(N-R.median)/R.mad;n[M]=X,Math.abs(X)>e&&(c[M]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:c,flagged:g}}function f(l={}){const t=l||{},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(!(ie.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=c=>Number(c==null?NaN:c[a]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((R,X)=>{const E=R?.[d],S=X?.[d];return E===S?0:E==null?-1:S==null?1:E<S?-1:1});const M=g.map(n);let N,G;if(r)({flags:N,scores:G}=u(M,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const R=ue(M,{k:t.k});N=M.map(X=>R?Number.isFinite(X)&&(X<R.lower||X>R.upper):!1),G=M.map(()=>null)}else({flags:N,scores:G}=le(M,{threshold:t.threshold}));if(h){const R=N.length-1;return R<0||!N[R]?!1:{method:m,field:a,flagged:[{row:g[R],score:G[R]}]}}const F=[];for(let R=0;R<N.length;R++)N[R]&&F.push({row:g[R],score:G[R]});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 _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return l}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,Q=fe.studentTQuantile,ne=me("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function ie(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 le(t){return Math.min(K,Math.max(T,t))}function ue(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),c=h+d*(r-h),g=t(n),M=t(c);for(let N=0;N<e;N++)g<M?(r=c,c=n,M=g,n=r-d*(r-h),g=t(n)):(h=n,n=c,g=M,c=h+d*(r-h),M=t(c));return(h+r)/2}function W(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 c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;h+=(c-g)**2,r+=1;const M=e;e=a*c+(1-a)*(M+d),d=m*(e-M)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Y(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=X=>{let E=0,S=0;for(let U=X;U<X+a&&U<h;U++)t[U]!==null&&(E+=t[U],S+=1);return S?E/S:null},n=r(0),c=r(a);if(n===null||c===null)return null;let g=n,M=(c-n)/a;const N=new Array(a).fill(0);for(let X=0;X<a;X++)N[X]=t[X]===null?0:t[X]-g;const G=N.reduce((X,E)=>X+E,0)/a;for(let X=0;X<a;X++)N[X]-=G;let F=0,R=0;for(let X=a;X<h;X++){const E=X%a,S=N[E],U=t[X];if(U===null){g+=M;continue}const H=g+M+S;F+=(U-H)**2,R+=1;const $=g;g=m*(U-S)+(1-m)*(g+M),M=e*(g-$)+(1-e)*M,N[E]=d*(U-g)+(1-d)*S}return{level:g,trend:M,season:N,phase:(h-1)%a,sse:F,count:R}}function ee(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=_.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=ie(t),n=r.map(F=>F.value),c=n.filter(F=>F!==null),g=c.length,{lastAt:M,step:N}=g?J(r):{lastAt:0,step:1},G=F=>M+F*N;return m==="linear"?A(r,g,e,d,h,G):m==="movingAverage"?i(c,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 A(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 c=0,g=0,M=0;for(const U of t){if(U.value===null)continue;const H=U.at-r,$=U.value-n;c+=H*H,g+=H*$,M+=$*$}if(c===0)return null;const N=g/c,G=n-N*r,F=M===0?1:Math.max(0,Math.min(1,g*g/(c*M))),R=Math.max(0,M-N*g),X=a>2?Math.sqrt(R/(a-2)):null,E=a>2?Q(d,a-2):null,S=[];for(let U=1;U<=m;U++){const H=h(U),$=G+N*H;let re=null,te=null,ae=null,p=null,B=null;if(X!==null){const q=1/a+(H-r)**2/c,oe=X*Math.sqrt(1+q),w=X*Math.sqrt(q);B=oe,re=$-E*oe,te=$+E*oe,ae=$-E*w,p=$+E*w}S.push({step:U,at:H,mean:$,lower:re,upper:te,lowerMean:ae,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:X,r2:F,params:{slope:N,intercept:G},points:S}}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))),c=t.slice(a-n);let g=0;for(const X of c)g+=X;const M=g/n;let N=null,G=null;if(n>1){let X=0;for(const S of c)X+=(S-M)**2;N=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),G=Q(d,n-1)}const F=N===null?null:G*N,R=[];for(let X=1;X<=m;X++)R.push({step:X,at:r(X),mean:M,lower:F===null?null:M-F,upper:F===null?null:M+F,se:N});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:N===null?null:N,params:{windowLen:n},points:R}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null;n===null&&(n=ue(G=>W(t,G).sse));const c=W(t,n),g=he(d),M=c.m>0?c.sse/c.m:null,N=[];for(let G=1;G<=m;G++){const F=c.level;let R=null,X=null,E=null;if(M!==null){const S=[];for(let H=1;H<G;H++)S.push(n);const U=ee(M,S,g);E=U.se,R=F-U.margin,X=F+U.margin}N.push({step:G,at:r(G),mean:F,lower:R,upper:X,se:E})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:M===null?null:Math.sqrt(M),params:{alpha:n},points:N}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null,c=Number.isFinite(h.beta)?le(h.beta):null;if(n===null||c===null){let R=n===null?.5:n,X=c===null?.5:c;for(let E=0;E<6;E++)n===null&&(R=ue(S=>L(t,S,X).sse)),c===null&&(X=ue(S=>L(t,R,S).sse));n=n===null?R:n,c=c===null?X:c}const g=L(t,n,c),M=he(d),N=g.m>0?g.sse/g.m:null,G=n*c,F=[];for(let R=1;R<=m;R++){const X=g.level+R*g.trend;let E=null,S=null,U=null;if(N!==null){const H=[];for(let re=1;re<R;re++)H.push(n+re*G);const $=ee(N,H,M);U=$.se,E=X-$.margin,S=X+$.margin}F.push({step:R,at:r(R),mean:X,lower:E,upper:S,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:N===null?null:Math.sqrt(N),params:{alpha:n,beta:c},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return ne("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let c=Number.isFinite(h.alpha)?le(h.alpha):null,g=Number.isFinite(h.beta)?le(h.beta):null,M=Number.isFinite(h.gamma)?le(h.gamma):null;const N=(U,H,$)=>{const re=Y(t,n,U,H,$);return re?re.sse:1/0};if(c===null||g===null||M===null){let U=c===null?.5:c,H=g===null?.5:g,$=M===null?.5:M;for(let re=0;re<8;re++)c===null&&(U=ue(te=>N(te,H,$))),g===null&&(H=ue(te=>N(U,te,$))),M===null&&($=ue(te=>N(U,H,te)));c=c===null?U:c,g=g===null?H:g,M=M===null?$:M}const G=Y(t,n,c,g,M);if(!G)return null;const F=he(d),R=G.count>0?G.sse/G.count:null,X=c*g,E=M*(1-c),S=[];for(let U=1;U<=m;U++){const H=G.season[(G.phase+U)%n],$=G.level+U*G.trend+H;let re=null,te=null,ae=null;if(R!==null){const p=[];for(let q=1;q<U;q++)p.push(c+q*X+(q%n===0?E:0));const B=ee(R,p,F);ae=B.se,re=$-B.margin,te=$+B.margin}S.push({step:U,at:r(U),mean:$,lower:re,upper:te,se:ae})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:R===null?null:Math.sqrt(R),params:{alpha:c,beta:g,gamma:M,period:n},points:S}}const l={FORECAST_METHODS:_,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 Q=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const 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 ne=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return ne.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return ne.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return ne.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return ne.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ne.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return ne.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return ne.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return ne.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return ne.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return ne.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return ne.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return ne.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return ne.QUANTILE_SAMPLE}});const _=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const 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 ie=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ie.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ie.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ie.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ie.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ie.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ie.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 le=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return le.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return le.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return le.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return le.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return le.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le.SKETCH_BOUNDS}});const ue=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ue.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ue.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ue.openWindow}});const W=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return W.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return W.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return W.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 Y=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),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,Q=fe.OPS,z=fe.CONTROL,ne=fe.ERRORS,_=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,ie=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),le=J.packChunk,ue=J.packedTransfers;let W=null,L=null,Y=null;async function ee(f){if(W)return W;if(!L){const l=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(l).then(t=>(W=t,t)).catch(t=>(Y=t,W=null,null))}return L}function C(f){W=f,L=f?Promise.resolve(f):null,Y=f?null:Y}function A(f,l,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:l,pool:K(),locale:t}}function i(f,l){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return le(a.schema||[],a.rows||[],a.opts||{});const m=l[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=ne.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return m(_(a.handle),a.order??null,a.opts||{});case Q.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 Q.EVALUATE_FILTERS:return m(a.filters,A(T(a.handles||[]),a.count,a.locale));case Q.COMPACT:return m(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return m(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return m(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=ne.PROTOCOL,e}}}async function s(f,l={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return l.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(l.cancelled?.has(t))return l.cancelled.delete(t),null;try{const e=le(f.args.schema||[],f.args.rows||[],f.args.opts||{});return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ue(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ee(l.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:ne.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(l.cancelled?.has(t))return l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,l={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:l.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(l.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{}var Fn=Ln("packages/modules/htmx/index.js");typeof module=="object"&&module.exports?module.exports=Fn:typeof define=="function"&&define.amd?define(function(){return Fn}):hr.LatticeGridHtmx=Fn})(typeof globalThis<"u"?globalThis:this);
|
|
57
|
+
`)||(i.preventDefault(),this.fromText(g))})))}openFile(){const c=O(this.#n,"input",{attrs:{type:"file",accept:r}});c.style.display="none",this.#o.push(u(c,"change",()=>{const i=c.files&&c.files[0];i&&this.#c(i),c.parentNode&&c.parentNode.removeChild(c)})),this.#n.body.appendChild(c),c.click()}#c(c){if(L(c.arrayBuffer)){c.arrayBuffer().then(g=>{const d=new Uint8Array(g);if(D(d)){this.fromXlsx(d,c.name);return}this.fromText(new TextDecoder().decode(d),c.name)});return}if(L(c.text)){c.text().then(g=>this.fromText(g,c.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),c.name),i.readAsText(c)}async fromXlsx(c,i){const{header:g,rows:d}=await K(c);if(!g.length)return;const h=H(g,d,{columns:this.#e.columns.all()}),l=d.filter(m=>m.length!==g.length).length;this.#l={rows:d,columns:h,delimiter:null,name:i,warnings:l?[`${l} row(s) do not have ${g.length} columns`]:[]},this.#d()}fromText(c,i){const{header:g,rows:d,delimiter:h}=X(c);if(!g.length)return;const l=H(g,d,{columns:this.#e.columns.all()}),m=d.filter(w=>w.length!==g.length).length;this.#l={rows:d,columns:l,delimiter:h,name:i,warnings:m?[`${m} row(s) do not have ${g.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const c=this.#i.querySelector(t);c&&L(c.focus)&&c.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(c,i){const g=this.#t&&this.#t.announce;L(g)&&g.call(this.#t,c,i)}#h(c,i){return(this.#e&&this.#e.messages?this.#e.messages:F).t(c,i)}#p(){const c=this.#n,i=O(c,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),g=O(c,"div",{class:`${n}__panel`});g.appendChild(O(c,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=O(c,"div",{class:`${n}__body`}),g.appendChild(this.#s);const d=O(c,"div",{class:`${n}__footer`}),h=O(c,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),l=O(c,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(u(h,"click",()=>this.close())),this.#o.push(u(l,"click",()=>this.#g())),d.appendChild(h),d.appendChild(l),g.appendChild(d),i.appendChild(g),this.#o.push(u(i,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const k=[...i.querySelectorAll(t)].filter(E=>!E.hidden);if(!k.length)return;const p=k[0],b=k[k.length-1];w.shiftKey&&this.#n.activeElement===p?(w.preventDefault(),b.focus()):!w.shiftKey&&this.#n.activeElement===b&&(w.preventDefault(),p.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const c=this.#n,i=y(this.#s),{rows:g,columns:d,name:h,warnings:l}=this.#l;i.appendChild(O(c,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:g.length,name:h||this.#h("import.clipboard")})}));for(const E of l)i.appendChild(O(c,"p",{class:`${n}__warning`,text:E}));const m=this.#e.columns.all().map(E=>E.field||E.id).filter(Boolean),w=O(c,"table",{class:`${n}__map`}),k=O(c,"tr",{});for(const E of["import.colSource","import.colField","import.colType"])k.appendChild(O(c,"th",{text:this.#h(E)}));w.appendChild(k),d.forEach((E,T)=>{const P=O(c,"tr",{});P.appendChild(O(c,"td",{text:E.source}));const x=O(c,"select",{attrs:{"data-col":String(T),"aria-label":this.#h("import.mapLabel",{source:E.source})}});x.appendChild(O(c,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const A of m)x.appendChild(O(c,"option",{text:A,attrs:{value:A,selected:A===E.field?!0:null}}));E.field&&!m.includes(E.field)&&x.appendChild(O(c,"option",{text:E.field,attrs:{value:E.field,selected:!0}}));const C=O(c,"td",{});C.appendChild(x),P.appendChild(C),P.appendChild(O(c,"td",{class:`${n}__type`,text:E.type})),w.appendChild(P)}),i.appendChild(w);const p=O(c,"div",{class:`${n}__mode`}),b=O(c,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});b.appendChild(O(c,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),b.appendChild(O(c,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),p.appendChild(O(c,"label",{text:this.#h("import.modeLabel")})),p.appendChild(b),i.appendChild(p)}#g(){const{rows:c,columns:i}=this.#l;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));i[w]&&m.value!==void 0&&m.value!==null&&(i[w].field=m.value)}const g=this.#i.querySelector("select[data-mode]"),d=g?g.value:void 0,h=d==="replace"||d==="append"?d:this.#r.mode,l=V(c,i);this.#e.import.apply(l,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:l.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&L(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const c of this.#o)c();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),xe("packages/dom/src/historybar.js",function(e,G){"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 O}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),X=W.el,H=W.on,V=W.clear,K=W.documentFor,D="lat-history";class v{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,a){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(u,a)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||F;const a=u||{};if(this.doc=K(a),this.host=a.host||{},this.props=a.props||{},this.root=X(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 s=X(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(s,"click",()=>this.toggle())),this.root.appendChild(s),this.toggleButton=s,this.menu=X(this.doc,"div",{class:`${D}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,a,s){const n=X(this.doc,"button",{class:`${D}__${u}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${D}__glyph`,text:s,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${D}__label`,text:a})]});return this.off.push(H(n,"click",()=>{const t=this.host[u];L(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,a=L(u.canUndo)?u.canUndo():!1,s=L(u.canRedo)?u.canRedo():!1,n=L(u.peek)?u.peek("undo"):null,t=L(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",a,n),this.#t(this.redoButton,"redo",s,t),this.open&&this.#n()}#t(u,a,s,n){if(!u)return;u.disabled=!s;const t=a==="undo",r=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${D}__label`);o&&(o.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;u.setAttribute("title",s?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",s?f:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;V(u);const a=L(this.host.list)?this.host.list():[];if(!a.length){u.appendChild(X(this.doc,"p",{class:`${D}__empty`,text:this.t("history.empty")}));return}a.forEach((s,n)=>{const t=X(this.doc,"button",{class:`${D}__item`,attrs:{type:"button",role:"menuitem","data-type":s.type,"data-undone":s.undone?"true":null},children:[X(this.doc,"span",{class:`${D}__kind`,text:s.type}),X(this.doc,"span",{class:`${D}__text`,text:s.label||s.type})]});this.off.push(H(t,"click",()=>{const r=n+1;for(let o=0;o<r;o++)L(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&L(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const O=v}),xe("packages/dom/src/diffpaint.js",function(e,G){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",V="lat-cell--added-column";class K{#e;#t;#n=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){for(const y of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(y,()=>this.paint()));this.paint()}paint(){const y=this.#t.viewport.root;if(!y||!y.querySelectorAll)return;const u=this.#e.diff,a=u&&u.enabled;for(const s of y.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key"),t=a?u.statusOf(n):"unchanged";for(const o of Object.values(X))s.classList.remove(o);a&&X[t]&&s.classList.add(X[t]),s.setAttribute("data-diff",a?t:"");const r=a&&t==="changed";for(const o of s.querySelectorAll("[data-col]")){const f=o.getAttribute("data-col");if(o.classList.remove(H,V),o.removeAttribute("data-before"),!r)continue;const c=u.cellStatus(n,f);if(c==="changed"){o.classList.add(H);const i=this.#r(u,n,f);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else c==="added-column"&&o.classList.add(V)}}}#r(y,u,a){const s=this.#e,n=s&&s.columns,t=n&&L(n.get)?n.get(a):null,r=s&&s.permissions;if(t&&r&&L(r.isSecret)&&r.isSecret(t))return null;const o=y.before(u,a);if(o==null)return this.#o("diff.empty");if(!t||!L(t.formatValue))return String(o);const f=L(y.beforeRow)?y.beforeRow(u):void 0,i={...(s.rows&&L(s.rows.byKey)?s.rows.byKey(u):null)||{},data:f===void 0?{}:f};try{const g=t.formatValue(o,i,i.data);return g==null?"":String(g)}catch(g){return B(`diff-before-format:${a}`,`the formatter for column "${a}" threw while formatting a previous value, so the diff hover shows the raw one.`,g),String(o)}}#o(y,u){const a=this.#e;return(a&&a.messages?a.messages:W).t(y,u)}destroy(){for(const u of this.#n)u();this.#n=[];const y=this.#t.viewport.root;if(!(!y||!y.querySelectorAll)){for(const u of y.querySelectorAll("[data-key]")){for(const a of Object.values(X))u.classList.remove(a);u.removeAttribute("data-diff")}for(const u of y.querySelectorAll("[data-col]"))u.classList.remove(H,V),u.removeAttribute("data-before")}}}function D(O){return!!(O&&O.diff&&(L(O.diff)||typeof O.diff=="object"))}const v=K}),xe("packages/dom/src/highlightpaint.js",function(e,G){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",F="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const V=()=>{this.#o=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):L(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const K=this.#l();if(K){K.sweep();for(const D of V.querySelectorAll("[data-key]")){const v=D.getAttribute("data-key");for(const O of D.querySelectorAll("[data-col]")){const y=K.active?K.colourFor(v,O.getAttribute("data-col")):null;y?(O.classList.add(B),O.style.setProperty(F,y)):O.classList.contains(B)&&(O.classList.remove(B),O.style.removeProperty(F))}}this.#s(K)}}#s(V){this.#r!==null&&L(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const K=V.nextExpiry;if(!Number.isFinite(K)||!L(this.#i.setTimeout))return;const D=Math.max(0,K-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},D)}#l(){const V=this.#e.highlight;return V&&L(V.model)?V.model():null}destroy(){this.#r!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const K of this.#n)K();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const K of V.querySelectorAll(`.${B}`))K.classList.remove(B),K.style.removeProperty(F)}}const X=W}),xe("packages/dom/src/findpaint.js",function(e,G){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",F="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const V=()=>{this.#r=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):L(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const K=this.#e.find;if(!K||!L(K.stateFor))return;const D=L(K.model)?K.model():null,v=!!D&&D.active;if(!v&&!this.#o)return;let O=!1;for(const y of V.querySelectorAll("[data-key]")){const u=y.getAttribute("data-key");for(const a of y.querySelectorAll("[data-col]")){const s=v?K.stateFor(u,a.getAttribute("data-col")):null;s?(O=!0,a.classList.add(B),a.classList.toggle(F,s==="current")):a.classList.contains(B)&&a.classList.remove(B,F)}}this.#o=O}destroy(){for(const K of this.#n)K();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll)){for(const K of V.querySelectorAll(`.${B}`))K.classList.remove(B,F);this.#o=!1}}}const X=W}),xe("packages/dom/src/findbar.js",function(e,G){"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 u}});const Q=G("packages/dom/src/editors/common.js"),L=Q.el,B=Q.on,W=G("packages/dom/src/renderer/textentry.js").isTextEntry,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/core/src/internal/util.js").isFunction,D="lat-find",v=12,O=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!1;#p=!1;#m=null;#g=[];#y=null;#w=null;#k=!1;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#n=s.document||s.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=s.settings&&typeof s.settings=="object"?s.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(s,n){const t=this.#e;return(t&&t.messages&&K(t.messages.t)?t.messages:H).t(s,n)}mount(){const s=this.#O();if(!s)return;s.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),s.attachDriver({run:()=>this.#E()});const n=this.#t.viewport?.root;if(n&&K(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const o=r.target;if(this.#s&&o===this.#s){r.preventDefault(),r.stopPropagation(),K(this.#s.select)&&this.#s.select();return}W(o)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#P())),this.#g.push(this.#e.on("column:visible",()=>this.#P()))}show(s){const n=this.#j();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#b(),this.#O().setOpen(!0),s!=null&&(this.#s.value=String(s),this.#M()),this.#s.focus(),K(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#z();const s=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#b()),s&&(s.clear(),s.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&K(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(K(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;K(o.focus)&&o.focus()}search(){this.#M()}destroy(){this.#k=!0,this.#z();for(const n of this.#g)n();this.#g=[];const s=this.#O();s&&(s.attachUi(null),s.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#b(){const s=this.#t;s&&K(s.invalidate)&&s.invalidate("size")}#O(){const s=this.#e&&this.#e.find;return s&&K(s.model)?s.model():null}#j(){if(this.#i)return this.#i;const s=this.#t.viewport,n=s?.root,t=this.#n;if(!n||!t||!K(n.insertBefore))return null;const r=L(t,"div",{class:D,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=L(t,"input",{class:`${D}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=L(t,"span",{class:`${D}__count`,attrs:{"aria-hidden":"true"}}),this.#a=L(t,"span",{class:`${D}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=L(t,"span",{class:`${D}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=L(t,"button",{class:`${D}__nav ${D}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=L(t,"button",{class:`${D}__nav ${D}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=L(t,"button",{class:`${D}__toggle ${D}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=L(t,"button",{class:`${D}__toggle ${D}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=L(t,"select",{class:`${D}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const c=L(t,"button",{class:`${D}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=L(t,"div",{class:`${D}__options`,children:[this.#c,this.#d,this.#f]});for(const d of[this.#s,this.#l,this.#a,this.#u,o,f,c,i])r.appendChild(d);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),this.#M()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#M()})),this.#g.push(B(this.#f,"change",()=>{const d=this.#f.value;this.#m=d?String(d):null,this.#M()})),this.#g.push(B(c,"click",()=>this.hide()));const g=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),this.hide();return}d.key==="Enter"&&d.target===this.#s&&(d.preventDefault(),d.stopPropagation(),this.#y!==null&&(this.#x(),this.#M()),d.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",g),this.#g.push(()=>r.removeEventListener("keydown",g)),r.style.display="none",n.insertBefore(r,s.header||n.firstChild),this.#i=r,this.#P(),r}#P(){const s=this.#f;if(!s)return;const n=this.#n;for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(L(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&K(t.visible)?t.visible():[];let o=!1;for(const f of r){if(!f||f.id===void 0)continue;const c=String(f.id);s.appendChild(L(n,"option",{text:f.title||c,attrs:{value:c}})),c===this.#m&&(o=!0)}o||(this.#m=null),s.value=this.#m||""}#S(){const s=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):O;if(this.#x(),s===0||!K(this.#r.setTimeout)){this.#M();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#M()},s)}#M(){const s=this.#O();if(!s||this.#k)return;const n=this.#s?this.#s.value:"";if(!n){this.#I(),s.clear();return}s.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#A()}),this.#E()}#A(){const s=this.#t&&this.#t.window,n=s&&Number.isFinite(s.first)?s.first:0;return Math.max(0,n)}#E(){if(this.#w!==null||this.#k)return;const s=()=>{this.#w=null,this.#R()};K(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(s):K(this.#r.setTimeout)?this.#w=this.#r.setTimeout(s,0):s()}#R(){const s=this.#O();!s||this.#k||!s.active||(s.stale&&s.rescan({from:this.#A()}),!s.complete&&(s.step(v)||this.#E()))}#L(){if(!this.#i||this.#k)return;const s=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(s.total===0?(t=s.complete?this.t("find.none"):this.t("find.searching"),r=s.complete?"none":"searching"):(t=this.t(s.complete?"find.count":"find.countPartial",{current:s.current,total:s.total}),r=s.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const o=n&&s.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",n?s.complete&&(this.#u.textContent=s.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:s.current,count:s.total})):this.#u.textContent=""}#x(){this.#y!==null&&K(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#I(){this.#w!==null&&(K(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):K(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#z(){this.#x(),this.#I()}}const u=y}),xe("packages/dom/src/redactpaint.js",function(e,G){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q="lat-cell--redacted",L="lat-cell";class B{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const H=this.#e.redaction;if(!H)return;const V=H.active;for(const K of X.querySelectorAll(`.${L}[data-col]`))V&&H.has(K.getAttribute("data-col"))?K.classList.add(Q):K.classList.contains(Q)&&K.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const F=B}),xe("packages/dom/src/validationpaint.js",function(e,G){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const L=G("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function F(H,V){let K=H;for(;K;){if(V(K))return K;K=K.parentNode}return null}class W{#e;#t;#n=[];constructor(V){this.#e=V.grid,this.#t=V.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const V of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(V,()=>this.paint()));this.paint()}#r(V){const K=F(V,D=>D.getAttribute&&D.getAttribute("data-key")!==null);return K?K.getAttribute("data-key"):null}paint(){const V=this.#e.validation;if(!V||!V.active)return;const K=this.#t.viewport?.root;if(!(!K||!K.querySelectorAll))for(const D of K.querySelectorAll(`.${B}[data-col]`)){const v=D.getAttribute("data-col"),O=this.#r(D),y=O?V.errorFor(O,v):null;L(D,y?y.message:null)}}destroy(){for(const V of this.#n)V();this.#n=[]}}const X=W}),xe("packages/dom/src/presentation.js",function(e,G){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/dom/src/renderer/textentry.js").isTextEntry,X=G("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",V="lat-presenting--changing",K="lat-presenting__progress",D="lat-cell--dimmed",v=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class O{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),this.#r.push(this.#e.on("presentation:view",s=>this.#a(s))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&L(this.#n.watch)&&this.#r.push(this.#n.watch(s=>{s||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const a=this.#t.viewport?.root;if(a&&L(a.addEventListener)){const s=n=>this.#l(n);a.addEventListener("keydown",s),this.#r.push(()=>a.removeEventListener("keydown",s))}}#l(a){const s=this.#e.presentation;if(!s?.active)return;const n=a.ctrlKey||a.metaKey,t=a.key;if(t==="Escape"&&!this.#n){a.defaultPrevented||(s.stop(),a.preventDefault?.());return}if(n){t==="="||t==="+"?(s.nudge(1),a.preventDefault?.()):t==="-"||t==="_"?(s.nudge(-1),a.preventDefault?.()):t==="0"&&(s.setScale(1.5),a.preventDefault?.());return}if(!s.views.length||F(a.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(s.step(1),a.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(s.step(-1),a.preventDefault?.()):t==="Home"?(s.goTo(0),a.preventDefault?.()):t==="End"?(s.goTo(s.views.length-1),a.preventDefault?.()):(t==="r"||t==="R")&&(s.reset(),a.preventDefault?.())}#a(a){!a||!a.viewId||(this.#u(),this.#e.views?.apply?.(a.viewId),this.#c(a))}#u(){const a=this.#t.viewport?.root;a?.classList&&(a.classList.remove(V),a.offsetWidth,a.classList.add(V))}#c(a){const s=this.#t.viewport?.overlays;if(!s||!this.#e.presentation.views.length)return;const n=s.ownerDocument;if(!n?.createElement)return;if(!this.#i){const o=n.createElement("div");o.className=K,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),s.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(a.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(a.index||0)+1} / ${a.count||0}`:`${(a.index||0)+1} / ${a.count||0}`}#d(){if(this.#o){this.#h();return}const a=!!(this.#n&&this.#n.active());this.#n&&!a&&this.#n.enter();const s=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of v){if(s.has(r)||r==="toolPanel"&&this.#k())continue;const o=this.#b(r);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",n.push(o))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:a,hidden:n},this.#t.viewport?.root?.classList?.add(H),this.#h(),this.#m()}#f(){const a=this.#o;this.#o=null;const s=this.#t.viewport?.root;if(s?.classList?.remove(H),s?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),s?.classList?.remove(V),this.#p(),a){const n=this.#e.toolPanel;n&&L(n.presentRestore)&&n.presentRestore();for(const t of a.hidden)t.style.display="";this.#n&&!a.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const a=this.#t.viewport?.root;!a||!a.style||(a.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const a=this.#t.viewport?.root;if(!a?.querySelectorAll)return;const s=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=s&&s.keys.length?new Set(s.keys):null,t=s&&s.colIds.length?new Set(s.colIds):null;for(const r of a.querySelectorAll("[data-key]")){const o=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!s||o&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(D):f.classList.add(D)}}#m(){this.#g();const a=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(a)||a<=0||!this.#e.presentation.views.length)return;const s=this.#t.viewport?.root?.ownerDocument?.defaultView;s?.setInterval&&(this.#s=s.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,a)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const a=this.#e.element;return!a||!L(a.querySelector)?null:a.querySelector(`.${X.statusBar}`)}#w(a){const s=a.children||[];for(const n of s)if(!n.style||n.style.display!=="none")return!1;return!0}#k(){const a=this.#e.toolPanel;return!!(a&&L(a.presentOnly)&&a.presentOnly())}#b(a){const s=this.#e.element;if(!s||!L(s.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[a];return n?s.querySelector(n):null}destroy(){this.#o&&this.#f();for(const a of this.#r)a();this.#r=[]}}const y=O}),xe("packages/dom/src/capture.js",function(e,G){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const L=G("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(K,D,v){const O=v.getComputedStyle(K),y=D.style;if(y)for(let u=0;u<O.length;u++){const a=O[u];B.has(a)||y.setProperty(a,O.getPropertyValue(a),O.getPropertyPriority(a))}}function W(K,D,v){if(F(K,D,v),K.tagName==="CANVAS"&&L(K.toDataURL))try{const u=K.toDataURL("image/png"),a=D.style;a&&(a.setProperty("background-image",`url(${u})`),a.setProperty("background-size","100% 100%"),a.setProperty("background-repeat","no-repeat"))}catch{}const O=K.children||[],y=D.children||[];for(let u=0;u<O.length&&u<y.length;u++)W(O[u],y[u],v)}function X(K,D){if(!K||K.startsWith("data:")||K.startsWith("blob:"))return!0;try{return new URL(K,D).origin===D}catch{return!0}}async function H(K,D={}){const v=K.ownerDocument,O=v?.defaultView;if(!O||typeof O.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=K.getBoundingClientRect(),u=Math.max(1,Math.ceil(y.width)),a=Math.max(1,Math.ceil(y.height)),s=Math.max(.1,Number(D.scale)||2),n=O.location?.origin||"";for(const g of K.querySelectorAll("img")){const d=g.getAttribute("src")||"";if(!X(d,n))throw new Error(`capture refused: the image at ${d} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=K.cloneNode(!0);W(K,t,O),t.style.width=`${u}px`,t.style.height=`${a}px`,t.style.margin="0";const r=new O.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${a}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new O.Image;await new Promise((g,d)=>{f.onload=()=>g(void 0),f.onerror=()=>d(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const c=v.createElement("canvas");c.width=Math.round(u*s),c.height=Math.round(a*s);const i=c.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=D.background||O.getComputedStyle(K).backgroundColor||"#ffffff",i.fillRect(0,0,c.width,c.height),i.drawImage(f,0,0,c.width,c.height),new Promise((g,d)=>{c.toBlob(h=>h?g({blob:h,width:c.width,height:c.height}):d(new Error("capture produced no image")),D.type||"image/png",D.quality)})}const V=H}),xe("packages/dom/src/annotate.js",function(e,G){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.uid,F=Q.warnOnce,X=G("packages/dom/src/renderer/direction.js").signedX,H=Object.freeze(["pen","arrow","rect","highlight","erase"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),K=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),v=14,O="system-ui, -apple-system, sans-serif";function y(h,l){if(!h||typeof h!="object")return null;const m=K[h.type];if(!m)return null;const w=typeof h.id=="string"&&h.id?h.id:B("mark"),k=Array.isArray(h.points)?h.points:[],p=[];for(const E of k){const T=Number(E&&E.x),P=Number(E&&E.y);Number.isFinite(T)&&Number.isFinite(P)&&p.push({x:T,y:P})}const b=typeof h.colour=="string"&&h.colour?h.colour:l;if(m==="text"){const E=typeof h.text=="string"?h.text:"";if(!p.length||!E)return null;const T={id:w,tool:m,colour:b,points:[p[0]],text:E,region:u(h.region)},P=Number(h.fontSize);return Number.isFinite(P)&&P>0&&(T.fontSize=P),typeof h.background=="string"&&h.background&&(T.background=h.background),T}return p.length<2?null:{id:w,tool:m,colour:b,points:p,region:u(h.region)}}function u(h){return h==="start"||h==="end"?h:"centre"}function a(h){const l={id:h.id,type:D[h.tool]||h.tool,colour:h.colour,points:h.points.map(m=>({x:m.x,y:m.y}))};return(h.region==="start"||h.region==="end")&&(l.region=h.region),h.tool==="text"&&(l.text=h.text,h.fontSize!==void 0&&(l.fontSize=h.fontSize),h.background!==void 0&&(l.background=h.background)),l}const s="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,l){return{id:h,count:l,valueOf(){return this.count}}}const o=10;function f(h,l,m){const w=m.x-l.x,k=m.y-l.y,p=w*w+k*k;let b=p?((h.x-l.x)*w+(h.y-l.y)*k)/p:0;b=Math.max(0,Math.min(1,b));const E=l.x+b*w,T=l.y+b*k;return Math.hypot(h.x-E,h.y-T)}function c(h){const l=h.points;if(!l.length)return null;if(h.tool==="text"){const b=h.fontSize||v,E=(h.text||"").length*b*.6;return{x1:l[0].x,y1:l[0].y,x2:l[0].x+E,y2:l[0].y+b*1.2}}let m=1/0,w=1/0,k=-1/0,p=-1/0;for(const b of l)m=Math.min(m,b.x),w=Math.min(w,b.y),k=Math.max(k,b.x),p=Math.max(p,b.y);return{x1:m,y1:w,x2:k,y2:p}}function i(h,l){const m=c(h);if(!m)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(l.x>=m.x1&&l.x<=m.x2&&l.y>=m.y1&&l.y<=m.y2)return 0;if(h.tool==="text")return 1/0}const w=h.points;if(h.tool==="rect"){const p=[{x:m.x1,y:m.y1},{x:m.x2,y:m.y1},{x:m.x2,y:m.y2},{x:m.x1,y:m.y2}];let b=1/0;for(let E=0;E<4;E++)b=Math.min(b,f(l,p[E],p[(E+1)%4]));return b}if(w.length===1)return Math.hypot(l.x-w[0].x,l.y-w[0].y);let k=1/0;for(let p=0;p<w.length-1;p++)k=Math.min(k,f(l,w[p],w[p+1]));return k}class g{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#u=Array.isArray(l.seed)?l.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(l){const m=y(l,this.#i);return m?(m.durable=!0,this.#s.push(m),this.#M(),this.redraw(),this.#R(),r(m.id,this.#s.length)):(F("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(a)}remove(l){const m=this.#s.findIndex(w=>w.id===l);return m<0?(F("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${l}".`),!1):(this.#s.splice(m,1),this.#c===l&&(this.#c=null),this.redraw(),this.#R(),!0)}replaceAll(l){const m=Array.isArray(l)?l:[];this.#s=m.map(w=>y(w,this.#i)).filter(Boolean);for(const w of this.#s)w.durable=!0;this.#s.length&&this.#M(),this.redraw(),this.#R()}#d(){const l=this.#t.viewport?.root;if(!l||!L(l.addEventListener))return;const m=w=>{if(!(!this.#o||!w)){if(w.key==="Escape"){this.use(null),w.preventDefault?.();return}if(this.#o==="erase"){if(w.key==="Tab"){this.#f(w);return}(w.key==="Delete"||w.key==="Backspace")&&this.#h(w)}}};l.addEventListener("keydown",m,!0),this.#a.push(()=>l.removeEventListener("keydown",m,!0))}#f(l){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}l.preventDefault?.();const m=this.#c?this.#s.findIndex(p=>p.id===this.#c):-1,w=l.shiftKey?-1:1,k=m<0?w>0?0:this.#s.length-1:(m+w+this.#s.length)%this.#s.length;this.#c=this.#s[k].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:k+1,of:this.#s.length})}#h(l){if(!this.#c)return;l.preventDefault?.();const m=this.#c;this.remove(m),this.#x("a11y.annotate.erased")}#p(){const l=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!l||!L(l.matchMedia))return;let m=null;const w=()=>{const k=l.devicePixelRatio||1;let p;try{p=l.matchMedia(`(resolution: ${k}dppx)`)}catch{return}m=p;const b=()=>{this.redraw(),w()};L(p.addEventListener)?p.addEventListener("change",b,{once:!0}):L(p.addListener)&&p.addListener(b)};w(),this.#a.push(()=>{m=null})}use(l,m={}){const w=!!m.colour&&l===this.#o;m.colour&&(this.#i=String(m.colour));const k=l&&H.includes(l)?l:null;this.#o=k&&k===this.#o&&!w?null:k,this.#o!=="erase"&&(this.#c=null);const p=this.#o?this.#M():this.#n;return p&&(p.style.pointerEvents=this.#o?"auto":"none",p.style.cursor=this.#o?"crosshair":""),this.#R(),this.#o}undo(){const l=this.#s.pop();return l&&this.#c===l.id&&(this.#c=null),this.redraw(),this.#R(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#R())}#m(){const l=this.#s.filter(m=>m.durable);l.length!==this.#s.length&&(this.#s=l,this.redraw(),this.#R())}redraw(){!this.#n&&this.#s.length&&this.#M();const l=this.#n,m=this.#r;if(!l||!m)return;this.#A();const{left:w,top:k}=this.#S();m.clearRect(0,0,l.width,l.height);const p=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const E=p.filter(T=>u(T.region)===b);if(E.length){m.save(),this.#g(m,b),m.translate((b==="centre"?-w:0)||0,-k||0);for(const T of E)this.#b(m,T),T.id===this.#c&&this.#j(m,T);m.restore()}}}#g(l,m="centre"){const w=this.#n,k=this.#t.viewport?.bodyViewport;if(!L(w?.getBoundingClientRect)||!L(k?.getBoundingClientRect))return;const p=w.getBoundingClientRect(),b=k.getBoundingClientRect();if(!b.width||!b.height)return;const E=this.#y(m,b);E&&(l.beginPath(),l.rect(E.left-p.left,b.top-p.top,E.width,b.height),l.clip())}#y(l,m){const w=P=>{if(!L(P?.getBoundingClientRect))return null;const x=P.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},k=w(this.#t.viewport?.bodyStart),p=w(this.#t.viewport?.bodyEnd);if(l==="start")return k;if(l==="end")return p;let b=m.left,E=m.left+m.width;const T=m.left+m.width/2;for(const P of[k,p]){if(!P)continue;const x=P.left+P.width;P.left+P.width/2<T?b=Math.max(b,x):E=Math.min(E,P.left)}return E>b?{left:b,width:E-b}:null}#w(l){for(const[m,w]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!L(w?.getBoundingClientRect))continue;const k=w.getBoundingClientRect();if(k&&k.width>0&&l>=k.left&&l<k.left+k.width)return m}return"centre"}#k(l){const m=this.#t.viewport?.bodyViewport;if(!L(m?.getBoundingClientRect))return!0;const w=m.getBoundingClientRect();return!w.width||!w.height?!0:l.clientX>=w.left&&l.clientX<=w.right&&l.clientY>=w.top&&l.clientY<=w.bottom}#b(l,m){const w=m.points;if(!w.length)return;const k=this.#e.presentation?.scale||1;l.lineWidth=(n[m.tool]||3)*k,l.strokeStyle=m.colour,l.fillStyle=m.colour,l.lineCap="round",l.lineJoin="round",l.globalAlpha=m.tool==="highlight"?.32:1;const p=w[0],b=w[w.length-1];if(m.tool==="text"){const E=(m.fontSize||v)*k;l.font=`${E}px ${O}`,l.textBaseline="top";const T=m.text||"";if(m.background){let P=T.length*E*.6;if(typeof l.measureText=="function"){const x=l.measureText(T);x&&Number.isFinite(x.width)&&(P=x.width)}l.fillStyle=m.background,l.fillRect(p.x-E*.15,p.y-E*.1,P+E*.3,E*1.2)}l.fillStyle=m.colour,l.fillText(T,p.x,p.y),l.globalAlpha=1;return}if(m.tool==="rect")l.strokeRect(p.x,p.y,b.x-p.x,b.y-p.y);else if(m.tool==="arrow")l.beginPath(),l.moveTo(p.x,p.y),l.lineTo(b.x,b.y),l.stroke(),this.#O(l,p,b,l.lineWidth);else{l.beginPath(),l.moveTo(p.x,p.y);for(let E=1;E<w.length;E++)l.lineTo(w[E].x,w[E].y);l.stroke()}l.globalAlpha=1}#O(l,m,w,k){const p=Math.atan2(w.y-m.y,w.x-m.x),b=Math.max(8,k*3);l.beginPath(),l.moveTo(w.x,w.y),l.lineTo(w.x-b*Math.cos(p-Math.PI/7),w.y-b*Math.sin(p-Math.PI/7)),l.lineTo(w.x-b*Math.cos(p+Math.PI/7),w.y-b*Math.sin(p+Math.PI/7)),l.closePath(),l.fill()}#j(l,m){const w=c(m);if(!w||!L(l.strokeRect))return;const k=6;l.save(),l.setLineDash?.([4,3]),l.strokeStyle="#1a73e8",l.lineWidth=2,l.globalAlpha=1,l.strokeRect(w.x1-k,w.y1-k,w.x2-w.x1+k*2,w.y2-w.y1+k*2),l.restore()}#P(l,m){const w=this.#e.presentation?.scale||1,k=o*w;for(let p=this.#s.length-1;p>=0;p--){const b=this.#s[p];if(u(b.region)===m&&i(b,l)<=k)return b}return null}#S(){const l=L(this.#t.scrollPosition)?this.#t.scrollPosition():null,m=this.#t.viewport?.rtl===!0;return{left:X(l?.left||0,m),top:l?.top||0}}#M(){if(this.#n)return this.#n;const l=this.#t.viewport?.overlays,m=l?.ownerDocument;if(!l||!m?.createElement)return null;const w=m.createElement("canvas");return w.className=s,w.style.position="absolute",w.style.inset="0",w.style.pointerEvents="none",l.appendChild(w),this.#n=w,this.#r=w.getContext?w.getContext("2d"):null,this.#A(),this.#E(w),w}#A(){const l=this.#n,m=this.#t.viewport?.root;if(!l||!m?.getBoundingClientRect)return;const w=m.getBoundingClientRect(),p=l.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(w.width*p)),E=Math.max(1,Math.round(w.height*p));l.width===b&&l.height===E||(l.width=b,l.height=E,l.style&&(l.style.width=`${Math.max(1,w.width)}px`,l.style.height=`${Math.max(1,w.height)}px`),this.#r?.setTransform(p,0,0,p,0,0))}#E(l){const m=(E,T="centre")=>{const P=l.getBoundingClientRect(),{left:x,top:C}=this.#S();return{x:E.clientX-P.left+(T==="centre"?x:0),y:E.clientY-P.top+C}},w=E=>{if(!this.#o||!this.#k(E))return;const T=this.#w(E.clientX);if(this.#o==="erase"){const P=this.#P(m(E,T),T);P&&(this.remove(P.id),this.#x("a11y.annotate.erased")),E.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[m(E,T)],region:T},l.setPointerCapture?.(E.pointerId),E.preventDefault?.()},k=E=>{if(!this.#l)return;const T=m(E,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(T),this.redraw()},p=E=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,l.releasePointerCapture?.(E.pointerId),this.redraw(),this.#R())},b=E=>{if(!this.#o)return;const T=this.#t.viewport?.bodyViewport;if(!T)return;let P=!1;E.deltaY&&typeof T.scrollTop=="number"&&(T.scrollTop+=E.deltaY,P=!0),E.deltaX&&typeof T.scrollLeft=="number"&&(T.scrollLeft+=E.deltaX,P=!0),P&&E.preventDefault?.()};l.addEventListener("pointerdown",w),l.addEventListener("pointermove",k),l.addEventListener("pointerup",p),l.addEventListener("pointercancel",p),l.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{l.removeEventListener("pointerdown",w),l.removeEventListener("pointermove",k),l.removeEventListener("pointerup",p),l.removeEventListener("pointercancel",p),l.removeEventListener("wheel",b)})}#R(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(l,m){const w=this.#e.messages;return w&&L(w.t)?w.t(l,m):l}#x(l,m){this.#t.announce?.(this.#L(l,m),{repeat:!0})}destroy(){for(const l of this.#a)l();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const d=g}),xe("packages/dom/src/timelinebar.js",function(e,G){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function X(D){if(!Number.isFinite(D)||D<1e3)return"now";const v=Math.round(D/1e3);if(v<60)return`${v}s ago`;const O=Math.round(v/60);return O<60?`${O}m ago`:`${Math.round(O/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 V{#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,O=v.depth,y=v.position;this.#r.max=String(Math.max(1,O)),this.#r.value=String(Math.max(0,O-y)),this.#r.disabled=O===0;const u=v.at(),a=v.live;this.#o&&(this.#o.textContent=a?this.#l("timeline.live"):X(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",a?"true":"false")),this.#i&&(this.#i.textContent=O===0?this.#l("timeline.recording"):H(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",a?"true":"false")}#l(v,O){const y=this.#e;return(y&&y.messages?y.messages:F).t(v,O)}#a(){if(this.#n)return;const v=this.#t.viewport?.overlays,O=v?.ownerDocument;if(!v||!O?.createElement)return;const y=O.createElement("div");y.className=W;const u=O.createElement("span");u.className=`${W}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const a=O.createElement("input");a.className=`${W}__range`,a.type="range",a.min="0",a.step="1",a.setAttribute("aria-label",this.#l("timeline.scrub"));const s=O.createElement("span");s.className=`${W}__clock`;const n=O.createElement("button");n.className=`${W}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(u),y.appendChild(a),y.appendChild(s),y.appendChild(n),v.appendChild(y),this.#n=y,this.#r=a,this.#o=u,this.#i=s;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(a.value))};a.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const o=f=>f.stopPropagation();a.addEventListener("keydown",o),this.#s.push(()=>{a.removeEventListener("input",t),n.removeEventListener("click",r),a.removeEventListener("keydown",o)})}#u(){this.#n&&(L(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 K=V}),xe("packages/dom/src/commentpaint.js",function(e,G){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",V="lat-cell--commented",K="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 u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const a=[];for(const s of u.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key");if(n){a.push(n);for(const t of s.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),o=y.at(n,r),f=!!(o&&o.count);t.classList.toggle(V,f),t.classList.toggle(K,f&&o.unresolved>0),this.#i(t,o,r)}}}(a.length!==this.#r.length||a.some((s,n)=>s!==this.#r[n]))&&(this.#r=a,y.request(a))}#o(y,u){const a=this.#e;return(a&&a.messages?a.messages:F).t(y,u)}#i(y,u,a){if(!u||!u.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const s=u.count,n=u.unresolved,t=this.#o("count.comments",{count:s});y.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const y=this.#t.viewport?.root;if(!y||!L(y.addEventListener))return;const u=s=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=s.target&&L(s.target.closest)?s.target.closest("[data-col]"):null;if(!t||!t.classList.contains(V)||!this.#l(t,s))return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.stopPropagation(),s.preventDefault(),n.open(o,t.getAttribute("data-col")))},a=s=>{const n=this.#e.comments;if(!n||!n.enabled||!s.altKey||s.key!=="m"&&s.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&L(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.preventDefault(),s.stopPropagation(),n.open(o,t.getAttribute("data-col")))};y.addEventListener("click",u,!0),y.addEventListener("keydown",a,!0),this.#n.push(()=>{y.removeEventListener("click",u,!0),y.removeEventListener("keydown",a,!0)})}#l(y,u){if(!L(y.getBoundingClientRect))return!1;const a=y.getBoundingClientRect(),s=Math.max(14,Math.min(24,a.height*.6));return(X(y)?u.clientX<=a.left+s:u.clientX>=a.right-s)&&u.clientY<=a.top+s}destroy(){for(const y of this.#n)y();this.#n=[]}}const v=D}),xe("packages/dom/src/presencepaint.js",function(e,G){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/editors/common.js").cssEscape,V=G("packages/core/src/model/presence.js").CURSOR_LABEL_MS,K="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 u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,a=>this.#l(u,a)));this.#a(),this.paint()}}#l(y,u){if(this.#f(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const s=u&&u.peer;s&&(this.#r.textContent=this.#h(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:s.name}))}#a(){const y=this.#t.viewport?.overlays,u=y?.ownerDocument;if(!y||!u?.createElement)return;const a=this.#e.get("presence")||{},s=u.createElement("span");if(s.className=`${K}__live`,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),y.appendChild(s),this.#r=s,a.roster===!1)return;const n=u.createElement("div");n.className=K,a.roster&&a.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",y.appendChild(n),this.#n=n}paint(){const y=this.#e.presence,u=this.#t.viewport?.root;if(!y||!y.enabled||!u?.querySelectorAll)return;this.#d(u);const a=y.peers(),s=[...a].sort((n,t)=>n.at-t.at);for(const n of s)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const o of t.columns||[])this.#c(u,r,o,n,"range");for(const n of s)n.cursor&&this.#c(u,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of s)n.editing&&this.#c(u,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(a)}#u(y){if(this.#s!==null)return;const u=y.filter(n=>n.cursorFresh);if(!u.length)return;const s=Math.max(...u.map(n=>n.cursorAt||0))+V-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,s))}#c(y,u,a,s,n){const t=y.querySelector(`[data-key="${X(u)}"]`),r=t&&t.querySelector(`[data-col="${X(a)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",s.colour),r.setAttribute("data-peer-name",s.name),r.setAttribute("data-peer-initial",s.initials||(s.name||"?").slice(0,1).toUpperCase()),s.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&s.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${a}`))}#d(y){if(this.#o.size){for(const u of y.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const y=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const s of u){const n=y.createElement("button");n.className=`${K}__peer`,n.type="button",n.style.setProperty("--lat-peer",s.colour),n.toggleAttribute("data-idle",!!s.idle),n.toggleAttribute("data-hidden",!!s.hidden);let t="presence.peer";s.hidden?t="presence.peerHidden":s.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:s.name}));const r=y.createElement("span");r.className=`${K}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=s.initials||(s.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const o=y.createElement("span");o.className=`${K}__name`,o.textContent=s.name,n.appendChild(o),n.addEventListener("click",()=>this.#e.presence.jumpTo(s.id)),this.#n.appendChild(n)}const a=u.filter(s=>s.hidden).length;if(a){const s=y.createElement("span");s.className=`${K}__hidden`,s.textContent=this.#h("presence.hidden",{count:a}),this.#n.appendChild(s)}}announceRefusal(y){if(!this.#r)return;const u=y&&y.name?y.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:u})}#h(y,u){const a=this.#e;return(a&&a.messages?a.messages:F).t(y,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const v=D}),xe("packages/dom/src/commentpanel.js",function(e,G){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,X=G("packages/dom/src/editors/common.js").cssEscape,V=G("packages/core/src/model/comments.js").parseCellKey,K="lat-comments",D=/^(https?:|mailto:)/i,v='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function O(s,n){if(!Number.isFinite(s))return"";const t=Math.max(0,Math.round((n-s)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function y(s,n,t,r){n.textContent="";const o=String(t??"");if(!r){n.textContent=o;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let c=0,i=f.exec(o);for(;i;){i.index>c&&n.appendChild(s.createTextNode(o.slice(c,i.index)));const g=i[0];if(g.startsWith("*")){const d=s.createElement("em");d.textContent=g.slice(1,-1),n.appendChild(d)}else if(g.startsWith("`")){const d=s.createElement("code");d.textContent=g.slice(1,-1),n.appendChild(d)}else{const d=g.indexOf("]("),h=g.slice(1,d),l=g.slice(d+2,-1);if(D.test(l)){const m=s.createElement("a");m.href=l,m.textContent=h,m.rel="noopener noreferrer",m.target="_blank",n.appendChild(m)}else n.appendChild(s.createTextNode(h))}c=i.index+g.length,i=f.exec(o)}c<o.length&&n.appendChild(s.createTextNode(o.slice(c)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#b()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#b(),this.#o&&L(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&L(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=V(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${K}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const o=r.querySelector(`[data-key="${X(n)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:F).t(n,t)}#p(n){const t=n.createElement("div");t.className=K,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${K}__head`;const o=n.createElement("div");o.className=`${K}__title`,r.appendChild(o);const f=n.createElement("button");f.className=`${K}__resolve`,f.type="button",r.appendChild(f);const c=n.createElement("button");c.className=`${K}__close`,c.type="button",c.setAttribute("aria-label",this.#h("comments.close")),c.textContent="×",r.appendChild(c);const i=n.createElement("div");i.className=`${K}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const g=n.createElement("form");g.className=`${K}__composer`;const d=n.createElement("textarea");d.className=`${K}__input`,d.rows=2,d.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${K}__send`,h.type="submit",h.textContent=this.#h("comments.post"),g.appendChild(d),g.appendChild(h),t.appendChild(r),t.appendChild(i),t.appendChild(g),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=d,this.#m=o,this.#g=f;const l=p=>{p.preventDefault();const b=String(d.value||"").trim();b&&(d.value="",this.#e.comments.add(b))},m=()=>this.#e.comments.close(),w=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},k=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.#e.comments.close();return}if(p.key!=="Tab")return;const b=[...t.querySelectorAll(v)].filter(x=>x.offsetParent!==null||x===d);if(!b.length)return;const E=b[0],T=b[b.length-1],P=t.ownerDocument.activeElement;p.shiftKey&&P===E?(p.preventDefault(),T.focus()):!p.shiftKey&&P===T&&(p.preventDefault(),E.focus())};g.addEventListener("submit",l),c.addEventListener("click",m),f.addEventListener("click",w),t.addEventListener("keydown",k),this.#l.push(()=>{g.removeEventListener("submit",l),c.removeEventListener("click",m),f.removeEventListener("click",w),t.removeEventListener("keydown",k)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},o=Date.now(),f=n.openKey,{rowId:c,field:i}=V(f),g=this.#e.columns.get(i),d=this.#e.rows.byKey(c),h=L(r.rowLabel)&&d?r.rowLabel(d):c;if(this.#m.textContent=this.#h("comments.cellTitle",{column:g&&(g.title??g.id)||i,row:h}),this.#g.textContent=this.#y()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const l=n.thread||[];if(!l.length){this.#d(this.#h("comments.empty"));return}const m=d&&g?g.getValue(d.data,d):void 0;for(const w of l)this.#r.appendChild(this.#k(t,w,o,m,r))}#k(n,t,r,o,f){const c=n.createElement("article");c.className=`${K}__item`,t.pending&&c.setAttribute("data-pending","true"),t.resolved&&c.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${K}__meta`;const g=n.createElement("span");g.className=`${K}__author`,g.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),i.appendChild(g);const d=n.createElement("time");d.className=`${K}__time`;const h=O(t.at,r);d.textContent=t.edited?this.#h("comments.edited",{time:h}):h,i.appendChild(d),c.appendChild(i);const l=n.createElement("div");if(l.className=`${K}__body`,y(n,l,t.body,!!f.markdown),c.appendChild(l),t.value!==void 0&&!Object.is(t.value,o)){const k=n.createElement("p");k.className=`${K}__moved`,k.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(o)}),c.appendChild(k)}const m=t.can||{},w=k=>m[k]!==!1;if(w("edit")||w("delete")){const k=n.createElement("div");if(k.className=`${K}__actions`,w("delete")){const p=n.createElement("button");p.type="button",p.className=`${K}__action`,p.textContent=this.#h("comments.delete"),p.addEventListener("click",()=>this.#e.comments.remove(t.id)),k.appendChild(p)}c.appendChild(k)}return c}#b(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:o}=V(t),f=this.#f(r,o)||this.#i,c=this.#t.viewport?.root;if(!f||!c||!L(f.getBoundingClientRect))return;const i=f.getBoundingClientRect(),g=c.getBoundingClientRect(),d=this.#n.getBoundingClientRect();let h=i.bottom-g.top+4;h+d.height>g.height&&i.top-g.top>d.height&&(h=i.top-g.top-d.height-4);let l=i.left-g.left;l+d.width>g.width&&(l=Math.max(0,g.width-d.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,l)}px`;const m=i.bottom<g.top||i.top>g.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const a=u}),xe("packages/dom/src/watermark.js",function(e,G){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),X=W.el,H=W.on,V="lat-watermark",K="https://www.latticegrid.dev",D=["br","bl","tl","tr"],v=4e3;class O{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(a){this.#e=a.grid,this.#t=a.document,this.#n=a.element,this.#i=a.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),L(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const a=this.#e.licence&&this.#e.licence.ready;a&&L(a.then)&&a.then(()=>this.refresh(),()=>this.refresh())}refresh(){const a=this.#d();a&&!this.#r?(this.#f(),this.#u()):!a&&this.#r&&(this.#h(),this.#c())}#a(){const a=this.#i;if(!a||!L(a.matchMedia))return!1;try{return!!a.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),L(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%D.length,this.#h(),this.#f(),this.#u()},v)))}#c(){this.#l!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const a=this.#e.licence;return!!(a&&L(a.watermark)&&a.watermark())}#f(){const a=X(this.#t,"a",{class:`${V}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:K,target:"_blank",rel:"noopener noreferrer"}});this.#r=X(this.#t,"div",{class:`${V} ${V}--${D[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a]}),this.#o.push(H(this.#r,"pointerdown",s=>{L(s.stopPropagation)&&s.stopPropagation()})),this.#n&&L(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const a of this.#o)a();this.#o=[],this.#h()}}const y=O}),xe("packages/dom/src/maximise.js",function(e,G){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=G("packages/core/src/internal/util.js"),L=Q.warnOnce,B=Q.isFunction,F=G("packages/dom/src/editors/common.js"),W=F.el,X=F.on,V=G("packages/dom/src/themeof.js").themeOf,K="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",O="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(s){this.#e=s.element,this.#t=s.document,this.#n=B(s.onChange)?s.onChange:null,this.#r=B(s.captureScroll)?s.captureScroll:null,this.#o=B(s.restoreScroll)?s.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const s=this.#e.parentNode;if(!s||!this.#t.body)return L("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:O}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?V(s):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),s.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,c]of Object.entries(D))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=c;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(K),this.#t.body.classList&&this.#t.body.classList.add(v),r&&this.#o&&this.#o(r),this.#s=X(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const s=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,o]of Object.entries(this.#a))this.#e.style[r]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(K),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(v),s&&this.#o&&this.#o(s),this.#s&&this.#s(),this.#s=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(s){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;s(),t&&B(t.focus)&&t.focus()}#f(s){!s||s.key!=="Escape"||s.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const s of this.#l)s(this.active())}watch(s){return B(s)?(this.#l.add(s),()=>this.#l.delete(s)):()=>{}}destroy(){this.exit()}}const u=y}),xe("packages/dom/src/promptbar.js",function(e,G){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=G("packages/dom/src/editors/common.js"),L=Q.documentFor,B=Q.el,F=Q.on,W=Q.clear,H=G("packages/core/src/i18n/index.js").defaultMessages,K=G("packages/core/src/internal/util.js").isFunction,D=G("packages/core/src/ai/schema.js"),v=D.describeGrid,O=D.promptText,y=G("packages/core/src/ai/intent.js"),u=y.applyPlan,a=y.buildPrompt,s=y.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#y="idle";#w=0;#k=!1;#b=[];t(c,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(c,i)}init(c={}){this.messages=c&&c.messages||c&&c.grid&&c.grid.messages||H,this.#e=L(c),this.#t=c.grid||null,this.#n=K(c.ask)?c.ask:null,this.#r=c.schemaOptions||{},this.#o=c.context,this.#i={onPlan:K(c.onPlan)?c.onPlan:null,onApply:K(c.onApply)?c.onApply:null,onError:K(c.onError)?c.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(c)}element(){return this.#s}refresh(){this.#k||!this.#s||this.#y!=="busy"&&this.#M()}destroy(){this.#k=!0,this.#w++;for(const c of this.#b)c();this.#b.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(c){if(this.#k||this.#y==="busy")return null;const i=String(c??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const g=++this.#w;this.#j("busy"),this.#A("Thinking…");let d;try{const h=v(this.#t,this.#r),l=O(h);if(d=await this.#n({prompt:i,schema:h,schemaText:l,message:a(i,l),context:this.#o}),this.#k||g!==this.#w)return null;const m=s(d,h);return this.#P(m),m}catch(h){return this.#k||g!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#E(h instanceof Error?h.message:String(h))),null}}apply(){const c=this.#g;if(this.#k||!c||!c.ok)return null;const i=this.#t?.ai,g=K(i?.apply)?i.apply(c):u(c,this.#t);return this.#i.onApply&&this.#i.onApply(g,c),this.#M(),this.#l&&(this.#l.value=""),g.failed.length?this.#E(`Applied ${g.applied.length}; ${g.failed.map(d=>`${d.type} failed: ${d.reason}`).join("; ")}`):this.#A(`Applied: ${c.describe()}`),g}discard(){this.#k||(this.#M(),this.#A("Discarded."))}#O(c){const i=this.#e,g=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:c.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":c.label||"Ask about this grid",autocomplete:"off"}}),this.#b.push(F(this.#l,"keydown",h=>{const l=h&&h.key;l==="Enter"?(K(h.preventDefault)&&h.preventDefault(),this.ask()):l==="Escape"&&this.#g&&(K(h.preventDefault)&&h.preventDefault(),this.discard())})),g.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#b.push(F(this.#a,"click",()=>{this.ask()})),g.appendChild(this.#a),this.#s.appendChild(g),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const d=B(i,"div",{class:`${n}__buttons`});this.#f=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#b.push(F(this.#f,"click",()=>{this.apply()})),this.#b.push(F(this.#h,"click",()=>{this.discard()})),d.appendChild(this.#f),d.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(d),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#j(c){if(this.#y=c,!this.#s)return;this.#s.setAttribute("data-state",c);const i=c==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,c!=="preview"),o(this.#m,c!=="error")}#P(c){const i=c;if(this.#i.onPlan&&this.#i.onPlan(c),!i.ok){this.#g=null;const g=i.rejected.length?i.rejected.map(d=>d.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${g}`);return}this.#g=c,this.#A(""),this.#c&&(this.#c.textContent=i.describe()),this.#S(i.rejected),this.#j("preview")}#S(c){const i=this.#d;if(i){W(i),o(i,!c.length);for(const g of c.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:g.reason}));c.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:c.length-6})}))}}#M(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#A(c){this.#p&&(this.#p.textContent=c)}#E(c){this.#g=null,this.#A(""),this.#m&&(this.#m.textContent=c),this.#j("error")}}function r(f,c){f&&(f.disabled=c,c?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function o(f,c){f&&(f.hidden=c,c?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),xe("packages/dom/src/stat.js",function(e,G){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return c}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.isObject,F=Q.warnOnce,X=G("packages/core/src/source/derive.js").reduceValues,V=G("packages/core/src/source/memory.js").isPipelineSettle,D=G("packages/core/src/i18n/index.js").defaultMessages,O=G("packages/dom/src/cell/icons.js").renderIconInto,y={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",a=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),s=Object.freeze({direction:"flat",change:null,percent:null});function n(l,m){if(!Number.isFinite(l)||!Number.isFinite(m))return s;const w=l-m,k=w>0?"up":w<0?"down":"flat",p=m===0?null:w/Math.abs(m)*100;return{direction:k,change:w,percent:p}}function t(l,m){return l==="flat"||m==="neither"?"flat":l===m?"good":"bad"}function r(l,m,w=null){if(L(m)){const P=m(l,w);return P==="good"||P==="warn"||P==="bad"?P:null}if(!B(m))return null;const k=typeof l=="number"&&Number.isFinite(l)?l:null;if(k===null)return null;const p=Number.isFinite(Number(m.good))?Number(m.good):null,b=Number.isFinite(Number(m.warn))?Number(m.warn):null,E=String(m.direction||"up")==="down",T=P=>E?k<=P:k>=P;return p!==null&&T(p)?"good":b!==null&&T(b)?"warn":p===null&&b===null?null:"bad"}function o(l){return!(L(l.value)||l.value!==void 0&&!B(l.value))}function f(l){return!l||!l.rows||!L(l.rows.totalCount)?!0:l.rows.totalCount()>0}function c(l){const m=B(l)?l:{},w=m.grid||null,k=d(m.container,w);if(!k)return F("stat.container","createStat needs a `container`: an element or a selector."),h();const p=k.ownerDocument||(typeof document>"u"?null:document);if(!p)return F("stat.document","createStat needs a document; it draws DOM."),h();const b=p.createElement("div");b.className=["lattice",y.root,m.class].filter(Boolean).join(" "),b.setAttribute("role","group");const E=p.createElement("div");E.className=y.title;const T=p.createElement("div");T.className=y.value;const P=p.createElement("div");P.className=y.interval;const x=p.createElement("div");x.className=y.delta;const C=p.createElement("div");C.className=y.footer;const A=p.createElement("div");if(A.className=y.note,A.hidden=!0,m.icon!=null&&m.icon!==""){const ee=p.createElement("span");ee.className=y.icon,ee.setAttribute("aria-hidden","true"),O(ee,m.icon,`stat:${m.title||"stat"}`),b.appendChild(ee);const te=p.createElement("div");te.className=y.body,te.appendChild(E),te.appendChild(T),te.appendChild(A),te.appendChild(P),te.appendChild(x),te.appendChild(C),b.appendChild(te)}else b.appendChild(E),b.appendChild(T),b.appendChild(A),b.appendChild(P),b.appendChild(x),b.appendChild(C);k.appendChild(b);let $=null;const z=[];let M=!1;function R(){if(L(m.value))return m.value(w);if(m.value!==void 0&&!B(m.value))return m.value;const ee=B(m.value)?m.value:m,te=ee.of,ne=ee.fn||"sum",ae=ee.show;return w?ne==="count"?I().length:te?ae?q(String(te),String(ne),String(ae)):S()==="filtered"&&w.statistics&&L(w.statistics.reduce)?w.statistics.reduce(String(te),String(ne)):X(I().map(de=>g(de,String(te))),String(ne)):null:null}function S(){return String(m.scope||"filtered")}function I(){if(!w||!w.rows)return[];const ee=S();if(ee==="all"){const ne=[];return L(w.rows.forEachAll)&&w.rows.forEachAll(ae=>{ae.group||ne.push(i(ae))}),ne}if(ee==="selected")return(w.selection&&L(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(i);const te=[];return L(w.rows.forEach)&&w.rows.forEach(ne=>{ne.group||te.push(i(ne))}),te}function q(ee,te,ne){if(te!=="min"&&te!=="max")return F(`stat.show.${te}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${te}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ae=null,de=null;for(const ie of I()){const oe=Number(g(ie,ee));Number.isFinite(oe)&&(ae===null||(te==="max"?oe>ae:oe<ae))&&(ae=oe,de=ie)}return de===null?null:g(de,ne)}function Z(ee){if(L(m.format))return String(m.format(ee,w));if(ee==null)return m.empty??"—";const te=B(m.value)?m.value:m,ne=te.show||te.of;if((te.show?!0:a.has(String(te.fn||"sum")))&&w&&ne&&L(w.columns?.get)){const de=w.columns.get(String(ne));if(de&&L(de.formatValue))return de.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(m.decimals??2):String(ee)}function _(ee){return ee?(w&&w.messages||D).t(`stat.tone.${ee}`):""}function J(){if(M)return;const ee=R(),te=o(m)&&!!w&&!f(w),ne=te?null:ee,ae=L(m.baseline)?m.baseline(w):m.baseline;$=ne,E.textContent=m.title??"",E.hidden=!m.title,T.textContent=Z(ne),A.hidden=!te,te&&(A.textContent=w.messages.t("stat.noData"));const de=te||ae===void 0||ae===null?s:n(typeof ne=="number"?ne:null,Number(ae)),ie=t(de.direction,m.goodWhen||"up");if(x.hidden=de.change===null,de.change!==null){const ke=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Re=de.percent===null?Z(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;x.textContent=`${ke} ${Re}`,x.setAttribute("data-tone",ie),x.setAttribute("data-direction",de.direction)}const oe=L(m.interval)?m.interval(ne,w):null,ce=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);P.hidden=!ce,ce&&(P.textContent=`${Z(oe.lower)} – ${Z(oe.upper)}`,Number.isFinite(oe.confidence)&&P.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const fe=te?u:m.bands?r(ne,m.bands,w):null;fe?b.setAttribute("data-tone",fe):b.removeAttribute("data-tone"),C.textContent=L(m.footer)?String(m.footer(ne,w)):m.footer??"",C.hidden=!C.textContent,b.setAttribute("aria-label",[m.title,T.textContent,te?A.textContent:"",ce?P.textContent:"",de.change===null?"":x.textContent,de.change===null?"":_(ie),C.textContent].filter(Boolean).join(", "))}if(w&&L(w.on)&&m.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const te=ne=>{ee==="model:changed"&&!V(ne)||J()};w.on(ee,te),z.push(()=>L(w.off)&&w.off(ee,te))}return J(),{element:()=>b,value:()=>$,refresh:J,destroy(){M=!0;for(const ee of z)try{ee()}catch{}z.length=0,b.remove()}}}function i(l){return B(l)&&"data"in l?l.data:l}function g(l,m){if(!B(l))return;if(!m.includes("."))return l[m];let w=l;for(const k of m.split(".")){if(!B(w))return;w=w[k]}return w}function d(l,m){if(l&&typeof l=="object")return l;if(typeof l!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(l):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),xe("packages/dom/src/kpistrip.js",function(e,G){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const L=G("packages/core/src/internal/util.js").isObject,F=G("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:V,document:K,kpis:D}){this.#e=V,this.#t=K,this.#n=Array.isArray(D)?D.filter(L):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const K=this.#t.createElement("div");K.className=`lattice ${W.band}`,K.setAttribute("role","group"),K.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=K;for(const D of this.#n){const v=F({...D,grid:this.#e,container:K});this.#o.push(v)}}destroy(){for(const V of this.#o)try{V.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),xe("packages/dom/src/createGrid.js",function(e,G){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const L=G("packages/core/src/index.js").createHeadlessGrid,F=G("packages/core/src/defaults.js").applyDefaults,X=G("packages/core/src/export/download.js").downloadBlob,H=G("packages/core/src/internal/util.js"),V=H.fail,K=H.isFunction,D=H.warnOnce,O=G("packages/dom/src/localviews.js").createLocalViewStorage,u=G("packages/dom/src/renderer/index.js").DomRenderer,s=G("packages/dom/src/cell/index.js").createCellLayer,n=G("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=G("packages/dom/src/editors/index.js").editors,i=G("packages/dom/src/filters/index.js").filters,g=G("packages/dom/src/ui/index.js"),d=g.StatusBar,h=g.TooltipManager,l=g.Pagination,m=g.GroupByZone,k=G("packages/dom/src/ui/celltooltip.js").CellTooltips,b=G("packages/dom/src/filtermenu.js").FilterMenu,T=G("packages/dom/src/columnmenu.js").ColumnMenu,x=G("packages/dom/src/shortcutshelp.js").ShortcutsHelp,A=G("packages/dom/src/rowreorder.js").RowReorder,$=G("packages/dom/src/alignedgrids.js").AlignedGrids,M=G("packages/dom/src/columntagbar.js").ColumnTagBar,S=G("packages/dom/src/anomalychip.js").AnomalyChip,q=G("packages/dom/src/rowform.js").RowForm,Z=G("packages/dom/src/toolpanelmount.js"),_=Z.ToolPanelDock,J=Z.panelHost,te=G("packages/dom/src/celledit.js").CellEditController,ae=G("packages/dom/src/editbar.js").EditBar,ie=G("packages/dom/src/rangeselect.js").RangeController,ce=G("packages/core/src/model/selection.js").resolveSelectionConfig,ke=G("packages/dom/src/importer.js").ImportController,Ee=G("packages/dom/src/historybar.js").HistoryBar,ye=G("packages/dom/src/diffpaint.js").DiffPainter,Se=G("packages/dom/src/detailhost.js").DetailHost,Ie=G("packages/dom/src/highlightpaint.js").HighlightPainter,Ye=G("packages/dom/src/findpaint.js").FindPainter,Te=G("packages/dom/src/findbar.js").FindBar,Ke=G("packages/dom/src/redactpaint.js").RedactionPainter,it=G("packages/dom/src/validationpaint.js").ValidationPainter,yt=G("packages/dom/src/presentation.js").PresentationController,At=G("packages/dom/src/capture.js").captureElement,Tt=G("packages/dom/src/annotate.js").AnnotationLayer,zt=G("packages/dom/src/timelinebar.js").TimelineBar,Ge=G("packages/dom/src/commentpaint.js").CommentPainter,pe=G("packages/dom/src/presencepaint.js").PresencePainter,Ue=G("packages/dom/src/commentpanel.js").CommentPanel,nt=G("packages/dom/src/watermark.js").Watermark,we=G("packages/dom/src/maximise.js").Maximiser,je=G("packages/dom/src/promptbar.js").PromptBar,me=G("packages/dom/src/kpistrip.js").KpiStrip;function Me(He,lt,rt){const vt=lt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?He(vt):He(lt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const Ae=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ne=2e3;function De(He,lt,rt,vt){const Nt=lt.annotate===!0?qe(He,vt):[];if(lt.actions===!1)return[];if(lt.actions===void 0&<.side!=="left")return Nt;const $t=Array.isArray(lt.actions)?lt.actions:Ae,gt=(Bt,Qt)=>He.messages.t(Bt,Qt),Rt={undo:{name:"undo",title:()=>Me(gt,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>Me(gt,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>gt("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:lt.exportName})},excel:{name:"excel",title:()=>gt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:lt.exportName})},clipboard:{name:"clipboard",title:()=>gt("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>gt("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return gt("toolbar.pause");const Bt=He.updates.stats().pending;return Bt?gt("toolbar.applyHeld",{count:Bt}):gt("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>gt("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>gt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete Rt.maximise,$t.map(Bt=>Bt==="-"?{name:"-",separator:!0}:typeof Bt=="string"?Rt[Bt]:!Bt||typeof Bt!="object"||!Bt.name?null:{...Bt,run:K(Bt.run)?()=>Bt.run({grid:He,keys:He.selection&&K(He.selection.keys)?He.selection.keys():[],cells:He.selection&&K(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(Nt)}function qe(He,lt){const rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},vt=($t,gt)=>He.messages.t($t,gt),Nt=["pen","arrow","rect","highlight","erase"].map($t=>({name:$t,title:()=>vt(`toolbar.annotate.${$t}`),icon:rt[$t],run:()=>He.annotate?.use($t),active:()=>He.annotate?.tool===$t,annotation:!0}));return Nt.push(ot(He,vt,lt)),Nt}function ot(He,lt,rt){return{name:"clearAll",title:()=>lt("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>ut(He,lt,rt)}}function ut(He,lt,rt){const vt=He.toolPanel;if(!vt)return;const Nt=gt=>rt?.announce?.(lt(gt),{repeat:!0});vt.removeAction("clearAll");const $t=()=>{vt.removeAction("clearAllConfirm"),vt.removeAction("clearAllKeep"),vt.addAction(ot(He,lt,rt))};vt.addAction({name:"clearAllConfirm",title:()=>lt("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),$t(),Nt("a11y.annotate.cleared")}}),vt.addAction({name:"clearAllKeep",title:()=>lt("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>$t()}),Nt("a11y.annotate.confirmClear")}const dt=["pen","arrow","rect","highlight","erase","clearAll"];function st(He){let lt=null;return{rowCount:()=>{if(K(He.rows.matchCount))return He.rows.matchCount();const rt=He.pagination&&K(He.pagination.get)?He.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:He.rows.count()},totalRowCount:()=>K(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{lt||(lt=K(He.rendererHost)?He.rendererHost():{});const rt=K(lt.selectionSummary)?lt.selectionSummary():null;return rt&&rt.predicate?{count:rt.count}:null},selectedCount:()=>{const rt=He.selection&&He.selection.keys?He.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=He.selection;return!rt||!K(rt.cells)?[]:rt.cells().map(({key:vt,colId:Nt})=>He.rows.value(vt,Nt))},hiddenUnresolved:()=>K(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>K(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function wt(He,lt){for(const[rt,vt]of Object.entries(f||{}))He.register("editor",rt,vt);for(const[rt,vt]of Object.entries(i||{}))He.register("filter",rt,vt);for(const[rt,vt]of Object.entries(lt.components||{}))He.register("component",rt,vt);for(const[rt,vt]of Object.entries(lt.pipes||{}))He.register("pipe",rt,vt);for(const[rt,vt]of Object.entries(lt.totalFns||{}))He.register("totalFn",rt,vt)}function ct(He,lt,rt,vt,Nt,$t){const gt=[],Rt=lt.viewport;let Bt=null;if(rt.maximise!==!1&&(Bt=new we({element:$t,document:vt,onChange:()=>lt.invalidate("all"),captureScroll:()=>lt.scrollState(),restoreScroll:at=>lt.restoreScroll(at)}),He.maximise=Bt,gt.push(()=>Bt.destroy())),rt.statusBar){const at=typeof rt.statusBar=="object"?rt.statusBar:{},bt=new d;bt.init({document:vt,host:st(He),panels:at.panels,registry:at.registry,locale:He.get("locale"),messages:He.messages}),Rt.statusBar.appendChild(bt.element());const Mt=()=>{const en=Rt.statusBar.offsetHeight||Rt.statusBar.getBoundingClientRect?.().height||0;Rt.root.style.setProperty("--lattice-status-height",`${Math.ceil(en)}px`)},Ht=()=>{bt.refresh(),Mt()},Kt=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(en=>He.on(en,Ht));Ht(),Mt(),gt.push(()=>{for(const en of Kt)en();Rt.root.style.removeProperty("--lattice-status-height"),bt.destroy?.()})}const Qt=ce(rt.selection);if(Qt.ranges){const at=new ie({grid:He,renderer:lt,document:vt});at.mount(),He.ranges=at,gt.push(()=>at.destroy())}if(rt.import){const at=new ke({grid:He,renderer:lt,document:vt,settings:typeof rt.import=="object"?rt.import:{}});He.importer=at,gt.push(()=>at.destroy())}if(rt.historyBar){const at=typeof rt.historyBar=="object"?rt.historyBar.element:null,bt=new Ee;bt.init({document:vt,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Ht=>He.history.peek(Ht),list:()=>He.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(at||Rt.root).appendChild(bt.element());const Mt=[He.on("history:changed",()=>bt.refresh())];He.historyBar=bt,gt.push(()=>{for(const Ht of Mt)Ht();bt.destroy()})}if(rt.diff){const at=new ye({grid:He,renderer:lt});at.mount(),He.diffPainter=at,gt.push(()=>at.destroy())}if(rt.ai&&K(rt.ai.ask)){const at=new je;at.init({document:vt,grid:He,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const bt=rt.ai.element||Rt.root;bt===Rt.root?bt.insertBefore(at.element(),bt.firstChild):bt.appendChild(at.element()),He.promptBar=at,gt.push(()=>at.destroy())}if(rt.groupPanel){const at=typeof rt.groupPanel=="object"?rt.groupPanel:{},bt=new m;bt.init({document:vt,grid:He,host:J(He,vt,(Mt,Ht)=>lt.announce?.(Mt,Ht)),props:{header:Rt.header,hint:at.hint}}),Rt.root.insertBefore(bt.element(),Rt.header),He.groupPanel=bt;for(const Mt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])K(He.on)&>.push(He.on(Mt,()=>bt.refresh()));gt.push(()=>bt.destroy())}if(rt.kpis){const at=new me({grid:He,document:vt,kpis:rt.kpis});at.active&&(at.mount(),Rt.root.insertBefore(at.element(),Rt.header),He.kpiStrip=at,gt.push(()=>at.destroy()))}if(rt.toolPanel){const at=typeof rt.toolPanel=="object"?rt.toolPanel:{},bt=new _({grid:He,document:vt,root:Rt.root,panels:at.panels,openPanel:at.openPanel,side:at.side,icons:at.icons,actions:De(He,at,Bt,lt),announce:(Mt,Ht)=>lt.announce?.(Mt,Ht)});bt.mount(),He.toolPanel=bt,gt.push(()=>bt.destroy()),at.annotate===void 0&&(gt.push(He.on("presentation:started",()=>{for(const Mt of qe(He,lt))bt.addAction(Mt)})),gt.push(He.on("presentation:ended",()=>{for(const Mt of dt)bt.removeAction(Mt)})))}if(!!rt.pagination&&(()=>{const at=typeof rt.pagination=="object"?rt.pagination:{};return He.pagination.set({pageSize:Number(at.pageSize)||100}),He.pagination.get().pageSize>0})()){const at=typeof rt.pagination=="object"?rt.pagination:{},bt=new l;bt.init({document:vt,pageSize:at.pageSize,pageSizes:at.pageSizes,page:at.page,total:at.total,locale:He.get("locale"),messages:He.messages,onChange:({page:Kt,pageSize:en})=>He.pagination.set({page:Kt,pageSize:en})});const Mt=()=>{const Kt=He.pagination.get();bt.total=Kt.total,bt.counting=Kt.counting===!0,bt.hasMore=Kt.total==null&&Kt.pageCount>Kt.page+1,bt.page=Kt.page,bt.paint()};He.pagination.set({pageSize:bt.pageSize}),Mt();const Ht=["rows:changed","filter:changed","model:changed"].map(Kt=>He.on(Kt,Mt));Rt.statusBar.appendChild(bt.element()),gt.push(()=>{for(const Kt of Ht)Kt();bt.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const at=new ae({grid:He,document:vt,root:Rt.root});at.mount(),He.editBar=at,gt.push(()=>at.destroy())}else{const at=new te({grid:He,document:vt,renderer:lt,registry:Nt,cellLayer:lt.cellLayer});at.mount(),gt.push(()=>at.destroy())}const cn=new b({grid:He,document:vt,layer:Rt.overlays,registry:Nt});cn.mount(),gt.push(()=>cn.destroy());const _t=new T({grid:He,document:vt,host:Rt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:K(rt.contextMenu)?rt.contextMenu:void 0,headerItems:K(rt.columnMenu)?rt.columnMenu:void 0});if(_t.mount(),gt.push(()=>_t.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const at=new $;at.add(He);for(const bt of rt.alignedGrids)bt&&bt!==He&&at.add(bt);gt.push(()=>at.destroy())}const Wt=new q({grid:He,renderer:lt,document:vt,registry:Nt});Wt.active&&(Wt.mount(),gt.push(()=>Wt.destroy())),Object.defineProperty(He,"form",{configurable:!0,value:Object.freeze({open(at){return Wt.active?Wt.openRow(at):!1},openNew(at){return Wt.active?Wt.openNew(at):(D("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){Wt.active&&Wt.close()},save(){return Wt.active?Wt.save():!1},isOpen(){return Wt.active?Wt.open:!1}})}),gt.push(()=>{delete He.form}),Object.defineProperty(He,"icons",{configurable:!0,value:Object.freeze({get(at){const bt=t(at);return bt?{viewBox:bt.viewBox,paths:bt.paths.slice(),paint:bt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),gt.push(()=>{delete He.icons});const Pt=new M({grid:He,renderer:lt,document:vt});Pt.active&&(Pt.mount(),gt.push(()=>Pt.destroy()));const Ft=new S({grid:He,renderer:lt,document:vt});Ft.active&&(Ft.mount(),gt.push(()=>Ft.destroy()));const Dt=new A({grid:He,renderer:lt,document:vt});if(Dt.active){Dt.mount(),Dt.paint();const at=He.on("render:done",()=>Dt.paint());gt.push(()=>{at(),Dt.destroy()})}if(rt.shortcuts!==!1){const at=new x({grid:He,renderer:lt});at.mount(),gt.push(()=>at.destroy())}const Gt=new Ie({grid:He,renderer:lt,window:vt.defaultView||void 0});Gt.mount(),gt.push(()=>Gt.destroy());const Yt=new Ye({grid:He,renderer:lt,window:vt.defaultView||void 0});if(Yt.mount(),gt.push(()=>Yt.destroy()),rt.find!==!1){const at=new Te({grid:He,renderer:lt,document:vt,settings:rt.find});at.mount(),gt.push(()=>at.destroy())}const Zt=new Ke({grid:He,renderer:lt});Zt.mount(),gt.push(()=>Zt.destroy());const Xt=new it({grid:He,renderer:lt});Xt.mount(),gt.push(()=>Xt.destroy());const nn=new yt({grid:He,renderer:lt,maximiser:Bt});nn.mount(),gt.push(()=>nn.destroy());const Jt=new zt({grid:He,renderer:lt});Jt.mount(),gt.push(()=>Jt.destroy()),rt.environment||He.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let un=null;for(const[at,bt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])gt.push(He.on(at,()=>{un=bt}));gt.push(He.on("render:done",at=>{He.diagnostics.render(un||at.cause,at.phases),un=null}));const an=vt.defaultView;if(an&&K(an.requestAnimationFrame)){let at=an.requestAnimationFrame(function bt(Mt){He.diagnostics.frame(Mt),at=an.requestAnimationFrame(bt)});gt.push(()=>{K(an.cancelAnimationFrame)&&an.cancelAnimationFrame(at)})}const gn=new pe({grid:He,renderer:lt});if(gn.mount(),gt.push(()=>gn.destroy()),gt.push(He.on("presence:lockRefused",at=>gn.announceRefusal(at.peer))),He.presence&&He.presence.enabled){for(const Mt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])gt.push(He.on(Mt,()=>He.presence.publish()));let at="";gt.push(He.on("render:done",()=>{const Mt=lt.focusState&<.focusState(),Ht=Mt?`${Mt.rowKey}${Mt.colId}`:"";Ht!==at&&(at=Ht,He.presence.publish())}));const bt=$t.ownerDocument;if(bt&&K(bt.addEventListener)){const Mt=()=>He.presence.setPaused(bt.visibilityState==="hidden");bt.addEventListener("visibilitychange",Mt),Mt(),gt.push(()=>bt.removeEventListener("visibilitychange",Mt))}}const yn=new Ge({grid:He,renderer:lt});yn.mount(),gt.push(()=>yn.destroy());const bn=new Ue({grid:He,renderer:lt});bn.mount(),gt.push(()=>bn.destroy()),gt.push(He.on("facet:computed",()=>lt.refreshHeader?.())),Qt&&Qt.headerCheckbox===!0&>.push(He.on("selection:changed",()=>lt.refreshHeader?.())),gt.push(He.on("facet:expanded",()=>lt.invalidate("columns"))),gt.push(He.on("model:changed",()=>lt.invalidate("rows")));const qt=(at,bt)=>lt.announce?.(at,bt),pn=He.messages,Ut=(at,bt)=>pn.t(at,bt),mn=at=>Ut("count.rows",{count:at});gt.push(He.on("sort:changed",()=>{const at=He.sort.get();if(!at.length){qt(Ut("a11y.sort.cleared"));return}const bt=at.map(Mt=>{const Ht=He.columns.get(Mt.col);return Ut("a11y.sort.column",{column:Ht&&Ht.title||Mt.col,direction:Ut(Mt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});qt(Ut("a11y.sort.by",{columns:pn.list(bt)}))})),gt.push(He.on("filter:changed",()=>{const at=He.rows.matchCount?He.rows.matchCount():He.rows.count(),bt=He.rows.totalCount?He.rows.totalCount():at;qt(at===bt?Ut("a11y.filter.cleared",{rows:mn(bt)}):Ut("a11y.filter.applied",{shown:mn(at),total:mn(bt)}))})),gt.push(He.on("selection:changed",()=>{const at=He.selection.keys().length;qt(at===0?Ut("a11y.selection.cleared"):Ut("a11y.selection.count",{count:at}))})),gt.push(He.on("group:toggled",at=>{const bt=He.rows.byKey?He.rows.byKey(at.key):null,Mt=(bt&&(bt.groupLabel??bt.groupValue))??at.key;qt(Ut(at.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Mt,rows:mn(He.rows.count())}))})),gt.push(He.on("column:grouped",at=>{const bt=Array.isArray(at.columns)?at.columns:[];if(!bt.length){qt(Ut("a11y.group.cleared"));return}const Mt=bt.map(Ht=>{const Kt=He.columns.get(Ht);return Kt&&Kt.title||Ht});qt(Ut("a11y.group.by",{columns:pn.list(Mt)}))})),gt.push(He.on("page:changed",at=>{const bt=Number(at.size)||0,Mt=Number(at.total)||0,Ht=bt>0?Math.max(1,Math.ceil(Mt/bt)):1;qt(Ut("a11y.page.position",{page:(Number(at.page)||0)+1,pages:Ht}))}));let rn={added:0,removed:0},on=null;const Pn=()=>{on=null;const at=[];rn.added&&at.push(Ut("count.rowsAdded",{count:rn.added})),rn.removed&&at.push(Ut("count.rowsRemoved",{count:rn.removed})),rn={added:0,removed:0},at.length&&qt(pn.list(at))};gt.push(He.on("rows:changed",at=>{if(!at||typeof at.added!="number")return;const bt=Number(at.added)||0,Mt=Number(at.removed)||0;!bt&&!Mt||(rn.added+=bt,rn.removed+=Mt,on||(on=setTimeout(Pn,Ne)))})),gt.push(()=>{on&&clearTimeout(on)}),gt.push(He.on("rows:paused",()=>{on&&(clearTimeout(on),on=null),rn={added:0,removed:0},qt(Ut("a11y.updates.paused"),{repeat:!0})})),gt.push(He.on("rows:resumed",()=>qt(Ut("a11y.updates.resumed"),{repeat:!0})));let dn={count:0,first:null},fn=null;const _n=()=>{fn=null;const{count:at,first:bt}=dn;if(dn={count:0,first:null},!at||!bt)return;const Mt=He.columns.get(bt.colId),Ht=Mt&&Mt.title||bt.colId,Kt=bt.reason?Ut("a11y.edit.reason",{reason:bt.reason}):"";if(at===1){const en=bt.restored===void 0||bt.restored===null||bt.restored===""?Ut("value.empty"):String(bt.restored);qt(Ut("a11y.edit.refusedOne",{column:Ht,value:en,reason:Kt}),{repeat:!0});return}qt(Ut("a11y.edit.refusedMany",{count:at,reason:Kt}),{repeat:!0})};gt.push(He.on("cell:reverted",at=>{!at||!at.applied||(dn.count+=1,dn.first||(dn.first=at),fn||(fn=setTimeout(_n,150)))})),gt.push(()=>{fn&&clearTimeout(fn)}),gt.push(He.on("history:applied",at=>{const bt=!!(at&&at.direction==="redo"),Mt=at&&at.step&&at.step.label;qt(Mt?Ut(bt?"a11y.history.redo":"a11y.history.undo",{label:Mt}):Ut(bt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const wn=new Tt({grid:He,renderer:lt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});wn.mount(),gt.push(()=>wn.destroy()),He.annotate=wn,He.capture=async(at={})=>{const{blob:bt,width:Mt,height:Ht}=await At(lt.viewport.root,at);return(at.download===!0||at.download!==!1&&at.fileName)&&X(bt,at.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Mt,height:Ht,bytes:bt.size,mimeType:bt.type,fileName:at.fileName||null},"api"),bt};const vn=new nt({grid:He,document:vt,element:Rt.overlays,window:vt.defaultView||void 0});vn.mount(),gt.push(()=>vn.destroy());const Cn=new h({grid:He,document:vt,element:Rt.overlays});Cn.mount?.(),gt.push(()=>Cn.destroy?.());const En=new k({grid:He,host:He.rendererHost(),viewport:Rt,document:vt});return En.mount(),gt.push(()=>En.destroy()),gt}function pt(He){const lt=[],rt=vt=>{if(vt&&(vt.__lattice&<.push(vt),vt.children))for(const Nt of vt.children)rt(Nt)};return rt(He),lt}function jt(He,lt={}){(!He||typeof He!="object"||!("appendChild"in He))&&V("createGrid needs a host element as its first argument."),lt=F(lt);const rt=He.ownerDocument||(typeof document<"u"?document:null);rt||V("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const vt=rt.documentElement&&rt.documentElement.lang,Nt=!lt.licence&&K(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,$t={...lt};if(!lt.locale&&vt&&($t.locale=vt),Nt&&($t.licence=Nt),lt.views&<.views.local)if(lt.views.storage)D("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const _t=lt.views.local===!0?{}:lt.views.local;$t.views={...lt.views,storage:O(_t)}}const gt=L($t),Rt=gt.rendererHost();Rt.document=rt,wt(Rt.registry,lt),Rt.cellLayer=s(Rt),Rt.detailHost=new Se({grid:gt,document:He.ownerDocument||globalThis.document,createGrid:(_t,Wt)=>jt(_t,Wt)});const Bt=new u(He,Rt),Qt=gt.on("detail:toggled",()=>{Rt.detailHost.syncTarget(),Rt.detailHost.prune()}),hn=gt.on("config:changed",_t=>{_t&&_t.key==="detail"&&Rt.detailHost.reconfigure()});gt.on("destroy",()=>{Qt(),hn(),Rt.detailHost.destroy()}),Rt.detailHost.syncTarget(),gt.attachRenderer(Bt),Bt.mount();const sn=ct(gt,Bt,lt,rt,Rt.registry,He),cn=gt.destroy.bind(gt);return gt.destroy=()=>{for(const _t of sn)try{_t()}catch{}He.__lattice===gt&&(He.__lattice=null),cn()},He.__lattice=gt,gt}}),xe("packages/dom/src/hydrate.js",function(e,G){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return s}});const Q=G("packages/core/src/internal/util.js"),L=Q.isFunction,B=Q.warnOnce,W=G("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,H=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,K=G("packages/dom/src/createGrid.js").createGrid,D=new Set([...Object.keys(W),...Object.keys(H)]);function v(n,t){for(const r of n.children)if(r.tagName===t.toUpperCase())return r;return null}function O(n,t){const r=[];for(const o of n.children)o.tagName===t.toUpperCase()&&r.push(o);return r}function y(n,t){const r=L(n.getAttribute)?n.getAttribute("data-field"):null;return r||String(n.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${t}`}function u(n){const t=n.trim();if(t==="")return null;if(t==="true"||t==="false")return t==="true";const r=Number(t);return Number.isFinite(r)&&t!==""?r:t}function a(n){const t=v(n,"thead"),r=v(t||n,"tr"),f=(r?O(r,"th").length?O(r,"th"):O(r,"td"):[]).map((d,h)=>{const l=y(d,h),m={id:l,field:l,title:String(d.textContent||"").trim()||l},w=L(d.getAttribute)?d.getAttribute("data-type"):null;w&&(D.has(w)?m.type=w:B(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${l}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const k=L(d.getAttribute)?d.getAttribute("data-format"):null;return k&&(m.format=k),m}),c=v(n,"tbody"),g=(c?O(c,"tr"):O(n,"tr").filter(d=>d!==r)).map((d,h)=>{const l=O(d,"td"),w={__row:(L(d.getAttribute)?d.getAttribute("data-id"):null)||`row${h}`};return f.forEach((k,p)=>{w[k.field]=l[p]?u(String(l[p].textContent||"")):null}),w});return{columns:f,rows:g}}function s(n,t={}){const{columns:r,rows:o}=a(n),f=n.ownerDocument.createElement("div");return n.parentNode.insertBefore(f,n),n.parentNode.removeChild(n),K(f,{rowKey:"__row",columns:r,rows:o,...t,columns:t.columns!==void 0?t.columns:r,rows:t.rows!==void 0?t.rows:o})}}),xe("packages/dom/src/autoinit.js",function(e,G){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return D}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/dom/src/createGrid.js").createGrid,X=G("packages/dom/src/hydrate.js").hydrateTable;function H(v,O){const y=[];return L(v.hasAttribute)&&v.hasAttribute(O)&&y.push(v),L(v.querySelectorAll)&&y.push(...v.querySelectorAll(`[${O}]`)),y}function V(v){const O=v.parentNode;if(!O||!O.children)return null;const y=[...O.children],u=y.indexOf(v),a=[y[u+1],y[u-1]];for(const s of a)if(s&&s.tagName==="SCRIPT"&&L(s.getAttribute)&&s.hasAttribute("data-lattice-config"))return s;return null}function K(v){const O=V(v);if(!O)return{};try{return JSON.parse(O.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function D(v){const O=v||(typeof document<"u"?document:null);if(!O)return[];const y=[];for(const u of H(O,"data-lattice-grid")){if(u.__lattice)continue;const a=K(u);y.push(u.tagName==="TABLE"?X(u,a):F(u,a))}return y}}),xe("packages/modules/htmx/controller.js",function(e,G){"use strict";Object.defineProperty(e,"destroyWithin",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"initWithin",{enumerable:!0,get:function(){return F}});const L=G("packages/core/src/internal/util.js").isFunction;function B(W,X){if(!W||!L(X))return 0;let H=0;for(const V of X(W))V.__lattice&&L(V.__lattice.destroy)&&(V.__lattice.destroy(),H+=1);return H}function F(W,X){return!W||!L(X)?[]:X(W)}}),xe("packages/modules/htmx/history.js",function(e,G){"use strict";Object.defineProperty(e,"saveStateWithin",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"restoreStateWithin",{enumerable:!0,get:function(){return V}});const L=G("packages/core/src/internal/util.js").isFunction,B=G("packages/core/src/model/state.js"),F=B.serialiseState,W=B.restoreState;function X(K,D){const v=[];return K&&(L(K.hasAttribute)&&K.hasAttribute(D)&&v.push(K),L(K.querySelectorAll)&&v.push(...K.querySelectorAll(`[${D}]`))),v}function H(K,D){if(!K||!L(D))return 0;let v=0;for(const O of D(K))!O.__lattice||!L(O.setAttribute)||(O.setAttribute("data-lattice-state",F(O.__lattice)),v+=1);return v}function V(K,D){if(!K)return 0;const v=X(K,"data-lattice-grid").filter(y=>!y.__lattice);for(const y of v)for(;y.firstChild;)y.removeChild(y.firstChild);v.length&&L(D)&&D(K);let O=0;for(const y of X(K,"data-lattice-state")){const u=L(y.getAttribute)?y.getAttribute("data-lattice-state"):null;!u||!y.__lattice||(W(y.__lattice,u),O+=1)}return O}}),xe("packages/modules/htmx/rowmodel.js",function(e,G){"use strict";Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return D}});const Q=G("packages/dom/src/hydrate.js"),L=Q.coerceCell,B=Q.childTags,F=Q.firstChildTag,W=5e3;function X(v,O={}){const y=v.pagination.get(),u=O.limit??(y.pageSize||100);return{offset:O.offset??(y.page??0)*u,limit:u,sort:JSON.stringify(v.sort.get()),filters:JSON.stringify(v.filters.get())}}function H(v,O){let y;if(v.tagName==="TR")y=[v];else{const u=F(v,"tbody")||v;y=B(u,"tr").length?B(u,"tr"):B(v,"tr")}return y.map((u,a)=>{const s=B(u,"td"),t={__row:(typeof u.getAttribute=="function"?u.getAttribute("data-id"):null)||`row${a}`};return O.forEach((r,o)=>{t[r.field]=s[o]?L(String(s[o].textContent||"")):null}),t})}function V(v){const O=JSON.parse(v);return Array.isArray(O)?{rows:O,total:void 0}:{rows:O.rows||[],total:O.total}}function K(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,O){if(/json/i.test(v.contentType||""))return V(v.text);const u=H(v.fragment,O);return K(u.length),{rows:u,total:void 0}}}),xe("packages/modules/htmx/oob.js",function(e,G){"use strict";Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return W}});const L=G("packages/core/src/internal/util.js").isFunction,F=G("packages/modules/htmx/rowmodel.js").rowsFromFragment;function W(X,H={}){const V=H.doc||(typeof document<"u"?document:null);if(!V||!L(V.addEventListener))return()=>{};const K=D=>{const v=D.detail,O=v&&v.target,y=O&&L(O.getAttribute)?O.getAttribute("data-lattice-row"):null;if(!y||!v.fragment)return;const u=H.columns||X.columns.visible().map(s=>({field:s.field||s.id})),[a]=F(v.fragment,u);a&&(delete a.__row,X.rows.apply({update:[{...a,[X.get("rowKey")]:y}]})),v.shouldSwap=!1};return V.addEventListener("htmx:oobBeforeSwap",K),()=>V.removeEventListener("htmx:oobBeforeSwap",K)}}),xe("packages/modules/htmx/servermode.js",function(e,G){"use strict";Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return D}});const L=G("packages/core/src/internal/util.js").isFunction,B=G("packages/modules/htmx/rowmodel.js"),F=B.queryParams,W=B.ingestResponse,X="lattice:query-changed";function H(v,O){const y=v.createElement("tbody");if(L(v.createRange)){const u=v.createRange();u.selectNodeContents(y),y.appendChild(u.createContextualFragment(O))}return y}function V(v,O,y={}){const u=O.ownerDocument;let a=!1;const s=i=>{i.target!==O||!i.detail||!i.detail.parameters||Object.assign(i.detail.parameters,F(v,y))},n=i=>{i.target===O&&(a=!0)},t=i=>{if(a=!1,i.target!==O)return;const g=i.detail&&i.detail.xhr&&i.detail.xhr.status,d=g?`Could not load rows (server responded ${g}).`:"Could not load rows, the request failed to reach the server.";v.overlay.show("empty",d)},r=i=>{if(i.target!==O||(a=!1,i.detail&&(i.detail.shouldSwap=!1),!i.detail||!i.detail.xhr||i.detail.isError))return;const{xhr:g}=i.detail,d=L(g.getResponseHeader)&&g.getResponseHeader("Content-Type")||"",h=i.detail.serverResponse??g.responseText??"",l=y.columns||v.columns.visible().map(k=>({field:k.field||k.id})),m=/json/i.test(d)?null:H(u,h),{rows:w}=W({contentType:d,text:h,fragment:m},l);v.rows.load(w)},o=()=>{if(a&&L(O.dispatchEvent)){const g=u.defaultView&&u.defaultView.CustomEvent;O.dispatchEvent(g?new g("htmx:abort"):{type:"htmx:abort",bubbles:!0})}const i=globalThis.htmx;i&&L(i.trigger)&&i.trigger(O,X)};u.addEventListener("htmx:configRequest",s),u.addEventListener("htmx:beforeRequest",n),u.addEventListener("htmx:beforeSwap",r),u.addEventListener("htmx:responseError",t),u.addEventListener("htmx:sendError",t);const f=v.on("sort:changed",o),c=v.on("filter:changed",o);return()=>{u.removeEventListener("htmx:configRequest",s),u.removeEventListener("htmx:beforeRequest",n),u.removeEventListener("htmx:beforeSwap",r),u.removeEventListener("htmx:responseError",t),u.removeEventListener("htmx:sendError",t),f(),c()}}const K="lattice:scroll-near-end";function D(v,O,y={}){const u=O.ownerDocument,a=y.threshold??20;let s=!1,n=!1;const t=p=>{p.target!==O||!p.detail||!p.detail.parameters||Object.assign(p.detail.parameters,F(v,{...y,offset:v.rows.count()}))},r=p=>{p.target===O&&(s=!0)},o=p=>{p.target===O&&(s=!1)},f=p=>{if(p.target!==O||(s=!1,p.detail&&(p.detail.shouldSwap=!1),!p.detail||!p.detail.xhr||p.detail.isError))return;const{xhr:b}=p.detail,E=L(b.getResponseHeader)&&b.getResponseHeader("Content-Type")||"",T=p.detail.serverResponse??b.responseText??"",P=y.columns||v.columns.visible().map(A=>({field:A.field||A.id})),x=/json/i.test(E)?null:H(u,T),{rows:C}=W({contentType:E,text:T,fragment:x},P);if(!C.length){n=!0;return}v.rows.apply({add:C})},c=()=>{n=!1},i=()=>{if(s||n)return;const p=globalThis.htmx;p&&L(p.trigger)&&p.trigger(O,K)};let g=!1;const d=()=>{g=!0},h=({last:p})=>{g&&(g=!1,(v.rows.count()===0||p>=v.rows.count()-1-a)&&i())};u.addEventListener("htmx:configRequest",t),u.addEventListener("htmx:beforeRequest",r),u.addEventListener("htmx:beforeSwap",f),u.addEventListener("htmx:responseError",o),u.addEventListener("htmx:sendError",o);const l=v.on("render:done",h),m=v.on("scroll",d),w=v.on("sort:changed",c),k=v.on("filter:changed",c);return()=>{u.removeEventListener("htmx:configRequest",t),u.removeEventListener("htmx:beforeRequest",r),u.removeEventListener("htmx:beforeSwap",f),u.removeEventListener("htmx:responseError",o),u.removeEventListener("htmx:sendError",o),l(),m(),w(),k()}}}),xe("packages/modules/htmx/index.js",function(e,G){"use strict";Object.defineProperty(e,"attach",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const L=G("packages/core/src/internal/util.js").isFunction,B=G("packages/dom/src/createGrid.js"),F=B.gridElementsWithin,W=G("packages/dom/src/autoinit.js"),X=W.autoInit,H=G("packages/modules/htmx/controller.js"),V=H.destroyWithin,K=H.initWithin,D=G("packages/modules/htmx/history.js"),v=D.saveStateWithin,O=D.restoreStateWithin;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return B.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return B.gridElementsWithin}});const y=G("packages/dom/src/hydrate.js");Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return y.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return y.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}});const u=G("packages/core/src/model/state.js");Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return u.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return u.restoreState}});const a=G("packages/core/src/index.js");Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return a.createHeadlessGrid}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return a.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return a.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return a.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return a.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return a.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return a.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return a.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return a.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return a.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return a.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return a.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return a.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return a.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return a.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return a.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return a.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return a.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return a.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return a.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return a.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return a.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return a.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return a.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return a.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return a.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return a.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return a.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return a.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return a.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return a.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return a.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return a.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return a.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return a.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return a.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return a.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return a.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return a.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return a.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return a.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return a.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return a.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return a.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return a.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return a.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return a.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return a.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return a.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return a.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return a.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return a.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return a.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return a.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return a.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return a.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return a.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return a.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return a.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return a.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return a.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return a.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return a.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return a.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return a.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return a.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return a.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return a.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return a.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return a.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return a.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return a.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return a.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return a.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return a.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return a.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return a.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return a.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return a.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return a.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return a.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return a.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return a.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return a.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return a.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return a.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return a.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return a.WINDOW_KINDS}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return a.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return a.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return a.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return a.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return a.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return a.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return a.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return a.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return a.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return a.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return a.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return a.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return a.createStreamSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return a.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return a.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return a.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return a.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return a.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return a.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return a.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return a.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return a.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return a.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return a.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return a.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return a.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return a.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return a.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return a.filtersToSql}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return a.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return a.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return a.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return a.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return a.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return a.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return a.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return a.STATE_VERSION}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return a.VERSION}});const s=G("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return s.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return s.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return s.toneOf}});const n=G("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return n.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return n.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return n.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 t=G("packages/modules/htmx/oob.js");Object.defineProperty(e,"driveOobUpdates",{enumerable:!0,get:function(){return t.driveOobUpdates}});const r=G("packages/modules/htmx/servermode.js");Object.defineProperty(e,"driveServerMode",{enumerable:!0,get:function(){return r.driveServerMode}}),Object.defineProperty(e,"driveInfiniteScroll",{enumerable:!0,get:function(){return r.driveInfiniteScroll}}),Object.defineProperty(e,"QUERY_CHANGED_EVENT",{enumerable:!0,get:function(){return r.QUERY_CHANGED_EVENT}}),Object.defineProperty(e,"SCROLL_NEAR_END_EVENT",{enumerable:!0,get:function(){return r.SCROLL_NEAR_END_EVENT}});const o=G("packages/modules/htmx/rowmodel.js");Object.defineProperty(e,"queryParams",{enumerable:!0,get:function(){return o.queryParams}}),Object.defineProperty(e,"rowsFromFragment",{enumerable:!0,get:function(){return o.rowsFromFragment}}),Object.defineProperty(e,"rowsFromJson",{enumerable:!0,get:function(){return o.rowsFromJson}}),Object.defineProperty(e,"ingestResponse",{enumerable:!0,get:function(){return o.ingestResponse}}),Object.defineProperty(e,"warnIfLargeHtmlPayload",{enumerable:!0,get:function(){return o.warnIfLargeHtmlPayload}}),Object.defineProperty(e,"HTML_ROW_WARNING_THRESHOLD",{enumerable:!0,get:function(){return o.HTML_ROW_WARNING_THRESHOLD}});function f(i){const g=i||(typeof document<"u"?document:null);if(!g||!L(g.addEventListener))return()=>{};const d=w=>V(w.target,F),h=w=>K(w.detail&&w.detail.elt||w.target,X),l=w=>{v(w.detail&&w.detail.historyElt||g,F)},m=w=>{w.detail&&w.detail.cacheMiss||O(g,X)};return g.addEventListener("htmx:beforeCleanupElement",d),g.addEventListener("htmx:load",h),g.addEventListener("htmx:beforeHistorySave",l),g.addEventListener("htmx:historyRestore",m),()=>{g.removeEventListener("htmx:beforeCleanupElement",d),g.removeEventListener("htmx:load",h),g.removeEventListener("htmx:beforeHistorySave",l),g.removeEventListener("htmx:historyRestore",m)}}f();const c=f});try{Ln("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 Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return oe}});const fe="1.81.0";async function he(){return fe}const Q="1.81.0",z=new Set,ne=2e3;function _(w){if(z.add(w),z.size>ne){const v=z.values().next().value;v!==void 0&&z.delete(v)}}const T=[],K=500;function ie(w,v,Z){T.push({key:w,level:v,message:Z.map(x=>typeof x=="string"?x:J(x)).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 le(){return T.map(w=>({...w}))}function ue(w){if(w.length===0||typeof w[0]!="string")return w;const v=w[0].replace(/^\\[lattice\\]\\s*/,"");return v===w[0]?w:[v,...w.slice(1)]}function W(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"warn",Z),console.warn("[lattice]",...Z)}function L(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"info",Z),console.info("[lattice]",...Z)}function Y(){z.clear(),T.length=0}function ee(w,v){const Z=new Error(`[lattice] ${w}`);throw v!==void 0&&(Z.cause=v),Z}function C(w,v){w||ee(v)}const A=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function s(w){return typeof w=="function"}function u(w){return w==null}function f(w){return w==null||w===""}function l(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const t=new Map;function a(w){let v=t.get(w);if(v)return v;if(!w.includes("."))v=Z=>Z?.[w];else{const Z=w.split("."),x=Z.length;v=de=>{let we=de;for(let ge=0;ge<x;ge++){if(we==null)return;we=we[Z[ge]]}return we}}return t.set(w,v),v}const m=new Map;function e(w){let v=m.get(w);if(v)return v;if(!w.includes("."))v=(Z,x)=>{Z!=null&&(Z[w]=x)};else{const Z=w.split("."),x=Z.length-1;v=(de,we)=>{let ge=de;for(let pe=0;pe<x;pe++){if(ge==null)return;const Te=Z[pe];ge[Te]==null&&(ge[Te]={}),ge=ge[Te]}ge!=null&&(ge[Z[x]]=we)}}return m.set(w,v),v}function d(w,v){return a(v)(w)}function h(w,v,Z){e(v)(w,Z)}function r(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(/^./,Z=>Z.toUpperCase()):""}const n={"&":"&","<":"<",">":">",\'"\':""","\'":"'"};function c(w){const v=w==null?"":String(w);return/[&<>"\']/.test(v)?v.replace(/[&<>"\']/g,Z=>n[Z]):v}function g(w){return String(w).replace(/\\w\\S*/g,v=>v[0].toUpperCase()+v.slice(1).toLowerCase())}function M(w,v,Z){if(w!==void 0)return w===!0?{enabled:!0,...Z}:w===!1?{enabled:!1}:i(w)?w:{[v]:w,enabled:!0}}function N(w){return w==null?[]:Array.isArray(w)?w:[w]}const G=Object.freeze(new Set(["__proto__","constructor","prototype"]));function F(w,v){if(!i(w))return i(v)?{...v}:v;if(!i(v))return v===void 0?w:v;const Z={...w};for(const x of Object.keys(v)){if(G.has(x))continue;const de=v[x];de!==void 0&&(Z[x]=i(de)&&i(Z[x])?F(Z[x],de):de)}return Z}function R(w,v){if(!i(w)||!i(v)||w===v)return v;const Z=Object.create(Object.getPrototypeOf(w));return Object.assign(Z,w,v),Z}class X{#t;#e=new Map;#n;constructor(v=256,Z=null){this.#t=v,this.#n=Z}get size(){return this.#e.size}get max(){return this.#t}set max(v){this.#t=v,this.#r()}has(v){return this.#e.has(v)}get(v){const Z=this.#e;if(!Z.has(v))return;const x=Z.get(v);return Z.delete(v),Z.set(v,x),x}peek(v){return this.#e.get(v)}set(v,Z){const x=this.#e;return x.has(v)&&x.delete(v),x.set(v,Z),this.#r(),Z}delete(v){const Z=this.#e.get(v);return this.#e.delete(v)&&this.#n&&this.#n(Z,v),Z}clear(){if(this.#n)for(const[v,Z]of this.#e)this.#n(Z,v);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const v=this.#e;for(;v.size>this.#t;){const Z=v.keys().next().value,x=v.get(Z);v.delete(Z),this.#n&&this.#n(x,Z)}}}const E=new Map;function S(w,v){const Z=`${w||""}|${v?JSON.stringify(v):""}`;let x=E.get(Z);return x||(x=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...v}),E.set(Z,x)),x}function U(w,v){if(w===v)return 0;if(w==null)return 1;if(v==null)return-1;if(typeof w=="number"&&typeof v=="number")return Number.isNaN(w)?Number.isNaN(v)?0:1:Number.isNaN(v)||w<v?-1:w>v?1:0;const Z=String(w),x=String(v);return Z<x?-1:Z>x?1:0}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const $=typeof requestAnimationFrame=="function";function re(w){return $?requestAnimationFrame(w):setTimeout(()=>w(H()),16)}function te(w){w!=null&&($?cancelAnimationFrame(w):clearTimeout(w))}function ae(w){let v=null,Z=null;const x=()=>{v=null;const we=Z;Z=null,w(...we||[])},de=(...we)=>{Z=we,v===null&&(v=re(x))};return de.cancel=()=>{te(v),v=null,Z=null},de.flush=()=>{v!==null&&(te(v),x())},de}function p(w,v){let Z=null,x=null;const de=()=>{if(Z=null,x===null)return;const pe=x;x=null,w(...pe),we()},we=()=>{Z=setTimeout(de,v),typeof Z?.unref=="function"&&Z.unref()},ge=(...pe)=>{Z===null?(w(...pe),we()):(x=pe,clearTimeout(Z),we())};return ge.flush=()=>{if(Z!==null&&clearTimeout(Z),Z=null,x===null)return;const pe=x;x=null,w(...pe)},ge.cancel=()=>{Z!==null&&clearTimeout(Z),Z=null,x=null},ge.pending=()=>Z!==null||x!==null,ge}function B(w,v=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:v}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let q=0;function oe(w="l"){return`${w}${(++q).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 ne}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),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 ue}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.isFunction,z=1,ne=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),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?ie(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ie(s){return Array.isArray(s)?s:Q(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 le{#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 l=0;l<u.length;l++){let t=u[l];for(;t;)t&=t-1,f++}return f}}class ue{#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 l=this.#t.length;return this.#t.push(u),this.#e.set(u,l),this.#n++,l}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",l=this.#r.get(f);if(l&&l.version===this.#n)return l.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 c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),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 W(s){if(s==null)return null;const u=s.presence?new le(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ue(s.dict):null,l=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(l[e]):l[e];case"bitset":return(l[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(l[n]):l[n];return r}default:return l[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:l,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]=W(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let l=0;l<s.length;l++)if(s[l].length>=f){const t=s.splice(l,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let l=0;l<u.length;l++)if(u[l].length>=f)return u.splice(l,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=l=>{if(!ee(l))return;const t=l.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 l of s)f(l);return u}if(typeof s=="object")for(const l of Object.keys(s)){const t=s[l];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function A(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 l of s)if(!A(l,u+1))return!1;return!0}for(const l of Object.keys(s))if(!A(s[l],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 l=f.conditions;if(Array.isArray(l))for(const t of l)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 ne=Math.max(0,z|0);this.#n=ne,this.#e=new Uint8Array(Math.ceil(ne/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,ne){return ne?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const ne=Math.max(0,z|0);if(ne<=this.#n)return this;const _=Math.ceil(ne/fe);if(_>this.#e.length){const T=new Uint8Array(_);T.set(this.#e),this.#e=T}return this.#n=ne,this}count(){const z=this.#e,ne=he.#t;let _=0;for(let T=0;T<z.length;T++)_+=ne[z[T]];return _}and(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]&=ne[K];for(let K=T;K<_.length;K++)_[K]=0;return this}or(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]|=ne[K];return this}not(){const z=this.#e;for(let ne=0;ne<z.length;ne++)z[ne]=~z[ne]&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 ne=this.#n>>3;ne<this.#e.length&&(this.#e[ne]&=(1<<z)-1)}static from(z){const ne=Array.isArray(z)?z:Array.from(z),_=new he(ne.length);for(let T=0;T<ne.length;T++)ne[T]&&_.set(T);return _}}}),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,Q=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let T=0;T<_.length;T++){const K=_[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 _=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(_+=K.length*2),_+=16}return _}codeOf(_){const T=this.#e.get(_);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(_),this.#e.set(_,K),this.#n++,K}lookup(_){const T=this.#e.get(_);return T===void 0?-1:T}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const T=_||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,ie=new Array(K);for(let W=0;W<K;W++)ie[W]=W;const J=he(_).compare,le=this.#t;ie.sort((W,L)=>this.#h(le[W],le[L],J));const ue=new Uint32Array(K);for(let W=0;W<K;W++)ue[ie[W]]=W;return this.#r=ue,this.#i=this.#n,this.#s=T,ue}#h(_,T,K){return typeof _=="string"&&typeof T=="string"?K(_,T):Q(_,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(Q={}){const z=Math.max(1,Q.rows??16),ne=Math.max(1,Q.values??z);this.#t=new Int32Array(ne),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(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,z){if(Q<0||Q>=this.#n)return!1;const ne=this.#t,_=this.#e[Q+1];for(let T=this.#e[Q];T<_;T++)if(ne[T]===z)return!0;return!1}hasAny(Q,z){for(let ne=0;ne<z.length;ne++)if(this.has(Q,z[ne]))return!0;return!1}hasAll(Q,z){for(let ne=0;ne<z.length;ne++)if(!this.has(Q,z[ne]))return!1;return!0}hasNone(Q,z){return!this.hasAny(Q,z)}push(Q){const z=this.#n,ne=Q.length;this.#i(z+1),this.#s(this.#r+ne);const _=this.#r;for(let T=0;T<ne;T++)this.#t[_+T]=Q[T]|0;return this.#r+=ne,this.#n=z+1,this.#e[z]=_,this.#e[z+1]=this.#r,z}write(Q,z){if(Q===this.#n){this.push(z);return}if(Q<0||Q>this.#n)return;const ne=this.#e[Q],_=this.#e[Q+1],T=z.length;if(_-ne===T){for(let K=0;K<T;K++)this.#t[ne+K]=z[K]|0;return}this.#h(Q,z)}compact(Q,z,ne){const _=this.#t,T=this.#e,K=this.#n,ie=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let le=0;for(let ue=0;ue<K;ue++){if(Q[ue]===ne)continue;const W=T[ue],L=T[ue+1];J[Q[ue]]=le;for(let Y=W;Y<L;Y++)ie[le++]=_[Y];J[Q[ue]+1]=le}this.#t=ie,this.#e=J,this.#n=z,this.#r=le}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<Q;)z=z*2||16;const ne=new Uint32Array(z+1);ne.set(this.#e),this.#e=ne}#s(Q){if(Q<=this.#t.length)return;let z=this.#t.length;for(;z<Q;)z=z*2||16;const ne=new Int32Array(z);ne.set(this.#t),this.#t=ne}#h(Q,z){const ne=this.#t,_=this.#e,T=this.#n,K=z.length-(_[Q+1]-_[Q]),ie=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(_.length);let le=0;for(let ue=0;ue<T;ue++){if(J[ue]=le,ue===Q)for(let W=0;W<z.length;W++)ie[le++]=z[W]|0;else for(let W=_[ue];W<_[ue+1];W++)ie[le++]=ne[W];J[ue+1]=le}this.#t=ie,this.#e=J,this.#r=le}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return A}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare,z=fe.warnOnce;function ne(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(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 l=null;typeof s.from=="function"?l=s.from([!1,!0]):(l=new s(8),l.set(1));const t=l&&l.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function ie(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:ie(i.presence)}function le(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ue(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function W(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const l=u[s],t=u[s+1];if(!(t>l))return[];const a=i.dict,m=new Array(t-l);for(let e=l;e<t;e++)m[e-l]=a?ue(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 l=i.dict;return u?t=>u(t)?ue(l,s[t]):null:t=>ue(l,s[t])}if(f==="bitset"){const l=ie(s);return u?t=>u(t)?l(t)===1:null:t=>l(t)===1}if(f==="multi")return u?l=>u(l)?W(i,l):null:l=>W(i,l);if(!s&&typeof i.get=="function"){const l=i.get.bind(i);return t=>{const a=l(t);return a===void 0?null:a}}return u?l=>{if(!u(l))return null;const t=s[l];return t===void 0?null:t}:l=>{const t=s[l];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const l=Object.is(i,-0),t=Object.is(s,-0);return l===t?0:l?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const l=typeof u,t=typeof f;if(l==="string"&&t==="string")return s.compare(u,f);if(l==="number"&&t==="number")return Y(u,f);if(l==="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 Y(a,m)}return Q(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,l=ee(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>l(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 A(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 l}}),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 R}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,Q=fe.dictRanks,z=fe.dictSize,ne=fe.identity,_=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,ie=fe.valueComparator,J=fe.valueReader,le=new Uint32Array(0),ue=new ArrayBuffer(8),W=new Float64Array(ue),L=new Uint32Array(ue),Y=(W[0]=-1,(L[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function C(E,S){W[0]=E;let U=L[Y],H=L[ee];(U&2147483648)!==0?(U=~U>>>0,H=~H>>>0):U=(U^2147483648)>>>0,S[0]=H,S[1]=U}function A(E,S,U,H){if(H<2)return E;const $=new Uint32Array(256*8);for(let w=0;w<H;w++){const v=S[w],Z=U[w];$[v&255]++,$[256+(v>>>8&255)]++,$[512+(v>>>16&255)]++,$[768+(v>>>24&255)]++,$[1024+(Z&255)]++,$[1280+(Z>>>8&255)]++,$[1536+(Z>>>16&255)]++,$[1792+(Z>>>24&255)]++}let re=E,te=S,ae=U,p=new Uint32Array(H),B=new Uint32Array(H),q=new Uint32Array(H);const oe=new Uint32Array(256);for(let w=0;w<8;w++){const v=w<<8,Z=(w&3)<<3,x=w>=4;let de=!1;for(let pe=0;pe<256;pe++)if($[v+pe]===H){de=!0;break}if(de)continue;let we=0;for(let pe=0;pe<256;pe++)oe[pe]=we,we+=$[v+pe];for(let pe=0;pe<H;pe++){const Te=te[pe],Le=ae[pe],Be=(x?Le:Te)>>>Z&255,ze=oe[Be]++;p[ze]=re[pe],B[ze]=Te,q[ze]=Le}let ge=re;re=p,p=ge,ge=te,te=B,B=ge,ge=ae,ae=q,q=ge}return re}function i(E,S,U){if(U<2)return E;const H=new Uint32Array(256*4);for(let B=0;B<U;B++){const q=S[B];H[q&255]++,H[256+(q>>>8&255)]++,H[512+(q>>>16&255)]++,H[768+(q>>>24&255)]++}let $=E,re=S,te=new Uint32Array(U),ae=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const q=B<<8,oe=B<<3;let w=!1;for(let x=0;x<256;x++)if(H[q+x]===U){w=!0;break}if(w)continue;let v=0;for(let x=0;x<256;x++)p[x]=v,v+=H[q+x];for(let x=0;x<U;x++){const de=re[x],we=p[de>>>oe&255]++;te[we]=$[x],ae[we]=de}let Z=$;$=te,te=Z,Z=re,re=ae,ae=Z}return $}function s(E,S,U,H){const $=new Uint32Array(H+1);for(let ae=0;ae<U;ae++)$[S[ae]]++;let re=0;for(let ae=0;ae<=H;ae++){const p=$[ae];$[ae]=re,re+=p}const te=new Uint32Array(U);for(let ae=0;ae<U;ae++)te[$[S[ae]]++]=E[ae];return te}function u(E,S,U,H){return U<2?E:H<=65536||H<=U*2?s(E,S,U,H):i(E,S,U)}function f(E,S){return E.length===S&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,S)}function l(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=new Uint32Array($),te=new Uint32Array($),ae=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let q=0,oe=0;for(let Z=0;Z<$;Z++){const x=H[Z],de=E[x];if(Number.isNaN(de)){p[oe++]=x;continue}C(de,B),U?(te[q]=~B[0]>>>0,ae[q]=~B[1]>>>0):(te[q]=B[0],ae[q]=B[1]),re[q++]=x}const w=A(re.subarray(0,q),te.subarray(0,q),ae.subarray(0,q),q);if(oe===0)return f(w,q);const v=new Uint32Array($);return v.set(w.subarray(0,q),0),v.set(p.subarray(0,oe),q),v}function t(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=Uint32Array.from(H),te=new Uint32Array($);for(let ae=0;ae<$;ae++){const p=(E[re[ae]]^2147483648)>>>0;te[ae]=U?~p>>>0:p}return f(i(re,te,$),$)}function a(E,S,U={}){const H=S||ne(K(E,U)),$=H.length;if($<2)return Uint32Array.from(H);const re=Q(E.dict,U.locale),te=E.values,ae=T(E),p=Math.max(z(E.dict),re.length),B=p,q=Uint32Array.from(H),oe=new Uint32Array($),w=!!U.descending;for(let v=0;v<$;v++){const Z=q[v];let x=ae&&ae(Z)===0?B:re[te[Z]];x===void 0&&(x=B),oe[v]=w?B-x:x}return f(u(q,oe,$,p+1),$)}function m(E,S,U){const H=S.length;let $=Uint32Array.from(S);if(H<2)return $;let re=new Uint32Array(H);for(let te=1;te<H;te<<=1){for(let p=0;p<H;p+=te<<1){const B=Math.min(p+te,H),q=Math.min(p+(te<<1),H);let oe=p,w=B,v=p;for(;oe<B&&w<q;)re[v++]=U(E[$[oe]],E[$[w]])<=0?$[oe++]:$[w++];for(;oe<B;)re[v++]=$[oe++];for(;w<q;)re[v++]=$[w++]}const ae=$;$=re,re=ae}return $}function e(E,S,U){const H=he(E.values),$=S.length,re=new Uint32Array($),te=U?1:0;let ae=0;for(let p=0;p<$;p++)H(S[p])===te&&(re[ae++]=S[p]);for(let p=0;p<$;p++)H(S[p])!==te&&(re[ae++]=S[p]);return re}function d(E,S){const U=E.values,H=E.kind;if((H==="object"||H===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!E.presence)return U;const re=J(E),te=new Array(K(E)||0);for(let ae=0;ae<S.length;ae++){const p=S[ae];te[p]=re(p)}return te}function h(E,S){for(let U=0;U<S.length;U++)if(typeof E[S[U]]!="string")return!1;return!0}function r(E,S,U,H,$){const re=E.length,te=Uint32Array.from(E);if(re<2||H<1)return te;const ae=new Uint32Array(re),p=H-1;for(let B=0;B<re;B++){const q=U[S[B]];ae[B]=$?p-q:q}return f(u(te,ae,re,H),re)}function n(E,S,U){const H=ie(U),$=new Array(S);for(let te=0;te<S;te++)$[te]=te;$.sort((te,ae)=>H(E[te],E[ae])||te-ae);const re=new Uint32Array(S);for(let te=0;te<S;te++)re[$[te]]=te;return re}function c(E,S,U){const H=S.length,$=new Map,re=[],te=new Uint32Array(H);for(let B=0;B<H;B++){const q=E[S[B]];let oe=$.get(q);oe===void 0&&(oe=re.length,$.set(q,oe),re.push(q)),te[B]=oe}const ae=re.length,p=n(re,ae,U.locale);return r(S,te,p,ae,!!U.descending)}function g(E,S,U){const H=d(E,S);if(S.length>=2&&h(H,S)){const te=E.stringRank;return te&&te.version===E.version&&te.usable(S,H,U.locale)?te.sort(S,U):c(H,S,U)}const $=ie(U.locale),re=U.descending?(te,ae)=>$(ae,te):$;return m(H,S,re)}function M(E,S,U){const H=d(E,S),$=U.compare,te=!!U.descending?(ae,p)=>-$(ae,p,void 0,void 0,!0):(ae,p)=>$(ae,p,void 0,void 0,!1);return m(H,S,te)}function N(E,S){const U=S.length,H=T(E),$=E.values,re=E.kind==="float64"&&!!$,te=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!H&&!re&&!te)return{present:S,absent:le};const ae=new Uint32Array(U),p=new Uint32Array(U);let B=0,q=0;if(H&&re)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1&&!Number.isNaN($[w])?ae[B++]=w:p[q++]=w}else if(re&&!H)for(let oe=0;oe<U;oe++){const w=S[oe];Number.isNaN($[w])?p[q++]=w:ae[B++]=w}else if(H&&!te)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1?ae[B++]=w:p[q++]=w}else{const oe=J(E);for(let w=0;w<U;w++){const v=S[w];_(oe(v))?p[q++]=v:ae[B++]=v}}return q===0?{present:S,absent:le}:{present:ae.subarray(0,B),absent:p.subarray(0,q)}}function G(E,S,U){if(S.length===0)return E;const H=new Uint32Array(E.length+S.length);return U?(H.set(S,0),H.set(E,S.length)):(H.set(E,0),H.set(S,E.length)),H}function F(E,S,U={}){const H=S||ne(K(E,U));if(!E||H.length<2)return Uint32Array.from(H);const{present:$,absent:re}=N(E,H);if($.length===0)return Uint32Array.from(H);const te=!!U.descending;let ae;if(typeof U.compare=="function")ae=M(E,$,U);else switch(E.kind){case"float64":ae=l(E.values,$,te);break;case"int32":ae=t(E.values,$,te);break;case"dictionary":ae=a(E,$,U);break;case"bitset":ae=e(E,$,te);break;default:ae=g(E,$,U);break}return G(ae,re,!!U.nullsFirst)}function R(E,S,U,H={}){const $=S||[],re=$.length&&($[0].handle||X(E,$[0].col))||E&&E[0];let te=U||ne(K(re,H));for(let ae=$.length-1;ae>=0;ae--){const p=$[ae],B=p.handle||X(E,p.col)||E&&E[ae];B&&(te=F(B,te,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:H.locale,compare:p.compare}))}return te instanceof Uint32Array?te:Uint32Array.from(te)}function X(E,S){if(!(!E||S===void 0)){for(let U=0;U<E.length;U++)if(E[U]&&E[U].id===S)return E[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 ne}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,Q=fe.rankSortStrings,z=1e5;class ne{#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 ie=0;ie<K.length;ie++)T+=K[ie].length*2+24;return T}#a(T,K){const ie=this.#e.get(T);if(ie!==void 0)return ie;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 ie=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ie);for(let J=0;J<ie;J++){const le=T[J],ue=typeof le=="string"?this.#a(le,!1):-1;this.#n[J]=ue<0?0:ue}this.#r=ie}append(T,K,ie){const J=(K|0)+(ie|0);if(J>this.#n.length){const le=new Uint32Array(J);le.set(this.#n.subarray(0,this.#r)),this.#n=le}for(let le=K|0;le<J;le++){const ue=T[le],W=typeof ue=="string"?this.#a(ue,!0):-1;this.#n[le]=W<0?0:W}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 ie=he(this.#t,this.#t.length,T);return this.#o=ie,this.#c=this.#i,this.#l=K,ie}usable(T,K,ie){if(this.#u||this.#t.length===0)return!1;const J=this.#n,le=this.#t,ue=this.#r;for(let W=0;W<T.length;W++){const L=T[W];if(L>=ue||le[J[L]]!==K[L])return!1}return!0}sort(T,K){const ie=this.ranks(K.locale),J=this.#t.length,le=T.length,ue=new Uint32Array(le),W=this.#n;for(let L=0;L<le;L++)ue[L]=W[T[L]];return Q(T,ue,ie,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return W}}),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,Q=fe.isFunction,z=fe.pathGetter,_=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,ue=me("packages/core/src/store/stringrank.js").StringRankIndex,W=4294967295,L=1024,Y=5e3,ee=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function A(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 A(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 l(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 c=d;c<h;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const 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=Q(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 ue(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,c=this.#m;let g=!1;switch(this.#e){case"float64":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]);if(typeof G=="number"){n&&c.set(d+N),M[d+N]=G;continue}const F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?NaN:i(G)}break}case"int32":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?0:s(G)}break}case"bitset":{const M=this.#c;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M.assign(d+N,!F&&!!G)}break}case"dictionary":{const M=this.#o,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0),M[d+G]=R?0:N.codeOf(F)}break}case"multi":{const M=this.#l,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0);const X=u(F),E=new Array(X.length);for(let S=0;S<X.length;S++)E[S]=N.codeOf(X[S]);M.write(d+G,E)}break}default:{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=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 c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let M=0;M<h;M++)this.#c.assign(d+M,(g[M>>3]&1<<(M&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],M=new Uint32Array(g.length);for(let R=0;R<g.length;R++)M[R]=this.#a.codeOf(g[R]);const N=e.values,G=this.#o,F=r;for(let R=0;R<h;R++){if(F&&(n&&(n[R>>3]&1<<(R&7))===0)){G[d+R]=0;continue}G[d+R]=M[N[R]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],M=new Uint32Array(g.length);for(let F=0;F<g.length;F++)M[F]=this.#a.codeOf(g[F]);const N=e.values,G=e.offsets;for(let F=0;F<h;F++){const R=G[F],X=G[F+1],E=new Array(X-R);for(let S=R;S<X;S++)E[S-R]=M[N[S]]??0;this.#l.write(d+F,E)}this.#f++;return}for(let g=0;g<h;g++){const M=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,M?null:l(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 c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?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[c,g]of r)e[c]!==W&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==W&&(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]!==W&&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,W);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==W&&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 _(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 _(d)),this.#p=d}#A(e,d){const h=A(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 c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);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 _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!A(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 _(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??Y:0,this.#w=d.compactRatio??ee;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 c=0;c<r;c++)this.#r[h+c]=d[c];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 c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,h,r):c.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?W:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)h[c]!==W&&(n[h[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(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 le}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,Q=fe.nextFrame,z=fe.infoOnce,ne=fe.warnOnce,_=fe.isFunction,T=fe.pathGetter,ie=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function le(A,i={}){if(i.multi)return"multi";if(A.length===0)return"object";let s=0,u=0,f=0,l=0,t=0;for(let m=0;m<A.length;m++){const e=A[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?l++:Array.isArray(e)&&t++}const a=A.length;return s===a?"float64":u===a?"bitset":l===a?"float64":f===a?"text":t===a?"multi":"object"}function ue(A,i,s){return i<=0||A<s*i?"dictionary":"object"}function W(A,i,s){const u=new Map,f=new Map;for(const c of A){if(c.computed)continue;const g=_(c.read)?c.read:T(c.field||c.id);f.set(c.id,g),u.set(c.id,g)}const l=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=l.filter(c=>_(t[c])),d=e.some(c=>a[c]==="*");let h=new WeakMap;const r=c=>{const g={};if(d)for(const[M,N]of f)g[M]=N(c);for(const M of e){const N=a[M];let G;if(N==="*")G=g;else{G={};const F=N||[];for(let R=0;R<F.length;R++){const X=F[R];G[X]=X in g?g[X]:f.get(X)?.(c)}}g[M]=t[M](m?m(G,M):G,{data:c,row:null,column:null,grid:null,context:s})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=h.get(c);return g===void 0&&(g=r(c),h.set(c,g)),g};for(const c of e)u.set(c,g=>n(g)[c]);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 Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=W(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ie(this.#e.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.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 l=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,l)),this.#a(this.#i,l),this.#i=l,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),l=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))){ne(`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)??(_(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=le(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=ue(r,d.length,l),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 l=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&l.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 l=this.#d(f);if(f.kind==="dictionary"&&l>=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=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&l>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&l<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${l} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(A,i={},s={}){const u=new Y(A,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(l=>{f(l)});return u.result()}function C(A,i={},s={}){const u=new Y(A,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 Y}});const he=me("packages/core/src/internal/util.js").pathGetter,Q=me("packages/core/src/store/ingest.js"),z=Q.inferKind,ne=Q.decideText,_=Q.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,ie=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const C of ee)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!ie.has(C.kind))return!1;return!0}function le(ee){const C=K(ee);return Number.isFinite(C)?C|0:0}function ue(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function W(ee,C,A,i){if(ee.kind)return ee.kind;const s=[];for(let l=0;l<C.length&&s.length<_.sampleSize;l++){const t=C[l];t!=null&&s.push(t)}const u=z(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return ne(f,s.length,i)}function L(ee,C,A={}){const i=C.length|0,s=A.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const l=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=l(C[r]);a[r]=n===void 0?null:n}const m=W(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 c=a[n],g=c===null;g||d(n),r[n]=g?NaN:K(c)}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 c=a[n],g=c===null;g||d(n),r[n]=g?0:le(c)}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 c=a[n],g=c===null;g||d(n),!g&&c&&(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=[],c=new Map;for(let g=0;g<i;g++){const M=a[g];if(M===null){r[g]=0;continue}d(g);let N=c.get(M);N===void 0&&(N=n.length,n.push(M),c.set(M,N)),r[g]=N}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let M=0;M<i;M++){const N=a[M];c[M]=g.length,N===null||d(M);const F=ue(N);for(let R=0;R<F.length;R++){const X=F[R];let E=n.get(X);E===void 0&&(E=r.length,r.push(X),n.set(X,E)),g.push(E)}}c[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=a[n];c!==null&&d(n),r[n]=c}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 Y(ee){const C=[];if(!ee||!Array.isArray(ee.columns))return C;const A=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of ee.columns)A(i.values),A(i.presence),A(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 Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ne}});function fe(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function he(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let T=0;T<_.length;T++)if(!he(_[T]))return!1;return!0}function z(_,T){const K=_.col!==void 0?_.col:_.handle&&_.handle.id,ie=_.locale!==void 0?_.locale:T;return{col:K,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:fe(ie)}}function ne(_,T){const K=_||[],ie=new Array(K.length);for(let J=0;J<K.length;J++)ie[J]=z(K[J],T);return ie}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),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 ue}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return W}}),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,Q=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(A){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<A.length;){const l=A[s];if(l==="\'"){if(A[s+1]==="\'"){u+="\'",s+=2;continue}const a=A.indexOf("\'",s+1);if(a===-1){u+=A.slice(s+1),s=A.length;continue}u+=A.slice(s+1,a),s=a+1;continue}const t=z.find(a=>A.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(l)&&Q(`date.pattern.token:${l}`,`the date pattern "${A}" contains \'${l}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=l,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(A){if(he(A)||A==="")return null;if(A instanceof Date)return Number.isNaN(A.getTime())?null:A;if(typeof A=="number")return Number.isNaN(A)?null:new Date(A);if(typeof A=="string"){const i=_.exec(A.trim());if(i){const[,u,f,l,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+l,+t,+a,+m)}const s=new Date(A);return Number.isNaN(s.getTime())?null:s}return null}function K(A,i){return String(A).padStart(i,"0")}function ie(A){if(!A)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:A,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 l of i.formatToParts(u))switch(l.type){case"year":f.year=Number(l.value);break;case"month":f.month=Number(l.value);break;case"day":f.day=Number(l.value);break;case"hour":f.hour=Number(l.value)%24;break;case"minute":f.minute=Number(l.value);break;case"second":f.second=Number(l.value);break;case"weekday":f.weekday=s[l.value]??0;break;default:break}return f}}function J(A,i,s){const u=ne(A),f=ie(s),l=new Set(u.filter(d=>d.token).map(d=>d.token)),t=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=l.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 le=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ue(A,i){const s=A||{},u=s.locale||i||void 0,f=s.nullDisplay??"",l=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,l);else if(s.dateStyle||s.timeStyle){const h={timeZone:l};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:l});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 c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[M,N]of le)if(Math.abs(g)>=N||M==="second")return a.format(Math.round(g/N),M)}}return t(n)};return d.spec=s,d}function W(A){if(he(A)||A==="")return null;if(typeof A=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(A.trim());if(u)return u[1];const f=T(A);return f?W(f):null}const i=T(A);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(A,i){if(he(A)||A==="")return null;if(typeof A=="string"){const u=A.trim();if(Y.test(u)){const t=T(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,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 l=T(u);return l?L(l):null}const s=T(A);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(A,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(A).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=`${A.getFullYear()}-${s(A.getMonth()+1)}-${s(A.getDate())}`,f=A.getSeconds(),l=`${s(A.getHours())}:${s(A.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${l}`}function C(A,i){const s=he(A)||A===""?null:String(A),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 X}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ae}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,Q=fe.toArray,z=fe.warnOnce,_=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,ie=T.dictSize,J=T.dictValue,le=T.presenceReader,ue=T.valueComparator,W=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(p,B){const q=p&&p.pool;if(q){const oe=q.mask||q.acquireMask||q.acquire||q.take;if(typeof oe=="function"){const w=oe.call(q,B);if(w&&w.length>=B)return w}}return new Uint8Array(B)}function C(p,B){const q=p&&p.pool;if(!q||!B)return;const oe=q.release||q.releaseMask||q.free||q.recycle;typeof oe=="function"&&oe.call(q,B)}function A(p,B,q){return p.fill(q,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 q=_(p);return q===null?u(p):q}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 l(p,B){const q=typeof p=="string"?p:String(p);return B?q:q.toLowerCase()}function t(p,B){return p==null?Y:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,q){const oe=new Set;for(const w of Q(p)){const v=s(w,q);oe.add(t(v,B)),typeof v=="string"&&v!==""&&Number.isFinite(Number(v))?oe.add(Number(v)):typeof v=="number"&&Number.isFinite(v)&&oe.add(t(String(v),B))}return oe}function m(p,B,q){if(p==null||B===null||B===void 0)return p==null&&B==null;const oe=typeof p,w=typeof B;return oe==="string"&&w==="string"?q?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):oe==="number"&&w==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):oe==="number"&&w==="string"?p===Number(B):oe==="string"&&w==="number"?Number(p)===B:oe==="boolean"||w==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((v,Z)=>m(v,B[Z],q)):p===B}function e(p,B){try{if(p instanceof RegExp){const q=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||q.includes("i")?q:`${q}i`)}return new RegExp(String(p),B?"":"i")}catch(q){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,q),null}}function d(p,B){const q=h(p,B),oe=p&&p.type;return oe!=="date"&&oe!=="dateString"?q:w=>q(typeof w=="string"&&L.test(w)?w:_(w)??w)}function h(p,B){const q=p&&p.op,oe=!!(p&&p.caseSensitive),w=p&&p.type,v=ue(B),Z=x=>de=>!x(de);switch(q){case"eq":{const x=s(p.value,w);return de=>m(de,x,oe)}case"ne":{const x=s(p.value,w);return de=>!m(de,x,oe)}case"lt":case"lte":case"gt":case"gte":{const x=s(p.value,w);if(i(x))return()=>!1;const de=q==="lt"?-1:q==="lte"?0:q==="gt"?1:2;return we=>{if(i(we))return!1;const ge=v(we,x);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const x=Q(p.value),de=s(x[0],w),we=s(x[1],w),ge=p.bounds||"[]",pe=ge.charAt(0)!=="(",Te=ge.charAt(1)!==")";if(i(de)||i(we))return q==="between"?()=>!1:()=>!0;const Le=Be=>{if(i(Be))return!1;const ze=v(Be,de),Ke=v(Be,we);return(pe?ze>=0:ze>0)&&(Te?Ke<=0:Ke<0)};return q==="between"?Le:Z(Le)}case"in":case"notIn":{const x=a(p.value,oe,w),de=we=>x.has(t(we,oe));return q==="in"?de:Z(de)}case"contains":case"notContains":{const x=l(s(p.value,w),oe),de=we=>we==null?!1:l(we,oe).includes(x);return q==="contains"?de:Z(de)}case"startsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).startsWith(x)}case"endsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).endsWith(x)}case"matches":{const x=e(p.value,oe);return x?de=>de==null?!1:x.test(String(de)):()=>!1}case"blank":return x=>he(x)||Array.isArray(x)&&x.length===0;case"notBlank":return x=>!(he(x)||Array.isArray(x)&&x.length===0);case"containsAny":case"containsNone":{const x=a(p.value,oe,w),de=we=>{const ge=we==null?[]:Q(we);for(let pe=0;pe<ge.length;pe++)if(x.has(t(ge[pe],oe)))return!0;return!1};return q==="containsAny"?de:Z(de)}case"containsAll":{const x=Q(p.value).map(de=>t(s(de,w),oe));return de=>{const we=de==null?[]:Q(de);if(x.length===0)return!0;const ge=new Set(we.map(pe=>t(pe,oe)));for(let pe=0;pe<x.length;pe++)if(!ge.has(x[pe]))return!1;return!0}}default:{const x=ae(q);return x?x.compile(p.value):(z(`op:${String(q)}`,`unknown filter operator "${String(q)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,q){return d(B,q)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,q){const oe=p&&p.op,w=n[oe]||oe,v=d({...p,op:w,type:B.type},q),Z=B.items,x=de=>{const we=Z(de);if(!we)return!1;for(let ge=0;ge<we.length;ge++)if(v(we[ge]))return!0;return!1};return n[oe]?de=>!x(de):x}function M(p,B,q,oe){const w=le(p);if(w){const x=B?1:0;for(let de=0;de<oe;de++)q[de]=w(de)===x?1:0;return q}const v=p.kind;if(v==="float64"||v==="int32"||v==="bitset")return A(q,oe,B?1:0);const Z=W(p);for(let x=0;x<oe;x++){const de=Z(x),we=he(de)||Array.isArray(de)&&de.length===0;q[x]=we===B?0:1}return q}function N(p,B,q,oe){const w=p.dict,v=ie(w),Z=new Uint8Array(v);for(let ge=0;ge<v;ge++)Z[ge]=B(J(w,ge))?1:0;const x=p.values,de=le(p);if(!de){for(let ge=0;ge<oe;ge++)q[ge]=Z[x[ge]];return q}const we=B(null)?1:0;for(let ge=0;ge<oe;ge++)q[ge]=de(ge)===1?Z[x[ge]]:we;return q}function G(p,B,q,oe){const w=K(p.values),v=B(!0)?1:0,Z=B(!1)?1:0,x=le(p);if(!x){for(let we=0;we<oe;we++)q[we]=w(we)===1?v:Z;return q}const de=B(null)?1:0;for(let we=0;we<oe;we++)q[we]=x(we)===0?de:w(we)===1?v:Z;return q}function F(p,B,q,oe,w){const v=p.values,Z=B.type,x=B.op;let de=!0;switch(x){case"eq":case"ne":{const ge=f(s(B.value,Z)),pe=typeof B.value=="number"&&Number.isNaN(B.value),Te=x==="ne"?1:0;if(pe)for(let Le=0;Le<w;Le++)oe[Le]=(Number.isNaN(v[Le])?1:0)^Te;else for(let Le=0;Le<w;Le++)oe[Le]=(v[Le]===ge?1:0)^Te;break}case"lt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<ge?1:0;break}case"lte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>ge?1:0;break}case"gte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>=ge?1:0;break}case"between":case"notBetween":{const ge=Q(B.value),pe=f(s(ge[0],Z)),Te=f(s(ge[1],Z)),Le=B.bounds||"[]",Be=Le.charAt(0)!=="(",ze=Le.charAt(1)!==")",Ke=x==="notBetween"?1:0;if(Be&&ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<=Te?1:0)^Ke;else if(Be)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<Te?1:0)^Ke;else if(ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<=Te?1:0)^Ke;else for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<Te?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Te of Q(B.value)){const Le=f(s(Te,Z));Number.isNaN(Le)||ge.add(Le)}const pe=x==="notIn"?1:0;for(let Te=0;Te<w;Te++)oe[Te]=(ge.has(v[Te])?1:0)^pe;break}default:de=!1;break}if(!de)return!1;const we=le(p);if(we){const ge=q(null)?1:0;for(let pe=0;pe<w;pe++)we(pe)===0&&(oe[pe]=ge)}return!0}function R(p,B,q,oe){const w=W(p);for(let v=0;v<oe;v++)q[v]=B(w(v))?1:0;return q}function X(p,B,q){const oe=B.count|0,w=q||ee(B,oe);if(!p)return A(w,oe,1);const v=typeof B.handle=="function"?B.handle(p.col):void 0,Z=typeof B.custom=="function"?B.custom:null;if(!v){if(Z){for(let ge=0;ge<oe;ge++)w[ge]=Z(p,ge)?1:0;return w}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),A(w,oe,0)}const x=p.op;if(x==="blank"||x==="notBlank")return M(v,x==="notBlank",w,oe);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ae(x)&&!c.has(x))return R(v,g(p,de,B.locale),w,oe);const we=d(p,B.locale);switch(v.kind){case"dictionary":return N(v,we,w,oe);case"bitset":return G(v,we,w,oe);case"float64":case"int32":return F(v,p,we,w,oe)?w:R(v,we,w,oe);default:return R(v,we,w,oe)}}function E(p,B,q){if(!p)return A(ee(B,q),q,1);if(Array.isArray(p.conditions)){const oe=p.conditions.filter(Z=>Z!=null),w=p.op==="or"?"or":p.op==="not"?"not":"and";if(oe.length===0)return A(ee(B,q),q,1);const v=E(oe[0],B,q);for(let Z=1;Z<oe.length;Z++){const x=E(oe[Z],B,q);if(w==="or")for(let de=0;de<q;de++)v[de]|=x[de];else for(let de=0;de<q;de++)v[de]&=x[de];C(B,x)}if(w==="not")for(let Z=0;Z<q;Z++)v[Z]^=1;return v}return X(p,B,ee(B,q))}function S(p,B){return E(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const q=p;if(Array.isArray(q.conditions)){if((q.op==="or"?"or":q.op==="not"?"not":"and")!=="and")return H(q,B)?null:p;const w=[];for(const v of q.conditions){const Z=U(v,B);Z&&w.push(Z)}return w.length?{...q,op:"and",conditions:w}:null}return q.col===B?null:p}function H(p,B){if(!p||typeof p!="object")return!1;const q=p;if(q.col===B)return!0;if(Array.isArray(q.conditions)){for(const oe of q.conditions)if(H(oe,B))return!0}return!1}function $(p,B,q){if(q&&q.length>=B){let Z=0;for(let x=0;x<B;x++)p[x]&&(q[Z++]=x);return q.subarray(0,Z)}let oe=0;for(let Z=0;Z<B;Z++)oe+=p[Z]?1:0;const w=new Uint32Array(oe);let v=0;for(let Z=0;Z<B;Z++)p[Z]&&(w[v++]=Z);return w}const re=new Map;function te(p){if(!(!p||typeof p!="object"))for(const[B,q]of Object.entries(p))q&&typeof q.compile=="function"&&re.set(B,q)}function ae(p){return typeof p=="string"?re.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 ue}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,Q=fe.identity,z=fe.presenceReader,ne=fe.rowCount,_=fe.valueReader,T="",K="\\0",ie=1<<20;function J(W,L,Y,ee){const C=W.length,A=W.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?A.map((t,a)=>ee[a]?m=>ee[a](t(m)):t):A;if(!i&&C>0&&W.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=W.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=W.map(r=>r.values),e=W.map(r=>z(r)),d=r=>{let n=0;for(let c=0;c<C;c++){const g=e[c],M=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+M}return n},h=new Float64Array(Y);for(let r=0;r<Y;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},l=new Array(Y);for(let t=0;t<Y;t++)l[t]=f(L[t]);return{packed:null,strings:l,product:1/0,readers:s,keyOf:f}}function le(W,L,Y,ee){const C=new Uint32Array(ee+1);for(let u=0;u<Y;u++)C[L[u]+1]++;for(let u=0;u<ee;u++)C[u+1]+=C[u];const A=new Uint32Array(Y),i=C.slice(0,ee);for(let u=0;u<Y;u++)A[i[L[u]]++]=W[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=A.subarray(C[u],C[u+1]);return s}function ue(W,L,Y={}){const ee=W||[],C=L||Q(ne(ee[0],Y)),A=C.length;if(ee.length===0||A===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(ee,C,A,Y.project),l=new Uint32Array(A);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ie,A*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<A;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<A;n++)l[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<A;r++){const n=i[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<A;r++){const n=s[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}}const m=le(C,l,A,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let c=0;c<f.length;c++)n[c]=f[c](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 _}}),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 ie}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return W}}),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 A}}),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,Q=fe.valueReader,z=fe.dictSize,ne=fe.dictValue,_=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,ie=50,J=1e4;function le(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const M=c&&c.base;if(M==="date"||M==="datetime"||M==="time"||M==="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 M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function ue(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return N=>c[N];const M=Q(n);return N=>W(M(N))}function W(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,c,g,M=ie){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 N=Q(n),G=c?c.length:g,F=new Set;for(let R=0;R<G;R++){const X=N(c?c[R]:R);if(X!=null&&(F.add(X),F.size>M))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Y=36e5,ee=864e5;function C(n,c=K){const g=Number.isFinite(n)&&n>0?n:0,M=Math.max(1,c)*2;return g/Y<=M?"hour":g/ee<=M?"day":g/(7*ee)<=M?"week":g/(30*ee)<=M?"month":g/(91*ee)<=M?"quarter":"year"}function A(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const M=(g.getDay()+6)%7;return g.setDate(g.getDate()-M),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,c,g){const M=ue(n),N=he(n),G=c?c.length:g;let F=1/0,R=-1/0,X=0,E=0;for(let S=0;S<G;S++){const U=c?c[S]:S;if(N&&!N(U)){X++;continue}const H=M(U);if(!Number.isFinite(H)){X++;continue}H<F&&(F=H),H>R&&(R=H),E++}return{min:F,max:R,nulls:X,finite:E}}function u(n,c,g,M){const N=ue(n),G=he(n),F=c?c.length:g,R=F>M?F/M:1,X=[];for(let S=0;S<F;S+=R){const U=c?c[Math.floor(S)]:Math.floor(S);if(G&&!G(U))continue;const H=N(U);Number.isFinite(H)&&X.push(H)}const E=Float64Array.from(X);return E.sort(),E}function f(n,c,g,M={}){const N=M.kind||le(n,M.type);return N==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:N==="boolean"?l(n,c,g):N==="category"?t(n,c,g,M):a(n,c,g,N,M)}function l(n,c,g){const M=he(n);let N=0;if(M){const F=c?c.length:g;for(let R=0;R<F;R++)M(c?c[R]:R)||N++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return N>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,c,g,M){const N=M.cardinalityLimit??ie,{cardinality:G}=L(n,c,g,N);if(G>N&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=Q(n),R=c?c.length:g,X=new Map;let E=0;for(let re=0;re<R;re++){const te=F(c?c[re]:re);if(te==null||te===""){E++;continue}if(Array.isArray(te)){if(!te.length){E++;continue}for(const ae of te)X.set(ae,(X.get(ae)||0)+1);continue}X.set(te,(X.get(te)||0)+1)}let S=[...X.entries()];M.order==="alpha"?S.sort((re,te)=>String(re[0]).localeCompare(String(te[0]))):S.sort((re,te)=>te[1]-re[1]);let U=0,H=0;if(S.length>N){H=S.length-N;for(let re=N;re<S.length;re++)U+=S[re][1];S=S.slice(0,N)}const $=S.map(([re])=>({value:re,label:String(re)}));return U>0&&$.push({remainder:!0,label:`Other (${H} values)`}),E>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,c,g,M,N){const{min:G,max:F,nulls:R,finite:X}=s(n,c,g);if(!X)return{kind:M,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(N.buckets||K));let S=[];if(M==="date"){const H=T.includes(N.granularity)?N.granularity:C(F-G,E);let $=A(G,H);for(;$<=F&&S.length<4096;){const re=i($,H);if(!(re>$))break;S.push({from:$,to:re}),$=re}return{kind:M,buckets:m(S,R),granularity:H}}const U=_.includes(N.strategy)?N.strategy:"equal";if(U==="quantile"){const H=u(n,c,g,J);if(H.length){const $=[H[0]];for(let re=1;re<E;re++){const te=H[Math.min(H.length-1,Math.floor(re/E*H.length))];te>$[$.length-1]&&$.push(te)}$.push(F);for(let re=0;re<$.length-1;re++)S.push({from:$[re],to:$[re+1]})}}else if(U==="log"&&G>0){const H=Math.log10(G),re=(Math.log10(F)-H)/E||1;for(let te=0;te<E;te++)S.push({from:10**(H+te*re),to:10**(H+(te+1)*re)})}if(!S.length){const H=(F-G)/E||1;for(let $=0;$<E;$++)S.push({from:G+$*H,to:G+($+1)*H})}return S[S.length-1].to=F,{kind:M,buckets:m(S,R),strategy:U,min:G,max:F}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,M,N){const G=M&&M.buckets||[],F=N&&N.length>=G.length?N.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const R=G.length-1,X=!!G[R]&&G[R].null===!0,E=c?c.length:g;if(M.kind==="boolean"){const re=Q(n);for(let te=0;te<E;te++){const ae=re(c?c[te]:te);if(ae==null){X&&F[R]++;continue}F[ae?1:0]++}return F}if(M.kind==="category"){const re=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&re.set(G[p].value,p);const te=G.findIndex(p=>p.remainder),ae=Q(n);for(let p=0;p<E;p++){const B=ae(c?c[p]:p);if(B==null||B===""){X&&F[R]++;continue}if(Array.isArray(B)){if(!B.length){X&&F[R]++;continue}for(const oe of B){const w=re.get(oe);w!==void 0?F[w]++:te>=0&&F[te]++}continue}const q=re.get(B);q!==void 0?F[q]++:te>=0&&F[te]++}return F}const S=X?G.length-1:G.length,U=new Float64Array(S+1);for(let re=0;re<S;re++)U[re]=G[re].from;U[S]=S?G[S-1].to:0;const H=ue(n),$=he(n);for(let re=0;re<E;re++){const te=c?c[re]:re;if($&&!$(te)){X&&F[R]++;continue}const ae=H(te);if(!Number.isFinite(ae)){X&&F[R]++;continue}const p=d(U,S,ae);p>=0&&F[p]++}return F}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let M=0,N=c-1;for(;M<N;){const G=M+N+1>>>1;g>=n[G]?M=G:N=G-1}return M}function h(n,c,g,M={}){const N=M.bounds||f(n,M.boundsIndices??c,g,M);return{bounds:N,counts:e(n,c,g,N)}}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 _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,Q=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const A=C-1;let i=.9999999999998099;const s=A+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(A+u+1);return .5*Math.log(2*Math.PI)+(A+.5)*Math.log(s)-s+Math.log(i)}function ne(C,A,i){const s=C+A,u=C+1,f=C-1;let l=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(A-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t,a*=t*l,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t;const h=t*l;if(a*=h,Math.abs(h-1)<he)break}return a}function _(C,A,i){if(!(C>0)||!(A>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+A)-z(C)-z(A)+C*Math.log(i)+A*Math.log(1-i));return i<(C+1)/(C+A+2)?s*ne(C,A,i)/C:1-s*ne(A,C,1-i)/A}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const A=[-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 l,t,a;C<f?(l=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1)):C<=1-f?(l=C-.5,t=l*l,a=(((((A[0]*t+A[1])*t+A[2])*t+A[3])*t+A[4])*t+A[5])*l/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(l=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+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 A=Math.abs(C),i=2/(2+A),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,l=0,t;for(let m=u.length-1;m>0;m--)t=l,l=s*l-f+u[m],f=t;const a=i*Math.exp(-A*A+.5*(u[0]+s*l)-f);return C>=0?a:2-a}function ie(C){return .5*K(-C/Math.SQRT2)}function J(C,A){if(!(A>0)||!Number.isFinite(C))return Number.NaN;const i=.5*_(A/2,.5,A/(A+C*C));return C>0?1-i:i}function le(C,A){if(!(C>0)||!(C<1)||!(A>0))return Number.NaN;if(A>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(A/2)+z(.5)-z((A+1)/2);for(let l=0;l<60;l++){const t=J(u,A);t<C?i=u:s=u;const a=Math.exp(-((A+1)/2)*Math.log(1+u*u/A)-f)/Math.sqrt(A),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 ue(C,A){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=A/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-A+C*Math.log(A)-z(C))}function W(C,A){let i=A+1-C,s=1/Q,u=1/i,f=u;for(let l=1;l<=300;l++){const t=-l*(l-C);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-A+C*Math.log(A)-z(C))*f}function L(C,A){return!(C>0)||!(A>=0)||!Number.isFinite(A)?Number.NaN:A===0?0:A<C+1?ue(C,A):1-W(C,A)}function Y(C,A){return A>0?L(A/2,C/2):Number.NaN}function ee(C,A){const i=Y(C,A);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 Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function fe(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let le=0;le<=J;le++){let ue=T[J][le];for(let W=0;W<le;W++)ue-=ie[J][W]*ie[le][W];if(J===le){if(!(ue>0))return null;ie[J][le]=Math.sqrt(ue)}else ie[J][le]=ue/ie[le][le]}return ie}function he(T,K){const ie=T.length,J=new Array(ie).fill(0);for(let ue=0;ue<ie;ue++){let W=K[ue];for(let L=0;L<ue;L++)W-=T[ue][L]*J[L];J[ue]=W/T[ue][ue]}const le=new Array(ie).fill(0);for(let ue=ie-1;ue>=0;ue--){let W=J[ue];for(let L=ue+1;L<ie;L++)W-=T[L][ue]*le[L];le[ue]=W/T[ue][ue]}return le}function Q(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const le=new Array(K).fill(0);le[J]=1;const ue=he(T,le);for(let W=0;W<K;W++)ie[W][J]=ue[W]}return ie}function z(T,K,ie){const J=T.length,le=J?T[0].length:0,ue=Array.from({length:le},()=>new Array(le).fill(0)),W=new Array(le).fill(0);for(let L=0;L<J;L++){const Y=ie?ie[L]:1,ee=T[L];for(let C=0;C<le;C++){const A=Y*ee[C];W[C]+=A*K[L];for(let i=C;i<le;i++)ue[C][i]+=A*ee[i]}}for(let L=0;L<le;L++)for(let Y=0;Y<L;Y++)ue[L][Y]=ue[Y][L];return{xtwx:ue,xtwy:W}}function ne(T,K){return T.map(ie=>ie.reduce((J,le,ue)=>J+le*K[ue],0))}function _(T,K){let ie=0;for(let J=0;J<T.length;J++){let le=0;for(let ue=0;ue<T.length;ue++)le+=K[J][ue]*T[ue];ie+=T[J]*le}return ie}}),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 ne}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ue}});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 Y=L-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(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 Y=this.#t+L.#t,ee=L.#e-this.#e;this.#e+=ee*(L.#t/Y),this.#n+=L.#n+ee*ee*(this.#t*L.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const 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,Y=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Y of this.#t)L+=Y;return L/this.#t.length}quantile(L){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const C=(Y-1)*Math.min(1,Math.max(0,L)),A=Math.floor(C),i=Math.ceil(C);return A===i?ee[A]:ee[A]+(C-A)*(ee[i]-ee[A])}}function Q(W){return W^=W>>>16,W=Math.imul(W,2246822507),W^=W>>>13,W=Math.imul(W,3266489909),W^=W>>>15,W>>>0}function z(W){if(typeof W=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,W===0?0:W),Q(ee.getUint32(0)^ee.getUint32(4))}const L=typeof W=="string"?W:String(W);let Y=2166136261;for(let ee=0;ee<L.length;ee++)Y^=L.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class ne{#t;#e;#n;constructor(L=14){const Y=Math.floor(L);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Y=1<<Math.floor(L),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return ne.errorBoundFor(this.#t)}add(L){const Y=z(L),ee=Y&this.#e-1,C=Y>>>this.#t|1<<32-this.#t;let A=1,i=C;for(;(i&1)===0;)A++,i>>>=1;A>this.#n[ee]&&(this.#n[ee]=A)}count(){const L=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<L;i++)ee[this.#n[i]]++;let C=L*K(1-ee[Y+1]/L);for(let i=Y;i>=1;i--)C=.5*(C+ee[i]);C+=L*T(ee[0]/L);const A=_*L*L/C;return Math.round(A)}}const _=.5/Math.log(2);function T(W){if(W===1)return 1/0;let L=1,Y=W,ee;do W*=W,ee=Y,Y+=W*L,L+=L;while(Y!==ee);return Y}function K(W){if(W===0||W===1)return 0;let L=1,Y=1-W,ee;do W=Math.sqrt(W),ee=Y,L*=.5,Y-=(1-W)**2*L;while(Y!==ee);return Y/3}class ie{#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 Y=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Y=this.#t.get(L);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let ee,C=1/0;for(const[A,i]of this.#t)i.count<C&&(C=i.count,ee=A);this.#t.delete(ee),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([ee,C])=>({item:ee,count:C.count,error:C.error})).sort((ee,C)=>C.count-ee.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Y=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Y,this.#i=2/3}static errorBoundFor(L=200){const Y=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const ee=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**ee);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 Y=this.#e[L];Y.sort((A,i)=>A-i),L+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[L+1],C=this.#r()<.5?0:1;for(let A=C;A<Y.length;A+=2)ee.push(Y[A]);this.#e[L]=[];for(let A=0;A<this.#e.length;A++)if(this.#e[A].length>=this.#s(A)){this.#h(A);return}}#u(){const L=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const C of this.#e[Y])L.push({v:C,w:ee})}return L}quantile(L){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const C=Math.min(1,Math.max(0,L))*ee;let A=0;for(const i of Y)if(A+=i.w,A>=C)return i.v;return Y[Y.length-1].v}rank(L){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const C=1<<ee;for(const A of this.#e[ee])A<=L&&(Y+=C)}return Y}}const le=Object.freeze({distinct:ne.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"})}),ue={Welford:fe,Reservoir:he,HyperLogLog:ne,SpaceSaving:ie,KLL:J,hash32:z,SKETCH_BOUNDS:le}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return A}}),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 l}}),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 c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return N}}),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 R}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return te}}),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 Le}}),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 Ee}}),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,Q=fe.valueReader,z=me("packages/core/src/compute/special.js"),ne=z.studentTQuantile,_=z.studentT,T=z.normalQuantile,K=z.normalCdf,ie=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),le=J.cholesky,ue=J.choleskySolve,W=J.choleskyInverse,L=J.normalEquations,Y=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,A=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 se=0;se<y;se++){const ce=j[se];if(D&&D(ce)!==1)continue;const Oe=I[ce];Number.isNaN(Oe)||(O[k++]=Oe)}return O.subarray(0,k)}const V=Q(b);for(let I=0;I<y;I++){const D=V(j[I]);if(D==null||D==="")continue;const se=typeof D=="number"?D:Number(D);Number.isFinite(se)&&(O[k++]=se)}return O.subarray(0,k)}function l(b,j){const y=new Map,O=Q(b);let k=0;for(let V=0;V<j.length;V++){const I=O(j[V]);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 P=[...y.values()].sort((V,I)=>I-V);return{counts:P,total:k,distinct:P.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=l(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=l(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=l(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=l(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let P=0;for(let V=0;V<Math.min(k,O.counts.length);V++)P+=O.counts[V];return P/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 P=0,V=0;for(let I=0;I<O;I++)P+=k[I],V+=(I+1)*k[I];return P===0?0:2*V/(O*P)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const P=b[k];j++;const V=P-y;y+=V/j,O+=V*(P-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),P=Math.ceil(O);return k===P?b[k]:b[k]+(O-k)*(b[P]-b[k])}function c(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=Q(b);let O=0,k=0,P=0;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&P++}return{pass:O+P,fail:k,warn:P,judged:O+P+k}}const M=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)=>X(f(b,j),.1),winsorizedMean:(b,j)=>E(f(b,j),.1),robustOutliers:(b,j)=>S(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?c(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?c(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?c(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?c(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?c(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?c(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=c(y,.5),k=new Float64Array(y.length);for(let P=0;P<y.length;P++)k[P]=Math.abs(y[P]-O);return c(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let P=0;P<y.length;P++)y[P]<O&&(O=y[P]),y[P]>k&&(k=y[P]);return k-O},distinct:(b,j)=>{const y=Q(b),O=new Set;for(let k=0;k<j.length;k++){const P=y(j[k]);P==null||P===""||O.add(P instanceof Date?P.getTime():P)}return O.size},mode:(b,j)=>{const y=Q(b),O=new Map;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,P=1;for(const[V,I]of O)I>P&&(P=I,k=V);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<3||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/V)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<4||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let ce=0;ce<y.length;ce++)I+=((y[ce]-k)/V)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),se=3*(O-1)**2/((O-2)*(O-3));return D*I-se},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}),N=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=Q(b),k=Q(j);let P=0,V=0;for(let I=0;I<y.length;I++){const D=y[I],se=Number(O(D)),ce=Number(k(D));!Number.isFinite(se)||!Number.isFinite(ce)||(P+=se*ce,V+=ce)}return V===0?null:P/V}function F(b,j,y){const O=Q(b);let k=null,P=y?-1/0:1/0;for(let V=0;V<j.length;V++){const I=j[V],D=Number(O(I));Number.isFinite(D)&&(y?D>P:D<P)&&(P=D,k=I)}return k}function R(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0,I=0,D=0,se=0,ce=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)||(P++,V+=Pe,I+=ye,D+=Pe*Pe,se+=ye*ye,ce+=Pe*ye)}if(P<2)return null;const Oe=P*ce-V*I,ke=Math.sqrt((P*D-V*V)*(P*se-I*I));if(ke===0)return null;const je=Oe/ke;return Math.max(-1,Math.min(1,je))}function X(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))),P=O.slice(k,y-k);if(!P.length)return n(O,.5);let V=0;for(const I of P)V+=I;return V/P.length}function E(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,se)=>D-se),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O[k],V=O[y-1-k];let I=0;for(const D of O)I+=Math.min(V,Math.max(P,D));return I/y}function S(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,se)=>D-se),k=n(O,.5),P=O.map(D=>Math.abs(D-k)).sort((D,se)=>D-se),V=n(P,.5);if(V===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/V)>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,P=0;for(const D of b){const se=D-y;O+=se*se,k+=se*se*se,P+=se*se*se*se}if(O/=j,k/=j,P/=j,O===0)return null;const V=k/O**1.5,I=P/(O*O)-3;return j/6*(V*V+I*I/4)}function H(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const se=Number(b[D]),ce=Number(j[D]);!Number.isFinite(se)||!Number.isFinite(ce)||ce<=0||(O.push([se,ce]),k+=ce)}if(!O.length||k<=0)return null;if(O.sort((D,se)=>D[0]-se[0]),O.length===1)return O[0][0];const P=[];let V=0;for(const[,D]of O)P.push((V+D/2)/k),V+=D;const I=Math.max(0,Math.min(1,y));if(I<=P[0])return O[0][0];if(I>=P[P.length-1])return O[O.length-1][0];for(let D=1;D<P.length;D++){if(I>P[D])continue;const se=P[D]-P[D-1],ce=se>0?(I-P[D-1])/se:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*ce}return O[O.length-1][0]}function $(b,j,y){const O=Q(b),k=Q(j),P=new Float64Array(y.length),V=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const se=y[D],ce=Number(O(se)),Oe=Number(k(se));!Number.isFinite(ce)||!Number.isFinite(Oe)||(P[I]=ce,V[I]=Oe,I++)}return{xs:P.subarray(0,I),ys:V.subarray(0,I),n:I}}function re(b,j,y,O=!1){const{xs:k,ys:P,n:V}=$(b,j,y);if(V<2)return null;let I=0,D=0;for(let ce=0;ce<V;ce++)I+=k[ce],D+=P[ce];I/=V,D/=V;let se=0;for(let ce=0;ce<V;ce++)se+=(k[ce]-I)*(P[ce]-D);return se/(O?V:V-1)}function te(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;let V=0,I=0;for(let Pe=0;Pe<P;Pe++)V+=O[Pe],I+=k[Pe];V/=P,I/=P;let D=0,se=0,ce=0;for(let Pe=0;Pe<P;Pe++){const ye=O[Pe]-V,ve=k[Pe]-I;D+=ye*ye,se+=ye*ve,ce+=ve*ve}if(D===0)return null;const Oe=se/D,ke=I-Oe*V,je=ce===0?1:Math.max(0,Math.min(1,se*se/(D*ce))),be=Math.max(0,ce-Oe*se),Ae=P>2?Math.sqrt(be/(P-2)/D):0;return{slope:Oe,intercept:ke,r2:je,stdError:Ae,n:P}}const ae=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),q=1.345;function oe(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),P=le(O);if(!P)return null;const V=ue(P,k),I=W(P),D=w(b,V),se=j.map((ce,Oe)=>ce-D[Oe]);return{beta:V,cov:I,fitted:D,residuals:se}}function w(b,j){return b.map(y=>y.reduce((O,k,P)=>O+k*j[P],0))}function v(b,j){const y=b.length,O=b.map(se=>se[j]),k=b.map(se=>[1,...se.filter((ce,Oe)=>Oe!==j)]),P=oe(k,O,null);if(!P)return 1;const V=O.reduce((se,ce)=>se+ce,0)/y;let I=0,D=0;for(let se=0;se<y;se++)I+=P.residuals[se]**2,D+=(O[se]-V)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function Z(b){const j=[...b].sort((k,P)=>k-P),y=x(j),O=b.map(k=>Math.abs(k-y)).sort((k,P)=>k-P);return x(O)/.6745}function x(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(!ae.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,P=k&&Array.isArray(b[0])?b[0].length:0,V=P+1;if(!(k>V))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==P)return null;for(let Ne=0;Ne<P;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 se,ce=null;if(O==="robust"){if(se=oe(D,j,null),!se)return null;for(let Me=0;Me<50;Me++){const Ne=Z(se.residuals);if(!(Ne>0))break;const Re=se.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=q?1:q/We}),Ce=oe(D,j,Re);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-se.beta[Je])),0);if(se=Ce,ce=Re,Ve<1e-10)break}}else if(se=oe(D,j,I),!se)return null;const Oe=O==="robust"?ce:I,{beta:ke,cov:je,fitted:be,residuals:Ae}=se;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[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=Oe?Oe[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-V,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===P?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?ne(1-(1-He)/2,De):1/0,Lt=ke.map((Me,Ne)=>{const Re=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Re>0?Me/Re:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-_(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Re:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Re,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=Oe?Oe[Me]:1,Re=Math.max(0,Math.min(1,Ne*Y(D[Me],je)));dt[Me]=Re;const Ce=(1-Re)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(V*qe)*(Re/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(P<2)return 1;const Re=v(b,Ne);return Re>=1?1/0:1/(1-Re)});let gt=null;{const Me=Ae.map(Re=>Re*Re),Ne=oe(D,Me,null);if(Ne){const Re=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]-Re)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=ie(We,P);gt={statistic:We,df:P,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(P===1){const Me=b.map((Ne,Re)=>Re).sort((Ne,Re)=>b[Ne][0]-b[Re][0]);bt={confidence:He,points:Me.map(Ne=>{const Re=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Y(Re,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:Oe?[...Oe]:null}}function we(b){const j=b.length,y=Array.from({length:j},(P,V)=>V).sort((P,V)=>b[P]-b[V]),O=new Float64Array(j);let k=0;for(;k<j;){let P=k;for(;P+1<j&&b[y[P+1]]===b[y[k]];)P++;const V=(k+P)/2+1;for(let I=k;I<=P;I++)O[y[I]]=V;k=P+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const P=(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])+P*(b-y[0]))))}if(b>=y[2]){const P=(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])+P*(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 Te(b,j,y,O){const k=y-O,P=O+3,V=new Array(k),I=new Array(k);let D=!0,se=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(P);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<P;ye++)Number.isFinite(Pe[ye])||(se=Math.min(se,ye-3));V[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:ce,xtwy:Oe}=L(V,I,null);let ke=0,je=1/0;for(let be=0;be<=se;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=ce[Ue].slice(0,Ae);const ye=le(Pe);if(!ye)continue;const ve=ue(ye,Oe.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=V[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,ke=be)}return ke}function Le(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 P=new Array(k);for(let je=0;je<k;je++)P[je]=y[je+1]-y[je];let V=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);V=Math.max(0,Math.min(V,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(P[ye-Fe]);Ae.push(ve),Pe.push(P[ye])}return de(Ae,Pe,{method:"ols"})},D=Te(y,P,k,V),se=I(D,D);if(!se||!se.coefficients[2])return null;const ce=se.coefficients[2].t,Oe=pe(ce),ke=ce<ge["5%"];return{statistic:ce,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:Oe,pApproximate:!0,stationary:ke,verdict:ke?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let ke=0;ke<b.length;ke++){const je=Number(b[ke]);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 P=0;for(const ke of y)P+=ke;P/=O;const V=y.map(ke=>ke-P);let I=0;for(const ke of V)I+=ke*ke;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let ke=1;ke<=k;ke++){let je=0;for(let be=ke;be<O;be++)je+=V[be]*V[be-ke];D[ke]=I>0?je/O/I:0}const se=new Array(k+1).fill(0);se[0]=1;let ce=[];for(let ke=1;ke<=k;ke++){let je=D[ke];for(let ye=1;ye<ke;ye++)je-=ce[ye-1]*D[ke-ye];let be=1;for(let ye=1;ye<ke;ye++)be-=ce[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(ke);for(let ye=1;ye<ke;ye++)Pe[ye-1]=ce[ye-1]-Ae*ce[ke-1-ye];Pe[ke-1]=Ae,se[ke]=Ae,ce=Pe}const Oe=1.96/Math.sqrt(O);return{acf:D,pacf:se,bounds:{upper:Oe,lower:-Oe},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;const V=we(O),I=we(k);let D=0,se=0;for(let je=0;je<P;je++)D+=V[je],se+=I[je];D/=P,se/=P;let ce=0,Oe=0,ke=0;for(let je=0;je<P;je++){const be=V[je]-D,Ae=I[je]-se;ce+=be*Ae,Oe+=be*be,ke+=Ae*Ae}return Oe===0||ke===0?null:Math.max(-1,Math.min(1,ce/Math.sqrt(Oe*ke)))}function Ke(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2||P>A)return null;let V=0,I=0,D=0,se=0;for(let ke=0;ke<P;ke++)for(let je=ke+1;je<P;je++){const be=Math.sign(O[ke]-O[je]),Ae=Math.sign(k[ke]-k[je]),Pe=be*Ae;Pe>0?V++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:se++)}const ce=V+I+se,Oe=V+I+D;return ce===0||Oe===0?null:(V-I)/Math.sqrt(ce*Oe)}function Ee(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],P=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&P.push((b[ye]-ve)/Math.abs(ve))}let V=null;if(P.length>1){let ye=0;for(const Fe of P)ye+=Fe;ye/=P.length;let ve=0;for(const Fe of P)ve+=(Fe-ye)**2;V=Math.sqrt(ve/(P.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],se=0,ce=0,Oe=0,ke=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],se=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>ce&&(ce=ve,Oe=se,ke=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 P)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:V,annualisedVolatility:V!==null&&I?V*Math.sqrt(I):null,growth:Pe,maxDrawdown:ce,maxDrawdownFrom:Oe,maxDrawdownTo:ke,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,P)=>k+P,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 P=0;for(let be=0;be<y;be++)P+=b[be];P/=y;let V=0;for(let be=0;be<y;be++)V+=(b[be]-P)**2;const I=Math.sqrt(V/(y-1)),D=xe(b),se=D?D.sigma:null,ce=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-P)/(3*be):1/0,ve=O!==null?(P-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},Oe=ce(se),ke=ce(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:P,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:se,sigmaOverall:I,cp:Oe.index,cpk:Oe.k,pp:ke.index,ppk:ke.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,P=I=>(b[I]-O)/k,V=[];for(let I=0;I<y;I++){if(Math.abs(P(I))>3&&V.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let se=0;for(let ce=I-2;ce<=I;ce++)P(ce)*D>2&&se++;if(se>=2){V.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let se=0;for(let ce=I-4;ce<=I;ce++)P(ce)*D>1&&se++;if(se>=4){V.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let se=!0;for(let ce=I-7;ce<=I;ce++)if(P(ce)*D<=0){se=!1;break}if(se){V.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return V}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=D=>(b[D]-O)/k,V=(D,se,ce,Oe)=>{for(const ke of[1,-1]){let je=0;for(let be=D;be<=se;be++)P(be)*ke>ce&&je++;if(je>=Oe)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(P(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const se of[1,-1]){let ce=!0;for(let Oe=D-8;Oe<=D;Oe++)if(P(Oe)*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const se of[1,-1]){let ce=!0;for(let Oe=D-4;Oe<=D;Oe++)if((b[Oe]-b[Oe-1])*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:3,description:se>0?"six rising":"six falling"});break}}if(D>=13){let se=!0;for(let ce=D-12;ce<=D;ce++){const Oe=b[ce]-b[ce-1],ke=b[ce+1<=D?ce+1:ce]-b[ce];if(ce+1>D)break;if(Oe===0||ke===0||Oe>0==ke>0){se=!1;break}}se&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&V(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&V(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let se=!0;for(let ce=D-14;ce<=D;ce++)if(Math.abs(P(ce))>=1){se=!1;break}se&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let se=!0;for(let ce=D-7;ce<=D;ce++)if(Math.abs(P(ce))<=1){se=!1;break}se&&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 P=b[0],V=b[k-1];if(V===P)return[{from:P,to:V,count:k}];const I=y-j,D=1.5*I;let se=I>0?Math.max(P,j-D):P,ce=I>0?Math.min(V,y+D):V;ce>se||(se=P,ce=V);const Oe=I>0?2*I/Math.cbrt(k):(ce-se)/(Math.ceil(Math.log2(k))+1),ke=Oe>0?Math.min(O,Math.max(1,Math.ceil((ce-se)/Oe))):1,je=(ce-se)/ke,be=[];for(let Ae=0;Ae<ke;Ae++)be.push({from:se+Ae*je,to:se+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(ke-1,Math.max(0,Math.floor((b[Ae]-se)/je)));be[Pe].count++}return be[0].from=P,be[ke-1].to=V,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 ce=0;ce<y;ce++)O+=b[ce];const k=O/y;let P=0;for(let ce=0;ce<y;ce++){const Oe=b[ce]-k;P+=Oe*Oe}const V=Math.sqrt(P/(y-1)),I=Qe(j),se=ne(1-(1-I)/2,y-1)*V/Math.sqrt(y);return{mean:k,lower:k-se,upper:k+se,margin:se,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 P=Qe(y),V=T(1-(1-P)/2),I=O/k,D=V*V,se=1+D/k,ce=(I+D/(2*k))/se,Oe=V/se*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,ce-Oe),upper:Math.min(1,ce+Oe),n:k,confidence:P}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=ne(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 P=Qe(y),I=T(1-(1-P)/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:P}}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=Q(b);let k=0;for(let P=0;P<j.length;P++){const V=O(j[P]);if(V==null||V===""||typeof V=="number"&&Number.isNaN(V))continue;const I=V instanceof Date?V.getTime():typeof V=="object"?String(V):V;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 P=new Set(b.keys());for(const V of y.keys())P.add(V);for(const V of P){const I=(b.get(V)||0)/j,D=(y.get(V)||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:se}=r(I),ce=D>0?lt({mean:y.mean,sd:y.sd},se):null;return{measure:"standardizedMeanDifference",magnitude:ce,distance:ce===null?0:at(ce),direction:ce===null?0:Math.sign(ce),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:P}=_e(b,j),V=ft(k,P,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:V,distance:V===null?0:V,direction:0,subsetN:P,populationN:y.total||0,reliable:P>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=Q(b);let O=0,k=0;for(let P=0;P<j.length&&O<200;P++){const V=y(j[P]);if(V==null||V==="")continue;if(V instanceof Date)return!1;O++;const I=typeof V=="number"?V:Number(V);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:P,mean:V,m2:I}=r(k);return{numeric:!0,mean:V,sd:P>0?Math.sqrt(I/P):0,n:P}}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 l}}),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,Q=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),ne=z.presenceReader,_=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),ie=K.STAT_FNS,J=K.STAT_LABELS;function le(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ue(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++){const R=N[n[F]];Number.isNaN(R)||(g+=R)}return g}for(let F=0;F<c;F++){const R=n[F];if(G(R)===1){const X=N[R];Number.isNaN(X)||(g+=X)}}return g}const M=T(r);for(let N=0;N<c;N++){const G=u(M(n[N]));G!==null&&(g+=G)}return g}ue.kernel=!0;function W(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++)Number.isNaN(N[n[F]])||g++;return g}for(let F=0;F<c;F++){const R=n[F];G(R)===1&&!Number.isNaN(N[R])&&g++}return g}const M=T(r);for(let N=0;N<c;N++){const G=M(n[N]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}W.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Y(r,n){const c=W(r,n);return c===0?null:ue(r,n)/c}Y.kernel=!0;function ee(r,n,c,g){const M=n.length;if(le(r)){const R=r.values,X=ne(r);let E=null;if(!X){for(let S=0;S<M;S++){const U=R[n[S]];Number.isNaN(U)||(E===null||(c<0?U<E:U>E))&&(E=U)}return E}for(let S=0;S<M;S++){const U=n[S];if(X(U)===0)continue;const H=R[U];Number.isNaN(H)||(E===null||(c<0?H<E:H>E))&&(E=H)}return E}const N=T(r),G=_(g);let F=null;for(let R=0;R<M;R++){const X=N(n[R]);X==null||typeof X=="number"&&Number.isNaN(X)||(F===null||(c<0?G(X,F)<0:G(X,F)>0))&&(F=X)}return F}function C(r,n,c){return ee(r,n,-1,c&&c.locale)}C.kernel=!0;function A(r,n,c){return ee(r,n,1,c&&c.locale)}A.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:ue,min:C,max:A,avg:Y,count:L,first:i,last:s,countValues:W,...ie},l=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"?l[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 c=a.filter(g=>g in f);for(const g of Object.keys(f))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=T(r),g=[];for(let M=0;M<n.length;M++){const N=c(n[M]);N!=null&&g.push(N)}return g}function h(r,n,c,g){const M=n||[];if(typeof c=="string"){const N=f[c];return N?N(r,M,g):(Q(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,M,g):c(d(r,M),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,_=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,ie="|",J="/",le=2e3;function ue(u,f,l){return`${u}${ie}${f}${ie}${l}`}function W(u,f){let l="";for(let t=0;t<u.length;t++){const a=u[t];l+=(t===0?"":f)+(a==null?"":String(a))}return l}function L(u,f,l={}){const t=l.separator||J,a=f.length,{keyOf:m,readers:e}=_(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const R=f[F],X=m(R);if(d.has(X))continue;d.set(X,h.length),r.push(X);const E=new Array(e.length);for(let S=0;S<e.length;S++)E[S]=e[S](R);h.push(E)}const n=z(l.locale),c=h.map((F,R)=>R);c.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=Y(X[S],E[S],n);if(U!==0)return U}return F-R});const g=new Array(c.length),M=new Array(c.length),N=new Map;for(let F=0;F<c.length;F++){const R=c[F];g[F]=h[R],M[F]=W(h[R],t),N.set(r[R],F)}return{keys:g,paths:M,idOf:F=>{const R=N.get(m(F));return R===void 0?-1:R}}}function Y(u,f,l){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:l(u,f)}function ee(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 l=typeof u.handle=="function"?u.handle:null;if(!l)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=l(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,l){if(Array.isArray(u)){const t=l||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function A(u,f,l){const t=C(u,f,l),a=t.separator||J,m=ee(t),e=t.maxColumns===void 0?le: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(X=>W(X,a)):[""]),n=s(h),{keys:c,paths:g,idOf:M}=L(t.pivotHandles||[],n,t),N=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&N>e){const X=new Map;return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${N} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:N,maxColumns:e}}}const F=new Map,R=g.length;for(let X=0;X<h.length;X++){const E=h[X],S=r[X]===void 0?"":r[X],U=E.length;if(U===0)continue;const H=new Int32Array(U),$=new Uint32Array(R+1);for(let ae=0;ae<U;ae++){const p=M(E[ae]);H[ae]=p,p>=0&&$[p+1]++}for(let ae=0;ae<R;ae++)$[ae+1]+=$[ae];const re=new Uint32Array(U),te=$.slice(0,R);for(let ae=0;ae<U;ae++){const p=H[ae];p>=0&&(re[te[p]++]=E[ae])}for(let ae=0;ae<R;ae++){const p=$[ae],B=$[ae+1];if(B===p)continue;const q=re.subarray(p,B);for(let oe=0;oe<m.length;oe++){const w=m[oe],v=K(w.handle,q,w.fn,t.totalContext||{locale:t.locale});F.set(ue(S,g[ae],w.colId),v)}}}return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:F,cells:F,error:null}}function i(u,f,l){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${l}${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 l=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(l.set(a,t),t+=a.length);return l}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,_=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,ie=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,le="";function ue(i,s,u={}){const f=u.separator||ie,l=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(l.length===0)return{tuples:[[]],paths:[le],buckets:[t]};const{keyOf:m,readers:e}=_(l,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const R=t[F],X=m(R);let E=d.get(X);if(E===void 0){E=h.length,d.set(X,E),r.push(X);const S=new Array(e.length);for(let U=0;U<e.length;U++)S[U]=e[U](R);h.push(S),n.push([])}n[E].push(R)}const c=he(u.locale),g=h.map((F,R)=>R);g.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=W(X[S],E[S],c);if(U!==0)return U}return F-R});const M=new Array(g.length),N=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const R=g[F];M[F]=h[R],N[F]=K(h[R],f),G[F]=Uint32Array.from(n[R])}return{tuples:M,paths:N,buckets:G}}function W(i,s,u){const f=i==null,l=s==null;return f||l?f&&l?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let l=0;l<i.length;l++)u.has(i[l])&&f.push(i[l]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ie,f=s.totalContext||{locale:s.locale},l=(i.measures||[]).filter(N=>N&&N.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ue(i.rowHandles||[],t,{...s,separator:u}),m=ue(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,l.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.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,c=new Map,g=new Map,M=m.buckets.map(N=>new Set(N));for(let N=0;N<m.paths.length;N++){const G=m.buckets[N],F=m.paths[N];for(const R of l)c.set(A(F,R.colId),Y(R.handle,G,R.fn,f))}for(let N=0;N<a.paths.length;N++){const G=a.buckets[N],F=a.paths[N];for(const R of l)n.set(A(F,R.colId),Y(R.handle,G,R.fn,f));for(let R=0;R<m.paths.length;R++){const X=L(G,m.buckets[R],M[R]);if(X.length===0)continue;const E=m.paths[R];for(const S of l)r.set(C(F,E,S.colId),Y(S.handle,X,S.fn,f))}}for(const N of l)g.set(N.colId,Y(N.handle,t,N.fn,f));return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function A(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 le}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const he=me("packages/core/src/internal/util.js").getPath,Q=me("packages/core/src/compute/handle.js"),z=Q.isMissing,ne=Q.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",ie="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function le(i,s,u={}){const f=s||[];let l=i.map((t,a)=>a);if(f.length===0)return l;for(let t=f.length-1;t>=0;t--)l=ue(i,l,f[t],u);return l}function ue(i,s,u,f){const l=u.locale!==void 0?u.locale:f.locale,t=ne(l),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 c=J(i[r],u.col),g=J(i[n],u.col);let M;return typeof u.compare=="function"?(M=u.compare(c,g,i[r],i[n],a),a&&(M=-M)):M=a?t(g,c):t(c,g),M!==0?M:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function W(i,s,u={}){const f=[];for(let l=0;l<i.length;l++)L(i[l],s,u,l)&&f.push(l);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const l=s.conditions.filter(a=>a!=null);if(l.length===0)return!0;if(s.op==="or")return l.some(a=>L(i,a,u,f));const t=l.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 Y(i,s,u,f){const l=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of l){const d=s.map((n,c)=>{const g=J(i[e],n);return f&&f[c]?f[c](g):g}),h=d.map(n=>n==null?ie: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 ee(i,s,u={}){const f=ne(u.locale),l=i.filter(a=>!z(a)),t=l.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return l.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return l.length===0?null:t.reduce((a,m)=>a+m,0)/l.length;case"min":return l.length===0?null:l.reduce((a,m)=>f(m,a)<0?m:a);case"max":return l.length===0?null:l.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:A(i[0]);case"last":return i.length===0?null:A(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 A(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 Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(K,ie=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(ie>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(ie),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,ie=this.#r()){Number.isFinite(K)&&(this.#n.push({t:ie,v:K}),this.#s(ie))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ie=K-this.#e;for(;this.#n.length&&this.#n[0].t<ie;)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 ie=new he;let J=0,le=1/0,ue=-1/0;for(const{v:W}of this.#n)J+=W,W<le&&(le=W),W>ue&&(ue=W),ie.add(W);return{over:K,count:this.#n.length,sum:J,mean:ie.mean(),min:le,max:ue,variance:ie.variance(),stddev:ie.stddev()}}reduce(K){const ie=this.aggregate(),J={sum:ie.sum,avg:ie.mean,mean:ie.mean,min:ie.min,max:ie.max,count:ie.count,variance:ie.variance,stddev:ie.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:ie.over}}}const z=Object.freeze(["count","time","session"]);function ne(T,K=Date.now){const ie=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new Q(T.kind,ie,K)}const _={Window:Q,WINDOW_KINDS:z,openWindow:ne}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),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 ie}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return A}}),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,ne=.6745,_=3.5,T=1.5,K=.975,ie=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(l){if(!l.length)return null;const a=Array.from(l,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 le(l,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,m=l.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let c=0;c<m;c++){const g=Number(l[c]);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 c=0;c<m;c++){const g=Number(l[c]);if(!Number.isFinite(g))continue;const M=ne*(g-r.median)/r.mad;e[c]=M,Math.abs(M)>a&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function ue(l,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<l.length;n++){const c=Number(l[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),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 W(l,t){if(t<=0)return 0;const a=z(l);if(t<l+1){let c=l,g=1/l,M=g;for(let N=0;N<1e3&&(c+=1,M*=t/c,g+=M,!(Math.abs(M)<Math.abs(g)*1e-15));N++);return g*Math.exp(-t+l*Math.log(t)-a)}const m=1e-300;let e=t+1-l,d=1/m,h=1/e,r=h;for(let c=1;c<1e3;c++){const g=-c*(c-l);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 M=h*d;if(r*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-t+l*Math.log(t)-a)*r}function L(l,t){return l<=0?0:W(t/2,l/2)}function Y(l,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,l);for(;L(m,l)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,l)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function ee(l){const t=l.length,a=l.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(l,t){const a=l.length,m=new Array(t).fill(0);for(const h of l)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 l)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(h[c]-m[c])}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 A(l,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=l.length;if(!e)return null;const d=l[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),c=[],g=[];for(let S=0;S<e;S++){const U=l[S];let H=U.length===d;const $=new Array(d);for(let re=0;H&&re<d;re++){const te=Number(U[re]);Number.isFinite(te)?$[re]=te:H=!1}H&&(c.push(S),g.push($))}const M=d,N=Y(M,a);if(g.length<=d)return{center:[],df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let R=ee(F),X=!1;if(!R){X=!0;let S=0;for(let $=0;$<d;$++)S+=F[$][$];const U=S/d*m||m,H=F.map(($,re)=>$.map((te,ae)=>re===ae?te+U:te));if(R=ee(H),!R)return{center:G,df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let E=0;for(let S=0;S<g.length;S++){const U=g[S],H=new Array(d);for(let te=0;te<d;te++)H[te]=U[te]-G[te];let $=0;for(let te=0;te<d;te++){let ae=0;for(let p=0;p<d;p++)ae+=R[te][p]*H[p];$+=H[te]*ae}$<0&&($=0);const re=c[S];r[re]=$,h[re]=Math.sqrt($),$>N&&(n[re]=!0,E++)}return{center:G,df:M,cutoff:N,singular:X,used:g.length,distances:h,squared:r,flags:n,flagged:E}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(l,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:_,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=l.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let M=0;M<r;M++){const N=Number(l[M]);if(!Number.isFinite(N))continue;const G=Math.max(0,M-m+1),F=[];for(let R=G;R<=M;R++){const X=Number(l[R]);Number.isFinite(X)&&F.push(X)}if(!(F.length<h))if(a==="rollingIqr"){const R=ue(F,{k:d});if(!R)continue;(N<R.lower||N>R.upper)&&(c[M]=!0,g++)}else{const R=J(F);if(!R||R.mad===0)continue;const X=ne*(N-R.median)/R.mad;n[M]=X,Math.abs(X)>e&&(c[M]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:c,flagged:g}}function f(l={}){const t=l||{},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(!(ie.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=c=>Number(c==null?NaN:c[a]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((R,X)=>{const E=R?.[d],S=X?.[d];return E===S?0:E==null?-1:S==null?1:E<S?-1:1});const M=g.map(n);let N,G;if(r)({flags:N,scores:G}=u(M,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const R=ue(M,{k:t.k});N=M.map(X=>R?Number.isFinite(X)&&(X<R.lower||X>R.upper):!1),G=M.map(()=>null)}else({flags:N,scores:G}=le(M,{threshold:t.threshold}));if(h){const R=N.length-1;return R<0||!N[R]?!1:{method:m,field:a,flagged:[{row:g[R],score:G[R]}]}}const F=[];for(let R=0;R<N.length;R++)N[R]&&F.push({row:g[R],score:G[R]});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 _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return l}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,Q=fe.studentTQuantile,ne=me("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function ie(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 le(t){return Math.min(K,Math.max(T,t))}function ue(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),c=h+d*(r-h),g=t(n),M=t(c);for(let N=0;N<e;N++)g<M?(r=c,c=n,M=g,n=r-d*(r-h),g=t(n)):(h=n,n=c,g=M,c=h+d*(r-h),M=t(c));return(h+r)/2}function W(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 c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;h+=(c-g)**2,r+=1;const M=e;e=a*c+(1-a)*(M+d),d=m*(e-M)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Y(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=X=>{let E=0,S=0;for(let U=X;U<X+a&&U<h;U++)t[U]!==null&&(E+=t[U],S+=1);return S?E/S:null},n=r(0),c=r(a);if(n===null||c===null)return null;let g=n,M=(c-n)/a;const N=new Array(a).fill(0);for(let X=0;X<a;X++)N[X]=t[X]===null?0:t[X]-g;const G=N.reduce((X,E)=>X+E,0)/a;for(let X=0;X<a;X++)N[X]-=G;let F=0,R=0;for(let X=a;X<h;X++){const E=X%a,S=N[E],U=t[X];if(U===null){g+=M;continue}const H=g+M+S;F+=(U-H)**2,R+=1;const $=g;g=m*(U-S)+(1-m)*(g+M),M=e*(g-$)+(1-e)*M,N[E]=d*(U-g)+(1-d)*S}return{level:g,trend:M,season:N,phase:(h-1)%a,sse:F,count:R}}function ee(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=_.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=ie(t),n=r.map(F=>F.value),c=n.filter(F=>F!==null),g=c.length,{lastAt:M,step:N}=g?J(r):{lastAt:0,step:1},G=F=>M+F*N;return m==="linear"?A(r,g,e,d,h,G):m==="movingAverage"?i(c,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 A(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 c=0,g=0,M=0;for(const U of t){if(U.value===null)continue;const H=U.at-r,$=U.value-n;c+=H*H,g+=H*$,M+=$*$}if(c===0)return null;const N=g/c,G=n-N*r,F=M===0?1:Math.max(0,Math.min(1,g*g/(c*M))),R=Math.max(0,M-N*g),X=a>2?Math.sqrt(R/(a-2)):null,E=a>2?Q(d,a-2):null,S=[];for(let U=1;U<=m;U++){const H=h(U),$=G+N*H;let re=null,te=null,ae=null,p=null,B=null;if(X!==null){const q=1/a+(H-r)**2/c,oe=X*Math.sqrt(1+q),w=X*Math.sqrt(q);B=oe,re=$-E*oe,te=$+E*oe,ae=$-E*w,p=$+E*w}S.push({step:U,at:H,mean:$,lower:re,upper:te,lowerMean:ae,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:X,r2:F,params:{slope:N,intercept:G},points:S}}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))),c=t.slice(a-n);let g=0;for(const X of c)g+=X;const M=g/n;let N=null,G=null;if(n>1){let X=0;for(const S of c)X+=(S-M)**2;N=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),G=Q(d,n-1)}const F=N===null?null:G*N,R=[];for(let X=1;X<=m;X++)R.push({step:X,at:r(X),mean:M,lower:F===null?null:M-F,upper:F===null?null:M+F,se:N});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:N===null?null:N,params:{windowLen:n},points:R}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null;n===null&&(n=ue(G=>W(t,G).sse));const c=W(t,n),g=he(d),M=c.m>0?c.sse/c.m:null,N=[];for(let G=1;G<=m;G++){const F=c.level;let R=null,X=null,E=null;if(M!==null){const S=[];for(let H=1;H<G;H++)S.push(n);const U=ee(M,S,g);E=U.se,R=F-U.margin,X=F+U.margin}N.push({step:G,at:r(G),mean:F,lower:R,upper:X,se:E})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:M===null?null:Math.sqrt(M),params:{alpha:n},points:N}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null,c=Number.isFinite(h.beta)?le(h.beta):null;if(n===null||c===null){let R=n===null?.5:n,X=c===null?.5:c;for(let E=0;E<6;E++)n===null&&(R=ue(S=>L(t,S,X).sse)),c===null&&(X=ue(S=>L(t,R,S).sse));n=n===null?R:n,c=c===null?X:c}const g=L(t,n,c),M=he(d),N=g.m>0?g.sse/g.m:null,G=n*c,F=[];for(let R=1;R<=m;R++){const X=g.level+R*g.trend;let E=null,S=null,U=null;if(N!==null){const H=[];for(let re=1;re<R;re++)H.push(n+re*G);const $=ee(N,H,M);U=$.se,E=X-$.margin,S=X+$.margin}F.push({step:R,at:r(R),mean:X,lower:E,upper:S,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:N===null?null:Math.sqrt(N),params:{alpha:n,beta:c},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return ne("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let c=Number.isFinite(h.alpha)?le(h.alpha):null,g=Number.isFinite(h.beta)?le(h.beta):null,M=Number.isFinite(h.gamma)?le(h.gamma):null;const N=(U,H,$)=>{const re=Y(t,n,U,H,$);return re?re.sse:1/0};if(c===null||g===null||M===null){let U=c===null?.5:c,H=g===null?.5:g,$=M===null?.5:M;for(let re=0;re<8;re++)c===null&&(U=ue(te=>N(te,H,$))),g===null&&(H=ue(te=>N(U,te,$))),M===null&&($=ue(te=>N(U,H,te)));c=c===null?U:c,g=g===null?H:g,M=M===null?$:M}const G=Y(t,n,c,g,M);if(!G)return null;const F=he(d),R=G.count>0?G.sse/G.count:null,X=c*g,E=M*(1-c),S=[];for(let U=1;U<=m;U++){const H=G.season[(G.phase+U)%n],$=G.level+U*G.trend+H;let re=null,te=null,ae=null;if(R!==null){const p=[];for(let q=1;q<U;q++)p.push(c+q*X+(q%n===0?E:0));const B=ee(R,p,F);ae=B.se,re=$-B.margin,te=$+B.margin}S.push({step:U,at:r(U),mean:$,lower:re,upper:te,se:ae})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:R===null?null:Math.sqrt(R),params:{alpha:c,beta:g,gamma:M,period:n},points:S}}const l={FORECAST_METHODS:_,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 Q=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const 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 ne=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return ne.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return ne.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return ne.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return ne.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ne.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return ne.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return ne.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return ne.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return ne.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return ne.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return ne.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return ne.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return ne.QUANTILE_SAMPLE}});const _=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const 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 ie=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ie.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ie.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ie.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ie.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ie.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ie.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 le=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return le.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return le.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return le.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return le.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return le.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le.SKETCH_BOUNDS}});const ue=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ue.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ue.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ue.openWindow}});const W=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return W.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return W.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return W.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 Y=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),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,Q=fe.OPS,z=fe.CONTROL,ne=fe.ERRORS,_=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,ie=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),le=J.packChunk,ue=J.packedTransfers;let W=null,L=null,Y=null;async function ee(f){if(W)return W;if(!L){const l=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(l).then(t=>(W=t,t)).catch(t=>(Y=t,W=null,null))}return L}function C(f){W=f,L=f?Promise.resolve(f):null,Y=f?null:Y}function A(f,l,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:l,pool:K(),locale:t}}function i(f,l){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return le(a.schema||[],a.rows||[],a.opts||{});const m=l[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=ne.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return m(_(a.handle),a.order??null,a.opts||{});case Q.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 Q.EVALUATE_FILTERS:return m(a.filters,A(T(a.handles||[]),a.count,a.locale));case Q.COMPACT:return m(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return m(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return m(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=ne.PROTOCOL,e}}}async function s(f,l={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return l.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(l.cancelled?.has(t))return l.cancelled.delete(t),null;try{const e=le(f.args.schema||[],f.args.rows||[],f.args.opts||{});return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ue(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ee(l.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:ne.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(l.cancelled?.has(t))return l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,l={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:l.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(l.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{}var Fn=Ln("packages/modules/htmx/index.js");typeof module=="object"&&module.exports?module.exports=Fn:typeof define=="function"&&define.amd?define(function(){return Fn}):hr.LatticeGridHtmx=Fn})(typeof globalThis<"u"?globalThis:this);
|
|
58
58
|
|
|
59
59
|
//# sourceMappingURL=htmx.min.js.map
|