@toclocoinc/lattice-grid 1.74.0 → 1.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +44 -6
- package/docs/CHART-CODES.md +8 -0
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.html +1 -1
- package/docs/api/charts.html +28 -2
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +2 -2
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +13 -1
- package/docs/api-detail.html +13 -4
- package/docs/warnings.json +36 -3
- package/lattice-grid.d.ts +37 -2
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- package/lattice-grid.min.js +3 -3
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +2 -2
- package/modules/ai.min.cjs +2 -2
- package/modules/ai.min.js +2 -2
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +2 -2
- package/modules/alarms.min.cjs +2 -2
- package/modules/alarms.min.js +2 -2
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +2 -2
- package/modules/chart-calendar.esm.min.js.map +1 -1
- package/modules/chart-calendar.min.cjs +2 -2
- package/modules/chart-calendar.min.js +2 -2
- package/modules/chart-calendar.min.js.map +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +2 -2
- package/modules/chart-choropleth.esm.min.js.map +1 -1
- package/modules/chart-choropleth.min.cjs +2 -2
- package/modules/chart-choropleth.min.js +2 -2
- package/modules/chart-choropleth.min.js.map +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +2 -2
- package/modules/chart-hexbin.esm.min.js.map +1 -1
- package/modules/chart-hexbin.min.cjs +2 -2
- package/modules/chart-hexbin.min.js +2 -2
- package/modules/chart-hexbin.min.js.map +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +2 -2
- package/modules/chart-hexmap.esm.min.js.map +1 -1
- package/modules/chart-hexmap.min.cjs +2 -2
- package/modules/chart-hexmap.min.js +2 -2
- package/modules/chart-hexmap.min.js.map +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +185 -178
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +185 -178
- package/modules/charts.min.js +185 -178
- package/modules/charts.min.js.map +2 -2
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +2 -2
- package/modules/data-router.min.cjs +2 -2
- package/modules/data-router.min.js +2 -2
- package/modules/deckgl.d.ts +9 -3
- package/modules/deckgl.esm.min.js +18 -11
- package/modules/deckgl.esm.min.js.map +2 -2
- package/modules/deckgl.min.cjs +18 -11
- package/modules/deckgl.min.js +18 -11
- package/modules/deckgl.min.js.map +2 -2
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +1 -1
- package/modules/devtools.min.cjs +1 -1
- package/modules/devtools.min.js +1 -1
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +2 -2
- package/modules/dhtmlx-compat.min.cjs +2 -2
- package/modules/dhtmlx-compat.min.js +2 -2
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +2 -2
- package/modules/gantt.min.cjs +2 -2
- package/modules/gantt.min.js +2 -2
- package/modules/geo-europe-nuts.d.ts +1 -1
- package/modules/geo-europe-nuts.esm.min.js +1 -1
- package/modules/geo-europe-nuts.min.cjs +1 -1
- package/modules/geo-europe-nuts.min.js +1 -1
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +1 -1
- package/modules/geo-uk.min.js +1 -1
- package/modules/geo-us-states.d.ts +1 -1
- package/modules/geo-us-states.esm.min.js +1 -1
- package/modules/geo-us-states.min.cjs +1 -1
- package/modules/geo-us-states.min.js +1 -1
- package/modules/geo-world-110m.d.ts +1 -1
- package/modules/geo-world-110m.esm.min.js +1 -1
- package/modules/geo-world-110m.min.cjs +1 -1
- package/modules/geo-world-110m.min.js +1 -1
- package/modules/geo-world-50m.d.ts +1 -1
- package/modules/geo-world-50m.esm.min.js +1 -1
- package/modules/geo-world-50m.min.cjs +1 -1
- package/modules/geo-world-50m.min.js +1 -1
- package/modules/geometry.d.ts +1 -1
- package/modules/geometry.esm.min.js +2 -2
- package/modules/geometry.min.cjs +2 -2
- package/modules/geometry.min.js +2 -2
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +3 -3
- package/modules/htmx.min.cjs +3 -3
- package/modules/htmx.min.js +3 -3
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +2 -2
- package/modules/kanban.min.cjs +2 -2
- package/modules/kanban.min.js +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +2 -2
- package/modules/kpi.min.cjs +2 -2
- package/modules/kpi.min.js +2 -2
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +2 -2
- package/modules/layout.min.cjs +2 -2
- package/modules/layout.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +1 -1
- package/modules/mock-socket.min.cjs +1 -1
- package/modules/mock-socket.min.js +1 -1
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +2 -2
- package/modules/tabs.min.cjs +2 -2
- package/modules/tabs.min.js +2 -2
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +3 -3
- package/modules/webcomponent.min.cjs +3 -3
- package/modules/webcomponent.min.js +3 -3
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, deckgl module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
var Rt=Object.create(null),zt=Object.create(null);function Le(o,oe){Rt[o]=oe}function Lt(o){var oe=zt[o];if(oe)return oe;var me=Object.create(null);zt[o]=me;var X=Rt[o];if(!X)throw new Error("[lattice] missing module: "+o);return X(me,Lt),me}Le("packages/core/src/internal/util.js",function(o,oe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return y}});const me="1.74.0";async function X(){return me}const l="1.74.0",le=new Set,ne=2e3;function he(r){if(le.add(r),le.size>ne){const u=le.values().next().value;u!==void 0&&le.delete(u)}}const W=[],Z=500;function fe(r,u,h){W.push({key:r,level:u,message:h.map(M=>typeof M=="string"?M:V(M)).join(" "),at:Date.now()}),W.length>Z&&W.shift()}function V(r){if(r instanceof Error)return r.message;try{return JSON.stringify(r)}catch{return String(r)}}function I(){return W.map(r=>({...r}))}function U(r,...u){le.has(r)||(he(r),fe(r,"warn",u),console.warn("[lattice]",...u))}function D(r,...u){le.has(r)||(he(r),fe(r,"info",u),console.info("[lattice]",...u))}function T(){le.clear(),W.length=0}function _(r,u){const h=new Error(`[lattice] ${r}`);throw u!==void 0&&(h.cause=u),h}function k(r,u){r||_(u)}const N=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function b(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function a(r){return typeof r=="function"}function v(r){return r==null}function g(r){return r==null||r===""}function R(r){return typeof r!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(r))?!0:!!(r.prototype&&Object.getOwnPropertyNames(r.prototype).length>1)}const F=new Map;function p(r){let u=F.get(r);if(u)return u;if(!r.includes("."))u=h=>h?.[r];else{const h=r.split("."),M=h.length;u=A=>{let C=A;for(let Y=0;Y<M;Y++){if(C==null)return;C=C[h[Y]]}return C}}return F.set(r,u),u}const L=new Map;function B(r){let u=L.get(r);if(u)return u;if(!r.includes("."))u=(h,M)=>{h!=null&&(h[r]=M)};else{const h=r.split("."),M=h.length-1;u=(A,C)=>{let Y=A;for(let ee=0;ee<M;ee++){if(Y==null)return;const ue=h[ee];Y[ue]==null&&(Y[ue]={}),Y=Y[ue]}Y!=null&&(Y[h[M]]=C)}}return L.set(r,u),u}function H(r,u){return p(u)(r)}function G(r,u,h){B(u)(r,h)}function ae(r){return r?(r.includes(".")?r.slice(r.lastIndexOf(".")+1):r).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(/^./,h=>h.toUpperCase()):""}const J={"&":"&","<":"<",">":">",'"':""","'":"'"};function q(r){const u=r==null?"":String(r);return/[&<>"']/.test(u)?u.replace(/[&<>"']/g,h=>J[h]):u}function ce(r){return String(r).replace(/\w\S*/g,u=>u[0].toUpperCase()+u.slice(1).toLowerCase())}function j(r,u,h){if(r!==void 0)return r===!0?{enabled:!0,...h}:r===!1?{enabled:!1}:b(r)?r:{[u]:r,enabled:!0}}function z(r){return r==null?[]:Array.isArray(r)?r:[r]}const t=Object.freeze(new Set(["__proto__","constructor","prototype"]));function c(r,u){if(!b(r))return b(u)?{...u}:u;if(!b(u))return u===void 0?r:u;const h={...r};for(const M of Object.keys(u)){if(t.has(M))continue;const A=u[M];A!==void 0&&(h[M]=b(A)&&b(h[M])?c(h[M],A):A)}return h}function f(r,u){if(!b(r)||!b(u)||r===u)return u;const h=Object.create(Object.getPrototypeOf(r));return Object.assign(h,r,u),h}class e{#e;#t=new Map;#n;constructor(u=256,h=null){this.#e=u,this.#n=h}get size(){return this.#t.size}get max(){return this.#e}set max(u){this.#e=u,this.#r()}has(u){return this.#t.has(u)}get(u){const h=this.#t;if(!h.has(u))return;const M=h.get(u);return h.delete(u),h.set(u,M),M}peek(u){return this.#t.get(u)}set(u,h){const M=this.#t;return M.has(u)&&M.delete(u),M.set(u,h),this.#r(),h}delete(u){const h=this.#t.get(u);return this.#t.delete(u)&&this.#n&&this.#n(h,u),h}clear(){if(this.#n)for(const[u,h]of this.#t)this.#n(h,u);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const u=this.#t;for(;u.size>this.#e;){const h=u.keys().next().value,M=u.get(h);u.delete(h),this.#n&&this.#n(M,h)}}}const x=new Map;function S(r,u){const h=`${r||""}|${u?JSON.stringify(u):""}`;let M=x.get(h);return M||(M=new Intl.Collator(r||void 0,{numeric:!0,sensitivity:"variant",...u}),x.set(h,M)),M}function P(r,u){if(r===u)return 0;if(r==null)return 1;if(u==null)return-1;if(typeof r=="number"&&typeof u=="number")return Number.isNaN(r)?Number.isNaN(u)?0:1:Number.isNaN(u)||r<u?-1:r>u?1:0;const h=String(r),M=String(u);return h<M?-1:h>M?1:0}function w(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const s=typeof requestAnimationFrame=="function";function i(r){return s?requestAnimationFrame(r):setTimeout(()=>r(w()),16)}function O(r){r!=null&&(s?cancelAnimationFrame(r):clearTimeout(r))}function $(r){let u=null,h=null;const M=()=>{u=null;const C=h;h=null,r(...C||[])},A=(...C)=>{h=C,u===null&&(u=i(M))};return A.cancel=()=>{O(u),u=null,h=null},A.flush=()=>{u!==null&&(O(u),M())},A}function E(r,u){let h=null,M=null;const A=()=>{if(h=null,M===null)return;const ee=M;M=null,r(...ee),C()},C=()=>{h=setTimeout(A,u),typeof h?.unref=="function"&&h.unref()},Y=(...ee)=>{h===null?(r(...ee),C()):(M=ee,clearTimeout(h),C())};return Y.flush=()=>{if(h!==null&&clearTimeout(h),h=null,M===null)return;const ee=M;M=null,r(...ee)},Y.cancel=()=>{h!==null&&clearTimeout(h),h=null,M=null},Y.pending=()=>h!==null||M!==null,Y}function n(r,u=50){return typeof requestIdleCallback=="function"?requestIdleCallback(r,{timeout:u}):setTimeout(()=>r({timeRemaining:()=>0,didTimeout:!0}),1)}let d=0;function y(r="l"){return`${r}${(++d).toString(36)}`}}),Le("packages/core/src/source/filterwire.js",function(o,oe){"use strict";Object.defineProperty(o,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnWherePageRelative",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"warnWhereNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"warnWhereOverThreshold",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"parseRelativeToken",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"resolveRelativeRange",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"relativeTokenOf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"relativeTokenHelp",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isResolvableRelative",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"resolveRelativeCondition",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"isGroup",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"forEachCondition",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"mapConditions",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"normaliseFilterSet",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"buildFilterSet",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"wireFilters",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"querySignature",{enumerable:!0,get:function(){return ce}});const X=oe("packages/core/src/internal/util.js").warnOnce,l="source.remote.hostFilter",le="source.where.pageRelative";function ne(t,c){!Array.isArray(t)||!t.length||X(le,`filters.where (${t.join(", ")}) runs over the rows the ${c} 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 he(t){const c=(t||{}).config;!c||!c.hostFilter||X(l,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const W="source.where.notApplied";function Z(t,c){X(`${W}:${t}`,`filters.where("${t}") is registered but the ${c} 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 fe="source.where.overThreshold";function V(t,c,f,e){!Array.isArray(t)||!t.length||X(`${fe}:${c}`,`filters.where (${t.join(", ")}) is not applied to the ${c} pushdown source:`,f===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${f.toLocaleString()} rows, at or past the whereRowLimit of ${e.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 I=new Map;function U(t){let c=I.get(t);return c||(c=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),I.set(t,c)),c}function D(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function T(t,c){const f=U(c).formatToParts(new Date(t)),e={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const x of f)x.type==="year"?e.y=+x.value:x.type==="month"?e.m=+x.value:x.type==="day"?e.d=+x.value:x.type==="hour"?e.h=+x.value%24:x.type==="minute"?e.mi=+x.value:x.type==="second"&&(e.s=+x.value);return e}function _(t,c){const f=T(t,c);return Date.UTC(f.y,f.m-1,f.d,f.h,f.mi,f.s)-Math.floor(t/1e3)*1e3}function k(t,c,f,e){const x=Date.UTC(t,c-1,f),S=x-_(x,e);return x-_(S,e)}function N(t,c,f){const e=new Date(Date.UTC(t.y,t.m-1,t.d+c));return k(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),f)}const b=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function a(t,c){if(typeof t!="string")return null;const f=t.trim().toLowerCase().replace(/[\s_-]+/g,""),e=/^last(\d*|n)days?$/.exec(f);if(e){const x=e[1]==="n"?"":e[1],S=Number(x||c);return!Number.isFinite(S)||S<=0?null:{kind:"lastNDays",n:Math.floor(S)}}switch(f){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 v(t,c={}){const f=a(t,c.n);if(!f)return null;const e=c.tz||D(),x=c.now instanceof Date?c.now.getTime():typeof c.now=="number"?c.now:Date.now(),S=T(x,e),P=k(S.y,S.m,S.d,e),w=N(S,1,e);let s=P,i=w;switch(f.kind){case"today":break;case"yesterday":s=N(S,-1,e),i=P;break;case"lastNDays":i=c.includeToday?w:P,s=N(S,c.includeToday?-(f.n-1):-f.n,e);break;case"thisWeek":{const O=Number.isFinite(c.weekStartsOn)?Number(c.weekStartsOn):1,E=(new Date(Date.UTC(S.y,S.m-1,S.d)).getUTCDay()-O+7)%7;s=N(S,-E,e),i=N(S,-E+7,e);break}case"thisMonth":s=k(S.y,S.m,1,e),i=k(S.m===12?S.y+1:S.y,S.m===12?1:S.m+1,1,e);break;case"thisQuarter":case"quarterToDate":{const O=Math.floor((S.m-1)/3)*3+1;s=k(S.y,O,1,e),i=f.kind==="quarterToDate"?w:O===10?k(S.y+1,1,1,e):k(S.y,O+3,1,e);break}case"thisYear":case"yearToDate":s=k(S.y,1,1,e),i=f.kind==="yearToDate"?w:k(S.y+1,1,1,e);break;default:return null}return{from:new Date(s).toISOString(),to:new Date(i).toISOString(),bounds:"[)",tz:e,relative:f.kind==="lastNDays"?`last${f.n}Days`:f.kind,n:f.n}}function g(t){if(!t||typeof t!="object")return null;const c=t.value;if(c&&typeof c=="object"&&!Array.isArray(c)&&"relative"in c)return{token:String(c.relative),n:typeof c.n=="number"?c.n:void 0};if(t.op==="relative"&&typeof t.value=="string")return{token:t.value,n:void 0};const f=t.meta;return f&&typeof f.relative=="string"&&t.value===void 0?{token:f.relative,n:typeof f.n=="number"?f.n:void 0}:null}function R(){return`Known tokens: ${b.filter(c=>c!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function F(t){const c=g(t);return c?a(c.token,c.n)!==null:!1}function p(t,c={}){const f=g(t);if(!f)return t;const e=v(f.token,{...c,n:f.n});return e?{...t,type:t.type||"date",op:"between",value:[e.from,e.to],bounds:t.bounds||e.bounds,meta:{...t.meta||{},relative:e.relative,tz:e.tz}}:(X(`source.relative.${f.token}`,`unknown relative date token "${f.token}"; sending the condition unresolved.`,R()),t)}function L(t){return!!t&&typeof t=="object"&&Array.isArray(t.conditions)}function B(t,c){if(t){if(L(t)){for(const f of t.conditions)B(f,c);return}c(t)}}function H(t,c){if(!t)return null;if(!L(t))return c(t);const f=t;let e=!1;const x=[];for(const S of f.conditions){const P=H(S,c);P!==S&&(e=!0),P&&x.push(P)}return!e&&x.length===f.conditions.length?t:x.length?{...f,conditions:x}:null}function G(t){if(!t)return null;if(!L(t))return t;const c=t,f=[];for(const e of c.conditions){const x=G(e);x&&f.push(x)}return f.length?{op:c.op,conditions:f}:null}function ae(t){const c=G(t);return c?L(c)&&c.op==="and"?c:{op:"and",conditions:[c]}:null}function J(t){const c=(t||[]).filter(Boolean);return c.length?{op:"and",conditions:c}:null}function q(t,c={}){const f=H(t,e=>p(e,c));return ae(f)}function ce(t){const c=j(t.filters??null);return JSON.stringify([c,t.sort??null,t.quick??"",t.groupBy??null,t.pivotBy??null,z(t.context)])}function j(t){if(!t)return null;if(L(t)){const e=t;return{op:e.op,conditions:e.conditions.map(j)}}const c=t,f=c.meta&&typeof c.meta.relative=="string"?c.meta.relative:g(c)?.token;return{col:c.col,op:c.op,bounds:c.bounds??null,caseSensitive:c.caseSensitive??!1,value:f?`rel:${f}`:c.value??null}}function z(t){if(t==null)return null;try{return JSON.parse(JSON.stringify(t))}catch{return X("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Le("packages/core/src/source/aggregates.js",function(o,oe){"use strict";Object.defineProperty(o,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"pushableAggregates",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"fillAggregateSql",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"resolveAggregatesConfig",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"routeAggregate",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"resolveAggregatePlan",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"groupKeysPushable",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"pushdownDocRows",{enumerable:!0,get:function(){return fe}});const me=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function X(){const V=new Set;for(const[I,U]of Object.entries(me))U.pushable&&V.add(I);return V}function l(V,I,U){let D=V.split("%c").join(I);return U!==void 0&&(D=D.split("%w").join(U)),D}function le(V){const I=V||{},U=I.default==="engine"||I.default==="engine-if-identical"?I.default:"client",D={};if(I.overrides&&typeof I.overrides=="object")for(const[T,_]of Object.entries(I.overrides))(_==="engine"||_==="client")&&(D[T]=_);return{default:U,overrides:D}}function ne(V,I){const U=me[V];if(!U||!U.pushable)return"client";const D=I.overrides[V];return D==="engine"||D==="client"?D:I.default==="client"?"client":I.default==="engine-if-identical"?U.class==="identical"?"engine":"client":"engine"}function he(V,I){const U=le(I),D=[],T=[];for(const _ of V||[]){const k=me[_.fn],N=ne(_.fn,U),b={id:_.id,col:_.col,fn:_.fn,class:k?k.class:"fallback"};_.weight!==void 0&&(b.weight=_.weight),_.params!==void 0&&(b.params=_.params),N==="engine"?D.push(b):(b.reason=k&&!k.pushable?k.note||"the engine cannot express this stat":"client by config",T.push(b))}return{engine:D,client:T,config:U}}const W=/^[A-Za-z_][A-Za-z0-9_$]*$/;function Z(V,I=[]){return(V||[]).every(D=>{if(typeof D=="string")return W.test(D);if(!D||typeof D!="object")return!1;const T=D;return Array.isArray(I)&&I.includes(T.bucket)&&typeof T.col=="string"&&W.test(T.col)&&typeof T.size=="number"&&Number.isFinite(T.size)&&T.size>0})}function fe(){return Object.entries(me).map(([V,I])=>({stat:V,class:I.class,sql:I.sql?l(I.sql,"col",I.twoColumn?"weight":void 0):"",note:I.note||(I.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Le("packages/core/src/source/abort.js",function(o,oe){"use strict";Object.defineProperty(o,"SupersededError",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"RequestToken",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"AbortScope",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"createAbortScope",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isAbortError",{enumerable:!0,get:function(){return ne}});class me extends Error{constructor(W,Z="superseded"){super(`[lattice] request ${W?`"${W}" `:""}${Z}`),this.name="SupersededError",this.superseded=!0,this.key=W}}class X{#e;constructor(W,Z,fe,V){this.#e=W,this.key=Z,this.controller=fe,this.signal=fe.signal,this.seq=V}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(W){this.signal.aborted||this.controller.abort(new me(this.key,W)),this.#e.settle(this)}}class l{#e=new Map;#t=0;begin(W="",Z="superseded"){const fe=this.#e.get(W);fe&&!fe.signal.aborted&&fe.controller.abort(new me(W,Z));const V=new X(this,W,new AbortController,++this.#t);return this.#e.set(W,V),V}tokenFor(W){return this.#e.get(W)}pending(W=""){const Z=this.#e.get(W);return!!Z&&!Z.signal.aborted}get size(){return this.#e.size}settle(W){this.#e.get(W.key)===W&&this.#e.delete(W.key)}abort(W="",Z="superseded"){const fe=this.#e.get(W);fe&&fe.abort(Z)}abortAll(W="superseded"){for(const Z of[...this.#e.values()])Z.abort(W);this.#e.clear()}}function le(){return new l}function ne(he){if(!he||typeof he!="object")return!1;const W=he;return W.superseded===!0||W.name==="AbortError"||W.name==="SupersededError"}}),Le("packages/core/src/source/pushdown.js",function(o,oe){"use strict";Object.defineProperty(o,"NO_CAPABILITIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"resolveMutate",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"capabilitiesOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"splitFilters",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"planQuery",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"applyResidual",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"createPushdownSource",{enumerable:!0,get:function(){return z}});const me=oe("packages/core/src/internal/util.js"),X=me.isFunction,l=me.warnOnce,le=oe("packages/core/src/source/filterwire.js"),ne=le.isGroup,he=le.warnWherePageRelative,W=le.warnWhereOverThreshold,Z=oe("packages/core/src/source/aggregates.js"),fe=Z.resolveAggregatePlan,V=Z.groupKeysPushable,I=Z.STAT_PUSHDOWN,D=oe("packages/core/src/source/abort.js").SupersededError;function T(t){const c=t&&t.signal;if(!c||!c.aborted)return;const f=c.reason;throw f instanceof Error?f:new D("","superseded before it was sent")}const _=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,mutate:!1});function k(t){if(!t||typeof t!="object")return!1;const c=t.returning==="row"||t.returning==="key"?t.returning:"none";return{append:t.append===!0,update:t.update===!0,delete:t.delete===!0,returning:c}}function N(t,c){if(!t||typeof c!="string")return;if(!c.includes("."))return t[c];let f=t;for(const e of c.split(".")){if(f===null||typeof f!="object")return;f=f[e]}return f}function b(t){if(t===!0)return!0;if(!t||typeof t!="object")return!1;const c=t;return c.enabled===!1?!1:c.enabled===!0||X(c.commit)}function a(t){const c={..._,...t||{}};return c.operators=new Set(c.operators||[]),c.mutate=k(c.mutate),c}function v(t,c){return!t||!t.op||!c.operators.size?!1:c.operators.has(t.op)}function g(t,c){if(!t)return{pushed:null,residual:null};if(!c.filter)return{pushed:null,residual:t};if(c.filter==="term"){if(ne(t)){const S=t.conditions||[];if(String(t.op)!=="and")return{pushed:null,residual:t};const P=S.findIndex(s=>!ne(s)&&v(s,c));if(P<0)return{pushed:null,residual:t};const w=S.filter((s,i)=>i!==P);return{pushed:S[P],residual:w.length?{op:"and",conditions:w}:null}}return v(t,c)?{pushed:t,residual:null}:{pushed:null,residual:t}}if(!ne(t))return v(t,c)?{pushed:t,residual:null}:{pushed:null,residual:t};if(String(t.op)!=="and")return(t.conditions||[]).every(P=>ne(P)?g(P,c).residual===null:v(P,c))?{pushed:t,residual:null}:{pushed:null,residual:t};const f=[],e=[];for(const S of t.conditions||[]){if(ne(S)){if(c.filter==="flat"){e.push(S);continue}const P=g(S,c);P.pushed&&f.push(P.pushed),P.residual&&e.push(P.residual);continue}(v(S,c)?f:e).push(S)}const x=S=>S.length===0?null:S.length===1?S[0]:{op:"and",conditions:S};return{pushed:x(f),residual:x(e)}}function R(t,c,f,e,x,S,P){const w=Array.isArray(t.groupBy)?t.groupBy:[],s=Array.isArray(t.groupPath)?t.groupPath:[],i=Array.isArray(t.groupValues)?t.groupValues:null;return c.group?V(w)?f.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":e?x?S?"a host `where` predicate can only run in the browser, over rows the engine grouped":P?"fullDataset holds the whole matching set, so the grid groups it itself":!i||i.length!==s.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":"the adapter does not declare the `group` capability"}function F(t,c,f=!1){const e=g(t.filters||null,c),x=[];e.residual&&x.push("filter");const S=t.sort||[],P=S.length===0||c.sort==="multi"&&S.length>=1||c.sort==="single"&&S.length===1;!P&&S.length&&x.push("sort");const w=t.quick?String(t.quick):"",s=!w||!!c.quick;s||x.push("quick");const i=t.where&&t.where.active?t.where:null;i&&x.push("where");const O={filters:e.residual,sort:P?null:S,quick:s?"":w,where:i},$=!!f,E=Array.isArray(t.groupBy)&&t.groupBy.length>0,n=E?R(t,c,e,P,s,i,$):"",d=E&&n==="";E&&!d&&x.push("group");const y=d&&Array.isArray(t.groupValues)?t.groupValues.length:0,r=d?!1:$||!!(O.filters||O.sort||O.quick||O.where)||!c.range;return{pushed:{...t,filters:e.pushed,sort:P?S:[],quick:s?w:"",range:r?null:t.range},residual:O,needsAll:r,unpushed:x,full:$,grouped:d,groupLevel:y,groupReason:n}}function p(t){const c=Array.isArray(t.totals)?t.totals:[],f=t.totalFns&&typeof t.totalFns=="object"?t.totalFns:{},e=[],x=[];for(const S of c){const P=String(S),w=typeof f[P]=="string"?f[P]:null,s=w?I[w]:null;w?!s||!s.pushable||!s.sql?x.push({id:P,fn:w,class:s?s.class:"fallback",reason:s&&s.note?s.note:`the pushdown map cannot express "${w}"`}):s.twoColumn?x.push({id:P,fn:w,class:s.class,reason:`"${w}" reduces two columns, and a grouped request carries no weight column`}):e.push({id:P,col:P,fn:w,class:s.class}):x.push({id:P,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:e,client:x}}const L=Object.freeze({items:t=>t==null?[]:Array.isArray(t)?t:[t]});function B(t,c,f){if(!c)return t;let e=t;if(c.filters&&X(f.evaluateFilters)){const x=e,S={count:e.length,handle:s=>({id:s,get:i=>N(x[i],s)}),itemwise:s=>x.some(i=>Array.isArray(N(i,s)))?L:null},P=f.evaluateFilters(c.filters,S),w=[];for(let s=0;s<e.length;s++)P[s]&&w.push(e[s]);e=w}if(c.where&&c.where.active&&(c.whole||he(c.where.names,"pushdown"),e=e.filter(x=>c.where.passes(x))),c.quick){const x=c.quick.toLowerCase();e=e.filter(S=>{if(!S||typeof S!="object")return!1;for(const P of Object.values(S))if(P!=null&&String(P).toLowerCase().includes(x))return!0;return!1})}if(c.sort&&c.sort.length&&X(f.sortMulti)){const x=[...new Set(c.sort.map(s=>s.col))],S=e,P=x.map(s=>({id:s,get:i=>N(S[i],s)})),w=f.sortMulti(P,c.sort.map(s=>({col:s.col,dir:s.dir})),Uint32Array.from({length:e.length},(s,i)=>i),{});e=Array.from(w,s=>S[s])}return e}function H(t){return JSON.stringify({filters:t.filters||null,sort:t.sort||[],quick:t.quick||"",groupBy:t.groupBy||[],groupPath:t.groupPath||[],context:t.context??null})}function G(t){if(!t||typeof t!="object")return 16;let c="";try{c=JSON.stringify(t)}catch{return 200}return c.length*2+64}function ae(t){const c=t||{};return{enabled:!!c.enabled,maxRows:Number.isFinite(c.maxRows)?c.maxRows:1e6,maxBytesEstimate:Number.isFinite(c.maxBytesEstimate)?c.maxBytesEstimate:512*1024*1024}}const J=5e4;function q(t){return Number.isFinite(t)&&t>=0?t:J}function ce(t){return!!t&&X(t.then)}async function j(t){if(!t||t.total!==void 0||!ce(t.pendingTotal))return t;const c=await t.pendingTotal,{pendingTotal:f,...e}=t;return typeof c=="number"?{...e,total:c}:e}function z(t={}){const c=t.adapter;if(!c||!X(c.execute))return l("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...t,mode:"remote",fetch:async()=>({rows:[],total:0})};const f=a(c.capabilities),e=c.capabilities&&Object.getOwnPropertyDescriptor(c.capabilities,"operators");e&&X(e.get)&&Object.defineProperty(f,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(c.capabilities.operators||[]),set:()=>{}});const x=c.name||"adapter";let S=null;const P=()=>X(c.ready)?(S||(S=Promise.resolve(c.ready()).then(()=>{Object.assign(f,a(c.capabilities))},ge=>{throw S=null,ge})),S):null,w=ae(t.fullDataset),s=!!t.allowPartialResults,i=q(t.whereRowLimit);let O=null;const $=t.aggregates;let E=null,n=null,d=null,y=null,r=null,u,h=null,M=0,A=null;const C=()=>!w.enabled||!E?null:(A!==E.key&&(M++,A=E.key),{rows:E.rows,version:M}),Y=async ge=>{const Ae=ge.where&&ge.where.active?ge.where:null;if(!Ae)return{request:ge,probe:null};const{where:Me,...Ne}=ge,Be=F(Ne,f,w.enabled);if(Be.needsAll)return{request:ge,probe:null};const Fe=H(Be.pushed);let De=null;return(!O||O.key!==Fe)&&(f.total?(T(ge),De=await j(await c.execute(Be.pushed,ge)),O={key:Fe,size:De&&typeof De.total=="number"?De.total:null}):O={key:Fe,size:null}),O.size!==null&&O.size<i?{request:ge,probe:null}:(W(Ae.names,x,O.size,i),{request:Ne,probe:De})},ee=async(ge,Ae)=>{h=null;const Me=p(ge.pushed);d={engine:Me.engine,client:Me.client,groupBy:ge.pushed.groupBy},Me.client.length&&l(`source.pushdown.group.totals.${x}.${Me.client.map(Fe=>Fe.id).join(".")}`,`the ${x} adapter cannot compute the group subtotal for ${Me.client.map(Fe=>`"${Fe.id}" (${Fe.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 Ne=await c.executeGroupLevel(ge.pushed,Me.engine,Ae)||{};let Be=Ne.rows||[];return!f.range&&Ae.range&&(Be=Be.slice(Ae.range.start,Ae.range.end)),typeof Ne.matchCount=="number"&&(y=Ne.matchCount,r=Ne.grand?{totals:Ne.grand,leafCount:Ne.matchCount}:null,u===void 0&&X(c.unfilteredCount)&&(u=null,Promise.resolve(c.unfilteredCount()).then(Fe=>{u=typeof Fe=="number"?Fe:null}).catch(Fe=>{l(`source.pushdown.group.unfiltered.${x}`,`the ${x} adapter could not count the unfiltered set (${Fe&&Fe.message?Fe.message:Fe}), so "N of M" falls back to the display count for its denominator.`)}))),Ne.total===void 0?{rows:Be}:{rows:Be,total:Ne.total}},ue=(ge,Ae)=>{const Me={key:Ae,state:"pending",value:null};return h=Me,ge.then(Ne=>(h===Me&&(h={key:Ae,state:"settled",value:typeof Ne=="number"?Ne:null}),Ne),Ne=>{throw h===Me&&(h={key:Ae,state:"failed",value:null}),Ne})},we=async ge=>{const Ae=P();Ae&&await Ae;const Me=await Y(ge);T(ge);let Ne=F(Me.request,f,w.enabled);if(Ne.grouped&&!X(c.executeGroupLevel)&&(l(`source.pushdown.group.method.${x}`,`the ${x} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid is left to group whatever rows it holds. Implement the method or drop the capability.`),Ne=F(Me.request,{...f,group:!1},w.enabled)),n=Ne,Ne.grouped)return ee(Ne,ge);if(Ne.groupReason&&l(`source.pushdown.group.${x}.${Ne.groupReason}`,`the ${x} adapter was not asked to group this query because ${Ne.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.`),!Ne.needsAll){const Pe=Me.probe||await c.execute(Ne.pushed,ge),Re=Pe.rows||[];return ce(Pe.pendingTotal)&&Pe.total===void 0?{rows:Re,pendingTotal:ue(Pe.pendingTotal,H(Ne.pushed))}:(h=null,!f.total&&Pe.total===void 0?{rows:Re}:{rows:Re,total:Pe.total??Re.length})}Ne.unpushed.length&&l(`source.pushdown.residual.${x}.${Ne.unpushed.join(".")}`,`the ${x} adapter cannot push ${Ne.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 Be=H(Ne.pushed);if(!E||E.key!==Be){const Pe=await j(await c.execute(Ne.pushed,ge));h=null;const Re=Pe.rows||[];if(Ne.full){const Ye=typeof Pe.total=="number"?Math.max(Pe.total,Re.length):Re.length;if(Ye>w.maxRows)throw new Error(`[lattice] fullDataset refused: the ${x} adapter's matching set is ${Ye.toLocaleString()} rows, past the configured maxRows of ${w.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 tt=Re.length*G(Re[0]);if(tt>w.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${x} adapter's matching set is an estimated ${Math.round(tt/(1024*1024)).toLocaleString()} MB across ${Re.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(w.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 Pe.total=="number"&&Re.length<Pe.total){const Ye=!!(Ne.residual.filters||Ne.residual.quick||Ne.residual.sort&&Ne.residual.sort.length);if(Ye&&!s)throw new Error(`[lattice] the ${x} adapter returned ${Re.length} of ${Pe.total} matching rows when asked for the whole result, and the query has residual ${Ne.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.`);Ye?l(`source.pushdown.partial.residual.${x}`,`the ${x} adapter returned ${Re.length} of ${Pe.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.`):l(`source.pushdown.partial.${x}`,`the ${x} adapter returned ${Re.length} of ${Pe.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}E={key:Be,rows:Re,total:typeof Pe.total=="number"?Pe.total:null}}let Fe=Ne;if(Ne.residual.where){const Pe=E.total??E.rows.length;if(Pe>=i){W(Ne.residual.where.names,x,Pe,i);const{where:Re,...Ye}=Me.request;Fe=F(Ye,f,w.enabled),n=Fe}}const De=E.total!==null&&E.rows.length>=E.total,We=B(E.rows,{...Fe.residual,whole:De},t.compute||{}),Ue=ge.range?ge.range.start:0,He=ge.range?ge.range.end:We.length;return{rows:We.slice(Ue,He),total:We.length}},Oe=async(ge,Ae)=>{const Me=P();Me&&await Me;const Ne=F(ge,f,w.enabled);n=Ne;const Be=fe(Ae,$),Fe=Array.isArray(ge.groupBy)?ge.groupBy:[],De=Fe.length>0,We=!Ne.residual.filters&&!Ne.residual.quick,Ue=!De||V(Fe,f.buckets);let He=Be.engine,Pe=Be.client;const Re=ft=>{Pe=[...He.map(ut=>({...ut,reason:ft})),...Pe],He=[]};He.length&&!We?Re(Ne.residual.quick&&!Ne.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):He.length&&!Ue&&Re("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Ye={},tt;return He.length&&(X(De?c.executeGroupedAggregates:c.executeAggregates)?De?tt=await c.executeGroupedAggregates(Ne.pushed,Fe,He)||[]:Ye=await c.executeAggregates(Ne.pushed,He)||{}:(l(`source.pushdown.aggregates.${x}${De?".grouped":""}`,`the ${x} adapter cannot compute ${De?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Re(`adapter cannot compute ${De?"grouped ":""}aggregates`))),d={engine:He,client:Pe,...De?{groupBy:Fe}:{}},{values:Ye,engine:He,client:Pe,...tt!==void 0?{groups:tt}:{}}},ke=b(t.edit),$e=t.edit&&typeof t.edit=="object"&&X(t.edit.commit);let je=t.edit;if(ke&&!$e)if(f.mutate&&f.mutate.update){const ge=Ae=>{if(!f.mutate||!f.mutate.update)throw new Error(`[lattice] the ${x} 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 Me={kind:"update",key:String(Ae.key),patch:{[Ae.colId]:Ae.value}};return c.mutate(Me,Ae.request||{})};je={...t.edit===!0?{}:t.edit,commit:ge}}else l(`source.pushdown.readonly.${x}`,`edit is enabled but the ${x} adapter declares mutate: ${f.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 xe=ke&&f.mutate&&(f.mutate.append||f.mutate.delete)?{append:f.mutate.append===!0,remove:f.mutate.delete===!0,returning:f.mutate.returning,mutate:(ge,Ae)=>c.mutate(ge,Ae||{})}:null;return{...t,edit:je,rowMutate:xe,mode:"remote",fetch:we,aggregate:Oe,lastPlan:()=>n?{...n,...d?{aggregates:d}:{},...h?{total:{deferred:!0,state:h.state,value:h.value}}:{}}:null,fullFrame:C,counts:()=>({match:y,total:u??null,pending:!!h&&h.state==="pending"}),grandTotals:()=>r}}}),Le("packages/modules/shared/engine.js",function(o,oe){"use strict";Object.defineProperty(o,"sourceId",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"engineSource",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"loadedAndMatching",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"gridHoldsWindow",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"gridEngineRequest",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"EngineFlight",{enumerable:!0,get:function(){return T}});const me=oe("packages/core/src/source/pushdown.js"),X=me.capabilitiesOf,l=me.planQuery,ne=oe("packages/core/src/source/filterwire.js").wireFilters,he=new WeakMap;let W=0;function Z(_){let k=he.get(_);return k===void 0&&(k=++W,he.set(_,k)),k}function fe(_){const k=_&&typeof _.config=="function"?_.config():null,N=k&&k.source&&typeof k.source=="object"?k.source:null;if(!N||typeof N.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const b=X(N.adapter&&N.adapter.capabilities);return{source:N,caps:b,config:k}}function V(_){let k=0;_.rows.forEach(b=>{b&&!b.group&&b.data!==null&&b.data!==void 0&&k++});const N=typeof _.rows.matchCount=="function"?_.rows.matchCount():NaN;return{loaded:k,total:Number.isFinite(N)?N:NaN}}function I(_){const k=_&&typeof _.config=="function"?_.config():null,N=k&&k.source&&typeof k.source=="object"?k.source:null;if(!N||N.mode!=="remote"&&N.mode!=="paged")return!1;const{loaded:b,total:a}=V(_);return Number.isFinite(a)&&b<a}function U(_,k){return k?_?{op:"and",conditions:[_,k]}:k:_||null}function D(_,k,N=null){const b=_.filters&&typeof _.filters.where=="function"?_.filters.where():[];if(Array.isArray(b)&&b.length)return{reason:`a \`where\` predicate is in force (${b.join(", ")}), which only the browser can run`};const a=_.filters&&typeof _.filters.quickState=="function"?_.filters.quickState():{text:""},v=a&&a.text?String(a.text):"",{config:g,caps:R}=k,F={filters:ne(U(_.filters.get(),N),{tz:g.timeZone,weekStartsOn:g.weekStartsOn}),sort:[],range:null,context:g.context??null,...v?{quick:v}:{}},p=l(F,R);return p.unpushed.includes("filter")?{reason:N?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:p.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:F,quick:v}}class T{#e=null;#t=null;#n=!1;answer(k){return this.#t&&this.#t.key===k?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(k,N,b){const a=this.#e;if(a){a.key!==k&&a.controller&&a.controller.abort();return}const v=globalThis.AbortController,g=typeof v=="function"?new v:null,R={key:k,controller:g};this.#e=R;let F;Promise.resolve().then(()=>N(g?g.signal:null)).then(p=>{F={key:k,result:p}},p=>{F={key:k,error:p}}).then(()=>{this.#e===R&&(this.#e=null),!this.#n&&(g&&g.signal.aborted||(this.#t=F),b())})}abort(){const k=this.#e;k&&k.controller&&k.controller.abort()}close(){this.#n=!0,this.abort()}}}),Le("packages/modules/charts/scale.js",function(o,oe){"use strict";Object.defineProperty(o,"isNumber",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"toNumber",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"toTime",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extent",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"niceStep",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"niceDomain",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureDomain",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"linearTicks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"timeStepFor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"timeTicks",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"linearScale",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"timeScale",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"key",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"bandScale",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"sqrtScale",{enumerable:!0,get:function(){return F}});const me=[1,2,2.5,5,10],X=6e4,l=36e5,le=864e5,ne=365.25*le,he=[1,2,5,10,20,25,50,100],W=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,X,5*X,15*X,30*X,l,3*l,6*l,12*l,le,2*le,7*le,14*le,30*le,90*le,180*le,...he.map(p=>p*ne)];function Z(p){return typeof p=="number"&&Number.isFinite(p)}function fe(p){if(p==null||p==="")return null;if(p instanceof Date){const B=p.getTime();return Number.isFinite(B)?B:null}if(typeof p=="boolean")return p?1:0;const L=Number(p);return Number.isFinite(L)?L:null}function V(p){if(p==null||p==="")return null;if(p instanceof Date){const B=p.getTime();return Number.isFinite(B)?B:null}if(typeof p=="number")return Number.isFinite(p)?p:null;const L=Date.parse(String(p));return Number.isFinite(L)?L:null}function I(p){let L=1/0,B=-1/0;for(let H=0;H<p.length;H++){const G=p[H];Z(G)&&(G<L&&(L=G),G>B&&(B=G))}return L===1/0?null:{min:L,max:B}}function U(p){if(!(p>0))return 1;const L=10**Math.floor(Math.log10(p));for(const B of me)if(p<=B*L)return B*L;return 10*L}function D(p,L=5){const B=U((p.max-p.min)/Math.max(1,L));return{min:Math.floor(p.min/B)*B,max:Math.ceil(p.max/B)*B,step:B}}function T(p,L={}){const B=I(p)||{min:0,max:1};let{min:H,max:G}=B;if(L.zero&&(H>0&&(H=0),G<0&&(G=0)),H===G){const ae=Math.abs(H)>0?Math.abs(H)/10:1;H-=ae,G+=ae}if(L.nice!==!1){const ae=D({min:H,max:G},L.ticks||5);H=ae.min,G=ae.max}return Z(L.min)&&(H=L.min),Z(L.max)&&(G=L.max),H===G&&(G=H+1),{min:H,max:G}}function _(p,L=5){const B=U((p.max-p.min)/Math.max(1,L)),H=Math.ceil(p.min/B),G=Math.floor(p.max/B),ae=[];for(let J=H;J<=G;J++){const q=J*B;ae.push(Math.abs(q)<B/1e6?0:Number(q.toPrecision(12)))}return ae}function k(p,L=5){const B=Math.max(1,L),H=p/B;let G=W[W.length-1];for(const q of W)if(q>=H){G=q;break}if(G<ne)return G;let ae=G,J=Math.abs(p/G-B);for(const q of W){if(q<ne)continue;const ce=Math.abs(p/q-B);ce<J&&(J=ce,ae=q)}return ae}function N(p,L){const B=new Date(p.min).getUTCFullYear();let H=Math.ceil(B/L)*L;Date.UTC(H,0,1)<p.min&&(H+=L);const G=[];for(;Date.UTC(H,0,1)<=p.max;H+=L)G.push(Date.UTC(H,0,1));return G}function b(p,L=5){const B=k(p.max-p.min,L);if(B>=ne)return N(p,Math.round(B/ne));const H=[],G=Math.ceil(p.min/B)*B;for(let ae=G;ae<=p.max;ae+=B)H.push(ae);return H}function a(p,L){const B=p.max-p.min||1,[H,G]=L;return{kind:"linear",domain:p,range:L,of(ae){return H+(ae-p.min)/B*(G-H)},invert(ae){return p.min+(ae-H)/(G-H||1)*B},ticks(ae=5){return _(p,ae)}}}function v(p,L){return{...a(p,L),kind:"time",ticks(H=5){return b(p,H)}}}function g(p){if(p==null)return" null";if(p instanceof Date)return` date:${p.getTime()}`;if(typeof p=="object"){const L=p,B=L.id??L.key??L.value;return B!==void 0&&typeof B!="object"?` obj:${String(B)}`:` obj:${String(p)}`}return String(p)}function R(p,L,B=.2){const H=Math.min(.9,Math.max(0,B)),[G,ae]=L,J=new Map;for(let j=0;j<p.length;j++){const z=g(p[j]);J.has(z)||J.set(z,j)}const q=p.length?(ae-G)/p.length:ae-G,ce=Math.max(0,q*(1-H));return{kind:"band",domain:p,range:L,bandwidth:ce,step:q,of(j){const z=J.get(g(j));return z===void 0?NaN:G+z*q+(q-ce)/2},centre(j){const z=this.of(j);return Number.isNaN(z)?NaN:z+ce/2},ticks(){return p}}}function F(p,L){const[B,H]=L,G=Math.max(Math.abs(p.max),Math.abs(p.min),0)||1;return{kind:"sqrt",domain:p,range:L,of(ae){const J=Math.sqrt(Math.abs(ae)/G);return B+J*(H-B)}}}}),Le("packages/modules/charts/svg.js",function(o,oe){"use strict";Object.defineProperty(o,"SVG_NS",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"el",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"svg",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"attr",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"attrs",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setText",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"clear",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"append",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"path",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"ribbonPath",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"round",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pathRings",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"insideRings",{enumerable:!0,get:function(){return D}});const me="http://www.w3.org/2000/svg";function X(T,_,k){const N=T.createElement(_);return k&&N.setAttribute("class",k),N}function l(T,_,k){const N=T.createElementNS(me,_);if(k)for(const b of Object.keys(k))N.setAttribute(b,String(k[b]));return N}function le(T,_,k){T&&(k==null?T.removeAttribute(_):T.setAttribute(_,String(k)))}function ne(T,_){if(T)for(const k of Object.keys(_))le(T,k,_[k])}function he(T,_){T&&(T.textContent=_==null?"":String(_))}function W(T){if(T)for(;T.firstChild;)T.removeChild(T.firstChild)}function Z(T,_){for(const k of _)k&&T.appendChild(k);return T}function fe(T){return T.join(" ")}function V(T){if(!T||T.length<2)return"";const _=["M",T[0].x,T[0].upper];for(let k=1;k<T.length;k++)_.push("L",T[k].x,T[k].upper);for(let k=T.length-1;k>=0;k--)_.push("L",T[k].x,T[k].lower);return _.push("Z"),fe(_)}function I(T){return Math.round(T*100)/100}function U(T){const _=[];let k=[];const N=String(T||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let b="",a=[];const v=()=>{if(!b||!a.length){a=[];return}if(b==="M"||b==="L")for(let g=0;g+1<a.length;g+=2)k.push([a[g],a[g+1]]);else b!=="Z"&&a.length>=2&&k.push([a[a.length-2],a[a.length-1]]);a=[]};for(const g of N){if(/[A-Za-z]/.test(g)){if(v(),g==="Z"||g==="z"){k.length>2&&_.push(k),k=[],b="";continue}g==="M"&&k.length>2&&(_.push(k),k=[]),b=g;continue}a.push(Number(g))}return v(),k.length>2&&_.push(k),_}function D(T,_,k){let N=!1;for(const b of T)for(let a=0,v=b.length-1;a<b.length;v=a++){const[g,R]=b[a],[F,p]=b[v];R>k!=p>k&&_<(F-g)*(k-R)/(p-R||1e-12)+g&&(N=!N)}return N}}),Le("packages/modules/charts/typography.js",function(o,oe){"use strict";Object.defineProperty(o,"BASE_SIZE",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"BASE_FAMILY",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"CHAR_RATIO",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"resolveType",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"textWidth",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"widestLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"truncateTo",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"applySize",{enumerable:!0,get:function(){return fe}});const me=12,X="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",l=.62;function le(V){const I=V&&V.font,U=typeof I=="number"?{size:I}:I||{},D=ne(U.size,me);return{family:U.family||X,size:D,small:ne(U.small??U.tickSize,Math.max(9,D-1)),title:ne(U.title,Math.round(D*1.15)),axisTitle:ne(U.axisTitle,Math.max(10,D-1)),weight:U.weight||"inherit"}}function ne(V,I){const U=Number(V);return Number.isFinite(U)&&U>0?U:I}function he(V,I){return String(V??"").length*I*l}function W(V,I){let U=0;for(const D of V||[]){const T=he(D,I);T>U&&(U=T)}return U}function Z(V,I,U){const D=String(V??""),T=Math.floor(I/(U*l));return T<=0?"":D.length<=T?D:T===1?"…":`${D.slice(0,T-1)}…`}function fe(V,I){!V||!Number.isFinite(I)||(V.style?V.style.fontSize=`${I}px`:V.setAttribute("style",`font-size:${I}px`))}}),Le("packages/modules/charts/frame.js",function(o,oe){"use strict";Object.defineProperty(o,"LABEL_GAP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"resolveMargin",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"plotRect",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"shouldRotate",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"Pool",{enumerable:!0,get:function(){return U}});const X=oe("packages/modules/charts/svg.js").SVG_NS,l=oe("packages/modules/charts/typography.js"),le=l.textWidth,ne=l.widestLabel,he=8,W=6,Z=.4;function fe(D,T){const _=typeof D=="number"?D:T,k=D&&typeof D=="object"?D:{},N=b=>Number.isFinite(b)&&b>=0?Number(b):_;return{base:_,top:N(k.top),right:N(k.right),bottom:N(k.bottom),left:N(k.left)}}function V(D){const T=fe(D.margin,typeof D.padding=="number"?D.padding:8),_=T.base,k=D.fontSize||12,N=D.yLabels||[],b=D.xLabels||[],a=D.ySide==="right"?"right":"left",v=a==="right"?"left":"right",g=D.titles||{},R=D.titleSize||k,F=z=>z?R+W:0,p=ne(N,k),L=N.length?Math.min(D.width*Z,T[a]+p+W):Math.max(he,T[a]),B=T[v]+(D.rightGutter||0),H=(a==="left"?L:B)+F(g.left),G=ne(b.map(z=>String(z).slice(0,14)),k),ae=(b.length?D.rotated?Math.min(D.height*Z,W+G):k+W+T.bottom:Math.max(he,T.bottom))+F(g.bottom),J=(a==="right"?L:B)+F(g.right),q=T.top+(D.topGutter||0),ce=Math.max(0,D.width-H-J),j=Math.max(0,D.height-q-ae);return{left:H,top:q,width:ce,height:j,right:H+ce,bottom:q+j,gutter:{left:H,bottom:ae,right:J,top:q}}}function I(D,T,_,k){if(!D.length||T<=0)return!1;const N=Number.isFinite(k)&&k>0?Number(k):1;return ne(D,_)>T*N-4}class U{#e;#t=0;static#n="data-pool-key";constructor(T){this.#e=T}next(T,_,k){if(k!=null)return this.#r(T,_,String(k));const N=this.#e.childNodes[this.#t],b=N&&N.tagName;if(b&&String(b).toLowerCase()===T.toLowerCase())return _&&N.setAttribute("class",_),this.#t++,N;const a=this.#e.ownerDocument.createElementNS(X,T);return _&&a.setAttribute("class",_),N?this.#e.insertBefore(a,N):this.#e.appendChild(a),this.#t++,a}#r(T,_,k){const N=T.toLowerCase();for(let v=this.#t;v<this.#e.childNodes.length;v++){const g=this.#e.childNodes[v],R=g&&g.tagName;if(R&&String(R).toLowerCase()===N&&g.getAttribute(U.#n)===k)return v!==this.#t&&this.#e.insertBefore(g,this.#e.childNodes[this.#t]),_&&g.setAttribute("class",_),this.#t++,g}const b=this.#e.ownerDocument.createElementNS(X,T);b.setAttribute(U.#n,k),_&&b.setAttribute("class",_);const a=this.#e.childNodes[this.#t];return a?this.#e.insertBefore(b,a):this.#e.appendChild(b),this.#t++,b}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Le("packages/modules/charts/scheme.js",function(o,oe){"use strict";Object.defineProperty(o,"PALETTE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"SCHEMES",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"registerScheme",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"setDefaultScheme",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"schemeNames",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"resolveScheme",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"toRgb",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rampStops",{enumerable:!0,get:function(){return k}});const X=oe("packages/core/src/internal/util.js").warnOnce,l=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),le=Object.freeze({default:{series:l,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"}}),ne=new Map;let he="default";function W(N,b){!N||!b||ne.set(String(N),b)}function Z(N){if(typeof N=="string"){he=N;return}N&&typeof N=="object"&&(ne.set("__default__",N),he="__default__")}function fe(){return[...Object.keys(le),...ne.keys()].filter(N=>!N.startsWith("__"))}function V(N){return ne.has(N)?ne.get(N):le[N]||null}const I=["series","sequential","diverging","positive","negative"];function U(N){return!N||typeof N!="object"||Array.isArray(N)?!1:!I.some(b=>b in N)}function D(N){const b=V(he)||le.default,a=N&&N.scheme,v=U(a)?a:null,g=typeof a=="string"?V(a):v?null:a||null,R=N&&Array.isArray(N.palette)&&N.palette.length?N.palette:null;v&&R&&X("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const F=v?null:R,p={...le.default,...b,...g||{}};F&&(p.series=F);const L=N&&Array.isArray(N.ramp)&&N.ramp.length>=2?N.ramp:null;L&&(p.sequential=L);const B=!!(g||F||v),H=p.series&&p.series.length?p.series:l,G=new Map;let ae=0;return{...p,series:(q,ce)=>{if(v&&ce!==void 0&&ce!==null){const j=String(ce);return Object.prototype.hasOwnProperty.call(v,j)?v[j]:(G.has(j)||G.set(j,ae++),T(H,G.get(j),!0))}return T(H,q,B)},explicit:B,nameMap:!!v}}function T(N,b,a){const v=(b%N.length+N.length)%N.length;return a?N[v]:`var(--lattice-chart-${v+1}, ${N[v]})`}function _(N){if(typeof N!="string")return null;const b=N.trim(),a=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(b);if(a){const R=a[1];return R.length===3?[0,1,2].map(F=>parseInt(R[F]+R[F],16)):[0,2,4].map(F=>parseInt(R.slice(F,F+2),16))}const v=/^rgba?\(([^)]+)\)$/i.exec(b);if(!v)return null;const g=v[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return g.length===3&&g.every(R=>Number.isFinite(R))?g:null}function k(N,b){const a=b?N.diverging:N.sequential,v=b?le.default.diverging:le.default.sequential,g=(Array.isArray(a)?a:v).map((R,F)=>_(R)||_(v[F])||[0,0,0]);return g.length>=2?g:v.map(R=>_(R))}}),Le("packages/modules/charts/styles.js",function(o,oe){"use strict";Object.defineProperty(o,"NS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"seriesColour",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"css",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"injectStyles",{enumerable:!0,get:function(){return W}});const X=oe("packages/modules/charts/scheme.js").PALETTE,l="lat-chartview",le="data-lattice-chartview";function ne(Z){const fe=(Z%X.length+X.length)%X.length;return`var(--lattice-chart-${fe+1}, ${X[fe]})`}function he(){return`
|
|
6
|
+
var Rt=Object.create(null),Ft=Object.create(null);function Ge(o,ue){Rt[o]=ue}function zt(o){var ue=Ft[o];if(ue)return ue;var xe=Object.create(null);Ft[o]=xe;var re=Rt[o];if(!re)throw new Error("[lattice] missing module: "+o);return re(xe,zt),xe}Ge("packages/core/src/internal/util.js",function(o,ue){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return w}});const xe="1.75.0";async function re(){return xe}const l="1.75.0",ge=new Set,ae=2e3;function ke(r){if(ge.add(r),ge.size>ae){const u=ge.values().next().value;u!==void 0&&ge.delete(u)}}const K=[],te=500;function pe(r,u,N){K.push({key:r,level:u,message:N.map(G=>typeof G=="string"?G:V(G)).join(" "),at:Date.now()}),K.length>te&&K.shift()}function V(r){if(r instanceof Error)return r.message;try{return JSON.stringify(r)}catch{return String(r)}}function B(){return K.map(r=>({...r}))}function Y(r,...u){ge.has(r)||(ke(r),pe(r,"warn",u),console.warn("[lattice]",...u))}function C(r,...u){ge.has(r)||(ke(r),pe(r,"info",u),console.info("[lattice]",...u))}function L(){ge.clear(),K.length=0}function F(r,u){const N=new Error(`[lattice] ${r}`);throw u!==void 0&&(N.cause=u),N}function x(r,u){r||F(u)}const _=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function p(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function i(r){return typeof r=="function"}function S(r){return r==null}function d(r){return r==null||r===""}function W(r){return typeof r!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(r))?!0:!!(r.prototype&&Object.getOwnPropertyNames(r.prototype).length>1)}const I=new Map;function b(r){let u=I.get(r);if(u)return u;if(!r.includes("."))u=N=>N?.[r];else{const N=r.split("."),G=N.length;u=j=>{let R=j;for(let J=0;J<G;J++){if(R==null)return;R=R[N[J]]}return R}}return I.set(r,u),u}const H=new Map;function z(r){let u=H.get(r);if(u)return u;if(!r.includes("."))u=(N,G)=>{N!=null&&(N[r]=G)};else{const N=r.split("."),G=N.length-1;u=(j,R)=>{let J=j;for(let ne=0;ne<G;ne++){if(J==null)return;const ce=N[ne];J[ce]==null&&(J[ce]={}),J=J[ce]}J!=null&&(J[N[G]]=R)}}return H.set(r,u),u}function q(r,u){return b(u)(r)}function U(r,u,N){z(u)(r,N)}function oe(r){return r?(r.includes(".")?r.slice(r.lastIndexOf(".")+1):r).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(/^./,N=>N.toUpperCase()):""}const ee={"&":"&","<":"<",">":">",'"':""","'":"'"};function Z(r){const u=r==null?"":String(r);return/[&<>"']/.test(u)?u.replace(/[&<>"']/g,N=>ee[N]):u}function de(r){return String(r).replace(/\w\S*/g,u=>u[0].toUpperCase()+u.slice(1).toLowerCase())}function E(r,u,N){if(r!==void 0)return r===!0?{enabled:!0,...N}:r===!1?{enabled:!1}:p(r)?r:{[u]:r,enabled:!0}}function D(r){return r==null?[]:Array.isArray(r)?r:[r]}const t=Object.freeze(new Set(["__proto__","constructor","prototype"]));function f(r,u){if(!p(r))return p(u)?{...u}:u;if(!p(u))return u===void 0?r:u;const N={...r};for(const G of Object.keys(u)){if(t.has(G))continue;const j=u[G];j!==void 0&&(N[G]=p(j)&&p(N[G])?f(N[G],j):j)}return N}function c(r,u){if(!p(r)||!p(u)||r===u)return u;const N=Object.create(Object.getPrototypeOf(r));return Object.assign(N,r,u),N}class e{#e;#t=new Map;#n;constructor(u=256,N=null){this.#e=u,this.#n=N}get size(){return this.#t.size}get max(){return this.#e}set max(u){this.#e=u,this.#r()}has(u){return this.#t.has(u)}get(u){const N=this.#t;if(!N.has(u))return;const G=N.get(u);return N.delete(u),N.set(u,G),G}peek(u){return this.#t.get(u)}set(u,N){const G=this.#t;return G.has(u)&&G.delete(u),G.set(u,N),this.#r(),N}delete(u){const N=this.#t.get(u);return this.#t.delete(u)&&this.#n&&this.#n(N,u),N}clear(){if(this.#n)for(const[u,N]of this.#t)this.#n(N,u);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const u=this.#t;for(;u.size>this.#e;){const N=u.keys().next().value,G=u.get(N);u.delete(N),this.#n&&this.#n(G,N)}}}const v=new Map;function $(r,u){const N=`${r||""}|${u?JSON.stringify(u):""}`;let G=v.get(N);return G||(G=new Intl.Collator(r||void 0,{numeric:!0,sensitivity:"variant",...u}),v.set(N,G)),G}function M(r,u){if(r===u)return 0;if(r==null)return 1;if(u==null)return-1;if(typeof r=="number"&&typeof u=="number")return Number.isNaN(r)?Number.isNaN(u)?0:1:Number.isNaN(u)||r<u?-1:r>u?1:0;const N=String(r),G=String(u);return N<G?-1:N>G?1:0}function y(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const s=typeof requestAnimationFrame=="function";function a(r){return s?requestAnimationFrame(r):setTimeout(()=>r(y()),16)}function A(r){r!=null&&(s?cancelAnimationFrame(r):clearTimeout(r))}function P(r){let u=null,N=null;const G=()=>{u=null;const R=N;N=null,r(...R||[])},j=(...R)=>{N=R,u===null&&(u=a(G))};return j.cancel=()=>{A(u),u=null,N=null},j.flush=()=>{u!==null&&(A(u),G())},j}function T(r,u){let N=null,G=null;const j=()=>{if(N=null,G===null)return;const ne=G;G=null,r(...ne),R()},R=()=>{N=setTimeout(j,u),typeof N?.unref=="function"&&N.unref()},J=(...ne)=>{N===null?(r(...ne),R()):(G=ne,clearTimeout(N),R())};return J.flush=()=>{if(N!==null&&clearTimeout(N),N=null,G===null)return;const ne=G;G=null,r(...ne)},J.cancel=()=>{N!==null&&clearTimeout(N),N=null,G=null},J.pending=()=>N!==null||G!==null,J}function n(r,u=50){return typeof requestIdleCallback=="function"?requestIdleCallback(r,{timeout:u}):setTimeout(()=>r({timeRemaining:()=>0,didTimeout:!0}),1)}let h=0;function w(r="l"){return`${r}${(++h).toString(36)}`}}),Ge("packages/modules/geometry/geodata.js",function(o,ue){"use strict";Object.defineProperty(o,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"EARTH_RADIUS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toWkt",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toWkb",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"readGeometry",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"parseGeometry",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"haversine",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"geometryInfo",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"geometryKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"spatialOperand",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"spatialPredicate",{enumerable:!0,get:function(){return we}});const xe=ue("packages/core/src/internal/util.js"),re=xe.isNil,l=xe.isObject,ge=xe.warnOnce,ae=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),ke=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),K=Object.freeze([...ke,"blank","notBlank"]),te=63710088e-1,pe=Math.PI/180,V=16,B=1e-12;class Y extends Error{}function C(g){throw new Y(g)}function L(g){(!Array.isArray(g)||g.length<2)&&C("a position needs at least two numbers");const k=Number(g[0]),O=Number(g[1]);return(typeof g[0]!="number"||typeof g[1]!="number"||!Number.isFinite(k)||!Number.isFinite(O))&&C("a coordinate is not a finite number"),[k,O]}function F(g,k,O){Array.isArray(g)||C(`${O} is not an array of positions`);const X=g.map(L);return X.length<k&&C(`${O} needs at least ${k} positions, found ${X.length}`),X}function x(g){const k=F(g,3,"a polygon ring"),O=k[0],X=k[k.length-1];return(O[0]!==X[0]||O[1]!==X[1])&&k.push([O[0],O[1]]),k.length<4&&C(`a polygon ring needs at least 3 distinct corners, found ${k.length-1}`),k}function _(g){return(!Array.isArray(g)||g.length===0)&&C("a polygon needs at least an outer ring"),g.map(x)}function p(g,k){switch(k>V&&C("geometry collections nest too deeply"),l(g)||C("GeoJSON must be an object"),g.type){case"Feature":return g.geometry==null?null:p(g.geometry,k+1);case"FeatureCollection":return C("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:L(g.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:F(g.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:F(g.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray(g.coordinates)||!g.coordinates.length)&&C("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:g.coordinates.map(O=>F(O,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:_(g.coordinates)};case"MultiPolygon":return(!Array.isArray(g.coordinates)||!g.coordinates.length)&&C("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:g.coordinates.map(_)};case"GeometryCollection":{(!Array.isArray(g.geometries)||!g.geometries.length)&&C("a GeometryCollection needs at least one geometry");const O=g.geometries.map(X=>p(X,k+1)).filter(Boolean);return O.length?{type:"GeometryCollection",geometries:O}:null}default:return C(`"${String(g.type)}" is not a GeoJSON geometry type`)}}const i=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),S=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,d=/[A-Za-z]+/y,W=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class I{text;at=0;constructor(k){this.text=k}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(k){this.space(),this.text[this.at]!==k&&C(`WKT expected "${k}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(k){return this.space(),this.text[this.at]===k?(this.at++,!0):!1}word(){this.space(),d.lastIndex=this.at;const k=d.exec(this.text);return k?(this.at+=k[0].length,k[0].toUpperCase()):""}numberNext(){return this.space(),S.lastIndex=this.at,S.test(this.text)}number(){this.space(),S.lastIndex=this.at;const k=S.exec(this.text);return k||C(`WKT expected a number at character ${this.at+1}`),this.at+=k[0].length,Number(k[0])}position(){const k=this.number(),O=this.number();for(;this.numberNext();)this.number();return[k,O]}positionList(){this.expect("(");const k=[this.position()];for(;this.accept(",");)k.push(this.position());return this.expect(")"),k}empty(){const k=this.at;return this.word()==="EMPTY"?!0:(this.at=k,!1)}geometry(k){k>V&&C("geometry collections nest too deeply");const O=this.word(),X=i[O];X||C(O?`"${O}" is not a WKT geometry type`:"WKT expected a geometry type");const ie=this.at,be=this.word();return be!=="Z"&&be!=="M"&&be!=="ZM"&&(this.at=ie),this.empty()?null:this.body(X,k)}body(k,O){switch(k){case"Point":{this.expect("(");const X=this.position();return this.expect(")"),{type:"Point",coordinates:X}}case"LineString":return{type:"LineString",coordinates:F(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const X=[];do this.empty()||(this.accept("(")?(X.push(this.position()),this.expect(")")):X.push(this.position()));while(this.accept(","));return this.expect(")"),X.length?{type:"MultiPoint",coordinates:X}:null}case"MultiLineString":{const X=this.parts(()=>F(this.positionList(),2,"a LineString"));return X.length?{type:"MultiLineString",coordinates:X}:null}case"MultiPolygon":{const X=this.parts(()=>this.polygonBody());return X.length?{type:"MultiPolygon",coordinates:X}:null}default:{this.expect("(");const X=[];do{const ie=this.geometry(O+1);ie&&X.push(ie)}while(this.accept(","));return this.expect(")"),X.length?{type:"GeometryCollection",geometries:X}:null}}}parts(k){this.expect("(");const O=[];do this.empty()||O.push(k());while(this.accept(","));return this.expect(")"),O}polygonBody(){return _(this.parts(()=>this.positionList()))}}function b(g){const k=new I(String(g).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),O=k.geometry(0);return k.space(),k.at<k.text.length&&C(`WKT has unexpected text after the geometry at character ${k.at+1}`),O}function H(g){return Object.is(g,-0)?"0":String(g)}function z(g){return`${H(g[0])} ${H(g[1])}`}function q(g){return`(${g.map(z).join(", ")})`}function U(g){return`(${g.map(q).join(", ")})`}function oe(g){const k=s(g);return k?ee(k):""}function ee(g){switch(g.type){case"Point":return`POINT (${z(g.coordinates)})`;case"LineString":return`LINESTRING ${q(g.coordinates)}`;case"Polygon":return`POLYGON ${U(g.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${g.coordinates.map(k=>`(${z(k)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${g.coordinates.map(q).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${g.coordinates.map(U).join(", ")})`;default:return`GEOMETRYCOLLECTION (${g.geometries.map(ee).join(", ")})`}}class Z{view;at=0;constructor(k){this.view=new DataView(k.buffer,k.byteOffset,k.byteLength)}need(k){this.at+k>this.view.byteLength&&C(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(k){this.need(4);const O=this.view.getUint32(this.at,k);return this.at+=4,O}f64(k){this.need(8);const O=this.view.getFloat64(this.at,k);return this.at+=8,O}count(k,O){const X=this.u32(k);return X*O>this.view.byteLength-this.at&&C(`WKB claims ${X} elements, more than its bytes can hold`),X}position(k,O){const X=this.f64(k),ie=this.f64(k);for(let be=2;be<O;be++)this.f64(k);return[X,ie]}positions(k,O){const X=this.count(k,8*O),ie=new Array(X);for(let be=0;be<X;be++)ie[be]=this.position(k,O);return ie}geometry(k,O){k>V&&C("geometry collections nest too deeply");const X=this.u8();X!==0&&X!==1&&C(`WKB byte-order mark is ${X}, not 0 or 1`);const ie=X===1,be=this.u32(ie);let ve=2;be&2147483648&&ve++,be&1073741824&&ve++,be&536870912&&this.u32(ie);let $e=be&268435455;if($e>=1e3){const je=Math.floor($e/1e3);je>3&&C(`WKB geometry type ${$e} is not one this reads`),ve=2+(je===3?2:1),$e%=1e3}const Te=ae[$e-1];switch(Te||C(`WKB geometry type ${$e} is not one this reads`),O&&Te!==O&&C(`a part of a WKB Multi${O} is a ${Te}`),Te){case"Point":{const je=this.position(ie,ve);return Number.isNaN(je[0])&&Number.isNaN(je[1])?null:{type:"Point",coordinates:L(je)}}case"LineString":return{type:"LineString",coordinates:F(this.positions(ie,ve),2,"a LineString")};case"Polygon":{const je=this.count(ie,4),Oe=[];for(let _e=0;_e<je;_e++)Oe.push(this.positions(ie,ve));return je?{type:"Polygon",coordinates:_(Oe)}:null}default:{const je=this.count(ie,5),Oe=Te==="GeometryCollection"?void 0:Te.slice(5),_e=[];for(let Ue=0;Ue<je;Ue++){const rt=this.geometry(k+1,Oe);rt&&_e.push(rt)}return _e.length?Te==="GeometryCollection"?{type:Te,geometries:_e}:{type:Te,coordinates:_e.map(Ue=>Ue.coordinates)}:null}}}}function de(g){const k=new Z(g),O=k.geometry(0);return k.at!==g.byteLength&&C(`WKB has ${g.byteLength-k.at} bytes left over after the geometry`),O}function E(g){const k=s(g);if(!k)return null;const O=[];let X=0;const ie=Oe=>{const _e=new DataView(new ArrayBuffer(5));_e.setUint8(0,1),_e.setUint32(1,ae.indexOf(Oe)+1,!0),O.push(_e),X+=5},be=Oe=>{const _e=new DataView(new ArrayBuffer(4));_e.setUint32(0,Oe,!0),O.push(_e),X+=4},ve=Oe=>{const _e=new DataView(new ArrayBuffer(16*Oe.length));Oe.forEach((Ue,rt)=>{_e.setFloat64(rt*16,Ue[0],!0),_e.setFloat64(rt*16+8,Ue[1],!0)}),O.push(_e),X+=16*Oe.length},$e=Oe=>{switch(ie(Oe.type),Oe.type){case"Point":ve([Oe.coordinates]);break;case"LineString":be(Oe.coordinates.length),ve(Oe.coordinates);break;case"Polygon":be(Oe.coordinates.length);for(const _e of Oe.coordinates)be(_e.length),ve(_e);break;case"GeometryCollection":be(Oe.geometries.length);for(const _e of Oe.geometries)$e(_e);break;default:{const _e=Oe.type.slice(5);be(Oe.coordinates.length);for(const Ue of Oe.coordinates)$e({type:_e,coordinates:Ue})}}};$e(k);const Te=new Uint8Array(X);let je=0;for(const Oe of O)Te.set(new Uint8Array(Oe.buffer),je),je+=Oe.byteLength;return Te}const D=/^0[01](?:[0-9a-fA-F]{2})+$/,t=/^[A-Za-z0-9+/_-]+={0,2}$/,f=(()=>{const g=new Int16Array(128).fill(-1),k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let O=0;O<k.length;O++)g[k.charCodeAt(O)]=O;return g[45]=62,g[95]=63,g})();function c(g){const k=new Uint8Array(g.length/2);for(let O=0;O<k.length;O++)k[O]=parseInt(g.slice(O*2,O*2+2),16);return k}function e(g){const k=g.replace(/=+$/,""),O=new Uint8Array(Math.floor(k.length*3/4));let X=0,ie=0,be=0;for(let ve=0;ve<k.length;ve++)ie=ie<<6|f[k.charCodeAt(ve)],X+=6,X>=8&&(X-=8,O[be++]=ie>>X&255);return O.subarray(0,be)}function v(g){const k=g.trim();if(k==="")return null;if(k[0]==="{"){let O;try{O=JSON.parse(k)}catch{return C("the text starts like GeoJSON but is not valid JSON")}return p(O,0)}if(D.test(k))return de(c(k));if(W.test(k))return b(k);if(t.test(k)){const O=e(k);if(O.length>=5&&(O[0]===0||O[0]===1))return de(O)}return C("the text is not WKT, GeoJSON, or hex or base64 WKB")}const $=new WeakSet;function M(g){if(re(g))return{geometry:null,reason:null};if(typeof g=="object"&&$.has(g))return{geometry:g,reason:null};try{let k;return typeof g=="string"?k=v(g):g instanceof Uint8Array?k=de(g):g instanceof ArrayBuffer?k=de(new Uint8Array(g)):ArrayBuffer.isView(g)?k=de(new Uint8Array(g.buffer,g.byteOffset,g.byteLength)):l(g)?k=p(g,0):C(`${Array.isArray(g)?"an array":`a ${typeof g}`} is not a geometry`),k&&y(k),{geometry:k||null,reason:null}}catch(k){if(k instanceof Y)return{geometry:null,reason:k.message};throw k}}function y(g){if($.add(g),g.type==="GeometryCollection")for(const k of g.geometries)y(k)}function s(g){return M(g).geometry}function a(g,k){switch(g.type){case"Point":k(g.coordinates);break;case"MultiPoint":case"LineString":g.coordinates.forEach(k);break;case"MultiLineString":case"Polygon":for(const O of g.coordinates)O.forEach(k);break;case"MultiPolygon":for(const O of g.coordinates)for(const X of O)X.forEach(k);break;default:for(const O of g.geometries)a(O,k)}}function A(g,k){const O=g[1]*pe,X=k[1]*pe,ie=X-O,be=(k[0]-g[0])*pe,ve=Math.sin(ie/2)**2+Math.cos(O)*Math.cos(X)*Math.sin(be/2)**2;return 2*te*Math.asin(Math.min(1,Math.sqrt(ve)))}function P(g){let k=0;for(let O=1;O<g.length;O++)k+=A(g[O-1],g[O]);return k}function T(g){const k=g.length-1;if(k<3)return 0;let O=0;for(let X=0;X<k;X++){const ie=g[(X-1+k)%k],be=g[(X+1)%k];O+=(be[0]-ie[0])*pe*Math.sin(g[X][1]*pe)}return Math.abs(O)*te*te/2}function n(g){let k=T(g[0]);for(let O=1;O<g.length;O++)k-=T(g[O]);return Math.max(0,k)}function h(g){let k=0,O=0,X=0;for(let ie=0;ie<g.length-1;ie++){const[be,ve]=g[ie],[$e,Te]=g[ie+1],je=be*Te-$e*ve;k+=je,O+=(be+$e)*je,X+=(ve+Te)*je}return{a:k,cx:O,cy:X}}function w(){let g=0,k=0,O=0;return{add(X,ie,be){g+=X*be,k+=ie*be,O+=be},get(){return O>0?[g/O,k/O]:null}}}function r(g){let k=0,O=0;for(const X of g)k+=X[0],O+=X[1];return[k/g.length,O/g.length]}function u(g,k){switch(g.type){case"Point":k[0].add(g.coordinates[0],g.coordinates[1],1);break;case"MultiPoint":for(const O of g.coordinates)k[0].add(O[0],O[1],1);break;case"LineString":case"MultiLineString":{const O=g.type==="LineString"?[g.coordinates]:g.coordinates;for(const X of O){for(let ie=1;ie<X.length;ie++){const[be,ve]=X[ie-1],[$e,Te]=X[ie],je=Math.hypot($e-be,Te-ve);k[1].add((be+$e)/2,(ve+Te)/2,je)}for(const ie of X)k[0].add(ie[0],ie[1],1)}break}case"Polygon":case"MultiPolygon":{const O=g.type==="Polygon"?[g.coordinates]:g.coordinates;for(const X of O){let ie=0,be=0,ve=0;X.forEach((Te,je)=>{const Oe=h(Te),_e=(je===0?1:-1)*(Oe.a<0?-1:1);ie+=_e*Oe.a,be+=_e*Oe.cx,ve+=_e*Oe.cy}),Math.abs(ie)>B&&k[2].add(be/(3*ie),ve/(3*ie),Math.abs(ie)/2);const $e=X[0].slice(0,-1);for(const Te of $e)k[0].add(Te[0],Te[1],1)}break}default:for(const O of g.geometries)u(O,k)}}const N=new WeakMap;function G(g){const k=s(g);if(!k)return null;const O=N.get(k);if(O)return O;const X=[1/0,1/0,-1/0,-1/0];a(k,Oe=>{Oe[0]<X[0]&&(X[0]=Oe[0]),Oe[1]<X[1]&&(X[1]=Oe[1]),Oe[0]>X[2]&&(X[2]=Oe[0]),Oe[1]>X[3]&&(X[3]=Oe[1])});const ie=[w(),w(),w()];u(k,ie);const be=ie[2].get()||ie[1].get()||ie[0].get()||r([[X[0],X[1]],[X[2],X[3]]]);let ve=0,$e=0;const Te=Oe=>{switch(Oe.type){case"LineString":ve+=P(Oe.coordinates);break;case"MultiLineString":for(const _e of Oe.coordinates)ve+=P(_e);break;case"Polygon":$e+=n(Oe.coordinates);for(const _e of Oe.coordinates)ve+=P(_e);break;case"MultiPolygon":for(const _e of Oe.coordinates){$e+=n(_e);for(const Ue of _e)ve+=P(Ue)}break;case"GeometryCollection":for(const _e of Oe.geometries)Te(_e);break;default:break}};Te(k);const je=Object.freeze({kind:k.type,bbox:Object.freeze(X),centroid:Object.freeze(be),length:ve,area:$e});return N.set(k,je),je}function j(g){const k=G(g);return k?k.kind:null}function R(g,k){const O=typeof g=="string"?g.split(/[\s,;]+/).filter(Boolean):g;if(!Array.isArray(O)||O.length!==k)return null;const X=O.map(ie=>typeof ie=="number"?ie:typeof ie=="string"?Number(ie):NaN);return X.every(Number.isFinite)?X:null}function J(g,k){if(g==="withinBbox"){const O=R(k,4);return O?O[0]>O[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:O[1]>O[3]?{reason:"the box's minLat is above its maxLat"}:{operand:O}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if(g==="withinDistance"){let O=null;if(l(k)&&!Array.isArray(k)){const X=k;O=R([X.lon,X.lat,X.metres],3)}else O=R(k,3);return!O||O[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:O[0],lat:O[1],metres:O[2]}}}if(g==="withinPolygon"||g==="intersects"){const O=g==="intersects"?R(k,4):null;if(O){if(O[0]>O[2]||O[1]>O[3])return{reason:"the box's minimum is above its maximum"};const[be,ve,$e,Te]=O;return{operand:{type:"Polygon",coordinates:[[[be,ve],[$e,ve],[$e,Te],[be,Te],[be,ve]]]}}}const{geometry:X,reason:ie}=M(k);return X?g==="withinPolygon"&&X.type!=="Polygon"&&X.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${X.type}`}:{operand:X}:{reason:`${g} needs a geometry: ${ie||"none was given"}`}}return{reason:`"${g}" is not a spatial operator`}}function ne(g,k){const[O,X]=g;let ie=!1;for(let be=0,ve=k.length-2;be<k.length-1;ve=be++){const[$e,Te]=k[be],[je,Oe]=k[ve];Te>X!=Oe>X&&O<(je-$e)*(X-Te)/(Oe-Te)+$e&&(ie=!ie)}return ie}function ce(g,k){if(!ne(g,k[0]))return!1;for(let O=1;O<k.length;O++)if(ne(g,k[O]))return!1;return!0}function Me(g,k={points:[],segments:[],polygons:[]}){const O=X=>{for(let ie=1;ie<X.length;ie++)k.segments.push([X[ie-1],X[ie]]);for(const ie of X)k.points.push(ie)};switch(g.type){case"Point":k.points.push(g.coordinates);break;case"MultiPoint":for(const X of g.coordinates)k.points.push(X);break;case"LineString":O(g.coordinates);break;case"MultiLineString":g.coordinates.forEach(O);break;case"Polygon":k.polygons.push(g.coordinates),g.coordinates.forEach(O);break;case"MultiPolygon":for(const X of g.coordinates)k.polygons.push(X),X.forEach(O);break;default:for(const X of g.geometries)Me(X,k)}return k}function Le(g,k,O){const X=(k[0]-g[0])*(O[1]-g[1])-(k[1]-g[1])*(O[0]-g[0]);return Math.abs(X)<=B?0:Math.sign(X)}function Ne(g,k,O){return g[0]>=Math.min(k[0],O[0])-B&&g[0]<=Math.max(k[0],O[0])+B&&g[1]>=Math.min(k[1],O[1])-B&&g[1]<=Math.max(k[1],O[1])+B}function Re(g,k){const[O,X]=g,[ie,be]=k,ve=Le(O,X,ie),$e=Le(O,X,be),Te=Le(ie,be,O),je=Le(ie,be,X);return ve!==$e&&Te!==je?!0:ve===0&&Ne(ie,O,X)||$e===0&&Ne(be,O,X)||Te===0&&Ne(O,ie,be)||je===0&&Ne(X,ie,be)}function Ie(g,k){return g[0]<=k[2]&&k[0]<=g[2]&&g[1]<=k[3]&&k[1]<=g[3]}function Ce(g,k){const O=G(g),X=G(k);if(!Ie(O.bbox,X.bbox))return!1;const ie=Me(g),be=Me(k);for(const ve of be.polygons)for(const $e of ie.points)if(ce($e,ve))return!0;for(const ve of ie.polygons)for(const $e of be.points)if(ce($e,ve))return!0;for(const ve of ie.segments)for(const $e of be.segments)if(Re(ve,$e))return!0;for(const ve of ie.points){for(const $e of be.points)if(Math.abs(ve[0]-$e[0])<=B&&Math.abs(ve[1]-$e[1])<=B)return!0;for(const $e of be.segments)if(Le($e[0],$e[1],ve)===0&&Ne(ve,$e[0],$e[1]))return!0}for(const ve of be.points)for(const $e of ie.segments)if(Le($e[0],$e[1],ve)===0&&Ne(ve,$e[0],$e[1]))return!0;return!1}function we(g,k){const{operand:O,reason:X}=J(g,k);if(X)return ge(`filter:geometry:${g}`,`a "${g}" condition was refused: ${X}. It matches no row rather than guessing.`),()=>!1;switch(g){case"withinBbox":return ie=>{const be=G(ie);if(!be)return!1;const ve=be.bbox;return ve[0]>=O[0]&&ve[1]>=O[1]&&ve[2]<=O[2]&&ve[3]<=O[3]};case"withinPolygon":{const ie=O.type==="Polygon"?[O.coordinates]:O.coordinates,be=ve=>ie.some($e=>ce(ve,$e));return ve=>{const $e=s(ve);return $e?$e.type==="Point"?be($e.coordinates):$e.type==="MultiPoint"?$e.coordinates.every(be):be(G($e).centroid):!1}}case"intersects":return ie=>{const be=s(ie);return!!be&&Ce(be,O)};default:{const ie=[O.lon,O.lat];return be=>{const ve=G(be);return!!ve&&A(ve.centroid,ie)<=O.metres}}}}}),Ge("packages/core/src/source/filterwire.js",function(o,ue){"use strict";Object.defineProperty(o,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"warnWherePageRelative",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"warnWhereNotApplied",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"warnWhereOverThreshold",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"resolveRelativeRange",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"relativeTokenOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"relativeTokenHelp",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"isResolvableRelative",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"resolveRelativeCondition",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"isGroup",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"forEachCondition",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"mapConditions",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"normaliseFilterSet",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"buildFilterSet",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"wireFilters",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"querySignature",{enumerable:!0,get:function(){return de}});const re=ue("packages/core/src/internal/util.js").warnOnce,l="source.remote.hostFilter",ge="source.where.pageRelative";function ae(t,f){!Array.isArray(t)||!t.length||re(ge,`filters.where (${t.join(", ")}) runs over the rows the ${f} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function ke(t){const f=(t||{}).config;!f||!f.hostFilter||re(l,"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 K="source.where.notApplied";function te(t,f){re(`${K}:${t}`,`filters.where("${t}") is registered but the ${f} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const pe="source.where.overThreshold";function V(t,f,c,e){!Array.isArray(t)||!t.length||re(`${pe}:${f}`,`filters.where (${t.join(", ")}) is not applied to the ${f} 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 ${e.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 B=new Map;function Y(t){let f=B.get(t);return f||(f=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),B.set(t,f)),f}function C(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function L(t,f){const c=Y(f).formatToParts(new Date(t)),e={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const v of c)v.type==="year"?e.y=+v.value:v.type==="month"?e.m=+v.value:v.type==="day"?e.d=+v.value:v.type==="hour"?e.h=+v.value%24:v.type==="minute"?e.mi=+v.value:v.type==="second"&&(e.s=+v.value);return e}function F(t,f){const c=L(t,f);return Date.UTC(c.y,c.m-1,c.d,c.h,c.mi,c.s)-Math.floor(t/1e3)*1e3}function x(t,f,c,e){const v=Date.UTC(t,f-1,c),$=v-F(v,e);return v-F($,e)}function _(t,f,c){const e=new Date(Date.UTC(t.y,t.m-1,t.d+f));return x(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),c)}const p=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(t,f){if(typeof t!="string")return null;const c=t.trim().toLowerCase().replace(/[\s_-]+/g,""),e=/^last(\d*|n)days?$/.exec(c);if(e){const v=e[1]==="n"?"":e[1],$=Number(v||f);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 S(t,f={}){const c=i(t,f.n);if(!c)return null;const e=f.tz||C(),v=f.now instanceof Date?f.now.getTime():typeof f.now=="number"?f.now:Date.now(),$=L(v,e),M=x($.y,$.m,$.d,e),y=_($,1,e);let s=M,a=y;switch(c.kind){case"today":break;case"yesterday":s=_($,-1,e),a=M;break;case"lastNDays":a=f.includeToday?y:M,s=_($,f.includeToday?-(c.n-1):-c.n,e);break;case"thisWeek":{const A=Number.isFinite(f.weekStartsOn)?Number(f.weekStartsOn):1,T=(new Date(Date.UTC($.y,$.m-1,$.d)).getUTCDay()-A+7)%7;s=_($,-T,e),a=_($,-T+7,e);break}case"thisMonth":s=x($.y,$.m,1,e),a=x($.m===12?$.y+1:$.y,$.m===12?1:$.m+1,1,e);break;case"thisQuarter":case"quarterToDate":{const A=Math.floor(($.m-1)/3)*3+1;s=x($.y,A,1,e),a=c.kind==="quarterToDate"?y:A===10?x($.y+1,1,1,e):x($.y,A+3,1,e);break}case"thisYear":case"yearToDate":s=x($.y,1,1,e),a=c.kind==="yearToDate"?y:x($.y+1,1,1,e);break;default:return null}return{from:new Date(s).toISOString(),to:new Date(a).toISOString(),bounds:"[)",tz:e,relative:c.kind==="lastNDays"?`last${c.n}Days`:c.kind,n:c.n}}function d(t){if(!t||typeof t!="object")return null;const f=t.value;if(f&&typeof f=="object"&&!Array.isArray(f)&&"relative"in f)return{token:String(f.relative),n:typeof f.n=="number"?f.n:void 0};if(t.op==="relative"&&typeof t.value=="string")return{token:t.value,n:void 0};const c=t.meta;return c&&typeof c.relative=="string"&&t.value===void 0?{token:c.relative,n:typeof c.n=="number"?c.n:void 0}:null}function W(){return`Known tokens: ${p.filter(f=>f!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function I(t){const f=d(t);return f?i(f.token,f.n)!==null:!1}function b(t,f={}){const c=d(t);if(!c)return t;const e=S(c.token,{...f,n:c.n});return e?{...t,type:t.type||"date",op:"between",value:[e.from,e.to],bounds:t.bounds||e.bounds,meta:{...t.meta||{},relative:e.relative,tz:e.tz}}:(re(`source.relative.${c.token}`,`unknown relative date token "${c.token}"; sending the condition unresolved.`,W()),t)}function H(t){return!!t&&typeof t=="object"&&Array.isArray(t.conditions)}function z(t,f){if(t){if(H(t)){for(const c of t.conditions)z(c,f);return}f(t)}}function q(t,f){if(!t)return null;if(!H(t))return f(t);const c=t;let e=!1;const v=[];for(const $ of c.conditions){const M=q($,f);M!==$&&(e=!0),M&&v.push(M)}return!e&&v.length===c.conditions.length?t:v.length?{...c,conditions:v}:null}function U(t){if(!t)return null;if(!H(t))return t;const f=t,c=[];for(const e of f.conditions){const v=U(e);v&&c.push(v)}return c.length?{op:f.op,conditions:c}:null}function oe(t){const f=U(t);return f?H(f)&&f.op==="and"?f:{op:"and",conditions:[f]}:null}function ee(t){const f=(t||[]).filter(Boolean);return f.length?{op:"and",conditions:f}:null}function Z(t,f={}){const c=q(t,e=>b(e,f));return oe(c)}function de(t){const f=E(t.filters??null);return JSON.stringify([f,t.sort??null,t.quick??"",t.groupBy??null,t.pivotBy??null,D(t.context)])}function E(t){if(!t)return null;if(H(t)){const e=t;return{op:e.op,conditions:e.conditions.map(E)}}const f=t,c=f.meta&&typeof f.meta.relative=="string"?f.meta.relative:d(f)?.token;return{col:f.col,op:f.op,bounds:f.bounds??null,caseSensitive:f.caseSensitive??!1,value:c?`rel:${c}`:f.value??null}}function D(t){if(t==null)return null;try{return JSON.parse(JSON.stringify(t))}catch{return re("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ge("packages/core/src/source/aggregates.js",function(o,ue){"use strict";Object.defineProperty(o,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"pushableAggregates",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"fillAggregateSql",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"resolveAggregatesConfig",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"routeAggregate",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"resolveAggregatePlan",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"groupKeysPushable",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pushdownDocRows",{enumerable:!0,get:function(){return pe}});const xe=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 re(){const V=new Set;for(const[B,Y]of Object.entries(xe))Y.pushable&&V.add(B);return V}function l(V,B,Y){let C=V.split("%c").join(B);return Y!==void 0&&(C=C.split("%w").join(Y)),C}function ge(V){const B=V||{},Y=B.default==="engine"||B.default==="engine-if-identical"?B.default:"client",C={};if(B.overrides&&typeof B.overrides=="object")for(const[L,F]of Object.entries(B.overrides))(F==="engine"||F==="client")&&(C[L]=F);return{default:Y,overrides:C}}function ae(V,B){const Y=xe[V];if(!Y||!Y.pushable)return"client";const C=B.overrides[V];return C==="engine"||C==="client"?C:B.default==="client"?"client":B.default==="engine-if-identical"?Y.class==="identical"?"engine":"client":"engine"}function ke(V,B){const Y=ge(B),C=[],L=[];for(const F of V||[]){const x=xe[F.fn],_=ae(F.fn,Y),p={id:F.id,col:F.col,fn:F.fn,class:x?x.class:"fallback"};F.weight!==void 0&&(p.weight=F.weight),F.params!==void 0&&(p.params=F.params),_==="engine"?C.push(p):(p.reason=x&&!x.pushable?x.note||"the engine cannot express this stat":"client by config",L.push(p))}return{engine:C,client:L,config:Y}}const K=/^[A-Za-z_][A-Za-z0-9_$]*$/;function te(V,B=[]){return(V||[]).every(C=>{if(typeof C=="string")return K.test(C);if(!C||typeof C!="object")return!1;const L=C;return Array.isArray(B)&&B.includes(L.bucket)&&typeof L.col=="string"&&K.test(L.col)&&typeof L.size=="number"&&Number.isFinite(L.size)&&L.size>0})}function pe(){return Object.entries(xe).map(([V,B])=>({stat:V,class:B.class,sql:B.sql?l(B.sql,"col",B.twoColumn?"weight":void 0):"",note:B.note||(B.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ge("packages/core/src/source/abort.js",function(o,ue){"use strict";Object.defineProperty(o,"SupersededError",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"RequestToken",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"AbortScope",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"createAbortScope",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"isAbortError",{enumerable:!0,get:function(){return ae}});class xe extends Error{constructor(K,te="superseded"){super(`[lattice] request ${K?`"${K}" `:""}${te}`),this.name="SupersededError",this.superseded=!0,this.key=K}}class re{#e;constructor(K,te,pe,V){this.#e=K,this.key=te,this.controller=pe,this.signal=pe.signal,this.seq=V}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(K){this.signal.aborted||this.controller.abort(new xe(this.key,K)),this.#e.settle(this)}}class l{#e=new Map;#t=0;begin(K="",te="superseded"){const pe=this.#e.get(K);pe&&!pe.signal.aborted&&pe.controller.abort(new xe(K,te));const V=new re(this,K,new AbortController,++this.#t);return this.#e.set(K,V),V}tokenFor(K){return this.#e.get(K)}pending(K=""){const te=this.#e.get(K);return!!te&&!te.signal.aborted}get size(){return this.#e.size}settle(K){this.#e.get(K.key)===K&&this.#e.delete(K.key)}abort(K="",te="superseded"){const pe=this.#e.get(K);pe&&pe.abort(te)}abortAll(K="superseded"){for(const te of[...this.#e.values()])te.abort(K);this.#e.clear()}}function ge(){return new l}function ae(ke){if(!ke||typeof ke!="object")return!1;const K=ke;return K.superseded===!0||K.name==="AbortError"||K.name==="SupersededError"}}),Ge("packages/core/src/source/pushdown.js",function(o,ue){"use strict";Object.defineProperty(o,"NO_CAPABILITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"resolveMutate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"capabilitiesOf",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"splitFilters",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"planQuery",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"applyResidual",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"createPushdownSource",{enumerable:!0,get:function(){return D}});const xe=ue("packages/core/src/internal/util.js"),re=xe.isFunction,l=xe.warnOnce,ge=ue("packages/core/src/source/filterwire.js"),ae=ge.isGroup,ke=ge.warnWherePageRelative,K=ge.warnWhereOverThreshold,te=ue("packages/core/src/source/aggregates.js"),pe=te.resolveAggregatePlan,V=te.groupKeysPushable,B=te.STAT_PUSHDOWN,C=ue("packages/core/src/source/abort.js").SupersededError;function L(t){const f=t&&t.signal;if(!f||!f.aborted)return;const c=f.reason;throw c instanceof Error?c:new C("","superseded before it was sent")}const F=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,mutate:!1});function x(t){if(!t||typeof t!="object")return!1;const f=t.returning==="row"||t.returning==="key"?t.returning:"none";return{append:t.append===!0,update:t.update===!0,delete:t.delete===!0,returning:f}}function _(t,f){if(!t||typeof f!="string")return;if(!f.includes("."))return t[f];let c=t;for(const e of f.split(".")){if(c===null||typeof c!="object")return;c=c[e]}return c}function p(t){if(t===!0)return!0;if(!t||typeof t!="object")return!1;const f=t;return f.enabled===!1?!1:f.enabled===!0||re(f.commit)}function i(t){const f={...F,...t||{}};return f.operators=new Set(f.operators||[]),f.mutate=x(f.mutate),f}function S(t,f){return!t||!t.op||!f.operators.size?!1:f.operators.has(t.op)}function d(t,f){if(!t)return{pushed:null,residual:null};if(!f.filter)return{pushed:null,residual:t};if(f.filter==="term"){if(ae(t)){const $=t.conditions||[];if(String(t.op)!=="and")return{pushed:null,residual:t};const M=$.findIndex(s=>!ae(s)&&S(s,f));if(M<0)return{pushed:null,residual:t};const y=$.filter((s,a)=>a!==M);return{pushed:$[M],residual:y.length?{op:"and",conditions:y}:null}}return S(t,f)?{pushed:t,residual:null}:{pushed:null,residual:t}}if(!ae(t))return S(t,f)?{pushed:t,residual:null}:{pushed:null,residual:t};if(String(t.op)!=="and")return(t.conditions||[]).every(M=>ae(M)?d(M,f).residual===null:S(M,f))?{pushed:t,residual:null}:{pushed:null,residual:t};const c=[],e=[];for(const $ of t.conditions||[]){if(ae($)){if(f.filter==="flat"){e.push($);continue}const M=d($,f);M.pushed&&c.push(M.pushed),M.residual&&e.push(M.residual);continue}(S($,f)?c:e).push($)}const v=$=>$.length===0?null:$.length===1?$[0]:{op:"and",conditions:$};return{pushed:v(c),residual:v(e)}}function W(t,f,c,e,v,$,M){const y=Array.isArray(t.groupBy)?t.groupBy:[],s=Array.isArray(t.groupPath)?t.groupPath:[],a=Array.isArray(t.groupValues)?t.groupValues:null;return f.group?V(y)?c.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":e?v?$?"a host `where` predicate can only run in the browser, over rows the engine grouped":M?"fullDataset holds the whole matching set, so the grid groups it itself":!a||a.length!==s.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":"the adapter does not declare the `group` capability"}function I(t,f,c=!1){const e=d(t.filters||null,f),v=[];e.residual&&v.push("filter");const $=t.sort||[],M=$.length===0||f.sort==="multi"&&$.length>=1||f.sort==="single"&&$.length===1;!M&&$.length&&v.push("sort");const y=t.quick?String(t.quick):"",s=!y||!!f.quick;s||v.push("quick");const a=t.where&&t.where.active?t.where:null;a&&v.push("where");const A={filters:e.residual,sort:M?null:$,quick:s?"":y,where:a},P=!!c,T=Array.isArray(t.groupBy)&&t.groupBy.length>0,n=T?W(t,f,e,M,s,a,P):"",h=T&&n==="";T&&!h&&v.push("group");const w=h&&Array.isArray(t.groupValues)?t.groupValues.length:0,r=h?!1:P||!!(A.filters||A.sort||A.quick||A.where)||!f.range;return{pushed:{...t,filters:e.pushed,sort:M?$:[],quick:s?y:"",range:r?null:t.range},residual:A,needsAll:r,unpushed:v,full:P,grouped:h,groupLevel:w,groupReason:n}}function b(t){const f=Array.isArray(t.totals)?t.totals:[],c=t.totalFns&&typeof t.totalFns=="object"?t.totalFns:{},e=[],v=[];for(const $ of f){const M=String($),y=typeof c[M]=="string"?c[M]:null,s=y?B[y]:null;y?!s||!s.pushable||!s.sql?v.push({id:M,fn:y,class:s?s.class:"fallback",reason:s&&s.note?s.note:`the pushdown map cannot express "${y}"`}):s.twoColumn?v.push({id:M,fn:y,class:s.class,reason:`"${y}" reduces two columns, and a grouped request carries no weight column`}):e.push({id:M,col:M,fn:y,class:s.class}):v.push({id:M,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:e,client:v}}const H=Object.freeze({items:t=>t==null?[]:Array.isArray(t)?t:[t]});function z(t,f,c){if(!f)return t;let e=t;if(f.filters&&re(c.evaluateFilters)){const v=e,$={count:e.length,handle:s=>({id:s,get:a=>_(v[a],s)}),itemwise:s=>v.some(a=>Array.isArray(_(a,s)))?H:null},M=c.evaluateFilters(f.filters,$),y=[];for(let s=0;s<e.length;s++)M[s]&&y.push(e[s]);e=y}if(f.where&&f.where.active&&(f.whole||ke(f.where.names,"pushdown"),e=e.filter(v=>f.where.passes(v))),f.quick){const v=f.quick.toLowerCase();e=e.filter($=>{if(!$||typeof $!="object")return!1;for(const M of Object.values($))if(M!=null&&String(M).toLowerCase().includes(v))return!0;return!1})}if(f.sort&&f.sort.length&&re(c.sortMulti)){const v=[...new Set(f.sort.map(s=>s.col))],$=e,M=v.map(s=>({id:s,get:a=>_($[a],s)})),y=c.sortMulti(M,f.sort.map(s=>({col:s.col,dir:s.dir})),Uint32Array.from({length:e.length},(s,a)=>a),{});e=Array.from(y,s=>$[s])}return e}function q(t){return JSON.stringify({filters:t.filters||null,sort:t.sort||[],quick:t.quick||"",groupBy:t.groupBy||[],groupPath:t.groupPath||[],context:t.context??null})}function U(t){if(!t||typeof t!="object")return 16;let f="";try{f=JSON.stringify(t)}catch{return 200}return f.length*2+64}function oe(t){const f=t||{};return{enabled:!!f.enabled,maxRows:Number.isFinite(f.maxRows)?f.maxRows:1e6,maxBytesEstimate:Number.isFinite(f.maxBytesEstimate)?f.maxBytesEstimate:512*1024*1024}}const ee=5e4;function Z(t){return Number.isFinite(t)&&t>=0?t:ee}function de(t){return!!t&&re(t.then)}async function E(t){if(!t||t.total!==void 0||!de(t.pendingTotal))return t;const f=await t.pendingTotal,{pendingTotal:c,...e}=t;return typeof f=="number"?{...e,total:f}:e}function D(t={}){const f=t.adapter;if(!f||!re(f.execute))return l("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...t,mode:"remote",fetch:async()=>({rows:[],total:0})};const c=i(f.capabilities),e=f.capabilities&&Object.getOwnPropertyDescriptor(f.capabilities,"operators");e&&re(e.get)&&Object.defineProperty(c,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(f.capabilities.operators||[]),set:()=>{}});const v=f.name||"adapter";let $=null;const M=()=>re(f.ready)?($||($=Promise.resolve(f.ready()).then(()=>{Object.assign(c,i(f.capabilities))},we=>{throw $=null,we})),$):null,y=oe(t.fullDataset),s=!!t.allowPartialResults,a=Z(t.whereRowLimit);let A=null;const P=t.aggregates;let T=null,n=null,h=null,w=null,r=null,u,N=null,G=0,j=null;const R=()=>!y.enabled||!T?null:(j!==T.key&&(G++,j=T.key),{rows:T.rows,version:G}),J=async we=>{const g=we.where&&we.where.active?we.where:null;if(!g)return{request:we,probe:null};const{where:k,...O}=we,X=I(O,c,y.enabled);if(X.needsAll)return{request:we,probe:null};const ie=q(X.pushed);let be=null;return(!A||A.key!==ie)&&(c.total?(L(we),be=await E(await f.execute(X.pushed,we)),A={key:ie,size:be&&typeof be.total=="number"?be.total:null}):A={key:ie,size:null}),A.size!==null&&A.size<a?{request:we,probe:null}:(K(g.names,v,A.size,a),{request:O,probe:be})},ne=async(we,g)=>{N=null;const k=b(we.pushed);h={engine:k.engine,client:k.client,groupBy:we.pushed.groupBy},k.client.length&&l(`source.pushdown.group.totals.${v}.${k.client.map(ie=>ie.id).join(".")}`,`the ${v} adapter cannot compute the group subtotal for ${k.client.map(ie=>`"${ie.id}" (${ie.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 O=await f.executeGroupLevel(we.pushed,k.engine,g)||{};let X=O.rows||[];return!c.range&&g.range&&(X=X.slice(g.range.start,g.range.end)),typeof O.matchCount=="number"&&(w=O.matchCount,r=O.grand?{totals:O.grand,leafCount:O.matchCount}:null,u===void 0&&re(f.unfilteredCount)&&(u=null,Promise.resolve(f.unfilteredCount()).then(ie=>{u=typeof ie=="number"?ie:null}).catch(ie=>{l(`source.pushdown.group.unfiltered.${v}`,`the ${v} adapter could not count the unfiltered set (${ie&&ie.message?ie.message:ie}), so "N of M" falls back to the display count for its denominator.`)}))),O.total===void 0?{rows:X}:{rows:X,total:O.total}},ce=(we,g)=>{const k={key:g,state:"pending",value:null};return N=k,we.then(O=>(N===k&&(N={key:g,state:"settled",value:typeof O=="number"?O:null}),O),O=>{throw N===k&&(N={key:g,state:"failed",value:null}),O})},Me=async we=>{const g=M();g&&await g;const k=await J(we);L(we);let O=I(k.request,c,y.enabled);if(O.grouped&&!re(f.executeGroupLevel)&&(l(`source.pushdown.group.method.${v}`,`the ${v} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid is left to group whatever rows it holds. Implement the method or drop the capability.`),O=I(k.request,{...c,group:!1},y.enabled)),n=O,O.grouped)return ne(O,we);if(O.groupReason&&l(`source.pushdown.group.${v}.${O.groupReason}`,`the ${v} adapter was not asked to group this query because ${O.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.`),!O.needsAll){const je=k.probe||await f.execute(O.pushed,we),Oe=je.rows||[];return de(je.pendingTotal)&&je.total===void 0?{rows:Oe,pendingTotal:ce(je.pendingTotal,q(O.pushed))}:(N=null,!c.total&&je.total===void 0?{rows:Oe}:{rows:Oe,total:je.total??Oe.length})}O.unpushed.length&&l(`source.pushdown.residual.${v}.${O.unpushed.join(".")}`,`the ${v} adapter cannot push ${O.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 X=q(O.pushed);if(!T||T.key!==X){const je=await E(await f.execute(O.pushed,we));N=null;const Oe=je.rows||[];if(O.full){const _e=typeof je.total=="number"?Math.max(je.total,Oe.length):Oe.length;if(_e>y.maxRows)throw new Error(`[lattice] fullDataset refused: the ${v} adapter's matching set is ${_e.toLocaleString()} rows, past the configured maxRows of ${y.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 Ue=Oe.length*U(Oe[0]);if(Ue>y.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${v} adapter's matching set is an estimated ${Math.round(Ue/(1024*1024)).toLocaleString()} MB across ${Oe.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(y.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 je.total=="number"&&Oe.length<je.total){const _e=!!(O.residual.filters||O.residual.quick||O.residual.sort&&O.residual.sort.length);if(_e&&!s)throw new Error(`[lattice] the ${v} adapter returned ${Oe.length} of ${je.total} matching rows when asked for the whole result, and the query has residual ${O.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.`);_e?l(`source.pushdown.partial.residual.${v}`,`the ${v} adapter returned ${Oe.length} of ${je.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.`):l(`source.pushdown.partial.${v}`,`the ${v} adapter returned ${Oe.length} of ${je.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}T={key:X,rows:Oe,total:typeof je.total=="number"?je.total:null}}let ie=O;if(O.residual.where){const je=T.total??T.rows.length;if(je>=a){K(O.residual.where.names,v,je,a);const{where:Oe,..._e}=k.request;ie=I(_e,c,y.enabled),n=ie}}const be=T.total!==null&&T.rows.length>=T.total,ve=z(T.rows,{...ie.residual,whole:be},t.compute||{}),$e=we.range?we.range.start:0,Te=we.range?we.range.end:ve.length;return{rows:ve.slice($e,Te),total:ve.length}},Le=async(we,g)=>{const k=M();k&&await k;const O=I(we,c,y.enabled);n=O;const X=pe(g,P),ie=Array.isArray(we.groupBy)?we.groupBy:[],be=ie.length>0,ve=!O.residual.filters&&!O.residual.quick,$e=!be||V(ie,c.buckets);let Te=X.engine,je=X.client;const Oe=rt=>{je=[...Te.map(ct=>({...ct,reason:rt})),...je],Te=[]};Te.length&&!ve?Oe(O.residual.quick&&!O.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Te.length&&!$e&&Oe("a grouping key the engine cannot form forces all-client (no mixed provenance)");let _e={},Ue;return Te.length&&(re(be?f.executeGroupedAggregates:f.executeAggregates)?be?Ue=await f.executeGroupedAggregates(O.pushed,ie,Te)||[]:_e=await f.executeAggregates(O.pushed,Te)||{}:(l(`source.pushdown.aggregates.${v}${be?".grouped":""}`,`the ${v} adapter cannot compute ${be?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Oe(`adapter cannot compute ${be?"grouped ":""}aggregates`))),h={engine:Te,client:je,...be?{groupBy:ie}:{}},{values:_e,engine:Te,client:je,...Ue!==void 0?{groups:Ue}:{}}},Ne=p(t.edit),Re=t.edit&&typeof t.edit=="object"&&re(t.edit.commit);let Ie=t.edit;if(Ne&&!Re)if(c.mutate&&c.mutate.update){const we=g=>{if(!c.mutate||!c.mutate.update)throw new Error(`[lattice] the ${v} 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 k={kind:"update",key:String(g.key),patch:{[g.colId]:g.value}};return f.mutate(k,g.request||{})};Ie={...t.edit===!0?{}:t.edit,commit:we}}else l(`source.pushdown.readonly.${v}`,`edit is enabled but the ${v} adapter declares mutate: ${c.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 Ce=Ne&&c.mutate&&(c.mutate.append||c.mutate.delete)?{append:c.mutate.append===!0,remove:c.mutate.delete===!0,returning:c.mutate.returning,mutate:(we,g)=>f.mutate(we,g||{})}:null;return{...t,edit:Ie,rowMutate:Ce,mode:"remote",fetch:Me,aggregate:Le,lastPlan:()=>n?{...n,...h?{aggregates:h}:{},...N?{total:{deferred:!0,state:N.state,value:N.value}}:{}}:null,fullFrame:R,counts:()=>({match:w,total:u??null,pending:!!N&&N.state==="pending"}),grandTotals:()=>r}}}),Ge("packages/modules/shared/engine.js",function(o,ue){"use strict";Object.defineProperty(o,"sourceId",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"engineSource",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"loadedAndMatching",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"gridHoldsWindow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"gridEngineRequest",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"EngineFlight",{enumerable:!0,get:function(){return L}});const xe=ue("packages/core/src/source/pushdown.js"),re=xe.capabilitiesOf,l=xe.planQuery,ae=ue("packages/core/src/source/filterwire.js").wireFilters,ke=new WeakMap;let K=0;function te(F){let x=ke.get(F);return x===void 0&&(x=++K,ke.set(F,x)),x}function pe(F){const x=F&&typeof F.config=="function"?F.config():null,_=x&&x.source&&typeof x.source=="object"?x.source:null;if(!_||typeof _.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const p=re(_.adapter&&_.adapter.capabilities);return{source:_,caps:p,config:x}}function V(F){let x=0;F.rows.forEach(p=>{p&&!p.group&&p.data!==null&&p.data!==void 0&&x++});const _=typeof F.rows.matchCount=="function"?F.rows.matchCount():NaN;return{loaded:x,total:Number.isFinite(_)?_:NaN}}function B(F){const x=F&&typeof F.config=="function"?F.config():null,_=x&&x.source&&typeof x.source=="object"?x.source:null;if(!_||_.mode!=="remote"&&_.mode!=="paged")return!1;const{loaded:p,total:i}=V(F);return Number.isFinite(i)&&p<i}function Y(F,x){return x?F?{op:"and",conditions:[F,x]}:x:F||null}function C(F,x,_=null){const p=F.filters&&typeof F.filters.where=="function"?F.filters.where():[];if(Array.isArray(p)&&p.length)return{reason:`a \`where\` predicate is in force (${p.join(", ")}), which only the browser can run`};const i=F.filters&&typeof F.filters.quickState=="function"?F.filters.quickState():{text:""},S=i&&i.text?String(i.text):"",{config:d,caps:W}=x,I={filters:ae(Y(F.filters.get(),_),{tz:d.timeZone,weekStartsOn:d.weekStartsOn}),sort:[],range:null,context:d.context??null,...S?{quick:S}:{}},b=l(I,W);return b.unpushed.includes("filter")?{reason:_?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:b.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:I,quick:S}}class L{#e=null;#t=null;#n=!1;answer(x){return this.#t&&this.#t.key===x?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(x,_,p){const i=this.#e;if(i){i.key!==x&&i.controller&&i.controller.abort();return}const S=globalThis.AbortController,d=typeof S=="function"?new S:null,W={key:x,controller:d};this.#e=W;let I;Promise.resolve().then(()=>_(d?d.signal:null)).then(b=>{I={key:x,result:b}},b=>{I={key:x,error:b}}).then(()=>{this.#e===W&&(this.#e=null),!this.#n&&(d&&d.signal.aborted||(this.#t=I),p())})}abort(){const x=this.#e;x&&x.controller&&x.controller.abort()}close(){this.#n=!0,this.abort()}}}),Ge("packages/modules/charts/scale.js",function(o,ue){"use strict";Object.defineProperty(o,"isNumber",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumber",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"toTime",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extent",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"niceStep",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"niceDomain",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"measureDomain",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"linearTicks",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"timeStepFor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"timeTicks",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"linearScale",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"timeScale",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"key",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"bandScale",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"sqrtScale",{enumerable:!0,get:function(){return I}});const xe=[1,2,2.5,5,10],re=6e4,l=36e5,ge=864e5,ae=365.25*ge,ke=[1,2,5,10,20,25,50,100],K=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,re,5*re,15*re,30*re,l,3*l,6*l,12*l,ge,2*ge,7*ge,14*ge,30*ge,90*ge,180*ge,...ke.map(b=>b*ae)];function te(b){return typeof b=="number"&&Number.isFinite(b)}function pe(b){if(b==null||b==="")return null;if(b instanceof Date){const z=b.getTime();return Number.isFinite(z)?z:null}if(typeof b=="boolean")return b?1:0;const H=Number(b);return Number.isFinite(H)?H:null}function V(b){if(b==null||b==="")return null;if(b instanceof Date){const z=b.getTime();return Number.isFinite(z)?z:null}if(typeof b=="number")return Number.isFinite(b)?b:null;const H=Date.parse(String(b));return Number.isFinite(H)?H:null}function B(b){let H=1/0,z=-1/0;for(let q=0;q<b.length;q++){const U=b[q];te(U)&&(U<H&&(H=U),U>z&&(z=U))}return H===1/0?null:{min:H,max:z}}function Y(b){if(!(b>0))return 1;const H=10**Math.floor(Math.log10(b));for(const z of xe)if(b<=z*H)return z*H;return 10*H}function C(b,H=5){const z=Y((b.max-b.min)/Math.max(1,H));return{min:Math.floor(b.min/z)*z,max:Math.ceil(b.max/z)*z,step:z}}function L(b,H={}){const z=B(b)||{min:0,max:1};let{min:q,max:U}=z;if(H.zero&&(q>0&&(q=0),U<0&&(U=0)),q===U){const oe=Math.abs(q)>0?Math.abs(q)/10:1;q-=oe,U+=oe}if(H.nice!==!1){const oe=C({min:q,max:U},H.ticks||5);q=oe.min,U=oe.max}return te(H.min)&&(q=H.min),te(H.max)&&(U=H.max),q===U&&(U=q+1),{min:q,max:U}}function F(b,H=5){const z=Y((b.max-b.min)/Math.max(1,H)),q=Math.ceil(b.min/z),U=Math.floor(b.max/z),oe=[];for(let ee=q;ee<=U;ee++){const Z=ee*z;oe.push(Math.abs(Z)<z/1e6?0:Number(Z.toPrecision(12)))}return oe}function x(b,H=5){const z=Math.max(1,H),q=b/z;let U=K[K.length-1];for(const Z of K)if(Z>=q){U=Z;break}if(U<ae)return U;let oe=U,ee=Math.abs(b/U-z);for(const Z of K){if(Z<ae)continue;const de=Math.abs(b/Z-z);de<ee&&(ee=de,oe=Z)}return oe}function _(b,H){const z=new Date(b.min).getUTCFullYear();let q=Math.ceil(z/H)*H;Date.UTC(q,0,1)<b.min&&(q+=H);const U=[];for(;Date.UTC(q,0,1)<=b.max;q+=H)U.push(Date.UTC(q,0,1));return U}function p(b,H=5){const z=x(b.max-b.min,H);if(z>=ae)return _(b,Math.round(z/ae));const q=[],U=Math.ceil(b.min/z)*z;for(let oe=U;oe<=b.max;oe+=z)q.push(oe);return q}function i(b,H){const z=b.max-b.min||1,[q,U]=H;return{kind:"linear",domain:b,range:H,of(oe){return q+(oe-b.min)/z*(U-q)},invert(oe){return b.min+(oe-q)/(U-q||1)*z},ticks(oe=5){return F(b,oe)}}}function S(b,H){return{...i(b,H),kind:"time",ticks(q=5){return p(b,q)}}}function d(b){if(b==null)return" null";if(b instanceof Date)return` date:${b.getTime()}`;if(typeof b=="object"){const H=b,z=H.id??H.key??H.value;return z!==void 0&&typeof z!="object"?` obj:${String(z)}`:` obj:${String(b)}`}return String(b)}function W(b,H,z=.2){const q=Math.min(.9,Math.max(0,z)),[U,oe]=H,ee=new Map;for(let E=0;E<b.length;E++){const D=d(b[E]);ee.has(D)||ee.set(D,E)}const Z=b.length?(oe-U)/b.length:oe-U,de=Math.max(0,Z*(1-q));return{kind:"band",domain:b,range:H,bandwidth:de,step:Z,of(E){const D=ee.get(d(E));return D===void 0?NaN:U+D*Z+(Z-de)/2},centre(E){const D=this.of(E);return Number.isNaN(D)?NaN:D+de/2},ticks(){return b}}}function I(b,H){const[z,q]=H,U=Math.max(Math.abs(b.max),Math.abs(b.min),0)||1;return{kind:"sqrt",domain:b,range:H,of(oe){const ee=Math.sqrt(Math.abs(oe)/U);return z+ee*(q-z)}}}}),Ge("packages/modules/charts/svg.js",function(o,ue){"use strict";Object.defineProperty(o,"SVG_NS",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"el",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"svg",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"attr",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"attrs",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"setText",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"clear",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"append",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"path",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"ribbonPath",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"round",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"pathRings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"insideRings",{enumerable:!0,get:function(){return C}});const xe="http://www.w3.org/2000/svg";function re(L,F,x){const _=L.createElement(F);return x&&_.setAttribute("class",x),_}function l(L,F,x){const _=L.createElementNS(xe,F);if(x)for(const p of Object.keys(x))_.setAttribute(p,String(x[p]));return _}function ge(L,F,x){L&&(x==null?L.removeAttribute(F):L.setAttribute(F,String(x)))}function ae(L,F){if(L)for(const x of Object.keys(F))ge(L,x,F[x])}function ke(L,F){L&&(L.textContent=F==null?"":String(F))}function K(L){if(L)for(;L.firstChild;)L.removeChild(L.firstChild)}function te(L,F){for(const x of F)x&&L.appendChild(x);return L}function pe(L){return L.join(" ")}function V(L){if(!L||L.length<2)return"";const F=["M",L[0].x,L[0].upper];for(let x=1;x<L.length;x++)F.push("L",L[x].x,L[x].upper);for(let x=L.length-1;x>=0;x--)F.push("L",L[x].x,L[x].lower);return F.push("Z"),pe(F)}function B(L){return Math.round(L*100)/100}function Y(L){const F=[];let x=[];const _=String(L||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let p="",i=[];const S=()=>{if(!p||!i.length){i=[];return}if(p==="M"||p==="L")for(let d=0;d+1<i.length;d+=2)x.push([i[d],i[d+1]]);else p!=="Z"&&i.length>=2&&x.push([i[i.length-2],i[i.length-1]]);i=[]};for(const d of _){if(/[A-Za-z]/.test(d)){if(S(),d==="Z"||d==="z"){x.length>2&&F.push(x),x=[],p="";continue}d==="M"&&x.length>2&&(F.push(x),x=[]),p=d;continue}i.push(Number(d))}return S(),x.length>2&&F.push(x),F}function C(L,F,x){let _=!1;for(const p of L)for(let i=0,S=p.length-1;i<p.length;S=i++){const[d,W]=p[i],[I,b]=p[S];W>x!=b>x&&F<(I-d)*(x-W)/(b-W||1e-12)+d&&(_=!_)}return _}}),Ge("packages/modules/charts/typography.js",function(o,ue){"use strict";Object.defineProperty(o,"BASE_SIZE",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"BASE_FAMILY",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"CHAR_RATIO",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"resolveType",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"textWidth",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"widestLabel",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"truncateTo",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"applySize",{enumerable:!0,get:function(){return pe}});const xe=12,re="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",l=.62;function ge(V){const B=V&&V.font,Y=typeof B=="number"?{size:B}:B||{},C=ae(Y.size,xe);return{family:Y.family||re,size:C,small:ae(Y.small??Y.tickSize,Math.max(9,C-1)),title:ae(Y.title,Math.round(C*1.15)),axisTitle:ae(Y.axisTitle,Math.max(10,C-1)),weight:Y.weight||"inherit"}}function ae(V,B){const Y=Number(V);return Number.isFinite(Y)&&Y>0?Y:B}function ke(V,B){return String(V??"").length*B*l}function K(V,B){let Y=0;for(const C of V||[]){const L=ke(C,B);L>Y&&(Y=L)}return Y}function te(V,B,Y){const C=String(V??""),L=Math.floor(B/(Y*l));return L<=0?"":C.length<=L?C:L===1?"…":`${C.slice(0,L-1)}…`}function pe(V,B){!V||!Number.isFinite(B)||(V.style?V.style.fontSize=`${B}px`:V.setAttribute("style",`font-size:${B}px`))}}),Ge("packages/modules/charts/frame.js",function(o,ue){"use strict";Object.defineProperty(o,"LABEL_GAP",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"resolveMargin",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"plotRect",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"shouldRotate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"Pool",{enumerable:!0,get:function(){return Y}});const re=ue("packages/modules/charts/svg.js").SVG_NS,l=ue("packages/modules/charts/typography.js"),ge=l.textWidth,ae=l.widestLabel,ke=8,K=6,te=.4;function pe(C,L){const F=typeof C=="number"?C:L,x=C&&typeof C=="object"?C:{},_=p=>Number.isFinite(p)&&p>=0?Number(p):F;return{base:F,top:_(x.top),right:_(x.right),bottom:_(x.bottom),left:_(x.left)}}function V(C){const L=pe(C.margin,typeof C.padding=="number"?C.padding:8),F=L.base,x=C.fontSize||12,_=C.yLabels||[],p=C.xLabels||[],i=C.ySide==="right"?"right":"left",S=i==="right"?"left":"right",d=C.titles||{},W=C.titleSize||x,I=D=>D?W+K:0,b=ae(_,x),H=_.length?Math.min(C.width*te,L[i]+b+K):Math.max(ke,L[i]),z=L[S]+(C.rightGutter||0),q=(i==="left"?H:z)+I(d.left),U=ae(p.map(D=>String(D).slice(0,14)),x),oe=(p.length?C.rotated?Math.min(C.height*te,K+U):x+K+L.bottom:Math.max(ke,L.bottom))+I(d.bottom),ee=(i==="right"?H:z)+I(d.right),Z=L.top+(C.topGutter||0),de=Math.max(0,C.width-q-ee),E=Math.max(0,C.height-Z-oe);return{left:q,top:Z,width:de,height:E,right:q+de,bottom:Z+E,gutter:{left:q,bottom:oe,right:ee,top:Z}}}function B(C,L,F,x){if(!C.length||L<=0)return!1;const _=Number.isFinite(x)&&x>0?Number(x):1;return ae(C,F)>L*_-4}class Y{#e;#t=0;static#n="data-pool-key";constructor(L){this.#e=L}next(L,F,x){if(x!=null)return this.#r(L,F,String(x));const _=this.#e.childNodes[this.#t],p=_&&_.tagName;if(p&&String(p).toLowerCase()===L.toLowerCase())return F&&_.setAttribute("class",F),this.#t++,_;const i=this.#e.ownerDocument.createElementNS(re,L);return F&&i.setAttribute("class",F),_?this.#e.insertBefore(i,_):this.#e.appendChild(i),this.#t++,i}#r(L,F,x){const _=L.toLowerCase();for(let S=this.#t;S<this.#e.childNodes.length;S++){const d=this.#e.childNodes[S],W=d&&d.tagName;if(W&&String(W).toLowerCase()===_&&d.getAttribute(Y.#n)===x)return S!==this.#t&&this.#e.insertBefore(d,this.#e.childNodes[this.#t]),F&&d.setAttribute("class",F),this.#t++,d}const p=this.#e.ownerDocument.createElementNS(re,L);p.setAttribute(Y.#n,x),F&&p.setAttribute("class",F);const i=this.#e.childNodes[this.#t];return i?this.#e.insertBefore(p,i):this.#e.appendChild(p),this.#t++,p}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Ge("packages/modules/charts/scheme.js",function(o,ue){"use strict";Object.defineProperty(o,"PALETTE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"SCHEMES",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"registerScheme",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"setDefaultScheme",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"schemeNames",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"resolveScheme",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"RAMP_SCALES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"toRgb",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rampStops",{enumerable:!0,get:function(){return p}});const re=ue("packages/core/src/internal/util.js").warnOnce,l=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),ge=Object.freeze({default:{series:l,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"}}),ae=new Map;let ke="default";function K(i,S){!i||!S||ae.set(String(i),S)}function te(i){if(typeof i=="string"){ke=i;return}i&&typeof i=="object"&&(ae.set("__default__",i),ke="__default__")}function pe(){return[...Object.keys(ge),...ae.keys()].filter(i=>!i.startsWith("__"))}function V(i){return ae.has(i)?ae.get(i):ge[i]||null}const B=["series","sequential","diverging","positive","negative"];function Y(i){return!i||typeof i!="object"||Array.isArray(i)?!1:!B.some(S=>S in i)}function C(i){const S=V(ke)||ge.default,d=i&&i.scheme,W=Y(d)?d:null,I=typeof d=="string"?V(d):W?null:d||null,b=i&&Array.isArray(i.palette)&&i.palette.length?i.palette:null;W&&b&&re("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const H=W?null:b,z={...ge.default,...S,...I||{}};H&&(z.series=H);const q=i&&i.ramp&&typeof i.ramp=="object"&&!Array.isArray(i.ramp)?i.ramp:null,U=q?q.colours:i&&i.ramp,oe=Array.isArray(U)&&U.length>=2?U:null;oe&&(z.sequential=oe);const ee=q?F(q.scale):null,Z=!!(I||H||W),de=z.series&&z.series.length?z.series:l,E=new Map;let D=0;return{...z,series:(f,c)=>{if(W&&c!==void 0&&c!==null){const e=String(c);return Object.prototype.hasOwnProperty.call(W,e)?W[e]:(E.has(e)||E.set(e,D++),x(de,E.get(e),!0))}return x(de,f,Z)},explicit:Z,nameMap:!!W,rampScale:ee}}const L=Object.freeze(["linear","log","quantile"]);function F(i){return i==null?null:L.includes(i)?i:(re(`chart:ramp:scale:${String(i)}`,`chart "ramp.scale" was "${String(i)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function x(i,S,d){const W=(S%i.length+i.length)%i.length;return d?i[W]:`var(--lattice-chart-${W+1}, ${i[W]})`}function _(i){if(typeof i!="string")return null;const S=i.trim(),d=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(S);if(d){const b=d[1];return b.length===3?[0,1,2].map(H=>parseInt(b[H]+b[H],16)):[0,2,4].map(H=>parseInt(b.slice(H,H+2),16))}const W=/^rgba?\(([^)]+)\)$/i.exec(S);if(!W)return null;const I=W[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return I.length===3&&I.every(b=>Number.isFinite(b))?I:null}function p(i,S){const d=S?i.diverging:i.sequential,W=S?ge.default.diverging:ge.default.sequential,I=(Array.isArray(d)?d:W).map((b,H)=>_(b)||_(W[H])||[0,0,0]);return I.length>=2?I:W.map(b=>_(b))}}),Ge("packages/modules/charts/styles.js",function(o,ue){"use strict";Object.defineProperty(o,"NS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"seriesColour",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"css",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"injectStyles",{enumerable:!0,get:function(){return K}});const re=ue("packages/modules/charts/scheme.js").PALETTE,l="lat-chartview",ge="data-lattice-chartview";function ae(te){const pe=(te%re.length+re.length)%re.length;return`var(--lattice-chart-${pe+1}, ${re[pe]})`}function ke(){return`
|
|
7
7
|
.${l}{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;
|
|
8
8
|
width:100%;height:100%;box-sizing:border-box;
|
|
9
9
|
font-family:var(--lattice-font-family,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);
|
|
10
10
|
font-size:var(--lattice-font-size,13px);
|
|
11
11
|
color:var(--lattice-foreground,#1c2126);
|
|
12
12
|
background:var(--lattice-background,#fff);
|
|
13
|
-
--lattice-chart-1:${
|
|
14
|
-
--lattice-chart-3:${
|
|
15
|
-
--lattice-chart-5:${
|
|
16
|
-
--lattice-chart-7:${
|
|
13
|
+
--lattice-chart-1:${re[0]};--lattice-chart-2:${re[1]};
|
|
14
|
+
--lattice-chart-3:${re[2]};--lattice-chart-4:${re[3]};
|
|
15
|
+
--lattice-chart-5:${re[4]};--lattice-chart-6:${re[5]};
|
|
16
|
+
--lattice-chart-7:${re[6]};--lattice-chart-8:${re[7]};
|
|
17
17
|
--lattice-chart-grid:var(--lattice-border-color,#dfe3e6);
|
|
18
18
|
--lattice-chart-empty:var(--lattice-surface,#f7f8f9);
|
|
19
19
|
--lattice-chart-axis:var(--lattice-foreground-muted,#5b6670);
|
|
@@ -256,6 +256,13 @@ var Rt=Object.create(null),zt=Object.create(null);function Le(o,oe){Rt[o]=oe}fun
|
|
|
256
256
|
.${l}__legend[data-position="right"] .${l}__legend-ramp{flex-direction:column;height:110px}
|
|
257
257
|
.${l}__legend[data-position="left"] .${l}__legend-ramp-bar,
|
|
258
258
|
.${l}__legend[data-position="right"] .${l}__legend-ramp-bar{width:10px;height:auto;min-width:0;min-height:32px}
|
|
259
|
+
.${l}__legend-ramp-bar{position:relative}
|
|
260
|
+
.${l}__legend-ramp[data-ticks]{padding-bottom:14px}
|
|
261
|
+
.${l}__legend-ramp-tick{position:absolute;top:100%;transform:translateX(-50%);padding-top:2px;line-height:1.1;white-space:nowrap;color:var(--lattice-foreground-muted,#5b6670)}
|
|
262
|
+
.${l}__legend[data-position="left"] .${l}__legend-ramp[data-ticks],
|
|
263
|
+
.${l}__legend[data-position="right"] .${l}__legend-ramp[data-ticks]{padding-bottom:0;padding-right:40px}
|
|
264
|
+
.${l}__legend[data-position="left"] .${l}__legend-ramp-tick,
|
|
265
|
+
.${l}__legend[data-position="right"] .${l}__legend-ramp-tick{top:auto;left:100%;transform:translateY(50%);padding:0 0 0 3px}
|
|
259
266
|
.${l}__tooltip{position:fixed;z-index:5;pointer-events:none;max-width:260px;
|
|
260
267
|
padding:5px 8px;border-radius:4px;font-size:var(--lattice-font-size-sm,11px);
|
|
261
268
|
background:var(--lattice-surface,#f7f8f9);color:var(--lattice-foreground,#1c2126);
|
|
@@ -294,10 +301,10 @@ var Rt=Object.create(null),zt=Object.create(null);function Le(o,oe){Rt[o]=oe}fun
|
|
|
294
301
|
}
|
|
295
302
|
@scope ([data-theme="light"],[data-theme="auto"]){
|
|
296
303
|
:scope.${l},.${l}{
|
|
297
|
-
--lattice-chart-1:${
|
|
298
|
-
--lattice-chart-3:${
|
|
299
|
-
--lattice-chart-5:${
|
|
300
|
-
--lattice-chart-7:${
|
|
304
|
+
--lattice-chart-1:${re[0]};--lattice-chart-2:${re[1]};
|
|
305
|
+
--lattice-chart-3:${re[2]};--lattice-chart-4:${re[3]};
|
|
306
|
+
--lattice-chart-5:${re[4]};--lattice-chart-6:${re[5]};
|
|
307
|
+
--lattice-chart-7:${re[6]};--lattice-chart-8:${re[7]};color-scheme:light}
|
|
301
308
|
}
|
|
302
309
|
@media (prefers-color-scheme: dark){
|
|
303
310
|
@scope ([data-theme="auto"]){
|
|
@@ -325,6 +332,6 @@ var Rt=Object.create(null),zt=Object.create(null);function Le(o,oe){Rt[o]=oe}fun
|
|
|
325
332
|
.${l}__swatch{border:1px solid CanvasText}
|
|
326
333
|
.${l}__mark[data-dim]{opacity:1;fill:GrayText}
|
|
327
334
|
}
|
|
328
|
-
`}function W(Z){const fe=Z.documentElement;if(!fe||fe.getAttribute(le))return;fe.setAttribute(le,"1");const V=Z.createElement("style");V.textContent=he(),(Z.head||Z.body||fe).appendChild(V)}}),Le("packages/modules/charts/axis.js",function(o,oe){"use strict";Object.defineProperty(o,"pinXDomain",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"TICK_FLOOR",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"tickFloor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"fitBandLabels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normaliseAxes",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"tickValues",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"tickLabeller",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"drawAxisTitle",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"labelEvery",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"drawMeasureAxis",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"drawCategoryAxis",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"leftLabelRoom",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"setLabelText",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"drawBandLabels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"drawContinuousAxis",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"drawAxisLines",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"createGroups",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"MARK_OVERHANG",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"overhangFor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"setPlotClip",{enumerable:!0,get:function(){return w}});const X=oe("packages/modules/charts/frame.js").Pool,l=oe("packages/modules/charts/svg.js"),le=l.attrs,ne=l.round,he=l.setText,W=l.svg,Z=oe("packages/modules/charts/typography.js"),fe=Z.applySize,V=Z.CHAR_RATIO,I=Z.truncateTo,D=oe("packages/modules/charts/styles.js").NS,T=oe("packages/modules/charts/scale.js"),_=T.toNumber,k=T.toTime,b=oe("packages/core/src/internal/util.js").warnOnce;function a(s,i,O){const $=i&&i.kind==="time"?k:_,E=h=>h==null||h===""?null:$(h),n=E(O&&O.min),d=E(O&&O.max);if(n===null&&d===null)return s;if(n!==null&&d!==null)return n<d?{min:n,max:d}:(b("chart.axis.x.domain.inverted",`axis.x.min (${n}) is not below axis.x.max (${d}), which is a mirrored axis rather than a narrow one, so both were ignored and the x domain was taken from the data. On a time axis both are epoch milliseconds.`),s);const y=n!==null?n:s.min,r=d!==null?d:s.max;if(y<r)return{min:y,max:r};const u=Math.abs(s.max-s.min)||1;return b("chart.axis.x.domain.beyond",`axis.x.${n!==null?"min":"max"} is outside the x values entirely, so the plot is empty. The pin was kept and the other edge moved to hold the axis width; check the units (a time axis is pinned in epoch milliseconds).`),n!==null?{min:y,max:y+u}:{min:r-u,max:r}}const v=6,g=9;function R(s){const i=s&&s.ownerDocument,O=i&&i.defaultView;if(!O||typeof O.getComputedStyle!="function")return g;const $=O.getComputedStyle(s).getPropertyValue("--lattice-chart-tick-min"),E=parseFloat($);return Number.isFinite(E)&&E>0?E:g}function F(s){const{size:i,floor:O,slot:$,per:E}=s,n=Number.isFinite(s.every)&&s.every>0?Number(s.every):null;if(n!==null&&n!==1)return{size:i,every:n,thinned:!1};if(!($>0)||!(E>0))return{size:i,every:1,thinned:!1};const d=Math.min(i,$/E);return d>=O?{size:d,every:1,thinned:!1}:{size:O,every:Math.max(1,Math.ceil(O*E/$)),thinned:!0}}function p(s,i){const O=Math.ceil(s/i),$=s-O;b("chart.axis.band.thinned",`${$} of ${s} band labels were hidden: even the smallest font (--lattice-chart-tick-min) could not make them all fit. Set axis.x.every or axis.y.every to choose which ones show.`)}const L=1.2;function B(s){if(s===!1){const $={labels:!1,grid:!1};return{x:{...$},y:{...$},y2:{...$}}}const i=s&&typeof s=="object"?s:{},O=$=>typeof $=="string"?{title:$}:$&&typeof $=="object"?{...$}:{};return{x:O(i.x),y:O(i.y),y2:O(i.y2||i.right)}}function H(s,i){const O=i&&i.ticks;if(Array.isArray(O)){const E=s.domain;return!E||E.min===void 0?O:O.filter(n=>Number(n)>=E.min&&Number(n)<=E.max)}const $=Number.isFinite(O)&&O>0?Number(O):5;return s.ticks($)}function G(s,i,O,$){const E=s&&s.format;return typeof E=="function"?n=>String(E(n)):typeof E=="string"&&O&&O.formatting&&O.formatting.format?n=>String(O.formatting.format(n,E)):$&&$.format&&$.format.pattern&&typeof $.formatValue=="function"?n=>String($.formatValue(n,null)):i.tick}function ae(s){if(!s.text)return;const i=s.side==="left"||s.side==="right"?s.plot.height:s.plot.width,O=Number.isFinite(i)?I(String(s.text),Math.max(0,i),s.size):String(s.text);if(!O||O==="…")return;const $=W(s.group.ownerDocument,"text",{class:`${D}__axis-title`});if(fe($,s.size),s.side==="left"){const E=Math.max(s.size,s.plot.left-s.plot.gutter.left+s.size),n=s.plot.top+s.plot.height/2;le($,{transform:`translate(${ne(E)} ${ne(n)}) rotate(-90)`,"text-anchor":"middle"})}else if(s.side==="right"){const E=s.plot.right+s.plot.gutter.right-s.size,n=s.plot.top+s.plot.height/2;le($,{transform:`translate(${ne(E)} ${ne(n)}) rotate(90)`,"text-anchor":"middle"})}else le($,{x:ne(s.plot.left+s.plot.width/2),y:ne(s.plot.bottom+s.plot.gutter.bottom-2),"text-anchor":"middle"});he($,O),O!==String(s.text)&&$.setAttribute("aria-label",String(s.text)),s.group.appendChild($)}function J(s){const{values:i,scale:O,size:$,horizontal:E,label:n}=s;if(i.length<2)return 1;let d=1/0;for(let r=1;r<i.length;r++){const u=Math.abs(O.of(i[r])-O.of(i[r-1]));Number.isFinite(u)&&u<d&&(d=u)}if(!Number.isFinite(d))return 1;if(d<=0)return i.length;let y=$*L+2;if(E){let r=0;for(const u of i){const h=String(n(u)||"").length*$*V;h>r&&(r=h)}y=r+v}return Math.max(1,Math.ceil(y/d))}function q(s){const{gridGroup:i,axisGroup:O,plot:$,scale:E,format:n}=s,d=s.config||{},y=H(E,d),r=G(d,n,s.grid),u=s.size||11,h=J({values:y,scale:E,size:u,horizontal:!!s.horizontal,label:r}),M=d.grid===!1?null:i,A=M?new X(M):null,C=new X(O);for(let Y=0;Y<y.length;Y++){const ee=y[Y],ue=ne(E.of(ee)),we=ee===0,Oe=Y%h!==0;if(s.horizontal){if(A&&le(A.next("line",`${D}__gridline`),{x1:ue,x2:ue,y1:ne($.top),y2:ne($.bottom),"stroke-opacity":we?1:.6,"stroke-width":we?1.5:1}),d.labels===!1||Oe)continue;const ke=C.next("text",`${D}__tick`);fe(ke,u),le(ke,{x:ue,y:ne($.bottom+v),"text-anchor":"middle","dominant-baseline":"hanging"}),he(ke,r(ee))}else{if(A&&le(A.next("line",`${D}__gridline`),{x1:ne($.left),x2:ne($.right),y1:ue,y2:ue,"stroke-opacity":we?1:.6,"stroke-width":we?1.5:1}),d.labels===!1||Oe)continue;const ke=C.next("text",`${D}__tick`);fe(ke,u);const $e=s.side==="right";le(ke,{x:ne($e?$.right+v:$.left-v),y:ue,"text-anchor":$e?"start":"end","dominant-baseline":"middle"}),he(ke,r(ee))}}return A?A.finish():new X(i).finish(),C.finish(),y}function ce(s){const{group:i,plot:O,scale:$,labels:E}=s,n=s.config||{};if(n.labels===!1){new X(i).finish();return}const d=new X(i),y=$.domain,r=$.step,u=n.rotate===void 0||n.rotate==="auto"?s.rotated:!!n.rotate,h=u?F({size:s.fontSize,floor:R(i),slot:r,per:Math.SQRT2,every:n.every}):{size:s.fontSize,every:Number.isFinite(n.every)&&n.every>0?Number(n.every):1,thinned:!1},{size:M,every:A}=h;h.thinned&&p(y.length,A);const C=r*A;for(let Y=0;Y<y.length;Y++){const ee=ne($.centre(y[Y]));if(Number.isNaN(ee)||Y%A!==0)continue;const ue=d.next("text",`${D}__tick`);fe(ue,M);const we=E[Y]===void 0?"":E[Y];u?(le(ue,{x:0,y:0,"text-anchor":"end","dominant-baseline":"middle",transform:`translate(${ee} ${ne(O.bottom+v)}) rotate(-45)`}),z(ue,we,Math.max(0,O.gutter.bottom-v)*Math.SQRT2,M)):(le(ue,{x:ee,y:ne(O.bottom+v),"text-anchor":"middle","dominant-baseline":"hanging",transform:null}),z(ue,we,C,M))}d.finish()}function j(s){return Math.max(0,(s.gutter?s.gutter.left:s.left)-v)}function z(s,i,O,$){const E=String(i??""),n=I(E,O,$);return he(s,n),n!==E?s.setAttribute("aria-label",E):s.removeAttribute("aria-label"),n}function t(s){const{group:i,plot:O,scale:$,labels:E}=s,n=s.config||{},d=new X(i),y=$.domain,r=j(O),u=F({size:s.fontSize,floor:R(i),slot:$.step,per:L,every:n.every}),{size:h,every:M}=u;u.thinned&&p(y.length,M);for(let A=0;A<y.length;A++){if(A%M!==0)continue;const C=ne($.centre(y[A]));if(Number.isNaN(C))continue;const Y=d.next("text",`${D}__tick`);le(Y,{x:ne(O.left-v),y:C,"text-anchor":"end","dominant-baseline":"middle"}),fe(Y,h),z(Y,E[A],r,h)}d.finish()}function c(s){const{group:i,plot:O,scale:$,format:E}=s,n=s.config||{};if(n.labels===!1){new X(i).finish();return}const d=G(n,E,s.grid,s.column),y=new X(i);for(const r of H($,n)){const u=ne($.of(r));if(u<O.left-1||u>O.right+1)continue;const h=y.next("text",`${D}__tick`);fe(h,s.size||11),le(h,{x:u,y:ne(O.bottom+v),"text-anchor":"middle","dominant-baseline":"hanging"}),he(h,d(r))}y.finish()}function f(s){const{group:i,plot:O}=s,$=s.side==="right"?O.right:O.left,E=new X(i);le(E.next("line"),{x1:ne($),x2:ne($),y1:ne(O.top),y2:ne(O.bottom)}),le(E.next("line"),{x1:ne(O.left),x2:ne(O.right),y1:ne(O.bottom),y2:ne(O.bottom)}),E.finish()}let e=0;function x(s,i){const O=`${D}-plot-clip-${++e}`,$=W(s,"rect"),E=W(s,"clipPath",{id:O});E.appendChild($);const n=`${D}-box-clip-${e}`,d=W(s,"clipPath",{id:n});d.appendChild(W(s,"rect",{x:0,y:0,width:"100%",height:"100%"}));const y=W(s,"defs");y.appendChild(E),y.appendChild(d);const r={grid:W(s,"g",{class:`${D}__grid`}),marks:W(s,"g",{class:`${D}__marks`}),rules:W(s,"g",{class:`${D}__axis`}),axis:W(s,"g",{class:`${D}__axis`}),labels:W(s,"g",{class:`${D}__labels`}),overlay:W(s,"g",{class:`${D}__overlay`}),clip:$,clipId:O,boxClipId:n};i.appendChild(y);for(const u of["grid","marks","rules","axis","labels","overlay"])i.appendChild(r[u]);return r}const S=30;function P(s){return s==="bubble"?S:s==="scatter"?6:3}function w(s,i,O){if(!s||!s.marks||!s.clip)return;if(!i||!Number.isFinite(i.width)||!Number.isFinite(i.height)){s.marks.removeAttribute("clip-path");return}const $=Number.isFinite(O)&&O>=0?Number(O):S;le(s.clip,{x:ne(i.left-$),y:ne(i.top-$),width:ne(Math.max(0,i.width)+$*2),height:ne(Math.max(0,i.height)+$*2)}),s.marks.setAttribute("clip-path",`url(#${s.clipId})`)}}),Le("packages/modules/charts/format.js",function(o,oe){"use strict";Object.defineProperty(o,"precisionFor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"axisNumber",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"r2Digits",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dateFormatFor",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"formatters",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"measureText",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"measureFormat",{enumerable:!0,get:function(){return fe}});const X=oe("packages/modules/charts/scale.js").timeStepFor;function l(V){if(!Number.isFinite(V)||V<=0)return 0;const I=Math.ceil(-Math.log10(V));return Math.min(6,Math.max(0,I))}function le(V,I,U=0){return Number.isFinite(V)?Math.abs(V)>=1e4?I.number(V,{notation:"compact",maximumFractionDigits:1}):I.number(V,{minimumFractionDigits:U,maximumFractionDigits:U}):""}function ne(V,I){const U=V&&V.messages;return!U||typeof U.number!="function"?Number(I).toFixed(2):U.number(I,{minimumFractionDigits:2,maximumFractionDigits:2})}function he(V){const U=V>0?X(V):0;return U>0&&U<1e3?{minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}:U>0&&U<6e4?{hour:"2-digit",minute:"2-digit",second:"2-digit"}:V<=864e5?{hour:"2-digit",minute:"2-digit"}:V<=180*864e5?U>0&&U<864e5?{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short"}:V<=3*365*864e5?{month:"short",year:"numeric"}:{year:"numeric"}}function W(V,I,U){const D=V.messages,T=D.locale,k=U&&U.format&&U.format.timeZone||V.get("timeZone")||void 0;if(I.kind==="time"){const b=he(I.span||0),a=new Intl.DateTimeFormat(T,k?{...b,timeZone:k}:b),v=new Intl.DateTimeFormat(T,k?{dateStyle:"medium",timeStyle:"short",timeZone:k}:{dateStyle:"medium",timeStyle:"short"});return{tick:g=>Number.isFinite(Number(g))?a.format(new Date(Number(g))):"",value:g=>Number.isFinite(Number(g))?v.format(new Date(Number(g))):""}}const N=l(I.step||0);return{tick:b=>typeof b=="number"?le(b,D,N):String(b??""),value:b=>typeof b=="number"?D.number(b):String(b??"")}}function Z(V,I){if(V==null||!Number.isFinite(V))return"";const U=Math.abs(V)>=1e-6?Number(V.toPrecision(6)):V;return I.number(U)}function fe(V,I,U){return V==null||!Number.isFinite(Number(V))?"":I&&I.format&&typeof I.formatValue=="function"?String(I.formatValue(V,null)):Z(Number(V),U&&U.messages)}}),Le("packages/modules/charts/labels.js",function(o,oe){"use strict";Object.defineProperty(o,"resolveLabels",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collides",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"placeLabels",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"labelText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"drawAnchoredLabels",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"drawDataLabels",{enumerable:!0,get:function(){return v}});const X=oe("packages/modules/charts/frame.js").Pool,le=oe("packages/modules/charts/format.js").measureText,ne=oe("packages/modules/charts/svg.js"),he=ne.attrs,W=ne.round,Z=ne.setText,V=oe("packages/modules/charts/styles.js").NS,I=oe("packages/modules/charts/typography.js"),U=I.applySize,D=I.textWidth,T=4;function _(g){const R=g&&g.labels;if(!R)return{show:!1,names:R!==!1,position:"outside",format:null,minGap:2,total:!1};const F=typeof R=="object"?R:{};return{show:!0,names:!0,position:["outside","inside","auto"].includes(F.position)?F.position:"outside",format:F.format||null,minGap:Number.isFinite(F.minGap)?Number(F.minGap):2,total:!!F.total}}function k(g,R,F){for(const p of R)if(g.x-F<p.x+p.width&&g.x+g.width+F>p.x&&g.y-F<p.y+p.height&&g.y+g.height+F>p.y)return!0;return!1}function N(g){const{points:R,plot:F,size:p}=g,L=g.minGap===void 0?2:g.minGap,B=[],H=[];for(const G of R){if(G.px===void 0||G.py===void 0)continue;const ae=g.text(G);if(!ae)continue;const J=D(ae,p),q=p;let ce=G.px,j=G.py-T,z="middle",t=!1;g.horizontal?(ce=G.px+T,j=G.py,z="start",g.position!=="outside"&&G.pbase!==void 0&&Math.abs(G.px-G.pbase)>J+T*2&&(ce=G.px-T,z="end",t=!0)):g.position!=="outside"&&G.pbase!==void 0&&Math.abs(G.pbase-G.py)>q+T*2&&(j=G.py+q+T,t=!0);const c=()=>({x:z==="middle"?ce-J/2:z==="end"?ce-J:ce,y:j-q,width:J,height:q});let f=c();!(f.y>=F.top-1)&&!t&&!g.horizontal&&G.pbase!==void 0&&Math.abs(G.pbase-G.py)>q+T*2&&(j=G.py+q+T,t=!0,f=c()),!(f.x+f.width<=F.right+1)&&!t&&g.horizontal&&G.pbase!==void 0&&Math.abs(G.px-G.pbase)>J+T*2&&(ce=G.px-T,z="end",t=!0,f=c()),!(f.x<F.left-1||f.x+f.width>F.right+1)&&(f.y<F.top-1||f.y+f.height>F.bottom+q||k(f,B,L)||(B.push(f),H.push({x:W(ce),y:W(j),text:ae,anchor:z,inside:t})))}return H}function b(g,R,F){return g==null?"":typeof R.format=="function"?String(R.format(g)):typeof R.format=="string"&&F&&F.formatting&&F.formatting.format?String(F.formatting.format(g,R.format)):le(g,F&&F.messages)}function a(g){const R=new X(g.group),F=g.minGap===void 0?2:g.minGap,p=g.size,L=[];let B=0;for(const H of g.anchors){if(!H||!H.text)continue;const G=H.width===void 0?D(H.text,g.size):H.width,ae=H.anchor||"middle",q={x:ae==="end"?H.x-G:ae==="start"?H.x:H.x-G/2,y:H.y-p/2,width:G,height:p};if(g.plot&&(q.x<g.plot.left-1||q.x+q.width>g.plot.right+1||q.y<g.plot.top-1||q.y+q.height>g.plot.bottom+1)||H.width!==void 0&&G>H.width||H.height!==void 0&&p>H.height||k(q,L,F))continue;L.push(q);const ce=R.next("text",H.className||`${V}__data-label`);U(ce,g.size),he(ce,{x:W(H.x),y:W(H.y),"text-anchor":ae,"dominant-baseline":H.baseline||"middle","data-inside":H.inside?"true":null}),Z(ce,H.text),B++}return R.finish(),B}function v(g){const R=new X(g.group),{options:F}=g;let p=0;const L=B=>typeof F.format=="function"&&B.y!==null&&B.y!==void 0?String(F.format(B.y,B)):b(B.y,F,g.grid);for(const B of g.series){const H=N({points:B.points,plot:g.plot,size:g.size,position:F.position,horizontal:g.horizontal,minGap:F.minGap,text:L});for(const G of H){const ae=R.next("text",`${V}__data-label`);U(ae,g.size),he(ae,{x:G.x,y:G.y,"text-anchor":G.anchor,"data-inside":G.inside?"true":null}),Z(ae,G.text),p++}}return R.finish(),p}}),Le("packages/modules/charts/dense.js",function(o,oe){"use strict";Object.defineProperty(o,"CANVAS_THRESHOLD",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"downsample",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"markCount",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"wantsCanvas",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"paintDense",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"sizeCanvas",{enumerable:!0,get:function(){return he}});const me=3e3;function X(W,Z){const fe=W.length;if(!Number.isFinite(Z)||Z>=fe||Z<3||fe<3)return W;const V=[W[0]],I=(fe-2)/(Z-2);let U=0;for(let D=0;D<Z-2;D++){const T=Math.floor(D*I)+1,_=Math.min(Math.floor((D+1)*I)+1,fe-1),k=_,N=Math.min(Math.floor((D+2)*I)+1,fe);let b=0,a=0,v=0;for(let p=k;p<N;p++){const L=W[p];!L||!Number.isFinite(L.y)||(b+=L.x,a+=L.y,v++)}v&&(b/=v,a/=v);const g=W[U];if(T>=_)continue;let R=T,F=-1;for(let p=T;p<_;p++){const L=W[p];if(!L||!Number.isFinite(L.y))continue;const B=Math.abs((g.x-b)*(L.y-g.y)-(g.x-L.x)*(a-g.y));B>F&&(F=B,R=p)}R<=U||(V.push(W[R]),U=R)}return V.push(W[fe-1]),V}function l(W){let Z=0;for(const fe of W)Z+=fe.points.length;return Z}function le(W){if(W.canvas===!0)return!0;if(W.canvas===!1)return!1;const Z=Number.isFinite(W.canvas)?Number(W.canvas):me;return l(W.series)>Z}function ne(W){const{context:Z,series:fe,ratio:V}=W;Z.save(),Z.scale(V,V);for(const I of fe){const U=W.colour(I.index);if(W.type==="scatter"||W.type==="bubble"){Z.fillStyle=U;for(const T of I.points)T.px!==void 0&&(Z.beginPath(),Z.arc(T.px,T.py,T.pr||2,0,Math.PI*2),Z.fill());continue}Z.strokeStyle=U,Z.lineWidth=2,Z.lineJoin="round",Z.beginPath();let D=!1;for(const T of I.points){if(T.px===void 0||T.py===void 0){D=!1;continue}D?Z.lineTo(T.px,T.py):Z.moveTo(T.px,T.py),D=!0}Z.stroke()}Z.restore()}function he(W){const{canvas:Z}=W;return Z.width=Math.max(1,Math.round(W.width*W.ratio)),Z.height=Math.max(1,Math.round(W.height*W.ratio)),Z.style&&(Z.style.width=`${W.width}px`,Z.style.height=`${W.height}px`),typeof Z.getContext=="function"?Z.getContext("2d"):null}}),Le("packages/modules/charts/annotations.js",function(o,oe){"use strict";Object.defineProperty(o,"overlayLayer",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"annotationValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"annotationAxis",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"annotationText",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"drawAnnotations",{enumerable:!0,get:function(){return ae}});const X=oe("packages/modules/charts/frame.js").Pool,l=oe("packages/modules/charts/scale.js"),le=l.isNumber,ne=l.toNumber,he=l.toTime,W=oe("packages/modules/charts/svg.js"),Z=W.attrs,fe=W.path,V=W.round,I=W.setText,U=W.SVG_NS,T=oe("packages/modules/charts/styles.js").NS,k=oe("packages/core/src/internal/util.js").warnOnce;function N(J,q){for(const j of J.childNodes||[])if(j&&String(j.getAttribute&&j.getAttribute("class"))===q)return j;const ce=J.ownerDocument.createElementNS(U,"g");return ce.setAttribute("class",q),J.appendChild(ce),ce}const b=new Set(["line","target","band","callout","event"]);function a(J,q){return J.kind==="time"?he(q):ne(q)}function v(J,q,ce){if(J.kind==="band"){const z=J.of(q);if(!Number.isFinite(z))return NaN;const t=Number(J.bandwidth)||0;return ce==="right"?z+t:z}const j=a(J,q);return j===null?NaN:J.of(j)}function g(J,q,ce){const j=J.kind||"line",z=J.label?` (${JSON.stringify(J.label)})`:"";k(`chart:annotation:dropped:${j}:${q}:${ce}`,`chart annotation${z} of kind ${JSON.stringify(j)}, reading the ${q} axis, was not drawn: ${ce}.`)}function R(J,q){if(J instanceof Date){const j=J.getTime();return Number.isFinite(j)?J.toISOString().slice(0,10):String(J)}if(typeof J=="number")return Number.isFinite(J)?q(J):String(J);const ce=ne(J);return ce===null||typeof J=="string"?String(J):q(ce)}function F(J,q,ce){const j=[];for(const z of J)if((z.axis==="right"?"right":"left")===ce&&!(q.series!==void 0&&z.key!==q.series))for(const c of z.points)le(c.y)&&j.push(Number(c.y));return j}function p(J,q){if(!J.length)return null;const ce=[...J].sort((c,f)=>c-f);if(ce.length===1)return ce[0];const j=Math.min(100,Math.max(0,q))/100*(ce.length-1),z=Math.floor(j),t=Math.ceil(j);return z===t?ce[z]:ce[z]+(ce[t]-ce[z])*(j-z)}function L(J,q,ce){if(!J.compute)return ne(J.value);const j=F(q,J,ce);if(!j.length)return null;const z=String(J.compute).toLowerCase();if(z==="mean"||z==="avg")return j.reduce((c,f)=>c+f,0)/j.length;if(z==="median"||z==="p50")return p(j,50);if(z==="min")return Math.min(...j);if(z==="max")return Math.max(...j);const t=/^p(\d+(?:\.\d+)?)$/.exec(z);return t?p(j,Number(t[1])):null}function B(J){return J.axis==="right"||J.axis==="y2"?"right":"left"}function H(J,q,ce,j){const z=J.label?`${J.label}: `:"",t=j?` (${B(J)==="right"?"right axis":"left axis"})`:"",c=J.kind||"line";if(c==="band"){if(!Array.isArray(q)||q[0]===null||q[1]===null)return"";const[e,x]=q;return`${z||"Band: "}${ce(Math.min(e,x))} to ${ce(Math.max(e,x))}${t}`}return q==null?"":`${z||`${c==="target"?"Target":c==="callout"?"Callout":"Reference"}: `}${ce(q)}${t}`}function G(J){return(J.kind||"line")==="band"?0:1}function ae(J){const{group:q,plot:ce,xScale:j,yScale:z,rightScale:t,series:c,format:f}=J,e=new X(N(q,`${T}__annotations`)),x=[],P=[...Array.isArray(J.annotations)?J.annotations:[]].sort((w,s)=>G(w)-G(s));for(const w of P){const s=w.kind||"line";if(!b.has(s))continue;const i=B(w),O=i==="right"&&t?t:z;if(s==="band"){if(w.orient==="vertical"){const h=v(j,w.from,"left"),M=v(j,w.to,"right");if(Number.isNaN(h)||Number.isNaN(M)){const ee=Number.isNaN(h)&&Number.isNaN(M)?"from and to":Number.isNaN(h)?"from":"to";g(w,i,`its ${ee} value could not be placed on the x scale`);continue}const A=V(Math.min(h,M)),C=V(Math.max(h,M));if(Z(e.next("rect",`${T}__annotation-band ${w.className||""}`.trim()),{x:A,y:V(ce.top),width:Math.max(0,C-A),height:V(Math.max(0,ce.bottom-ce.top)),fill:w.colour||"currentColor","fill-opacity":w.opacity===void 0?.12:w.opacity}),w.label){const ee=e.next("text",`${T}__annotation-label`);Z(ee,{x:A+4,y:V(ce.top+12),"text-anchor":"start"}),I(ee,w.label)}const Y=w.label?`${w.label}: `:"Event window: ";x.push({text:`${Y}${R(w.from,f)} to ${R(w.to,f)}`});continue}const d=L({...w,value:w.from,compute:w.fromCompute},c,i),y=L({...w,value:w.to,compute:w.toCompute},c,i);if(d===null||y===null)continue;const r=V(O.of(d)),u=V(O.of(y));if(Z(e.next("rect",`${T}__annotation-band ${w.className||""}`.trim()),{x:V(ce.left),y:Math.min(r,u),width:V(Math.max(0,ce.right-ce.left)),height:Math.max(0,Math.abs(u-r)),fill:w.colour||"currentColor","fill-opacity":w.opacity===void 0?.12:w.opacity}),w.label){const h=e.next("text",`${T}__annotation-label`);Z(h,{x:V(ce.left+4),y:Math.min(r,u)+12,"text-anchor":"start"}),I(h,w.label)}x.push({text:H(w,[d,y],f,J.dual)});continue}if(s==="event"){const d=w.x!==void 0?w.x:w.at,y=V(v(j,d,"left")+(j.kind==="band"?(Number(j.bandwidth)||0)/2:0));if(Number.isNaN(y)){g(w,i,"its x value could not be placed on the x scale");continue}if(Z(e.next("path",`${T}__annotation-event`),{d:fe(["M",y,V(ce.top),"L",y,V(ce.bottom)]),stroke:w.colour||"currentColor",fill:"none"}),Z(e.next("circle",`${T}__annotation-event-flag`),{cx:y,cy:V(ce.top),r:3,fill:w.colour||"currentColor"}),w.label){const u=e.next("text",`${T}__annotation-label`);Z(u,{x:y+5,y:V(ce.top+10),"text-anchor":"start"}),I(u,w.label)}const r=w.label?`${w.label} — `:"Event — ";x.push({text:`${r}at ${R(d,f)}`});continue}if(s==="callout"){const d=L(w,c,i);if(d===null)continue;const y=w.at!==void 0?V(j.kind==="band"?j.centre(w.at):j.of(a(j,w.at)??NaN)):V(ce.right-4),r=V(O.of(d));if(Number.isNaN(y)){g(w,i,"its x value could not be placed on the x scale");continue}if(Z(e.next("circle",`${T}__annotation-point`),{cx:y,cy:r,r:3.5,fill:w.colour||"currentColor"}),w.label){const u=e.next("text",`${T}__annotation-label`);Z(u,{x:y+6,y:r-6,"text-anchor":"start"}),I(u,w.label)}x.push({text:H(w,d,f,J.dual)});continue}if(w.orient==="vertical"||w.x!==void 0){const d=w.x!==void 0?w.x:w.value,y=j.kind==="band"?V(j.centre(d)):V(j.of(a(j,d)??NaN));if(Number.isNaN(y)){g(w,i,"its x value could not be placed on the x scale");continue}const r=s==="target"?`${T}__annotation-target`:`${T}__annotation-line`;if(Z(e.next("path",r),{d:fe(["M",y,V(ce.top),"L",y,V(ce.bottom)]),stroke:w.colour||"currentColor",fill:"none"}),w.label){const u=e.next("text",`${T}__annotation-label`);Z(u,{x:y+4,y:V(ce.top+10),"text-anchor":"start"}),I(u,w.label)}x.push({text:w.label?`${w.label} — at ${R(d,f)}`:""});continue}const $=L(w,c,i);if($===null)continue;const E=V(O.of($)),n=s==="target"?`${T}__annotation-target`:`${T}__annotation-line`;if(Z(e.next("path",n),{d:fe(["M",V(ce.left),E,"L",V(ce.right),E]),stroke:w.colour||"currentColor",fill:"none"}),w.label){const d=e.next("text",`${T}__annotation-label`);Z(d,{x:V(ce.right-4),y:E-4,"text-anchor":"end"}),I(d,w.label)}x.push({text:H(w,$,f,J.dual)})}return e.finish(),x.filter(w=>w.text)}}),Le("packages/modules/charts/combo.js",function(o,oe){"use strict";Object.defineProperty(o,"toPareto",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"drawCombo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"drawRightAxis",{enumerable:!0,get:function(){return s}});const me=oe("packages/modules/charts/axis.js"),X=me.drawAxisLines,l=me.drawCategoryAxis,le=me.drawContinuousAxis,ne=me.drawMeasureAxis,he=me.overhangFor,W=me.pinXDomain,Z=me.setPlotClip,fe=oe("packages/modules/charts/frame.js"),V=fe.Pool,I=fe.shouldRotate,D=oe("packages/modules/charts/format.js").formatters,T=oe("packages/modules/charts/scale.js"),_=T.bandScale,k=T.extent,N=T.isNumber,b=T.linearScale,a=T.measureDomain,v=T.timeScale,g=T.toNumber,R=T.toTime,F=oe("packages/modules/charts/svg.js"),p=F.attrs,L=F.path,B=F.round,G=oe("packages/modules/charts/styles.js").NS,J=oe("packages/modules/charts/scheme.js").resolveScheme,ce=oe("packages/modules/charts/labels.js").drawDataLabels,z=oe("packages/modules/charts/annotations.js").drawAnnotations;function t(i){return{left:i.filter(O=>O.axis!=="right"),right:i.filter(O=>O.axis==="right")}}function c(i,O){const $=i&&i.seriesStyle&&i.seriesStyle[O];if($)return{width:$.width!=null?String($.width):null,dash:Array.isArray($.dash)&&$.dash.length?$.dash.join(" "):null,opacity:null,emphasized:!1};const E=i&&Array.isArray(i.emphasis)?i.emphasis:null;if(!E||!E.length)return{width:null,dash:null,opacity:null,emphasized:!1};const n=E.includes(O);return{width:n?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:n?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:n}}function f(i,O,$,E){const n=[];let d=!1;for(const y of O.points){if(y.px===void 0){d=!1;continue}n.push(d?"L":"M",y.px,y.py),d=!0}p(i.next("path",`${G}__line ${G}__mark`),{d:n.length?L(n):"",stroke:$,"data-series":O.index,"stroke-width":E.width,"stroke-dasharray":E.dash,opacity:E.opacity});for(const y of O.points)y.px!==void 0&&p(i.next("circle",`${G}__point ${G}__mark`),{cx:y.px,cy:y.py,r:3,fill:$})}function e(i,O){const $=[];for(const E of i)for(const n of E.points)$.push(n.y);return a($,{zero:O})}function x(i){const O=i.series[0];if(!O)return i;const $=O.points.map((y,r)=>({point:y,label:i.labels[r],category:i.categories[r]})).filter(y=>N(y.point.y)).sort((y,r)=>r.point.y-y.point.y),E=$.reduce((y,r)=>y+r.point.y,0);let n=0;const d=$.map(y=>(n+=y.point.y,E>0?n/E*100:0));return{...i,categories:$.map(y=>y.category),labels:$.map(y=>y.label),series:[{...O,index:0,mark:"bar",axis:"left",points:$.map(y=>y.point)},{key:"cumulative",label:i.cumulativeLabel||"%",index:1,mark:"line",axis:"right",points:$.map((y,r)=>({x:y.category,xKey:y.point.xKey,label:y.label,y:d[r],rows:y.point.rows,rowKey:y.point.rowKey}))}]}}function S(i,O,$){const E=[O.left,O.right];if(i.kind!=="time"&&i.kind!=="linear")return _(i.categories,E,.2);const n=i.kind==="time"?i.categories.map(R):i.categories.map(g);if(i.kind==="time"){const r=k(n);if(r&&r.min===r.max)return v(W({min:r.min-3e4,max:r.max+3e4},i,$),E)}const d=i.xDomain||a(n,{zero:!1,nice:i.kind!=="time"}),y=i.xDomain?d:W(d,i,$);return i.kind==="time"?v(y,E):b(y,E)}function P(i,O){const $=[...new Set(i.filter(r=>Number.isFinite(r)))].sort((r,u)=>r-u);if($.length<2){const[r,u]=O.range;return Math.max(4,(u-r)/10)}const E=[];for(let r=1;r<$.length;r++)E.push($[r]-$[r-1]);E.sort((r,u)=>r-u);const n=Math.floor(E.length/2),d=E.length%2?E[n]:(E[n-1]+E[n])/2,y=Math.abs(O.of($[0]+d)-O.of($[0]));return Math.max(1,y*.8)}function w(i){const O=i.scheme||J(),{plot:$}=i,E=i.pareto?x(i.bound):i.bound,n=E.series.filter(ge=>!i.hidden.has(ge.key)),d=t(n),y=d.left.some(ge=>(ge.mark||"bar")==="bar"),r=E.yDomain||e(d.left,y),u=b(r,[$.bottom,$.top]),h=d.right.length?i.pareto?{min:0,max:100}:e(d.right,!1):null,M=h?b(h,[$.bottom,$.top]):null,A=S(E,$,i.axis&&i.axis.x),C=A.kind!=="band",Y=C?E.categories.map(ge=>E.kind==="time"?R(ge):g(ge)):null;ne({gridGroup:i.groups.grid,axisGroup:i.groups.axis,plot:$,scale:u,format:D(i.grid,{kind:"linear",step:(r.max-r.min)/5})});const ee=E.dimension&&E.dimension.col?i.grid.columns.get(E.dimension.col):void 0;C?le({group:i.groups.overlay,plot:$,scale:A,format:D(i.grid,{kind:E.kind,span:A.domain.max-A.domain.min,step:(A.domain.max-A.domain.min)/5},ee),grid:i.grid,size:i.fontSize}):l({group:i.groups.overlay,plot:$,scale:A,labels:E.labels,fontSize:i.fontSize,rotated:I(E.labels,A.step,i.fontSize)}),X({group:i.groups.rules,plot:$}),M&&s({group:i.groups.axis,plot:$,scale:M,colour:O.series(d.right[0].index),format:D(i.grid,{kind:"linear",step:(h.max-h.min)/5}),suffix:i.pareto?"%":""}),Z(i.groups,$,he(i.type));const ue=new V(i.groups.marks),we=n.filter(ge=>(ge.mark||"bar")==="bar"),Oe=C?P(Y,A):A.bandwidth,ke=we.length?Oe/we.length:Oe;let $e=0;const je=[];for(const ge of n){const Ae=ge.mark||"bar",Me=ge.axis==="right"&&M?M:u,Ne=O.series(ge.index);if(Ae==="bar"){const We=$e*ke;$e++;const Ue=Me.of(Math.max(Me.domain.min,0));for(let He=0;He<ge.points.length;He++){const Pe=ge.points[He];if(!N(Pe.y))continue;let Re;if(C){const tt=E.kind==="time"?R(Pe.x):g(Pe.x);Re=tt===null?NaN:A.of(tt)-Oe/2}else Re=A.of(Pe.x);if(Number.isNaN(Re))continue;const Ye=Me.of(Pe.y);p(ue.next("rect",`${G}__bar ${G}__mark`),{x:B(Re+We),y:B(Math.min(Ye,Ue)),width:B(Math.max(0,ke)),height:B(Math.max(1,Math.abs(Ue-Ye))),fill:Ne,"data-series":ge.index,"data-point":He}),Pe.px=B(Re+We+ke/2),Pe.py=B(Math.min(Ye,Ue))}continue}const Be=[];let Fe=!1;for(const We of ge.points){if(!N(We.y)){Fe=!1;continue}let Ue;if(C){const Pe=E.kind==="time"?R(We.x):g(We.x);Ue=Pe===null?NaN:B(A.of(Pe))}else Ue=B(A.centre(We.x));if(Number.isNaN(Ue)){Fe=!1;continue}const He=B(Me.of(We.y));Be.push(Fe?"L":"M",Ue,He),Fe=!0,We.px=Ue,We.py=He}const De=c(i,ge.label);De.emphasized?je.push({series:ge,colour:Ne,style:De}):f(ue,ge,Ne,De)}for(const ge of je)f(ue,ge.series,ge.colour,ge.style);ue.finish(),i.labels&&i.labels.show&&ce({group:i.groups.labels,series:n,plot:$,options:i.labels,grid:i.grid,size:i.typography&&i.typography.small||i.fontSize});let xe=null;return i.annotations&&i.annotations.length&&(xe=z({group:i.groups.overlay,plot:$,xScale:A,yScale:u,rightScale:M,series:n,annotations:i.annotations,dual:!!M,format:D(i.grid,{kind:"linear",step:(r.max-r.min)/5}).tick})),{xScale:A,yScale:u,rightScale:M,dual:!!M,series:n,bound:E,annotations:xe}}function s(i){const{group:O,plot:$,scale:E,format:n}=i,d=i.side==="left"?"left":"right",y=d==="right"?$.right:$.left,r=new V(O);p(r.next("line",`${G}__axis-right`),{x1:B(y),x2:B(y),y1:B($.top),y2:B($.bottom),stroke:i.colour});for(const u of E.ticks(5)){const h=B(E.of(u)),M=r.next("text",`${G}__tick`);p(M,{x:B(d==="right"?$.right+6:$.left-6),y:h,"text-anchor":d==="right"?"start":"end","dominant-baseline":"middle",fill:i.colour}),M.textContent=`${n.tick(u)}${i.suffix||""}`}r.finish()}}),Le("packages/modules/charts/quantile.js",function(o,oe){"use strict";Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return V}});const me=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),X=3e-12,l=1e-300;function le(I){if(I<.5)return Math.log(Math.PI/Math.sin(Math.PI*I))-le(1-I);const U=I-1;let D=.9999999999998099;const T=U+7.5;for(let _=0;_<me.length;_++)D+=me[_]/(U+_+1);return .5*Math.log(2*Math.PI)+(U+.5)*Math.log(T)-T+Math.log(D)}function ne(I,U,D){const T=I+U,_=I+1,k=I-1;let N=1,b=1-T*D/_;Math.abs(b)<l&&(b=l),b=1/b;let a=b;for(let v=1;v<=300;v++){const g=2*v;let R=v*(U-v)*D/((k+g)*(I+g));b=1+R*b,Math.abs(b)<l&&(b=l),N=1+R/N,Math.abs(N)<l&&(N=l),b=1/b,a*=b*N,R=-(I+v)*(T+v)*D/((I+g)*(_+g)),b=1+R*b,Math.abs(b)<l&&(b=l),N=1+R/N,Math.abs(N)<l&&(N=l),b=1/b;const F=b*N;if(a*=F,Math.abs(F-1)<X)break}return a}function he(I,U,D){if(!(I>0)||!(U>0)||!Number.isFinite(D))return Number.NaN;if(D<=0)return 0;if(D>=1)return 1;const T=Math.exp(le(I+U)-le(I)-le(U)+I*Math.log(D)+U*Math.log(1-D));return D<(I+1)/(I+U+2)?T*ne(I,U,D)/I:1-T*ne(U,I,1-D)/U}function W(I){const U=Math.abs(I),D=2/(2+U),T=4*D-2,_=[-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 k=0,N=0,b;for(let v=_.length-1;v>0;v--)b=N,N=T*N-k+_[v],k=b;const a=D*Math.exp(-U*U+.5*(_[0]+T*N)-k);return I>=0?a:2-a}function Z(I){if(!(I>0)||!(I<1))return I===0?-1/0:I===1?1/0:Number.NaN;const U=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],D=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],T=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],_=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],k=.02425;let N,b,a;I<k?(N=Math.sqrt(-2*Math.log(I)),a=(((((T[0]*N+T[1])*N+T[2])*N+T[3])*N+T[4])*N+T[5])/((((_[0]*N+_[1])*N+_[2])*N+_[3])*N+1)):I<=1-k?(N=I-.5,b=N*N,a=(((((U[0]*b+U[1])*b+U[2])*b+U[3])*b+U[4])*b+U[5])*N/(((((D[0]*b+D[1])*b+D[2])*b+D[3])*b+D[4])*b+1)):(N=Math.sqrt(-2*Math.log(1-I)),a=-(((((T[0]*N+T[1])*N+T[2])*N+T[3])*N+T[4])*N+T[5])/((((_[0]*N+_[1])*N+_[2])*N+_[3])*N+1));const g=(.5*W(-a/Math.SQRT2)-I)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-g/(1+a*g/2)}function fe(I,U){if(!(U>0)||!Number.isFinite(I))return Number.NaN;const D=.5*he(U/2,.5,U/(U+I*I));return I>0?1-D:D}function V(I,U){if(!(I>0)||!(I<1)||!(U>0))return Number.NaN;if(U>1e7)return Z(I);let D=-1e4,T=1e4,_=Z(I);const k=le(U/2)+le(.5)-le((U+1)/2);for(let N=0;N<60;N++){const b=fe(_,U);b<I?D=_:T=_;const a=Math.exp(-((U+1)/2)*Math.log(1+_*_/U)-k)/Math.sqrt(U),v=a>0?(b-I)/a:0;if(Math.abs(v)<1e-12)break;const g=_-v;if(_=g>D&&g<T&&Number.isFinite(g)?g:(D+T)/2,T-D<1e-12)break}return _}}),Le("packages/modules/charts/trendline.js",function(o,oe){"use strict";Object.defineProperty(o,"normaliseTrends",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"linearTrend",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"movingAverageTrend",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"exponentialTrend",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"computeTrend",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"trendText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"drawTrendlines",{enumerable:!0,get:function(){return f}});const X=oe("packages/modules/charts/frame.js").Pool,l=oe("packages/modules/charts/svg.js"),le=l.attrs,ne=l.path,he=l.ribbonPath,W=l.round,Z=l.setText,fe=l.SVG_NS,I=oe("packages/modules/charts/typography.js").applySize,D=oe("packages/modules/charts/styles.js").NS,T=oe("packages/modules/charts/scale.js"),_=T.toNumber,k=T.toTime,b=oe("packages/modules/charts/quantile.js").studentTQuantile,v=oe("packages/modules/charts/format.js").r2Digits,g={linear:new Set(["linear","lr","ols","regression","least-squares"]),movingAverage:new Set(["movingaverage","moving-average","ma","sma","rolling"]),exponential:new Set(["exponential","exp","ewma","ses","holt","smoothing"])},R=1e-4,F=1-1e-4;function p(e){const x=String(e||"linear").toLowerCase();return g.linear.has(x)?"linear":g.movingAverage.has(x)?"movingAverage":g.exponential.has(x)?"exponential":null}function L(e){if(!e)return[];const x=Array.isArray(e)?e:[e],S=[];for(const P of x){if(P===!0){S.push({method:"linear"});continue}if(typeof P=="string"){const w=p(P);w&&S.push({method:w});continue}if(P&&typeof P=="object"){const w=p(P.method);w&&S.push({...P,method:w})}}return S}function B(e,x){if(e.kind==="band")return e.centre(x);const S=e.kind==="time"?k(x):_(x);return S===null?NaN:e.of(S)}function H(e){const x=[];for(const S of e.points){const P=Number(S.y);x.push({value:Number.isFinite(P)?P:null,rawX:S.x})}return x}function G(e,x){const S=[];for(const P of e.points){const w=x.kind==="time"?k(P.x):_(P.x),s=Number(P.y);w===null||!Number.isFinite(w)||!Number.isFinite(s)||S.push({x:w,y:s})}return S.sort((P,w)=>P.x-w.x),S}function ae(e,x,S={}){const P=e.length;if(P<2)return null;let w=0,s=0;for(const Y of e)w+=Y.x,s+=Y.y;w/=P,s/=P;let i=0,O=0,$=0;for(const Y of e){const ee=Y.x-w,ue=Y.y-s;i+=ee*ee,O+=ee*ue,$+=ue*ue}if(i===0)return null;const E=O/i,n=s-E*w,d=$===0?1:Math.max(0,Math.min(1,O*O/(i*$))),y=e[0].x,r=e[P-1].x,u=Y=>({x:Y,y:n+E*Y}),h=[u(y),u(r)],M=[];let A=null;const C=Math.max(0,Math.floor(Number(x)||0));if(C>0&&r>y){const Y=(r-y)/(P-1);if(Y>0&&(M.push(u(r),u(r+C*Y)),P>2)){const ee=Number.isFinite(S.confidence)&&S.confidence>0&&S.confidence<1?Number(S.confidence):.95,ue=1-(1-ee)/2,we=Math.max(0,$-E*O),Oe=Math.sqrt(we/(P-2)),ke=b(ue,P-2),$e=[];for(let je=0;je<=C;je++){const xe=r+je*Y,ge=n+E*xe,Ae=1/P+(xe-w)**2/i,Me=Oe*Math.sqrt(1+Ae),Ne=Oe*Math.sqrt(Ae);$e.push({x:xe,mean:ge,lower:ge-ke*Me,upper:ge+ke*Me,lowerMean:ge-ke*Ne,upperMean:ge+ke*Ne})}A={confidence:ee,points:$e}}}return{fit:h,forecast:M,band:A,stats:{method:"linear",slope:E,intercept:n,r2:d,n:P,forecast:M.length?C:0,confidence:A?A.confidence:null}}}function J(e,x){const S=Math.max(1,Math.floor(Number(x)||3)),P=[];let w=0;const s=[];for(const i of e)Number.isFinite(i.value)&&(P.push(i.value),w+=i.value,P.length>S&&(w-=P.shift())),P.length&&s.push({x:i.rawX,y:w/P.length});return s.length<2?null:{fit:s,stats:{method:"movingAverage",window:S}}}function q(e,x){const S=e.length,P=new Array(S).fill(null);let w=null,s=0;for(let i=0;i<S;i++){const O=e[i];if(!Number.isFinite(O)){w!==null&&(P[i]=w);continue}if(w===null){w=O,P[i]=O;continue}s+=(O-w)**2,w=x*O+(1-x)*w,P[i]=w}return{smoothed:P,sse:s}}function ce(e,x,S){const P=e.length,w=new Array(P).fill(null);let s=null,i=null,O=0;for(let $=0;$<P;$++){const E=e[$];if(!Number.isFinite(E)){s!==null&&(s+=i,w[$]=s);continue}if(s===null){s=E,w[$]=E;continue}if(i===null){i=E-s;const y=s+i;O+=(E-y)**2;const r=s;s=x*E+(1-x)*(r+i),i=S*(s-r)+(1-S)*i,w[$]=s;continue}const n=s+i;O+=(E-n)**2;const d=s;s=x*E+(1-x)*(d+i),i=S*(s-d)+(1-S)*i,w[$]=s}return{smoothed:w,sse:O}}function j(e,x,S,P=80){const w=(Math.sqrt(5)-1)/2;let s=x,i=S,O=i-w*(i-s),$=s+w*(i-s),E=e(O),n=e($);for(let d=0;d<P;d++)E<n?(i=$,$=O,n=E,O=i-w*(i-s),E=e(O)):(s=O,O=$,E=n,$=s+w*(i-s),n=e($));return(s+i)/2}function z(e,x){const S=String(x.kind||x.model||"").toLowerCase()==="holt",P=e.map(n=>Number.isFinite(n.value)?n.value:null);if(P.filter(n=>n!==null).length<(S?2:1))return null;const s=n=>Math.min(F,Math.max(R,n));let i=Number.isFinite(x.alpha)?s(Number(x.alpha)):null,O=S&&Number.isFinite(x.beta)?s(Number(x.beta)):null;if(S){if(i===null||O===null){let n=i===null?.5:i,d=O===null?.5:O;for(let y=0;y<6;y++)i===null&&(n=j(r=>ce(P,r,d).sse,R,F)),O===null&&(d=j(r=>ce(P,n,r).sse,R,F));i=i===null?n:i,O=O===null?d:O}}else i===null&&(i=j(n=>q(P,n).sse,R,F));const $=S?ce(P,i,O):q(P,i),E=[];for(let n=0;n<e.length;n++){const d=$.smoothed[n];d===null||!Number.isFinite(d)||E.push({x:e[n].rawX,y:d})}return E.length<2?null:{fit:E,stats:{method:"exponential",kind:S?"holt":"ses",alpha:i,beta:S?O:null}}}function t(e,x,S){if(x.method==="linear"){const w=G(e,S);return ae(w,x.forecast,{confidence:x.confidence})}const P=H(e);return x.method==="movingAverage"?J(P,x.window||x.period):z(P,x)}function c(e,x,S,P,w,s){const i=x?` for ${x}`:"";if(e.method==="linear"){const n=Number.isFinite(e.r2)?`, R² ${e.r2.toFixed(2)}`:"";let d=`Trend (linear)${i}: slope ${S(e.slope)}${n}`;if(e.forecast>0&&P&&P.length){const y=P[P.length-1];if(d+=`; forecast ${e.forecast} step${e.forecast===1?"":"s"} ahead to ${S(y.y)}`,w&&w.points.length){const r=w.points[w.points.length-1],u=s==="confidence"||s==="mean",h=u?r.lowerMean:r.lower,M=u?r.upperMean:r.upper,A=u?"confidence":"prediction",C=Math.round(w.confidence*100);d+=`; ${C}% ${A} band ${S(h)} to ${S(M)} at the horizon`}}return d}if(e.method==="movingAverage")return`Trend (moving average, window ${e.window})${i}`;const O=e.kind==="holt"?"Holt":"single",$=Number.isFinite(e.alpha)?`, α ${e.alpha.toFixed(2)}`:"",E=Number.isFinite(e.beta)?`, β ${e.beta.toFixed(2)}`:"";return`Trend (exponential, ${O})${i}${$}${E}`}function f(e){const x=L(e.trend);if(!x.length)return[];const S=e.group.ownerDocument;let P=null;for(const i of e.group.childNodes||[])if(i&&String(i.getAttribute&&i.getAttribute("class"))===`${D}__trends`){P=i;break}P||(P=S.createElementNS(fe,"g"),P.setAttribute("class",`${D}__trends`),e.group.appendChild(P)),e.clip?P.setAttribute("clip-path",`url(#${e.clip})`):P.removeAttribute("clip-path");const w=new X(P),s=[];for(const i of x)for(const O of e.series){const $=O.axis==="right"&&e.rightScale?e.rightScale:e.yScale,E=t(O,i,e.xScale);if(!E)continue;const n=e.scheme.series(O.index),d=[];for(const u of E.fit){const h=B(e.xScale,u.x),M=$.of(u.y);!Number.isFinite(h)||!Number.isFinite(M)||d.push(d.length?"L":"M",W(h),W(M))}if(d.length<4)continue;if(le(w.next("path",`${D}__trend`),{d:ne(d),fill:"none",stroke:n,"data-series":O.index}),i.band!==!1&&E.band&&E.band.points.length>=2){const u=i.band==="confidence"||i.band==="mean",h=[];for(const A of E.band.points){const C=B(e.xScale,A.x),Y=u?A.lowerMean:A.lower,ee=u?A.upperMean:A.upper,ue=$.of(Y),we=$.of(ee);!Number.isFinite(C)||!Number.isFinite(ue)||!Number.isFinite(we)||h.push({x:W(C),lower:W(ue),upper:W(we)})}const M=he(h);M&&le(w.next("path",`${D}__trend-band`),{d:M,fill:n,"fill-opacity":.15,stroke:"none","data-series":O.index})}const r=E.forecast||[];if(r.length>=2){const u=[];for(const h of r){const M=B(e.xScale,h.x),A=$.of(h.y);!Number.isFinite(M)||!Number.isFinite(A)||u.push(u.length?"L":"M",W(M),W(A))}u.length>=4&&le(w.next("path",`${D}__trend-forecast`),{d:ne(u),fill:"none",stroke:n,"data-series":O.index})}if(i.label!==!1&&E.stats.method==="linear"&&Number.isFinite(E.stats.r2)){const u=E.fit[E.fit.length-1],h=w.next("text",`${D}__trend-label`);I(h,e.size),le(h,{x:W(B(e.xScale,u.x)),y:W($.of(u.y))-4,"text-anchor":"end",fill:n}),Z(h,e.grid.messages.t("chart.r2",{value:v(e.grid,E.stats.r2)}))}s.push({text:c(E.stats,O.label,e.format,r,i.band===!1?null:E.band,i.band)})}return w.finish(),s.filter(i=>i.text)}}),Le("packages/modules/charts/rulecolour.js",function(o,oe){"use strict";Object.defineProperty(o,"colourOf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"ruleColour",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"ruleLegend",{enumerable:!0,get:function(){return le}});const me="*";function X(ne){if(!ne||typeof ne!="object")return null;for(const he of["background","backgroundColor","color"]){const W=ne[he];if(typeof W=="string"&&W.trim())return W.trim()}return null}function l(ne){const{grid:he,col:W,value:Z}=ne;if(!he||!W||!he.formatting||typeof he.formatting.styleFor!="function")return null;try{return X(he.formatting.styleFor(W,Z))}catch{return null}}function le(ne){const{grid:he,col:W}=ne,Z=new Set([...ne.colours||[]].filter(Boolean));if(!Z.size||!he||!he.formatting||typeof he.formatting.list!="function")return[];let fe;try{fe=[...he.formatting.list(me)||[],...W?he.formatting.list(W)||[]:[]]}catch{return[]}const V=[],I=new Set;for(const U of fe){if(!U||U.enabled===!1)continue;const D=X(U.style);!D||!Z.has(D)||I.has(D)||(I.add(D),V.push({key:U.id||`rule:${V.length}`,label:U.label||U.id||D,colour:D,index:V.length}))}return V}}),Le("packages/modules/charts/cartesian.js",function(o,oe){"use strict";Object.defineProperty(o,"CARTESIAN",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"axisWindowSpan",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"axisWindowNow",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(o,"rollingDomain",{enumerable:!0,get:function(){return je}}),Object.defineProperty(o,"WINDOW_LEAD",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"aheadOfWindow",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"staleWindow",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"windowedBound",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"slotPadFor",{enumerable:!0,get:function(){return De}}),Object.defineProperty(o,"pinnedContinuousX",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return He}}),Object.defineProperty(o,"bandedX",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(o,"dataInterval",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"continuousSlot",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"xDomainFor",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(o,"xScaleFor",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"drawFits",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"drawConfidenceBand",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"drawBoundErrorBars",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"drawForest",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(o,"drawReferenceLines",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"drawCartesian",{enumerable:!0,get:function(){return Kt}}),Object.defineProperty(o,"HIT_TOLERANCE",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"nearestDrawnPoint",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(o,"nearestCategory",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(o,"categoryKeyAt",{enumerable:!0,get:function(){return Jt}});const me=oe("packages/modules/charts/axis.js"),X=me.drawAxisLines,l=me.drawAxisTitle,le=me.drawBandLabels,ne=me.drawCategoryAxis,he=me.drawContinuousAxis,W=me.drawMeasureAxis,Z=me.overhangFor,fe=me.pinXDomain,V=me.setPlotClip,I=oe("packages/modules/charts/frame.js"),U=I.Pool,D=I.shouldRotate,T=oe("packages/modules/charts/format.js"),_=T.formatters,k=T.r2Digits,N=oe("packages/modules/charts/scale.js"),b=N.bandScale,a=N.extent,v=N.isNumber,g=N.key,R=N.linearScale,F=N.measureDomain,p=N.timeScale,L=N.toNumber,B=N.toTime,H=oe("packages/modules/charts/svg.js"),G=H.attrs,ae=H.path,J=H.ribbonPath,q=H.round,ce=H.setText,j=H.SVG_NS,t=oe("packages/modules/charts/styles.js").NS,f=oe("packages/modules/charts/labels.js").drawDataLabels,x=oe("packages/modules/charts/dense.js").downsample,P=oe("packages/modules/charts/scheme.js").resolveScheme,s=oe("packages/modules/charts/typography.js").applySize,O=oe("packages/modules/charts/combo.js").drawRightAxis,$=oe("packages/modules/charts/annotations.js"),E=$.drawAnnotations,n=$.overlayLayer,y=oe("packages/modules/charts/trendline.js").drawTrendlines,r=oe("packages/modules/charts/rulecolour.js"),u=r.ruleColour,h=r.ruleLegend,A=oe("packages/core/src/internal/util.js").warnOnce,C=3.5,Y=Object.freeze({line:{zero:!1,marks:"path"},step:{zero:!1,marks:"path"},area:{zero:!0,marks:"path"},rangeArea:{zero:!1,marks:"path"},bar:{zero:!0,marks:"rect"},horizontalBar:{zero:!0,marks:"rect",horizontal:!0},waterfall:{zero:!0,marks:"rect"},scatter:{zero:!1,marks:"circle"},bubble:{zero:!1,marks:"circle"},candlestick:{zero:!1,marks:"rect"}});function ee(m){const te=[];for(let K=0;K<m.length;K++){const Q=m[K];if(K===0){te.push("M",Q.x,Q.y);continue}te.push("L",Q.x,m[K-1].y),te.push("L",Q.x,Q.y)}return te}function ue(m,te,K){if(K)return[0,100];if(!te){const se=[];for(const be of m)for(const de of be.points)se.push(de.y);return se}const Q=[],re=[],ie=m[0]?m[0].points.length:0;for(let se=0;se<ie;se++){let be=0,de=0;for(const pe of m){const ye=pe.points[se]?pe.points[se].y:null;v(ye)&&(ye>=0?be+=ye:de+=ye)}Q.push(be),re.push(de)}return[...Q,...re]}function we(m){const te=[0];if(!m)return te;let K=0;for(const Q of m.points)v(Q.y)&&(K+=Q.y,te.push(K));return te}function Oe(m,te){const K=new Float64Array(m),Q=new Float64Array(m);return{take(re,ie){const se=te?te[re]:0,be=te?se?ie/se*100:0:ie;if(be>=0){const pe=K[re];return K[re]+=be,[pe,K[re]]}const de=Q[re];return Q[re]+=be,[de,Q[re]]}}}function ke(m){const te=m&&m.window;if(!te||typeof te!="object")return 0;const K=Number(te.span);return!Number.isFinite(K)||K<=0?0:te.kind!=="time"?(A("chart.axis.window.kind",`axis window kind "${te.kind}" is not supported on a chart axis; only { kind: "time", span } rolls the domain. Bound the row count with the source's maxRows instead.`),0):K}function $e(m,te){const K=m&&m.window;if(!K||typeof K!="object"||typeof K.now!="function")return te;const Q=Number(K.now());return Number.isFinite(Q)?Q:(A("chart.axis.window.now","axis.x.window.now did not return a time, so the rolling window is measured from this device's clock instead. It must return epoch milliseconds — the same number Date.now() returns — because that is what the x values are compared against."),te)}function je(m,te,K){const Q=K+m*xe;let re=K;for(const ie of te)Number.isFinite(ie)&&ie>re&&ie<=Q&&(re=ie);return{min:re-m,max:re}}const xe=.25;function ge(m,te,K){const Q=ke(te);if(!Q||!m||!Array.isArray(m.categories))return null;const re=Y[K];if(!re||re.horizontal||m.kind==="category"||K==="bar"&&!He(m,K,te))return null;const ie=m.categories.map(se=>m.kind==="time"?B(se):L(se));return{span:Q,values:ie}}function Ae(m,te,K,Q){const re=ge(m,te,K);if(!re)return null;const ie=re.span*xe;let se=0,be=0;for(const de of re.values)de===null||!Number.isFinite(de)||de-Q<=ie||(se+=1,de-Q>be&&(be=de-Q));return se?{span:re.span,limit:ie,count:se,lead:be}:null}function Me(m,te,K,Q){const re=ge(m,te,K);if(!re)return null;const{span:ie}=re,se=re.values.filter(ye=>ye!==null&&Number.isFinite(ye));if(!se.length)return null;const{min:be,max:de}=je(ie,se,Q);let pe=-1/0;for(const ye of se){if(ye>=be&&ye<=de)return null;ye<be&&ye>pe&&(pe=ye)}return pe===-1/0?{span:ie,newest:null,age:null,points:se.length}:{span:ie,newest:pe,age:Q-pe,points:se.length}}function Ne(m,te,K,Q){const re=ge(m,te,K);if(!re)return m;const{span:ie,values:se}=re,be=se.filter(ve=>ve!==null&&Number.isFinite(ve));if(!be.length)return m;const{min:de,max:pe}=je(ie,be,Q),ye=[];for(let ve=0;ve<se.length;ve++){const _e=se[ve];(_e===null||!Number.isFinite(_e)||_e>=de&&_e<=pe)&&ye.push(ve)}return ye.length===se.length?m:{...m,categories:ye.map(ve=>m.categories[ve]),labels:Array.isArray(m.labels)?ye.map(ve=>m.labels[ve]):m.labels,series:(m.series||[]).map(ve=>({...ve,points:Array.isArray(ve.points)?ye.map(_e=>ve.points[_e]).filter(_e=>_e!==void 0):ve.points})),windowed:se.length-ye.length}}const Be=Object.freeze({bar:.2,candlestick:.3}),Fe=.4;function De(m){return Object.hasOwn(Be,m)?Be[m]:Fe}const We=new Set(["bar","candlestick"]);function Ue(m){const te=m&&typeof m.scale=="string"?m.scale:"";return te==="time"||te==="linear"}function He(m,te,K){if(!m||m.kind==="category")return!1;const Q=Y[te];return Q&&Q.horizontal?!1:We.has(te)?Ue(K):!0}function Pe(m,te,K){return!He(m,te,K)}function Re(m){const te=m.filter(re=>typeof re=="number"&&Number.isFinite(re)).slice().sort((re,ie)=>re-ie),K=[];for(let re=1;re<te.length;re++){const ie=te[re]-te[re-1];ie>0&&K.push(ie)}if(!K.length)return 0;K.sort((re,ie)=>re-ie);const Q=Math.floor(K.length/2);return K.length%2?K[Q]:(K[Q-1]+K[Q])/2}function Ye(m){const{bound:te,scale:K,config:Q,padding:re}=m,ie=Q?Number(Q.barWidth):NaN,se=Number.isFinite(ie)&&ie>0,be=(te.categories||[]).map(ve=>te.kind==="time"?B(ve):L(ve)),de=se?ie:Re(be),pe=Math.abs(K.range[1]-K.range[0]);if(!de)return Math.max(1,pe/20*(1-re));const ye=Math.abs(K.of(K.domain.min+de)-K.of(K.domain.min));return Math.max(1,se?ye:ye*(1-re))}function tt(m,te,K,Q){if(Pe(m,te,K))return null;const re=ke(K),ie=m.kind==="time"?m.categories.map(B):m.categories.map(L);if(m.kind==="time"&&!re){const be=a(ie);if(be&&be.min===be.max)return fe({min:be.min-3e4,max:be.max+3e4},m,K)}const se=re?je(re,ie,Number.isFinite(Q)?Q:$e(K,Date.now())):F(ie,{zero:!1,nice:m.kind!=="time"});return fe(se,m,K)}function ft(m,te,K,Q){const re=[te.left,te.right];if(Pe(m,K,Q))return ke(Q)&&A("chart.axis.window.band","a rolling time window needs a continuous x axis; this chart bands its x values, so the window is ignored. Bind a date or numeric column to x, or put this type on a continuous axis with axis.x.scale."),b(m.categories,re,De(K));const ie=m.xDomain||tt(m,K,Q);return m.kind==="time"?p(ie,re):R(ie,re)}function ut(m,te){if(m.kind==="band")return m.centre(te.x);const K=m.kind==="time"?B(te.x):L(te.x);return K===null?NaN:m.of(K)}function It(m,te){const K=m&&m.seriesStyle&&m.seriesStyle[te];if(K)return{width:K.width!=null?String(K.width):null,dash:Array.isArray(K.dash)&&K.dash.length?K.dash.join(" "):null,opacity:null,emphasized:!1};const Q=m&&Array.isArray(m.emphasis)?m.emphasis:null;if(!Q||!Q.length)return{width:null,dash:null,opacity:null,emphasized:!1};const re=Q.includes(te);return{width:re?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:re?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:re}}function St(m){const{series:te,xScale:K,yScale:Q,baseline:re,fill:ie,colour:se,stack:be,style:de}=m,pe=[],ye=[];let ve=!1;const _e=[];for(let Se=0;Se<te.points.length;Se++){const Je=te.points[Se],Ge=q(ut(K,Je));if(!v(Je.y)||Number.isNaN(Ge)){ve=!1;continue}_e[Se]=!0;const Ze=Je.y,ze=be?be.take(Se,Ze):null,qe=q(Q.of(ze?ze[1]:Ze)),Xe=q(Q.of(ze?ze[0]:re));m.step&&ve&&pe.push("L",Ge,m.previous),pe.push(ve?"L":"M",Ge,qe),m.previous=qe,ie&&ye.push(ve?"L":"M",Ge,qe),ie&&!ve&&ye.push("M",Ge,qe),ve=!0,Je.px=Ge,Je.py=qe,Je.pbase=Xe}if(G(m.pool.next("path",`${t}__line ${t}__mark`),{d:pe.length?ae(pe):"",stroke:se,"data-series":m.index,"stroke-width":de?de.width:null,"stroke-dasharray":de?de.dash:null,opacity:de?de.opacity:null}),!ie){$t({...m,placed:_e});return}const Ee=[];let Ce=[];const Ke=()=>{if(Ce.length<2){Ce=[];return}Ee.push("M",Ce[0].x,Ce[0].base);for(const Se of Ce)Ee.push("L",Se.x,Se.y);for(let Se=Ce.length-1;Se>=0;Se--)Ee.push("L",Ce[Se].x,Ce[Se].base);Ee.push("Z"),Ce=[]};for(const Se of te.points){if(!v(Se.y)||Se.px===void 0){Ke();continue}Ce.push({x:Se.px,y:Se.py,base:Se.pbase})}Ke(),G(m.pool.next("path",`${t}__area ${t}__mark`),{d:Ee.length?ae(Ee):"",fill:se,"data-series":m.index,opacity:de?de.emphasized?"1":de.opacity:null}),$t({...m,placed:_e})}function $t(m){const{series:te,placed:K}=m;for(let Q=0;Q<te.points.length;Q++){if(!K[Q]||K[Q-1]||K[Q+1])continue;const re=te.points[Q];G(m.pool.next("circle",`${t}__point ${t}__mark`),{cx:re.px,cy:re.py,r:C,fill:m.colour,"data-series":m.index,"data-point":Q})}}function st(m,te){const K=m&&m.range;if(!Array.isArray(K)||K.length!==2)return te;const[Q,re]=K;return!Number.isFinite(Q)||!Number.isFinite(re)||!Number.isFinite(te)?te:Math.min(Math.max(Q,re),Math.max(Math.min(Q,re),te))}function Bt(m){const{series:te,xScale:K,yScale:Q,baseline:re,colour:ie,stack:se,slot:be}=m;for(let de=0;de<te.points.length;de++){const pe=te.points[de];if(!v(pe.y))continue;const ye=K.kind==="band"?K.of(pe.x):ut(K,pe)-be.span/2;if(Number.isNaN(ye))continue;const ve=pe.y,_e=m.pointColour&&m.pointColour(pe)||ie,Ee=se?se.take(de,ve):[re,ve],Ce=st(Q,Q.of(Ee[1])),Ke=st(Q,Q.of(Ee[0])),Se=ye+be.offset,Je=K.kind==="band"?Se:st(K,Se),Ge=K.kind==="band"?Se+be.width:st(K,Se+be.width),Ze=m.pool.next("rect",`${t}__bar ${t}__mark`,`${te.key}:${g(pe.x)}`);G(Ze,{x:q(Je),y:q(Math.min(Ce,Ke)),width:q(Math.max(0,Ge-Je)),height:q(Math.max(1,Math.abs(Ke-Ce))),fill:_e,"data-series":m.index,"data-point":de}),pe.px=q(ye+be.offset+be.width/2),pe.py=q(Math.min(Ce,Ke)),pe.pbase=q(Math.max(Ce,Ke))}}function Wt(m){const{series:te,xScale:K,yScale:Q}=m;let re=0;for(let ie=0;ie<te.points.length;ie++){const se=te.points[ie];if(!v(se.y))continue;const be=se.y,de=ie===te.points.length-1,pe=m.total&&de?0:re,ye=(m.total&&de,re+be);m.total,re+=be;const ve=st(Q,Q.of(Math.max(pe,ye))),_e=st(Q,Q.of(Math.min(pe,ye))),Ee=m.pool.next("rect",`${t}__bar ${t}__mark`,`${te.key}:${g(se.x)}`);G(Ee,{x:q(K.of(se.x)),y:q(ve),width:q(K.bandwidth),height:q(Math.max(1,_e-ve)),fill:be>=0?m.positive:m.negative,"data-series":m.index,"data-point":ie}),se.px=q(K.of(se.x)+K.bandwidth/2),se.py=q(ve)}}function Ht(m){const{series:te,valueScale:K,baseline:Q,colour:re,stack:ie,slot:se}=m;for(let be=0;be<te.points.length;be++){const de=te.points[be];if(!v(de.y))continue;const pe=m.bandScale.of(de.x);if(Number.isNaN(pe))continue;const ye=de.y,ve=m.pointColour&&m.pointColour(de)||re,_e=ie?ie.take(be,ye):[Q,ye],Ee=st(K,K.of(_e[0])),Ce=st(K,K.of(_e[1]));G(m.pool.next("rect",`${t}__bar ${t}__mark`,`${te.key}:${g(de.x)}`),{x:q(Math.min(Ee,Ce)),y:q(pe+se.offset),width:q(Math.max(1,Math.abs(Ce-Ee))),height:q(Math.max(0,se.width)),fill:ve,"data-series":m.index,"data-point":be}),de.px=q(Ce),de.py=q(pe+se.offset+se.width/2),de.pbase=q(Ee)}}function Ot(m){const te=m.group.ownerDocument;let K=null;for(const ie of m.group.childNodes||[])if(ie&&String(ie.getAttribute&&ie.getAttribute("class"))===`${t}__fits`){K=ie;break}K||(K=te.createElementNS(j,"g"),K.setAttribute("class",`${t}__fits`),m.group.appendChild(K));const Q=new U(K),re=[];for(const ie of m.series){let se=0,be=0,de=0;for(const ze of ie.points){const qe=Number(ze.x),Xe=Number(ze.y);!Number.isFinite(qe)||!Number.isFinite(Xe)||(se++,be+=qe,de+=Xe)}if(se<2)continue;const pe=be/se,ye=de/se;let ve=0,_e=0,Ee=0,Ce=1/0,Ke=-1/0;for(const ze of ie.points){const qe=Number(ze.x),Xe=Number(ze.y);if(!Number.isFinite(qe)||!Number.isFinite(Xe))continue;const Qe=qe-pe,dt=Xe-ye;ve+=Qe*Qe,_e+=Qe*dt,Ee+=dt*dt,qe<Ce&&(Ce=qe),qe>Ke&&(Ke=qe)}if(ve===0)continue;const Se=_e/ve,Je=ye-Se*pe,Ge=Ee===0?1:Math.max(0,Math.min(1,_e*_e/(ve*Ee))),Ze=m.scheme.series(ie.index);if(G(Q.next("path",`${t}__fit`),{d:ae(["M",q(m.xScale.of(Ce)),q(m.yScale.of(Je+Se*Ce)),"L",q(m.xScale.of(Ke)),q(m.yScale.of(Je+Se*Ke))]),fill:"none",stroke:Ze,"data-series":ie.index}),m.showR2){const ze=Q.next("text",`${t}__fit-label`);s(ze,m.size),G(ze,{x:q(m.xScale.of(Ke)),y:q(m.yScale.of(Je+Se*Ke))-4,"text-anchor":"end",fill:Ze}),ce(ze,m.grid.messages.t("chart.r2",{value:k(m.grid,Ge)}))}re.push({key:ie.key,slope:Se,intercept:Je,r2:Ge,n:se})}return Q.finish(),re}function jt(m){const te=m.group.ownerDocument;let K=null;for(const pe of m.group.childNodes||[])if(pe&&String(pe.getAttribute&&pe.getAttribute("class"))===`${t}__band`){K=pe;break}K||(K=te.createElementNS(j,"g"),K.setAttribute("class",`${t}__band`),m.group.firstChild?m.group.insertBefore(K,m.group.firstChild):m.group.appendChild(K));const Q=new U(K),re=m.band&&Array.isArray(m.band.points)?m.band.points:[],ie=Number.isFinite(m.index)?Number(m.index):0,se=m.scheme.series(ie),be=Number.isFinite(m.opacity)?Number(m.opacity):.15,de=[];for(const pe of re){const ye=Number(pe.x),ve=Number(pe.lower),_e=Number(pe.upper);if(!Number.isFinite(ye)||!Number.isFinite(ve)||!Number.isFinite(_e))continue;const Ee=Number(pe.yhat);de.push({x:q(m.xScale.of(ye)),lower:q(m.yScale.of(ve)),upper:q(m.yScale.of(_e)),yhat:Number.isFinite(Ee)?q(m.yScale.of(Ee)):null})}if(de.length>=2&&(G(Q.next("path",`${t}__band-fill`),{d:J(de),fill:se,"fill-opacity":be,stroke:"none","data-series":ie}),m.line!==!1)){const pe=[];let ye=!1;for(const ve of de){if(ve.yhat===null){ye=!1;continue}pe.push(ye?"L":"M",ve.x,ve.yhat),ye=!0}G(Q.next("path",`${t}__band-line`),{d:pe.length?ae(pe):"",fill:"none",stroke:se,"data-series":ie})}return Q.finish(),{points:de.length,confidence:m.band&&Number.isFinite(m.band.confidence)?Number(m.band.confidence):null}}function At(m){const te=m.group.ownerDocument;let K=null;for(const de of m.group.childNodes||[])if(de&&String(de.getAttribute&&de.getAttribute("class"))===`${t}__whiskers`){K=de;break}K||(K=te.createElementNS(j,"g"),K.setAttribute("class",`${t}__whiskers`),m.group.appendChild(K));const Q=new U(K),re=Number.isFinite(m.cap)?Number(m.cap):4,ie=m.colour||"currentColor",se=m.orient!=="v";let be=0;for(const de of m.points||[]){const pe=Number(de.main),ye=Number(de.lo),ve=Number(de.hi);if(!Number.isFinite(pe)||!Number.isFinite(ye)||!Number.isFinite(ve))continue;const _e=se?["M",ye,pe,"L",ve,pe,"M",ye,pe-re,"L",ye,pe+re,"M",ve,pe-re,"L",ve,pe+re]:["M",pe,ye,"L",pe,ve,"M",pe-re,ye,"L",pe+re,ye,"M",pe-re,ve,"L",pe+re,ve];G(Q.next("path",`${t}__whisker`),{d:ae(_e),stroke:ie,fill:"none"}),be++}return Q.finish(),be}function Gt(m){const te=m.scheme||P(),K=m.typography||{small:m.fontSize||11,axisTitle:11},{plot:Q,bound:re}=m,ie=re.series[0]&&re.series[0].points||[],se=ie.map(Ee=>Ee.label),be=te.series(0),de=b(se,[Q.top,Q.bottom],.4),pe=[0];for(const Ee of ie)for(const Ce of[Ee.x,Ee.lower,Ee.upper])Number.isFinite(Ce)&&pe.push(Ce);const ye=R(F(pe,{zero:!1}),[Q.left,Q.right]);At({group:m.groups.overlay,orient:"h",colour:be,points:ie.map(Ee=>({main:q(de.centre(Ee.label)),lo:q(ye.of(Ee.lower)),hi:q(ye.of(Ee.upper))}))});const ve=new U(m.groups.marks);let _e=0;for(const Ee of ie)Number.isFinite(Ee.x)&&(G(ve.next("circle",`${t}__point ${t}__mark`),{cx:q(ye.of(Ee.x)),cy:q(de.centre(Ee.label)),r:C,fill:be}),_e++);return ve.finish(),mt({group:m.groups.rules,plot:Q,scale:ye,lines:[{value:0}]}),he({group:m.groups.axis,plot:Q,scale:ye,format:_(m.grid,{kind:"linear",step:(ye.domain.max-ye.domain.min)/5}),config:{},grid:m.grid,size:K.small}),le({group:m.groups.labels,plot:Q,scale:de,labels:se,fontSize:K.small,config:{}}),{series:[],marks:_e}}function mt(m){const te=new U(n(m.group,`${t}__reflines`));for(const K of m.lines||[]){if(!v(K.value))continue;const Q=q(m.scale.of(K.value));if(G(te.next("path",`${t}__reference`),{d:ae(["M",q(m.plot.left),Q,"L",q(m.plot.right),Q]),stroke:K.colour||"currentColor","stroke-dasharray":"4 3",fill:"none"}),!K.label)continue;const re=te.next("text",`${t}__reference-label`);G(re,{x:q(m.plot.right-4),y:Q-4,"text-anchor":"end"}),ce(re,K.label)}te.finish()}function Vt(m){const{series:te,xScale:K,yScale:Q,colour:re}=m,ie=m.size||null;for(let se=0;se<te.points.length;se++){const be=te.points[se];if(!v(be.y))continue;const de=q(ut(K,be));if(Number.isNaN(de))continue;const pe=q(Q.of(be.y));G(m.pool.next("circle",`${t}__point ${t}__mark`),{cx:de,cy:pe,r:ie&&v(be.size)?q(ie.of(be.size)):C,fill:re,"fill-opacity":ie?.7:1,"data-series":m.index,"data-point":se}),be.px=de,be.py=pe}}function Ut(m){const{group:te,series:K,xScale:Q,yScale:re,options:ie}=m,se=m.grid&&m.grid.statistics,be=se&&typeof se.intervalOf=="function"?(Ke,Se)=>se.intervalOf(Ke,Se):null,de=new U(n(te,`${t}__errorbars`)),pe=Number.isFinite(Number(ie.confidence))?Number(ie.confidence):.95,ye=4;let ve=0,_e=0,Ee=0,Ce=0;for(const Ke of K)for(const Se of Ke.points){if(Se.y===null||Se.y===void 0)continue;_e++;const Je=Array.isArray(Se.values)&&Se.values.length===1;Je&&Ee++;let Ge=null,Ze=null;if(ie.of!==void 0&&Number.isFinite(Number(Se[ie.of]))){const Qe=Math.abs(Number(Se[ie.of]));Ge=Se.y-Qe,Ze=Se.y+Qe}else if(Array.isArray(Se.values)&&Se.values.length>1&&be){const Qe=be(Se.values,pe);Qe&&(Ge=Qe.lower,Ze=Qe.upper)}if(Ge===null||!Number.isFinite(Ge)||!Number.isFinite(Ze)){Je&&Ce++;continue}const ze=q(Q.of(Se.xKey!==void 0?Se.xKey:Se.x)+(Q.bandwidth?Q.bandwidth/2:0)),qe=q(re.of(Ze)),Xe=q(re.of(Ge));G(de.next("path",`${t}__error-bar ${t}__mark`),{d:ae(["M",ze-ye,qe,"L",ze+ye,qe,"M",ze,qe,"L",ze,Xe,"M",ze-ye,Xe,"L",ze+ye,Xe]),fill:"none",stroke:"currentColor","data-lower":Ge,"data-upper":Ze}),ve++}return de.finish(),{drawn:ve,marks:_e,single:Ee,singleSkipped:Ce}}function Kt(m){const te=m.scheme||P(),K=m.axis||{x:{},y:{},y2:{}},Q=m.typography||{small:m.fontSize||11,axisTitle:11},{bound:re,plot:ie,type:se}=m,be=Y[se]||Y.line,de=re.series.filter(Te=>!m.hidden.has(Te.key)),pe=!!be.horizontal,ye=!pe&&K.y.position==="right"?"right":"left",ve=ye==="right"?"left":"right",_e=(se==="bar"||se==="horizontalBar")&&m.byRuleColour&&de.length===1&&re.measure&&re.measure.col||null,Ee=_e?new Set:null,Ce=_e?Te=>{const Ie=u({grid:m.grid,col:_e,value:Te.y});return Ie&&Ee.add(Ie),Ie}:null,Se=(se==="bar"||se==="horizontalBar")&&m.byRuleColour&&de.length===1&&te.nameMap?Te=>te.series(0,Te.label):null,Je=Ce||Se?Te=>Ce&&Ce(Te)||Se&&Se(Te)||null:null,Ge=!pe&&se!=="waterfall"?de.filter(Te=>Te.axis==="right"):[],Ze=Ge.length?de.filter(Te=>Te.axis!=="right"):de,ze=Ge.length>0,qe=(se==="bar"||se==="area"||se==="horizontalBar")&&!ze,Xe=m.stack==="percent"&&qe&&Ze.length>1,Qe=(Xe||!!m.stack)&&Ze.length>1&&qe,dt=se==="waterfall"?we(de[0]):ue(Ze,Qe,Xe),at=re.yDomain||m.domain||F(dt,{zero:be.zero,min:K.y.min,max:K.y.max}),rt=pe?R(at,[ie.left,ie.right]):R(at,[ie.bottom,ie.top]),Ve=pe?b(re.categories,[ie.top,ie.bottom],.2):ft(re,ie,se,K.x),wt=at.min<=0&&at.max>=0?0:at.min,Zt=Ge.some(Te=>(Te.mark||(se==="bar"?"bar":se))==="bar"),lt=ze?F(ue(Ge,!1,!1),{zero:Zt,min:K.y2.min,max:K.y2.max}):null,ot=lt?R(lt,[ie.bottom,ie.top]):null,kt=_(m.grid,{kind:"linear",step:(at.max-at.min)/5}),gt=m.axes!==!1;if(gt&&W({gridGroup:m.groups.grid,axisGroup:m.groups.axis,plot:ie,scale:rt,format:kt,horizontal:pe,side:ye,config:K.y,grid:m.grid,size:Q.small}),gt)if(pe)le({group:m.groups.overlay,plot:ie,scale:Ve,labels:re.labels,fontSize:Q.small,config:K.x});else if(Ve.kind==="band")ne({group:m.groups.overlay,plot:ie,scale:Ve,labels:re.labels,fontSize:Q.small,rotated:D(re.labels,Ve.step,Q.small,K.x.every),config:K.x});else{const Te=re.dimension&&re.dimension.col?m.grid.columns.get(re.dimension.col):void 0;he({group:m.groups.overlay,plot:ie,scale:Ve,format:_(m.grid,{kind:re.kind,span:Ve.domain.max-Ve.domain.min,step:(Ve.domain.max-Ve.domain.min)/5},Te),config:K.x,grid:m.grid,column:Te,size:Q.small})}if(gt&&(X({group:m.groups.rules,plot:ie,side:ye}),l({group:m.groups.axis,plot:ie,text:K.y.title,side:pe?"bottom":ye,size:Q.axisTitle}),l({group:m.groups.axis,plot:ie,text:K.x.title,side:pe?"left":"bottom",size:Q.axisTitle})),gt&&ot){O({group:m.groups.axis,plot:ie,scale:ot,colour:te.series(Ge[0].index),side:ve,format:_(m.grid,{kind:"linear",step:(lt.max-lt.min)/5})});const Te=K.y2.title||(Ge.length===1?Ge[0].label:"");l({group:m.groups.axis,plot:ie,text:Te,side:ve,size:Q.axisTitle}),!K.y.title&&Ze.length===1&&Ze[0].label&&l({group:m.groups.axis,plot:ie,text:Ze[0].label,side:ye,size:Q.axisTitle})}const Et=Number.isFinite(m.downsampleTo)?Number(m.downsampleTo):Math.max(2,Math.round(ie.width));let Tt=!1;if(be.marks==="path"||se==="scatter"||se==="bubble"){for(const Te of de)if(Te.kept=null,Te.points.length>Et*1.5){const Ie=Te.points.map((nt,it)=>({x:it,y:nt.y,point:nt})),et=x(Ie,Et);Te.points=et.map(nt=>nt.point),Te.kept=et.map(nt=>nt.x),Tt=!0}}m.pool||V(m.groups,ie,Z(se));const ct=m.pool||new U(m.groups.marks),Xt=Xe?re.categories.map((Te,Ie)=>de.reduce((et,nt)=>{const it=nt.points[Ie]?nt.points[Ie].y:null;return v(it)?et+Math.abs(it):et},0)):null,xt=Qe?Oe(re.categories.length,Xt):null,vt=ze?de.filter(Te=>(Te.mark||(se==="bar"?"bar":se))==="bar"):de,Qt=ze?Math.max(1,vt.length):Math.max(1,de.length),en=se==="bar"||ze&&vt.length>0,pt=Ve.kind==="band"?Ve.bandwidth:en?Ye({bound:re,scale:Ve,config:K.x,padding:De("bar")}):0,bt=Qe?pt:pt/Qt,yt=new Map;for(const Te of vt)yt.set(Te.key,yt.size);const Mt=[];for(let Te=0;Te<de.length;Te++){const Ie=de[Te],et=te.series(Ie.index,Ie.label),nt=Ie.axis==="right"&&ot?ot:rt,it=ze?Ie.mark||(se==="bar"?"bar":se):se,nn=ze&&yt.has(Ie.key)?yt.get(Ie.key):Te;if(se==="horizontalBar")Ht({pool:ct,series:Ie,bandScale:Ve,valueScale:rt,baseline:wt,colour:et,stack:xt,index:Ie.index,slot:{offset:Qe?0:Te*bt,width:bt,span:pt},pointColour:Je});else if(se==="waterfall")Wt({pool:ct,series:Ie,xScale:Ve,yScale:rt,index:Ie.index,total:!0,positive:te.positive,negative:te.negative});else if(it==="bar")Bt({pool:ct,series:Ie,xScale:Ve,yScale:nt,baseline:nt===ot?lt.min<=0&<.max>=0?0:lt.min:wt,colour:et,stack:xt,index:Ie.index,slot:{offset:Qe?0:nn*bt,width:bt,span:pt},pointColour:Je});else if(se==="scatter"||se==="bubble")Vt({pool:ct,series:Ie,xScale:Ve,yScale:nt,colour:et,index:Ie.index,size:se==="bubble"?m.sizes:null});else{const Ct=It(m,Ie.label),Ft={pool:ct,series:Ie,xScale:Ve,yScale:nt,baseline:wt,fill:it==="area"||it==="rangeArea",step:it==="step",colour:et,stack:xt,index:Ie.index,style:Ct};Ct.emphasized?Mt.push(Ft):St(Ft)}}for(const Te of Mt)St(Te);m.pool||ct.finish(),m.band&&typeof Ve.invert=="function"&&jt({group:m.groups.overlay,band:m.band,xScale:Ve,yScale:rt,scheme:te,index:0,line:m.band.line!==!1&&!m.fit}),m.fit&&(se==="scatter"||se==="bubble")&&typeof Ve.invert=="function"&&Ot({group:m.groups.overlay,series:de,xScale:Ve,yScale:rt,plot:ie,scheme:te,grid:m.grid,size:Q.small,showR2:m.fit!=="line"});let ht=null;m.trend&&(ht=y({group:m.groups.overlay,series:de,xScale:Ve,yScale:rt,rightScale:ot,plot:ie,scheme:te,trend:m.trend,grid:m.grid,format:Te=>kt.tick(Te),size:Q.small,clip:m.groups.boxClipId}));let _t=null;if(m.error&&(_t=Ut({group:m.groups.overlay,series:de,xScale:Ve,yScale:rt,grid:m.grid,options:m.error===!0?{}:m.error})),m.labels&&m.labels.show&&f({group:m.groups.labels,series:de,plot:ie,options:m.labels,grid:m.grid,size:Q.small,horizontal:pe}),m.reference&&m.reference.length){const Te=m.reference.filter(et=>!(et.axis==="right"||et.axis==="y2")),Ie=ot?m.reference.filter(et=>et.axis==="right"||et.axis==="y2"):[];Te.length&&mt({group:m.groups.overlay,plot:ie,scale:rt,lines:Te}),Ie.length&&mt({group:m.groups.overlay,plot:ie,scale:ot,lines:Ie})}let Nt=null;m.annotations&&m.annotations.length&&(Nt=E({group:m.groups.overlay,plot:ie,xScale:Ve,yScale:rt,rightScale:ot,series:de,annotations:m.annotations,dual:ze,format:Te=>kt.tick(Te),size:Q.small}));const tn=Array.isArray(ht)&&ht.length?[...Nt||[],...ht]:Nt;return{xScale:Ve,yScale:rt,rightScale:ot,dual:ze,series:de,horizontal:pe,percent:Xe,plot:ie,errorBars:_t,annotations:tn,trendlines:ht,reduced:Tt,legend:_e?h({grid:m.grid,col:_e,colours:Ee}):null}}const Pt=32;function qt(m){const{series:te,xScale:K,at:Q}=m,re=Number.isFinite(m.tolerance)?Number(m.tolerance):Pt,ie=[];let se=-1,be=1/0;for(const de of te){let pe=null,ye=-1,ve=1/0;const _e=de.points||[];for(let Ee=0;Ee<_e.length;Ee++){const Ce=_e[Ee];if(!Ce||!v(Ce.y))continue;const Ke=ut(K,Ce);if(Number.isNaN(Ke))continue;const Se=Math.abs(Ke-Q);Se>=ve||(ve=Se,pe=Ce,ye=Array.isArray(de.kept)?de.kept[Ee]:Ee)}!pe||ve>re||(ie.push({series:de,point:pe}),ve<be&&(be=ve,se=ye))}return se<0?null:{index:se,entries:ie}}function Yt(m){const{bound:te,xScale:K,at:Q}=m;if(!te.categories.length)return-1;if(K.kind==="band"){const se=Math.floor((Q-K.range[0])/(K.step||1));return se>=0&&se<te.categories.length?se:-1}let re=-1,ie=1/0;for(let se=0;se<te.categories.length;se++){const be=K.kind==="time"?B(te.categories[se]):L(te.categories[se]);if(be===null)continue;const de=Math.abs(K.of(be)-Q);de<ie&&(ie=de,re=se)}return re}function Jt(m,te){return te<0||te>=m.categories.length?"":g(m.categories[te])}}),Le("packages/modules/charts/drawable.js",function(o,oe){"use strict";Object.defineProperty(o,"REASONS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"DRAWABLE",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"namedColumns",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"missingColumns",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"bucketKey",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"bucketMessage",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"drawability",{enumerable:!0,get:function(){return T}});const me=oe("packages/modules/charts/scale.js"),X=me.extent,l=me.toNumber,le=me.toTime,he=oe("packages/modules/charts/cartesian.js").staleWindow,W=Object.freeze({EMPTY:"empty",INCOMPLETE:"incomplete",STALE:"stale",MISSING_COLUMN:"missing-column",NO_DOMAIN:"no-domain",BUCKETED:"bucketed"}),Z=Object.freeze({ok:!0});function fe(_){if(!_||typeof _!="object")return[];const k=[],N=(b,a)=>{typeof a=="string"&&a?k.push({key:b,col:a}):a&&typeof a=="object"&&typeof a.col=="string"&&a.col&&k.push({key:b,col:a.col})};if(Array.isArray(_.points))return[];if(N("x",_.x),N("code",_.code),N("y",_.y),N("series",_.series),N("size",_.size),N("source",_.source),N("target",_.target),typeof _.multiples=="string"&&N("multiples",_.multiples),Array.isArray(_.measures))for(const b of _.measures)N("measures",b);return k}function V(_,k){const N=_&&_.columns;return!N||typeof N.get!="function"?[]:fe(k).filter(({col:b})=>!N.get(b))}function I(_){return`chart:x:date-bucket:${_}`}function U(_,k,N){return`chart x column ${JSON.stringify(_)} is a 'date', which stores a calendar day, so all ${k} rows collapsed into one point and were reduced by '${N}'. For a series inside a single day, type the column 'datetime' or bind epoch milliseconds.`}function D(_,k){return!k||k.kind!=="time"&&k.kind!=="linear"?!1:_!=="bar"&&_!=="horizontalBar"}function T(_){const{grid:k,spec:N,type:b,bound:a}=_,v=_.id===void 0?"":String(_.id),g=Number.isFinite(_.now)?Number(_.now):Date.now(),R=(L,B,H,G=!0)=>({ok:!1,reason:L,key:H||`chart:${v}:${L}`,message:B,tell:G}),F=V(k,N);if(F.length){const L=F.map(H=>`${H.key}: ${JSON.stringify(H.col)}`).join(", "),B=k&&k.columns&&typeof k.columns.all=="function"?k.columns.all().map(H=>H.id||H.field).filter(Boolean):[];return R(W.MISSING_COLUMN,`chart ${L} ${F.length>1?"name columns":"names a column"} this grid does not have, so there is nothing to read and nothing to draw.${B.length?` The columns it does have: ${B.slice(0,12).map(H=>JSON.stringify(H)).join(", ")}${B.length>12?", …":""}.`:""} Bind a column the grid declares, or declare the column.`)}if(a&&a.empty){const L=k&&k.rows&&typeof k.rows.count=="function"?k.rows.count():0;return R(W.EMPTY,L?`chart bound nothing from the ${L} row(s) the grid is showing, so it shows its empty state. The binding named no series to draw: check that the spec names the columns this chart needs — a flow type needs source and target, a measure needs a column with values in it.`:"chart has no rows to draw, so it shows its empty state.",void 0,L>0)}if(b==="candlestick"&&(!a||!a.series||a.series.length<4)){const L=a&&a.series?a.series.length:0;return R(W.INCOMPLETE,`a candlestick chart needs four measures — open, high, low and close, in that order — and ${L===0?"none was":`only ${L} were`} bound. Pass them as measures: [open, high, low, close].`)}const p=he(a,_.axis&&_.axis.x,b,g);if(p){const L=p.newest===null?"and every one of them is stamped ahead of it":`and the newest of ${p.points} x value(s) is ${Math.round(p.age/1e3)}s old`;return R(W.STALE,`the rolling x window covers the last ${p.span} ms, ${L}, so every mark would be drawn outside the plot. The chart shows its empty state instead. Seed it with data inside the window, widen axis.x.window.span, or drop the window while showing history.`,`chart:${v}:x:window:stale:${N&&N.x||""}`,p.newest!==null)}if(D(b,a)){const L=Array.isArray(a.categories)?a.categories:[],B=a.kind==="time"?L.map(le):L.map(l);if(L.length&&!X(B)){const H=N&&typeof N.x=="string"&&N.x||a.dimension&&a.dimension.col||"";return R(W.NO_DOMAIN,`chart x ${H?`column ${JSON.stringify(H)} `:""}is drawn on a ${a.kind==="time"?"time":"continuous"} axis, and not one of its ${L.length} value(s) reads as a ${a.kind==="time"?"date":"number"} — so the axis would be drawn over a domain invented from nothing rather than measured from the data. Remove axis.x.scale to let the column choose its own scale, or type the column so its values parse.`)}}if(a&&a.bucketed&&D(b,a)){const{col:L,rows:B,fn:H}=a.bucketed;return R(W.BUCKETED,U(L,B,H),I(L))}return Z}}),Le("packages/modules/charts/bind.js",function(o,oe){"use strict";Object.defineProperty(o,"AGGREGATIONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"DEFAULT_AGGREGATION",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"resolveAggregation",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"defaultAggregationFor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"walkRows",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"leafRows",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"selectedRows",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"topGroups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"forcedScaleKind",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"scaleKindFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"bindSeries",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"bindPoints",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"bindMeasures",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"bindLinks",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"bindHierarchy",{enumerable:!0,get:function(){return ce}});const me=oe("packages/modules/charts/scale.js"),X=me.key,l=me.toNumber,le=me.toTime,ne=oe("packages/modules/charts/drawable.js"),he=ne.bucketKey,W=ne.bucketMessage,fe=oe("packages/core/src/internal/util.js").warnOnce,V={sum:j=>j.length?j.reduce((z,t)=>z+t,0):null,avg:j=>j.length?j.reduce((z,t)=>z+t,0)/j.length:null,mean:j=>j.length?j.reduce((z,t)=>z+t,0)/j.length:null,min:j=>{let z=null;for(let t=0;t<j.length;t++)(z===null||j[t]<z)&&(z=j[t]);return z},max:j=>{let z=null;for(let t=0;t<j.length;t++)(z===null||j[t]>z)&&(z=j[t]);return z},median:j=>{if(!j.length)return null;const z=j.slice().sort((e,x)=>e-x),t=(z.length-1)/2,c=Math.floor(t),f=Math.ceil(t);return c===f?z[c]:(z[c]+z[f])/2},count:(j,z)=>z,countValues:j=>j.length,first:j=>j.length?j[0]:null,last:j=>j.length?j[j.length-1]:null},I="sum";function U(j){return j==null?I:typeof j=="string"&&j in V?j:(fe(`chart:measure:fn:${String(j)}`,`chart measure fn ${JSON.stringify(j)} is not a known aggregation; using '${I}'. Supported: ${Object.keys(V).join(", ")}.`),I)}function D(j){if(!j)return I;const z=j.groupTotal??j.total;if(typeof z=="string"&&z in V)return z;const t=j.dataType&&j.dataType.totals?j.dataType.totals.supported:null;if(Array.isArray(t)&&!t.includes(I)){const c=["avg","mean","max","min","countValues","count"].find(f=>t.includes(f)&&f in V);if(c)return c}return I}function T(j,z){const t=D(z);return j?typeof j=="string"?{col:j,fn:t}:{col:j.col||null,fn:j.fn==null?t:U(j.fn)}:{col:null,fn:t}}function _(j,z){const t=new Set,c=f=>{if(!f||t.has(f)||(t.add(f),z(f),!f.group)||f.expanded)return;const e=f.filteredChildren||f.children;if(Array.isArray(e))for(const x of e)c(x)};j.rows.forEach(c)}function k(j){const z=[];return _(j,t=>{!t.group&&t.data!==null&&t.data!==void 0&&z.push(t)}),z}function N(j){const z=new Set(j.selection.keys());if(!z.size)return[];const t=[];return _(j,c=>{!c.group&&z.has(c.key)&&t.push(c)}),t}function b(j){const z=[];let t=1/0;return _(j,c=>{c.group&&(c.level<t&&(t=c.level,z.length=0),c.level===t&&z.push(c))}),z}function a(j,z,t){return z.group&&z.totals&&t in z.totals?l(z.totals[t]):l(j.rows.value(z.key,t))}function v(j,z,t,c){if(!z.group){const f=j.rows.text(z.key,t);if(f)return f}return c==null?"":c instanceof Date?c.toISOString().slice(0,10):String(c)}function g(j,z){return(V[z]||V[I])(j.values,j.rows)}const R=Object.freeze(["number","currency","percent"]),F=Object.freeze(["date","datetime","timestamp","dateString"]),p=Object.freeze({auto:"",band:"category",category:"category",linear:"linear",time:"time"});function L(j){const z=j&&typeof j=="object"?j.axis:null;if(!z||typeof z!="object")return"";const t=z.x;if(!t||typeof t!="object")return"";const c=typeof t.scale=="string"?t.scale:"";return c?Object.hasOwn(p,c)?p[c]:(fe(`chart:x:scale:unknown:${c}`,`chart axis.x.scale ${JSON.stringify(c)} is not a scale this chart draws. Use one of: ${Object.keys(p).join(", ")}. The scale was chosen from the column instead.`),""):""}function B(j){if(j.length<3)return"";let z=0,t=0;for(const c of j){if(c==null||c===""||typeof c=="boolean")return"";l(c)!==null?z++:typeof c=="string"&&le(c)!==null&&t++}return t===j.length?"time":z===j.length?"linear":""}function H(j,z,t={}){if(t.forced)return t.forced;const c=j&&typeof j.type=="string"?j.type:"";if(F.includes(c)||z.length&&z.every(x=>x instanceof Date))return"time";if(R.includes(c))return"linear";const f=t.id?String(t.id):"";if(!f)return"category";const e=c&&c!=="text"?"":B(z);return e&&fe(`chart:x:banded:${f}`,`chart x column ${JSON.stringify(f)} is typed ${JSON.stringify(c||"text")}, so its ${z.length} values are drawn as categories on a band scale even though they all read as ${e==="time"?"dates":"numbers"}. Type the column ${e==="time"?"'date' (or 'datetime'/'timestamp'/'dateString')":"'number'"} for a continuous axis, or pin it with axis: { x: { scale: '${e}' } }.`),"category"}function G(j,z){const t=z.x||null,c=z.series||(typeof z.multiples=="string"?z.multiples:null)||null,f=j.columns,e=t?f.get(t):void 0,x=T(z.y),S=x.col?f.get(x.col):void 0,P=T(z.y,S);let w;const s=typeof z.rows=="function"?z.rows(j):z.rows;Array.isArray(s)?w=s:z.from==="groups"?w=b(j):z.from==="selection"?w=N(j):w=k(j);const i=w.length?w:k(j),O=new Map,$=new Map,E=[];for(let A=0;A<i.length;A++){const C=i[A],Y=t?C.group&&C.groupColumn===t?C.groupValue:j.rows.value(C.key,t):A,ee=X(Y);O.has(ee)||(O.set(ee,{value:Y,label:t?v(j,C,t,Y):String(A),order:O.size}),E.push(Y));const ue=c?C.group&&C.groupColumn===c?C.groupValue:j.rows.value(C.key,c):null,we=c?X(ue):"";$.has(we)||$.set(we,{label:c?v(j,C,c,ue):S?.title||"",points:new Map});const Oe=$.get(we);let ke=Oe.points.get(ee);ke||(ke={values:[],rows:0,rowKey:C.key},Oe.points.set(ee,ke)),ke.rows+=C.group&&C.leafCount||1;const $e=P.col?a(j,C,P.col):null;if($e!==null&&ke.values.push($e),z.size){const je=l(j.rows.value(C.key,z.size));je!==null&&(ke.sizes=(ke.sizes||0)+je)}}const n=[...O.values()].sort((A,C)=>A.order-C.order),d=typeof z.limit=="number"&&z.limit>0?n.slice(0,z.limit):n,y=H(e,E,{forced:L(z),id:t});let r=null;y==="time"&&i.length>1&&O.size===1&&e&&(e.type==="date"||e.type==="dateString")&&(r={col:String(t),rows:i.length,fn:P.fn},fe(he(r.col),W(r.col,r.rows,r.fn)));const h=R.includes(e&&typeof e.type=="string"?e.type:"")?[...d].sort((A,C)=>(l(A.value)??0)-(l(C.value)??0)):d,M=[...$.entries()].map(([A,C],Y)=>({key:A,label:C.label,index:Y,points:h.map(ee=>{const ue=X(ee.value),we=C.points.get(ue);return{x:ee.value,xKey:ue,label:ee.label,y:we?g(we,P.fn):null,size:we&&we.sizes!==void 0?we.sizes:null,rows:we?we.rows:0,rowKey:we?we.rowKey:null,values:we&&we.values?we.values:null}})}));return{series:M,categories:h.map(A=>A.value),labels:h.map(A=>A.label),kind:y,measure:{...P,title:S?.title||P.col||""},dimension:{col:t,title:e?.title||t||""},empty:M.length===0||h.length===0,rows:i.length,truncated:n.length-h.length,bucketed:r}}function ae(j){const z=Array.isArray(j.points)?j.points:[],t=z.length>0&&z.every(e=>typeof e.x=="number"&&Number.isFinite(e.x)),c=e=>typeof e=="number"&&Number.isFinite(e)?e:null,f=z.map((e,x)=>({x:e.x,xKey:X(e.x),label:e.label!=null?String(e.label):String(e.x),y:c(e.y),size:c(e.size),lower:c(e.lower),upper:c(e.upper),rows:1,rowKey:e.key!=null?String(e.key):String(x),values:null}));return{series:[{key:j.seriesKey||"",label:j.seriesLabel||"",index:0,points:f}],categories:f.map(e=>e.x),labels:f.map(e=>e.label),kind:t?"linear":"category",measure:{col:null,fn:"sum",title:j.measureTitle||""},dimension:{col:null,title:j.dimensionTitle||""},empty:f.length===0,rows:f.length,truncated:0}}function J(j,z){const t=Array.isArray(z.measures)?z.measures:[];if(!t.length)return G(j,z);const c=t.map(S=>{const P=typeof S=="string"?{col:S}:S;return{spec:P,result:G(j,{x:z.x,from:z.from,limit:z.limit,axis:z.axis,y:{col:P.col,fn:P.fn}})}}),f=c[0].result,e=new Map(f.categories.map((S,P)=>[X(S),P])),x=c.map(({spec:S,result:P},w)=>{const s=j.columns.get(S.col),i=f.categories.map(()=>null),O=P.series[0];if(O)for(const $ of O.points){const E=e.get($.xKey);E!==void 0&&(i[E]=$)}return{key:S.col,label:S.title||S.label||s&&s.title||S.col,index:w,mark:S.type||null,axis:S.axis==="right"?"right":"left",points:f.categories.map(($,E)=>i[E]||{x:$,xKey:X($),label:f.labels[E],y:null,rows:0,rowKey:null})}});return{series:x,categories:f.categories,labels:f.labels,kind:f.kind,measure:{col:null,fn:"sum",title:x.map(S=>S.label).join(", ")},dimension:f.dimension,empty:!x.length||!f.categories.length,rows:f.rows,truncated:f.truncated}}function q(j,z,t={}){const c=T(z.y),f=!!t.perRow,e=Array.isArray(t.nodes)?t.nodes:[],x=z.source||z.x||null,S=z.target||null;if(!x||!S)return{nodes:[],links:[],measure:{...c,title:""},dimension:{col:null,title:""},series:[],categories:[],labels:[],empty:!0,total:0};const P=c.col?j.columns.get(c.col):void 0,w=new Map,s=new Map,i=(n,d,y)=>{const r=X(n);return w.has(r)||w.set(r,{key:r,value:n,label:v(j,d,y,n),index:w.size,in:0,out:0}),w.get(r)},O=new Map;for(const n of e)!n||n.id===null||n.id===void 0||O.set(X(n.id),n);for(const n of k(j)){const d=j.rows.value(n.key,x),y=j.rows.value(n.key,S);if(d==null||y===null||y===void 0)continue;const r=c.col?l(j.rows.value(n.key,c.col)):1;if(r===null||r<=0)continue;const u=i(d,n,x),h=i(y,n,S);if(f){const M=u.key>h.key,A=M?h:u,C=M?u:h;s.set(`${A.key}\0${C.key}\0${s.size}`,{source:A,target:C,value:r,undirected:!0,pair:`${A.key}\0${C.key}`,rowKeys:[n.key]})}else{const M=`${u.key}\0${h.key}`,A=s.get(M)||{source:u,target:h,value:0,rowKeys:[]};A.value+=r,A.rowKeys.length<64&&A.rowKeys.push(n.key),s.set(M,A)}u.out+=r,h.in+=r}for(const[n,d]of O)w.has(n)||w.set(n,{key:n,value:d.id,label:String(d.label??d.id),index:w.size,in:0,out:0});for(const[n,d]of O){const y=w.get(n);y&&(y.declared=!0,d.label!==void 0&&d.label!==null&&(y.label=String(d.label)),typeof d.icon=="string"&&d.icon&&(y.icon=d.icon),Number.isFinite(d.x)&&Number.isFinite(d.y)&&(y.fx=Number(d.x),y.fy=Number(d.y)))}const $=f?[...s.values()]:[...s.values()].sort((n,d)=>d.value-n.value),E=typeof z.limit=="number"&&z.limit>0?$.slice(0,z.limit):$;return{nodes:[...w.values()],links:E,measure:{...c,title:P?.title||c.col||""},dimension:{col:x,title:j.columns.get(x)?.title||x},series:[],categories:[],labels:[],empty:!E.length,total:E.reduce((n,d)=>n+d.value,0)}}function ce(j,z){const t=T(z.y),c=typeof z.depth=="number"&&z.depth>0?z.depth:1/0,f=t.col?j.columns.get(t.col):void 0,e=(s,i,O)=>({label:s,value:i,depth:O,total:0,children:[],rowKey:null}),x=e("",null,0),S=b(j);if(S.length){const s=(i,O,$)=>{const E=i.groupColumn?v(j,i,i.groupColumn,i.groupValue):"",n=e(E,i.groupValue,$);n.rowKey=i.key;const d=t.col?a(j,i,t.col):null;n.total=d===null?0:Math.abs(d),O.children.push(n);const y=i.filteredChildren||i.children;if($<c&&Array.isArray(y))for(const r of y)r.group&&s(r,n,$+1);return!n.total&&n.children.length&&(n.total=n.children.reduce((r,u)=>r+u.total,0)),n};for(const i of S)s(i,x,1)}else{const i=G(j,{x:z.x,y:z.y,limit:z.limit}).series[0];if(i)for(const O of i.points){const $=e(O.label,O.x,1);$.total=O.y===null?0:Math.abs(O.y),$.rowKey=O.rowKey,x.children.push($)}}x.total=x.children.reduce((s,i)=>s+i.total,0);let P=0;const w=s=>{s.depth>P&&(P=s.depth);for(const i of s.children)w(i)};return w(x),{root:x,depth:P,measure:{...t,title:f?.title||t.col||""},empty:x.total<=0||x.children.length===0}}}),Le("packages/modules/charts/engine.js",function(o,oe){"use strict";Object.defineProperty(o,"AGGREGATE_MODES",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"ENGINE_TYPES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"aggregateMode",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"planAggregate",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"holdsWindow",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"boundFromGroups",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"measureProvenance",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"specMeasures",{enumerable:!0,get:function(){return c}});const me=oe("packages/modules/charts/scale.js"),X=me.key,l=me.toNumber,le=oe("packages/modules/charts/bind.js"),ne=le.forcedScaleKind,he=le.measureOf,W=le.scaleKindFor,Z=oe("packages/core/src/source/aggregates.js"),fe=Z.resolveAggregatePlan,V=Z.STAT_PUSHDOWN,U=oe("packages/core/src/internal/util.js").warnOnce,D=oe("packages/modules/shared/engine.js"),T=D.engineSource,_=D.gridEngineRequest,k=D.gridHoldsWindow,N=D.loadedAndMatching,b=D.sourceId,a=Object.freeze(["auto","engine","client"]),v=Object.freeze(new Set(["line","step","area","bar","horizontalBar","waterfall","combo","pareto","heatmap","radar","funnel","stream","marimekko"])),g=Object.freeze(new Set(["combo","bar","line","step","area"])),R=Object.freeze({mean:"avg"}),F="__rows",p="m",L="__size",B=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(f){const e=f?f.aggregate:void 0;return e==null?"auto":typeof e=="string"&&a.includes(e)?e:(U(`chart:aggregate:mode:${String(e)}`,`chart aggregate ${JSON.stringify(e)} is not a mode; use one of ${a.join(", ")}. The chart used 'auto'.`),"auto")}function G(f,e,x){const S=f.columns.get(e);if(!S)return`the ${x} column "${e}" is not a column of the grid`;const P=S.value&&typeof S.value=="object"?S.value:null;return S.computed||P&&(typeof P.get=="function"||typeof P.compute=="function")?`the ${x} column "${e}" is computed by the grid, which the engine cannot reproduce`:(typeof S.field=="string"?S.field:e)!==e||!B.test(e)?`the ${x} column "${e}" is not a plain physical column the engine can name`:x!=="measure"&&S.type==="geometry"?`the ${x} column "${e}" is a geometry, which charts group in the browser for now`:""}function ae(f,e,x){const S=g.has(x)&&Array.isArray(e.measures)&&e.measures.length>0;return(S?e.measures:[e.y]).map((w,s)=>{const i=he(w),O=i.col?f.columns.get(i.col):void 0,$=he(w,O),E=w&&typeof w=="object"?w:{};return{id:`${p}${s}`,col:$.col,fn:$.fn,stat:R[$.fn]||$.fn,label:S?E.title||E.label||O&&O.title||$.col||"":O&&O.title||$.col||"",mark:S&&E.type||null,axis:S&&E.axis==="right"?"right":"left",multi:S}})}function J(f,e,x){const S=H(e),P=(C,Y=!1)=>({mode:"client",asked:S,reason:C,refused:S==="engine",windowed:Y});if(S==="client")return{...P("aggregate: 'client' was asked for"),refused:!1};if(!v.has(x))return P(`a "${x}" chart does not draw a grouped aggregate`);if(Array.isArray(e.points))return P("the chart draws an explicit point set");if(e.rows)return P("the chart was handed its own rows");if(e.from==="groups"||e.from==="selection")return P(`the chart reads the grid's ${e.from==="groups"?"group rows":"selection"}`);if(e.error)return P("error bars need the readings behind each mark");const w=T(f);if("reason"in w)return P(w.reason);const{source:s,caps:i}=w;if(!i.group)return P("the source's adapter does not declare the `group` capability");const O=typeof e.x=="string"&&e.x?e.x:null;if(!O)return P("the chart names no x column to group by");const $=typeof e.series=="string"&&e.series?e.series:typeof e.multiples=="string"?e.multiples:null,E=ae(f,e,x),n=E.length>0&&E[0].multi,d=$&&!n?[O,$]:[O];for(const[C,Y]of d.entries()){const ee=G(f,Y,C===0?"x":"series");if(ee)return P(ee)}for(const C of E){if(!C.col)return P("a measure names no column to reduce");const Y=G(f,C.col,"measure");if(Y)return P(Y);const ee=V[C.stat];if(!ee||!ee.pushable)return P(`"${C.fn}" of "${C.col}" is not a reduction the engine can compute`)}if(e.size){const C=typeof e.size=="string"?G(f,e.size,"measure"):"the size channel is not a column";if(C)return P(C)}const y=[...E.map(C=>({id:C.id,col:C.col,fn:C.stat})),{id:F,col:O,fn:"count"},...e.size?[{id:L,col:e.size,fn:"sum"}]:[]],r=fe(y,s.aggregates);if(r.client.length){const C=r.client[0];return P(`the source computes "${C.fn}" client-side (${C.reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to compute it in the engine`)}const u=_(f,w);if("reason"in u)return P(u.reason);const{quick:h}=u,M={...u.request,groupBy:d};if(S==="auto"){const{loaded:C,total:Y}=N(f);if(Number.isFinite(Y)&&C>=Y)return P("the grid holds every matching row")}const A=JSON.stringify([b(s),M.filters,h,d,y]);return{mode:"engine",asked:S,key:A,source:s,request:M,requested:y,groupBy:d,measures:E}}function q(f){return k(f)}function ce(f,e){if(e==null)return"";if(f&&typeof f.formatValue=="function")try{const x=f.formatValue(e,null);if(typeof x=="string"&&x)return x}catch{}return e instanceof Date?e.toISOString().slice(0,10):String(e)}function j(f,e){if(f==null)return e==null?0:1;if(e==null)return-1;const x=f instanceof Date?f.getTime():l(f),S=e instanceof Date?e.getTime():l(e);return typeof f!="string"&&typeof e!="string"&&x!==null&&S!==null?x-S:String(f).localeCompare(String(e))}function z(f,e,x,S){const{groupBy:P,measures:w}=x,s=P[0],i=P[1]||null,O=w[0].multi,$=f.columns.get(s),E=i?f.columns.get(i):void 0,n=(S||[]).filter(ke=>ke&&ke.level===P.length),d=new Map,y=new Map,r=new Map;for(const ke of n){const $e=ke.keys[0],je=X($e);d.has(je)||d.set(je,$e);const xe=i?ke.keys[1]:null,ge=i?X(xe):"";y.has(ge)||y.set(ge,xe),r.set(`${ge}\0${je}`,ke.values||{})}const u=f.sort&&typeof f.sort.get=="function"?f.sort.get():[],h=Array.isArray(u)&&u[0]&&u[0].col===s&&u[0].dir==="desc",M=[...d.entries()].sort((ke,$e)=>j(ke[1],$e[1]));h&&M.reverse();const A=typeof e.limit=="number"&&e.limit>0?M.slice(0,e.limit):M,C=A.map(([,ke])=>ce($,ke)),Y=A.map(([,ke])=>ke),ee=(ke,$e,je,xe,ge)=>{const Ae=r.get(`${ke}\0${$e}`),Me=Ae?l(Ae[F]):null;return{x:je,xKey:$e,label:xe,y:Ae?l(Ae[ge]):null,size:Ae&&e.size?l(Ae[L]):null,rows:Me===null?0:Me,rowKey:null,values:null}};let ue;O?ue=w.map((ke,$e)=>({key:ke.col,label:ke.label,index:$e,mark:ke.mark,axis:ke.axis,points:A.map(([je,xe],ge)=>ee("",je,xe,C[ge],ke.id))})):ue=[...y.entries()].sort(($e,je)=>j($e[1],je[1])).map(([$e,je],xe)=>({key:$e,label:i?ce(E,je):w[0].label,index:xe,points:A.map(([ge,Ae],Me)=>ee($e,ge,Ae,C[Me],w[0].id))}));const we=n.reduce((ke,$e)=>ke+(l($e.values&&$e.values[F])||0),0),Oe=W($,Y,{forced:ne(e),id:s});return{series:ue,categories:Y,labels:C,kind:Oe,measure:O?{col:null,fn:"sum",title:ue.map(ke=>ke.label).join(", ")}:{col:w[0].col,fn:w[0].fn,title:w[0].label},dimension:{col:s,title:$&&$.title||s},empty:ue.length===0||A.length===0,rows:we,truncated:M.length-A.length,bucketed:null}}function t(f,e,x=[],S=""){return f.map(P=>{const w=x.find(s=>s.id===P.id);return{col:P.col||null,fn:P.fn,computed:e,...w&&w.class?{class:w.class}:{},...e==="client"&&S?{reason:S}:{}}})}function c(f,e,x){try{return ae(f,e,x).filter(S=>S.col)}catch{return[]}}}),Le("packages/core/src/format/date.js",function(o,oe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return N}});const me=oe("packages/core/src/internal/util.js"),X=me.isNil,l=me.warnOnce,le=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(b){const a=[];let v=0,g="";const R=()=>{g&&(a.push({token:null,text:g}),g="")};for(;v<b.length;){const F=b[v];if(F==="'"){if(b[v+1]==="'"){g+="'",v+=2;continue}const L=b.indexOf("'",v+1);if(L===-1){g+=b.slice(v+1),v=b.length;continue}g+=b.slice(v+1,L),v=L+1;continue}const p=le.find(L=>b.startsWith(L,v));if(p){R(),a.push({token:p,text:p}),v+=p.length;continue}/[A-Za-z]/.test(F)&&l(`date.pattern.token:${F}`,`the date pattern "${b}" contains '${F}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${le.join(" ")}.`),g+=F,v+=1}return R(),a}const he=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(b){if(X(b)||b==="")return null;if(b instanceof Date)return Number.isNaN(b.getTime())?null:b;if(typeof b=="number")return Number.isNaN(b)?null:new Date(b);if(typeof b=="string"){const a=he.exec(b.trim());if(a){const[,g,R,F,p="0",L="0",B="0"]=a;return new Date(+g,+R-1,+F,+p,+L,+B)}const v=new Date(b);return Number.isNaN(v.getTime())?null:v}return null}function Z(b,a){return String(b).padStart(a,"0")}function fe(b){if(!b)return g=>({year:g.getFullYear(),month:g.getMonth()+1,day:g.getDate(),hour:g.getHours(),minute:g.getMinutes(),second:g.getSeconds(),ms:g.getMilliseconds(),weekday:g.getDay()});const a=new Intl.DateTimeFormat("en-US",{timeZone:b,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),v={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return g=>{const R={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:g.getMilliseconds(),weekday:0};for(const F of a.formatToParts(g))switch(F.type){case"year":R.year=Number(F.value);break;case"month":R.month=Number(F.value);break;case"day":R.day=Number(F.value);break;case"hour":R.hour=Number(F.value)%24;break;case"minute":R.minute=Number(F.value);break;case"second":R.second=Number(F.value);break;case"weekday":R.weekday=v[F.value]??0;break;default:break}return R}}function V(b,a,v){const g=ne(b),R=fe(v),F=new Set(g.filter(G=>G.token).map(G=>G.token)),p=F.has("MMM")?new Intl.DateTimeFormat(a,{month:"short",timeZone:v}):null,L=F.has("MMMM")?new Intl.DateTimeFormat(a,{month:"long",timeZone:v}):null,B=F.has("EEE")?new Intl.DateTimeFormat(a,{weekday:"short",timeZone:v}):null,H=F.has("EEEE")?new Intl.DateTimeFormat(a,{weekday:"long",timeZone:v}):null;return G=>{const ae=R(G);let J="";for(const q of g){if(!q.token){J+=q.text;continue}switch(q.token){case"yyyy":J+=Z(ae.year,4);break;case"yy":J+=Z(ae.year%100,2);break;case"MMMM":J+=L.format(G);break;case"MMM":J+=p.format(G);break;case"MM":J+=Z(ae.month,2);break;case"M":J+=String(ae.month);break;case"dd":J+=Z(ae.day,2);break;case"d":J+=String(ae.day);break;case"EEEE":J+=H.format(G);break;case"EEE":J+=B.format(G);break;case"HH":J+=Z(ae.hour,2);break;case"H":J+=String(ae.hour);break;case"hh":J+=Z(ae.hour%12===0?12:ae.hour%12,2);break;case"h":J+=String(ae.hour%12===0?12:ae.hour%12);break;case"mm":J+=Z(ae.minute,2);break;case"m":J+=String(ae.minute);break;case"ss":J+=Z(ae.second,2);break;case"s":J+=String(ae.second);break;case"SSS":J+=Z(ae.ms,3);break;case"a":J+=ae.hour<12?"AM":"PM";break;default:J+=q.text;break}}return J}}const I=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function U(b,a){const v=b||{},g=v.locale||a||void 0,R=v.nullDisplay??"",F=v.timeZone;let p;if(v.pattern)p=V(v.pattern,g,F);else if(v.dateStyle||v.timeStyle){const ae={timeZone:F};v.dateStyle&&(ae.dateStyle=v.dateStyle),v.timeStyle&&(ae.timeStyle=v.timeStyle);const J=new Intl.DateTimeFormat(g,ae);p=q=>J.format(q)}else{const ae=new Intl.DateTimeFormat(g,{dateStyle:"medium",timeZone:F});p=J=>ae.format(J)}const L=v.relative?new Intl.RelativeTimeFormat(g,{numeric:"auto"}):null,H=(typeof v.relative=="object"&&v.relative?v.relative.threshold??7:7)*24*36e5,G=(ae,J)=>{const q=W(ae);if(!q)return R;if(L){const ce=J&&typeof J.now=="number"?J.now:Date.now(),j=q.getTime()-ce;if(Math.abs(j)<H){for(const[z,t]of I)if(Math.abs(j)>=t||z==="second")return L.format(Math.round(j/t),z)}}return p(q)};return G.spec=v,G}function D(b){if(X(b)||b==="")return null;if(typeof b=="string"){const g=/^(\d{4}-\d{2}-\d{2})/.exec(b.trim());if(g)return g[1];const R=W(b);return R?D(R):null}const a=W(b);if(!a)return null;const v=g=>String(g).padStart(2,"0");return`${a.getFullYear()}-${v(a.getMonth()+1)}-${v(a.getDate())}`}function T(b,a){if(X(b)||b==="")return null;if(typeof b=="string"){const g=b.trim();if(_.test(g)){const p=W(g);return p?k(p,a):null}const R=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(g);if(R){const[,p,L,B,H]=R;return`${p}T${L}:${B}${H&&H!=="00"?`:${H}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(g))return`${g}T00:00`;const F=W(g);return F?T(F):null}const v=W(b);return v?k(v,a):null}const _=/(?:Z|[+-]\d{2}:?\d{2})$/i;function k(b,a){const v=p=>String(p).padStart(2,"0");if(a)try{const p=new Intl.DateTimeFormat("en-CA",{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(b).reduce((H,G)=>(G.type!=="literal"&&(H[G.type]=G.value),H),{}),L=p.hour==="24"?"00":p.hour,B=Number(p.second);return`${p.year}-${p.month}-${p.day}T${L}:${p.minute}`+(B?`:${p.second}`:"")}catch{}const g=`${b.getFullYear()}-${v(b.getMonth()+1)}-${v(b.getDate())}`,R=b.getSeconds(),F=`${v(b.getHours())}:${v(b.getMinutes())}${R?`:${v(R)}`:""}`;return`${g}T${F}`}function N(b,a){const v=X(b)||b===""?null:String(b),g=X(a)||a===""?null:String(a);return v===null?g===null?0:1:g===null||v<g?-1:v>g?1:0}}),Le("packages/core/src/compute/handle.js",function(o,oe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return b}});const me=oe("packages/core/src/internal/util.js"),X=me.collator,l=me.defaultCompare,le=me.warnOnce;function ne(a){const v=new Uint32Array(a);for(let g=0;g<a;g++)v[g]=g;return v}function he(a,v){if(v&&typeof v.count=="number")return v.count;if(!a)return 0;if(typeof a.count=="number")return a.count;if(typeof a.length=="number")return a.length;const g=a.values;return a.kind==="multi"&&a.offsets?Math.max(0,a.offsets.length-1):g?a.kind==="bitset"?typeof g.size=="number"?g.size:a.presence&&typeof a.presence.size=="number"?a.presence.size:(le(`count:${a.id}`,`column "${a.id}" is bitset-backed with no declared row count; assuming ${g.length*8}`),g.length*8):g.length:a.presence&&typeof a.presence.size=="number"?a.presence.size:0}const W=new WeakMap;function Z(a){const v=a.constructor;if(!v)return"unknown";const g=W.get(v);if(g)return g;let R="unknown";try{let F=null;typeof v.from=="function"?F=v.from([!1,!0]):(F=new v(8),F.set(1));const p=F&&F.words;p&&p.length&&(p[0]===2?R="lsb":p[0]===64&&(R="msb"))}catch{R="unknown"}return W.set(v,R),R}function fe(a){if(!a)return()=>0;const v=a instanceof Uint8Array?a:a.words;if(v instanceof Uint8Array){const g=a instanceof Uint8Array?"lsb":Z(a);if(g==="lsb")return R=>v[R>>>3]>>>(R&7)&1;if(g==="msb")return R=>v[R>>>3]>>>7-(R&7)&1}return typeof a.get=="function"?g=>a.get(g)?1:0:()=>0}function V(a){return!a||!a.presence?null:fe(a.presence)}function I(a){return a?typeof a.size=="number"?a.size:typeof a.values=="function"?a.values().length:0:0}function U(a,v){return a?typeof a.valueOf=="function"?a.valueOf(v):typeof a.values=="function"?a.values()[v]:null:null}function D(a,v){const g=a.offsets,R=a.values;if(!g||!R)return[];const F=g[v],p=g[v+1];if(!(p>F))return[];const L=a.dict,B=new Array(p-F);for(let H=F;H<p;H++)B[H-F]=L?U(L,R[H]):R[H];return B}function T(a){if(!a)return()=>{};const v=a.values,g=V(a),R=a.kind;if(R==="dictionary"){const F=a.dict;return g?p=>g(p)?U(F,v[p]):null:p=>U(F,v[p])}if(R==="bitset"){const F=fe(v);return g?p=>g(p)?F(p)===1:null:p=>F(p)===1}if(R==="multi")return g?F=>g(F)?D(a,F):null:F=>D(a,F);if(!v&&typeof a.get=="function"){const F=a.get.bind(a);return p=>{const L=F(p);return L===void 0?null:L}}return g?F=>{if(!g(F))return null;const p=v[F];return p===void 0?null:p}:F=>{const p=v[F];return p===void 0?null:p}}function _(a,v){if(a<v)return-1;if(a>v)return 1;if(a===v){const F=Object.is(a,-0),p=Object.is(v,-0);return F===p?0:F?-1:1}const g=Number.isNaN(a),R=Number.isNaN(v);return g&&R?0:g?1:-1}function k(a){const v=X(a);return(g,R)=>{if(g===R)return 0;const F=typeof g,p=typeof R;if(F==="string"&&p==="string")return v.compare(g,R);if(F==="number"&&p==="number")return _(g,R);if(F==="boolean"&&p==="boolean")return g===R?0:g?1:-1;if(g instanceof Date||R instanceof Date){const L=g instanceof Date?g.getTime():Number(g),B=R instanceof Date?R.getTime():Number(R);return _(L,B)}return l(g,R)}}function N(a,v){if(a&&typeof a.ranks=="function")return a.ranks(v);const g=a&&typeof a.values=="function"?a.values():[],R=g.length,F=k(v),p=new Array(R);for(let B=0;B<R;B++)p[B]=B;p.sort((B,H)=>F(g[B],g[H])||B-H);const L=new Uint32Array(R);for(let B=0;B<R;B++)L[p[B]]=B;return L}function b(a){return a==null||typeof a=="number"&&Number.isNaN(a)}}),Le("packages/core/src/compute/filter.js",function(o,oe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return E}});const me=oe("packages/core/src/internal/util.js"),X=me.isBlank,l=me.toArray,le=me.warnOnce,he=oe("packages/core/src/format/date.js").toIsoDate,W=oe("packages/core/src/compute/handle.js"),Z=W.bitReader,fe=W.dictSize,V=W.dictValue,I=W.presenceReader,U=W.valueComparator,D=W.valueReader,T=/^\d{4}-\d{2}-\d{2}$/,_="\0null\0";function k(n,d){const y=n&&n.pool;if(y){const r=y.mask||y.acquireMask||y.acquire||y.take;if(typeof r=="function"){const u=r.call(y,d);if(u&&u.length>=d)return u}}return new Uint8Array(d)}function N(n,d){const y=n&&n.pool;if(!y||!d)return;const r=y.release||y.releaseMask||y.free||y.recycle;typeof r=="function"&&r.call(y,d)}function b(n,d,y){return n.fill(y,0,d),n}function a(n){return n==null||typeof n=="number"&&Number.isNaN(n)}function v(n,d){if(n==null)return n;if(d==="number")return typeof n=="number"?n:Number(n);if(d==="date"||d==="dateString"){const y=he(n);return y===null?g(n):y}return d==="boolean"?typeof n=="boolean"?n:n==="true"||n===1?!0:n==="false"||n===0?!1:!!n:n}function g(n){return n instanceof Date?n.getTime():typeof n=="number"?n:Date.parse(String(n))}function R(n){return typeof n=="number"?n:n instanceof Date?n.getTime():n==null||n===""?NaN:Number(n)}function F(n,d){const y=typeof n=="string"?n:String(n);return d?y:y.toLowerCase()}function p(n,d){return n==null?_:typeof n=="string"?d?n:n.toLowerCase():n instanceof Date?n.getTime():n}function L(n,d,y){const r=new Set;for(const u of l(n)){const h=v(u,y);r.add(p(h,d)),typeof h=="string"&&h!==""&&Number.isFinite(Number(h))?r.add(Number(h)):typeof h=="number"&&Number.isFinite(h)&&r.add(p(String(h),d))}return r}function B(n,d,y){if(n==null||d===null||d===void 0)return n==null&&d==null;const r=typeof n,u=typeof d;return r==="string"&&u==="string"?y?n===d:n.toLowerCase()===d.toLowerCase():n instanceof Date||d instanceof Date?g(n)===g(d):r==="number"&&u==="number"?n===d||Number.isNaN(n)&&Number.isNaN(d):r==="number"&&u==="string"?n===Number(d):r==="string"&&u==="number"?Number(n)===d:r==="boolean"||u==="boolean"?n===d:Array.isArray(n)&&Array.isArray(d)?n.length===d.length&&n.every((h,M)=>B(h,d[M],y)):n===d}function H(n,d){try{if(n instanceof RegExp){const y=n.flags.replace(/[gy]/g,"");return new RegExp(n.source,d||y.includes("i")?y:`${y}i`)}return new RegExp(String(n),d?"":"i")}catch(y){return le(`regex:${String(n)}`,`filter operator "matches" received an invalid pattern: ${String(n)}`,y),null}}function G(n,d){const y=ae(n,d),r=n&&n.type;return r!=="date"&&r!=="dateString"?y:u=>y(typeof u=="string"&&T.test(u)?u:he(u)??u)}function ae(n,d){const y=n&&n.op,r=!!(n&&n.caseSensitive),u=n&&n.type,h=U(d),M=A=>C=>!A(C);switch(y){case"eq":{const A=v(n.value,u);return C=>B(C,A,r)}case"ne":{const A=v(n.value,u);return C=>!B(C,A,r)}case"lt":case"lte":case"gt":case"gte":{const A=v(n.value,u);if(a(A))return()=>!1;const C=y==="lt"?-1:y==="lte"?0:y==="gt"?1:2;return Y=>{if(a(Y))return!1;const ee=h(Y,A);return C===-1?ee<0:C===0?ee<=0:C===1?ee>0:ee>=0}}case"between":case"notBetween":{const A=l(n.value),C=v(A[0],u),Y=v(A[1],u),ee=n.bounds||"[]",ue=ee.charAt(0)!=="(",we=ee.charAt(1)!==")";if(a(C)||a(Y))return y==="between"?()=>!1:()=>!0;const Oe=ke=>{if(a(ke))return!1;const $e=h(ke,C),je=h(ke,Y);return(ue?$e>=0:$e>0)&&(we?je<=0:je<0)};return y==="between"?Oe:M(Oe)}case"in":case"notIn":{const A=L(n.value,r,u),C=Y=>A.has(p(Y,r));return y==="in"?C:M(C)}case"contains":case"notContains":{const A=F(v(n.value,u),r),C=Y=>Y==null?!1:F(Y,r).includes(A);return y==="contains"?C:M(C)}case"startsWith":{const A=F(v(n.value,u),r);return C=>C==null?!1:F(C,r).startsWith(A)}case"endsWith":{const A=F(v(n.value,u),r);return C=>C==null?!1:F(C,r).endsWith(A)}case"matches":{const A=H(n.value,r);return A?C=>C==null?!1:A.test(String(C)):()=>!1}case"blank":return A=>X(A)||Array.isArray(A)&&A.length===0;case"notBlank":return A=>!(X(A)||Array.isArray(A)&&A.length===0);case"containsAny":case"containsNone":{const A=L(n.value,r,u),C=Y=>{const ee=Y==null?[]:l(Y);for(let ue=0;ue<ee.length;ue++)if(A.has(p(ee[ue],r)))return!0;return!1};return y==="containsAny"?C:M(C)}case"containsAll":{const A=l(n.value).map(C=>p(v(C,u),r));return C=>{const Y=C==null?[]:l(C);if(A.length===0)return!0;const ee=new Set(Y.map(ue=>p(ue,r)));for(let ue=0;ue<A.length;ue++)if(!ee.has(A[ue]))return!1;return!0}}default:{const A=E(y);return A?A.compile(n.value):(le(`op:${String(y)}`,`unknown filter operator "${String(y)}"; the condition is refused rather than matching every row`),()=>!1)}}}function J(n,d,y){return G(d,y)(n)}const q=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),ce=new Set(["containsAny","containsAll","containsNone"]);function j(n,d,y){const r=n&&n.op,u=q[r]||r,h=G({...n,op:u,type:d.type},y),M=d.items,A=C=>{const Y=M(C);if(!Y)return!1;for(let ee=0;ee<Y.length;ee++)if(h(Y[ee]))return!0;return!1};return q[r]?C=>!A(C):A}function z(n,d,y,r){const u=I(n);if(u){const A=d?1:0;for(let C=0;C<r;C++)y[C]=u(C)===A?1:0;return y}const h=n.kind;if(h==="float64"||h==="int32"||h==="bitset")return b(y,r,d?1:0);const M=D(n);for(let A=0;A<r;A++){const C=M(A),Y=X(C)||Array.isArray(C)&&C.length===0;y[A]=Y===d?0:1}return y}function t(n,d,y,r){const u=n.dict,h=fe(u),M=new Uint8Array(h);for(let ee=0;ee<h;ee++)M[ee]=d(V(u,ee))?1:0;const A=n.values,C=I(n);if(!C){for(let ee=0;ee<r;ee++)y[ee]=M[A[ee]];return y}const Y=d(null)?1:0;for(let ee=0;ee<r;ee++)y[ee]=C(ee)===1?M[A[ee]]:Y;return y}function c(n,d,y,r){const u=Z(n.values),h=d(!0)?1:0,M=d(!1)?1:0,A=I(n);if(!A){for(let Y=0;Y<r;Y++)y[Y]=u(Y)===1?h:M;return y}const C=d(null)?1:0;for(let Y=0;Y<r;Y++)y[Y]=A(Y)===0?C:u(Y)===1?h:M;return y}function f(n,d,y,r,u){const h=n.values,M=d.type,A=d.op;let C=!0;switch(A){case"eq":case"ne":{const ee=R(v(d.value,M)),ue=typeof d.value=="number"&&Number.isNaN(d.value),we=A==="ne"?1:0;if(ue)for(let Oe=0;Oe<u;Oe++)r[Oe]=(Number.isNaN(h[Oe])?1:0)^we;else for(let Oe=0;Oe<u;Oe++)r[Oe]=(h[Oe]===ee?1:0)^we;break}case"lt":{const ee=R(v(d.value,M));for(let ue=0;ue<u;ue++)r[ue]=h[ue]<ee?1:0;break}case"lte":{const ee=R(v(d.value,M));for(let ue=0;ue<u;ue++)r[ue]=h[ue]<=ee?1:0;break}case"gt":{const ee=R(v(d.value,M));for(let ue=0;ue<u;ue++)r[ue]=h[ue]>ee?1:0;break}case"gte":{const ee=R(v(d.value,M));for(let ue=0;ue<u;ue++)r[ue]=h[ue]>=ee?1:0;break}case"between":case"notBetween":{const ee=l(d.value),ue=R(v(ee[0],M)),we=R(v(ee[1],M)),Oe=d.bounds||"[]",ke=Oe.charAt(0)!=="(",$e=Oe.charAt(1)!==")",je=A==="notBetween"?1:0;if(ke&&$e)for(let xe=0;xe<u;xe++)r[xe]=(h[xe]>=ue&h[xe]<=we?1:0)^je;else if(ke)for(let xe=0;xe<u;xe++)r[xe]=(h[xe]>=ue&h[xe]<we?1:0)^je;else if($e)for(let xe=0;xe<u;xe++)r[xe]=(h[xe]>ue&h[xe]<=we?1:0)^je;else for(let xe=0;xe<u;xe++)r[xe]=(h[xe]>ue&h[xe]<we?1:0)^je;break}case"in":case"notIn":{const ee=new Set;for(const we of l(d.value)){const Oe=R(v(we,M));Number.isNaN(Oe)||ee.add(Oe)}const ue=A==="notIn"?1:0;for(let we=0;we<u;we++)r[we]=(ee.has(h[we])?1:0)^ue;break}default:C=!1;break}if(!C)return!1;const Y=I(n);if(Y){const ee=y(null)?1:0;for(let ue=0;ue<u;ue++)Y(ue)===0&&(r[ue]=ee)}return!0}function e(n,d,y,r){const u=D(n);for(let h=0;h<r;h++)y[h]=d(u(h))?1:0;return y}function x(n,d,y){const r=d.count|0,u=y||k(d,r);if(!n)return b(u,r,1);const h=typeof d.handle=="function"?d.handle(n.col):void 0,M=typeof d.custom=="function"?d.custom:null;if(!h){if(M){for(let ee=0;ee<r;ee++)u[ee]=M(n,ee)?1:0;return u}return le(`filter:col:${String(n.col)}`,`filter references unknown column "${String(n.col)}"; the condition is refused rather than matching every row`),b(u,r,0)}const A=n.op;if(A==="blank"||A==="notBlank")return z(h,A==="notBlank",u,r);const C=typeof d.itemwise=="function"?d.itemwise(n.col):null;if(C&&!E(A)&&!ce.has(A))return e(h,j(n,C,d.locale),u,r);const Y=G(n,d.locale);switch(h.kind){case"dictionary":return t(h,Y,u,r);case"bitset":return c(h,Y,u,r);case"float64":case"int32":return f(h,n,Y,u,r)?u:e(h,Y,u,r);default:return e(h,Y,u,r)}}function S(n,d,y){if(!n)return b(k(d,y),y,1);if(Array.isArray(n.conditions)){const r=n.conditions.filter(M=>M!=null),u=n.op==="or"?"or":n.op==="not"?"not":"and";if(r.length===0)return b(k(d,y),y,1);const h=S(r[0],d,y);for(let M=1;M<r.length;M++){const A=S(r[M],d,y);if(u==="or")for(let C=0;C<y;C++)h[C]|=A[C];else for(let C=0;C<y;C++)h[C]&=A[C];N(d,A)}if(u==="not")for(let M=0;M<y;M++)h[M]^=1;return h}return x(n,d,k(d,y))}function P(n,d){return S(n,d,d.count|0)}function w(n,d){if(!n||!d)return n||null;const y=n;if(Array.isArray(y.conditions)){if((y.op==="or"?"or":y.op==="not"?"not":"and")!=="and")return s(y,d)?null:n;const u=[];for(const h of y.conditions){const M=w(h,d);M&&u.push(M)}return u.length?{...y,op:"and",conditions:u}:null}return y.col===d?null:n}function s(n,d){if(!n||typeof n!="object")return!1;const y=n;if(y.col===d)return!0;if(Array.isArray(y.conditions)){for(const r of y.conditions)if(s(r,d))return!0}return!1}function i(n,d,y){if(y&&y.length>=d){let M=0;for(let A=0;A<d;A++)n[A]&&(y[M++]=A);return y.subarray(0,M)}let r=0;for(let M=0;M<d;M++)r+=n[M]?1:0;const u=new Uint32Array(r);let h=0;for(let M=0;M<d;M++)n[M]&&(u[h++]=M);return u}const O=new Map;function $(n){if(!(!n||typeof n!="object"))for(const[d,y]of Object.entries(n))y&&typeof y.compile=="function"&&O.set(d,y)}function E(n){return typeof n=="string"?O.get(n):void 0}}),Le("packages/modules/charts/viewport-filter.js",function(o,oe){"use strict";Object.defineProperty(o,"VIEWPORT_FILTER_DEBOUNCE_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"resolveViewportFilter",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"viewportTarget",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"viewportBbox",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"sameBbox",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"findColumnCondition",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"viewportCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"conditionBbox",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneTarget",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"mergeViewportCondition",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"adoptedGeoView",{enumerable:!0,get:function(){return _}});const X=oe("packages/core/src/compute/filter.js").pruneColumn,l=150,le=1e-6;function ne(k){const N={enabled:!1,column:null,debounce:l};if(k==null||k===!1)return N;const b=k===!0?{}:k;if(typeof b!="object")return N;const a=typeof b.column=="string"&&b.column?b.column:null,v=Number.isFinite(b.debounce)&&b.debounce>=0?Number(b.debounce):l;return{enabled:!0,column:a,debounce:v}}function he(k,N){return typeof N=="string"&&N?{kind:"geometry",column:N}:k&&typeof k.geometry=="string"&&k.geometry?{kind:"geometry",column:k.geometry}:k&&typeof k.lon=="string"&&k.lon&&typeof k.lat=="string"&&k.lat?{kind:"lonlat",lon:k.lon,lat:k.lat}:null}function W(k,N){if(!k||!N||typeof k.xScale?.invert!="function"||typeof k.yScale?.invert!="function")return null;const b=k.xScale.invert(N.left),a=k.xScale.invert(N.right),v=k.yScale.invert(N.bottom),g=k.yScale.invert(N.top);if(![b,a,v,g].every(Number.isFinite))return null;const R=Math.max(-180,Math.min(b,a)),F=Math.min(180,Math.max(b,a)),p=Math.max(-90,Math.min(v,g)),L=Math.min(90,Math.max(v,g));return!(F>R)||!(L>p)?null:[R,p,F,L]}function Z(k,N){return!k||!N?!k&&!N:Math.abs(k[0]-N[0])<=le&&Math.abs(k[1]-N[1])<=le&&Math.abs(k[2]-N[2])<=le&&Math.abs(k[3]-N[3])<=le}function fe(k,N){if(!k)return null;if(Array.isArray(k.conditions)){for(const b of k.conditions){const a=fe(b,N);if(a)return a}return null}return k.col===N?k:null}function V(k,N,b){const[a,v,g,R]=N,F=b?{meta:{label:b}}:{};return k.kind==="geometry"?{col:k.column,op:"withinBbox",value:[a,v,g,R],...F}:{op:"and",conditions:[{col:k.lon,op:"between",value:[a,g]},{col:k.lat,op:"between",value:[v,R]}],...F}}function I(k,N){if(!k||!N)return null;if(N.kind==="geometry"){const p=fe(k,N.column);if(!p||p.op!=="withinBbox"||!Array.isArray(p.value)||p.value.length<4)return null;const L=p.value.map(Number);return L.every(Number.isFinite)?L:null}const b=fe(k,N.lon),a=fe(k,N.lat);if(!b||b.op!=="between"||!Array.isArray(b.value)||b.value.length<2||!a||a.op!=="between"||!Array.isArray(a.value)||a.value.length<2)return null;const[v,g]=b.value.map(Number),[R,F]=a.value.map(Number);return[v,R,g,F].every(Number.isFinite)?[v,R,g,F]:null}function U(k){return k.kind==="geometry"?[k.column]:[k.lon,k.lat]}function D(k,N){let b=k||null;for(const a of U(N))b=X(b,a);return b}function T(k,N,b){const a=D(k,N);return a?{op:"and",conditions:[...a.conditions||[a],b]}:b}function _(k,N,b,a){if(!k||!N||!b||!a||!(a.scale>0))return null;const[v,g,R,F]=k,[p,L,B,H]=N,G=R-v,ae=F-g,J=B-p,q=H-L;if(!(G>0)||!(ae>0)||!(J>0)||!(q>0))return null;const ce=(p+B)/2,j=(L+H)/2,z=b.left+(ce-v)/G*(b.right-b.left),t=b.bottom-(j-g)/ae*(b.bottom-b.top);if(!Number.isFinite(z)||!Number.isFinite(t))return null;const c=(b.left+b.right)/2,f=(b.top+b.bottom)/2,e=c-z,x=f-t,[S,P]=a.offset,w=[S-e/a.scale,P+x/a.scale],s=Math.min(G/J,ae/q);return!Number.isFinite(s)||s<=0?null:{zoom:Math.min(8,Math.max(1,a.zoom*s)),offset:w}}}),Le("packages/modules/charts/mapview.js",function(o,oe){"use strict";Object.defineProperty(o,"MAP_ENGINE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"DEFAULT_VIEWPORT_CAP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"DENSITY_CELLS_ACROSS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"DENSITY_FIT_PASSES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"FRAME_REFIT_RATIO",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"viewportCap",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"densityCellSize",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"boxSpan",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ringsBox",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"needsRefit",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"frameMoved",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"planMapViewport",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"engineRowsReader",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"frameOf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"capClientBound",{enumerable:!0,get:function(){return c}});const X=oe("packages/core/src/source/pushdown.js").planQuery,le=oe("packages/core/src/source/aggregates.js").resolveAggregatePlan,he=oe("packages/core/src/internal/util.js").warnOnce,W=oe("packages/modules/shared/engine.js"),Z=W.engineSource,fe=W.gridEngineRequest,V=W.loadedAndMatching,I=W.sourceId,D=oe("packages/modules/charts/engine.js").aggregateMode,T=oe("packages/modules/charts/viewport-filter.js"),_=T.conditionBbox,k=T.viewportCondition,N=T.viewportTarget,b=Object.freeze(new Set(["markermap","bubblemap","choropleth"])),a=2e4,v=24,g=8,R=2,F="__viewport_rows",p=/^[A-Za-z_][A-Za-z0-9_$]*$/;function L(f){const e=f?f.viewportCap:void 0;return e==null?a:typeof e=="number"&&Number.isInteger(e)&&e>0?e:(he(`chart:viewportCap:${String(e)}`,`chart viewportCap ${JSON.stringify(e)} is not a positive whole number of rows; the map used ${a}.`),a)}function B(f){const e=Number.isFinite(f)&&f>0?Math.min(360,f):360,x=2**Math.floor(Math.log2(e/v));return Math.min(90,Math.max(2**-20,x))}function H(f){return Math.max(f[2]-f[0],f[3]-f[1])}function G(f){let e=1/0,x=1/0,S=-1/0,P=-1/0;for(const w of f||[])for(const[s,i]of w)!Number.isFinite(s)||!Number.isFinite(i)||(e=Math.min(e,s),S=Math.max(S,s),x=Math.min(x,i),P=Math.max(P,i));return S>=e&&P>=x?[e,x,S,P]:null}function ae(f,e){if(!f||!e)return!1;for(const[x,S]of[[0,2],[1,3]]){const P=f[S]-f[x],w=e[S]-e[x];if(!(P>0)||!(w>0))continue;const s=P/w;if(s>R||s<1/R)return!0}return!1}function J(f,e){if(!f||!e)return!!e;const x=1e-9;return!(e[0]>=f[0]-x&&e[1]>=f[1]-x&&e[2]<=f[2]+x&&e[3]<=f[3]+x)||ae(f,e)}function q(f,e,x){const S=f.columns.get(e);if(!S)return`the ${x} column "${e}" is not a column of the grid`;const P=S.value&&typeof S.value=="object"?S.value:null;return S.computed||P&&(typeof P.get=="function"||typeof P.compute=="function")?`the ${x} column "${e}" is computed by the grid, which the engine cannot reproduce`:(typeof S.field=="string"?S.field:e)!==e||!p.test(e)?`the ${x} column "${e}" is not a plain physical column the engine can name`:""}function ce(f,e,x,S){const P=D(e),w=ge=>({mode:"client",asked:P,reason:ge,refused:P==="engine"});if(P==="client")return{...w("aggregate: 'client' was asked for"),refused:!1};if(!b.has(x))return w(`a "${x}" chart does not draw a viewport`);if(e.rows)return w("the chart was handed its own rows");const s=N(e);if(!s)return w("the map names neither a geometry column nor lon/lat columns");if(s.kind==="geometry"&&(e.lon||e.lat))return w("the map names both a geometry column and lon/lat columns");const i=s.kind==="geometry"?[s.column]:[s.lon,s.lat];for(const ge of i){const Ae=q(f,ge,"placement");if(Ae)return w(Ae)}const O=Z(f);if("reason"in O)return w(O.reason);const{source:$,caps:E}=O,n=$.adapter;if(!n||typeof n.execute!="function")return w("the source's adapter has no execute() to fetch rows with");const d=i[0],y=le([{id:F,col:d,fn:"count"}],$.aggregates);if(y.client.length)return w(`the source computes "count" client-side (${y.client[0].reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to count in the engine`);const r=Array.isArray(S&&S.bbox)?S.bbox:null,u=r?k(s,r):null,h=fe(f,O,u);if("reason"in h)return w(h.reason);if(P==="auto"){const{loaded:ge,total:Ae}=V(f);if(Number.isFinite(Ae)&&ge>=Ae)return w("the grid holds every matching row")}const M=L(e),A=r||_(f.filters&&typeof f.filters.get=="function"?f.filters.get():null,s),C=A?B(H(A)):null,Y=s.kind==="geometry"&&x!=="choropleth"&&Array.isArray(E.buckets)&&E.buckets.includes("grid")&&typeof n.executeGroupedAggregates=="function",ee=x==="choropleth"?"a choropleth draws each shape, and has no density form":s.kind!=="geometry"?"the engine bins a geometry column, and this map places its rows by lon/lat":"the source's adapter cannot bin a geometry column into grid cells (no `buckets` capability)",{request:ue,quick:we}=h,Oe=fe(f,O),ke=JSON.stringify([I($),"request"in Oe?Oe.request.filters:null,we]),$e=JSON.stringify([I($),ue.filters,we,s,M,x]),je=JSON.stringify([$e,Y?C||"fit":0]);return{mode:"engine",asked:P,key:je,rowsKey:$e,baseKey:ke,cap:M,bbox:r,box:A,cellSize:C,run:async ge=>{const Ae=ge?{signal:ge}:{},Me=await $.aggregate({...ue,...Ae},[{id:F,col:d,fn:"count"}]);if(Me&&Array.isArray(Me.client)&&Me.client.length)return{map:!0,refused:`the source counted client-side (${Me.client[0].reason})`};const Ne=Number(Me&&Me.values?Me.values[F]:NaN);if(!Number.isFinite(Ne))return{map:!0,refused:"the engine did not report a count for the view"};if(Ne<=M){const De={...ue,range:{start:0,end:M}},We=X(De,E).pushed,Ue=await n.execute({...We,...Ae},{...De,...Ae});return{map:!0,kind:"rows",rows:(Ue&&Array.isArray(Ue.rows)?Ue.rows:[]).slice(0,M),count:Ne,cap:M,bbox:r,rowsKey:$e}}if(!Y)return{map:!0,kind:"over",count:Ne,cap:M,bbox:r,reason:ee};let Be=C||B(360),Fe=[];for(let De=1;;De++){const We=await $.aggregate({...ue,groupBy:[{col:s.column,bucket:"grid",size:Be}],...Ae},[{id:F,col:d,fn:"count"}]);if(We&&Array.isArray(We.client)&&We.client.length)return{map:!0,kind:"over",count:Ne,cap:M,bbox:r,reason:`the source binned client-side (${We.client[0].reason})`};Fe=[];for(const Pe of We&&We.groups||[]){if(!Pe||Pe.level!==1||!Array.isArray(Pe.keys)||!Array.isArray(Pe.keys[0]))continue;const[Re,Ye]=Pe.keys[0].map(Number),tt=Number(Pe.values?Pe.values[F]:NaN);!Number.isFinite(Re)||!Number.isFinite(Ye)||!(tt>0)||Fe.push({west:Re*Be,south:Ye*Be,east:(Re+1)*Be,north:(Ye+1)*Be,count:tt})}if(C||De>=g)break;const Ue=G(z([],Fe));if(!Ue)break;const He=B(H(Ue));if(He>=Be)break;Be=He}return{map:!0,kind:"density",cells:Fe,count:Ne,cap:M,bbox:r,size:Be}}}}function j(f,e){const x=typeof f.config=="function"?f.config():{},S=x&&typeof x.rowKey=="string"?x.rowKey:null,P=f.permissions&&typeof f.permissions.levelOf=="function"?f.permissions:null,w=new Map,s=e.map(($,E)=>{const n=S&&$&&$[S]!==void 0&&$[S]!==null?$[S]:`engine:${E}`,d=w.has(n)?`engine:${E}`:n,y={key:d,data:$,group:!1};return w.set(d,y),y}),i=$=>{if(!P)return!0;const E=P.levelOf($);return E==="read"||E==="write"},O=($,E)=>{const n=w.get($);if(!n||!i(E))return;const d=f.columns.get(E),y=d&&typeof d.field=="string"?d.field:E,r=n.data?n.data[y]:void 0,u=d&&d.dataType;if(u&&typeof u.toStorage=="function"&&r!==null&&r!==void 0)try{return u.toStorage(r,{colId:E})}catch{return null}return r};return{columns:f.columns,formatting:f.formatting,messages:f.messages,rows:{count:()=>s.length,get:$=>s[$],value:O,text:($,E)=>{const n=O($,E);if(n==null)return"";const d=f.columns.get(E);if(d&&typeof d.formatValue=="function")try{const y=d.formatValue(n,w.get($));if(typeof y=="string")return y}catch{}return String(n)}}}}function z(f,e=[]){let x=1/0,S=1/0,P=-1/0,w=-1/0;for(const n of f||[])!Number.isFinite(n.lon)||!Number.isFinite(n.lat)||(x=Math.min(x,n.lon),P=Math.max(P,n.lon),S=Math.min(S,n.lat),w=Math.max(w,n.lat));for(const n of e||[])x=Math.min(x,n.west),P=Math.max(P,n.east),S=Math.min(S,n.south),w=Math.max(w,n.north);if(!(P>=x)||!(w>=S))return null;const s=(n,d)=>Math.max(-d,Math.min(d,n)),i=s(x,180),O=s(P,180),$=s(S,90),E=s(w,90);return[[[i,$],[O,$],[O,E],[i,E]]]}function t(f,e){if(!e)return!0;const[x,S,P,w]=e,s=(i,O)=>i>=x&&i<=P&&O>=S&&O<=w;if(f.point)return s(f.point[0],f.point[1]);for(const i of f.polygons||[])for(const O of i)for(const[$,E]of O)if(s($,E))return!0;return!1}function c(f,e,x,S){const P=L(x),w=S&&Array.isArray(S.bbox)?S.bbox:null;if(!e||!b.has(f))return{bound:e,viewport:null};if(f==="choropleth"){const h=e.features||[];if(h.length<=P)return{bound:e,viewport:null};let M=0;for(const Y of h)t(Y,w)&&M++;if(M<=P)return{bound:e,viewport:null};const A=[];for(const Y of h){Y.point&&A.push({lon:Y.point[0],lat:Y.point[1]});for(const ee of Y.polygons||[])for(const ue of ee)for(const[we,Oe]of ue)A.push({lon:we,lat:Oe})}const C="a choropleth draws each shape, and has no density form";return{bound:{...e,features:[],empty:!1,over:{count:M,cap:P,reason:C},frame:e.frame||z(A)},viewport:{rows:0,matched:M,cap:P,binned:!1,cells:0,over:C,bbox:w?[...w]:null,computed:"client"}}}const s=e.points||[];if(s.length<=P)return{bound:e,viewport:null};const[i,O,$,E]=w||[-1/0,-1/0,1/0,1/0],n=s.filter(h=>h.lon>=i&&h.lon<=$&&h.lat>=O&&h.lat<=E);if(n.length<=P)return{bound:e,viewport:null};const d=w||G([n.map(h=>[h.lon,h.lat])]),y=B(d?H(d):360),r=new Map;for(const h of n){const M=Math.floor(h.lon/y),A=Math.floor(h.lat/y),C=`${M}:${A}`,Y=r.get(C)||{west:M*y,south:A*y,east:(M+1)*y,north:(A+1)*y,count:0};Y.count++,r.set(C,Y)}const u=[...r.values()];return{bound:{...e,density:{cells:u,size:y},frame:e.frame||z(s)},viewport:{rows:0,matched:n.length,cap:P,binned:!0,cells:u.length,over:null,bbox:w?[...w]:null,computed:"client"}}}}),Le("packages/modules/deckgl/index.js",function(o,oe){"use strict";Object.defineProperty(o,"bindDeck",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return F}});const X=oe("packages/core/src/internal/util.js").warnOnce,le=oe("packages/modules/shared/engine.js").EngineFlight,ne=oe("packages/modules/charts/mapview.js"),he=ne.planMapViewport,W=ne.engineRowsReader,Z=ne.viewportCap,fe=oe("packages/modules/charts/viewport-filter.js"),V=fe.resolveViewportFilter,I=fe.viewportTarget,U=fe.viewportCondition,D=fe.mergeViewportCondition,T=fe.conditionBbox,_=fe.pruneTarget,k=fe.sameBbox;function N(p){if(!Array.isArray(p)||p.length<4)return null;const[L,B,H,G]=p.map(Number);if(![L,B,H,G].every(Number.isFinite))return null;const ae=Math.max(-180,Math.min(L,H)),J=Math.min(180,Math.max(L,H)),q=Math.max(-90,Math.min(B,G)),ce=Math.min(90,Math.max(B,G));return!(J>ae)||!(ce>q)?null:[ae,q,J,ce]}function b(p,L){const B=J=>typeof J=="string"&&J!==""&&!!(p.columns&&p.columns.get(J));if(!L||typeof L!="object")return"options.position is missing; pass { lon, lat } or { geometry } naming the grid's columns";const{lon:H,lat:G,geometry:ae}=L;return ae!==void 0?B(ae)?{geometry:ae}:`options.position.geometry ${JSON.stringify(ae)} is not a column of the grid`:H!==void 0||G!==void 0?B(H)?B(G)?{lon:H,lat:G}:`options.position.lat ${JSON.stringify(G)} is not a column of the grid`:`options.position.lon ${JSON.stringify(H)} is not a column of the grid`:"options.position names neither { lon, lat } nor { geometry }"}function a(p){if(typeof p.getViewports!="function")return null;try{const L=p.getViewports(),B=Array.isArray(L)?L[0]:null;return B&&typeof B.getBounds=="function"?B:null}catch{return null}}function v(p){const L=a(p);if(!L)return null;try{return N(L.getBounds())}catch{return null}}function g(){return{update(){},layers(){return[]},destroy(){}}}function R(p,L){const B=L&&typeof L=="object"?L:{},H=B.deck;if(!H||typeof H.setProps!="function")return X("deckgl:deck","bindDeck: options.deck has no setProps(); pass the page's deck.gl Deck instance. Nothing was bound."),g();if(typeof B.layers!="function")return X("deckgl:layers","bindDeck: options.layers is not a function; pass (rows, ctx) => Layer[] built with your deck.gl classes. Nothing was bound."),g();const G=p?b(p,B.position):"there is no grid";if(typeof G=="string")return X("deckgl:position",`bindDeck: the grid has no position: ${G}. Nothing was bound.`),g();const ae=B.layers,J={...G,...B.viewportCap!==void 0?{viewportCap:B.viewportCap}:{}},q=V(B.viewportFilter),ce=I(J,null),j=new le,z=globalThis;let t=[],c=0,f=0,e=!1,x=null,S=!1;const P=h=>{const M=[],A=h.rows.count();for(let C=0;C<A;C++){const Y=h.rows.get(C);if(!Y||Y.group||Y.data===null||Y.data===void 0)continue;let ee=null;if(G.geometry){const ue=h.rows.value(Y.key,G.geometry);ee=ue&&typeof ue=="object"?ue:null}else{const ue=h.rows.value(Y.key,G.lon),we=h.rows.value(Y.key,G.lat),Oe=je=>je==null||je==="",ke=Number(ue),$e=Number(we);ee=!Oe(ue)&&!Oe(we)&&Number.isFinite(ke)&&Number.isFinite($e)?{type:"Point",coordinates:[ke,$e]}:null}ee&&M.push({type:"Feature",geometry:ee,properties:Y.data})}return M},w=()=>{const h=[];p.rows.forEach(A=>{A&&!A.group&&A.data!==null&&A.data!==void 0&&h.push(A)});const M={rows:{count:()=>h.length,get:A=>h[A],value:(A,C)=>p.rows.value(A,C)}};return{rows:h.map(A=>A.data),reader:M}},s=()=>{if(e)return;c&&(i(c),c=0);const h=v(H),M=Z(J),A=he(p,J,"markermap",{bbox:h});let C=[],Y=[],ee=!1,ue=!1,we;if(A.mode==="engine"){const $e=j.answer(A.key);$e||j.ask(A.key,A.run,()=>O());const je=$e||j.last();ue=j.busy;const xe=je&&!("error"in je)?je.result:null;if(xe&&xe.kind==="rows")C=xe.rows,Y=P(W(p,C)),we={rows:C.length,matched:xe.count,cap:M,binned:!1,cells:0,over:null,bbox:xe.bbox?[...xe.bbox]:null,computed:"engine"};else if(xe&&xe.kind==="density")C=xe.cells,ee=!0,we={rows:0,matched:xe.count,cap:M,binned:!0,cells:C.length,over:null,bbox:xe.bbox?[...xe.bbox]:null,computed:"engine"};else if(xe&&xe.kind==="over")X("deckgl:over",`bindDeck: deck's view holds ${xe.count} matching rows, more than its viewportCap of ${xe.cap}, and ${xe.reason}, so no rows were handed to the layers. Zoom in, narrow the filter, or raise viewportCap.`),we={rows:0,matched:xe.count,cap:M,binned:!1,cells:0,over:xe.reason,bbox:xe.bbox?[...xe.bbox]:null,computed:"engine"};else{const ge=xe&&xe.refused?String(xe.refused):je&&"error"in je?String(je.error?.message||je.error):null;we={rows:0,matched:0,cap:M,binned:!1,cells:0,over:ge,bbox:h?[...h]:null,computed:"engine"}}}else{const $e=w();C=$e.rows,Y=P($e.reader),we={rows:C.length,matched:C.length,cap:M,binned:!1,cells:0,over:null,bbox:h?[...h]:null,computed:"client"}}const Oe={grid:p,position:{...G},binned:ee,pending:ue,features:Y,provenance:we},ke=ae(C,Oe);t=Array.isArray(ke)?ke:[],H.setProps({layers:t})};function i(h){typeof z.cancelAnimationFrame=="function"&&z.cancelAnimationFrame(h),clearTimeout(h)}function O(){if(e||c)return;c=(typeof z.requestAnimationFrame=="function"?z.requestAnimationFrame.bind(z):M=>setTimeout(M,16))(()=>{c=0,s()})||1}const $=()=>{if(!q.enabled||!ce)return;const h=T(p.filters.get(),ce);if(!h){x=null;return}if(k(h,x))return;x=h;const M=a(H);if(!M||typeof M.fitBounds!="function")return;const[A,C,Y,ee]=h;let ue;try{ue=M.fitBounds([[A,C],[Y,ee]])}catch{return}if(!ue)return;const we={longitude:ue.longitude,latitude:ue.latitude,zoom:ue.zoom,pitch:0,bearing:0},Oe=H.props||{};Oe.viewState?H.setProps({viewState:{...Oe.viewState,...we}}):H.setProps({initialViewState:{...Oe.initialViewState||{},...we}})},E=()=>{$(),O()},n=()=>{if(f=0,e||!ce)return;const h=v(H);if(!h||k(h,x))return;const M=p.messages&&typeof p.messages.t=="function"?p.messages.t("chart.viewportFilter.label"):void 0,A=D(p.filters.get(),ce,U(ce,h,M));x=h,p.filters.set(A)},d=H.props&&typeof H.props.onViewStateChange=="function"?H.props.onViewStateChange:null,y=!!a(H)||typeof H.getViewports=="function",r=h=>{const M=d?d(h):void 0,A=h&&h.interactionState,C=!!A&&typeof A=="object"&&Object.values(A).some(Boolean);return!e&&C&&(clearTimeout(f),f=setTimeout(()=>{q.enabled?n():f=0,O()},q.debounce)),M};q.enabled&&!y&&!S&&(S=!0,X("deckgl:viewports","bindDeck: viewportFilter is on but options.deck has no getViewports(), so its view cannot be read as a box; the grid is not filtered by it.")),y&&H.setProps({onViewStateChange:r});const u=["model:changed","rows:changed"].map(h=>{const M=p.on(h,E);return typeof M=="function"?M:()=>p.off(h,E)});return $(),s(),{update:s,layers:()=>t,destroy(){if(!e){e=!0,c&&i(c),c=0,clearTimeout(f),j.close();for(const h of u)h();if(y&&H.setProps({onViewStateChange:d}),x&&ce){const h=p.filters.get(),M=_(h,ce);M!==h&&p.filters.set(M)}x=null}}}}const F=R});const Dt=Lt("packages/modules/deckgl/index.js"),rn=Dt.bindDeck;var on=Dt.default;export{rn as bindDeck,on as default};
|
|
335
|
+
`}function K(te){const pe=te.documentElement;if(!pe||pe.getAttribute(ge))return;pe.setAttribute(ge,"1");const V=te.createElement("style");V.textContent=ke(),(te.head||te.body||pe).appendChild(V)}}),Ge("packages/modules/charts/axis.js",function(o,ue){"use strict";Object.defineProperty(o,"pinXDomain",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"TICK_FLOOR",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"tickFloor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"fitBandLabels",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"normaliseAxes",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"tickValues",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"tickLabeller",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"drawAxisTitle",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"labelEvery",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"drawMeasureAxis",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"drawCategoryAxis",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"leftLabelRoom",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"setLabelText",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"drawBandLabels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"drawContinuousAxis",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"drawAxisLines",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"createGroups",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"MARK_OVERHANG",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"overhangFor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"setPlotClip",{enumerable:!0,get:function(){return y}});const re=ue("packages/modules/charts/frame.js").Pool,l=ue("packages/modules/charts/svg.js"),ge=l.attrs,ae=l.round,ke=l.setText,K=l.svg,te=ue("packages/modules/charts/typography.js"),pe=te.applySize,V=te.CHAR_RATIO,B=te.truncateTo,C=ue("packages/modules/charts/styles.js").NS,L=ue("packages/modules/charts/scale.js"),F=L.toNumber,x=L.toTime,p=ue("packages/core/src/internal/util.js").warnOnce;function i(s,a,A){const P=a&&a.kind==="time"?x:F,T=N=>N==null||N===""?null:P(N),n=T(A&&A.min),h=T(A&&A.max);if(n===null&&h===null)return s;if(n!==null&&h!==null)return n<h?{min:n,max:h}:(p("chart.axis.x.domain.inverted",`axis.x.min (${n}) is not below axis.x.max (${h}), which is a mirrored axis rather than a narrow one, so both were ignored and the x domain was taken from the data. On a time axis both are epoch milliseconds.`),s);const w=n!==null?n:s.min,r=h!==null?h:s.max;if(w<r)return{min:w,max:r};const u=Math.abs(s.max-s.min)||1;return p("chart.axis.x.domain.beyond",`axis.x.${n!==null?"min":"max"} is outside the x values entirely, so the plot is empty. The pin was kept and the other edge moved to hold the axis width; check the units (a time axis is pinned in epoch milliseconds).`),n!==null?{min:w,max:w+u}:{min:r-u,max:r}}const S=6,d=9;function W(s){const a=s&&s.ownerDocument,A=a&&a.defaultView;if(!A||typeof A.getComputedStyle!="function")return d;const P=A.getComputedStyle(s).getPropertyValue("--lattice-chart-tick-min"),T=parseFloat(P);return Number.isFinite(T)&&T>0?T:d}function I(s){const{size:a,floor:A,slot:P,per:T}=s,n=Number.isFinite(s.every)&&s.every>0?Number(s.every):null;if(n!==null&&n!==1)return{size:a,every:n,thinned:!1};if(!(P>0)||!(T>0))return{size:a,every:1,thinned:!1};const h=Math.min(a,P/T);return h>=A?{size:h,every:1,thinned:!1}:{size:A,every:Math.max(1,Math.ceil(A*T/P)),thinned:!0}}function b(s,a){const A=Math.ceil(s/a),P=s-A;p("chart.axis.band.thinned",`${P} of ${s} band labels were hidden: even the smallest font (--lattice-chart-tick-min) could not make them all fit. Set axis.x.every or axis.y.every to choose which ones show.`)}const H=1.2;function z(s){if(s===!1){const P={labels:!1,grid:!1};return{x:{...P},y:{...P},y2:{...P}}}const a=s&&typeof s=="object"?s:{},A=P=>typeof P=="string"?{title:P}:P&&typeof P=="object"?{...P}:{};return{x:A(a.x),y:A(a.y),y2:A(a.y2||a.right)}}function q(s,a){const A=a&&a.ticks;if(Array.isArray(A)){const T=s.domain;return!T||T.min===void 0?A:A.filter(n=>Number(n)>=T.min&&Number(n)<=T.max)}const P=Number.isFinite(A)&&A>0?Number(A):5;return s.ticks(P)}function U(s,a,A,P){const T=s&&s.format;return typeof T=="function"?n=>String(T(n)):typeof T=="string"&&A&&A.formatting&&A.formatting.format?n=>String(A.formatting.format(n,T)):P&&P.format&&P.format.pattern&&typeof P.formatValue=="function"?n=>String(P.formatValue(n,null)):a.tick}function oe(s){if(!s.text)return;const a=s.side==="left"||s.side==="right"?s.plot.height:s.plot.width,A=Number.isFinite(a)?B(String(s.text),Math.max(0,a),s.size):String(s.text);if(!A||A==="…")return;const P=K(s.group.ownerDocument,"text",{class:`${C}__axis-title`});if(pe(P,s.size),s.side==="left"){const T=Math.max(s.size,s.plot.left-s.plot.gutter.left+s.size),n=s.plot.top+s.plot.height/2;ge(P,{transform:`translate(${ae(T)} ${ae(n)}) rotate(-90)`,"text-anchor":"middle"})}else if(s.side==="right"){const T=s.plot.right+s.plot.gutter.right-s.size,n=s.plot.top+s.plot.height/2;ge(P,{transform:`translate(${ae(T)} ${ae(n)}) rotate(90)`,"text-anchor":"middle"})}else ge(P,{x:ae(s.plot.left+s.plot.width/2),y:ae(s.plot.bottom+s.plot.gutter.bottom-2),"text-anchor":"middle"});ke(P,A),A!==String(s.text)&&P.setAttribute("aria-label",String(s.text)),s.group.appendChild(P)}function ee(s){const{values:a,scale:A,size:P,horizontal:T,label:n}=s;if(a.length<2)return 1;let h=1/0;for(let r=1;r<a.length;r++){const u=Math.abs(A.of(a[r])-A.of(a[r-1]));Number.isFinite(u)&&u<h&&(h=u)}if(!Number.isFinite(h))return 1;if(h<=0)return a.length;let w=P*H+2;if(T){let r=0;for(const u of a){const N=String(n(u)||"").length*P*V;N>r&&(r=N)}w=r+S}return Math.max(1,Math.ceil(w/h))}function Z(s){const{gridGroup:a,axisGroup:A,plot:P,scale:T,format:n}=s,h=s.config||{},w=q(T,h),r=U(h,n,s.grid),u=s.size||11,N=ee({values:w,scale:T,size:u,horizontal:!!s.horizontal,label:r}),G=h.grid===!1?null:a,j=G?new re(G):null,R=new re(A);for(let J=0;J<w.length;J++){const ne=w[J],ce=ae(T.of(ne)),Me=ne===0,Le=J%N!==0;if(s.horizontal){if(j&&ge(j.next("line",`${C}__gridline`),{x1:ce,x2:ce,y1:ae(P.top),y2:ae(P.bottom),"stroke-opacity":Me?1:.6,"stroke-width":Me?1.5:1}),h.labels===!1||Le)continue;const Ne=R.next("text",`${C}__tick`);pe(Ne,u),ge(Ne,{x:ce,y:ae(P.bottom+S),"text-anchor":"middle","dominant-baseline":"hanging"}),ke(Ne,r(ne))}else{if(j&&ge(j.next("line",`${C}__gridline`),{x1:ae(P.left),x2:ae(P.right),y1:ce,y2:ce,"stroke-opacity":Me?1:.6,"stroke-width":Me?1.5:1}),h.labels===!1||Le)continue;const Ne=R.next("text",`${C}__tick`);pe(Ne,u);const Re=s.side==="right";ge(Ne,{x:ae(Re?P.right+S:P.left-S),y:ce,"text-anchor":Re?"start":"end","dominant-baseline":"middle"}),ke(Ne,r(ne))}}return j?j.finish():new re(a).finish(),R.finish(),w}function de(s){const{group:a,plot:A,scale:P,labels:T}=s,n=s.config||{};if(n.labels===!1){new re(a).finish();return}const h=new re(a),w=P.domain,r=P.step,u=n.rotate===void 0||n.rotate==="auto"?s.rotated:!!n.rotate,N=u?I({size:s.fontSize,floor:W(a),slot:r,per:Math.SQRT2,every:n.every}):{size:s.fontSize,every:Number.isFinite(n.every)&&n.every>0?Number(n.every):1,thinned:!1},{size:G,every:j}=N;N.thinned&&b(w.length,j);const R=r*j;for(let J=0;J<w.length;J++){const ne=ae(P.centre(w[J]));if(Number.isNaN(ne)||J%j!==0)continue;const ce=h.next("text",`${C}__tick`);pe(ce,G);const Me=T[J]===void 0?"":T[J];u?(ge(ce,{x:0,y:0,"text-anchor":"end","dominant-baseline":"middle",transform:`translate(${ne} ${ae(A.bottom+S)}) rotate(-45)`}),D(ce,Me,Math.max(0,A.gutter.bottom-S)*Math.SQRT2,G)):(ge(ce,{x:ne,y:ae(A.bottom+S),"text-anchor":"middle","dominant-baseline":"hanging",transform:null}),D(ce,Me,R,G))}h.finish()}function E(s){return Math.max(0,(s.gutter?s.gutter.left:s.left)-S)}function D(s,a,A,P){const T=String(a??""),n=B(T,A,P);return ke(s,n),n!==T?s.setAttribute("aria-label",T):s.removeAttribute("aria-label"),n}function t(s){const{group:a,plot:A,scale:P,labels:T}=s,n=s.config||{},h=new re(a),w=P.domain,r=E(A),u=I({size:s.fontSize,floor:W(a),slot:P.step,per:H,every:n.every}),{size:N,every:G}=u;u.thinned&&b(w.length,G);for(let j=0;j<w.length;j++){if(j%G!==0)continue;const R=ae(P.centre(w[j]));if(Number.isNaN(R))continue;const J=h.next("text",`${C}__tick`);ge(J,{x:ae(A.left-S),y:R,"text-anchor":"end","dominant-baseline":"middle"}),pe(J,N),D(J,T[j],r,N)}h.finish()}function f(s){const{group:a,plot:A,scale:P,format:T}=s,n=s.config||{};if(n.labels===!1){new re(a).finish();return}const h=U(n,T,s.grid,s.column),w=new re(a);for(const r of q(P,n)){const u=ae(P.of(r));if(u<A.left-1||u>A.right+1)continue;const N=w.next("text",`${C}__tick`);pe(N,s.size||11),ge(N,{x:u,y:ae(A.bottom+S),"text-anchor":"middle","dominant-baseline":"hanging"}),ke(N,h(r))}w.finish()}function c(s){const{group:a,plot:A}=s,P=s.side==="right"?A.right:A.left,T=new re(a);ge(T.next("line"),{x1:ae(P),x2:ae(P),y1:ae(A.top),y2:ae(A.bottom)}),ge(T.next("line"),{x1:ae(A.left),x2:ae(A.right),y1:ae(A.bottom),y2:ae(A.bottom)}),T.finish()}let e=0;function v(s,a){const A=`${C}-plot-clip-${++e}`,P=K(s,"rect"),T=K(s,"clipPath",{id:A});T.appendChild(P);const n=`${C}-box-clip-${e}`,h=K(s,"clipPath",{id:n});h.appendChild(K(s,"rect",{x:0,y:0,width:"100%",height:"100%"}));const w=K(s,"defs");w.appendChild(T),w.appendChild(h);const r={grid:K(s,"g",{class:`${C}__grid`}),marks:K(s,"g",{class:`${C}__marks`}),rules:K(s,"g",{class:`${C}__axis`}),axis:K(s,"g",{class:`${C}__axis`}),labels:K(s,"g",{class:`${C}__labels`}),overlay:K(s,"g",{class:`${C}__overlay`}),clip:P,clipId:A,boxClipId:n};a.appendChild(w);for(const u of["grid","marks","rules","axis","labels","overlay"])a.appendChild(r[u]);return r}const $=30;function M(s){return s==="bubble"?$:s==="scatter"?6:3}function y(s,a,A){if(!s||!s.marks||!s.clip)return;if(!a||!Number.isFinite(a.width)||!Number.isFinite(a.height)){s.marks.removeAttribute("clip-path");return}const P=Number.isFinite(A)&&A>=0?Number(A):$;ge(s.clip,{x:ae(a.left-P),y:ae(a.top-P),width:ae(Math.max(0,a.width)+P*2),height:ae(Math.max(0,a.height)+P*2)}),s.marks.setAttribute("clip-path",`url(#${s.clipId})`)}}),Ge("packages/modules/charts/format.js",function(o,ue){"use strict";Object.defineProperty(o,"precisionFor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"axisNumber",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"r2Digits",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"dateFormatFor",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"formatters",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"measureText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"measureFormat",{enumerable:!0,get:function(){return pe}});const re=ue("packages/modules/charts/scale.js").timeStepFor;function l(V){if(!Number.isFinite(V)||V<=0)return 0;const B=Math.ceil(-Math.log10(V));return Math.min(6,Math.max(0,B))}function ge(V,B,Y=0){return Number.isFinite(V)?Math.abs(V)>=1e4?B.number(V,{notation:"compact",maximumFractionDigits:1}):B.number(V,{minimumFractionDigits:Y,maximumFractionDigits:Y}):""}function ae(V,B){const Y=V&&V.messages;return!Y||typeof Y.number!="function"?Number(B).toFixed(2):Y.number(B,{minimumFractionDigits:2,maximumFractionDigits:2})}function ke(V){const Y=V>0?re(V):0;return Y>0&&Y<1e3?{minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}:Y>0&&Y<6e4?{hour:"2-digit",minute:"2-digit",second:"2-digit"}:V<=864e5?{hour:"2-digit",minute:"2-digit"}:V<=180*864e5?Y>0&&Y<864e5?{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short"}:V<=3*365*864e5?{month:"short",year:"numeric"}:{year:"numeric"}}function K(V,B,Y){const C=V.messages,L=C.locale,x=Y&&Y.format&&Y.format.timeZone||V.get("timeZone")||void 0;if(B.kind==="time"){const p=ke(B.span||0),i=new Intl.DateTimeFormat(L,x?{...p,timeZone:x}:p),S=new Intl.DateTimeFormat(L,x?{dateStyle:"medium",timeStyle:"short",timeZone:x}:{dateStyle:"medium",timeStyle:"short"});return{tick:d=>Number.isFinite(Number(d))?i.format(new Date(Number(d))):"",value:d=>Number.isFinite(Number(d))?S.format(new Date(Number(d))):""}}const _=l(B.step||0);return{tick:p=>typeof p=="number"?ge(p,C,_):String(p??""),value:p=>typeof p=="number"?C.number(p):String(p??"")}}function te(V,B){if(V==null||!Number.isFinite(V))return"";const Y=Math.abs(V)>=1e-6?Number(V.toPrecision(6)):V;return B.number(Y)}function pe(V,B,Y){return V==null||!Number.isFinite(Number(V))?"":B&&B.format&&typeof B.formatValue=="function"?String(B.formatValue(V,null)):te(Number(V),Y&&Y.messages)}}),Ge("packages/modules/charts/labels.js",function(o,ue){"use strict";Object.defineProperty(o,"resolveLabels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"collides",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"placeLabels",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"labelText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"drawAnchoredLabels",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"drawDataLabels",{enumerable:!0,get:function(){return S}});const re=ue("packages/modules/charts/frame.js").Pool,ge=ue("packages/modules/charts/format.js").measureText,ae=ue("packages/modules/charts/svg.js"),ke=ae.attrs,K=ae.round,te=ae.setText,V=ue("packages/modules/charts/styles.js").NS,B=ue("packages/modules/charts/typography.js"),Y=B.applySize,C=B.textWidth,L=4;function F(d){const W=d&&d.labels;if(!W)return{show:!1,names:W!==!1,position:"outside",format:null,minGap:2,total:!1};const I=typeof W=="object"?W:{};return{show:!0,names:!0,position:["outside","inside","auto"].includes(I.position)?I.position:"outside",format:I.format||null,minGap:Number.isFinite(I.minGap)?Number(I.minGap):2,total:!!I.total}}function x(d,W,I){for(const b of W)if(d.x-I<b.x+b.width&&d.x+d.width+I>b.x&&d.y-I<b.y+b.height&&d.y+d.height+I>b.y)return!0;return!1}function _(d){const{points:W,plot:I,size:b}=d,H=d.minGap===void 0?2:d.minGap,z=[],q=[];for(const U of W){if(U.px===void 0||U.py===void 0)continue;const oe=d.text(U);if(!oe)continue;const ee=C(oe,b),Z=b;let de=U.px,E=U.py-L,D="middle",t=!1;d.horizontal?(de=U.px+L,E=U.py,D="start",d.position!=="outside"&&U.pbase!==void 0&&Math.abs(U.px-U.pbase)>ee+L*2&&(de=U.px-L,D="end",t=!0)):d.position!=="outside"&&U.pbase!==void 0&&Math.abs(U.pbase-U.py)>Z+L*2&&(E=U.py+Z+L,t=!0);const f=()=>({x:D==="middle"?de-ee/2:D==="end"?de-ee:de,y:E-Z,width:ee,height:Z});let c=f();!(c.y>=I.top-1)&&!t&&!d.horizontal&&U.pbase!==void 0&&Math.abs(U.pbase-U.py)>Z+L*2&&(E=U.py+Z+L,t=!0,c=f()),!(c.x+c.width<=I.right+1)&&!t&&d.horizontal&&U.pbase!==void 0&&Math.abs(U.px-U.pbase)>ee+L*2&&(de=U.px-L,D="end",t=!0,c=f()),!(c.x<I.left-1||c.x+c.width>I.right+1)&&(c.y<I.top-1||c.y+c.height>I.bottom+Z||x(c,z,H)||(z.push(c),q.push({x:K(de),y:K(E),text:oe,anchor:D,inside:t})))}return q}function p(d,W,I){return d==null?"":typeof W.format=="function"?String(W.format(d)):typeof W.format=="string"&&I&&I.formatting&&I.formatting.format?String(I.formatting.format(d,W.format)):ge(d,I&&I.messages)}function i(d){const W=new re(d.group),I=d.minGap===void 0?2:d.minGap,b=d.size,H=[];let z=0;for(const q of d.anchors){if(!q||!q.text)continue;const U=q.width===void 0?C(q.text,d.size):q.width,oe=q.anchor||"middle",Z={x:oe==="end"?q.x-U:oe==="start"?q.x:q.x-U/2,y:q.y-b/2,width:U,height:b};if(d.plot&&(Z.x<d.plot.left-1||Z.x+Z.width>d.plot.right+1||Z.y<d.plot.top-1||Z.y+Z.height>d.plot.bottom+1)||q.width!==void 0&&U>q.width||q.height!==void 0&&b>q.height||x(Z,H,I))continue;H.push(Z);const de=W.next("text",q.className||`${V}__data-label`);Y(de,d.size),ke(de,{x:K(q.x),y:K(q.y),"text-anchor":oe,"dominant-baseline":q.baseline||"middle","data-inside":q.inside?"true":null}),te(de,q.text),z++}return W.finish(),z}function S(d){const W=new re(d.group),{options:I}=d;let b=0;const H=z=>typeof I.format=="function"&&z.y!==null&&z.y!==void 0?String(I.format(z.y,z)):p(z.y,I,d.grid);for(const z of d.series){const q=_({points:z.points,plot:d.plot,size:d.size,position:I.position,horizontal:d.horizontal,minGap:I.minGap,text:H});for(const U of q){const oe=W.next("text",`${V}__data-label`);Y(oe,d.size),ke(oe,{x:U.x,y:U.y,"text-anchor":U.anchor,"data-inside":U.inside?"true":null}),te(oe,U.text),b++}}return W.finish(),b}}),Ge("packages/modules/charts/dense.js",function(o,ue){"use strict";Object.defineProperty(o,"CANVAS_THRESHOLD",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"downsample",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"markCount",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"wantsCanvas",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"paintDense",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"sizeCanvas",{enumerable:!0,get:function(){return ke}});const xe=3e3;function re(K,te){const pe=K.length;if(!Number.isFinite(te)||te>=pe||te<3||pe<3)return K;const V=[K[0]],B=(pe-2)/(te-2);let Y=0;for(let C=0;C<te-2;C++){const L=Math.floor(C*B)+1,F=Math.min(Math.floor((C+1)*B)+1,pe-1),x=F,_=Math.min(Math.floor((C+2)*B)+1,pe);let p=0,i=0,S=0;for(let b=x;b<_;b++){const H=K[b];!H||!Number.isFinite(H.y)||(p+=H.x,i+=H.y,S++)}S&&(p/=S,i/=S);const d=K[Y];if(L>=F)continue;let W=L,I=-1;for(let b=L;b<F;b++){const H=K[b];if(!H||!Number.isFinite(H.y))continue;const z=Math.abs((d.x-p)*(H.y-d.y)-(d.x-H.x)*(i-d.y));z>I&&(I=z,W=b)}W<=Y||(V.push(K[W]),Y=W)}return V.push(K[pe-1]),V}function l(K){let te=0;for(const pe of K)te+=pe.points.length;return te}function ge(K){if(K.canvas===!0)return!0;if(K.canvas===!1)return!1;const te=Number.isFinite(K.canvas)?Number(K.canvas):xe;return l(K.series)>te}function ae(K){const{context:te,series:pe,ratio:V}=K;te.save(),te.scale(V,V);for(const B of pe){const Y=K.colour(B.index);if(K.type==="scatter"||K.type==="bubble"){te.fillStyle=Y;for(const L of B.points)L.px!==void 0&&(te.beginPath(),te.arc(L.px,L.py,L.pr||2,0,Math.PI*2),te.fill());continue}te.strokeStyle=Y,te.lineWidth=2,te.lineJoin="round",te.beginPath();let C=!1;for(const L of B.points){if(L.px===void 0||L.py===void 0){C=!1;continue}C?te.lineTo(L.px,L.py):te.moveTo(L.px,L.py),C=!0}te.stroke()}te.restore()}function ke(K){const{canvas:te}=K;return te.width=Math.max(1,Math.round(K.width*K.ratio)),te.height=Math.max(1,Math.round(K.height*K.ratio)),te.style&&(te.style.width=`${K.width}px`,te.style.height=`${K.height}px`),typeof te.getContext=="function"?te.getContext("2d"):null}}),Ge("packages/modules/charts/annotations.js",function(o,ue){"use strict";Object.defineProperty(o,"overlayLayer",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"annotationValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"annotationAxis",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"annotationText",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"drawAnnotations",{enumerable:!0,get:function(){return oe}});const re=ue("packages/modules/charts/frame.js").Pool,l=ue("packages/modules/charts/scale.js"),ge=l.isNumber,ae=l.toNumber,ke=l.toTime,K=ue("packages/modules/charts/svg.js"),te=K.attrs,pe=K.path,V=K.round,B=K.setText,Y=K.SVG_NS,L=ue("packages/modules/charts/styles.js").NS,x=ue("packages/core/src/internal/util.js").warnOnce;function _(ee,Z){for(const E of ee.childNodes||[])if(E&&String(E.getAttribute&&E.getAttribute("class"))===Z)return E;const de=ee.ownerDocument.createElementNS(Y,"g");return de.setAttribute("class",Z),ee.appendChild(de),de}const p=new Set(["line","target","band","callout","event"]);function i(ee,Z){return ee.kind==="time"?ke(Z):ae(Z)}function S(ee,Z,de){if(ee.kind==="band"){const D=ee.of(Z);if(!Number.isFinite(D))return NaN;const t=Number(ee.bandwidth)||0;return de==="right"?D+t:D}const E=i(ee,Z);return E===null?NaN:ee.of(E)}function d(ee,Z,de){const E=ee.kind||"line",D=ee.label?` (${JSON.stringify(ee.label)})`:"";x(`chart:annotation:dropped:${E}:${Z}:${de}`,`chart annotation${D} of kind ${JSON.stringify(E)}, reading the ${Z} axis, was not drawn: ${de}.`)}function W(ee,Z){if(ee instanceof Date){const E=ee.getTime();return Number.isFinite(E)?ee.toISOString().slice(0,10):String(ee)}if(typeof ee=="number")return Number.isFinite(ee)?Z(ee):String(ee);const de=ae(ee);return de===null||typeof ee=="string"?String(ee):Z(de)}function I(ee,Z,de){const E=[];for(const D of ee)if((D.axis==="right"?"right":"left")===de&&!(Z.series!==void 0&&D.key!==Z.series))for(const f of D.points)ge(f.y)&&E.push(Number(f.y));return E}function b(ee,Z){if(!ee.length)return null;const de=[...ee].sort((f,c)=>f-c);if(de.length===1)return de[0];const E=Math.min(100,Math.max(0,Z))/100*(de.length-1),D=Math.floor(E),t=Math.ceil(E);return D===t?de[D]:de[D]+(de[t]-de[D])*(E-D)}function H(ee,Z,de){if(!ee.compute)return ae(ee.value);const E=I(Z,ee,de);if(!E.length)return null;const D=String(ee.compute).toLowerCase();if(D==="mean"||D==="avg")return E.reduce((f,c)=>f+c,0)/E.length;if(D==="median"||D==="p50")return b(E,50);if(D==="min")return Math.min(...E);if(D==="max")return Math.max(...E);const t=/^p(\d+(?:\.\d+)?)$/.exec(D);return t?b(E,Number(t[1])):null}function z(ee){return ee.axis==="right"||ee.axis==="y2"?"right":"left"}function q(ee,Z,de,E){const D=ee.label?`${ee.label}: `:"",t=E?` (${z(ee)==="right"?"right axis":"left axis"})`:"",f=ee.kind||"line";if(f==="band"){if(!Array.isArray(Z)||Z[0]===null||Z[1]===null)return"";const[e,v]=Z;return`${D||"Band: "}${de(Math.min(e,v))} to ${de(Math.max(e,v))}${t}`}return Z==null?"":`${D||`${f==="target"?"Target":f==="callout"?"Callout":"Reference"}: `}${de(Z)}${t}`}function U(ee){return(ee.kind||"line")==="band"?0:1}function oe(ee){const{group:Z,plot:de,xScale:E,yScale:D,rightScale:t,series:f,format:c}=ee,e=new re(_(Z,`${L}__annotations`)),v=[],M=[...Array.isArray(ee.annotations)?ee.annotations:[]].sort((y,s)=>U(y)-U(s));for(const y of M){const s=y.kind||"line";if(!p.has(s))continue;const a=z(y),A=a==="right"&&t?t:D;if(s==="band"){if(y.orient==="vertical"){const N=S(E,y.from,"left"),G=S(E,y.to,"right");if(Number.isNaN(N)||Number.isNaN(G)){const ne=Number.isNaN(N)&&Number.isNaN(G)?"from and to":Number.isNaN(N)?"from":"to";d(y,a,`its ${ne} value could not be placed on the x scale`);continue}const j=V(Math.min(N,G)),R=V(Math.max(N,G));if(te(e.next("rect",`${L}__annotation-band ${y.className||""}`.trim()),{x:j,y:V(de.top),width:Math.max(0,R-j),height:V(Math.max(0,de.bottom-de.top)),fill:y.colour||"currentColor","fill-opacity":y.opacity===void 0?.12:y.opacity}),y.label){const ne=e.next("text",`${L}__annotation-label`);te(ne,{x:j+4,y:V(de.top+12),"text-anchor":"start"}),B(ne,y.label)}const J=y.label?`${y.label}: `:"Event window: ";v.push({text:`${J}${W(y.from,c)} to ${W(y.to,c)}`});continue}const h=H({...y,value:y.from,compute:y.fromCompute},f,a),w=H({...y,value:y.to,compute:y.toCompute},f,a);if(h===null||w===null)continue;const r=V(A.of(h)),u=V(A.of(w));if(te(e.next("rect",`${L}__annotation-band ${y.className||""}`.trim()),{x:V(de.left),y:Math.min(r,u),width:V(Math.max(0,de.right-de.left)),height:Math.max(0,Math.abs(u-r)),fill:y.colour||"currentColor","fill-opacity":y.opacity===void 0?.12:y.opacity}),y.label){const N=e.next("text",`${L}__annotation-label`);te(N,{x:V(de.left+4),y:Math.min(r,u)+12,"text-anchor":"start"}),B(N,y.label)}v.push({text:q(y,[h,w],c,ee.dual)});continue}if(s==="event"){const h=y.x!==void 0?y.x:y.at,w=V(S(E,h,"left")+(E.kind==="band"?(Number(E.bandwidth)||0)/2:0));if(Number.isNaN(w)){d(y,a,"its x value could not be placed on the x scale");continue}if(te(e.next("path",`${L}__annotation-event`),{d:pe(["M",w,V(de.top),"L",w,V(de.bottom)]),stroke:y.colour||"currentColor",fill:"none"}),te(e.next("circle",`${L}__annotation-event-flag`),{cx:w,cy:V(de.top),r:3,fill:y.colour||"currentColor"}),y.label){const u=e.next("text",`${L}__annotation-label`);te(u,{x:w+5,y:V(de.top+10),"text-anchor":"start"}),B(u,y.label)}const r=y.label?`${y.label} — `:"Event — ";v.push({text:`${r}at ${W(h,c)}`});continue}if(s==="callout"){const h=H(y,f,a);if(h===null)continue;const w=y.at!==void 0?V(E.kind==="band"?E.centre(y.at):E.of(i(E,y.at)??NaN)):V(de.right-4),r=V(A.of(h));if(Number.isNaN(w)){d(y,a,"its x value could not be placed on the x scale");continue}if(te(e.next("circle",`${L}__annotation-point`),{cx:w,cy:r,r:3.5,fill:y.colour||"currentColor"}),y.label){const u=e.next("text",`${L}__annotation-label`);te(u,{x:w+6,y:r-6,"text-anchor":"start"}),B(u,y.label)}v.push({text:q(y,h,c,ee.dual)});continue}if(y.orient==="vertical"||y.x!==void 0){const h=y.x!==void 0?y.x:y.value,w=E.kind==="band"?V(E.centre(h)):V(E.of(i(E,h)??NaN));if(Number.isNaN(w)){d(y,a,"its x value could not be placed on the x scale");continue}const r=s==="target"?`${L}__annotation-target`:`${L}__annotation-line`;if(te(e.next("path",r),{d:pe(["M",w,V(de.top),"L",w,V(de.bottom)]),stroke:y.colour||"currentColor",fill:"none"}),y.label){const u=e.next("text",`${L}__annotation-label`);te(u,{x:w+4,y:V(de.top+10),"text-anchor":"start"}),B(u,y.label)}v.push({text:y.label?`${y.label} — at ${W(h,c)}`:""});continue}const P=H(y,f,a);if(P===null)continue;const T=V(A.of(P)),n=s==="target"?`${L}__annotation-target`:`${L}__annotation-line`;if(te(e.next("path",n),{d:pe(["M",V(de.left),T,"L",V(de.right),T]),stroke:y.colour||"currentColor",fill:"none"}),y.label){const h=e.next("text",`${L}__annotation-label`);te(h,{x:V(de.right-4),y:T-4,"text-anchor":"end"}),B(h,y.label)}v.push({text:q(y,P,c,ee.dual)})}return e.finish(),v.filter(y=>y.text)}}),Ge("packages/modules/charts/combo.js",function(o,ue){"use strict";Object.defineProperty(o,"toPareto",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"drawCombo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"drawRightAxis",{enumerable:!0,get:function(){return s}});const xe=ue("packages/modules/charts/axis.js"),re=xe.drawAxisLines,l=xe.drawCategoryAxis,ge=xe.drawContinuousAxis,ae=xe.drawMeasureAxis,ke=xe.overhangFor,K=xe.pinXDomain,te=xe.setPlotClip,pe=ue("packages/modules/charts/frame.js"),V=pe.Pool,B=pe.shouldRotate,C=ue("packages/modules/charts/format.js").formatters,L=ue("packages/modules/charts/scale.js"),F=L.bandScale,x=L.extent,_=L.isNumber,p=L.linearScale,i=L.measureDomain,S=L.timeScale,d=L.toNumber,W=L.toTime,I=ue("packages/modules/charts/svg.js"),b=I.attrs,H=I.path,z=I.round,U=ue("packages/modules/charts/styles.js").NS,ee=ue("packages/modules/charts/scheme.js").resolveScheme,de=ue("packages/modules/charts/labels.js").drawDataLabels,D=ue("packages/modules/charts/annotations.js").drawAnnotations;function t(a){return{left:a.filter(A=>A.axis!=="right"),right:a.filter(A=>A.axis==="right")}}function f(a,A){const P=a&&a.seriesStyle&&a.seriesStyle[A];if(P)return{width:P.width!=null?String(P.width):null,dash:Array.isArray(P.dash)&&P.dash.length?P.dash.join(" "):null,opacity:null,emphasized:!1};const T=a&&Array.isArray(a.emphasis)?a.emphasis:null;if(!T||!T.length)return{width:null,dash:null,opacity:null,emphasized:!1};const n=T.includes(A);return{width:n?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:n?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:n}}function c(a,A,P,T){const n=[];let h=!1;for(const w of A.points){if(w.px===void 0){h=!1;continue}n.push(h?"L":"M",w.px,w.py),h=!0}b(a.next("path",`${U}__line ${U}__mark`),{d:n.length?H(n):"",stroke:P,"data-series":A.index,"stroke-width":T.width,"stroke-dasharray":T.dash,opacity:T.opacity});for(const w of A.points)w.px!==void 0&&b(a.next("circle",`${U}__point ${U}__mark`),{cx:w.px,cy:w.py,r:3,fill:P})}function e(a,A){const P=[];for(const T of a)for(const n of T.points)P.push(n.y);return i(P,{zero:A})}function v(a){const A=a.series[0];if(!A)return a;const P=A.points.map((w,r)=>({point:w,label:a.labels[r],category:a.categories[r]})).filter(w=>_(w.point.y)).sort((w,r)=>r.point.y-w.point.y),T=P.reduce((w,r)=>w+r.point.y,0);let n=0;const h=P.map(w=>(n+=w.point.y,T>0?n/T*100:0));return{...a,categories:P.map(w=>w.category),labels:P.map(w=>w.label),series:[{...A,index:0,mark:"bar",axis:"left",points:P.map(w=>w.point)},{key:"cumulative",label:a.cumulativeLabel||"%",index:1,mark:"line",axis:"right",points:P.map((w,r)=>({x:w.category,xKey:w.point.xKey,label:w.label,y:h[r],rows:w.point.rows,rowKey:w.point.rowKey}))}]}}function $(a,A,P){const T=[A.left,A.right];if(a.kind!=="time"&&a.kind!=="linear")return F(a.categories,T,.2);const n=a.kind==="time"?a.categories.map(W):a.categories.map(d);if(a.kind==="time"){const r=x(n);if(r&&r.min===r.max)return S(K({min:r.min-3e4,max:r.max+3e4},a,P),T)}const h=a.xDomain||i(n,{zero:!1,nice:a.kind!=="time"}),w=a.xDomain?h:K(h,a,P);return a.kind==="time"?S(w,T):p(w,T)}function M(a,A){const P=[...new Set(a.filter(r=>Number.isFinite(r)))].sort((r,u)=>r-u);if(P.length<2){const[r,u]=A.range;return Math.max(4,(u-r)/10)}const T=[];for(let r=1;r<P.length;r++)T.push(P[r]-P[r-1]);T.sort((r,u)=>r-u);const n=Math.floor(T.length/2),h=T.length%2?T[n]:(T[n-1]+T[n])/2,w=Math.abs(A.of(P[0]+h)-A.of(P[0]));return Math.max(1,w*.8)}function y(a){const A=a.scheme||ee(),{plot:P}=a,T=a.pareto?v(a.bound):a.bound,n=T.series.filter(we=>!a.hidden.has(we.key)),h=t(n),w=h.left.some(we=>(we.mark||"bar")==="bar"),r=T.yDomain||e(h.left,w),u=p(r,[P.bottom,P.top]),N=h.right.length?a.pareto?{min:0,max:100}:e(h.right,!1):null,G=N?p(N,[P.bottom,P.top]):null,j=$(T,P,a.axis&&a.axis.x),R=j.kind!=="band",J=R?T.categories.map(we=>T.kind==="time"?W(we):d(we)):null;ae({gridGroup:a.groups.grid,axisGroup:a.groups.axis,plot:P,scale:u,format:C(a.grid,{kind:"linear",step:(r.max-r.min)/5})});const ne=T.dimension&&T.dimension.col?a.grid.columns.get(T.dimension.col):void 0;R?ge({group:a.groups.overlay,plot:P,scale:j,format:C(a.grid,{kind:T.kind,span:j.domain.max-j.domain.min,step:(j.domain.max-j.domain.min)/5},ne),grid:a.grid,size:a.fontSize}):l({group:a.groups.overlay,plot:P,scale:j,labels:T.labels,fontSize:a.fontSize,rotated:B(T.labels,j.step,a.fontSize)}),re({group:a.groups.rules,plot:P}),G&&s({group:a.groups.axis,plot:P,scale:G,colour:A.series(h.right[0].index),format:C(a.grid,{kind:"linear",step:(N.max-N.min)/5}),suffix:a.pareto?"%":""}),te(a.groups,P,ke(a.type));const ce=new V(a.groups.marks),Me=n.filter(we=>(we.mark||"bar")==="bar"),Le=R?M(J,j):j.bandwidth,Ne=Me.length?Le/Me.length:Le;let Re=0;const Ie=[];for(const we of n){const g=we.mark||"bar",k=we.axis==="right"&&G?G:u,O=A.series(we.index);if(g==="bar"){const ve=Re*Ne;Re++;const $e=k.of(Math.max(k.domain.min,0));for(let Te=0;Te<we.points.length;Te++){const je=we.points[Te];if(!_(je.y))continue;let Oe;if(R){const Ue=T.kind==="time"?W(je.x):d(je.x);Oe=Ue===null?NaN:j.of(Ue)-Le/2}else Oe=j.of(je.x);if(Number.isNaN(Oe))continue;const _e=k.of(je.y);b(ce.next("rect",`${U}__bar ${U}__mark`),{x:z(Oe+ve),y:z(Math.min(_e,$e)),width:z(Math.max(0,Ne)),height:z(Math.max(1,Math.abs($e-_e))),fill:O,"data-series":we.index,"data-point":Te}),je.px=z(Oe+ve+Ne/2),je.py=z(Math.min(_e,$e))}continue}const X=[];let ie=!1;for(const ve of we.points){if(!_(ve.y)){ie=!1;continue}let $e;if(R){const je=T.kind==="time"?W(ve.x):d(ve.x);$e=je===null?NaN:z(j.of(je))}else $e=z(j.centre(ve.x));if(Number.isNaN($e)){ie=!1;continue}const Te=z(k.of(ve.y));X.push(ie?"L":"M",$e,Te),ie=!0,ve.px=$e,ve.py=Te}const be=f(a,we.label);be.emphasized?Ie.push({series:we,colour:O,style:be}):c(ce,we,O,be)}for(const we of Ie)c(ce,we.series,we.colour,we.style);ce.finish(),a.labels&&a.labels.show&&de({group:a.groups.labels,series:n,plot:P,options:a.labels,grid:a.grid,size:a.typography&&a.typography.small||a.fontSize});let Ce=null;return a.annotations&&a.annotations.length&&(Ce=D({group:a.groups.overlay,plot:P,xScale:j,yScale:u,rightScale:G,series:n,annotations:a.annotations,dual:!!G,format:C(a.grid,{kind:"linear",step:(r.max-r.min)/5}).tick})),{xScale:j,yScale:u,rightScale:G,dual:!!G,series:n,bound:T,annotations:Ce}}function s(a){const{group:A,plot:P,scale:T,format:n}=a,h=a.side==="left"?"left":"right",w=h==="right"?P.right:P.left,r=new V(A);b(r.next("line",`${U}__axis-right`),{x1:z(w),x2:z(w),y1:z(P.top),y2:z(P.bottom),stroke:a.colour});for(const u of T.ticks(5)){const N=z(T.of(u)),G=r.next("text",`${U}__tick`);b(G,{x:z(h==="right"?P.right+6:P.left-6),y:N,"text-anchor":h==="right"?"start":"end","dominant-baseline":"middle",fill:a.colour}),G.textContent=`${n.tick(u)}${a.suffix||""}`}r.finish()}}),Ge("packages/modules/charts/quantile.js",function(o,ue){"use strict";Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return V}});const xe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),re=3e-12,l=1e-300;function ge(B){if(B<.5)return Math.log(Math.PI/Math.sin(Math.PI*B))-ge(1-B);const Y=B-1;let C=.9999999999998099;const L=Y+7.5;for(let F=0;F<xe.length;F++)C+=xe[F]/(Y+F+1);return .5*Math.log(2*Math.PI)+(Y+.5)*Math.log(L)-L+Math.log(C)}function ae(B,Y,C){const L=B+Y,F=B+1,x=B-1;let _=1,p=1-L*C/F;Math.abs(p)<l&&(p=l),p=1/p;let i=p;for(let S=1;S<=300;S++){const d=2*S;let W=S*(Y-S)*C/((x+d)*(B+d));p=1+W*p,Math.abs(p)<l&&(p=l),_=1+W/_,Math.abs(_)<l&&(_=l),p=1/p,i*=p*_,W=-(B+S)*(L+S)*C/((B+d)*(F+d)),p=1+W*p,Math.abs(p)<l&&(p=l),_=1+W/_,Math.abs(_)<l&&(_=l),p=1/p;const I=p*_;if(i*=I,Math.abs(I-1)<re)break}return i}function ke(B,Y,C){if(!(B>0)||!(Y>0)||!Number.isFinite(C))return Number.NaN;if(C<=0)return 0;if(C>=1)return 1;const L=Math.exp(ge(B+Y)-ge(B)-ge(Y)+B*Math.log(C)+Y*Math.log(1-C));return C<(B+1)/(B+Y+2)?L*ae(B,Y,C)/B:1-L*ae(Y,B,1-C)/Y}function K(B){const Y=Math.abs(B),C=2/(2+Y),L=4*C-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 x=0,_=0,p;for(let S=F.length-1;S>0;S--)p=_,_=L*_-x+F[S],x=p;const i=C*Math.exp(-Y*Y+.5*(F[0]+L*_)-x);return B>=0?i:2-i}function te(B){if(!(B>0)||!(B<1))return B===0?-1/0:B===1?1/0:Number.NaN;const Y=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],C=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],L=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],F=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],x=.02425;let _,p,i;B<x?(_=Math.sqrt(-2*Math.log(B)),i=(((((L[0]*_+L[1])*_+L[2])*_+L[3])*_+L[4])*_+L[5])/((((F[0]*_+F[1])*_+F[2])*_+F[3])*_+1)):B<=1-x?(_=B-.5,p=_*_,i=(((((Y[0]*p+Y[1])*p+Y[2])*p+Y[3])*p+Y[4])*p+Y[5])*_/(((((C[0]*p+C[1])*p+C[2])*p+C[3])*p+C[4])*p+1)):(_=Math.sqrt(-2*Math.log(1-B)),i=-(((((L[0]*_+L[1])*_+L[2])*_+L[3])*_+L[4])*_+L[5])/((((F[0]*_+F[1])*_+F[2])*_+F[3])*_+1));const d=(.5*K(-i/Math.SQRT2)-B)*Math.sqrt(2*Math.PI)*Math.exp(i*i/2);return i-d/(1+i*d/2)}function pe(B,Y){if(!(Y>0)||!Number.isFinite(B))return Number.NaN;const C=.5*ke(Y/2,.5,Y/(Y+B*B));return B>0?1-C:C}function V(B,Y){if(!(B>0)||!(B<1)||!(Y>0))return Number.NaN;if(Y>1e7)return te(B);let C=-1e4,L=1e4,F=te(B);const x=ge(Y/2)+ge(.5)-ge((Y+1)/2);for(let _=0;_<60;_++){const p=pe(F,Y);p<B?C=F:L=F;const i=Math.exp(-((Y+1)/2)*Math.log(1+F*F/Y)-x)/Math.sqrt(Y),S=i>0?(p-B)/i:0;if(Math.abs(S)<1e-12)break;const d=F-S;if(F=d>C&&d<L&&Number.isFinite(d)?d:(C+L)/2,L-C<1e-12)break}return F}}),Ge("packages/modules/charts/trendline.js",function(o,ue){"use strict";Object.defineProperty(o,"normaliseTrends",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"linearTrend",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"movingAverageTrend",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"exponentialTrend",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"computeTrend",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"trendText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"drawTrendlines",{enumerable:!0,get:function(){return c}});const re=ue("packages/modules/charts/frame.js").Pool,l=ue("packages/modules/charts/svg.js"),ge=l.attrs,ae=l.path,ke=l.ribbonPath,K=l.round,te=l.setText,pe=l.SVG_NS,B=ue("packages/modules/charts/typography.js").applySize,C=ue("packages/modules/charts/styles.js").NS,L=ue("packages/modules/charts/scale.js"),F=L.toNumber,x=L.toTime,p=ue("packages/modules/charts/quantile.js").studentTQuantile,S=ue("packages/modules/charts/format.js").r2Digits,d={linear:new Set(["linear","lr","ols","regression","least-squares"]),movingAverage:new Set(["movingaverage","moving-average","ma","sma","rolling"]),exponential:new Set(["exponential","exp","ewma","ses","holt","smoothing"])},W=1e-4,I=1-1e-4;function b(e){const v=String(e||"linear").toLowerCase();return d.linear.has(v)?"linear":d.movingAverage.has(v)?"movingAverage":d.exponential.has(v)?"exponential":null}function H(e){if(!e)return[];const v=Array.isArray(e)?e:[e],$=[];for(const M of v){if(M===!0){$.push({method:"linear"});continue}if(typeof M=="string"){const y=b(M);y&&$.push({method:y});continue}if(M&&typeof M=="object"){const y=b(M.method);y&&$.push({...M,method:y})}}return $}function z(e,v){if(e.kind==="band")return e.centre(v);const $=e.kind==="time"?x(v):F(v);return $===null?NaN:e.of($)}function q(e){const v=[];for(const $ of e.points){const M=Number($.y);v.push({value:Number.isFinite(M)?M:null,rawX:$.x})}return v}function U(e,v){const $=[];for(const M of e.points){const y=v.kind==="time"?x(M.x):F(M.x),s=Number(M.y);y===null||!Number.isFinite(y)||!Number.isFinite(s)||$.push({x:y,y:s})}return $.sort((M,y)=>M.x-y.x),$}function oe(e,v,$={}){const M=e.length;if(M<2)return null;let y=0,s=0;for(const J of e)y+=J.x,s+=J.y;y/=M,s/=M;let a=0,A=0,P=0;for(const J of e){const ne=J.x-y,ce=J.y-s;a+=ne*ne,A+=ne*ce,P+=ce*ce}if(a===0)return null;const T=A/a,n=s-T*y,h=P===0?1:Math.max(0,Math.min(1,A*A/(a*P))),w=e[0].x,r=e[M-1].x,u=J=>({x:J,y:n+T*J}),N=[u(w),u(r)],G=[];let j=null;const R=Math.max(0,Math.floor(Number(v)||0));if(R>0&&r>w){const J=(r-w)/(M-1);if(J>0&&(G.push(u(r),u(r+R*J)),M>2)){const ne=Number.isFinite($.confidence)&&$.confidence>0&&$.confidence<1?Number($.confidence):.95,ce=1-(1-ne)/2,Me=Math.max(0,P-T*A),Le=Math.sqrt(Me/(M-2)),Ne=p(ce,M-2),Re=[];for(let Ie=0;Ie<=R;Ie++){const Ce=r+Ie*J,we=n+T*Ce,g=1/M+(Ce-y)**2/a,k=Le*Math.sqrt(1+g),O=Le*Math.sqrt(g);Re.push({x:Ce,mean:we,lower:we-Ne*k,upper:we+Ne*k,lowerMean:we-Ne*O,upperMean:we+Ne*O})}j={confidence:ne,points:Re}}}return{fit:N,forecast:G,band:j,stats:{method:"linear",slope:T,intercept:n,r2:h,n:M,forecast:G.length?R:0,confidence:j?j.confidence:null}}}function ee(e,v){const $=Math.max(1,Math.floor(Number(v)||3)),M=[];let y=0;const s=[];for(const a of e)Number.isFinite(a.value)&&(M.push(a.value),y+=a.value,M.length>$&&(y-=M.shift())),M.length&&s.push({x:a.rawX,y:y/M.length});return s.length<2?null:{fit:s,stats:{method:"movingAverage",window:$}}}function Z(e,v){const $=e.length,M=new Array($).fill(null);let y=null,s=0;for(let a=0;a<$;a++){const A=e[a];if(!Number.isFinite(A)){y!==null&&(M[a]=y);continue}if(y===null){y=A,M[a]=A;continue}s+=(A-y)**2,y=v*A+(1-v)*y,M[a]=y}return{smoothed:M,sse:s}}function de(e,v,$){const M=e.length,y=new Array(M).fill(null);let s=null,a=null,A=0;for(let P=0;P<M;P++){const T=e[P];if(!Number.isFinite(T)){s!==null&&(s+=a,y[P]=s);continue}if(s===null){s=T,y[P]=T;continue}if(a===null){a=T-s;const w=s+a;A+=(T-w)**2;const r=s;s=v*T+(1-v)*(r+a),a=$*(s-r)+(1-$)*a,y[P]=s;continue}const n=s+a;A+=(T-n)**2;const h=s;s=v*T+(1-v)*(h+a),a=$*(s-h)+(1-$)*a,y[P]=s}return{smoothed:y,sse:A}}function E(e,v,$,M=80){const y=(Math.sqrt(5)-1)/2;let s=v,a=$,A=a-y*(a-s),P=s+y*(a-s),T=e(A),n=e(P);for(let h=0;h<M;h++)T<n?(a=P,P=A,n=T,A=a-y*(a-s),T=e(A)):(s=A,A=P,T=n,P=s+y*(a-s),n=e(P));return(s+a)/2}function D(e,v){const $=String(v.kind||v.model||"").toLowerCase()==="holt",M=e.map(n=>Number.isFinite(n.value)?n.value:null);if(M.filter(n=>n!==null).length<($?2:1))return null;const s=n=>Math.min(I,Math.max(W,n));let a=Number.isFinite(v.alpha)?s(Number(v.alpha)):null,A=$&&Number.isFinite(v.beta)?s(Number(v.beta)):null;if($){if(a===null||A===null){let n=a===null?.5:a,h=A===null?.5:A;for(let w=0;w<6;w++)a===null&&(n=E(r=>de(M,r,h).sse,W,I)),A===null&&(h=E(r=>de(M,n,r).sse,W,I));a=a===null?n:a,A=A===null?h:A}}else a===null&&(a=E(n=>Z(M,n).sse,W,I));const P=$?de(M,a,A):Z(M,a),T=[];for(let n=0;n<e.length;n++){const h=P.smoothed[n];h===null||!Number.isFinite(h)||T.push({x:e[n].rawX,y:h})}return T.length<2?null:{fit:T,stats:{method:"exponential",kind:$?"holt":"ses",alpha:a,beta:$?A:null}}}function t(e,v,$){if(v.method==="linear"){const y=U(e,$);return oe(y,v.forecast,{confidence:v.confidence})}const M=q(e);return v.method==="movingAverage"?ee(M,v.window||v.period):D(M,v)}function f(e,v,$,M,y,s){const a=v?` for ${v}`:"";if(e.method==="linear"){const n=Number.isFinite(e.r2)?`, R² ${e.r2.toFixed(2)}`:"";let h=`Trend (linear)${a}: slope ${$(e.slope)}${n}`;if(e.forecast>0&&M&&M.length){const w=M[M.length-1];if(h+=`; forecast ${e.forecast} step${e.forecast===1?"":"s"} ahead to ${$(w.y)}`,y&&y.points.length){const r=y.points[y.points.length-1],u=s==="confidence"||s==="mean",N=u?r.lowerMean:r.lower,G=u?r.upperMean:r.upper,j=u?"confidence":"prediction",R=Math.round(y.confidence*100);h+=`; ${R}% ${j} band ${$(N)} to ${$(G)} at the horizon`}}return h}if(e.method==="movingAverage")return`Trend (moving average, window ${e.window})${a}`;const A=e.kind==="holt"?"Holt":"single",P=Number.isFinite(e.alpha)?`, α ${e.alpha.toFixed(2)}`:"",T=Number.isFinite(e.beta)?`, β ${e.beta.toFixed(2)}`:"";return`Trend (exponential, ${A})${a}${P}${T}`}function c(e){const v=H(e.trend);if(!v.length)return[];const $=e.group.ownerDocument;let M=null;for(const a of e.group.childNodes||[])if(a&&String(a.getAttribute&&a.getAttribute("class"))===`${C}__trends`){M=a;break}M||(M=$.createElementNS(pe,"g"),M.setAttribute("class",`${C}__trends`),e.group.appendChild(M)),e.clip?M.setAttribute("clip-path",`url(#${e.clip})`):M.removeAttribute("clip-path");const y=new re(M),s=[];for(const a of v)for(const A of e.series){const P=A.axis==="right"&&e.rightScale?e.rightScale:e.yScale,T=t(A,a,e.xScale);if(!T)continue;const n=e.scheme.series(A.index),h=[];for(const u of T.fit){const N=z(e.xScale,u.x),G=P.of(u.y);!Number.isFinite(N)||!Number.isFinite(G)||h.push(h.length?"L":"M",K(N),K(G))}if(h.length<4)continue;if(ge(y.next("path",`${C}__trend`),{d:ae(h),fill:"none",stroke:n,"data-series":A.index}),a.band!==!1&&T.band&&T.band.points.length>=2){const u=a.band==="confidence"||a.band==="mean",N=[];for(const j of T.band.points){const R=z(e.xScale,j.x),J=u?j.lowerMean:j.lower,ne=u?j.upperMean:j.upper,ce=P.of(J),Me=P.of(ne);!Number.isFinite(R)||!Number.isFinite(ce)||!Number.isFinite(Me)||N.push({x:K(R),lower:K(ce),upper:K(Me)})}const G=ke(N);G&&ge(y.next("path",`${C}__trend-band`),{d:G,fill:n,"fill-opacity":.15,stroke:"none","data-series":A.index})}const r=T.forecast||[];if(r.length>=2){const u=[];for(const N of r){const G=z(e.xScale,N.x),j=P.of(N.y);!Number.isFinite(G)||!Number.isFinite(j)||u.push(u.length?"L":"M",K(G),K(j))}u.length>=4&&ge(y.next("path",`${C}__trend-forecast`),{d:ae(u),fill:"none",stroke:n,"data-series":A.index})}if(a.label!==!1&&T.stats.method==="linear"&&Number.isFinite(T.stats.r2)){const u=T.fit[T.fit.length-1],N=y.next("text",`${C}__trend-label`);B(N,e.size),ge(N,{x:K(z(e.xScale,u.x)),y:K(P.of(u.y))-4,"text-anchor":"end",fill:n}),te(N,e.grid.messages.t("chart.r2",{value:S(e.grid,T.stats.r2)}))}s.push({text:f(T.stats,A.label,e.format,r,a.band===!1?null:T.band,a.band)})}return y.finish(),s.filter(a=>a.text)}}),Ge("packages/modules/charts/rulecolour.js",function(o,ue){"use strict";Object.defineProperty(o,"colourOf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"ruleColour",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"ruleLegend",{enumerable:!0,get:function(){return ge}});const xe="*";function re(ae){if(!ae||typeof ae!="object")return null;for(const ke of["background","backgroundColor","color"]){const K=ae[ke];if(typeof K=="string"&&K.trim())return K.trim()}return null}function l(ae){const{grid:ke,col:K,value:te}=ae;if(!ke||!K||!ke.formatting||typeof ke.formatting.styleFor!="function")return null;try{return re(ke.formatting.styleFor(K,te))}catch{return null}}function ge(ae){const{grid:ke,col:K}=ae,te=new Set([...ae.colours||[]].filter(Boolean));if(!te.size||!ke||!ke.formatting||typeof ke.formatting.list!="function")return[];let pe;try{pe=[...ke.formatting.list(xe)||[],...K?ke.formatting.list(K)||[]:[]]}catch{return[]}const V=[],B=new Set;for(const Y of pe){if(!Y||Y.enabled===!1)continue;const C=re(Y.style);!C||!te.has(C)||B.has(C)||(B.add(C),V.push({key:Y.id||`rule:${V.length}`,label:Y.label||Y.id||C,colour:C,index:V.length}))}return V}}),Ge("packages/modules/charts/cartesian.js",function(o,ue){"use strict";Object.defineProperty(o,"CARTESIAN",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"axisWindowSpan",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"axisWindowNow",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"rollingDomain",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"WINDOW_LEAD",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(o,"aheadOfWindow",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"staleWindow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"windowedBound",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"slotPadFor",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"pinnedContinuousX",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"bandedX",{enumerable:!0,get:function(){return je}}),Object.defineProperty(o,"dataInterval",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"continuousSlot",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"xDomainFor",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(o,"xScaleFor",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"drawFits",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(o,"drawConfidenceBand",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"drawBoundErrorBars",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"drawForest",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(o,"drawReferenceLines",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"drawCartesian",{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(o,"HIT_TOLERANCE",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"nearestDrawnPoint",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(o,"nearestCategory",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(o,"categoryKeyAt",{enumerable:!0,get:function(){return Jt}});const xe=ue("packages/modules/charts/axis.js"),re=xe.drawAxisLines,l=xe.drawAxisTitle,ge=xe.drawBandLabels,ae=xe.drawCategoryAxis,ke=xe.drawContinuousAxis,K=xe.drawMeasureAxis,te=xe.overhangFor,pe=xe.pinXDomain,V=xe.setPlotClip,B=ue("packages/modules/charts/frame.js"),Y=B.Pool,C=B.shouldRotate,L=ue("packages/modules/charts/format.js"),F=L.formatters,x=L.r2Digits,_=ue("packages/modules/charts/scale.js"),p=_.bandScale,i=_.extent,S=_.isNumber,d=_.key,W=_.linearScale,I=_.measureDomain,b=_.timeScale,H=_.toNumber,z=_.toTime,q=ue("packages/modules/charts/svg.js"),U=q.attrs,oe=q.path,ee=q.ribbonPath,Z=q.round,de=q.setText,E=q.SVG_NS,t=ue("packages/modules/charts/styles.js").NS,c=ue("packages/modules/charts/labels.js").drawDataLabels,v=ue("packages/modules/charts/dense.js").downsample,M=ue("packages/modules/charts/scheme.js").resolveScheme,s=ue("packages/modules/charts/typography.js").applySize,A=ue("packages/modules/charts/combo.js").drawRightAxis,P=ue("packages/modules/charts/annotations.js"),T=P.drawAnnotations,n=P.overlayLayer,w=ue("packages/modules/charts/trendline.js").drawTrendlines,r=ue("packages/modules/charts/rulecolour.js"),u=r.ruleColour,N=r.ruleLegend,j=ue("packages/core/src/internal/util.js").warnOnce,R=3.5,J=Object.freeze({line:{zero:!1,marks:"path"},step:{zero:!1,marks:"path"},area:{zero:!0,marks:"path"},rangeArea:{zero:!1,marks:"path"},bar:{zero:!0,marks:"rect"},horizontalBar:{zero:!0,marks:"rect",horizontal:!0},waterfall:{zero:!0,marks:"rect"},scatter:{zero:!1,marks:"circle"},bubble:{zero:!1,marks:"circle"},candlestick:{zero:!1,marks:"rect"}});function ne(m){const le=[];for(let Q=0;Q<m.length;Q++){const se=m[Q];if(Q===0){le.push("M",se.x,se.y);continue}le.push("L",se.x,m[Q-1].y),le.push("L",se.x,se.y)}return le}function ce(m,le,Q){if(Q)return[0,100];if(!le){const me=[];for(const Pe of m)for(const ye of Pe.points)me.push(ye.y);return me}const se=[],fe=[],he=m[0]?m[0].points.length:0;for(let me=0;me<he;me++){let Pe=0,ye=0;for(const Se of m){const Ae=Se.points[me]?Se.points[me].y:null;S(Ae)&&(Ae>=0?Pe+=Ae:ye+=Ae)}se.push(Pe),fe.push(ye)}return[...se,...fe]}function Me(m){const le=[0];if(!m)return le;let Q=0;for(const se of m.points)S(se.y)&&(Q+=se.y,le.push(Q));return le}function Le(m,le){const Q=new Float64Array(m),se=new Float64Array(m);return{take(fe,he){const me=le?le[fe]:0,Pe=le?me?he/me*100:0:he;if(Pe>=0){const Se=Q[fe];return Q[fe]+=Pe,[Se,Q[fe]]}const ye=se[fe];return se[fe]+=Pe,[ye,se[fe]]}}}function Ne(m){const le=m&&m.window;if(!le||typeof le!="object")return 0;const Q=Number(le.span);return!Number.isFinite(Q)||Q<=0?0:le.kind!=="time"?(j("chart.axis.window.kind",`axis window kind "${le.kind}" is not supported on a chart axis; only { kind: "time", span } rolls the domain. Bound the row count with the source's maxRows instead.`),0):Q}function Re(m,le){const Q=m&&m.window;if(!Q||typeof Q!="object"||typeof Q.now!="function")return le;const se=Number(Q.now());return Number.isFinite(se)?se:(j("chart.axis.window.now","axis.x.window.now did not return a time, so the rolling window is measured from this device's clock instead. It must return epoch milliseconds — the same number Date.now() returns — because that is what the x values are compared against."),le)}function Ie(m,le,Q){const se=Q+m*Ce;let fe=Q;for(const he of le)Number.isFinite(he)&&he>fe&&he<=se&&(fe=he);return{min:fe-m,max:fe}}const Ce=.25;function we(m,le,Q){const se=Ne(le);if(!se||!m||!Array.isArray(m.categories))return null;const fe=J[Q];if(!fe||fe.horizontal||m.kind==="category"||Q==="bar"&&!Te(m,Q,le))return null;const he=m.categories.map(me=>m.kind==="time"?z(me):H(me));return{span:se,values:he}}function g(m,le,Q,se){const fe=we(m,le,Q);if(!fe)return null;const he=fe.span*Ce;let me=0,Pe=0;for(const ye of fe.values)ye===null||!Number.isFinite(ye)||ye-se<=he||(me+=1,ye-se>Pe&&(Pe=ye-se));return me?{span:fe.span,limit:he,count:me,lead:Pe}:null}function k(m,le,Q,se){const fe=we(m,le,Q);if(!fe)return null;const{span:he}=fe,me=fe.values.filter(Ae=>Ae!==null&&Number.isFinite(Ae));if(!me.length)return null;const{min:Pe,max:ye}=Ie(he,me,se);let Se=-1/0;for(const Ae of me){if(Ae>=Pe&&Ae<=ye)return null;Ae<Pe&&Ae>Se&&(Se=Ae)}return Se===-1/0?{span:he,newest:null,age:null,points:me.length}:{span:he,newest:Se,age:se-Se,points:me.length}}function O(m,le,Q,se){const fe=we(m,le,Q);if(!fe)return m;const{span:he,values:me}=fe,Pe=me.filter(Ee=>Ee!==null&&Number.isFinite(Ee));if(!Pe.length)return m;const{min:ye,max:Se}=Ie(he,Pe,se),Ae=[];for(let Ee=0;Ee<me.length;Ee++){const Be=me[Ee];(Be===null||!Number.isFinite(Be)||Be>=ye&&Be<=Se)&&Ae.push(Ee)}return Ae.length===me.length?m:{...m,categories:Ae.map(Ee=>m.categories[Ee]),labels:Array.isArray(m.labels)?Ae.map(Ee=>m.labels[Ee]):m.labels,series:(m.series||[]).map(Ee=>({...Ee,points:Array.isArray(Ee.points)?Ae.map(Be=>Ee.points[Be]).filter(Be=>Be!==void 0):Ee.points})),windowed:me.length-Ae.length}}const X=Object.freeze({bar:.2,candlestick:.3}),ie=.4;function be(m){return Object.hasOwn(X,m)?X[m]:ie}const ve=new Set(["bar","candlestick"]);function $e(m){const le=m&&typeof m.scale=="string"?m.scale:"";return le==="time"||le==="linear"}function Te(m,le,Q){if(!m||m.kind==="category")return!1;const se=J[le];return se&&se.horizontal?!1:ve.has(le)?$e(Q):!0}function je(m,le,Q){return!Te(m,le,Q)}function Oe(m){const le=m.filter(fe=>typeof fe=="number"&&Number.isFinite(fe)).slice().sort((fe,he)=>fe-he),Q=[];for(let fe=1;fe<le.length;fe++){const he=le[fe]-le[fe-1];he>0&&Q.push(he)}if(!Q.length)return 0;Q.sort((fe,he)=>fe-he);const se=Math.floor(Q.length/2);return Q.length%2?Q[se]:(Q[se-1]+Q[se])/2}function _e(m){const{bound:le,scale:Q,config:se,padding:fe}=m,he=se?Number(se.barWidth):NaN,me=Number.isFinite(he)&&he>0,Pe=(le.categories||[]).map(Ee=>le.kind==="time"?z(Ee):H(Ee)),ye=me?he:Oe(Pe),Se=Math.abs(Q.range[1]-Q.range[0]);if(!ye)return Math.max(1,Se/20*(1-fe));const Ae=Math.abs(Q.of(Q.domain.min+ye)-Q.of(Q.domain.min));return Math.max(1,me?Ae:Ae*(1-fe))}function Ue(m,le,Q,se){if(je(m,le,Q))return null;const fe=Ne(Q),he=m.kind==="time"?m.categories.map(z):m.categories.map(H);if(m.kind==="time"&&!fe){const Pe=i(he);if(Pe&&Pe.min===Pe.max)return pe({min:Pe.min-3e4,max:Pe.max+3e4},m,Q)}const me=fe?Ie(fe,he,Number.isFinite(se)?se:Re(Q,Date.now())):I(he,{zero:!1,nice:m.kind!=="time"});return pe(me,m,Q)}function rt(m,le,Q,se){const fe=[le.left,le.right];if(je(m,Q,se))return Ne(se)&&j("chart.axis.window.band","a rolling time window needs a continuous x axis; this chart bands its x values, so the window is ignored. Bind a date or numeric column to x, or put this type on a continuous axis with axis.x.scale."),p(m.categories,fe,be(Q));const he=m.xDomain||Ue(m,Q,se);return m.kind==="time"?b(he,fe):W(he,fe)}function ct(m,le){if(m.kind==="band")return m.centre(le.x);const Q=m.kind==="time"?z(le.x):H(le.x);return Q===null?NaN:m.of(Q)}function Dt(m,le){const Q=m&&m.seriesStyle&&m.seriesStyle[le];if(Q)return{width:Q.width!=null?String(Q.width):null,dash:Array.isArray(Q.dash)&&Q.dash.length?Q.dash.join(" "):null,opacity:null,emphasized:!1};const se=m&&Array.isArray(m.emphasis)?m.emphasis:null;if(!se||!se.length)return{width:null,dash:null,opacity:null,emphasized:!1};const fe=se.includes(le);return{width:fe?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:fe?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:fe}}function Nt(m){const{series:le,xScale:Q,yScale:se,baseline:fe,fill:he,colour:me,stack:Pe,style:ye}=m,Se=[],Ae=[];let Ee=!1;const Be=[];for(let Fe=0;Fe<le.points.length;Fe++){const Ze=le.points[Fe],Ve=Z(ct(Q,Ze));if(!S(Ze.y)||Number.isNaN(Ve)){Ee=!1;continue}Be[Fe]=!0;const Xe=Ze.y,He=Pe?Pe.take(Fe,Xe):null,Je=Z(se.of(He?He[1]:Xe)),Qe=Z(se.of(He?He[0]:fe));m.step&&Ee&&Se.push("L",Ve,m.previous),Se.push(Ee?"L":"M",Ve,Je),m.previous=Je,he&&Ae.push(Ee?"L":"M",Ve,Je),he&&!Ee&&Ae.push("M",Ve,Je),Ee=!0,Ze.px=Ve,Ze.py=Je,Ze.pbase=Qe}if(U(m.pool.next("path",`${t}__line ${t}__mark`),{d:Se.length?oe(Se):"",stroke:me,"data-series":m.index,"stroke-width":ye?ye.width:null,"stroke-dasharray":ye?ye.dash:null,opacity:ye?ye.opacity:null}),!he){Ot({...m,placed:Be});return}const ze=[];let We=[];const Ye=()=>{if(We.length<2){We=[];return}ze.push("M",We[0].x,We[0].base);for(const Fe of We)ze.push("L",Fe.x,Fe.y);for(let Fe=We.length-1;Fe>=0;Fe--)ze.push("L",We[Fe].x,We[Fe].base);ze.push("Z"),We=[]};for(const Fe of le.points){if(!S(Fe.y)||Fe.px===void 0){Ye();continue}We.push({x:Fe.px,y:Fe.py,base:Fe.pbase})}Ye(),U(m.pool.next("path",`${t}__area ${t}__mark`),{d:ze.length?oe(ze):"",fill:me,"data-series":m.index,opacity:ye?ye.emphasized?"1":ye.opacity:null}),Ot({...m,placed:Be})}function Ot(m){const{series:le,placed:Q}=m;for(let se=0;se<le.points.length;se++){if(!Q[se]||Q[se-1]||Q[se+1])continue;const fe=le.points[se];U(m.pool.next("circle",`${t}__point ${t}__mark`),{cx:fe.px,cy:fe.py,r:R,fill:m.colour,"data-series":m.index,"data-point":se})}}function at(m,le){const Q=m&&m.range;if(!Array.isArray(Q)||Q.length!==2)return le;const[se,fe]=Q;return!Number.isFinite(se)||!Number.isFinite(fe)||!Number.isFinite(le)?le:Math.min(Math.max(se,fe),Math.max(Math.min(se,fe),le))}function Bt(m){const{series:le,xScale:Q,yScale:se,baseline:fe,colour:he,stack:me,slot:Pe}=m;for(let ye=0;ye<le.points.length;ye++){const Se=le.points[ye];if(!S(Se.y))continue;const Ae=Q.kind==="band"?Q.of(Se.x):ct(Q,Se)-Pe.span/2;if(Number.isNaN(Ae))continue;const Ee=Se.y,Be=m.pointColour&&m.pointColour(Se)||he,ze=me?me.take(ye,Ee):[fe,Ee],We=at(se,se.of(ze[1])),Ye=at(se,se.of(ze[0])),Fe=Ae+Pe.offset,Ze=Q.kind==="band"?Fe:at(Q,Fe),Ve=Q.kind==="band"?Fe+Pe.width:at(Q,Fe+Pe.width),Xe=m.pool.next("rect",`${t}__bar ${t}__mark`,`${le.key}:${d(Se.x)}`);U(Xe,{x:Z(Ze),y:Z(Math.min(We,Ye)),width:Z(Math.max(0,Ve-Ze)),height:Z(Math.max(1,Math.abs(Ye-We))),fill:Be,"data-series":m.index,"data-point":ye}),Se.px=Z(Ae+Pe.offset+Pe.width/2),Se.py=Z(Math.min(We,Ye)),Se.pbase=Z(Math.max(We,Ye))}}function Wt(m){const{series:le,xScale:Q,yScale:se}=m;let fe=0;for(let he=0;he<le.points.length;he++){const me=le.points[he];if(!S(me.y))continue;const Pe=me.y,ye=he===le.points.length-1,Se=m.total&&ye?0:fe,Ae=(m.total&&ye,fe+Pe);m.total,fe+=Pe;const Ee=at(se,se.of(Math.max(Se,Ae))),Be=at(se,se.of(Math.min(Se,Ae))),ze=m.pool.next("rect",`${t}__bar ${t}__mark`,`${le.key}:${d(me.x)}`);U(ze,{x:Z(Q.of(me.x)),y:Z(Ee),width:Z(Q.bandwidth),height:Z(Math.max(1,Be-Ee)),fill:Pe>=0?m.positive:m.negative,"data-series":m.index,"data-point":he}),me.px=Z(Q.of(me.x)+Q.bandwidth/2),me.py=Z(Ee)}}function Gt(m){const{series:le,valueScale:Q,baseline:se,colour:fe,stack:he,slot:me}=m;for(let Pe=0;Pe<le.points.length;Pe++){const ye=le.points[Pe];if(!S(ye.y))continue;const Se=m.bandScale.of(ye.x);if(Number.isNaN(Se))continue;const Ae=ye.y,Ee=m.pointColour&&m.pointColour(ye)||fe,Be=he?he.take(Pe,Ae):[se,Ae],ze=at(Q,Q.of(Be[0])),We=at(Q,Q.of(Be[1]));U(m.pool.next("rect",`${t}__bar ${t}__mark`,`${le.key}:${d(ye.x)}`),{x:Z(Math.min(ze,We)),y:Z(Se+me.offset),width:Z(Math.max(1,Math.abs(We-ze))),height:Z(Math.max(0,me.width)),fill:Ee,"data-series":m.index,"data-point":Pe}),ye.px=Z(We),ye.py=Z(Se+me.offset+me.width/2),ye.pbase=Z(ze)}}function $t(m){const le=m.group.ownerDocument;let Q=null;for(const he of m.group.childNodes||[])if(he&&String(he.getAttribute&&he.getAttribute("class"))===`${t}__fits`){Q=he;break}Q||(Q=le.createElementNS(E,"g"),Q.setAttribute("class",`${t}__fits`),m.group.appendChild(Q));const se=new Y(Q),fe=[];for(const he of m.series){let me=0,Pe=0,ye=0;for(const He of he.points){const Je=Number(He.x),Qe=Number(He.y);!Number.isFinite(Je)||!Number.isFinite(Qe)||(me++,Pe+=Je,ye+=Qe)}if(me<2)continue;const Se=Pe/me,Ae=ye/me;let Ee=0,Be=0,ze=0,We=1/0,Ye=-1/0;for(const He of he.points){const Je=Number(He.x),Qe=Number(He.y);if(!Number.isFinite(Je)||!Number.isFinite(Qe))continue;const et=Je-Se,dt=Qe-Ae;Ee+=et*et,Be+=et*dt,ze+=dt*dt,Je<We&&(We=Je),Je>Ye&&(Ye=Je)}if(Ee===0)continue;const Fe=Be/Ee,Ze=Ae-Fe*Se,Ve=ze===0?1:Math.max(0,Math.min(1,Be*Be/(Ee*ze))),Xe=m.scheme.series(he.index);if(U(se.next("path",`${t}__fit`),{d:oe(["M",Z(m.xScale.of(We)),Z(m.yScale.of(Ze+Fe*We)),"L",Z(m.xScale.of(Ye)),Z(m.yScale.of(Ze+Fe*Ye))]),fill:"none",stroke:Xe,"data-series":he.index}),m.showR2){const He=se.next("text",`${t}__fit-label`);s(He,m.size),U(He,{x:Z(m.xScale.of(Ye)),y:Z(m.yScale.of(Ze+Fe*Ye))-4,"text-anchor":"end",fill:Xe}),de(He,m.grid.messages.t("chart.r2",{value:x(m.grid,Ve)}))}fe.push({key:he.key,slope:Fe,intercept:Ze,r2:Ve,n:me})}return se.finish(),fe}function Pt(m){const le=m.group.ownerDocument;let Q=null;for(const Se of m.group.childNodes||[])if(Se&&String(Se.getAttribute&&Se.getAttribute("class"))===`${t}__band`){Q=Se;break}Q||(Q=le.createElementNS(E,"g"),Q.setAttribute("class",`${t}__band`),m.group.firstChild?m.group.insertBefore(Q,m.group.firstChild):m.group.appendChild(Q));const se=new Y(Q),fe=m.band&&Array.isArray(m.band.points)?m.band.points:[],he=Number.isFinite(m.index)?Number(m.index):0,me=m.scheme.series(he),Pe=Number.isFinite(m.opacity)?Number(m.opacity):.15,ye=[];for(const Se of fe){const Ae=Number(Se.x),Ee=Number(Se.lower),Be=Number(Se.upper);if(!Number.isFinite(Ae)||!Number.isFinite(Ee)||!Number.isFinite(Be))continue;const ze=Number(Se.yhat);ye.push({x:Z(m.xScale.of(Ae)),lower:Z(m.yScale.of(Ee)),upper:Z(m.yScale.of(Be)),yhat:Number.isFinite(ze)?Z(m.yScale.of(ze)):null})}if(ye.length>=2&&(U(se.next("path",`${t}__band-fill`),{d:ee(ye),fill:me,"fill-opacity":Pe,stroke:"none","data-series":he}),m.line!==!1)){const Se=[];let Ae=!1;for(const Ee of ye){if(Ee.yhat===null){Ae=!1;continue}Se.push(Ae?"L":"M",Ee.x,Ee.yhat),Ae=!0}U(se.next("path",`${t}__band-line`),{d:Se.length?oe(Se):"",fill:"none",stroke:me,"data-series":he})}return se.finish(),{points:ye.length,confidence:m.band&&Number.isFinite(m.band.confidence)?Number(m.band.confidence):null}}function jt(m){const le=m.group.ownerDocument;let Q=null;for(const ye of m.group.childNodes||[])if(ye&&String(ye.getAttribute&&ye.getAttribute("class"))===`${t}__whiskers`){Q=ye;break}Q||(Q=le.createElementNS(E,"g"),Q.setAttribute("class",`${t}__whiskers`),m.group.appendChild(Q));const se=new Y(Q),fe=Number.isFinite(m.cap)?Number(m.cap):4,he=m.colour||"currentColor",me=m.orient!=="v";let Pe=0;for(const ye of m.points||[]){const Se=Number(ye.main),Ae=Number(ye.lo),Ee=Number(ye.hi);if(!Number.isFinite(Se)||!Number.isFinite(Ae)||!Number.isFinite(Ee))continue;const Be=me?["M",Ae,Se,"L",Ee,Se,"M",Ae,Se-fe,"L",Ae,Se+fe,"M",Ee,Se-fe,"L",Ee,Se+fe]:["M",Se,Ae,"L",Se,Ee,"M",Se-fe,Ae,"L",Se+fe,Ae,"M",Se-fe,Ee,"L",Se+fe,Ee];U(se.next("path",`${t}__whisker`),{d:oe(Be),stroke:he,fill:"none"}),Pe++}return se.finish(),Pe}function Ht(m){const le=m.scheme||M(),Q=m.typography||{small:m.fontSize||11,axisTitle:11},{plot:se,bound:fe}=m,he=fe.series[0]&&fe.series[0].points||[],me=he.map(ze=>ze.label),Pe=le.series(0),ye=p(me,[se.top,se.bottom],.4),Se=[0];for(const ze of he)for(const We of[ze.x,ze.lower,ze.upper])Number.isFinite(We)&&Se.push(We);const Ae=W(I(Se,{zero:!1}),[se.left,se.right]);jt({group:m.groups.overlay,orient:"h",colour:Pe,points:he.map(ze=>({main:Z(ye.centre(ze.label)),lo:Z(Ae.of(ze.lower)),hi:Z(Ae.of(ze.upper))}))});const Ee=new Y(m.groups.marks);let Be=0;for(const ze of he)Number.isFinite(ze.x)&&(U(Ee.next("circle",`${t}__point ${t}__mark`),{cx:Z(Ae.of(ze.x)),cy:Z(ye.centre(ze.label)),r:R,fill:Pe}),Be++);return Ee.finish(),mt({group:m.groups.rules,plot:se,scale:Ae,lines:[{value:0}]}),ke({group:m.groups.axis,plot:se,scale:Ae,format:F(m.grid,{kind:"linear",step:(Ae.domain.max-Ae.domain.min)/5}),config:{},grid:m.grid,size:Q.small}),ge({group:m.groups.labels,plot:se,scale:ye,labels:me,fontSize:Q.small,config:{}}),{series:[],marks:Be}}function mt(m){const le=new Y(n(m.group,`${t}__reflines`));for(const Q of m.lines||[]){if(!S(Q.value))continue;const se=Z(m.scale.of(Q.value));if(U(le.next("path",`${t}__reference`),{d:oe(["M",Z(m.plot.left),se,"L",Z(m.plot.right),se]),stroke:Q.colour||"currentColor","stroke-dasharray":"4 3",fill:"none"}),!Q.label)continue;const fe=le.next("text",`${t}__reference-label`);U(fe,{x:Z(m.plot.right-4),y:se-4,"text-anchor":"end"}),de(fe,Q.label)}le.finish()}function Kt(m){const{series:le,xScale:Q,yScale:se,colour:fe}=m,he=m.size||null;for(let me=0;me<le.points.length;me++){const Pe=le.points[me];if(!S(Pe.y))continue;const ye=Z(ct(Q,Pe));if(Number.isNaN(ye))continue;const Se=Z(se.of(Pe.y));U(m.pool.next("circle",`${t}__point ${t}__mark`),{cx:ye,cy:Se,r:he&&S(Pe.size)?Z(he.of(Pe.size)):R,fill:fe,"fill-opacity":he?.7:1,"data-series":m.index,"data-point":me}),Pe.px=ye,Pe.py=Se}}function Ut(m){const{group:le,series:Q,xScale:se,yScale:fe,options:he}=m,me=m.grid&&m.grid.statistics,Pe=me&&typeof me.intervalOf=="function"?(Ye,Fe)=>me.intervalOf(Ye,Fe):null,ye=new Y(n(le,`${t}__errorbars`)),Se=Number.isFinite(Number(he.confidence))?Number(he.confidence):.95,Ae=4;let Ee=0,Be=0,ze=0,We=0;for(const Ye of Q)for(const Fe of Ye.points){if(Fe.y===null||Fe.y===void 0)continue;Be++;const Ze=Array.isArray(Fe.values)&&Fe.values.length===1;Ze&&ze++;let Ve=null,Xe=null;if(he.of!==void 0&&Number.isFinite(Number(Fe[he.of]))){const et=Math.abs(Number(Fe[he.of]));Ve=Fe.y-et,Xe=Fe.y+et}else if(Array.isArray(Fe.values)&&Fe.values.length>1&&Pe){const et=Pe(Fe.values,Se);et&&(Ve=et.lower,Xe=et.upper)}if(Ve===null||!Number.isFinite(Ve)||!Number.isFinite(Xe)){Ze&&We++;continue}const He=Z(se.of(Fe.xKey!==void 0?Fe.xKey:Fe.x)+(se.bandwidth?se.bandwidth/2:0)),Je=Z(fe.of(Xe)),Qe=Z(fe.of(Ve));U(ye.next("path",`${t}__error-bar ${t}__mark`),{d:oe(["M",He-Ae,Je,"L",He+Ae,Je,"M",He,Je,"L",He,Qe,"M",He-Ae,Qe,"L",He+Ae,Qe]),fill:"none",stroke:"currentColor","data-lower":Ve,"data-upper":Xe}),Ee++}return ye.finish(),{drawn:Ee,marks:Be,single:ze,singleSkipped:We}}function Vt(m){const le=m.scheme||M(),Q=m.axis||{x:{},y:{},y2:{}},se=m.typography||{small:m.fontSize||11,axisTitle:11},{bound:fe,plot:he,type:me}=m,Pe=J[me]||J.line,ye=fe.series.filter(De=>!m.hidden.has(De.key)),Se=!!Pe.horizontal,Ae=!Se&&Q.y.position==="right"?"right":"left",Ee=Ae==="right"?"left":"right",Be=(me==="bar"||me==="horizontalBar")&&m.byRuleColour&&ye.length===1&&fe.measure&&fe.measure.col||null,ze=Be?new Set:null,We=Be?De=>{const Ke=u({grid:m.grid,col:Be,value:De.y});return Ke&&ze.add(Ke),Ke}:null,Fe=(me==="bar"||me==="horizontalBar")&&m.byRuleColour&&ye.length===1&&le.nameMap?De=>le.series(0,De.label):null,Ze=We||Fe?De=>We&&We(De)||Fe&&Fe(De)||null:null,Ve=!Se&&me!=="waterfall"?ye.filter(De=>De.axis==="right"):[],Xe=Ve.length?ye.filter(De=>De.axis!=="right"):ye,He=Ve.length>0,Je=(me==="bar"||me==="area"||me==="horizontalBar")&&!He,Qe=m.stack==="percent"&&Je&&Xe.length>1,et=(Qe||!!m.stack)&&Xe.length>1&&Je,dt=me==="waterfall"?Me(ye[0]):ce(Xe,et,Qe),lt=fe.yDomain||m.domain||I(dt,{zero:Pe.zero,min:Q.y.min,max:Q.y.max}),ot=Se?W(lt,[he.left,he.right]):W(lt,[he.bottom,he.top]),qe=Se?p(fe.categories,[he.top,he.bottom],.2):rt(fe,he,me,Q.x),wt=lt.min<=0&<.max>=0?0:lt.min,Zt=Ve.some(De=>(De.mark||(me==="bar"?"bar":me))==="bar"),ut=He?I(ce(Ve,!1,!1),{zero:Zt,min:Q.y2.min,max:Q.y2.max}):null,it=ut?W(ut,[he.bottom,he.top]):null,kt=F(m.grid,{kind:"linear",step:(lt.max-lt.min)/5}),gt=m.axes!==!1;if(gt&&K({gridGroup:m.groups.grid,axisGroup:m.groups.axis,plot:he,scale:ot,format:kt,horizontal:Se,side:Ae,config:Q.y,grid:m.grid,size:se.small}),gt)if(Se)ge({group:m.groups.overlay,plot:he,scale:qe,labels:fe.labels,fontSize:se.small,config:Q.x});else if(qe.kind==="band")ae({group:m.groups.overlay,plot:he,scale:qe,labels:fe.labels,fontSize:se.small,rotated:C(fe.labels,qe.step,se.small,Q.x.every),config:Q.x});else{const De=fe.dimension&&fe.dimension.col?m.grid.columns.get(fe.dimension.col):void 0;ke({group:m.groups.overlay,plot:he,scale:qe,format:F(m.grid,{kind:fe.kind,span:qe.domain.max-qe.domain.min,step:(qe.domain.max-qe.domain.min)/5},De),config:Q.x,grid:m.grid,column:De,size:se.small})}if(gt&&(re({group:m.groups.rules,plot:he,side:Ae}),l({group:m.groups.axis,plot:he,text:Q.y.title,side:Se?"bottom":Ae,size:se.axisTitle}),l({group:m.groups.axis,plot:he,text:Q.x.title,side:Se?"left":"bottom",size:se.axisTitle})),gt&&it){A({group:m.groups.axis,plot:he,scale:it,colour:le.series(Ve[0].index),side:Ee,format:F(m.grid,{kind:"linear",step:(ut.max-ut.min)/5})});const De=Q.y2.title||(Ve.length===1?Ve[0].label:"");l({group:m.groups.axis,plot:he,text:De,side:Ee,size:se.axisTitle}),!Q.y.title&&Xe.length===1&&Xe[0].label&&l({group:m.groups.axis,plot:he,text:Xe[0].label,side:Ae,size:se.axisTitle})}const Mt=Number.isFinite(m.downsampleTo)?Number(m.downsampleTo):Math.max(2,Math.round(he.width));let Et=!1;if(Pe.marks==="path"||me==="scatter"||me==="bubble"){for(const De of ye)if(De.kept=null,De.points.length>Mt*1.5){const Ke=De.points.map((nt,st)=>({x:st,y:nt.y,point:nt})),tt=v(Ke,Mt);De.points=tt.map(nt=>nt.point),De.kept=tt.map(nt=>nt.x),Et=!0}}m.pool||V(m.groups,he,te(me));const ft=m.pool||new Y(m.groups.marks),Xt=Qe?fe.categories.map((De,Ke)=>ye.reduce((tt,nt)=>{const st=nt.points[Ke]?nt.points[Ke].y:null;return S(st)?tt+Math.abs(st):tt},0)):null,xt=et?Le(fe.categories.length,Xt):null,vt=He?ye.filter(De=>(De.mark||(me==="bar"?"bar":me))==="bar"):ye,Qt=He?Math.max(1,vt.length):Math.max(1,ye.length),en=me==="bar"||He&&vt.length>0,pt=qe.kind==="band"?qe.bandwidth:en?_e({bound:fe,scale:qe,config:Q.x,padding:be("bar")}):0,bt=et?pt:pt/Qt,yt=new Map;for(const De of vt)yt.set(De.key,yt.size);const Tt=[];for(let De=0;De<ye.length;De++){const Ke=ye[De],tt=le.series(Ke.index,Ke.label),nt=Ke.axis==="right"&&it?it:ot,st=He?Ke.mark||(me==="bar"?"bar":me):me,nn=He&&yt.has(Ke.key)?yt.get(Ke.key):De;if(me==="horizontalBar")Gt({pool:ft,series:Ke,bandScale:qe,valueScale:ot,baseline:wt,colour:tt,stack:xt,index:Ke.index,slot:{offset:et?0:De*bt,width:bt,span:pt},pointColour:Ze});else if(me==="waterfall")Wt({pool:ft,series:Ke,xScale:qe,yScale:ot,index:Ke.index,total:!0,positive:le.positive,negative:le.negative});else if(st==="bar")Bt({pool:ft,series:Ke,xScale:qe,yScale:nt,baseline:nt===it?ut.min<=0&&ut.max>=0?0:ut.min:wt,colour:tt,stack:xt,index:Ke.index,slot:{offset:et?0:nn*bt,width:bt,span:pt},pointColour:Ze});else if(me==="scatter"||me==="bubble")Kt({pool:ft,series:Ke,xScale:qe,yScale:nt,colour:tt,index:Ke.index,size:me==="bubble"?m.sizes:null});else{const _t=Dt(m,Ke.label),Ct={pool:ft,series:Ke,xScale:qe,yScale:nt,baseline:wt,fill:st==="area"||st==="rangeArea",step:st==="step",colour:tt,stack:xt,index:Ke.index,style:_t};_t.emphasized?Tt.push(Ct):Nt(Ct)}}for(const De of Tt)Nt(De);m.pool||ft.finish(),m.band&&typeof qe.invert=="function"&&Pt({group:m.groups.overlay,band:m.band,xScale:qe,yScale:ot,scheme:le,index:0,line:m.band.line!==!1&&!m.fit}),m.fit&&(me==="scatter"||me==="bubble")&&typeof qe.invert=="function"&&$t({group:m.groups.overlay,series:ye,xScale:qe,yScale:ot,plot:he,scheme:le,grid:m.grid,size:se.small,showR2:m.fit!=="line"});let ht=null;m.trend&&(ht=w({group:m.groups.overlay,series:ye,xScale:qe,yScale:ot,rightScale:it,plot:he,scheme:le,trend:m.trend,grid:m.grid,format:De=>kt.tick(De),size:se.small,clip:m.groups.boxClipId}));let Lt=null;if(m.error&&(Lt=Ut({group:m.groups.overlay,series:ye,xScale:qe,yScale:ot,grid:m.grid,options:m.error===!0?{}:m.error})),m.labels&&m.labels.show&&c({group:m.groups.labels,series:ye,plot:he,options:m.labels,grid:m.grid,size:se.small,horizontal:Se}),m.reference&&m.reference.length){const De=m.reference.filter(tt=>!(tt.axis==="right"||tt.axis==="y2")),Ke=it?m.reference.filter(tt=>tt.axis==="right"||tt.axis==="y2"):[];De.length&&mt({group:m.groups.overlay,plot:he,scale:ot,lines:De}),Ke.length&&mt({group:m.groups.overlay,plot:he,scale:it,lines:Ke})}let St=null;m.annotations&&m.annotations.length&&(St=T({group:m.groups.overlay,plot:he,xScale:qe,yScale:ot,rightScale:it,series:ye,annotations:m.annotations,dual:He,format:De=>kt.tick(De),size:se.small}));const tn=Array.isArray(ht)&&ht.length?[...St||[],...ht]:St;return{xScale:qe,yScale:ot,rightScale:it,dual:He,series:ye,horizontal:Se,percent:Qe,plot:he,errorBars:Lt,annotations:tn,trendlines:ht,reduced:Et,legend:Be?N({grid:m.grid,col:Be,colours:ze}):null}}const At=32;function qt(m){const{series:le,xScale:Q,at:se}=m,fe=Number.isFinite(m.tolerance)?Number(m.tolerance):At,he=[];let me=-1,Pe=1/0;for(const ye of le){let Se=null,Ae=-1,Ee=1/0;const Be=ye.points||[];for(let ze=0;ze<Be.length;ze++){const We=Be[ze];if(!We||!S(We.y))continue;const Ye=ct(Q,We);if(Number.isNaN(Ye))continue;const Fe=Math.abs(Ye-se);Fe>=Ee||(Ee=Fe,Se=We,Ae=Array.isArray(ye.kept)?ye.kept[ze]:ze)}!Se||Ee>fe||(he.push({series:ye,point:Se}),Ee<Pe&&(Pe=Ee,me=Ae))}return me<0?null:{index:me,entries:he}}function Yt(m){const{bound:le,xScale:Q,at:se}=m;if(!le.categories.length)return-1;if(Q.kind==="band"){const me=Math.floor((se-Q.range[0])/(Q.step||1));return me>=0&&me<le.categories.length?me:-1}let fe=-1,he=1/0;for(let me=0;me<le.categories.length;me++){const Pe=Q.kind==="time"?z(le.categories[me]):H(le.categories[me]);if(Pe===null)continue;const ye=Math.abs(Q.of(Pe)-se);ye<he&&(he=ye,fe=me)}return fe}function Jt(m,le){return le<0||le>=m.categories.length?"":d(m.categories[le])}}),Ge("packages/modules/charts/drawable.js",function(o,ue){"use strict";Object.defineProperty(o,"REASONS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DRAWABLE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"namedColumns",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"missingColumns",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"bucketKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"bucketMessage",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"drawability",{enumerable:!0,get:function(){return L}});const xe=ue("packages/modules/charts/scale.js"),re=xe.extent,l=xe.toNumber,ge=xe.toTime,ke=ue("packages/modules/charts/cartesian.js").staleWindow,K=Object.freeze({EMPTY:"empty",INCOMPLETE:"incomplete",STALE:"stale",MISSING_COLUMN:"missing-column",NO_DOMAIN:"no-domain",BUCKETED:"bucketed"}),te=Object.freeze({ok:!0});function pe(F){if(!F||typeof F!="object")return[];const x=[],_=(p,i)=>{typeof i=="string"&&i?x.push({key:p,col:i}):i&&typeof i=="object"&&typeof i.col=="string"&&i.col&&x.push({key:p,col:i.col})};if(Array.isArray(F.points))return[];if(_("x",F.x),_("code",F.code),_("y",F.y),_("series",F.series),_("size",F.size),_("source",F.source),_("target",F.target),typeof F.multiples=="string"&&_("multiples",F.multiples),Array.isArray(F.measures))for(const p of F.measures)_("measures",p);return x}function V(F,x){const _=F&&F.columns;return!_||typeof _.get!="function"?[]:pe(x).filter(({col:p})=>!_.get(p))}function B(F){return`chart:x:date-bucket:${F}`}function Y(F,x,_){return`chart x column ${JSON.stringify(F)} is a 'date', which stores a calendar day, so all ${x} rows collapsed into one point and were reduced by '${_}'. For a series inside a single day, type the column 'datetime' or bind epoch milliseconds.`}function C(F,x){return!x||x.kind!=="time"&&x.kind!=="linear"?!1:F!=="bar"&&F!=="horizontalBar"}function L(F){const{grid:x,spec:_,type:p,bound:i}=F,S=F.id===void 0?"":String(F.id),d=Number.isFinite(F.now)?Number(F.now):Date.now(),W=(H,z,q,U=!0)=>({ok:!1,reason:H,key:q||`chart:${S}:${H}`,message:z,tell:U}),I=V(x,_);if(I.length){const H=I.map(q=>`${q.key}: ${JSON.stringify(q.col)}`).join(", "),z=x&&x.columns&&typeof x.columns.all=="function"?x.columns.all().map(q=>q.id||q.field).filter(Boolean):[];return W(K.MISSING_COLUMN,`chart ${H} ${I.length>1?"name columns":"names a column"} this grid does not have, so there is nothing to read and nothing to draw.${z.length?` The columns it does have: ${z.slice(0,12).map(q=>JSON.stringify(q)).join(", ")}${z.length>12?", …":""}.`:""} Bind a column the grid declares, or declare the column.`)}if(i&&i.empty){const H=x&&x.rows&&typeof x.rows.count=="function"?x.rows.count():0;return W(K.EMPTY,H?`chart bound nothing from the ${H} row(s) the grid is showing, so it shows its empty state. The binding named no series to draw: check that the spec names the columns this chart needs — a flow type needs source and target, a measure needs a column with values in it.`:"chart has no rows to draw, so it shows its empty state.",void 0,H>0)}if(p==="candlestick"&&(!i||!i.series||i.series.length<4)){const H=i&&i.series?i.series.length:0;return W(K.INCOMPLETE,`a candlestick chart needs four measures — open, high, low and close, in that order — and ${H===0?"none was":`only ${H} were`} bound. Pass them as measures: [open, high, low, close].`)}const b=ke(i,F.axis&&F.axis.x,p,d);if(b){const H=b.newest===null?"and every one of them is stamped ahead of it":`and the newest of ${b.points} x value(s) is ${Math.round(b.age/1e3)}s old`;return W(K.STALE,`the rolling x window covers the last ${b.span} ms, ${H}, so every mark would be drawn outside the plot. The chart shows its empty state instead. Seed it with data inside the window, widen axis.x.window.span, or drop the window while showing history.`,`chart:${S}:x:window:stale:${_&&_.x||""}`,b.newest!==null)}if(C(p,i)){const H=Array.isArray(i.categories)?i.categories:[],z=i.kind==="time"?H.map(ge):H.map(l);if(H.length&&!re(z)){const q=_&&typeof _.x=="string"&&_.x||i.dimension&&i.dimension.col||"";return W(K.NO_DOMAIN,`chart x ${q?`column ${JSON.stringify(q)} `:""}is drawn on a ${i.kind==="time"?"time":"continuous"} axis, and not one of its ${H.length} value(s) reads as a ${i.kind==="time"?"date":"number"} — so the axis would be drawn over a domain invented from nothing rather than measured from the data. Remove axis.x.scale to let the column choose its own scale, or type the column so its values parse.`)}}if(i&&i.bucketed&&C(p,i)){const{col:H,rows:z,fn:q}=i.bucketed;return W(K.BUCKETED,Y(H,z,q),B(H))}return te}}),Ge("packages/modules/charts/bind.js",function(o,ue){"use strict";Object.defineProperty(o,"AGGREGATIONS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"DEFAULT_AGGREGATION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"resolveAggregation",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"defaultAggregationFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"measureOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"walkRows",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"leafRows",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"selectedRows",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"topGroups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"forcedScaleKind",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"scaleKindFor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"bindSeries",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"bindPoints",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"bindMeasures",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"bindLinks",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bindHierarchy",{enumerable:!0,get:function(){return de}});const xe=ue("packages/modules/charts/scale.js"),re=xe.key,l=xe.toNumber,ge=xe.toTime,ae=ue("packages/modules/charts/drawable.js"),ke=ae.bucketKey,K=ae.bucketMessage,pe=ue("packages/core/src/internal/util.js").warnOnce,V={sum:E=>E.length?E.reduce((D,t)=>D+t,0):null,avg:E=>E.length?E.reduce((D,t)=>D+t,0)/E.length:null,mean:E=>E.length?E.reduce((D,t)=>D+t,0)/E.length:null,min:E=>{let D=null;for(let t=0;t<E.length;t++)(D===null||E[t]<D)&&(D=E[t]);return D},max:E=>{let D=null;for(let t=0;t<E.length;t++)(D===null||E[t]>D)&&(D=E[t]);return D},median:E=>{if(!E.length)return null;const D=E.slice().sort((e,v)=>e-v),t=(D.length-1)/2,f=Math.floor(t),c=Math.ceil(t);return f===c?D[f]:(D[f]+D[c])/2},count:(E,D)=>D,countValues:E=>E.length,first:E=>E.length?E[0]:null,last:E=>E.length?E[E.length-1]:null},B="sum";function Y(E){return E==null?B:typeof E=="string"&&E in V?E:(pe(`chart:measure:fn:${String(E)}`,`chart measure fn ${JSON.stringify(E)} is not a known aggregation; using '${B}'. Supported: ${Object.keys(V).join(", ")}.`),B)}function C(E){if(!E)return B;const D=E.groupTotal??E.total;if(typeof D=="string"&&D in V)return D;const t=E.dataType&&E.dataType.totals?E.dataType.totals.supported:null;if(Array.isArray(t)&&!t.includes(B)){const f=["avg","mean","max","min","countValues","count"].find(c=>t.includes(c)&&c in V);if(f)return f}return B}function L(E,D){const t=C(D);return E?typeof E=="string"?{col:E,fn:t}:{col:E.col||null,fn:E.fn==null?t:Y(E.fn)}:{col:null,fn:t}}function F(E,D){const t=new Set,f=c=>{if(!c||t.has(c)||(t.add(c),D(c),!c.group)||c.expanded)return;const e=c.filteredChildren||c.children;if(Array.isArray(e))for(const v of e)f(v)};E.rows.forEach(f)}function x(E){const D=[];return F(E,t=>{!t.group&&t.data!==null&&t.data!==void 0&&D.push(t)}),D}function _(E){const D=new Set(E.selection.keys());if(!D.size)return[];const t=[];return F(E,f=>{!f.group&&D.has(f.key)&&t.push(f)}),t}function p(E){const D=[];let t=1/0;return F(E,f=>{f.group&&(f.level<t&&(t=f.level,D.length=0),f.level===t&&D.push(f))}),D}function i(E,D,t){return D.group&&D.totals&&t in D.totals?l(D.totals[t]):l(E.rows.value(D.key,t))}function S(E,D,t,f){if(!D.group){const c=E.rows.text(D.key,t);if(c)return c}return f==null?"":f instanceof Date?f.toISOString().slice(0,10):String(f)}function d(E,D){return(V[D]||V[B])(E.values,E.rows)}const W=Object.freeze(["number","currency","percent"]),I=Object.freeze(["date","datetime","timestamp","dateString"]),b=Object.freeze({auto:"",band:"category",category:"category",linear:"linear",time:"time"});function H(E){const D=E&&typeof E=="object"?E.axis:null;if(!D||typeof D!="object")return"";const t=D.x;if(!t||typeof t!="object")return"";const f=typeof t.scale=="string"?t.scale:"";return f?Object.hasOwn(b,f)?b[f]:(pe(`chart:x:scale:unknown:${f}`,`chart axis.x.scale ${JSON.stringify(f)} is not a scale this chart draws. Use one of: ${Object.keys(b).join(", ")}. The scale was chosen from the column instead.`),""):""}function z(E){if(E.length<3)return"";let D=0,t=0;for(const f of E){if(f==null||f===""||typeof f=="boolean")return"";l(f)!==null?D++:typeof f=="string"&&ge(f)!==null&&t++}return t===E.length?"time":D===E.length?"linear":""}function q(E,D,t={}){if(t.forced)return t.forced;const f=E&&typeof E.type=="string"?E.type:"";if(I.includes(f)||D.length&&D.every(v=>v instanceof Date))return"time";if(W.includes(f))return"linear";const c=t.id?String(t.id):"";if(!c)return"category";const e=f&&f!=="text"?"":z(D);return e&&pe(`chart:x:banded:${c}`,`chart x column ${JSON.stringify(c)} is typed ${JSON.stringify(f||"text")}, so its ${D.length} values are drawn as categories on a band scale even though they all read as ${e==="time"?"dates":"numbers"}. Type the column ${e==="time"?"'date' (or 'datetime'/'timestamp'/'dateString')":"'number'"} for a continuous axis, or pin it with axis: { x: { scale: '${e}' } }.`),"category"}function U(E,D){const t=D.x||null,f=D.series||(typeof D.multiples=="string"?D.multiples:null)||null,c=E.columns,e=t?c.get(t):void 0,v=L(D.y),$=v.col?c.get(v.col):void 0,M=L(D.y,$);let y;const s=typeof D.rows=="function"?D.rows(E):D.rows;Array.isArray(s)?y=s:D.from==="groups"?y=p(E):D.from==="selection"?y=_(E):y=x(E);const a=y.length?y:x(E),A=new Map,P=new Map,T=[];for(let j=0;j<a.length;j++){const R=a[j],J=t?R.group&&R.groupColumn===t?R.groupValue:E.rows.value(R.key,t):j,ne=re(J);A.has(ne)||(A.set(ne,{value:J,label:t?S(E,R,t,J):String(j),order:A.size}),T.push(J));const ce=f?R.group&&R.groupColumn===f?R.groupValue:E.rows.value(R.key,f):null,Me=f?re(ce):"";P.has(Me)||P.set(Me,{label:f?S(E,R,f,ce):$?.title||"",points:new Map});const Le=P.get(Me);let Ne=Le.points.get(ne);Ne||(Ne={values:[],rows:0,rowKey:R.key},Le.points.set(ne,Ne)),Ne.rows+=R.group&&R.leafCount||1;const Re=M.col?i(E,R,M.col):null;if(Re!==null&&Ne.values.push(Re),D.size){const Ie=l(E.rows.value(R.key,D.size));Ie!==null&&(Ne.sizes=(Ne.sizes||0)+Ie)}}const n=[...A.values()].sort((j,R)=>j.order-R.order),h=typeof D.limit=="number"&&D.limit>0?n.slice(0,D.limit):n,w=q(e,T,{forced:H(D),id:t});let r=null;w==="time"&&a.length>1&&A.size===1&&e&&(e.type==="date"||e.type==="dateString")&&(r={col:String(t),rows:a.length,fn:M.fn},pe(ke(r.col),K(r.col,r.rows,r.fn)));const N=W.includes(e&&typeof e.type=="string"?e.type:"")?[...h].sort((j,R)=>(l(j.value)??0)-(l(R.value)??0)):h,G=[...P.entries()].map(([j,R],J)=>({key:j,label:R.label,index:J,points:N.map(ne=>{const ce=re(ne.value),Me=R.points.get(ce);return{x:ne.value,xKey:ce,label:ne.label,y:Me?d(Me,M.fn):null,size:Me&&Me.sizes!==void 0?Me.sizes:null,rows:Me?Me.rows:0,rowKey:Me?Me.rowKey:null,values:Me&&Me.values?Me.values:null}})}));return{series:G,categories:N.map(j=>j.value),labels:N.map(j=>j.label),kind:w,measure:{...M,title:$?.title||M.col||""},dimension:{col:t,title:e?.title||t||""},empty:G.length===0||N.length===0,rows:a.length,truncated:n.length-N.length,bucketed:r}}function oe(E){const D=Array.isArray(E.points)?E.points:[],t=D.length>0&&D.every(e=>typeof e.x=="number"&&Number.isFinite(e.x)),f=e=>typeof e=="number"&&Number.isFinite(e)?e:null,c=D.map((e,v)=>({x:e.x,xKey:re(e.x),label:e.label!=null?String(e.label):String(e.x),y:f(e.y),size:f(e.size),lower:f(e.lower),upper:f(e.upper),rows:1,rowKey:e.key!=null?String(e.key):String(v),values:null}));return{series:[{key:E.seriesKey||"",label:E.seriesLabel||"",index:0,points:c}],categories:c.map(e=>e.x),labels:c.map(e=>e.label),kind:t?"linear":"category",measure:{col:null,fn:"sum",title:E.measureTitle||""},dimension:{col:null,title:E.dimensionTitle||""},empty:c.length===0,rows:c.length,truncated:0}}function ee(E,D){const t=Array.isArray(D.measures)?D.measures:[];if(!t.length)return U(E,D);const f=t.map($=>{const M=typeof $=="string"?{col:$}:$;return{spec:M,result:U(E,{x:D.x,from:D.from,limit:D.limit,axis:D.axis,y:{col:M.col,fn:M.fn}})}}),c=f[0].result,e=new Map(c.categories.map(($,M)=>[re($),M])),v=f.map(({spec:$,result:M},y)=>{const s=E.columns.get($.col),a=c.categories.map(()=>null),A=M.series[0];if(A)for(const P of A.points){const T=e.get(P.xKey);T!==void 0&&(a[T]=P)}return{key:$.col,label:$.title||$.label||s&&s.title||$.col,index:y,mark:$.type||null,axis:$.axis==="right"?"right":"left",points:c.categories.map((P,T)=>a[T]||{x:P,xKey:re(P),label:c.labels[T],y:null,rows:0,rowKey:null})}});return{series:v,categories:c.categories,labels:c.labels,kind:c.kind,measure:{col:null,fn:"sum",title:v.map($=>$.label).join(", ")},dimension:c.dimension,empty:!v.length||!c.categories.length,rows:c.rows,truncated:c.truncated}}function Z(E,D,t={}){const f=L(D.y),c=!!t.perRow,e=Array.isArray(t.nodes)?t.nodes:[],v=D.source||D.x||null,$=D.target||null;if(!v||!$)return{nodes:[],links:[],measure:{...f,title:""},dimension:{col:null,title:""},series:[],categories:[],labels:[],empty:!0,total:0};const M=f.col?E.columns.get(f.col):void 0,y=new Map,s=new Map,a=(n,h,w)=>{const r=re(n);return y.has(r)||y.set(r,{key:r,value:n,label:S(E,h,w,n),index:y.size,in:0,out:0}),y.get(r)},A=new Map;for(const n of e)!n||n.id===null||n.id===void 0||A.set(re(n.id),n);for(const n of x(E)){const h=E.rows.value(n.key,v),w=E.rows.value(n.key,$);if(h==null||w===null||w===void 0)continue;const r=f.col?l(E.rows.value(n.key,f.col)):1;if(r===null||r<=0)continue;const u=a(h,n,v),N=a(w,n,$);if(c){const G=u.key>N.key,j=G?N:u,R=G?u:N;s.set(`${j.key}\0${R.key}\0${s.size}`,{source:j,target:R,value:r,undirected:!0,pair:`${j.key}\0${R.key}`,rowKeys:[n.key]})}else{const G=`${u.key}\0${N.key}`,j=s.get(G)||{source:u,target:N,value:0,rowKeys:[]};j.value+=r,j.rowKeys.length<64&&j.rowKeys.push(n.key),s.set(G,j)}u.out+=r,N.in+=r}for(const[n,h]of A)y.has(n)||y.set(n,{key:n,value:h.id,label:String(h.label??h.id),index:y.size,in:0,out:0});for(const[n,h]of A){const w=y.get(n);w&&(w.declared=!0,h.label!==void 0&&h.label!==null&&(w.label=String(h.label)),typeof h.icon=="string"&&h.icon&&(w.icon=h.icon),Number.isFinite(h.x)&&Number.isFinite(h.y)&&(w.fx=Number(h.x),w.fy=Number(h.y)))}const P=c?[...s.values()]:[...s.values()].sort((n,h)=>h.value-n.value),T=typeof D.limit=="number"&&D.limit>0?P.slice(0,D.limit):P;return{nodes:[...y.values()],links:T,measure:{...f,title:M?.title||f.col||""},dimension:{col:v,title:E.columns.get(v)?.title||v},series:[],categories:[],labels:[],empty:!T.length,total:T.reduce((n,h)=>n+h.value,0)}}function de(E,D){const t=L(D.y),f=typeof D.depth=="number"&&D.depth>0?D.depth:1/0,c=t.col?E.columns.get(t.col):void 0,e=(s,a,A)=>({label:s,value:a,depth:A,total:0,children:[],rowKey:null}),v=e("",null,0),$=p(E);if($.length){const s=(a,A,P)=>{const T=a.groupColumn?S(E,a,a.groupColumn,a.groupValue):"",n=e(T,a.groupValue,P);n.rowKey=a.key;const h=t.col?i(E,a,t.col):null;n.total=h===null?0:Math.abs(h),A.children.push(n);const w=a.filteredChildren||a.children;if(P<f&&Array.isArray(w))for(const r of w)r.group&&s(r,n,P+1);return!n.total&&n.children.length&&(n.total=n.children.reduce((r,u)=>r+u.total,0)),n};for(const a of $)s(a,v,1)}else{const a=U(E,{x:D.x,y:D.y,limit:D.limit}).series[0];if(a)for(const A of a.points){const P=e(A.label,A.x,1);P.total=A.y===null?0:Math.abs(A.y),P.rowKey=A.rowKey,v.children.push(P)}}v.total=v.children.reduce((s,a)=>s+a.total,0);let M=0;const y=s=>{s.depth>M&&(M=s.depth);for(const a of s.children)y(a)};return y(v),{root:v,depth:M,measure:{...t,title:c?.title||t.col||""},empty:v.total<=0||v.children.length===0}}}),Ge("packages/modules/charts/engine.js",function(o,ue){"use strict";Object.defineProperty(o,"AGGREGATE_MODES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ENGINE_TYPES",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"aggregateMode",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"planAggregate",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"holdsWindow",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"boundFromGroups",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureProvenance",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"specMeasures",{enumerable:!0,get:function(){return f}});const xe=ue("packages/modules/charts/scale.js"),re=xe.key,l=xe.toNumber,ge=ue("packages/modules/charts/bind.js"),ae=ge.forcedScaleKind,ke=ge.measureOf,K=ge.scaleKindFor,te=ue("packages/core/src/source/aggregates.js"),pe=te.resolveAggregatePlan,V=te.STAT_PUSHDOWN,Y=ue("packages/core/src/internal/util.js").warnOnce,C=ue("packages/modules/shared/engine.js"),L=C.engineSource,F=C.gridEngineRequest,x=C.gridHoldsWindow,_=C.loadedAndMatching,p=C.sourceId,i=Object.freeze(["auto","engine","client"]),S=Object.freeze(new Set(["line","step","area","bar","horizontalBar","waterfall","combo","pareto","heatmap","radar","funnel","stream","marimekko"])),d=Object.freeze(new Set(["combo","bar","line","step","area"])),W=Object.freeze({mean:"avg"}),I="__rows",b="m",H="__size",z=/^[A-Za-z_][A-Za-z0-9_$]*$/;function q(c){const e=c?c.aggregate:void 0;return e==null?"auto":typeof e=="string"&&i.includes(e)?e:(Y(`chart:aggregate:mode:${String(e)}`,`chart aggregate ${JSON.stringify(e)} is not a mode; use one of ${i.join(", ")}. The chart used 'auto'.`),"auto")}function U(c,e,v){const $=c.columns.get(e);if(!$)return`the ${v} column "${e}" is not a column of the grid`;const M=$.value&&typeof $.value=="object"?$.value:null;return $.computed||M&&(typeof M.get=="function"||typeof M.compute=="function")?`the ${v} column "${e}" is computed by the grid, which the engine cannot reproduce`:(typeof $.field=="string"?$.field:e)!==e||!z.test(e)?`the ${v} column "${e}" is not a plain physical column the engine can name`:v!=="measure"&&$.type==="geometry"?`the ${v} column "${e}" is a geometry, which charts group in the browser for now`:""}function oe(c,e,v){const $=d.has(v)&&Array.isArray(e.measures)&&e.measures.length>0;return($?e.measures:[e.y]).map((y,s)=>{const a=ke(y),A=a.col?c.columns.get(a.col):void 0,P=ke(y,A),T=y&&typeof y=="object"?y:{};return{id:`${b}${s}`,col:P.col,fn:P.fn,stat:W[P.fn]||P.fn,label:$?T.title||T.label||A&&A.title||P.col||"":A&&A.title||P.col||"",mark:$&&T.type||null,axis:$&&T.axis==="right"?"right":"left",multi:$}})}function ee(c,e,v){const $=q(e),M=(R,J=!1)=>({mode:"client",asked:$,reason:R,refused:$==="engine",windowed:J});if($==="client")return{...M("aggregate: 'client' was asked for"),refused:!1};if(!S.has(v))return M(`a "${v}" chart does not draw a grouped aggregate`);if(Array.isArray(e.points))return M("the chart draws an explicit point set");if(e.rows)return M("the chart was handed its own rows");if(e.from==="groups"||e.from==="selection")return M(`the chart reads the grid's ${e.from==="groups"?"group rows":"selection"}`);if(e.error)return M("error bars need the readings behind each mark");const y=L(c);if("reason"in y)return M(y.reason);const{source:s,caps:a}=y;if(!a.group)return M("the source's adapter does not declare the `group` capability");const A=typeof e.x=="string"&&e.x?e.x:null;if(!A)return M("the chart names no x column to group by");const P=typeof e.series=="string"&&e.series?e.series:typeof e.multiples=="string"?e.multiples:null,T=oe(c,e,v),n=T.length>0&&T[0].multi,h=P&&!n?[A,P]:[A];for(const[R,J]of h.entries()){const ne=U(c,J,R===0?"x":"series");if(ne)return M(ne)}for(const R of T){if(!R.col)return M("a measure names no column to reduce");const J=U(c,R.col,"measure");if(J)return M(J);const ne=V[R.stat];if(!ne||!ne.pushable)return M(`"${R.fn}" of "${R.col}" is not a reduction the engine can compute`)}if(e.size){const R=typeof e.size=="string"?U(c,e.size,"measure"):"the size channel is not a column";if(R)return M(R)}const w=[...T.map(R=>({id:R.id,col:R.col,fn:R.stat})),{id:I,col:A,fn:"count"},...e.size?[{id:H,col:e.size,fn:"sum"}]:[]],r=pe(w,s.aggregates);if(r.client.length){const R=r.client[0];return M(`the source computes "${R.fn}" client-side (${R.reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to compute it in the engine`)}const u=F(c,y);if("reason"in u)return M(u.reason);const{quick:N}=u,G={...u.request,groupBy:h};if($==="auto"){const{loaded:R,total:J}=_(c);if(Number.isFinite(J)&&R>=J)return M("the grid holds every matching row")}const j=JSON.stringify([p(s),G.filters,N,h,w]);return{mode:"engine",asked:$,key:j,source:s,request:G,requested:w,groupBy:h,measures:T}}function Z(c){return x(c)}function de(c,e){if(e==null)return"";if(c&&typeof c.formatValue=="function")try{const v=c.formatValue(e,null);if(typeof v=="string"&&v)return v}catch{}return e instanceof Date?e.toISOString().slice(0,10):String(e)}function E(c,e){if(c==null)return e==null?0:1;if(e==null)return-1;const v=c instanceof Date?c.getTime():l(c),$=e instanceof Date?e.getTime():l(e);return typeof c!="string"&&typeof e!="string"&&v!==null&&$!==null?v-$:String(c).localeCompare(String(e))}function D(c,e,v,$){const{groupBy:M,measures:y}=v,s=M[0],a=M[1]||null,A=y[0].multi,P=c.columns.get(s),T=a?c.columns.get(a):void 0,n=($||[]).filter(Ne=>Ne&&Ne.level===M.length),h=new Map,w=new Map,r=new Map;for(const Ne of n){const Re=Ne.keys[0],Ie=re(Re);h.has(Ie)||h.set(Ie,Re);const Ce=a?Ne.keys[1]:null,we=a?re(Ce):"";w.has(we)||w.set(we,Ce),r.set(`${we}\0${Ie}`,Ne.values||{})}const u=c.sort&&typeof c.sort.get=="function"?c.sort.get():[],N=Array.isArray(u)&&u[0]&&u[0].col===s&&u[0].dir==="desc",G=[...h.entries()].sort((Ne,Re)=>E(Ne[1],Re[1]));N&&G.reverse();const j=typeof e.limit=="number"&&e.limit>0?G.slice(0,e.limit):G,R=j.map(([,Ne])=>de(P,Ne)),J=j.map(([,Ne])=>Ne),ne=(Ne,Re,Ie,Ce,we)=>{const g=r.get(`${Ne}\0${Re}`),k=g?l(g[I]):null;return{x:Ie,xKey:Re,label:Ce,y:g?l(g[we]):null,size:g&&e.size?l(g[H]):null,rows:k===null?0:k,rowKey:null,values:null}};let ce;A?ce=y.map((Ne,Re)=>({key:Ne.col,label:Ne.label,index:Re,mark:Ne.mark,axis:Ne.axis,points:j.map(([Ie,Ce],we)=>ne("",Ie,Ce,R[we],Ne.id))})):ce=[...w.entries()].sort((Re,Ie)=>E(Re[1],Ie[1])).map(([Re,Ie],Ce)=>({key:Re,label:a?de(T,Ie):y[0].label,index:Ce,points:j.map(([we,g],k)=>ne(Re,we,g,R[k],y[0].id))}));const Me=n.reduce((Ne,Re)=>Ne+(l(Re.values&&Re.values[I])||0),0),Le=K(P,J,{forced:ae(e),id:s});return{series:ce,categories:J,labels:R,kind:Le,measure:A?{col:null,fn:"sum",title:ce.map(Ne=>Ne.label).join(", ")}:{col:y[0].col,fn:y[0].fn,title:y[0].label},dimension:{col:s,title:P&&P.title||s},empty:ce.length===0||j.length===0,rows:Me,truncated:G.length-j.length,bucketed:null}}function t(c,e,v=[],$=""){return c.map(M=>{const y=v.find(s=>s.id===M.id);return{col:M.col||null,fn:M.fn,computed:e,...y&&y.class?{class:y.class}:{},...e==="client"&&$?{reason:$}:{}}})}function f(c,e,v){try{return oe(c,e,v).filter($=>$.col)}catch{return[]}}}),Ge("packages/core/src/format/date.js",function(o,ue){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return _}});const xe=ue("packages/core/src/internal/util.js"),re=xe.isNil,l=xe.warnOnce,ge=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ae(p){const i=[];let S=0,d="";const W=()=>{d&&(i.push({token:null,text:d}),d="")};for(;S<p.length;){const I=p[S];if(I==="'"){if(p[S+1]==="'"){d+="'",S+=2;continue}const H=p.indexOf("'",S+1);if(H===-1){d+=p.slice(S+1),S=p.length;continue}d+=p.slice(S+1,H),S=H+1;continue}const b=ge.find(H=>p.startsWith(H,S));if(b){W(),i.push({token:b,text:b}),S+=b.length;continue}/[A-Za-z]/.test(I)&&l(`date.pattern.token:${I}`,`the date pattern "${p}" contains '${I}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${ge.join(" ")}.`),d+=I,S+=1}return W(),i}const ke=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function K(p){if(re(p)||p==="")return null;if(p instanceof Date)return Number.isNaN(p.getTime())?null:p;if(typeof p=="number")return Number.isNaN(p)?null:new Date(p);if(typeof p=="string"){const i=ke.exec(p.trim());if(i){const[,d,W,I,b="0",H="0",z="0"]=i;return new Date(+d,+W-1,+I,+b,+H,+z)}const S=new Date(p);return Number.isNaN(S.getTime())?null:S}return null}function te(p,i){return String(p).padStart(i,"0")}function pe(p){if(!p)return d=>({year:d.getFullYear(),month:d.getMonth()+1,day:d.getDate(),hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),ms:d.getMilliseconds(),weekday:d.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:p,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 d=>{const W={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:d.getMilliseconds(),weekday:0};for(const I of i.formatToParts(d))switch(I.type){case"year":W.year=Number(I.value);break;case"month":W.month=Number(I.value);break;case"day":W.day=Number(I.value);break;case"hour":W.hour=Number(I.value)%24;break;case"minute":W.minute=Number(I.value);break;case"second":W.second=Number(I.value);break;case"weekday":W.weekday=S[I.value]??0;break;default:break}return W}}function V(p,i,S){const d=ae(p),W=pe(S),I=new Set(d.filter(U=>U.token).map(U=>U.token)),b=I.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:S}):null,H=I.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:S}):null,z=I.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:S}):null,q=I.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:S}):null;return U=>{const oe=W(U);let ee="";for(const Z of d){if(!Z.token){ee+=Z.text;continue}switch(Z.token){case"yyyy":ee+=te(oe.year,4);break;case"yy":ee+=te(oe.year%100,2);break;case"MMMM":ee+=H.format(U);break;case"MMM":ee+=b.format(U);break;case"MM":ee+=te(oe.month,2);break;case"M":ee+=String(oe.month);break;case"dd":ee+=te(oe.day,2);break;case"d":ee+=String(oe.day);break;case"EEEE":ee+=q.format(U);break;case"EEE":ee+=z.format(U);break;case"HH":ee+=te(oe.hour,2);break;case"H":ee+=String(oe.hour);break;case"hh":ee+=te(oe.hour%12===0?12:oe.hour%12,2);break;case"h":ee+=String(oe.hour%12===0?12:oe.hour%12);break;case"mm":ee+=te(oe.minute,2);break;case"m":ee+=String(oe.minute);break;case"ss":ee+=te(oe.second,2);break;case"s":ee+=String(oe.second);break;case"SSS":ee+=te(oe.ms,3);break;case"a":ee+=oe.hour<12?"AM":"PM";break;default:ee+=Z.text;break}}return ee}}const B=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function Y(p,i){const S=p||{},d=S.locale||i||void 0,W=S.nullDisplay??"",I=S.timeZone;let b;if(S.pattern)b=V(S.pattern,d,I);else if(S.dateStyle||S.timeStyle){const oe={timeZone:I};S.dateStyle&&(oe.dateStyle=S.dateStyle),S.timeStyle&&(oe.timeStyle=S.timeStyle);const ee=new Intl.DateTimeFormat(d,oe);b=Z=>ee.format(Z)}else{const oe=new Intl.DateTimeFormat(d,{dateStyle:"medium",timeZone:I});b=ee=>oe.format(ee)}const H=S.relative?new Intl.RelativeTimeFormat(d,{numeric:"auto"}):null,q=(typeof S.relative=="object"&&S.relative?S.relative.threshold??7:7)*24*36e5,U=(oe,ee)=>{const Z=K(oe);if(!Z)return W;if(H){const de=ee&&typeof ee.now=="number"?ee.now:Date.now(),E=Z.getTime()-de;if(Math.abs(E)<q){for(const[D,t]of B)if(Math.abs(E)>=t||D==="second")return H.format(Math.round(E/t),D)}}return b(Z)};return U.spec=S,U}function C(p){if(re(p)||p==="")return null;if(typeof p=="string"){const d=/^(\d{4}-\d{2}-\d{2})/.exec(p.trim());if(d)return d[1];const W=K(p);return W?C(W):null}const i=K(p);if(!i)return null;const S=d=>String(d).padStart(2,"0");return`${i.getFullYear()}-${S(i.getMonth()+1)}-${S(i.getDate())}`}function L(p,i){if(re(p)||p==="")return null;if(typeof p=="string"){const d=p.trim();if(F.test(d)){const b=K(d);return b?x(b,i):null}const W=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(d);if(W){const[,b,H,z,q]=W;return`${b}T${H}:${z}${q&&q!=="00"?`:${q}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(d))return`${d}T00:00`;const I=K(d);return I?L(I):null}const S=K(p);return S?x(S,i):null}const F=/(?:Z|[+-]\d{2}:?\d{2})$/i;function x(p,i){const S=b=>String(b).padStart(2,"0");if(i)try{const b=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(p).reduce((q,U)=>(U.type!=="literal"&&(q[U.type]=U.value),q),{}),H=b.hour==="24"?"00":b.hour,z=Number(b.second);return`${b.year}-${b.month}-${b.day}T${H}:${b.minute}`+(z?`:${b.second}`:"")}catch{}const d=`${p.getFullYear()}-${S(p.getMonth()+1)}-${S(p.getDate())}`,W=p.getSeconds(),I=`${S(p.getHours())}:${S(p.getMinutes())}${W?`:${S(W)}`:""}`;return`${d}T${I}`}function _(p,i){const S=re(p)||p===""?null:String(p),d=re(i)||i===""?null:String(i);return S===null?d===null?0:1:d===null||S<d?-1:S>d?1:0}}),Ge("packages/core/src/compute/handle.js",function(o,ue){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return p}});const xe=ue("packages/core/src/internal/util.js"),re=xe.collator,l=xe.defaultCompare,ge=xe.warnOnce;function ae(i){const S=new Uint32Array(i);for(let d=0;d<i;d++)S[d]=d;return S}function ke(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 d=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):d?i.kind==="bitset"?typeof d.size=="number"?d.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(ge(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${d.length*8}`),d.length*8):d.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const K=new WeakMap;function te(i){const S=i.constructor;if(!S)return"unknown";const d=K.get(S);if(d)return d;let W="unknown";try{let I=null;typeof S.from=="function"?I=S.from([!1,!0]):(I=new S(8),I.set(1));const b=I&&I.words;b&&b.length&&(b[0]===2?W="lsb":b[0]===64&&(W="msb"))}catch{W="unknown"}return K.set(S,W),W}function pe(i){if(!i)return()=>0;const S=i instanceof Uint8Array?i:i.words;if(S instanceof Uint8Array){const d=i instanceof Uint8Array?"lsb":te(i);if(d==="lsb")return W=>S[W>>>3]>>>(W&7)&1;if(d==="msb")return W=>S[W>>>3]>>>7-(W&7)&1}return typeof i.get=="function"?d=>i.get(d)?1:0:()=>0}function V(i){return!i||!i.presence?null:pe(i.presence)}function B(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function Y(i,S){return i?typeof i.valueOf=="function"?i.valueOf(S):typeof i.values=="function"?i.values()[S]:null:null}function C(i,S){const d=i.offsets,W=i.values;if(!d||!W)return[];const I=d[S],b=d[S+1];if(!(b>I))return[];const H=i.dict,z=new Array(b-I);for(let q=I;q<b;q++)z[q-I]=H?Y(H,W[q]):W[q];return z}function L(i){if(!i)return()=>{};const S=i.values,d=V(i),W=i.kind;if(W==="dictionary"){const I=i.dict;return d?b=>d(b)?Y(I,S[b]):null:b=>Y(I,S[b])}if(W==="bitset"){const I=pe(S);return d?b=>d(b)?I(b)===1:null:b=>I(b)===1}if(W==="multi")return d?I=>d(I)?C(i,I):null:I=>C(i,I);if(!S&&typeof i.get=="function"){const I=i.get.bind(i);return b=>{const H=I(b);return H===void 0?null:H}}return d?I=>{if(!d(I))return null;const b=S[I];return b===void 0?null:b}:I=>{const b=S[I];return b===void 0?null:b}}function F(i,S){if(i<S)return-1;if(i>S)return 1;if(i===S){const I=Object.is(i,-0),b=Object.is(S,-0);return I===b?0:I?-1:1}const d=Number.isNaN(i),W=Number.isNaN(S);return d&&W?0:d?1:-1}function x(i){const S=re(i);return(d,W)=>{if(d===W)return 0;const I=typeof d,b=typeof W;if(I==="string"&&b==="string")return S.compare(d,W);if(I==="number"&&b==="number")return F(d,W);if(I==="boolean"&&b==="boolean")return d===W?0:d?1:-1;if(d instanceof Date||W instanceof Date){const H=d instanceof Date?d.getTime():Number(d),z=W instanceof Date?W.getTime():Number(W);return F(H,z)}return l(d,W)}}function _(i,S){if(i&&typeof i.ranks=="function")return i.ranks(S);const d=i&&typeof i.values=="function"?i.values():[],W=d.length,I=x(S),b=new Array(W);for(let z=0;z<W;z++)b[z]=z;b.sort((z,q)=>I(d[z],d[q])||z-q);const H=new Uint32Array(W);for(let z=0;z<W;z++)H[b[z]]=z;return H}function p(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ge("packages/core/src/compute/filter.js",function(o,ue){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return T}});const xe=ue("packages/core/src/internal/util.js"),re=xe.isBlank,l=xe.toArray,ge=xe.warnOnce,ke=ue("packages/core/src/format/date.js").toIsoDate,K=ue("packages/core/src/compute/handle.js"),te=K.bitReader,pe=K.dictSize,V=K.dictValue,B=K.presenceReader,Y=K.valueComparator,C=K.valueReader,L=/^\d{4}-\d{2}-\d{2}$/,F="\0null\0";function x(n,h){const w=n&&n.pool;if(w){const r=w.mask||w.acquireMask||w.acquire||w.take;if(typeof r=="function"){const u=r.call(w,h);if(u&&u.length>=h)return u}}return new Uint8Array(h)}function _(n,h){const w=n&&n.pool;if(!w||!h)return;const r=w.release||w.releaseMask||w.free||w.recycle;typeof r=="function"&&r.call(w,h)}function p(n,h,w){return n.fill(w,0,h),n}function i(n){return n==null||typeof n=="number"&&Number.isNaN(n)}function S(n,h){if(n==null)return n;if(h==="number")return typeof n=="number"?n:Number(n);if(h==="date"||h==="dateString"){const w=ke(n);return w===null?d(n):w}return h==="boolean"?typeof n=="boolean"?n:n==="true"||n===1?!0:n==="false"||n===0?!1:!!n:n}function d(n){return n instanceof Date?n.getTime():typeof n=="number"?n:Date.parse(String(n))}function W(n){return typeof n=="number"?n:n instanceof Date?n.getTime():n==null||n===""?NaN:Number(n)}function I(n,h){const w=typeof n=="string"?n:String(n);return h?w:w.toLowerCase()}function b(n,h){return n==null?F:typeof n=="string"?h?n:n.toLowerCase():n instanceof Date?n.getTime():n}function H(n,h,w){const r=new Set;for(const u of l(n)){const N=S(u,w);r.add(b(N,h)),typeof N=="string"&&N!==""&&Number.isFinite(Number(N))?r.add(Number(N)):typeof N=="number"&&Number.isFinite(N)&&r.add(b(String(N),h))}return r}function z(n,h,w){if(n==null||h===null||h===void 0)return n==null&&h==null;const r=typeof n,u=typeof h;return r==="string"&&u==="string"?w?n===h:n.toLowerCase()===h.toLowerCase():n instanceof Date||h instanceof Date?d(n)===d(h):r==="number"&&u==="number"?n===h||Number.isNaN(n)&&Number.isNaN(h):r==="number"&&u==="string"?n===Number(h):r==="string"&&u==="number"?Number(n)===h:r==="boolean"||u==="boolean"?n===h:Array.isArray(n)&&Array.isArray(h)?n.length===h.length&&n.every((N,G)=>z(N,h[G],w)):n===h}function q(n,h){try{if(n instanceof RegExp){const w=n.flags.replace(/[gy]/g,"");return new RegExp(n.source,h||w.includes("i")?w:`${w}i`)}return new RegExp(String(n),h?"":"i")}catch(w){return ge(`regex:${String(n)}`,`filter operator "matches" received an invalid pattern: ${String(n)}`,w),null}}function U(n,h){const w=oe(n,h),r=n&&n.type;return r!=="date"&&r!=="dateString"?w:u=>w(typeof u=="string"&&L.test(u)?u:ke(u)??u)}function oe(n,h){const w=n&&n.op,r=!!(n&&n.caseSensitive),u=n&&n.type,N=Y(h),G=j=>R=>!j(R);switch(w){case"eq":{const j=S(n.value,u);return R=>z(R,j,r)}case"ne":{const j=S(n.value,u);return R=>!z(R,j,r)}case"lt":case"lte":case"gt":case"gte":{const j=S(n.value,u);if(i(j))return()=>!1;const R=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return J=>{if(i(J))return!1;const ne=N(J,j);return R===-1?ne<0:R===0?ne<=0:R===1?ne>0:ne>=0}}case"between":case"notBetween":{const j=l(n.value),R=S(j[0],u),J=S(j[1],u),ne=n.bounds||"[]",ce=ne.charAt(0)!=="(",Me=ne.charAt(1)!==")";if(i(R)||i(J))return w==="between"?()=>!1:()=>!0;const Le=Ne=>{if(i(Ne))return!1;const Re=N(Ne,R),Ie=N(Ne,J);return(ce?Re>=0:Re>0)&&(Me?Ie<=0:Ie<0)};return w==="between"?Le:G(Le)}case"in":case"notIn":{const j=H(n.value,r,u),R=J=>j.has(b(J,r));return w==="in"?R:G(R)}case"contains":case"notContains":{const j=I(S(n.value,u),r),R=J=>J==null?!1:I(J,r).includes(j);return w==="contains"?R:G(R)}case"startsWith":{const j=I(S(n.value,u),r);return R=>R==null?!1:I(R,r).startsWith(j)}case"endsWith":{const j=I(S(n.value,u),r);return R=>R==null?!1:I(R,r).endsWith(j)}case"matches":{const j=q(n.value,r);return j?R=>R==null?!1:j.test(String(R)):()=>!1}case"blank":return j=>re(j)||Array.isArray(j)&&j.length===0;case"notBlank":return j=>!(re(j)||Array.isArray(j)&&j.length===0);case"containsAny":case"containsNone":{const j=H(n.value,r,u),R=J=>{const ne=J==null?[]:l(J);for(let ce=0;ce<ne.length;ce++)if(j.has(b(ne[ce],r)))return!0;return!1};return w==="containsAny"?R:G(R)}case"containsAll":{const j=l(n.value).map(R=>b(S(R,u),r));return R=>{const J=R==null?[]:l(R);if(j.length===0)return!0;const ne=new Set(J.map(ce=>b(ce,r)));for(let ce=0;ce<j.length;ce++)if(!ne.has(j[ce]))return!1;return!0}}default:{const j=T(w);return j?j.compile(n.value):(ge(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition is refused rather than matching every row`),()=>!1)}}}function ee(n,h,w){return U(h,w)(n)}const Z=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),de=new Set(["containsAny","containsAll","containsNone"]);function E(n,h,w){const r=n&&n.op,u=Z[r]||r,N=U({...n,op:u,type:h.type},w),G=h.items,j=R=>{const J=G(R);if(!J)return!1;for(let ne=0;ne<J.length;ne++)if(N(J[ne]))return!0;return!1};return Z[r]?R=>!j(R):j}function D(n,h,w,r){const u=B(n);if(u){const j=h?1:0;for(let R=0;R<r;R++)w[R]=u(R)===j?1:0;return w}const N=n.kind;if(N==="float64"||N==="int32"||N==="bitset")return p(w,r,h?1:0);const G=C(n);for(let j=0;j<r;j++){const R=G(j),J=re(R)||Array.isArray(R)&&R.length===0;w[j]=J===h?0:1}return w}function t(n,h,w,r){const u=n.dict,N=pe(u),G=new Uint8Array(N);for(let ne=0;ne<N;ne++)G[ne]=h(V(u,ne))?1:0;const j=n.values,R=B(n);if(!R){for(let ne=0;ne<r;ne++)w[ne]=G[j[ne]];return w}const J=h(null)?1:0;for(let ne=0;ne<r;ne++)w[ne]=R(ne)===1?G[j[ne]]:J;return w}function f(n,h,w,r){const u=te(n.values),N=h(!0)?1:0,G=h(!1)?1:0,j=B(n);if(!j){for(let J=0;J<r;J++)w[J]=u(J)===1?N:G;return w}const R=h(null)?1:0;for(let J=0;J<r;J++)w[J]=j(J)===0?R:u(J)===1?N:G;return w}function c(n,h,w,r,u){const N=n.values,G=h.type,j=h.op;let R=!0;switch(j){case"eq":case"ne":{const ne=W(S(h.value,G)),ce=typeof h.value=="number"&&Number.isNaN(h.value),Me=j==="ne"?1:0;if(ce)for(let Le=0;Le<u;Le++)r[Le]=(Number.isNaN(N[Le])?1:0)^Me;else for(let Le=0;Le<u;Le++)r[Le]=(N[Le]===ne?1:0)^Me;break}case"lt":{const ne=W(S(h.value,G));for(let ce=0;ce<u;ce++)r[ce]=N[ce]<ne?1:0;break}case"lte":{const ne=W(S(h.value,G));for(let ce=0;ce<u;ce++)r[ce]=N[ce]<=ne?1:0;break}case"gt":{const ne=W(S(h.value,G));for(let ce=0;ce<u;ce++)r[ce]=N[ce]>ne?1:0;break}case"gte":{const ne=W(S(h.value,G));for(let ce=0;ce<u;ce++)r[ce]=N[ce]>=ne?1:0;break}case"between":case"notBetween":{const ne=l(h.value),ce=W(S(ne[0],G)),Me=W(S(ne[1],G)),Le=h.bounds||"[]",Ne=Le.charAt(0)!=="(",Re=Le.charAt(1)!==")",Ie=j==="notBetween"?1:0;if(Ne&&Re)for(let Ce=0;Ce<u;Ce++)r[Ce]=(N[Ce]>=ce&N[Ce]<=Me?1:0)^Ie;else if(Ne)for(let Ce=0;Ce<u;Ce++)r[Ce]=(N[Ce]>=ce&N[Ce]<Me?1:0)^Ie;else if(Re)for(let Ce=0;Ce<u;Ce++)r[Ce]=(N[Ce]>ce&N[Ce]<=Me?1:0)^Ie;else for(let Ce=0;Ce<u;Ce++)r[Ce]=(N[Ce]>ce&N[Ce]<Me?1:0)^Ie;break}case"in":case"notIn":{const ne=new Set;for(const Me of l(h.value)){const Le=W(S(Me,G));Number.isNaN(Le)||ne.add(Le)}const ce=j==="notIn"?1:0;for(let Me=0;Me<u;Me++)r[Me]=(ne.has(N[Me])?1:0)^ce;break}default:R=!1;break}if(!R)return!1;const J=B(n);if(J){const ne=w(null)?1:0;for(let ce=0;ce<u;ce++)J(ce)===0&&(r[ce]=ne)}return!0}function e(n,h,w,r){const u=C(n);for(let N=0;N<r;N++)w[N]=h(u(N))?1:0;return w}function v(n,h,w){const r=h.count|0,u=w||x(h,r);if(!n)return p(u,r,1);const N=typeof h.handle=="function"?h.handle(n.col):void 0,G=typeof h.custom=="function"?h.custom:null;if(!N){if(G){for(let ne=0;ne<r;ne++)u[ne]=G(n,ne)?1:0;return u}return ge(`filter:col:${String(n.col)}`,`filter references unknown column "${String(n.col)}"; the condition is refused rather than matching every row`),p(u,r,0)}const j=n.op;if(j==="blank"||j==="notBlank")return D(N,j==="notBlank",u,r);const R=typeof h.itemwise=="function"?h.itemwise(n.col):null;if(R&&!T(j)&&!de.has(j))return e(N,E(n,R,h.locale),u,r);const J=U(n,h.locale);switch(N.kind){case"dictionary":return t(N,J,u,r);case"bitset":return f(N,J,u,r);case"float64":case"int32":return c(N,n,J,u,r)?u:e(N,J,u,r);default:return e(N,J,u,r)}}function $(n,h,w){if(!n)return p(x(h,w),w,1);if(Array.isArray(n.conditions)){const r=n.conditions.filter(G=>G!=null),u=n.op==="or"?"or":n.op==="not"?"not":"and";if(r.length===0)return p(x(h,w),w,1);const N=$(r[0],h,w);for(let G=1;G<r.length;G++){const j=$(r[G],h,w);if(u==="or")for(let R=0;R<w;R++)N[R]|=j[R];else for(let R=0;R<w;R++)N[R]&=j[R];_(h,j)}if(u==="not")for(let G=0;G<w;G++)N[G]^=1;return N}return v(n,h,x(h,w))}function M(n,h){return $(n,h,h.count|0)}function y(n,h){if(!n||!h)return n||null;const w=n;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return s(w,h)?null:n;const u=[];for(const N of w.conditions){const G=y(N,h);G&&u.push(G)}return u.length?{...w,op:"and",conditions:u}:null}return w.col===h?null:n}function s(n,h){if(!n||typeof n!="object")return!1;const w=n;if(w.col===h)return!0;if(Array.isArray(w.conditions)){for(const r of w.conditions)if(s(r,h))return!0}return!1}function a(n,h,w){if(w&&w.length>=h){let G=0;for(let j=0;j<h;j++)n[j]&&(w[G++]=j);return w.subarray(0,G)}let r=0;for(let G=0;G<h;G++)r+=n[G]?1:0;const u=new Uint32Array(r);let N=0;for(let G=0;G<h;G++)n[G]&&(u[N++]=G);return u}const A=new Map;function P(n){if(!(!n||typeof n!="object"))for(const[h,w]of Object.entries(n))w&&typeof w.compile=="function"&&A.set(h,w)}function T(n){return typeof n=="string"?A.get(n):void 0}}),Ge("packages/modules/charts/viewport-filter.js",function(o,ue){"use strict";Object.defineProperty(o,"VIEWPORT_FILTER_DEBOUNCE_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"resolveViewportFilter",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"viewportTarget",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"viewportBbox",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"sameBbox",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"findColumnCondition",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"viewportCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"conditionBbox",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"pruneTarget",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"mergeViewportCondition",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"adoptedGeoView",{enumerable:!0,get:function(){return F}});const re=ue("packages/core/src/compute/filter.js").pruneColumn,l=150,ge=1e-6;function ae(x){const _={enabled:!1,column:null,debounce:l};if(x==null||x===!1)return _;const p=x===!0?{}:x;if(typeof p!="object")return _;const i=typeof p.column=="string"&&p.column?p.column:null,S=Number.isFinite(p.debounce)&&p.debounce>=0?Number(p.debounce):l;return{enabled:!0,column:i,debounce:S}}function ke(x,_){return typeof _=="string"&&_?{kind:"geometry",column:_}:x&&typeof x.geometry=="string"&&x.geometry?{kind:"geometry",column:x.geometry}:x&&typeof x.lon=="string"&&x.lon&&typeof x.lat=="string"&&x.lat?{kind:"lonlat",lon:x.lon,lat:x.lat}:null}function K(x,_){if(!x||!_||typeof x.xScale?.invert!="function"||typeof x.yScale?.invert!="function")return null;const p=x.xScale.invert(_.left),i=x.xScale.invert(_.right),S=x.yScale.invert(_.bottom),d=x.yScale.invert(_.top);if(![p,i,S,d].every(Number.isFinite))return null;const W=Math.max(-180,Math.min(p,i)),I=Math.min(180,Math.max(p,i)),b=Math.max(-90,Math.min(S,d)),H=Math.min(90,Math.max(S,d));return!(I>W)||!(H>b)?null:[W,b,I,H]}function te(x,_){return!x||!_?!x&&!_:Math.abs(x[0]-_[0])<=ge&&Math.abs(x[1]-_[1])<=ge&&Math.abs(x[2]-_[2])<=ge&&Math.abs(x[3]-_[3])<=ge}function pe(x,_){if(!x)return null;if(Array.isArray(x.conditions)){for(const p of x.conditions){const i=pe(p,_);if(i)return i}return null}return x.col===_?x:null}function V(x,_,p){const[i,S,d,W]=_,I=p?{meta:{label:p}}:{};return x.kind==="geometry"?{col:x.column,op:"withinBbox",value:[i,S,d,W],...I}:{op:"and",conditions:[{col:x.lon,op:"between",value:[i,d]},{col:x.lat,op:"between",value:[S,W]}],...I}}function B(x,_){if(!x||!_)return null;if(_.kind==="geometry"){const b=pe(x,_.column);if(!b||b.op!=="withinBbox"||!Array.isArray(b.value)||b.value.length<4)return null;const H=b.value.map(Number);return H.every(Number.isFinite)?H:null}const p=pe(x,_.lon),i=pe(x,_.lat);if(!p||p.op!=="between"||!Array.isArray(p.value)||p.value.length<2||!i||i.op!=="between"||!Array.isArray(i.value)||i.value.length<2)return null;const[S,d]=p.value.map(Number),[W,I]=i.value.map(Number);return[S,W,d,I].every(Number.isFinite)?[S,W,d,I]:null}function Y(x){return x.kind==="geometry"?[x.column]:[x.lon,x.lat]}function C(x,_){let p=x||null;for(const i of Y(_))p=re(p,i);return p}function L(x,_,p){const i=C(x,_);return i?{op:"and",conditions:[...i.conditions||[i],p]}:p}function F(x,_,p,i){if(!x||!_||!p||!i||!(i.scale>0))return null;const[S,d,W,I]=x,[b,H,z,q]=_,U=W-S,oe=I-d,ee=z-b,Z=q-H;if(!(U>0)||!(oe>0)||!(ee>0)||!(Z>0))return null;const de=(b+z)/2,E=(H+q)/2,D=p.left+(de-S)/U*(p.right-p.left),t=p.bottom-(E-d)/oe*(p.bottom-p.top);if(!Number.isFinite(D)||!Number.isFinite(t))return null;const f=(p.left+p.right)/2,c=(p.top+p.bottom)/2,e=f-D,v=c-t,[$,M]=i.offset,y=[$-e/i.scale,M+v/i.scale],s=Math.min(U/ee,oe/Z);return!Number.isFinite(s)||s<=0?null:{zoom:Math.min(8,Math.max(1,i.zoom*s)),offset:y}}}),Ge("packages/modules/charts/mapview.js",function(o,ue){"use strict";Object.defineProperty(o,"MAP_ENGINE_TYPES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"DEFAULT_VIEWPORT_CAP",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"DENSITY_CELLS_ACROSS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"DENSITY_FIT_PASSES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"FRAME_REFIT_RATIO",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"viewportCap",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"densityCellSize",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"boxSpan",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"ringsBox",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"needsRefit",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"frameMoved",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"planMapViewport",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"engineRowsReader",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"frameOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"capClientBound",{enumerable:!0,get:function(){return f}});const re=ue("packages/core/src/source/pushdown.js").planQuery,ge=ue("packages/core/src/source/aggregates.js").resolveAggregatePlan,ke=ue("packages/core/src/internal/util.js").warnOnce,K=ue("packages/modules/shared/engine.js"),te=K.engineSource,pe=K.gridEngineRequest,V=K.loadedAndMatching,B=K.sourceId,C=ue("packages/modules/charts/engine.js").aggregateMode,L=ue("packages/modules/charts/viewport-filter.js"),F=L.conditionBbox,x=L.viewportCondition,_=L.viewportTarget,p=Object.freeze(new Set(["markermap","bubblemap","choropleth"])),i=2e4,S=24,d=8,W=2,I="__viewport_rows",b=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(c){const e=c?c.viewportCap:void 0;return e==null?i:typeof e=="number"&&Number.isInteger(e)&&e>0?e:(ke(`chart:viewportCap:${String(e)}`,`chart viewportCap ${JSON.stringify(e)} is not a positive whole number of rows; the map used ${i}.`),i)}function z(c){const e=Number.isFinite(c)&&c>0?Math.min(360,c):360,v=2**Math.floor(Math.log2(e/S));return Math.min(90,Math.max(2**-20,v))}function q(c){return Math.max(c[2]-c[0],c[3]-c[1])}function U(c){let e=1/0,v=1/0,$=-1/0,M=-1/0;for(const y of c||[])for(const[s,a]of y)!Number.isFinite(s)||!Number.isFinite(a)||(e=Math.min(e,s),$=Math.max($,s),v=Math.min(v,a),M=Math.max(M,a));return $>=e&&M>=v?[e,v,$,M]:null}function oe(c,e){if(!c||!e)return!1;for(const[v,$]of[[0,2],[1,3]]){const M=c[$]-c[v],y=e[$]-e[v];if(!(M>0)||!(y>0))continue;const s=M/y;if(s>W||s<1/W)return!0}return!1}function ee(c,e){if(!c||!e)return!!e;const v=1e-9;return!(e[0]>=c[0]-v&&e[1]>=c[1]-v&&e[2]<=c[2]+v&&e[3]<=c[3]+v)||oe(c,e)}function Z(c,e,v){const $=c.columns.get(e);if(!$)return`the ${v} column "${e}" is not a column of the grid`;const M=$.value&&typeof $.value=="object"?$.value:null;return $.computed||M&&(typeof M.get=="function"||typeof M.compute=="function")?`the ${v} column "${e}" is computed by the grid, which the engine cannot reproduce`:(typeof $.field=="string"?$.field:e)!==e||!b.test(e)?`the ${v} column "${e}" is not a plain physical column the engine can name`:""}function de(c,e,v,$){const M=C(e),y=we=>({mode:"client",asked:M,reason:we,refused:M==="engine"});if(M==="client")return{...y("aggregate: 'client' was asked for"),refused:!1};if(!p.has(v))return y(`a "${v}" chart does not draw a viewport`);if(e.rows)return y("the chart was handed its own rows");const s=_(e);if(!s)return y("the map names neither a geometry column nor lon/lat columns");if(s.kind==="geometry"&&(e.lon||e.lat))return y("the map names both a geometry column and lon/lat columns");const a=s.kind==="geometry"?[s.column]:[s.lon,s.lat];for(const we of a){const g=Z(c,we,"placement");if(g)return y(g)}const A=te(c);if("reason"in A)return y(A.reason);const{source:P,caps:T}=A,n=P.adapter;if(!n||typeof n.execute!="function")return y("the source's adapter has no execute() to fetch rows with");const h=a[0],w=ge([{id:I,col:h,fn:"count"}],P.aggregates);if(w.client.length)return y(`the source computes "count" client-side (${w.client[0].reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to count in the engine`);const r=Array.isArray($&&$.bbox)?$.bbox:null,u=r?x(s,r):null,N=pe(c,A,u);if("reason"in N)return y(N.reason);if(M==="auto"){const{loaded:we,total:g}=V(c);if(Number.isFinite(g)&&we>=g)return y("the grid holds every matching row")}const G=H(e),j=r||F(c.filters&&typeof c.filters.get=="function"?c.filters.get():null,s),R=j?z(q(j)):null,J=s.kind==="geometry"&&v!=="choropleth"&&Array.isArray(T.buckets)&&T.buckets.includes("grid")&&typeof n.executeGroupedAggregates=="function",ne=v==="choropleth"?"a choropleth draws each shape, and has no density form":s.kind!=="geometry"?"the engine bins a geometry column, and this map places its rows by lon/lat":"the source's adapter cannot bin a geometry column into grid cells (no `buckets` capability)",{request:ce,quick:Me}=N,Le=pe(c,A),Ne=JSON.stringify([B(P),"request"in Le?Le.request.filters:null,Me]),Re=JSON.stringify([B(P),ce.filters,Me,s,G,v]),Ie=JSON.stringify([Re,J?R||"fit":0]);return{mode:"engine",asked:M,key:Ie,rowsKey:Re,baseKey:Ne,cap:G,bbox:r,box:j,cellSize:R,run:async we=>{const g=we?{signal:we}:{},k=await P.aggregate({...ce,...g},[{id:I,col:h,fn:"count"}]);if(k&&Array.isArray(k.client)&&k.client.length)return{map:!0,refused:`the source counted client-side (${k.client[0].reason})`};const O=Number(k&&k.values?k.values[I]:NaN);if(!Number.isFinite(O))return{map:!0,refused:"the engine did not report a count for the view"};if(O<=G){const be={...ce,range:{start:0,end:G}},ve=re(be,T).pushed,$e=await n.execute({...ve,...g},{...be,...g});return{map:!0,kind:"rows",rows:($e&&Array.isArray($e.rows)?$e.rows:[]).slice(0,G),count:O,cap:G,bbox:r,rowsKey:Re}}if(!J)return{map:!0,kind:"over",count:O,cap:G,bbox:r,reason:ne};let X=R||z(360),ie=[];for(let be=1;;be++){const ve=await P.aggregate({...ce,groupBy:[{col:s.column,bucket:"grid",size:X}],...g},[{id:I,col:h,fn:"count"}]);if(ve&&Array.isArray(ve.client)&&ve.client.length)return{map:!0,kind:"over",count:O,cap:G,bbox:r,reason:`the source binned client-side (${ve.client[0].reason})`};ie=[];for(const je of ve&&ve.groups||[]){if(!je||je.level!==1||!Array.isArray(je.keys)||!Array.isArray(je.keys[0]))continue;const[Oe,_e]=je.keys[0].map(Number),Ue=Number(je.values?je.values[I]:NaN);!Number.isFinite(Oe)||!Number.isFinite(_e)||!(Ue>0)||ie.push({west:Oe*X,south:_e*X,east:(Oe+1)*X,north:(_e+1)*X,count:Ue})}if(R||be>=d)break;const $e=U(D([],ie));if(!$e)break;const Te=z(q($e));if(Te>=X)break;X=Te}return{map:!0,kind:"density",cells:ie,count:O,cap:G,bbox:r,size:X}}}}function E(c,e){const v=typeof c.config=="function"?c.config():{},$=v&&typeof v.rowKey=="string"?v.rowKey:null,M=c.permissions&&typeof c.permissions.levelOf=="function"?c.permissions:null,y=new Map,s=e.map((P,T)=>{const n=$&&P&&P[$]!==void 0&&P[$]!==null?P[$]:`engine:${T}`,h=y.has(n)?`engine:${T}`:n,w={key:h,data:P,group:!1};return y.set(h,w),w}),a=P=>{if(!M)return!0;const T=M.levelOf(P);return T==="read"||T==="write"},A=(P,T)=>{const n=y.get(P);if(!n||!a(T))return;const h=c.columns.get(T),w=h&&typeof h.field=="string"?h.field:T,r=n.data?n.data[w]:void 0,u=h&&h.dataType;if(u&&typeof u.toStorage=="function"&&r!==null&&r!==void 0)try{return u.toStorage(r,{colId:T})}catch{return null}return r};return{columns:c.columns,formatting:c.formatting,messages:c.messages,rows:{count:()=>s.length,get:P=>s[P],value:A,text:(P,T)=>{const n=A(P,T);if(n==null)return"";const h=c.columns.get(T);if(h&&typeof h.formatValue=="function")try{const w=h.formatValue(n,y.get(P));if(typeof w=="string")return w}catch{}return String(n)}}}}function D(c,e=[]){let v=1/0,$=1/0,M=-1/0,y=-1/0;for(const n of c||[])!Number.isFinite(n.lon)||!Number.isFinite(n.lat)||(v=Math.min(v,n.lon),M=Math.max(M,n.lon),$=Math.min($,n.lat),y=Math.max(y,n.lat));for(const n of e||[])v=Math.min(v,n.west),M=Math.max(M,n.east),$=Math.min($,n.south),y=Math.max(y,n.north);if(!(M>=v)||!(y>=$))return null;const s=(n,h)=>Math.max(-h,Math.min(h,n)),a=s(v,180),A=s(M,180),P=s($,90),T=s(y,90);return[[[a,P],[A,P],[A,T],[a,T]]]}function t(c,e){if(!e)return!0;const[v,$,M,y]=e,s=(a,A)=>a>=v&&a<=M&&A>=$&&A<=y;if(c.point)return s(c.point[0],c.point[1]);for(const a of c.polygons||[])for(const A of a)for(const[P,T]of A)if(s(P,T))return!0;return!1}function f(c,e,v,$){const M=H(v),y=$&&Array.isArray($.bbox)?$.bbox:null;if(!e||!p.has(c))return{bound:e,viewport:null};if(c==="choropleth"){const N=e.features||[];if(N.length<=M)return{bound:e,viewport:null};let G=0;for(const J of N)t(J,y)&&G++;if(G<=M)return{bound:e,viewport:null};const j=[];for(const J of N){J.point&&j.push({lon:J.point[0],lat:J.point[1]});for(const ne of J.polygons||[])for(const ce of ne)for(const[Me,Le]of ce)j.push({lon:Me,lat:Le})}const R="a choropleth draws each shape, and has no density form";return{bound:{...e,features:[],empty:!1,over:{count:G,cap:M,reason:R},frame:e.frame||D(j)},viewport:{rows:0,matched:G,cap:M,binned:!1,cells:0,over:R,bbox:y?[...y]:null,computed:"client"}}}const s=e.points||[];if(s.length<=M)return{bound:e,viewport:null};const[a,A,P,T]=y||[-1/0,-1/0,1/0,1/0],n=s.filter(N=>N.lon>=a&&N.lon<=P&&N.lat>=A&&N.lat<=T);if(n.length<=M)return{bound:e,viewport:null};const h=y||U([n.map(N=>[N.lon,N.lat])]),w=z(h?q(h):360),r=new Map;for(const N of n){const G=Math.floor(N.lon/w),j=Math.floor(N.lat/w),R=`${G}:${j}`,J=r.get(R)||{west:G*w,south:j*w,east:(G+1)*w,north:(j+1)*w,count:0};J.count++,r.set(R,J)}const u=[...r.values()];return{bound:{...e,density:{cells:u,size:w},frame:e.frame||D(s)},viewport:{rows:0,matched:n.length,cap:M,binned:!0,cells:u.length,over:null,bbox:y?[...y]:null,computed:"client"}}}}),Ge("packages/modules/deckgl/index.js",function(o,ue){"use strict";Object.defineProperty(o,"bindDeck",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return H}});const re=ue("packages/core/src/internal/util.js").warnOnce,ge=ue("packages/modules/geometry/geodata.js").readGeometry,ke=ue("packages/modules/shared/engine.js").EngineFlight,K=ue("packages/modules/charts/mapview.js"),te=K.planMapViewport,pe=K.engineRowsReader,V=K.viewportCap,B=ue("packages/modules/charts/viewport-filter.js"),Y=B.resolveViewportFilter,C=B.viewportTarget,L=B.viewportCondition,F=B.mergeViewportCondition,x=B.conditionBbox,_=B.pruneTarget,p=B.sameBbox;function i(z){if(!Array.isArray(z)||z.length<4)return null;const[q,U,oe,ee]=z.map(Number);if(![q,U,oe,ee].every(Number.isFinite))return null;const Z=Math.max(-180,Math.min(q,oe)),de=Math.min(180,Math.max(q,oe)),E=Math.max(-90,Math.min(U,ee)),D=Math.min(90,Math.max(U,ee));return!(de>Z)||!(D>E)?null:[Z,E,de,D]}function S(z,q){const U=de=>typeof de=="string"&&de!==""&&!!(z.columns&&z.columns.get(de));if(!q||typeof q!="object")return"options.position is missing; pass { lon, lat } or { geometry } naming the grid's columns";const{lon:oe,lat:ee,geometry:Z}=q;return Z!==void 0?U(Z)?{geometry:Z}:`options.position.geometry ${JSON.stringify(Z)} is not a column of the grid`:oe!==void 0||ee!==void 0?U(oe)?U(ee)?{lon:oe,lat:ee}:`options.position.lat ${JSON.stringify(ee)} is not a column of the grid`:`options.position.lon ${JSON.stringify(oe)} is not a column of the grid`:"options.position names neither { lon, lat } nor { geometry }"}function d(z){if(typeof z.getViewports!="function")return null;try{const q=z.getViewports(),U=Array.isArray(q)?q[0]:null;return U&&typeof U.getBounds=="function"?U:null}catch{return null}}function W(z){const q=d(z);if(!q)return null;try{return i(q.getBounds())}catch{return null}}function I(){return{update(){},layers(){return[]},destroy(){}}}function b(z,q){const U=q&&typeof q=="object"?q:{},oe=U.deck;if(!oe||typeof oe.setProps!="function")return re("deckgl:deck","bindDeck: options.deck has no setProps(); pass the page's deck.gl Deck instance. Nothing was bound."),I();if(typeof U.layers!="function")return re("deckgl:layers","bindDeck: options.layers is not a function; pass (rows, ctx) => Layer[] built with your deck.gl classes. Nothing was bound."),I();const ee=z?S(z,U.position):"there is no grid";if(typeof ee=="string")return re("deckgl:position",`bindDeck: the grid has no position: ${ee}. Nothing was bound.`),I();const Z=U.layers,de={...ee,...U.viewportCap!==void 0?{viewportCap:U.viewportCap}:{}},E=Y(U.viewportFilter),D=C(de,null),t=new ke,f=globalThis;let c=[],e=0,v=0,$=!1,M=null,y=!1;const s=j=>{const R=[],J=j.rows.count();for(let ne=0;ne<J;ne++){const ce=j.rows.get(ne);if(!ce||ce.group||ce.data===null||ce.data===void 0)continue;let Me=null;if(ee.geometry)Me=ge(j.rows.value(ce.key,ee.geometry)).geometry;else{const Le=j.rows.value(ce.key,ee.lon),Ne=j.rows.value(ce.key,ee.lat),Re=we=>we==null||we==="",Ie=Number(Le),Ce=Number(Ne);Me=!Re(Le)&&!Re(Ne)&&Number.isFinite(Ie)&&Number.isFinite(Ce)?{type:"Point",coordinates:[Ie,Ce]}:null}Me&&R.push({type:"Feature",geometry:Me,properties:ce.data})}return R},a=()=>{const j=[];z.rows.forEach(J=>{J&&!J.group&&J.data!==null&&J.data!==void 0&&j.push(J)});const R={rows:{count:()=>j.length,get:J=>j[J],value:(J,ne)=>z.rows.value(J,ne)}};return{rows:j.map(J=>J.data),reader:R}},A=()=>{if($)return;e&&(P(e),e=0);const j=W(oe),R=V(de),J=te(z,de,"markermap",{bbox:j});let ne=[],ce=[],Me=!1,Le=!1,Ne;if(J.mode==="engine"){const Ce=t.answer(J.key);Ce||t.ask(J.key,J.run,()=>T());const we=Ce||t.last();Le=t.busy;const g=we&&!("error"in we)?we.result:null;if(g&&g.kind==="rows")ne=g.rows,ce=s(pe(z,ne)),Ne={rows:ce.length,skipped:ne.length-ce.length,matched:g.count,cap:R,binned:!1,cells:0,over:null,bbox:g.bbox?[...g.bbox]:null,computed:"engine"};else if(g&&g.kind==="density")ne=g.cells,Me=!0,Ne={rows:0,skipped:0,matched:g.count,cap:R,binned:!0,cells:ne.length,over:null,bbox:g.bbox?[...g.bbox]:null,computed:"engine"};else if(g&&g.kind==="over")re("deckgl:over",`bindDeck: deck's view holds ${g.count} matching rows, more than its viewportCap of ${g.cap}, and ${g.reason}, so no rows were handed to the layers. Zoom in, narrow the filter, or raise viewportCap.`),Ne={rows:0,skipped:0,matched:g.count,cap:R,binned:!1,cells:0,over:g.reason,bbox:g.bbox?[...g.bbox]:null,computed:"engine"};else{const k=g&&g.refused?String(g.refused):we&&"error"in we?String(we.error?.message||we.error):null;Ne={rows:0,skipped:0,matched:0,cap:R,binned:!1,cells:0,over:k,bbox:j?[...j]:null,computed:"engine"}}}else{const Ce=a();ne=Ce.rows,ce=s(Ce.reader),Ne={rows:ce.length,skipped:ne.length-ce.length,matched:ne.length,cap:R,binned:!1,cells:0,over:null,bbox:j?[...j]:null,computed:"client"}}const Re={grid:z,position:{...ee},binned:Me,pending:Le,features:ce,provenance:Ne},Ie=Z(ne,Re);c=Array.isArray(Ie)?Ie:[],oe.setProps({layers:c})};function P(j){typeof f.cancelAnimationFrame=="function"&&f.cancelAnimationFrame(j),clearTimeout(j)}function T(){if($||e)return;e=(typeof f.requestAnimationFrame=="function"?f.requestAnimationFrame.bind(f):R=>setTimeout(R,16))(()=>{e=0,A()})||1}const n=()=>{if(!E.enabled||!D)return;const j=x(z.filters.get(),D);if(!j){M=null;return}if(p(j,M))return;M=j;const R=d(oe);if(!R||typeof R.fitBounds!="function")return;const[J,ne,ce,Me]=j;let Le;try{Le=R.fitBounds([[J,ne],[ce,Me]])}catch{return}if(!Le)return;const Ne={longitude:Le.longitude,latitude:Le.latitude,zoom:Le.zoom,pitch:0,bearing:0},Re=oe.props||{};Re.viewState?oe.setProps({viewState:{...Re.viewState,...Ne}}):oe.setProps({initialViewState:{...Re.initialViewState||{},...Ne}})},h=()=>{n(),T()},w=()=>{if(v=0,$||!D)return;const j=W(oe);if(!j||p(j,M))return;const R=z.messages&&typeof z.messages.t=="function"?z.messages.t("chart.viewportFilter.label"):void 0,J=F(z.filters.get(),D,L(D,j,R));M=j,z.filters.set(J)},r=oe.props&&typeof oe.props.onViewStateChange=="function"?oe.props.onViewStateChange:null,u=!!d(oe)||typeof oe.getViewports=="function",N=j=>{const R=r?r(j):void 0,J=j&&j.interactionState,ne=!!J&&typeof J=="object"&&Object.values(J).some(Boolean);return!$&&ne&&(clearTimeout(v),v=setTimeout(()=>{E.enabled?w():v=0,T()},E.debounce)),R};E.enabled&&!u&&!y&&(y=!0,re("deckgl:viewports","bindDeck: viewportFilter is on but options.deck has no getViewports(), so its view cannot be read as a box; the grid is not filtered by it.")),u&&oe.setProps({onViewStateChange:N});const G=["model:changed","rows:changed"].map(j=>{const R=z.on(j,h);return typeof R=="function"?R:()=>z.off(j,h)});return n(),A(),{update:A,layers:()=>c,destroy(){if(!$){$=!0,e&&P(e),e=0,clearTimeout(v),t.close();for(const j of G)j();if(u&&oe.setProps({onViewStateChange:r}),M&&D){const j=z.filters.get(),R=_(j,D);R!==j&&z.filters.set(R)}M=null}}}}const H=b});const It=zt("packages/modules/deckgl/index.js"),rn=It.bindDeck;var on=It.default;export{rn as bindDeck,on as default};
|
|
329
336
|
|
|
330
337
|
//# sourceMappingURL=deckgl.esm.min.js.map
|