@toclocoinc/lattice-grid 1.80.0 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +4 -4
  5. package/docs/THEMING.md +6 -3
  6. package/docs/api/adapters.html +1 -1
  7. package/docs/api/ai.html +1 -1
  8. package/docs/api/alarms.html +1 -1
  9. package/docs/api/charts.html +1 -1
  10. package/docs/api/dashboard.html +1 -1
  11. package/docs/api/data-router.html +1 -1
  12. package/docs/api/deckgl.html +1 -1
  13. package/docs/api/gantt.html +1 -1
  14. package/docs/api/geometry.html +1 -1
  15. package/docs/api/grid.html +2 -2
  16. package/docs/api/index.html +1 -1
  17. package/docs/api/kanban.html +1 -1
  18. package/docs/api/kpi.html +1 -1
  19. package/docs/api/layout.html +1 -1
  20. package/docs/api/leaflet.html +1 -1
  21. package/docs/api/list.html +1 -1
  22. package/docs/api/mock-socket.html +1 -1
  23. package/docs/api/presets.html +1 -1
  24. package/docs/api/tabs.html +1 -1
  25. package/docs/api/types.html +1 -1
  26. package/docs/api-detail.html +4 -4
  27. package/docs/warnings.json +1 -1
  28. package/lattice-grid.d.ts +1 -1
  29. package/lattice-grid.esm.min.js +3 -3
  30. package/lattice-grid.min.cjs +3 -3
  31. package/lattice-grid.min.css +1 -1
  32. package/lattice-grid.min.js +3 -3
  33. package/modules/ai.d.ts +1 -1
  34. package/modules/ai.esm.min.js +2 -2
  35. package/modules/ai.min.cjs +2 -2
  36. package/modules/ai.min.js +2 -2
  37. package/modules/alarms.d.ts +1 -1
  38. package/modules/alarms.esm.min.js +2 -2
  39. package/modules/alarms.min.cjs +2 -2
  40. package/modules/alarms.min.js +2 -2
  41. package/modules/angular.d.ts +1 -1
  42. package/modules/angular.esm.min.js +2 -2
  43. package/modules/angular.min.cjs +2 -2
  44. package/modules/angular.min.js +2 -2
  45. package/modules/chart-alluvial.d.ts +1 -1
  46. package/modules/chart-alluvial.esm.min.js +1 -1
  47. package/modules/chart-alluvial.min.cjs +1 -1
  48. package/modules/chart-alluvial.min.js +1 -1
  49. package/modules/chart-arc.d.ts +1 -1
  50. package/modules/chart-arc.esm.min.js +1 -1
  51. package/modules/chart-arc.min.cjs +1 -1
  52. package/modules/chart-arc.min.js +1 -1
  53. package/modules/chart-bubblemap.d.ts +1 -1
  54. package/modules/chart-bubblemap.esm.min.js +1 -1
  55. package/modules/chart-bubblemap.min.cjs +1 -1
  56. package/modules/chart-bubblemap.min.js +1 -1
  57. package/modules/chart-bump.d.ts +1 -1
  58. package/modules/chart-bump.esm.min.js +1 -1
  59. package/modules/chart-bump.min.cjs +1 -1
  60. package/modules/chart-bump.min.js +1 -1
  61. package/modules/chart-calendar.d.ts +1 -1
  62. package/modules/chart-calendar.esm.min.js +1 -1
  63. package/modules/chart-calendar.min.cjs +1 -1
  64. package/modules/chart-calendar.min.js +1 -1
  65. package/modules/chart-choropleth.d.ts +1 -1
  66. package/modules/chart-choropleth.esm.min.js +1 -1
  67. package/modules/chart-choropleth.min.cjs +1 -1
  68. package/modules/chart-choropleth.min.js +1 -1
  69. package/modules/chart-decomposition.d.ts +1 -1
  70. package/modules/chart-decomposition.esm.min.js +1 -1
  71. package/modules/chart-decomposition.min.cjs +1 -1
  72. package/modules/chart-decomposition.min.js +1 -1
  73. package/modules/chart-diverging.d.ts +1 -1
  74. package/modules/chart-diverging.esm.min.js +1 -1
  75. package/modules/chart-diverging.min.cjs +1 -1
  76. package/modules/chart-diverging.min.js +1 -1
  77. package/modules/chart-dumbbell.d.ts +1 -1
  78. package/modules/chart-dumbbell.esm.min.js +1 -1
  79. package/modules/chart-dumbbell.min.cjs +1 -1
  80. package/modules/chart-dumbbell.min.js +1 -1
  81. package/modules/chart-fan.d.ts +1 -1
  82. package/modules/chart-fan.esm.min.js +1 -1
  83. package/modules/chart-fan.min.cjs +1 -1
  84. package/modules/chart-fan.min.js +1 -1
  85. package/modules/chart-hexbin.d.ts +1 -1
  86. package/modules/chart-hexbin.esm.min.js +1 -1
  87. package/modules/chart-hexbin.min.cjs +1 -1
  88. package/modules/chart-hexbin.min.js +1 -1
  89. package/modules/chart-hexmap.d.ts +1 -1
  90. package/modules/chart-hexmap.esm.min.js +1 -1
  91. package/modules/chart-hexmap.min.cjs +1 -1
  92. package/modules/chart-hexmap.min.js +1 -1
  93. package/modules/chart-icicle.d.ts +1 -1
  94. package/modules/chart-icicle.esm.min.js +1 -1
  95. package/modules/chart-icicle.min.cjs +1 -1
  96. package/modules/chart-icicle.min.js +1 -1
  97. package/modules/chart-markermap.d.ts +1 -1
  98. package/modules/chart-markermap.esm.min.js +1 -1
  99. package/modules/chart-markermap.min.cjs +1 -1
  100. package/modules/chart-markermap.min.js +1 -1
  101. package/modules/chart-parallel.d.ts +1 -1
  102. package/modules/chart-parallel.esm.min.js +1 -1
  103. package/modules/chart-parallel.min.cjs +1 -1
  104. package/modules/chart-parallel.min.js +1 -1
  105. package/modules/chart-ridgeline.d.ts +1 -1
  106. package/modules/chart-ridgeline.esm.min.js +1 -1
  107. package/modules/chart-ridgeline.min.cjs +1 -1
  108. package/modules/chart-ridgeline.min.js +1 -1
  109. package/modules/chart-roc.d.ts +1 -1
  110. package/modules/chart-roc.esm.min.js +1 -1
  111. package/modules/chart-roc.min.cjs +1 -1
  112. package/modules/chart-roc.min.js +1 -1
  113. package/modules/chart-slope.d.ts +1 -1
  114. package/modules/chart-slope.esm.min.js +1 -1
  115. package/modules/chart-slope.min.cjs +1 -1
  116. package/modules/chart-slope.min.js +1 -1
  117. package/modules/chart-splom.d.ts +1 -1
  118. package/modules/chart-splom.esm.min.js +1 -1
  119. package/modules/chart-splom.min.cjs +1 -1
  120. package/modules/chart-splom.min.js +1 -1
  121. package/modules/chart-waffle.d.ts +1 -1
  122. package/modules/chart-waffle.esm.min.js +1 -1
  123. package/modules/chart-waffle.min.cjs +1 -1
  124. package/modules/chart-waffle.min.js +1 -1
  125. package/modules/charts.d.ts +1 -1
  126. package/modules/charts.esm.min.js +2 -2
  127. package/modules/charts.min.cjs +2 -2
  128. package/modules/charts.min.js +2 -2
  129. package/modules/dashboard.d.ts +1 -1
  130. package/modules/dashboard.esm.min.js +2 -2
  131. package/modules/dashboard.min.cjs +2 -2
  132. package/modules/dashboard.min.js +2 -2
  133. package/modules/data-router.d.ts +1 -1
  134. package/modules/data-router.esm.min.js +2 -2
  135. package/modules/data-router.min.cjs +2 -2
  136. package/modules/data-router.min.js +2 -2
  137. package/modules/deckgl.d.ts +1 -1
  138. package/modules/deckgl.esm.min.js +2 -2
  139. package/modules/deckgl.min.cjs +2 -2
  140. package/modules/deckgl.min.js +2 -2
  141. package/modules/devtools.d.ts +1 -1
  142. package/modules/devtools.esm.min.js +1 -1
  143. package/modules/devtools.min.cjs +1 -1
  144. package/modules/devtools.min.js +1 -1
  145. package/modules/dhtmlx-compat.d.ts +1 -1
  146. package/modules/dhtmlx-compat.esm.min.js +2 -2
  147. package/modules/dhtmlx-compat.min.cjs +2 -2
  148. package/modules/dhtmlx-compat.min.js +2 -2
  149. package/modules/gantt.d.ts +1 -1
  150. package/modules/gantt.esm.min.js +2 -2
  151. package/modules/gantt.min.cjs +2 -2
  152. package/modules/gantt.min.js +2 -2
  153. package/modules/geo-europe-nuts.d.ts +1 -1
  154. package/modules/geo-europe-nuts.esm.min.js +1 -1
  155. package/modules/geo-europe-nuts.min.cjs +1 -1
  156. package/modules/geo-europe-nuts.min.js +1 -1
  157. package/modules/geo-uk.d.ts +1 -1
  158. package/modules/geo-uk.esm.min.js +1 -1
  159. package/modules/geo-uk.min.cjs +1 -1
  160. package/modules/geo-uk.min.js +1 -1
  161. package/modules/geo-us-states.d.ts +1 -1
  162. package/modules/geo-us-states.esm.min.js +1 -1
  163. package/modules/geo-us-states.min.cjs +1 -1
  164. package/modules/geo-us-states.min.js +1 -1
  165. package/modules/geo-world-110m.d.ts +1 -1
  166. package/modules/geo-world-110m.esm.min.js +1 -1
  167. package/modules/geo-world-110m.min.cjs +1 -1
  168. package/modules/geo-world-110m.min.js +1 -1
  169. package/modules/geo-world-50m.d.ts +1 -1
  170. package/modules/geo-world-50m.esm.min.js +1 -1
  171. package/modules/geo-world-50m.min.cjs +1 -1
  172. package/modules/geo-world-50m.min.js +1 -1
  173. package/modules/geometry.d.ts +1 -1
  174. package/modules/geometry.esm.min.js +2 -2
  175. package/modules/geometry.min.cjs +2 -2
  176. package/modules/geometry.min.js +2 -2
  177. package/modules/htmx.d.ts +1 -1
  178. package/modules/htmx.esm.min.js +3 -3
  179. package/modules/htmx.min.cjs +3 -3
  180. package/modules/htmx.min.js +3 -3
  181. package/modules/kanban.d.ts +1 -1
  182. package/modules/kanban.esm.min.js +2 -2
  183. package/modules/kanban.min.cjs +2 -2
  184. package/modules/kanban.min.js +2 -2
  185. package/modules/kpi.d.ts +1 -1
  186. package/modules/kpi.esm.min.js +2 -2
  187. package/modules/kpi.min.cjs +2 -2
  188. package/modules/kpi.min.js +2 -2
  189. package/modules/layout.d.ts +1 -1
  190. package/modules/layout.esm.min.js +2 -2
  191. package/modules/layout.min.cjs +2 -2
  192. package/modules/layout.min.js +2 -2
  193. package/modules/leaflet.d.ts +1 -1
  194. package/modules/leaflet.esm.min.js +2 -2
  195. package/modules/leaflet.min.cjs +2 -2
  196. package/modules/leaflet.min.js +2 -2
  197. package/modules/list.d.ts +1 -1
  198. package/modules/list.esm.min.js +2 -2
  199. package/modules/list.min.cjs +2 -2
  200. package/modules/list.min.js +2 -2
  201. package/modules/mock-socket.d.ts +1 -1
  202. package/modules/mock-socket.esm.min.js +1 -1
  203. package/modules/mock-socket.min.cjs +1 -1
  204. package/modules/mock-socket.min.js +1 -1
  205. package/modules/presets/antd5.css +23 -0
  206. package/modules/presets/bootstrap5.css +46 -5
  207. package/modules/presets/fluent2.css +31 -4
  208. package/modules/presets/material3.css +53 -5
  209. package/modules/presets.d.ts +1 -1
  210. package/modules/presets.esm.min.js +2 -2
  211. package/modules/presets.min.cjs +2 -2
  212. package/modules/presets.min.js +2 -2
  213. package/modules/react.d.ts +1 -1
  214. package/modules/react.esm.min.js +2 -2
  215. package/modules/react.min.cjs +2 -2
  216. package/modules/react.min.js +2 -2
  217. package/modules/svelte.d.ts +1 -1
  218. package/modules/svelte.esm.min.js +2 -2
  219. package/modules/svelte.min.cjs +2 -2
  220. package/modules/svelte.min.js +2 -2
  221. package/modules/tabs.d.ts +1 -1
  222. package/modules/tabs.esm.min.js +2 -2
  223. package/modules/tabs.min.cjs +2 -2
  224. package/modules/tabs.min.js +2 -2
  225. package/modules/vue.d.ts +1 -1
  226. package/modules/vue.esm.min.js +2 -2
  227. package/modules/vue.min.cjs +2 -2
  228. package/modules/vue.min.js +2 -2
  229. package/modules/webcomponent.d.ts +1 -1
  230. package/modules/webcomponent.esm.min.js +3 -3
  231. package/modules/webcomponent.min.cjs +3 -3
  232. package/modules/webcomponent.min.js +3 -3
  233. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.80.0, core + DOM renderer
2
+ * Lattice Grid 1.81.0, core + DOM renderer
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var dr=Object.create(null),fr=Object.create(null);function xe(e,K){dr[e]=K}function Gn(e){var K=fr[e];if(K)return K;var X=Object.create(null);fr[e]=X;var L=dr[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(X,Gn),X}xe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const X="1.80.0";async function L(){return X}const B="1.80.0",F=new Set,_=2e3;function Q(ne){if(F.add(ne),F.size>_){const ae=F.values().next().value;ae!==void 0&&F.delete(ae)}}const G=[],H=500;function U(ne,ae,de){G.push({key:ne,level:ae,message:de.map(ie=>typeof ie=="string"?ie:z(ie)).join(" "),at:Date.now()}),G.length>H&&G.shift()}function z(ne){if(ne instanceof Error)return ne.message;try{return JSON.stringify(ne)}catch{return String(ne)}}function S(){return G.map(ne=>({...ne}))}function O(ne){if(ne.length===0||typeof ne[0]!="string")return ne;const ae=ne[0].replace(/^\[lattice\]\s*/,"");return ae===ne[0]?ne:[ae,...ne.slice(1)]}function b(ne,...ae){if(F.has(ne))return;Q(ne);const de=O(ae);U(ne,"warn",de),console.warn("[lattice]",...de)}function u(ne,...ae){if(F.has(ne))return;Q(ne);const de=O(ae);U(ne,"info",de),console.info("[lattice]",...de)}function d(){F.clear(),G.length=0}function s(ne,ae){const de=new Error(`[lattice] ${ne}`);throw ae!==void 0&&(de.cause=ae),de}function n(ne,ae){ne||s(ae)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ne){return ne!==null&&typeof ne=="object"&&!Array.isArray(ne)}function o(ne){return typeof ne=="function"}function f(ne){return ne==null}function l(ne){return ne==null||ne===""}function i(ne){return typeof ne!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ne))?!0:!!(ne.prototype&&Object.getOwnPropertyNames(ne.prototype).length>1)}const g=new Map;function c(ne){let ae=g.get(ne);if(ae)return ae;if(!ne.includes("."))ae=de=>de?.[ne];else{const de=ne.split("."),ie=de.length;ae=oe=>{let ce=oe;for(let fe=0;fe<ie;fe++){if(ce==null)return;ce=ce[de[fe]]}return ce}}return g.set(ne,ae),ae}const h=new Map;function a(ne){let ae=h.get(ne);if(ae)return ae;if(!ne.includes("."))ae=(de,ie)=>{de!=null&&(de[ne]=ie)};else{const de=ne.split("."),ie=de.length-1;ae=(oe,ce)=>{let fe=oe;for(let ke=0;ke<ie;ke++){if(fe==null)return;const Re=de[ke];fe[Re]==null&&(fe[Re]={}),fe=fe[Re]}fe!=null&&(fe[de[ie]]=ce)}}return h.set(ne,ae),ae}function m(ne,ae){return c(ae)(ne)}function w(ne,ae,de){a(ae)(ne,de)}function v(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,de=>de.toUpperCase()):""}const p={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function y(ne){const ae=ne==null?"":String(ne);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,de=>p[de]):ae}function C(ne){return String(ne).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function T(ne,ae,de){if(ne!==void 0)return ne===!0?{enabled:!0,...de}:ne===!1?{enabled:!1}:r(ne)?ne:{[ae]:ne,enabled:!0}}function P(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(ne,ae){if(!r(ne))return r(ae)?{...ae}:ae;if(!r(ae))return ae===void 0?ne:ae;const de={...ne};for(const ie of Object.keys(ae)){if(x.has(ie))continue;const oe=ae[ie];oe!==void 0&&(de[ie]=r(oe)&&r(de[ie])?E(de[ie],oe):oe)}return de}function j(ne,ae){if(!r(ne)||!r(ae)||ne===ae)return ae;const de=Object.create(Object.getPrototypeOf(ne));return Object.assign(de,ne,ae),de}class A{#e;#t=new Map;#n;constructor(ae=256,de=null){this.#e=ae,this.#n=de}get size(){return this.#t.size}get max(){return this.#e}set max(ae){this.#e=ae,this.#r()}has(ae){return this.#t.has(ae)}get(ae){const de=this.#t;if(!de.has(ae))return;const ie=de.get(ae);return de.delete(ae),de.set(ae,ie),ie}peek(ae){return this.#t.get(ae)}set(ae,de){const ie=this.#t;return ie.has(ae)&&ie.delete(ae),ie.set(ae,de),this.#r(),de}delete(ae){const de=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(de,ae),de}clear(){if(this.#n)for(const[ae,de]of this.#t)this.#n(de,ae);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const ae=this.#t;for(;ae.size>this.#e;){const de=ae.keys().next().value,ie=ae.get(de);ae.delete(de),this.#n&&this.#n(ie,de)}}}const $=new Map;function D(ne,ae){const de=`${ne||""}|${ae?JSON.stringify(ae):""}`;let ie=$.get(de);return ie||(ie=new Intl.Collator(ne||void 0,{numeric:!0,sensitivity:"variant",...ae}),$.set(de,ie)),ie}function M(ne,ae){if(ne===ae)return 0;if(ne==null)return 1;if(ae==null)return-1;if(typeof ne=="number"&&typeof ae=="number")return Number.isNaN(ne)?Number.isNaN(ae)?0:1:Number.isNaN(ae)||ne<ae?-1:ne>ae?1:0;const de=String(ne),ie=String(ae);return de<ie?-1:de>ie?1:0}function R(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function I(ne){return k?requestAnimationFrame(ne):setTimeout(()=>ne(R()),16)}function q(ne){ne!=null&&(k?cancelAnimationFrame(ne):clearTimeout(ne))}function Z(ne){let ae=null,de=null;const ie=()=>{ae=null;const ce=de;de=null,ne(...ce||[])},oe=(...ce)=>{de=ce,ae===null&&(ae=I(ie))};return oe.cancel=()=>{q(ae),ae=null,de=null},oe.flush=()=>{ae!==null&&(q(ae),ie())},oe}function W(ne,ae){let de=null,ie=null;const oe=()=>{if(de=null,ie===null)return;const ke=ie;ie=null,ne(...ke),ce()},ce=()=>{de=setTimeout(oe,ae),typeof de?.unref=="function"&&de.unref()},fe=(...ke)=>{de===null?(ne(...ke),ce()):(ie=ke,clearTimeout(de),ce())};return fe.flush=()=>{if(de!==null&&clearTimeout(de),de=null,ie===null)return;const ke=ie;ie=null,ne(...ke)},fe.cancel=()=>{de!==null&&clearTimeout(de),de=null,ie=null},fe.pending=()=>de!==null||ie!==null,fe}function J(ne,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ne,{timeout:ae}):setTimeout(()=>ne({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function te(ne="l"){return`${ne}${(++ee).toString(36)}`}}),xe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return C}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Q=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function G(T,P){const x=Number(T),E=Number(P);if(T!==null&&T!==""&&P!==null&&P!==""&&Number.isFinite(x)&&Number.isFinite(E))return x<E?-1:x>E?1:0;const A=String(T??"").toLowerCase(),$=String(P??"").toLowerCase();return A<$?-1:A>$?1:0}function H(T){return T==null||T===""}function U(T,P){if(!P||typeof P!="object")return!1;const{op:x}=P,E=P.value,j=P.value2;switch(x){case"blank":return H(T);case"notBlank":return!H(T);case"true":return T===!0;case"false":return T===!1;default:break}if(H(T))return!1;switch(x){case"eq":return G(T,E)===0;case"ne":return G(T,E)!==0;case"gt":return G(T,E)>0;case"gte":return G(T,E)>=0;case"lt":return G(T,E)<0;case"lte":return G(T,E)<=0;case"between":return G(T,E)>=0&&G(T,j)<=0;case"outside":return G(T,E)<0||G(T,j)>0;case"contains":return String(T).toLowerCase().includes(String(E??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(E??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(E??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(E??"").toLowerCase());default:return!1}}function z(T,P,x){const E=q=>{const Z=String(q).replace("#",""),W=Z.length===3?Z.split("").map(J=>J+J).join(""):Z;return[0,2,4].map(J=>parseInt(W.slice(J,J+2),16)||0)},[j,A,$]=E(T),[D,M,R]=E(P),k=Math.max(0,Math.min(1,x)),I=(q,Z)=>Math.round(q+(Z-q)*k);return`#${[I(j,D),I(A,M),I($,R)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function S(T){const P=[];for(const D of T||[]){if(D==null||D==="")continue;const M=D instanceof Date?D.getTime():Number(D);Number.isFinite(M)&&P.push(M)}if(!P.length)return null;P.sort((D,M)=>D-M);let x=0,E=0,j=0;for(const D of P){x++;const M=D-E;E+=M/x,j+=M*(D-E)}const A=O(P,.25),$=O(P,.75);return{n:P.length,min:P[0],max:P[P.length-1],mean:E,stddev:P.length>1?Math.sqrt(j/(P.length-1)):0,median:O(P,.5),q1:A,q3:$,iqr:$-A,sorted:P}}function O(T,P){if(!T.length)return 0;const x=(T.length-1)*Math.max(0,Math.min(1,P)),E=Math.floor(x),j=Math.ceil(x);return E===j?T[E]:T[E]+(x-E)*(T[j]-T[E])}function b(T){for(const P of Array.isArray(T)?T:[])if(!(!P||typeof P!="object")&&(P.when&&_.includes(P.when.op)||P.scale&&P.scale.from||P.dataBar&&!(Number.isFinite(Number(P.dataBar.min))&&Number.isFinite(Number(P.dataBar.max)))||P.iconSet&&!Array.isArray(P.iconSet.thresholds)))return!0;return!1}function u(T,P){const x=Number(T.value),E=j=>O(P.sorted,j);switch(T.op){case"topPercent":{const j=d(x,10);return{op:"gte",value:E(1-j)}}case"bottomPercent":{const j=d(x,10);return{op:"lte",value:E(j)}}case"topN":{const j=Math.max(1,Math.floor(x)||1),A=Math.max(0,P.sorted.length-j);return{op:"gte",value:P.sorted[A]}}case"bottomN":{const j=Math.max(1,Math.floor(x)||1),A=Math.min(P.sorted.length-1,j-1);return{op:"lte",value:P.sorted[A]}}case"aboveMean":return{op:"gt",value:P.mean};case"belowMean":return{op:"lt",value:P.mean};case"aboveMedian":return{op:"gt",value:P.median};case"belowMedian":return{op:"lt",value:P.median};case"zAbove":return P.stddev?{op:"gte",value:P.mean+(Number.isFinite(x)?x:2)*P.stddev}:null;case"zBelow":return P.stddev?{op:"lte",value:P.mean-(Number.isFinite(x)?x:2)*P.stddev}:null;case"outlier":{const j=(Number.isFinite(x)&&x>0?x:1.5)*P.iqr;return P.iqr?{op:"outside",value:P.q1-j,value2:P.q3+j}:null}default:return null}}function d(T,P){const x=Number.isFinite(T)?T:P,E=x>1?x/100:x;return Math.max(0,Math.min(1,E))}function s(T,P){if(T.from==="minmax")return{...T,min:P.min,max:P.max};if(T.from==="quantile")return{...T,min:O(P.sorted,d(Number(T.low),5)),max:O(P.sorted,d(Number(T.high),95))};if(T.from==="stddev"){const x=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:P.mean-x*P.stddev,max:P.mean+x*P.stddev}}return T}function n(T,P){const x=Array.isArray(T)?T:[];return!P||!P.n?x.map(E=>E&&b([E])?{...E,enabled:!1}:E):x.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:s(E.scale,P)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,P)};if(E.iconSet)return{...E,iconSet:r(E.iconSet,P)};if(!E.when||!_.includes(E.when.op))return E;const j=u(E.when,P);return j?{...E,when:j}:{...E,enabled:!1}})}function t(T,P){const x=Number.isFinite(Number(T.min))?Number(T.min):void 0,E=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(x!==void 0&&E!==void 0)return{...T,min:x,max:E};if(T.from==="quantile")return{...T,min:x??O(P.sorted,d(Number(T.low),5)),max:E??O(P.sorted,d(Number(T.high),95))};if(T.from==="stddev"){const j=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:x??P.mean-j*P.stddev,max:E??P.mean+j*P.stddev}}return{...T,min:x??P.min,max:E??P.max}}function r(T,P){if(Array.isArray(T.thresholds))return T;const x=o(T),E=[];for(let j=1;j<x;j++)E.push(O(P.sorted,j/x));return{...T,thresholds:E}}function o(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const P=a[T.set];return P?P.length:3}function f(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function l(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function i(T,P){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${P==="up"?"8,2 14,13 2,13":P==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function g(T,P){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${P*16} 16">`;for(let j=0;j<P;j++){const A=j<T?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${j*16},0)" d="${x}" fill="${A}"/>`}return`${E}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),h=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),a=Object.freeze({arrows:c,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(T=>g(T,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(E=>/^\s*(url\(|data:|<)/.test(String(E))&&String(E).trim().startsWith("<")?f(String(E)):String(E));const P=T.set||"arrows";if(P==="ratings"){const E=o(T),j=[];for(let A=1;A<=E;A++)j.push(f(g(A,E)));return j}const x=a[P];return x?x.map(f):(B(`iconSet:${P}`,`unknown icon set '${P}'; falling back to arrows.`),c.map(f))}function v(T){const P=Number(T.min),E=Number(T.max)-P,j=T.colour||T.color||"#5b9bd5",A=T.negativeColour||T.negativeColor||"#d13438",$=T.direction==="rtl"?"left":"right",D=R=>Math.max(0,Math.min(1,(R-P)/E))*100,M=E?Math.max(0,Math.min(100,(0-P)/E*100)):0;return R=>{if(H(R))return null;const k=Number(R);if(!Number.isFinite(k)||!E)return null;const I=D(k),q=Math.min(I,M),Z=Math.max(I,M),W=k>=0?j:A;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${W} ${q}%, ${W} ${Z}%, transparent ${Z}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function p(T){const P=w(T),x=T.reverse?[...P].reverse():P,E=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),j=Number.isFinite(Number(T.size))?Number(T.size):16,A=T.set==="ratings"?j*o(T):j;return $=>{if(H($))return null;const D=Number($);if(!Number.isFinite(D))return null;let M=0;for(const k of E)D>=k&&M++;const R=x[Math.min(M,x.length-1)];return R?{backgroundImage:R,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${A}px ${j}px`,paddingLeft:`${A+4}px`}:null}}function y(T){const P=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],x=Number(T.min),E=Number(T.max),j=E-x,A=P.length-1,$=[];for(let M=0;M<=A;M++)$.push(A?M/A:0);const D=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(P.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${P.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&j&&D>Math.min(x,E)&&D<Math.max(x,E)){const M=A/2,R=Math.max(0,Math.min(1,(D-x)/j));for(let k=0;k<=A;k++)$[k]=k<=M?M?k/M*R:R:R+(k-M)/(A-M)*(1-R)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return M=>{const R=Number(M);if(!Number.isFinite(R)||!j)return null;const k=Math.max(0,Math.min(1,(R-x)/j));let I=0;for(;I<A-1&&k>$[I+1];)I++;const q=$[I+1]-$[I],Z=q>0?(k-$[I])/q:0;return{background:z(P[I],P[I+1],Math.max(0,Math.min(1,Z)))}}}function C(T,P=null){const x=b(T)?n(T,P):T,E=(Array.isArray(x)?x:[]).filter(A=>A&&typeof A=="object");if(!E.length)return()=>null;const j=E.map(A=>A.scale?{scale:y(A.scale),enabled:A.enabled!==!1}:A.dataBar?{scale:v(A.dataBar),enabled:A.enabled!==!1}:A.iconSet?{scale:p(A.iconSet),enabled:A.enabled!==!1}:{when:A.when,style:A.style,stop:A.stopIfTrue!==!1,enabled:A.enabled!==!1});return A=>{const $=A?A.value:void 0;let D=null;for(const M of j){if(!M.enabled)continue;if(M.scale){const k=M.scale($);k&&(D={...D||{},...k});continue}if(!U($,M.when))continue;const R=L(M.style)?M.style(A):M.style;if(R&&(D={...D||{},...R}),M.stop)break}return D}}}),xe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const X="num",L="str",B="ref",F="name",_="op",Q="end",G=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(o,f){super(o),this.name="FormulaError",this.at=f}}function z(r){const o=[];let f=0;for(;f<r.length;){const l=r[f];if(l===" "||l===" "||l===`
6
+ var dr=Object.create(null),fr=Object.create(null);function xe(e,K){dr[e]=K}function Gn(e){var K=fr[e];if(K)return K;var X=Object.create(null);fr[e]=X;var L=dr[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(X,Gn),X}xe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const X="1.81.0";async function L(){return X}const B="1.81.0",F=new Set,_=2e3;function Q(ne){if(F.add(ne),F.size>_){const ae=F.values().next().value;ae!==void 0&&F.delete(ae)}}const G=[],H=500;function U(ne,ae,de){G.push({key:ne,level:ae,message:de.map(ie=>typeof ie=="string"?ie:z(ie)).join(" "),at:Date.now()}),G.length>H&&G.shift()}function z(ne){if(ne instanceof Error)return ne.message;try{return JSON.stringify(ne)}catch{return String(ne)}}function S(){return G.map(ne=>({...ne}))}function O(ne){if(ne.length===0||typeof ne[0]!="string")return ne;const ae=ne[0].replace(/^\[lattice\]\s*/,"");return ae===ne[0]?ne:[ae,...ne.slice(1)]}function b(ne,...ae){if(F.has(ne))return;Q(ne);const de=O(ae);U(ne,"warn",de),console.warn("[lattice]",...de)}function u(ne,...ae){if(F.has(ne))return;Q(ne);const de=O(ae);U(ne,"info",de),console.info("[lattice]",...de)}function d(){F.clear(),G.length=0}function s(ne,ae){const de=new Error(`[lattice] ${ne}`);throw ae!==void 0&&(de.cause=ae),de}function n(ne,ae){ne||s(ae)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(ne){return ne!==null&&typeof ne=="object"&&!Array.isArray(ne)}function o(ne){return typeof ne=="function"}function f(ne){return ne==null}function l(ne){return ne==null||ne===""}function i(ne){return typeof ne!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ne))?!0:!!(ne.prototype&&Object.getOwnPropertyNames(ne.prototype).length>1)}const g=new Map;function c(ne){let ae=g.get(ne);if(ae)return ae;if(!ne.includes("."))ae=de=>de?.[ne];else{const de=ne.split("."),ie=de.length;ae=oe=>{let ce=oe;for(let fe=0;fe<ie;fe++){if(ce==null)return;ce=ce[de[fe]]}return ce}}return g.set(ne,ae),ae}const h=new Map;function a(ne){let ae=h.get(ne);if(ae)return ae;if(!ne.includes("."))ae=(de,ie)=>{de!=null&&(de[ne]=ie)};else{const de=ne.split("."),ie=de.length-1;ae=(oe,ce)=>{let fe=oe;for(let ke=0;ke<ie;ke++){if(fe==null)return;const Re=de[ke];fe[Re]==null&&(fe[Re]={}),fe=fe[Re]}fe!=null&&(fe[de[ie]]=ce)}}return h.set(ne,ae),ae}function m(ne,ae){return c(ae)(ne)}function w(ne,ae,de){a(ae)(ne,de)}function v(ne){return ne?(ne.includes(".")?ne.slice(ne.lastIndexOf(".")+1):ne).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,de=>de.toUpperCase()):""}const p={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function y(ne){const ae=ne==null?"":String(ne);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,de=>p[de]):ae}function C(ne){return String(ne).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function T(ne,ae,de){if(ne!==void 0)return ne===!0?{enabled:!0,...de}:ne===!1?{enabled:!1}:r(ne)?ne:{[ae]:ne,enabled:!0}}function P(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}const x=Object.freeze(new Set(["__proto__","constructor","prototype"]));function E(ne,ae){if(!r(ne))return r(ae)?{...ae}:ae;if(!r(ae))return ae===void 0?ne:ae;const de={...ne};for(const ie of Object.keys(ae)){if(x.has(ie))continue;const oe=ae[ie];oe!==void 0&&(de[ie]=r(oe)&&r(de[ie])?E(de[ie],oe):oe)}return de}function j(ne,ae){if(!r(ne)||!r(ae)||ne===ae)return ae;const de=Object.create(Object.getPrototypeOf(ne));return Object.assign(de,ne,ae),de}class A{#e;#t=new Map;#n;constructor(ae=256,de=null){this.#e=ae,this.#n=de}get size(){return this.#t.size}get max(){return this.#e}set max(ae){this.#e=ae,this.#r()}has(ae){return this.#t.has(ae)}get(ae){const de=this.#t;if(!de.has(ae))return;const ie=de.get(ae);return de.delete(ae),de.set(ae,ie),ie}peek(ae){return this.#t.get(ae)}set(ae,de){const ie=this.#t;return ie.has(ae)&&ie.delete(ae),ie.set(ae,de),this.#r(),de}delete(ae){const de=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(de,ae),de}clear(){if(this.#n)for(const[ae,de]of this.#t)this.#n(de,ae);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const ae=this.#t;for(;ae.size>this.#e;){const de=ae.keys().next().value,ie=ae.get(de);ae.delete(de),this.#n&&this.#n(ie,de)}}}const $=new Map;function D(ne,ae){const de=`${ne||""}|${ae?JSON.stringify(ae):""}`;let ie=$.get(de);return ie||(ie=new Intl.Collator(ne||void 0,{numeric:!0,sensitivity:"variant",...ae}),$.set(de,ie)),ie}function M(ne,ae){if(ne===ae)return 0;if(ne==null)return 1;if(ae==null)return-1;if(typeof ne=="number"&&typeof ae=="number")return Number.isNaN(ne)?Number.isNaN(ae)?0:1:Number.isNaN(ae)||ne<ae?-1:ne>ae?1:0;const de=String(ne),ie=String(ae);return de<ie?-1:de>ie?1:0}function R(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function I(ne){return k?requestAnimationFrame(ne):setTimeout(()=>ne(R()),16)}function q(ne){ne!=null&&(k?cancelAnimationFrame(ne):clearTimeout(ne))}function Z(ne){let ae=null,de=null;const ie=()=>{ae=null;const ce=de;de=null,ne(...ce||[])},oe=(...ce)=>{de=ce,ae===null&&(ae=I(ie))};return oe.cancel=()=>{q(ae),ae=null,de=null},oe.flush=()=>{ae!==null&&(q(ae),ie())},oe}function W(ne,ae){let de=null,ie=null;const oe=()=>{if(de=null,ie===null)return;const ke=ie;ie=null,ne(...ke),ce()},ce=()=>{de=setTimeout(oe,ae),typeof de?.unref=="function"&&de.unref()},fe=(...ke)=>{de===null?(ne(...ke),ce()):(ie=ke,clearTimeout(de),ce())};return fe.flush=()=>{if(de!==null&&clearTimeout(de),de=null,ie===null)return;const ke=ie;ie=null,ne(...ke)},fe.cancel=()=>{de!==null&&clearTimeout(de),de=null,ie=null},fe.pending=()=>de!==null||ie!==null,fe}function J(ne,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ne,{timeout:ae}):setTimeout(()=>ne({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function te(ne="l"){return`${ne}${(++ee).toString(36)}`}}),xe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return C}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Q=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function G(T,P){const x=Number(T),E=Number(P);if(T!==null&&T!==""&&P!==null&&P!==""&&Number.isFinite(x)&&Number.isFinite(E))return x<E?-1:x>E?1:0;const A=String(T??"").toLowerCase(),$=String(P??"").toLowerCase();return A<$?-1:A>$?1:0}function H(T){return T==null||T===""}function U(T,P){if(!P||typeof P!="object")return!1;const{op:x}=P,E=P.value,j=P.value2;switch(x){case"blank":return H(T);case"notBlank":return!H(T);case"true":return T===!0;case"false":return T===!1;default:break}if(H(T))return!1;switch(x){case"eq":return G(T,E)===0;case"ne":return G(T,E)!==0;case"gt":return G(T,E)>0;case"gte":return G(T,E)>=0;case"lt":return G(T,E)<0;case"lte":return G(T,E)<=0;case"between":return G(T,E)>=0&&G(T,j)<=0;case"outside":return G(T,E)<0||G(T,j)>0;case"contains":return String(T).toLowerCase().includes(String(E??"").toLowerCase());case"notContains":return!String(T).toLowerCase().includes(String(E??"").toLowerCase());case"startsWith":return String(T).toLowerCase().startsWith(String(E??"").toLowerCase());case"endsWith":return String(T).toLowerCase().endsWith(String(E??"").toLowerCase());default:return!1}}function z(T,P,x){const E=q=>{const Z=String(q).replace("#",""),W=Z.length===3?Z.split("").map(J=>J+J).join(""):Z;return[0,2,4].map(J=>parseInt(W.slice(J,J+2),16)||0)},[j,A,$]=E(T),[D,M,R]=E(P),k=Math.max(0,Math.min(1,x)),I=(q,Z)=>Math.round(q+(Z-q)*k);return`#${[I(j,D),I(A,M),I($,R)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function S(T){const P=[];for(const D of T||[]){if(D==null||D==="")continue;const M=D instanceof Date?D.getTime():Number(D);Number.isFinite(M)&&P.push(M)}if(!P.length)return null;P.sort((D,M)=>D-M);let x=0,E=0,j=0;for(const D of P){x++;const M=D-E;E+=M/x,j+=M*(D-E)}const A=O(P,.25),$=O(P,.75);return{n:P.length,min:P[0],max:P[P.length-1],mean:E,stddev:P.length>1?Math.sqrt(j/(P.length-1)):0,median:O(P,.5),q1:A,q3:$,iqr:$-A,sorted:P}}function O(T,P){if(!T.length)return 0;const x=(T.length-1)*Math.max(0,Math.min(1,P)),E=Math.floor(x),j=Math.ceil(x);return E===j?T[E]:T[E]+(x-E)*(T[j]-T[E])}function b(T){for(const P of Array.isArray(T)?T:[])if(!(!P||typeof P!="object")&&(P.when&&_.includes(P.when.op)||P.scale&&P.scale.from||P.dataBar&&!(Number.isFinite(Number(P.dataBar.min))&&Number.isFinite(Number(P.dataBar.max)))||P.iconSet&&!Array.isArray(P.iconSet.thresholds)))return!0;return!1}function u(T,P){const x=Number(T.value),E=j=>O(P.sorted,j);switch(T.op){case"topPercent":{const j=d(x,10);return{op:"gte",value:E(1-j)}}case"bottomPercent":{const j=d(x,10);return{op:"lte",value:E(j)}}case"topN":{const j=Math.max(1,Math.floor(x)||1),A=Math.max(0,P.sorted.length-j);return{op:"gte",value:P.sorted[A]}}case"bottomN":{const j=Math.max(1,Math.floor(x)||1),A=Math.min(P.sorted.length-1,j-1);return{op:"lte",value:P.sorted[A]}}case"aboveMean":return{op:"gt",value:P.mean};case"belowMean":return{op:"lt",value:P.mean};case"aboveMedian":return{op:"gt",value:P.median};case"belowMedian":return{op:"lt",value:P.median};case"zAbove":return P.stddev?{op:"gte",value:P.mean+(Number.isFinite(x)?x:2)*P.stddev}:null;case"zBelow":return P.stddev?{op:"lte",value:P.mean-(Number.isFinite(x)?x:2)*P.stddev}:null;case"outlier":{const j=(Number.isFinite(x)&&x>0?x:1.5)*P.iqr;return P.iqr?{op:"outside",value:P.q1-j,value2:P.q3+j}:null}default:return null}}function d(T,P){const x=Number.isFinite(T)?T:P,E=x>1?x/100:x;return Math.max(0,Math.min(1,E))}function s(T,P){if(T.from==="minmax")return{...T,min:P.min,max:P.max};if(T.from==="quantile")return{...T,min:O(P.sorted,d(Number(T.low),5)),max:O(P.sorted,d(Number(T.high),95))};if(T.from==="stddev"){const x=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:P.mean-x*P.stddev,max:P.mean+x*P.stddev}}return T}function n(T,P){const x=Array.isArray(T)?T:[];return!P||!P.n?x.map(E=>E&&b([E])?{...E,enabled:!1}:E):x.map(E=>{if(!E||typeof E!="object")return E;if(E.scale&&E.scale.from)return{...E,scale:s(E.scale,P)};if(E.dataBar)return{...E,dataBar:t(E.dataBar,P)};if(E.iconSet)return{...E,iconSet:r(E.iconSet,P)};if(!E.when||!_.includes(E.when.op))return E;const j=u(E.when,P);return j?{...E,when:j}:{...E,enabled:!1}})}function t(T,P){const x=Number.isFinite(Number(T.min))?Number(T.min):void 0,E=Number.isFinite(Number(T.max))?Number(T.max):void 0;if(x!==void 0&&E!==void 0)return{...T,min:x,max:E};if(T.from==="quantile")return{...T,min:x??O(P.sorted,d(Number(T.low),5)),max:E??O(P.sorted,d(Number(T.high),95))};if(T.from==="stddev"){const j=Number.isFinite(Number(T.deviations))?Number(T.deviations):2;return{...T,min:x??P.mean-j*P.stddev,max:E??P.mean+j*P.stddev}}return{...T,min:x??P.min,max:E??P.max}}function r(T,P){if(Array.isArray(T.thresholds))return T;const x=o(T),E=[];for(let j=1;j<x;j++)E.push(O(P.sorted,j/x));return{...T,thresholds:E}}function o(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.length;if(Number.isFinite(Number(T.count))&&Number(T.count)>=2)return Math.floor(Number(T.count));const P=a[T.set];return P?P.length:3}function f(T){return`url("data:image/svg+xml,${encodeURIComponent(T)}")`}function l(T){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${T}"/></svg>`}function i(T,P){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${P==="up"?"8,2 14,13 2,13":P==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${T}"/></svg>`}function g(T,P){const x="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${P*16} 16">`;for(let j=0;j<P;j++){const A=j<T?"#f5a623":"#d0d0d0";E+=`<path transform="translate(${j*16},0)" d="${x}" fill="${A}"/>`}return`${E}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),h=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),a=Object.freeze({arrows:c,trafficLights:h,ratings:Object.freeze([1,2,3,4,5].map(T=>g(T,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(T){if(Array.isArray(T.icons)&&T.icons.length>=2)return T.icons.map(E=>/^\s*(url\(|data:|<)/.test(String(E))&&String(E).trim().startsWith("<")?f(String(E)):String(E));const P=T.set||"arrows";if(P==="ratings"){const E=o(T),j=[];for(let A=1;A<=E;A++)j.push(f(g(A,E)));return j}const x=a[P];return x?x.map(f):(B(`iconSet:${P}`,`unknown icon set '${P}'; falling back to arrows.`),c.map(f))}function v(T){const P=Number(T.min),E=Number(T.max)-P,j=T.colour||T.color||"#5b9bd5",A=T.negativeColour||T.negativeColor||"#d13438",$=T.direction==="rtl"?"left":"right",D=R=>Math.max(0,Math.min(1,(R-P)/E))*100,M=E?Math.max(0,Math.min(100,(0-P)/E*100)):0;return R=>{if(H(R))return null;const k=Number(R);if(!Number.isFinite(k)||!E)return null;const I=D(k),q=Math.min(I,M),Z=Math.max(I,M),W=k>=0?j:A;return{backgroundImage:`linear-gradient(to ${$}, transparent ${q}%, ${W} ${q}%, ${W} ${Z}%, transparent ${Z}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function p(T){const P=w(T),x=T.reverse?[...P].reverse():P,E=(Array.isArray(T.thresholds)?T.thresholds:[]).map(Number).filter(Number.isFinite),j=Number.isFinite(Number(T.size))?Number(T.size):16,A=T.set==="ratings"?j*o(T):j;return $=>{if(H($))return null;const D=Number($);if(!Number.isFinite(D))return null;let M=0;for(const k of E)D>=k&&M++;const R=x[Math.min(M,x.length-1)];return R?{backgroundImage:R,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${A}px ${j}px`,paddingLeft:`${A+4}px`}:null}}function y(T){const P=Array.isArray(T.colours)&&T.colours.length>=2?T.colours:["#f8f9fa","#1a6bc7"],x=Number(T.min),E=Number(T.max),j=E-x,A=P.length-1,$=[];for(let M=0;M<=A;M++)$.push(A?M/A:0);const D=Number(T.mid);if(T.mid!==void 0&&T.mid!==null)if(P.length%2===0)B("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${P.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&j&&D>Math.min(x,E)&&D<Math.max(x,E)){const M=A/2,R=Math.max(0,Math.min(1,(D-x)/j));for(let k=0;k<=A;k++)$[k]=k<=M?M?k/M*R:R:R+(k-M)/(A-M)*(1-R)}else Number.isFinite(D)&&B("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return M=>{const R=Number(M);if(!Number.isFinite(R)||!j)return null;const k=Math.max(0,Math.min(1,(R-x)/j));let I=0;for(;I<A-1&&k>$[I+1];)I++;const q=$[I+1]-$[I],Z=q>0?(k-$[I])/q:0;return{background:z(P[I],P[I+1],Math.max(0,Math.min(1,Z)))}}}function C(T,P=null){const x=b(T)?n(T,P):T,E=(Array.isArray(x)?x:[]).filter(A=>A&&typeof A=="object");if(!E.length)return()=>null;const j=E.map(A=>A.scale?{scale:y(A.scale),enabled:A.enabled!==!1}:A.dataBar?{scale:v(A.dataBar),enabled:A.enabled!==!1}:A.iconSet?{scale:p(A.iconSet),enabled:A.enabled!==!1}:{when:A.when,style:A.style,stop:A.stopIfTrue!==!1,enabled:A.enabled!==!1});return A=>{const $=A?A.value:void 0;let D=null;for(const M of j){if(!M.enabled)continue;if(M.scale){const k=M.scale($);k&&(D={...D||{},...k});continue}if(!U($,M.when))continue;const R=L(M.style)?M.style(A):M.style;if(R&&(D={...D||{},...R}),M.stop)break}return D}}}),xe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const X="num",L="str",B="ref",F="name",_="op",Q="end",G=["<=",">=","<>","!="],H="+-*/^%(),<>=";class U extends Error{constructor(o,f){super(o),this.name="FormulaError",this.at=f}}function z(r){const o=[];let f=0;for(;f<r.length;){const l=r[f];if(l===" "||l===" "||l===`
7
7
  `||l==="\r"){f++;continue}if(l>="0"&&l<="9"){f=O(r,f,o);continue}if(l==="."&&r[f+1]>="0"&&r[f+1]<="9"){f=O(r,f,o);continue}if(l==='"'||l==="'"){f=b(r,f,o);continue}if(l==="["){const g=r.indexOf("]",f+1);if(g<0)throw new U("a [column reference] was opened and never closed",f);o.push({kind:B,value:r.slice(f+1,g).trim(),at:f}),f=g+1;continue}if(S(l)){f=u(r,f,o);continue}const i=r.slice(f,f+2);if(G.includes(i)){o.push({kind:_,value:i==="!="?"<>":i,at:f}),f+=2;continue}if(H.includes(l)){o.push({kind:_,value:l,at:f}),f++;continue}throw new U(`unexpected character ${JSON.stringify(l)}`,f)}return o.push({kind:Q,value:null,at:r.length}),o}function S(r){return/[A-Za-z_À-￿]/.test(r)}function O(r,o,f){let l=o,i=!1;for(;l<r.length;){const g=r[l];if(g>="0"&&g<="9"){l++;continue}if(g==="."&&!i){i=!0,l++;continue}if((g==="e"||g==="E")&&/[0-9+-]/.test(r[l+1]||"")){for(l+=2;l<r.length&&r[l]>="0"&&r[l]<="9";)l++;break}break}return f.push({kind:X,value:Number(r.slice(o,l)),at:o}),l}function b(r,o,f){const l=r[o];let i=o+1,g="";for(;i<r.length;){if(r[i]===l){if(r[i+1]===l){g+=l,i+=2;continue}return f.push({kind:L,value:g,at:o}),i+1}g+=r[i],i++}throw new U("a string was opened and never closed",o)}function u(r,o,f){let l=o;for(;l<r.length&&/[A-Za-z0-9_.À-￿]/.test(r[l]);)l++;const i=r.slice(o,l);let g=l;for(;g<r.length&&r[g]===" ";)g++;return f.push({kind:r[g]==="("?F:B,value:i,at:o}),l}const d={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function s(r){const o=String(r??"").replace(/^\s*=/,"");if(!o.trim())throw new U("the formula is empty");const f=z(o);let l=0;const i=()=>f[l],g=()=>f[l++],c=y=>{const C=i();if(C.kind!==_||C.value!==y)throw new U(`expected ${JSON.stringify(y)}`,C.at);l++},h=y=>{let C=a();for(;;){const T=i();if(T.kind!==_)break;const P=d[T.value];if(!P||P<y)break;l++;const x=h(T.value==="^"?P:P+1);C={kind:"bin",op:T.value,left:C,right:x}}return C},a=()=>{const y=i();return y.kind===_&&(y.value==="-"||y.value==="+")?(l++,{kind:"unary",op:y.value,arg:a()}):m()},m=()=>{let y=w();for(;i().kind===_&&i().value==="%";)l++,y={kind:"unary",op:"%",arg:y};return y},w=()=>{const y=g();if(y.kind===X)return{kind:"num",value:y.value};if(y.kind===L)return{kind:"str",value:y.value};if(y.kind===B)return{kind:"ref",name:y.value};if(y.kind===F){c("(");const C=[];if(!(i().kind===_&&i().value===")"))for(;;){if(C.push(h(1)),i().kind===_&&i().value===","){l++;continue}break}return c(")"),{kind:"call",name:String(y.value).toUpperCase(),args:C}}if(y.kind===_&&y.value==="("){const C=h(1);return c(")"),C}throw y.kind===Q?new U("the formula ends unexpectedly",y.at):new U(`unexpected ${JSON.stringify(y.value)}`,y.at)},v=h(1),p=i();if(p.kind!==Q)throw new U(`unexpected ${JSON.stringify(p.value)}: is an operator missing?`,p.at);return v}function n(r){const o=new Set,f=l=>{if(!(!l||typeof l!="object")){if(l.kind==="ref"){o.add(String(l.name));return}if(l.kind==="bin"){f(l.left),f(l.right);return}if(l.kind==="unary"){f(l.arg);return}if(l.kind==="call")for(const i of l.args)f(i)}};return f(r),[...o]}function t(r){return typeof r=="string"&&/^\s*=/.test(r)&&r.trim()!=="="}}),xe("packages/core/src/formula/evaluate.js",function(e,K){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const L=K("packages/core/src/formula/parse.js").FormulaError;function B(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const u=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new L(`${JSON.stringify(b)} is not a number`);return u}function F(b){return b==null?"":String(b)}function _(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const u=String(b).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function Q(b){const u=[];for(const d of b){if(Array.isArray(d)){for(const s of d)s!=null&&s!==""&&u.push(B(s));continue}d==null||d===""||u.push(B(d))}return u}function G(b,u){const d=10**u,s=b*d;return Math.sign(s)*Math.round(Math.abs(s)+Number.EPSILON*Math.abs(s))/d}function H(b,u){if(!b.length)return 0;const d=b.slice().sort((r,o)=>r-o),s=(d.length-1)*Math.min(1,Math.max(0,u)),n=Math.floor(s),t=Math.ceil(s);return n===t?d[n]:d[n]+(s-n)*(d[t]-d[n])}function U(b,u){let d=0,s=0,n=0;for(const r of b){d++;const o=r-s;s+=o/d,n+=o*(r-s)}const t=u?d-1:d;return t>0?Math.sqrt(n/t):0}const z={SUM:b=>Q(b).reduce((u,d)=>u+d,0),AVERAGE:b=>{const u=Q(b);return u.length?u.reduce((d,s)=>d+s,0)/u.length:0},MIN:b=>{const u=Q(b);return u.length?Math.min(...u):0},MAX:b=>{const u=Q(b);return u.length?Math.max(...u):0},COUNT:b=>Q(b).length,PRODUCT:b=>Q(b).reduce((u,d)=>u*d,1),ROUND:b=>G(B(b[0]),b.length>1?B(b[1]):0),ROUNDDOWN:b=>{const u=10**(b.length>1?B(b[1]):0),d=B(b[0])*u;return(d<0?Math.ceil(d):Math.floor(d))/u},ROUNDUP:b=>{const u=10**(b.length>1?B(b[1]):0),d=B(b[0])*u;return(d<0?Math.floor(d):Math.ceil(d))/u},ABS:b=>Math.abs(B(b[0])),FLOOR:b=>Math.floor(B(b[0])),CEILING:b=>Math.ceil(B(b[0])),SQRT:b=>Math.sqrt(B(b[0])),POWER:b=>B(b[0])**B(b[1]),MOD:b=>{const u=B(b[1]);if(u===0)throw new L("MOD by zero");return(B(b[0])%u+u)%u},IF:b=>_(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(_),OR:b=>b.some(_),NOT:b=>!_(b[0]),COALESCE:b=>b.find(u=>u!=null&&u!=="")??null,CONCAT:b=>b.map(F).join(""),LEN:b=>F(b[0]).length,UPPER:b=>F(b[0]).toUpperCase(),LOWER:b=>F(b[0]).toLowerCase(),TRIM:b=>F(b[0]).trim(),LEFT:b=>F(b[0]).slice(0,b.length>1?B(b[1]):1),RIGHT:b=>{const u=b.length>1?B(b[1]):1;return u<=0?"":F(b[0]).slice(-u)},MEDIAN:b=>H(Q(b),.5),PERCENTILE:b=>{const u=B(b[b.length-1]);return H(Q(b.slice(0,-1)),u>1?u/100:u)},QUARTILE1:b=>H(Q(b),.25),QUARTILE3:b=>H(Q(b),.75),STDEV:b=>U(Q(b),!0),STDEVP:b=>U(Q(b),!1),VAR:b=>{const u=U(Q(b),!0);return u*u},VARP:b=>{const u=U(Q(b),!1);return u*u},COUNTDISTINCT:b=>{const u=new Set;for(const d of b){const s=Array.isArray(d)?d:[d];for(const n of s)n!=null&&n!==""&&u.add(n)}return u.size},IQR:b=>{const u=Q(b);return H(u,.75)-H(u,.25)}};z.AVG=z.AVERAGE,z.CEIL=z.CEILING,z.POW=z.POWER,z.STDEVS=z.STDEV,z.PERCENTILEINC=z.PERCENTILE;function S(b,u){const d=Number(b),s=Number(u);if(b!==null&&b!==""&&u!==null&&u!==""&&Number.isFinite(d)&&Number.isFinite(s))return d<s?-1:d>s?1:0;const t=F(b).toLowerCase(),r=F(u).toLowerCase();return t<r?-1:t>r?1:0}function O(b,u={}){const d=typeof u.lookup=="function"?u.lookup:null,s=u.functions?{...z,...u.functions}:z,n=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!d)throw new L(`there is no column called ${JSON.stringify(t.name)} here`);const r=d(String(t.name));if(r===void 0)throw new L(`there is no column called ${JSON.stringify(t.name)}`);return r}case"unary":{if(t.op==="%")return B(n(t.arg))/100;const r=B(n(t.arg));return t.op==="-"?-r:r}case"bin":{const r=t.op;if(r==="=")return S(n(t.left),n(t.right))===0;if(r==="<>")return S(n(t.left),n(t.right))!==0;if(r==="<")return S(n(t.left),n(t.right))<0;if(r==="<=")return S(n(t.left),n(t.right))<=0;if(r===">")return S(n(t.left),n(t.right))>0;if(r===">=")return S(n(t.left),n(t.right))>=0;const o=B(n(t.left)),f=B(n(t.right));if(r==="+")return o+f;if(r==="-")return o-f;if(r==="*")return o*f;if(r==="^")return o**f;if(r==="/"){if(f===0)throw new L("division by zero");return o/f}throw new L(`unknown operator ${JSON.stringify(r)}`)}case"call":{const r=s[t.name];if(typeof r!="function")throw new L(`there is no function called ${t.name}`);return r(t.args.map(n),u)}default:throw new L("the formula could not be read")}};return n(b)}}),xe("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return S}});const X=K("packages/core/src/formula/parse.js"),L=X.parseFormula,B=X.referencesOf,F=X.looksLikeFormula,_=X.FormulaError,Q=X.tokenise,G=K("packages/core/src/formula/evaluate.js"),H=G.evaluateAst,U=G.FUNCTIONS;function z(O){const{grid:b,row:u,data:d}=O||{},s=f=>String(f).toLowerCase().replace(/[\s_-]/g,""),n=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],t=b&&b.permissions,r=t&&typeof t.isReadable=="function"?f=>t.isReadable(f):()=>!0,o=new Set;for(const f of n)r(f)||(o.add(s(f.id)),f.field&&o.add(s(f.field)),f.title&&o.add(s(f.title)));return f=>{const l=s(f);if(o.has(l))throw new _(`"${f}" cannot be read`);for(const i of n)if(s(i.id)===l||i.field&&s(i.field)===l||i.title&&s(i.title)===l)return u&&b.rows&&typeof b.rows.value=="function"?b.rows.value(u.key,i.id):d?d[i.field||i.id]:void 0;if(d&&typeof d=="object"){for(const i of Object.keys(d))if(s(i)===l){if(!r(i))throw new _(`"${f}" cannot be read`);return d[i]}}}}function S(O,b={}){try{const u=L(O);return{ok:!0,value:H(u,{lookup:z(b),functions:b.formulaFunctions}),references:B(u)}}catch(u){return{ok:!1,error:u instanceof _?u.message:"the formula could not be read",at:u instanceof _?u.at:void 0}}}}),xe("packages/core/src/defaults.js",function(e,K){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const X=K("packages/core/src/internal/util.js"),L=X.isObject,B=X.merge,F=X.warnOnce;let _=null;class Q extends Error{}function G(z,S=new Set){if(Array.isArray(z)){if(S.has(z))throw new Q;S.add(z);const b=z.map(u=>G(u,S));return S.delete(z),b}if(!L(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;if(S.has(z))throw new Q;S.add(z);const O={};for(const[b,u]of Object.entries(z))O[b]=G(u,S);return S.delete(z),O}function H(z){if(z===void 0)return G(_??{});if(z===null)return _=null,{};if(!L(z))return F("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(z)?"an array":typeof z}. The call was ignored and the defaults are unchanged.`),G(_??{});try{_=G(z)}catch(S){if(!(S instanceof Q))throw S;return F("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),G(_??{})}return G(_)}function U(z){return _===null?z:B(G(_),z)}}),xe("packages/core/src/events/names.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return B}});const X=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),L=new Set(X);function B(F){return F==="*"||L.has(F)}}),xe("packages/core/src/events/bus.js",function(e,K){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return u}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.uid,F=X.DEV,Q=K("packages/core/src/events/names.js").isKnownEvent,G="*";function H(d,s){!F||Q(s)||L(`bus.unknown:${s}`,`${d}('${s}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const U=new Set(["api","user","init","ai"]),z=new WeakMap;function S(d){let s=z.get(d);return s||(s=B("h"),z.set(d,s)),s}function O(){return typeof performance=="object"&&performance?performance.now():Date.now()}function b(d){if(!d||typeof d!="object")return{};const s={};for(const[n,t]of Object.entries(d))n!=="grid"&&(t==null?s[n]=String(t):Array.isArray(t)?s[n]=`[${t.length}]`:typeof t=="object"?s[n]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?s[n]="[function]":s[n]=String(t).slice(0,60));return s}class u{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(s=null){this.#i=s}attach(s){this.#i=s}get grid(){return this.#i}get destroyed(){return this.#s}on(s,n){if(typeof n!="function")return L(`bus.handler:${s}`,`on('${s}') needs a function; ignored.`),()=>{};H("on",s);let t=this.#e.get(s);return t||(t=[],this.#e.set(s,t)),t.push(n),()=>this.off(s,n)}once(s,n){if(typeof n!="function")return L(`bus.handler:${s}`,`once('${s}') needs a function; ignored.`),()=>{};H("once",s);const t=r=>{this.off(s,n),n(r)};return this.#o.set(n,t),this.on(s,t)}off(s,n){if(n===void 0){this.#e.delete(s);return}const t=this.#e.get(s);if(!t)return;const r=this.#o.get(n),o=r&&t.includes(r)?r:n,f=t.indexOf(o);f>=0&&t.splice(f,1),r&&o===r&&this.#o.delete(n),t.length===0&&this.#e.delete(s)}count(s){const n=this.#e.get(s),t=s===G?null:this.#e.get(G);return(n?n.length:0)+(t?t.length:0)}#a(s,n,t,r,o){this.#n.push({type:s,origin:n,listeners:(r?r.length:0)+(o?o.length:0),payload:b(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(s,n){this.#t=!!s,Number.isFinite(n)&&n>0&&(this.#r=Math.floor(n)),s||(this.#n=[])}eventLog(){return this.#n.map(s=>({...s}))}clearEventLog(){this.#n=[]}counts(){const s={};for(const[n,t]of this.#e)s[n]=t.length;return s}emit(s,n,t){const r=t??(n&&n.origin),o=U.has(r)?r:"api",f={...n||null,type:s,origin:o,grid:this.#i};if(this.#s)return f;const l=this.#e.get(s),i=s===G?void 0:this.#e.get(G);if(this.#t&&this.#a(s,o,n,l,i),!l&&!i)return f;const g=this.#t?O():0;this.#l++;try{l&&this.#u(l.slice(),f,s),i&&this.#u(i.slice(),f,G)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=O()-g)}return f}emitBefore(s,n,t){const r=t??(n&&n.origin),o=U.has(r)?r:"user";let f=!1,l=null;const i=w=>{f=!0,w!=null&&l===null&&(l=String(w))},g={...n||null,type:s,origin:o,grid:this.#i,get defaultPrevented(){return f},get reason(){return l},preventDefault(w){i(w)}};if(this.#s)return!0;const c=this.#e.get(s);this.#t&&this.#a(s,o,n,c,void 0);const h=c?c.slice():[];if(h.length===0)return!0;const a=()=>(f&&l===null&&(l="prevented"),f&&n&&typeof n=="object"&&(n.reason=l),!f),m=[];for(const w of h)try{const v=w(g);v&&typeof v.then=="function"?m.push(v):v===!1&&i("prevented")}catch(v){i("error"),L(`bus.beforeThrow:${s}:${S(w)}`,`a '${s}' before-handler threw; the action was cancelled.`,v)}return m.length===0?a():Promise.allSettled(m).then(w=>{for(const v of w)v.status==="rejected"?(i("error"),L(`bus.beforeReject:${s}`,`a '${s}' before-handler rejected; the action was cancelled.`,v.reason)):v.value===!1&&i("prevented");return a()})}#u(s,n,t){for(let r=0;r<s.length;r++)try{s[r](n)}catch(o){L(`bus.throw:${t}:${S(s[r])}`,`a '${t}' handler threw; other handlers were unaffected.`,o)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),xe("packages/core/src/registry/licence.js",function(e,K){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return C}});const L=K("packages/core/src/internal/util.js").warnOnce,B="lattice-grid",F=1,_="LG1",Q=64,G="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",U=(()=>{const T=new Int16Array(128).fill(-1);for(let P=0;P<H.length;P++)T[H.charCodeAt(P)]=P;return T[43]=62,T[47]=63,T})();function z(T){if(typeof T!="string")return null;let P="";for(let D=0;D<T.length;D++){const M=T.charCodeAt(D);if(M!==61){if(M>127||U[M]<0)return null;P+=T[D]}}const x=P.length;if(x%4===1)return null;const E=new Uint8Array(Math.floor(x*3/4));let j=0,A=0,$=0;for(let D=0;D<x;D++)j=j<<6|U[P.charCodeAt(D)],A+=6,A>=8&&(A-=8,E[$++]=j>>A&255);return $===E.length?E:E.subarray(0,$)}function S(T){let P="",x=0;for(;x+2<T.length;x+=3){const j=T[x]<<16|T[x+1]<<8|T[x+2];P+=H[j>>18&63]+H[j>>12&63]+H[j>>6&63]+H[j&63]}const E=T.length-x;if(E===1){const j=T[x]<<16;P+=H[j>>18&63]+H[j>>12&63]}else if(E===2){const j=T[x]<<16|T[x+1]<<8;P+=H[j>>18&63]+H[j>>12&63]+H[j>>6&63]}return P}function O(T){const P=new Uint8Array(T.length);for(let x=0;x<T.length;x++)P[x]=T.charCodeAt(x)&127;return P}function b(T){if(typeof TextDecoder=="function")return new TextDecoder().decode(T);let P="";for(let x=0;x<T.length;x++)P+=String.fromCharCode(T[x]);return P}function u(T){const P={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof T=="string"?T:""};if(typeof T!="string"||T.length===0)return{...P,reason:"missing"};const x=T.trim(),E=x.split(".");if(E.length!==3)return P;const[j,A,$]=E;if(j!==_)return{...P,reason:"prefix"};const D=z(A),M=z($);if(!D||!M)return P;let R;try{R=JSON.parse(b(D))}catch{return P}return R===null||typeof R!="object"?P:{ok:!0,reason:null,product:typeof R.p=="string"?R.p:null,issuedTo:typeof R.t=="string"?R.t:null,expires:typeof R.e=="string"?R.e:null,features:Array.isArray(R.f)?R.f.slice():[],deployments:Array.isArray(R.d)?R.d.slice():[],version:typeof R.v=="number"?R.v:0,message:O(A),signature:M,raw:x}}function d(T,P){if(!T)return!1;const x=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(T)?`${T}T23:59:59.999Z`:T);return Number.isNaN(x)?!0:P>x}let s=null,n=null,t=null;function r(){const T=globalThis.crypto;return T&&T.subtle?T.subtle:null}async function o(T){if(s&&n===T)return s;const P=r();if(!P)return null;const x=z(T);if(!x)return null;try{const E=await P.importKey("raw",x,{name:"Ed25519"},!1,["verify"]);return s=E,n=T,E}catch{return null}}async function f(){return t!==null||(t=await o(G)!==null),t}async function l(T,P={}){const x=P.warn!==!1,E=P.product||B,j=P.publicKey||G,A=P.now??Date.now(),$=u(T);if(!$.ok){const q=$.reason==="missing"?"missing":"malformed";return x&&L(`licence.${q}`,q==="missing"?"no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.":"licence key could not be read. The grid will render with a watermark."),{valid:!1,reason:q}}const D={product:$.product||void 0,issuedTo:$.issuedTo||void 0,expires:$.expires||void 0};if($.product!==E)return x&&L("licence.product",`licence key is for '${$.product}', not '${E}'. The grid will render with a watermark.`),{valid:!1,...D,reason:"product"};if(d($.expires,A))return x&&L("licence.expired",`licence expired on ${$.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...D,reason:"expired"};const M=P.host??g(),R=$.deployments||[];if(R.length&&M&&!i(M)&&!c(M,R))return x&&L("licence.domain",`licence key is not valid for ${M}; it covers ${R.join(", ")}. The grid will render with a watermark.`),{valid:!1,...D,reason:"domain"};const k=await o(j);if(!k){const q=!!$.signature&&$.signature.length===Q;return x&&L("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),q?{valid:!0,...D,reason:"unverified"}:{valid:!1,...D,reason:"signature"}}let I=!1;try{I=await r().verify({name:"Ed25519"},k,$.signature,$.message)}catch{I=!1}return I?{valid:!0,...D}:(x&&L("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...D,reason:"signature"})}function i(T){const P=String(T??g()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!P||P==="localhost"||P.endsWith(".localhost")||P==="::1"||P==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(P)}function g(){const T=globalThis.location;return T&&typeof T.hostname=="string"?T.hostname:null}function c(T,P){const x=h(T);return!x||!Array.isArray(P)?!1:P.some(E=>{const j=h(E);if(!j)return!1;if(j==="*")return!0;if(j.startsWith("*.")){const A=j.slice(2);return x===A||x.endsWith(`.${A}`)}return x===j})}function h(T){return String(T??"").trim().toLowerCase().replace(/\.$/,"")}class a{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(P={}){this.#o=P}set(P){this.#e=typeof P=="string"?P.trim():"";const x=u(this.#e);return this.#t=x.ok?{valid:!d(x.expires,Date.now())&&x.product===(this.#o.product||B),product:x.product||void 0,issuedTo:x.issuedTo||void 0,expires:x.expires||void 0,reason:"pending"}:{valid:!1,reason:x.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const P=this.#e;return this.#n=l(P,this.#o).then(x=>{if(this.#e===P){this.#t=x;for(const E of this.#i)E(x)}return x}),this.#n}onSettled(P){return this.#i.add(P),()=>this.#i.delete(P)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!i(this.#r)}setHost(P){this.#r=P}state(){return this.#t.valid?"licensed":i(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const m=new a;function w(T){return m.set(T)}function v(){return m.info()}function p(){return m.watermark()}function y(){return m.state()}function C(){return m}}),xe("packages/core/src/registry/registry.js",function(e,K){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=X.DEV,_=K("packages/core/src/registry/licence.js"),Q=_.LicenceHolder,G=_.sharedLicence,H=["renderer","editor","filter","dataType","totalFn","pipe","component"],U=["all","header","body","totals","panels"];class z{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(o={}){for(const f of H)this.#t.set(f,new Map);this.#o=o.holder||G(),this.#s=o.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),o.licence&&this.setLicence(o.licence)}registerModules(o,f={}){f.licence&&this.setLicence(f.licence),f.grid!==void 0&&(this.#s=f.grid);const l=Array.isArray(o)?o:[o],i=[];for(const g of l){if(!g||typeof g!="object"||typeof g.name!="string"||!g.name){L("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(g.name)){F&&this.#c(this.#e.get(g.name),g);continue}if(!B(g.install)){L(`registry.module.install:${g.name}`,`module '${g.name}' has no install() and was ignored.`);continue}const c={registry:this,grid:this.#s};try{g.install(c)}catch(h){L(`registry.module.throw:${g.name}`,`module '${g.name}' threw during install; it was not registered.`,h);continue}this.#e.set(g.name,g);for(const h of S(g))this.#n.add(h);i.push(g.name),this.#d({reason:"module",name:g.name,capabilities:this.capabilities(),regions:u(g)})}return i}unregisterModule(o){const f=this.#e.get(o);if(!f)return!1;if(B(f.uninstall))try{f.uninstall({registry:this,grid:this.#s})}catch(l){L(`registry.module.uninstall:${o}`,`module '${o}' threw during uninstall.`,l)}return this.#e.delete(o),this.#u(),this.#d({reason:"unmodule",name:o,capabilities:this.capabilities(),regions:u(f)}),!0}modules(){return[...this.#e.values()]}has(o){return this.#e.has(o)}#u(){this.#n.clear();for(const o of this.#e.values())for(const f of S(o))this.#n.add(f)}#c(o,f){!o||o===f||O(o,f)||L(`registry.module.reconfigure:${f.name}`,`module '${f.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(o){return this.#n.has(o)}onChange(o){return B(o)?(this.#r.add(o),this.#a.set(o,this.#s),()=>{this.#r.delete(o),this.#a.delete(o)}):()=>{}}#d(o){for(const f of[...this.#r])try{f(o)}catch(l){L("registry.onChange.throw","a registry change handler threw.",l)}}register(o,f,l){const i=this.#t.get(o);if(!i){L(`registry.kind:${o}`,`unknown registry kind '${o}'; expected one of ${H.join(", ")}.`);return}if(!f||typeof f!="string"){L(`registry.name:${o}`,`register('${o}', ...) needs a name.`);return}i.has(f)&&i.get(f)!==l&&L(`registry.replace:${o}:${f}`,`'${f}' was already registered as a ${o} and has been replaced.`),i.set(f,l),this.#d({reason:"register",name:f,kind:o,capabilities:this.capabilities(),regions:d(o)})}registerAll(o,f){if(f)for(const l of Object.keys(f))this.register(o,l,f[l])}get(o,f){const l=this.#t.get(o);return l?l.get(f):void 0}names(o){const f=this.#t.get(o);return f?[...f.keys()]:[]}#f(o,f){const l=this.#t.get(o).get(f);return l!==void 0?l:this.#t.get("component").get(f)}renderer(o){return this.#f("renderer",o)}editor(o){return this.#f("editor",o)}filter(o){return this.#f("filter",o)}dataType(o){return this.get("dataType",o)}totalFn(o){return this.get("totalFn",o)}pipe(o){return this.get("pipe",o)}setLicence(o){return this.#o.set(o)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(o){o!=null&&(this.#l.add(o),this.#s=o)}detach(o){if(o!=null){this.#l.delete(o);for(const[f,l]of[...this.#a])l===o&&(this.#r.delete(f),this.#a.delete(f));if(this.#s===o){const f=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=f}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(o){if(o!=null){this.detach(o);return}for(const f of[...this.#e.keys()])this.unregisterModule(f);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function S(r){const o=r.capabilities,f=Array.isArray(o)?o.filter(l=>typeof l=="string"):[];return[r.name,...f]}function O(r,o){return r.install!==o.install||r.uninstall!==o.uninstall||(r.version||"")!==(o.version||"")?!1:b(S(r),S(o))&&b(u(r),u(o))}function b(r,o){const f=new Set(r),l=new Set(o);if(f.size!==l.size)return!1;for(const i of f)if(!l.has(i))return!1;return!0}function u(r){const o=r.regions;return!Array.isArray(o)||o.length===0?["all"]:o.filter(f=>U.includes(f))}function d(r){switch(r){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const s=new z;function n(){return s}function t(r,o={}){return s.registerModules(r,o)}}),xe("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return B}});const L=K("packages/core/src/internal/util.js").isNil;function B(F,_){const Q=F||{},G=Q.locale||_||void 0,H=Q.style||"decimal",U=typeof Q.scale=="number"?Q.scale:1,z=Q.nullDisplay??"",S=Q.zeroDisplay,O=Q.prefix||"",b=Q.suffix||"",u=Q.negative||"minus",d=Q.signed===!0,s={style:H,notation:Q.notation||"standard"};H==="currency"&&(s.currency=Q.currency||"USD",Q.currencyDisplay&&(s.currencyDisplay=Q.currencyDisplay)),typeof Q.decimals=="number"?(s.minimumFractionDigits=Q.decimals,s.maximumFractionDigits=Q.decimals):(typeof Q.minDecimals=="number"&&(s.minimumFractionDigits=Q.minDecimals),typeof Q.maxDecimals=="number"&&(s.maximumFractionDigits=Q.maxDecimals),s.minimumFractionDigits>(s.maximumFractionDigits??20)&&(s.maximumFractionDigits=s.minimumFractionDigits)),Q.thousandsSeparator===!1&&(s.useGrouping=!1),s.notation==="compact"&&(s.compactDisplay=Q.compactDisplay||"short");const n=new Intl.NumberFormat(G,s),t=typeof Q.thousandsSeparator=="string"?Q.thousandsSeparator:null,r=typeof Q.decimalSeparator=="string"?Q.decimalSeparator:null;let o=",",f=".";if(t||r)for(const a of n.formatToParts(12345.6))a.type==="group"?o=a.value:a.type==="decimal"&&(f=a.value);const l=a=>{let m=a;return t&&(m=m.split(o).join("")),r&&(m=m.split(f).join("")),t&&(m=m.split("").join(t)),r&&(m=m.split("").join(r)),m},i=!!(t||r),g=O!==""&&H==="currency",c=a=>{let m;if(g){const w=n.formatToParts(a);let v=!1;m="";for(const p of w)m+=p.value,!v&&p.type==="currency"&&(m+=O,v=!0);v||(m=O+m)}else m=O+n.format(a);return i&&(m=l(m)),m+b},h=a=>{if(L(a)||a==="")return z;const m=typeof a=="number"?a:Number(a);if(Number.isNaN(m))return z;const w=U===1?m:m*U;return w===0&&S!==void 0?S:w<0?u==="parentheses"?`(${c(-w)})`:u==="suffix"?`${c(-w)}-`:c(w):d&&w>0?`+${c(w)}`:c(w)};return h.negativeClass=Q.negativeClass||null,h.spec=Q,h}}),xe("packages/core/src/format/date.js",function(e,K){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return n}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.warnOnce,F=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(t){const r=[];let o=0,f="";const l=()=>{f&&(r.push({token:null,text:f}),f="")};for(;o<t.length;){const i=t[o];if(i==="'"){if(t[o+1]==="'"){f+="'",o+=2;continue}const c=t.indexOf("'",o+1);if(c===-1){f+=t.slice(o+1),o=t.length;continue}f+=t.slice(o+1,c),o=c+1;continue}const g=F.find(c=>t.startsWith(c,o));if(g){l(),r.push({token:g,text:g}),o+=g.length;continue}/[A-Za-z]/.test(i)&&B(`date.pattern.token:${i}`,`the date pattern "${t}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${F.join(" ")}.`),f+=i,o+=1}return l(),r}const Q=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function G(t){if(L(t)||t==="")return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t=="number")return Number.isNaN(t)?null:new Date(t);if(typeof t=="string"){const r=Q.exec(t.trim());if(r){const[,f,l,i,g="0",c="0",h="0"]=r;return new Date(+f,+l-1,+i,+g,+c,+h)}const o=new Date(t);return Number.isNaN(o.getTime())?null:o}return null}function H(t,r){return String(t).padStart(r,"0")}function U(t){if(!t)return f=>({year:f.getFullYear(),month:f.getMonth()+1,day:f.getDate(),hour:f.getHours(),minute:f.getMinutes(),second:f.getSeconds(),ms:f.getMilliseconds(),weekday:f.getDay()});const r=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),o={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return f=>{const l={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:f.getMilliseconds(),weekday:0};for(const i of r.formatToParts(f))switch(i.type){case"year":l.year=Number(i.value);break;case"month":l.month=Number(i.value);break;case"day":l.day=Number(i.value);break;case"hour":l.hour=Number(i.value)%24;break;case"minute":l.minute=Number(i.value);break;case"second":l.second=Number(i.value);break;case"weekday":l.weekday=o[i.value]??0;break;default:break}return l}}function z(t,r,o){const f=_(t),l=U(o),i=new Set(f.filter(m=>m.token).map(m=>m.token)),g=i.has("MMM")?new Intl.DateTimeFormat(r,{month:"short",timeZone:o}):null,c=i.has("MMMM")?new Intl.DateTimeFormat(r,{month:"long",timeZone:o}):null,h=i.has("EEE")?new Intl.DateTimeFormat(r,{weekday:"short",timeZone:o}):null,a=i.has("EEEE")?new Intl.DateTimeFormat(r,{weekday:"long",timeZone:o}):null;return m=>{const w=l(m);let v="";for(const p of f){if(!p.token){v+=p.text;continue}switch(p.token){case"yyyy":v+=H(w.year,4);break;case"yy":v+=H(w.year%100,2);break;case"MMMM":v+=c.format(m);break;case"MMM":v+=g.format(m);break;case"MM":v+=H(w.month,2);break;case"M":v+=String(w.month);break;case"dd":v+=H(w.day,2);break;case"d":v+=String(w.day);break;case"EEEE":v+=a.format(m);break;case"EEE":v+=h.format(m);break;case"HH":v+=H(w.hour,2);break;case"H":v+=String(w.hour);break;case"hh":v+=H(w.hour%12===0?12:w.hour%12,2);break;case"h":v+=String(w.hour%12===0?12:w.hour%12);break;case"mm":v+=H(w.minute,2);break;case"m":v+=String(w.minute);break;case"ss":v+=H(w.second,2);break;case"s":v+=String(w.second);break;case"SSS":v+=H(w.ms,3);break;case"a":v+=w.hour<12?"AM":"PM";break;default:v+=p.text;break}}return v}}const S=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function O(t,r){const o=t||{},f=o.locale||r||void 0,l=o.nullDisplay??"",i=o.timeZone;let g;if(o.pattern)g=z(o.pattern,f,i);else if(o.dateStyle||o.timeStyle){const w={timeZone:i};o.dateStyle&&(w.dateStyle=o.dateStyle),o.timeStyle&&(w.timeStyle=o.timeStyle);const v=new Intl.DateTimeFormat(f,w);g=p=>v.format(p)}else{const w=new Intl.DateTimeFormat(f,{dateStyle:"medium",timeZone:i});g=v=>w.format(v)}const c=o.relative?new Intl.RelativeTimeFormat(f,{numeric:"auto"}):null,a=(typeof o.relative=="object"&&o.relative?o.relative.threshold??7:7)*24*36e5,m=(w,v)=>{const p=G(w);if(!p)return l;if(c){const y=v&&typeof v.now=="number"?v.now:Date.now(),C=p.getTime()-y;if(Math.abs(C)<a){for(const[T,P]of S)if(Math.abs(C)>=P||T==="second")return c.format(Math.round(C/P),T)}}return g(p)};return m.spec=o,m}function b(t){if(L(t)||t==="")return null;if(typeof t=="string"){const f=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(f)return f[1];const l=G(t);return l?b(l):null}const r=G(t);if(!r)return null;const o=f=>String(f).padStart(2,"0");return`${r.getFullYear()}-${o(r.getMonth()+1)}-${o(r.getDate())}`}function u(t,r){if(L(t)||t==="")return null;if(typeof t=="string"){const f=t.trim();if(d.test(f)){const g=G(f);return g?s(g,r):null}const l=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(f);if(l){const[,g,c,h,a]=l;return`${g}T${c}:${h}${a&&a!=="00"?`:${a}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(f))return`${f}T00:00`;const i=G(f);return i?u(i):null}const o=G(t);return o?s(o,r):null}const d=/(?:Z|[+-]\d{2}:?\d{2})$/i;function s(t,r){const o=g=>String(g).padStart(2,"0");if(r)try{const g=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((a,m)=>(m.type!=="literal"&&(a[m.type]=m.value),a),{}),c=g.hour==="24"?"00":g.hour,h=Number(g.second);return`${g.year}-${g.month}-${g.day}T${c}:${g.minute}`+(h?`:${g.second}`:"")}catch{}const f=`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`,l=t.getSeconds(),i=`${o(t.getHours())}:${o(t.getMinutes())}${l?`:${o(l)}`:""}`;return`${f}T${i}`}function n(t,r){const o=L(t)||t===""?null:String(t),f=L(r)||r===""?null:String(r);return o===null?f===null?0:1:f===null||o<f?-1:o>f?1:0}}),xe("packages/core/src/format/boolean.js",function(e,K){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isNil,B={true:"☑",false:"☐",null:""},F={true:"◉",false:"◯",null:""};function _(G){if(L(G)||G==="")return null;if(typeof G=="boolean")return G;if(typeof G=="number")return G!==0;const H=String(G).trim().toLowerCase();return H==="true"||H==="yes"||H==="y"||H==="1"?!0:H==="false"||H==="no"||H==="n"||H==="0"?!1:null}function Q(G,H){const U=G||{},z=U.display||"text",S=U.trueLabel??"Yes",O=U.falseLabel??"No",b=U.nullLabel??"";let u=S,d=O;const s=b;z==="checkbox"?(u=B.true,d=B.false):z==="switch"?(u=F.true,d=F.false):z==="icon"&&(u=U.trueIcon??S,d=U.falseIcon??O);const n=t=>{const r=_(t);return r===null?s:r?u:d};return n.display=z,n.labels={true:S,false:O,null:b},n.locale=H,n.spec=U,n}}),xe("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return F}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.titleCase;function F(_,Q){const G=_||{},H=G.locale||Q||void 0,U=G.nullDisplay??"",z=G.emptyDisplay??"",S=G.transform||"none",O=typeof G.truncate=="number"?{chars:G.truncate}:G.truncate||null,b=O?O.chars:0,u=O?O.ellipsis??"…":"",d=n=>{switch(S){case"upper":return H?n.toLocaleUpperCase(H):n.toUpperCase();case"lower":return H?n.toLocaleLowerCase(H):n.toLowerCase();case"title":return B(n);default:return n}},s=n=>{if(L(n))return U;let t=typeof n=="string"?n:String(n);return t===""?z:(S!=="none"&&(t=d(t)),b>0&&t.length>b&&(t=t.slice(0,b)+u),t)};return s.spec=G,s}}),xe("packages/core/src/format/mask.js",function(e,K){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Q}});const X=new Set(["0","#","?",",","."]),L="\0";function B(H){const U=[];let z="",S=!1;for(let O=0;O<H.length;O++){const b=H[O];if(b==="\\"){z+=b+(H[O+1]??""),O+=1;continue}if(b==='"'){S=!S,z+=b;continue}if(b===";"&&!S){U.push(z),z="";continue}z+=b}return U.push(z),U}function F(H){let U="",z="",S="",O=1,b=!1,u=!1;const d=g=>{u?z+=g:U+=g};for(let g=0;g<H.length;g++){const c=H[g];if(c==="\\"){d(H[g+1]??""),g+=1;continue}if(c==='"'){const h=H.indexOf('"',g+1);d(h===-1?H.slice(g+1):H.slice(g+1,h)),g=h===-1?H.length:h;continue}if(c==="%"){O*=100,d("%");continue}if(c==="@"){b=!0,d("\0");continue}if(X.has(c)){S+=c,u=!0;continue}d(c)}let s=-1;for(let g=S.length-1;g>=0;g--){const c=S[g];if(c==="0"||c==="#"||c==="?"){s=g;break}}let n=!1,t="";for(let g=0;g<S.length;g++){const c=S[g];if(c===","){g>s?O/=1e3:n=!0;continue}t+=c}const r=t.indexOf("."),o=r===-1?t:t.slice(0,r),f=r===-1?"":t.slice(r+1);let l=0;for(const g of o)g==="0"&&(l+=1);let i=0;for(const g of f)g==="0"&&(i+=1);return{prefix:U,suffix:z,minInt:l,minDec:i,maxDec:f.length,grouping:n,scale:O,hasNumber:s!==-1,isText:b}}function _(H,U){const z=new Intl.NumberFormat(U,{minimumIntegerDigits:Math.max(H.minInt,1),minimumFractionDigits:H.minDec,maximumFractionDigits:Math.max(H.maxDec,H.minDec),useGrouping:H.grouping}),{prefix:S,suffix:O,scale:b,hasNumber:u}=H;return d=>{if(!u)return S+O;const s=b===1?d:d*b;return S+z.format(s)+O}}function Q(H,U){const S=B(String(H)).map(F),O=S.map(t=>_(t,U)),b=0,u=S.length>1?1:-1,d=S.length>2?2:-1,s=S.length>3?3:-1,n=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const r=Number(t);if(Number.isNaN(r))return s===-1?String(t):(S[s].prefix+S[s].suffix).split("\0").join(String(t));t=r}return t===0&&d!==-1?O[d](0):t<0&&u!==-1?O[u](-t):O[b](t)};return n.spec={mask:H},{format:n,ooxml:G(String(H))}}function G(H){return H.trim()}}),xe("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return G}});const X=["currency","number","percent","date","boolean","text","relative"],L=/[#0?@;"\\]/,B=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function F(H){return typeof H!="string"||H===""||Q(H)?!1:L.test(H)}function _(H){return typeof H!="string"||H===""||Q(H)?!1:B.test(H)}function Q(H){const U=H.indexOf(":"),z=U===-1?H:H.slice(0,U);return X.includes(z)?z:null}function G(H){const U=Q(H);if(!U)return null;const z=H.indexOf(":"),S=z===-1?"":H.slice(z+1),O=S===""?[]:S.split(":");switch(U){case"currency":{const b={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(b.decimals=Number(O[1])),b}case"number":{const b={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"percent":{const b={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"date":return{type:"date",pattern:S||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=S.split("/"),u={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(u.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(u.falseLabel=b[1]),b[2]!==void 0&&(u.nullLabel=b[2]),u}case"text":{const b={type:"text"};return O[0]&&(b.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(b.truncate=Number(O[1])),b}default:return null}}}),xe("packages/core/src/format/index.js",function(e,K){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return v}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.isObject,F=X.warnOnce,_=K("packages/core/src/format/number.js"),Q=_.compileNumber,G=K("packages/core/src/format/date.js"),H=G.compileDate,U=G.scanPattern,z=K("packages/core/src/format/boolean.js"),S=z.compileBoolean,O=K("packages/core/src/format/text.js"),b=O.compileText,u=K("packages/core/src/format/mask.js"),d=u.compileMask,s=K("packages/core/src/format/shorthand.js"),n=s.parseShorthand,t=s.looksLikeMask,r=s.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return _.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return G.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return G.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return G.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return G.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return z.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return z.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return O.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return u.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return u.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return u.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return s.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return s.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return s.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),f=new Set(["type","locale"]),l={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},i=new Set(["number","date","boolean","text"]);function g(T,P){const x=T.type;if(x===void 0||i.has(x)||!o.has(String(x)))return;const E=P?`"${P}"`:"with no id";F(`format:unknown-style-key:${P||""}:${x}`,`column ${E} has format: { type: "${x}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${x}" instead?`)}function c(T,P,x){const E=l[P],j=x?`"${x}"`:"with no id";for(const A of T){if(f.has(A)||E.has(A))continue;const $=Object.keys(l).find(D=>D!==P&&l[D].has(A));$?F(`format:inapplicable:${x||""}:${A}`,`column ${j} has format key "${A}", which applies to a ${$} column, not the ${P} column it was applied to; it is ignored.`):F(`format:unknown:${x||""}:${A}`,`column ${j} has an unrecognised format key "${A}" for its ${P} format; it is ignored.`)}}function h(T){if(T.type==="number"||T.type==="date"||T.type==="boolean"||T.type==="text")return!0;const P=o.has(String(T.style));return!!(T.pattern||T.dateStyle||T.timeStyle||T.relative||T.timeZone||T.trueLabel||T.falseLabel||T.display||T.trueIcon||T.falseIcon||T.transform||T.truncate||T.emptyDisplay||P||T.currency||T.decimals!==void 0||T.minDecimals!==void 0||T.maxDecimals!==void 0||T.notation||T.negative||T.scale!==void 0||T.prefix||T.suffix||T.zeroDisplay!==void 0)}function a(T,P){if(T.type==="number"||T.type==="date"||T.type==="boolean"||T.type==="text")return T.type;if(T.pattern||T.dateStyle||T.timeStyle||T.relative||T.timeZone)return"date";if(T.trueLabel||T.falseLabel||T.display||T.trueIcon||T.falseIcon)return"boolean";if(T.transform||T.truncate||T.emptyDisplay)return"text";if(T.style||T.currency||T.decimals!==void 0||T.minDecimals!==void 0||T.maxDecimals!==void 0||T.notation||T.negative||T.scale!==void 0||T.prefix||T.suffix||T.zeroDisplay!==void 0)return"number";const x=P&&P.base;return x==="number"?"number":x==="date"||x==="dateString"?"date":x==="boolean"?"boolean":"text"}function m(T,P=null,x=void 0,E=void 0,j=void 0){if(T==null||T==="")return null;const A=B(T)?Object.keys(T):null;if(typeof T=="function"){const M=(R,k)=>String(T({...k||{},value:R,locale:x})??"");return M.ooxml=P&&P.excel||"General",M}if(typeof T=="string"){if(t(T)){const{format:R,ooxml:k}=d(T,x);return R.ooxml=k,R}const M=n(T)||(r(T)?{type:"date",pattern:T}:null);return M?m(M,P,x,E,j):(F(`format:${T}`,`unrecognised format string "${T}"; the value will be stringified`),null)}if(!B(T))return F("format:shape","format must be a spec object or a string; ignoring",T),null;if(P&&L(P.format)&&!h(T)||P&&L(P.format)&&Array.isArray(P.formatPatterns)&&T.type===void 0)return null;const $=a(T,P);$==="date"&&E&&T.timeZone===void 0&&(T={...T,timeZone:E}),g(T,j),c(A||Object.keys(T),$,j);let D;switch($){case"number":D=Q(T,x);break;case"date":D=H(T,x);break;case"boolean":D=S(T,x);break;default:D=b(T,x);break}return D.ooxml=v(T,$,x,P),D.kind=$,D}const w={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function v(T,P,x=void 0,E=null){if(P==="date"){if(T.pattern){let M="";for(const R of U(T.pattern))M+=R.token?w[R.token]??R.text:R.text;return M}return E&&E.excel||"yyyy-mm-dd"}if(P==="boolean")return"General";if(P==="text")return"@";if(T.notation==="compact"||T.notation==="scientific")return"General";const j=typeof T.decimals=="number"?T.decimals:typeof T.minDecimals=="number"?T.minDecimals:T.style==="currency"?2:0;let $=`${T.thousandsSeparator===!1?"":"#,#"}#0${j>0?`.${"0".repeat(j)}`:""}`,D="";return T.style==="currency"&&(D+=p(C(T.currency||"USD",x))),T.prefix&&(D+=p(T.prefix)),$=D+$,T.style==="percent"&&($=`${$}%`),T.suffix&&($+=p(T.suffix)),T.negative==="parentheses"?`${$};(${$})`:T.negative==="suffix"?`${$};${$}-`:$}function p(T){return`"${String(T).split('"').join("")}"`}const y=new Map;function C(T,P){const x=`${T}|${P||""}`;let E=y.get(x);if(E!==void 0)return E;E=T;try{const A=new Intl.NumberFormat(P,{style:"currency",currency:T}).formatToParts(0).find($=>$.type==="currency");A&&(E=A.value)}catch{}return y.set(x,E),E}}),xe("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Je}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.isFunction,F=K("packages/core/src/format/date.js"),_=F.toDate,Q=F.compilePattern,G=F.compileDate,H=F.toIsoDateTime,U=F.compareIso,z=864e5,S=Object.freeze({}),O=1e3,b=60*O,u=60*b,d=24*u,s=7*d,n=new WeakMap;function t(Te,_e){const Ke=Te&&Te.locale||"",nt=Te&&Te.column;if(!nt)return Ke?{locale:Ke}:S;const ot=n.get(nt);if(ot&&ot.locale===Ke)return ot.bag;const pt=nt.typeOptions||nt[_e]||(r(nt.format)?nt.format:null),bt={...pt||S,locale:pt&&pt.locale||Ke||void 0};return n.set(nt,{locale:Ke,bag:bt}),bt}function r(Te){return Te!==null&&typeof Te=="object"&&!Array.isArray(Te)&&!(Te instanceof Date)}function o(Te,_e){const Ke=Te===null||Number.isNaN(Te)?null:Te,nt=_e===null||Number.isNaN(_e)?null:_e;return Ke===null?nt===null?0:1:nt===null||Ke<nt?-1:Ke>nt?1:0}const f=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,l=/^(\d{3,6})$/;function i(Te,_e,Ke,nt){return!(Te>=0&&Te<=23)||!(_e>=0&&_e<=59)||!(Ke>=0&&Ke<=59)||!(nt>=0&&nt<=999)?null:Te*u+_e*b+Ke*O+nt}function g(Te){if(L(Te))return null;const _e=String(Te).trim();if(_e==="")return null;const Ke=l.exec(_e);if(Ke){const Et=Ke[1];if(Et.length===5)return null;const Mt=Et.length===3?1:2;return i(Number(Et.slice(0,Mt)),Number(Et.slice(Mt,Mt+2)),Number(Et.slice(Mt+2,Mt+4)||0),0)}const nt=f.exec(_e);if(!nt)return null;let ot=Number(nt[1]);const pt=Number(nt[2]||0),bt=Number(nt[3]||0),Ot=nt[4]?Number(nt[4].padEnd(3,"0")):0,Pt=nt[5]?nt[5][0].toLowerCase():null;if(Pt){if(ot<1||ot>12)return null;ot=ot%12,Pt==="p"&&(ot+=12)}return i(ot,pt,bt,Ot)}function c(Te){return L(Te)||Te===""?null:typeof Te=="number"?Number.isFinite(Te)?(Te%d+d)%d:null:Te instanceof Date?Number.isNaN(Te.getTime())?null:Te.getHours()*u+Te.getMinutes()*b+Te.getSeconds()*O+Te.getMilliseconds():g(Te)}const h=new Map;function a(Te){const _e=Te.pattern||"",Ke=Te.timeStyle||(Te.seconds?"medium":"short"),nt=`${Te.locale||""}|${_e}|${Ke}`;let ot=h.get(nt);if(ot)return ot;if(_e)ot=Q(_e,Te.locale||void 0,"UTC");else{const pt=new Intl.DateTimeFormat(Te.locale||void 0,{timeStyle:Ke,timeZone:"UTC"});ot=bt=>pt.format(bt)}return h.set(nt,ot),ot}function m(Te,_e){const Ke=_e||S;if(Te==null||typeof Te!="number"||!Number.isFinite(Te))return Ke.nullDisplay??"";const nt=(Te%d+d)%d;return a(Ke)(new Date(nt))}function w(Te){return Te instanceof Date?!Number.isNaN(Te.getTime()):typeof Te=="number"?Number.isFinite(Te)&&Te>=0&&Te<d:typeof Te!="string"||!Te.includes(":")?!1:g(Te)!==null}function v(Te){const _e=c(Te);return _e==null?"":m(_e,{pattern:_e%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const p=new Map;function y(Te){const _e=Te||"";let Ke=p.get(_e);return Ke||(Ke=new Intl.DateTimeFormat("en-GB",{timeZone:Te||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),p.set(_e,Ke)),Ke}function C(Te,_e){const Ke={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const nt of y(_e).formatToParts(new Date(Te)))nt.type==="year"?Ke.year=Number(nt.value):nt.type==="month"?Ke.month=Number(nt.value):nt.type==="day"?Ke.day=Number(nt.value):nt.type==="hour"?Ke.hour=Number(nt.value)%24:nt.type==="minute"?Ke.minute=Number(nt.value):nt.type==="second"&&(Ke.second=Number(nt.value));return Ke}function T(Te,_e){const Ke=C(Te,_e);return Date.UTC(Ke.year,Ke.month-1,Ke.day,Ke.hour,Ke.minute,Ke.second,0)-Math.floor(Te/1e3)*1e3}function P(Te,_e){const Ke=Te.hour||0,nt=Te.minute||0,ot=Te.second||0,pt=Te.ms||0;if(!_e)return new Date(Te.year,Te.month-1,Te.day,Ke,nt,ot,pt).getTime();const bt=Date.UTC(Te.year,Te.month-1,Te.day,Ke,nt,ot,pt);let Ot=bt-T(bt,_e);return Ot=bt-T(Ot,_e),Ot}const x=/(?:Z|[+-]\d{2}:?\d{2})$/i,E=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function j(Te,_e){if(L(Te))return null;const Ke=String(Te).trim();if(Ke==="")return null;const nt=_e&&_e.timeZone||void 0;if(!x.test(Ke)){const ot=E.exec(Ke);if(ot){const pt=(ot[4]||"").trim(),bt=pt===""?0:g(pt);if(bt===null)return null;const Ot=P({year:Number(ot[1]),month:Number(ot[2]),day:Number(ot[3]),hour:Math.floor(bt/u),minute:Math.floor(bt/b)%60,second:Math.floor(bt/O)%60,ms:bt%O},nt);return Number.isNaN(Ot)?null:new Date(Ot)}}return _(Ke)}function A(Te){if(typeof Te=="number")return Number.isFinite(Te)?Te:null;const _e=_(Te);return _e?_e.getTime():null}const $=new Map;function D(Te){const _e=[Te.locale||"",Te.pattern||"",Te.dateStyle||"",Te.timeStyle||"",Te.timeZone||"",Te.seconds?"1":""].join("|");let Ke=$.get(_e);if(Ke)return Ke;const nt=Te.pattern?{type:"date",pattern:Te.pattern,timeZone:Te.timeZone}:{type:"date",dateStyle:Te.dateStyle||"medium",timeStyle:Te.timeStyle||(Te.seconds?"medium":"short"),timeZone:Te.timeZone};return Ke=G(nt,Te.locale||void 0),$.set(_e,Ke),Ke}function M(Te,_e){const Ke=_e||S,nt=A(Te);return nt==null?Ke.nullDisplay??"":D(Ke)(nt)}function R(Te){return Te instanceof Date?!Number.isNaN(Te.getTime()):typeof Te!="string"||!E.test(Te.trim())?!1:j(Te)!==null}const k=Object.freeze([{key:"w",ms:s,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:d,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:O,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),I=new Map;for(const Te of k)for(const _e of Te.names)I.set(_e,Te);const q=Object.freeze(k.filter(Te=>Te.key!=="w")),Z=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,W=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ee(Te){const _e=Te&&Te.defaultUnit?I.get(String(Te.defaultUnit).toLowerCase()):null;return _e?_e.ms:b}function te(Te){return(Te&&Te.defaultUnit?I.get(String(Te.defaultUnit).toLowerCase()):null)||I.get("m")}function ne(Te,_e){if(L(Te))return null;let Ke=String(Te).trim().toLowerCase();if(Ke==="")return null;let nt=1;if(Ke[0]==="-"?(nt=-1,Ke=Ke.slice(1).trim()):Ke[0]==="+"&&(Ke=Ke.slice(1).trim()),Ke==="")return null;const ot=J.exec(Ke);if(ot){const Pt=ot[3]!==void 0,Et=Number(ot[1])*u+Number(ot[2])*b+(Pt?Number(ot[3])*O:0)+(ot[4]?Number(ot[4].padEnd(3,"0")):0);return nt*Et}if(W.test(Ke))return Math.round(nt*Number(Ke)*ee(_e||S));let pt=Ke,bt=0,Ot=0;for(;pt!=="";){const Pt=Z.exec(pt);if(!Pt)return null;const Et=I.get(Pt[2]);if(!Et)return null;bt+=Number(Pt[1])*Et.ms,pt=pt.slice(Pt[0].length),Ot++}return Ot===0?null:Math.round(nt*bt)}function ae(Te){return L(Te)||Te===""?null:typeof Te=="number"?Number.isFinite(Te)?Te:null:ne(Te)}const de=new Map;function ie(Te,_e,Ke){const nt=`${Ke||""}|${_e.intl}`;let ot=de.get(nt);if(ot===void 0){try{ot=new Intl.NumberFormat(Ke||void 0,{style:"unit",unit:_e.intl,unitDisplay:"long"})}catch{ot=null}de.set(nt,ot)}return ot?ot.format(Te):`${Te} ${Te===1?_e.long[0]:_e.long[1]}`}function oe(Te,_e){return String(Te).padStart(_e,"0")}function ce(Te,_e){const Ke=_e||S;if(Te==null||typeof Te!="number"||!Number.isFinite(Te))return Ke.nullDisplay??"";const nt=Ke.style||"short",ot=Te<0;let pt=Math.round(Math.abs(Te));const bt=ot?"-":"";if(pt===0&&Ke.zeroDisplay!=null)return Ke.zeroDisplay;if(nt==="clock"){const Mt=Math.floor(pt/u),Dt=Math.floor(pt/b)%60,Bt=Math.floor(pt/O)%60;return`${bt}${oe(Mt,2)}:${oe(Dt,2)}:${oe(Bt,2)}`}if(pt===0){const Mt=te(Ke);return nt==="long"?ie(0,Mt,Ke.locale):`0${Mt.key}`}const Ot=Ke.weeks===!0?k:q,Pt=typeof Ke.maxUnits=="number"&&Ke.maxUnits>0?Ke.maxUnits:Ke.maxUnits===void 0?2:1/0,Et=[];for(const Mt of Ot){if(Et.length>=Pt)break;const Dt=Math.floor(pt/Mt.ms);Dt!==0&&(pt-=Dt*Mt.ms,Et.push(nt==="long"?ie(Dt,Mt,Ke.locale):`${Dt}${Mt.key}`))}return bt+Et.join(" ")}function fe(Te){if(typeof Te!="string")return!1;const _e=Te.trim();return _e===""||J.test(_e)||!/[a-z]/i.test(_e)?!1:ne(_e)!==null}const ke=Date.UTC(1899,11,30),Re=new Map;function Ee(Te,_e){const Ke=Te||"";let nt=Re.get(Ke);nt||(nt=new Intl.DateTimeFormat("en-GB",{timeZone:Te||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Re.set(Ke,nt));const ot=typeof _e=="number"?_e:Date.now();for(const pt of nt.formatToParts(new Date(ot)))if(pt.type==="timeZoneName")return pt.value;return""}function Fe(Te){if(Te)return Te;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ye(Te,_e){const Ke=Fe(Te),nt=Ee(Te,_e);return nt?`${Ke} (${nt})`:Ke}function he(Te,_e){if(Te&&Te.timeZone)return Te.timeZone;const Ke=_e&&_e.grid;return(Ke&&B(Ke.get)?Ke.get("timeZone"):void 0)||void 0}function Se(Te,_e){const Ke=_e||S,nt=A(Te);if(nt==null)return Ke.nullDisplay??"";const ot=D(Ke)(nt);if(!Ke.showOrigin)return ot;const pt=Ke.originZone;return pt?pt===(Ke.timeZone||Fe(Ke.timeZone))?ot:`${ot} (${ye(pt,nt)})`:`${ot} (no origin recorded)`}function Ce(Te,_e,Ke,nt){if(_e==="instant"||!_e)return Te;const ot=C(Te,Ke);if(_e==="month")return P({year:ot.year,month:ot.month,day:1},Ke);if(_e==="week"){const pt=nt>=1&&nt<=7?nt:1,Ot=((new Date(Date.UTC(ot.year,ot.month-1,ot.day)).getUTCDay()+6)%7+1-pt+7)%7,Pt=new Date(Date.UTC(ot.year,ot.month-1,ot.day-Ot));return P({year:Pt.getUTCFullYear(),month:Pt.getUTCMonth()+1,day:Pt.getUTCDate()},Ke)}return P({year:ot.year,month:ot.month,day:ot.day},Ke)}function Ie(Te,_e){const Ke=Te&&Te.group,nt=Ke&&Ke.granularity||"day";if(nt==="instant")return null;const ot=Ke&&Ke.weekStart;return pt=>typeof pt=="number"?Ce(pt,nt,_e,ot):pt}const ze={time:{base:"number",storage:"float64",matches:w,format:Te=>m(c(Te.value),t(Te,"time")),parse:Te=>g(Te.text),compare:(Te,_e)=>o(c(Te),c(_e)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Te=>{const _e=c(Te);return _e===null?null:_e/z},toStorage:Te=>c(Te),toClipboard:v,fromClipboard:g},datetime:{base:"dateString",storage:"dictionary",matches:R,format:Te=>M(Te.value,t(Te,"datetime")),parse:Te=>H(j(Te.text,t(Te,"datetime"))??Te.text),compare:U,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Te,_e)=>H(Te,_e&&_e.timeZone),toClipboard:Te=>L(Te)?"":String(Te),fromClipboard:Te=>H(Te)},duration:{base:"number",storage:"float64",matches:fe,format:Te=>ce(ae(Te.value),t(Te,"duration")),parse:Te=>ne(Te.text,t(Te,"duration")),compare:(Te,_e)=>o(ae(Te),ae(_e)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Te=>{const _e=ae(Te);return _e===null?null:_e/z},toStorage:Te=>ae(Te),toClipboard:Te=>ce(ae(Te),{style:"short",maxUnits:-1}),fromClipboard:Te=>ne(Te)},timestamp:{base:"number",storage:"float64",format:Te=>{const _e=t(Te,"timestamp");return Se(Te.value,{..._e,timeZone:he(_e,Te)})},parse:Te=>{const _e=t(Te,"timestamp"),Ke=j(Te.text,{timeZone:he(_e,Te)});return Ke?Ke.getTime():null},compare:(Te,_e)=>o(A(Te),A(_e)),groupProjector:(Te,_e)=>Ie(Te,_e),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Te,_e)=>{const Ke=A(Te);if(Ke==null)return null;const nt=C(Ke,_e&&_e.timeZone||void 0);return(Date.UTC(nt.year,nt.month-1,nt.day,nt.hour,nt.minute,nt.second)-ke)/z},toStorage:Te=>A(Te),toClipboard:Te=>{const _e=A(Te);return _e==null?"":new Date(_e).toISOString()},fromClipboard:Te=>A(Te)}},Xe=["datetime","time","duration"],Je=ze}),xe("packages/core/src/columns/types/network.js",function(e,K){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return j}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.Lru,F=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Q(A){if(L(A))return null;if(typeof A=="string")return G(A);const $=Number(A);return Number.isFinite($)?$<0?$<-2147483648?null:$>>>0:$>F?null:Math.trunc($)>>>0:null}function G(A){if(L(A))return null;const $=String(A).trim();if($==="")return null;const D=_.exec($);if(!D)return null;let M=0;for(let R=1;R<=4;R++){const k=D[R];if(k.length>1&&k.charCodeAt(0)===48)return null;const I=Number(k);if(I>255)return null;M=M*256+I}return M}function H(A){const $=Q(A);return $===null?"":`${$>>>24&255}.${$>>>16&255}.${$>>>8&255}.${$&255}`}function U(A){return typeof A=="string"&&G(A)!==null}function z(A,$){const D=Q(A),M=Q($);return D===null?M===null?0:1:M===null||D<M?-1:D>M?1:0}const S=64,O=F*S+32,b=/^(?:0|[1-9]\d?)$/;function u(A,$){return A*S+$}function d(A){if(L(A))return null;if(typeof A=="string"){const M=s(A);return M===null?null:d(M)}if(typeof A=="object"){const M=Q(A.address),R=Number(A.prefix);return M===null||!Number.isInteger(R)||R<0||R>32?null:{address:M,prefix:R}}const $=Number(A);if(!Number.isInteger($)||$<0||$>O)return null;const D=$%S;return D>32?null:{address:($-D)/S,prefix:D}}function s(A){if(L(A))return null;const $=String(A).trim();if($==="")return null;const D=$.indexOf("/");if(D<0)return null;const M=G($.slice(0,D));if(M===null)return null;const R=$.slice(D+1).trim();if(!b.test(R))return null;const k=Number(R);return k>32?null:u(M,k)}function n(A){const $=d(A);return $?`${H($.address)}/${$.prefix}`:""}function t(A){return typeof A=="string"&&s(A)!==null}function r(A,$){const D=d(A),M=d($);return D?M?D.address!==M.address?D.address<M.address?-1:1:D.prefix-M.prefix:-1:M?1:0}function o(A){return A===0?0:4294967295<<32-A>>>0}function f(A){const $=d(A);return $?($.address&o($.prefix))>>>0:null}function l(A){const $=d(A);return $?($.address&o($.prefix)|~o($.prefix)>>>0)>>>0:null}function i(A){const $=d(A);return $?2**(32-$.prefix):null}function g(A){const $=d(A);return $?$.prefix===32?1:$.prefix===31?2:2**(32-$.prefix)-2:null}function c(A,$){const D=d(A);if(!D)return!1;const M=Q($);if(M===null)return!1;const R=o(D.prefix);return(M&R)>>>0===(D.address&R)>>>0}function h(A,$){const D=f(A),M=f($);return D===null||M===null?!1:D<=l($)&&M<=l(A)}const a=/^[0-9a-fA-F]{1,4}$/,m=new B(512);function w(A){if(L(A))return null;let $=String(A).trim();if($==="")return null;const D=$.indexOf("%");if(D>=0&&($=$.slice(0,D)),$==="")return null;if($.indexOf(".")>=0){const Z=$.lastIndexOf(":");if(Z<0)return null;const W=G($.slice(Z+1));if(W===null)return null;$=`${$.slice(0,Z+1)}${(W>>>16&65535).toString(16)}:${(W&65535).toString(16)}`}const M=$.split("::");if(M.length>2)return null;const R=v(M[0]);if(R===null)return null;if(M.length===1)return R.length===8?R:null;const k=v(M[1]);if(k===null)return null;const I=8-R.length-k.length;if(I<1)return null;const q=R.slice();for(let Z=0;Z<I;Z++)q.push(0);for(const Z of k)q.push(Z);return q}function v(A){if(A==="")return[];const $=[];for(const D of A.split(":")){if(!a.test(D))return null;$.push(parseInt(D,16))}return $}function p(A){if(typeof A!="string")return w(A);if(m.has(A))return m.get(A);const $=w(A);return m.set(A,$),$}function y(A){if(A[0]===0&&A[1]===0&&A[2]===0&&A[3]===0&&A[4]===0&&A[5]===65535)return`::ffff:${H((A[6]<<16|A[7])>>>0)}`;let $=-1,D=0,M=-1,R=0;for(let q=0;q<8;q++)A[q]===0?(M<0?(M=q,R=1):R++,R>D&&(D=R,$=M)):(M=-1,R=0);if(D<2)return A.map(q=>q.toString(16)).join(":");const k=A.slice(0,$).map(q=>q.toString(16)).join(":"),I=A.slice($+D).map(q=>q.toString(16)).join(":");return`${k}::${I}`}function C(A){const $=w(A);return $===null?null:y($)}function T(A){return C(A)??""}function P(A){return typeof A=="string"&&A.indexOf(":")>=0&&w(A)!==null}function x(A,$){const D=p(A),M=p($);if(!D)return M?1:0;if(!M)return-1;for(let R=0;R<8;R++)if(D[R]!==M[R])return D[R]<M[R]?-1:1;return 0}const E=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:U,parse:A=>G(A.text),compare:z,format:A=>H(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>Q(A),toClipboard:A=>H(A),fromClipboard:A=>G(A)},cidr:{base:"number",storage:"float64",matches:t,parse:A=>s(A.text),compare:r,format:A=>n(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>{const $=d(A);return $===null?null:u($.address,$.prefix)},toClipboard:A=>n(A),fromClipboard:A=>s(A)},ipv6:{base:"text",storage:"dictionary",matches:P,parse:A=>C(A.text),compare:x,format:A=>T(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:A=>C(A),toClipboard:A=>T(A),fromClipboard:A=>C(A)}}),j=E}),xe("packages/core/src/i18n/catalogue.js",function(e,K){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return L}});const X=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Next / previous cell, wrapping across rows","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown"}),L=Object.freeze(Object.keys(X))}),xe("packages/core/src/i18n/format.js",function(e,K){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return O}});const L=K("packages/core/src/internal/util.js").isFunction,B=/\{(\w+)\}/g,F=new Map,_=new Map;function Q(b){const u=b||"";if(F.has(u))return F.get(u);let d=null;try{d=new Intl.PluralRules(b||void 0)}catch{d=null}return F.set(u,d),d}function G(b,u,d="conjunction"){const s=Array.isArray(b)?b.filter(r=>r!=null&&r!==""):[];if(s.length===0)return"";if(s.length===1)return String(s[0]);const n=`${u||""}|${d}`;let t=_.get(n);if(t===void 0){try{t=new Intl.ListFormat(u||void 0,{style:"long",type:d})}catch{t=null}_.set(n,t)}return t?t.format(s.map(String)):s.map(String).join(", ")}function H(b,u){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(b)}function U(b,u,d){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const s=u&&typeof u.count=="number"?u.count:null;if(s===null)return b.other??"";const n=Q(d),t=n?n.select(s):s===1?"one":"other";return b[t]??b.other??""}function z(b,u={},d){const s=U(b,u,d);return s?s.replace(B,(n,t)=>Object.prototype.hasOwnProperty.call(u,t)?H(u[t],d):n):""}function S(b,u,d="en-GB"){return typeof b=="string"&&b?b:typeof u=="string"&&u?u:d}function O(b,u){const d=b?b[u]:void 0;return d==null||L(d)?u:d}}),xe("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return s}});const X=K("packages/core/src/i18n/catalogue.js"),L=X.EN_GB,B=X.MESSAGE_KEYS,F=K("packages/core/src/i18n/format.js"),_=F.formatMessage,Q=F.formatList,G=F.lookup,H=F.resolveLocale,U=K("packages/core/src/internal/util.js"),z=U.isFunction,S=U.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return X.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return F.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return F.resolveLocale}});const O="en-GB";class b{#e=O;#t=L;constructor(t={}){this.configure(t)}configure(t={}){this.#e=H(t.locale,t.declared,O);const r=t.messages;if(!r||typeof r!="object"){this.#t=L;return}const o=Object.keys(r).filter(f=>!(f in L));o.length&&S(`i18n:unknown:${o[0]}`,`message keys not in the catalogue and so ignored: ${o.slice(0,5).join(", ")}${o.length>5?`, and ${o.length-5} more`:""}`),this.#t={...L,...r}}get locale(){return this.#e}t(t,r){return _(G(this.#t,t),r||{},this.#e)}list(t,r){return Q(t,this.#e,r)}number(t,r){const o=Number(t);return Number.isFinite(o)?o.toLocaleString(this.#e,r||{maximumFractionDigits:20}):""}}const u=new b;function d(n){return n instanceof b?n:new b(n||{})}function s(n){const t=n&&typeof n=="object"?n:{},r=B.filter(f=>{const l=t[f];return l==null||l===""||z(l)}),o=Object.keys(t).filter(f=>!(f in L));return{missing:r,unknown:o}}}),xe("packages/core/src/columns/types/structured.js",function(e,K){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.isObject,_=K("packages/core/src/i18n/index.js").defaultMessages,Q=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function G(n,t){const r=t||{},o=r.emptyDisplay??Q.emptyDisplay;if(L(n)||n==="")return o;const l=[...typeof r.char=="string"&&r.char!==""?r.char:Q.char][0]||Q.char,i=r.fixedLength??Q.fixedLength,g=Number.isFinite(r.length)&&Number(r.length)>0?Math.floor(Number(r.length)):Q.length,c=typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?String(n):null;let h=0;if(c!==null){const a=Number.isFinite(r.lastVisible)?Math.floor(Number(r.lastVisible)):Q.lastVisible,m=[...c];if(h=a>0&&a<m.length?a:0,h>0){const w=m.slice(m.length-h).join(""),v=Math.max(1,(i?g:m.length)-h);return l.repeat(v)+w}return l.repeat(i?g:Math.max(1,m.length))}return l.repeat(g)}const H=48;function U(n){try{const t=JSON.stringify(n);return t===void 0?null:t}catch{return null}}function z(n,t){if(L(n))return"";const r=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):H;if(typeof n=="string")return n.length>r?`${n.slice(0,r-1)}…`:n;if(typeof n!="object")return String(n);const o=U(n);if(o!==null&&o.length<=r)return o;if(Array.isArray(n)){const l=n.length;return`[${_.t("count.items",{count:l})}]`}const f=Object.keys(n).length;return`{${_.t("count.keys",{count:f})}}`}function S(n,t){if(n==null)return"null";const r=typeof n;if(r==="number"||r==="boolean"||r==="bigint")return String(n);if(r==="string")return JSON.stringify(n);if(r!=="object")return JSON.stringify(String(n));const o=t||new WeakSet;return o.has(n)?'"[circular]"':(o.add(n),n instanceof Date?JSON.stringify(n.toISOString()):Array.isArray(n)?`[${n.map(i=>S(i,o)).join(",")}]`:`{${Object.keys(n).sort().map(i=>`${JSON.stringify(i)}:${S(n[i],o)}`).join(",")}}`)}function O(n,t){if(L(n))return L(t)?0:1;if(L(t))return-1;const r=S(n),o=S(t);return r<o?-1:r>o?1:0}function b(n){if(L(n))return null;const t=String(n);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function u(n){const t=n&&n.cell&&n.cell.props;return B(t)?t:{}}const d=Object.freeze({json:{base:"object",storage:"object",format:n=>z(n&&n.value,u(n&&n.column)),parse:n=>b(n&&n.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:n=>{if(L(n))return"";if(typeof n=="string")return n;try{const t=JSON.stringify(n,null,2);return t===void 0?String(n):t}catch{return String(n)}},fromClipboard:n=>b(n)},secret:{base:"text",storage:"object",format:n=>G(n&&n.value,u(n&&n.column)),parse:n=>{const t=n&&n.text;return L(t)||String(t)===""?null:String(t)},compare:(n,t)=>{const r=L(n)||n==="",o=L(t)||t==="";return r===o?0:r?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:n=>G(n),fromClipboard:n=>L(n)||String(n)===""?null:String(n)}}),s=d}),xe("packages/core/src/columns/types/unit.js",function(e,K){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.warnOnce;function F(R,k,I,q){return Object.freeze({symbol:R,factor:k,aliases:Object.freeze(I||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function _(R,k,I,q){return F(R,k,I,q)}const Q=Object.freeze({data:Object.freeze([F("B",1,["byte","bytes"]),F("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),F("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),F("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),F("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),F("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),F("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),F("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),F("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),F("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([F("bps",1,["bit","bits","bit/s","b/s"]),F("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),F("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),F("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),F("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([F("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),F("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),F("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),F("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),F("in",.0254,["inch","inches"],{auto:!1}),F("ft",.3048,["foot","feet"],{auto:!1}),F("yd",.9144,["yard","yards"],{auto:!1}),F("m",1,["metre","metres","meter","meters"]),F("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),F("mi",1609.344,["mile","miles"],{auto:!1}),F("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([F("mg",.001,["milligram","milligrams"]),F("g",1,["gram","grams"]),F("oz",28.349523125,["ounce","ounces"],{auto:!1}),F("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),F("kg",1e3,["kilogram","kilograms"]),F("st",6350.29318,["stone"],{auto:!1}),F("t",1e6,["tonne","tonnes","ton"],{auto:!1}),F("ton (US)",907184.74,["ton","shortton"],{auto:!1}),F("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([F("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),F("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),F("ms",.001,["msec","msecs","millisecond","milliseconds"]),F("s",1,["sec","secs","second","seconds"]),F("m",60,["min","mins","minute","minutes"]),F("h",3600,["hr","hrs","hour","hours"]),F("d",86400,["day","days"])]),speed:Object.freeze([F("mm/s",.001,["millimetre/s","millimeter/s"]),F("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),F("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),F("mph",.44704,["mile/h","miles/h"],{auto:!1}),F("kn",1852/3600,["knot","knots"],{auto:!1}),F("m/s",1,["metre/s","meter/s","mps"]),F("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([F("mm/s²",.001,["mm/s2"]),F("ft/s²",.3048,["ft/s2"],{auto:!1}),F("m/s²",1,["m/s2","metre/s2","meter/s2"]),F("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([F("mm²",1e-6,["mm2"]),F("cm²",1e-4,["cm2"]),F("in²",64516e-8,["in2","sqin"],{auto:!1}),F("ft²",.09290304,["ft2","sqft"],{auto:!1}),F("yd²",.83612736,["yd2","sqyd"],{auto:!1}),F("m²",1,["m2","sqm"]),F("ha",1e4,["hectare","hectares"],{auto:!1}),F("ac",4046.8564224,["acre","acres"],{auto:!1}),F("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([F("µL",1e-6,["ul","microlitre","microliter"]),F("mL",.001,["millilitre","milliliter"]),F("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),F("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),F("L",1,["litre","litres","liter","liters"]),F("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),F("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),F("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),F("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([F("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),F("J",1,["joule","joules"]),F("cal",4.184,["calorie","calories"],{auto:!1}),F("kJ",1e3,["kilojoule","kilojoules"]),F("BTU",1055.05585262,["btu"],{auto:!1}),F("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),F("MJ",1e6,["megajoule","megajoules"]),F("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),F("GJ",1e9,["gigajoule","gigajoules"]),F("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([F("mW",.001,["milliwatt","milliwatts"]),F("W",1,["watt","watts"]),F("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),F("kW",1e3,["kilowatt","kilowatts"]),F("hp",745.6998715822702,["horsepower"],{auto:!1}),F("MW",1e6,["megawatt","megawatts"]),F("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([F("mN",.001,["millinewton","millinewtons"]),F("N",1,["newton","newtons"]),F("lbf",4.4482216152605,["poundforce"],{auto:!1}),F("kgf",9.80665,["kilogramforce"],{auto:!1}),F("kN",1e3,["kilonewton","kilonewtons"]),F("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([F("Pa",1,["pascal","pascals"]),F("mbar",100,["millibar"],{auto:!1}),F("inH₂O",249.0889,["inh2o"],{auto:!1}),F("mmHg",133.322387415,["torr"],{auto:!1}),F("kPa",1e3,["kilopascal","kilopascals"]),F("inHg",3386.388640341,["inhg"],{auto:!1}),F("psi",6894.757293168361,["lbf/in2"],{auto:!1}),F("bar",1e5,[],{auto:!1}),F("atm",101325,["atmosphere","atmospheres"],{auto:!1}),F("MPa",1e6,["megapascal","megapascals"]),F("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([F("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),F("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),F("kN·m",1e3,["knm","kn.m"],{auto:!1}),F("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([F("kg/m³",1,["kg/m3"]),F("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),F("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),F("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([F("L/min",1/6e4,["lpm","l/min"],{auto:!1}),F("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),F("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),F("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),F("cfm",.0004719474432,["ft3/min"],{auto:!1}),F("L/s",.001,["lps","l/s"],{auto:!1}),F("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([F("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),F("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),F("mrad",.001,["milliradian","milliradians"],{auto:!1}),F("mil",Math.PI/3200,["nato-mil"],{auto:!1}),F("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),F("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),F("rad",1,["radian","radians"]),F("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([F("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),F("rad/s",1,["radps","radians/s"]),F("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),F("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([F("ppt",1e-12,["partspertrillion"],{auto:!1}),F("ppb",1e-9,["partsperbillion"]),F("ppm",1e-6,["partspermillion"]),F("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),F("‰",.001,["permille","permil"],{auto:!1}),F("%",.01,["pct","percent"]),F("×",1,["x","ratio","times"])]),molarity:Object.freeze([F("pM",1e-12,["picomolar","picomolarity"]),F("nM",1e-9,["nanomolar","nanomolarity"]),F("µM",1e-6,["um-molar","micromolar","micromolarity"]),F("mM",.001,["millimolar","millimolarity"]),F("M",1,["molar","mol/l","mol/L","molarity"]),F("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([F("mg/s",1e-6,["milligrams/s"]),F("g/s",.001,["grams/s"]),F("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),F("kg/s",1,["kilograms/s","kgps"]),F("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),F("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),F("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([F("µPa·s",1e-6,["upas","micropascalsecond"]),F("cP",.001,["centipoise"],{auto:!1}),F("mPa·s",.001,["mpas","millipascalsecond"]),F("P",.1,["poise"],{auto:!1}),F("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([F("cSt",1e-6,["centistokes","centistoke"]),F("mm²/s",1e-6,["mm2/s"],{auto:!1}),F("St",1e-4,["stokes","stoke"],{auto:!1}),F("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([F("mW/(m·K)",.001,["mw/mk"]),F("W/(m·K)",1,["w/mk","wmk"]),F("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),F("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([F("J/(kg·K)",1,["j/kgk","jkgk"]),F("kJ/(kg·K)",1e3,["kj/kgk"]),F("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([F("nSv/h",1e-9,["nsvh"]),F("µSv/h",1e-6,["usv/h","usvh"]),F("mSv/h",.001,["msvh"]),F("Sv/h",1,["svh"]),F("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),G=Symbol("ambiguous"),H=new Map,U=new Map;function z(R,k){const I=String(R||"").trim();if(!I)throw new Error("[lattice] a unit system needs a name");if(Q[I]||U.has(I))throw new Error(`[lattice] unit system "${I}" already exists`);const q=[...k||[]];if(!q.length)throw new Error(`[lattice] unit system "${I}" has no units`);if(!q.some(W=>W.factor===1))throw new Error(`[lattice] unit system "${I}" has no base unit (none with factor 1)`);const Z=new Set;for(const W of q){if(Z.has(W.symbol))throw new Error(`[lattice] unit system "${I}" declares "${W.symbol}" twice`);Z.add(W.symbol)}return U.set(I,Object.freeze(q)),H.delete(I),I}function S(){return[...Object.keys(Q),...U.keys()]}function O(R){const k=b(R);return k?k.units:[]}function b(R){const k=String(R||""),I=H.get(k);if(I!==void 0)return I;const q=Q[k]||U.get(k);if(!q)return H.set(k,null),null;const Z=Object.freeze([...q].sort((ne,ae)=>ne.factor-ae.factor)),W=new Map,J=new Map,ee=(ne,ae)=>{const de=W.get(ne);de===void 0?W.set(ne,ae):de!==ae&&W.set(ne,G)};for(const ne of Z){ee(ne.symbol.toLowerCase(),ne);for(const ae of ne.aliases)ee(ae.toLowerCase(),ne);if(ne.prefix){const ae=J.get(ne.prefix)||[];ae.push(ne),J.set(ne.prefix,ae)}}const te={units:Z,byToken:W,byPrefix:J,decimal:Z.filter(ne=>!ne.binary&&ne.auto),binary:Z.some(ne=>ne.binary)?Z.filter(ne=>(ne.binary||ne.factor===1)&&ne.auto):null};return H.set(k,te),te}function u(R,k){return k&&R.binary||R.decimal}function d(R,k){const I=b(R);if(!I||L(k))return null;const q=I.units.find(W=>W.symbol===String(k));if(q)return q;const Z=I.byToken.get(String(k).trim().toLowerCase());return Z&&Z!==G?Z:null}const s=new WeakMap;function n(R){const k=R||{};if(typeof k=="object"&&k!==null){const W=s.get(k);if(W!==void 0)return W}const I=k.system||"data",q=b(I);let Z=null;if(!q)B(`unit:system:${I}`,`unknown unit system "${I}"; known systems are ${S().join(", ")}`);else{let W=k.unit?d(I,k.unit):null;W||(k.unit&&B(`unit:unit:${I}:${k.unit}`,`unknown unit "${k.unit}" in system "${I}"; falling back to ${q.units[0].symbol}`),W=q.units.find(J=>J.factor===1)||q.units[0]),Z={index:q,base:W,binary:k.binary===!0}}return typeof k=="object"&&k!==null&&s.set(k,Z),Z}const t=new WeakMap;function r(R,k){if(!R||!k||!Array.isArray(R.compound)||R.compound.length===0)return null;const I=t.get(R);if(I!==void 0)return I;const q=new Set,Z=[];for(const J of R.compound){const ee=d(R.system||"data",J);if(!ee){B(`unit:compound:${R.system}:${J}`,`unknown compound unit "${J}" in system "${R.system||"data"}"; ignoring it`);continue}q.has(ee.symbol)||(q.add(ee.symbol),Z.push(ee))}Z.sort((J,ee)=>ee.factor-J.factor);const W=Z.length>=2?Z:null;return t.set(R,W),W}function o(R,k,I){return k===I||k.factor===I.factor?R:R*k.factor/I.factor}const f=new Map;function l(R){const k=R||"",I=f.get(k);if(I)return I;const q={group:",",decimal:"."};try{for(const Z of new Intl.NumberFormat(R||void 0).formatToParts(12345.6))Z.type==="group"?q.group=Z.value:Z.type==="decimal"&&(q.decimal=Z.value)}catch{}return f.set(k,q),q}const i=/[\s   ]/g,g=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,c=/^[^\d+\-(.,\s]+\s*/,h=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function a(R,k){const{group:I,decimal:q}=l(k);let Z=String(R).replace(i,"");if(Z==="")return null;const W=q?Z.indexOf(q):-1;if(I&&I!==q){if(W>=0&&Z.indexOf(I,W+q.length)>=0)return null;Z=Z.split(I).join("")}if(q&&q!=="."&&(Z=Z.split(q).join(".")),!h.test(Z))return null;const J=Number(Z);return Number.isFinite(J)?J:null}function m(R,k,I){const q=String(R).trim().replace(/\.$/,"");if(q==="")return null;const Z=k.units.find(ae=>ae.symbol===q);if(Z)return Z;const W=q.toLowerCase(),J=k.byToken.get(W);if(J===G)return null;if(J)return J;const ee=k.byPrefix.get(W);if(!ee||!ee.length)return null;const te=u(k,I),ne=ee.filter(ae=>te.includes(ae));return ne.length===1?ne[0]:null}function w(R,k,I,q){let Z=R,W=0,J=!1,ee=!1;for(;Z!=="";){const te=g.exec(Z)[0];if(te==="")return null;const ne=a(te,q&&q.locale);if(ne===null)return null;Z=Z.slice(te.length).trim();const ae=Z.search(/[+-]?[\d]/),de=(ae>=0?Z.slice(0,ae):Z).trim();if(Z=ae>=0?Z.slice(ae).trim():"",de===""){if(J)return null;ee=!0,W+=o(ne,I[0],k.base)}else{const ie=m(de,k.index,k.binary);if(!ie)return null;W+=o(ne,ie,k.base)}if(J=!0,ee&&Z!=="")return null}return J?W:null}function v(R,k){if(L(R))return null;if(typeof R=="number")return Number.isFinite(R)?R:null;const I=n(k);if(!I)return null;let q=String(R).trim();if(q==="")return null;let Z=!1;q.startsWith("(")&&q.endsWith(")")&&(Z=!0,q=q.slice(1,-1).trim());const W=r(k,I);if(W){q.startsWith("-")&&(Z=!0,q=q.slice(1).trim());const oe=w(q,I,W,k);return oe===null?null:Z?-oe:oe}let J=null;const ee=c.exec(q);if(ee&&ee[0]){const oe=m(ee[0].trim(),I.index,I.binary);oe&&(J=oe,q=q.slice(ee[0].length).trim())}const te=g.exec(q)[0],ne=a(te,k&&k.locale);if(ne===null)return null;const ae=q.slice(te.length).trim();if(J&&ae!=="")return null;const de=J||(ae===""?I.base:m(ae,I.index,I.binary));if(!de)return null;const ie=o(ne,de,I.base);return Z?-ie:ie}const p=new Map;function y(R,k,I,q){const Z=`${R||""}|${k}|${I}|${q?1:0}`;let W=p.get(Z);return W||(W=new Intl.NumberFormat(R||void 0,{minimumFractionDigits:k,maximumFractionDigits:I,useGrouping:q}),p.set(Z,W)),W}function C(R,k){if(!Number.isFinite(R)||R===0)return Math.max(0,k-1);const I=Math.floor(Math.log10(Math.abs(R)));return Math.min(20,Math.max(0,k-1-I))}function T(R,k){if(!Number.isFinite(R)||R===0)return R;const I=Math.ceil(Math.log10(Math.abs(R))),q=10**(k-I);return Math.round(R*q)/q}function P(R,k,I){if(!I||I===k.base.symbol)return k.base;if(I!=="auto")return x(k,I);if(R===0||!Number.isFinite(R))return k.base;const q=Math.abs(R)*k.base.factor,Z=u(k.index,k.binary);let W=Z[0];for(const te of Z)q>=te.factor&&(W=te);if(q>=W.factor)return W;let J=W;for(const te of k.index.units)te.binary!==k.binary&&te.factor!==1||te.factor<=q&&te.factor>(J===W?0:J.factor)&&(J=te);if(J!==W)return J;let ee=W;for(const te of k.index.units)te.binary!==k.binary&&te.factor!==1||te.factor<ee.factor&&(ee=te);return ee.factor<k.base.factor?ee:k.base}function x(R,k){const I=R.index.units.find(Z=>Z.symbol===k);if(I)return I;const q=R.index.byToken.get(String(k).toLowerCase());return q&&q!==G?q:(B(`unit:display:${k}`,`unknown display unit "${k}"; rendering in ${R.base.symbol}`),R.base)}function E(R,k,I,q){const Z=R<0;let W=Math.abs(R)*k.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,ee=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),te=q.space??" ",ne=[];for(let de=0;de<I.length;de++){const ie=I[de],oe=de===I.length-1;let ce=oe?W/ie.factor:Math.floor(W/ie.factor);if(W-=ce*ie.factor,oe){const ke=10**ee;ce=Math.round(ce*ke)/ke+0}const fe=oe?y(q.locale,J,ee,q.group!==!1):y(q.locale,0,0,q.group!==!1);ne.push(`${fe.format(ce)}${te}${ie.symbol}`)}const ae=ne.join(" ");return Z?`-${ae}`:ae}function j(R,k){const I=k||{},q=I.nullDisplay??"";if(L(R)||R==="")return q;const Z=typeof R=="number"?R:Number(R);if(!Number.isFinite(Z))return q;const W=n(I);if(!W)return String(Z);const J=r(I,W);if(J)return E(Z,W,J,I);const ee=typeof I.significantFigures=="number"&&I.significantFigures>0?I.significantFigures:0,te=ee?T(Z,ee):Z,ne=P(te,W,I.display),ae=o(te,W.base,ne);let de=typeof I.decimals=="number"?I.decimals:I.minDecimals??0,ie=typeof I.decimals=="number"?I.decimals:I.maxDecimals??Math.max(de,2);ee&&(de=C(ae,ee),ie=de);const oe=y(I.locale,de,ie,I.group!==!1).format(ae),ce=I.space??" ";return I.placement==="prefix"?`${ne.symbol}${I.space??""}${oe}`:`${oe}${ce}${ne.symbol}`}function A(R,k){const I=L(R)||Number.isNaN(R)?null:Number(R),q=L(k)||Number.isNaN(k)?null:Number(k);return I===null||Number.isNaN(I)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||I<q?-1:I>q?1:0}function $(R){const k=typeof R.decimals=="number"&&R.decimals>0?`.${"0".repeat(R.decimals)}`:"";return`${typeof R.decimals=="number"?`#,##0${k}`:"#,##0.##"}" ${R.symbol}"`}function D(R){const k={system:"data",...R||{}},I=n(k),q=I?I.base.symbol:String(k.unit||""),Z=Object.freeze({...k,unit:q}),W=Object.freeze({...Z,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Z.locale||"",Z]]),ee=te=>{const ne=te||"";let ae=J.get(ne);return ae||(ae=Object.freeze({...Z,locale:te||void 0}),J.set(ne,ae)),ae};return{base:"number",extends:"number",storage:"float64",unitConfig:Z,format:te=>j(te.value,te.locale?ee(te.locale):Z),parse:te=>v(te.text,te.locale?ee(te.locale):Z),compare:A,defaults:{filter:"number",editor:"unit",align:"end",total:k.total||"sum"},...k.totals?{totals:k.totals}:{},excel:k.excel||$({decimals:k.decimals,symbol:q}),toStorage:te=>typeof te=="number"?Number.isFinite(te)?te:null:typeof te=="string"?v(te,Z):L(te)?null:v(String(te),Z),toClipboard:te=>j(te,W),fromClipboard:te=>v(te,Z)}}const M=D}),xe("packages/core/src/columns/types/engineering.js",function(e,K){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return _}});const L=K("packages/core/src/internal/util.js").isNil,F=K("packages/core/src/columns/types/unit.js").createUnitType;function _(H){const U=2*Math.PI/H;return z=>{let S=0,O=0,b=0;for(const d of z||[]){if(L(d))continue;const s=Number(d);Number.isFinite(s)&&(S+=Math.cos(s*U),O+=Math.sin(s*U),b+=1)}return!b||Math.hypot(S,O)/b<1e-12?null:(Math.atan2(O,S)/U%H+H)%H}}function Q(H){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:_(H)}}}const G=Object.freeze({metres:F({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:F({system:"length",unit:"mm",maxDecimals:2}),kilometres:F({system:"length",unit:"km",maxDecimals:3}),grams:F({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:F({system:"mass",unit:"kg",maxDecimals:3}),tonnes:F({system:"mass",unit:"t",maxDecimals:3}),seconds:F({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:F({system:"duration",unit:"ms",maxDecimals:3}),hours:F({system:"duration",unit:"h",maxDecimals:2}),speed:F({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:F({system:"speed",unit:"km/h",maxDecimals:1}),mph:F({system:"speed",unit:"mph",maxDecimals:1}),knots:F({system:"speed",unit:"kn",maxDecimals:1}),acceleration:F({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:F({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:F({system:"area",unit:"ha",maxDecimals:4}),volume:F({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:F({system:"volume",unit:"m³",maxDecimals:3}),energy:F({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:F({system:"energy",unit:"kWh",maxDecimals:2}),power:F({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:F({system:"power",unit:"kW",maxDecimals:2}),force:F({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:F({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:F({system:"pressure",unit:"bar",maxDecimals:3}),psi:F({system:"pressure",unit:"psi",maxDecimals:1}),torque:F({system:"torque",unit:"N·m",maxDecimals:2}),density:F({system:"density",unit:"kg/m³",maxDecimals:2}),flow:F({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:F({system:"flow",unit:"L/min",maxDecimals:1}),radians:F({system:"angle",unit:"rad",maxDecimals:4,totals:Q(2*Math.PI)}),degrees:F({system:"angle",unit:"°",maxDecimals:2,totals:Q(360)}),rpm:F({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:F({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:F({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:F({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:F({system:"fraction",unit:"bp",maxDecimals:1}),molarity:F({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:F({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:F({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:F({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:F({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:F({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:F({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:F({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),xe("packages/core/src/columns/types/si.js",function(e,K){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/core/src/columns/types/unit.js"),L=X.defineUnit,B=X.registerUnitSystem,F=X.createUnitType,_=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Q=Object.freeze(["p","n","µ","m","","k","M","G"]);function G(O){const b=String(O.base),u=new Set([...O.prefixes||Q,""]),d=[];for(const s of _){if(!u.has(s.symbol))continue;const n=`${s.symbol}${b}`,t=[];if(O.name){t.push(`${s.name}${O.name}`,`${s.name}${O.name}s`);const r=s.name.slice(-1);if(r&&O.name.startsWith(r)){const o=`${s.name.slice(0,-1)}${O.name}`;t.push(o,`${o}s`)}}s.symbol==="µ"&&t.push(`u${b}`),s.factor===1&&O.aliases&&t.push(...O.aliases),d.push(L(n,s.factor,t))}for(const s of O.extra||[])d.push(s);return d}function H(O,b){const u=G(b);return B(O,u)}function U(O,b,u){return H(O,b),F({system:O,unit:b.base,display:"auto",maxDecimals:3,...u||{}})}const z=Object.freeze({voltage:U("voltage",{base:"V",name:"volt"}),current:U("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:U("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:U("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:U("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:U("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[L("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),L("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:U("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:U("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[L("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:U("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:U("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:U("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:U("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:U("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:U("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:U("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[L("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:U("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),S=U}),xe("packages/core/src/columns/types/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const L=K("packages/core/src/internal/util.js").isNil,B=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:d=>d+273.15,fromKelvin:d=>d-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:d=>(d+459.67)*(5/9),fromKelvin:d=>d*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:d=>d,fromKelvin:d=>d}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:d=>d*(5/9),fromKelvin:d=>d*(9/5)})});function F(d){if(L(d))return null;const s=String(d).trim();if(s==="")return null;for(const[t,r]of Object.entries(B))if(s===t||s===r.symbol)return{key:t,scale:r};const n=s.toLowerCase();for(const[t,r]of Object.entries(B))if(r.aliases.includes(n))return{key:t,scale:r};return null}function _(d,s,n){const t=F(s),r=F(n);return!t||!r||!Number.isFinite(Number(d))?null:t.key===r.key?Number(d):r.scale.fromKelvin(t.scale.toKelvin(Number(d)))}const Q=new Map;function G(d,s,n){const t=`${d||""}|${s}|${n}`;let r=Q.get(t);return r||(r=new Intl.NumberFormat(d||void 0,{minimumFractionDigits:s,maximumFractionDigits:n}),Q.set(t,r)),r}function H(d,s){const n=s||{},t=n.nullDisplay??"";if(L(d)||d==="")return t;const r=Number(d);if(!Number.isFinite(r))return t;const o=F(n.scale||"C");if(!o)return String(r);const f=F(n.display||n.scale||"C")||o,l=f.key===o.key?r:f.scale.fromKelvin(o.scale.toKelvin(r)),i=typeof n.decimals=="number"?n.decimals:null,g=i??n.minDecimals??0,c=i??n.maxDecimals??1;return`${G(n.locale,g,c).format(l)}${n.space??" "}${f.scale.symbol}`}const U=/^[+-]?[\d\s.,  ]*\d/;function z(d,s){const n=String(d).trim();if(n==="")return null;const t=new Intl.NumberFormat(s||void 0).formatToParts(1.1).find(l=>l.type==="decimal")?.value||".",r=t===","?".":",",o=n.split(r).join("").split(/[\s  ]/).join("").replace(t,"."),f=Number(o);return Number.isFinite(f)?f:null}function S(d,s){if(L(d))return null;const n=s||{},t=F(n.scale||"C");if(!t)return null;if(typeof d=="number")return Number.isFinite(d)?d:null;let r=String(d).trim();if(r==="")return null;let o=!1;r.startsWith("(")&&r.endsWith(")")&&(o=!0,r=r.slice(1,-1).trim());const f=U.exec(r);if(!f)return null;const l=z(f[0],n.locale);if(l===null)return null;const i=r.slice(f[0].length).trim();if(i==="")return o?-l:l;const g=F(i);if(!g)return null;const c=g.key===t.key?l:t.scale.fromKelvin(g.scale.toKelvin(l));return o?-c:c}function O(d){const s=Object.freeze({scale:"C",...d||{}}),t=(F(s.scale)||F("C")).scale.symbol,r=Object.freeze({...s,display:s.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),o=new Map([[s.locale||"",s]]),f=l=>{const i=l||"";let g=o.get(i);return g||(g=Object.freeze({...s,locale:l||void 0}),o.set(i,g)),g};return{base:"number",extends:"number",storage:"float64",temperatureConfig:s,format:l=>H(l.value,l.locale?f(l.locale):s),parse:l=>S(l.text,l.locale?f(l.locale):s),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:s.excel||`#,##0${typeof s.decimals=="number"&&s.decimals>0?`.${"0".repeat(s.decimals)}`:".#"}" ${t}"`,toStorage:l=>typeof l=="number"?Number.isFinite(l)?l:null:typeof l=="string"?S(l,s):L(l)?null:S(String(l),s),toClipboard:l=>H(l,r),fromClipboard:l=>S(l,s)}}const b=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),u=O}),xe("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const X=K("packages/core/src/internal/util.js"),L=X.isNil,B=X.warnOnce,F=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),_=Object.freeze({2:1,8:3,16:4}),Q=Object.freeze({2:"0b",8:"0o",16:"0x"}),G=Object.freeze({2:4,8:3,16:2}),H=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),U=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),z=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),S=/[\s\u00a0\u202f_,']/g,O=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,b=Object.freeze([8,16,32,53]),u=new WeakSet,d=new WeakMap,s=new Map,n=new WeakMap,t=new WeakMap,r=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function o(j){if(j==null)return 16;const A=typeof j=="string"?j.toLowerCase():j,$=F[A];return $||(B(`radix:base:${String(j)}`,`unsupported radix ${String(j)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function f(j,A){return Math.ceil(j/_[A])}function l(j,A){if(!j)return A?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!A)return{min:0,max:2**j-1};const $=2**(j-1);return{min:-$,max:$-1}}function i(j){return U[j]||"hexadecimal"}function g(j){if(typeof j=="string"){const A=r[j];return A||B(`radix:preset:${j}`,`unknown radix preset "${j}"; known presets are ${Object.keys(r).join(", ")}`),{...A||{}}}if(j&&typeof j.preset=="string"){const A=r[j.preset];return A||B(`radix:preset:${j.preset}`,`unknown radix preset "${j.preset}"; known presets are ${Object.keys(r).join(", ")}`),{...A||{},...j}}return j||{}}function c(j){const A=g(j),$=o(A.radix),D=_[$];let M=null;if(A.bitWidth!==void 0&&A.bitWidth!==null&&A.bitWidth!==!1){const te=Number(A.bitWidth);b.includes(te)?M=te:B(`radix:width:${String(A.bitWidth)}`,`unsupported bitWidth ${String(A.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let R=A.signed!==!1;!R&&M===null&&(B("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),M=32);const k=A.prefix===void 0||A.prefix===!0?Q[$]:A.prefix===!1?"":String(A.prefix);let I=0;A.pad===!0?I=M?f(M,$):0:typeof A.pad=="number"&&A.pad>0&&(I=Math.floor(A.pad));let q=0;A.group===!0?q=G[$]:typeof A.group=="number"&&A.group>0&&(q=Math.floor(A.group));const Z=l(M,R),W=typeof A.min=="number"?Math.max(Z.min,A.min):Z.min,J=typeof A.max=="number"?Math.min(Z.max,A.max):Z.max,ee=Object.freeze({radix:$,bits:D,prefix:k,uppercase:A.uppercase!==!1,pad:I,group:q,groupSeparator:typeof A.groupSeparator=="string"?A.groupSeparator:" ",bitWidth:M,signed:R,min:W,max:J<W?W:J,nullDisplay:typeof A.nullDisplay=="string"?A.nullDisplay:"",name:i($)});return u.add(ee),ee}function h(j){if(j&&u.has(j))return j;if(typeof j=="string"){let A=s.get(j);return A||(A=c(j),s.set(j,A)),A}if(j&&typeof j=="object"){let A=d.get(j);return A||(A=c(j),d.set(j,A)),A}return h("hex")}function a(j){return j<0?-Math.round(-j):Math.round(j)}function m(j,A,$){if(A<=0||j.length<=A)return j;const D=j.length%A||A,M=[j.slice(0,D)];for(let R=D;R<j.length;R+=A)M.push(j.slice(R,R+A));return M.join($)}function w(j){const A=h(j),{radix:$,prefix:D,uppercase:M,pad:R,group:k,groupSeparator:I,signed:q,bitWidth:Z,nullDisplay:W}=A,J=Z?2**Z:0,ee=te=>{if(L(te)||te==="")return W;const ne=typeof te=="number"?te:Number(te);if(!Number.isFinite(ne))return W;const ae=a(ne);let de="",ie=ae;ae<0&&(q?(de="-",ie=-ae):ie=(ae%J+J)%J);let oe=ie.toString($);return oe=M?oe.toUpperCase():oe.toLowerCase(),R>0&&oe.length<R&&(oe=oe.padStart(R,"0")),k>0&&(oe=m(oe,k,I)),de+D+oe};return ee.options=A,ee}function v(j,A){const $=h(A);let D=n.get($);return D||(D=w($),n.set($,D)),D(j)}function p(j){const A=h(j),{radix:$,groupSeparator:D,signed:M,min:R,max:k}=A,I=H[$],q=Z=>{if(L(Z))return{ok:!0,value:null,reason:"blank"};let W=String(Z);if(D&&D!==""&&(W=W.split(D).join("")),W=W.replace(S,""),W==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((W[0]==="-"||W[0]==="+")&&(J=W[0]==="-",W=W.slice(1)),W==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[ne,ae]of z){const de=ne.exec(W);if(!de)continue;const ie=W.slice(de[0].length);if(ie==="")break;if(!H[ae].test(ie))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ie,ae);break}if(ee===null)if(I.test(W))ee=parseInt(W,$);else if(O.test(W))ee=Number(W);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const te=a(J?-ee:ee);return!M&&te<0?{ok:!1,value:te,reason:"negative"}:te<R||te>k?{ok:!1,value:te,reason:"range"}:{ok:!0,value:te,reason:"ok"}};return q.options=A,q}function y(j,A){const $=h(A);let D=t.get($);return D||(D=p($),t.set($,D)),D(j)}function C(j,A){const $=y(j,A);return $.ok?$.value:null}function T(j,A){const $=L(j)||Number.isNaN(j)?null:Number(j),D=L(A)||Number.isNaN(A)?null:Number(A);return $===null?D===null?0:1:D===null||$<D?-1:$>D?1:0}function P(j){const A=j.min>=-2147483648&&j.max<=2147483647;return j.bitWidth&&A?"int32":"float64"}function x(j){const A=c(j),$=w(A),D=p(A);return{base:"number",extends:"number",storage:P(A),matches:null,format:M=>$(M.value),parse:M=>{const R=D(M.text);return R.ok?R.value:null},compare:T,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:M=>$(M),fromClipboard:M=>{const R=D(M);return R.ok?R.value:null},radix:A,formatValue:$,parseText:D}}const E=x}),xe("packages/core/src/columns/types/aggregable.js",function(e,K){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return _}});const L=K("packages/core/src/internal/util.js").isNil;function B(z){const S=[];for(const O of z||[]){if(L(O))continue;const b=Number(O);Number.isFinite(b)&&S.push(b)}return S}function F(z){return S=>{const O=B(S);if(!O.length)return null;let b=0;for(const u of O)b+=10**(u/z);return z*Math.log10(b)}}function _(z){return S=>{const O=B(S);if(!O.length)return null;let b=0;for(const u of O)b+=10**(u/z);return z*Math.log10(b/O.length)}}function Q(z,S){const O=S&&S.column,u=(O&&O.typeOptions||{}).weight,d=S&&S.valueAt;if(!u||typeof d!="function")return null;let s=0,n=0;for(let t=0;t<z.length;t++){if(L(z[t]))continue;const r=Number(z[t]);if(!Number.isFinite(r))continue;const o=d(u,t);if(L(o))continue;const f=Number(o);!Number.isFinite(f)||f<=0||(s+=r*f,n+=f)}return n===0?null:s/n}function G(z={}){const S=z.factor===20?20:10,O=typeof z.suffix=="string"?z.suffix:"",b=Number.isInteger(z.decimals)?z.decimals:1;return{base:"number",storage:"float64",name:z.name||"logarithmic",format:u=>{const d=u&&u.value;return L(d)||!Number.isFinite(Number(d))?"":`${Number(d).toFixed(b)}${O}`},parse:u=>{const d=String((u&&u.text)??"").replace(O,"").trim();if(!d)return null;const s=Number(d);return Number.isFinite(s)?s:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:F(S),avg:_(S)}}}}function H(z={}){const S=Number.isInteger(z.decimals)?z.decimals:1,O=z.percent===!0;return{base:"number",storage:"float64",name:z.name||"ratio",format:b=>{const u=b&&b.value;return L(u)||!Number.isFinite(Number(u))?"":O?`${Number(u).toFixed(S)}%`:Number(u).toFixed(S)},parse:b=>{const u=String((b&&b.text)??"").replace("%","").trim();if(!u)return null;const d=Number(u);return Number.isFinite(d)?d:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Q}}}}const U=Object.freeze({decibel:G({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:G({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:H({name:"ratio"}),percentRate:H({name:"percentRate",percent:!0})})}),xe("packages/core/src/columns/types/currency.js",function(e,K){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const L=K("packages/core/src/internal/util.js").isNil,B="⚠ no rate";function F(l){if(L(l))return null;const i=String(l).trim().toUpperCase();return i===""?null:i}function _(l){if(L(l))return null;if(typeof l=="object"&&!Array.isArray(l)){const i=Number(l.amount),g=F(l.code);return!g||!Number.isFinite(i)?null:{amount:i,code:g}}if(Array.isArray(l)&&l.length===2){const i=Number(l[0]),g=F(l[1]);return!g||!Number.isFinite(i)?null:{amount:i,code:g}}return null}const Q=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),G=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),H=/[+-]?[\d\s., ]*\d/;function U(l,i){const g=String(l).trim();if(g==="")return null;const c=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",h=c===","?".":",",a=g.split(h).join("").split(/[\s ]/).join("").replace(c,"."),m=Number(a);return Number.isFinite(m)?m:null}function z(l,i){const g=i||{},c=F(g.code);if(L(l))return null;const h=_(l);if(h)return h;if(typeof l=="number")return Number.isFinite(l)&&c?{amount:l,code:c}:null;let a=String(l).trim();if(a==="")return null;let m=!1;a.startsWith("(")&&a.endsWith(")")&&(m=!0,a=a.slice(1,-1).trim());let w=null;for(const[P,x]of Object.entries(Q)){if(a.startsWith(P)){w=x,a=a.slice(P.length).trim();break}if(a.endsWith(P)){w=x,a=a.slice(0,-P.length).trim();break}}const v=H.exec(a);if(!v)return null;const p=U(v[0],g.locale);if(p===null)return null;const y=(a.slice(0,v.index)+" "+a.slice(v.index+v[0].length)).trim();!w&&y!==""&&(w=F(y));const C=w||c;return C?{amount:m?-p:p,code:C}:null}function S(l,i){if(typeof l=="function")return(g,c)=>{if(g===c)return 1;const h=l(g,c);return typeof h=="number"&&Number.isFinite(h)&&h>0?h:null};if(l&&typeof l=="object"){const g=l;return(c,h)=>{if(c===h)return 1;const a=Number(g[c]),m=Number(g[h]);return!Number.isFinite(a)||!Number.isFinite(m)||a<=0||m<=0?null:m/a}}return(g,c)=>g===c?1:null}function O(l,i,g){if(!l)return null;if(l.code===i)return l.amount;const c=g(l.code,i);return c===null?null:l.amount*c}const b=new Map;function u(l,i,g){const c=`${l||""}|${i}|${g??""}`;let h=b.get(c);if(!h){const a={style:"currency",currency:i};typeof g=="number"&&(a.minimumFractionDigits=g,a.maximumFractionDigits=g);try{h={fmt:new Intl.NumberFormat(l||void 0,a),currency:!0}}catch{h={fmt:new Intl.NumberFormat(l||void 0,typeof g=="number"?{minimumFractionDigits:g,maximumFractionDigits:g}:{}),currency:!1}}b.set(c,h)}return h}function d(l,i){const g=i||{},c=g.nullDisplay??"",h=_(l);if(!h)return c;const a=F(g.display)||h.code;let m=h.amount,w=h.code;if(a!==h.code){const y=g.rateFn||S(g.rates,g.rateBase),C=O(h,a,y);if(C===null)return`${g.missingRate??B} ${h.code}→${a}`;m=C,w=a}const{fmt:v,currency:p}=u(g.locale,w,g.decimals);return p?v.format(m):`${v.format(m)} ${w}`}function s(l){const i=_(l);return i?`${i.amount} ${i.code}`:""}function n(l){const i=l||{},g=F(i.display),c=i.rateFn||S(i.rates,i.rateBase);return(h,a)=>{const m=_(h),w=_(a);if(!m&&!w)return 0;if(!m)return 1;if(!w)return-1;if(g){const v=O(m,g,c),p=O(w,g,c);if(v!==null&&p!==null)return v===p?0:v<p?-1:1}return m.code===w.code?m.amount===w.amount?0:m.amount<w.amount?-1:1:m.code<w.code?-1:1}}function t(l){const i=l||{},g=(h,a)=>{const m=[];for(const C of h||[]){const T=_(C);T&&m.push(T)}if(!m.length)return null;if(new Set(m.map(C=>C.code)).size===1){const C=m[0].code;return{amount:a(m.map(T=>T.amount)),code:C}}const v=F(i.display);if(!v)return`${i.missingRate??B}: mixed currencies, no display currency set`;const p=i.rateFn||S(i.rates,i.rateBase),y=[];for(const C of m){const T=O(C,v,p);if(T===null)return`${i.missingRate??B}: ${C.code}→${v}`;y.push(T)}return{amount:a(y),code:v}},c=h=>h.reduce((a,m)=>a+m,0);return{sum:h=>g(h,c),avg:h=>g(h,a=>c(a)/a.length),min:h=>g(h,a=>Math.min(...a)),max:h=>g(h,a=>Math.max(...a))}}function r(l){const i=Object.freeze({code:"USD",...l||{}}),g=S(i.rates,i.rateBase),c=Object.freeze({...i,rateFn:g}),h=t(c),a=n(c),m=new Map([[i.locale||"",c]]),w=y=>{const C=y||"";let T=m.get(C);return T||(T=Object.freeze({...c,locale:y||void 0}),m.set(C,T)),T},v=G[F(i.display||i.code)]||"",p=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:c,format:y=>d(y.value,y.locale?w(y.locale):c),parse:y=>z(y.text,y.locale?w(y.locale):c),compare:a,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:h},excel:i.excel||(v?`"${v}"#,##0${p}`:`#,##0${p}`),toStorage:y=>{const C=_(y);return C||(typeof y=="string"||typeof y=="number"?z(y,c):null)},toClipboard:y=>s(y),fromClipboard:y=>z(y,c)}}const o=Object.freeze({currency:r({code:"USD"}),usd:r({code:"USD"}),eur:r({code:"EUR"}),gbp:r({code:"GBP"}),jpy:r({code:"JPY",decimals:0})}),f=r}),xe("packages/core/src/columns/types/index.js",function(e,K){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return P}});const X=K("packages/core/src/columns/types/temporal.js"),L=X.TEMPORAL_TYPES,B=K("packages/core/src/columns/types/network.js"),F=B.NETWORK_TYPES,_=K("packages/core/src/columns/types/structured.js"),Q=_.STRUCTURED_TYPES,G=K("packages/core/src/columns/types/unit.js"),H=G.createUnitType,U=G.UNIT_SYSTEMS,z=G.parseUnit,S=G.formatUnit,O=G.registerUnitSystem,b=G.unitSystemNames,u=G.unitsOf,d=G.defineUnit,s=K("packages/core/src/columns/types/engineering.js"),n=s.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),r=t.SI_TYPES,o=t.createSiType,f=t.createSiSystem,l=t.siUnits,i=t.SI_PREFIXES,g=K("packages/core/src/columns/types/temperature.js"),c=g.TEMPERATURE_TYPES,h=g.createTemperatureType,a=g.convertTemperature,m=g.formatTemperature,w=g.parseTemperature,v=g.TEMPERATURE_SCALES,p=K("packages/core/src/columns/types/radix.js"),y=p.createRadixType,C=p.RADIX_PRESETS,T=p.parseRadix,P=p.formatRadix,x=K("packages/core/src/columns/types/aggregable.js"),E=x.AGGREGABLE_TYPES,j=K("packages/core/src/columns/types/currency.js"),A=j.CURRENCY_TYPES,$=j.createCurrencyType,D=j.parseMoney,M=j.formatMoney,R=j.convertMoney,k=j.toMoney,I=j.rateFunction,q=j.moneyComparator,Z=j.normaliseCode,W=j.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return G.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return s.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return s.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return g.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return g.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return g.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return g.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return g.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return g.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return j.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return j.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return j.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return j.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return j.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return j.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return j.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return j.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return j.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return j.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return X.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return B.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return _.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return x.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return x.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return x.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return X.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return X.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return X.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return X.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return X.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return X.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return B.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return B.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return B.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return B.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return B.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return B.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return B.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return B.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return B.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return B.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return _.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _.summariseJson}});const J=Object.freeze({...L,...F,...Q,...E,hex:y(C.hex),hex8:y(C.hex8),hex16:y(C.hex16),hex32:y(C.hex32),binary:y(C.binary),binary8:y(C.binary8),octal:y(C.octal),bytes:H({system:"data",unit:"B",display:"auto"}),megabytes:H({system:"data",unit:"MB"}),gigabytes:H({system:"data",unit:"GB"}),bitrate:H({system:"bitrate",unit:"Mbps"}),gigabits:H({system:"bitrate",unit:"Gbps"}),...n,...r,...c,...A});{const ee=new Set;for(const te of[L,F,Q,E,n,r,c,A])for(const ne of Object.keys(te)){if(ee.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);ee.add(ne)}}}),xe("packages/core/src/compute/handle.js",function(e,K){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare,F=X.warnOnce;function _(r){const o=new Uint32Array(r);for(let f=0;f<r;f++)o[f]=f;return o}function Q(r,o){if(o&&typeof o.count=="number")return o.count;if(!r)return 0;if(typeof r.count=="number")return r.count;if(typeof r.length=="number")return r.length;const f=r.values;return r.kind==="multi"&&r.offsets?Math.max(0,r.offsets.length-1):f?r.kind==="bitset"?typeof f.size=="number"?f.size:r.presence&&typeof r.presence.size=="number"?r.presence.size:(F(`count:${r.id}`,`column "${r.id}" is bitset-backed with no declared row count; assuming ${f.length*8}`),f.length*8):f.length:r.presence&&typeof r.presence.size=="number"?r.presence.size:0}const G=new WeakMap;function H(r){const o=r.constructor;if(!o)return"unknown";const f=G.get(o);if(f)return f;let l="unknown";try{let i=null;typeof o.from=="function"?i=o.from([!1,!0]):(i=new o(8),i.set(1));const g=i&&i.words;g&&g.length&&(g[0]===2?l="lsb":g[0]===64&&(l="msb"))}catch{l="unknown"}return G.set(o,l),l}function U(r){if(!r)return()=>0;const o=r instanceof Uint8Array?r:r.words;if(o instanceof Uint8Array){const f=r instanceof Uint8Array?"lsb":H(r);if(f==="lsb")return l=>o[l>>>3]>>>(l&7)&1;if(f==="msb")return l=>o[l>>>3]>>>7-(l&7)&1}return typeof r.get=="function"?f=>r.get(f)?1:0:()=>0}function z(r){return!r||!r.presence?null:U(r.presence)}function S(r){return r?typeof r.size=="number"?r.size:typeof r.values=="function"?r.values().length:0:0}function O(r,o){return r?typeof r.valueOf=="function"?r.valueOf(o):typeof r.values=="function"?r.values()[o]:null:null}function b(r,o){const f=r.offsets,l=r.values;if(!f||!l)return[];const i=f[o],g=f[o+1];if(!(g>i))return[];const c=r.dict,h=new Array(g-i);for(let a=i;a<g;a++)h[a-i]=c?O(c,l[a]):l[a];return h}function u(r){if(!r)return()=>{};const o=r.values,f=z(r),l=r.kind;if(l==="dictionary"){const i=r.dict;return f?g=>f(g)?O(i,o[g]):null:g=>O(i,o[g])}if(l==="bitset"){const i=U(o);return f?g=>f(g)?i(g)===1:null:g=>i(g)===1}if(l==="multi")return f?i=>f(i)?b(r,i):null:i=>b(r,i);if(!o&&typeof r.get=="function"){const i=r.get.bind(r);return g=>{const c=i(g);return c===void 0?null:c}}return f?i=>{if(!f(i))return null;const g=o[i];return g===void 0?null:g}:i=>{const g=o[i];return g===void 0?null:g}}function d(r,o){if(r<o)return-1;if(r>o)return 1;if(r===o){const i=Object.is(r,-0),g=Object.is(o,-0);return i===g?0:i?-1:1}const f=Number.isNaN(r),l=Number.isNaN(o);return f&&l?0:f?1:-1}function s(r){const o=L(r);return(f,l)=>{if(f===l)return 0;const i=typeof f,g=typeof l;if(i==="string"&&g==="string")return o.compare(f,l);if(i==="number"&&g==="number")return d(f,l);if(i==="boolean"&&g==="boolean")return f===l?0:f?1:-1;if(f instanceof Date||l instanceof Date){const c=f instanceof Date?f.getTime():Number(f),h=l instanceof Date?l.getTime():Number(l);return d(c,h)}return B(f,l)}}function n(r,o){if(r&&typeof r.ranks=="function")return r.ranks(o);const f=r&&typeof r.values=="function"?r.values():[],l=f.length,i=s(o),g=new Array(l);for(let h=0;h<l;h++)g[h]=h;g.sort((h,a)=>i(f[h],f[a])||h-a);const c=new Uint32Array(l);for(let h=0;h<l;h++)c[g[h]]=h;return c}function t(r){return r==null||typeof r=="number"&&Number.isNaN(r)}}),xe("packages/core/src/compute/filter.js",function(e,K){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return Z}});const X=K("packages/core/src/internal/util.js"),L=X.isBlank,B=X.toArray,F=X.warnOnce,Q=K("packages/core/src/format/date.js").toIsoDate,G=K("packages/core/src/compute/handle.js"),H=G.bitReader,U=G.dictSize,z=G.dictValue,S=G.presenceReader,O=G.valueComparator,b=G.valueReader,u=/^\d{4}-\d{2}-\d{2}$/,d="\0null\0";function s(W,J){const ee=W&&W.pool;if(ee){const te=ee.mask||ee.acquireMask||ee.acquire||ee.take;if(typeof te=="function"){const ne=te.call(ee,J);if(ne&&ne.length>=J)return ne}}return new Uint8Array(J)}function n(W,J){const ee=W&&W.pool;if(!ee||!J)return;const te=ee.release||ee.releaseMask||ee.free||ee.recycle;typeof te=="function"&&te.call(ee,J)}function t(W,J,ee){return W.fill(ee,0,J),W}function r(W){return W==null||typeof W=="number"&&Number.isNaN(W)}function o(W,J){if(W==null)return W;if(J==="number")return typeof W=="number"?W:Number(W);if(J==="date"||J==="dateString"){const ee=Q(W);return ee===null?f(W):ee}return J==="boolean"?typeof W=="boolean"?W:W==="true"||W===1?!0:W==="false"||W===0?!1:!!W:W}function f(W){return W instanceof Date?W.getTime():typeof W=="number"?W:Date.parse(String(W))}function l(W){return typeof W=="number"?W:W instanceof Date?W.getTime():W==null||W===""?NaN:Number(W)}function i(W,J){const ee=typeof W=="string"?W:String(W);return J?ee:ee.toLowerCase()}function g(W,J){return W==null?d:typeof W=="string"?J?W:W.toLowerCase():W instanceof Date?W.getTime():W}function c(W,J,ee){const te=new Set;for(const ne of B(W)){const ae=o(ne,ee);te.add(g(ae,J)),typeof ae=="string"&&ae!==""&&Number.isFinite(Number(ae))?te.add(Number(ae)):typeof ae=="number"&&Number.isFinite(ae)&&te.add(g(String(ae),J))}return te}function h(W,J,ee){if(W==null||J===null||J===void 0)return W==null&&J==null;const te=typeof W,ne=typeof J;return te==="string"&&ne==="string"?ee?W===J:W.toLowerCase()===J.toLowerCase():W instanceof Date||J instanceof Date?f(W)===f(J):te==="number"&&ne==="number"?W===J||Number.isNaN(W)&&Number.isNaN(J):te==="number"&&ne==="string"?W===Number(J):te==="string"&&ne==="number"?Number(W)===J:te==="boolean"||ne==="boolean"?W===J:Array.isArray(W)&&Array.isArray(J)?W.length===J.length&&W.every((ae,de)=>h(ae,J[de],ee)):W===J}function a(W,J){try{if(W instanceof RegExp){const ee=W.flags.replace(/[gy]/g,"");return new RegExp(W.source,J||ee.includes("i")?ee:`${ee}i`)}return new RegExp(String(W),J?"":"i")}catch(ee){return F(`regex:${String(W)}`,`filter operator "matches" received an invalid pattern: ${String(W)}`,ee),null}}function m(W,J){const ee=w(W,J),te=W&&W.type;return te!=="date"&&te!=="dateString"?ee:ne=>ee(typeof ne=="string"&&u.test(ne)?ne:Q(ne)??ne)}function w(W,J){const ee=W&&W.op,te=!!(W&&W.caseSensitive),ne=W&&W.type,ae=O(J),de=ie=>oe=>!ie(oe);switch(ee){case"eq":{const ie=o(W.value,ne);return oe=>h(oe,ie,te)}case"ne":{const ie=o(W.value,ne);return oe=>!h(oe,ie,te)}case"lt":case"lte":case"gt":case"gte":{const ie=o(W.value,ne);if(r(ie))return()=>!1;const oe=ee==="lt"?-1:ee==="lte"?0:ee==="gt"?1:2;return ce=>{if(r(ce))return!1;const fe=ae(ce,ie);return oe===-1?fe<0:oe===0?fe<=0:oe===1?fe>0:fe>=0}}case"between":case"notBetween":{const ie=B(W.value),oe=o(ie[0],ne),ce=o(ie[1],ne),fe=W.bounds||"[]",ke=fe.charAt(0)!=="(",Re=fe.charAt(1)!==")";if(r(oe)||r(ce))return ee==="between"?()=>!1:()=>!0;const Ee=Fe=>{if(r(Fe))return!1;const ye=ae(Fe,oe),he=ae(Fe,ce);return(ke?ye>=0:ye>0)&&(Re?he<=0:he<0)};return ee==="between"?Ee:de(Ee)}case"in":case"notIn":{const ie=c(W.value,te,ne),oe=ce=>ie.has(g(ce,te));return ee==="in"?oe:de(oe)}case"contains":case"notContains":{const ie=i(o(W.value,ne),te),oe=ce=>ce==null?!1:i(ce,te).includes(ie);return ee==="contains"?oe:de(oe)}case"startsWith":{const ie=i(o(W.value,ne),te);return oe=>oe==null?!1:i(oe,te).startsWith(ie)}case"endsWith":{const ie=i(o(W.value,ne),te);return oe=>oe==null?!1:i(oe,te).endsWith(ie)}case"matches":{const ie=a(W.value,te);return ie?oe=>oe==null?!1:ie.test(String(oe)):()=>!1}case"blank":return ie=>L(ie)||Array.isArray(ie)&&ie.length===0;case"notBlank":return ie=>!(L(ie)||Array.isArray(ie)&&ie.length===0);case"containsAny":case"containsNone":{const ie=c(W.value,te,ne),oe=ce=>{const fe=ce==null?[]:B(ce);for(let ke=0;ke<fe.length;ke++)if(ie.has(g(fe[ke],te)))return!0;return!1};return ee==="containsAny"?oe:de(oe)}case"containsAll":{const ie=B(W.value).map(oe=>g(o(oe,ne),te));return oe=>{const ce=oe==null?[]:B(oe);if(ie.length===0)return!0;const fe=new Set(ce.map(ke=>g(ke,te)));for(let ke=0;ke<ie.length;ke++)if(!fe.has(ie[ke]))return!1;return!0}}default:{const ie=Z(ee);return ie?ie.compile(W.value):(F(`op:${String(ee)}`,`unknown filter operator "${String(ee)}"; the condition is refused rather than matching every row`),()=>!1)}}}function v(W,J,ee){return m(J,ee)(W)}const p=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),y=new Set(["containsAny","containsAll","containsNone"]);function C(W,J,ee){const te=W&&W.op,ne=p[te]||te,ae=m({...W,op:ne,type:J.type},ee),de=J.items,ie=oe=>{const ce=de(oe);if(!ce)return!1;for(let fe=0;fe<ce.length;fe++)if(ae(ce[fe]))return!0;return!1};return p[te]?oe=>!ie(oe):ie}function T(W,J,ee,te){const ne=S(W);if(ne){const ie=J?1:0;for(let oe=0;oe<te;oe++)ee[oe]=ne(oe)===ie?1:0;return ee}const ae=W.kind;if(ae==="float64"||ae==="int32"||ae==="bitset")return t(ee,te,J?1:0);const de=b(W);for(let ie=0;ie<te;ie++){const oe=de(ie),ce=L(oe)||Array.isArray(oe)&&oe.length===0;ee[ie]=ce===J?0:1}return ee}function P(W,J,ee,te){const ne=W.dict,ae=U(ne),de=new Uint8Array(ae);for(let fe=0;fe<ae;fe++)de[fe]=J(z(ne,fe))?1:0;const ie=W.values,oe=S(W);if(!oe){for(let fe=0;fe<te;fe++)ee[fe]=de[ie[fe]];return ee}const ce=J(null)?1:0;for(let fe=0;fe<te;fe++)ee[fe]=oe(fe)===1?de[ie[fe]]:ce;return ee}function x(W,J,ee,te){const ne=H(W.values),ae=J(!0)?1:0,de=J(!1)?1:0,ie=S(W);if(!ie){for(let ce=0;ce<te;ce++)ee[ce]=ne(ce)===1?ae:de;return ee}const oe=J(null)?1:0;for(let ce=0;ce<te;ce++)ee[ce]=ie(ce)===0?oe:ne(ce)===1?ae:de;return ee}function E(W,J,ee,te,ne){const ae=W.values,de=J.type,ie=J.op;let oe=!0;switch(ie){case"eq":case"ne":{const fe=l(o(J.value,de)),ke=typeof J.value=="number"&&Number.isNaN(J.value),Re=ie==="ne"?1:0;if(ke)for(let Ee=0;Ee<ne;Ee++)te[Ee]=(Number.isNaN(ae[Ee])?1:0)^Re;else for(let Ee=0;Ee<ne;Ee++)te[Ee]=(ae[Ee]===fe?1:0)^Re;break}case"lt":{const fe=l(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]<fe?1:0;break}case"lte":{const fe=l(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]<=fe?1:0;break}case"gt":{const fe=l(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]>fe?1:0;break}case"gte":{const fe=l(o(J.value,de));for(let ke=0;ke<ne;ke++)te[ke]=ae[ke]>=fe?1:0;break}case"between":case"notBetween":{const fe=B(J.value),ke=l(o(fe[0],de)),Re=l(o(fe[1],de)),Ee=J.bounds||"[]",Fe=Ee.charAt(0)!=="(",ye=Ee.charAt(1)!==")",he=ie==="notBetween"?1:0;if(Fe&&ye)for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>=ke&ae[Se]<=Re?1:0)^he;else if(Fe)for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>=ke&ae[Se]<Re?1:0)^he;else if(ye)for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>ke&ae[Se]<=Re?1:0)^he;else for(let Se=0;Se<ne;Se++)te[Se]=(ae[Se]>ke&ae[Se]<Re?1:0)^he;break}case"in":case"notIn":{const fe=new Set;for(const Re of B(J.value)){const Ee=l(o(Re,de));Number.isNaN(Ee)||fe.add(Ee)}const ke=ie==="notIn"?1:0;for(let Re=0;Re<ne;Re++)te[Re]=(fe.has(ae[Re])?1:0)^ke;break}default:oe=!1;break}if(!oe)return!1;const ce=S(W);if(ce){const fe=ee(null)?1:0;for(let ke=0;ke<ne;ke++)ce(ke)===0&&(te[ke]=fe)}return!0}function j(W,J,ee,te){const ne=b(W);for(let ae=0;ae<te;ae++)ee[ae]=J(ne(ae))?1:0;return ee}function A(W,J,ee){const te=J.count|0,ne=ee||s(J,te);if(!W)return t(ne,te,1);const ae=typeof J.handle=="function"?J.handle(W.col):void 0,de=typeof J.custom=="function"?J.custom:null;if(!ae){if(de){for(let fe=0;fe<te;fe++)ne[fe]=de(W,fe)?1:0;return ne}return F(`filter:col:${String(W.col)}`,`filter references unknown column "${String(W.col)}"; the condition is refused rather than matching every row`),t(ne,te,0)}const ie=W.op;if(ie==="blank"||ie==="notBlank")return T(ae,ie==="notBlank",ne,te);const oe=typeof J.itemwise=="function"?J.itemwise(W.col):null;if(oe&&!Z(ie)&&!y.has(ie))return j(ae,C(W,oe,J.locale),ne,te);const ce=m(W,J.locale);switch(ae.kind){case"dictionary":return P(ae,ce,ne,te);case"bitset":return x(ae,ce,ne,te);case"float64":case"int32":return E(ae,W,ce,ne,te)?ne:j(ae,ce,ne,te);default:return j(ae,ce,ne,te)}}function $(W,J,ee){if(!W)return t(s(J,ee),ee,1);if(Array.isArray(W.conditions)){const te=W.conditions.filter(de=>de!=null),ne=W.op==="or"?"or":W.op==="not"?"not":"and";if(te.length===0)return t(s(J,ee),ee,1);const ae=$(te[0],J,ee);for(let de=1;de<te.length;de++){const ie=$(te[de],J,ee);if(ne==="or")for(let oe=0;oe<ee;oe++)ae[oe]|=ie[oe];else for(let oe=0;oe<ee;oe++)ae[oe]&=ie[oe];n(J,ie)}if(ne==="not")for(let de=0;de<ee;de++)ae[de]^=1;return ae}return A(W,J,s(J,ee))}function D(W,J){return $(W,J,J.count|0)}function M(W,J){if(!W||!J)return W||null;const ee=W;if(Array.isArray(ee.conditions)){if((ee.op==="or"?"or":ee.op==="not"?"not":"and")!=="and")return R(ee,J)?null:W;const ne=[];for(const ae of ee.conditions){const de=M(ae,J);de&&ne.push(de)}return ne.length?{...ee,op:"and",conditions:ne}:null}return ee.col===J?null:W}function R(W,J){if(!W||typeof W!="object")return!1;const ee=W;if(ee.col===J)return!0;if(Array.isArray(ee.conditions)){for(const te of ee.conditions)if(R(te,J))return!0}return!1}function k(W,J,ee){if(ee&&ee.length>=J){let de=0;for(let ie=0;ie<J;ie++)W[ie]&&(ee[de++]=ie);return ee.subarray(0,de)}let te=0;for(let de=0;de<J;de++)te+=W[de]?1:0;const ne=new Uint32Array(te);let ae=0;for(let de=0;de<J;de++)W[de]&&(ne[ae++]=de);return ne}const I=new Map;function q(W){if(!(!W||typeof W!="object"))for(const[J,ee]of Object.entries(W))ee&&typeof ee.compile=="function"&&I.set(J,ee)}function Z(W){return typeof W=="string"?I.get(W):void 0}}),xe("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return A}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare,F=X.isNil,_=X.isObject,Q=X.isFunction,G=X.fail,H=X.titleCase,U=K("packages/core/src/format/date.js"),z=U.toDate,S=U.toIsoDate,O=U.compareIso,u=K("packages/core/src/format/boolean.js").toTriState,s=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,n=K("packages/core/src/formula/index.js"),t=n.evaluateFormula,r=n.looksLikeFormula,f=K("packages/core/src/compute/filter.js").declareOperators,l=/^\d{4}-\d{2}-\d{2}$/;function i($){return $.getHours()===0&&$.getMinutes()===0&&$.getSeconds()===0&&$.getMilliseconds()===0}const g=new Map;function c($){const D=$||"",M=g.get(D);if(M)return M;const R={group:",",decimal:"."};try{for(const k of new Intl.NumberFormat($||void 0).formatToParts(12345.6))k.type==="group"?R.group=k.value:k.type==="decimal"&&(R.decimal=k.value)}catch{}return g.set(D,R),R}const h=/\d\s*[*/^]\s*[\d.(]/;function a($,D){if(F($))return null;let M=String($).trim();if(M===""||M.startsWith("=")||h.test(M))return null;let R=1;M.startsWith("(")&&M.endsWith(")")&&(R=-1,M=M.slice(1,-1));const k=M.endsWith("%"),{group:I,decimal:q}=c(D);if(M=M.replace(/[\s\u00a0\u202f\u2009']/g,""),I&&I!=="."&&I!==","&&(M=M.split(I).join("")),M=M.replace(/[^0-9eE+\-.,]/g,""),q===","?M=M.split(".").join("").replace(",","."):M=M.split(",").join(""),M===""||M==="-"||M==="+")return null;const Z=Number(M);return Number.isNaN(Z)?null:R*(k?Z/100:Z)}function m($,D){const M=F($)||Number.isNaN($)?null:Number($),R=F(D)||Number.isNaN(D)?null:Number(D);return M===null?R===null?0:1:R===null||M<R?-1:M>R?1:0}function w($,D){const M=u($),R=u(D);return M===null?R===null?0:1:R===null?-1:M===R?0:M?1:-1}function v($,D){const M=z($),R=z(D);if(!M)return R?1:0;if(!R)return-1;const k=M.getTime(),I=R.getTime();return k<I?-1:k>I?1:0}const p=new Map;function y($){const D=z($.value);if(!D)return"";const M=$.locale||"";let R=p.get(M);return R||(R=new Intl.DateTimeFormat($.locale||void 0,{dateStyle:"medium"}),p.set(M,R)),R.format(D)}const C={boolean:{base:"boolean",storage:"bitset",matches:$=>typeof $=="boolean",parse:$=>u($.text),compare:w,format:$=>u($.value)===null?"":u($.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:$=>u($)===null?"":String(u($)),fromClipboard:$=>u($)},number:{base:"number",storage:"float64",matches:$=>typeof $=="number"&&!Number.isNaN($),parse:$=>{if(r($.text)){const D=t($.text,$);if(!D.ok)return null;const M=Number(D.value);return Number.isFinite(M)?M:null}return a($.text,$.locale)},compare:m,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:$=>F($)?"":String($),fromClipboard:($,D)=>a($,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&l.test($)&&!Number.isNaN(Date.parse($))||$ instanceof Date&&!Number.isNaN($.getTime())&&i($),parse:$=>S($.text),compare:O,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>S($),toClipboard:$=>F($)?"":String($),fromClipboard:$=>S($)},dateString:{base:"dateString",storage:"dictionary",matches:$=>typeof $=="string"&&l.test($)&&!Number.isNaN(Date.parse($)),parse:$=>S($.text),compare:O,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:$=>S($),toClipboard:$=>F($)?"":String($),fromClipboard:$=>S($)},text:{base:"text",storage:"dictionary",matches:$=>typeof $=="string",parse:$=>$.text===""?null:String($.text),compare:($,D)=>F($)?F(D)?0:1:F(D)?-1:L().compare(String($),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},image:{base:"text",storage:"dictionary",parse:$=>$.text===""||$.text==null?null:String($.text).trim(),compare:($,D)=>F($)?F(D)?0:1:F(D)?-1:L().compare(String($),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},lookup:{base:"text",storage:"dictionary",parse:$=>{if($.text===""||$.text==null)return null;const D=$.column&&$.column.lookup,M=D&&Q(D.options)?D.options():null;if(!M)return $.text;const R=String($.text),k=M.find(Z=>String(Z.id)===R);if(k)return k.id;const I=R.trim().toLowerCase(),q=M.find(Z=>String(Z.label).toLowerCase()===I);return q?q.id:$.text},compare:B,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:$=>F($)?"":String($),fromClipboard:$=>$},object:{base:"object",storage:"object",matches:$=>$!==null&&typeof $=="object"&&!($ instanceof Date),parse:$=>{try{return $.text===""?null:JSON.parse($.text)}catch{return $.text}},compare:($,D)=>B($,D),format:$=>{const D=$.value;if(F(D))return"";if(typeof D=="string")return D;try{return JSON.stringify(D)}catch{return String(D)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:$=>F($)?"":typeof $=="string"?$:JSON.stringify($),fromClipboard:$=>$}},T=["boolean","number","date","dateString","datetime","text","object"];function P($,D,M,R){const k=M.get($);if(k)return k;R.includes($)&&G(`circular data type extends chain: ${[...R,$].join(" → ")}`);const I=D[$];I||G(`unknown data type "${$}"`);let q=null;I.extends&&(q=P(I.extends,D,M,[...R,$]));const Z={...q||{},...I,name:$,defaults:{...q&&q.defaults||{},...I.defaults||{}}};return Z.base||(Z.base=q&&q.base||"text"),Z.storage||(Z.storage=q&&q.storage||"object"),M.set($,Z),Z}function x($,D){const M={...C,...s};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const k of D.names("dataType")){const I=D.dataType(k);I&&(M[k]=I)}if(_($))for(const[k,I]of Object.entries($))M[k]=I;const R=new Map;for(const k of T)P(k,M,R,[]);P("lookup",M,R,[]);for(const k of Object.keys(M))P(k,M,R,[]);for(const k of R.values())f(k.operators);return R}function E($,D){if($.base==="text"&&(!$.compare||$.compare===C.text.compare)){const M=L(D);return(R,k)=>F(R)?F(k)?0:1:F(k)?-1:M.compare(String(R),String(k))}return $.compare||B}function j($,D){return D?$.multiStorage||"multi":$.storage||"object"}function A($){return H(String($).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),xe("packages/core/src/columns/infer.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Q}});const X=K("packages/core/src/internal/util.js"),L=X.infoOnce,B=X.isNil,F=100;function _(G,H,U={}){const z=U.sampleSize??F,S=[];for(let O=0;O<G.length&&S.length<z;O++){const b=G[O];B(b)||typeof b=="number"&&Number.isNaN(b)||S.push(b)}if(S.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[O,b]of H){if(typeof b.matches!="function")continue;let u=!0;for(let d=0;d<S.length;d++)if(!b.matches(S[d])){u=!1;break}if(u)return{type:O,unanimous:!0,sampled:S.length}}return U.quiet||L(`infer:${U.colId||"?"}`,`column "${U.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:S.length}}function Q(G,H,U,z,S={}){const O=S.sampleSize??F,b=[];for(let u=0;u<H.length&&b.length<O;u++){const d=U(H[u]);B(d)||typeof d=="number"&&Number.isNaN(d)||b.push(d)}return _(b,z,{...S,colId:G}).type}}),xe("packages/core/src/columns/graph.js",function(e,K){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return z}});const X=K("packages/core/src/internal/util.js"),L=X.DEV,B=X.fail,F=X.isFunction,_=X.warnOnce,Q="*";function G(S){const O=S.value||{};if(!F(O.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const u=O.pure!==!1;return O.deps===Q?{computed:!0,wholeRow:!0,deps:[],pure:u}:Array.isArray(O.deps)?{computed:!0,wholeRow:!1,deps:O.deps.slice(),pure:u}:(_(`deps:missing:${S.id}`,`computed column "${S.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:u})}function H(S){const O=new Map;for(const g of S)O.set(g.id,g);const b=new Map,u=new Map,d=new Set,s=new Set,n=new Set,t=new Set;for(const g of S){const c=G(g);if(!c.computed){b.set(g.id,[]);continue}s.add(g.id),(c.pure?n:t).add(g.id),c.wholeRow&&d.add(g.id);const h=[],a=[];for(const m of c.deps)(O.has(m)?h:a).push(m);b.set(g.id,h),a.length&&u.set(g.id,a)}for(const g of n)for(const c of b.get(g))t.has(c)&&B(`pure computed column "${g}" depends on impure column "${c}". Mark it \`value.pure: false\` or make the dependency pure.`);const r=[],o=new Map,f=[],l=g=>{const c=o.get(g);if(c!=="done"){if(c==="open"){const h=f.indexOf(g);B(`circular column dependency: ${[...f.slice(h),g].join(" → ")}`)}o.set(g,"open"),f.push(g);for(const h of b.get(g)||[])O.has(h)&&l(h);f.pop(),o.set(g,"done"),r.push(g)}};for(const g of S)l(g.id);const i=new Map;for(const g of S)i.set(g.id,[]);for(const g of S)for(const c of b.get(g.id)||[]){const h=i.get(c);h&&!h.includes(g.id)&&h.push(g.id)}if(d.size)for(const g of S){if(s.has(g.id))continue;const c=i.get(g.id);for(const h of d)c.includes(h)||c.push(h)}return{order:r,dependents:i,pure:n,impure:t,computed:s,deps:b,wholeRow:d,external:u,index:O}}function U(S,O){const b=Array.isArray(O)?O:[O],u=new Set,d=[...b];for(;d.length;){const s=d.shift();for(const n of S.dependents.get(s)||[])u.has(n)||(u.add(n),d.push(n))}for(const s of b)u.delete(s);return S.order.filter(s=>u.has(s))}function z(S,O,b){if(!L)return S;const u=O instanceof Set?O:new Set(O);return new Proxy(S,{get(d,s){return typeof s=="string"&&!u.has(s)&&!Object.hasOwn(d,s)&&_(`undeclared:${b}:${s}`,`computed column "${b}" read undeclared dependency "${s}". Add it to \`value.deps\` or the value will go stale.`),d[s]}})}}),xe("packages/core/src/model/rowkey.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return d}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.pathGetter,F=X.isFunction,_=X.isBlank,Q=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],G="";function H(s){if(s===null)return"\0n";if(s===void 0)return"\0u";const n=typeof s;if(n==="string")return s;if(n==="number"||n==="bigint"||n==="boolean")return String(s);if(s instanceof Date)return`\0d${s.getTime()}`;try{return`\0o${JSON.stringify(s)}`}catch{return"\0o?"}}function U(s){if(s.length===1)return H(s[0]);let n="";for(let t=0;t<s.length;t++)t&&(n+=G),n+=H(s[t]);return n}function z(s,n={}){const t=n.warn!==!1;if(F(s)){const r=s;return{stable:!0,fields:[],disabled:[],key(o,f){try{const l=r(o);return Array.isArray(l)?U(l):H(l)}catch(l){return L("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",l),`#${f??-1}`}},keyEmpty(o){try{const f=r(o);return Array.isArray(f)?f.length===0||f.some(_):_(f)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(s)&&s.length>0){const r=s.filter(l=>typeof l=="string"),o=r.map(l=>B(l)),f=o.length;return{stable:!0,fields:r,disabled:[],key(l){const i=new Array(f);for(let g=0;g<f;g++)i[g]=o[g](l);return U(i)},keyEmpty(l){for(let i=0;i<f;i++)if(_(o[i](l)))return!0;return!1},missingFields(l){const i=[];for(let g=0;g<f;g++)_(o[g](l))&&i.push(r[g]);return i}}}if(typeof s=="string"&&s.length>0){const r=B(s);return{stable:!0,fields:[s],disabled:[],key(o){return H(r(o))},keyEmpty(o){return _(r(o))},missingFields(o){return _(r(o))?[s]:[]}}}return t&&L("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${Q.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:Q.slice(),key(r,o){if(r===null||typeof r!="object")return`#${o??0}:${String(r)}`;let f=S.get(r);return f===void 0&&(f=`#${O++}`,S.set(r,f)),f}}}const S=new WeakMap;let O=0;function b(s,n){if(!s||s.stable===!1||!F(s.keyEmpty)||!Array.isArray(n)||n.length===0)return;let t=0,r=null,o;for(let g=0;g<n.length;g++){const c=n[g];s.keyEmpty(c)&&(t++,r===null&&(r=F(s.missingFields)?s.missingFields(c):[],o=c))}if(t===0)return;const f=s.fields.length?s.fields.join(","):"(function)",l=r&&r.length?r.join(", "):s.fields.length?s.fields.join(", "):"the rowKey function",i=o!==null&&typeof o=="object"?Object.keys(o).join(", ")||"(no fields)":String(o);L(`rowKey.emptyValue:${f}`,`rowKey ${l} is missing on ${t} of ${n.length} rows; the first such row has: ${i}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function u(s){return U(s)}function d(s){return s.split(G)}}),xe("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return s}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare,F=X.isFunction,_=X.isNil,Q=X.warnOnce,H=K("packages/core/src/model/rowkey.js").compositeKey,U=", ",z="";function S(n,t,r,o){if(n===null||typeof n!="object")return{id:n,label:n==null?"":String(n)};const f=n[t],l=n[r],i={id:f,label:l==null?String(f??""):String(l)};n.disabled&&(i.disabled=!0),n.variant&&(i.variant=n.variant),n.icon&&(i.icon=n.icon);const g=o?n[o]:n.group;return g!==void 0&&(i.group=g),i}function O(n,t,r=0,o=[],f=[]){for(const l of n||[]){const i=l&&typeof l=="object"?l[t]:null;if(f.push({raw:l,depth:r,path:o}),Array.isArray(i)&&i.length){const g=String(l&&typeof l=="object"?l.label??l.name??l.id??"":l);O(i,t,r+1,[...o,g],f)}}return f}function b(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&F(n.router&&n.router.subscribe)}class u{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#f=new Map;constructor(t,r={}){this.#e=t||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=L(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??U}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(t){this.#n=t,this.#c=L(t)}#h(t){const r=this.#e,o=r.valueKey||"id",f=r.labelKey||"label",l=r.childrenKey||"children";this.#o=O(t,l).map(i=>{const g=S(i.raw,o,f,r.groupKey);return i.depth&&(g.depth=i.depth,g.path=i.path),g}),this.#i=new Map,this.#s=new Map,this.#o.forEach((i,g)=>{this.#i.set(i.id,i),this.#s.set(i.id,g)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const t=this.#e.options;if(Array.isArray(t)||t===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(b(t))return this.#u=this.#p(t),this.#u;if(!F(t))return Q(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let r;try{r=t()}catch(o){return this.#a="error",Q(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),this.#u=Promise.resolve([]),this.#u}return!r||!F(r.then)?(this.#h(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(o=>(this.#h(o),this.#r&&this.#r(this),this.#o),o=>(this.#a="error",Q(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const r=this.#e,o=r.valueKey||"id",f=r.labelKey||"label",l=r.groupKey,i=F(t.map)?t.map:null,g=h=>S(i?i(h):h,o,f,l).id,c=h=>this.#m(h,i,o,f,l);return t.router.subscribe(t.predicate,c,{rowKey:g}),this.#d=()=>{F(t.router.detach)&&t.router.detach(c)},this.#a="ready",Promise.resolve(this.#o)}#m(t,r,o,f,l){const i=t&&t.add||[],g=t&&t.update||[],c=t&&t.remove||[];if(!(!i.length&&!g.length&&!c.length)){for(const h of i)this.#g(h,r,o,f,l);for(const h of g)this.#g(h,r,o,f,l);for(const h of c){if(!this.#f.has(h))continue;const a=this.#f.get(h);this.#f.delete(h),this.#i.delete(a);const m=this.#o.findIndex(w=>w.id===a);m>=0&&this.#o.splice(m,1)}this.#s=new Map(this.#o.map((h,a)=>[h.id,a])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,r,o,f,l){const i=S(r?r(t):t,o,f,l);this.#f.set(H([i.id]),i.id);const g=this.#o.findIndex(c=>c.id===i.id);g>=0?this.#o[g]=i:this.#o.push(i),this.#i.set(i.id,i)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,r){const o=this.#e;if(!F(o.search)){const i=String(t||"").toLowerCase();return Promise.resolve(i===""?this.#o:this.#o.filter(g=>g.label.toLowerCase().includes(i)))}const f=o.valueKey||"id",l=o.labelKey||"label";return Promise.resolve(o.search(t,r)).then(i=>(i||[]).map(g=>S(g,f,l,o.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const r=this.#i.get(t);if(r)return r.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||Q(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(t)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const o=this.#e.unknownLabel;return F(o)?String(o(t)??""):typeof o=="string"?o:String(t)}text(t){if(this.multiple){const r=d(t);return r.length===0?"":r.map(o=>this.label(o)).join(this.separator)}return this.label(t)}dictionary(){return this.#o.map(t=>t.id)}sorted(){const t=this.sortBy;if(t==="optionOrder"||t==="count")return this.#o.slice();if(t==="value")return this.#o.slice().sort((o,f)=>B(o.id,f.id));const r=this.#c;return this.#o.slice().sort((o,f)=>r.compare(o.label,f.label))}comparator(){const t=this.sortBy,r=this.multiple,o=this.#c,f=this.#s;if(r&&t==="count")return(i,g)=>d(i).length-d(g).length;const l=r?i=>d(i)[0]:i=>i;return t==="value"?(i,g)=>B(l(i),l(g)):t==="optionOrder"?(i,g)=>{const c=f.has(l(i))?f.get(l(i)):Number.MAX_SAFE_INTEGER,h=f.has(l(g))?f.get(l(g)):Number.MAX_SAFE_INTEGER;return c-h}:(i,g)=>{const c=l(i),h=l(g);return _(c)?_(h)?0:1:_(h)?-1:o.compare(this.label(c),this.label(h))}}groupKey(t){return this.multiple?d(t).map(o=>String(o)).sort().join(z):_(t)?"":String(t)}countValues(t){return this.multiple?d(t).length:_(t)?0:1}contains(t,r,o){const f=this.multiple?d(t):_(t)?[]:[t],l=Array.isArray(r)?r:[r];switch(o){case"containsAll":return l.every(i=>f.includes(i));case"containsNone":return!l.some(i=>f.includes(i));default:return l.some(i=>f.includes(i))}}exportText(t,r="label"){return r==="value"?this.multiple?d(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:o=>t?d(o).includes(r.id):o===r.id}))}}function d(n){return Array.isArray(n)?n:_(n)||n===""?[]:[n]}function s(n,t={}){const r=n.lookup;if(!r)return null;const o=new u(r,{colId:n.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&o.load(),o}}),xe("packages/core/src/columns/value.js",function(e,K){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return b}});const X=K("packages/core/src/internal/util.js"),L=X.getPath,B=X.isFunction,F=X.isNil,_=X.Lru,Q=X.warnOnce,H=K("packages/core/src/columns/graph.js").depsProxy,U="\0";function z(n,t={}){const r=t.locale,o=t.grid??null,f=t.context,l=n.value&&n.value.format,i=n.formatter||null,g=n.dataType&&n.dataType.format,c=n.lookup||null,h=(a,m,w)=>({value:a,data:w,row:m,column:n,colId:n.id,grid:o,context:f,locale:r});if(B(l))return(a,m,w)=>{const v=l(h(a,m,w));return v==null?"":String(v)};if(i){if(c){const a=i.kind==="text";return(m,w,v)=>i(a?c.text(m):m,h(m,w,v))}return(a,m,w)=>i(a,h(a,m,w))}return B(g)?(a,m,w)=>{const v=g(h(a,m,w));return v==null?"":String(v)}:c?a=>c.text(a):a=>F(a)?"":typeof a=="string"?a:String(a)}function S(n,t){!n||!n.value||n.value.pure!==!1||Q(`impure:${t}:${n.id}`,`column "${n.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class O{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(r=>[r.id,r])),this.#t=t.graph,this.#n=t.grid??null,this.#r=t.context,this.#i=t.stored||null,this.#o=t.rowKey||b}get graph(){return this.#t}setGraph(t){this.#t=t,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(t){if(this.#s.size===0)return;const r=t&&t.rows?new Set([...t.rows].map(String)):null,o=t&&t.columns?[...t.columns]:null;if(!r&&!o){this.#s.clear();return}const f=o?this.#l(o):null;for(const l of[...this.#s.keys()]){const i=String(l).split(U);i.length===3&&(r&&!r.has(i[0])||f&&!f.has(i[2])||this.#s.delete(l))}}#l(t){const r=new Set,o=this.#t,f=[...t];for(;f.length;){const l=f.pop();if(!r.has(l)){r.add(l);for(const i of o?o.dependents.get(l)||[]:[])f.push(i)}}return r}value(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return;if(!f.computed)return this.#u(f,r,o);if(f.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(f.id))return this.#i.get(f.id,o.physical);if(f.volatile)return this.compute(f,r,o);if(f.value.pure===!1)return this.compute(f,r,o);const l=`${this.#a(r,o)}${U}${f.id}`;if(this.#s.has(l))return this.#s.get(l);const i=this.compute(f,r,o);return this.#s.set(l,i),i}#a(t,r){return`${this.#o(t,r)}${U}${u(t)}`}#u(t,r,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,o.physical);if(t.field)return t.read?t.read(r):L(r,t.field)}compute(t,r,o){const f=this.#t,l=f&&f.wholeRow.has(t.id);let i;if(l)i=r??{};else{i={};const c=f&&f.deps.get(t.id)||[];for(const a of c)i[a]=this.value(a,r,o);const h=f&&f.external.get(t.id)||[];for(const a of h)i[a]=L(r,a);i=H(i,[...c,...h],t.id)}const g={data:r,row:o,column:t,grid:this.#n,context:this.#r};return t.value.compute(i,g)}values(t,r){const o={},f=this.#t?this.#t.order:[...this.#e.keys()];for(const l of f)o[l]=this.value(l,t,r);return o}text(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;return f?f.formatValue(this.value(f,r,o),o,r):""}key(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";const l=this.value(f,r,o);return B(f.value.key)?String(f.value.key(this.#c(f,l,r,o))):f.lookup?f.lookup.groupKey(l):F(l)?"":String(l)}quickFilterText(t,r,o){const f=typeof t=="string"?this.#e.get(t):t;if(!f)return"";if(B(f.value.quickFilterText)){const l=this.value(f,r,o);return String(f.value.quickFilterText(this.#c(f,l,r,o))??"")}return this.text(f,r,o)}#c(t,r,o,f){return{value:r,data:o,row:f,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,r,o,f){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return r;const i={text:r,value:this.value(l,o,f),data:o,row:f,column:l,grid:this.#n,context:this.#r,locale:this.#n&&B(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&B(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return B(l.value.parse)?l.value.parse(i):l.dataType&&B(l.dataType.parse)?l.dataType.parse(i):r}validate(t,r,o,f,l){const i=typeof t=="string"?this.#e.get(t):t;if(!i||!B(i.edit.validate))return!0;const g=i.edit.validate({value:r,oldValue:o,data:f,row:l,column:i,grid:this.#n,context:this.#r});return g===!0||g===void 0?!0:String(g)}apply(t,r,o,f){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return!1;const i=this.value(l,o,f);if(B(l.value.apply)){const g=l.value.apply({value:r,oldValue:i,data:o,row:f,column:l,grid:this.#n,context:this.#r});return this.#d(l,o,f),g!==!1}return l.field?i===r?!1:(l.write(o,r),this.#d(l,o,f),!0):(Q(`apply:${l.id}`,`column "${l.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,r,o,f){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const i=this.value(l,o,f),g=this.parse(l,r,o,f),c=this.validate(l,g,i,o,f);if(c!==!0)return{ok:!1,value:g,oldValue:i,changed:!1,error:c};const h=this.apply(l,g,o,f);return{ok:!0,value:g,oldValue:i,changed:h}}#d(t,r,o){if(this.#s.size===0)return;const f=this.#a(r,o);this.#s.delete(`${f}${U}${t.id}`);for(const l of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${f}${U}${l}`)}}function b(n,t){return t&&t.key!=null?String(t.key):u(n)}function u(n){if(n&&typeof n=="object"){let t=d.get(n);return t===void 0&&(t=`#${s++}`,d.set(n,t)),t}return String(n)}const d=new WeakMap;let s=0}),xe("packages/core/src/model/shadow.js",function(e,K){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const L=K("packages/core/src/internal/util.js").warnOnce,B=2e5,F=20,_=1e3,Q=50;function G(g){return Math.min(_,Math.max(Q,Math.floor(g)))}const H=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),U=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),z=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),S=.6745,O=3.5,b=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),d=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function s(g,c){if(!c)return null;const h=Number.isFinite(Number(c.lower))?Number(c.lower):null,a=Number.isFinite(Number(c.upper))?Number(c.upper):null;if(h===null&&a===null||!Number.isFinite(g))return null;if(h!==null&&g<h||a!==null&&g>a)return b.FAIL;const m=Number.isFinite(Number(c.warnLower))?Number(c.warnLower):null,w=Number.isFinite(Number(c.warnUpper))?Number(c.warnUpper):null;return m!==null&&g<m||w!==null&&g>w?b.WARN:b.PASS}function n(g,c,h){if(!c||typeof c!="object")return null;if(c.kind!=="time")return c.kind!==void 0&&L(`shadow.history.window.kind:${g}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${c.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const a=c.minutes!=null?Number(c.minutes)*6e4:Number(c.span);if(!(a>0))return L(`shadow.history.window.span:${g}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const m=Math.max(2,Math.floor(h)||F);return{span:a,bucketMs:Math.max(1,Math.floor(a/m))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#f=new Map;#h=null;#p=null;#m=null;constructor(c){this.#e=c.colId,this.#a=Math.max(2,c.depth||F),this.#u=Math.max(1,c.max||B),this.#c=c.now||(()=>Date.now()),this.#d=n(this.#e,c.historyWindow,this.#a),this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(c,h){const a=l(h);if(a===null)return;if(!this.#n.has(c)){this.#p=null,this.#m=null,this.#g(),this.#t.set(c,a),this.#n.set(c,a),this.#r.set(c,0),this.#o.set(c,this.#c()),this.#i.set(c,[a]),this.#d&&this.#f.set(c,[a]),this.#s.set(c,0);return}const m=this.#n.get(c);if(m===a)return;this.#p=null,this.#m=null,this.#n.set(c,a),this.#r.set(c,(this.#r.get(c)||0)+1),this.#o.set(c,this.#c());const w=this.#i.get(c)||[];w.push(a),w.length>this.#a&&w.splice(0,w.length-this.#a),this.#i.set(c,w);const v=Math.sign(a-m),p=this.#s.get(c)||0;this.#s.set(c,Math.sign(p)===v?p+v:v)}#g(){if(this.#n.size<this.#u)return;const c=this.#n.keys().next().value;c!==void 0&&(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#o.delete(c),this.#i.delete(c),this.#f.delete(c),this.#s.delete(c),this.#l++)}rebase(){for(const[c,h]of this.#n)this.#t.set(c,h);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#f.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#h=Math.floor(this.#c()/this.#d.bucketMs))}retain(c){const h=c instanceof Set?c:new Set(c);let a=0;for(const m of[...this.#n.keys()])h.has(m)||(this.#t.delete(m),this.#n.delete(m),this.#r.delete(m),this.#o.delete(m),this.#i.delete(m),this.#f.delete(m),this.#s.delete(m),a++);return a&&(this.#p=null,this.#m=null),a}advanceHistoryWindow(c=this.#c()){const h=this.#d;if(!h)return 0;const a=Math.floor(c/h.bucketMs),m=a-this.#h;if(!(m>0))return 0;const w=Math.min(m,this.#a);for(const[v,p]of this.#f){const y=this.#n.get(v);for(let C=0;C<w;C++)p.push(y);p.length>this.#a&&p.splice(0,p.length-this.#a)}return this.#h=a,m}read(c,h,a,m){switch(c){case"updates":return this.#r.has(h)?this.#r.get(h):0;case"updatedAt":{const w=this.#o.get(h);return w===void 0?null:new Date(w)}case"sinceUpdate":{const w=this.#o.get(h);return w===void 0?null:this.#c()-w}case"firstValue":return this.#t.has(h)?this.#t.get(h):null;case"delta":return this.#n.has(h)?this.#n.get(h)-this.#t.get(h):null;case"deltaPercent":{if(!this.#n.has(h))return null;const w=this.#t.get(h);return w?(this.#n.get(h)-w)/Math.abs(w)*100:null}case"rate":{const w=this.#i.get(h),v=this.#o.get(h);if(!w||w.length<2||v===void 0)return null;const p=this.#c()-v,y=w[w.length-1]-w[w.length-2];return p>0?y/p*1e3:y}case"history":return this.#d?this.#f.has(h)?[...this.#f.get(h)]:null:this.#i.has(h)?[...this.#i.get(h)]:null;case"streak":return this.#s.has(h)?this.#s.get(h):0;case"specStatus":return this.#n.has(h)?s(this.#n.get(h),m):null;default:return u.includes(c)?this.#k(c,h,a,m):null}}#y(c){if(c){if(this.#m&&this.#m.only===c)return this.#m.view;const h=this.#w(c);return this.#m={only:c,view:h},h}return this.#p?this.#p:(this.#p=this.#w(null),this.#p)}#w(c){const h=[];for(const[x,E]of this.#n)c&&!c.has(x)||h.push(E);const a=h.sort((x,E)=>x-E);let m=0,w=0,v=0,p=0;for(const x of a){p+=x,m++;const E=x-w;w+=E/m,v+=E*(x-w)}const y=[];for(const[x,E]of this.#t)c&&!c.has(x)||y.push(E);const C=m?r(a):0,T=a.map(x=>Math.abs(x-C)).sort((x,E)=>x-E),P=m?r(T):0;return{sorted:a,baseline:y.sort((x,E)=>x-E),sum:p,mean:m?w:0,sd:m>1?Math.sqrt(v/(m-1)):0,median:C,mad:P}}#k(c,h,a,m){if(!this.#n.has(h)||a&&!a.has(h))return null;const w=this.#n.get(h),v=this.#y(a),p=v.sorted.length;if(!p)return null;switch(c){case"rank":return p-f(v.sorted,w)+1;case"rankAsc":return o(v.sorted,w)+1;case"rankChange":{if(!this.#t.has(h)||!v.baseline.length)return null;const y=v.baseline.length-f(v.baseline,this.#t.get(h))+1,C=p-f(v.sorted,w)+1;return y-C}case"percentile":return f(v.sorted,w)/p*100;case"quartile":{const y=f(v.sorted,w)/p;return Math.min(4,Math.max(1,Math.ceil(y*4)))}case"zScore":return v.sd?(w-v.mean)/v.sd:null;case"anomalyScore":return v.mad?S*(w-v.median)/v.mad:null;case"anomalyFlag":{if(!v.mad)return null;const y=m&&Number.isFinite(Number(m.threshold))?Number(m.threshold):O;return Math.abs(S*(w-v.median)/v.mad)>y}case"shareOfTotal":return v.sum?w/v.sum*100:null;default:return null}}}function r(g){const c=g.length;if(!c)return 0;const h=(c-1)*.5,a=Math.floor(h),m=Math.ceil(h);return a===m?g[a]:g[a]+(h-a)*(g[m]-g[a])}function o(g,c){let h=0,a=g.length;for(;h<a;){const m=h+a>>1;g[m]<c?h=m+1:a=m}return h}function f(g,c){let h=0,a=g.length;for(;h<a;){const m=h+a>>1;g[m]<=c?h=m+1:a=m}return h}function l(g){if(g==null||g==="")return null;if(g instanceof Date){const h=g.getTime();return Number.isFinite(h)?h:null}const c=typeof g=="number"?g:Number(g);return Number.isFinite(c)?c:null}function i(g){const c=[];for(const h of g||[]){const a=h.shadow;if(!a)continue;const m=typeof a=="string"?{kind:a}:a,w=m.kind;H.includes(w)&&(U.includes(w)||z.includes(w)||c.push({colId:h.id||h.field,of:m.of||h.field||h.id,kind:w,depth:m.depth,historyWindow:w==="history"?m.window:void 0}))}return c}}),xe("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ne}});const X=K("packages/core/src/internal/util.js"),L=X.expand,B=X.fail,F=X.getPath,_=X.humanise,Q=X.isFunction,G=X.isObject,H=X.merge,U=X.pathGetter,z=X.pathSetter,S=X.toArray,O=X.uid,b=X.warnOnce,d=K("packages/core/src/format/index.js").compileFormat,s=K("packages/core/src/columns/datatypes.js"),n=s.comparatorFor,t=s.createTypeRegistry,r=s.storageKind,o=K("packages/core/src/columns/infer.js"),f=o.inferColumnType,l=o.DEFAULT_SAMPLE,i=K("packages/core/src/columns/graph.js"),g=i.buildGraph,c=i.affectedBy,a=K("packages/core/src/columns/lookup.js").createLookup,m=K("packages/core/src/columns/value.js"),w=m.compileDisplay,v=m.ValuePipeline,p=m.warnImpureUse,C=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,T=Object.freeze({geometry:"geometry",list:"list"}),P={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},x={centre:"center"},E=new Set(["start","center","end","left","right"]);function j(de){if(typeof de!="string")return;const ie=de.toLowerCase();return x[ie]?x[ie]:E.has(ie)?ie:void 0}function A(de){if(typeof de!="string")return;const ie=de.toLowerCase();return ie==="center"||ie==="centre"?"middle":ie==="top"||ie==="middle"||ie==="bottom"?ie:void 0}const $=["cell","layout","header"];function D(de){if(!G(de))return{};const ie={...de},oe=(ce,fe)=>{if(de[ce]===void 0)return;const ke=L(de[ce],fe);ke&&$.includes(ce)&&!G(de[ce])&&delete ke.enabled,ie[ce]=ke};return oe("sort","direction"),oe("filter","type"),oe("cell","render"),oe("edit","editor"),oe("layout","width"),oe("group","index"),oe("pivot","index"),oe("header","render"),oe("facet","strategy"),ie}function M(de,ie){const oe={...de||{}},ce=G(ie)&&G(ie.layout)&&ie.layout.width!==void 0;return oe.fit==="content"&&!ce&&delete oe.width,oe}const R=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),k=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function I(de,ie,oe,ce){const fe=oe==="columnGroup"?"column group":"column";for(const ke of Object.keys(de))ie.has(ke)||b(`${oe}.unknown:${ke}`,`'${ke}' is not a configuration key this grid recognises, so it had no effect on ${fe} "${ce}". Check the spelling against the reference.`)}function q(de,ie){const oe=ie&&Q(de.defaultsFor)?de.defaultsFor(ie):null,ce={...de.defaults||{},...G(oe)?oe:{}},fe={};return ce.align&&(fe.align=ce.align,fe.cell={align:ce.align},fe.header={align:ce.align}),ce.filter&&(fe.filter=ce.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ce.filter}),ce.editor&&(fe.edit=ce.editor==="none"?{editor:null}:{editor:ce.editor}),ce.total&&(fe.total=ce.total),ce.render&&(fe.cell={...fe.cell||{},render:ce.render}),de.export&&(fe.export={...de.export}),fe}function Z(de){if(typeof de=="string")return de.trim()?[de.trim()]:[];if(!Array.isArray(de))return[];const ie=[];for(const oe of de){if(typeof oe!="string")continue;const ce=oe.trim();ce&&!ie.includes(ce)&&ie.push(ce)}return ie}class W{#e=new Map;#t=[];#n=[];#r;#o;#i;#s;#l;#a;#u(ie,oe,ce){const fe=this.#c(ie,oe,ce);if(typeof fe!="string"||!this.#d)return fe??null;const ke=oe&&oe.totals&&oe.totals.implement;if(ke&&Q(ke[fe])){const Ee=ke[fe];return Ee.totalName=fe,Ee}const Re=this.#d.totalFn?.(fe);return Q(Re)?Re:fe}#c(ie,oe,ce){if(typeof ie!="string")return ie;const fe=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(fe)||fe.includes(ie))return ie;const ke=fe.length?fe.join(", "):"none";return B(`column "${ce}" is typed ${oe.name||"a type"}, for which the total "${ie}" is not meaningful. Supported: ${ke}. Aggregating it anyway would produce a confident wrong number.`),ie}#d;#f;#h;#p;#m;#g;#y=!1;#w;#k;constructor(ie={}){this.#o=D(ie.columnDefaults||{}),this.#i=ie.columnPresets||{},this.#l=ie.locale,this.#s=ie.timeZone,this.#a=A(ie.verticalAlign),this.#d=ie.registry||null,this.#f=ie.grid||null,this.#h=ie.context,this.#w=ie.sampleSize??l,this.#k=ie.onChange||null,this.#g=Q(ie.rowKey)?ie.rowKey:void 0,this.#r=t(ie.dataTypes,this.#d);const{leaves:oe,groups:ce}=ne(ie.columns||[]);this.#n=ce;for(const fe of oe){const ke=this.#b(fe.def,null);if(ke.groupPath=fe.path,this.#e.has(ke.id)){b(`columns.duplicate:${ke.id}`,`two columns resolve to the id '${ke.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}fe.column=ke,this.#e.set(ke.id,ke),this.#t.push(ke.id)}this.#S(ie.stored||null)}#b(ie,oe){I(ie,R,"column",ie.id||ie.field||"(unnamed)");const ce=D(ie),fe=S(ie.preset),ke=fe.map(Je=>{const Te=this.#i[Je];return Te?D(Te):(b(`preset:${Je}`,`unknown column preset "${Je}"; ignoring`),{})}),Re=this.#P(ce,ke,oe),Ee=this.#r.get(Re)||this.#r.get("text");if(!this.#r.has(Re)&&ie.type){const Je=T[Re];b(`type:${Re}`,`unknown data type "${Re}"; falling back to "text"`+(Je?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Je}'.`:""))}const Fe=Q(Ee.items)?this.#A(ce,ke,ie.id||ie.field||"(unnamed)"):null;let ye=P;ye=H(ye,this.#o),ie.type!==!1&&(ye=H(ye,q(Ee,Fe)));for(const Je of ke)ye=H(ye,Je);ye=H(ye,ce);const he=ye.edit;he&&he.editor&&he.enabled!==!0&&!Q(he.enabled)&&(ie.edit||{}).editor&&b(`column.editor-not-enabled:${ie.id||ie.field}`,`column '${ie.id||ie.field}' names the editor '${he.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Se=ie.id||ie.field||O("col");if(ie.shadow&&!Q(ye.value&&ye.value.compute)){const Je=typeof ie.shadow=="string"?{kind:ie.shadow}:ie.shadow,Te=Je.of||ie.field||Se,_e=C.includes(Je.kind),Ke=_e?Je.model||Je:null,nt=_e&&Ke?[...Array.isArray(Ke.predictors)?Ke.predictors:[],Ke.response].filter(Boolean):null;ye.value={...ye.value||{},deps:nt&&nt.length?nt:Je.orderBy&&Je.orderBy!==Te?[Te,Je.orderBy]:[Te],pure:!1,compute:(ot,pt)=>{const bt=pt.grid&&pt.grid.statistics;if(!bt)return null;const Ot=pt.row&&pt.row.key||bt.keyOf(pt.data);if(!Ot)return null;if(_e){if(!Q(bt.fitShadow))return null;const Pt=Je.model?{...Je.model,threshold:Je.threshold}:Je;return bt.fitShadow(Je.kind,Ot,Pt)}return bt.shadow(Te,Je.kind,Ot,Je.scope,Je)}}}if(ie.running&&!Q(ye.value&&ye.value.compute)){const Je=typeof ie.running=="string"?{kind:ie.running}:ie.running,Te=Je.of||ie.field||Se;ye.value={...ye.value||{},deps:[Te],pure:!1,compute:(_e,Ke)=>{const nt=Ke.grid&&Ke.grid.statistics;if(!nt||!Q(nt.running))return null;const ot=Ke.row&&Ke.row.key||nt.keyOf(Ke.data);return ot?nt.running(Te,Je.kind||"total",ot):null}},ie.sort===void 0&&(ye.sort={...ye.sort||{},enabled:!1})}const Ce=ie.field??(Q(ye.value&&ye.value.compute)?null:ie.id??null),Ie=Q(ye.value&&ye.value.compute),ze={id:Se,field:Ce,shadow:ie.shadow||null,running:ie.running||null,spec:ie.spec||null,validation:ie.validation||null,volatile:!!(ie.shadow||ie.running),title:ye.title??_(Ce||Se),type:Ee.name,dataType:Ee,itemType:Fe,nullable:ye.nullable!==!1,align:j(ce.cell&&ce.cell.align||ce.align||ye.cell&&ye.cell.align||ye.align||Ee.defaults&&Ee.defaults.align)||"start",verticalAlign:A(ce.cell&&ce.cell.verticalAlign||ce.verticalAlign||ye.cell&&ye.cell.verticalAlign||ye.verticalAlign)||this.#a,rowSpan:Q(ye.rowSpan)?ye.rowSpan:null,colSpan:Q(ye.colSpan)?ye.colSpan:null,value:{pure:!0,...ye.value||{}},cell:{...ye.cell||{}},edit:{...ye.edit||{}},sort:{...ye.sort||{}},filter:{...ye.filter||{}},group:{enabled:!1,index:-1,explode:!1,...ye.group||{}},pivot:{enabled:!1,index:-1,...ye.pivot||{}},total:this.#u(ye.total,Ee,ie.id||ie.field||"(unnamed)"),groupTotal:ye.groupTotal===void 0?null:this.#u(ye.groupTotal,Ee,ie.id||ie.field||"(unnamed)"),grandTotal:ye.grandTotal===void 0?null:this.#u(ye.grandTotal,Ee,ie.id||ie.field||"(unnamed)"),tags:Z(ye.tags),typeOptions:ye.typeOptions??null,...G(ye[Re])?{[Re]:ye[Re]}:{},layout:M(ye.layout,ce),header:{...ye.header||{}},contextMenu:ye.contextMenu===void 0?null:ye.contextMenu,facet:{...ye.facet||{}},export:{...ye.export||{}},allowGroup:ye.allowGroup!==!1,allowPivot:ye.allowPivot!==!1,allowTotal:ye.allowTotal!==!1,quickFilter:ye.quickFilter!==!1,def:ie,format:ye.format,presets:fe,inferred:oe!=null&&!ie.type,computed:Ie,diff:ie.diff===void 0?void 0:!!ie.diff,read:Ce?U(Ce):null,write:Ce?z(Ce):null};ze.cell.align=j(ce.cell&&ce.cell.align)||ze.align,ze.header.align=j(ce.header&&ce.header.align)||ze.align;const Xe=ye.lookup||null;return ze.lookup=Xe?a({id:Se,lookup:Xe},{locale:this.#l,onChange:()=>{this.#k&&this.#k("lookup",{colId:Se})}}):null,ze.group.explode&&ze.lookup&&ze.lookup.multiple&&b(`explode:${Se}`,`column "${Se}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#O(ze),ze}#O(ie){ie.formatter=d(ie.format,ie.dataType,this.#l,this.#s,ie.id),ie.formatValue=w(ie,{locale:this.#l,grid:this.#f,context:this.#h}),ie.itemCompare=ie.itemType?n(ie.itemType,this.#l):null,ie.compare=Q(ie.value.compare)?ie.value.compare:ie.lookup?ie.lookup.comparator():Q(ie.dataType.compareFor)?ie.dataType.compareFor(ie):n(ie.dataType,this.#l),ie.excel=ie.formatter&&ie.formatter.ooxml||ie.dataType&&ie.dataType.excel||"General",ie.storeKind=r(ie.dataType,!!(ie.lookup&&ie.lookup.multiple))}#A(ie,oe,ce){let fe=G(ie.typeOptions)?ie.typeOptions:null;for(let Fe=oe.length-1;!fe&&Fe>=0;Fe--)G(oe[Fe].typeOptions)&&(fe=oe[Fe].typeOptions);!fe&&G(this.#o.typeOptions)&&(fe=this.#o.typeOptions);const ke=fe&&fe.of!==void 0?fe.of:"text",Re=typeof ke=="string"?this.#r.get(ke):void 0;return Re&&!Q(Re.items)&&Re.storage!=="object"?Re:(b(`type:of:${String(ke)}`,`column "${ce}" names "${String(ke)}" as its item type (typeOptions.of), which is not ${Re?"a scalar data type":"a known data type"}; its items are read as text.`),this.#r.get("text"))}#P(ie,oe,ce){if(ie.type===!1)return"text";if(ie.type)return ie.type;for(let fe=oe.length-1;fe>=0;fe--)if(oe[fe].type)return oe[fe].type;if(this.#o.type)return this.#o.type;if(ie.shadow){const fe=typeof ie.shadow=="string"?ie.shadow:ie.shadow.kind;if(fe==="fitInfluence")return"boolean";if(fe==="fitPredicted"||fe==="fitResidual"||fe==="fitStdResidual"||fe==="fitLeverage"||fe==="fitCooksD"||fe==="tsTrend"||fe==="tsSeasonal"||fe==="tsResidual"||fe==="tsCoverage"||fe==="tsSmoothed"||fe==="tsSmoothingAlpha"||fe==="tsSmoothingBeta")return"number"}return ce||(ie.lookup?"lookup":"text")}#S(ie){const oe=this.all();this.#p=g(oe),this.#m?this.#m.setGraph(this.#p):this.#m=new v({columns:this.#e,graph:this.#p,grid:this.#f,context:this.#h,stored:ie||null,rowKey:this.#g});const ce=this.#m;for(const fe of oe)fe.getValue=(ke,Re)=>ce.value(fe,ke,Re)}all(){return this.#t.map(ie=>this.#e.get(ie))}visible(){return this.all().filter(ie=>!ie.layout.hidden)}get(ie){return this.#e.get(ie)}groups(){const ie=oe=>{const ce=[];for(const fe of oe)Array.isArray(fe.columns)?ce.push({...fe,columns:ie(fe.columns)}):fe.column&&ce.push(fe.column);return ce};return ie(this.#n)}graph(){return this.#p}pipeline(){return this.#m}types(){return this.#r}affectedBy(ie){return c(this.#p,ie)}value(ie,oe,ce){return this.#m.value(ie,oe,ce)}text(ie,oe,ce){return this.#m.text(ie,oe,ce)}checkImpure(ie,oe){p(this.#e.get(ie),oe)}setLocale(ie){this.#l=ie;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(ie),this.#O(oe);this.#k&&this.#k("locale",{locale:ie})}infer(ie){const oe={};if(this.#y||!Array.isArray(ie)||ie.length===0)return oe;this.#y=!0;let ce=!1;for(const fe of this.all()){const ke=fe.def;if(ke.type!==void 0||!fe.field||fe.computed||fe.lookup||this.#M(fe))continue;const Re=fe.read||(ye=>F(ye,fe.field)),Ee=f(fe.id,ie,Re,this.#r,{sampleSize:this.#w});if(Ee===fe.type)continue;oe[fe.id]=Ee;const Fe=this.#b(ke,Ee);Fe.groupPath=fe.groupPath,Fe.layout={...Fe.layout,...J(fe.layout)},this.#e.set(fe.id,Fe),ae(this.#n,fe.id,Fe),ce=!0}return ce&&this.#S(null),oe}redecorate(ie,oe,ce={}){const fe=this.#e.get(ie);if(!fe){b(`redecorate:${ie}`,`columns.decorate('${ie}', …): no column with id '${ie}'.`);return}const ke=fe.def||{},Re={...G(ke.cell)?ke.cell:{}};Re.decoration=oe??void 0,ce&&"variant"in ce&&(Re.variant=ce.variant);const Ee={...ke,cell:Re},Fe=this.#b(Ee,fe.type);return Fe.groupPath=fe.groupPath,Fe.layout={...Fe.layout,...J(fe.layout)},fe.lookup&&fe.lookup!==Fe.lookup&&Q(fe.lookup.destroy)&&fe.lookup.destroy(),this.#e.set(ie,Fe),ae(this.#n,ie,Fe),this.#S(null),this.#k&&this.#k("decorate",{colId:ie}),Fe}destroy(){for(const ie of this.#e.values())ie.lookup&&Q(ie.lookup.destroy)&&ie.lookup.destroy()}#M(ie){for(const oe of ie.presets){const ce=this.#i[oe];if(ce&&ce.type)return!0}return!!this.#o.type}#j(ie){return!ie.computed&&Q(ie.dataType&&ie.dataType.toStorage)}storeReader(ie){if(ie.computed)return oe=>this.#m.value(ie,oe,null);if(this.#j(ie)){const oe=ie.dataType.toStorage,ce={timeZone:ie.timeZone||this.#s,colId:ie.id,itemType:ie.itemType||null};return fe=>oe(ie.read(fe),ce)}return ie.read}storeValue(ie,oe){if(!(!ie||ie.computed)&&Q(ie.read))return this.storeReader(ie)(oe)}storeSchema(){const ie=[];for(const oe of this.all()){if(oe.computed&&oe.value.pure===!1||!oe.computed&&!oe.field)continue;const ce=this.storeReader(oe);let fe=null;!oe.computed&&!this.#j(oe)&&typeof oe.field=="string"&&!oe.lookup&&(fe=oe.field);const ke={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:ce};fe!==null&&(ke.field=fe),oe.lookup&&(ke.dictionary=oe.lookup.dictionary()),ie.push(ke)}return ie}state(){return this.all().map(ie=>({id:ie.id,width:ie.layout.width,flex:ie.layout.flex||void 0,hidden:!!ie.layout.hidden,pin:ie.layout.pin??null,sort:ie.sort.direction??null,sortIndex:ie.sort.direction?ie.sort.order??0:null,groupIndex:ie.group.enabled?ie.group.index??0:null,pivotIndex:ie.pivot.enabled?ie.pivot.index??0:null,total:typeof ie.total=="string"?ie.total:null,groupTotal:typeof ie.groupTotal=="string"?ie.groupTotal:void 0,grandTotal:typeof ie.grandTotal=="string"?ie.grandTotal:void 0,decoration:ie.cell&&ie.cell.decoration!=null?ee(ie.cell.decoration):void 0,variant:ie.cell&&ie.cell.variant!=null?ee(ie.cell.variant):void 0}))}applyState(ie,oe={}){const ce={applied:[],skipped:[]},fe=Array.isArray(ie)?ie:ie&&ie.columns||[],ke=!Array.isArray(ie)&&ie&&ie.columnOrder||null;for(const Ee of fe){if(!Ee||!Ee.id){ce.skipped.push({key:"?",reason:"no id"});continue}let Fe=this.#e.get(Ee.id);if(!Fe){ce.skipped.push({key:Ee.id,reason:"unknown column"});continue}if(Object.hasOwn(Ee,"decoration")||Object.hasOwn(Ee,"variant")){const ye=Fe.cell?Fe.cell.decoration:void 0,he=Ee.decoration??null,Se=Object.hasOwn(Ee,"variant"),Ce=Se&&!te(Fe.cell?Fe.cell.variant:void 0,Ee.variant);(!te(ye,he)||Ce)&&(this.redecorate(Ee.id,he,Se?{variant:Ee.variant??void 0}:{}),Fe=this.#e.get(Ee.id)||Fe)}Ee.width!=null&&(Fe.layout.width=Ee.width),Ee.flex!=null&&(Fe.layout.flex=Ee.flex),Ee.hidden!=null&&(Fe.layout.hidden=!!Ee.hidden),Ee.pin!==void 0&&(Fe.layout.pin=Ee.pin),Ee.sort!==void 0&&(Fe.sort.direction=Ee.sort),Ee.sortIndex!=null&&(Fe.sort.order=Ee.sortIndex),Ee.groupIndex!=null&&(Fe.group.enabled=!0,Fe.group.index=Ee.groupIndex),Ee.pivotIndex!=null&&(Fe.pivot.enabled=!0,Fe.pivot.index=Ee.pivotIndex),Ee.total!==void 0&&(Fe.total=Ee.total),Ee.groupTotal!==void 0&&(Fe.groupTotal=Ee.groupTotal),Ee.grandTotal!==void 0&&(Fe.grandTotal=Ee.grandTotal),ce.applied.push(Ee.id)}const Re=ke||(oe&&oe.keepOrder?[]:fe.map(Ee=>Ee&&Ee.id).filter(Boolean));if(Re.length){const Ee=Re.filter(ye=>this.#e.has(ye)),Fe=this.#t.filter(ye=>!Ee.includes(ye));this.#t=[...Ee,...Fe]}return this.#k&&this.#k("state",ce),ce}move(ie,oe){this.#E(ie,oe)&&(this.#L(),this.#k&&this.#k("move",{id:ie,to:oe}))}reorder(ie){const oe={applied:[],skipped:[]},ce=[];let fe=0;for(const ke of Array.isArray(ie)?ie:[]){const Re=fe++;this.#E(ke,Re)&&(oe.applied.push(ke),ce.push({id:ke,to:Re}))}if(!ce.length)return oe;if(this.#L(),this.#k)for(const ke of ce)this.#k("move",ke);return oe}#E(ie,oe){const ce=this.#t.indexOf(ie);if(ce===-1||Math.max(0,Math.min(Number(oe)||0,this.#t.length-1))===ce)return!1;const ke=this.#e.get(ie);if(ke.layout.movable===!1||ke.layout.lockPosition)return b(`move:${ie}`,`column "${ie}" is not movable; the move was ignored`),!1;const Re=this.#R(ie,oe);return Re?(b(`move.married:${Re}`,`band "${Re}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(ce,1),this.#t.splice(Math.max(0,Math.min(oe,this.#t.length)),0,ie),!0)}#R(ie,oe){if(!this.#n||!this.#n.length)return null;const ce=this.#t.filter(Ee=>Ee!==ie),fe=Math.max(0,Math.min(oe,ce.length)),ke=(Ee,Fe)=>{if(Array.isArray(Ee.columns)){for(const he of Ee.columns)ke(he,Fe);return Fe}const ye=Ee.column?Ee.column.id:Ee.id;return ye&&Fe.push(ye),Fe},Re=Ee=>{for(const Fe of Ee){if(!Array.isArray(Fe.columns))continue;if(Fe.marryChildren===!0){const he=ke(Fe,[]),Se=he.includes(ie),Ce=he.map(Ie=>ce.indexOf(Ie)).filter(Ie=>Ie>=0);if(Ce.length){const Ie=Math.min(...Ce),ze=Math.max(...Ce);if(Se?fe<Ie||fe>ze+1:fe>Ie&&fe<=ze)return Fe.id}}const ye=Re(Fe.columns);if(ye)return ye}return null};return Re(this.#n)}#L(){const ie=new Map(this.#t.map((fe,ke)=>[fe,ke])),oe=fe=>{if(!Array.isArray(fe.columns)){const Re=fe.column?fe.column.id:fe.id;return ie.has(Re)?ie.get(Re):1/0}let ke=1/0;for(const Re of fe.columns)ke=Math.min(ke,oe(Re));return ke},ce=fe=>{fe.sort((ke,Re)=>oe(ke)-oe(Re));for(const ke of fe)Array.isArray(ke.columns)&&ce(ke.columns)};ce(this.#n)}#x(ie){const oe=ce=>{for(let fe=0;fe<ce.length;fe++){const ke=ce[fe];if(Array.isArray(ke.columns)){const Re=oe(ke.columns);if(Re)return Re}else if(ke.column&&ke.column.id===ie)return ce.splice(fe,1)[0]}return null};return oe(this.#n)}#I(ie){const oe=[];for(let ce=ie.length-1;ce>=0;ce--){const fe=ie[ce];Array.isArray(fe.columns)&&(oe.push(...this.#I(fe.columns)),fe.columns.length===0&&(oe.push(fe.id),ie.splice(ce,1)))}return oe}#z(){const ie=(oe,ce)=>{for(const fe of oe)Array.isArray(fe.columns)?ie(fe.columns,[...ce,fe.id]):fe.column&&(fe.column.groupPath=ce)};ie(this.#n,[])}#$(ie){const oe=new Set(ie),ce=this.#t.filter(Ee=>oe.has(Ee));if(!ce.length)return;const fe=Math.min(...ce.map(Ee=>this.#t.indexOf(Ee))),ke=this.#t.slice(0,fe).filter(Ee=>!oe.has(Ee)),Re=this.#t.slice(fe).filter(Ee=>!oe.has(Ee));this.#t=[...ke,...ce,...Re]}#N(ie){const oe=[],ce=fe=>{if(Array.isArray(fe.columns))for(const ke of fe.columns)ce(ke);else fe.column&&oe.push(fe.column.id)};return ce(ie),oe}#H(ie){const oe=ce=>{for(const fe of ce){if(!Array.isArray(fe.columns))continue;if(fe.id===ie)return{node:fe,parent:ce};const ke=oe(fe.columns);if(ke)return ke}return null};return oe(this.#n)}groupColumns(ie,oe={}){const ce=S(ie).filter(Fe=>this.#e.has(Fe));if(!ce.length)return b("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Fe of ce)if(this.#e.get(Fe).layout.lockPosition)return b(`columns.group.locked:${Fe}`,`column "${Fe}" is position-locked and cannot be grouped.`),null;const fe=oe.groupId?this.#H(oe.groupId):null;if(oe.groupId&&!fe)return b(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let ke=null;if(!fe&&oe.id!=null&&(ke=String(oe.id),this.#H(ke)||this.#e.has(ke)))return b(`columns.group.idtaken:${ke}`,`band id "${ke}" is already in use; nothing was grouped.`),null;const Re=ce.map(Fe=>this.#x(Fe)).filter(Boolean);if(!Re.length)return null;let Ee;if(fe)fe.node.columns.push(...Re),Ee=fe.node.id;else{const Fe={id:ke||O("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Re},ye=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(ye,0,Fe),Ee=Fe.id}return this.#I(this.#n),this.#$(ce),this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"formed",groupId:Ee,ids:ce}),Ee}ungroupColumn(ie){const oe=this.#e.get(ie);if(!oe){b(`columns.ungroup.unknown:${ie}`,`no column "${ie}" to ungroup.`);return}const ce=oe.groupPath||[];if(!ce.length)return;const fe=ce[ce.length-1],ke=this.#H(fe);if(!ke)return;const Re=this.#x(ie);if(!Re)return;const Ee=ke.parent.indexOf(ke.node);ke.parent.splice(Ee+1,0,Re);const Fe=this.#I(this.#n),ye=this.#N(ke.node);if(ye.length){this.#$(ye);const he=Math.max(...ye.map(Ce=>this.#t.indexOf(Ce))),Se=this.#t.filter(Ce=>Ce!==ie);Se.splice(he+1,0,ie),this.#t=Se}this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"removed",id:ie,dissolved:Fe})}renameGroup(ie,oe){const ce=this.#H(ie);if(!ce){b(`columns.group.rename:${ie}`,`no band "${ie}" to rename.`);return}ce.node.title=String(oe??""),this.#k&&this.#k("columngroup",{action:"renamed",groupId:ie,title:ce.node.title})}dissolveGroup(ie){const oe=this.#H(ie);if(!oe){b(`columns.group.dissolve:${ie}`,`no band "${ie}" to dissolve.`);return}const ce=oe.parent.indexOf(oe.node);oe.parent.splice(ce,1,...oe.node.columns),this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"dissolved",groupId:ie})}moveGroup(ie,oe){const ce=this.#H(ie);if(!ce){b(`columns.group.move:${ie}`,`no band "${ie}" to move.`);return}const fe=ce.parent,ke=fe.indexOf(ce.node);ke!==-1&&(fe.splice(ke,1),fe.splice(Math.max(0,Math.min(oe,fe.length)),0,ce.node),this.#B(),this.#z(),this.#k&&this.#k("columngroup",{action:"moved",groupId:ie,to:oe}))}#B(){const ie=[],oe=fe=>{for(const ke of fe)Array.isArray(ke.columns)?oe(ke.columns):ke.column&&ie.push(ke.column.id)};oe(this.#n);const ce=new Set(ie);this.#t=[...ie,...this.#t.filter(fe=>!ce.has(fe))]}groupTree(){const ie=ce=>ce.map(fe=>Array.isArray(fe.columns)?{id:fe.id,title:fe.title||"",collapsible:!!fe.collapsible,openByDefault:fe.openByDefault!==!1,columns:ie(fe.columns)}:fe.column?fe.column.id:null).filter(fe=>fe!==null),oe=ie(this.#n);return oe.some(ce=>ce&&typeof ce=="object")?oe:[]}applyGroupTree(ie){if(!Array.isArray(ie))return;const oe=new Set,ce=ke=>{const Re=[];for(const Ee of ke)if(Ee&&typeof Ee=="object"&&Array.isArray(Ee.columns)){const Fe=ce(Ee.columns);if(!Fe.length)continue;Re.push({id:Ee.id||O("grp"),title:Ee.title||"",collapsible:Ee.collapsible===!0,openByDefault:Ee.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Fe})}else if(typeof Ee=="string"){const Fe=this.#e.get(Ee);Fe&&!oe.has(Ee)&&(oe.add(Ee),Re.push({column:Fe,path:[]}))}return Re},fe=ce(ie);for(const ke of this.#t){if(oe.has(ke))continue;const Re=this.#e.get(ke);Re&&fe.push({column:Re,path:[]})}this.#n=fe,this.#z(),this.#L(),this.#k&&this.#k("columngroup",{action:"applied"})}show(ie){this.#W(ie,!1)}hide(ie){this.#W(ie,!0)}#W(ie,oe){const ce=[];for(const fe of S(ie)){const ke=this.#e.get(fe);if(ke){if(oe&&ke.layout.lockVisible){b(`lockVisible:${fe}`,`column "${fe}" is \`layout.lockVisible\` and cannot be hidden`);continue}ke.layout.hidden!==oe&&(ke.layout.hidden=oe,ce.push(fe))}}ce.length&&this.#k&&this.#k("visible",{ids:ce,hidden:oe})}pin(ie,oe){const ce=this.#e.get(ie);ce&&(ce.layout.pin=oe??null,this.#k&&this.#k("pin",{id:ie,side:ce.layout.pin}))}resize(ie,oe){const ce=this.#e.get(ie);if(!ce)return;if(ce.layout.resizable===!1){b(`resize:${ie}`,`column "${ie}" is not resizable; the resize was ignored`);return}const fe=ce.layout.min??0,ke=ce.layout.max;let Re=Math.max(fe,oe);ke!=null&&(Re=Math.min(ke,Re)),ce.layout.width=Re,ce.layout.flex=0,this.#k&&this.#k("resize",{id:ie,width:Re})}}function J(de){const ie={};return de.width!=null&&(ie.width=de.width),de.hidden!=null&&(ie.hidden=de.hidden),de.pin!==void 0&&(ie.pin=de.pin),ie}function ee(de){if(de===null||typeof de!="object")return de;try{return structuredClone(de)}catch{}try{return JSON.parse(JSON.stringify(de))}catch{return de}}function te(de,ie){const oe=de??null,ce=ie??null;if(oe===ce)return!0;if(oe===null||ce===null)return!1;if(typeof oe!="object"||typeof ce!="object")return oe===ce;try{return JSON.stringify(oe)===JSON.stringify(ce)}catch{return!1}}function ne(de){const ie=[],oe=(fe,ke)=>{const Re=[];for(const Ee of fe){if(!G(Ee)){B("a column definition must be an object");continue}if(Array.isArray(Ee.columns)){I(Ee,k,"columnGroup",Ee.title||Ee.id||"(unnamed)");const Fe={id:Ee.id||O("grp"),title:Ee.title||"",collapsible:Ee.collapsible===!0,openByDefault:Ee.openByDefault!==!1,showWhen:Ee.showWhen||"always",marryChildren:Ee.marryChildren===!0,header:Ee.header||{},def:Ee,columns:[]};Fe.columns=oe(Ee.columns,[...ke,Fe.id]),Re.push(Fe)}else{const Fe={def:Ee,path:ke};ie.push(Fe),Re.push(Fe)}}return Re},ce=oe(de,[]);return{leaves:ie,groups:ce}}function ae(de,ie,oe){for(const ce of de){if(ce.columns){if(ae(ce.columns,ie,oe))return!0;continue}if(ce.column&&ce.column.id===ie)return ce.column=oe,!0}return!1}}),xe("packages/core/src/columns/autogroup.js",function(e,K){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return G}});const L=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_group",F=240,_=.5;function Q(H){const{columns:U,groupBy:z}=H,S=z.map(u=>U.get(u)).filter(Boolean),O=S.length?S.map(u=>u.title||u.id).join(" > "):"Group",b=H.config&&H.config.autoGroupColumnWidth||F;return{id:B,field:null,title:O,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:z.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:b,min:120,pin:H.config&&H.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(u,d){return d&&d.group?d.groupValue:null},formatValue(u,d){if(!d||!d.group)return"";if(d.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";const s=S[Math.min(d.level||0,S.length-1)];return s&&typeof s.formatValue=="function"?s.formatValue(u,d):u==null?"":String(u)}}}function G(H,U,z){!H.length||z<100||U<z*_||L(`grouping.cardinality:${H.join(",")}`,`grouping by ${H.join(", ")} produced ${U} groups for ${z} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),xe("packages/core/src/columns/selectcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const X="__lattice_select",L=44;function B(_){const Q=_.selection||{},G=_.config&&_.config.selectionColumnWidth||L;return{id:X,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:G,min:G,max:G,pin:_.config&&_.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Q.headerCheckbox===!0,def:{},getValue(H,U){return U?U.selected:!1},formatValue(){return""}}}const F=B}),xe("packages/core/src/columns/rownumbercolumn.js",function(e,K){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").isFunction,B="__lattice_rownumber",F=40,_=9,Q=22;function G(z){const S=String(Math.max(1,Math.trunc(Math.abs(z))||1)).length;return Math.max(F,S*_+Q)}function H(z){const S=z.rowNumbers,O=S&&typeof S=="object"?S:{},b=Number.isFinite(O.start)?O.start:1,u=Number.isFinite(O.width)?O.width:G((z.maxNumber||0)+b),d=L(z.rank)?z.rank:()=>null;return{id:B,field:null,title:typeof O.title=="string"?O.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:u,min:u,max:u,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(s,n){const t=d(n);return t==null?null:t-1+b},formatValue(s){return s==null?"":String(s)}}}const U=H}),xe("packages/core/src/model/detail.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=240,_=10;function Q(U){if(!U)return null;const z=U===!0?{}:U;return z.enabled===!1?null:!L(z.rows)&&!z.render?(B("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:z.render||null,config:z.config||null,rows:L(z.rows)?z.rows:null,height:z.height??F,cacheLimit:Number.isFinite(z.cacheLimit)?Math.max(0,z.cacheLimit):_,isMaster:L(z.isMaster)?z.isMaster:null,target:z.target||null,onCreate:L(z.onCreate)?z.onCreate:null,path:typeof z.path=="string"?z.path:null}}class G{#e;#t=new Set;#n;#r=0;constructor(z){this.#e=z.config,this.#n=L(z.onChange)?z.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(z){if(!z||z.group||z.detail)return!1;const S=this.#e.isMaster;return S?!!S(z.data,z):!0}isOpen(z){return this.#t.has(z)}keys(){return[...this.#t]}activeKey(){for(const z of this.#t)return z;return null}heightOf(z){const S=this.#e.height;return L(S)?Number(S(z))||F:S==="auto"?F:Number(S)||F}open(z){return this.#t.has(z)?!1:(this.inline||this.#t.clear(),this.#t.add(z),this.#o(),!0)}close(z){return this.#t.delete(z)?(this.#o(),!0):!1}toggle(z){return this.#t.has(z)?(this.close(z),!1):(this.open(z),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(z){if(!this.#t.size||!L(z))return;let S=!1;for(const O of[...this.#t])z(O)||(this.#t.delete(O),S=!0);S&&this.#o()}signature(){return`${this.#r}`}set(z){this.#t.clear();const S=Array.isArray(z)?z:[];for(const O of this.inline?S:S.slice(0,1))this.#t.add(O);this.#o()}#o(){this.#r++,this.#n()}}const H=G}),xe("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return s}});const X=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),L=3e-12,B=1e-300;function F(n){if(n<.5)return Math.log(Math.PI/Math.sin(Math.PI*n))-F(1-n);const t=n-1;let r=.9999999999998099;const o=t+7.5;for(let f=0;f<X.length;f++)r+=X[f]/(t+f+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(o)-o+Math.log(r)}function _(n,t,r){const o=n+t,f=n+1,l=n-1;let i=1,g=1-o*r/f;Math.abs(g)<B&&(g=B),g=1/g;let c=g;for(let h=1;h<=300;h++){const a=2*h;let m=h*(t-h)*r/((l+a)*(n+a));g=1+m*g,Math.abs(g)<B&&(g=B),i=1+m/i,Math.abs(i)<B&&(i=B),g=1/g,c*=g*i,m=-(n+h)*(o+h)*r/((n+a)*(f+a)),g=1+m*g,Math.abs(g)<B&&(g=B),i=1+m/i,Math.abs(i)<B&&(i=B),g=1/g;const w=g*i;if(c*=w,Math.abs(w-1)<L)break}return c}function Q(n,t,r){if(!(n>0)||!(t>0)||!Number.isFinite(r))return Number.NaN;if(r<=0)return 0;if(r>=1)return 1;const o=Math.exp(F(n+t)-F(n)-F(t)+n*Math.log(r)+t*Math.log(1-r));return r<(n+1)/(n+t+2)?o*_(n,t,r)/n:1-o*_(t,n,1-r)/t}function G(n){if(!(n>0)||!(n<1))return n===0?-1/0:n===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],o=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],f=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],l=.02425;let i,g,c;n<l?(i=Math.sqrt(-2*Math.log(n)),c=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((f[0]*i+f[1])*i+f[2])*i+f[3])*i+1)):n<=1-l?(i=n-.5,g=i*i,c=(((((t[0]*g+t[1])*g+t[2])*g+t[3])*g+t[4])*g+t[5])*i/(((((r[0]*g+r[1])*g+r[2])*g+r[3])*g+r[4])*g+1)):(i=Math.sqrt(-2*Math.log(1-n)),c=-(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((f[0]*i+f[1])*i+f[2])*i+f[3])*i+1));const a=(.5*H(-c/Math.SQRT2)-n)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-a/(1+c*a/2)}function H(n){const t=Math.abs(n),r=2/(2+t),o=4*r-2,f=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let l=0,i=0,g;for(let h=f.length-1;h>0;h--)g=i,i=o*i-l+f[h],l=g;const c=r*Math.exp(-t*t+.5*(f[0]+o*i)-l);return n>=0?c:2-c}function U(n){return .5*H(-n/Math.SQRT2)}function z(n,t){if(!(t>0)||!Number.isFinite(n))return Number.NaN;const r=.5*Q(t/2,.5,t/(t+n*n));return n>0?1-r:r}function S(n,t){if(!(n>0)||!(n<1)||!(t>0))return Number.NaN;if(t>1e7)return G(n);let r=-1e4,o=1e4,f=G(n);const l=F(t/2)+F(.5)-F((t+1)/2);for(let i=0;i<60;i++){const g=z(f,t);g<n?r=f:o=f;const c=Math.exp(-((t+1)/2)*Math.log(1+f*f/t)-l)/Math.sqrt(t),h=c>0?(g-n)/c:0;if(Math.abs(h)<1e-12)break;const a=f-h;if(f=a>r&&a<o&&Number.isFinite(a)?a:(r+o)/2,o-r<1e-12)break}return f}function O(n,t){let r=n,o=1/n,f=o;for(let l=0;l<300&&(r+=1,f*=t/r,o+=f,!(Math.abs(f)<Math.abs(o)*L));l++);return o*Math.exp(-t+n*Math.log(t)-F(n))}function b(n,t){let r=t+1-n,o=1/B,f=1/r,l=f;for(let i=1;i<=300;i++){const g=-i*(i-n);r+=2,f=g*f+r,Math.abs(f)<B&&(f=B),o=r+g/o,Math.abs(o)<B&&(o=B),f=1/f;const c=f*o;if(l*=c,Math.abs(c-1)<L)break}return Math.exp(-t+n*Math.log(t)-F(n))*l}function u(n,t){return!(n>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<n+1?O(n,t):1-b(n,t)}function d(n,t){return t>0?u(t/2,n/2):Number.NaN}function s(n,t){const r=d(n,t);return Number.isNaN(r)?Number.NaN:Math.min(1,Math.max(0,1-r))}}),xe("packages/core/src/compute/linalg.js",function(e,K){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Q}});function X(G){const H=G.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++)for(let S=0;S<=z;S++){let O=G[z][S];for(let b=0;b<S;b++)O-=U[z][b]*U[S][b];if(z===S){if(!(O>0))return null;U[z][S]=Math.sqrt(O)}else U[z][S]=O/U[S][S]}return U}function L(G,H){const U=G.length,z=new Array(U).fill(0);for(let O=0;O<U;O++){let b=H[O];for(let u=0;u<O;u++)b-=G[O][u]*z[u];z[O]=b/G[O][O]}const S=new Array(U).fill(0);for(let O=U-1;O>=0;O--){let b=z[O];for(let u=O+1;u<U;u++)b-=G[u][O]*S[u];S[O]=b/G[O][O]}return S}function B(G){const H=G.length,U=Array.from({length:H},()=>new Array(H).fill(0));for(let z=0;z<H;z++){const S=new Array(H).fill(0);S[z]=1;const O=L(G,S);for(let b=0;b<H;b++)U[b][z]=O[b]}return U}function F(G,H,U){const z=G.length,S=z?G[0].length:0,O=Array.from({length:S},()=>new Array(S).fill(0)),b=new Array(S).fill(0);for(let u=0;u<z;u++){const d=U?U[u]:1,s=G[u];for(let n=0;n<S;n++){const t=d*s[n];b[n]+=t*H[u];for(let r=n;r<S;r++)O[n][r]+=t*s[r]}}for(let u=0;u<S;u++)for(let d=0;d<u;d++)O[u][d]=O[d][u];return{xtwx:O,xtwy:b}}function _(G,H){return G.map(U=>U.reduce((z,S,O)=>z+S*H[O],0))}function Q(G,H){let U=0;for(let z=0;z<G.length;z++){let S=0;for(let O=0;O<G.length;O++)S+=H[z][O]*G[O];U+=G[z]*S}return U}}),xe("packages/core/src/compute/sketch.js",function(e,K){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});class X{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(u){if(!Number.isFinite(u))return;this.#e++;const d=u-this.#t;this.#t+=d/this.#e,this.#n+=d*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const d=this.#e+u.#e,s=u.#t-this.#t;this.#t+=s*(u.#e/d),this.#n+=u.#n+s*s*(this.#e*u.#e/d),this.#e=d}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class L{#e=[];#t=0;#n;#r;constructor(u,d=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=d}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const d=Math.floor(this.#r()*this.#t);d<this.#n&&(this.#e[d]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const d of this.#e)u+=d;return u/this.#e.length}quantile(u){const d=this.#e.length;if(!d)return null;const s=this.#e.slice().sort((o,f)=>o-f);if(d===1)return s[0];const n=(d-1)*Math.min(1,Math.max(0,u)),t=Math.floor(n),r=Math.ceil(n);return t===r?s[t]:s[t]+(n-t)*(s[r]-s[t])}}function B(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function F(b){if(typeof b=="number"){const s=new DataView(new ArrayBuffer(8));return s.setFloat64(0,b===0?0:b),B(s.getUint32(0)^s.getUint32(4))}const u=typeof b=="string"?b:String(b);let d=2166136261;for(let s=0;s<u.length;s++)d^=u.charCodeAt(s),d=Math.imul(d,16777619);return B(d)}class _{#e;#t;#n;constructor(u=14){const d=Math.floor(u);if(d<4||d>16)throw new RangeError("HLL precision must be 4..16");this.#e=d,this.#t=1<<d,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const d=1<<Math.floor(u),s=1.04/Math.sqrt(d);return Object.freeze({kind:"probabilistic",metric:"relative",value:s,statement:`distinct count within ~${(s*100).toFixed(2)}% relative standard error (m=${d} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(u){const d=F(u),s=d&this.#t-1,n=d>>>this.#e|1<<32-this.#e;let t=1,r=n;for(;(r&1)===0;)t++,r>>>=1;t>this.#n[s]&&(this.#n[s]=t)}count(){const u=this.#t,d=32-this.#e,s=new Float64Array(d+2);for(let r=0;r<u;r++)s[this.#n[r]]++;let n=u*H(1-s[d+1]/u);for(let r=d;r>=1;r--)n=.5*(n+s[r]);n+=u*G(s[0]/u);const t=Q*u*u/n;return Math.round(t)}}const Q=.5/Math.log(2);function G(b){if(b===1)return 1/0;let u=1,d=b,s;do b*=b,s=d,d+=b*u,u+=u;while(d!==s);return d}function H(b){if(b===0||b===1)return 0;let u=1,d=1-b,s;do b=Math.sqrt(b),s=d,u*=.5,d-=(1-b)**2*u;while(d!==s);return d/3}class U{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const d=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:d,statement:`each count overestimates the truth by at most N/m = ${d.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const d=this.#e.get(u);if(d){d.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let s,n=1/0;for(const[t,r]of this.#e)r.count<n&&(n=r.count,s=t);this.#e.delete(s),this.#e.set(u,{count:n+1,error:n})}top(u=this.#t){return[...this.#e.entries()].map(([s,n])=>({item:s,count:n.count,error:n.error})).sort((s,n)=>n.count-s.count).slice(0,Math.max(0,Math.floor(u)))}}class z{#e;#t=[[]];#n=0;#r;#o;constructor(u=200,d=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=d,this.#o=2/3}static errorBoundFor(u=200){const d=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:d,statement:`queried quantile's true rank within ~${(d*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return z.errorBoundFor(this.#e)}get count(){return this.#n}#i(u){const s=this.#t.length-1-u,n=Math.ceil(this.#e*this.#o**s);return Math.max(2,n)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(u){const d=this.#t[u];d.sort((t,r)=>t-r),u+1>=this.#t.length&&this.#t.push([]);const s=this.#t[u+1],n=this.#r()<.5?0:1;for(let t=n;t<d.length;t+=2)s.push(d[t]);this.#t[u]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const u=[];for(let d=0;d<this.#t.length;d++){const s=1<<d;for(const n of this.#t[d])u.push({v:n,w:s})}return u}quantile(u){const d=this.#l();if(!d.length)return null;d.sort((r,o)=>r.v-o.v);let s=0;for(const r of d)s+=r.w;const n=Math.min(1,Math.max(0,u))*s;let t=0;for(const r of d)if(t+=r.w,t>=n)return r.v;return d[d.length-1].v}rank(u){let d=0;for(let s=0;s<this.#t.length;s++){const n=1<<s;for(const t of this.#t[s])t<=u&&(d+=n)}return d}}const S=Object.freeze({distinct:_.errorBoundFor(14),median:z.errorBoundFor(200),p25:z.errorBoundFor(200),p75:z.errorBoundFor(200),p90:z.errorBoundFor(200),p95:z.errorBoundFor(200),p99:z.errorBoundFor(200),iqr:z.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),O={Welford:X,Reservoir:L,HyperLogLog:_,SpaceSaving:U,KLL:z,hash32:F,SKETCH_BOUNDS:S}}),xe("packages/core/src/compute/statistics.js",function(e,K){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return rt}});const X=K("packages/core/src/compute/handle.js"),L=X.presenceReader,B=X.valueReader,F=K("packages/core/src/compute/special.js"),_=F.studentTQuantile,Q=F.studentT,G=F.normalQuantile,H=F.normalCdf,U=F.chiSquareUpperTail,z=K("packages/core/src/compute/linalg.js"),S=z.cholesky,O=z.choleskySolve,b=z.choleskyInverse,u=z.normalEquations,d=z.quadForm,n=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,r=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),o=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:n.distinct}),median:Object.freeze({sketch:"KLL",bound:n.median}),p25:Object.freeze({sketch:"KLL",bound:n.p25}),p75:Object.freeze({sketch:"KLL",bound:n.p75}),p90:Object.freeze({sketch:"KLL",bound:n.p90}),p95:Object.freeze({sketch:"KLL",bound:n.p95}),p99:Object.freeze({sketch:"KLL",bound:n.p99}),iqr:Object.freeze({sketch:"KLL",bound:n.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:n.topK})});function f(ge){const we=ge==="sum"||ge==="avg"||ge==="countValues"||ge==="min"||ge==="max"?"maintained":Object.prototype.hasOwnProperty.call(r,ge)?r[ge]:null,ve=Object.prototype.hasOwnProperty.call(o,ge)?o[ge]:null;return{stat:ge,exact:we,approximate:ve}}function l(ge,we){const ve=we.length,Ae=new Float64Array(ve);let Le=0;if(ge&&(ge.kind==="float64"||ge.kind==="int32")){const je=ge.values,Ne=L(ge);for(let De=0;De<ve;De++){const qe=we[De];if(Ne&&Ne(qe)!==1)continue;const st=je[qe];Number.isNaN(st)||(Ae[Le++]=st)}return Ae.subarray(0,Le)}const Me=B(ge);for(let je=0;je<ve;je++){const Ne=Me(we[je]);if(Ne==null||Ne==="")continue;const De=typeof Ne=="number"?Ne:Number(Ne);Number.isFinite(De)&&(Ae[Le++]=De)}return Ae.subarray(0,Le)}function i(ge,we){const ve=new Map,Ae=B(ge);let Le=0;for(let Me=0;Me<we.length;Me++){const je=Ae(we[Me]);if(je==null||je===""||typeof je=="number"&&Number.isNaN(je))continue;const Ne=typeof je=="object"?String(je):je;ve.set(Ne,(ve.get(Ne)||0)+1),Le++}const me=[...ve.values()].sort((Me,je)=>je-Me);return{counts:me,total:Le,distinct:me.length}}function g(ge){return ge.total>0?ge.counts.map(we=>we/ge.total):[]}function c(ge,we){const ve=i(ge,we);if(!ve.total)return null;let Ae=0;for(const Le of g(ve))Ae+=Le*Le;return Ae}function h(ge,we){const ve=i(ge,we);if(!ve.total)return null;let Ae=0;for(const Le of g(ve))Le>0&&(Ae-=Le*Math.log2(Le));return Ae}function a(ge,we){const ve=i(ge,we);if(!ve.total||ve.distinct<2)return ve.total?1:null;let Ae=0;for(const Le of g(ve))Le>0&&(Ae-=Le*Math.log2(Le));return Ae/Math.log2(ve.distinct)}function m(ge,we,ve=3){const Ae=i(ge,we);if(!Ae.total)return null;const Le=Math.max(1,Math.floor(ve));let me=0;for(let Me=0;Me<Math.min(Le,Ae.counts.length);Me++)me+=Ae.counts[Me];return me/Ae.total}function w(ge,we){const ve=l(ge,we),Ae=ve.length;if(!Ae)return null;const Le=ve.slice().sort();if(Le[0]<0)return null;let me=0,Me=0;for(let je=0;je<Ae;je++)me+=Le[je],Me+=(je+1)*Le[je];return me===0?0:2*Me/(Ae*me)-(Ae+1)/Ae}function v(ge){let we=0,ve=0,Ae=0;for(let Le=0;Le<ge.length;Le++){const me=ge[Le];we++;const Me=me-ve;ve+=Me/we,Ae+=Me*(me-ve)}return{n:we,mean:ve,m2:Ae}}function p(ge,we){const ve=ge.length;if(!ve)return NaN;if(ve===1)return ge[0];const Ae=(ve-1)*Math.min(1,Math.max(0,we)),Le=Math.floor(Ae),me=Math.ceil(Ae);return Le===me?ge[Le]:ge[Le]+(Ae-Le)*(ge[me]-ge[Le])}function y(ge,we){if(!ge.length)return NaN;const ve=ge.slice().sort();return p(ve,we)}function C(ge,we){const ve=B(ge);let Ae=0,Le=0,me=0;for(let Me=0;Me<we.length;Me++){const je=ve(we[Me]);if(je==null||je==="")continue;const Ne=String(je).toUpperCase();Ne==="PASS"?Ae++:Ne==="FAIL"?Le++:Ne==="WARN"&&me++}return{pass:Ae+me,fail:Le,warn:me,judged:Ae+me+Le}}const T=Object.freeze({hhi:(ge,we)=>c(ge,we),entropy:(ge,we)=>h(ge,we),evenness:(ge,we)=>a(ge,we),top3Share:(ge,we)=>m(ge,we,3),top10Share:(ge,we)=>m(ge,we,10),gini:(ge,we)=>w(ge,we),trimmedMean:(ge,we)=>A(l(ge,we),.1),winsorizedMean:(ge,we)=>$(l(ge,we),.1),robustOutliers:(ge,we)=>D(l(ge,we),3.5),jarqueBera:(ge,we)=>M(l(ge,we)),variance:(ge,we)=>{const{n:ve,m2:Ae}=v(l(ge,we));return ve>1?Ae/(ve-1):null},varianceP:(ge,we)=>{const{n:ve,m2:Ae}=v(l(ge,we));return ve>0?Ae/ve:null},stddev:(ge,we)=>{const{n:ve,m2:Ae}=v(l(ge,we));return ve>1?Math.sqrt(Ae/(ve-1)):null},stddevP:(ge,we)=>{const{n:ve,m2:Ae}=v(l(ge,we));return ve>0?Math.sqrt(Ae/ve):null},median:(ge,we)=>{const ve=l(ge,we);return ve.length?y(ve,.5):null},p25:(ge,we)=>{const ve=l(ge,we);return ve.length?y(ve,.25):null},p75:(ge,we)=>{const ve=l(ge,we);return ve.length?y(ve,.75):null},p90:(ge,we)=>{const ve=l(ge,we);return ve.length?y(ve,.9):null},p95:(ge,we)=>{const ve=l(ge,we);return ve.length?y(ve,.95):null},p99:(ge,we)=>{const ve=l(ge,we);return ve.length?y(ve,.99):null},iqr:(ge,we)=>{const ve=l(ge,we);if(!ve.length)return null;const Ae=ve.slice().sort();return p(Ae,.75)-p(Ae,.25)},mad:(ge,we)=>{const ve=l(ge,we);if(!ve.length)return null;const Ae=y(ve,.5),Le=new Float64Array(ve.length);for(let me=0;me<ve.length;me++)Le[me]=Math.abs(ve[me]-Ae);return y(Le,.5)},range:(ge,we)=>{const ve=l(ge,we);if(!ve.length)return null;let Ae=1/0,Le=-1/0;for(let me=0;me<ve.length;me++)ve[me]<Ae&&(Ae=ve[me]),ve[me]>Le&&(Le=ve[me]);return Le-Ae},distinct:(ge,we)=>{const ve=B(ge),Ae=new Set;for(let Le=0;Le<we.length;Le++){const me=ve(we[Le]);me==null||me===""||Ae.add(me instanceof Date?me.getTime():me)}return Ae.size},mode:(ge,we)=>{const ve=B(ge),Ae=new Map;for(let Me=0;Me<we.length;Me++){const je=ve(we[Me]);if(je==null||je==="")continue;const Ne=je instanceof Date?je.getTime():je;Ae.set(Ne,(Ae.get(Ne)||0)+1)}let Le=null,me=1;for(const[Me,je]of Ae)je>me&&(me=je,Le=Me);return Le},skewness:(ge,we)=>{const ve=l(ge,we),{n:Ae,mean:Le,m2:me}=v(ve);if(Ae<3||me<=0)return null;const Me=Math.sqrt(me/(Ae-1));let je=0;for(let Ne=0;Ne<ve.length;Ne++)je+=((ve[Ne]-Le)/Me)**3;return Ae/((Ae-1)*(Ae-2))*je},kurtosis:(ge,we)=>{const ve=l(ge,we),{n:Ae,mean:Le,m2:me}=v(ve);if(Ae<4||me<=0)return null;const Me=Math.sqrt(me/(Ae-1));let je=0;for(let qe=0;qe<ve.length;qe++)je+=((ve[qe]-Le)/Me)**4;const Ne=Ae*(Ae+1)/((Ae-1)*(Ae-2)*(Ae-3)),De=3*(Ae-1)**2/((Ae-2)*(Ae-3));return Ne*je-De},geomean:(ge,we)=>{const ve=l(ge,we);if(!ve.length)return null;let Ae=0;for(let Le=0;Le<ve.length;Le++){if(ve[Le]<=0)return null;Ae+=Math.log(ve[Le])}return Math.exp(Ae/ve.length)},harmean:(ge,we)=>{const ve=l(ge,we);if(!ve.length)return null;let Ae=0;for(let Le=0;Le<ve.length;Le++){if(ve[Le]===0)return null;Ae+=1/ve[Le]}return ve.length/Ae},sumSquares:(ge,we)=>{const ve=l(ge,we);let Ae=0;for(let Le=0;Le<ve.length;Le++)Ae+=ve[Le]*ve[Le];return Ae},passRate:(ge,we)=>{const{pass:ve,judged:Ae}=C(ge,we);return Ae?ve/Ae:null},failureCount:(ge,we)=>C(ge,we).fail}),P=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function x(ge,we,ve){const Ae=B(ge),Le=B(we);let me=0,Me=0;for(let je=0;je<ve.length;je++){const Ne=ve[je],De=Number(Ae(Ne)),qe=Number(Le(Ne));!Number.isFinite(De)||!Number.isFinite(qe)||(me+=De*qe,Me+=qe)}return Me===0?null:me/Me}function E(ge,we,ve){const Ae=B(ge);let Le=null,me=ve?-1/0:1/0;for(let Me=0;Me<we.length;Me++){const je=we[Me],Ne=Number(Ae(je));Number.isFinite(Ne)&&(ve?Ne>me:Ne<me)&&(me=Ne,Le=je)}return Le}function j(ge,we,ve){const Ae=B(ge),Le=B(we);let me=0,Me=0,je=0,Ne=0,De=0,qe=0;for(let at=0;at<ve.length;at++){const vt=ve[at],dt=Number(Ae(vt)),mt=Number(Le(vt));!Number.isFinite(dt)||!Number.isFinite(mt)||(me++,Me+=dt,je+=mt,Ne+=dt*dt,De+=mt*mt,qe+=dt*mt)}if(me<2)return null;const st=me*qe-Me*je,ct=Math.sqrt((me*Ne-Me*Me)*(me*De-je*je));if(ct===0)return null;const ft=st/ct;return Math.max(-1,Math.min(1,ft))}function A(ge,we=.1){const ve=ge.length;if(!ve)return null;const Ae=Array.from(ge).sort((je,Ne)=>je-Ne),Le=Math.floor(ve*Math.min(.49,Math.max(0,we))),me=Ae.slice(Le,ve-Le);if(!me.length)return p(Ae,.5);let Me=0;for(const je of me)Me+=je;return Me/me.length}function $(ge,we=.1){const ve=ge.length;if(!ve)return null;const Ae=Array.from(ge).sort((Ne,De)=>Ne-De),Le=Math.floor(ve*Math.min(.49,Math.max(0,we))),me=Ae[Le],Me=Ae[ve-1-Le];let je=0;for(const Ne of Ae)je+=Math.min(Me,Math.max(me,Ne));return je/ve}function D(ge,we=3.5){if(!ge.length)return null;const Ae=Array.from(ge).sort((Ne,De)=>Ne-De),Le=p(Ae,.5),me=Ae.map(Ne=>Math.abs(Ne-Le)).sort((Ne,De)=>Ne-De),Me=p(me,.5);if(Me===0)return null;let je=0;for(const Ne of Ae)Math.abs(.6745*(Ne-Le)/Me)>we&&je++;return je}function M(ge){const we=ge.length;if(we<8)return null;let ve=0;for(const Ne of ge)ve+=Ne;ve/=we;let Ae=0,Le=0,me=0;for(const Ne of ge){const De=Ne-ve;Ae+=De*De,Le+=De*De*De,me+=De*De*De*De}if(Ae/=we,Le/=we,me/=we,Ae===0)return null;const Me=Le/Ae**1.5,je=me/(Ae*Ae)-3;return we/6*(Me*Me+je*je/4)}function R(ge,we,ve){const Ae=[];let Le=0;for(let Ne=0;Ne<ge.length;Ne++){const De=Number(ge[Ne]),qe=Number(we[Ne]);!Number.isFinite(De)||!Number.isFinite(qe)||qe<=0||(Ae.push([De,qe]),Le+=qe)}if(!Ae.length||Le<=0)return null;if(Ae.sort((Ne,De)=>Ne[0]-De[0]),Ae.length===1)return Ae[0][0];const me=[];let Me=0;for(const[,Ne]of Ae)me.push((Me+Ne/2)/Le),Me+=Ne;const je=Math.max(0,Math.min(1,ve));if(je<=me[0])return Ae[0][0];if(je>=me[me.length-1])return Ae[Ae.length-1][0];for(let Ne=1;Ne<me.length;Ne++){if(je>me[Ne])continue;const De=me[Ne]-me[Ne-1],qe=De>0?(je-me[Ne-1])/De:0;return Ae[Ne-1][0]+(Ae[Ne][0]-Ae[Ne-1][0])*qe}return Ae[Ae.length-1][0]}function k(ge,we,ve){const Ae=B(ge),Le=B(we),me=new Float64Array(ve.length),Me=new Float64Array(ve.length);let je=0;for(let Ne=0;Ne<ve.length;Ne++){const De=ve[Ne],qe=Number(Ae(De)),st=Number(Le(De));!Number.isFinite(qe)||!Number.isFinite(st)||(me[je]=qe,Me[je]=st,je++)}return{xs:me.subarray(0,je),ys:Me.subarray(0,je),n:je}}function I(ge,we,ve,Ae=!1){const{xs:Le,ys:me,n:Me}=k(ge,we,ve);if(Me<2)return null;let je=0,Ne=0;for(let qe=0;qe<Me;qe++)je+=Le[qe],Ne+=me[qe];je/=Me,Ne/=Me;let De=0;for(let qe=0;qe<Me;qe++)De+=(Le[qe]-je)*(me[qe]-Ne);return De/(Ae?Me:Me-1)}function q(ge,we,ve){const{xs:Ae,ys:Le,n:me}=k(ge,we,ve);if(me<2)return null;let Me=0,je=0;for(let dt=0;dt<me;dt++)Me+=Ae[dt],je+=Le[dt];Me/=me,je/=me;let Ne=0,De=0,qe=0;for(let dt=0;dt<me;dt++){const mt=Ae[dt]-Me,jt=Le[dt]-je;Ne+=mt*mt,De+=mt*jt,qe+=jt*jt}if(Ne===0)return null;const st=De/Ne,ct=je-st*Me,ft=qe===0?1:Math.max(0,Math.min(1,De*De/(Ne*qe))),at=Math.max(0,qe-st*De),vt=me>2?Math.sqrt(at/(me-2)/Ne):0;return{slope:st,intercept:ct,r2:ft,stdError:vt,n:me}}const Z=new Set(["ols","wls","robust"]),W=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ee=1.345;function te(ge,we,ve){const{xtwx:Ae,xtwy:Le}=u(ge,we,ve),me=S(Ae);if(!me)return null;const Me=O(me,Le),je=b(me),Ne=ne(ge,Me),De=we.map((qe,st)=>qe-Ne[st]);return{beta:Me,cov:je,fitted:Ne,residuals:De}}function ne(ge,we){return ge.map(ve=>ve.reduce((Ae,Le,me)=>Ae+Le*we[me],0))}function ae(ge,we){const ve=ge.length,Ae=ge.map(De=>De[we]),Le=ge.map(De=>[1,...De.filter((qe,st)=>st!==we)]),me=te(Le,Ae,null);if(!me)return 1;const Me=Ae.reduce((De,qe)=>De+qe,0)/ve;let je=0,Ne=0;for(let De=0;De<ve;De++)je+=me.residuals[De]**2,Ne+=(Ae[De]-Me)**2;return Ne===0?1:Math.max(0,Math.min(1,1-je/Ne))}function de(ge){const we=[...ge].sort((Le,me)=>Le-me),ve=ie(we),Ae=ge.map(Le=>Math.abs(Le-ve)).sort((Le,me)=>Le-me);return ie(Ae)/.6745}function ie(ge){const we=ge.length;if(!we)return 0;const ve=Math.floor(we/2);return we%2?ge[ve]:(ge[ve-1]+ge[ve])/2}function oe(ge,we,ve={}){const Ae=ve.method||"ols";if(J.has(Ae))throw new Error(`[lattice] regression method "${Ae}" is out of scope; use ols, wls or robust.`);if(W.has(Ae))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Z.has(Ae))throw new Error(`[lattice] unknown regression method "${Ae}"; use ols, wls or robust.`);const Le=Array.isArray(we)?we.length:0,me=Le&&Array.isArray(ge[0])?ge[0].length:0,Me=me+1;if(!(Le>Me))return null;for(let Ct=0;Ct<Le;Ct++){if(!Number.isFinite(we[Ct])||!Array.isArray(ge[Ct])||ge[Ct].length!==me)return null;for(let xt=0;xt<me;xt++)if(!Number.isFinite(ge[Ct][xt]))return null}let je=null;if(Ae==="wls"){if(je=ve.weights,!Array.isArray(je)||je.length!==Le)return null;for(let Ct=0;Ct<Le;Ct++)if(!(je[Ct]>0)||!Number.isFinite(je[Ct]))return null}const Ne=ge.map(Ct=>[1,...Ct]);let De,qe=null;if(Ae==="robust"){if(De=te(Ne,we,null),!De)return null;for(let Ct=0;Ct<50;Ct++){const xt=de(De.residuals);if(!(xt>0))break;const zt=De.residuals.map(Yt=>{const Qt=Math.abs(Yt/xt);return Qt<=ee?1:ee/Qt}),Kt=te(Ne,we,zt);if(!Kt)return null;const Xt=Kt.beta.reduce((Yt,Qt,rn)=>Math.max(Yt,Math.abs(Qt-De.beta[rn])),0);if(De=Kt,qe=zt,Xt<1e-10)break}}else if(De=te(Ne,we,je),!De)return null;const st=Ae==="robust"?qe:je,{beta:ct,cov:ft,fitted:at,residuals:vt}=De;let dt=0,mt=0,jt=0;for(let Ct=0;Ct<Le;Ct++){const xt=st?st[Ct]:1;dt+=xt*vt[Ct]**2,mt+=xt,jt+=xt*we[Ct]}const He=jt/mt;let ut=0;for(let Ct=0;Ct<Le;Ct++){const xt=st?st[Ct]:1;ut+=xt*(we[Ct]-He)**2}const it=Le-Me,kt=dt/it,Rt=ut===0?1:Math.max(0,Math.min(1,1-dt/ut)),It=1-(1-Rt)*(Le-1)/it,yt=Array.isArray(ve.names)&&ve.names.length===me?ve.names:ge[0].map((Ct,xt)=>`x${xt+1}`),Lt=Pt(ve.confidence),Ut=it>0?_(1-(1-Lt)/2,it):1/0,Jt=ct.map((Ct,xt)=>{const zt=Math.sqrt(Math.max(0,kt*ft[xt][xt])),Kt=zt>0?Ct/zt:Ct===0?0:1/0,Xt=Number.isFinite(Kt)?2*(1-Q(Math.abs(Kt),it)):0,Yt=Number.isFinite(Ut)?Ut*zt:null;return{name:xt===0?"(intercept)":yt[xt-1],estimate:Ct,stdError:zt,t:Kt,p:Math.max(0,Math.min(1,Xt)),lower:Yt===null?null:Ct-Yt,upper:Yt===null?null:Ct+Yt}}),pn=new Array(Le),an=new Array(Le);for(let Ct=0;Ct<Le;Ct++){const xt=st?st[Ct]:1,zt=Math.max(0,Math.min(1,xt*d(Ne[Ct],ft)));pn[Ct]=zt;const Kt=(1-zt)**2;an[Ct]=Kt>0&&kt>0?vt[Ct]**2/(Me*kt)*(zt/Kt):null}const dn=ge[0].map((Ct,xt)=>{if(me<2)return 1;const zt=ae(ge,xt);return zt>=1?1/0:1/(1-zt)});let qt=null;{const Ct=vt.map(zt=>zt*zt),xt=te(Ne,Ct,null);if(xt){const zt=Ct.reduce((en,cn)=>en+cn,0)/Le;let Kt=0,Xt=0;for(let en=0;en<Le;en++)Kt+=xt.residuals[en]**2,Xt+=(Ct[en]-zt)**2;const Yt=Xt===0?0:Math.max(0,Math.min(1,1-Kt/Xt)),Qt=Le*Yt,rn=U(Qt,me);qt={statistic:Qt,df:me,p:rn,heteroscedastic:rn<.05}}}let _t=null;if(me===1){const Ct=ge.map((xt,zt)=>zt).sort((xt,zt)=>ge[xt][0]-ge[zt][0]);_t={confidence:Lt,points:Ct.map(xt=>{const zt=Ne[xt],Kt=Math.sqrt(Math.max(0,kt*d(zt,ft)));return{x:ge[xt][0],yhat:at[xt],lower:at[xt]-Ut*Kt,upper:at[xt]+Ut*Kt}})}}return{method:Ae,coefficients:Jt,r2:Rt,adjR2:It,n:Le,df:it,sigma2:kt,fitted:at,residuals:vt,leverage:pn,cooksD:an,vif:dn,heteroscedasticity:qt,band:_t,weights:st?[...st]:null}}function ce(ge){const we=ge.length,ve=Array.from({length:we},(me,Me)=>Me).sort((me,Me)=>ge[me]-ge[Me]),Ae=new Float64Array(we);let Le=0;for(;Le<we;){let me=Le;for(;me+1<we&&ge[ve[me+1]]===ge[ve[Le]];)me++;const Me=(Le+me)/2+1;for(let je=Le;je<=me;je++)Ae[ve[je]]=Me;Le=me+1}return Ae}const fe=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(ge){const we=[.01,.05,.1],ve=[fe["1%"],fe["5%"],fe["10%"]];if(ge<=ve[0]){const me=(Math.log(we[1])-Math.log(we[0]))/(ve[1]-ve[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(we[0])+me*(ge-ve[0]))))}if(ge>=ve[2]){const me=(Math.log(we[2])-Math.log(we[1]))/(ve[2]-ve[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(we[2])+me*(ge-ve[2]))))}const Ae=ge<ve[1]?0:1,Le=(ge-ve[Ae])/(ve[Ae+1]-ve[Ae]);return Math.exp(Math.log(we[Ae])+Le*(Math.log(we[Ae+1])-Math.log(we[Ae])))}function Re(ge,we,ve,Ae){const Le=ve-Ae,me=Ae+3,Me=new Array(Le),je=new Array(Le);let Ne=!0,De=Ae;for(let at=0;at<Le;at++){const vt=Ae+at,dt=new Float64Array(me);dt[0]=1,dt[1]=at+1,dt[2]=ge[vt];for(let mt=1;mt<=Ae;mt++)dt[2+mt]=we[vt-mt];for(let mt=1;mt<me;mt++)Number.isFinite(dt[mt])||(De=Math.min(De,mt-3));Me[at]=dt,je[at]=we[vt],Number.isFinite(je[at])||(Ne=!1)}if(!Ne)return 0;const{xtwx:qe,xtwy:st}=u(Me,je,null);let ct=0,ft=1/0;for(let at=0;at<=De;at++){const vt=at+3;if(!(Le>vt))continue;const dt=new Array(vt);for(let Rt=0;Rt<vt;Rt++)dt[Rt]=qe[Rt].slice(0,vt);const mt=S(dt);if(!mt)continue;const jt=O(mt,st.slice(0,vt));let He=0;for(let Rt=0;Rt<Le;Rt++){const It=Me[Rt];let yt=0;for(let Lt=0;Lt<vt;Lt++)yt+=It[Lt]*jt[Lt];He+=(je[Rt]-yt)**2}const it=He/(Le-vt)*(Le-vt);if(!(it>0))continue;const kt=Le*Math.log(it/Le)+2*vt;kt<ft&&(ft=kt,ct=at)}return ct}function Ee(ge,we={}){const ve=[];for(let ft=0;ft<ge.length;ft++){const at=Number(ge[ft]);Number.isFinite(at)&&ve.push(at)}const Ae=ve.length,Le=Ae-1;if(Ae<8||Le<6)return null;const me=new Array(Le);for(let ft=0;ft<Le;ft++)me[ft]=ve[ft+1]-ve[ft];let Me=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.ceil(12*(Ae/100)**.25);Me=Math.max(0,Math.min(Me,Math.floor((Le-5)/2)));const je=(ft,at)=>{const vt=[],dt=[];for(let mt=at;mt<Le;mt++){const jt=[mt-at+1,ve[mt]];for(let He=1;He<=ft;He++)jt.push(me[mt-He]);vt.push(jt),dt.push(me[mt])}return oe(vt,dt,{method:"ols"})},Ne=Re(ve,me,Le,Me),De=je(Ne,Ne);if(!De||!De.coefficients[2])return null;const qe=De.coefficients[2].t,st=ke(qe),ct=qe<fe["5%"];return{statistic:qe,usedLag:Ne,nobs:Le-Ne,criticalValues:{...fe},pValue:st,pApproximate:!0,stationary:ct,verdict:ct?"stationary":"non-stationary",regression:"ct"}}function Fe(ge,we={}){const ve=[];for(let ct=0;ct<ge.length;ct++){const ft=Number(ge[ct]);Number.isFinite(ft)&&ve.push(ft)}const Ae=ve.length;if(Ae<3)return null;let Le=Number.isFinite(we.maxlag)?Math.floor(we.maxlag):Math.min(10,Ae-1);Le=Math.max(1,Math.min(Le,Ae-1));let me=0;for(const ct of ve)me+=ct;me/=Ae;const Me=ve.map(ct=>ct-me);let je=0;for(const ct of Me)je+=ct*ct;je/=Ae;const Ne=new Array(Le+1).fill(0);Ne[0]=1;for(let ct=1;ct<=Le;ct++){let ft=0;for(let at=ct;at<Ae;at++)ft+=Me[at]*Me[at-ct];Ne[ct]=je>0?ft/Ae/je:0}const De=new Array(Le+1).fill(0);De[0]=1;let qe=[];for(let ct=1;ct<=Le;ct++){let ft=Ne[ct];for(let mt=1;mt<ct;mt++)ft-=qe[mt-1]*Ne[ct-mt];let at=1;for(let mt=1;mt<ct;mt++)at-=qe[mt-1]*Ne[mt];const vt=at!==0?ft/at:0,dt=new Array(ct);for(let mt=1;mt<ct;mt++)dt[mt-1]=qe[mt-1]-vt*qe[ct-1-mt];dt[ct-1]=vt,De[ct]=vt,qe=dt}const st=1.96/Math.sqrt(Ae);return{acf:Ne,pacf:De,bounds:{upper:st,lower:-st},n:Ae,nlags:Le,approximate:!0}}function ye(ge,we,ve){const{xs:Ae,ys:Le,n:me}=k(ge,we,ve);if(me<2)return null;const Me=ce(Ae),je=ce(Le);let Ne=0,De=0;for(let ft=0;ft<me;ft++)Ne+=Me[ft],De+=je[ft];Ne/=me,De/=me;let qe=0,st=0,ct=0;for(let ft=0;ft<me;ft++){const at=Me[ft]-Ne,vt=je[ft]-De;qe+=at*vt,st+=at*at,ct+=vt*vt}return st===0||ct===0?null:Math.max(-1,Math.min(1,qe/Math.sqrt(st*ct)))}function he(ge,we,ve){const{xs:Ae,ys:Le,n:me}=k(ge,we,ve);if(me<2||me>t)return null;let Me=0,je=0,Ne=0,De=0;for(let ct=0;ct<me;ct++)for(let ft=ct+1;ft<me;ft++){const at=Math.sign(Ae[ct]-Ae[ft]),vt=Math.sign(Le[ct]-Le[ft]),dt=at*vt;dt>0?Me++:dt<0?je++:at===0&&vt===0||(at===0?Ne++:De++)}const qe=Me+je+De,st=Me+je+Ne;return qe===0||st===0?null:(Me-je)/Math.sqrt(qe*st)}function Se(ge,we={}){const ve=ge.length;if(ve<2)return null;const Ae=ge[0],Le=ge[ve-1],me=[];for(let mt=1;mt<ve;mt++){const jt=ge[mt-1];jt!==0&&me.push((ge[mt]-jt)/Math.abs(jt))}let Me=null;if(me.length>1){let mt=0;for(const He of me)mt+=He;mt/=me.length;let jt=0;for(const He of me)jt+=(He-mt)**2;Me=Math.sqrt(jt/(me.length-1))}const je=Number(we.periodsPerYear)>0?Number(we.periodsPerYear):null;let Ne=ge[0],De=0,qe=0,st=0,ct=0;for(let mt=1;mt<ve;mt++){if(ge[mt]>Ne){Ne=ge[mt],De=mt;continue}if(Ne<=0)continue;const jt=(Ne-ge[mt])/Ne;jt>qe&&(qe=jt,st=De,ct=mt)}let ft=null;if(ve>2){let mt=0;for(let ut=0;ut<ve;ut++)mt+=ge[ut];mt/=ve;let jt=0,He=0;for(let ut=0;ut<ve;ut++){const it=ge[ut]-mt;He+=it*it,ut>0&&(jt+=it*(ge[ut-1]-mt))}ft=He>0?jt/He:null}let at=0,vt=0;for(const mt of me)mt>0?at++:mt<0&&vt++;let dt=null;if(Ae>0&&Le>0){const mt=(Le/Ae)**(1/(ve-1))-1;dt=je?(1+mt)**je-1:mt}return{n:ve,first:Ae,last:Le,change:Le-Ae,changePercent:Ae===0?null:(Le-Ae)/Math.abs(Ae)*100,volatility:Me,annualisedVolatility:Me!==null&&je?Me*Math.sqrt(je):null,growth:dt,maxDrawdown:qe,maxDrawdownFrom:st,maxDrawdownTo:ct,autocorrelation:ft,upDays:at,downDays:vt}}const Ce=1.128,Ie=3.267;function ze(ge){const we=ge.length;if(we<2)return null;const ve=[];for(let Le=1;Le<we;Le++)ve.push(Math.abs(ge[Le]-ge[Le-1]));const Ae=ve.reduce((Le,me)=>Le+me,0)/ve.length;return{ranges:ve,centre:Ae,upper:Ie*Ae,lower:0}}function Xe(ge){const we=ge.length;if(we<2)return null;let ve=0;for(let Le=1;Le<we;Le++)ve+=Math.abs(ge[Le]-ge[Le-1]);const Ae=ve/(we-1);return{sigma:Ae/Ce,meanRange:Ae}}function Je(ge,we){const ve=ge.length;if(ve<2||!we)return null;const Ae=Number.isFinite(Number(we.lower))?Number(we.lower):null,Le=Number.isFinite(Number(we.upper))?Number(we.upper):null;if(Ae===null&&Le===null)return null;let me=0;for(let at=0;at<ve;at++)me+=ge[at];me/=ve;let Me=0;for(let at=0;at<ve;at++)Me+=(ge[at]-me)**2;const je=Math.sqrt(Me/(ve-1)),Ne=Xe(ge),De=Ne?Ne.sigma:null,qe=at=>{if(!at||at<=0)return{index:null,k:null};const dt=Ae!==null&&Le!==null?(Le-Ae)/(6*at):null,mt=Le!==null?(Le-me)/(3*at):1/0,jt=Ae!==null?(me-Ae)/(3*at):1/0;return{index:dt,k:Math.min(mt,jt)}},st=qe(De),ct=qe(je);let ft=0;for(let at=0;at<ve;at++){if(Ae!==null&&ge[at]<Ae){ft++;continue}Le!==null&&ge[at]>Le&&ft++}return{n:ve,mean:me,lower:Ae,upper:Le,target:Number.isFinite(Number(we.target))?Number(we.target):null,sigmaWithin:De,sigmaOverall:je,cp:st.index,cpk:st.k,pp:ct.index,ppk:ct.k,outOfSpec:ft,defectRate:ve?ft/ve:null}}function Te(ge){const we=ge.length;if(we<2)return null;const ve=Xe(ge);if(!ve||!(ve.sigma>0))return null;let Ae=0;for(let Le=0;Le<we;Le++)Ae+=ge[Le];return Ae/=we,{centre:Ae,sigma:ve.sigma,upper:Ae+3*ve.sigma,lower:Ae-3*ve.sigma}}function _e(ge,we){if(!we||!(we.sigma>0))return[];const ve=ge.length,{centre:Ae,sigma:Le}=we,me=je=>(ge[je]-Ae)/Le,Me=[];for(let je=0;je<ve;je++){if(Math.abs(me(je))>3&&Me.push({index:je,rule:1,description:"beyond three sigma"}),je>=2)for(const Ne of[1,-1]){let De=0;for(let qe=je-2;qe<=je;qe++)me(qe)*Ne>2&&De++;if(De>=2){Me.push({index:je,rule:2,description:"two of three past two sigma"});break}}if(je>=4)for(const Ne of[1,-1]){let De=0;for(let qe=je-4;qe<=je;qe++)me(qe)*Ne>1&&De++;if(De>=4){Me.push({index:je,rule:3,description:"four of five past one sigma"});break}}if(je>=7)for(const Ne of[1,-1]){let De=!0;for(let qe=je-7;qe<=je;qe++)if(me(qe)*Ne<=0){De=!1;break}if(De){Me.push({index:je,rule:4,description:"eight in a row on one side"});break}}}return Me}function Ke(ge,we){if(!we||!(we.sigma>0))return[];const ve=ge.length,{centre:Ae,sigma:Le}=we,me=Ne=>(ge[Ne]-Ae)/Le,Me=(Ne,De,qe,st)=>{for(const ct of[1,-1]){let ft=0;for(let at=Ne;at<=De;at++)me(at)*ct>qe&&ft++;if(ft>=st)return!0}return!1},je=[];for(let Ne=0;Ne<ve;Ne++){if(Math.abs(me(Ne))>3&&je.push({index:Ne,rule:1,description:"beyond three sigma"}),Ne>=8)for(const De of[1,-1]){let qe=!0;for(let st=Ne-8;st<=Ne;st++)if(me(st)*De<=0){qe=!1;break}if(qe){je.push({index:Ne,rule:2,description:"nine in a row on one side"});break}}if(Ne>=5)for(const De of[1,-1]){let qe=!0;for(let st=Ne-4;st<=Ne;st++)if((ge[st]-ge[st-1])*De<=0){qe=!1;break}if(qe){je.push({index:Ne,rule:3,description:De>0?"six rising":"six falling"});break}}if(Ne>=13){let De=!0;for(let qe=Ne-12;qe<=Ne;qe++){const st=ge[qe]-ge[qe-1],ct=ge[qe+1<=Ne?qe+1:qe]-ge[qe];if(qe+1>Ne)break;if(st===0||ct===0||st>0==ct>0){De=!1;break}}De&&je.push({index:Ne,rule:4,description:"fourteen alternating"})}if(Ne>=2&&Me(Ne-2,Ne,2,2)&&je.push({index:Ne,rule:5,description:"two of three past two sigma"}),Ne>=4&&Me(Ne-4,Ne,1,4)&&je.push({index:Ne,rule:6,description:"four of five past one sigma"}),Ne>=14){let De=!0;for(let qe=Ne-14;qe<=Ne;qe++)if(Math.abs(me(qe))>=1){De=!1;break}De&&je.push({index:Ne,rule:7,description:"fifteen within one sigma"})}if(Ne>=7){let De=!0;for(let qe=Ne-7;qe<=Ne;qe++)if(Math.abs(me(qe))<=1){De=!1;break}De&&je.push({index:Ne,rule:8,description:"eight beyond one sigma"})}}return je}const nt=Object.freeze(["westernElectric","nelson"]);function ot(ge,we,ve="westernElectric"){return String(ve)==="nelson"?Ke(ge,we):_e(ge,we)}function pt(ge,we,ve){let Ae=0;for(let Le=0;Le<ge.length;Le++)(ge[Le]<we||ge[Le]>ve)&&Ae++;return Ae}function bt(ge,we,ve,Ae=20){const Le=ge.length;if(!Le)return[];const me=ge[0],Me=ge[Le-1];if(Me===me)return[{from:me,to:Me,count:Le}];const je=ve-we,Ne=1.5*je;let De=je>0?Math.max(me,we-Ne):me,qe=je>0?Math.min(Me,ve+Ne):Me;qe>De||(De=me,qe=Me);const st=je>0?2*je/Math.cbrt(Le):(qe-De)/(Math.ceil(Math.log2(Le))+1),ct=st>0?Math.min(Ae,Math.max(1,Math.ceil((qe-De)/st))):1,ft=(qe-De)/ct,at=[];for(let vt=0;vt<ct;vt++)at.push({from:De+vt*ft,to:De+(vt+1)*ft,count:0});for(let vt=0;vt<Le;vt++){const dt=Math.min(ct-1,Math.max(0,Math.floor((ge[vt]-De)/ft)));at[dt].count++}return at[0].from=me,at[ct-1].to=Me,at}const Ot=.95;function Pt(ge){const we=Number(ge);return Number.isFinite(we)&&we>0&&we<1?we:Ot}function Et(ge,we=Ot){const ve=ge.length;if(ve<2)return null;let Ae=0;for(let qe=0;qe<ve;qe++)Ae+=ge[qe];const Le=Ae/ve;let me=0;for(let qe=0;qe<ve;qe++){const st=ge[qe]-Le;me+=st*st}const Me=Math.sqrt(me/(ve-1)),je=Pt(we),De=_(1-(1-je)/2,ve-1)*Me/Math.sqrt(ve);return{mean:Le,lower:Le-De,upper:Le+De,margin:De,n:ve,confidence:je}}function Mt(ge,we,ve=Ot){const Ae=Number(ge),Le=Number(we);if(!(Le>0)||!(Ae>=0)||Ae>Le)return null;const me=Pt(ve),Me=G(1-(1-me)/2),je=Ae/Le,Ne=Me*Me,De=1+Ne/Le,qe=(je+Ne/(2*Le))/De,st=Me/De*Math.sqrt(je*(1-je)/Le+Ne/(4*Le*Le));return{proportion:je,lower:Math.max(0,qe-st),upper:Math.min(1,qe+st),n:Le,confidence:me}}function Dt(ge,we=Ot){if(!ge||!(ge.n>2)||!Number.isFinite(ge.stdError))return null;const ve=Pt(we),Le=_(1-(1-ve)/2,ge.n-2)*ge.stdError;return{slope:ge.slope,lower:ge.slope-Le,upper:ge.slope+Le,margin:Le,confidence:ve}}function Bt(ge,we,ve=Ot){const Ae=Number(ge),Le=Number(we);if(!Number.isFinite(Ae)||!(Le>1))return null;const me=Pt(ve),je=G(1-(1-me)/2)*Math.sqrt(1/(9*Le)+Ae*Ae/(2*(Le-1)));return{index:Ae,lower:Ae-je,upper:Ae+je,margin:je,n:Le,confidence:me}}function Qe(ge,we){return!ge||!(ge.sd>0)||!Number.isFinite(we)||!Number.isFinite(ge.mean)?null:(we-ge.mean)/ge.sd}function Ge(ge){return Number.isFinite(ge)?Math.min(1,Math.max(0,2*H(Math.abs(ge)/2)-1)):0}function se(ge,we){const ve=new Map,Ae=B(ge);let Le=0;for(let me=0;me<we.length;me++){const Me=Ae(we[me]);if(Me==null||Me===""||typeof Me=="number"&&Number.isNaN(Me))continue;const je=Me instanceof Date?Me.getTime():typeof Me=="object"?String(Me):Me;ve.set(je,(ve.get(je)||0)+1),Le++}return{map:ve,total:Le}}function pe(ge,we,ve,Ae){if(!(we>0)||!(Ae>0))return null;let Le=0;const me=new Set(ge.keys());for(const Me of ve.keys())me.add(Me);for(const Me of me){const je=(ge.get(Me)||0)/we,Ne=(ve.get(Me)||0)/Ae;Le+=Math.abs(je-Ne)}return Le/2}const be=10;function Ue(ge,we,ve){if(ve&&ve.numeric){const je=l(ge,we),{n:Ne,mean:De}=v(je),qe=Ne>0?Qe({mean:ve.mean,sd:ve.sd},De):null;return{measure:"standardizedMeanDifference",magnitude:qe,distance:qe===null?0:Ge(qe),direction:qe===null?0:Math.sign(qe),subsetN:Ne,populationN:ve.n||0,reliable:Ne>=be}}const{map:Le,total:me}=se(ge,we),Me=pe(Le,me,ve.map,ve.total);return{measure:"categoricalTotalVariation",magnitude:Me,distance:Me===null?0:Me,direction:0,subsetN:me,populationN:ve.total||0,reliable:me>=be}}function Ve(ge,we){if(ge&&(ge.kind==="float64"||ge.kind==="int32"))return!0;const ve=B(ge);let Ae=0,Le=0;for(let me=0;me<we.length&&Ae<200;me++){const Me=ve(we[me]);if(Me==null||Me==="")continue;if(Me instanceof Date)return!1;Ae++;const je=typeof Me=="number"?Me:Number(Me);Number.isFinite(je)&&Le++}return Ae===0?!1:Le/Ae>=.9}function rt(ge,we){if(Ve(ge,we)){const Le=l(ge,we),{n:me,mean:Me,m2:je}=v(Le);return{numeric:!0,mean:Me,sd:me>0?Math.sqrt(je/me):0,n:me}}const{map:ve,total:Ae}=se(ge,we);return{numeric:!1,map:ve,total:Ae}}}),xe("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=K("packages/core/src/compute/handle.js"),_=F.presenceReader,Q=F.valueComparator,G=F.valueReader,H=K("packages/core/src/compute/statistics.js"),U=H.STAT_FNS,z=H.STAT_LABELS;function S(v){return!!v&&(v.kind==="float64"||v.kind==="int32")}function O(v,p){const y=p.length;let C=0;if(S(v)){const P=v.values,x=_(v);if(!x){for(let E=0;E<y;E++){const j=P[p[E]];Number.isNaN(j)||(C+=j)}return C}for(let E=0;E<y;E++){const j=p[E];if(x(j)===1){const A=P[j];Number.isNaN(A)||(C+=A)}}return C}const T=G(v);for(let P=0;P<y;P++){const x=f(T(p[P]));x!==null&&(C+=x)}return C}O.kernel=!0;function b(v,p){const y=p.length;let C=0;if(S(v)){const P=v.values,x=_(v);if(!x){for(let E=0;E<y;E++)Number.isNaN(P[p[E]])||C++;return C}for(let E=0;E<y;E++){const j=p[E];x(j)===1&&!Number.isNaN(P[j])&&C++}return C}const T=G(v);for(let P=0;P<y;P++){const x=T(p[P]);x!=null&&!(typeof x=="number"&&Number.isNaN(x))&&C++}return C}b.kernel=!0;function u(v,p){return p.length}u.kernel=!0;function d(v,p){const y=b(v,p);return y===0?null:O(v,p)/y}d.kernel=!0;function s(v,p,y,C){const T=p.length;if(S(v)){const j=v.values,A=_(v);let $=null;if(!A){for(let D=0;D<T;D++){const M=j[p[D]];Number.isNaN(M)||($===null||(y<0?M<$:M>$))&&($=M)}return $}for(let D=0;D<T;D++){const M=p[D];if(A(M)===0)continue;const R=j[M];Number.isNaN(R)||($===null||(y<0?R<$:R>$))&&($=R)}return $}const P=G(v),x=Q(C);let E=null;for(let j=0;j<T;j++){const A=P(p[j]);A==null||typeof A=="number"&&Number.isNaN(A)||(E===null||(y<0?x(A,E)<0:x(A,E)>0))&&(E=A)}return E}function n(v,p,y){return s(v,p,-1,y&&y.locale)}n.kernel=!0;function t(v,p,y){return s(v,p,1,y&&y.locale)}t.kernel=!0;function r(v,p){return p.length===0?null:G(v)(p[0])}r.kernel=!0;function o(v,p){return p.length===0?null:G(v)(p[p.length-1])}o.kernel=!0;function f(v){if(typeof v=="number")return Number.isNaN(v)?null:v;if(v==null||v===""||typeof v=="boolean")return null;if(v instanceof Date)return v.getTime();const p=Number(v);return Number.isNaN(p)?null:p}const l={sum:O,min:n,max:t,avg:d,count:u,first:r,last:o,countValues:b,...U},i=Object.freeze({...z,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function g(v){return v?typeof v=="string"?i[v]||v:"Total":""}const c=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function h(v){const p=v&&v.dataType&&v.dataType.totals&&v.dataType.totals.supported;if(Array.isArray(p))return p.slice();const y=c.filter(C=>C in l);for(const C of Object.keys(l))y.includes(C)||y.push(C);return y}function a(v,p){return typeof p!="string"?!0:h(v).includes(p)}function m(v,p){const y=G(v),C=[];for(let T=0;T<p.length;T++){const P=y(p[T]);P!=null&&C.push(P)}return C}function w(v,p,y,C){const T=p||[];if(typeof y=="string"){const P=l[y];return P?P(v,T,C):(B(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return L(y)?y.kernel===!0?y(v,T,C):y(m(v,T),C||{}):null}}),xe("packages/core/src/compute/windowed.js",function(e,K){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/compute/sketch.js").Welford;class B{#e;#t;#n=[];#r;#o;constructor(H,U=0,z=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(U>0))throw new RangeError(`a ${H} window needs a positive span`);this.#e=H,this.#t=Math.floor(U),this.#r=z,this.#o=z()}get size(){return this.#n.length}push(H,U=this.#r()){Number.isFinite(H)&&(this.#n.push({t:U,v:H}),this.#i(U))}#i(H){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const U=H-this.#t;for(;this.#n.length&&this.#n[0].t<U;)this.#n.shift()}}spec(){const H=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const U=new L;let z=0,S=1/0,O=-1/0;for(const{v:b}of this.#n)z+=b,b<S&&(S=b),b>O&&(O=b),U.add(b);return{over:H,count:this.#n.length,sum:z,mean:U.mean(),min:S,max:O,variance:U.variance(),stddev:U.stddev()}}reduce(H){const U=this.aggregate(),z={sum:U.sum,avg:U.mean,mean:U.mean,min:U.min,max:U.max,count:U.count,variance:U.variance,stddev:U.stddev};if(!(H in z))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:z[H],over:U.over}}}const F=Object.freeze(["count","time","session"]);function _(G,H=Date.now){const U=G.kind==="time"&&G.minutes!=null?G.minutes*6e4:G.span??0;return new B(G.kind,U,H)}const Q={Window:B,WINDOW_KINDS:F,openWindow:_}}),xe("packages/core/src/compute/rolling.js",function(e,K){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const L=K("packages/core/src/compute/windowed.js").openWindow,F=K("packages/core/src/compute/sketch.js").KLL,_=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Q(i,g,c,h){if(i.kind==="count"){const a=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,g/a),partial:g<a}}if(i.kind==="time"){const a=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(a>0))return{coverage:1,partial:!1};const m=c-h;return{coverage:Math.min(1,m/a),partial:m<a}}return{coverage:null,partial:!1}}function G(i,g){const c=L(g),h=new Map,a=i.length?i[0].at:0;for(let m=0;m<i.length;m++){const{key:w,at:v,value:p}=i[m];Number.isFinite(p)&&c.push(p,v);const y=c.aggregate(),C=Q(g,y.count,v,a);w!=null&&h.set(String(w),{sum:y.sum,avg:y.mean,min:y.min,max:y.max,count:y.count,coverage:C.coverage,partial:C.partial})}return h}function H(i){const g=new Map;let c=0;for(const{key:h,value:a}of i)Number.isFinite(a)&&(c+=a),h!=null&&g.set(String(h),c);return g}function U(i,g=1){const c=new Map,h=Math.max(1,Math.floor(g));for(let a=0;a<i.length;a++){const{key:m,value:w}=i[a];if(m==null)continue;const v=a>=h?i[a-h].value:null,p=Number.isFinite(w)?w:null,y=Number.isFinite(v)?v:null;c.set(String(m),p!==null&&y!==null?p-y:null)}return c}const z=4096;function S(i){let g=i>>>0;return()=>{g+=1831565813;let c=g;return c=Math.imul(c^c>>>15,c|1),c^=c+Math.imul(c^c>>>7,c|61),((c^c>>>14)>>>0)/4294967296}}function O(i,g){const c=i.length;if(c===1)return i[0];const h=(c-1)*g,a=Math.floor(h),m=Math.ceil(h);return a===m?i[a]:i[a]+(h-a)*(i[m]-i[a])}function b(i,g,c={}){const h=Math.min(1,Math.max(0,c.q==null?.5:c.q)),a=Math.max(1,Math.floor(c.cap==null?z:c.cap)),m=S(c.seed==null?2654435769:c.seed),w=new Map,v=i.length?i[0].at:0;if(g.kind==="session"){const y=new F(200,m);let C=0;for(const{key:T,value:P}of i)Number.isFinite(P)&&(y.add(P),C++),T!=null&&w.set(String(T),{value:C?y.quantile(h):null,approx:C>0,count:C,coverage:null,partial:!1});return w}const p=L(g);for(const{key:y,at:C,value:T}of i){Number.isFinite(T)&&p.push(T,C);const P=p.values(),x=P.length;let E=null,j=!1;if(x)if(x<=a)E=O([...P].sort(($,D)=>$-D),h);else{const $=new F(200,m);for(const D of P)$.add(D);E=$.quantile(h),j=!0}const A=Q(g,x,C,v);y!=null&&w.set(String(y),{value:E,approx:j,count:x,coverage:A.coverage,partial:A.partial})}return w}function u(i,g){const c=i.length,h=new Array(c).fill(null),a=Math.floor(g/2),m=g%2===0;for(let w=0;w<c;w++){if(w-a<0||w+a>=c)continue;let v=0,p=!0;if(m)for(let y=-a;y<=a;y++){const C=i[w+y];if(!Number.isFinite(C)){p=!1;break}v+=y===-a||y===a?C*.5:C}else for(let y=-a;y<=a;y++){const C=i[w+y];if(!Number.isFinite(C)){p=!1;break}v+=C}p&&(h[w]=v/g)}return h}function d(i,g){const c=new Map,h=Math.floor(Number(g&&g.period));if(!(h>=2))return c;const a=g&&g.model==="multiplicative",m=i.length,w=i.map(j=>Number.isFinite(j.value)?j.value:null),v=u(w,h),p=new Array(m).fill(null);for(let j=0;j<m;j++){const A=v[j],$=w[j];A===null||$===null||(a?A!==0&&(p[j]=$/A):p[j]=$-A)}const y=new Array(h).fill(0),C=new Array(h).fill(0);for(let j=0;j<m;j++){if(p[j]===null)continue;const A=j%h;y[A]+=p[j],C[A]+=1}const T=a?1:0,P=y.map((j,A)=>C[A]?j/C[A]:T),x=P.reduce((j,A)=>j+A,0)/h,E=a?P.map(j=>x!==0?j/x:1):P.map(j=>j-x);for(let j=0;j<m;j++){const{key:A}=i[j];if(A==null)continue;const $=v[j],D=E[j%h],M=w[j];let R=null;$!==null&&M!==null&&(R=a?$*D!==0?M/($*D):null:M-$-D),c.set(String(A),{trend:$,seasonal:M===null?null:D,residual:R,coverage:$===null?0:1,partial:$===null})}return c}function s(i,g,c,h=80){const a=(Math.sqrt(5)-1)/2;let m=g,w=c,v=w-a*(w-m),p=m+a*(w-m),y=i(v),C=i(p);for(let T=0;T<h;T++)y<C?(w=p,p=v,C=y,v=w-a*(w-m),y=i(v)):(m=v,v=p,y=C,p=m+a*(w-m),C=i(p));return(m+w)/2}const n=1e-4,t=1-1e-4;function r(i,g){const c=i.length,h=new Array(c).fill(null),a=new Array(c).fill(null);let m=null,w=0;for(let v=0;v<c;v++){const p=i[v];if(!Number.isFinite(p)){m!==null&&(a[v]=m,h[v]=m);continue}if(m===null){m=p,a[v]=p,h[v]=p;continue}a[v]=m,w+=(p-m)**2,m=g*p+(1-g)*m,h[v]=m}return{smoothed:h,fitted:a,sse:w}}function o(i,g,c){const h=i.length,a=new Array(h).fill(null),m=new Array(h).fill(null);let w=null,v=null,p=0;for(let y=0;y<h;y++){const C=i[y];if(!Number.isFinite(C)){w!==null&&(w+=v,a[y]=w);continue}if(w===null){w=C,a[y]=C;continue}if(v===null){v=C-w;const x=w+v;m[y]=x,p+=(C-x)**2;const E=w;w=g*C+(1-g)*(E+v),v=c*(w-E)+(1-c)*v,a[y]=w;continue}const T=w+v;m[y]=T,p+=(C-T)**2;const P=w;w=g*C+(1-g)*(P+v),v=c*(w-P)+(1-c)*v,a[y]=w}return{smoothed:a,fitted:m,sse:p}}function f(i,g={}){const c=new Map,h=g.method==="holt",a=i.map(T=>Number.isFinite(T.value)?T.value:null),m=a.filter(T=>T!==null).length,w=T=>Math.min(t,Math.max(n,T)),v=()=>{for(const{key:T}of i)T!=null&&c.set(String(T),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return c};if(m<(h?2:1))return v();let p=Number.isFinite(g.alpha)?w(g.alpha):null,y=h&&Number.isFinite(g.beta)?w(g.beta):null;if(h){if(p===null||y===null){let T=p===null?.5:p,P=y===null?.5:y;for(let x=0;x<6;x++)p===null&&(T=s(E=>o(a,E,P).sse,n,t)),y===null&&(P=s(E=>o(a,T,E).sse,n,t));p=p===null?T:p,y=y===null?P:y}}else p===null&&(p=s(T=>r(a,T).sse,n,t));const C=h?o(a,p,y):r(a,p);for(let T=0;T<i.length;T++){const{key:P}=i[T];P!=null&&c.set(String(P),{smoothed:C.smoothed[T],fitted:C.fitted[T],alpha:p,beta:h?y:null,sse:C.sse})}return c}const l={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:z,rollingWindow:G,rollingQuantile:b,cumulativeToDate:H,periodOverPeriod:U,seasonalDecompose:d,exponentialSmoothing:f}}),xe("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const X=K("packages/core/src/compute/statistics.js"),L=X.numbers,B=X.moments,F=X.frequencyMap,_=X.categoricalDistance,Q=X.normalTotalVariation,G=X.isNumericColumn,H=X.SUBSET_RELIABILITY_FLOOR,U=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function z(d,s){if(!d||!s||!(d.n>0)||!(s.n>0)||!Number.isFinite(d.mean)||!Number.isFinite(s.mean))return null;const n=(d.n*d.sd*d.sd+s.n*s.sd*s.sd)/(d.n+s.n);return n>0?(d.mean-s.mean)/Math.sqrt(n):null}function S(d,s){const n=L(d,s),{n:t,mean:r,m2:o}=B(n),f=t>0?Math.sqrt(o/t):0;return{mean:r,sd:f,n:t}}function O(d,s,n,t){return G(d,s)&&G(n,t)}function b(d,s,n,t){if(O(d,s,n,t)){const l=S(d,s),i=S(n,t),g=z(l,i);return{measure:U.numeric,magnitude:g,distance:g===null?0:Q(g),direction:g===null?0:Math.sign(g),nA:l.n,nB:i.n,reliable:l.n>=H&&i.n>=H}}const r=F(d,s),o=F(n,t),f=_(r.map,r.total,o.map,o.total);return{measure:U.categorical,magnitude:f,distance:f===null?0:f,direction:0,nA:r.total,nB:o.total,reliable:r.total>=H&&o.total>=H}}function u(d,s,n={}){const t=new Set(d.columns),r=new Set(s.columns),o=d.columns.filter(c=>r.has(c)),f=Array.isArray(n.columns)&&n.columns.length?o.filter(c=>n.columns.includes(c)):o,l=d.indices(),i=s.indices(),g=[];for(const c of f){const h=d.handle(c),a=s.handle(c);if(!h||!a)continue;const m=b(h,l,a,i);g.push({column:c,name:d.name&&d.name(c)||s.name&&s.name(c)||c,measure:m.measure,magnitude:m.magnitude,distance:m.distance,direction:m.direction,nA:m.nA,nB:m.nB,reliable:m.reliable})}return g.sort((c,h)=>h.distance-c.distance||Math.abs(h.magnitude||0)-Math.abs(c.magnitude||0)),{ranked:g,nA:l.length,nB:i.length,unmatched:{onlyA:d.columns.filter(c=>!r.has(c)),onlyB:s.columns.filter(c=>!t.has(c))},measures:U}}}),xe("packages/core/src/compute/anomaly.js",function(e,K){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l}});const L=K("packages/core/src/compute/statistics.js").quantileSorted,F=K("packages/core/src/compute/special.js").logGamma,_=.6745,Q=3.5,G=1.5,H=.975,U=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function z(i){if(!i.length)return null;const c=Array.from(i,Number).sort((w,v)=>w-v),h=L(c,.5),a=c.map(w=>Math.abs(w-h)).sort((w,v)=>w-v),m=L(a,.5);return{median:h,mad:m}}function S(i,g={}){const c=Number.isFinite(g.threshold)?g.threshold:Q,h=i.length,a=new Array(h).fill(null),m=new Array(h).fill(!1),w=[];for(let y=0;y<h;y++){const C=Number(i[y]);Number.isFinite(C)&&w.push(C)}if(!w.length)return{median:null,mad:null,threshold:c,scores:a,flags:m,flagged:0};const v=z(w);if(v.mad===0)return{median:v.median,mad:0,threshold:c,scores:a,flags:m,flagged:0};let p=0;for(let y=0;y<h;y++){const C=Number(i[y]);if(!Number.isFinite(C))continue;const T=_*(C-v.median)/v.mad;a[y]=T,Math.abs(T)>c&&(m[y]=!0,p++)}return{median:v.median,mad:v.mad,threshold:c,scores:a,flags:m,flagged:p}}function O(i,g={}){const c=Number.isFinite(g.k)?g.k:G,h=[];for(let p=0;p<i.length;p++){const y=Number(i[p]);Number.isFinite(y)&&h.push(y)}if(!h.length)return null;const a=h.sort((p,y)=>p-y),m=L(a,.25),w=L(a,.75),v=w-m;return{q1:m,q3:w,iqr:v,lower:m-c*v,upper:w+c*v,k:c}}function b(i,g){if(g<=0)return 0;const c=F(i);if(g<i+1){let y=i,C=1/i,T=C;for(let P=0;P<1e3&&(y+=1,T*=g/y,C+=T,!(Math.abs(T)<Math.abs(C)*1e-15));P++);return C*Math.exp(-g+i*Math.log(g)-c)}const h=1e-300;let a=g+1-i,m=1/h,w=1/a,v=w;for(let y=1;y<1e3;y++){const C=-y*(y-i);a+=2,w=C*w+a,Math.abs(w)<h&&(w=h),m=a+C/m,Math.abs(m)<h&&(m=h),w=1/w;const T=w*m;if(v*=T,Math.abs(T-1)<1e-15)break}return 1-Math.exp(-g+i*Math.log(g)-c)*v}function u(i,g){return i<=0?0:b(g/2,i/2)}function d(i,g=H){if(!(g>0)||!(g<1))return NaN;let c=0,h=Math.max(1,i);for(;u(h,i)<g;)h*=2;for(let a=0;a<200;a++){const m=(c+h)/2;if(u(m,i)<g?c=m:h=m,h-c<1e-10)break}return(c+h)/2}function s(i){const g=i.length,c=i.map((h,a)=>{const m=h.slice();for(let w=0;w<g;w++)m.push(a===w?1:0);return m});for(let h=0;h<g;h++){let a=h;for(let w=h+1;w<g;w++)Math.abs(c[w][h])>Math.abs(c[a][h])&&(a=w);if(Math.abs(c[a][h])<1e-12)return null;if(a!==h){const w=c[a];c[a]=c[h],c[h]=w}const m=c[h][h];for(let w=0;w<2*g;w++)c[h][w]/=m;for(let w=0;w<g;w++){if(w===h)continue;const v=c[w][h];if(v!==0)for(let p=0;p<2*g;p++)c[w][p]-=v*c[h][p]}}return c.map(h=>h.slice(g))}function n(i,g){const c=i.length,h=new Array(g).fill(0);for(const w of i)for(let v=0;v<g;v++)h[v]+=w[v];for(let w=0;w<g;w++)h[w]/=c;const a=Array.from({length:g},()=>new Array(g).fill(0));for(const w of i)for(let v=0;v<g;v++){const p=w[v]-h[v];for(let y=v;y<g;y++)a[v][y]+=p*(w[y]-h[y])}const m=c>1?c-1:1;for(let w=0;w<g;w++)for(let v=w;v<g;v++)a[w][v]/=m,a[v][w]=a[w][v];return{mean:h,cov:a}}function t(i,g={}){const c=Number.isFinite(g.p)?g.p:H,h=Number.isFinite(g.ridge)?g.ridge:1e-6,a=i.length;if(!a)return null;const m=i[0].length;if(!m)return null;const w=new Array(a).fill(null),v=new Array(a).fill(null),p=new Array(a).fill(!1),y=[],C=[];for(let D=0;D<a;D++){const M=i[D];let R=M.length===m;const k=new Array(m);for(let I=0;R&&I<m;I++){const q=Number(M[I]);Number.isFinite(q)?k[I]=q:R=!1}R&&(y.push(D),C.push(k))}const T=m,P=d(T,c);if(C.length<=m)return{center:[],df:T,cutoff:P,singular:!0,used:C.length,distances:w,squared:v,flags:p,flagged:0};const{mean:x,cov:E}=n(C,m);let j=s(E),A=!1;if(!j){A=!0;let D=0;for(let k=0;k<m;k++)D+=E[k][k];const M=D/m*h||h,R=E.map((k,I)=>k.map((q,Z)=>I===Z?q+M:q));if(j=s(R),!j)return{center:x,df:T,cutoff:P,singular:!0,used:C.length,distances:w,squared:v,flags:p,flagged:0}}let $=0;for(let D=0;D<C.length;D++){const M=C[D],R=new Array(m);for(let q=0;q<m;q++)R[q]=M[q]-x[q];let k=0;for(let q=0;q<m;q++){let Z=0;for(let W=0;W<m;W++)Z+=j[q][W]*R[W];k+=R[q]*Z}k<0&&(k=0);const I=y[D];v[I]=k,w[I]=Math.sqrt(k),k>P&&(p[I]=!0,$++)}return{center:x,df:T,cutoff:P,singular:A,used:C.length,distances:w,squared:v,flags:p,flagged:$}}const r=20,o=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function f(i,g={}){const c=g.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",h=Number.isFinite(g.windowLen)&&g.windowLen>=1?Math.floor(g.windowLen):r,a=Number.isFinite(g.threshold)?g.threshold:Q,m=Number.isFinite(g.k)?g.k:G,w=Number.isFinite(g.minPeriods)&&g.minPeriods>=1?Math.floor(g.minPeriods):h,v=i.length,p=new Array(v).fill(null),y=new Array(v).fill(!1);let C=0;for(let T=0;T<v;T++){const P=Number(i[T]);if(!Number.isFinite(P))continue;const x=Math.max(0,T-h+1),E=[];for(let j=x;j<=T;j++){const A=Number(i[j]);Number.isFinite(A)&&E.push(A)}if(!(E.length<w))if(c==="rollingIqr"){const j=O(E,{k:m});if(!j)continue;(P<j.lower||P>j.upper)&&(y[T]=!0,C++)}else{const j=z(E);if(!j||j.mad===0)continue;const A=_*(P-j.median)/j.mad;p[T]=A,Math.abs(A)>a&&(y[T]=!0,C++)}}return{method:c,windowLen:h,minPeriods:w,threshold:a,k:m,scores:p,flags:y,flagged:C}}function l(i={}){const g=i||{},c=g.field;if(typeof c!="string"||!c)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const h=g.method||"modifiedZScore";if(!(U.includes(h)||o.includes(h))||h==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${h}'`);const m=typeof g.orderBy=="string"?g.orderBy:null,w=g.latest===!0,v=o.includes(h),p=y=>Number(y==null?NaN:y[c]);return y=>{const C=Array.isArray(y)?y.slice():[...y];m&&C.sort((j,A)=>{const $=j?.[m],D=A?.[m];return $===D?0:$==null?-1:D==null?1:$<D?-1:1});const T=C.map(p);let P,x;if(v)({flags:P,scores:x}=f(T,{method:h,windowLen:g.windowLen,threshold:g.threshold,k:g.k,minPeriods:g.minPeriods}));else if(h==="iqr"){const j=O(T,{k:g.k});P=T.map(A=>j?Number.isFinite(A)&&(A<j.lower||A>j.upper):!1),x=T.map(()=>null)}else({flags:P,scores:x}=S(T,{threshold:g.threshold}));if(w){const j=P.length-1;return j<0||!P[j]?!1:{method:h,field:c,flagged:[{row:C[j],score:x[j]}]}}const E=[];for(let j=0;j<P.length;j++)P[j]&&E.push({row:C[j],score:x[j]});return E.length?{method:h,field:c,flagged:E}:!1}}}),xe("packages/core/src/compute/forecast.js",function(e,K){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const X=K("packages/core/src/compute/special.js"),L=X.normalQuantile,B=X.studentTQuantile,_=K("packages/core/src/internal/util.js").warnOnce,Q=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),G=1e-4,H=1-1e-4;function U(g){const c=[];for(let h=0;h<g.length;h++){const a=g[h];if(a!==null&&typeof a=="object"){const m=Number.isFinite(a.at)?a.at:h,w=Number.isFinite(a.value)?a.value:null;c.push({at:m,value:w})}else c.push({at:h,value:Number.isFinite(a)?Number(a):null})}return c}function z(g){const c=g.filter(v=>v.value!==null),h=c[0],a=c[c.length-1],m=a.at-h.at,w=c.length>1&&m>0?m/(c.length-1):1;return{lastAt:a.at,step:w}}function S(g){return Math.min(H,Math.max(G,g))}function O(g,c=G,h=H,a=80){const m=(Math.sqrt(5)-1)/2;let w=c,v=h,p=v-m*(v-w),y=w+m*(v-w),C=g(p),T=g(y);for(let P=0;P<a;P++)C<T?(v=y,y=p,T=C,p=v-m*(v-w),C=g(p)):(w=p,p=y,C=T,y=w+m*(v-w),T=g(y));return(w+v)/2}function b(g,c){let h=null,a=0,m=0;for(let w=0;w<g.length;w++){const v=g[w];if(v!==null){if(h===null){h=v;continue}a+=(v-h)**2,m+=1,h=c*v+(1-c)*h}}return{level:h,sse:a,m}}function u(g,c,h){let a=null,m=null,w=0,v=0;for(let p=0;p<g.length;p++){const y=g[p];if(y===null){a!==null&&m!==null&&(a+=m);continue}if(a===null){a=y;continue}m===null&&(m=y-a);const C=a+m;w+=(y-C)**2,v+=1;const T=a;a=c*y+(1-c)*(T+m),m=h*(a-T)+(1-h)*m}return{level:a,trend:m,sse:w,m:v}}function d(g,c,h,a,m){const w=g.length;if(w<2*c)return null;const v=A=>{let $=0,D=0;for(let M=A;M<A+c&&M<w;M++)g[M]!==null&&($+=g[M],D+=1);return D?$/D:null},p=v(0),y=v(c);if(p===null||y===null)return null;let C=p,T=(y-p)/c;const P=new Array(c).fill(0);for(let A=0;A<c;A++)P[A]=g[A]===null?0:g[A]-C;const x=P.reduce((A,$)=>A+$,0)/c;for(let A=0;A<c;A++)P[A]-=x;let E=0,j=0;for(let A=c;A<w;A++){const $=A%c,D=P[$],M=g[A];if(M===null){C+=T;continue}const R=C+T+D;E+=(M-R)**2,j+=1;const k=C;C=h*(M-D)+(1-h)*(C+T),T=a*(C-k)+(1-a)*T,P[$]=m*(M-C)+(1-m)*D}return{level:C,trend:T,season:P,phase:(w-1)%c,sse:E,count:j}}function s(g,c,h){let a=1;for(const w of c)a+=w*w;const m=Math.sqrt(g*a);return{se:m,margin:h*m}}function n(g,c={}){if(!g||typeof g.length!="number"||g.length===0)return null;const h=Q.includes(c.method)?c.method:"linear",a=Math.max(1,Math.floor(Number(c.horizon)||1)),m=Number.isFinite(c.confidence)&&c.confidence>0&&c.confidence<1?c.confidence:.95,w=1-(1-m)/2,v=U(g),p=v.map(E=>E.value),y=p.filter(E=>E!==null),C=y.length,{lastAt:T,step:P}=C?z(v):{lastAt:0,step:1},x=E=>T+E*P;return h==="linear"?t(v,C,a,m,w,x):h==="movingAverage"?r(y,C,a,m,w,c,x):h==="ses"?o(p,C,a,m,w,c,x):h==="holt"?f(p,C,a,m,w,c,x):l(p,C,a,m,w,c,x)}function t(g,c,h,a,m,w){if(c<2)return null;let v=0,p=0;for(const M of g)M.value!==null&&(v+=M.at,p+=M.value);v/=c,p/=c;let y=0,C=0,T=0;for(const M of g){if(M.value===null)continue;const R=M.at-v,k=M.value-p;y+=R*R,C+=R*k,T+=k*k}if(y===0)return null;const P=C/y,x=p-P*v,E=T===0?1:Math.max(0,Math.min(1,C*C/(y*T))),j=Math.max(0,T-P*C),A=c>2?Math.sqrt(j/(c-2)):null,$=c>2?B(m,c-2):null,D=[];for(let M=1;M<=h;M++){const R=w(M),k=x+P*R;let I=null,q=null,Z=null,W=null,J=null;if(A!==null){const ee=1/c+(R-v)**2/y,te=A*Math.sqrt(1+ee),ne=A*Math.sqrt(ee);J=te,I=k-$*te,q=k+$*te,Z=k-$*ne,W=k+$*ne}D.push({step:M,at:R,mean:k,lower:I,upper:q,lowerMean:Z,upperMean:W,se:J})}return{method:"linear",horizon:h,confidence:a,n:c,sigma:A,r2:E,params:{slope:P,intercept:x},points:D}}function r(g,c,h,a,m,w,v){if(c<1)return null;const p=Math.max(1,Math.min(c,Math.floor(Number(w.windowLen)||c))),y=g.slice(c-p);let C=0;for(const A of y)C+=A;const T=C/p;let P=null,x=null;if(p>1){let A=0;for(const D of y)A+=(D-T)**2;P=Math.sqrt(A/(p-1))*Math.sqrt(1+1/p),x=B(m,p-1)}const E=P===null?null:x*P,j=[];for(let A=1;A<=h;A++)j.push({step:A,at:v(A),mean:T,lower:E===null?null:T-E,upper:E===null?null:T+E,se:P});return{method:"movingAverage",horizon:h,confidence:a,n:c,sigma:P===null?null:P,params:{windowLen:p},points:j}}function o(g,c,h,a,m,w,v){if(c<1)return null;let p=Number.isFinite(w.alpha)?S(w.alpha):null;p===null&&(p=O(x=>b(g,x).sse));const y=b(g,p),C=L(m),T=y.m>0?y.sse/y.m:null,P=[];for(let x=1;x<=h;x++){const E=y.level;let j=null,A=null,$=null;if(T!==null){const D=[];for(let R=1;R<x;R++)D.push(p);const M=s(T,D,C);$=M.se,j=E-M.margin,A=E+M.margin}P.push({step:x,at:v(x),mean:E,lower:j,upper:A,se:$})}return{method:"ses",horizon:h,confidence:a,n:c,sigma:T===null?null:Math.sqrt(T),params:{alpha:p},points:P}}function f(g,c,h,a,m,w,v){if(c<2)return null;let p=Number.isFinite(w.alpha)?S(w.alpha):null,y=Number.isFinite(w.beta)?S(w.beta):null;if(p===null||y===null){let j=p===null?.5:p,A=y===null?.5:y;for(let $=0;$<6;$++)p===null&&(j=O(D=>u(g,D,A).sse)),y===null&&(A=O(D=>u(g,j,D).sse));p=p===null?j:p,y=y===null?A:y}const C=u(g,p,y),T=L(m),P=C.m>0?C.sse/C.m:null,x=p*y,E=[];for(let j=1;j<=h;j++){const A=C.level+j*C.trend;let $=null,D=null,M=null;if(P!==null){const R=[];for(let I=1;I<j;I++)R.push(p+I*x);const k=s(P,R,T);M=k.se,$=A-k.margin,D=A+k.margin}E.push({step:j,at:v(j),mean:A,lower:$,upper:D,se:M})}return{method:"holt",horizon:h,confidence:a,n:c,sigma:P===null?null:Math.sqrt(P),params:{alpha:p,beta:y},points:E}}function l(g,c,h,a,m,w,v){const p=Math.floor(Number(w.period));if(!(p>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(c<2*p)return null;let y=Number.isFinite(w.alpha)?S(w.alpha):null,C=Number.isFinite(w.beta)?S(w.beta):null,T=Number.isFinite(w.gamma)?S(w.gamma):null;const P=(M,R,k)=>{const I=d(g,p,M,R,k);return I?I.sse:1/0};if(y===null||C===null||T===null){let M=y===null?.5:y,R=C===null?.5:C,k=T===null?.5:T;for(let I=0;I<8;I++)y===null&&(M=O(q=>P(q,R,k))),C===null&&(R=O(q=>P(M,q,k))),T===null&&(k=O(q=>P(M,R,q)));y=y===null?M:y,C=C===null?R:C,T=T===null?k:T}const x=d(g,p,y,C,T);if(!x)return null;const E=L(m),j=x.count>0?x.sse/x.count:null,A=y*C,$=T*(1-y),D=[];for(let M=1;M<=h;M++){const R=x.season[(x.phase+M)%p],k=x.level+M*x.trend+R;let I=null,q=null,Z=null;if(j!==null){const W=[];for(let ee=1;ee<M;ee++)W.push(y+ee*A+(ee%p===0?$:0));const J=s(j,W,E);Z=J.se,I=k-J.margin,q=k+J.margin}D.push({step:M,at:v(M),mean:k,lower:I,upper:q,se:Z})}return{method:"holtWinters",horizon:h,confidence:a,n:c,sigma:j===null?null:Math.sqrt(j),params:{alpha:y,beta:C,gamma:T,period:p},points:D}}const i={FORECAST_METHODS:Q,forecast:n}}),xe("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return E}});const L=K("packages/core/src/internal/util.js").warnOnce,F=K("packages/core/src/compute/handle.js").valueReader,_=K("packages/core/src/compute/statistics.js"),Q=_.numbers,G=_.moments,H=_.frequencyMap,U=_.categoricalDistance,z=_.isNumericColumn,S=_.jarqueBera,O=_.proportionInterval,b=_.SUBSET_RELIABILITY_FLOOR,d=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,s=K("packages/core/src/compute/special.js"),n=s.studentT,t=s.studentTQuantile,r=s.normalCdf,o=s.normalQuantile,f=s.chiSquareUpperTail,l=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,g=2e6;function c(j){const A=Number(j);return Number.isFinite(A)&&A>0&&A<1?A:.95}function h(j){const{n:A,mean:$,m2:D}=G(j);return{mean:$,sd:A>0?Math.sqrt(D/A):0,n:A}}function a(j,A){const $=j.length;if($<2)return 0;let D=0;for(let M=0;M<$;M++){const R=j[M]-A;D+=R*R}return D/($-1)}function m(j,A){return{name:"pooledStandardMeanDifference",value:d(h(j),h(A))}}function w(j,A,$){const D=j.length,M=A.length;if(D<2||M<2)return null;const R=c($),{mean:k}=G(j),{mean:I}=G(A),q=a(j,k),Z=a(A,I),W=q/D+Z/M;if(!(W>0))return null;const J=Math.sqrt(W),ee=(k-I)/J,te=q/D*(q/D)/(D-1),ne=Z/M*(Z/M)/(M-1),ae=W*W/(te+ne),de=Math.min(1,Math.max(0,2*(1-n(Math.abs(ee),ae)))),ie=k-I,oe=t(1-(1-R)/2,ae)*J;return{test:l.WELCH,statistic:ee,statisticName:"t",df:ae,pValue:de,interval:{estimate:ie,lower:ie-oe,upper:ie+oe,confidence:R,method:"welch-t (difference of means)"},effectSize:m(j,A),nA:D,nB:M,reliable:D>=b&&M>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function v(j){const A=j.length;if(A===0)return Number.NaN;const $=A>>1;return A%2?j[$]:(j[$-1]+j[$])/2}function p(j,A,$){const D=j.length,M=A.length,R=D*M;if(R===0||R>g)return null;const k=new Float64Array(R);let I=0;for(let te=0;te<D;te++)for(let ne=0;ne<M;ne++)k[I++]=j[te]-A[ne];k.sort();const q=v(k),Z=Math.sqrt(D*M*(D+M+1)/12),W=o(1-(1-$)/2);let J=Math.round(R/2-W*Z);J>=0||(J=0);const ee=Math.floor((R-1)/2);return J>ee&&(J=ee),{estimate:q,lower:k[J],upper:k[R-1-J],confidence:$,method:"hodges-lehmann (normal approximation)"}}function y(j,A,$){const D=j.length,M=A.length;if(D<1||M<1)return null;const R=c($),k=D+M,I=new Array(k);for(let de=0;de<D;de++)I[de]={v:j[de],g:0};for(let de=0;de<M;de++)I[D+de]={v:A[de],g:1};I.sort((de,ie)=>de.v-ie.v);let q=0,Z=0,W=0;for(;W<k;){let de=W;for(;de<k&&I[de].v===I[W].v;)de++;const ie=de-W,oe=(W+1+de)/2;for(let ce=W;ce<de;ce++)I[ce].g===0&&(q+=oe);Z+=ie*ie*ie-ie,W=de}const J=q-D*(D+1)/2,ee=D*M/2,te=D*M/12*(k+1-Z/(k*(k-1)));let ne=1;if(te>0){const de=Math.max(0,Math.abs(J-ee)-.5);ne=Math.min(1,2*r(-de/Math.sqrt(te)))}const ae=p(j,A,R);return{test:l.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:ne,interval:ae,effectSize:m(j,A),nA:D,nB:M,reliable:D>=b&&M>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function C(j,A,$,D,M){const R=O(j,A,M),k=O($,D,M);if(!R||!k)return null;const I=R.proportion-k.proportion,q=I-Math.sqrt((R.proportion-R.lower)**2+(k.upper-k.proportion)**2),Z=I+Math.sqrt((R.upper-R.proportion)**2+(k.proportion-k.lower)**2);return{lower:q,upper:Z}}function T(j,A,$,D,M,R={}){if(!(A>0)||!(D>0))return null;const k=new Set([...j.keys(),...$.keys()]),I=k.size;if(I<2)return null;const q=A+D;let Z=0;for(const ne of k){const ae=j.get(ne)||0,de=$.get(ne)||0,ie=ae+de,oe=A*ie/q,ce=D*ie/q;oe>0&&(Z+=(ae-oe)*(ae-oe)/oe),ce>0&&(Z+=(de-ce)*(de-ce)/ce)}const W=I-1,J=f(Z,W);let ee=null;R.category!==void 0&&k.has(R.category)?ee=R.category:I===2&&([ee]=[...k]);let te=null;if(ee!==null){const ne=C(j.get(ee)||0,A,$.get(ee)||0,D,c(M));ne&&(te={estimate:(j.get(ee)||0)/A-($.get(ee)||0)/D,lower:ne.lower,upper:ne.upper,confidence:c(M),method:"newcombe (difference in this category's share)",category:ee})}return{test:l.CHI_SQUARE,statistic:Z,statisticName:"chiSquare",df:W,pValue:J,interval:te,effectSize:{name:"categoricalTotalVariation",value:U(j,A,$,D)},nA:A,nB:D,reliable:A>=b&&D>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function P(j){return j==null||j===""||typeof j=="number"&&Number.isNaN(j)?null:j instanceof Date?j.getTime():typeof j=="object"?String(j):j}function x(j,A,$){if($===l.WELCH||$===l.MANN_WHITNEY)return{test:$,chosenBy:"override",reason:`caller override: ${$}`};const D=S(j),M=S(A),R=D===null?null:Math.exp(-D/2),k=M===null?null:Math.exp(-M/2);return R!==null&&R<i||k!==null&&k<i?{test:l.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:l.WELCH,chosenBy:"auto",reason:R!==null||k!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function E(j,A,$,D={}){if(!j||!A)return null;const M=c(D.confidence),R=F(A);let k;if(Array.isArray(D.groups)&&D.groups.length===2)k=[P(D.groups[0]),P(D.groups[1])];else{const{map:de}=H(A,$),ie=[...de.entries()].sort((oe,ce)=>ce[1]-oe[1]).slice(0,2).map(oe=>oe[0]);if(ie.length<2)return L("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;k=ie}const[I,q]=k;if(I===null||q===null||I===q)return L("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Z=[],W=[];for(let de=0;de<$.length;de++){const ie=P(R($[de]));ie===I?Z.push($[de]):ie===q&&W.push($[de])}if(Z.length===0||W.length===0)return L("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=D.test&&D.test!=="auto"?String(D.test):null,ee=z(j,Z.concat(W));let te,ne,ae;if(J===l.CHI_SQUARE||!J&&!ee){ne=J?"override":"auto",ae=J?"caller override: chiSquare":"column family: categorical";const de=H(j,Z),ie=H(j,W);te=T(de.map,de.total,ie.map,ie.total,M,{category:D.category})}else{if((J===l.WELCH||J===l.MANN_WHITNEY)&&!ee)return L("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const de=Q(j,Z),ie=Q(j,W),oe=x(de,ie,J);ne=oe.chosenBy,ae=oe.reason,te=oe.test===l.MANN_WHITNEY?y(de,ie,M):w(de,ie,M)}return te?{...te,chosenBy:ne,reason:ae,groups:[I,q]}:(L("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),xe("packages/core/src/columns/detailcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const X="__lattice_detail",L=36;function B(_){const Q=_.config&&_.config.detailColumnWidth||L;return{id:X,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Q,min:Q,max:Q,pin:_.config&&_.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(G,H){return!!(H&&H.expanded)},formatValue(){return""}}}const F=B}),xe("packages/core/src/columns/treecolumn.js",function(e,K){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="__lattice_tree",F=260;function _(G){const H=G.tree||{},U=G.config&&G.config.treeColumnWidth||F,z=()=>(G.columns&&L(G.columns.visible)?G.columns.visible():[]).find(u=>!u.generated)||null,S=(b,u)=>{if(u&&u.group)return u.groupValue;if(L(H.label))return H.label(b,u);if(typeof H.label=="string")return b==null?null:b[H.label];const d=z();return d&&L(d.getValue)?d.getValue(b,u):null},O=()=>{if(H.title)return H.title;const b=typeof H.label=="string"?G.columns&&L(G.columns.get)?G.columns.get(H.label):null:z();return b&&(b.title||b.id)||"Hierarchy"};return{id:B,get title(){return O()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:U,min:140,pin:G.config&&G.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(b,u){return S(b,u)},formatValue(b,u){if(u&&u.grandTotal)return G.config&&G.config.grandTotalLabel||"Total";if(b==null)return"";if(!H.label){const d=z();if(d&&L(d.formatValue))return d.formatValue(b,u)}return String(b)}}}const Q=_}),xe("packages/core/src/columns/pivotcolumns.js",function(e,K){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return _}});const L=K("packages/core/src/internal/util.js").warnOnce,B="__lattice_pivot",F=500;function _(U){const{pivot:z,valueColumns:S,config:O}=U,b=z&&z.paths||[],u=U.separator||O&&O.pivot&&O.pivot.separator||" | ",d=O&&O.pivot&&O.pivot.maxColumns||F;if(!b.length||!S.length)return{tree:[],leaves:[],error:null};const s=Q(O),n=b.length*S.length+(s?S.length:0);if(n>d){const o=`pivot would generate ${n} columns, above the limit of ${d}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return L(`pivot.maxColumns:${n}`,o),{tree:[],leaves:[],error:o}}const t=[],r=[];for(const o of b){const f=[];for(const l of S){const i=H(o,l,u);f.push(i),r.push(i)}f.length===1?(f[0].title=String(o),t.push(f[0])):t.push({id:`${B}:group:${o}`,title:String(o),columns:f,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(s){const o=S.map(l=>G(l,O));r.push(...o);const f=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(o.length===1)o[0].title=f,s==="before"?t.unshift(o[0]):t.push(o[0]);else{const l={id:`${B}:group:__totals`,title:f,columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};s==="before"?t.unshift(l):t.push(l)}}return{tree:t,leaves:r,error:null}}function Q(U){const z=U&&U.pivot&&U.pivot.groupTotals;return z==="before"||z==="after"?z:null}function G(U,z){return{id:`${B}:__total${z&&z.pivot&&z.pivot.separator||" | "}${U.id}`,field:null,title:U.title||U.id,type:U.type,dataType:U.dataType,nullable:!0,align:U.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:U.id,total:!0},value:{pure:!0},cell:{align:U.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:U.total,lookup:null,layout:{width:U.layout&&U.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(S,O){const b=O&&O.totals;return b&&Object.hasOwn(b,U.id)?b[U.id]:null},formatValue(S,O){return S==null?"":U.formatValue?U.formatValue(S,O):String(S)}}}function H(U,z,S){return{id:`${B}:${U}${S}${z.id}`,field:null,title:z.title||z.id,type:z.type,dataType:z.dataType,nullable:!0,align:z.align,generated:!0,pivot:{enabled:!1,index:0,path:U,sourceId:z.id},value:{pure:!0},cell:{align:z.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:z.total,lookup:null,layout:{width:z.layout&&z.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(O,b){return O==null?"":z.formatValue?z.formatValue(O,b):String(O)}}}}),xe("packages/core/src/compute/group.js",function(e,K){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const X=K("packages/core/src/compute/handle.js"),L=X.dictSize,B=X.identity,F=X.presenceReader,_=X.rowCount,Q=X.valueReader,G="",H="\0",U=1<<20;function z(b,u,d,s){const n=b.length,t=b.map(g=>Q(g)),r=Array.isArray(s)&&s.some(Boolean),o=r?t.map((g,c)=>s[c]?h=>s[c](g(h)):g):t;if(!r&&n>0&&b.every(g=>g&&g.kind==="dictionary"&&g.dict)){const g=b.map(h=>L(h.dict)+1);let c=1;for(let h=0;h<n;h++)c*=g[h];if(c<=Number.MAX_SAFE_INTEGER){const h=b.map(v=>v.values),a=b.map(v=>F(v)),m=v=>{let p=0;for(let y=0;y<n;y++){const C=a[y],T=C&&C(v)===0?g[y]-1:h[y][v];p=p*g[y]+T}return p},w=new Float64Array(d);for(let v=0;v<d;v++)w[v]=m(u[v]);return{packed:w,strings:null,product:c,readers:o,keyOf:m}}}const l=g=>{let c="";for(let h=0;h<n;h++){const a=o[h](g);c+=(h===0?"":G)+(a==null?H:String(a))}return c},i=new Array(d);for(let g=0;g<d;g++)i[g]=l(u[g]);return{packed:null,strings:i,product:1/0,readers:o,keyOf:l}}function S(b,u,d,s){const n=new Uint32Array(s+1);for(let f=0;f<d;f++)n[u[f]+1]++;for(let f=0;f<s;f++)n[f+1]+=n[f];const t=new Uint32Array(d),r=n.slice(0,s);for(let f=0;f<d;f++)t[r[u[f]]++]=b[f];const o=new Array(s);for(let f=0;f<s;f++)o[f]=t.subarray(n[f],n[f+1]);return o}function O(b,u,d={}){const s=b||[],n=u||B(_(s[0],d)),t=n.length;if(s.length===0||t===0)return{keys:[],buckets:[]};const{packed:r,strings:o,product:f,readers:l}=z(s,n,t,d.project),i=new Uint32Array(t);let g=0,c=null;if(r&&f<=Math.max(1024,Math.min(U,t*4))){const w=f,v=new Int32Array(w).fill(-1);for(let p=0;p<t;p++)v[r[p]]=0;for(let p=0;p<w;p++)v[p]===0&&(v[p]=g++);for(let p=0;p<t;p++)i[p]=v[r[p]];c=new Float64Array(g);for(let p=0;p<w;p++)v[p]>=0&&(c[v[p]]=p)}else if(r){const w=new Map;for(let v=0;v<t;v++){const p=r[v];let y=w.get(p);y===void 0&&(y=g++,w.set(p,y)),i[v]=y}c=new Float64Array(g);for(const[v,p]of w)c[p]=v}else{const w=new Map;for(let v=0;v<t;v++){const p=o[v];let y=w.get(p);y===void 0&&(y=g++,w.set(p,y)),i[v]=y}}const h=S(n,i,t,g),a=new Array(g);for(let w=0;w<g;w++){const v=h[w][0],p=new Array(l.length);for(let y=0;y<l.length;y++)p[y]=l[y](v);a[w]=p}const m={keys:a,buckets:h};return c&&(m.packed=c),m}}),xe("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const L=K("packages/core/src/internal/util.js").warnOnce,F=K("packages/core/src/compute/handle.js").valueComparator,Q=K("packages/core/src/compute/group.js").packKeys,H=K("packages/core/src/compute/total.js").total,U="|",z="/",S=2e3;function O(f,l,i){return`${f}${U}${l}${U}${i}`}function b(f,l){let i="";for(let g=0;g<f.length;g++){const c=f[g];i+=(g===0?"":l)+(c==null?"":String(c))}return i}function u(f,l,i={}){const g=i.separator||z,c=l.length,{keyOf:h,readers:a}=Q(f,l,0),m=new Map,w=[],v=[];for(let E=0;E<c;E++){const j=l[E],A=h(j);if(m.has(A))continue;m.set(A,w.length),v.push(A);const $=new Array(a.length);for(let D=0;D<a.length;D++)$[D]=a[D](j);w.push($)}const p=F(i.locale),y=w.map((E,j)=>j);y.sort((E,j)=>{const A=w[E],$=w[j];for(let D=0;D<A.length;D++){const M=d(A[D],$[D],p);if(M!==0)return M}return E-j});const C=new Array(y.length),T=new Array(y.length),P=new Map;for(let E=0;E<y.length;E++){const j=y[E];C[E]=w[j],T[E]=b(w[j],g),P.set(v[j],E)}return{keys:C,paths:T,idOf:E=>{const j=P.get(h(E));return j===void 0?-1:j}}}function d(f,l,i){const g=f==null,c=l==null;return g||c?g&&c?0:g?1:-1:i(f,l)}function s(f){const l=f.values||f.totals||[];if(l.length&&typeof l[0]=="object"&&l[0]!==null)return l.filter(h=>h&&h.handle);const i=typeof f.handle=="function"?f.handle:null;if(!i)return l.length&&L("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const g=typeof f.totalOf=="function"?f.totalOf:null,c=[];for(const h of l){const a=i(h);a&&c.push({colId:h,handle:a,fn:g?g(h):"sum"})}return c}function n(f,l,i){if(Array.isArray(f)){const g=i||{};return{...g,pivotHandles:f,order:l||null,groups:g.groups||null}}return f||{}}function t(f,l,i){const g=n(f,l,i),c=g.separator||z,h=s(g),a=g.maxColumns===void 0?S:g.maxColumns,m=g.groups&&g.groups.buckets?g.groups:null,w=m?m.buckets:[g.order||new Uint32Array(0)],v=g.groupPaths||(m?m.keys.map(A=>b(A,c)):[""]),p=o(w),{keys:y,paths:C,idOf:T}=u(g.pivotHandles||[],p,g),P=C.length*Math.max(1,h.length),x=r(C,h,c);if(a&&P>a){const A=new Map;return{keys:y,paths:C,fields:x,groupPaths:v,columns:P,values:A,cells:A,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:a}}}const E=new Map,j=C.length;for(let A=0;A<w.length;A++){const $=w[A],D=v[A]===void 0?"":v[A],M=$.length;if(M===0)continue;const R=new Int32Array(M),k=new Uint32Array(j+1);for(let Z=0;Z<M;Z++){const W=T($[Z]);R[Z]=W,W>=0&&k[W+1]++}for(let Z=0;Z<j;Z++)k[Z+1]+=k[Z];const I=new Uint32Array(M),q=k.slice(0,j);for(let Z=0;Z<M;Z++){const W=R[Z];W>=0&&(I[q[W]++]=$[Z])}for(let Z=0;Z<j;Z++){const W=k[Z],J=k[Z+1];if(J===W)continue;const ee=I.subarray(W,J);for(let te=0;te<h.length;te++){const ne=h[te],ae=H(ne.handle,ee,ne.fn,g.totalContext||{locale:g.locale});E.set(O(D,C[Z],ne.colId),ae)}}}return{keys:y,paths:C,fields:x,groupPaths:v,columns:P,values:E,cells:E,error:null}}function r(f,l,i){if(l.length===0)return f.slice();const g=[];for(const c of f)for(const h of l)g.push(`${c}${i}${h.colId}`);return g}function o(f){if(f.length===1)return f[0]||new Uint32Array(0);let l=0;for(const c of f)l+=c?c.length:0;const i=new Uint32Array(l);let g=0;for(const c of f)!c||c.length===0||(i.set(c,g),g+=c.length);return i}}),xe("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return L}});const X=8;class L{static#e=new Uint8Array(256);static{for(let F=1;F<256;F++)L.#e[F]=L.#e[F>>1]+(F&1)}#t;#n;constructor(F=0){const _=Math.max(0,F|0);this.#n=_,this.#t=new Uint8Array(Math.ceil(_/X))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(F){return F<0||F>=this.#n?0:this.#t[F>>3]>>(F&7)&1}set(F){return F>=0&&F<this.#n&&(this.#t[F>>3]|=1<<(F&7)),this}clear(F){return F>=0&&F<this.#n&&(this.#t[F>>3]&=~(1<<(F&7))),this}assign(F,_){return _?this.set(F):this.clear(F)}fill(F=!1){return this.#t.fill(F?255:0),F&&this.#r(),this}grow(F){const _=Math.max(0,F|0);if(_<=this.#n)return this;const Q=Math.ceil(_/X);if(Q>this.#t.length){const G=new Uint8Array(Q);G.set(this.#t),this.#t=G}return this.#n=_,this}count(){const F=this.#t,_=L.#e;let Q=0;for(let G=0;G<F.length;G++)Q+=_[F[G]];return Q}and(F){const _=F instanceof L?F.words:F,Q=this.#t,G=Math.min(Q.length,_.length);for(let H=0;H<G;H++)Q[H]&=_[H];for(let H=G;H<Q.length;H++)Q[H]=0;return this}or(F){const _=F instanceof L?F.words:F,Q=this.#t,G=Math.min(Q.length,_.length);for(let H=0;H<G;H++)Q[H]|=_[H];return this}not(){const F=this.#t;for(let _=0;_<F.length;_++)F[_]=~F[_]&255;return this.#r(),this}clone(){const F=new L(this.#n);return F.words.set(this.#t.subarray(0,F.words.length)),F}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const F=this.#n&7;if(F===0)return;const _=this.#n>>3;_<this.#t.length&&(this.#t[_]&=(1<<F)-1)}static from(F){const _=Array.isArray(F)?F:Array.from(F),Q=new L(_.length);for(let G=0;G<_.length;G++)_[G]&&Q.set(G);return Q}}}),xe("packages/core/src/store/dictionary.js",function(e,K){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return F}});const X=K("packages/core/src/internal/util.js"),L=X.collator,B=X.defaultCompare;class F{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(Q=[]){this.#e=[];for(let G=0;G<Q.length;G++){const H=Q[G];this.#t.has(H)||(this.#t.set(H,this.#e.length),this.#e.push(H))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Q=this.#e.length*8;for(let G=0;G<this.#e.length;G++){const H=this.#e[G];typeof H=="string"&&(Q+=H.length*2),Q+=16}return Q}codeOf(Q){const G=this.#t.get(Q);if(G!==void 0)return G;const H=this.#e.length;return this.#e.push(Q),this.#t.set(Q,H),this.#n++,H}lookup(Q){const G=this.#t.get(Q);return G===void 0?-1:G}has(Q){return this.#t.has(Q)}valueOf(Q){return this.#e[Q]}values(){return this.#e}ranks(Q){const G=Q||"";if(this.#r&&this.#o===this.#n&&this.#i===G)return this.#r;const H=this.#e.length,U=new Array(H);for(let b=0;b<H;b++)U[b]=b;const z=L(Q).compare,S=this.#e;U.sort((b,u)=>this.#s(S[b],S[u],z));const O=new Uint32Array(H);for(let b=0;b<H;b++)O[U[b]]=b;return this.#r=O,this.#o=this.#n,this.#i=G,O}#s(Q,G,H){return typeof Q=="string"&&typeof G=="string"?H(Q,G):B(Q,G)}}}),xe("packages/core/src/store/multivalue.js",function(e,K){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return X}});class X{#e;#t;#n=0;#r=0;constructor(B={}){const F=Math.max(1,B.rows??16),_=Math.max(1,B.values??F);this.#e=new Int32Array(_),this.#t=new Uint32Array(F+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(B){return B<0||B>=this.#n?0:this.#t[B+1]-this.#t[B]}at(B){return B<0||B>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[B],this.#t[B+1])}has(B,F){if(B<0||B>=this.#n)return!1;const _=this.#e,Q=this.#t[B+1];for(let G=this.#t[B];G<Q;G++)if(_[G]===F)return!0;return!1}hasAny(B,F){for(let _=0;_<F.length;_++)if(this.has(B,F[_]))return!0;return!1}hasAll(B,F){for(let _=0;_<F.length;_++)if(!this.has(B,F[_]))return!1;return!0}hasNone(B,F){return!this.hasAny(B,F)}push(B){const F=this.#n,_=B.length;this.#o(F+1),this.#i(this.#r+_);const Q=this.#r;for(let G=0;G<_;G++)this.#e[Q+G]=B[G]|0;return this.#r+=_,this.#n=F+1,this.#t[F]=Q,this.#t[F+1]=this.#r,F}write(B,F){if(B===this.#n){this.push(F);return}if(B<0||B>this.#n)return;const _=this.#t[B],Q=this.#t[B+1],G=F.length;if(Q-_===G){for(let H=0;H<G;H++)this.#e[_+H]=F[H]|0;return}this.#s(B,F)}compact(B,F,_){const Q=this.#e,G=this.#t,H=this.#n,U=new Int32Array(Math.max(1,this.#r)),z=new Uint32Array(F+1);let S=0;for(let O=0;O<H;O++){if(B[O]===_)continue;const b=G[O],u=G[O+1];z[B[O]]=S;for(let d=b;d<u;d++)U[S++]=Q[d];z[B[O]+1]=S}this.#e=U,this.#t=z,this.#n=F,this.#r=S}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(B){if(B+1<=this.#t.length)return;let F=this.#t.length-1;for(;F<B;)F=F*2||16;const _=new Uint32Array(F+1);_.set(this.#t),this.#t=_}#i(B){if(B<=this.#e.length)return;let F=this.#e.length;for(;F<B;)F=F*2||16;const _=new Int32Array(F);_.set(this.#e),this.#e=_}#s(B,F){const _=this.#e,Q=this.#t,G=this.#n,H=F.length-(Q[B+1]-Q[B]),U=new Int32Array(Math.max(1,this.#r+H)),z=new Uint32Array(Q.length);let S=0;for(let O=0;O<G;O++){if(z[O]=S,O===B)for(let b=0;b<F.length;b++)U[S++]=F[b]|0;else for(let b=Q[O];b<Q[O+1];b++)U[S++]=_[b];z[O+1]=S}this.#e=U,this.#t=z,this.#r=S}}}),xe("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return j}});const X=K("packages/core/src/compute/handle.js"),L=X.bitReader,B=X.dictRanks,F=X.dictSize,_=X.identity,Q=X.isMissing,G=X.presenceReader,H=X.rowCount,U=X.valueComparator,z=X.valueReader,S=new Uint32Array(0),O=new ArrayBuffer(8),b=new Float64Array(O),u=new Uint32Array(O),d=(b[0]=-1,(u[1]&2147483648)!==0?1:0),s=d===1?0:1;function n($,D){b[0]=$;let M=u[d],R=u[s];(M&2147483648)!==0?(M=~M>>>0,R=~R>>>0):M=(M^2147483648)>>>0,D[0]=R,D[1]=M}function t($,D,M,R){if(R<2)return $;const k=new Uint32Array(256*8);for(let ne=0;ne<R;ne++){const ae=D[ne],de=M[ne];k[ae&255]++,k[256+(ae>>>8&255)]++,k[512+(ae>>>16&255)]++,k[768+(ae>>>24&255)]++,k[1024+(de&255)]++,k[1280+(de>>>8&255)]++,k[1536+(de>>>16&255)]++,k[1792+(de>>>24&255)]++}let I=$,q=D,Z=M,W=new Uint32Array(R),J=new Uint32Array(R),ee=new Uint32Array(R);const te=new Uint32Array(256);for(let ne=0;ne<8;ne++){const ae=ne<<8,de=(ne&3)<<3,ie=ne>=4;let oe=!1;for(let ke=0;ke<256;ke++)if(k[ae+ke]===R){oe=!0;break}if(oe)continue;let ce=0;for(let ke=0;ke<256;ke++)te[ke]=ce,ce+=k[ae+ke];for(let ke=0;ke<R;ke++){const Re=q[ke],Ee=Z[ke],Fe=(ie?Ee:Re)>>>de&255,ye=te[Fe]++;W[ye]=I[ke],J[ye]=Re,ee[ye]=Ee}let fe=I;I=W,W=fe,fe=q,q=J,J=fe,fe=Z,Z=ee,ee=fe}return I}function r($,D,M){if(M<2)return $;const R=new Uint32Array(256*4);for(let J=0;J<M;J++){const ee=D[J];R[ee&255]++,R[256+(ee>>>8&255)]++,R[512+(ee>>>16&255)]++,R[768+(ee>>>24&255)]++}let k=$,I=D,q=new Uint32Array(M),Z=new Uint32Array(M);const W=new Uint32Array(256);for(let J=0;J<4;J++){const ee=J<<8,te=J<<3;let ne=!1;for(let ie=0;ie<256;ie++)if(R[ee+ie]===M){ne=!0;break}if(ne)continue;let ae=0;for(let ie=0;ie<256;ie++)W[ie]=ae,ae+=R[ee+ie];for(let ie=0;ie<M;ie++){const oe=I[ie],ce=W[oe>>>te&255]++;q[ce]=k[ie],Z[ce]=oe}let de=k;k=q,q=de,de=I,I=Z,Z=de}return k}function o($,D,M,R){const k=new Uint32Array(R+1);for(let Z=0;Z<M;Z++)k[D[Z]]++;let I=0;for(let Z=0;Z<=R;Z++){const W=k[Z];k[Z]=I,I+=W}const q=new Uint32Array(M);for(let Z=0;Z<M;Z++)q[k[D[Z]]++]=$[Z];return q}function f($,D,M,R){return M<2?$:R<=65536||R<=M*2?o($,D,M,R):r($,D,M)}function l($,D){return $.length===D&&$.byteOffset===0?$:Uint32Array.prototype.slice.call($,0,D)}function i($,D,M=!1){const R=D||_($.length),k=R.length;if(k<2)return Uint32Array.from(R);const I=new Uint32Array(k),q=new Uint32Array(k),Z=new Uint32Array(k),W=new Uint32Array(k),J=new Uint32Array(2);let ee=0,te=0;for(let de=0;de<k;de++){const ie=R[de],oe=$[ie];if(Number.isNaN(oe)){W[te++]=ie;continue}n(oe,J),M?(q[ee]=~J[0]>>>0,Z[ee]=~J[1]>>>0):(q[ee]=J[0],Z[ee]=J[1]),I[ee++]=ie}const ne=t(I.subarray(0,ee),q.subarray(0,ee),Z.subarray(0,ee),ee);if(te===0)return l(ne,ee);const ae=new Uint32Array(k);return ae.set(ne.subarray(0,ee),0),ae.set(W.subarray(0,te),ee),ae}function g($,D,M=!1){const R=D||_($.length),k=R.length;if(k<2)return Uint32Array.from(R);const I=Uint32Array.from(R),q=new Uint32Array(k);for(let Z=0;Z<k;Z++){const W=($[I[Z]]^2147483648)>>>0;q[Z]=M?~W>>>0:W}return l(r(I,q,k),k)}function c($,D,M={}){const R=D||_(H($,M)),k=R.length;if(k<2)return Uint32Array.from(R);const I=B($.dict,M.locale),q=$.values,Z=G($),W=Math.max(F($.dict),I.length),J=W,ee=Uint32Array.from(R),te=new Uint32Array(k),ne=!!M.descending;for(let ae=0;ae<k;ae++){const de=ee[ae];let ie=Z&&Z(de)===0?J:I[q[de]];ie===void 0&&(ie=J),te[ae]=ne?J-ie:ie}return l(f(ee,te,k,W+1),k)}function h($,D,M){const R=D.length;let k=Uint32Array.from(D);if(R<2)return k;let I=new Uint32Array(R);for(let q=1;q<R;q<<=1){for(let W=0;W<R;W+=q<<1){const J=Math.min(W+q,R),ee=Math.min(W+(q<<1),R);let te=W,ne=J,ae=W;for(;te<J&&ne<ee;)I[ae++]=M($[k[te]],$[k[ne]])<=0?k[te++]:k[ne++];for(;te<J;)I[ae++]=k[te++];for(;ne<ee;)I[ae++]=k[ne++]}const Z=k;k=I,I=Z}return k}function a($,D,M){const R=L($.values),k=D.length,I=new Uint32Array(k),q=M?1:0;let Z=0;for(let W=0;W<k;W++)R(D[W])===q&&(I[Z++]=D[W]);for(let W=0;W<k;W++)R(D[W])!==q&&(I[Z++]=D[W]);return I}function m($,D){const M=$.values,R=$.kind;if((R==="object"||R===void 0)&&(Array.isArray(M)||ArrayBuffer.isView(M))&&!$.presence)return M;const I=z($),q=new Array(H($)||0);for(let Z=0;Z<D.length;Z++){const W=D[Z];q[W]=I(W)}return q}function w($,D){for(let M=0;M<D.length;M++)if(typeof $[D[M]]!="string")return!1;return!0}function v($,D,M,R,k){const I=$.length,q=Uint32Array.from($);if(I<2||R<1)return q;const Z=new Uint32Array(I),W=R-1;for(let J=0;J<I;J++){const ee=M[D[J]];Z[J]=k?W-ee:ee}return l(f(q,Z,I,R),I)}function p($,D,M){const R=U(M),k=new Array(D);for(let q=0;q<D;q++)k[q]=q;k.sort((q,Z)=>R($[q],$[Z])||q-Z);const I=new Uint32Array(D);for(let q=0;q<D;q++)I[k[q]]=q;return I}function y($,D,M){const R=D.length,k=new Map,I=[],q=new Uint32Array(R);for(let J=0;J<R;J++){const ee=$[D[J]];let te=k.get(ee);te===void 0&&(te=I.length,k.set(ee,te),I.push(ee)),q[J]=te}const Z=I.length,W=p(I,Z,M.locale);return v(D,q,W,Z,!!M.descending)}function C($,D,M){const R=m($,D);if(D.length>=2&&w(R,D)){const q=$.stringRank;return q&&q.version===$.version&&q.usable(D,R,M.locale)?q.sort(D,M):y(R,D,M)}const k=U(M.locale),I=M.descending?(q,Z)=>k(Z,q):k;return h(R,D,I)}function T($,D,M){const R=m($,D),k=M.compare,q=!!M.descending?(Z,W)=>-k(Z,W,void 0,void 0,!0):(Z,W)=>k(Z,W,void 0,void 0,!1);return h(R,D,q)}function P($,D){const M=D.length,R=G($),k=$.values,I=$.kind==="float64"&&!!k,q=$.kind==="object"||$.kind==="multi"||$.kind===void 0;if(!R&&!I&&!q)return{present:D,absent:S};const Z=new Uint32Array(M),W=new Uint32Array(M);let J=0,ee=0;if(R&&I)for(let te=0;te<M;te++){const ne=D[te];R(ne)===1&&!Number.isNaN(k[ne])?Z[J++]=ne:W[ee++]=ne}else if(I&&!R)for(let te=0;te<M;te++){const ne=D[te];Number.isNaN(k[ne])?W[ee++]=ne:Z[J++]=ne}else if(R&&!q)for(let te=0;te<M;te++){const ne=D[te];R(ne)===1?Z[J++]=ne:W[ee++]=ne}else{const te=z($);for(let ne=0;ne<M;ne++){const ae=D[ne];Q(te(ae))?W[ee++]=ae:Z[J++]=ae}}return ee===0?{present:D,absent:S}:{present:Z.subarray(0,J),absent:W.subarray(0,ee)}}function x($,D,M){if(D.length===0)return $;const R=new Uint32Array($.length+D.length);return M?(R.set(D,0),R.set($,D.length)):(R.set($,0),R.set(D,$.length)),R}function E($,D,M={}){const R=D||_(H($,M));if(!$||R.length<2)return Uint32Array.from(R);const{present:k,absent:I}=P($,R);if(k.length===0)return Uint32Array.from(R);const q=!!M.descending;let Z;if(typeof M.compare=="function")Z=T($,k,M);else switch($.kind){case"float64":Z=i($.values,k,q);break;case"int32":Z=g($.values,k,q);break;case"dictionary":Z=c($,k,M);break;case"bitset":Z=a($,k,q);break;default:Z=C($,k,M);break}return x(Z,I,!!M.nullsFirst)}function j($,D,M,R={}){const k=D||[],I=k.length&&(k[0].handle||A($,k[0].col))||$&&$[0];let q=M||_(H(I,R));for(let Z=k.length-1;Z>=0;Z--){const W=k[Z],J=W.handle||A($,W.col)||$&&$[Z];J&&(q=E(J,q,{descending:W.descending!==void 0?!!W.descending:W.dir==="desc",nullsFirst:!!W.nullsFirst,locale:W.locale!==void 0?W.locale:R.locale,compare:W.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function A($,D){if(!(!$||D===void 0)){for(let M=0;M<$.length;M++)if($[M]&&$[M].id===D)return $[M]}}}),xe("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return _}});const X=K("packages/core/src/compute/sort.js"),L=X.collateStringRanks,B=X.rankSortStrings,F=1e5;class _{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(G=F){this.#s=G>0?G:F,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(G){this.#i=G}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let G=this.#n.byteLength;const H=this.#e;for(let U=0;U<H.length;U++)G+=H[U].length*2+24;return G}#d(G,H){const U=this.#t.get(G);if(U!==void 0)return U;if(this.#l)return-1;if(H&&this.#e.length>=this.#s)return this.#l=!0,-1;const z=this.#e.length;return this.#e.push(G),this.#t.set(G,z),this.#o++,z}build(G,H){const U=H|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(U);for(let z=0;z<U;z++){const S=G[z],O=typeof S=="string"?this.#d(S,!1):-1;this.#n[z]=O<0?0:O}this.#r=U}append(G,H,U){const z=(H|0)+(U|0);if(z>this.#n.length){const S=new Uint32Array(z);S.set(this.#n.subarray(0,this.#r)),this.#n=S}for(let S=H|0;S<z;S++){const O=G[S],b=typeof O=="string"?this.#d(O,!0):-1;this.#n[S]=b<0?0:b}this.#r=Math.max(this.#r,z)}ranks(G){const H=G||"";if(this.#a&&this.#u===this.#o&&this.#c===H)return this.#a;const U=L(this.#e,this.#e.length,G);return this.#a=U,this.#u=this.#o,this.#c=H,U}usable(G,H,U){if(this.#l||this.#e.length===0)return!1;const z=this.#n,S=this.#e,O=this.#r;for(let b=0;b<G.length;b++){const u=G[b];if(u>=O||S[z[u]]!==H[u])return!1}return!0}sort(G,H){const U=this.ranks(H.locale),z=this.#e.length,S=G.length,O=new Uint32Array(S),b=this.#n;for(let u=0;u<S;u++)O[u]=b[G[u]];return B(G,O,U,z,!!H.descending)}}}),xe("packages/core/src/store/columnstore.js",function(e,K){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return c}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=X.pathGetter,Q=K("packages/core/src/store/bitset.js").Bitset,H=K("packages/core/src/store/dictionary.js").Dictionary,z=K("packages/core/src/store/multivalue.js").MultiValue,O=K("packages/core/src/store/stringrank.js").StringRankIndex,b=4294967295,u=1024,d=5e3,s=.2,n=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(h){return h==null}function r(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(typeof h=="boolean")return h?1:0;const a=Number(h);return Number.isNaN(a)&&typeof h=="string"?Date.parse(h):a}function o(h){const a=r(h);return Number.isFinite(a)?a|0:0}function f(h){return t(h)?[]:Array.isArray(h)?h:[h]}function l(h,a){switch(h.kind){case"float64":case"int32":return h.buf[a];case"bitset":return h.bits.get(a)===1;case"dictionary":return h.dict.valueOf(h.buf[a]);case"multi":{const m=h.mv.at(a),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=h.dict.valueOf(m[v]);return w}default:return h.buf[a]}}function i(h,a){switch(h.kind){case"float64":case"int32":return h.values[a];case"bitset":return(h.values[a>>3]&1<<(a&7))!==0;case"dictionary":return(h.table||[])[h.values[a]];case"multi":{const m=h.offsets[a],w=h.offsets[a+1],v=h.table||[],p=new Array(w-m);for(let y=m;y<w;y++)p[y-m]=v[h.values[y]];return p}default:return h.values[a]}}class g{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h;#p;#m=-1;#g=null;#y=0;#w=0;#k=null;#b=null;#O=!1;constructor(a,m){this.#e=a.id;const w=n.has(a.kind)?a.kind:"object";a.kind&&!n.has(a.kind)&&L(`store.kind.${a.id}`,`column "${a.id}" declares unknown storage kind "${a.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=a.nullable!==!1,this.#s=a.dictionary??null,this.#i=m,this.#o=B(a.read)?a.read:F(a.field||a.id),this.#h=a.stringRankIndex!=="off",this.#p=typeof a.stringRankMaxDistinct=="number"?a.stringRankMaxDistinct:0,this.#k=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#O?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#E().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#E().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const a=this.values,m=this.#i.physical();if(!a||m===0)return null;if(this.#f===null){if(typeof a[0]!="string")return null;const w=new O(this.#A());return w.build(a,m),w.version=this.#w,this.#f=w,this.#m=this.#w,w.capped?null:w}return this.#f.length<m&&this.#f.append(a,this.#f.length,m-this.#f.length),this.#f.version=this.#w,this.#m=this.#w,this.#f.capped?null:this.#f}#A(){return this.#p}#P(){this.#f=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#w}get bytes(){let a=0;return this.#a&&(a+=this.#a.byteLength??this.#a.length*8),this.#u&&(a+=this.#u.bytes),this.#c&&(a+=this.#c.bytes),this.#g&&(a+=this.#g.bytes),this.#d&&(a+=this.#d.bytes),this.#k&&(a+=this.#k.size*24),a}get(a){if(!this.#O&&!(a<0||a>=this.#i.physical())){if(!this.#l)return this.#j(a);if(this.#r&&this.#g.get(a)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[a];case"bitset":return this.#u.get(a)===1;case"dictionary":return this.#d.valueOf(this.#a[a]);case"multi":{const m=this.#c.at(a),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=this.#d.valueOf(m[v]);return w}default:return this.#a[a]}}}set(a,m){this.#O||(this.#l?this.#M(a,m):this.#k.set(a,m===void 0?null:m),this.#f&&this.#P(),this.#w++)}read(a){return this.#o(a)}appendColumn(a,m,w){if(this.#O||w<=0)return;if(!this.#l){this.#w++;return}const v=this.#o,p=this.#r,y=this.#g;let C=!1;switch(this.#t){case"float64":{const T=this.#a;for(let P=0;P<w;P++){const x=v(a[P]);if(typeof x=="number"){p&&y.set(m+P),T[m+P]=x;continue}const E=x==null;p?y.assign(m+P,!E):E&&(C=!0),T[m+P]=E?NaN:r(x)}break}case"int32":{const T=this.#a;for(let P=0;P<w;P++){const x=v(a[P]),E=x==null;p?y.assign(m+P,!E):E&&(C=!0),T[m+P]=E?0:o(x)}break}case"bitset":{const T=this.#u;for(let P=0;P<w;P++){const x=v(a[P]),E=x==null;p?y.assign(m+P,!E):E&&(C=!0),T.assign(m+P,!E&&!!x)}break}case"dictionary":{const T=this.#a,P=this.#d;for(let x=0;x<w;x++){const E=v(a[x]),j=E==null;p?y.assign(m+x,!j):j&&(C=!0),T[m+x]=j?0:P.codeOf(E)}break}case"multi":{const T=this.#c,P=this.#d;for(let x=0;x<w;x++){const E=v(a[x]),j=E==null;p?y.assign(m+x,!j):j&&(C=!0);const A=f(E),$=new Array(A.length);for(let D=0;D<A.length;D++)$[D]=P.codeOf(A[D]);T.write(m+x,$)}break}default:{const T=this.#a;for(let P=0;P<w;P++){const x=v(a[P]),E=x==null;p?y.assign(m+P,!E):E&&(C=!0),T[m+P]=E?null:x}break}}C&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#f&&this.#t==="object"&&(this.#f.append(this.#a,m,w),this.#f.version=this.#w+1,this.#m=this.#w+1),this.#w++}appendPacked(a,m,w){if(this.#O||w<=0||!a)return;if(!this.#l){this.#w++;return}const v=this.#g,p=a.presence;if(v)if(p)for(let C=0;C<w;C++)v.assign(m+C,(p[C>>3]&1<<(C&7))!==0);else for(let C=0;C<w;C++)v.set(m+C);const y=a.kind===this.#t;if(y&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(a.values,m),this.#w++;return}if(y&&this.#t==="bitset"){const C=a.values;for(let T=0;T<w;T++)this.#u.assign(m+T,(C[T>>3]&1<<(T&7))!==0);this.#w++;return}if(y&&this.#t==="dictionary"){const C=a.table||[],T=new Uint32Array(C.length);for(let j=0;j<C.length;j++)T[j]=this.#d.codeOf(C[j]);const P=a.values,x=this.#a,E=v;for(let j=0;j<w;j++){if(E&&(p&&(p[j>>3]&1<<(j&7))===0)){x[m+j]=0;continue}x[m+j]=T[P[j]]??0}this.#w++;return}if(y&&this.#t==="multi"){const C=a.table||[],T=new Uint32Array(C.length);for(let E=0;E<C.length;E++)T[E]=this.#d.codeOf(C[E]);const P=a.values,x=a.offsets;for(let E=0;E<w;E++){const j=x[E],A=x[E+1],$=new Array(A-j);for(let D=j;D<A;D++)$[D-j]=T[P[D]]??0;this.#c.write(m+E,$)}this.#w++;return}for(let C=0;C<w;C++){const T=p?(p[C>>3]&1<<(C&7))===0:a.kind==="object"?a.values[C]===null:!1;this.#M(m+C,T?null:i(a,C))}this.#w++}touch(){this.#w++}columnarise(a,m){if(this.#l||this.#O)return;const w=new Array(m);for(let v=0;v<m;v++)w[v]=this.#j(v);this.#t=this.#n,this.#l=!0,this.#S(a);for(let v=0;v<m;v++)this.#M(v,w[v]);this.#k.clear(),this.#b=null,this.#P(),this.#w++}grow(a){if(!(!this.#l||this.#O||a<=this.#y)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#a.constructor(a);m.set(this.#a),this.#a=m;break}case"bitset":this.#u.grow(a);break;case"multi":break;default:this.#a.length=a;break}this.#g&&this.#g.grow(a),this.#y=a,this.#w++}}convert(a){if(this.#O||!n.has(a)||(this.#n=a,!this.#l||a===this.#t))return!1;const m={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),v=this.#g;this.#t=a,this.#S(this.#y);for(let p=0;p<w;p++){const y=v!==null&&v.get(p)===0;y&&a!=="multi"||this.#M(p,y?null:l(m,p))}return this.#P(),this.#w++,!0}compact(a,m,w){if(!this.#O){if(this.#P(),!this.#l){const v=this.#k;if(v.size){const p=new Map;for(const[y,C]of v)a[y]!==b&&p.set(a[y],C);this.#k=p}this.#b=null,this.#w++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#a;for(let p=0;p<m;p++)a[p]!==b&&(v[a[p]]=v[p]);if(this.#t==="object")for(let p=w;p<m;p++)v[p]=void 0;break}case"bitset":{const v=this.#u;for(let p=0;p<m;p++)a[p]!==b&&v.assign(a[p],v.get(p)===1);for(let p=w;p<m;p++)v.clear(p);break}case"multi":this.#c.compact(a,w,b);break;default:break}if(this.#g){const v=this.#g;for(let p=0;p<m;p++)a[p]!==b&&v.assign(a[p],v.get(p)===1);for(let p=w;p<m;p++)v.clear(p)}this.#w++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#f=null,this.#k=new Map,this.#b=null,this.#y=0,this.#w++)}#S(a){const m=Math.max(1,a);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(m);break;case"int32":this.#a=new Int32Array(m);break;case"bitset":this.#u=new Q(m);break;case"dictionary":this.#a=new Uint32Array(m),this.#d=this.#d??new H(this.#s??[]);break;case"multi":this.#c=new z({rows:m,values:m}),this.#d=this.#d??new H(this.#s??[]);break;default:this.#a=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new Q(m)),this.#y=m}#M(a,m){const w=t(m);switch(this.#r?this.#g.assign(a,!w):w&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[a]=w?NaN:r(m);break;case"int32":this.#a[a]=w?0:o(m);break;case"bitset":this.#u.assign(a,!w&&!!m);break;case"dictionary":this.#a[a]=w?0:this.#d.codeOf(m);break;case"multi":{const v=f(m),p=new Array(v.length);for(let y=0;y<v.length;y++)p[y]=this.#d.codeOf(v[y]);this.#c.write(a,p);break}default:this.#a[a]=w?null:m;break}}#j(a){if(this.#k.has(a))return this.#k.get(a);const m=this.#o(this.#i.rowAt(a));return m===void 0?null:m}#E(){if(this.#b&&this.#b.version===this.#w)return this.#b;const a=this.#i.physical(),m=new Array(a),w=this.#r?new Q(a):null;for(let v=0;v<a;v++){const p=this.#j(v);m[v]=p,w&&!t(p)&&w.set(v)}return this.#b={version:this.#w,values:m,presence:w},this.#b}}class c{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new Q(0);#u=!1;#c=!0;#d;#f;#h;#p=!1;constructor(a,m={}){this.#e=Array.isArray(a)?a:[],this.#f=Math.max(1,m.initialCapacity??u),this.#c=m.retainSource!==!1,this.#d=this.#c?m.columnarBelow??d:0,this.#h=m.compactRatio??s;const w={rowAt:v=>this.#r[v],physical:()=>this.#o};for(const v of this.#e){if(!v||!v.id)continue;if(this.#t.has(v.id)){L(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const p=new g(v,w);this.#t.set(v.id,p),this.#n.push(p)}this.#d<=0&&this.#y()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let a=this.#a.bytes+this.#r.length*8;for(const m of this.#n)a+=m.bytes;return a}append(a){const m=this.#o;if(this.#p||!a)return{from:m,to:m};const w=a.length|0;if(w===0)return{from:m,to:m};if(this.#c)for(let p=0;p<w;p++)this.#r[m+p]=a[p];if(this.#o=m+w,this.#s+=w,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#y();else for(const p of this.#n)p.touch();return{from:m,to:this.#o}}this.#m(this.#o);const v=this.#n;for(let p=0;p<v.length;p++)v[p].appendColumn(a,m,w);return{from:m,to:this.#o}}appendPacked(a,m){const w=this.#o;if(this.#p||!a)return{from:w,to:w};const v=a.count|0;if(v===0)return{from:w,to:w};if(this.#c&&m)for(let y=0;y<v;y++)this.#r[w+y]=m[y];this.#o=w+v,this.#s+=v,this.#a.grow(this.#o),this.#u||this.#y(),this.#m(this.#o);const p=new Map;for(const y of a.columns)p.set(y.id,y);for(const y of this.#n){const C=p.get(y.id);C?y.appendPacked(C,w,v):y.grow(this.#i)}return{from:w,to:this.#o}}source(a){if(this.#c)return this.#r[a];if(!(a<0||a>=this.#o))return this.#g(a)}setSource(a,m){this.#p||a<0||a>=this.#o||this.#c&&(this.#r[a]=m)}get(a,m){const w=this.#t.get(a);return w?w.get(m):void 0}set(a,m,w){if(this.#p||m<0||m>=this.#o)return;const v=this.#t.get(a);if(!v){L(`store.set.${a}`,`set() on unknown column "${a}"`);return}v.set(m,w)}remove(a){return this.#p||a<0||a>=this.#o||this.#a.get(a)===1?!1:(this.#a.set(a),this.#l++,this.#s--,!0)}live(a){return a<0||a>=this.#o?!1:this.#a.get(a)===0}compact(a={}){if(this.#p||this.#l===0||!a.force&&this.#l/this.#o<this.#h)return null;const m=this.#o,w=new Uint32Array(m);let v=0;for(let p=0;p<m;p++)w[p]=this.#a.get(p)===1?b:v++;for(const p of this.#n)p.compact(w,m,v);if(this.#c){const p=this.#r;for(let y=0;y<m;y++)w[y]!==b&&(p[w[y]]=p[y]);p.length=v}return this.#o=v,this.#s=v,this.#l=0,this.#a=new Q(Math.max(this.#i,v)),w}column(a){return this.#t.get(a)}columns(){return this.#n.slice()}liveIndices(){const a=new Uint32Array(this.#s);if(this.#l===0){for(let w=0;w<this.#o;w++)a[w]=w;return a}let m=0;for(let w=0;w<this.#o;w++)this.#a.get(w)===0&&(a[m++]=w);return a}convert(a,m){const w=this.#t.get(a);return w?w.convert(m):!1}destroy(){if(!this.#p){this.#p=!0;for(const a of this.#n)a.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#m(a){if(a<=this.#i)return;let m=this.#i||this.#f;for(;m<a;)m*=2;for(const w of this.#n)w.grow(m);this.#a.grow(m),this.#i=m}#g(a){const m={};for(const w of this.#n)m[w.id]=w.get(a);return m}#y(){if(this.#u)return;let a=this.#f;for(;a<this.#o;)a*=2;this.#u=!0,this.#i=a,this.#a.grow(a);for(const m of this.#n)m.columnarise(a,this.#o)}}}),xe("packages/core/src/store/pool.js",function(e,K){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return _}});const X=64,L=8;function B(G){let H=X;for(;H<G;)H*=2;return H}class F{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(H={}){this.#n=H.limit??L}get bytes(){return this.#r}mask(H){const U=new Uint8Array(this.#i(H),0,H);return U.fill(0),U}indices(H){return new Uint32Array(this.#i(H*4),0,H)}release(H){if(!H||!H.buffer)return!1;const U=H.buffer;if(!this.#t.has(U))return!1;this.#t.delete(U),this.#o.released++;const z=U.byteLength;let S=this.#e.get(z);return S||this.#e.set(z,S=[]),S.length>=this.#n||(S.push(U),this.#r+=z),!0}releaseAll(H){for(const U of H)this.release(U)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(H){const U=B(H),z=this.#e.get(U);this.#o.acquired++;let S;return z&&z.length?(S=z.pop(),this.#r-=U,this.#o.reused++):S=new ArrayBuffer(U),this.#t.add(S),S}}function _(){return Q??=new F,Q}let Q=null}),xe("packages/core/src/compute/sortspec.js",function(e,K){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return _}});function X(Q){return{locale:Q===void 0?void 0:String(Q),numeric:!0,sensitivity:"variant"}}function L(Q){return!!Q&&typeof Q.compare!="function"}function B(Q){if(!Q)return!0;for(let G=0;G<Q.length;G++)if(!L(Q[G]))return!1;return!0}function F(Q,G){const H=Q.col!==void 0?Q.col:Q.handle&&Q.handle.id,U=Q.locale!==void 0?Q.locale:G;return{col:H,descending:Q.descending!==void 0?!!Q.descending:Q.dir==="desc",nullsFirst:!!Q.nullsFirst,collation:X(U)}}function _(Q,G){const H=Q||[],U=new Array(H.length);for(let z=0;z<H.length;z++)U[z]=F(H[z],G);return U}}),xe("packages/core/src/compute/facet.js",function(e,K){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const X=K("packages/core/src/compute/handle.js"),L=X.presenceReader,B=X.valueReader,F=X.dictSize,_=X.dictValue,Q=Object.freeze(["equal","quantile","log"]),G=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,U=50,z=1e4;function S(p,y){if(!p)return"none";const C=y;if(C&&(C.multi===!0||typeof C.items=="function"))return"category";const T=y&&y.base;if(T==="date"||T==="datetime"||T==="time"||T==="dateString")return"date";switch(p.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return T==="number"?"numeric":T==="boolean"?"boolean":T==="text"?"category":"none"}}function O(p){const y=p.values,C=p.kind;if((C==="float64"||C==="int32")&&y)return P=>y[P];const T=B(p);return P=>b(T(P))}function b(p){if(typeof p=="number")return p;if(p instanceof Date)return p.getTime();if(p==null||p==="")return NaN;if(typeof p=="boolean")return p?1:0;if(typeof p=="string"){const y=Number(p);if(Number.isFinite(y))return y;const C=Date.parse(p);return Number.isFinite(C)?C:NaN}return NaN}function u(p,y,C,T=U){if(!p)return{cardinality:0,exact:!0};if(p.dict)return{cardinality:F(p.dict),exact:!0};if(p.kind==="bitset")return{cardinality:2,exact:!0};const P=B(p),x=y?y.length:C,E=new Set;for(let j=0;j<x;j++){const A=P(y?y[j]:j);if(A!=null&&(E.add(A),E.size>T))return{cardinality:E.size,exact:!1}}return{cardinality:E.size,exact:!0}}const d=36e5,s=864e5;function n(p,y=H){const C=Number.isFinite(p)&&p>0?p:0,T=Math.max(1,y)*2;return C/d<=T?"hour":C/s<=T?"day":C/(7*s)<=T?"week":C/(30*s)<=T?"month":C/(91*s)<=T?"quarter":"year"}function t(p,y){if(!Number.isFinite(p))return NaN;const C=new Date(p);switch(y){case"hour":return C.setMinutes(0,0,0),C.getTime();case"day":return C.setHours(0,0,0,0),C.getTime();case"week":{C.setHours(0,0,0,0);const T=(C.getDay()+6)%7;return C.setDate(C.getDate()-T),C.getTime()}case"month":return C.setDate(1),C.setHours(0,0,0,0),C.getTime();case"quarter":return C.setMonth(Math.floor(C.getMonth()/3)*3,1),C.setHours(0,0,0,0),C.getTime();default:return C.setMonth(0,1),C.setHours(0,0,0,0),C.getTime()}}function r(p,y){const C=new Date(p);switch(y){case"hour":C.setHours(C.getHours()+1);break;case"day":C.setDate(C.getDate()+1);break;case"week":C.setDate(C.getDate()+7);break;case"month":C.setMonth(C.getMonth()+1);break;case"quarter":C.setMonth(C.getMonth()+3);break;default:C.setFullYear(C.getFullYear()+1);break}return C.getTime()}function o(p,y,C){const T=O(p),P=L(p),x=y?y.length:C;let E=1/0,j=-1/0,A=0,$=0;for(let D=0;D<x;D++){const M=y?y[D]:D;if(P&&!P(M)){A++;continue}const R=T(M);if(!Number.isFinite(R)){A++;continue}R<E&&(E=R),R>j&&(j=R),$++}return{min:E,max:j,nulls:A,finite:$}}function f(p,y,C,T){const P=O(p),x=L(p),E=y?y.length:C,j=E>T?E/T:1,A=[];for(let D=0;D<E;D+=j){const M=y?y[Math.floor(D)]:Math.floor(D);if(x&&!x(M))continue;const R=P(M);Number.isFinite(R)&&A.push(R)}const $=Float64Array.from(A);return $.sort(),$}function l(p,y,C,T={}){const P=T.kind||S(p,T.type);return P==="none"||!p?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?i(p,y,C):P==="category"?g(p,y,C,T):c(p,y,C,P,T)}function i(p,y,C){const T=L(p);let P=0;if(T){const E=y?y.length:C;for(let j=0;j<E;j++)T(y?y[j]:j)||P++}const x=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&x.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:x}}function g(p,y,C,T){const P=T.cardinalityLimit??U,{cardinality:x}=u(p,y,C,P);if(x>P&&(T.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:x};const E=B(p),j=y?y.length:C,A=new Map;let $=0;for(let I=0;I<j;I++){const q=E(y?y[I]:I);if(q==null||q===""){$++;continue}if(Array.isArray(q)){if(!q.length){$++;continue}for(const Z of q)A.set(Z,(A.get(Z)||0)+1);continue}A.set(q,(A.get(q)||0)+1)}let D=[...A.entries()];T.order==="alpha"?D.sort((I,q)=>String(I[0]).localeCompare(String(q[0]))):D.sort((I,q)=>q[1]-I[1]);let M=0,R=0;if(D.length>P){R=D.length-P;for(let I=P;I<D.length;I++)M+=D[I][1];D=D.slice(0,P)}const k=D.map(([I])=>({value:I,label:String(I)}));return M>0&&k.push({remainder:!0,label:`Other (${R} values)`}),$>0&&k.push({null:!0,label:"Empty"}),{kind:"category",buckets:k,cardinality:x}}function c(p,y,C,T,P){const{min:x,max:E,nulls:j,finite:A}=o(p,y,C);if(!A)return{kind:T,buckets:j?[{null:!0,label:"Empty"}]:[],empty:!0};const $=Math.max(1,Math.floor(P.buckets||H));let D=[];if(T==="date"){const R=G.includes(P.granularity)?P.granularity:n(E-x,$);let k=t(x,R);for(;k<=E&&D.length<4096;){const I=r(k,R);if(!(I>k))break;D.push({from:k,to:I}),k=I}return{kind:T,buckets:h(D,j),granularity:R}}const M=Q.includes(P.strategy)?P.strategy:"equal";if(M==="quantile"){const R=f(p,y,C,z);if(R.length){const k=[R[0]];for(let I=1;I<$;I++){const q=R[Math.min(R.length-1,Math.floor(I/$*R.length))];q>k[k.length-1]&&k.push(q)}k.push(E);for(let I=0;I<k.length-1;I++)D.push({from:k[I],to:k[I+1]})}}else if(M==="log"&&x>0){const R=Math.log10(x),I=(Math.log10(E)-R)/$||1;for(let q=0;q<$;q++)D.push({from:10**(R+q*I),to:10**(R+(q+1)*I)})}if(!D.length){const R=(E-x)/$||1;for(let k=0;k<$;k++)D.push({from:x+k*R,to:x+(k+1)*R})}return D[D.length-1].to=E,{kind:T,buckets:h(D,j),strategy:M,min:x,max:E}}function h(p,y){return y>0?[...p,{null:!0,label:"Empty"}]:p}function a(p,y,C,T,P){const x=T&&T.buckets||[],E=P&&P.length>=x.length?P.subarray(0,x.length):new Uint32Array(x.length);if(E.fill(0),!p||!x.length)return E;const j=x.length-1,A=!!x[j]&&x[j].null===!0,$=y?y.length:C;if(T.kind==="boolean"){const I=B(p);for(let q=0;q<$;q++){const Z=I(y?y[q]:q);if(Z==null){A&&E[j]++;continue}E[Z?1:0]++}return E}if(T.kind==="category"){const I=new Map;for(let W=0;W<x.length;W++)!x[W].null&&!x[W].remainder&&I.set(x[W].value,W);const q=x.findIndex(W=>W.remainder),Z=B(p);for(let W=0;W<$;W++){const J=Z(y?y[W]:W);if(J==null||J===""){A&&E[j]++;continue}if(Array.isArray(J)){if(!J.length){A&&E[j]++;continue}for(const te of J){const ne=I.get(te);ne!==void 0?E[ne]++:q>=0&&E[q]++}continue}const ee=I.get(J);ee!==void 0?E[ee]++:q>=0&&E[q]++}return E}const D=A?x.length-1:x.length,M=new Float64Array(D+1);for(let I=0;I<D;I++)M[I]=x[I].from;M[D]=D?x[D-1].to:0;const R=O(p),k=L(p);for(let I=0;I<$;I++){const q=y?y[I]:I;if(k&&!k(q)){A&&E[j]++;continue}const Z=R(q);if(!Number.isFinite(Z)){A&&E[j]++;continue}const W=m(M,D,Z);W>=0&&E[W]++}return E}function m(p,y,C){if(!y||C<p[0])return-1;if(C>=p[y])return C===p[y]?y-1:-1;let T=0,P=y-1;for(;T<P;){const x=T+P+1>>>1;C>=p[x]?T=x:P=x-1}return T}function w(p,y,C,T={}){const P=T.bounds||l(p,T.boundsIndices??y,C,T);return{bounds:P,counts:a(p,y,C,P)}}const v=w}),xe("packages/core/src/compute/pivotmatrix.js",function(e,K){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const L=K("packages/core/src/compute/handle.js").valueComparator,F=K("packages/core/src/compute/total.js").total,Q=K("packages/core/src/compute/group.js").packKeys,G=K("packages/core/src/compute/pivot.js"),H=G.joinPath,U=G.DEFAULT_PATH_SEPARATOR,z=G.DEFAULT_MAX_COLUMNS,S="";function O(r,o,f={}){const l=f.separator||U,i=r||[],g=o instanceof Uint32Array?o:Uint32Array.from(o||[]),c=g.length;if(i.length===0)return{tuples:[[]],paths:[S],buckets:[g]};const{keyOf:h,readers:a}=Q(i,g,0),m=new Map,w=[],v=[],p=[];for(let E=0;E<c;E++){const j=g[E],A=h(j);let $=m.get(A);if($===void 0){$=w.length,m.set(A,$),v.push(A);const D=new Array(a.length);for(let M=0;M<a.length;M++)D[M]=a[M](j);w.push(D),p.push([])}p[$].push(j)}const y=L(f.locale),C=w.map((E,j)=>j);C.sort((E,j)=>{const A=w[E],$=w[j];for(let D=0;D<A.length;D++){const M=b(A[D],$[D],y);if(M!==0)return M}return E-j});const T=new Array(C.length),P=new Array(C.length),x=new Array(C.length);for(let E=0;E<C.length;E++){const j=C[E];T[E]=w[j],P[E]=H(w[j],l),x[E]=Uint32Array.from(p[j])}return{tuples:T,paths:P,buckets:x}}function b(r,o,f){const l=r==null,i=o==null;return l||i?l&&i?0:l?1:-1:f(r,o)}function u(r,o,f){const l=[];for(let i=0;i<r.length;i++)f.has(r[i])&&l.push(r[i]);return Uint32Array.from(l)}function d(r,o,f,l){return{value:o.length?F(r,o,f,l):null,leaves:o,count:o.length}}function s(r){const o=r&&r.opts||{},f=o.separator||U,l=o.totalContext||{locale:o.locale},i=(r.measures||[]).filter(P=>P&&P.handle),g=r.leaves instanceof Uint32Array?r.leaves:Uint32Array.from(r.leaves||[]),c=O(r.rowHandles||[],g,{...o,separator:f}),h=O(r.columnHandles||[],g,{...o,separator:f}),a=o.maxColumns===void 0?z:o.maxColumns,m=h.paths.length*Math.max(1,i.length),w=new Map;if(a&&m>a)return{rowAxis:c,columnAxis:h,measures:i.map(P=>({colId:P.colId,fn:P.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${a}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:a}};const v=new Map,p=new Map,y=new Map,C=new Map,T=h.buckets.map(P=>new Set(P));for(let P=0;P<h.paths.length;P++){const x=h.buckets[P],E=h.paths[P];for(const j of i)y.set(t(E,j.colId),d(j.handle,x,j.fn,l))}for(let P=0;P<c.paths.length;P++){const x=c.buckets[P],E=c.paths[P];for(const j of i)p.set(t(E,j.colId),d(j.handle,x,j.fn,l));for(let j=0;j<h.paths.length;j++){const A=u(x,h.buckets[j],T[j]);if(A.length===0)continue;const $=h.paths[j];for(const D of i)v.set(n(E,$,D.colId),d(D.handle,A,D.fn,l))}}for(const P of i)C.set(P.colId,d(P.handle,g,P.fn,l));return{rowAxis:c,columnAxis:h,measures:i.map(P=>({colId:P.colId,fn:P.fn})),body:v,rowMargin:p,columnMargin:y,grand:C,columns:m,error:null}}function n(r,o,f){return`${r}\0${o}\0${f}`}function t(r,o){return`${r}\0${o}`}}),xe("packages/core/src/compute/reference.js",function(e,K){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return s}});const L=K("packages/core/src/internal/util.js").getPath,B=K("packages/core/src/compute/handle.js"),F=B.isMissing,_=B.valueComparator,G=K("packages/core/src/compute/filter.js").testValue,H="",U="\0";function z(r,o){const f=o.includes(".")?L(r,o):r?.[o];return f===void 0?null:f}function S(r,o,f={}){const l=o||[];let i=r.map((g,c)=>c);if(l.length===0)return i;for(let g=l.length-1;g>=0;g--)i=O(r,i,l[g],f);return i}function O(r,o,f,l){const i=f.locale!==void 0?f.locale:l.locale,g=_(i),c=f.descending!==void 0?!!f.descending:f.dir==="desc",h=[],a=[];for(const v of o){const p=z(r[v],f.col);F(p)?a.push(v):h.push(v)}const m=new Map;for(let v=0;v<h.length;v++)m.set(h[v],v);const w=(v,p)=>{const y=z(r[v],f.col),C=z(r[p],f.col);let T;return typeof f.compare=="function"?(T=f.compare(y,C,r[v],r[p],c),c&&(T=-T)):T=c?g(C,y):g(y,C),T!==0?T:m.get(v)-m.get(p)};return h.sort(w),f.nullsFirst?a.concat(h):h.concat(a)}function b(r,o,f={}){const l=[];for(let i=0;i<r.length;i++)u(r[i],o,f,i)&&l.push(i);return l}function u(r,o,f,l){if(!o)return!0;if(Array.isArray(o.conditions)){const i=o.conditions.filter(c=>c!=null);if(i.length===0)return!0;if(o.op==="or")return i.some(c=>u(r,c,f,l));const g=i.every(c=>u(r,c,f,l));return o.op==="not"?!g:g}return o.col===void 0&&typeof f.custom=="function"?!!f.custom(o,r,l):G(z(r,o.col),o,f.locale)}function d(r,o,f,l){const i=f||r.map((a,m)=>m),g=new Map,c=[],h=[];for(const a of i){const m=o.map((p,y)=>{const C=z(r[a],p);return l&&l[y]?l[y](C):C}),w=m.map(p=>p==null?U:String(p)).join(H);let v=g.get(w);v===void 0&&(v=c.length,g.set(w,v),c.push(m),h.push([])),h[v].push(a)}return{keys:c,buckets:h}}function s(r,o,f={}){const l=_(f.locale),i=r.filter(c=>!F(c)),g=i.map(n).filter(c=>c!==null);switch(o){case"count":return r.length;case"countValues":return i.length;case"sum":return g.reduce((c,h)=>c+h,0);case"avg":return i.length===0?null:g.reduce((c,h)=>c+h,0)/i.length;case"min":return i.length===0?null:i.reduce((c,h)=>l(h,c)<0?h:c);case"max":return i.length===0?null:i.reduce((c,h)=>l(h,c)>0?h:c);case"first":return r.length===0?null:t(r[0]);case"last":return r.length===0?null:t(r[r.length-1]);default:return null}}function n(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isNaN(o)?null:o}function t(r){return r===void 0?null:r}}),xe("packages/core/src/compute/index.js",function(e,K){"use strict";const X=K("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return X.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return X.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return X.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return X.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return X.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return X.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return X.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return X.rankSortStrings}});const L=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return L.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return L.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L.describeSort}});const B=K("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return B.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return B.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return B.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return B.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return B.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return B.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return B.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return B.mentionsColumn}});const F=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return F.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return F.packKeys}});const _=K("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Q=K("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Q.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Q.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Q.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Q.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Q.collectValues}});const G=K("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return G.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return G.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return G.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return G.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return G.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return G.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return G.DEFAULT_MAX_COLUMNS}});const H=K("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const U=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return U.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return U.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return U.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return U.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return U.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return U.referenceValue}});const z=K("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return z.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return z.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return z.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return z.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return z.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return z.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return z.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return z.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return z.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return z.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return z.isMissing}});const S=K("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return S.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return S.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return S.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return S.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return S.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return S.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return S.SKETCH_BOUNDS}});const O=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const b=K("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const u=K("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const d=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return d.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return d.forecast}})}),xe("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return u}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=32,_="\0";function Q(d){return new G(d)}class G{#e;#t;constructor(s){this.#e=B(s&&s.rowKey)?s.rowKey:null;const n=s&&s.config?s.config.rowHeight:void 0;this.#t=typeof n=="number"||B(n)?n:F}get keyed(){return this.#e!==null}keyOf(s,n){if(this.#e){const t=this.#e(s);if(t!=null)return String(t)}else L("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${n}`}heightOf(s){return B(this.#t)?Number(this.#t(s))||F:this.#t}leaf(s,n,t=0,r=null){const o={key:this.keyOf(s,n),data:s,level:t,parent:r,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:n};return o.height=this.heightOf(o),o}group(s){const n={key:b(s.keyPath||s.path),data:null,level:s.level,parent:s.parent||null,children:[],group:!0,expanded:s.expanded!==!1,leafCount:s.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:s.column,groupValue:s.value,groupPath:s.path,hasChildren:s.hasChildren!==!1};return s.totals&&(n.totals=s.totals),n.height=this.heightOf(n),n}footer(s){const n={key:`${s.key}${_}footer`,data:null,level:s.level,parent:s,group:!0,footer:!0,expanded:!1,leafCount:s.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:s.groupColumn,groupValue:s.groupValue,groupPath:s.groupPath,hasChildren:!1,totals:s.totals};return n.height=this.heightOf(n),n}detail(s,n){return{key:`${s.key}${_}detail`,data:s.data,level:s.level+1,parent:s,group:!1,detail:!0,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:s.key}}grandTotal(s,n){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:n,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:s};return t.height=this.heightOf(t),t}skeleton(s,n=0,t=!1){const r={key:`${_}pending${_}${s}`,data:null,level:n,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:s,selected:!1,physical:null,pending:!0};return t&&(r.loadError=!0),r.height=this.heightOf(r),r}}function H(d,s,n,t){return{key:`${_}pinned${_}${n}${_}${s}`,data:d,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:n}}function U(d,s){return new Proxy([],{get(n,t,r){if(t==="length")return d();if(typeof t=="string"){const o=Number(t);if(Number.isInteger(o)&&o>=0)return s(o)}return Reflect.get(n,t,r)},has(n,t){if(typeof t=="string"){const r=Number(t);if(Number.isInteger(r)&&r>=0)return r<d()}return Reflect.has(n,t)}})}function z(d){return d==null?"":String(d)}const S="";function O(d){if(d==null)return S;const s=String(d);return s.startsWith(S)?S+s:s}function b(d){const s=d||[];let n="g";for(let t=0;t<s.length;t++)n+=_+O(s[t]);return n}function u(d){const s=new Array(d.length),n=[];for(let t=0;t<d.length;t++)n.push(d[t]),s[t]=b(n);return s}}),xe("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return _}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce;class F{#e;#t;#n;#r=new Map;#o=0;constructor(G,H,U){this.#e=G,this.#t=H,this.#n=L(U)?U:()=>!1}get store(){const G=this.#e.store;return G&&L(G.column)?G:null}invalidate(){this.#o++}handle(G){const H=this.store;if(H){const O=H.column(G);if(O)return O}const U=this.#r.get(G);if(U&&U.builtAt===this.#o)return U.handle;const z=this.#i(G);if(!z)return;if(H&&this.#n()){B(`source.dropped.${G}`,`column "${G}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const S=this.#s(z);return this.#r.set(G,{handle:S,builtAt:this.#o}),S}#i(G){const H=this.#e.columns;return H&&L(H.get)?H.get(G):void 0}#s(G){const H=this.#t()||[],U=H.length,z=new Array(U),S=L(G.getValue)?b=>G.getValue(b):b=>b?.[G.field||G.id];for(let b=0;b<U;b++)z[b]=H[b]===void 0?void 0:S(H[b]);const O=this.#o;return{id:G.id,kind:"object",nullable:!1,values:z,presence:null,dict:null,offsets:null,get(b){return z[b]},version:O}}}function _(Q,G,H){return new F(Q,G,H)}}),xe("packages/core/src/compute/incremental.js",function(e,K){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/store/columnstore.js").toFloat,B=Object.freeze(["sum","avg","countValues","min","max"]),F=Object.freeze(["float64"]),_=1e15;function Q(z,S){return typeof z!="string"||!B.includes(z)?!1:!!S&&F.includes(S.kind)}function G(z){if(z==null)return null;const S=L(z);return Number.isNaN(S)?null:S}class H{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(S){this.#e=S}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(S){this.#a();for(let O=0;O<S.length;O++){const b=G(S[O]);b!==null&&this.#u(b)}this.#s=!0}seedColumn(S,O,b){this.#a();for(let u=0;u<b.length;u++){const d=b[u];if(O&&O(d)===0)continue;const s=S[d];Number.isNaN(s)||this.#u(s)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(S){if(!Number.isFinite(S)){this.#l=!0;return}const O=this.#t+S;this.#n+=Math.abs(this.#t)>=Math.abs(S)?this.#t-O+S:S-O+this.#t,this.#t=O,this.#r++,S<this.#o&&(this.#o=S),S>this.#i&&(this.#i=S)}#c(S){const O=this.#t-S;this.#n+=Math.abs(this.#t)>=Math.abs(S)?this.#t-O-S:-S-O+this.#t,this.#t=O,this.#r--}update(S,O){if(!this.#s)return!1;const b=G(S),u=G(O);return b===null&&u===null?!0:b!==null&&!Number.isFinite(b)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?b===null||u===null?!1:this.#e==="min"?u<this.#o?(this.#o=u,!0):b>this.#o:u>this.#i?(this.#i=u,!0):b<this.#i:Math.abs(this.#t)>_?!1:(b!==null&&this.#c(b),u!==null&&this.#u(u),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const U=H}),xe("packages/core/src/source/filterwire.js",function(e,K){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return y}});const L=K("packages/core/src/internal/util.js").warnOnce,B="source.remote.hostFilter",F="source.where.pageRelative";function _(P,x){!Array.isArray(P)||!P.length||L(F,`filters.where (${P.join(", ")}) runs over the rows the ${x} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Q(P){const x=(P||{}).config;!x||!x.hostFilter||L(B,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const G="source.where.notApplied";function H(P,x){L(`${G}:${P}`,`filters.where("${P}") is registered but the ${x} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const U="source.where.overThreshold";function z(P,x,E,j){!Array.isArray(P)||!P.length||L(`${U}:${x}`,`filters.where (${P.join(", ")}) is not applied to the ${x} pushdown source:`,E===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${E.toLocaleString()} rows, at or past the whereRowLimit of ${j.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 S=new Map;function O(P){let x=S.get(P);return x||(x=new Intl.DateTimeFormat("en-US",{timeZone:P,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),S.set(P,x)),x}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(P,x){const E=O(x).formatToParts(new Date(P)),j={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const A of E)A.type==="year"?j.y=+A.value:A.type==="month"?j.m=+A.value:A.type==="day"?j.d=+A.value:A.type==="hour"?j.h=+A.value%24:A.type==="minute"?j.mi=+A.value:A.type==="second"&&(j.s=+A.value);return j}function d(P,x){const E=u(P,x);return Date.UTC(E.y,E.m-1,E.d,E.h,E.mi,E.s)-Math.floor(P/1e3)*1e3}function s(P,x,E,j){const A=Date.UTC(P,x-1,E),$=A-d(A,j);return A-d($,j)}function n(P,x,E){const j=new Date(Date.UTC(P.y,P.m-1,P.d+x));return s(j.getUTCFullYear(),j.getUTCMonth()+1,j.getUTCDate(),E)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(P,x){if(typeof P!="string")return null;const E=P.trim().toLowerCase().replace(/[\s_-]+/g,""),j=/^last(\d*|n)days?$/.exec(E);if(j){const A=j[1]==="n"?"":j[1],$=Number(A||x);return!Number.isFinite($)||$<=0?null:{kind:"lastNDays",n:Math.floor($)}}switch(E){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function o(P,x={}){const E=r(P,x.n);if(!E)return null;const j=x.tz||b(),A=x.now instanceof Date?x.now.getTime():typeof x.now=="number"?x.now:Date.now(),$=u(A,j),D=s($.y,$.m,$.d,j),M=n($,1,j);let R=D,k=M;switch(E.kind){case"today":break;case"yesterday":R=n($,-1,j),k=D;break;case"lastNDays":k=x.includeToday?M:D,R=n($,x.includeToday?-(E.n-1):-E.n,j);break;case"thisWeek":{const I=Number.isFinite(x.weekStartsOn)?Number(x.weekStartsOn):1,Z=(new Date(Date.UTC($.y,$.m-1,$.d)).getUTCDay()-I+7)%7;R=n($,-Z,j),k=n($,-Z+7,j);break}case"thisMonth":R=s($.y,$.m,1,j),k=s($.m===12?$.y+1:$.y,$.m===12?1:$.m+1,1,j);break;case"thisQuarter":case"quarterToDate":{const I=Math.floor(($.m-1)/3)*3+1;R=s($.y,I,1,j),k=E.kind==="quarterToDate"?M:I===10?s($.y+1,1,1,j):s($.y,I+3,1,j);break}case"thisYear":case"yearToDate":R=s($.y,1,1,j),k=E.kind==="yearToDate"?M:s($.y+1,1,1,j);break;default:return null}return{from:new Date(R).toISOString(),to:new Date(k).toISOString(),bounds:"[)",tz:j,relative:E.kind==="lastNDays"?`last${E.n}Days`:E.kind,n:E.n}}function f(P){if(!P||typeof P!="object")return null;const x=P.value;if(x&&typeof x=="object"&&!Array.isArray(x)&&"relative"in x)return{token:String(x.relative),n:typeof x.n=="number"?x.n:void 0};if(P.op==="relative"&&typeof P.value=="string")return{token:P.value,n:void 0};const E=P.meta;return E&&typeof E.relative=="string"&&P.value===void 0?{token:E.relative,n:typeof E.n=="number"?E.n:void 0}:null}function l(){return`Known tokens: ${t.filter(x=>x!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(P){const x=f(P);return x?r(x.token,x.n)!==null:!1}function g(P,x={}){const E=f(P);if(!E)return P;const j=o(E.token,{...x,n:E.n});return j?{...P,type:P.type||"date",op:"between",value:[j.from,j.to],bounds:P.bounds||j.bounds,meta:{...P.meta||{},relative:j.relative,tz:j.tz}}:(L(`source.relative.${E.token}`,`unknown relative date token "${E.token}"; sending the condition unresolved.`,l()),P)}function c(P){return!!P&&typeof P=="object"&&Array.isArray(P.conditions)}function h(P,x){if(P){if(c(P)){for(const E of P.conditions)h(E,x);return}x(P)}}function a(P,x){if(!P)return null;if(!c(P))return x(P);const E=P;let j=!1;const A=[];for(const $ of E.conditions){const D=a($,x);D!==$&&(j=!0),D&&A.push(D)}return!j&&A.length===E.conditions.length?P:A.length?{...E,conditions:A}:null}function m(P){if(!P)return null;if(!c(P))return P;const x=P,E=[];for(const j of x.conditions){const A=m(j);A&&E.push(A)}return E.length?{op:x.op,conditions:E}:null}function w(P){const x=m(P);return x?c(x)&&x.op==="and"?x:{op:"and",conditions:[x]}:null}function v(P){const x=(P||[]).filter(Boolean);return x.length?{op:"and",conditions:x}:null}function p(P,x={}){const E=a(P,j=>g(j,x));return w(E)}function y(P){const x=C(P.filters??null);return JSON.stringify([x,P.sort??null,P.quick??"",P.groupBy??null,P.pivotBy??null,T(P.context)])}function C(P){if(!P)return null;if(c(P)){const j=P;return{op:j.op,conditions:j.conditions.map(C)}}const x=P,E=x.meta&&typeof x.meta.relative=="string"?x.meta.relative:f(x)?.token;return{col:x.col,op:x.op,bounds:x.bounds??null,caseSensitive:x.caseSensitive??!1,value:E?`rel:${E}`:x.value??null}}function T(P){if(P==null)return null;try{return JSON.parse(JSON.stringify(P))}catch{return L("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),xe("packages/core/src/source/tree.js",function(e,K){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return b}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F="",_="\0tree:";function Q(u,d){return{physical:u,key:d,level:0,children:[],value:void 0}}function G(u,d){const s=[],n=new Map;for(let t=0;t<u.length;t++){const r=u[t],o=d.pathOf(r),f=Array.isArray(o)?o.map(i=>String(i)):[];if(!f.length){const i=Q(r,d.keyOf(r));s.push(i);continue}let l=null;for(let i=0;i<f.length;i++){const g=f.slice(0,i+1).join(F),c=i===f.length-1;let h=n.get(g);h&&c&&h.physical===-1&&(h.physical=r,h.key=d.keyOf(r)),h||(h=Q(c?r:-1,c?d.keyOf(r):_+g),h.level=i,h.value=f[i],n.set(g,h),l?l.children.push(h):s.push(h)),l=h}}return{roots:s,nodes:n}}function H(u,d){const s=new Map,n=[];for(let f=0;f<u.length;f++){const l=u[f],i=d.keyOf(l),g=Q(l,i);s.set(i,g);const c=d.parentOf(l);c!=null&&c!==""&&n.push({node:g,parent:String(c)})}let t=null;const r=new Map;for(const{node:f,parent:l}of n){const i=s.get(l);if(i){r.set(f.key,i);continue}d.orphans&&d.orphans!=="root"&&(t||(t=Q(-1,`${_}orphans`),t.value=d.orphans),r.set(f.key,t))}const o=[];for(const f of s.values()){const l=r.get(f.key);l?l.children.push(f):o.push(f)}return t&&t.children.length&&o.push(t),{roots:U(o,s,d.orphans,t),nodes:s}}function U(u,d,s,n){const t=new Set,r=[...u];for(;r.length;){const g=r.pop();if(!t.has(g.key)){t.add(g.key);for(const c of g.children)r.push(c)}}const o=[];for(const g of d.values())t.has(g.key)||o.push(g);if(!o.length)return u;const f=!!s&&s!=="root";B("tree.cycle",`tree.parentKey produced ${o.length} row(s) inside a parent cycle; `+(f?`they are shown under "${s}".`:"they are shown at the root."));for(const g of o)g.children=g.children.filter(c=>t.has(c.key));if(!f)return[...u,...o];let l=n;const i=[...u];return l||(l=Q(-1,`${_}orphans`),l.value=s,i.push(l)),l.children.push(...o),i}function z(u){let d=0;const s=(n,t)=>{for(const r of n)r.level=t,t>d&&(d=t),r.children.length&&s(r.children,t+1)};return s(u,0),d}function S(u,d){if(!u||typeof u!="object")return null;const s=u.path,n=u.parentKey,t=L(u.hasChildren)?r=>!!u.hasChildren(d.dataAt(r)):null;if(L(s))return{mode:"path",pathOf:r=>s(d.dataAt(r)),keyOf:d.keyOf,declaresChildren:t};if(n!=null){const r=L(n)?n:o=>o?.[n];return{mode:"parentKey",parentOf:o=>r(d.dataAt(o)),keyOf:d.keyOf,orphans:u.orphans||"root",declaresChildren:t}}return B("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function O(u,d){const s=d.mode==="path"?G(u,d):H(u,d),n=z(s.roots);return{...s,depth:n}}function b(u,d){const s=new Map,n=t=>{for(let r=0;r<t.length;r++){const o=t[r];if(o.physical>=0){const f=d?d(o.physical):!1,l=f&&o.children.length===0;s.set(o.physical,{level:o.level,posinset:r+1,setsize:t.length,hasChildren:o.children.length>0||f,lazy:l})}o.children.length&&n(o.children)}};return n(u),s}}),xe("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return M}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.warnOnce,F=X.fail,_=X.isFunction,Q=X.defaultCompare,G=X.mergeRow,H=K("packages/core/src/source/rows.js"),U=H.createRowFactory,z=H.groupKey,S=H.groupPathElement,O=H.groupPrefixKeys,b=H.lazyRowView,d=K("packages/core/src/source/handles.js").createHandleProvider,s=K("packages/core/src/compute/incremental.js"),n=s.RunningTotal,t=s.isIncremental,o=K("packages/core/src/compute/handle.js").presenceReader,f=K("packages/core/src/source/filterwire.js"),l=f.querySignature,i=f.mapConditions,g=f.resolveRelativeCondition,c=K("packages/core/src/source/tree.js"),h=c.buildTree,a=c.resolveTree,m=c.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),v=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function p(R){const k=R&&typeof R=="object"?R.reason:null;return typeof k=="string"&&v.includes(k)}const y=Object.freeze([]);function C(R,k){if(!R)return null;const I=k==="grand"?R.grandTotal:R.groupTotal;return I??R.total}function T(R){return!!R&&!R.running}function P(R){if(R)return R.value&&_(R.value.compare)?R.value.compare:_(R.compare)?R.compare:void 0}function x(R){const k=R&&R.dataType;return!k||!_(k.items)?null:{items:k.items,type:R.itemType&&R.itemType.name||"text"}}function E(R){return!!R&&(typeof R=="object"||typeof R=="function")&&_(R.then)}const j=new Uint32Array(0),A=4096;function $(R,k){return new M(R,k)}function D(R,k){if(k==="regex")try{const I=new RegExp(R,"iu");return q=>I.test(q)}catch{return I=>I.includes(R)}if(k==="fuzzy"){const I=[...R].filter(q=>q!==" ");return I.length?q=>{let Z=0;for(let W=0;W<q.length&&Z<I.length;W++)q[W]===I[Z]&&Z++;return Z===I.length}:()=>!0}if(k==="words"){const I=R.split(/\s+/).filter(Boolean);return I.length?q=>I.every(Z=>q.includes(Z)):()=>!0}return I=>I.includes(R)}class M{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#f=new Map;#h;#p=null;#m=M.#g();static#g(){return{slots:[],groupHeadings:y,unnumbered:y,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#y=new Map;#w=null;#k=new Map;#b=-1;#O=[];#A=new Map;#P=-1;#S=[];#M=null;#j=null;#E=null;#R=null;#L=null;#x=null;#I=null;#z=null;#$=Symbol("unset");#N=new Map;#H=null;get#B(){return this.#m.slots}set#B(k){this.#m.slots=k}get#W(){return this.#m.inlineLeaves}set#W(k){this.#m.inlineLeaves=k}get#ie(){return this.#m.groupHeadings}set#ie(k){this.#m.groupHeadings=k}get#re(){return this.#m.unnumbered}set#re(k){this.#m.unnumbered=k}get#le(){return this.#m.pivot}set#le(k){this.#m.pivot=k}constructor(k,I){this.#t=k||{mode:"memory"},this.#e=I||{};const q=this.#e.config||{};this.#n=this.#t.rows||q.rows||[],this.#i=U(this.#e),this.#s=d(this.#e,()=>this.#n,()=>this.#r),this.#h=new L(Number(q.rowCacheSize)||A);for(const Z of w)this.#l.set(Z,{key:null,result:null,id:0,computed:!1})}count(){this.#X();const k=this.#ue();return k?k.length:this.#B.length}#ue(){const k=Number(this.#V("pageSize",0))||0;if(k<=0)return null;const I=this.#B.length,q=Math.max(1,Math.ceil(I/k)),W=Math.min(Math.max(0,Number(this.#V("page",0))||0),q-1)*k;return{offset:W,length:Math.max(0,Math.min(k,I-W))}}pageInfo(){this.#X();const k=Number(this.#V("pageSize",0))||0,I=this.#B.length;if(k<=0)return{page:0,pageSize:0,total:I,pageCount:1};const q=Math.max(1,Math.ceil(I/k));return{page:Math.min(Math.max(0,Number(this.#V("page",0))||0),q-1),pageSize:k,total:I,pageCount:q}}totalCount(){return this.#Me().length}matchCount(){return this.#X(),this.#m.matchCount}at(k){this.#X();const I=this.#ue();if(I)return k<0||k>=I.length?void 0:this.#He(I.offset+k,k);if(!(k<0||k>=this.#B.length))return this.#He(k,k)}byKey(k){this.#X(),this.#p||this.#_();const I=this.#p.get(k);if(I!==void 0)return this.#Ne(I);for(let q=0;q<this.#B.length;q++){const Z=this.#B[q];if(typeof Z!="number"&&Z&&Z.key===k)return this.#He(q)}}loaded(k){return k>=0&&k<this.count()}hint(k,I){}display(){return this.#X(),this.#H||(this.#H=this.#xt()),this.#H}invalidateQuickText(){this.#N.clear(),this.invalidate("filter")}invalidate(k){const I=w.indexOf(k);I<0&&F(`unknown pipeline stage "${k}"; expected one of ${w.join(", ")}`);for(let q=I;q<w.length;q++){const Z=this.#l.get(w[q]);Z.key=null,Z.computed=!1}this.#H=null}apply(k){const I=[],q={added:[],updated:[],removed:[],rejected:I};if(!k)return q;let Z=!1;const W=new Set;if(k.remove&&k.remove.length)for(const J of k.remove){const ee=this.#D(J);if(ee===void 0){I.push({operation:"remove",id:this.#q(J),reason:"unknown-id"});continue}q.removed.push(this.#i.keyOf(this.#r?this.#$e(ee):this.#n[ee],ee)),this.#r||(this.#n[ee]=void 0),this.#h.delete(ee),this.#N.delete(ee),Z=!0}if(k.update&&k.update.length){const J=this.#k.size||this.#Te()?this.#st():null,ee=this.#A.size?this.#nt():null,te=ee&&ee.length?this.#st():null;for(const ne of k.update){const ae=this.#D(ne);if(ae===void 0){I.push({operation:"update",id:this.#te(ne),reason:"unknown-id"});continue}const de=this.#r?this.#o&&this.#o.has(ae)?this.#o.get(ae):this.#$e(ae):this.#n[ae],ie=G(de,ne);for(const oe of this.#Pe(de,ie))W.add(oe);if(this.#r||(this.#n[ae]=ie),J&&this.#Pt(J,ae,de,ie),te&&this.#Ge(ee,te,ae,de,ie),this.#p){const oe=this.#i.keyOf(de,ae),ce=this.#i.keyOf(ie,ae);oe!==ce&&(this.#p.delete(oe),this.#p.set(ce,ae))}this.#h.delete(ae),this.#N.delete(ae),q.updated.push(this.#Ne(ae))}}if(k.add&&k.add.length&&this.#r){typeof k.at=="number"&&k.at<this.#et()&&(this.#h.clear(),this.#N.clear()),this.#p=null;for(const J of k.add){const ee=this.#K(this.#te(J));ee!==void 0&&q.added.push(this.#Ne(ee))}Z=!0}else if(k.add&&k.add.length){const J=typeof k.at=="number"?k.at:this.#n.length,ee=this.#n.length;let te=k.add===this.#n?k.add.slice():k.add;if(this.#i.keyed){const ne=[];for(const ae of te){const de=this.#te(ae);if(this.#D(de)!==void 0){I.push({operation:"add",id:de,reason:"duplicate-id"});continue}ne.push(ae)}ne.length!==te.length&&(te=ne)}if(!te.length)return q;if(J>=ee)for(let ne=0;ne<te.length;ne++)this.#n.push(te[ne]);else this.#n.splice(J,0,...te),this.#h.clear(),this.#N.clear();for(let ne=0;ne<te.length;ne++)q.added.push(this.#Ne(J>=ee?ee+ne:J+ne));Z=!0}return this.#u++,Z&&(this.#p=null,this.#ye()),this.#s.invalidate(),this.#H=null,Z||this.#me(W)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#qe("rows:changed",{companion:!0,added:q.added.length,updated:q.updated.length,removed:q.removed.length}),this.#o=null,q}groupHeadingsAt(k){this.#X();const I=this.#ie;if(!I.length||!Number.isInteger(k)||k<0)return y;let q=0,Z=I.length-1,W=-1;for(;q<=Z;){const ee=q+Z>>1;I[ee].at<=k?(W=ee,q=ee+1):Z=ee-1}if(W<0)return y;const J=[];for(let ee=I[W].row;ee;ee=ee.parent)J.push(ee);return J.reverse(),J}unnumberedRowCount(k){this.#X();const I=this.#re;if(!I.length||!Number.isInteger(k)||k<0)return 0;let q=0,Z=I.length-1,W=-1;for(;q<=Z;){const J=q+Z>>1;I[J].at<=k?(W=J,q=J+1):Z=J-1}return W+1}moveRow(k,I){if(this.#r)return B("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const q=this.#n;if(!Number.isInteger(k)||!Number.isInteger(I)||k<0||k>=q.length)return!1;const Z=Math.max(0,Math.min(q.length-1,I));if(Z===k)return!1;const[W]=q.splice(k,1);return q.splice(Z,0,W),this.#u++,this.#c++,this.#p=null,this.#h.clear(),this.#N.clear(),this.#ye(),this.#s.invalidate(),this.#H=null,this.invalidate("filter"),this.#qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(k){this.#he(),this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#ye(),this.#s.invalidate(),this.invalidate("filter"),this.#qe("model:changed",{reason:"reload"})}destroy(){this.#he(),this.#h.clear(),this.#N.clear(),this.#p=null,this.#B=[],this.#W=null,this.#H=null,this.#ye();for(const k of w)this.#l.set(k,{key:null,result:null,id:0,computed:!1})}#he(){for(const{controller:k}of this.#y.values())try{k.abort()}catch{}this.#y.clear()}setRows(k){this.#n=k||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#N.clear(),this.#h.clear(),this.#ye(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(k){this.#o=k||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#N.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const k=this.#e.store;if(!k||!_(k.source))return this.#n;const I=k.physical||0,q=new Array(I);for(let Z=0;Z<I;Z++)q[Z]=k.live&&!k.live(Z)?void 0:k.source(Z);return q}#we(){const k=this.#V("detail",null);return!k||!_(k.isOpen)||k.inline===!1?null:k}#pe(){const k=(this.#e.config||{}).tree;return this.#$!==k&&(this.#$=k,this.#z=a(k,{dataAt:I=>this.#$e(I),keyOf:I=>this.#i.keyOf(this.#$e(I),I)})),this.#z}#be(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#be())return null;this.#X();const k=this.#m.grand;return k?this.#i.grandTotal(k,this.#C(this.#m.grandLeaves)):null}pivot(){return this.#X(),this.#le}pivotMatrix(){this.#X();const k=this.#m.groupLeaves,I=(this.#e.compute||{}).pivotMatrix;if(!_(I))return null;const q=this.#V("groupBy",[]),Z=this.#V("pivotBy",[]);if(!q.length&&!Z.length)return null;const W=this.#st().map(ee=>({colId:ee.id,handle:this.#s.handle(ee.id),fn:C(ee,"group")})).filter(ee=>ee.handle&&ee.fn),J=this.#e.config||{};return I({rowHandles:q.map(ee=>this.#s.handle(ee)).filter(Boolean),columnHandles:Z.map(ee=>this.#s.handle(ee)).filter(Boolean),measures:W,leaves:k||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(k){const I=[];if(!k)return I;for(let q=0;q<k.length;q++){const Z=this.#Ne(k[q]);Z&&Z.key!=null&&I.push(String(Z.key))}return I}leavesOf(k){this.#X();const I=this.#l.get("group"),q=I&&I.result;if(!q||!q.nodes)return[];const Z=q.nodes.get(k);if(!Z)return[];const W=[],J=ee=>{const te=ee.row&&ee.row.children;if(te&&te.length){for(const ne of te){const ae=q.nodes.get(ne.key);ae&&J(ae)}return}if(ee.leaves)for(let ne=0;ne<ee.leaves.length;ne++)W.push(this.#Ne(ee.leaves[ne]))};return J(Z),W}#q(k){return typeof k=="string"?k:this.#te(k)}#te(k){try{return this.#i.keyOf(k,-1)}catch{return"(unkeyed)"}}#D(k){if(typeof k=="string")return this.#K(k);if(this.#i.keyed){const q=this.#i.keyOf(k,-1),Z=this.#K(q);if(Z!==void 0)return Z}if(this.#r)return;const I=this.#n.indexOf(k);return I>=0?I:void 0}#K(k){return this.#p||this.#_(),this.#p.get(k)}#_(){this.#p=new Map;const k=this.#et(),I=this.#e.store,q=I&&_(I.live)?Z=>I.live(Z):null;for(let Z=0;Z<k;Z++){if(q&&!q(Z))continue;const W=this.#$e(Z);W!==void 0&&this.#p.set(this.#i.keyOf(W,Z),Z)}}#Pe(k,I){const q=[];for(const Z of this.#oe())this.#Ue(Z)&&this.#ne(Z,k,I,new Set)&&q.push(Z);return q}#ne(k,I,q,Z){if(Z.has(k))return!1;Z.add(k);const W=this.#Ue(k);if(!W)return!1;const J=W.value&&W.value.deps;return Array.isArray(J)&&J.length?J.some(ee=>this.#ne(String(ee),I,q,Z)):_(W.getValue)?!Object.is(W.getValue(I),W.getValue(q)):!1}#oe(){const k=new Set;for(const q of this.#V("sort",[]))k.add(q.col);for(const q of this.#V("groupBy",[]))k.add(q);const I=q=>{if(q){if(Array.isArray(q.conditions)){q.conditions.forEach(I);return}q.col&&k.add(q.col)}};return I(this.#V("filters",null)),[...k]}#me(k){if(!k.size)return!1;if(this.#V("quick",""))return!0;for(const I of this.#oe())if(k.has(I))return!0;return!1}#X(){if(!this.#a){this.#a=!0;try{this.#ke()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#ke(){const k=this.#Z("filter",()=>this.#de(),()=>this.#Ae()),I=this.#ce(k),q=this.#Z("group",()=>this.#Ie(),()=>this.#dt(I)),Z=this.#Z("total",()=>this.#We(),()=>this.#tt(q));this.#Z("pivot",()=>this.#Ve(),()=>this.#vt(q)),this.#Z("flatten",()=>this.#Ee(),()=>this.#Ct(q)),this.#Le(q,Z)}#ce(k){const I=this.#l.get("sort"),q=this.#v();if(I.computed&&I.key===q&&!this.#y.has("sort"))return I.result;const Z=this.#y.get("sort");return Z&&Z.key===q?I.result:I.result&&this.#G(k)?(this.#T(k,q),I.result):this.#Z("sort",()=>q,()=>this.#De(k))}#se(){if(this.#w===null){const k=this.#e.pipelineWorker,I=_(k)?k():null;this.#w=I||!1}return this.#w||null}#Ce(){const k=this.#V("sort",[]);if(!Array.isArray(k)||!k.length)return null;const I=(this.#e.config||{}).locale,q=[],Z=[];for(const W of k){const J=this.#Ue(W.col);if(J&&J.running)continue;if(J&&J.value&&_(J.value.compare))return null;const ee=this.#s.handle(W.col);if(!ee)return null;q.push({col:W.col,descending:W.dir==="desc",nullsFirst:!!W.nullsFirst,locale:I}),Z.push(ee)}return q.length?{entries:q,handles:Z,locale:I}:null}#G(k){if(this.#fe())return!1;const I=this.#se();if(!I)return!1;const q=Number(I.threshold);return Number.isFinite(q)&&k.length<q?!1:!!this.#Ce()}#T(k,I){const q=this.#se(),Z=q&&this.#Ce();if(!Z){this.#Z("sort",()=>I,()=>this.#De(k));return}const W=new AbortController;this.#y.set("sort",{key:I,controller:W});const J=Z.entries.length===1?q.sortColumn(Z.handles[0],k,{descending:Z.entries[0].descending,nullsFirst:Z.entries[0].nullsFirst,locale:Z.locale,signal:W.signal,key:"sort"}):q.sortMulti(Z.handles,Z.entries.map((ee,te)=>({...ee,handle:Z.handles[te]})),k,{signal:W.signal,key:"sort"});if(!E(J)){this.#y.delete("sort"),this.#Z("sort",()=>I,()=>J);return}J.then(ee=>this.#U(I,ee),ee=>this.#ae("sort",I,ee))}#U(k,I){const q=this.#y.get("sort");if(!(!q||q.key!==k)){if(this.#v()!==k){this.#y.delete("sort");return}this.#y.delete("sort"),this.#Z("sort",()=>k,()=>I),this.#H=null,this.#X(),this.#qe("model:changed",{reason:v[0]})}}#ae(k,I,q){const Z=this.#y.get(k);if(!(!Z||Z.key!==I)&&(this.#y.delete(k),!(q&&q.name==="AbortError")&&k==="sort"&&this.#v()===I)){const W=this.#Z("filter",()=>this.#de(),()=>this.#Ae());this.#Z("sort",()=>I,()=>this.#De(W)),this.#H=null,this.#X(),B("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",q),this.#qe("model:changed",{reason:v[1]})}}#Le(k,I){const q=k&&k.leaves?k.leaves.length:this.#m.slots.length;this.#m.matchCount=q,this.#m.grand=I&&I.grand||null,this.#m.grandLeaves=k&&k.leaves?k.leaves.length:0,this.#m.groupLeaves=k&&k.leaves?k.leaves:null}#Z(k,I,q){const Z=this.#l.get(k),W=I();return Z.computed&&Z.key===W||(Z.result=q(),Z.key=W,Z.computed=!0,Z.id++,k==="flatten"&&(this.#H=null)),Z.result}#Y(k){return this.#l.get(k).id}#de(){const k=(this.#e.config||{}).hostFilter,I=k&&_(k.active)&&k.active()?1:0,q=this.#V("where",null),Z=q?q.version:0,W=this.#lt("filter.sig",`${this.#kt()}`,()=>l({filters:this.#V("filters",null),quick:this.#V("quick",""),quickMode:this.#V("quickMode","contains")}));return`${this.#c}|${W}|${I}|${Z}`}#v(){const k=this.#fe();return`${this.#Y("filter")}|${JSON.stringify(this.#V("sort",[]))}`+(k?`|manual:${k.version}`:"")}#fe(){const k=this.#V("rowOrder",null);return k&&Array.isArray(k.keys)?k:null}#Oe(k,I){this.#p||this.#_();const q=this.#p,Z=this.#et(),W=I.keys.length,J=new Float64Array(Z);for(let ee=0;ee<Z;ee++)J[ee]=W+ee;for(let ee=0;ee<W;ee++){const te=q.get(I.keys[ee]);te!==void 0&&(J[te]=ee)}return Uint32Array.from(k).sort((ee,te)=>J[ee]-J[te])}orderedKeys(){this.#p||this.#_();const k=this.#p,I=new Map;for(const[ee,te]of k)I.set(te,ee);const q=Uint32Array.from([...I.keys()]).sort(),Z=this.#fe(),W=Z?this.#Oe(q,Z):this.#De(q),J=new Array(W.length);for(let ee=0;ee<W.length;ee++)J[ee]=I.get(W[ee]);return J}#Ie(){return`${this.#Y("sort")}|${JSON.stringify(this.#V("groupBy",[]))}`}#We(){const k=this.#Je()?"f":"a",I=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#Y("group")}|${JSON.stringify(this.#V("totals",[]))}|${k}${I}|${this.#u}`}#Ve(){return`${this.#Y("group")}|${JSON.stringify(this.#V("pivotBy",[]))}`}#Ee(){const I=this.#Xe()||!this.#be()?this.#Y("total"):"x",q=`${this.#kt()}`,Z=this.#lt("flatten.keys",q,()=>{const J=this.#V("expanded",null);return J?[...J].sort().join(""):"*"}),W=this.#lt("flatten.detail",q,()=>{const J=this.#V("detail",null);return J&&_(J.signature)?J.signature():""});return`${I}|${this.#Y("pivot")}|${Z}|${W}`}#Xe(){const k=this.#V("groupBy",[]);return Array.isArray(k)&&k.length>0}stageState(){const k=[];for(const[I,q]of this.#l){const Z=q.result;k.push({stage:I,materialised:!!q.computed,bytes:Z&&typeof Z.byteLength=="number"?Z.byteLength:null,rows:Z&&typeof Z.length=="number"?Z.length:null,rebuilds:q.id})}return k}facetIndices(k){return this.#Ae(k||null)}facetRows(k){const I=this.facetIndices(k),q=[];for(let Z=0;Z<I.length;Z++){const W=this.#Ne(I[Z]);W&&q.push(W)}return q}invalidateRows(){this.#h.clear(),this.#N.clear(),this.#H=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Me()}filteredIndices(){const k=this.#l.get("filter");if(k&&k.computed&&k.key===this.#de())return k.result||this.#Me();this.#X();const I=this.#l.get("filter");return(I&&I.computed?I.result:null)||this.#Me()}unfilteredRows(){const k=this.#Me(),I=[];for(let q=0;q<k.length;q++){const Z=this.#Ne(k[q]);Z&&I.push(Z)}return I}#Ae(k=null){const I=this.#Me(),q=this.#V("filters",null),Z=k?this.#Ke("pruneColumn")(q,k):q,W=this.#Et(Z),J=String(this.#V("quick","")||"").trim().toLowerCase(),ee=J?D(J,String(this.#V("quickMode","contains")||"contains")):null,te=(this.#e.config||{}).hostFilter,ne=!!(te&&_(te.active)&&te.active()),ae=this.#V("where",null),de=!!(ae&&ae.active);if(!W&&!J&&!ne&&!de)return I;let ie=null;W&&(ie=this.#Ke("evaluateFilters")(W,{handle:ke=>this.#s.handle(ke),count:this.#et(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:ke=>x(this.#Ue(ke))}));const oe=new Uint32Array(I.length);let ce=0;for(let fe=0;fe<I.length;fe++){const ke=I[fe];if(!(ie&&!ie[ke])&&!(ee&&!this.#ht(ke,ee))){if(ne||de){const Re=this.#Ne(ke);if(ne&&!te.passes(Re)||de&&!ae.passes(Re.data,Re.key))continue}oe[ce++]=ke}}if(ie){const fe=(this.#e.compute||{}).releaseMask;_(fe)&&fe({pool:this.#e.pool},ie)}return oe.subarray(0,ce)}handleFor(k){return this.#s.handle(k)}#De(k){const I=this.#fe();if(I)return this.#Oe(k,I);const q=this.#V("sort",[]).filter(J=>{const ee=this.#Ue(J.col);return!ee||!ee.running?!0:(B(`source.sort.running.${J.col}`,`sort ignores "${J.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!q.length)return k;const Z=(this.#e.config||{}).locale;if(q.length===1){const J=q[0],ee=this.#s.handle(J.col);if(!ee)return B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),k;const te=this.#Ue(J.col);return this.#Ke("sortColumn")(ee,k,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:Z,compare:P(te)})}const W=[];for(const J of q){const ee=this.#s.handle(J.col);if(!ee){B(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}W.push({handle:ee,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:Z,compare:P(this.#Ue(J.col))})}return W.length?this.#Ke("sortMulti")(W.map(J=>J.handle),W,k):k}#dt(k){const I=this.#V("groupBy",[]),q=this.#pe();if(q&&!I.length){const fe=h(k,q);return this.#x=m(fe.roots,q.declaresChildren),{roots:null,leaves:k,nodes:new Map,tree:fe}}if(this.#x=null,q&&I.length&&B("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!I.length)return{roots:null,leaves:k,nodes:new Map};const Z=(this.#e.config||{}).timeZone,W=[],J=[];let ee=!1;for(const fe of I){const ke=this.#s.handle(fe);if(!ke){B(`source.group.${fe}`,`grouping ignores unknown column "${fe}".`);continue}W.push(ke);const Re=this.#Ue(fe),Ee=Re&&Re.dataType;if(Ee&&_(Ee.groupProjector)){const Fe=Re.typeOptions&&Re.typeOptions.timeZone||Re.timeZone||Z||void 0,ye=Ee.groupProjector(Re,Fe);J.push(ye||null),ye&&(ee=!0)}else J.push(null)}if(!W.length)return{roots:null,leaves:k,nodes:new Map};const{keys:te,buckets:ne}=this.#Ke("groupByColumns")(W,k,{locale:(this.#e.config||{}).locale,project:ee?J:void 0}),ae=this.#V("pivotBy",[]).length>0,de=[],ie=new Map;for(let fe=0;fe<ne.length;fe++){const ke=te[fe];let Re=null;const Ee=[];for(let Fe=0;Fe<ke.length;Fe++){Ee.push(S(ke[Fe]));const ye=z(Ee),he=Fe===ke.length-1;let Se=ie.get(ye);if(!Se){const Ce=this.#i.group({path:[...Ee],column:I[Fe],value:ke[Fe],level:Fe,parent:Re,expanded:ae&&he?!1:this.#pt(ye,{key:ye,column:I[Fe],value:ke[Fe],level:Fe,path:[...Ee]}),hasChildren:!(ae&&he)});Se={row:Ce,leaves:null},ie.set(ye,Se),Re?Re.children.push(Ce):de.push(Ce)}Se.row.leafCount+=ne[fe].length,Fe===ke.length-1&&(Se.leaves=ne[fe]),Re=Se.row}}const oe=this.#V("sort",[])||[],ce=(fe,ke)=>{if(!fe||fe.length<2){if(fe)for(const ye of fe)ce(ye.children,ke+1);return}const Re=I[ke],Ee=oe.find(ye=>ye.col===Re),Fe=Ee&&Ee.dir==="desc"?-1:1;fe.sort((ye,he)=>Fe*Q(ye.groupValue,he.groupValue));for(const ye of fe)ce(ye.children,ke+1)};return ce(de,0),{roots:de,leaves:k,nodes:ie,keys:te,buckets:ne}}#_e(k,I){const q=new Map,Z=new Map,W=J=>{const ee=J.physical>=0?[J.physical]:[];for(const te of J.children)ee.push(...W(te));if(J.children.length){const te=this.#at(I,Uint32Array.from(ee),null);J.physical>=0?q.set(J.physical,te):Z.set(J.key,te)}return ee};for(const J of k.roots)W(J);return{byPhysical:q,byKey:Z}}#tt(k){const I=this.#st();if(!I.length)return this.#j=null,this.#E=null,{grand:null};const q={id:this.#Y("group"),columns:I.map(oe=>oe.id).join("")},Z=this.#j&&this.#j.id===q.id&&this.#j.columns===q.columns,W=this.#Te()&&Z?this.#M:null,J=W?I.filter(oe=>W.has(oe.id)):I,ee=Z?this.#E:null,te=this.#Je()?null:this.#ze(),ne=this.#ge(I),ae=oe=>{const ce=k.nodes.get(oe.key);let fe=ce&&ce.leaves?ce.leaves:null;if(oe.children&&oe.children.length){const Ee=oe.children.map(ae);let Fe=0;for(const Se of Ee)Fe+=Se.length;const ye=new Uint32Array(Fe);let he=0;for(const Se of Ee)ye.set(Se,he),he+=Se.length;fe=ye}fe=fe||new Uint32Array(0);const ke=te?te.get(oe.key)||j:fe,Re=this.#ft(oe,W?J:I,ke,ne);return oe.totals=W?{...oe.totals,...Re}:Re,fe};if(k.roots&&J.length)for(const oe of k.roots)ae(oe);if(this.#I=k.tree?this.#_e(k.tree,I):null,this.#j=q,this.#M=this.#Te()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#E=null,{grand:null};const ie=te?this.#rt():k.leaves;return this.#E=this.#Q(I,ie,W,ee),{grand:this.#E}}#Q(k,I,q,Z){const W={},J=this.#Y("group");J!==this.#b&&(this.#xe(),this.#b=J);const ee=this.#O;this.#O=[];for(const te of k){if(!T(te))continue;const ne=this.#s.handle(te.id);if(!ne)continue;const ae=C(te,"grand");if(!t(ae,ne)){if(q&&!q.has(te.id)&&Z&&te.id in Z){W[te.id]=Z[te.id];continue}W[te.id]=this.#at([te],I,null,"grand")[te.id];continue}let de=this.#k.get(te.id);if((!de||de.fn!==ae)&&(de=new n(ae),this.#k.set(te.id,de)),de.valid){let ie=!0;for(const oe of ee)if(oe.colId===te.id&&!de.update(oe.before,oe.after)){ie=!1;break}if(ie){W[te.id]=de.value();continue}de.invalidate()}de.seedColumn(ne.values,o(ne),I),W[te.id]=de.valid?de.value():this.#at([te],I,null,"grand")[te.id]}return W}#ge(k){const I=this.#Y("group");I!==this.#P&&(this.#A.clear(),this.#P=I);const q=new Map;for(const W of k){if(!T(W))continue;const J=this.#s.handle(W.id),ee=C(W,"group");t(ee,J)&&q.set(W.id,{fn:ee})}if(!q.size)return this.#S.length=0,q;const Z=this.#S;this.#S=[];for(const W of Z){const{beforeKeys:J,afterKeys:ee,colDeltas:te}=W,ne=J.length?new Set(J):null,ae=ee.length?new Set(ee):null;for(const{colId:de,before:ie,after:oe}of te)if(q.has(de)){for(const ce of J)ae&&ae.has(ce)||this.#je(ce,de,ie,null);for(const ce of ee)ne&&ne.has(ce)||this.#je(ce,de,null,oe);for(const ce of J)ae&&!ae.has(ce)||this.#je(ce,de,ie,oe)}}return q}#je(k,I,q,Z){const W=this.#A.get(k),J=W&&W.get(I);!J||!J.valid||J.update(q,Z)||J.invalidate()}#ft(k,I,q,Z){if(!Z||!Z.size)return this.#at(I,q,k);const W={};let J=null,ee=this.#A.get(k.key);for(const te of I){const ne=Z.get(te.id);if(!ne){(J||(J=[])).push(te);continue}const ae=this.#s.handle(te.id);if(!ae)continue;ee||(ee=new Map,this.#A.set(k.key,ee));let de=ee.get(te.id);if((!de||de.fn!==ne.fn)&&(de=new n(ne.fn),ee.set(te.id,de)),de.valid||de.seedColumn(ae.values,o(ae),q),de.valid){W[te.id]=de.value();continue}(J||(J=[])).push(te)}return J&&Object.assign(W,this.#at(J,q,k)),W}#Pt(k,I,q,Z){const W=!this.#Je()||this.#wt(I);for(const J of k){const ee=J.getValue;if(!_(ee))continue;const te=ee(q),ne=ee(Z);Object.is(te,ne)||(this.#M&&this.#M.add(J.id),W&&this.#k.has(J.id)&&this.#O.push({colId:J.id,before:te,after:ne}))}}#nt(){const k=this.#V("groupBy",[]),I=[];for(const q of k){const Z=this.#Ue(q);Z&&I.push(Z)}return I}#Qe(k,I){const q=new Array(k.length);for(let Z=0;Z<k.length;Z++){const W=k[Z].getValue;q[Z]=S(_(W)?W(I):void 0)}return q}#Ge(k,I,q,Z,W){if(this.#Je()&&!this.#wt(q))return;const J=O(this.#Qe(k,Z)),ee=O(this.#Qe(k,W)),te=J.length!==ee.length||J.some((ae,de)=>ae!==ee[de]),ne=[];for(const ae of I){const de=ae.getValue;if(!_(de))continue;const ie=de(Z),oe=de(W);!te&&Object.is(ie,oe)||ne.push({colId:ae.id,before:ie,after:oe})}!ne.length&&!te||this.#S.push({beforeKeys:J,afterKeys:ee,colDeltas:ne})}#wt(k){const I=this.#l.get("filter"),q=I&&I.computed?I.result:null;if(!q)return!0;let Z=0,W=q.length-1;for(;Z<=W;){const J=Z+W>>1,ee=q[J];if(ee===k)return!0;ee<k?Z=J+1:W=J-1}return!1}#Je(){return(this.#e.config||{}).totalFilteredOnly!==!1}#C(k){return this.#Je()?k:this.#rt().length}#rt(){return(!this.#R||this.#R.version!==this.#c)&&(this.#R={version:this.#c,indices:this.#Me()}),this.#R.indices}#ze(){const k=this.#V("groupBy",[]),I=`${this.#c}|${JSON.stringify(k)}`;if(this.#L&&this.#L.key===I)return this.#L.map;const q=new Map,Z=[];for(const W of k){const J=this.#s.handle(W);J&&Z.push(J)}if(Z.length){const W=this.#rt(),{keys:J,buckets:ee}=this.#Ke("groupByColumns")(Z,W,{locale:(this.#e.config||{}).locale}),te=new Map;for(let ne=0;ne<ee.length;ne++){const ae=J[ne],de=[];for(let ie=0;ie<ae.length;ie++){de.push(S(ae[ie]));const oe=z(de);let ce=te.get(oe);ce||(ce=[],te.set(oe,ce));for(let fe=0;fe<ee[ne].length;fe++)ce.push(ee[ne][fe])}}for(const[ne,ae]of te)q.set(ne,Uint32Array.from(ae))}return this.#L={key:I,map:q},q}#Te(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#ye(){this.#xe(),this.#it(),this.#M=null,this.#j=null,this.#E=null}#xe(){this.#k.clear(),this.#O.length=0,this.#b=-1}#it(){this.#A.clear(),this.#S.length=0,this.#P=-1}#vt(k){const I=this.#V("pivotBy",[]);if(!I.length)return this.#le=null,null;const q=(this.#e.compute||{}).pivot;if(!_(q))return B("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#le=null,null;const Z=I.map(J=>this.#s.handle(J)).filter(Boolean),W=this.#st();return this.#le=q(Z,k.leaves,{groups:k.keys&&k.buckets?{keys:k.keys,buckets:k.buckets}:null,totals:W.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>C(W.find(ee=>ee.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#le}#Ct(k){const I=this.#l.get("total").result,q=!!(this.#e.config||{}).groupFooter,Z=this.#we();if(k.tree)return this.#ot(k,I,Z);if(!k.roots&&!Z){if(I&&I.grand&&!this.#be()){const ae=this.#i.grandTotal(I.grand,this.#C(k.leaves.length));if(this.#W===k.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=ae;else{const de=Array.from(k.leaves);de.push(ae),this.#B=de,this.#W=k.leaves}this.#re=[{at:this.#B.length-1}]}else this.#W=null,this.#B=k.leaves,this.#re=y;return this.#ie=y,this.#B}const W=[],J=[],ee=[],te=ae=>{if(W.push(ae),!Z)return;const de=this.#Ne(ae);!de||!Z.isOpen(de.key)||(de.master=!0,de.expanded=!0,ee.push({at:W.length}),W.push(this.#i.detail(de,Z.heightOf(de))))};if(!k.roots){for(let ae=0;ae<k.leaves.length;ae++)te(k.leaves[ae]);return I&&I.grand&&!this.#be()&&(ee.push({at:W.length}),W.push(this.#i.grandTotal(I.grand,this.#C(k.leaves.length)))),this.#W=null,this.#ie=y,this.#re=ee.length?ee:y,this.#B=W,W}const ne=(ae,de,ie)=>{if(ae.expanded=ae.hasChildren===!1?!1:this.#pt(ae.key,{key:ae.key,column:ae.groupColumn,value:ae.groupValue,level:ae.level,path:ae.groupPath}),ae.posinset=de+1,ae.setsize=ie,J.push({at:W.length,row:ae}),ee.push({at:W.length}),W.push(ae),!!ae.expanded){if(ae.children&&ae.children.length)for(let oe=0;oe<ae.children.length;oe++)ne(ae.children[oe],oe,ae.children.length);else{const oe=k.nodes.get(ae.key),ce=oe&&oe.leaves?oe.leaves:null;if(ce)for(let fe=0;fe<ce.length;fe++)te(ce[fe])}q&&ae.totals&&(ee.push({at:W.length}),W.push(this.#i.footer(ae)))}};for(let ae=0;ae<k.roots.length;ae++)ne(k.roots[ae],ae,k.roots.length);return I&&I.grand&&!this.#be()&&(ee.push({at:W.length}),W.push(this.#i.grandTotal(I.grand,this.#C(k.leaves.length)))),this.#ie=J,this.#re=ee,this.#B=W,W}#Me(){const k=this.#e.store;if(k&&_(k.liveIndices))return k.liveIndices();const I=new Uint32Array(this.#n.length);let q=0;for(let Z=0;Z<this.#n.length;Z++)this.#n[Z]!==void 0&&(I[q++]=Z);return I.subarray(0,q)}#et(){const k=this.#e.store;return k&&typeof k.physical=="number"?k.physical:this.#n.length}#$e(k){const I=this.#e.store;return I&&_(I.source)?I.source(k):this.#n[k]}#He(k,I=k){const q=this.#B[k];if(typeof q!="number")return q.index=I,q;const Z=this.#Ne(q);return Z.index=I,Z}#Ne(k){let I=this.#h.get(k);I||(I=this.#i.leaf(this.#$e(k),k),this.#h.set(k,I));const q=this.#x?this.#x.get(k):null;if(q){I.level=q.level,I.posinset=q.posinset,I.setsize=q.setsize,I.hasChildren=q.hasChildren,I.expanded=q.hasChildren&&!q.lazy&&this.#pt(I.key);const Z=this.#I?this.#I.byPhysical.get(k):void 0;Z?I.totals=Z:I.totals&&(I.totals=null)}else I.hasChildren&&(I.level=0,I.hasChildren=!1,I.expanded=!1,I.posinset=void 0,I.setsize=void 0);return I}#ot(k,I,q){const Z=[],W=[],J=te=>{if(te.leafCount!==void 0)return te.leafCount;let ne=te.physical>=0?1:0;for(const ae of te.children)ne+=J(ae);return te.leafCount=ne,ne},ee=te=>{const ne=this.#pt(te.key);if(te.physical>=0){if(Z.push(te.physical),q&&q.isOpen(this.#Ne(te.physical).key)){const ae=this.#Ne(te.physical);W.push({at:Z.length}),Z.push(this.#i.detail(ae,q.heightOf(ae)))}}else Z.push(this.#i.group({path:[te.key],column:null,value:te.value,level:te.level,parent:null,expanded:ne,hasChildren:te.children.length>0,leafCount:J(te),totals:this.#I?this.#I.byKey.get(te.key):void 0}));if(ne)for(const ae of te.children)ee(ae)};for(const te of k.tree.roots)ee(te);return I&&I.grand&&!this.#be()&&(W.push({at:Z.length}),Z.push(this.#i.grandTotal(I.grand,this.#C(k.leaves.length)))),this.#W=null,this.#ie=y,this.#re=W.length?W:y,this.#B=Z,Z}#xt(){return b(()=>this.count(),k=>this.at(k))}#ht(k,I){let q=this.#N.get(k);if(q===void 0){const Z=this.#$e(k),W=this.#ut(),J=[],ee=this.#e.columnHidden;for(const te of W){if(te.quickFilter===!1||_(ee)&&ee(te.id))continue;const ne=te.value&&_(te.value.quickFilterText)?te.value.quickFilterText({value:void 0,data:Z,row:null,column:te,colId:te.id,grid:null,context:this.#V("context",null)}):null,ae=ne??(_(te.formatValue)?te.formatValue(_(te.getValue)?te.getValue(Z):void 0):"");ae!=null&&ae!==""&&J.push(String(ae))}q=J.join(" ").toLowerCase(),this.#N.set(k,q)}return I(q)}#st(){const k=this.#V("totals",[]),I=k&&k.length?new Set(k):null;return this.#ut().filter(q=>I?I.has(q.id):!!(q.total||q.groupTotal||q.grandTotal))}#at(k,I,q,Z="group"){const W={},J=(this.#e.compute||{}).total;for(const ee of k){if(!T(ee))continue;const te=this.#s.handle(ee.id);if(!te)continue;const ne=C(ee,Z);if(ne)if(_(ne)){const ae=new Array(I.length);for(let de=0;de<I.length;de++)ae[de]=te.get(I[de]);W[ee.id]=ne(ae,{row:q,column:ee,grid:this.#e.grid||null,context:this.#V("context",null),valueAt:(de,ie)=>{const oe=this.#s.handle(de);return oe&&ie>=0&&ie<I.length?oe.get(I[ie]):null}})}else _(J)&&(W[ee.id]=J(te,I,ne))}return W}#Et(k){if(!k)return k;const I=this.#e.config||{},q={tz:I.timeZone,weekStartsOn:I.weekStartsOn};return i(k,Z=>{const W=g(Z,q);if(W&&W.type)return W;const J=this.#Ue(W&&W.col),ee=J&&(J.dataType?.base||J.type);return ee?{...W,type:ee}:W})}#pt(k,I){const q=this.#V("expanded",null);return q?_(q.has)?q.has(k,I):Array.prototype.includes.call(q,k):!0}#V(k,I){if(k==="context"||!_(this.#e.stateVersion))return this.#mt(k,I);const q=this.#Be(k),Z=this.#d.get(k);if(Z&&Z.version===q)return Z.value;const W=this.#mt(k,I);return this.#d.set(k,{version:q,value:W}),W}#mt(k,I){const q=this.#e.state;if(q&&_(q[k])){const Z=q[k]();return Z??I}return I}#kt(){const k=this.#e.stateVersion;return _(k)?k():0}#Tt(){const k=this.#e.columnsVersion,I=this.#e.permissionsVersion;return`${_(k)?k():0}|${_(I)?I():0}`}#Be(k){return k==="totals"?this.#Tt():`${this.#kt()}`}#lt(k,I,q){if(!_(this.#e.stateVersion))return q();const Z=this.#f.get(k);if(Z&&Z.version===I)return Z.key;const W=q();return this.#f.set(k,{version:I,key:W}),W}#Ke(k){const I=(this.#e.compute||{})[k];return _(I)||F(`ctx.compute.${k} is required by the memory source pipeline`),I}#ut(){const k=this.#e.columns;return k&&_(k.all)?k.all():[]}#Ue(k){const I=this.#e.columns;return I&&_(I.get)?I.get(k):void 0}#qe(k,I){const q=this.#e.emit;_(q)&&q(k,I)}}}),xe("packages/core/src/source/abort.js",function(e,K){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return _}});class X extends Error{constructor(G,H="superseded"){super(`[lattice] request ${G?`"${G}" `:""}${H}`),this.name="SupersededError",this.superseded=!0,this.key=G}}class L{#e;constructor(G,H,U,z){this.#e=G,this.key=H,this.controller=U,this.signal=U.signal,this.seq=z}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(G){this.signal.aborted||this.controller.abort(new X(this.key,G)),this.#e.settle(this)}}class B{#e=new Map;#t=0;begin(G="",H="superseded"){const U=this.#e.get(G);U&&!U.signal.aborted&&U.controller.abort(new X(G,H));const z=new L(this,G,new AbortController,++this.#t);return this.#e.set(G,z),z}tokenFor(G){return this.#e.get(G)}pending(G=""){const H=this.#e.get(G);return!!H&&!H.signal.aborted}get size(){return this.#e.size}settle(G){this.#e.get(G.key)===G&&this.#e.delete(G.key)}abort(G="",H="superseded"){const U=this.#e.get(G);U&&U.abort(H)}abortAll(G="superseded"){for(const H of[...this.#e.values()])H.abort(G);this.#e.clear()}}function F(){return new B}function _(Q){if(!Q||typeof Q!="object")return!1;const G=Q;return G.superseded===!0||G.name==="AbortError"||G.name==="SupersededError"}}),xe("packages/core/src/source/blockcache.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return F}});const X=100,L=32;class B{constructor(Q){this.id=Q,this.rows=null,this.state="pending",this.token=null,this.error=null}}class F{#e=new Map;#t;#n;#r=0;#o=-1;constructor(Q={}){this.#t=Math.max(1,Math.floor(Number(Q.pageSize)||X)),this.#n=Math.max(1,Math.floor(Number(Q.maxCachedPages)||L))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Q){return Math.floor(Q/this.#t)}rangeOf(Q){return{start:Q*this.#t,end:(Q+1)*this.#t}}has(Q){return this.#e.has(Q)}pending(Q){const G=this.#e.get(Q);return!!G&&G.state==="pending"}loaded(Q){const G=this.#e.get(Q);return!!G&&G.state==="loaded"}begin(Q,G){let H=this.#e.get(Q);return H||(H=new B(Q)),H.state="pending",H.token=G,H.error=null,this.#i(Q,H),H}fill(Q,G){const H=this.#e.get(Q)||new B(Q);H.rows=G,H.state="loaded",H.token=null,this.#i(Q,H)}failed(Q,G){const H=this.#e.get(Q)||new B(Q);H.state="error",H.error=G,H.token=null,this.#i(Q,H)}delete(Q){return this.#e.delete(Q)}rowAt(Q){const G=this.blockOf(Q),H=this.#e.get(G);if(!(!H||H.state!=="loaded"||!H.rows))return this.#i(G,H),H.rows[Q-G*this.#t]}rowLoaded(Q){const G=this.blockOf(Q),H=this.#e.get(G);return!!H&&H.state==="loaded"&&!!H.rows&&Q-G*this.#t<H.rows.length}erroredAt(Q){const G=this.#e.get(this.blockOf(Q));return!!G&&G.state==="error"}loadedExtent(){let Q=0;for(const G of this.#e.values()){if(G.state!=="loaded"||!G.rows)continue;const H=G.id*this.#t+G.rows.length;H>Q&&(Q=H)}return Q}fillOf(Q){const G=this.#e.get(Q);return G&&G.state==="loaded"&&G.rows?G.rows.length:null}protect(Q,G){this.#r=this.blockOf(Math.max(0,Q)),this.#o=this.blockOf(Math.max(0,G))}evict(){const Q=[];if(this.#e.size<=this.#n)return Q;for(const[G,H]of this.#e){if(this.#e.size-Q.length<=this.#n)break;G>=this.#r&&G<=this.#o||H.state!=="pending"&&Q.push(G)}for(const G of Q)this.#e.delete(G);return Q}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Q,G){this.#e.delete(Q),this.#e.set(Q,G)}}}),xe("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return X}});function X(L,B,F,_){const Q=Math.floor(Number(L)||0);if(Q<=0)return null;const G=Math.max(0,Math.floor(Number(B)||0)),H=Math.max(0,Math.floor(Number(F)||0));if(_){const U=Math.max(1,Math.ceil(H/Q)),z=Math.min(G,U-1),S=z*Q;return{page:z,pageSize:Q,offset:S,length:Math.max(0,Math.min(Q,H-S)),pageCount:U,total:H}}return{page:G,pageSize:Q,offset:G*Q,length:Q,pageCount:Math.max(G+2,Math.ceil(H/Q)),total:null}}}),xe("packages/core/src/source/paged.js",function(e,K){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return i}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.isFunction,F=X.warnOnce,_=X.settleDebounce,Q=K("packages/core/src/source/abort.js"),G=Q.createAbortScope,H=Q.isAbortError,U=K("packages/core/src/source/blockcache.js"),z=U.BlockCache,S=U.DEFAULT_PAGE_SIZE,O=U.DEFAULT_MAX_CACHED_PAGES,u=K("packages/core/src/source/rows.js").createRowFactory,d=K("packages/core/src/source/filterwire.js"),s=d.wireFilters,n=d.querySignature,t=d.warnHostFilterNotApplied,o=K("packages/core/src/source/pagewindow.js").pageWindow,f=120;function l(g,c){return new i(g,c)}class i{mode="paged";#e;#t;#n;#r=G();#o;#i;#s=new Map;#l=null;#a=!1;#u=0;#c="";#d={start:0,end:0};#f;#h=!1;#p=0;#m="";constructor(c,h){this.#e=c||{mode:"paged"},this.#t=h||{},this.#n=new z({pageSize:this.#e.pageSize||S,maxCachedPages:this.#e.maxCachedPages||O}),this.#o=u(this.#t),this.#i=new L(this.#n.pageSize*4),this.#f=_((a,m)=>this.#k(a,m),f),this.#c=this.#S(),B(this.#e.fetch)||F("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const c=this.#y();return c?c.length:this.#g()}#g(){if(this.#A(),this.#l!==null)return this.#l;const c=Math.max(this.#u,this.#n.loadedExtent());return this.#a?c:c+this.#n.pageSize}matchCount(){return this.#g()}totalCount(){return this.#g()}pageInfo(){const c=this.#y();if(!c){const h=this.#g();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:c.page,pageSize:c.pageSize,total:c.total,pageCount:c.pageCount,counting:c.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const c=this.#g(),h=o(this.#j("pageSize",0),this.#j("page",0),c,this.exact());if(!h)return this.#m="",null;const a=`${this.#p}:${h.offset}:${h.length}`;if(a!==this.#m&&!this.#h&&(this.#m=a,h.length>0)){const m=h.offset+h.length-1;this.#d={start:h.offset,end:m},this.#k(h.offset,m)}return h}at(c){const h=this.#y();if(h){if(c<0||c>=h.length)return;const a=this.#w(h.offset+c);return a&&(a.index=c),a}return this.#w(c)}#w(c){if(c<0||c>=this.#g())return;const h=this.#i.get(c);if(h&&(h.data!==null||!this.#n.rowLoaded(c)))return h;const a=this.#n.rowAt(c);if(a===void 0){const w=this.#o.skeleton(c,0,this.#n.erroredAt(c));return this.#i.set(c,w),w}const m=this.#o.leaf(a,c);return m.index=c,this.#i.set(c,m),this.#s.set(m.key,c),m}byKey(c){const h=this.#s.get(c);return h===void 0?void 0:this.#w(h)}loaded(c){const h=this.#y();return h?c>=0&&c<h.length&&this.#n.rowLoaded(h.offset+c):this.#n.rowLoaded(c)}hint(c,h){if(this.#h)return;const a=this.#A();let m=Math.max(0,Math.floor(c)),w=Math.max(m,Math.floor(h));const v=this.#y();if(v){if(v.length===0)return;m=v.offset,w=v.offset+v.length-1}this.#d={start:m,end:w},this.#n.protect(m,w);for(const p of this.#n.evict())this.#O(p);this.#f(m,w),a&&this.#f.flush()}#k(c,h){if(this.#h)return;this.#n.protect(c,h);const a=this.#n.blockOf(c),m=this.#n.blockOf(h);for(let w=a;w<=m&&!(this.#l!==null&&w*this.#n.pageSize>=this.#l);w++)this.#n.has(w)||this.#b(w)}apply(c){const h={added:[],updated:[],removed:[]};if(!c)return h;if(c.update)for(const a of c.update){const m=this.#o.keyOf(a,-1),w=this.#s.get(m);if(w===void 0)continue;const v=this.#o.leaf(a,w);v.index=w,this.#i.set(w,v),h.updated.push(v)}return(c.add&&c.add.length||c.remove&&c.remove.length)&&this.reload(),h}reload(c){this.#P("reload"),this.#f.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#h=!0,this.#f.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#a}pending(){return this.#r.size}async#b(c){if(!B(this.#e.fetch))return;const h=this.#r.begin(`block:${c}`);this.#n.begin(c,h);const{start:a,end:m}=this.#n.rangeOf(c),w=this.#c;try{const v=await this.#e.fetch({range:{start:a,end:m},sort:this.#j("sort",[]),filters:s(this.#j("filters",null),this.#M()),quick:this.#j("quick","")||void 0,context:this.#j("context",null),signal:h.signal});if(!h.current||w!==this.#c||this.#h)return;h.settle();const p=v&&v.rows||[];this.#n.fill(c,p);for(let C=0;C<p.length;C++)this.#i.delete(a+C);const y=v&&typeof v.total=="number"?v.total:v&&typeof v.count=="number"?v.count:null;y!==null?(this.#l=y,this.#a=!0):p.length<this.#n.pageSize?(this.#a=!0,this.#l=a+p.length):this.#u=Math.max(this.#u,a+p.length),this.#E("model:changed",{reason:"page",block:c,from:a,to:a+p.length}),this.#E("rows:changed",{companion:!0,reason:"page",block:c,from:a,to:a+p.length})}catch(v){if(h.settle(),H(v))return;this.#n.failed(c,v);for(let p=a;p<m;p++)this.#i.delete(p);this.#E("model:changed",{reason:"page-error",block:c,range:{start:a,end:m}}),this.#E("source:error",{error:v,block:c,range:{start:a,end:m}})}}#O(c){const{start:h,end:a}=this.#n.rangeOf(c);for(let m=h;m<a;m++){const w=this.#i.peek(m);w&&this.#s.delete(w.key),this.#i.delete(m)}}#A(){const c=this.#S();return c===this.#c?!1:(this.#c=c,this.#P("query"),!0)}#P(c){this.#r.abortAll(c),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=!1,this.#u=0,this.#p++,this.#E("model:changed",{reason:c})}#S(){return n({filters:this.#j("filters",null),sort:this.#j("sort",[]),quick:this.#j("quick",""),context:this.#j("context",null)})}#M(){const c=this.#t.config||{};return{tz:c.timeZone,weekStartsOn:c.weekStartsOn}}#j(c,h){const a=this.#t.state;if(a&&B(a[c])){const m=a[c]();return m??h}return h}#E(c,h){const a=this.#t.emit;B(a)&&a(c,h)}}}),xe("packages/core/src/source/aggregates.js",function(e,K){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return U}});const X=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function L(){const z=new Set;for(const[S,O]of Object.entries(X))O.pushable&&z.add(S);return z}function B(z,S,O){let b=z.split("%c").join(S);return O!==void 0&&(b=b.split("%w").join(O)),b}function F(z){const S=z||{},O=S.default==="engine"||S.default==="engine-if-identical"?S.default:"client",b={};if(S.overrides&&typeof S.overrides=="object")for(const[u,d]of Object.entries(S.overrides))(d==="engine"||d==="client")&&(b[u]=d);return{default:O,overrides:b}}function _(z,S){const O=X[z];if(!O||!O.pushable)return"client";const b=S.overrides[z];return b==="engine"||b==="client"?b:S.default==="client"?"client":S.default==="engine-if-identical"?O.class==="identical"?"engine":"client":"engine"}function Q(z,S){const O=F(S),b=[],u=[];for(const d of z||[]){const s=X[d.fn],n=_(d.fn,O),t={id:d.id,col:d.col,fn:d.fn,class:s?s.class:"fallback"};d.weight!==void 0&&(t.weight=d.weight),d.params!==void 0&&(t.params=d.params),n==="engine"?b.push(t):(t.reason=s&&!s.pushable?s.note||"the engine cannot express this stat":"client by config",u.push(t))}return{engine:b,client:u,config:O}}const G=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(z,S=[]){return(z||[]).every(b=>{if(typeof b=="string")return G.test(b);if(!b||typeof b!="object")return!1;const u=b;return Array.isArray(S)&&S.includes(u.bucket)&&typeof u.col=="string"&&G.test(u.col)&&typeof u.size=="number"&&Number.isFinite(u.size)&&u.size>0})}function U(){return Object.entries(X).map(([z,S])=>({stat:z,class:S.class,sql:S.sql?B(S.sql,"col",S.twoColumn?"weight":void 0):"",note:S.note||(S.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),xe("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return R}});const X=K("packages/core/src/internal/util.js"),L=X.defaultCompare,B=X.isFunction,F=X.toArray,_=X.warnOnce,Q=K("packages/core/src/source/filterwire.js"),G=Q.isGroup,H=Q.warnWherePageRelative,U=Q.warnWhereOverThreshold,z=K("packages/core/src/source/aggregates.js"),S=z.resolveAggregatePlan,O=z.groupKeysPushable,b=z.STAT_PUSHDOWN,d=K("packages/core/src/source/abort.js").SupersededError;function s(k){const I=k&&k.signal;if(!I||!I.aborted)return;const q=I.reason;throw q instanceof Error?q:new d("","superseded before it was sent")}const n=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function t(k){if(!k||typeof k!="object")return!1;const I=k.returning==="row"||k.returning==="key"?k.returning:"none";return{append:k.append===!0,update:k.update===!0,delete:k.delete===!0,returning:I}}function r(k,I){if(!k||typeof I!="string")return;if(!I.includes("."))return k[I];let q=k;for(const Z of I.split(".")){if(q===null||typeof q!="object")return;q=q[Z]}return q}function o(k){if(k===!0)return!0;if(!k||typeof k!="object")return!1;const I=k;return I.enabled===!1?!1:I.enabled===!0||B(I.commit)}function f(k){const I={...n,...k||{}};return I.operators=new Set(I.operators||[]),I.mutate=t(I.mutate),I}function l(k,I){return!k||!k.op||!I.operators.size?!1:I.operators.has(k.op)}function i(k,I){if(!k)return{pushed:null,residual:null};if(!I.filter)return{pushed:null,residual:k};if(I.filter==="term"){if(G(k)){const J=k.conditions||[];if(String(k.op)!=="and")return{pushed:null,residual:k};const ee=J.findIndex(ne=>!G(ne)&&l(ne,I));if(ee<0)return{pushed:null,residual:k};const te=J.filter((ne,ae)=>ae!==ee);return{pushed:J[ee],residual:te.length?{op:"and",conditions:te}:null}}return l(k,I)?{pushed:k,residual:null}:{pushed:null,residual:k}}if(!G(k))return l(k,I)?{pushed:k,residual:null}:{pushed:null,residual:k};if(String(k.op)!=="and")return(k.conditions||[]).every(ee=>G(ee)?i(ee,I).residual===null:l(ee,I))?{pushed:k,residual:null}:{pushed:null,residual:k};const q=[],Z=[];for(const J of k.conditions||[]){if(G(J)){if(I.filter==="flat"){Z.push(J);continue}const ee=i(J,I);ee.pushed&&q.push(ee.pushed),ee.residual&&Z.push(ee.residual);continue}(l(J,I)?q:Z).push(J)}const W=J=>J.length===0?null:J.length===1?J[0]:{op:"and",conditions:J};return{pushed:W(q),residual:W(Z)}}const g="__lattice_leaves";function c(k){return k.aggregates?k.aggregates instanceof Set?k.aggregates:new Set(F(k.aggregates)):new Set}function h(k){const I=c(k);return I.size?I.has("count")?k.filter!=="tree"||!k.operators||!k.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function a(k,I,q,Z,W,J,ee){const te=Array.isArray(k.groupBy)?k.groupBy:[],ne=Array.isArray(k.groupPath)?k.groupPath:[],ae=Array.isArray(k.groupValues)?k.groupValues:null;if(!I.group){const de=h(I);if(de)return de}return O(te)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Z?W?J?"a host `where` predicate can only run in the browser, over rows the engine grouped":ee?"fullDataset holds the whole matching set, so the grid groups it itself":!ae||ae.length!==ne.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const m="pushdown:pivot-unsupported",w="pushdown:group-unsupported",v=Symbol("lattice.remote.ungroupedLevel");function p(k,I,q,Z,W,J){const ee=Array.isArray(k.pivotBy)?k.pivotBy:[],te=Array.isArray(k.groupBy)?k.groupBy:[],ne=Array.isArray(k.groupPath)?k.groupPath:[],ae=Array.isArray(k.groupValues)?k.groupValues:null;return I.pivot?O(ee)?te.length&&!O(te)?"a grouping key is not a plain column the engine can name in a GROUP BY":q.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":Z?W?J?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!ae||ae.length!==ne.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function y(k,I,q=!1){const Z=i(k.filters||null,I),W=[];Z.residual&&W.push("filter");const J=k.sort||[],ee=J.length===0||I.sort==="multi"&&J.length>=1||I.sort==="single"&&J.length===1;!ee&&J.length&&W.push("sort");const te=k.quick?String(k.quick):"",ne=!te||!!I.quick;ne||W.push("quick");const ae=k.where&&k.where.active?k.where:null;ae&&W.push("where");const de={filters:Z.residual,sort:ee?null:J,quick:ne?"":te,where:ae},ie=!!q,oe=Array.isArray(k.groupBy)&&k.groupBy.length>0,ce=oe?a(k,I,Z,ee,ne,ae,ie):"",fe=k.pivotMode!==!1&&Array.isArray(k.pivotBy)&&k.pivotBy.length>0,ke=fe?p(k,I,Z,ee,ne,ae):"",Re=fe&&ke==="";fe&&!Re&&W.push("pivot");const Ee=fe?Re&&oe:oe&&ce==="";oe&&!fe&&!Ee&&W.push("group");const Fe=(Ee||Re)&&Array.isArray(k.groupValues)?k.groupValues.length:0,ye=Ee||fe?!1:ie||!!(de.filters||de.sort||de.quick||de.where)||!I.range;return{pushed:{...k,filters:Z.pushed,sort:ee?J:[],quick:ne?te:"",range:ye?null:k.range},residual:de,needsAll:ye,unpushed:W,full:ie,grouped:Ee,groupLevel:Fe,groupReason:fe?"":ce,pivoted:Re,pivotReason:ke}}function C(k){const I=Array.isArray(k.totals)?k.totals:[],q=k.totalFns&&typeof k.totalFns=="object"?k.totalFns:{},Z=[],W=[];for(const J of I){const ee=String(J),te=typeof q[ee]=="string"?q[ee]:null,ne=te?b[te]:null;te?!ne||!ne.pushable||!ne.sql?W.push({id:ee,fn:te,class:ne?ne.class:"fallback",reason:ne&&ne.note?ne.note:`the pushdown map cannot express "${te}"`}):ne.twoColumn?W.push({id:ee,fn:te,class:ne.class,reason:`"${te}" reduces two columns, and a grouped request carries no weight column`}):Z.push({id:ee,col:ee,fn:te,class:ne.class}):W.push({id:ee,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Z,client:W}}const T=Object.freeze({items:k=>k==null?[]:Array.isArray(k)?k:[k]});function P(k,I,q){if(!I)return k;let Z=k;if(I.filters&&B(q.evaluateFilters)){const W=Z,J={count:Z.length,handle:ne=>({id:ne,get:ae=>r(W[ae],ne)}),itemwise:ne=>W.some(ae=>Array.isArray(r(ae,ne)))?T:null},ee=q.evaluateFilters(I.filters,J),te=[];for(let ne=0;ne<Z.length;ne++)ee[ne]&&te.push(Z[ne]);Z=te}if(I.where&&I.where.active&&(I.whole||H(I.where.names,"pushdown"),Z=Z.filter(W=>I.where.passes(W))),I.quick){const W=I.quick.toLowerCase();Z=Z.filter(J=>{if(!J||typeof J!="object")return!1;for(const ee of Object.values(J))if(ee!=null&&String(ee).toLowerCase().includes(W))return!0;return!1})}if(I.sort&&I.sort.length&&B(q.sortMulti)){const W=[...new Set(I.sort.map(ne=>ne.col))],J=Z,ee=W.map(ne=>({id:ne,get:ae=>r(J[ae],ne)})),te=q.sortMulti(ee,I.sort.map(ne=>({col:ne.col,dir:ne.dir})),Uint32Array.from({length:Z.length},(ne,ae)=>ae),{});Z=Array.from(te,ne=>J[ne])}return Z}function x(k){return JSON.stringify({filters:k.filters||null,sort:k.sort||[],quick:k.quick||"",groupBy:k.groupBy||[],groupPath:k.groupPath||[],context:k.context??null})}function E(k){if(!k||typeof k!="object")return 16;let I="";try{I=JSON.stringify(k)}catch{return 200}return I.length*2+64}function j(k){const I=k||{};return{enabled:!!I.enabled,maxRows:Number.isFinite(I.maxRows)?I.maxRows:1e6,maxBytesEstimate:Number.isFinite(I.maxBytesEstimate)?I.maxBytesEstimate:512*1024*1024}}const A=5e4;function $(k){return Number.isFinite(k)&&k>=0?k:A}function D(k){return!!k&&B(k.then)}async function M(k){if(!k||k.total!==void 0||!D(k.pendingTotal))return k;const I=await k.pendingTotal,{pendingTotal:q,...Z}=k;return typeof I=="number"?{...Z,total:I}:Z}function R(k={}){const I=k.adapter;if(!I||!B(I.execute))return _("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...k,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=f(I.capabilities),Z=I.capabilities&&Object.getOwnPropertyDescriptor(I.capabilities,"operators");Z&&B(Z.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(I.capabilities.operators||[]),set:()=>{}});const W=I.name||"adapter";let J=null;const ee=()=>B(I.ready)?(J||(J=Promise.resolve(I.ready()).then(()=>{Object.assign(q,f(I.capabilities))},Qe=>{throw J=null,Qe})),J):null,te=j(k.fullDataset),ne=!!k.allowPartialResults,ae=$(k.whereRowLimit);let de=null;const ie=k.aggregates;let oe=null,ce=null,fe=null,ke=null,Re=null,Ee,Fe=null,ye=0,he=null;const Se=()=>!te.enabled||!oe?null:(he!==oe.key&&(ye++,he=oe.key),{rows:oe.rows,version:ye}),Ce=async Qe=>{const Ge=Qe.where&&Qe.where.active?Qe.where:null;if(!Ge)return{request:Qe,probe:null};const{where:se,...pe}=Qe,be=y(pe,q,te.enabled);if(be.needsAll)return{request:Qe,probe:null};const Ue=x(be.pushed);let Ve=null;return(!de||de.key!==Ue)&&(q.total?(s(Qe),Ve=await M(await I.execute(be.pushed,Qe)),de={key:Ue,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):de={key:Ue,size:null}),de.size!==null&&de.size<ae?{request:Qe,probe:null}:(U(Ge.names,W,de.size,ae),{request:pe,probe:Ve})},Ie=async(Qe,Ge)=>{Fe=null;const se=C(Qe.pushed);fe={engine:se.engine,client:se.client,groupBy:Qe.pushed.groupBy},se.client.length&&_(`source.pushdown.group.totals.${W}.${se.client.map(Ue=>Ue.id).join(".")}`,`the ${W} adapter cannot compute the group subtotal for ${se.client.map(Ue=>`"${Ue.id}" (${Ue.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const pe=await I.executeGroupLevel(Qe.pushed,se.engine,Ge)||{};let be=pe.rows||[];return!q.range&&Ge.range&&(be=be.slice(Ge.range.start,Ge.range.end)),Te(pe),pe.total===void 0?{rows:be}:{rows:be,total:pe.total}},ze=new Map,Xe=64,Je=async(Qe,Ge)=>{Fe=null;const se=Qe.pushed,pe=se.groupBy,be=Array.isArray(se.groupValues)?se.groupValues:[],Ue=be.length,Ve=[...se.filters?[se.filters]:[],...pe.slice(0,Ue).map((dt,mt)=>({col:dt,op:"eq",value:be[mt]===void 0?null:be[mt],caseSensitive:!0}))],rt=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},ge=Ge.range?Ge.range.start:0;if(Ue>=pe.length){const dt={...se,filters:rt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},mt=await M(await I.execute(dt,Ge))||{};let jt=mt.rows||[];return!q.range&&Ge.range&&(jt=jt.slice(Ge.range.start,Ge.range.end)),typeof mt.total=="number"?{rows:jt,total:mt.total}:{rows:jt}}const we=pe[Ue],ve=C(se),Ae=c(q),Le=ve.engine.filter(dt=>Ae.has(dt.fn)),me=[...ve.engine.filter(dt=>!Ae.has(dt.fn)).map(dt=>({id:dt.id,fn:dt.fn,class:dt.class,reason:`the ${W} adapter does not compute "${dt.fn}"`})),...ve.client];fe={engine:Le,client:me,groupBy:pe},me.length&&_(`source.pushdown.group.totals.${W}.${me.map(dt=>dt.id).join(".")}`,`the ${W} adapter cannot compute the group subtotal for ${me.map(dt=>`"${dt.id}" (${dt.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Me=[...Le.map(dt=>({id:dt.id,col:dt.col,fn:dt.fn})),{id:g,col:we,fn:"count"}],je={...se,filters:rt,range:null},Ne=JSON.stringify([x(je),be,we,Me]);let De=ge>0?ze.get(Ne):void 0;if(!De){for(De=Promise.resolve(I.executeGroupedAggregates(je,[we],Me)),ze.delete(Ne),ze.set(Ne,De);ze.size>Xe;)ze.delete(ze.keys().next().value);De.catch(()=>{ze.get(Ne)===De&&ze.delete(Ne)})}const qe=await De||[];s(Ge);const st=dt=>{const mt={};for(const jt of Le)mt[jt.id]=dt?dt[jt.id]:void 0;return mt},ct=(se.sort||[]).find(dt=>dt&&dt.col===we),ft=ct&&ct.dir==="desc"?-1:1,at=qe.filter(dt=>dt&&dt.level===1).map(dt=>({[we]:dt.keys[0]===void 0?null:dt.keys[0],leafCount:Number(dt.values&&dt.values[g])||0,totals:st(dt.values)})).sort((dt,mt)=>ft*L(dt[we],mt[we]));if(Ue===0){const dt=qe.find(jt=>jt&&jt.level===0),mt=dt?Number(dt.values&&dt.values[g]):NaN;Te({matchCount:Number.isFinite(mt)?mt:at.reduce((jt,He)=>jt+He.leafCount,0),...dt?{grand:st(dt.values)}:{}})}const vt=Ge.range?Ge.range.end:at.length;return{rows:at.slice(ge,vt),total:at.length}},Te=Qe=>{typeof Qe.matchCount=="number"&&(ke=Qe.matchCount,Re=Qe.grand?{totals:Qe.grand,leafCount:Qe.matchCount}:null,Ee===void 0&&B(I.unfilteredCount)&&(Ee=null,Promise.resolve(I.unfilteredCount()).then(Ge=>{Ee=typeof Ge=="number"?Ge:null}).catch(Ge=>{_(`source.pushdown.group.unfiltered.${W}`,`the ${W} adapter could not count the unfiltered set (${Ge&&Ge.message?Ge.message:Ge}), so "N of M" falls back to the display count for its denominator.`)})))},_e=async(Qe,Ge)=>{Fe=null;const se=C(Qe.pushed);fe={engine:se.engine,client:se.client,groupBy:Qe.pushed.groupBy,pivotBy:Qe.pushed.pivotBy},se.client.length&&_(`source.pushdown.pivot.totals.${W}.${se.client.map(rt=>rt.id).join(".")}`,`the ${W} adapter cannot compute the pivot cells for ${se.client.map(rt=>`"${rt.id}" (${rt.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const pe=await I.executePivotLevel(Qe.pushed,se.engine,Ge)||{};let be=pe.rows||[];!q.range&&Ge.range&&(be=be.slice(Ge.range.start,Ge.range.end)),Te(pe);const Ue=pe.pivot&&typeof pe.pivot=="object"?pe.pivot:{},Ve={cells:Array.isArray(Ue.cells)?Ue.cells:[],...Array.isArray(Ue.axis)?{axis:Ue.axis}:{}};return pe.total===void 0?{rows:be,pivot:Ve}:{rows:be,total:pe.total,pivot:Ve}},Ke=Qe=>{_(`source.pushdown.pivot.${W}.${Qe}`,`pushdown:pivot-unsupported: the ${W} adapter cannot pivot this query because ${Qe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Ge=new Error(`[lattice] ${m}: the ${W} adapter cannot pivot this query because ${Qe}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Ge.code=m,Ge.reason=Qe,Ge},nt=(Qe,Ge)=>{const se={key:Ge,state:"pending",value:null};return Fe=se,Qe.then(pe=>(Fe===se&&(Fe={key:Ge,state:"settled",value:typeof pe=="number"?pe:null}),pe),pe=>{throw Fe===se&&(Fe={key:Ge,state:"failed",value:null}),pe})},ot=async Qe=>{const Ge=ee();Ge&&await Ge;const pe=Qe&&Qe.pivotMode!==!1&&Array.isArray(Qe.pivotBy)&&Qe.pivotBy.length>0?{request:Qe,probe:null}:await Ce(Qe);s(Qe);let be=y(pe.request,q,te.enabled);if(q.group&&be.grouped&&!be.pivoted&&!B(I.executeGroupLevel)&&(_(`source.pushdown.group.method.${W}`,`the ${W} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),be=y(pe.request,{...q,group:!1,aggregates:null},te.enabled)),be.pivoted&&!B(I.executePivotLevel)&&(be=y(pe.request,{...q,pivot:!1},te.enabled),be.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),be.grouped&&!be.pivoted&&!q.group&&!B(I.executeGroupedAggregates)&&(_(`source.pushdown.group.aggregates.method.${W}`,`the ${W} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),be=y(pe.request,{...q,aggregates:null},te.enabled)),ce=be,be.pivoted)return _e(be,Qe);if(be.pivotReason&&Ke(be.pivotReason),be.grouped)return q.group?Ie(be,Qe):Je(be,Qe);const Ve=!!be.groupReason&&!be.full;Ve?_(`source.pushdown.group-unsupported.${W}.${be.groupReason}`,`pushdown:group-unsupported: the ${W} adapter was not asked to group this query because ${be.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):be.groupReason&&_(`source.pushdown.group.${W}.${be.groupReason}`,`the ${W} adapter was not asked to group this query because ${be.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const rt=Me=>Ve?{...Me,[v]:!0}:Me;if(!be.needsAll){const Me=pe.probe||await I.execute(be.pushed,Qe),je=Me.rows||[];return D(Me.pendingTotal)&&Me.total===void 0?rt({rows:je,pendingTotal:nt(Me.pendingTotal,x(be.pushed))}):(Fe=null,!q.total&&Me.total===void 0?rt({rows:je}):rt({rows:je,total:Me.total??je.length}))}be.unpushed.length&&_(`source.pushdown.residual.${W}.${be.unpushed.join(".")}`,`the ${W} adapter cannot push ${be.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ge=x(be.pushed);if(!oe||oe.key!==ge){const Me=await M(await I.execute(be.pushed,Qe));Fe=null;const je=Me.rows||[];if(be.full){const Ne=typeof Me.total=="number"?Math.max(Me.total,je.length):je.length;if(Ne>te.maxRows)throw new Error(`[lattice] fullDataset refused: the ${W} adapter's matching set is ${Ne.toLocaleString()} rows, past the configured maxRows of ${te.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const De=je.length*E(je[0]);if(De>te.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${W} adapter's matching set is an estimated ${Math.round(De/(1024*1024)).toLocaleString()} MB across ${je.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(te.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Me.total=="number"&&je.length<Me.total){const Ne=!!(be.residual.filters||be.residual.quick||be.residual.sort&&be.residual.sort.length);if(Ne&&!ne)throw new Error(`[lattice] the ${W} adapter returned ${je.length} of ${Me.total} matching rows when asked for the whole result, and the query has residual ${be.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);Ne?_(`source.pushdown.partial.residual.${W}`,`the ${W} adapter returned ${je.length} of ${Me.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):_(`source.pushdown.partial.${W}`,`the ${W} adapter returned ${je.length} of ${Me.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}oe={key:ge,rows:je,total:typeof Me.total=="number"?Me.total:null}}let we=be;if(be.residual.where){const Me=oe.total??oe.rows.length;if(Me>=ae){U(be.residual.where.names,W,Me,ae);const{where:je,...Ne}=pe.request;we=y(Ne,q,te.enabled),ce=we}}const ve=oe.total!==null&&oe.rows.length>=oe.total,Ae=P(oe.rows,{...we.residual,whole:ve},k.compute||{}),Le=Qe.range?Qe.range.start:0,me=Qe.range?Qe.range.end:Ae.length;return rt({rows:Ae.slice(Le,me),total:Ae.length})},pt=async(Qe,Ge)=>{const se=ee();se&&await se;const pe=y(Qe,q,te.enabled);ce=pe;const be=S(Ge,ie),Ue=Array.isArray(Qe.groupBy)?Qe.groupBy:[],Ve=Ue.length>0,rt=!pe.residual.filters&&!pe.residual.quick,ge=!Ve||O(Ue,q.buckets);let we=be.engine,ve=be.client;if(q.aggregates&&we.length){const Me=q.aggregates instanceof Set?q.aggregates:new Set(F(q.aggregates)),je=we.filter(Ne=>!Me.has(Ne.fn));je.length&&(we=we.filter(Ne=>Me.has(Ne.fn)),ve=[...je.map(Ne=>({...Ne,reason:`the ${W} adapter does not compute "${Ne.fn}"`})),...ve])}const Ae=Me=>{ve=[...we.map(je=>({...je,reason:Me})),...ve],we=[]};we.length&&!rt?Ae(pe.residual.quick&&!pe.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):we.length&&!ge&&Ae("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Le={},me;return we.length&&(B(Ve?I.executeGroupedAggregates:I.executeAggregates)?Ve?me=await I.executeGroupedAggregates(pe.pushed,Ue,we)||[]:Le=await I.executeAggregates(pe.pushed,we)||{}:(_(`source.pushdown.aggregates.${W}${Ve?".grouped":""}`,`the ${W} adapter cannot compute ${Ve?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Ae(`adapter cannot compute ${Ve?"grouped ":""}aggregates`))),fe={engine:we,client:ve,...Ve?{groupBy:Ue}:{}},{values:Le,engine:we,client:ve,...me!==void 0?{groups:me}:{}}},bt=o(k.edit),Ot=k.edit&&typeof k.edit=="object"&&B(k.edit.commit);let Pt=k.edit;if(bt&&!Ot)if(q.mutate&&q.mutate.update){const Qe=Ge=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${W} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const se={kind:"update",key:String(Ge.key),patch:{[Ge.colId]:Ge.value}};return I.mutate(se,Ge.request||{})};Pt={...k.edit===!0?{}:k.edit,commit:Qe}}else _(`source.pushdown.readonly.${W}`,`edit is enabled but the ${W} adapter declares mutate: ${q.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const Et=bt&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:(Qe,Ge)=>I.mutate(Qe,Ge||{})}:null,Mt=async Qe=>{const Ge=ee();Ge&&await Ge;const{range:se,signal:pe,export:be,...Ue}=Qe||{},Ve={...Ue,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:y(Ve,q,te.enabled),signal:pe}};async function*Dt(Qe,Ge={}){const{plan:se,signal:pe}=await Mt(Qe),be=Math.max(1,Math.floor(Number(Ge.pageSize))||5e3),Ue={signal:pe,stream:!0};if(!se.needsAll)for(let ge=0;;ge+=be){s(Ue);const we=await I.execute({...se.pushed,range:{start:ge,end:ge+be}},Ue);we&&D(we.pendingTotal)&&we.pendingTotal.then(null,()=>{});const ve=we&&we.rows||[];if(ve.length&&(yield ve),ve.length<be)return}s(Ue);const Ve=await M(await I.execute({...se.pushed,range:void 0},Ue)),rt=P(Ve&&Ve.rows||[],{...se.residual,whole:!0},k.compute||{});for(let ge=0;ge<rt.length;ge+=be)yield rt.slice(ge,ge+be)}return{...k,edit:Pt,rowMutate:Et,mode:"remote",fetch:ot,aggregate:pt,countMatching:async Qe=>{const{plan:Ge,signal:se}=await Mt(Qe);if(!Ge.needsAll&&q.total){s({signal:se});const be=await M(await I.execute({...Ge.pushed,range:{start:0,end:0}},{signal:se}));if(be&&typeof be.total=="number")return be.total}let pe=0;for await(const be of Dt(Qe))pe+=be.length;return pe},streamMatching:Dt,lastPlan:()=>ce?{...ce,...fe?{aggregates:fe}:{},...Fe?{total:{deferred:!0,state:Fe.state,value:Fe.value}}:{}}:null,fullFrame:Se,counts:()=>({match:ke,total:Ee??null,pending:!!Fe&&Fe.state==="pending"}),grandTotals:()=>Re}}}),xe("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return E}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.isFunction,F=X.warnOnce,_=X.settleDebounce,Q=K("packages/core/src/source/abort.js"),G=Q.createAbortScope,H=Q.isAbortError,U=K("packages/core/src/source/blockcache.js"),z=U.BlockCache,S=U.DEFAULT_PAGE_SIZE,O=U.DEFAULT_MAX_CACHED_PAGES,b=K("packages/core/src/source/rows.js"),u=b.createRowFactory,d=b.groupKey,s=K("packages/core/src/source/filterwire.js"),n=s.wireFilters,t=s.querySignature,r=s.warnHostFilterNotApplied,f=K("packages/core/src/source/pagewindow.js").pageWindow,i=K("packages/core/src/source/memory.js").MemorySource,c=K("packages/core/src/compute/handle.js").valueComparator,h=K("packages/core/src/compute/pivot.js"),a=h.pivotKey,m=h.joinPath,w=h.DEFAULT_PATH_SEPARATOR,p=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,y=1,C=120;function T(j,A,$){for(let D=0;D<Math.max(j.length,A.length);D++){const M=j[D],R=A[D],k=M==null,I=R==null;if(k||I){if(k&&I)continue;return k?1:-1}const q=$(M,R);if(q!==0)return q}return 0}function P(j,A){return new E(j,A)}class x{constructor(A,$,D,M){this.path=A,this.keyPath=M||A,this.values=[],this.level=$,this.key=d(this.keyPath),this.cache=new z(D),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null,this.flat=!1}}class E{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=G();#l;#a;#u=new Map;#c=[];#d=null;#f="";#h;#p=!1;#m=0;#g="";#y=null;#w=-1;constructor(A,$){this.#e=A||{mode:"remote"},this.#t=$||{},B(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#R(),this.unfilteredIndices=()=>this.#L(),this.handleFor=k=>this.#x(k),this.display=()=>this.#I(),this.grandTotalRow=()=>this.#$(),this.unfilteredRows=()=>this.#B(),this.facetIndices=k=>this.#z(k));const D=this.#e.counts;B(D)&&(this.matchCount=()=>this.#N("match"),this.totalCount=()=>this.#N("total"));const M=this.#e.grandTotals;B(M)&&(this.grandTotalRow=()=>this.#H());const R=this.#e;B(R.countMatching)&&B(R.streamMatching)&&(this.selectionQuery=()=>this.#W(),this.countMatching=k=>R.countMatching(k),this.streamMatching=(k,I)=>R.streamMatching(k,I),this.loadedRows=()=>this.#ie(),this.resident=()=>this.#j()!==null),this.#n={pageSize:this.#e.pageSize||S,maxCachedPages:this.#e.maxCachedPages||O},this.#l=u(this.#t),this.#a=new L(this.#n.pageSize*4),this.#h=_((k,I)=>this.#S(k,I),C),this.#r=new x([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#f=this.#me(),B(this.#e.fetch)||F("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Ce()}count(){const A=this.#O();return A?A.length:this.#k()}#k(){const A=this.#j();return A?A.count():(this.#ne(),this.#q(this.#r))}#b(){if(this.#j())return!0;const A=$=>{if($.count===null&&!$.complete)return!1;for(const D of $.children.values())if(this.#X(D.key)&&!A(D))return!1;return!0};return A(this.#r)}pageInfo(){const A=this.#O(),$=this.totalPending();if(!A){const D=this.#k();return{page:0,pageSize:0,total:this.#b()?D:null,pageCount:1,counting:$}}return{page:A.page,pageSize:A.pageSize,total:A.total,pageCount:A.pageCount,counting:$||A.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#O(){const A=this.#k(),$=f(this.#T("pageSize",0),this.#T("page",0),A,this.#b());if(!$)return this.#g="",null;const D=`${this.#m}:${$.offset}:${$.length}`;return D!==this.#g&&!this.#p&&(this.#g=D,$.length>0&&!this.#j()&&this.#S($.offset,$.offset+$.length-1)),$}at(A){const $=this.#O();if($){if(A<0||A>=$.length)return;const D=this.#A($.offset+A);return D&&(D.index=A),D}return this.#A(A)}#A(A){const $=this.#j();if($)return $.at(A);if(this.#ne(),A<0||A>=this.#k())return;const D=this.#D(this.#r,A);if(!D)return;const M=this.#K(D.node,D.local);return M&&(M.index=A),M||this.#l.skeleton(A,D.node.level,D.node.cache.erroredAt(D.local))}byKey(A){const $=this.#j();if($)return $.byKey(A);const D=this.#u.get(A);if(!D)return;const M=D.lastIndexOf(":"),R=this.#o.get(D.slice(0,M));return R&&this.#K(R,Number(D.slice(M+1)))||void 0}loaded(A){const $=this.#O();if($){if(A<0||A>=$.length)return!1;A+=$.offset}const D=this.#j();if(D)return D.loaded(A);if(A<0||A>=this.#k())return!1;const M=this.#D(this.#r,A);return!!M&&M.node.cache.rowLoaded(M.local)}hint(A,$){if(this.#p)return;const D=this.#ne();let M=Math.max(0,Math.floor(A)),R=Math.max(M,Math.floor($));const k=this.#O();if(k){if(k.length===0)return;M=k.offset,R=k.offset+k.length-1}for(const[I,q]of this.#P(M,R)){I.cache.protect(q.min,q.max);for(const Z of I.cache.evict())this.#Pe(I,Z)}this.#h(M,R),D&&this.#h.flush()}#P(A,$){const D=this.#k(),M=new Map;for(let R=A;R<=$&&R<D;R++){const k=this.#D(this.#r,R);if(!k)continue;const I=M.get(k.node);I?(I.min=Math.min(I.min,k.local),I.max=Math.max(I.max,k.local)):M.set(k.node,{min:k.local,max:k.local})}return M.size||M.set(this.#r,{min:A,max:A}),M}#S(A,$){if(!this.#p)for(const[D,M]of this.#P(A,$)){D.cache.protect(M.min,M.max);const R=D.cache.blockOf(M.min),k=D.cache.blockOf(M.max);for(let I=R;I<=k&&!(D.count!==null&&I*D.cache.pageSize>=D.count);I++)D.cache.has(I)||this.#le(D,I)}}apply(A){const $={added:[],updated:[],removed:[]};if(!A)return $;if(A.update)for(const D of A.update){const M=this.#u.get(this.#l.keyOf(D,-1));if(!M)continue;this.#a.delete(M);const R=M.lastIndexOf(":"),k=this.#o.get(M.slice(0,R));if(!k)continue;const I=Number(M.slice(R+1)),q=k.cache.blockOf(I);if(!k.cache.loaded(q))continue;const{start:Z}=k.cache.rangeOf(q),W=[];for(let ee=Z;ee<Z+k.cache.pageSize;ee++){const te=k.cache.rowAt(ee);if(te===void 0)break;W.push(ee===I?D:te)}k.cache.fill(q,W);const J=this.#K(k,I);J&&$.updated.push(J)}return(A.add&&A.add.length||A.remove&&A.remove.length)&&this.reload({keepExpanded:!0}),$}reload(A){this.#s.abortAll("reload"),this.#h.cancel(),A&&A.keepExpanded===!1&&this.#i.clear(),this.#oe(),this.#U("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#oe(),this.#o.clear(),this.#i.clear(),this.#y&&B(this.#y.destroy)&&this.#y.destroy(),this.#y=null}expand(A){this.#i.has(A)||(this.#i.add(A),this.#U("group:toggled",{key:A,expanded:!0}),this.#U("model:changed",{reason:"expand",key:A}))}collapse(A){this.#i.delete(A)&&(this.#U("group:toggled",{key:A,expanded:!1}),this.#U("model:changed",{reason:"collapse",key:A}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#ne();const A=this.#d;if(!A||!A.keys.size||!this.#T("pivotBy",[]).length)return null;if(!A.result){const $=c((this.#t.config||{}).locale),D=[...A.keys.entries()].sort((R,k)=>T(R[1],k[1],$)),M=D.map(([R])=>R);A.result={keys:D.map(([,R])=>R),paths:M,fields:this.#pe(M),groupPaths:[],columns:M.length*Math.max(1,this.#ke().length),values:A.cells,cells:A.cells,error:null}}return A.result}invalidateHandles(){this.#y&&(B(this.#y.invalidateHandles)&&this.#y.invalidateHandles(),B(this.#y.invalidate)&&this.#y.invalidate("filter"))}#M(){const A=this.#e.fullFrame;return B(A)?A():null}#j(){const A=this.#M();return A?(this.#y||(this.#y=new i({mode:"memory"},this.#E())),A.version!==this.#w&&(this.#y.setRows(A.rows),this.#w=A.version),this.#y):null}#E(){const A=this.#t,$=A.state||{};return{...A,state:{...$,page:()=>0,pageSize:()=>0}}}#R(){const A=this.#j();return A?A.filteredIndices():new Uint32Array(0)}#L(){const A=this.#j();return A?A.unfilteredIndices():new Uint32Array(0)}#x(A){const $=this.#j();return $?$.handleFor(A):void 0}#I(){const A=this.#j();return A?A.display():[]}#z(A){const $=this.#j();return $&&B($.facetIndices)?$.facetIndices(A):new Uint32Array(0)}#$(){const A=this.#j();return A&&B(A.grandTotalRow)?A.grandTotalRow():null}#N(A){const $=this.#j();if($){const k=A==="match"?$.matchCount:$.totalCount;if(B(k))return k.call($)}const D=this.#e.counts,M=B(D)?D():null,R=M?M[A]:null;return typeof R=="number"?R:this.#k()}#H(){const A=this.#j();if(A&&B(A.grandTotalRow))return A.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const D=this.#e.grandTotals,M=B(D)?D():null;return!M||!M.totals?null:this.#l.grandTotal(M.totals,M.leafCount||0)}#B(){const A=this.#j();if(A&&B(A.unfilteredRows))return A.unfilteredRows();const $=[],D=this.count();for(let M=0;M<D;M++){const R=this.at(M);R&&$.push(R)}return $}#W(){const A=this.#T("quick",""),$={protocol:y,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:n(this.#T("filters",null),this.#G()),sort:this.#T("sort",[]),context:this.#T("context",null)};A&&($.quick=A);const D=this.#T("where",null);return D&&D.active&&($.where=D),$}#ie(){const A=this.#T("groupBy",[]).length,$=[];for(const D of this.#o.values())if(!(D.level!==A&&!D.flat))for(const M of D.cache.ids()){if(!D.cache.loaded(M))continue;const{start:R,end:k}=D.cache.rangeOf(M);for(let I=R;I<k&&D.cache.rowLoaded(I);I++){const q=this.#K(D,I);q&&!q.group&&$.push(q)}}return $}#re(A,$,D){const{start:M,end:R}=A.cache.rangeOf($),k=this.#T("groupBy",[]),I=this.#T("pivotBy",[]),q=this.#T("quick",""),Z=this.#ke(),W={protocol:y,range:{start:M,end:R},groupPath:A.path,groupValues:A.values,groupBy:k,totals:Z,totalFns:this.#ce(Z),pivotBy:I,pivotMode:I.length>0,filters:n(this.#T("filters",null),this.#G()),sort:this.#T("sort",[]),context:this.#T("context",null),signal:D};q&&(W.quick=q);const J=this.#T("where",null);return J&&J.active&&(W.where=J),W}async#le(A,$){if(!B(this.#e.fetch))return;const D=this.#s.begin(`${A.key}:${$}`);A.cache.begin($,D);const M=this.#f,{start:R}=A.cache.rangeOf($);try{const k=await this.#e.fetch(this.#re(A,$,D.signal));if(!D.current||M!==this.#f||this.#p)return;D.settle();const I=k&&k.rows||[];if(!!(k&&k[p])&&!A.flat){A.flat=!0,A.children.clear();for(const[J,ee]of[...this.#u])ee.startsWith(`${A.key}:`)&&(this.#a.delete(ee),this.#u.delete(J))}A.cache.fill($,I);for(let J=0;J<I.length;J++)this.#a.delete(`${A.key}:${R+J}`);const Z=k&&typeof k.count=="number"?k.count:k&&typeof k.total=="number"?k.total:null,W=k&&B(k.pendingTotal?.then)?k.pendingTotal:null;Z!==null?(A.count=Z,A.complete=!0):I.length<A.cache.pageSize?(A.count=R+I.length,A.complete=!0):W&&(A.counting=!0),k&&Array.isArray(k.pivotFields)&&this.#he(k.pivotFields),k&&k.pivot&&typeof k.pivot=="object"&&this.#be(k.pivot),this.#U("model:changed",{reason:"page",groupPath:A.path,block:$}),this.#U("rows:changed",{companion:!0,reason:"page",groupPath:A.path,block:$}),W&&this.#ue(A,W,M)}catch(k){if(D.settle(),H(k))return;A.cache.failed($,k);const{end:I}=A.cache.rangeOf($);for(let q=R;q<I;q++)this.#a.delete(`${A.key}:${q}`);this.#U("model:changed",{reason:"page-error",groupPath:A.path,block:$}),this.#U("source:error",{error:k,groupPath:A.path,block:$})}}async#ue(A,$,D){let M;try{M=await $}catch(R){if(D!==this.#f||this.#p)return;A.counting=!1,H(R)||this.#U("source:error",{error:R,groupPath:A.path});return}D!==this.#f||this.#p||(A.counting=!1,typeof M=="number"&&(A.count=M,A.complete=!0,this.#U("source:total",{total:M,groupPath:A.path}),this.#U("model:changed",{reason:"total",count:M,groupPath:A.path})))}totalPending(){return this.#r.counting===!0}#he(A){A.length===this.#c.length&&A.every(($,D)=>$===this.#c[D])||(this.#c=A,this.#U("column:pivoted",{pivotFields:A,remote:!0}))}#we(){const A=this.#t.config||{};return A.pivot&&A.pivot.separator||w}#pe(A){const $=this.#we(),D=this.#ke();if(!D.length)return A.slice();const M=[];for(const R of A)for(const k of D)M.push(`${R}${$}${k}`);return M}#be(A){const $=this.#we();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const D=this.#d;let M=!1;const R=I=>{const q=Array.isArray(I)?I:[I],Z=m(q,$);return D.keys.has(Z)||(D.keys.set(Z,q),M=!0),Z},k=this.#T("groupBy",[]).length>0;for(const I of Array.isArray(A.axis)?A.axis:[])R(I);for(const I of Array.isArray(A.cells)?A.cells:[]){if(!I||typeof I!="object")continue;const q=R(I.pivot);if(k&&!(Array.isArray(I.group)&&I.group.length))continue;const Z=m(Array.isArray(I.group)?I.group:[],$);for(const[W,J]of Object.entries(I.values||{}))D.cells.set(a(Z,q,W),J)}D.result=null,M&&this.#he((this.pivot()||{fields:[]}).fields)}#q(A){let $=this.#te(A);for(const D of A.children.values())this.#X(D.key)&&($+=this.#q(D));return $}#te(A){if(A.count!==null)return A.count;const $=A.cache.loadedExtent();return A.complete?$:A.row&&A.row.leafCount>0?A.level>=this.#T("groupBy",[]).length?Math.max($,A.row.leafCount):$===0?1:Math.min($+A.cache.pageSize,Math.max($,A.row.leafCount)):$+A.cache.pageSize}#D(A,$){let D=$,M=0;const R=[...A.children.entries()].filter(([,I])=>this.#X(I.key)).sort((I,q)=>I[0]-q[0]);for(const[I,q]of R){const Z=I-M+1;if(D<Z)return{node:A,local:M+D};D-=Z,M=I+1;const W=this.#q(q);if(D<W)return this.#D(q,D);D-=W}const k=this.#te(A);return M+D<k?{node:A,local:M+D}:null}#K(A,$){const D=`${A.key}:${$}`,M=this.#a.get(D);if(M)return M;const R=A.cache.rowAt($);if(R===void 0)return null;const k=this.#T("groupBy",[]);let I;if(A.level<k.length&&!A.flat){const q=k[A.level],Z=this.#d!==null&&A.level===k.length-1&&this.#T("pivotBy",[]).length>0,W=this.#se(R,q),J=W==null,ee=[...A.path,J?"":String(W)],te=[...A.keyPath,J?null:String(W)];if(I=this.#l.group({path:ee,keyPath:te,column:q,value:W,level:A.level,parent:A.row,leafCount:Number(R.leafCount)||0,expanded:Z?!1:this.#X(d(te)),...Z?{hasChildren:!1}:{}}),I.totals=this.#_(R),I.data=R,!Z){let ne=this.#o.get(I.key);ne?ne.row=I:(ne=new x(ee,A.level+1,this.#n,te),ne.row=I,this.#o.set(ne.key,ne)),ne.values=[...A.values,W],A.children.set($,ne)}}else I=this.#l.leaf(R,$,A.level,A.row);return this.#a.set(D,I),this.#u.set(I.key,D),I}#_(A){const $=A||{};if($.totals&&typeof $.totals=="object")return $.totals;const D={};for(const M of this.#ke())Object.hasOwn($,M)&&(D[M]=$[M]);return D}#Pe(A,$){const{start:D,end:M}=A.cache.rangeOf($);for(let R=D;R<M;R++){const k=`${A.key}:${R}`,I=this.#a.peek(k);I&&this.#u.delete(I.key),this.#a.delete(k)}}#ne(){const A=this.#me();return A===this.#f?!1:(this.#f=A,this.#s.abortAll("query"),this.#oe(),this.#U("model:changed",{reason:"query"}),!0)}#oe(){for(const A of this.#o.values())A.cache.clear(),A.count=null,A.complete=!1,A.counting=!1,A.children.clear(),A.flat=!1;this.#a.clear(),this.#u.clear(),this.#m++,this.#d=null}#me(){const A=this.#T("where",null);return`${t({filters:this.#T("filters",null),sort:this.#T("sort",[]),quick:this.#T("quick",""),groupBy:this.#T("groupBy",[]),pivotBy:this.#T("pivotBy",[]),context:this.#T("context",null)})}|${A?A.version:0}`}#X(A){const $=this.#T("expanded",null);return $?B($.has)?$.has(A):Array.prototype.includes.call($,A):this.#i.has(A)}#ke(){const A=this.#T("totals",[]);if(A&&A.length)return[...A];const $=this.#t.columns;return!$||!B($.all)?[]:$.all().filter(D=>!!D.total).map(D=>D.id)}#ce(A){const $=this.#t.columns,D={};if(!$||!B($.get))return D;for(const M of A){const R=$.get(M);if(!R)continue;const k=R.groupTotal!=null?R.groupTotal:R.total;typeof k=="string"&&(D[M]=k)}return D}#se(A,$){const D=this.#t.columns,M=D&&B(D.get)?D.get($):void 0;return M&&B(M.getValue)?M.getValue(A):A?.[$]}#Ce(){r(this.#t)}#G(){const A=this.#t.config||{};return{tz:A.timeZone,weekStartsOn:A.weekStartsOn}}#T(A,$){const D=this.#t.state;if(D&&B(D[A])){const M=D[A]();return M??$}return $}#U(A,$){const D=this.#t.emit;B(D)&&D(A,$)}}}),xe("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return L}});const X=64;class L{#e;#t=0;#n=0;constructor(F=X){this.#e=new Uint32Array(Math.max(1,F)),this.#n=this.#e.length}static from(F,_=X){const Q=new L(F.length+Math.max(1,_));return Q.#e.set(F,0),Q.#t=F.length,Q.#n=Q.#e.length,Q}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(F){return F<0||F>=this.length?0:F<this.#t?this.#e[F]:this.#e[F+(this.#n-this.#t)]}insert(F,_){const Q=F<0?0:F>this.length?this.length:F;this.#r(Q),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=_}push(F){this.insert(this.length,F)}removeAt(F){return!Number.isInteger(F)||F<0||F>=this.length?!1:(this.#r(F),this.#n++,!0)}toArray(){const F=new Uint32Array(this.length);return F.set(this.#e.subarray(0,this.#t),0),F.set(this.#e.subarray(this.#n),this.#t),F}clear(){this.#t=0,this.#n=this.#e.length}#r(F){if(F!==this.#t)if(F<this.#t){const _=this.#t-F;this.#e.copyWithin(this.#n-_,F,this.#t),this.#t=F,this.#n-=_}else{const _=F-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+_),this.#t=F,this.#n+=_}}#o(){const F=this.#e.length-this.#n,_=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+X));_.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),_.length-F),this.#e=_,this.#n=_.length-F}}}),xe("packages/core/src/store/ingest.js",function(e,K){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return n}});const X=K("packages/core/src/internal/util.js"),L=X.now,B=X.nextFrame,F=X.infoOnce,_=X.warnOnce,Q=X.isFunction,G=X.pathGetter,U=K("packages/core/src/store/columnstore.js").ColumnStore,z=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function S(t,r={}){if(r.multi)return"multi";if(t.length===0)return"object";let o=0,f=0,l=0,i=0,g=0;for(let h=0;h<t.length;h++){const a=t[h];typeof a=="number"?o++:typeof a=="boolean"?f++:typeof a=="string"?l++:a instanceof Date?i++:Array.isArray(a)&&g++}const c=t.length;return o===c?"float64":f===c?"bitset":i===c?"float64":l===c?"text":g===c?"multi":"object"}function O(t,r,o){return r<=0||t<o*r?"dictionary":"object"}function b(t,r,o){const f=new Map,l=new Map;for(const y of t){if(y.computed)continue;const C=Q(y.read)?y.read:G(y.field||y.id);l.set(y.id,C),f.set(y.id,C)}const i=r?.order??[],g=r?.fns??{},c=r?.deps??{},h=r?.wrapDeps??null,a=i.filter(y=>Q(g[y])),m=a.some(y=>c[y]==="*");let w=new WeakMap;const v=y=>{const C={};if(m)for(const[T,P]of l)C[T]=P(y);for(const T of a){const P=c[T];let x;if(P==="*")x=C;else{x={};const E=P||[];for(let j=0;j<E.length;j++){const A=E[j];x[A]=A in C?C[A]:l.get(A)?.(y)}}C[T]=g[T](h?h(x,T):x,{data:y,row:null,column:null,grid:null,context:o})}return C},p=y=>{if(y===null||typeof y!="object"&&typeof y!="function")return v(y);let C=w.get(y);return C===void 0&&(C=v(y),w.set(y,C)),C};for(const y of a)f.set(y,C=>p(C)[y]);return{readers:f,reset(){w=new WeakMap}}}class u{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(r,o){this.spec=r,this.read=o,this.kind="object",this.inferred=!1,this.nullable=r.nullable!==!1}}class d{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(r,o={},f={}){this.#e=Array.isArray(r)?r:Array.from(r||[]),this.#i={...z,...f};const l=o.columns??[];this.#r=b(l,o.computed??null,o.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(l,o.computed??null),this.#n=new U(this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const r=L(),{chunkMs:o,chunkRows:f}=this.#i,l=this.#e.length;do{const i=Math.min(this.#o+f,l);this.#n.append(this.#e.slice(this.#o,i)),this.#d(this.#o,i),this.#o=i,this.#r.reset(),this.#h(!1)}while(this.#o<l&&L()-r<o);return this.#a+=L()-r,this.#i.onProgress?.({loaded:this.#o,total:l}),this.#o>=l?(this.#h(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,read:r.read,dictionary:r.spec.dictionary})),decisions:this.#t.map(r=>({id:r.spec.id,kind:r.kind,nullable:r.nullable,inferred:r.inferred,distinct:r.candidate||r.change?this.#f(r):null,change:r.change,reason:r.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(r,o){const f=this.#e,l=Math.min(this.#i.sampleSize,f.length),i=this.#i.dictionaryRatio,g=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const c of r){if(!c||!c.id)continue;if(c.computed&&(c.pure===!1||o&&!g.has(c.id))){_(`ingest.impure.${c.id}`,`column "${c.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(c.id)??(Q(c.read)?c.read:G(c.field||c.id)),a=new u(c,h);if(c.kind)a.kind=c.kind,a.reason="declared by the caller";else if(c.dictionary)a.kind=c.multi?"multi":"dictionary",a.reason="value table supplied (lookup column)";else{const m=[];for(let v=0;v<l&&m.length<this.#i.sampleSize;v++){const p=h(f[v]);p!=null&&m.push(p)}a.inferred=!0;const w=S(m,{multi:c.multi});if(w==="text"){const v=new Set(m).size;a.kind=O(v,m.length,i),a.candidate=this.#u,a.reason=`sampled ${v} distinct in ${m.length}`}else a.kind=w,a.reason=`inferred from ${m.length} sampled values`,w==="object"&&m.length&&F(`ingest.mixed.${c.id}`,`column "${c.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);a.kind==="object"&&a.candidate&&(a.distinct=new Set(m))}this.#t.push(a)}}#d(r,o){const f=this.#e;for(const l of this.#t){if(!l.candidate||!l.distinct)continue;const i=l.distinct;for(let g=r;g<o;g++){const c=l.read(f[g]);c!=null&&i.add(c)}}}#f(r){if(r.distinct)return r.distinct.size;const o=this.#n.column(r.spec.id);return o?.dict?o.dict.size:0}#h(r){const o=this.#i.dictionaryRatio,f=this.#e.length;for(const l of this.#t){if(!l.candidate)continue;const i=this.#f(l);if(l.kind==="dictionary"&&i>=o*f){const g=this.#n.column(l.spec.id);l.distinct=new Set(g?.dict?g.dict.values():[]),this.#n.convert(l.spec.id,"object"),l.kind="object",l.change="demoted",l.reason=`${i} distinct values is at or above ${o*100}% of ${f} rows`;continue}if(l.kind==="object"&&i>=o*f){l.candidate=!1,l.distinct=null,l.reason=`${i} distinct values is at or above ${o*100}% of ${f} rows`;continue}r&&l.kind==="object"&&i<o*f&&(this.#n.convert(l.spec.id,"dictionary"),l.kind="dictionary",l.change=l.change==="demoted"?null:"promoted",l.reason=`${i} distinct values is below ${o*100}% of ${f} rows`,l.distinct=null),r&&(l.candidate=!1)}}}async function s(t,r={},o={}){const f=new d(t,r,o),l=o.scheduler?.frame??B;for(;f.slice();)await new Promise(i=>{l(i)});return f.result()}function n(t,r={},o={}){const f=new d(t,r,{...o,chunkMs:1/0});for(;f.slice(););return f.result()}}),xe("packages/core/src/store/columnpack.js",function(e,K){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return d}});const L=K("packages/core/src/internal/util.js").pathGetter,B=K("packages/core/src/store/ingest.js"),F=B.inferKind,_=B.decideText,Q=B.INGEST_DEFAULTS,H=K("packages/core/src/store/columnstore.js").toFloat,U=new Set(["float64","int32","bitset","dictionary","object","multi"]);function z(s){if(!Array.isArray(s)||s.length===0)return!1;for(const n of s)if(!n||typeof n.id!="string"||typeof n.field!="string"||n.field===""||n.kind&&!U.has(n.kind))return!1;return!0}function S(s){const n=H(s);return Number.isFinite(n)?n|0:0}function O(s){return s==null?[]:Array.isArray(s)?s:[s]}function b(s,n,t,r){if(s.kind)return s.kind;const o=[];for(let i=0;i<n.length&&o.length<Q.sampleSize;i++){const g=n[i];g!=null&&o.push(g)}const f=F(o,{multi:s.multi});if(f!=="text")return f;const l=new Set(o).size;return _(l,o.length,r)}function u(s,n,t={}){const r=n.length|0,o=t.dictionaryRatio??Q.dictionaryRatio,f=[];for(const l of s){const i=L(l.field||l.id),g=l.nullable!==!1,c=new Array(r);for(let v=0;v<r;v++){const p=i(n[v]);c[v]=p===void 0?null:p}const h=b(l,c,r,o),a=g?new Uint8Array(r+7>>3):null,m=v=>{a&&(a[v>>3]|=1<<(v&7))};let w;switch(h){case"float64":{const v=new Float64Array(r);for(let p=0;p<r;p++){const y=c[p],C=y===null;C||m(p),v[p]=C?NaN:H(y)}w={id:l.id,kind:h,nullable:g,values:v,presence:a,offsets:null,table:null};break}case"int32":{const v=new Int32Array(r);for(let p=0;p<r;p++){const y=c[p],C=y===null;C||m(p),v[p]=C?0:S(y)}w={id:l.id,kind:h,nullable:g,values:v,presence:a,offsets:null,table:null};break}case"bitset":{const v=new Uint8Array(r+7>>3);for(let p=0;p<r;p++){const y=c[p],C=y===null;C||m(p),!C&&y&&(v[p>>3]|=1<<(p&7))}w={id:l.id,kind:h,nullable:g,values:v,presence:a,offsets:null,table:null};break}case"dictionary":{const v=new Uint32Array(r),p=[],y=new Map;for(let C=0;C<r;C++){const T=c[C];if(T===null){v[C]=0;continue}m(C);let P=y.get(T);P===void 0&&(P=p.length,p.push(T),y.set(T,P)),v[C]=P}w={id:l.id,kind:h,nullable:g,values:v,presence:a,offsets:null,table:p};break}case"multi":{const v=[],p=new Map,y=new Uint32Array(r+1),C=[];for(let T=0;T<r;T++){const P=c[T];y[T]=C.length,P===null||m(T);const E=O(P);for(let j=0;j<E.length;j++){const A=E[j];let $=p.get(A);$===void 0&&($=v.length,v.push(A),p.set(A,$)),C.push($)}}y[r]=C.length,w={id:l.id,kind:h,nullable:g,values:Int32Array.from(C),presence:a,offsets:y,table:v};break}default:{const v=new Array(r);for(let p=0;p<r;p++){const y=c[p];y!==null&&m(p),v[p]=y}w={id:l.id,kind:"object",nullable:g,values:v,presence:a,offsets:null,table:null};break}}f.push(w)}return{count:r,columns:f}}function d(s){const n=[];if(!s||!Array.isArray(s.columns))return n;const t=r=>{ArrayBuffer.isView(r)&&r.buffer&&!n.includes(r.buffer)&&n.push(r.buffer)};for(const r of s.columns)t(r.values),t(r.presence),t(r.offsets);return n}}),xe("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return P}});const X=K("packages/core/src/internal/util.js"),L=X.Lru,B=X.isFunction,F=X.now,_=X.nextFrame,Q=X.cancelFrame,G=X.whenIdle,H=X.defaultCompare,U=X.warnOnce,z=X.infoOnce,S=X.getPath,O=K("packages/core/src/source/abort.js"),b=O.createAbortScope,u=O.isAbortError,d=K("packages/core/src/source/rows.js"),s=d.createRowFactory,n=d.lazyRowView,r=K("packages/core/src/source/gapbuffer.js").GapBuffer,f=K("packages/core/src/source/memory.js").createMemorySource,i=K("packages/core/src/source/filterwire.js").querySignature,c=K("packages/core/src/store/columnpack.js").isPortableSchema,h=25e4,a=Symbol("lattice.stream.storeBacked"),m=8,w=.1,v=1e3,p=50;function y(x){return Math.min(v,Math.max(p,Math.floor(x/4)))}function C(x){if(x instanceof Date)return x.getTime();if(typeof x=="number")return Number.isFinite(x)?x:NaN;if(typeof x=="string"){const E=x.trim();if(!E)return NaN;const j=Date.parse(E);return Number.isNaN(j)?Number(E):j}return NaN}function T(x,E){return new P(x,E)}class P{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=b();#c={loaded:0,estimated:void 0};#d=null;#f=0;#h=0;#p=0;#m=0;#g=null;#y=null;#w=null;#k=!1;#b=!1;#O=!1;#A=!1;#P="";#S=0;#M=0;#j=0;#E=null;#R=1/0;#L=!1;#x=null;#I=null;#z=null;#$=null;#N=!1;#H=0;#B=0;#W=!1;constructor(E,j){this.#e=E||{mode:"stream"},this.#t=j||{},this.#s=s(this.#t),this.#l=new L(4096),this.#P=this.#Q();const A=(this.#t.config||{}).ingest;this.#N=!!A&&A.retainSource===!1,B(this.#e.open)||U("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const $=Number(this.#e.poll);Number.isFinite($)&&$>0&&(this.#$=setInterval(()=>{this.#A||this.reload()},$),this.#$&&B(this.#$.unref)&&this.#$.unref()),this.#re()}#ie(){const E=Number(this.#e.maxAge);return Number.isFinite(E)&&E>0?E:0}#re(){const E=this.#ie();if(!E)return;const j=this.#e.ageBy;B(j)?this.#I=j:typeof j=="string"&&j?this.#I=A=>S(A,j):this.#I=null,this.#E=[],this.#x=setInterval(()=>{this.#A||this.#le()&&(this.#ce(),this.#fe())},y(E)),this.#x&&B(this.#x.unref)&&this.#x.unref()}#le(){const E=this.#ie();return!E||!this.#E?!1:this.#L?!0:this.#R<Date.now()-E*(1+w)}#ue(E,j){if(!this.#E)return;const A=this.#I?C(this.#I(j)):Date.now();this.#E[E]=A,Number.isNaN(A)||(A<this.#R&&(this.#R=A),A<Date.now()-this.#ie()&&(this.#L=!0))}#he(){return this.#ge("groupBy",[]).length>0?!0:!!this.#ge("pivotMode",!1)&&this.#ge("pivotBy",[]).length>0}#we(){if(this.#g||this.#A)return;const E=this.#he();if(E&&!this.#y){this.#y=f({mode:"memory",rows:this.#n},this.#pe()),this.#k=!1;return}!E&&this.#y&&(this.#y.destroy(),this.#y=null)}#pe(){if(this.#w)return this.#w;const E=this,j={liveIndices:()=>E.#be(),live:A=>E.#n[A]!==void 0,source:A=>E.#Ee(A),get physical(){return E.#n.length}};return this.#N&&(j.column=A=>{const $=E.#t.store;return $&&B($.column)?$.column(A):void 0}),this.#w=Object.create(this.#t,{store:{value:j,enumerable:!0,configurable:!0}}),this.#w}#be(){const E=new Uint32Array(this.#n.length);let j=0;for(let A=0;A<this.#n.length;A++)this.#n[A]!==void 0&&(E[j++]=A);return E.subarray(0,j)}#q(){return this.#g?this.#g:this.#y?(this.#k&&(this.#k=!1,this.#y.setRows(this.#n)),this.#y):null}invalidate(E="filter"){if(this.#g){this.#g.invalidate(E);return}this.#we(),this.#y&&this.#y.invalidate(E),(E==="filter"||E==="sort")&&this.#T()}count(){const E=this.#q();return E?E.count():this.#r?this.#r.length:this.#S}matchCount(){const E=this.#q();return E&&B(E.matchCount)?E.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const E=this.#q();return E&&B(E.totalCount)?E.totalCount():this.#S}unfilteredRows(){const E=this.#q();if(E&&B(E.unfilteredRows))return E.unfilteredRows();const j=[];for(let A=0;A<this.#n.length;A++){if(!this.#n[A])continue;const $=this.#Ae(A);$&&j.push($)}return j}at(E){const j=this.#q();if(j)return j.at(E);if(E<0||E>=this.count())return;const A=this.#r?this.#r.at(E):E,$=this.#Ae(A);return $.index=E,$}byKey(E){const j=this.#q();if(j)return j.byKey(E);const A=this.#a.get(E);return A===void 0?void 0:this.#Ae(A)}leavesOf(E){const j=this.#q();return j&&B(j.leavesOf)?j.leavesOf(E):[]}loaded(E){return E>=0&&E<this.count()}hint(E,j){if(this.#g){this.#g.hint(E,j);return}this.#te(),this.#p=Math.max(0,Math.floor(E))}#te(){this.#A||this.#Q()===this.#P||this.reload()}display(){const E=this.#q();return E?E.display():n(()=>this.count(),j=>this.at(j))}apply(E){if(this.#g)return this.#g.apply(E);const j={added:[],updated:[],removed:[]};if(!E)return j;if(E.update){let A=!1;for(const $ of E.update){const D=this.#a.get(this.#s.keyOf($,-1));if(D===void 0)continue;const M=this.#Le(D);this.#N?this.#Xe(D,$):this.#n[D]=$,this.#l.delete(D),this.#Z(D,M),this.#E&&(this.#ue(D,$),A=!0),this.#k=!0,j.updated.push(this.#Ae(D))}A&&this.#ce()}if(E.add&&E.add.length){const A=this.#X(E.add);for(const $ of A)j.added.push(this.#Ae($))}return E.remove&&E.remove.length&&U("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#fe(),j}reload(E){this.#u.abortAll("reload"),this.#tt(),this.#y&&(this.#y.destroy(),this.#y=null),this.#k=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#M=0,this.#j=0,this.#E&&(this.#E=[]),this.#R=1/0,this.#L=!1,this.#b=!1,this.#O=!1,this.#c={loaded:0,estimated:void 0},this.#P=this.#Q(),this.#je("model:changed",{reason:"reload"}),this.start()}destroy(){this.#A=!0,this.#$!==null&&(clearInterval(this.#$),this.#$=null),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#E=null,this.#u.abortAll("destroyed"),this.#tt(),this.#d!==null&&(this.#Ve(this.#d),this.#d=null),this.#y&&(this.#y.destroy(),this.#y=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#A||!B(this.#e.open))return;this.#O=!0;const E=this.#u.begin("stream");this.#T(),this.#we();let j;try{j=this.#e.open({sort:this.#ge("sort",[]),filters:this.#ge("filters",null),quick:this.#ge("quick","")||void 0,context:this.#ge("context",null),signal:E.signal})}catch($){this.#je("source:error",{error:$});return}const A=B(j[Symbol.asyncIterator])?j[Symbol.asyncIterator]():j[Symbol.iterator]();this.#z=A;try{for(;;){const $=await A.next();if(!E.current||this.#A)return;if($.done){this.#v();return}if(await this.#D($.value,E),!E.current||this.#A)return;if($.value&&$.value.done){this.#v();return}if(await this.#Oe(),!E.current||this.#A)return}}catch($){if(u($))return;this.#je("source:error",{error:$})}finally{E.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#b,live:this.#S,evicted:this.#M}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const E=this.#q();E&&(B(E.invalidateHandles)&&E.invalidateHandles(),B(E.invalidate)&&E.invalidate("sort"))}renderCount(){return this.#f}ingestStats(){return{worker:this.#H,inline:this.#B,storeBacked:this.#N}}#D(E,j){if(!E)return;const A=E.rows;if(A&&A.length&&this.#_(A))return this.#ne(E,j);const $=F();A&&A.length&&(this.#X(A),this.#B++),this.#K(E),this.#h+=F()-$,this.#fe()}#K(E){this.#c.loaded=E.progress&&typeof E.progress.loaded=="number"?E.progress.loaded:this.#n.length,E.progress&&typeof E.progress.estimated=="number"&&(this.#c.estimated=E.progress.estimated)}#_(E){if(this.#W||this.#g)return!1;const j=this.#oe();if(!j)return!1;const A=this.#t.store;if(!A||!B(A.appendPacked))return!1;const $=this.#me();return!$||!c($)?(this.#W=!0,z("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):E.length<j.threshold?!1:!this.#Pe(E)}#Pe(E){if(!this.#s.keyed)return!1;const j=new Set;for(let A=0;A<E.length;A++){const $=this.#s.keyOf(E[A],this.#n.length+A);if($!=null){if(j.has($)||this.#a.has($))return!0;j.add($)}}return!1}async#ne(E,j){const A=E.rows,$=this.#oe(),D=this.#me();let M;try{M=await $.columnize(D,A,{key:"ingest:stream",signal:j&&j.signal})}catch(Z){if(u(Z)||(U("source.stream.columnize","worker columnization failed; columnizing on the main thread",Z),this.#W=!0,j&&(!j.current||this.#A)))return;this.#X(A),this.#B++,this.#K(E),this.#fe();return}if(j&&(!j.current||this.#A))return;const R=this.#t.store,k=this.#N?void 0:A,{from:I}=R.appendPacked(M,k),q=M.count|0;for(let Z=0;Z<q;Z++){const W=I+Z,J=A[Z],ee=this.#s.keyed?this.#s.keyOf(J,W):null;if(this.#n[W]=this.#N?a:J,this.#S++,this.#ue(W,J),ee!==null&&this.#a.set(ee,W),!this.#r||!this.#U(W))continue;const te=this.#Y(W);this.#r.insert(te,W),te<=this.#p&&this.#m++}this.#k=!0,this.#ce(),this.#H++,this.#K(E),this.#fe()}#oe(){const E=this.#t.ingestWorker;return B(E)?E():null}#me(){const E=this.#t.storeSchema;return B(E)?E():null}#X(E){const j=[],A=this.#t.store,$=new Array(E.length),D=[],M=new Set;for(let k=0;k<E.length;k++){const I=this.#s.keyed?this.#s.keyOf(E[k],this.#n.length+D.length):null;$[k]=I,!(I!==null&&(this.#a.has(I)||M.has(I)))&&(I!==null&&M.add(I),D.push(E[k]))}let R=D.length&&A&&B(A.append)?A.append(D).from:this.#n.length;for(let k=0;k<E.length;k++){const I=E[k],q=$[k];if(q!==null&&this.#a.has(q)){const J=this.#a.get(q),ee=this.#Le(J);this.#N||(this.#n[J]=I,A&&B(A.setSource)&&A.setSource(J,I)),this.#Xe(J,I),this.#l.delete(J),this.#ue(J,I),this.#Z(J,ee);continue}const Z=R++;if(this.#n[Z]=this.#N?a:I,this.#S++,this.#ue(Z,I),q!==null&&this.#a.set(q,Z),j.push(Z),!this.#r||!this.#U(Z))continue;const W=this.#Y(Z);this.#r.insert(W,Z),W<=this.#p&&this.#m++}return this.#k=!0,this.#ce(),j}#ke(E){const j=this.#n[E];let A=!1;if(this.#r){const R=this.#G(E);R>=0&&R<=this.#p&&(A=!0)}else E<=this.#p&&(A=!0);const $=j===a?this.#Ee(E):j,D=this.#s.keyed?this.#s.keyOf($,E):null;D!==null&&this.#a.get(D)===E&&this.#a.delete(D),this.#n[E]=void 0,this.#E&&(this.#E[E]=NaN),this.#l.delete(E);const M=this.#t.store;return M&&B(M.remove)&&M.remove(E),this.#S--,A}#ce(){let E=0,j=0;const A=this.#Ce();E+=A.dropped,j+=A.aboveAnchor;const $=this.#se();E+=$.dropped,j+=$.aboveAnchor,E&&(this.#k=!0,this.#M+=E,this.#T(),this.#m-=j,this.#je("stream:evicted",{evicted:E,total:this.#M,live:this.#S}))}#se(){const E=this.#e.maxRows;if(!Number.isFinite(E)||E<=0||this.#S<=E)return{dropped:0,aboveAnchor:0};const j=Math.max(1,Math.floor(E*(1-w)));let A=0,$=0;for(;this.#S>j&&this.#j<this.#n.length;){const D=this.#j++;this.#n[D]!==void 0&&(this.#ke(D)&&$++,A++)}return{dropped:A,aboveAnchor:$}}#Ce(){const E=this.#ie();if(!E||!this.#E||!this.#le())return{dropped:0,aboveAnchor:0};const j=Date.now()-E;let A=0,$=0,D=1/0;for(let M=this.#j;M<this.#n.length;M++){if(this.#n[M]===void 0)continue;const R=this.#E[M];if(!(Number.isNaN(R)||R===void 0)){if(R>=j){R<D&&(D=R);continue}this.#ke(M)&&$++,A++}}for(this.#R=D,this.#L=!1;this.#j<this.#n.length&&this.#n[this.#j]===void 0;)this.#j++;return{dropped:A,aboveAnchor:$}}#G(E){if(!this.#r)return E;for(let j=0;j<this.#r.length;j++)if(this.#r.at(j)===E)return j;return-1}#T(){this.#o=this.#ge("sort",[]),this.#i=this.#ge("filters",null);const E=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#ie()>0,j=this.#ge("where",null),A=(this.#t.config||{}).hostFilter,$=!!(j&&j.active)||!!(A&&B(A.active)&&A.active());if(!(E||this.#o.length>0||!!this.#i||!!this.#ge("quick","")||$)){this.#r=null;return}this.#r=new r(Math.max(64,this.#n.length+64));for(let M=0;M<this.#n.length;M++)this.#n[M]!==void 0&&this.#U(M)&&this.#r.insert(this.#Y(M),M)}#U(E){const j=this.#Ee(E);if(this.#i&&!this.#ae(this.#i,j))return!1;const A=String(this.#ge("quick","")||"").toLowerCase();if(A&&!this.#dt(j).includes(A))return!1;const $=(this.#t.config||{}).hostFilter;if($&&B($.active)&&$.active()&&!$.passes(this.#Ae(E)))return!1;const D=this.#ge("where",null);if(D&&D.active){const M=this.#Ae(E);if(!D.passes(M.data,M.key))return!1}return!0}#ae(E,j){if(!E)return!0;const A=E;if(Array.isArray(A.conditions))return A.op==="or"?A.conditions.some(M=>this.#ae(M,j)):A.op==="not"?!A.conditions.some(M=>this.#ae(M,j)):A.conditions.every(M=>this.#ae(M,j));const $=E,D=(this.#t.compute||{}).testValue;return B(D)?!!D(this.#De(j,$.col),$,(this.#t.config||{}).locale):(U("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Le(E){if(!this.#r)return-1;if(!this.#o.length)return this.#G(E);let j=0,A=this.#r.length;for(;j<A;){const $=j+A>>>1;this.#de(this.#r.at($),E)<0?j=$+1:A=$}for(let $=j;$<this.#r.length;$++){const D=this.#r.at($);if(D===E)return $;if(this.#de(D,E)>0)break}return this.#G(E)}#Z(E,j){if(!this.#r||!this.#o.length)return;const A=this.#U(E);if(j>=0&&this.#r.at(j)===E)this.#r.removeAt(j),j<=this.#p&&this.#m--;else if(j>=0)return;if(!A)return;const $=this.#Y(E);this.#r.insert($,E),$<=this.#p&&this.#m++}#Y(E){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let j=0,A=this.#r.length;for(;j<A;){const $=j+A>>>1;this.#de(E,this.#r.at($))<0?A=$:j=$+1}return j}#de(E,j){const A=this.#Ee(E),$=this.#Ee(j);for(const D of this.#o){const M=this.#_e(D.col),R=this.#De(A,D.col),k=this.#De($,D.col),q=(M&&M.value&&B(M.value.compare)?M.value.compare:H)(R,k);if(q!==0)return D.dir==="desc"?-q:q}return 0}#v(){this.#b=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const E=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:h;!this.#N&&this.#n.length<E&&(this.#g=f({mode:"memory",rows:this.#n},this.#t),this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#y&&(this.#y.destroy(),this.#y=null)),this.#fe(),this.#je("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:E})}#fe(){this.#d!==null||this.#A||(this.#d=this.#We(()=>{this.#d=null,this.#f++;const E=this.#m;this.#m=0,this.#h=0,this.#je("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#f}),this.#je("model:changed",{reason:"stream",shiftAboveViewport:E,anchor:this.#p}),this.#je("rows:changed",{companion:!0,reason:"stream"})}))}#Oe(){return this.#f===0||this.#h<this.#Ie()?Promise.resolve():(this.#h=0,new Promise(E=>{const j=(this.#t.scheduler||{}).idle;B(j)?j(()=>E()):G(()=>E())}))}#Ie(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:m}#We(E){const j=this.#t.scheduler||{};return B(j.frame)?j.frame(E):_(E)}#Ve(E){const j=this.#t.scheduler||{};B(j.cancel)?j.cancel(E):Q(E)}#Ee(E){const j=this.#n[E];if(j!==void 0&&j!==a)return j;if(j===void 0)return;const A=this.#t.store;return A&&B(A.source)?A.source(E):void 0}#Xe(E,j){const A=this.#t.store;if(!A||!B(A.set))return;const $=this.#me();if(Array.isArray($))for(const D of $){if(!D||!D.id)continue;const M=B(D.read)?D.read:R=>S(R,D.field||D.id);A.set(D.id,E,M(j))}}#Ae(E){let j=this.#l.get(E);return j||(j=this.#s.leaf(this.#Ee(E),E),this.#l.set(E,j)),j}#De(E,j){const A=this.#_e(j);return A&&B(A.getValue)?A.getValue(E):E?.[j]}#dt(E){const j=this.#t.columns,A=j&&B(j.all)?j.all():[],$=[];for(const D of A){const M=B(D.getValue)?D.getValue(E):void 0;M!=null&&M!==""&&$.push(String(M))}return $.join(" ").toLowerCase()}#_e(E){const j=this.#t.columns;return j&&B(j.get)?j.get(E):void 0}#tt(){const E=this.#z;if(this.#z=null,E&&B(E.return))try{E.return()}catch{}}#Q(){return i({context:this.#ge("context",null)})}#ge(E,j){const A=this.#t.state;if(A&&B(A[E])){const $=A[E]();return $??j}return j}#je(E,j){const A=this.#t.emit;B(A)&&A(E,j)}}}),xe("packages/core/src/source/url.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return S}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isObject,F=X.isFunction,_=X.getPath,G=K("packages/core/src/source/abort.js").isAbortError,H=500,U=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),z=Symbol("lattice.url.skip");function S(c,h={}){const a=B(h)?h:{},m=F(a.fetch)?a.fetch:typeof globalThis<"u"&&F(globalThis.fetch)?globalThis.fetch:null,w=a.format==="json"||a.format==="ndjson"?a.format:void 0,v=typeof a.rowsPath=="string"&&a.rowsPath?a.rowsPath:void 0,p=F(a.map)?a.map:void 0,y=B(a.headers)?a.headers:void 0,C=Number.isFinite(a.batchSize)&&a.batchSize>0?Math.floor(a.batchSize):H,T=a.lenient===!0,P=Number.isFinite(a.poll)&&a.poll>0?Math.floor(a.poll):void 0,x=typeof c=="string"&&c.length>0;x||L("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*E(A={}){if(!x)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const $=A&&A.signal;let D;try{D=await m(c,y?{signal:$,headers:y}:{signal:$})}catch(k){throw G(k)?k:new Error(`[lattice] createUrlSource: request to ${c} failed — ${k&&k.message||k}`)}if(!D||!D.ok){const k=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${k} for ${c}`)}const M=O(c,w,D),R=D.body&&F(D.body.getReader)?D.body.getReader():null;try{if(!R){const q=await D.text();(M||d(q,c))==="ndjson"?yield*f(null,null,q,0,D,c,C,T):yield*o(q,c,v,p);return}const k=new TextDecoder("utf-8");if(M==="json"){yield*o(await r(R,k,""),c,v,p);return}if(M==="ndjson"){yield*f(R,k,"",0,D,c,C,T);return}const I=await s(R,k,c);I.format==="json"?yield*o(await r(R,k,I.seed),c,v,p):yield*f(R,k,I.seed,I.bytes,D,c,C,T)}finally{if(R&&F(R.cancel))try{await R.cancel()}catch{}}}const j={mode:"stream",open:E,autoStart:a.autoStart!==!1};return P!==void 0&&(j.poll=P),Number.isFinite(a.maxRows)&&(j.maxRows=a.maxRows),Number.isFinite(a.maxAge)&&(j.maxAge=a.maxAge),(typeof a.ageBy=="string"||F(a.ageBy))&&(j.ageBy=a.ageBy),Number.isFinite(a.coalesceMs)&&(j.coalesceMs=a.coalesceMs),Number.isFinite(a.promoteToMemoryBelow)&&(j.promoteToMemoryBelow=a.promoteToMemoryBelow),j}function O(c,h,a){if(h)return h;const m=b(c);if(m)return m;const w=a&&a.headers&&F(a.headers.get)?a.headers.get("content-type"):null;return u(w)}function b(c){const h=String(c).split(/[?#]/)[0].toLowerCase();if(h.endsWith(".ndjson")||h.endsWith(".jsonl"))return"ndjson";if(h.endsWith(".json"))return"json"}function u(c){if(!c)return;const h=c.split(";")[0].trim().toLowerCase();if(U.has(h))return"ndjson";if(h==="application/json"||h==="text/json"||h.endsWith("+json"))return"json"}function d(c,h){const a=c.replace(/^\s+/,""),m=n(a);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${h} — pass opts.format: 'json' | 'ndjson'.`);return m}async function s(c,h,a){let m="",w=0;for(;;){const{value:p,done:y}=await c.read();if(p&&(w+=p.byteLength,m+=h.decode(p,{stream:!0})),y){m+=h.decode();break}const C=m.replace(/^\s+/,"");if(C){if(C[0]==="[")return{format:"json",seed:m,bytes:w};if(C[0]!=="{"||m.indexOf(`
8
8
  `)!==-1)break}}const v=n(m.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${a} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:m,bytes:w}}function n(c){if(!c||c[0]==="[")return"json";if(c[0]!=="{")return"error";const h=c.indexOf(`
9
9
  `);if(h===-1)return"json";let a=c.slice(0,h);return a.endsWith("\r")&&(a=a.slice(0,-1)),t(a)?"ndjson":"json"}function t(c){try{return JSON.parse(c),!0}catch{return!1}}async function r(c,h,a){let m=a;for(;;){const{value:w,done:v}=await c.read();if(w&&(m+=h.decode(w,{stream:!0})),v)break}return m+=h.decode(),m}function*o(c,h,a,m){let w;try{w=JSON.parse(c)}catch(p){throw new Error(`[lattice] createUrlSource: ${h} is not valid JSON — ${p.message}`)}let v=a!==void 0?_(w,a):w;if(m&&(v=m(v)),!Array.isArray(v)){const p=a!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${h} did not resolve to an array${p}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*f(c,h,a,m,w,v,p,y){const C=g(w);let T=a||"",P=m||0,x=0,E=0,j=[];function*A(){let D;for(;(D=T.indexOf(`
@@ -54,6 +54,6 @@ ${ee}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
54
54
  `,w),T=a.slice(y,C),P=T.split(`
55
55
  `);let x=0;const E=P.map(j=>{if(!c)return x+=v.length,v+j;if(j.startsWith(v))return x-=v.length,j.slice(v.length);const A=j.replace(/^[ \t]/,"");return x-=j.length-A.length,A}).join(`
56
56
  `);return E===T?!1:(h.value=a.slice(0,y)+E+a.slice(C),this.#r(Math.max(y,m+(c?-v.length:v.length)),Math.max(y,w+x)),this.revalidate(),!0)}#r(c,h){const a=this.input;a&&(a.selectionStart=c,a.selectionEnd=h===void 0?c:h,G(a.setSelectionRange)&&a.setSelectionRange(a.selectionStart,a.selectionEnd))}format(c){const h=this.input;if(!h||this.language!=="json")return!1;const a=s(h.value);if(!a.ok)return this.revalidate(),!1;if(a.value===null&&h.value.trim()==="")return!1;try{const m=JSON.stringify(a.value,null,c===void 0?this.indent:c);return m===void 0?!1:(h.value=m,this.#r(m.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const c=this.input?this.input.value:"",h=o(c,this.language);this.lastResult=h;const a=this.errorNode;return a&&(a.textContent=h.ok?"":f(h),a.classList.toggle(S.errorOn,!h.ok)),this.input&&(h.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),h.ok||!a?this.input.removeAttribute("aria-errormessage"):(a.id||(a.id=H("lat-err")),this.input.setAttribute("aria-errormessage",a.id))),h}text(){return this.input?this.input.value:""}readValue(){const c=this.text();if(c.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return c;const a=s(c);return a.ok?a.value:c}checkValue(c){if(this.props.allowInvalid===!0)return!0;const h=this.revalidate();return h.ok?!0:f(h)}toClipboard(){return this.text()}fromClipboard(c){const h=c==null?"":String(c);return this.input&&(this.input.value=h),this.revalidate(),h.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:h}:{ok:!0,value:z(h)}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const i=l}),xe("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,G=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/unit.js"),U=H.parseUnit,z=H.formatUnit,S=H.findUnit;function O(d,s){return z(d,s)}class b extends L{input=null;hint=null;opts=null;#e=[];buildOptions(){const s=this.props,n=this.params.column&&this.params.column.dataType||null,t=n&&n.unitConfig||{};return{system:s.system||t.system||"data",unit:s.unit??t.unit,binary:s.binary===!0||s.binary===void 0&&t.binary===!0,display:s.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const s=this.props;this.opts=this.buildOptions();const n=this.symbol(),t=`${this.id}-unit`,r=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:s.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?t:null}});r.value=O(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const o=typeof s.step=="number"?s.step:0;return o>0&&this.#e.push(_(r,"keydown",f=>{f.key==="ArrowUp"?(G(f.preventDefault)&&f.preventDefault(),this.nudge(o)):f.key==="ArrowDown"&&(G(f.preventDefault)&&f.preventDefault(),this.nudge(-o))})),this.hint=F(this.doc,"span",{class:`${B.editor}__suffix`,text:n,attrs:{id:t,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${B.editor}__unit`,children:[r,this.hint]})}symbol(){const s=S(this.opts.system,this.opts.unit);return s?s.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const s=this.input;s&&!this.params.key&&this.props.selectOnFocus!==!1&&G(s.select)&&s.select()}nudge(s){const n=U(this.input?this.input.value:"",this.opts);let t=(n??0)+s;const{min:r,max:o}=this.props;typeof r=="number"&&t<r&&(t=r),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=O(t,this.opts))}readValue(){const s=this.input?this.input.value:"";if(String(s).trim()==="")return null;const n=U(s,this.opts);if(n===null)return NaN;if(this.mode()!=="clamp")return n;const{min:t,max:r}=this.props;let o=n;return typeof t=="number"&&o<t&&(o=t),typeof r=="number"&&o>r&&(o=r),o}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(s){if(s===null)return!0;if(typeof s!="number"||Number.isNaN(s)){const n=this.symbol();return n?`Enter a value such as 10 ${n}`:"Enter a value"}if(this.mode()==="reject"){const{min:n,max:t}=this.props;if(typeof n=="number"&&s<n)return`Must be ${this.describe(n)} or more`;if(typeof t=="number"&&s>t)return`Must be ${this.describe(t)} or less`}return!0}describe(s){return z(s,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return z(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(s){const n=s==null?"":String(s);if(n.trim()==="")return{ok:!0,value:null};const t=U(n,this.opts),r=t===null?NaN:t,o=this.checkValue(r);return o!==!0?{ok:!1,message:o}:{ok:!0,value:r}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const u=b}),xe("packages/dom/src/editors/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,Q=K("packages/core/src/internal/util.js"),G=Q.isFunction,H=Q.uid,U=K("packages/core/src/columns/types/radix.js"),z=U.compileRadixFormat,S=U.compileRadixParse,O=U.normaliseRadixOptions,b=U.radixRange,u=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),d=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),s=new Map;function n(f){const l=f||"";let i=s.get(l);if(i)return i;try{i=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0})}catch{i={format:g=>String(g)}}return s.set(l,i),i}function t(f,l){const i=l||{},g={};if(f){for(const h of d)f[h]!==void 0&&(g[h]=f[h]);const c=b(f.bitWidth??null,f.signed!==!1);typeof f.min=="number"&&f.min>c.min&&(g.min=f.min),typeof f.max=="number"&&f.max<c.max&&(g.max=f.max)}for(const c of d)i[c]!==void 0&&(g[c]=i[c]);return typeof i.min=="number"&&(g.min=i.min),typeof i.max=="number"&&(g.max=i.max),O(g)}class r extends L{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const l=this.params.column&&this.params.column.dataType;this.options=t(l&&l.radix||null,this.props),this.format=z(this.options),this.parse=S(this.options);const i=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});i.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(i.value=this.params.key),this.input=i;const g=F(this.doc,"span",{class:u.hint,attrs:{"aria-live":"polite"}});this.hint=g,this.#e.push(_(i,"input",()=>this.refresh())),this.#e.push(_(i,"keydown",h=>this.#n(h)));const c=F(this.doc,"div",{class:u.root,children:[i,g]});return this.refresh(),c}focusTarget(){return this.input}attached(){super.attached();const l=this.input;l&&!this.params.key&&this.props.selectOnFocus!==!1&&G(l.select)&&l.select()}#t(l){return l.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(l)}#n(l){const i=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;l.key==="ArrowUp"?(G(l.preventDefault)&&l.preventDefault(),this.nudge(i)):l.key==="ArrowDown"&&(G(l.preventDefault)&&l.preventDefault(),this.nudge(-i))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(l){const{min:i,max:g}=this.options;return l<i?i:l>g?g:l}evaluate(){const l=this.input?String(this.input.value):"";if(l.trim()==="")return{value:null,message:null};const i=this.parse(l);return i.ok?{value:this.mode()==="clamp"?this.clamp(i.value):i.value,message:null}:this.mode()==="clamp"&&typeof i.value=="number"&&(i.reason==="range"||i.reason==="negative")?{value:this.clamp(i.value),message:null}:{value:NaN,message:this.messageFor(i.reason)}}messageFor(l){const i=this.options;return l==="negative"?`This column holds an unsigned ${i.bitWidth}-bit pattern; enter ${this.format(0)} or more`:l==="range"?`Must be between ${this.format(i.min)} and ${this.format(i.max)}`:`Enter a ${i.name} value, e.g. ${this.format(i.radix===2?5:26)}`}refresh(){const{value:l,message:i}=this.evaluate();if(this.input&&this.input.classList&&(i?this.input.classList.add(B.invalid):this.input.classList.remove(B.invalid),this.input.setAttribute("aria-invalid",i?"true":"false"),i&&this.hint?(this.hint.id||(this.hint.id=H("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(i){this.hint.textContent=i,this.hint.classList&&this.hint.classList.add(u.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(u.hintInvalid),this.hint.textContent=l===null?"":`= ${n(this.params.locale).format(l)}`}}nudge(l){if(!this.input)return;const i=this.parse(this.input.value);let g;typeof i.value=="number"?g=i.value:typeof this.params.value=="number"?g=this.params.value:g=0,this.input.value=this.format(this.clamp(g+l)),this.refresh()}readValue(){return this.evaluate().value}checkValue(l){return l===null?!0:typeof l!="number"||Number.isNaN(l)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&l<0?this.messageFor("negative"):this.mode()==="reject"&&(l<this.options.min||l>this.options.max)?this.messageFor("range"):!0}toClipboard(){const l=this.readValue();return l===null||Number.isNaN(l)?this.input?String(this.input.value):"":this.format(l)}fromClipboard(l){const i=l==null?"":String(l);if(i.trim()==="")return{ok:!0,value:null};const g=this.parse(i);let c;if(g.ok)c=g.value;else if(this.mode()==="clamp"&&typeof g.value=="number"&&(g.reason==="range"||g.reason==="negative"))c=this.clamp(g.value);else return{ok:!1,message:this.messageFor(g.reason)};const h=this.checkValue(c);return h!==!0?{ok:!1,message:h}:{ok:!0,value:c}}destroy(){for(const l of this.#e)l();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const o=r}),xe("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,Q=X.keyOf,G=X.normaliseLookup,H=X.documentFor,U=X.lookupFor,S=K("packages/dom/src/editors/select.js").SelectEditor,b=K("packages/core/src/internal/util.js").isFunction,d=K("packages/dom/src/cell/icons.js").createIcon,s=6;class n extends L{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(f){const l=f||{},i=t(l),g=U(l,i,{colId:l.column&&(l.column.id||l.column.field)}),c=Number(i.max??s),h=g.options().length;if(Number.isFinite(c)&&h>c){const a=new S;a.init(l),this.#e=a,this.params=l,this.doc=H(l),this.props=i,this.lookup=g,this.popup=a.popup;return}super.init(l),(!this.lookup||!this.lookup.options().length)&&(this.lookup=g)}usesFallback(){return this.#e!==null}build(){const f=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const l=F(f,"div",{class:`${B.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let i=0;i<this.options.length;i++)l.appendChild(this.buildSegment(this.options[i],i));return this.props.allowClear===!0&&l.appendChild(this.buildClear()),this.#t.push(_(l,"keydown",i=>this.onKeyDown(i))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),l}buildSegment(f,l){const i=this.doc,g=F(i,"button",{class:`${B.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":l,"data-variant":f.variant??null,"aria-disabled":f.disabled===!0?"true":null}});return f.icon&&g.appendChild(d(i,f.icon,{className:B.icon})),g.appendChild(F(i,"span",{class:`${B.editor}__segment-label`,text:f.label})),this.#t.push(_(g,"mousedown",c=>{c&&b(c.preventDefault)&&c.preventDefault(),f.disabled!==!0&&(this.focused=l,this.select(l,{commit:!0}))})),this.segments.push(g),g}buildClear(){const f=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(_(f,"mousedown",l=>{l&&b(l.preventDefault)&&l.preventDefault(),this.clearSelection()})),f}indexOf(f){if(f==null)return-1;const l=Q(f);for(let i=0;i<this.options.length;i++)if(Q(this.options[i].id)===l)return i;return-1}paint(){for(let f=0;f<this.segments.length;f++){const l=f===this.indexOf(this.selected),i=this.segments[f];i.setAttribute("aria-checked",l?"true":"false"),i.setAttribute("tabindex",f===this.focused?"0":"-1"),i.classList.toggle(`${B.editor}__segment--active`,l),i.classList.toggle(`${B.editor}__segment--disabled`,this.options[f].disabled===!0)}}select(f,l){const i=this.options[f];!i||i.disabled===!0||(this.selected=i.id,this.paint(),l&&l.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(f){const l=this.segments.length;if(!l)return;let i=this.focused;for(let g=0;g<l;g++)if(i=(i+f+l)%l,this.options[i].disabled!==!0){this.focusAt(i);return}}focusAt(f){if(f<0||f>=this.segments.length)return;this.focused=f,this.paint();const l=this.segments[f];l&&b(l.focus)&&l.focus()}edgeIndex(f){const l=this.options.length;for(let i=0;i<l;i++){const g=f===1?i:l-1-i;if(this.options[g].disabled!==!0)return g}return-1}onKeyDown(f){const l=()=>{b(f.preventDefault)&&f.preventDefault()};switch(f.key){case"ArrowRight":case"ArrowDown":l(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":l(),this.moveFocus(-1);break;case"Home":l(),this.focusAt(this.edgeIndex(1));break;case"End":l(),this.focusAt(this.edgeIndex(-1));break;case"Enter":l(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":l(),this.select(this.focused);break;case"Escape":l(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(f)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(f)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const f=this.indexOf(this.selected);return this.segments[f>=0?f:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const f=this.lookup.ready();!f||!b(f.then)||f.then(()=>{if(!super.element()||this.options.length)return;const l=super.element();this.options=this.lookup.options();for(let i=0;i<this.options.length;i++)l.appendChild(this.buildSegment(this.options[i],i));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(f){return this.#e?this.#e.validate(f):super.validate(f)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(f){return this.#e?this.#e.fromClipboard(f):super.fromClipboard(f)}destroy(){for(const f of this.#t)f();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(o){return{...o.column&&o.column.edit&&o.column.edit.props||{},...o.props||{}}}const r=n}),xe("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,G=K("packages/dom/src/cell/icons.js").createIcon,H=K("packages/dom/src/cell/renderers/rating.js"),U=H.ratingFills,z=H.fillState,S=H.ratingText,O=H.clampRating,b=H.DEFAULT_RATING_ICON,u=H.DEFAULT_RATING_MAX,s=K("packages/core/src/internal/util.js").isFunction;class n extends L{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const f=Math.floor(Number(this.props.max??u));return Number.isFinite(f)&&f>0?f:u}step(){return this.props.allowHalf===!0?.5:1}build(){const f=this.doc,l=this.max();this.rating=t(this.params.value,l,this.props.allowHalf===!0);const i=F(f,"div",{class:`${B.editor}__rating`}),g=F(f,"div",{class:`${B.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(l),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let h=0;h<l;h++)g.appendChild(this.buildItem(h));i.appendChild(g),this.slider=g;const c=F(f,"span",{class:`${B.editor}__rating-value`});return i.appendChild(c),this.readout=c,this.props.allowClear===!0&&i.appendChild(this.buildClear()),this.#e.push(_(g,"keydown",h=>this.onKeyDown(h))),this.props.hoverPreview!==!1&&this.#e.push(_(g,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),l)),this.paint(),i}buildItem(f){const l=this.doc,i=String(this.props.icon??b),g=F(l,"span",{class:`${B.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[G(l,i,{className:B.icon})]}),c=F(l,"span",{class:`${B.editor}__rating-item`,attrs:{"data-index":f,"data-icon":i,"aria-hidden":"true"},children:[G(l,i,{className:B.icon}),g]});return this.fills.push(g),this.#e.push(_(c,"mousedown",h=>{h&&s(h.preventDefault)&&h.preventDefault(),this.setRating(this.ratingAt(f,h),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(c,"mousemove",h=>{const a=this.ratingAt(f,h);a!==this.preview&&(this.preview=a,this.paint())})),this.items.push(c),c}buildClear(){const f=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(_(f,"mousedown",l=>{l&&s(l.preventDefault)&&l.preventDefault(),this.setRating(null)})),f}ratingAt(f,l){if(this.props.allowHalf!==!0)return f+1;const i=this.items[f],g=i&&Number(i.offsetWidth),c=l&&Number(l.offsetX);return!Number.isFinite(g)||g<=0||!Number.isFinite(c)?f+1:c*2<g?f+.5:f+1}focusTarget(){return this.slider}setRating(f,l){this.rating=f===null?null:O(f,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),l&&l.commit&&this.commit()}nudge(f){const l=this.rating===null?0:this.rating;this.setRating(l+f)}paint(){const f=this.max(),l=this.props.allowHalf===!0,i=this.preview===null?this.rating:this.preview,g=U(i===null?0:i,f,{allowHalf:l});for(let a=0;a<this.items.length;a++){const m=z(g[a]);this.items[a].setAttribute("data-fill",m),this.items[a].classList.toggle(`${B.editor}__rating-item--filled`,m!=="empty"),this.fills[a]&&this.fills[a].style.setProperty("--lat-rating-fill",`${(g[a]*100).toFixed(2)}%`)}const c=i===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:S(i),max:f}),h=this.slider;h&&(h.setAttribute("aria-valuenow",i===null?"0":String(i)),h.setAttribute("aria-valuetext",c),h.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=c)}onKeyDown(f){const l=()=>{s(f.preventDefault)&&f.preventDefault()},i=this.step();if(/^[0-9]$/.test(f.key)){l(),this.setRating(Math.min(Number(f.key),this.max()));return}switch(f.key){case"ArrowRight":case"ArrowUp":l(),this.nudge(i);break;case"ArrowLeft":case"ArrowDown":l(),this.nudge(-i);break;case"Home":l(),this.setRating(0);break;case"End":l(),this.setRating(this.max());break;case"Enter":l(),this.commit();break;case"Escape":l(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(f){if(f==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof f!="number"||!Number.isFinite(f))return"Enter a rating";const l=this.max();return f<0?"Must be 0 or more":f>l?`Must be ${l} or less`:this.props.allowHalf!==!0&&!Number.isInteger(f)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":S(this.rating)}fromClipboard(f){const l=String(f??"").trim();if(l==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const i=Number(l);if(!Number.isFinite(i))return{ok:!1,message:`"${l}" is not a rating`};const g=this.checkValue(i);return g!==!0?{ok:!1,message:g}:{ok:!0,value:i}}destroy(){for(const f of this.#e)f();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(o,f,l){if(o==null||o==="")return null;const i=Number(o);return Number.isFinite(i)?O(i,f,l,!1):null}const r=n}),xe("packages/dom/src/editors/slider.js",function(e,K){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,Q=K("packages/dom/src/editors/number.js"),G=Q.parseNumberText,H=Q.presentNumber,z=K("packages/core/src/internal/util.js").isFunction,S=0,O=100;class b extends L{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const r=Number(this.props.min??S);return Number.isFinite(r)?r:S}max(){const r=Number(this.props.max??O);return Number.isFinite(r)?r:O}step(){const r=Number(this.props.step??1);return Number.isFinite(r)&&r>0?r:1}build(){const r=this.doc,o=this.min(),f=this.max(),l=this.step(),i=s(this.props.marks);this.marks=i,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const g=F(r,"div",{class:`${B.editor}__slider`});this.root=g;const c=F(r,"input",{class:`${B.editor}__slider-input`,attrs:{type:"range",min:String(o),max:String(f),step:String(l),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:i.length?`${this.id}-marks`:null}});if(this.range=c,g.appendChild(c),i.length){const a=F(r,"datalist",{attrs:{id:`${this.id}-marks`}}),m=F(r,"div",{class:`${B.editor}__slider-marks`});for(const w of i){a.appendChild(F(r,"option",{attrs:{value:String(w.value),label:w.label}}));const v=F(r,"span",{class:`${B.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});v.style&&z(v.style.setProperty)&&v.style.setProperty("--lat-slider-mark",`${(u(w.value,o,f)*100).toFixed(2)}%`),m.appendChild(v)}g.appendChild(a),g.appendChild(m)}const h=F(r,"input",{class:`${B.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=h,g.appendChild(h),this.props.showValue!==!1){const a=F(r,"span",{class:`${B.editor}__slider-value`});g.appendChild(a),this.readout=a}return this.#e.push(_(c,"input",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"change",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"keydown",a=>this.onKeyDown(a))),this.#e.push(_(h,"input",()=>this.onFieldInput())),this.#e.push(_(h,"change",()=>this.paint())),this.#e.push(_(h,"keydown",a=>this.onKeyDown(a))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(h.value=this.params.key,this.onFieldInput()),this.paint(),g}focusTarget(){return this.field}attached(){super.attached();const r=this.field;r&&!this.params.key&&this.props.selectOnFocus!==!1&&z(r.select)&&r.select()}snap(r){if(!Number.isFinite(r))return this.min();const o=this.min(),f=this.max(),l=this.step(),i=Math.min(Math.max(r,o),f),g=o+Math.round((i-o)/l)*l,c=d(l),h=c>0?Number(g.toFixed(c)):Math.round(g);return Math.min(Math.max(h,o),f)}setAmount(r,o){this.amount=r===null?null:this.snap(r),this.paint(o)}onFieldInput(){const r=this.field?String(this.field.value):"";if(r.trim()===""){this.amount=null,this.paint("field");return}const o=G(r,this.params.locale);if(o===null||Number.isNaN(o)){this.paint("field");return}this.setAmount(o,"field")}paint(r){const o=this.min(),f=this.max(),l=this.amount,i=l===null?o:l;this.range&&r!=="range"&&(this.range.value=String(i)),this.field&&r!=="field"&&(this.field.value=l===null?"":H(l,this.props));const g=this.root;g&&g.style&&z(g.style.setProperty)&&g.style.setProperty("--lat-slider-pos",`${(u(i,o,f)*100).toFixed(2)}%`),g&&g.setAttribute&&g.setAttribute("data-empty",l===null?"true":"false");const c=this.labelFor(l);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",c),this.readout&&(this.readout.textContent=c)}labelFor(r){if(r===null)return String(this.props.emptyLabel??"");const o=this.marks.find(l=>l.value===r),f=H(r,this.props);return o&&o.label!==f?`${f} (${o.label})`:f}onKeyDown(r){if(r.key==="Escape"){z(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){z(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.field?String(this.field.value):"";if(r.trim()==="")return null;const o=G(r,this.params.locale);return o===null||Number.isNaN(o)?NaN:this.snap(o)}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof r!="number"||Number.isNaN(r)?"Enter a number":r<this.min()?`Must be ${this.min()} or more`:r>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(r){const o=String(r??"").trim();if(o==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const f=G(o,this.params.locale);if(f===null||Number.isNaN(f))return{ok:!1,message:"Enter a number"};const l=this.snap(f),i=this.checkValue(l);return i!==!0?{ok:!1,message:i}:{ok:!0,value:l}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function u(t,r,o){const f=o-r;return!Number.isFinite(f)||f===0?0:Math.min(1,Math.max(0,(Number(t)-r)/f))}function d(t){if(!Number.isFinite(t))return 0;const r=String(t),o=r.indexOf("e");if(o>=0){const l=r.slice(0,o),i=l.indexOf("."),g=i<0?0:l.length-i-1;return Math.min(15,Math.max(0,g-Number(r.slice(o+1))))}const f=r.indexOf(".");return f<0?0:Math.min(15,r.length-f-1)}function s(t){if(!t)return[];const r=[];if(Array.isArray(t)){for(const o of t){if(o&&typeof o=="object"){const l=Number(o.value);Number.isFinite(l)&&r.push({value:l,label:String(o.label??l)});continue}const f=Number(o);Number.isFinite(f)&&r.push({value:f,label:String(f)})}return r}if(typeof t=="object")for(const[o,f]of Object.entries(t)){const l=Number(o);Number.isFinite(l)&&r.push({value:l,label:String(f)})}return r}const n=b}),xe("packages/dom/src/editors/colour.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,Q=K("packages/dom/src/cell/renderers/colour.js"),G=Q.normaliseColour,H=Q.parseColour,z=K("packages/core/src/internal/util.js").isFunction,S=Object.freeze(["neutral","info","success","warning","danger","accent"]),O=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function b(r){if(r==null)return null;if(typeof r=="object"){const l=r,i=b(l.token??l.value??l.colour??l.color);return i?{...i,label:l.label==null?i.label:String(l.label)}:null}const o=String(r).trim();if(o==="")return null;const f=G(o);return f?{token:null,hex:f,label:f}:Object.hasOwn(O,o)?{token:o,hex:O[o],label:o}:null}function u(r,o){const f=r&&r.ownerDocument,l=f&&f.defaultView;if(!l||!z(l.getComputedStyle))return null;try{const i=l.getComputedStyle(r);return!i||!z(i.getPropertyValue)?null:G(String(i.getPropertyValue(`--lattice-variant-${o}-solid`)).trim())}catch{return null}}class d extends L{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const o=this.doc;this.swatches=s(this.props.swatches);const f=F(o,"div",{class:`${B.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=F(o,"span",{class:`${B.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),f.appendChild(this.preview),this.swatches.length){const i=F(o,"div",{class:`${B.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let g=0;g<this.swatches.length;g++)i.appendChild(this.buildSwatch(this.swatches[g],g));f.appendChild(i)}this.native=F(o,"input",{class:`${B.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),f.appendChild(this.native),this.hex=F(o,"input",{class:`${B.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),f.appendChild(this.hex),this.props.allowClear===!0&&f.appendChild(this.buildClear()),this.#e.push(_(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.hex,"input",()=>this.paint())),this.#e.push(_(this.hex,"change",()=>this.paint())),this.#e.push(_(this.hex,"keydown",i=>this.onKeyDown(i))),this.#e.push(_(f,"keydown",i=>this.onKeyDown(i)));const l=G(this.params.value,{alpha:this.alpha()});return this.hex.value=l===null?this.params.value==null?"":String(this.params.value):l,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),f}buildSwatch(o,f){const l=F(this.doc,"button",{class:`${B.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":o.label,"data-index":f,"data-variant":o.token}});return o.token||n(l,o.hex),this.#e.push(_(l,"mousedown",i=>{i&&z(i.preventDefault)&&i.preventDefault(),this.setColour(this.swatches[f].hex)})),this.buttons.push(l),l}buildClear(){const o=F(this.doc,"button",{class:`${B.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(o,"mousedown",f=>{f&&z(f.preventDefault)&&f.preventDefault(),this.setColour(null)})),o}focusTarget(){return this.hex}attached(){super.attached();for(let o=0;o<this.swatches.length;o++){const f=this.swatches[o];if(!f.token)continue;const l=u(this.buttons[o]||this.element(),f.token);l&&(f.hex=l)}this.paint()}setColour(o){const f=o===null?null:G(o,{alpha:this.alpha()});this.hex&&(this.hex.value=f===null?"":f),this.paint()}current(){const o=this.hex?String(this.hex.value).trim():"";return o===""?null:G(o,{alpha:this.alpha()})}paint(){const o=this.current(),f=o===null?null:o.slice(0,7);n(this.preview,f),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",o===null?"true":"false"),this.native&&(this.native.value=f===null?"#000000":f);for(let l=0;l<this.buttons.length;l++){const i=o!==null&&this.swatches[l].hex.toLowerCase()===o.toLowerCase();this.buttons[l].setAttribute("aria-checked",i?"true":"false"),this.buttons[l].classList.toggle(`${B.editor}__colour-swatch--selected`,i),this.swatches[l].token||n(this.buttons[l],this.swatches[l].hex)}}onKeyDown(o){if(o.key==="Escape"){z(o.preventDefault)&&o.preventDefault(),this.cancel();return}if(o.key==="Enter"){z(o.preventDefault)&&o.preventDefault(),this.commit();return}o.key==="Tab"&&this.commit()}readValue(){const o=this.hex?String(this.hex.value).trim():"";if(o==="")return null;const f=G(o,{alpha:this.alpha()});return f===null?o:f}checkValue(o){if(o==null||o==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const f=H(o);return f?!this.alpha()&&f.a<1?"This column does not accept transparency":!0:`"${String(o)}" is not a colour`}toClipboard(){const o=this.current();return o===null?"":o}fromClipboard(o){const f=String(o??"").trim();if(f==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const l=G(f,{alpha:this.alpha()});if(l===null)return{ok:!1,message:`"${f}" is not a colour`};const i=this.checkValue(l);return i!==!0?{ok:!1,message:i}:{ok:!0,value:l}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function s(r){const o=Array.isArray(r)&&r.length?r:r===!1?[]:S,f=[];for(const l of o){const i=b(l);i&&f.push(i)}return f}function n(r,o){const f=r&&r.style;if(f){if(o===null){z(f.removeProperty)&&f.removeProperty("--lat-swatch");return}z(f.setProperty)&&f.setProperty("--lat-swatch",o)}}const t=d}),xe("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const L=K("packages/dom/src/editors/select.js").SelectEditorBase,F=K("packages/dom/src/cell/icons.js").createIcon,_=K("packages/dom/src/editors/common.js"),Q=_.CLS,G=_.el,H=_.on,U=_.clear,z=_.keyOf,S=_.rawOptions,O=_.lookupKey,b=K("packages/core/src/internal/util.js"),u=b.isFunction,d=b.isObject,s="\0";class n extends L{static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const o=super.build();return o.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),o}initSelection(){this.rebuild(),this.selected=this.params.value??null;const o=this.nodeById(this.selected);if(o)for(let f=o.parent;f;f=f.parent)this.expanded.add(f.key)}rebuild(){const o=S(this.params,this.props),f=this.props.keys||{},l=f.value||O(this.params,"valueKey")||"id",i=f.label||O(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const g of o){if(!d(g)){this.addNode(null,String(g??""),g,null);continue}Array.isArray(g.path)&&g.path.length?this.addByPath(g,l,i):this.addByChildren(g,null,l,i)}if(this.props.defaultExpanded===!0)for(const g of this.nodes.keys())this.expanded.add(g)}addNode(o,f,l,i){const g=o?`${o.key}${s}${f}`:f;let c=this.nodes.get(g);return c?c.id===void 0&&l!==void 0&&(c.id=l):(c={id:l,label:f,key:g,parent:o,children:[],depth:o?o.depth+1:0,disabled:!1},this.nodes.set(g,c),(o?o.children:this.roots).push(c)),i&&(i.disabled===!0&&(c.disabled=!0),i.icon!==void 0&&(c.icon=i.icon),i.variant!==void 0&&(c.variant=i.variant)),c}addByPath(o,f,l){const i=o.path;let g=null;for(let c=0;c<i.length;c++){const h=c===i.length-1,a=String(i[c]),m=h&&o[l]!=null?String(o[l]):a,w=this.addNode(g,a,h?o[f]:void 0,h?o:null);h&&(w.label=m),g=w}}addByChildren(o,f,l,i){const g=o[l],c=o[i]!=null?String(o[i]):String(g??""),h=this.addNode(f,c,g,o),a=Array.isArray(o.children)?o.children:[];for(const m of a)d(m)?this.addByChildren(m,h,l,i):this.addNode(h,String(m??""),m,null)}nodeById(o){if(o==null)return;const f=z(o);for(const l of this.nodes.values())if(l.id!==void 0&&z(l.id)===f)return l}filterOptions(o){const f=String(o||"").trim().toLowerCase(),l=f!=="";this.matched=l?this.computeMatches(f):new Set;const i=[],g=c=>{for(const h of c)l&&!this.matched.has(h.key)||(i.push(h),h.children.length&&(l||this.expanded.has(h.key))&&g(h.children))};return g(this.roots),i}computeMatches(o){const f=new Set,l=i=>{let g=i.label.toLowerCase().includes(o);for(const c of i.children)l(c)&&(g=!0);return g&&f.add(i.key),g};for(const i of this.roots)l(i);return f}repaint(o){if(this.refreshOptions(),!o||!this.list)return;const f=this.visible.findIndex(l=>l.key===o);f>=0&&this.list.setActive(f)}isBranch(o){return!!o&&o.children.length>0}isSelectable(o){return!o||o.disabled||o.id===void 0||o.id===null?!1:!(this.leavesOnly&&this.isBranch(o))}setExpanded(o,f){this.isBranch(o)&&(f?this.expanded.add(o.key):this.expanded.delete(o.key),this.repaint(o.key))}choose(o){if(o){if(!this.isSelectable(o)){this.isBranch(o)&&this.setExpanded(o,!this.expanded.has(o.key));return}this.selected=o.id,this.input&&(this.input.value=""),this.query="",this.repaint(o.key),this.paintDisplay(),this.commit()}}isSelected(o){return this.selected!=null&&o&&o.id!==void 0&&z(o.id)===z(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(o){if(o==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const f=this.nodeById(o);return f&&this.isSelectable(f)?!0:f?`"${f.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(o)}" is not a valid option`}renderOption(o,f,l){U(f),f.setAttribute("role","treeitem"),f.setAttribute("aria-level",String(o.depth+1)),f.setAttribute("data-depth",String(o.depth));const i=G(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<o.depth;w++)i.appendChild(G(this.doc,"span",{class:"lat-tree__guide"}));f.appendChild(i);const g=this.isBranch(o),c=g&&(this.expanded.has(o.key)||this.query.trim()!==""),h=g?c?"chevronDown":"chevronRight":"blank",a=G(this.doc,"span",{class:g?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[F(this.doc,h,{className:Q.icon})],attrs:{"data-icon":g?h:null,"aria-hidden":"true"}});g&&H(a,"mousedown",w=>{u(w.preventDefault)&&w.preventDefault(),u(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(o,!this.expanded.has(o.key))}),f.appendChild(a),o.icon&&f.appendChild(F(this.doc,o.icon,{className:Q.icon})),f.appendChild(G(this.doc,"span",{class:`${Q.option}__label`,text:o.label})),o.variant?f.setAttribute("data-variant",o.variant):f.removeAttribute("data-variant"),g?f.setAttribute("aria-expanded",c?"true":"false"):f.removeAttribute("aria-expanded");const m=this.isSelected(o);f.classList.toggle(Q.optionSelected,m),f.classList.toggle(Q.optionDisabled,!this.isSelectable(o)),f.classList.toggle("lat-tree__row--branch",g),f.setAttribute("aria-selected",m?"true":"false"),this.isSelectable(o)?f.removeAttribute("aria-disabled"):f.setAttribute("aria-disabled","true")}paintDisplay(){const o=this.display;if(!o)return;if(U(o),this.selected==null){o.removeAttribute("data-variant");return}const f=this.nodeById(this.selected);if(!f){o.appendChild(G(this.doc,"span",{text:String(this.selected)}));return}f.icon&&o.appendChild(F(this.doc,f.icon,{className:Q.icon})),o.appendChild(G(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(f)})),f.variant?o.setAttribute("data-variant",f.variant):o.removeAttribute("data-variant")}pathLabel(o){const f=[];for(let l=o;l;l=l.parent)f.unshift(l.label);return f.join(String(this.props.pathSeparator??" / "))}onKeyDown(o){const f=this.list,l=f&&f.active>=0?this.visible[f.active]:null;switch(o.key){case"ArrowRight":{if(u(o.preventDefault)&&o.preventDefault(),!l)return;this.isBranch(l)&&!this.expanded.has(l.key)?this.setExpanded(l,!0):this.isBranch(l)&&f&&f.setActive(Math.min(this.visible.length-1,f.active+1));return}case"ArrowLeft":{if(u(o.preventDefault)&&o.preventDefault(),!l)return;this.isBranch(l)&&this.expanded.has(l.key)?this.setExpanded(l,!1):l.parent&&this.focusNode(l.parent.key);return}case"Home":u(o.preventDefault)&&o.preventDefault(),f&&this.visible.length&&f.setActive(0);return;case"End":u(o.preventDefault)&&o.preventDefault(),f&&this.visible.length&&f.setActive(this.visible.length-1);return;default:super.onKeyDown(o)}}focusNode(o){if(!this.list)return;const f=this.visible.findIndex(l=>l.key===o);f>=0&&this.list.setActive(f)}acceptHighlight(o){const f=this.list,l=f&&f.active>=0?this.visible[f.active]:null;if(!l){o&&o.commit&&this.commit();return}if(this.isSelectable(l)){this.choose(l);return}this.isBranch(l)?this.setExpanded(l,!this.expanded.has(l.key)):o&&o.commit&&this.commit()}moveHighlight(o){const f=this.list;if(!f)return;let l=f.active;for(let i=0;i<this.visible.length;i++){if(l+=o,l<0||l>=this.visible.length)return;if(!this.visible[l].disabled){f.setActive(l);return}}}}const t=n}),xe("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const L=K("packages/dom/src/editors/select.js").SelectEditorBase,B=K("packages/dom/src/editors/common.js"),F=B.CLS,_=B.el,Q=B.on,G=B.clear,H=B.keyOf,U=B.debounce,z=B.rawOptions,S=B.optionSource,O=B.lookupSearch,b=B.lookupKey,u=K("packages/core/src/internal/util.js"),d=u.isFunction,s=u.isObject,n=u.getPath,r=K("packages/dom/src/cell/icons.js").createIcon;class o extends L{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const h=super.build();if(h.classList.add("lat-objectpicker"),d(this.props.search)&&!(this.lookup&&this.lookup.search)){const a=Number(this.props.searchDebounce)||200;this.#n=U(m=>this.runRemoteSearch(String(m)),a)}return h}onQuery(h){super.onQuery(h),this.#n&&this.#n(h)}initSelection(){const h=z(this.params,this.props).map(a=>this.toOption(a));(h.length||!this.all.length)&&(this.all=h),this.selected=this.params.value??null}toOption(h){if(!s(h)){const y=h==null?"":String(h);return{id:h,label:y,secondary:"",avatar:"",initials:l(y),disabled:!1,raw:{}}}const a=this.props.valueKey||b(this.params,"valueKey")||"id",m=this.props.labelKey||b(this.params,"labelKey")||"label",w=f(h,this.props.template??m,""),v=f(h,this.props.secondary,""),p=f(h,this.props.avatar,"");return{id:h[a],label:w||String(h[a]??""),secondary:v,avatar:p,initials:l(w||String(h[a]??"")),disabled:h.disabled===!0,icon:h.icon,variant:h.variant,raw:h}}attached(){if(super.attached(),this.#t||this.all.length)return;const h=S(this.params,this.props);d(h)&&(this.#t=!0,Promise.resolve(h()).then(a=>{!this.element()||!Array.isArray(a)||(this.all=a.map(m=>this.toOption(m)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(h){const a=String(h||"").trim().toLowerCase();if(a==="")return this.all;const m=i(this.props.searchFields);return this.all.filter(w=>{if(!m)return w.label.toLowerCase().includes(a)||w.secondary.toLowerCase().includes(a);for(const v of m){const p=d(v)?v(w.raw):n(w.raw,v);if(p!=null&&String(p).toLowerCase().includes(a))return!0}return!1})}async runRemoteSearch(h){const a=O(this.params,this.props);if(!a)return;this.#e&&this.#e.abort();const m=new AbortController;this.#e=m;try{const w=await a(h,m.signal);if(m.signal.aborted||this.#e!==m)return;this.refreshOptions(Array.isArray(w)?w.map(v=>this.toOption(v)):[])}catch(w){if(!m.signal.aborted)throw w}finally{this.#e===m&&(this.#e=null)}}choose(h){!h||h.disabled||(this.selected=h.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(h){return this.selected!=null&&h!=null&&H(h.id)===H(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(h){if(h==null)return;const a=H(h);return this.all.find(m=>H(m.id)===a)}checkValue(h){return h==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(h)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(h)}" is not a valid option`}renderOption(h,a,m){G(a),a.appendChild(this.buildAvatar(h));const w=_(this.doc,"span",{class:"lat-object__text"});w.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:h.label})),h.secondary&&w.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:h.secondary})),a.appendChild(w),h.icon&&a.appendChild(r(this.doc,h.icon,{className:F.icon})),h.variant?a.setAttribute("data-variant",h.variant):a.removeAttribute("data-variant");const v=this.isSelected(h);a.classList.add("lat-object__row"),a.classList.toggle(F.optionSelected,v),a.classList.toggle(F.optionDisabled,h.disabled===!0),a.setAttribute("aria-selected",v?"true":"false"),h.disabled?a.setAttribute("aria-disabled","true"):a.removeAttribute("aria-disabled")}buildAvatar(h){const a=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!h.avatar)return a.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),a.setAttribute("data-fallback","initials"),a;const m=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:h.avatar,alt:"",loading:"lazy",decoding:"async"}});return Q(m,"error",()=>{m.parentNode===a&&(a.removeChild(m),a.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:h.initials})),a.setAttribute("data-fallback","initials"))}),a.appendChild(m),a}paintDisplay(){const h=this.display;if(!h)return;if(G(h),this.selected==null){h.removeAttribute("data-variant");return}const a=this.optionById(this.selected);if(!a){h.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}h.appendChild(this.buildAvatar(a)),h.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:a.label})),a.variant?h.setAttribute("data-variant",a.variant):h.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function f(c,h,a){if(h==null)return a;const m=d(h)?h(c):n(c,String(h));return m==null?a:String(m)}function l(c){const h=String(c||"").trim().split(/\s+/).filter(w=>w!=="");if(!h.length)return"";const a=[...h[0]][0]||"";if(h.length===1)return a.toUpperCase();const m=[...h[h.length-1]][0]||"";return(a+m).toUpperCase()}function i(c){if(c==null)return null;const a=(Array.isArray(c)?c:[c]).filter(m=>typeof m=="string"||d(m));return a.length?a:null}const g=o}),xe("packages/dom/src/editors/iconpicker.js",function(e,K){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.VirtualList,_=X.el,Q=X.on,G=X.clear,H=K("packages/dom/src/cell/icons.js"),U=H.createIcon,z=H.iconNames,O=K("packages/core/src/internal/util.js").isFunction;class b extends L{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const n=this.props;this.columns=Math.max(1,Math.floor(Number(n.columns)||8)),this.names=u(n.icons),this.selected=this.params.value==null?null:String(this.params.value);const t=_(this.doc,"div",{class:["lat-iconpicker",`${B.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=_(this.doc,"div",{class:`${B.editor}__display`}),this.input=_(this.doc,"input",{class:B.input,attrs:{type:"text",autocomplete:"off",placeholder:n.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new F({document:this.doc,itemHeight:Number(n.rowHeight)||34,height:Number(n.listHeight)||204,renderItem:(r,o,f)=>this.renderRow(r,o,f)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),n.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(Q(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(Q(this.input,"keydown",r=>this.onKeyDown(r))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),t}buildClearButton(){const n=_(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(Q(n,"mousedown",t=>{O(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),n}focusTarget(){return this.input}onQuery(n){this.query=n,this.refreshIcons()}refreshIcons(){const n=this.query.trim().toLowerCase();this.matches=n===""?this.names.slice():this.names.filter(r=>r.toLowerCase().includes(n)),this.rows=[];for(let r=0;r<this.matches.length;r+=this.columns)this.rows.push(this.matches.slice(r,r+this.columns));const t=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=t>=0?t:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(n){return n<0?-1:Math.floor(n/this.columns)}moveCursor(n){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+n));return this.setCursor(t)}setCursor(n){return this.cursor=n,this.list&&this.list.setActive(this.rowOf(n)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(n,t,r){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let o=t.__latIconCells;if(!o){o=[],G(t);for(let f=0;f<this.columns;f++){const l=_(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});Q(l,"mousedown",i=>{O(i.preventDefault)&&i.preventDefault();const g=l.getAttribute("data-icon");g&&this.choose(g)}),t.appendChild(l),o.push(l)}t.__latIconCells=o}for(let f=0;f<o.length;f++){const l=o[f],i=n[f];if(i===void 0){l.setAttribute("aria-hidden","true"),l.removeAttribute("data-icon"),l.removeAttribute("title"),l.removeAttribute("aria-label"),l.classList.add("lat-iconpicker__cell--empty"),l.classList.remove("lat-iconpicker__cell--active"),l.classList.remove("lat-iconpicker__cell--selected"),l.__latIconName!==void 0&&(G(l),l.__latIconName=void 0);continue}const g=r*this.columns+f;l.removeAttribute("aria-hidden"),l.classList.remove("lat-iconpicker__cell--empty"),l.setAttribute("data-icon",i),l.setAttribute("title",i),l.setAttribute("aria-label",i),l.__latIconName!==i&&(G(l),l.appendChild(U(this.doc,i,{className:B.icon})),l.__latIconName=i);const c=this.selected===i;l.classList.toggle("lat-iconpicker__cell--active",g===this.cursor),l.classList.toggle("lat-iconpicker__cell--selected",c),l.setAttribute("aria-selected",c?"true":"false")}}paintDisplay(){const n=this.display;if(n){if(G(n),this.selected==null){n.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}n.appendChild(U(this.doc,this.selected,{className:B.icon})),n.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(n){this.selected=n;const t=this.matches.indexOf(n);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(n))?!0:`"${String(n)}" is not a known icon name`}onKeyDown(n){const t=()=>{O(n.preventDefault)&&n.preventDefault()};switch(n.key){case"ArrowRight":t(),this.moveCursor(1);return;case"ArrowLeft":t(),this.moveCursor(-1);return;case"ArrowDown":t(),this.moveCursor(this.columns);return;case"ArrowUp":t(),this.moveCursor(-this.columns);return;case"PageDown":t(),this.moveCursor(this.columns*5);return;case"PageUp":t(),this.moveCursor(-this.columns*5);return;case"Home":t(),this.setCursor(this.matches.length?0:-1);return;case"End":t(),this.setCursor(this.matches.length-1);return;case"Enter":{t();const r=this.cursorName();r&&this.choose(r);return}case"Escape":t(),this.cancel();return;case"Tab":{const r=this.cursorName();r&&(this.selected=r),this.commit();return}default:break}}destroy(){for(const n of this.off)n();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function u(s){const n=z();if(Array.isArray(s)&&s.length){const t=new Set(n);return s.map(r=>String(r)).filter(r=>t.has(r))}return n.filter(t=>t!=="blank")}const d=b}),xe("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,G=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/temperature.js"),U=H.formatTemperature,z=H.parseTemperature,S=H.findScale;function O(d,s){return U(d,{...s,decimals:void 0,minDecimals:0,maxDecimals:20})}class b extends L{input=null;hint=null;opts=null;#e=[];buildOptions(){const s=this.params.column&&this.params.column.dataType||null,n=s&&s.temperatureConfig||{};return{scale:this.props.scale||n.scale||"C",locale:this.params.locale}}build(){const s=this.props;this.opts=this.buildOptions();const n=S(this.opts.scale),t=n?n.scale.symbol:"",r=`${this.id}-scale`,o=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:s.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?r:null}});o.value=O(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(o.value=this.params.key),this.input=o;const f=typeof s.step=="number"?s.step:0;return f>0&&this.#e.push(_(o,"keydown",l=>{l.key==="ArrowUp"?(G(l.preventDefault)&&l.preventDefault(),this.nudge(f)):l.key==="ArrowDown"&&(G(l.preventDefault)&&l.preventDefault(),this.nudge(-f))})),this.hint=F(this.doc,"span",{class:`${B.editor}__suffix`,text:t,attrs:{id:r,"aria-hidden":"true"}}),F(this.doc,"div",{class:`${B.editor}__unit`,children:[o,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const s=this.input;s&&!this.params.key&&this.props.selectOnFocus!==!1&&G(s.select)&&s.select()}nudge(s){const n=z(this.input?this.input.value:"",this.opts);let t=(n??0)+s;const{min:r,max:o}=this.props;typeof r=="number"&&t<r&&(t=r),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=O(t,this.opts))}readValue(){const s=this.input?String(this.input.value).trim():"";if(s==="")return null;const n=z(s,this.opts);return n===null?Number.NaN:n}checkValue(s){if(s===null)return!0;if(typeof s!="number"||Number.isNaN(s))return"Enter a temperature";const{min:n,max:t}=this.props;return typeof n=="number"&&s<n?`Must be ${n} or more`:typeof t=="number"&&s>t?`Must be ${t} or less`:!0}destroy(){for(const s of this.#e)s();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const u=b}),xe("packages/dom/src/editors/currency.js",function(e,K){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const X=K("packages/dom/src/editors/common.js"),L=X.BaseEditor,B=X.CLS,F=X.el,_=X.on,G=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/columns/types/currency.js"),U=H.parseMoney,z=H.toMoney,S=H.normaliseCode,O=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function b(s){const n=z(s);return n?String(n.amount):""}class u extends L{input=null;picker=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.currencyConfig||{},r=z(this.params.value),o=S(this.props.code)||r&&r.code||S(t.code)||"USD";let f=this.props.codes||t.codes||O;return f=f.map(l=>S(l)).filter(Boolean),f.includes(o)||(f=[o,...f]),{code:o,codes:f,locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=F(this.doc,"input",{class:B.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});t.value=b(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const r=F(this.doc,"select",{class:`${B.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const o of this.opts.codes){const f=F(this.doc,"option",{text:o,attrs:{value:o}});o===this.opts.code&&(f.selected=!0),r.appendChild(f)}return this.picker=r,F(this.doc,"div",{class:`${B.editor}__unit`,children:[t,r]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&G(n.select)&&n.select()}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=this.picker?this.picker.value:this.opts.code,r=U(n,{...this.opts,code:t});return r===null?Number.NaN:r}checkValue(n){if(n===null)return!0;if(!n||typeof n!="object"||!Number.isFinite(n.amount))return"Enter an amount";const t=n.amount,{min:r,max:o}=this.props;return typeof r=="number"&&t<r?`Must be ${r} or more`:typeof o=="number"&&t>o?`Must be ${o} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const d=u}),xe("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return fe}});const L=K("packages/dom/src/editors/text.js").TextEditor,F=K("packages/dom/src/editors/textarea.js").TextareaEditor,Q=K("packages/dom/src/editors/number.js").NumberEditor,H=K("packages/dom/src/editors/date.js").DateEditor,z=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,O=K("packages/dom/src/editors/select.js").SelectEditor,u=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,s=K("packages/dom/src/editors/time.js").TimeEditor,t=K("packages/dom/src/editors/datetime.js").DateTimeEditor,o=K("packages/dom/src/editors/duration.js").DurationEditor,l=K("packages/dom/src/editors/ipaddress.js").IpAddressEditor,g=K("packages/dom/src/editors/password.js").PasswordEditor,h=K("packages/dom/src/editors/code.js").CodeEditor,m=K("packages/dom/src/editors/unit.js").UnitEditor,v=K("packages/dom/src/editors/radix.js").RadixEditor,y=K("packages/dom/src/editors/segmented.js").SegmentedEditor,T=K("packages/dom/src/editors/rating.js").RatingEditor,x=K("packages/dom/src/editors/slider.js").SliderEditor,j=K("packages/dom/src/editors/colour.js").ColourEditor,$=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,M=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,k=K("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=K("packages/dom/src/editors/temperature.js").TemperatureEditor,W=K("packages/dom/src/editors/currency.js").CurrencyEditor,J=K("packages/core/src/internal/util.js"),ee=J.isCtor,te=J.isFunction,ne=J.warnOnce,ae=K("packages/dom/src/editors/common.js");for(const ke of Object.keys(ae))ke!=="default"&&Object.defineProperty(e,ke,{enumerable:!0,get:function(){return ae[ke]}});const de=Object.freeze({text:L,textarea:F,number:Q,date:H,checkbox:z,select:O,multiSelect:u,temperature:q,currency:W,time:s,datetime:t,duration:o,ipaddress:l,password:g,code:h,unit:m,radix:v,slider:x,rating:T,segmented:y,treeSelect:$,objectPicker:M,iconPicker:k,colour:j}),ie=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function oe(ke,Re){const Ee=ke&&ke.edit&&ke.edit.editor,Fe=Re&&Re.editors||{},ye=!!(ke&&ke.lookup&&ke.lookup.multiple);if(ee(Ee)||te(Ee))return Ee;if(typeof Ee=="string"){if(ye&&Ee==="select")return u;const Ce=Fe[Ee]||de[Ee];if(Ce)return Ce;ne(`editor:missing:${Ee}`,`unknown editor "${Ee}"; falling back to the data type default`)}const he=ke&&ke.type||"text";if(he==="lookup"||ke&&ke.lookup)return ye?u:O;const Se=ie[he];return Se&&(Fe[Se]||de[Se])||null}function ce(ke,Re){const Ee=oe(ke.column||{},Re);if(!Ee)return null;const Fe=new Ee;return Fe.init(ke),te(Fe.cancelBeforeStart)&&Fe.cancelBeforeStart()===!0?(te(Fe.destroy)&&Fe.destroy(),null):Fe}const fe=de}),xe("packages/dom/src/ui/statusbar.js",function(e,K){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,_=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction;function z(c){let h=0,a=0,m=0,w=null,v=null;for(const p of c||[]){if(p==null||p==="")continue;h++;const y=typeof p=="number"?p:Number(p);Number.isFinite(y)&&(a++,m+=y,(w===null||y<w)&&(w=y),(v===null||y>v)&&(v=y))}return{count:h,numericCount:a,sum:a?m:null,min:w,max:v,avg:a?m/a:null}}class S{root=null;valueNode=null;init(h){this.ctx=h,this.doc=h.document,this.root=F(this.doc,"div",{class:`${L.statusBar}__panel`,attrs:{"data-align":h.align||"end"}}),h.label&&this.root.appendChild(F(this.doc,"span",{class:`${L.statusBar}__label`,text:h.label})),this.valueNode=F(this.doc,"span",{class:`${L.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(h,a){const m=this.ctx&&this.ctx.messages;return(m&&U(m.t)?m:G).t(h,a)}element(){return this.root}refresh(){const h=this.read();this.valueNode&&this.valueNode.textContent!==h&&(this.valueNode.textContent=h)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class O extends S{read(){const h=this.ctx.host||{},a=U(h.totalRowCount)?h.totalRowCount():0;if(a==null)return this.t("status.counting");const m=U(h.rowCount)?h.rowCount():a,w=this.ctx.noun,v=p=>w===void 0?this.t("count.rows",{count:p}):`${f(p,this.ctx.locale)}${w?` ${w}`:""}`;return m===a?this.t("status.total",{rows:v(a)}):this.t("status.shownOfTotal",{shown:f(m,this.ctx.locale),total:v(a)})}}class b extends S{read(){const h=this.ctx.host||{},a=U(h.selectedAcrossSource)?h.selectedAcrossSource():null;if(a)return typeof a.count=="number"?this.t("status.selectedAcrossSource",{count:a.count}):this.t("status.selectedAcrossSourceCounting");const m=U(h.selectedCount)?h.selectedCount():0;return m?this.t("status.selected",{count:m}):""}}class u extends S{read(){const h=this.ctx.host||{},a=U(h.rangeValues)?h.rangeValues():[],m=z(a);if(!m.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],v=[];for(const p of w){if(p==="count"){v.push(this.t("status.count",{count:m.count}));continue}const y=m[p];y!==null&&v.push(`${this.t(`status.stat.${p}`)} ${i(y,this.ctx.locale)}`)}return v.join(" ")}}class d extends S{read(){const h=this.ctx.host||{},a=U(h.progress)?h.progress():null;if(!a)return"";const{loaded:m,estimated:w,done:v}=a;if(v)return"";if(!w)return this.t("status.loading",{count:m||0});const p=Math.min(100,Math.round((m||0)/w*100));return this.t("status.loadingOf",{loaded:m||0,total:w,percent:p})}}class s extends S{read(){const h=this.ctx.host||{},a=U(h.updateStats)?h.updateStats():null;return a?a.paused?a.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:a.pending})}):this.t("status.paused"):a.coalescedTotal?this.t("status.coalesced",{count:a.coalescedTotal}):"":""}}class n extends S{read(){const h=this.ctx.host||{},a=U(h.hiddenUnresolved)?h.hiddenUnresolved():0;return a?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:a})}):""}}const t=Object.freeze({rowCount:O,selectedCount:b,aggregation:u,progress:d,updates:s,comments:n});class r{panels=[];root=null;init(h){const a=h||{};this.doc=B(a),this.host=a.host||{},this.messages=a.messages||null,this.root=F(this.doc,"div",{class:L.statusBar,attrs:{role:"status","aria-live":"polite"}});const m=a.registry||{},w=Array.isArray(a.panels)&&a.panels.length?a.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const v of w){const p=typeof v=="string"?v:v.name,y=typeof v=="function"?v:m[p]||t[p];if(!y)continue;const C=new y;C.init({document:this.doc,host:this.host,locale:a.locale,messages:this.messages,...typeof v=="object"?v.props||{}:{}}),this.panels.push({name:String(p||"panel"),panel:C}),this.root.appendChild(C.element())}this.refresh()}element(){return this.root}addPanel(h,a,m){const w=new a;return w.init({document:this.doc,host:this.host,messages:this.messages,...m||{}}),this.panels.push({name:h,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(h){const a=this.panels.findIndex(v=>v.name===h);if(a<0)return!1;const[m]=this.panels.splice(a,1),w=m.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),U(m.panel.destroy)&&m.panel.destroy(),!0}refresh(){for(const h of this.panels)h.panel.refresh()}destroy(){for(const h of this.panels)U(h.panel.destroy)&&h.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const o=new Map;function f(c,h){const a=h||"";let m=o.get(a);return m||(m=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:0}),o.set(a,m)),m.format(Number(c)||0)}const l=new Map;function i(c,h){const a=h||"";let m=l.get(a);return m||(m=new Intl.NumberFormat(h||void 0,{maximumFractionDigits:3}),l.set(a,m)),m.format(Number(c)||0)}const g=r}),xe("packages/dom/src/ui/contextmenu.js",function(e,K){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,_=X.on,Q=X.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/renderer/direction.js").isRtlElement,O=K("packages/dom/src/cell/icons.js").renderIconInto;function b(t,r){const o=[];for(const f of t||[]){const l=H(f)?f(r):f;if(l==null||l===!1)continue;if(l==="separator"){o.push({separator:!0});continue}if(typeof l=="string"){o.push({name:l});continue}const i=l,g=i.subMenu||i.children;g?o.push({...i,subMenu:b(g,r)}):o.push(i)}return o.filter((f,l,i)=>f.separator?l===0||l===i.length-1?!1:!i[l-1].separator:!0)}class u{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(r){const o=r||{};this.doc=B(o),this.host=o.host||this.doc.body,this.ctx=o.ctx||{},this.onClose=o.onClose||null,this.parent=o.parent||null}place(r){const o=this.host,f=H(o.getBoundingClientRect)?o.getBoundingClientRect():{left:0,top:0},l=H(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},i=this.doc.defaultView||{innerWidth:0,innerHeight:0},g=i.innerWidth||0,c=i.innerHeight||0;let h=r.x||0,a=r.y||0;const m=z(o);if(r.anchor&&H(r.anchor.getBoundingClientRect)){const p=r.anchor.getBoundingClientRect();r.placement==="below"?(h=m?p.right-l.width:p.left,a=p.bottom):(h=m?p.left-l.width:p.right,a=p.top)}else m&&(h-=l.width);const w={left:Math.max(0,f.left||0),top:Math.max(0,f.top||0),right:Math.min(g||1/0,(f.left||0)+(f.width||1/0)),bottom:Math.min(c||1/0,(f.top||0)+(f.height||1/0))};h+l.width>w.right&&(h-=l.width),h<w.left&&(h=w.left),a+l.height>w.bottom&&(a-=l.height),a<w.top&&(a=w.top);const v=w.bottom-a;l.height>v&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(v))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(h-f.left+(o.scrollLeft||0))}px`,this.root.style.top=`${Math.round(a-f.top+(o.scrollTop||0))}px`}show(r){return this.hide(),r.ctx&&(this.ctx={...this.ctx||{},...r.ctx}),this.items=b(r.items,this.ctx),this.returnFocus=r.returnFocus||null,this.anchor=r.anchor&&H(r.anchor.setAttribute)&&r.anchor.getAttribute&&r.anchor.getAttribute("aria-haspopup")?r.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=F(this.doc,"div",{class:L.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((o,f)=>{if(o.separator){this.root.appendChild(F(this.doc,"div",{class:L.menuSeparator,attrs:{role:"separator"}}));return}const l=F(this.doc,"div",{class:[L.menuItem,o.cssClass||""],attrs:{role:o.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":o.disabled?"true":null,"aria-checked":o.checked===void 0?null:String(o.checked===!0),"aria-haspopup":o.subMenu?"true":null,"aria-expanded":o.subMenu?"false":null,"data-index":f}});if(o.icon!=null&&o.icon!==""){const g=F(this.doc,"span",{class:L.icon});O(g,o.icon,`menu:${o.name||f}`),l.appendChild(g)}l.appendChild(F(this.doc,"span",{class:`${L.menuItem}__label`,text:o.name||""})),o.shortcut&&l.appendChild(F(this.doc,"span",{class:`${L.menuItem}__shortcut`,text:o.shortcut})),o.subMenu&&l.appendChild(F(this.doc,"span",{class:`${L.menuItem}__arrow`,text:"›"}));const i=this.itemNodes.length;this.off.push(_(l,"click",()=>this.invoke(i))),this.off.push(_(l,"mouseenter",()=>{this.focus(i),o.subMenu?this.openSubMenu(i):this.closeChild()})),this.itemNodes.push(l),this.root.appendChild(l)}),this.host.appendChild(this.root),this.place(r),this.open=!0,this.off.push(_(this.root,"keydown",o=>this.onKeyDown(o))),H(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=o=>{this.root&&!s(this.root,o.target)&&!(this.child&&this.child.root&&s(this.child.root,o.target))&&this.hide()},!0)),H(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let r=0;r<this.itemNodes.length;r++)if(!this.itemAt(r).disabled)return r;return-1}itemAt(r){const o=this.itemNodes[r];return o?this.items[Number(o.getAttribute("data-index"))]||{}:{}}focus(r){if(r<0||r>=this.itemNodes.length)return;const o=this.itemNodes[this.focused];o&&o.classList.remove(`${L.menuItem}--focused`),this.focused=r;const f=this.itemNodes[r];f.classList.add(`${L.menuItem}--focused`),H(f.focus)&&f.focus(),H(f.scrollIntoView)&&f.scrollIntoView({block:"nearest",inline:"nearest"})}move(r){const o=this.itemNodes.length;if(!o)return;let f=this.focused;for(let l=0;l<o;l++)if(f=(f+r+o)%o,!this.itemAt(f).disabled){this.focus(f);return}}invoke(r){const o=this.itemAt(r);if(!(!o||o.disabled)){if(o.subMenu){this.openSubMenu(r);return}H(o.action)&&o.action({...this.ctx,item:o}),this.hideRoot()}}openSubMenu(r){const o=this.itemAt(r);o.subMenu&&(this.closeChild(),this.child=new u({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:o.subMenu,anchor:this.itemNodes[r]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(r){switch(r.key){case"ArrowDown":d(r),this.move(1);break;case"ArrowUp":d(r),this.move(-1);break;case"Home":d(r),this.focus(this.firstEnabled());break;case"End":d(r),this.focus(this.itemNodes.length-1);break;case"ArrowRight":d(r),this.openSubMenu(this.focused);break;case"ArrowLeft":d(r),this.parent&&(this.hide(),H(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":d(r),this.invoke(this.focused);break;case"Escape":d(r),this.hideRoot();break;default:r.key&&r.key.length===1&&this.jumpTo(r.key);break}}jumpTo(r){const o=r.toLowerCase(),f=this.itemNodes.length;for(let l=1;l<=f;l++){const i=(this.focused+l+f)%f,g=this.itemAt(i);if(!g.disabled&&(g.name||"").toLowerCase().startsWith(o)){this.focus(i);return}}}hideRoot(){let r=this;for(;r.parent;)r=r.parent;r.hide()}hide(){this.closeChild();for(const r of this.off)r();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&H(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&H(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,H(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function d(t){H(t.preventDefault)&&t.preventDefault(),H(t.stopPropagation)&&t.stopPropagation()}function s(t,r){let o=r;for(;o;){if(o===t)return!0;o=o.parentNode}return!1}const n=u}),xe("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,_=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,S=K("packages/dom/src/cell/icons.js").createIcon,O=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class b{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(n,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:G).t(n,t)}init(n){this.messages=n&&n.messages||n&&n.grid&&n.grid.messages||G;const t=n||{};this.doc=L(t),this.host=t.host||{},this.props=t.props||{},this.root=B(this.doc,"div",{class:O.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const n=this.root;if(!n)return;for(const l of this.off)l();this.off.length=0,_(n),this.diffs=new Map;const t=this.views(),r=t.filter(l=>l.builtin),o=t.filter(l=>!l.builtin);r.length&&(n.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),r.length)),n.appendChild(this.buildList(r))),n.appendChild(this.buildHead(String(this.props.title||"Saved views"),o.length)),o.length?n.appendChild(this.buildList(o)):n.appendChild(B(this.doc,"p",{class:O.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const f=this.buildFoot();f&&n.appendChild(f)}buildList(n){const t=B(this.doc,"div",{class:O.list,attrs:{role:"list"}});for(const r of n)t.appendChild(this.buildItem(r));return t}views(){const n=U(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?n:n.slice().sort((t,r)=>String(t.name||"").localeCompare(String(r.name||"")))}activeId(){return U(this.host.activeId)?this.host.activeId():null}buildHead(n,t){return B(this.doc,"div",{class:O.head,children:[B(this.doc,"span",{class:O.title,text:String(n)}),B(this.doc,"span",{class:O.count,text:String(t)})]})}buildItem(n){const t=String(n.id),r=this.activeId()===t,o=U(this.host.canEdit)?this.host.canEdit(n)!==!1:!0,f=B(this.doc,"div",{class:[O.item,r?O.itemActive:"",this.editing===t?O.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":n.shared?"true":"false"}});if(this.editing===t)return f.appendChild(this.buildRenameRow(n)),f;const l=B(this.doc,"button",{class:O.apply,attrs:{type:"button","aria-current":r?"true":null,title:[r?`${n.name} is applied`:`Apply ${n.name}`,n.shared?"Shared with everyone":"Private to you"].join(": ")},children:[B(this.doc,"span",{class:O.name,text:String(n.name||"")}),n.isDefault?this.buildBadges(n):null].filter(Boolean)});U(this.host.apply)?this.off.push(F(l,"click",()=>this.applyView(t))):l.setAttribute("disabled",""),n.description&&l.appendChild(B(this.doc,"span",{class:O.description,text:String(n.description)}));const i=this.buildDiff(t,r);return i&&l.appendChild(i),f.appendChild(l),n.builtin||f.appendChild(this.confirming===t?this.buildConfirm(n):this.buildActions(n,o)),f}buildBadges(n){const t=B(this.doc,"span",{class:O.badges});return n.isDefault&&t.appendChild(B(this.doc,"span",{class:[O.badge,O.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(n,t){if(this.props.showDiff!==!0||!U(this.host.diff))return null;const r=this.diffOf(n);if(!r)return null;if(!r.changed)return B(this.doc,"span",{class:[O.diff,O.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const o=u(r);return o.length?B(this.doc,"span",{class:O.diff,text:o.join(" · ")}):null}diffOf(n){if(!U(this.host.diff))return null;if(this.diffs.has(n))return this.diffs.get(n);let t=null;try{t=this.host.diff(n)}catch{t=null}return this.diffs.set(n,t),t}buildActions(n,t){const r=String(n.id),o=B(this.doc,"span",{class:O.actions});if(t&&U(this.host.rename)&&o.appendChild(this.buildAction("Rename",`Rename ${n.name}`,()=>{this.editing=r,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),n.isDefault&&U(this.host.clearDefault)?o.appendChild(this.buildAction("Unset default",`Stop applying ${n.name} at load`,()=>{this.host.clearDefault(r),this.refresh()},"pin")):!n.isDefault&&U(this.host.setDefault)&&o.appendChild(this.buildAction("Make default",`Apply ${n.name} when the grid loads`,()=>{this.host.setDefault(r),this.refresh()},"pin")),U(this.host.export)&&o.appendChild(this.buildAction("Share",`Export ${n.name}`,()=>this.host.export(r),"share")),t&&U(this.host.remove)){const f=this.buildAction("Delete",`Delete ${n.name}`,()=>{this.confirming=r,this.refresh()},"trash");f.classList.add(O.actionDanger),o.appendChild(f)}return o}buildConfirm(n){const t=String(n.id),r=B(this.doc,"span",{class:O.confirm});r.appendChild(B(this.doc,"span",{text:this.t("views.confirmDelete",{name:n.name})}));const o=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:n.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return o.classList.add(O.actionDanger),r.appendChild(o),r.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),r}buildRenameRow(n){const t=String(n.id),r=B(this.doc,"span",{class:O.confirm}),o=B(this.doc,"input",{class:O.input,attrs:{type:"text","aria-label":`New name for ${n.name}`}});o.value=String(n.name||""),this.input=o;const f=()=>{const i=String(o.value||"").trim();this.editing=null,i&&i!==n.name&&this.host.rename(t,i),this.refresh()},l=()=>{this.editing=null,this.refresh()};return this.off.push(F(o,"keydown",i=>{i.key==="Enter"?f():i.key==="Escape"&&l()})),r.appendChild(o),r.appendChild(this.buildAction("Save","Save the new name",f)),r.appendChild(this.buildAction("Cancel","Leave the name alone",l)),r}buildFoot(){if(this.props.allowSave===!1||!U(this.host.saveAs))return null;const n=B(this.doc,"div",{class:O.foot}),t=B(this.doc,"input",{class:O.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const r=()=>{const f=String(t.value||"").trim();if(!f){U(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(f),this.refresh()};this.off.push(F(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push(F(t,"keydown",f=>{f.key==="Enter"&&r()}));const o=B(this.doc,"button",{class:O.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(F(o,"click",r)),n.appendChild(t),n.appendChild(o),n}buildAction(n,t,r,o){const f=B(this.doc,"button",{class:O.action,text:o?null:n,attrs:{type:"button",title:t,"aria-label":t,"data-action":n}});return o&&f.appendChild(S(this.doc,o,{className:O.actionIcon})),this.off.push(F(f,"click",r)),f}applyView(n){this.confirming=null,this.host.apply(n),this.refresh()}focusInput(){const n=this.input;n&&U(n.focus)&&n.focus(),n&&U(n.select)&&n.select()}destroy(){for(const n of this.off)n();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function u(s,n=3){if(!s||!s.changed)return[];const t=s.counts||{},r=[],o=(f,l,i)=>{f&&r.push((f===1?l:i).replace("%",String(f)))};if(o(t.columnsHidden,"hides % column","hides % columns"),o(t.columnsShown,"shows % column","shows % columns"),o(t.columnsMoved,"moves % column","moves % columns"),o(t.columnsPinned,"repins % column","repins % columns"),o(t.columnsResized,"resizes % column","resizes % columns"),s.filters&&s.filters.changed){const f=t.filterColumns||0;r.push(f?`changes ${f} filter${f===1?"":"s"}`:"changes the filter")}return s.quick&&s.quick.changed&&r.push("changes the search"),s.sort&&s.sort.changed&&r.push("changes the sort"),s.group&&s.group.changed&&r.push("changes the grouping"),s.pivot&&s.pivot.changed&&r.push("changes the pivot"),o(t.columnsTotalled,"changes % total","changes % totals"),s.pagination&&s.pagination.changed&&r.push("changes the page size"),r.length<=n?r:[...r.slice(0,n),`and ${r.length-n} more`]}const d=b}),xe("packages/dom/src/ui/panelbase.js",function(e,K){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return Q}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,_=K("packages/core/src/i18n/index.js").defaultMessages;class Q{root=null;off=[];init(H){this.ctx=H,this.doc=H.document,this.host=H.host||{},this.props=H.props||{},this.root=B(this.doc,"div",{class:`${L.panel}__body`}),this.refresh()}t(H,U){const z=this.host||{};if(typeof z.t=="function")return z.t(H,U);const S=this.ctx||{};if(S.messages&&typeof S.messages.t=="function")return S.messages.t(H,U);const O=S.grid;return(O&&O.messages?O.messages:_).t(H,U)}element(){return this.root}refresh(){}destroy(){for(const H of this.off)H();this.off.length=0,this.root=null}}}),xe("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,_=X.on,Q=X.clear,H=K("packages/core/src/internal/util.js").isFunction,z=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,S=K("packages/core/src/formatting/rules.js"),O=S.compileRules,b=S.summariseColumn,u=S.needsDistribution,d=S.DISTRIBUTION_LABELS,s="*",n=8,t=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),r=Object.freeze([{op:"topPercent",label:d.topPercent,values:1},{op:"bottomPercent",label:d.bottomPercent,values:1},{op:"topN",label:d.topN,values:1},{op:"bottomN",label:d.bottomN,values:1},{op:"aboveMean",label:d.aboveMean,values:0},{op:"belowMean",label:d.belowMean,values:0},{op:"aboveMedian",label:d.aboveMedian,values:0},{op:"belowMedian",label:d.belowMedian,values:0},{op:"zAbove",label:d.zAbove,values:1},{op:"zBelow",label:d.zBelow,values:1},{op:"outlier",label:d.outlier,values:0}]),o=Object.freeze([...t,...r]),f=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),l=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),i=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function g(w){const v=o.find(p=>p.op===w);return v?v.values:1}function c(w){if(!w)return"";if(w.scale){const{min:C,max:T,from:P}=w.scale;if(Number.isFinite(C)&&Number.isFinite(T))return`Colour scale, ${C} to ${T}`;const x=i.find(E=>E.from===P);return x?`Colour scale ${x.label}`:"Colour scale"}const v=w.when||{},p=o.find(C=>C.op===v.op),y=p?p.label:v.op;return!p||p.values===0?`Value ${y}`:p.values===2?`Value ${y} ${v.value} and ${v.value2}`:`Value ${y} ${v.value}`}class h extends z{scope=s;mode="condition";refresh(){const v=this.root;if(v){for(const p of this.off)p();this.off.length=0,Q(v),v.appendChild(this.#o()),v.appendChild(this.#i()),v.appendChild(this.#l())}}#e(){const v=H(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:s,title:"All columns"},...v]}#t(){return H(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(v){if(!H(this.host.columnSamples))return[];const p=this.host.columnSamples(v);return Array.isArray(p)?p:[...p||[]]}#r(v,p,y){const C=u(v)?b(p):null;return O(v,C)({value:y})}#o(){const v=F(this.doc,"div",{class:`${L.panel}__row`});v.appendChild(F(this.doc,"label",{class:`${L.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const y of this.#e()){const C=F(this.doc,"option",{text:y.title,attrs:{value:y.id}});y.id===this.scope&&C.setAttribute("selected","selected"),p.appendChild(C)}return p.value=this.scope,this.off.push(_(p,"change",()=>{this.scope=p.value||s,this.refresh()})),v.appendChild(p),v}#i(){const v=F(this.doc,"ul",{class:`${L.panel}__list`}),p=this.#t();if(!p.length)return v.appendChild(F(this.doc,"li",{class:`${L.panel}__empty`,text:this.t("formatting.noRules")})),v;p.forEach((T,P)=>{const x=F(this.doc,"li",{class:`${L.panel}__item`,attrs:{"data-rule":T.id}}),E=F(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${c(T)}`}});E.checked=T.enabled!==!1,this.off.push(_(E,"change",()=>{this.#c("updateRule",this.scope,T.id,{enabled:E.checked})})),x.appendChild(E);const j=F(this.doc,"span",{class:`${L.panel}__swatch`}),A=T.style||{};if(A.background&&j.style&&j.style.setProperty)j.style.setProperty("background",String(A.background));else if(T.scale&&T.scale.colours&&j.style&&j.style.setProperty){const R=T.scale.colours;j.style.setProperty("background",`linear-gradient(90deg, ${R[0]}, ${R[R.length-1]})`)}x.appendChild(j),x.appendChild(F(this.doc,"span",{class:`${L.panel}__text`,text:c(T)}));const $=F(this.doc,"button",{class:`${L.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...P===0?{disabled:"disabled"}:{}}});this.off.push(_($,"click",()=>this.#c("moveRule",this.scope,T.id,P-1))),x.appendChild($);const D=F(this.doc,"button",{class:`${L.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...P===p.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,T.id,P+1))),x.appendChild(D);const M=F(this.doc,"button",{class:`${L.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${c(T)}`}});this.off.push(_(M,"click",()=>this.#c("removeRule",this.scope,T.id))),x.appendChild(M),v.appendChild(x)});const y=this.#s(p);y&&v.appendChild(y);const C=F(this.doc,"button",{class:`${L.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(_(C,"click",()=>this.#c("clearRules",this.scope))),v.appendChild(C),v}#s(v){const p=this.#n(this.scope);if(!p.length)return null;const y=v.filter(T=>T.enabled!==!1);if(!y.length)return null;const C=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const T of p.slice(0,n)){const P=this.#r(y,p,T),x=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(T)});P&&x.style&&x.style.setProperty&&(P.background&&x.style.setProperty("background",String(P.background)),P.color&&x.style.setProperty("color",String(P.color))),C.appendChild(x)}return C}#l(){const v=F(this.doc,"div",{class:`${L.panel}__form`}),p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return p.appendChild(F(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),p.appendChild(F(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),p.value=this.mode,this.off.push(_(p,"change",()=>{this.mode=p.value==="scale"?"scale":"condition",this.refresh()})),v.appendChild(p),this.mode==="scale"?v.appendChild(this.#u()):v.appendChild(this.#a()),v}#a(){const v=F(this.doc,"div",{class:`${L.panel}__form`}),p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),y=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const M of t)y.appendChild(F(this.doc,"option",{text:M.label,attrs:{value:M.op}}));p.appendChild(y);const C=F(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const M of r)C.appendChild(F(this.doc,"option",{text:M.label,attrs:{value:M.op}}));p.appendChild(C),p.value="gt",v.appendChild(p);const T=F(this.doc,"input",{class:`${L.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),P=F(this.doc,"input",{class:`${L.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});v.appendChild(T),v.appendChild(P);const x=()=>{const M=g(p.value);T.style.setProperty("display",M>=1?"":"none"),P.style.setProperty("display",M>=2?"":"none"),$()};this.off.push(_(p,"change",x));const E=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const M of f)E.appendChild(F(this.doc,"option",{text:M.name,attrs:{value:M.name}}));E.value=f[0].name,v.appendChild(E);const j=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(j);const A=()=>{const M=f.find(I=>I.name===E.value)||f[0],R=g(p.value),k={op:p.value};return R>=1&&(k.value=T.value),R>=2&&(k.value2=P.value),{when:k,style:{background:M.background,color:M.color}}},$=()=>{Q(j);const M=this.#n(this.scope);if(M.length)for(const R of M.slice(0,n)){const k=this.#r([A()],M,R),I=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(R)});k&&I.style&&I.style.setProperty&&(k.background&&I.style.setProperty("background",String(k.background)),k.color&&I.style.setProperty("color",String(k.color))),j.appendChild(I)}};this.off.push(_(T,"input",$)),this.off.push(_(P,"input",$)),this.off.push(_(E,"change",$)),x();const D=F(this.doc,"button",{class:`${L.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,A()),T.value="",P.value=""})),v.appendChild(D),v}#u(){const v=F(this.doc,"div",{class:`${L.panel}__form`}),p=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const E of l)p.appendChild(F(this.doc,"option",{text:E.name,attrs:{value:E.name}}));p.value=l[0].name,v.appendChild(p);const y=F(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const E of i)y.appendChild(F(this.doc,"option",{text:E.label,attrs:{value:E.from}}));y.value=i[0].from,v.appendChild(y);const C=F(this.doc,"div",{class:`${L.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(C);const T=()=>{const E=l.find(j=>j.name===p.value)||l[0];return{scale:{from:y.value,colours:[...E.colours]}}},P=()=>{Q(C);const E=this.#n(this.scope);if(E.length)for(const j of E.slice(0,n)){const A=this.#r([T()],E,j),$=F(this.doc,"span",{class:`${L.panel}__previewcell`,text:String(j)});A&&A.background&&$.style&&$.style.setProperty&&$.style.setProperty("background",String(A.background)),C.appendChild($)}};this.off.push(_(p,"change",P)),this.off.push(_(y,"change",P)),P();const x=F(this.doc,"button",{class:`${L.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(x,"click",()=>{this.#c("addRule",this.scope,T())})),v.appendChild(x),v}#c(v,...p){H(this.host[v])&&this.host[v](...p),this.refresh()}}function a(w={}){const v=new h;return v.init({document:B(w),host:w.host||{}}),v}const m=h}),xe("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return u}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.on,_=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"},{key:"min",label:"stats.min",kind:"value"},{key:"max",label:"stats.max",kind:"value"},{key:"mean",label:"stats.mean",kind:"value"},{key:"median",label:"stats.median",kind:"value"},{key:"q1",label:"stats.q1",kind:"value"},{key:"q3",label:"stats.q3",kind:"value"},{key:"iqr",label:"stats.iqr",kind:"value"},{key:"stddev",label:"stats.stddev",kind:"value"},{key:"outliers",label:"stats.outliers",kind:"count"}]),S=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),O=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function b(d){if(d==null||!Number.isFinite(d))return"—";if(Number.isInteger(d))return String(d);const s=Math.abs(d);return s!==0&&(s<.001||s>=1e7)?d.toExponential(2):String(Number(d.toPrecision(4)))}class u extends U{column=null;#e(){return G(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const s=this.root;if(!s)return;for(const o of this.off)o();this.off.length=0,_(s);const n=this.#e();if(!n.length){s.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("stats.noColumns")}));return}n.some(o=>o.id===this.column)||(this.column=n[0].id),s.appendChild(this.#t(n));const t=G(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!t||!t.present){s.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("stats.noValues")}));return}if(s.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("stats.filtered",{count:t.rows})})),Array.isArray(t.topValues)){s.appendChild(this.#o(t,S)),s.appendChild(this.#i(t.topValues));return}s.appendChild(this.#o(t));for(const o of O){const f=this.#n(o);f&&s.appendChild(f)}const r=this.#r();r&&s.appendChild(r),t.histogram&&t.histogram.length>1&&s.appendChild(this.#s(t.histogram))}#t(s){const n=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const t of s){const r=B(this.doc,"option",{text:t.title,attrs:{value:t.id,selected:t.id===this.column?!0:null}});n.appendChild(r)}return n.value=this.column,this.off.push(F(n,"change",()=>{this.column=n.value,this.refresh()})),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t("stats.column")}),n]})}#n(s){const n=this.host.reduceColumn;if(!G(n)||!this.column)return null;const t=[];for(const f of s.kernels){const l=n(this.column,f);l==null||Number.isNaN(l)||t.push([f,l])}if(!t.length)return null;const r=this.doc.createElement("div");r.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t(s.label)}));const o=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const[f,l]of t)o.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(`total.${f}`)})),o.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:typeof l=="number"?b(l):String(l)}));return r.appendChild(o),r}#r(){const s=this.host.columnCapability;if(!G(s)||!this.column)return null;const n=s(this.column);if(!n)return null;const t=this.doc.createElement("div");t.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.section.capability")}));const r=B(this.doc,"dl",{class:`${L.panel}__stats`}),o=[["stats.cp",n.cp,null],["stats.cpk",n.cpk,n.interval],["stats.pp",n.pp,null],["stats.ppk",n.ppk,n.intervalPp],["stats.outOfSpec",n.outOfSpec,null]];for(const[f,l,i]of o){if(l==null)continue;r.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(f)}));const g=[B(this.doc,"span",{text:b(l)})];i&&Number.isFinite(i.lower)&&g.push(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${b(i.lower)} – ${b(i.upper)}`,attrs:{title:`${Math.round(i.confidence*100)}%`}})),r.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:g}))}return t.appendChild(r),t}#o(s,n=z){const t=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const r of n){const o=s[r.key];t.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(r.label)})),t.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:r.kind==="count"?String(o??0):b(o)}))}return t}#i(s){const n=this.doc.createElement("div");n.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.topValues")}));const t=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const r of s)t.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:String(r.value)})),t.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:[B(this.doc,"span",{text:String(r.count)}),B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${Math.round(r.share*100)}%`})]}));return n.appendChild(t),n}#s(s){const n=s.reduce((r,o)=>Math.max(r,o.count),0)||1,t=B(this.doc,"div",{class:`${L.panel}__histogram`});t.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t("stats.distribution")}));for(const r of s){const o=B(this.doc,"div",{class:`${L.panel}__bar`,style:{width:`${r.count?Math.max(2,r.count/n*100):0}%`}});t.appendChild(B(this.doc,"div",{class:`${L.panel}__bin`,attrs:{title:this.t("stats.bin",{count:r.count,from:b(r.from),to:b(r.to)})},children:[o]}))}return t}}}),xe("packages/dom/src/regressionpanel.js",function(e,K){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.clear,Q=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function U(O,b=4){const u=Number(O);return Number.isFinite(u)?u.toFixed(b):u===1/0?"∞":"—"}class z extends H{#e(){const b=this.props||{};if(Array.isArray(b.predictors)&&b.predictors.length&&b.response)return b;const u=this.ctx&&this.ctx.grid,d=u&&Q(u.get)?u.get("regression"):null;return d&&Array.isArray(d.predictors)&&d.response?d:null}refresh(){const b=this.root;if(!b)return;F(b);const u=this.#e();if(!u){b.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.noModel")}));return}const d=Q(this.host.regressionModel)?this.host.regressionModel(u):null;if(!d){b.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.cannotFit")}));return}b.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("regression.observations",{count:d.n})})),b.appendChild(this.#t(d)),b.appendChild(this.#n(d));const s=this.#r(d,u);s&&b.appendChild(s),b.appendChild(this.#o(d))}#t(b){const u=B(this.doc,"dl",{class:`${L.panel}__stats`}),d=(s,n)=>{u.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-label`,text:s})),u.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:n}))};return d(this.t("regression.r2"),U(b.r2,4)),d(this.t("regression.adjR2"),U(b.adjR2,4)),u}#n(b){const u=B(this.doc,"div",{class:`${L.panel}__section`});u.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.coefficients")}));const d=B(this.doc,"table",{class:`${L.panel}__coef-table`}),s=B(this.doc,"tr");for(const n of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])s.appendChild(B(this.doc,"th",{text:this.t(n)}));d.appendChild(s);for(const n of b.coefficients){const t=B(this.doc,"tr");t.appendChild(B(this.doc,"td",{text:n.name})),t.appendChild(B(this.doc,"td",{text:`${U(n.estimate)} ± ${U(n.stdError)}`})),t.appendChild(B(this.doc,"td",{text:U(n.stdError)})),t.appendChild(B(this.doc,"td",{text:U(n.t,3)})),t.appendChild(B(this.doc,"td",{text:U(n.p,4)})),d.appendChild(t)}return u.appendChild(d),u}#r(b,u){if(!Array.isArray(b.vif)||b.vif.length<2)return null;const d=B(this.doc,"div",{class:`${L.panel}__section`});d.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.vif")}));const s=B(this.doc,"dl",{class:`${L.panel}__stats`});return b.vif.forEach((n,t)=>{s.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-label`,text:u.predictors[t]})),s.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:U(n,3)}))}),d.appendChild(s),d}#o(b){const u=b.heteroscedasticity,d=B(this.doc,"div",{class:`${L.panel}__section`});return d.appendChild(B(this.doc,"h4",{class:`${L.panel}__heading`,text:this.t("regression.heteroscedasticity")})),u?(d.appendChild(B(this.doc,"p",{class:`${L.panel}__flag`,attrs:{"data-heteroscedastic":u.heteroscedastic?"true":"false"},text:this.t(u.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:U(u.statistic,3),p:U(u.p,4)})})),d):(d.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("regression.cannotFit")})),d)}}const S=z}),xe("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return O}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.on,_=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"pearson",label:"compare.pearson"},{key:"spearman",label:"compare.spearman"},{key:"kendall",label:"compare.kendall"},{key:"slope",label:"compare.slope"},{key:"intercept",label:"compare.intercept"},{key:"r2",label:"compare.r2"},{key:"stdError",label:"compare.stdError"},{key:"covariance",label:"compare.covariance"},{key:"weighted",label:"compare.weighted"}]);function S(b){if(b==null||!Number.isFinite(b))return"—";if(Number.isInteger(b))return String(b);const u=Math.abs(b);return u!==0&&(u<.001||u>=1e7)?b.toExponential(2):String(Number(b.toPrecision(4)))}class O extends U{first=null;second=null;#e(){return G(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const u=this.root;if(!u)return;for(const t of this.off)t();this.off.length=0,_(u);const d=this.#e();if(d.length<2){u.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("compare.needTwo")}));return}d.some(t=>t.id===this.first)||(this.first=d[0].id),(!d.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(d.find(t=>t.id!==this.first)||d[0]).id),u.appendChild(this.#t("compare.first",d,this.first,t=>{this.first=t,this.second===t&&(this.second=(d.find(r=>r.id!==t)||d[0]).id),this.refresh()})),u.appendChild(this.#t("compare.second",d,this.second,t=>{this.second=t,this.first===t&&(this.first=(d.find(r=>r.id!==t)||d[0]).id),this.refresh()}));const s=G(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!s||!s.n){u.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("compare.noPairs")}));return}u.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("compare.pairs",{count:s.n})}));const n=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const t of z){const r=s[t.key];r!=null&&(n.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(t.label)})),n.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,text:S(r)})))}u.appendChild(n)}#t(u,d,s,n){const t=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const r of d)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===s?!0:null}}));return t.value=s,this.off.push(F(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t(u)}),t]})}}}),xe("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return O}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.el,F=X.on,_=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=Object.freeze([{key:"stats.cp",field:"cp",interval:null},{key:"stats.cpk",field:"cpk",interval:"interval"},{key:"stats.pp",field:"pp",interval:null},{key:"stats.ppk",field:"ppk",interval:"intervalPp"},{key:"stats.outOfSpec",field:"outOfSpec",interval:null}]);function S(b){if(b==null||!Number.isFinite(b))return"—";if(Number.isInteger(b))return String(b);const u=Math.abs(b);return u!==0&&(u<.001||u>=1e7)?b.toExponential(2):String(Number(b.toPrecision(4)))}class O extends U{column=null;by=null;#e(){return G(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const u=this.root;if(!u)return;for(const o of this.off)o();this.off.length=0,_(u);const d=this.#e();if(!d.length){u.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.empty")}));return}const s=this.#t();s&&u.appendChild(s);const n=this.#n();n&&u.appendChild(n),u.appendChild(this.#o(d));const t=this.#s();t&&u.appendChild(t);const r=this.#u();r&&u.appendChild(r)}#t(){if(!G(this.host.subsetVsPopulation))return null;const u=this.host.subsetVsPopulation();if(!u)return null;const d=this.#c("insights.subset");return u.filtered?(d.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("stats.filtered",{count:u.subsetN})})),d.appendChild(this.#r(u.ranked)),d):(d.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.noFilter")})),d)}#n(){const u=this.props&&this.props.other;if(!u||!G(this.host.datasetVsDataset))return null;let d;try{d=this.host.datasetVsDataset(u)}catch{return null}if(!d||!d.ranked)return null;const s=this.#c("insights.dataset");return s.appendChild(this.#r(d.ranked)),s}#r(u){const d=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const s of u||[]){const n=B(this.doc,"dt",{class:`${L.panel}__stat-name`});n.appendChild(B(this.doc,"span",{text:String(s.name??s.column)})),n.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:String(s.measure||"")}));const t=B(this.doc,"dd",{class:`${L.panel}__stat-value`});t.appendChild(B(this.doc,"span",{text:S(s.magnitude)})),s.reliable===!1&&t.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:this.t("insights.smallSample")})),d.appendChild(n),d.appendChild(t)}return d}#o(u){const d=this.#c("insights.groups");u.some(n=>n.id===this.column)||(this.column=u[0].id),(!u.some(n=>n.id===this.by)||this.by===this.column)&&(this.by=(u.find(n=>n.id!==this.column)||u[0]).id),d.appendChild(this.#d("stats.column",u,this.column,n=>{this.column=n,this.by===n&&(this.by=(u.find(t=>t.id!==n)||u[0]).id),this.refresh()})),d.appendChild(this.#d("insights.by",u,this.by,n=>{this.by=n,this.column===n&&(this.column=(u.find(t=>t.id!==n)||u[0]).id),this.refresh()}));const s=G(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return s?(d.appendChild(this.#i(s)),d):(d.appendChild(B(this.doc,"p",{class:`${L.panel}__empty`,text:this.t("insights.needGroups")})),d)}#i(u){const d=B(this.doc,"dl",{class:`${L.panel}__stats`});Array.isArray(u.groups)&&u.groups.length===2&&this.#a(d,"insights.groups",`${u.groups[0]} · ${u.groups[1]}`),this.#a(d,"insights.test",String(u.method||u.test||""));const s=u.effectSize||{};this.#a(d,"insights.effect",`${s.name||""} ${S(s.value)}`.trim());const n=u.interval;let t="—";if(n&&Number.isFinite(n.lower)&&Number.isFinite(n.upper)){const o=Number.isFinite(n.confidence)?` (${Math.round(n.confidence*100)}%)`:"";t=`${S(n.lower)} – ${S(n.upper)}${o}`}const r=this.#a(d,"insights.interval",t);return n&&n.method&&r.appendChild(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:String(n.method)})),Number.isFinite(u.pValue)&&this.#a(d,"insights.pValue",S(u.pValue)),d}#s(){if(!G(this.host.anomalies))return null;let u;try{u=this.host.anomalies()}catch{return null}if(!u)return null;const d=this.#c("insights.anomalies");d.appendChild(B(this.doc,"p",{class:`${L.panel}__count`,text:this.t("insights.anomalyCount",{count:u.flagged||0,n:u.n||0})}));const s=B(this.doc,"dl",{class:`${L.panel}__stats`});this.#a(s,"insights.anomalyMethod",String(u.method||""));const n=this.#l(u);n!==null&&this.#a(s,"insights.anomalyThreshold",S(n)),d.appendChild(s);const t=(u.rows||[]).map(r=>({name:r.rowKey!=null?String(r.rowKey):`#${r.index}`,measure:(r.why||[]).map(o=>o.name||o.column).join(", "),magnitude:r.score}));return d.appendChild(this.#r(t)),d}#l(u){if(u.method==="mahalanobis")return Number.isFinite(u.cutoff)?u.cutoff:null;if(u.method==="iqr")return Number.isFinite(u.k)?u.k:null;const d=Array.isArray(u.columns)?u.columns[0]:null;return d&&Number.isFinite(d.threshold)?d.threshold:null}#a(u,d,s){u.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(d)}));const n=B(this.doc,"dd",{class:`${L.panel}__stat-value`});return n.appendChild(B(this.doc,"span",{text:s})),u.appendChild(n),n}#u(){if(!G(this.host.columnCapability)||!this.column)return null;const u=this.host.columnCapability(this.column);if(!u)return null;const d=this.#c("stats.section.capability"),s=B(this.doc,"dl",{class:`${L.panel}__stats`});for(const n of z){const t=u[n.field];if(t==null)continue;s.appendChild(B(this.doc,"dt",{class:`${L.panel}__stat-name`,text:this.t(n.key)}));const r=[B(this.doc,"span",{text:S(t)})],o=n.interval?u[n.interval]:null;o&&Number.isFinite(o.lower)&&r.push(B(this.doc,"span",{class:`${L.panel}__stat-interval`,text:`${S(o.lower)} – ${S(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),s.appendChild(B(this.doc,"dd",{class:`${L.panel}__stat-value`,children:r}))}return d.appendChild(s),d}#c(u){const d=this.doc.createElement("div");return d.appendChild(B(this.doc,"h4",{class:`${L.panel}__subtitle`,text:this.t(u)})),d}#d(u,d,s,n){const t=B(this.doc,"select",{class:`${L.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const r of d)t.appendChild(B(this.doc,"option",{text:r.title,attrs:{value:r.id,selected:r.id===s?!0:null}}));return t.value=s,this.off.push(F(t,"change",()=>n(t.value))),B(this.doc,"label",{class:`${L.panel}__field`,children:[B(this.doc,"span",{class:`${L.panel}__label`,text:this.t(u)}),t]})}}}),xe("packages/dom/src/ui/toolpanel.js",function(e,K){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.cssEscape,F=X.documentFor,_=X.el,Q=X.on,G=X.clear,U=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js"),S=z.isFunction,O=z.nextFrame,b=K("packages/dom/src/cell/icons.js"),u=b.createIcon,d=b.updateIcon,s=b.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,o=K("packages/dom/src/formattingpanel.js").FormattingPanel,l=K("packages/dom/src/statisticspanel.js").StatisticsPanel,g=K("packages/dom/src/regressionpanel.js").RegressionPanel,h=K("packages/dom/src/comparepanel.js").ComparePanel,m=K("packages/dom/src/insightspanel.js").InsightsPanel,v=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,y=K("packages/core/src/compute/total.js").TOTAL_LABELS;class C extends v{dragging=null;refresh(){const R=this.root;if(!R)return;for(const W of this.off)W();this.off.length=0,G(R);const k=_(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(Q(k,"input",()=>{this.query=k.value,this.paintList()})),R.appendChild(k),R.appendChild(this.buildZone("group","Row groups")),R.appendChild(this.buildZone("values","Grouped row calculation")),R.appendChild(this.buildZone("pivot","Pivot"));const I=_(this.doc,"div",{class:`${L.panel}__heading`});I.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const q=_(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),Z=_(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(Q(q,"click",()=>{const W=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);S(this.host.showColumns)&&this.host.showColumns(W),this.refresh()})),this.off.push(Q(Z,"click",()=>{const W=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);S(this.host.hideColumns)&&this.host.hideColumns(W),this.refresh()})),I.appendChild(q),I.appendChild(Z),R.appendChild(I),this.list=_(this.doc,"div",{class:`${L.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),R.appendChild(this.list),this.paintList()}columns(){const R=this.host;return S(R.columns)?R.columns()||[]:R.columns&&S(R.columns.all)?R.columns.all():[]}paintList(){const R=this.list;if(!R)return;G(R);const k=String(this.query||"").trim().toLowerCase();for(const I of this.columns()){const q=String(I.title||I.id||"");if(k&&!q.toLowerCase().includes(k))continue;const Z=_(this.doc,"div",{class:`${L.panel}__column`,attrs:{"data-col":I.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});Z.appendChild(_(this.doc,"span",{class:`${L.panel}__grip`,attrs:{"aria-hidden":"true"}}));const W=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});W.checked=!(I.layout&&I.layout.hidden),I.layout&&I.layout.lockVisible&&W.setAttribute("disabled",""),this.off.push(Q(W,"change",()=>this.setVisible(I.id,W.checked))),Z.appendChild(W),Z.appendChild(_(this.doc,"span",{text:q})),Z.setAttribute("tabindex","0"),Z.setAttribute("role","listitem"),this.off.push(Q(Z,"keydown",J=>this.onRowKey(J,I))),this.off.push(Q(Z,"dragstart",()=>{this.dragging=I.id})),this.off.push(Q(Z,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(Q(Z,"dragover",J=>{if(!this.dragging||this.dragging===I.id)return;S(J.preventDefault)&&J.preventDefault();const ee=D(J,Z);Z.setAttribute("data-drop",ee?"before":"after")})),this.off.push(Q(Z,"dragleave",()=>Z.removeAttribute("data-drop"))),this.off.push(Q(Z,"drop",J=>{S(J.preventDefault)&&J.preventDefault();const ee=this.dragging;this.dragging=null,this.clearDropMark(),!(!ee||ee===I.id)&&this.moveColumn(ee,I.id,D(J,Z))})),R.appendChild(Z)}}onRowKey(R,k){const I=R&&R.key,q=C.zoneKeys[String(I).toLowerCase()];if(q&&!R.ctrlKey&&!R.metaKey&&!R.altKey){S(R.preventDefault)&&R.preventDefault(),this.toggleZone(q,k);return}if(I!=="ArrowUp"&&I!=="ArrowDown")return;const Z=I==="ArrowUp",W=this.columns().map(de=>de.id),J=W.indexOf(k.id);if(J<0)return;if(S(R.preventDefault)&&R.preventDefault(),!R.shiftKey){const de=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ie=de.findIndex(ce=>ce.getAttribute("data-col")===k.id),oe=de[ie+(Z?-1:1)];oe&&S(oe.focus)&&oe.focus();return}const ee=k.layout&&(k.layout.movable===!1||k.layout.lockPosition),te=String(k.title||k.id||"");if(ee){this.announce(this.t("a11y.panel.cannotMove",{column:te}),{repeat:!0});return}const ne=W[J+(Z?-1:1)];if(!ne){this.announce(this.t(Z?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:te}),{repeat:!0});return}this.moveColumn(k.id,ne,Z),this.announce(this.t("a11y.panel.moved",{column:te,at:Z?J:J+2,of:W.length}),{repeat:!0});const ae=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(k.id)}"]`):null;ae&&S(ae.focus)&&ae.focus()}toggleZone(R,k){const I=this.titleOf(k.id),q=this.t(C.zoneLabel[R]||"panel.zone.group");if(this.zoneColumns(R).includes(k.id)){this.dropFromZone(R,k.id),this.announce(this.t("a11y.panel.removedFrom",{column:I,list:q}),{repeat:!0}),this.restoreFocus(k.id);return}if(this.addToZone(R,k.id)){this.announce(this.t("a11y.panel.addedTo",{column:I,list:q}),{repeat:!0}),this.restoreFocus(k.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:I,list:q}),{repeat:!0})}restoreFocus(R){const k=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${B(R)}"]`):null;k&&S(k.focus)&&k.focus()}announce(R,k){const I=this.host||{};S(I.announce)&&I.announce(R,k)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const R of this.list.querySelectorAll("[data-drop]"))R.removeAttribute("data-drop")}moveColumn(R,k,I){const q=this.host||{};S(q.moveColumn)&&(q.moveColumn(R,k,I),this.refresh())}buildZone(R,k){const I=_(this.doc,"div",{class:`${L.panel}__zone`,attrs:{"data-zone":R,role:"group","aria-label":k}});I.appendChild(_(this.doc,"div",{class:`${L.panel}__zoneTitle`,text:k}));const q=this.zoneColumns(R);let Z=C.zoneAbout[R]||"";R==="values"&&q.length&&!this.zoneColumns("group").length&&(Z+=" Add a row group to see them."),Z&&I.appendChild(_(this.doc,"div",{class:`${L.panel}__zoneAbout`,text:Z}));const W=_(this.doc,"div",{class:`${L.panel}__zoneBody`});q.length||W.appendChild(_(this.doc,"span",{class:`${L.panel}__zoneHint`,text:this.t(C.zoneHint[R]||"panel.zoneHint.any")})),R==="values"&&W.classList.add(`${L.panel}__zoneBody--rows`);for(const J of q){const ee=_(this.doc,"span",{class:[L.chip,R==="values"?`${L.chip}--row`:""]});if(ee.appendChild(_(this.doc,"span",{class:`${L.chip}__label`,text:this.titleOf(J)})),R==="values"&&S(this.host.setValueAggregation)){const ne=S(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",ae=_(this.doc,"select",{class:`${L.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const de of C.aggregations)ae.appendChild(_(this.doc,"option",{text:this.t(`total.${de.name}`),attrs:{value:de.name,selected:de.name===ne?"":null}}));ae.value=ne,this.off.push(Q(ae,"change",()=>{this.host.setValueAggregation(J,ae.value),this.refresh()})),ee.appendChild(ae)}const te=_(this.doc,"button",{class:L.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(Q(te,"click",()=>this.dropFromZone(R,J))),ee.appendChild(te),W.appendChild(ee)}return this.off.push(Q(I,"dragover",J=>{S(J.preventDefault)&&J.preventDefault(),I.setAttribute("data-over","true")})),this.off.push(Q(I,"dragleave",()=>I.removeAttribute("data-over"))),this.off.push(Q(I,"drop",J=>{S(J.preventDefault)&&J.preventDefault(),I.removeAttribute("data-over"),this.dragging&&this.addToZone(R,this.dragging)})),I.appendChild(W),I}static aggregations=Object.freeze(Object.keys(y).map(R=>({name:R})));static zoneAbout=Object.freeze({group:"Rows are grouped by these columns, in order.",values:"Each column here is calculated for every group. Pick the calculation on its chip.",pivot:"Generates a column for each distinct value."});static zoneHint=Object.freeze({group:"panel.zoneHint.group",values:"panel.zoneHint.values",pivot:"panel.zoneHint.pivot"});static zoneKeys=Object.freeze({g:"group",v:"values",p:"pivot"});static zoneLabel=Object.freeze({group:"panel.zone.group",values:"panel.zone.values",pivot:"panel.zone.pivot"});static zoneApi=Object.freeze({group:{read:"groupBy",write:"setGroupBy",permission:"allowGroup"},values:{read:"valueColumns",write:"setValueColumns",permission:"allowTotal"},pivot:{read:"pivotBy",write:"setPivotBy",permission:"allowPivot"}});zoneColumns(R){const k=C.zoneApi[R],I=this.host;return k&&S(I[k.read])?I[k.read]()||[]:[]}titleOf(R){const k=this.columns().find(I=>I.id===R);return String(k&&(k.title||k.id)||R)}addToZone(R,k){const I=C.zoneApi[R],q=this.columns().find(W=>W.id===k);if(!I||!q||q[I.permission]===!1||!S(this.host[I.write]))return!1;const Z=this.zoneColumns(R);return Z.includes(k)?!1:(this.host[I.write]([...Z,k]),this.refresh(),!0)}dropFromZone(R,k){const I=C.zoneApi[R];return!I||!S(this.host[I.write])?!1:(this.host[I.write](this.zoneColumns(R).filter(q=>q!==k)),this.refresh(),!0)}setVisible(R,k){const I=this.host;k&&S(I.showColumns)?I.showColumns([R]):!k&&S(I.hideColumns)&&I.hideColumns([R])}}class T extends v{open=new Set;query="";#e=!1;#t=!1;refresh(){if(this.#e){this.#t=!0;return}this.#e=!0;try{do this.#t=!1,this.#n();while(this.#t)}finally{this.#e=!1}}#n(){const R=this.root;if(!R)return;for(const ee of this.off)ee();this.off.length=0,G(R);const k=this.host,I=(S(k.columns)?k.columns():[]).filter(ee=>!(ee.filter&&ee.filter.enabled===!1));if(!S(k.filterFor))return;const q=I.filter(ee=>this.isFiltered(ee.id));R.appendChild(this.buildSearch()),R.appendChild(this.buildSummary(q.length,I.length));const Z=this.query.trim().toLowerCase(),W=Z?I.filter(ee=>String(ee.title||ee.id).toLowerCase().includes(Z)):I;if(!W.length){R.appendChild(_(this.doc,"p",{class:`${L.panel}__empty`,text:Z?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${L.panel}__filters`});for(const ee of W)J.appendChild(this.buildSection(ee));R.appendChild(J)}isFiltered(R){const k=this.host;return S(k.isFiltered)?k.isFiltered(R)===!0:!1}buildSearch(){const R=_(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return R.value=this.query,this.off.push(Q(R,"input",()=>{this.query=R.value||"",this.refresh();const k=this.root&&this.root.querySelector?this.root.querySelector(`.${L.panel}__search`):null;k&&S(k.focus)&&k.focus()})),R}buildSummary(R,k){const I=_(this.doc,"div",{class:`${L.panel}__filterSummary`});if(I.appendChild(_(this.doc,"span",{class:`${L.panel}__filterCount`,text:R?this.t("panel.filterSummaryActive",{active:R,total:k}):this.t("panel.filterSummaryNone",{total:k}),attrs:{"data-active":R?"true":"false"}})),!R)return I;const q=_(this.doc,"button",{class:`${L.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(Q(q,"click",()=>{S(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),I.appendChild(q),I}buildSection(R){const k=R.id,I=String(R.title||k),q=this.isFiltered(k),Z=this.open.has(k),W=_(this.doc,"section",{class:`${L.panel}__filter`,attrs:{"data-col":k,"data-filtered":q?"true":null}}),J=_(this.doc,"button",{class:`${L.panel}__filterTitle`,attrs:{type:"button","aria-expanded":Z?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:I})},children:[u(this.doc,Z?"chevronDown":"chevronRight",{className:`${L.panel}__twisty`}),_(this.doc,"span",{class:`${L.panel}__filterName`,text:I})]});q&&J.appendChild(_(this.doc,"span",{class:`${L.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ee=_(this.doc,"div",{class:`${L.panel}__filterBody`,style:{display:Z?"":"none"}}),te=()=>{if(ee.firstChild)return;const ne=this.host.filterFor(k);ne&&S(ne.element)&&ee.appendChild(ne.element())};if(this.off.push(Q(J,"click",()=>{const ne=this.open.has(k);ne?this.open.delete(k):this.open.add(k),J.setAttribute("aria-expanded",ne?"false":"true"),ee.style.display=ne?"none":"";const ae=J.firstElementChild;ae&&d(ae,ne?"chevronRight":"chevronDown"),ne||te()})),W.appendChild(J),q){const ne=_(this.doc,"button",{class:`${L.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:I}),title:this.t("panel.clearFilter")},children:[u(this.doc,"close",{className:L.icon})]});this.off.push(Q(ne,"click",ae=>{S(ae.stopPropagation)&&ae.stopPropagation(),S(this.host.clearFilter)&&this.host.clearFilter(k),this.refresh()})),W.appendChild(ne)}return W.appendChild(ee),Z&&te(),W}}class P extends v{refresh(){const R=this.root;if(!R)return;if(this.box){const Z=S(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==Z&&(this.box.value=Z),this.paintCount();return}for(const Z of this.off)Z();this.off.length=0,G(R);const k=S(this.host.quickFilter)?this.host.quickFilter():"",I=_(this.doc,"input",{class:`${L.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});I.value=k||"",this.off.push(Q(I,"input",()=>{S(this.host.setQuickFilter)&&this.host.setQuickFilter(I.value),this.paintCount()})),R.appendChild(I),this.box=I;const q=_(this.doc,"button",{class:`${L.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(Q(q,"click",()=>{I.value="",S(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),S(I.focus)&&I.focus()})),R.appendChild(q),this.count=_(this.doc,"p",{class:`${L.panel}__count`}),R.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){O(()=>{this.box&&S(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const R=S(this.host.rowCount)?this.host.rowCount():null,k=S(this.host.totalRowCount)?this.host.totalRowCount():null;if(R===null||k===null){this.count.textContent="";return}this.count.textContent=R===k?this.t("count.rows",{count:k}):this.t("panel.rowsOf",{shown:R,total:k})}}const x=Object.freeze({columns:C,filters:T,views:t,quick:P,formatting:o,statistics:l,regression:g,compare:h,insights:m}),E=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),j=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class A{panels=[];actions=[];root=null;openPanel=null;off=[];t(R,k){return(this.messages&&typeof this.messages.t=="function"?this.messages:U).t(R,k)}init(R){const k=R||{};this.doc=F(k),this.host=k.host||{},this.messages=k.messages||k.grid&&k.grid.messages||U,this.icons=k.icons===void 0?k.side==="left":!!k.icons,this.side=k.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[L.panel,`${L.panel}--${this.side}`,this.icons?`${L.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${L.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${L.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=_(this.doc,"div",{class:`${L.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const Z of Array.isArray(k.actions)?k.actions:[])this.registerAction(Z);const I=k.registry||{},q=Array.isArray(k.panels)&&k.panels.length?k.panels:["columns","filters"];for(const Z of q){const W=typeof Z=="string"?Z:Z.name,J=typeof Z=="function"?Z:I[W]||x[W];J&&this.registerPanel(String(W),J,typeof Z=="object"?Z:{})}k.openPanel&&this.show(k.openPanel)}registerPanel(R,k,I){const q=new k;q.init({document:this.doc,host:this.host,props:I&&I.props||{}});const Z=I&&I.title||R,W=I&&I.icon||R,J=_(this.doc,"button",{class:`${L.panel}__tab`,text:this.icons?null:Z,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":R,title:this.icons?Z:null,"aria-label":this.icons?Z:null}});return this.icons&&J.appendChild(u(this.doc,W,{className:`${L.panel}__icon`})),this.off.push(Q(J,"click",()=>this.toggle(R))),this.tabs.appendChild(J),this.panels.push({name:R,title:Z,panel:q}),q}registerAction(R){if(!R||!R.name)return null;if(R.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${L.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const k=_(this.doc,"button",{class:`${L.panel}__action`,text:this.icons?null:S(R.title)?String(R.title()):R.title,attrs:{type:"button","data-action":R.name,title:S(R.title)?null:R.title,"aria-label":S(R.title)?null:R.title}});if(this.icons){const Z=(S(R.icon)?R.icon():R.icon)||(s(R.name)?R.name:"blank");k.appendChild(u(this.doc,Z,{className:`${L.panel}__icon`})),k.setAttribute("data-icon",Z)}const I=Q(k,"click",()=>{S(R.enabled)&&!R.enabled()||(S(R.run)&&R.run(),this.paintActions())});return this.off.push(I),this.actionGroup.appendChild(k),this.actions.push({...R,button:k,offClick:I}),this.paintActions(),k}removeAction(R){const k=this.actions.findIndex(q=>q.name===R);if(k<0)return!1;const I=this.actions[k];return S(I.offClick)&&I.offClick(),I.button&&I.button.parentNode&&I.button.parentNode.removeChild(I.button),this.actions.splice(k,1),!0}paintActions(){for(const R of this.actions){if(!R.button)continue;const k=S(R.enabled)?!!R.enabled():!0;if(R.button.disabled=!k,R.button.setAttribute("aria-disabled",k?"false":"true"),S(R.active)&&R.button.setAttribute("aria-pressed",R.active()?"true":"false"),S(R.title)){const I=String(R.title());R.button.setAttribute("title",I),R.button.setAttribute("aria-label",I),!this.icons&&R.button.textContent!==I&&(R.button.textContent=I)}if(this.icons&&S(R.icon)){const I=String(R.icon());R.button.getAttribute("data-icon")!==I&&(G(R.button),R.button.appendChild(u(this.doc,I,{className:`${L.panel}__icon`})),R.button.setAttribute("data-icon",I))}}}show(R){const k=this.panels.find(I=>I.name===R);return k?(G(this.body),S(k.panel.refresh)&&k.panel.refresh(),this.body.appendChild(k.panel.element()),this.openPanel=R,this.paintTabs(),S(k.panel.focus)&&k.panel.focus(),!0):!1}hide(){G(this.body),this.openPanel=null,this.paintTabs()}toggle(R){this.openPanel===R?this.hide():this.show(R)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let R=0;R<this.tabs.childNodes.length;R++){const k=this.tabs.childNodes[R];k&&k.setAttribute&&k.setAttribute("aria-selected",k.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const R=this.panels.find(k=>k.name===this.openPanel);R&&S(R.panel.refresh)&&!this.#e(R.panel)&&R.panel.refresh(),this.paintActions()}#e(R){const k=this.doc&&this.doc.activeElement;if(!k||k===this.doc.body)return!1;const I=S(R.element)?R.element():null;return!!(I&&S(I.contains)&&I.contains(k))}destroy(){for(const R of this.off)R();this.off.length=0;for(const R of this.panels)S(R.panel.destroy)&&R.panel.destroy();this.panels=[],this.root=null}}const $=A;function D(M,R){if(!R.getBoundingClientRect||typeof M.clientY!="number")return!0;const k=R.getBoundingClientRect();return M.clientY<k.top+k.height/2}}),xe("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return O}});const L=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=K("packages/dom/src/editors/common.js"),F=B.CLS,_=B.el,Q=B.on,G=B.clear,H=B.cssEscape,z=K("packages/core/src/internal/util.js").isFunction,S="text/x-lattice-col";class O extends L{dragging=null;#e=[];init(u){this.ctx=u,this.doc=u.document,this.host=u.host||{},this.props=u.props||{},this.root=_(this.doc,"div",{class:F.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const u=this.host;return z(u.columns)?u.columns()||[]:u.columns&&z(u.columns.all)?u.columns.all():[]}groups(){return z(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(u){z(this.host.setGroupBy)&&this.host.setGroupBy(u)}titleOf(u){const d=this.columns().find(s=>s.id===u);return String(d&&(d.title||d.id)||u)}canGroup(u){const d=this.columns().find(s=>s.id===u);return!!d&&d.allowGroup!==!1&&!d.generated}announce(u,d){z(this.host.announce)&&this.host.announce(u,d)}refresh(){const u=this.root;if(!u)return;for(const n of this.off)n();this.off.length=0,G(u),u.appendChild(_(this.doc,"span",{class:F.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const d=this.groups(),s=_(this.doc,"div",{class:F.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});d.length||s.appendChild(_(this.doc,"span",{class:F.groupZoneHint,text:this.t("groupZone.hint")})),d.forEach((n,t)=>s.appendChild(this.#t(n,t,d.length))),u.appendChild(s),this.chips=s,u.appendChild(this.#i(d)),this.off.push(Q(u,"dragover",n=>{this.dragging==null&&!this.#l(n)||(z(n.preventDefault)&&n.preventDefault(),u.setAttribute("data-over","true"))})),this.off.push(Q(u,"dragleave",()=>u.removeAttribute("data-over"))),this.off.push(Q(u,"drop",n=>{z(n.preventDefault)&&n.preventDefault(),u.removeAttribute("data-over");const t=this.#l(n)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(u,d,s){const n=this.titleOf(u),t=_(this.doc,"div",{class:[F.chip,F.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":u,"aria-label":this.t("groupZone.chip",{column:n,at:d+1,of:s})}});t.appendChild(_(this.doc,"span",{class:F.groupZoneChipText,text:n}));const r=_(this.doc,"button",{class:F.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:n})}});return this.off.push(Q(r,"click",()=>this.#r(u))),t.appendChild(r),this.off.push(Q(t,"dragstart",o=>{this.dragging=u,o.dataTransfer&&z(o.dataTransfer.setData)&&o.dataTransfer.setData(S,u)})),this.off.push(Q(t,"dragend",()=>{this.dragging=null})),this.off.push(Q(t,"dragover",o=>{const f=this.#l(o)||this.dragging;f==null||f===u||z(o.preventDefault)&&o.preventDefault()})),this.off.push(Q(t,"drop",o=>{const f=this.#l(o)||this.dragging;f!=null&&(z(o.preventDefault)&&o.preventDefault(),z(o.stopPropagation)&&o.stopPropagation(),this.#o(f,d))})),this.off.push(Q(t,"keydown",o=>this.#n(o,u,d))),t}#n(u,d,s){const n=u&&u.key,t=this.groups();if(n==="Delete"||n==="Backspace"){z(u.preventDefault)&&u.preventDefault(),this.#r(d,t,s);return}const r=n==="ArrowLeft"||n==="ArrowUp",o=n==="ArrowRight"||n==="ArrowDown",f=n==="Home",l=n==="End";if(!r&&!o&&!f&&!l)return;if(z(u.preventDefault)&&u.preventDefault(),u.shiftKey&&(r||o)){const c=s+(r?-1:1);if(c<0||c>=t.length){this.announce(this.t(r?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(d)}),{repeat:!0});return}const h=t.slice();h.splice(s,1),h.splice(c,0,d),this.setGroups(h),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(d),at:c+1,of:h.length}),{repeat:!0}),this.#a(d);return}let i=s+(r?-1:o?1:0);f&&(i=0),l&&(i=t.length-1);const g=t[i];g&&this.#a(g)}#r(u,d=this.groups(),s=d.indexOf(u)){const n=this.titleOf(u);this.setGroups(d.filter(r=>r!==u)),this.announce(this.t("a11y.panel.removedFrom",{column:n,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(s,t.length-1)]):this.#u()}#o(u,d){if(!this.canGroup(u)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0});return}const s=this.groups(),n=s.indexOf(u),t=s.slice();n>=0&&(t.splice(n,1),n<d&&(d-=1)),t.splice(Math.max(0,Math.min(d,t.length)),0,u),this.setGroups(t);const r=t.indexOf(u);this.announce(this.t(n>=0?"a11y.panel.moved":"a11y.panel.addedTo",n>=0?{column:this.titleOf(u),at:r+1,of:t.length}:{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(u)}#i(u){const d=new Set(u),s=_(this.doc,"label",{class:F.groupZoneAdd}),n=_(this.doc,"select",{class:F.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});n.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())d.has(t.id)||!this.canGroup(t.id)||n.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(Q(n,"change",()=>{const t=n.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=n,s.appendChild(n),s}#s(){for(const d of this.#e)d();this.#e.length=0;const u=this.props&&this.props.header;if(!(!u||!z(u.querySelectorAll)))for(const d of u.querySelectorAll("[data-col]")){const s=z(d.getAttribute)?d.getAttribute("data-col"):null;!s||!this.canGroup(s)||(z(d.setAttribute)&&d.setAttribute("draggable","true"),this.#e.push(Q(d,"dragstart",n=>{this.dragging=s,n.dataTransfer&&z(n.dataTransfer.setData)&&n.dataTransfer.setData(S,s)})),this.#e.push(Q(d,"dragend",()=>{this.dragging=null})))}}#l(u){const d=u&&u.dataTransfer;if(d&&z(d.getData)){const s=d.getData(S);if(s)return s}return null}#a(u){const d=this.chips&&z(this.chips.querySelector)?this.chips.querySelector(`[data-col="${H(u)}"]`):null;d&&z(d.focus)&&d.focus()}#u(){this.adderSelect&&z(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const u of this.#e)u();this.#e.length=0,super.destroy()}}}),xe("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,_=X.on,Q=X.clear,H=K("packages/core/src/internal/util.js").isFunction;class U{root=null;init(b){this.doc=b.document,this.root=F(this.doc,"div",{class:`${L.tooltip}__text`}),this.update(b.content)}update(b){if(!this.root)return;const u=b==null?"":String(b);this.root.textContent!==u&&(this.root.textContent=u)}element(){return this.root}destroy(){this.root=null}}class z{root=null;component=null;timer=null;target=null;off=[];constructor(b){const u=b||{};this.doc=B(u),this.host=u.host||this.doc.body,this.delay=u.delay??400,this.hideDelay=u.hideDelay??0,this.components={text:U,...u.components||{}}}show(b){this.cancelTimer();const u=b.delay??this.delay;if(!u){this.showNow(b);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(b)},u)}showNow(b){const u=b.component||"text",d=typeof u=="function"?u:this.components[u]||U;return this.root||(this.root=F(this.doc,"div",{class:L.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==d?(this.component&&H(this.component.destroy)&&this.component.destroy(),Q(this.root),this.component=new d,this.componentCtor=d,this.component.init({document:this.doc,content:b.content,...b.props||{}}),this.root.appendChild(this.component.element())):H(this.component.update)&&this.component.update(b.content),this.target=b.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!H(this.target.getBoundingClientRect))return;const b=this.target.getBoundingClientRect(),u=this.doc.defaultView||{};this.root.style.left=`${b.left+(u.scrollX||0)}px`,this.root.style.top=`${b.bottom+(u.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(b,u,d){const s=()=>this.show({target:b,content:u(),...d||{}}),n=()=>this.hide(),t=[_(b,"mouseenter",s),_(b,"mouseleave",n),_(b,"focus",s),_(b,"blur",n)],r=()=>{for(const o of t)o()};return this.off.push(r),r}destroy(){this.hide();for(const b of this.off)b();this.off.length=0,this.component&&H(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const S=z}),xe("packages/dom/src/ui/pagination.js",function(e,K){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,_=X.on,Q=X.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,z=K("packages/core/src/internal/util.js").isFunction;function S(u){const d=Math.max(1,Number(u.pageSize)||100),s=u.total==null?null:Math.max(0,Number(u.total)),n=s==null?null:Math.max(1,Math.ceil(s/d)),t=Math.max(0,n==null?Number(u.page)||0:Math.min(Number(u.page)||0,n-1)),r=s===0?0:t*d+1,o=s==null?(t+1)*d:Math.min(s,(t+1)*d);return{page:t,pageSize:d,pageCount:n,from:r,to:o,first:t===0,last:n==null?u.hasMore!==!0:t>=n-1,total:s}}class O{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(d){const s=d||{};this.doc=B(s),this.host=s.host||{},this.pageSize=Number(s.pageSize)||100;const n=Array.isArray(s.pageSizes)&&s.pageSizes.length?[...s.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!n.includes(this.pageSize)&&n.push(this.pageSize),this.pageSizes=n.sort((t,r)=>t-r),this.page=Number(s.page)||0,this.total=s.total===void 0?null:s.total,this.locale=s.locale,this.messages=s.messages||null,this.onChange=s.onChange||null,this.root=F(this.doc,"nav",{class:L.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(d,s){const n=this.messages;return(n&&typeof n.t=="function"?n:H).t(d,s)}element(){return this.root}model(){return S({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(d){d.total!==void 0&&(this.total=d.total),d.counting!==void 0&&(this.counting=d.counting===!0),d.hasMore!==void 0&&(this.hasMore=d.hasMore===!0),d.page!==void 0&&(this.page=Number(d.page)||0),this.paint()}goTo(d){const s=this.page;this.page=d;const n=this.model();return this.page=n.page,this.paint(),this.page!==s&&z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize}),this.page}next(){return this.model().last?this.page:this.goTo(this.page+1)}previous(){return this.page===0?0:this.goTo(this.page-1)}last(){const d=this.model();return d.pageCount==null?this.page:this.goTo(d.pageCount-1)}setPageSize(d){const s=this.page*this.pageSize;this.pageSize=Math.max(1,Number(d)||1),this.page=Math.floor(s/this.pageSize),this.paint(),z(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const d=this.root;if(!d)return;for(const i of this.off)i();this.off.length=0,Q(d);const s=this.model(),n=F(this.doc,"select",{class:`${L.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const i of this.pageSizes)n.appendChild(F(this.doc,"option",{text:String(i),attrs:{value:i}}));n.value=String(this.pageSize),this.off.push(_(n,"change",()=>this.setPageSize(Number(n.value)))),d.appendChild(n);const t=s.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:s.from,to:s.to}):this.t("pagination.summary",{from:s.from,to:s.to,total:s.total});d.appendChild(F(this.doc,"span",{class:`${L.pagination}__summary`,text:t}));const r=(i,g,c,h)=>{const a=F(this.doc,"button",{class:`${L.pagination}__button`,text:i,attrs:{type:"button","aria-label":h,disabled:c?"":null}});return c||this.off.push(_(a,"click",g)),a};d.appendChild(r("«",()=>this.goTo(0),s.first,this.t("pagination.first"))),d.appendChild(r("‹",()=>this.previous(),s.first,this.t("pagination.previous")));const o=F(this.doc,"span",{class:`${L.pagination}__page`});o.appendChild(F(this.doc,"span",{text:`${this.t("pagination.page")} `}));const f=F(this.doc,"input",{class:`${L.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":s.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:s.pageCount}),size:String(Math.max(2,String(s.pageCount??s.page+1).length))}});f.value=String(s.page+1);const l=()=>{const i=parseInt(String(f.value).trim(),10);if(!Number.isFinite(i)){f.value=String(this.model().page+1);return}this.goTo(i-1)};this.off.push(_(f,"keydown",i=>{i.key==="Enter"?(l(),i.preventDefault?.()):i.key==="Escape"?(f.value=String(this.model().page+1),f.blur?.()):i.stopPropagation?.()})),this.off.push(_(f,"blur",()=>l())),this.off.push(_(f,"focus",()=>f.select?.())),o.appendChild(f),s.pageCount!=null&&o.appendChild(F(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:s.pageCount})}`})),d.appendChild(o),d.appendChild(r("›",()=>this.next(),s.last,this.t("pagination.next"))),d.appendChild(r("»",()=>this.last(),s.last||s.pageCount==null,this.t("pagination.last")))}destroy(){for(const d of this.off)d();this.off.length=0,this.root=null}}const b=O}),xe("packages/dom/src/ui/overlay.js",function(e,K){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const X=K("packages/dom/src/editors/common.js"),L=X.CLS,B=X.documentFor,F=X.el,_=X.clear,G=K("packages/core/src/internal/util.js").isFunction,U=K("packages/core/src/i18n/index.js").defaultMessages;function z(s,n){const t=s&&s.grid&&s.grid.messages;return(t&&G(t.t)?t:U).t(n)}class S{root=null;init(n){this.doc=n.document,this.root=F(this.doc,"div",{class:`${L.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[F(this.doc,"span",{class:`${L.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),F(this.doc,"span",{class:`${L.overlay}__message`,text:n.message||z(n,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class O{root=null;init(n){this.doc=n.document,this.root=F(this.doc,"div",{class:`${L.overlay}__empty`,attrs:{role:"status"},children:[F(this.doc,"span",{class:`${L.overlay}__message`,text:n.message||z(n,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const b=Object.freeze({loading:S,empty:O});class u{root=null;slot=null;component=null;current=null;init(n){const t=n||{};this.doc=B(t),this.components={...b,...t.components||{}},this.root=F(this.doc,"div",{class:L.overlay,attrs:{"data-open":"false"}}),this.slot=F(this.doc,"div",{class:`${L.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(n,t){const r=typeof n=="function"?n:this.components[n];return r?(this.hide(),this.component=new r,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof n=="string"?n:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&G(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&_(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(n,t){this.components[n]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const d=u}),xe("packages/dom/src/ui/index.js",function(e,K){"use strict";const X=K("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return X.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return X.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return X.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return X.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return X.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return X.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return X.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return X.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return X.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return X.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return X.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return X.formatNumber}});const L=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return L.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return L.resolveMenuItems}});const B=K("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return B.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return B.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return B.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return B.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return B.toolPanels}});const F=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return F.GroupByZone}});const _=K("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return _.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return _.TextTooltip}});const Q=K("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return Q.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return Q.pageModel}});const G=K("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return G.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return G.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return G.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return G.overlays}})}),xe("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,_=X.clear,Q=K("packages/core/src/internal/util.js"),G=Q.isFunction,H=Q.warnOnce,z=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,O=K("packages/dom/src/detailhost.js").insideDetail,u=K("packages/dom/src/renderer/renderer.js").displayIndexOf,d=K("packages/dom/src/renderer/viewport.js"),s=d.CLASS,n=d.NAMESPACE,r=K("packages/dom/src/themeof.js").carryTheme,o={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},f=400,l=140,i=6;let g=0;class c{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#f=null;#h=[];#p=!1;constructor(m){const w=m||{};this.#e=w.grid,this.#t=w.host,this.#n=w.viewport,this.#r=L(w),g+=1,this.#s=`lat-cell-tooltip-${g}`}mount(){const m=this.#n&&this.#n.root;if(!m||!G(m.addEventListener))return;const w=this.#e.on("cell:mouseover",y=>this.#w(y));G(w)&&this.#h.push(w);const v=this.#e.on("cell:mouseout",()=>this.#A());G(v)&&this.#h.push(v),this.#h.push(F(m,"focusin",y=>this.#k(y))),this.#h.push(F(m,"focusout",()=>this.#A())),this.#h.push(F(this.#r,"keydown",y=>this.#b(y),!0));const p=this.#r.defaultView;p&&G(p.addEventListener)&&this.#h.push(F(p,"scroll",()=>this.hide(),!0))}#m(){const m=G(this.#e.get)?this.#e.get("tooltip"):null,w=m&&typeof m=="object"?m:{},v=Number.isFinite(w.delay)&&w.delay>=0?Number(w.delay):f,p=w.maxWidth;return{delay:v,hideDelay:l,maxWidth:typeof p=="number"&&Number.isFinite(p)?`${p}px`:typeof p=="string"&&p?p:null}}#g(m){const w=m&&m.cell?m.cell.tooltip:null;return!w||typeof w!="object"||Array.isArray(w)||!G(w.render)&&!G(w.mount)?null:w}#y(m){if(!m||!G(m.closest))return null;const w=m.closest(`.${s.row}`);if(!w)return null;const v=u(w);if(v<0)return null;const p=this.#t.rowAt(v);if(!p)return null;const y=m.getAttribute("data-col");if(!y)return null;const C=this.#t.columns.get(y);return C?{row:p,key:p.key,index:v,colId:y,column:C,value:this.#t.cellValue?this.#t.cellValue(p,C):void 0,text:this.#t.cellText?this.#t.cellText(p,C):"",cell:m,grid:this.#e}:null}#w(m){const w=m&&m.target;if(!this.#g(m&&m.column)){this.#A();return}this.#O(w)}#k(m){const w=m&&m.target;if(!w||!G(w.closest)||O(w,this.#n.root))return;const v=w.closest(`.${s.cell}`);if(!v||v!==w){this.#A();return}const p=v.getAttribute("data-col"),y=p?this.#t.columns.get(p):null;if(!this.#g(y)){this.#A();return}this.#O(v)}#b(m){!m||m.key!=="Escape"||m.defaultPrevented||this.#l&&(G(m.preventDefault)&&m.preventDefault(),this.hide())}#O(m){if(this.#p||!m||(this.#x(),this.#l&&this.#a===m))return;this.#L();const{delay:w}=this.#m();if(!w){this.#j(m);return}this.#d=setTimeout(()=>{this.#d=null,this.#j(m)},w)}#A(){if(this.#L(),!this.#l||this.#f!==null)return;const{hideDelay:m}=this.#m();this.#f=setTimeout(()=>{this.#f=null,this.hide()},m)}#P(){if(this.#o)return this.#o;const m=this.#r,w=B(m,"div",{class:[n,o.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=B(m,"div",{class:o.body}),w.appendChild(this.#i),this.#h.push(F(w,"mouseenter",()=>this.#x())),this.#h.push(F(w,"mouseleave",()=>this.#A()));const v=m.body;return v&&G(v.appendChild)&&v.appendChild(w),this.#o=w,w}#S(m,w){const v=this.#i;if(_(v),m==null||m==="")return!1;if(typeof m=="string")return v.textContent=m,!0;if(typeof m=="object"){if(typeof m.nodeType=="number")return v.appendChild(m),!0;const p=m;if(typeof p.html=="string")return v.innerHTML=z(p.html),!0;if(p.title!==void 0||p.rows!==void 0||p.note!==void 0)return this.#M(p),!0}return H(`tooltip-content:${w}`,`Column '${w}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#M(m){const w=this.#r,v=this.#i,p=C=>C==null?"":String(C);m.title!==void 0&&m.title!==null&&m.title!==""&&v.appendChild(B(w,"div",{class:o.title,text:p(m.title)}));const y=Array.isArray(m.rows)?m.rows:[];if(y.length){const C=B(w,"div",{class:o.rows});for(const T of y){if(!T||typeof T!="object")continue;const P=B(w,"div",{class:o.row});P.appendChild(B(w,"span",{class:o.label,text:p(T.label)})),P.appendChild(B(w,"span",{class:o.value,text:p(T.value)})),C.appendChild(P)}v.appendChild(C)}m.note!==void 0&&m.note!==null&&m.note!==""&&v.appendChild(B(w,"div",{class:o.note,text:p(m.note)}))}#j(m){if(this.#p)return;const w=this.#y(m);if(!w){this.hide();return}const v=this.#g(w.column);if(!v){this.hide();return}this.hide();const p=this.#P();r(p,this.#n&&this.#n.root);let y;if(G(v.render))try{y=v.render(w)}catch(P){H(`tooltip-render:${w.colId}`,`Column '${w.colId}' cell.tooltip render threw; no tooltip was shown.`,P);return}const C=this.#S(y,w.colId);if(G(v.mount))try{v.mount(this.#i,w),this.#u=v}catch(P){H(`tooltip-mount:${w.colId}`,`Column '${w.colId}' cell.tooltip mount threw; the tooltip was closed.`,P),this.hide();return}else if(!C)return;const{maxWidth:T}=this.#m();T&&(p.style.maxWidth=T),this.#a=m,this.#l=!0,p.setAttribute("data-open","true"),this.#E(m),this.#R(m)}#E(m){if(!G(m.setAttribute))return;const w=G(m.getAttribute)?m.getAttribute("aria-describedby"):null;this.#c={cell:m,previous:w},m.setAttribute("aria-describedby",w?`${w} ${this.#s}`:this.#s)}#R(m){const w=this.#o;if(!w||!G(m.getBoundingClientRect))return;const v=this.#r.defaultView;if(!v)return;const p=m.getBoundingClientRect(),y=G(w.getBoundingClientRect)?w.getBoundingClientRect():{width:0,height:0},C=v.innerWidth||0,T=v.innerHeight||0,P=y.width||0,x=y.height||0;let E=p.bottom+i;const j=p.top-i-x;E+x>T-i&&j>=i&&(E=j),T&&(E=Math.max(i,Math.min(E,Math.max(i,T-x-i))));let A=p.left;C&&(A=Math.min(A,Math.max(i,C-P-i))),A=Math.max(i,A),w.style.left=`${Math.round(A)}px`,w.style.top=`${Math.round(E)}px`}hide(){if(this.#L(),this.#x(),!this.#l)return;if(this.#l=!1,this.#u&&G(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(w){H("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",w)}this.#u=null,this.#i&&_(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const m=this.#c;m&&G(m.cell.setAttribute)&&(m.previous?m.cell.setAttribute("aria-describedby",m.previous):G(m.cell.removeAttribute)&&m.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#L(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#x(){this.#f!==null&&(clearTimeout(this.#f),this.#f=null)}destroy(){this.hide(),this.#p=!0;for(const m of this.#h)m();this.#h.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=c}),xe("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return X}});function X(){const L=globalThis.navigator,B=String(L&&(L.userAgentData?.platform||L.platform)||"");return/mac|iphone|ipad/i.test(B)}}),xe("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/dom/src/platform.js").macLike,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/dom/src/ui/contextmenu.js").ContextMenu,z=K("packages/core/src/compute/total.js"),S=z.aggregatesFor,O=z.totalLabel,b=10,u=150;function d(v,p){const y=(ee,te)=>(v&&v.messages?v.messages:G).t(ee,te),C=v.columns.get(p);if(!C)return[];const T=v.sort.get(),P=T.find(ee=>ee.col===p),x=C.layout&&C.layout.pin,E=v.state.get().group||[],j=E.includes(p);if(C.generated&&Array.isArray(C.groupedIds))return r(v,C,E);const A=!C.sort||C.sort.enabled!==!1,$=!C.filter||C.filter.enabled!==!1,D=[];A&&D.push({name:y("menu.sortAscending"),icon:"↑",disabled:P&&P.dir==="asc",action:()=>v.sort.set([{col:p,dir:"asc"}])},{name:y("menu.sortDescending"),icon:"↓",disabled:P&&P.dir==="desc",action:()=>v.sort.set([{col:p,dir:"desc"}])},{name:y("menu.clearSort"),disabled:!P,action:()=>v.sort.set(T.filter(ee=>ee.col!==p))},{separator:!0}),$&&D.push({name:y("menu.filterEllipsis"),action:()=>v.emit("column:filter:open",{colId:p})},{separator:!0}),D.push({name:y("menu.columnStatistics"),action:()=>v.emit("column:profile:open",{colId:p})},{separator:!0}),D.push({name:y("menu.pinColumn"),children:[{name:y("menu.pinStart"),disabled:x==="start",action:()=>v.columns.pin(p,"start")},{name:y("menu.pinEnd"),disabled:x==="end",action:()=>v.columns.pin(p,"end")},{name:y("menu.unpin"),disabled:!x,action:()=>v.columns.pin(p,null)}]});const M=!(C.layout&&(C.layout.movable===!1||C.layout.lockPosition)),R=!(C.layout&&C.layout.resizable===!1),k=ee=>{const te=v.columns.get(ee);return Number(te&&te.layout&&te.layout.width)||u},I=v.columns.visible().filter(ee=>!ee.generated).map(ee=>ee.id),q=I.indexOf(p);if(D.push({name:y("menu.sizeToFit"),action:()=>v.columns.autoSize(p)},{name:y("menu.sizeAllToFit"),action:()=>v.columns.fit()},{name:y("menu.width"),disabled:!R,children:[{name:y("menu.narrower"),disabled:!R,action:()=>v.columns.resize(p,Math.max(1,k(p)-b))},{name:y("menu.wider"),disabled:!R,action:()=>v.columns.resize(p,k(p)+b)},{name:y("menu.autosize"),disabled:!R,action:()=>v.columns.autoSize(p)}]},{separator:!0},{name:y("menu.moveColumn"),disabled:!M,children:[{name:y("menu.moveLeft"),disabled:!M||q<=0,action:()=>v.columns.move(p,Math.max(0,q-1))},{name:y("menu.moveRight"),disabled:!M||q<0||q>=I.length-1,action:()=>v.columns.move(p,Math.min(I.length-1,q+1))},{name:y("menu.moveToStart"),disabled:!M||q<=0,action:()=>v.columns.move(p,0)},{name:y("menu.moveToEnd"),disabled:!M||q<0||q>=I.length-1,action:()=>v.columns.move(p,I.length-1)}]},{separator:!0}),C.allowGroup!==!1&&D.push({name:y(j?"menu.ungroup":"menu.groupBy"),action:()=>v.columns.group(j?E.filter(ee=>ee!==p):[...E,p])}),E.length&&D.push({name:y("menu.expandAll"),action:()=>v.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>v.rows.collapseAll()}),L(v.columns.groupColumns)){const ee=C.groupPath||[],te=ee.length?ee[ee.length-1]:null,ne=[{name:y("columngroup.group"),disabled:I.length<2||q<0,action:()=>{const ae=I[q+1]??I[q-1];if(!ae)return;const de=(v.columns.get(ae)||{}).groupPath||[],ie=de.length?de[de.length-1]:null;ie?v.columns.groupColumns([p],{groupId:ie}):v.columns.groupColumns([p,ae],{title:y("columngroup.newGroup")})}}];te&&ne.push({name:y("columngroup.dissolve"),action:()=>v.columns.dissolveGroup(te)}),D.push({separator:!0},...ne)}const Z=v.state&&L(v.state.get)?v.state.get().pivot:null,W=Z&&Z.columns||[],J=W.includes(p);if(C.allowPivot!==!1&&D.push({name:y(J?"menu.unpivot":"menu.pivotBy"),action:()=>v.columns.pivot(J?W.filter(ee=>ee!==p):[...W,p])}),C.allowTotal!==!1)if(L(v.get)&&v.get("aggregateChooser")===!0)D.push(s(v,C,y));else{const te=!!C.total;D.push({name:y(te?"menu.stopTotalling":"menu.totalColumn"),action:()=>v.columns.setTotal(p,te?null:"sum")})}return D.push({name:y("menu.hideColumn"),disabled:C.layout&&C.layout.lockVisible===!0,action:()=>v.columns.hide(p)}),D}function s(v,p,y){const C=p.id,T=typeof p.total=="string"?p.total:null,P=[{name:y("menu.aggregateNone"),checked:!p.total,action:()=>v.columns.setTotal(C,null)},{separator:!0},...S(p).map(x=>({name:O(x),checked:T===x,action:()=>v.columns.setTotal(C,x)})),{separator:!0},n(v,p,y,"group",y("menu.aggregateGroup")),n(v,p,y,"grand",y("menu.aggregateGrand"))];return{name:y("menu.aggregate"),children:P}}function n(v,p,y,C,T){const P=p.id,x=C==="grand"?p.grandTotal:p.groupTotal,E=typeof x=="string"?x:null,j=[{name:y("menu.aggregateSame"),checked:x==null,action:()=>v.columns.setTotal(P,null,{scope:C})},{separator:!0},...S(p).map(A=>({name:O(A),checked:E===A,action:()=>v.columns.setTotal(P,A,{scope:C})}))];return{name:T,children:j}}function t(v,p){const y=(E,j)=>(v&&v.messages?v.messages:G).t(E,j),C=v.columns.get(p);if(!C)return[];const T=v.redaction,P=!!(T&&T.has(p)),x=[];return T&&(x.push({name:y(P?"menu.stopRedacting":"menu.redactColumn"),action:()=>T.toggle(p)}),(T.list().length>1||T.active&&!P)&&x.push({name:y("menu.stopRedactingAll"),action:()=>T.clear()}),x.push({separator:!0})),x.push({name:y("menu.hideColumn"),disabled:C.layout&&C.layout.lockVisible===!0,action:()=>v.columns.hide(p)}),x}function r(v,p,y){const C=(j,A)=>(v&&v.messages?v.messages:G).t(j,A),T=y[0],P=v.sort.get(),x=T?P.find(j=>j.col===T):null,E=[];T&&E.push({name:C("menu.sortGroupsAscending"),icon:"↑",disabled:x&&x.dir==="asc",action:()=>v.sort.set([{col:T,dir:"asc"}])},{name:C("menu.sortGroupsDescending"),icon:"↓",disabled:x&&x.dir==="desc",action:()=>v.sort.set([{col:T,dir:"desc"}])},{separator:!0},{name:C("menu.filterGroups"),action:()=>v.emit("column:filter:open",{colId:p.id})},{separator:!0}),E.push({name:C("menu.expandAll"),action:()=>v.rows.expandAll()},{name:C("menu.collapseAll"),action:()=>v.rows.collapseAll()},{separator:!0});for(const j of y){const A=v.columns.get(j);E.push({name:`Remove "${A&&A.title||j}" from grouping`,action:()=>v.columns.group(y.filter($=>$!==j))})}return E.push({name:C("menu.clearGrouping"),disabled:!y.length,action:()=>v.columns.group([])}),E}function o(){const v=globalThis.navigator&&globalThis.navigator.clipboard;return!!(v&&typeof v.readText=="function")}function f(v){return L(v.get)&&v.get("edit")===!1?!1:(v.columns&&L(v.columns.visible)?v.columns.visible():[]).some(y=>{const C=y&&y.edit;return C?C.enabled===void 0||L(C.enabled)?!0:C.enabled!==!1:!1})}function l(v,p){if(L(v.get)&&v.get("edit")===!1)return!1;const y=p&&p.edit;return y?y.enabled===void 0||L(y.enabled)?!0:y.enabled!==!1:!1}const i=new Set(["number","currency","percent","integer"]);function g(v){const p=L(v.get)?v.get("rangeChart"):void 0;return p?L(p)?{enabled:!0,handler:p}:p&&typeof p=="object"&&L(p.onChart)?{enabled:!0,handler:p.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function c(v){const p=v.selection&&L(v.selection.ranges)?v.selection.ranges():[];if(!Array.isArray(p)||!p.length)return null;const y=p[p.length-1],C=L(v.columns.visible)?v.columns.visible():[],T=new Set(C.filter(P=>P&&i.has(P.type)).map(P=>P.id));return(y.columns||[]).some(P=>T.has(P))?y:null}function h(v,p){const y=(W,J)=>(v&&v.messages?v.messages:G).t(W,J),{colId:C,row:T}=p,P=v.selection.keys().length,x=v.selection.cells().length,E=(v.state&&L(v.state.get)?v.state.get().group:null)||[],j=v.ranges||null,A=_()?"Cmd":"Ctrl",$=()=>x||P||0,D=W=>v.columns&&L(v.columns.get)?v.columns.get(W):null,M=L(v.selection.cells)?v.selection.cells():[],R=[...new Set(M.map(W=>W&&W.colId).filter(Boolean))];!R.length&&C&&R.push(C);const k=R.length?R.some(W=>l(v,D(W))):f(v),I=C?l(v,D(C)):!1,q=g(v),Z=q.enabled?c(v):null;return[{name:x>1?`Copy ${x} cells`:y("menu.copy"),shortcut:`${A}+C`,disabled:!$(),action:()=>j&&x?j.copy():v.export.clipboard({rows:P?"selected":"range"})},{name:y("menu.copyWithHeaders"),disabled:!$(),action:()=>v.export.clipboard({headers:!0,rows:P?"selected":"range"})},...C==null?[]:[{name:y("menu.paste"),shortcut:`${A}+V`,disabled:!j||!k||!o(),action:()=>j&&j.paste()},{separator:!0},{name:y("menu.clearCells",{count:x||1}),shortcut:"Delete",disabled:!j||!k||!x,action:()=>j&&j.clear()},{name:y("menu.fillDown"),shortcut:`${A}+D`,disabled:!j||!k||x<2,action:()=>j&&j.fillDown()}],...Z&&q.handler?[{name:"Chart selection",action:()=>q.handler(v,Z)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>v.export.csv({rows:"visible",download:!0})},{name:`Export ${P} selected row${P===1?"":"s"} to CSV`,disabled:!P,action:()=>v.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>v.export.excel({rows:"visible",download:!0})},{name:`Export ${P} selected row${P===1?"":"s"} to Excel`,disabled:!P,action:()=>v.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>v.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>v.export.print()},...v.importer&&L(v.importer.openFile)?[{name:y("menu.importCsv"),action:()=>v.importer.openFile()}]:[],{separator:!0},...E.length?[{name:y("menu.expandAll"),action:()=>v.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>v.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!P,action:()=>v.selection.clear()},...L(v.get)&&v.get("rowDelete")===!0?[{name:y("menu.deleteRow",{count:P||1}),disabled:!P&&!T,action:()=>v.edit.deleteRows(P?void 0:T?T.key:void 0)}]:[],...C==null?[]:[{name:"Edit cell",disabled:!T||!C||!I,action:()=>T&&C&&v.edit.start(T.key,C)}]]}function a(v,p,y,C){if(v==null)return{items:p,spoke:!1,suppress:!1};if(v===!1)return{items:p,spoke:!0,suppress:!0};if(v===!0)return{items:p,spoke:!0,suppress:!1};if(Array.isArray(v))return{items:[...p,...v],spoke:!0,suppress:!1};if(L(v)){const T=v(y,p);return{items:Array.isArray(T)?T:p,spoke:!0,suppress:!1}}return B(`menu-layer:${C}`,`${C} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof v}. Ignoring it.`),{items:p,spoke:!1,suppress:!1}}function m(v,p,y){let C=Array.isArray(v)?v:[],T=!1;for(const P of p){if(!P)continue;const x=a(P.layer,C,y,P.where);C=x.items,x.spoke&&(T=x.suppress)}return T?null:C}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(p){this.#n=p.grid,this.#e=p.cellMenu!==!1,this.#t=p.headerMenu!==!1,this.#i=L(p.items)?p.items:null,this.#s=L(p.headerItems)?p.headerItems:null,this.#r=new U({document:p.document,host:p.host,ctx:{grid:p.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",p=>{const y=String(p.colId),C=this.#c(y,d(this.#n,y));C.length&&this.#r.show({items:C,ctx:this.#u(y),anchor:p.element,placement:"below",returnFocus:p.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",p=>{const y=String(p.colId),C=this.#c(y,t(this.#n,y));C.length&&this.#r.show({items:C,ctx:this.#u(y),x:p.x,y:p.y,returnFocus:p.element})})),this.#o.push(this.#n.on("cell:contextmenu",p=>{const y=p.event;this.#e&&y&&L(y.preventDefault)&&y.preventDefault();const C=this.#l(p),T=h(this.#n,C),P=m(T,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(C.column),where:`column '${C.colId}' contextMenu`}],C);!P||!P.length||(!this.#e&&y&&L(y.preventDefault)&&y.preventDefault(),this.#r.show({items:P,ctx:C,x:y?y.clientX:void 0,y:y?y.clientY:void 0}))}))}#l(p){const y=this.#n.columns,C=p.column||(p.colId!=null&&y&&L(y.get)?y.get(p.colId):void 0),T=p.row,P=this.#n.rows,x=p.key!==void 0?p.key:T?T.key:void 0;return{key:x,colId:p.colId,value:p.value!==void 0||x===void 0||p.colId==null?p.value:P&&L(P.value)?P.value(x,p.colId):void 0,row:T,data:T?T.data:void 0,column:C,index:p.index!==void 0?p.index:p.rowIndex,grid:this.#n}}#a(p){if(!(!p||p.contextMenu===void 0||p.contextMenu===null))return p.contextMenu}#u(p){return{colId:p,column:this.#n.columns.get(p),grid:this.#n}}#c(p,y){return this.#s?m(y,[{layer:this.#s,where:"columnMenu"}],this.#u(p))||[]:y}destroy(){for(const p of this.#o)p();this.#o=[],this.#r.destroy()}}}),xe("packages/dom/src/shortcutshelp.js",function(e,K){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return O}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/renderer/keyboard.js"),Q=_.groupedShortcuts,G=_.SHORTCUT_IDS,U=K("packages/dom/src/platform.js").macLike,z="lat-shortcuts",S='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class O{#e;#t;#n=null;#r=null;#o=[];constructor(u){this.#e=u.grid,this.#t=u.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(u,d){const s=this.#e;return(s&&s.messages?s.messages:F).t(u,d)}#s(u){const d=G[u.combo];if(!d)return u.meaning;const s=`shortcut.${d}`,n=this.#i(s);return n===s?u.meaning:n}mount(){const u=this.#t.viewport?.root;if(!u||!L(u.addEventListener))return;const d=s=>{if(this.open||s.key!=="?")return;const n=s.target,t=n&&n.tagName;t==="INPUT"||t==="TEXTAREA"||n&&n.isContentEditable||(s.preventDefault(),s.stopPropagation(),this.show())};u.addEventListener("keydown",d,!0),this.#o.push(()=>u.removeEventListener("keydown",d,!0))}show(){const u=this.#l();if(!u)return;const d=u.ownerDocument;this.#r=d&&d.activeElement,u.style.display="",L(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const u=this.#r;this.#r=null,u&&L(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const u=this.#t.viewport?.overlays,d=u?.ownerDocument;if(!u||!d?.createElement)return null;const s=d.createElement("div");s.className=z,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("tabindex","-1");const n=`${z}-title`;s.setAttribute("aria-labelledby",n);const t=d.createElement("div");t.className=`${z}__head`;const r=d.createElement("h2");r.className=`${z}__title`,r.id=n,r.textContent=this.#i("shortcuts.title");const o=d.createElement("button");o.className=`${z}__close`,o.type="button",o.setAttribute("aria-label",this.#i("shortcuts.close")),o.textContent="×",t.appendChild(r),t.appendChild(o),s.appendChild(t);const f=d.createElement("div");f.className=`${z}__body`;for(const i of Q())i.items.length&&f.appendChild(this.#a(d,i));s.appendChild(f);const l=d.createElement("p");return l.className=`${z}__hint`,l.textContent=this.#i("shortcuts.hint"),s.appendChild(l),u.appendChild(s),this.#n=s,this.#u(s,o),s}#a(u,d){const s=u.createElement("section");s.className=`${z}__group`;const n=u.createElement("h3");n.className=`${z}__group-title`,n.textContent=this.#i(d.messageKey),s.appendChild(n);const t=u.createElement("dl");t.className=`${z}__list`;const r=U();for(const o of d.items){const f=u.createElement("dt");f.className=`${z}__keys`,o.alternatives.forEach((i,g)=>{if(g>0){const c=u.createElement("span");c.className=`${z}__or`,c.textContent=this.#i("shortcuts.or"),f.appendChild(c)}i.forEach((c,h)=>{h>0&&f.appendChild(u.createTextNode("+"));const a=u.createElement("kbd");a.textContent=r&&c==="Ctrl"?this.#i("shortcuts.key.cmd"):c,f.appendChild(a)})});const l=u.createElement("dd");l.className=`${z}__meaning`,l.textContent=this.#s(o),t.appendChild(f),t.appendChild(l)}return s.appendChild(t),s}#u(u,d){const s=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const r=[...u.querySelectorAll(S)];if(!r.length){t.preventDefault();return}const o=r[0],f=r[r.length-1],l=u.ownerDocument.activeElement;t.shiftKey&&(l===o||l===u)?(t.preventDefault(),f.focus()):!t.shiftKey&&l===f&&(t.preventDefault(),o.focus())},n=t=>{t.preventDefault?.(),this.hide()};u.addEventListener("keydown",s),d.addEventListener("click",n),this.#o.push(()=>{u.removeEventListener("keydown",s),d.removeEventListener("click",n)})}destroy(){for(const u of this.#o)u();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),xe("packages/dom/src/rowreorder.js",function(e,K){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return s}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/renderer/renderer.js").displayIndexOf,G="lat-rowdrag",H="lat-rowdrag-marker",U="lat-rowdrag-lifted",z="lat-manual-order",S=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),O=4,b=new Set;function u(n){if(!n)return null;const t=n===!0?{}:typeof n=="object"?n:null;return t?{send:t.send!==!1,receive:t.receive!==!1,mode:t.mode==="copy"?"copy":"move",group:typeof t.group=="string"?t.group:null}:null}function d(n){return n===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!n||typeof n!="object"?null:{column:typeof n.column=="string"?n.column:null,manualOrder:n.manualOrder===!0,betweenGroups:n.betweenGroups===!0}}class s{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(t){this.#e=t.grid,this.#t=t.renderer,this.#n=t.document,this.#r=d(t.grid.get("rowReorder")),this.#o=u(t.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(t){if(!this.#o||!this.#o.receive)return!1;const r=t&&t.transfer;return!r||!r.send?!1:r.group===this.#o.group}get transfer(){return this.#o}#u(t,r){const o=this.#e;return(o&&o.messages?o.messages:F).t(t,r)}#c(t,r){const o=this.#t&&this.#t.announce;L(o)&&o.call(this.#t,t,r)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(r=>!r.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),r=this.#t.viewport?.root;if(!t||!r)return;const o=r.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const f of o){if(f.querySelector(`.${G}`))continue;const l=f.parentNode;if(l&&L(l.getAttribute)&&l.getAttribute("data-pinned"))continue;const i=this.#n.createElement("span");i.className=G,i.setAttribute("data-role","row-drag"),i.setAttribute("aria-hidden","true"),i.setAttribute("title",this.#u("a11y.reorder.grab")),i.textContent="⠿",f.insertBefore(i,f.firstChild||null)}this.#h(r,t)}#f(){const t=this.#e.rowOrder;return!!(t&&L(t.manual)&&t.manual())}#h(t,r){const o=this.#f();if(L(t.setAttribute)&&(o?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const f=t.querySelector(`.lat-header-cell[data-col="${r}"]`);if(!f)return;let l=f.querySelector(`.${z}`);l||(l=this.#n.createElement("button"),l.className=z,l.setAttribute("type","button"),l.setAttribute("data-role","manual-order"),l.setAttribute("tabindex","-1"),l.textContent=this.#u("rowOrder.button"),l.addEventListener("click",g=>{g.stopPropagation?.(),this.toggleManual()}),l.addEventListener("pointerdown",g=>g.stopPropagation?.()),f.insertBefore(l,f.firstChild||null)),l.setAttribute("aria-pressed",o?"true":"false");const i=this.#u(o?"rowOrder.exit":"rowOrder.enter");l.setAttribute("title",i),l.setAttribute("aria-label",i)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const r=this.#f()?t.exit():t.enter({origin:"user"}),o=f=>{f&&f.reason&&this.#c(this.#u(S[f.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};r&&L(r.then)?r.then(o):o(r)}mount(){if(!this.active)return;b.add(this);const t=this.#t.viewport?.root;if(!t||!L(t.addEventListener))return;const r=g=>this.#p(g),o=g=>this.#m(g),f=()=>this.#g(),l=g=>this.#M(g);if(t.addEventListener("pointerdown",r),t.addEventListener("keydown",l),L(this.#e.on)){let g=this.#f();this.#a.push(this.#e.on("state:changed",c=>{!c||!Array.isArray(c.sections)||!c.sections.includes("rowOrder")||this.#f()!==g&&(g=this.#f(),this.#c(this.#u(g?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const i=this.#n.defaultView||this.#n;i.addEventListener?.("pointermove",o),i.addEventListener?.("pointerup",f),this.#a.push(()=>{t.removeEventListener("pointerdown",r),t.removeEventListener("keydown",l),i.removeEventListener?.("pointermove",o),i.removeEventListener?.("pointerup",f)})}#p(t){const r=t.target;if(!r||!L(r.closest)||!r.closest('[data-role="row-drag"]'))return;const o=r.closest(".lat-row"),f=o?Q(o):-1;if(f<0)return;const l=this.#e.rows.get(f);if(!l||l.group)return;const i=this.#L();if(i&&!(this.#o&&this.#o.send)){this.#c(this.#u(i),{repeat:!0});return}t.preventDefault?.(),this.#i={key:l.key,from:f,at:f,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const r=this.#i;if(!r)return;if(!r.armed){if(Math.abs(t.clientX-r.x)+Math.abs(t.clientY-r.y)<O)return;r.armed=!0,this.#I(r),r.over=this,this.#e.emit("rowDrag:started",this.#y(r,this,r.from,r.key),"user")}this.#l&&this.#z(t.clientX,t.clientY);const o=this.#S(t.clientX,t.clientY);if(r.target=o,o!==this){this.#H(),o&&o.accepts(this)?(o.showDropTarget(t.clientX,t.clientY),r.hit=o.hitAt(t.clientX,t.clientY)):r.hit=null,this.#k(r,o),this.#b(r,o,r.hit?r.hit.at:null,r.hit?r.hit.overKey:null);return}const f=this.#x(t.clientX,t.clientY);if(this.#k(r,o),f<0){this.#b(r,this,null,null);return}r.at=f,this.#N(f);const l=this.#e.rows.get(f);this.#b(r,this,f,l?l.key:null)}#g(){const t=this.#i;this.#i=null,this.#H(),this.#$();for(const f of b)f.hideDropTarget();if(!t||(this.#O(t),!t.armed))return;const r=t.target;if(this.#e.emit("rowDrag:ended",this.#w(t),"user"),r&&r!==this){this.#P(t,r);return}if(t.at===t.from)return;const o=this.#L();if(o){this.#c(this.#u(o),{repeat:!0});return}this.#E(t.key,t.at)}#y(t,r,o,f){const l=this.#e.rows.byKey(t.key);return{key:t.key,data:l?l.data:null,over:r?r.grid:null,at:o,overKey:f}}#w(t){const r=t.target||null;if(r&&r!==this){if(!r.accepts(this))return{...this.#y(t,r,null,null),dropped:!1};const o=t.hit||{at:r.grid.rows.count(),overKey:null};return{...this.#y(t,r,o.at,o.overKey),dropped:!0}}if(r===this){const o=this.#e.rows.get(t.at);return{...this.#y(t,this,t.at,o?o.key:null),dropped:t.at!==t.from&&this.#L()===null}}return{...this.#y(t,null,null,null),dropped:!1}}#k(t,r){if(t.over===r)return;const o=t.over;t.over=r,o&&(this.#O(t),this.#e.emit("rowDrag:left",this.#y(t,o,null,null),"user"))}#b(t,r,o,f){t.pending={over:r,at:o,overKey:f},t.frame===null&&(t.frame=this.#A(()=>{t.frame=null;const l=t.pending;t.pending=null,!(!l||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#y(t,l.over,l.at,l.overKey),"user")}))}#O(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#A(t){const r=this.#n.defaultView||globalThis;if(L(r.requestAnimationFrame)){const f=r.requestAnimationFrame(t);return()=>{L(r.cancelAnimationFrame)&&r.cancelAnimationFrame(f)}}const o=setTimeout(t,16);return()=>clearTimeout(o)}#P(t,r){if(!r.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const o=this.#e.rows.byKey(t.key);if(!o)return;const f=this.#o.mode,l=t.key,i=t.hit||{at:r.grid.rows.count(),overKey:null};let g=null;const c=r.receive(o.data,i.at,{overKey:i.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(l),onCancel:a=>{g=a}}),h=a=>{if(a!==!0){const m=a===!1?"a11y.transfer.refused":g==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(m),{repeat:!0});return}f==="move"?(this.#e.rows.apply({remove:[l]}),this.#e.emit("row:sent",{key:l,data:o.data,mode:f})):this.#e.emit("row:copied",{key:l,data:o.data,mode:f}),this.#c(this.#u(f==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};c&&L(c.then)?c.then(h):h(c)}receive(t,r,o={}){const f=this.#e,l=t&&typeof t=="object"?{...t}:t,i=o.overKey??null,g=o.source||null,c=L(o.onCancel)?o.onCancel:null,h=()=>{const p=f.rows.totalCount(),y=f.rows.apply({add:[l],at:Math.max(0,r||0)}),C=f.rows.totalCount()>p;return C&&f.emit("row:received",{data:l,at:r,overKey:i,rejected:y?.rejected||[]}),C},a=()=>{if(i!==null){const p=f.rows.get(r);if(!p||p.key!==i)return!1}else r=f.rows.count();return!L(o.revalidate)||o.revalidate()},m=L(f.rendererHost)?f.rendererHost():null;if(!m||!L(m.gateBefore))return h();const w=c?f.on("rowReceive:cancelled",p=>c(p.reason)):null,v=m.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:l,at:r,overKey:i,source:g,origin:"user"},h,a);return w&&(v&&L(v.then)?v.then(w,w):w()),v}hitAt(t,r){const o=this.#x(t,r);if(o<0)return{at:this.#e.rows.count(),overKey:null};const f=this.#e.rows.get(o);return{at:o,overKey:f?f.key:null}}showDropTarget(t,r){const o=this.root;o&&L(o.setAttribute)&&o.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&L(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#S(t,r){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=o&&L(o.closest)?o.closest(".lattice"):null;if(!f)return null;for(const l of b)if(l.root===f)return l;return null}#M(t){if(!t.altKey||!t.shiftKey)return;if(this.#r&&this.#r.manualOrder&&(t.code==="KeyM"||t.key==="M"||t.key==="m")){t.preventDefault?.(),t.stopPropagation?.(),this.toggleManual();return}const r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!r)return;const o=this.#n.activeElement,f=o&&L(o.closest)?o.closest(".lat-row"):null,l=f?Q(f):-1;if(l<0)return;t.preventDefault?.(),t.stopPropagation?.();const i=this.#L();if(i){this.#c(this.#u(i),{repeat:!0});return}const g=this.#e.rows.get(l);!g||g.group||this.#E(g.key,this.#j(l,r))}#j(t,r){const o=this.#e;if(r>0||!L(o.rows.groupHeadings))return t+r;const f=new Set(o.rows.groupHeadings(t).map(i=>i.key));let l=t+r;for(;l>=0;){const i=o.rows.get(l);if(!i||!f.has(i.key))break;l+=r}return l<0?t:l}#E(t,r){const o=this.#e.rows.count(),f=Math.max(0,Math.min(o-1,r)),l=this.#e.rows.move(t,f,{origin:"user"});l&&L(l.then)?l.then(i=>this.#R(i,o)):this.#R(l,o)}#R(t,r){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const o=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,f=o?this.#u("a11y.reorder.vetoedBecause",{reason:o}):this.#u(S[t.reason]||"a11y.reorder.refused");this.#c(f,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const o=t.regrouped.map(f=>String(f.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:o}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:r}),{repeat:!0})}#L(){const t=this.#e,r=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return r.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#f()&&!r.betweenGroups)return"a11y.reorder.grouped";const o=t.filters.get();return o&&Object.keys(o).length?"a11y.reorder.filtered":null}#x(t,r){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,r):null,f=o&&L(o.closest)?o.closest(".lat-row"):null;return!f||L(f.getAttribute)&&f.getAttribute("data-pinned")?-1:Q(f)}#I(t){const r=this.root,o=r&&L(r.querySelector)?r.querySelector(`.lat-row[data-index="${t.from}"]`):null;o&&L(o.classList?.add)&&o.classList.add(U);const f=this.#n.body;if(!f||!L(f.appendChild))return;const l=this.#d(),i=l&&L(this.#e.rows?.text)&&this.#e.rows.text(t.key,l)||this.#u("a11y.reorder.grab"),g=r&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(r):null,c=(a,m)=>g&&g.getPropertyValue(a).trim()||m,h=this.#n.createElement("div");h.textContent=String(i),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${c("--lattice-space","4px")} calc(${c("--lattice-space","4px")} * 2)`,`border-radius:${c("--lattice-radius-sm",c("--lattice-radius","4px"))}`,`border:${c("--lattice-border-width","1px")} solid ${c("--lattice-border-strong","#0003")}`,`background:${c("--lattice-background","#fff")}`,`color:${c("--lattice-foreground","#000")}`,`box-shadow:${c("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${c("--lattice-font-size","13px")} ${c("--lattice-font-family","system-ui, sans-serif")}`].join(";"),f.appendChild(h),this.#l=h}#z(t,r){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(r)+16}px)`)}#$(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,r=t&&L(t.querySelectorAll)?t.querySelectorAll(`.${U}`):[];for(const o of r)o.classList.remove(U)}#N(t){const r=this.#t.viewport?.overlays;if(!r)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=H,r.appendChild(this.#s));const o=this.#t.viewport.root,f=o.querySelector(`.lat-row[data-index="${t}"]`)||o.querySelectorAll(".lat-row")[0];if(!f||!L(f.getBoundingClientRect))return;const l=f.getBoundingClientRect(),i=o.getBoundingClientRect(),g=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((g?l.bottom:l.top)-i.top)}px`}#H(){this.#s&&(this.#s.style.display="none")}destroy(){b.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#O(this.#i),this.#i=null,this.#$(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),xe("packages/dom/src/alignedgrids.js",function(e,K){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B=["column:resized","column:moved","column:visible","column:pinned"];function F(G){return(G||[]).map(H=>({id:H.id,width:H.width,flex:H.flex,hidden:H.hidden,pin:H.pin===void 0?null:H.pin}))}class _{#e=new Set;#t=new Map;#n=!1;add(H){if(!H||this.#e.has(H))return;this.#e.add(H);const U=[];for(const S of B)U.push(H.on(S,()=>this.#r(H)));U.push(H.on("scroll",S=>this.#i(H,S))),U.push(H.on("destroy",()=>this.remove(H))),this.#t.set(H,U);const[z]=this.#e;z!==H&&this.#o(H,F(z.columns.state()))}remove(H){const U=this.#t.get(H);if(U)for(const z of U)z();this.#t.delete(H),this.#e.delete(H)}get size(){return this.#e.size}destroy(){for(const H of[...this.#e])this.remove(H)}#r(H){if(this.#n)return;const U=F(H.columns.state());this.#n=!0;try{for(const z of this.#e)z!==H&&this.#o(z,U)}finally{this.#n=!1}}#o(H,U){if(!H.columns||!L(H.columns.apply))return;const z=new Map((H.columns.state()||[]).map(O=>[O.id,O])),S=[];for(const O of U){const b=z.get(O.id);b&&(S.push({...b,...O}),z.delete(O.id))}for(const O of z.values())S.push(O);H.columns.apply(S)}#i(H,U){if(this.#n)return;const z=U&&typeof U.left=="number"?U.left:null;if(z!==null){this.#n=!0;try{for(const S of this.#e)S!==H&&S.scroll?.to?.({left:z})}finally{this.#n=!1}}}}function Q(G){const H=new _;for(const U of G||[])H.add(U);return H}}),xe("packages/dom/src/columntagbar.js",function(e,K){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return G}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function Q(U){if(!U)return null;const z=U===!0?{}:typeof U=="object"?U:null;return z?{multiple:z.multiple===!0,label:typeof z.label=="string"?z.label:null}:null}class G{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(z){this.#e=z.grid,this.#t=z.renderer,this.#n=z.document,this.#r=Q(z.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(z,S){const O=this.#e;return(O&&O.messages?O.messages:F).t(z,S)}mount(){if(!this.active)return;const z=this.#t.viewport,S=z?.root;if(!S||!L(S.insertBefore))return;const O=this.#n.createElement("div");O.className=_,O.setAttribute("role","toolbar"),O.setAttribute("aria-label",this.#a("tags.label"));const b=this.#n.createElement("label");b.className=`${_}__label`,b.textContent=this.#r.label||this.#a("tags.label");const u=this.#n.createElement("select");u.className=`${_}__select`,this.#r.multiple&&u.setAttribute("multiple","");const d=`${_}-select-${Math.abs(H(String(S.className)))}`;u.id=d,b.setAttribute("for",d),O.appendChild(b),O.appendChild(u),S.insertBefore(O,z.header||S.firstChild),this.#o=O,this.#i=u;const s=()=>{const t=this.#r.multiple?[...u.selectedOptions||[]].map(r=>r.value).filter(Boolean):u.value?[u.value]:[];this.#e.columns.showTagged(t),this.#u(t)};u.addEventListener("change",s),this.#l.push(()=>u.removeEventListener("change",s));const n=this.#e.on("model:changed",()=>this.refresh());this.#l.push(n),this.refresh()}#u(z){const S=this.#t&&this.#t.announce;if(!L(S))return;const O=z.length?z.join(", "):this.#a("tags.all");S.call(this.#t,this.#a("tags.showing",{tag:O}))}refresh(){if(!this.#i||!this.#o)return;const z=this.#e.columns.tags();if(this.#o.style.display=z.length?"":"none",!z.length)return;const S=z.join("\0");if(S===this.#s)return;this.#s=S;const O=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const b=this.#n.createElement("option");b.value="",b.textContent=this.#a("tags.all"),this.#i.appendChild(b)}for(const b of z){const u=this.#n.createElement("option");u.value=b,u.textContent=b,O.includes(b)&&(u.selected=!0),this.#i.appendChild(u)}this.#r.multiple||(this.#i.value=O.length?O[0]:"")}destroy(){for(const z of this.#l)z();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function H(U){let z=0;for(let S=0;S<U.length;S++)z=z*31+U.charCodeAt(S)|0;return z}}),xe("packages/dom/src/anomalychip.js",function(e,K){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-anomaly-chip";function Q(z){if(!z)return null;const S=z===!0?{}:typeof z=="object"?z:null;return S?{column:typeof S.column=="string"?S.column:null,label:typeof S.label=="string"?S.label:null}:null}function G(z){return z?typeof z=="string"?{kind:z}:typeof z=="object"?z:null:null}function H(z,S){return z?Array.isArray(z.conditions)?z.conditions.some(O=>H(O,S)):z.col===S&&z.op==="eq"&&z.value===!0:!1}class U{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(S){this.#e=S.grid,this.#t=S.renderer,this.#n=S.document,this.#r=Q(S.grid.get("anomalySummary"))}get active(){return this.#r!==null}#f(S,O){const b=this.#e;return(b&&b.messages?b.messages:F).t(S,O)}#h(){const S=this.#r&&this.#r.column;let O=null;for(const b of this.#e.columns.all()){const u=G(b.shadow);if(!u||u.kind!=="anomalyFlag")continue;const d=u.of||b.field||b.id;if(S){if(b.id===S||d===S)return this.#d=b.id,b}else O||(O=b,this.#d=b.id)}return S?null:O}#p(){if(!this.#d||!L(this.#e.rows&&this.#e.rows.forEach))return 0;let S=0;try{this.#e.rows.forEach(O=>{!O||O.group||O.key==null||this.#e.rows.value(O.key,this.#d)===!0&&S++})}catch{return 0}return S}mount(){if(!this.active)return;const S=this.#t.viewport,O=S&&S.root;if(!O||!L(O.insertBefore))return;const b=this.#n.createElement("div");b.className=_,b.setAttribute("role","status");const u=this.#n.createElement("button");u.className=`${_}__button`,u.setAttribute("type","button"),u.setAttribute("aria-pressed","false"),b.appendChild(u),O.insertBefore(b,S.header||O.firstChild),this.#o=b,this.#i=u;const d=()=>this.toggle();u.addEventListener("click",d),this.#s.push(()=>u.removeEventListener("click",d));for(const s of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(s,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#m()}#m(){if(!this.#d)return;this.#u=this.#e.filters.get();const S={col:this.#d,op:"eq",value:!0},O=this.#u?{op:"and",conditions:[this.#u,S]}:S;this.#l=!0,this.#a=!0;try{this.#e.filters.set(O)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#h()){this.#o.style.display="none";return}if(this.#l&&!H(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#y(this.#c,!0);return}const O=this.#p();if(this.#c=O,!O){this.#o.style.display="none";return}this.#y(O,!1)}#y(S,O){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",O?"true":"false"),this.#i.setAttribute("aria-pressed",O?"true":"false");const b=this.#r&&this.#r.label,u=O?this.#f("anomaly.chipActive",{count:S}):b||this.#f("anomaly.chip",{count:S});this.#i.textContent=u}destroy(){for(const S of this.#s)S();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),xe("packages/dom/src/rowform.js",function(e,K){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return o}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,G=K("packages/core/src/model/rowkey.js").createRowKey,U=K("packages/dom/src/editors/index.js").createEditor,S=K("packages/dom/src/renderer/renderer.js").displayIndexOf,b=K("packages/dom/src/themeof.js").themeOf,u="lat-rowform",d='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function s(f){if(!f)return null;const l=f===!0?{}:typeof f=="object"?f:null;if(!l)return null;const i=L(l.load)?l.load:null,g=Array.isArray(l.fields)&&l.fields.length?l.fields:null;return{timeout:r(l.timeout),container:l.container??null,mode:l.container?"inline":l.mode==="dialog"?"dialog":"drawer",load:i,create:L(l.create)?l.create:null,fields:g,title:l.title??null,width:typeof l.width=="string"?l.width:null,trigger:l.trigger===!1?"none":"dblclick"}}function n(f,l){const i=L(f)?f():f;return i?typeof i=="string"?l&&L(l.querySelector)?l.querySelector(i):null:i&&L(i.appendChild)?i:null:null}const t=2e3;function r(f){return f===!1||f===0?0:typeof f!="number"||!Number.isFinite(f)||f<=0?t:f}class o{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#f=null;#h=0;#p=null;#m=!1;#g=[];constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document,this.#r=l.registry||null,this.#o=s(l.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#y(l,i){const g=this.#e;return(g&&g.messages?g.messages:_).t(l,i)}mount(){if(!this.active)return;const l=this.#t.viewport?.root;if(!l||!L(l.addEventListener)||this.#o.trigger==="none")return;const i=g=>{const c=g.target;if(!c||!L(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const h=c.closest(".lat-row"),a=h?S(h):-1;if(a<0)return;const m=this.#e.rows.get(a);!m||m.group||m.detail||(g.preventDefault?.(),g.stopPropagation?.(),this.openRow(m.key))};l.addEventListener("dblclick",i,!0),this.#g.push(()=>l.removeEventListener("dblclick",i,!0))}openRow(l){const i=this.#e.rows.byKey(l);if(!i)return!1;const g=this.#P();if(!g)return!1;this.#a=i,this.#u=!1,this.#A(),this.#f=this.#n.activeElement,g.style.display="",this.#N(g),this.#M(i);const c=this.#o.load;if(!c)this.#z(i.data);else{this.#L();const h=++this.#h;this.#j(h,a=>{this.#x(new Error(`Loading the record timed out after ${a}ms`),l,"form.loadTimeout")}),Promise.resolve().then(()=>c({row:i,data:i.data,key:l,grid:this.#e})).then(a=>{h!==this.#h||!this.open||(this.#R(),this.#z(a||i.data))}).catch(a=>{h!==this.#h||!this.open||(this.#R(),this.#x(a,l))})}return L(g.focus)&&g.focus(),this.#e.emit("form:opened",{key:l,row:i}),!0}openNew(l){const i=this.#P();if(!i)return!1;this.#h+=1,this.#R(),this.#a=null,this.#u=!0,this.#A(),this.open||(this.#f=this.#n.activeElement),i.style.display="",this.#N(i);const g=i.querySelector(`.${u}__title`);return g&&(g.textContent=this.#y("form.newTitle")),this.#z(l&&typeof l=="object"?{...l}:{}),L(i.focus)&&i.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#h+=1,this.#R(),this.#he(),this.#i.style.display="none";const l=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#A();const i=this.#f;this.#f=null,i&&L(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:l})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const l=this.#a?this.#a.key:null,i={},g={},c=[],h=[];for(const a of this.#d){const m=L(a.editor.commit)?a.editor.commit():{ok:!0,value:void 0};if(!m.ok)return this.#W(a,m.message),!1;if(i[a.field]=m.value,a.readOnly){h.push(a.field);continue}const w=a.initial;Object.is(w,m.value)||(g[a.field]=m.value,a.colId?c.push({key:l,colId:a.colId,value:m.value}):h.push(a.field))}return this.#u?this.#w(i):(c.length&&this.#e.edit.setCells(c,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:l,values:i,changed:g,unmapped:h}),this.close(),!0)}#w(l){const i=this.#d.filter(h=>!h.colId).map(h=>h.field),g=this.#o.create;if(!g)return this.#k(l)?(this.#b(l,l,i),!0):(B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#A(),this.#E(!1);const c=++this.#h;return this.#j(c,h=>{this.#O(new Error(`Adding the record timed out after ${h}ms`),l,!0)}),Promise.resolve().then(()=>g(l)).then(h=>{if(!(c!==this.#h||!this.open)){if(this.#R(),!this.#k(h)){B("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#O(new Error("rowForm.create answered with a row that carries no row key"),l,!1);return}this.#b(h,l,i)}}).catch(h=>{c!==this.#h||!this.open||(this.#R(),this.#O(h,l,!1))}),!0}#k(l){if(!l||typeof l!="object")return!1;const i=G(this.#e.get("rowKey"),{warn:!1});return!i||i.stable===!1?!1:L(i.keyEmpty)?!i.keyEmpty(l):!0}#b(l,i,g){const c=this.#e,h=c.rows.apply({add:[l]}),a=h&&Array.isArray(h.added)?h.added[0]:null;if(!a){this.#O(new Error("The new row could not be added"),i,!1);return}const m=a.key;c.emit("form:saved",{key:m,values:i,changed:i,unmapped:g,created:!0}),this.close();const w=c.get("selection");(typeof w=="string"?w!=="none":w&&typeof w=="object"&&w.mode!=="none")&&c.selection&&L(c.selection.set)&&c.selection.set([m]),c.scroll&&L(c.scroll.toRow)&&c.scroll.toRow(m)}#O(l,i,g){this.#E(!0),this.#A();const c=this.#n.createElement("div");c.className=`${u}__failure`;const h=this.#n.createElement("p");h.className=`${u}__note ${u}__note--error`,h.setAttribute("role","alert"),h.textContent=this.#y("form.createFailed");const a=this.#n.createElement("button");a.className=`${u}__retry`,a.type="button",a.textContent=this.#y("form.retry"),a.addEventListener("click",()=>this.save()),c.appendChild(h),c.appendChild(a),L(this.#s.insertBefore)?this.#s.insertBefore(c,this.#s.firstChild):this.#s.appendChild(c),this.#c=c,this.#e.emit("form:error",{key:null,error:l,timedOut:g,created:!0})}#A(){const l=this.#c;this.#c=null,l&&l.parentNode&&l.parentNode.removeChild(l)}#P(){if(this.#i)return this.#i;const l=this.#t.viewport?.overlays,i=this.#n||l?.ownerDocument;if(!i?.createElement)return null;const g=n(this.#o.container,i),c=g||l;if(!c)return null;this.#o.container&&!g&&B("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!g;const h=i.createElement("div"),a=this.#m?"lattice ":"";h.className=`${a}${u} ${u}--${this.#m?"inline":this.#o.mode}`,h.setAttribute("role",this.#m?"region":"dialog"),this.#m||h.setAttribute("aria-modal","true"),h.setAttribute("tabindex","-1"),this.#o.width&&h.style.setProperty("--lattice-rowform-width",this.#o.width);const m=`${u}-title`;h.setAttribute("aria-labelledby",m);const w=i.createElement("div");w.className=`${u}__head`;const v=i.createElement("h2");v.className=`${u}__title`,v.id=m,w.appendChild(v);const p=i.createElement("div");p.className=`${u}__body`;const y=i.createElement("div");y.className=`${u}__foot`;const C=i.createElement("button");C.className=`${u}__cancel`,C.type="button",C.textContent=this.#y("form.cancel");const T=i.createElement("button");return T.className=`${u}__save`,T.type="button",T.textContent=this.#y("form.save"),y.appendChild(C),y.appendChild(T),h.appendChild(w),h.appendChild(p),h.appendChild(y),c.appendChild(h),this.#i=h,this.#s=p,this.#l=T,this.#S(h,T,C),h}#S(l,i,g){const c=m=>{if(m.stopPropagation(),m.key==="Escape"){m.preventDefault(),this.close();return}if(m.key!=="Tab"||this.#m)return;const w=[...l.querySelectorAll(d)];if(!w.length){m.preventDefault();return}const v=w[0],p=w[w.length-1],y=l.ownerDocument.activeElement;m.shiftKey&&(y===v||y===l)?(m.preventDefault(),p.focus()):!m.shiftKey&&y===p&&(m.preventDefault(),v.focus())},h=m=>{m.preventDefault?.(),this.save()},a=m=>{m.preventDefault?.(),this.close()};l.addEventListener("keydown",c),i.addEventListener("click",h),g.addEventListener("click",a),this.#g.push(()=>{l.removeEventListener("keydown",c),i.removeEventListener("click",h),g.removeEventListener("click",a)})}#M(l){const i=this.#i.querySelector(`.${u}__title`);if(!i)return;const g=this.#o.title;L(g)?i.textContent=String(g({row:l,data:l.data})??""):typeof g=="string"?i.textContent=g:i.textContent=this.#y("form.title")}#j(l,i){this.#R();const g=this.#o.timeout;if(!g)return;const c=this.#n.defaultView||globalThis;L(c.setTimeout)&&(this.#p=c.setTimeout(()=>{this.#p=null,!(l!==this.#h||!this.open)&&(this.#h+=1,i(g))},g))}#E(l){this.#l&&(this.#l.disabled=!l,l?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#R(){if(this.#p===null)return;const l=this.#n.defaultView||globalThis;L(l.clearTimeout)&&l.clearTimeout(this.#p),this.#p=null}#L(){this.#he(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const l=this.#n.createElement("p");l.className=`${u}__note`,l.setAttribute("role","status"),l.textContent=this.#y("form.loading"),this.#s.appendChild(l)}#x(l,i,g="form.loadFailed"){this.#he(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${u}__note ${u}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#y(g);const h=this.#n.createElement("button");h.className=`${u}__retry`,h.type="button",h.textContent=this.#y("form.retry"),h.addEventListener("click",()=>this.openRow(i)),this.#s.appendChild(c),this.#s.appendChild(h),this.#e.emit("form:error",{key:i,error:l,timedOut:g==="form.loadTimeout"})}#I(){return this.#o.fields?this.#o.fields.map(l=>typeof l=="string"?{field:l}:l):this.#e.columns.all().filter(l=>!l.generated&&l.field).map(l=>({field:l.field,label:l.title,colId:l.id}))}#z(l){this.#he(),this.#E(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const i=l&&typeof l=="object"?l:{};for(const g of this.#I()){const c=g.field;if(!c)continue;const h=g.colId?this.#e.columns.get(g.colId):this.#ue(c),a=Object.hasOwn(i,c)?i[c]:null,m=this.#n.createElement("div");m.className=`${u}__field`;const w=this.#n.createElement("label");w.className=`${u}__label`,w.textContent=String(g.label??(h&&h.title)??c);const v=this.#n.createElement("div");v.className=`${u}__control`,m.appendChild(w),m.appendChild(v),this.#s.appendChild(m);const p={field:c,colId:h?h.id:null,editor:null,initial:a,opener:null,wrap:m,readOnly:!1},C=!!(h&&(h.computed||h.generated))?null:U({grid:this.#e,column:this.#le(g,h,c),colId:h?h.id:c,row:this.#a,data:i,value:a,text:a==null?"":String(a),locale:this.#e.get("locale"),props:g.props||h&&h.edit&&h.edit.props,lookup:g.lookup||h&&h.lookup,document:this.#n,cell:v,overlay:this.#H(),stop:()=>this.#ie(p)},this.#r);if(!C){p.readOnly=!0,p.colId=null,p.editor={commit:()=>({ok:!0,value:p.initial})},this.#$(v,h,a),this.#d.push(p);continue}p.editor=C;try{L(C.value)&&(p.initial=C.value())}catch{}if(this.#d.push(p),C.popup===!0)this.#B(v,p);else{const T=L(C.element)?C.element():null;T&&v.appendChild(T)}}this.#d.length||B("rowform:no-fields","rowForm has no fields to show; the form opened with no controls. Check rowForm.fields, or the grid's columns when fields is absent.")}#$(l,i,g){const c=this.#n.createElement("div");c.className=`${u}__static`,c.setAttribute("aria-readonly","true");let h="";try{const a=i&&i.dataType&&i.dataType.format;L(a)&&(h=a({value:g,column:i,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{h=""}(h===""||h==null)&&(h=g==null?"":String(g)),c.textContent=h,l.appendChild(c)}#N(l){if(!this.#m)return;const i=this.#t.viewport?.root;if(!(!i||!L(i.getAttribute)))for(const g of["data-theme","data-density","dir"]){const c=g==="data-theme"?b(i):i.getAttribute(g);c?l.setAttribute(g,c):L(l.removeAttribute)&&l.removeAttribute(g)}}#H(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#B(l,i){const g=this.#n.createElement("button");g.className=`${u}__opener`,g.type="button",i.opener=g,this.#re(i);const c=()=>{L(i.editor.attached)&&i.editor.attached()};g.addEventListener("click",c),this.#g.push(()=>g.removeEventListener("click",c)),l.appendChild(g)}#W(l,i){const g=l.wrap;g&&L(g.scrollIntoView)&&g.scrollIntoView({block:"nearest"});const c=l.opener||(L(l.editor.focusTarget)?l.editor.focusTarget():null);c&&L(c.focus)&&c.focus();const h=this.#t&&this.#t.announce;L(h)&&i&&h.call(this.#t,String(i))}#ie(l){if(!l.opener||!l.editor)return;const i=L(l.editor.popupHandle)?l.editor.popupHandle():null;i&&L(i.hide)&&i.hide(),this.#re(l),L(l.opener.focus)&&l.opener.focus()}#re(l){if(!l.opener)return;let i="";try{const c=l.colId?this.#e.columns.get(l.colId):null,h=c&&c.dataType&&c.dataType.format;L(h)&&(i=h({value:L(l.editor.value)?l.editor.value():null,column:c,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&L(l.editor.toClipboard)&&(i=l.editor.toClipboard())}catch{i=""}const g=i===""||i==null;l.opener.textContent=g?this.#y("form.choose"):String(i),l.opener.classList.toggle(`${u}__opener--empty`,g)}#le(l,i,g){const c=l.editor||l.type||l.lookup||l.props,h={...i&&i.edit?i.edit:{},enabled:!0};return l.editor&&(h.editor=l.editor),l.props&&(h.props=l.props),i&&!c?{...i,edit:h}:{...i||{id:g,field:g},type:l.type||i&&i.type||"text",lookup:l.lookup||i&&i.lookup||void 0,edit:h}}#ue(l){for(const i of this.#e.columns.all())if(!i.generated&&i.field===l)return i;return null}#he(){for(const l of this.#d)L(l.editor.destroy)&&l.editor.destroy();this.#d=[]}destroy(){this.#h+=1,this.#R(),this.#he();for(const l of this.#g)l();this.#g=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),xe("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return E}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,F=K("packages/dom/src/ui/toolpanel.js"),_=F.ToolPanel,Q=F.toolPanels,G=F.toolPanelTitles,H=F.toolPanelIcons,U=K("packages/dom/src/filters/index.js"),z=U.createFilter,S=U.filterFor,b=K("packages/dom/src/filters/text.js").TextFilter,u=K("packages/dom/src/filters/engineset.js"),d=u.EngineSetFilter,s=u.VALUE_LIMIT,n=K("packages/dom/src/editors/common.js"),t=n.CLS,r=n.documentFor,o=n.scannableRows,f=n.el,l=K("packages/dom/src/filtermenu.js"),i=l.mergeColumnFilter,g=l.branchFor,c=l.valueSource,h=l.isSetFilter,a=Object.freeze(["column:visible","column:moved","column:pinned","column:grouped","column:pivoted","filter:changed","model:changed","views:changed","sort:changed","history:changed","state:reset","cell:changed","formatting:changed"]);function m(j,A,$){const D=f(j,"div",{class:`${t.panel}__filterRefusal`});return D.appendChild(f(j,"div",{class:`${t.filter}__note`,text:$,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),D.appendChild(A.element()),{get:()=>A.get(),set:M=>A.set(M),active:()=>A.active(),...L(A.clear)?{clear:()=>A.clear()}:{},destroy:()=>A.destroy(),element:()=>D}}function w(j){const{grid:A,container:$}=j||{};if(!A)throw new Error("[lattice] mountPanel needs a grid");if(!$||!$.appendChild)throw new Error("[lattice] mountPanel needs a container element");const D=L(j.panel)?j.panel:Q[String(j.panel)];if(!D)throw new Error(`[lattice] unknown panel "${j.panel}"; known panels are ${Object.keys(Q).join(", ")}`);const M=$.ownerDocument||r($),R=x(A,M,j.announce),k=new D;k.init({document:M,host:R,grid:A,props:j.props||{}});const I=k.element();$.appendChild(I);const q=[];for(const Z of a)L(A.on)&&q.push(A.on(Z,()=>k.refresh()));return{element:I,refresh(){k.refresh()},destroy(){for(const Z of q)Z();q.length=0,L(k.destroy)&&k.destroy(),I&&I.parentNode&&I.parentNode.removeChild(I)}}}const v=260,p=30,y=`${t.panel}-dock`;function C(j,A,$){if(!j||!L(j.set))return;const D=g($.filters.get(),A)||null,M=L(j.get)&&(!L(j.active)||j.active())&&j.get()||null;JSON.stringify(M)!==JSON.stringify(D)&&(D?j.set(D):L(j.clear)?j.clear():j.set(null))}function T(j,A){if(j==="insights"){const M=A&&L(A.get)?A.get("insights"):null;return{other:(M&&typeof M=="object"?M:{}).compareWith||null}}if(j!=="views")return{};const $=A&&L(A.get)?A.get("views"):null,D=$&&typeof $=="object"?$:{};return{allowSave:D.allowSave!==!1,showDiff:D.showDiff===!0,builtinTitle:D.builtinTitle,savedTitle:D.savedTitle}}function P(j){const A=j.pagination&&L(j.pagination.get)?j.pagination.get():null;return A&&Number.isFinite(A.total)?A.total:j.rows.count()}function x(j,A,$){const D=new Map;return{announce(M,R){L($)&&$(M,R)},t(M,R){return j.messages.t(M,R)},grid:j,document:A,columns:()=>j.columns.all(),showColumns:M=>j.columns.show(M),hideColumns:M=>j.columns.hide(M),groupBy:()=>j.state.get().group||[],setGroupBy:M=>j.columns.group(M),pivotBy:()=>(j.state.get().pivot||{}).columns||[],setPivotBy:M=>j.columns.pivot(M),valueColumns:()=>j.columns.all().filter(M=>M.total).map(M=>M.id),setValueColumns:M=>j.columns.totals(M),valueAggregation(M){const R=j.columns.get(M);return!R||!R.total?"sum":typeof R.total=="string"?R.total:"custom"},setValueAggregation(M,R){j.columns.setTotal(M,R)},quickFilter:()=>j.state.get().quick||"",setQuickFilter:M=>j.filters.quick(M),rowCount:()=>P(j),totalRowCount:()=>L(j.rows.totalCount)?j.rows.totalCount():j.rows.count(),formattableColumns:()=>j.columns.visible().filter(M=>!M.generated).map(M=>({id:M.id,title:String(M.title??M.id)})),formattingRules:M=>j.formatting.list(M),columnSamples:M=>{let R=M;if(!R||R==="*"){const q=j.columns.visible().find(Z=>!Z.generated);R=q?q.id:null}if(!R)return[];const k=[],I=new Set;for(const q of o(j)){const Z=j.rows.value(q.key,R);if(Z==null||Z==="")continue;const W=typeof Z=="object"?k.length:Z;if(!I.has(W)&&(I.add(W),k.push(Z),k.length>=24))break}return k},profilableColumns:()=>j.columns.visible().filter(M=>!M.generated).map(M=>({id:M.id,title:String(M.title??M.id)})),columnProfile:M=>j.statistics.profile(M),reduceColumn:(M,R)=>j.statistics.reduce(M,R),columnCapability:M=>j.statistics.capability(M),regressionModel:M=>L(j.statistics.regressionModel)?j.statistics.regressionModel(M):null,insightsColumns:()=>j.columns.visible().filter(M=>!M.generated).map(M=>({id:M.id,title:String(M.title??M.id),type:M.type})),subsetVsPopulation:()=>j.statistics.subsetVsPopulation(),datasetVsDataset:M=>j.statistics.datasetVsDataset(M),compareGroups:(M,R)=>j.statistics.compareGroups(M,R),anomalies:M=>j.statistics.anomalies(M||{}),compareColumns:(M,R)=>{if(!M||!R||M===R)return null;const k=j.statistics.regression(M,R);return{n:k?k.n:0,pearson:j.statistics.correlation(M,R),spearman:j.statistics.spearman(M,R),kendall:j.statistics.kendall(M,R),covariance:j.statistics.covariance(M,R),slope:k?k.slope:null,intercept:k?k.intercept:null,r2:k?k.r2:null,stdError:k?k.stdError:null,weighted:j.statistics.weightedAverage(M,R)}},addRule:(M,R)=>j.formatting.add(M,R),removeRule:(M,R)=>j.formatting.remove(M,R),updateRule:(M,R,k)=>j.formatting.update(M,R,k),moveRule:(M,R,k)=>j.formatting.move(M,R,k),clearRules:M=>j.formatting.clear(M),views:()=>j.views.list(),activeId:()=>j.views.activeId,apply:M=>{j.views.apply(M)},saveAs:M=>j.views.save(M),rename:(M,R)=>j.views.rename(M,R),setDefault:M=>j.views.setDefault(M),clearDefault:()=>j.views.setDefault(null),remove:M=>j.views.remove(M),export:M=>j.views.export(M),diff:M=>j.views.diff(M),moveColumn(M,R,k){const I=j.columns.all().map(J=>J.id),q=I.indexOf(M),Z=I.indexOf(R);if(q<0||Z<0)return;let W=k?Z:Z+1;q<W&&(W-=1),W!==q&&j.columns.move(M,W)},isFiltered(M){return g(j.filters.get(),M)!==null},clearFilter(M){j.filters.set(i(j.filters.get(),M,null));const R=D.get(M);R&&L(R.clear)?R.clear():R&&L(R.set)&&R.set(null)},clearAllFilters(){j.filters.set(null);for(const M of D.values())L(M.clear)?M.clear():L(M.set)&&M.set(null)},filterFor(M){if(D.has(M))return C(D.get(M),M,j),D.get(M);const R=j.columns.get(M);if(!R)return null;const k=R.filter&&R.filter.props&&R.filter.props.values,I=c(j),q=I?j.config().context??null:null,Z=I?te=>I.columnValues(M,{...te||{},context:q}):null,W={grid:j,column:R,colId:M,type:R.type,locale:j.get("locale"),props:{...R.filter&&R.filter.props,values:k||(R.lookup?void 0:I?()=>Z({limit:s}).then(te=>te&&te.supported?te.values.map(ne=>ne.value):[]):()=>j.columns.distinct(M)),...I?{valueList:!1}:{}},lookup:R.lookup,document:A,value:te=>j.rows.value(te.row&&te.row.key,M),rows:I?()=>[]:R.lookup?void 0:()=>o(j),changed:()=>{const ne=(L(J.active)?J.active():!0)&&L(J.get)?J.get():null;j.filters.set(i(j.filters.get(),M,ne||null))},fetchValues:Z};let J=null;const ee=I&&!k&&!R.lookup?S(R):null;if(ee&&h(ee)){const te=I.columnValuesRefusal(M);if(te){const ne=new b;ne.init({...W,props:{...W.props,valueList:!1}}),J=m(A,ne,j.messages.t("filter.valuesUnsupported",{column:R.title||M})),B(`filter:values-unsupported:${M}`,`the filter on column "${M}" cannot list its values: ${te}. It offers the text condition editor instead.`)}else J=new d,J.init(W)}else J=z(W);return J&&(C(J,M,j),D.set(M,J)),J},destroyFilters(){for(const M of D.values())L(M.destroy)&&M.destroy();D.clear()}}}class E{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(A){this.#e=A.grid,this.#t=A.document,this.#n=A.root,this.#o=x(A.grid,A.document,A.announce);const D=(A.panels||["columns","filters"]).map(M=>Q[M]?{name:M,title:G[M]?A.grid.messages.t(G[M]):M,icon:H[M]||M,Ctor:Q[M],props:T(M,A.grid)}:(B(`toolpanel:${M}`,`unknown tool panel "${M}"`),null)).filter(Boolean);this.#l=A.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:A.document,host:this.#o,grid:A.grid,panels:D,actions:A.actions,icons:A.icons,side:this.#l,openPanel:A.openPanel})}mount(){const A=this.#t.createElement("div");A.className=`${y} ${y}--${this.#l}`,A.appendChild(this.#r.element()),this.#n.appendChild(A),this.#i=A;const $=this.#r.show.bind(this.#r),D=this.#r.hide.bind(this.#r);this.#r.show=M=>{const R=$(M);return this.#h(),R},this.#r.hide=()=>{D(),this.#h()};for(const M of[...a,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(M,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",M=>{this.#u=!0;const R=M&&M.options&&Array.isArray(M.options.chrome)?M.options.chrome:[];this.#c=R.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",M=>{const R=M&&M.colId,k=this.#r.panels.find(I=>I.name==="statistics");k&&R!=null&&(k.panel.column=String(R)),this.open("statistics")})),this.#h()}open(A){this.#r.show(A),this.#h()}close(){this.#r.hide(),this.#h()}toggle(A){this.#r.toggle(A),this.#h()}addAction(A){if(!(!A||!A.name)&&!this.#r.actions.some($=>$.name===A.name)){if(this.#r.registerAction(A),this.#a&&!A.annotation){const $=this.#r.actions.find(D=>D.name===A.name);$&&this.#f($.button)}else!this.#a&&A.annotation&&this.#u&&!this.#c&&this.#d();this.#h()}}removeAction(A){this.#r.removeAction(A)&&this.#h()}presentOnly(){return this.#a?!0:this.#r.actions.some(A=>A.annotation&&A.button)?(this.#d(),!0):!1}#d(){const A=this.#r;this.#a={hidden:[],reopen:A.openPanel||null},this.#a.reopen&&A.hide(),this.#f(A.body);for(const $ of[...A.tabs?.children||[]])$!==A.actionGroup&&this.#f($);for(const $ of[...A.actionGroup?.children||[]]){const D=A.actions.find(M=>M.button===$);(!D||!D.annotation)&&this.#f($)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#h()}presentRestore(){const A=this.#a;if(!A)return!1;this.#a=null;for(const $ of A.hidden)$.el&&$.el.style&&($.el.style.display=$.display);return A.reopen&&this.#r.show(A.reopen),this.#h(),!0}#f(A){if(!A||!A.style||!this.#a)return;const $=A.style.display||"";$!=="none"&&(A.style.display="none",this.#a.hidden.push({el:A,display:$}))}#h(){if(!this.#i)return;const A=!!this.#r.openPanel;this.#i.setAttribute("data-open",A?"true":"false"),this.#i.style.width=A?`${v}px`:"";const $=`${A?v:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?$:"",this.#n.style.paddingRight=this.#l==="left"?"":$,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?$:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":$)}#p(){const A=this.#r&&L(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,$=A&&(A.offsetWidth||A.getBoundingClientRect?.().width)||0;return $>0?Math.ceil($):p}destroy(){for(const A of this.#s)A();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),xe("packages/dom/src/celledit.js",function(e,K){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return b}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,Q=K("packages/dom/src/editors/common.js"),G=Q.CLS,H=Q.markInvalid,U=Q.isEditable,S=K("packages/dom/src/detailhost.js").insideDetail,O=`${G.editor}-host`;class b{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;constructor(t){this.#e=t.grid,this.#t=t.document,this.#n=t.renderer,this.#r=t.registry||null,this.#o=t.cellLayer||null}mount(){this.#u.push(this.#e.on("cell:edit:start",g=>this.open(g))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,r=this.#e.get("edit"),o=r&&typeof r=="object"&&r.start||"double",f=g=>{if(S(g.target,t))return;const c=u(g.target,v=>v.getAttribute&&v.getAttribute("data-col"));if(!c)return;const h=u(c,v=>v.getAttribute&&v.getAttribute("data-key"));if(!h)return;const a=this.#e.rows.byKey(h.getAttribute("data-key"));if(!a||a.group)return;const m=c.getAttribute("data-col"),w=this.#e.columns.get(m);!w||!w.edit||!w.edit.enabled||this.#e.edit.start(a.key,m)},l=o==="key"?null:o==="single"?"click":"dblclick";l&&(t.addEventListener(l,f),this.#u.push(()=>t.removeEventListener(l,f)));const i=g=>{!this.#i||!this.#l||this.#p(g.target)||this.commit()};this.#t.addEventListener("mousedown",i,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",i,!0))}get target(){return this.#l}open(t){this.close();const r=t.key||t.row&&t.row.key,o=t.colId;if(!r||!o)return;const f=this.#e.columns.get(o),l=this.#e.rows.byKey(r);if(!f||!l||!U({column:f,edit:f.edit,row:l,value:this.#e.rows.value(r,o),grid:this.#e}))return;const i=this.#w(r,o);if(this.#c=i,!i){B("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const g=this.#e.permissions,c=!!(g&&L(g.isSecret)&&g.isSecret(o)),h=_({grid:this.#e,column:f,colId:o,row:l,data:l.data,value:c?null:this.#e.rows.value(r,o),text:c?"":this.#e.rows.text(r,o),locale:this.#e.get("locale"),props:f.edit&&f.edit.props,lookup:f.lookup,document:this.#t,cell:i,overlay:this.#n.viewport.overlays,onCommit:w=>this.#h({value:w,key:r,colId:o}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:w=>{this.#d||this.#e.edit.stop(w)}},this.#r);if(!h){B(`celledit.noeditor:${o}`,`column "${o}" has no editor.`);return}this.#i=h,this.#s=i,this.#l={key:r,colId:o},this.#d=!1,this.#a=this.#y(i);const a=h.element();h.popup?(this.#n.viewport.overlays.appendChild(a),d(a,i,this.#n.viewport.root)):i.replaceChildren(a),i.classList.add(O),L(h.attached)&&h.attached(),s(a);const m=w=>this.#f(w);a.addEventListener("keydown",m),this.#u.push(()=>a.removeEventListener("keydown",m))}#f(t){const r=t.key;if(r!=="Enter"&&r!=="Tab"&&r!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),r==="Escape"){this.#e.edit.stop(!0);return}const o=r==="Enter"?this.#m(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&o&&this.#e.edit.start(o.key,o.colId)}#h(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if(L(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:r}=this.#l;if(L(this.#i.value)){const o=this.#i.value();if(L(this.#i.validate)){const f=this.#i.validate(o);if(f!==!0){if(H(this.#c,f),L(this.#i.focusTarget)){const l=this.#i.focusTarget();l&&L(l.focus)&&l.focus()}return!1}H(this.#c,null)}this.#h({value:o,key:t,colId:r})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#p(t){if(!t)return!1;const r=L(this.#i.element)?this.#i.element():null;if(r&&L(r.contains)&&r.contains(t))return!0;const o=this.#c;return!!(o&&L(o.contains)&&o.contains(t))}#m(t){if(!this.#l||this.#a<0)return null;for(let r=this.#a+t;r>=0&&r<this.#e.rows.count();r+=t){const o=this.#e.rows.get(r);if(o&&!o.group)return{key:o.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const r=this.#e.columns.visible(),o=r.findIndex(f=>f.id===this.#l.colId);for(let f=o+t;f>=0&&f<r.length;f+=t){const l=r[f];if(l.edit&&l.edit.enabled)return{key:this.#l.key,colId:l.id}}return null}#y(t){const r=u(t,f=>f.getAttribute&&f.getAttribute("data-index"));if(!r)return-1;const o=Number(r.getAttribute("data-index"));return Number.isFinite(o)?o:-1}#w(t,r){const o=this.#n.viewport.root;if(!o||!o.querySelectorAll)return null;for(const f of o.querySelectorAll(`[data-col="${r}"]`)){const l=u(f,i=>i.getAttribute&&i.getAttribute("data-key"));if(l&&l.getAttribute("data-key")===t)return f}return null}close(){this.#c&&H(this.#c,null);const t=this.#k();if(this.#i&&L(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(O),this.#o&&L(this.#o.releaseCell)){const r=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,r)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#b(this.#s),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1}#k(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const r=this.#i&&L(this.#i.element)?this.#i.element():null,o=f=>!!f&&L(f.contains)&&f.contains(t);return o(r)||o(this.#s)}#b(t){const o=L(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;o&&L(o.focus)&&o.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function u(n,t){let r=n;for(;r;){if(t(r))return r;r=r.parentNode}return null}function d(n,t,r){if(!L(t.getBoundingClientRect))return;const o=t.getBoundingClientRect(),f=r.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(o.top-f.top)}px`,n.style.minWidth=`${Math.round(o.width)}px`,n.style.left=`${Math.round(o.left-f.left)}px`;const l=n.offsetWidth||Math.round(o.width),i=Math.round(o.left-f.left)+l-Math.round(f.width);i>0&&(n.style.left=`${Math.max(0,Math.round(o.left-f.left)-i)}px`)}function s(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;L(t.focus)&&t.focus(),L(t.select)&&t.select()}}),xe("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return U}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,H=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class U{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(S){this.#e=S.grid,this.#t=S.document,this.#n=S.root}mount(){const S=this.#t,O=S.createElement("div");O.className=H;const b=S.createElement("span");b.className=`${H}__ref`,b.textContent="";const u=S.createElement("div");u.className=`${H}__slot`;const d=S.createElement("span");d.className=`${H}__readonly`,O.appendChild(b),O.appendChild(u),this.#n.insertBefore(O,this.#n.firstChild),this.#r=O,this.#o=b,this.#i=u,this.#l=d;for(const s of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(s,n=>this.#h(n)))}bind(S,O){const b=this.#e.columns.get(O),u=S?this.#e.rows.byKey(S):null;this.#a=u&&b&&!u.group?{key:S,colId:O}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#f(),!this.#a){this.#o.textContent="";return}const{key:S,colId:O}=this.#a,b=this.#e.columns.get(O);if(!b)return;if(this.#o.textContent=b.title||O,!!!(b.edit&&b.edit.enabled)){this.#l.textContent=this.#e.rows.text(S,O),this.#i.appendChild(this.#l);return}const d=this.#e.rows.byKey(S);if(!d)return;const s=_({grid:this.#e,column:b,colId:O,row:d,data:d.data,value:this.#e.rows.value(S,O),text:this.#e.rows.text(S,O),locale:this.#e.get("locale"),props:b.edit&&b.edit.props,lookup:b.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:f=>f?this.cancel():this.commit(!0)});if(!s){B(`editbar.noeditor:${O}`,`column "${O}" has no editor.`),this.#l.textContent=this.#e.rows.text(S,O),this.#i.appendChild(this.#l);return}this.#s=s;const n=s.element();s.popup?(this.#l.textContent=this.#e.rows.text(S,O),this.#i.appendChild(this.#l)):this.#i.appendChild(n),L(s.attached)&&s.attached();const t=f=>this.#p(f),r=()=>{this.#u=!0},o=[n,this.#i];for(const f of o)f.addEventListener("keydown",t),f.addEventListener("input",r),f.addEventListener("change",r);this.#c=()=>{for(const f of o)f.removeEventListener("keydown",t),f.removeEventListener("input",r),f.removeEventListener("change",r)}}#f(){this.#c&&(this.#c(),this.#c=null),this.#s&&L(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#h(S){if(S&&S.colId&&(S.key||S.row&&S.row.key)){this.bind(S.key||S.row.key,S.colId);return}this.refresh()}#p(S){if(S.key==="Enter"){S.preventDefault(),this.commit();return}S.key==="Escape"&&(S.preventDefault(),this.cancel())}commit(S){if(!this.#a||!this.#u&&!S)return!1;const{key:O,colId:b}=this.#a;if(!this.#s||!L(this.#s.value))return!1;const u=this.#s.value();return this.#u=!1,this.#e.edit.start(O,b),this.#e.edit.stop(!1,{value:u,key:O,colId:b}),this.refresh(),!0}destroy(){this.#f();for(const S of this.#d)S();this.#d=[],this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),xe("packages/dom/src/pastepreview.js",function(e,K){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return z}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),Q=_.el,G=_.clear,H="lat-pastepreview",U='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class z{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(O){this.#e=O.grid,this.#t=O.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(O,b){const u=this.#e;return(u&&u.messages?u.messages:F).t(O,b)}#d(O){const b=`paste.preview.reason.${O}`,u=this.#c(b);return u===b?O:u}#f(O){return O==null||O===""?"":String(O)}#h(O,b){const u=this.#e.columns&&L(this.#e.columns.get)?this.#e.columns.get(b):null;return`${u&&(u.title||u.headerName)||b} · ${O}`}show(O,b){const u=this.#w();if(!u)return!1;this.#l=b&&b.onConfirm,this.#a=b&&b.onCancel||null;const d=O&&O.changes||[],s=O&&O.rejected||[],n=d.filter(r=>r.changed);this.#p(n,s);const t=u.ownerDocument;return this.#s=t&&t.activeElement,u.style.display="",L(u.focus)&&u.focus(),this.#b(this.#c("a11y.paste.previewOpened",{count:n.length,changes:n.length,rejected:s.length}),{repeat:!0}),!0}#p(O,b){const u=this.#r.ownerDocument;G(this.#r);const d=Q(u,"p",{class:`${H}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:O.length,changes:O.length,rejected:b.length})});if(this.#r.appendChild(d),!O.length&&!b.length){this.#r.appendChild(Q(u,"p",{class:`${H}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!O.length;return}this.#o.disabled=!O.length,O.length&&(this.#r.appendChild(Q(u,"h3",{class:`${H}__heading`,text:this.#c("paste.preview.changesHeading",{count:O.length})})),this.#r.appendChild(this.#m(u,O))),b.length&&(this.#r.appendChild(Q(u,"h3",{class:`${H}__heading ${H}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:b.length})})),this.#r.appendChild(this.#g(u,b)))}#m(O,b){const u=Q(O,"tr",{children:[Q(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Q(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),Q(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),d=b.map(s=>Q(O,"tr",{children:[Q(O,"th",{attrs:{scope:"row"},text:this.#h(s.key,s.colId)}),Q(O,"td",{class:`${H}__old`,text:this.#f(s.oldValue)}),Q(O,"td",{class:`${H}__new`,text:this.#f(s.newValue)})]}));return Q(O,"table",{class:`${H}__table`,children:[Q(O,"thead",{children:[u]}),Q(O,"tbody",{children:d})]})}#g(O,b){const u=Q(O,"tr",{children:[Q(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Q(O,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),d=b.map(s=>Q(O,"tr",{children:[Q(O,"th",{attrs:{scope:"row"},text:this.#h(s.key,s.colId)}),Q(O,"td",{class:`${H}__reason`,text:this.#d(s.reason)})]}));return Q(O,"table",{class:`${H}__table ${H}__table--rejected`,children:[Q(O,"thead",{children:[u]}),Q(O,"tbody",{children:d})]})}confirm(){const O=this.#l;this.#y(),L(O)&&O()}cancel(){const O=this.#a;this.#y(),this.#b(this.#c("a11y.paste.cancelled"),{repeat:!0}),L(O)&&O()}#y(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const O=this.#s;this.#s=null,O&&L(O.focus)&&O.focus()}#w(){if(this.#n)return this.#n;const O=this.#t.viewport&&this.#t.viewport.overlays,b=O&&O.ownerDocument;if(!O||!b||!L(b.createElement))return null;const u=`${H}-title`,d=Q(b,"h2",{class:`${H}__title`,attrs:{id:u},text:this.#c("paste.preview.title")}),s=Q(b,"div",{class:`${H}__body`}),n=Q(b,"button",{class:`${H}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=Q(b,"button",{class:`${H}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),r=Q(b,"div",{class:`${H}__foot`,children:[t,n]}),o=Q(b,"div",{class:H,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":u},children:[Q(b,"div",{class:`${H}__head`,children:[d]}),s,r]});return O.appendChild(o),this.#n=o,this.#r=s,this.#o=n,this.#i=t,this.#k(o,n,t),o}#k(O,b,u){const d=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const r=[...O.querySelectorAll(U)].filter(i=>!i.disabled);if(!r.length){t.preventDefault();return}const o=r[0],f=r[r.length-1],l=O.ownerDocument.activeElement;t.shiftKey&&(l===o||l===O)?(t.preventDefault(),f.focus()):!t.shiftKey&&l===f&&(t.preventDefault(),o.focus())},s=t=>{t&&L(t.preventDefault)&&t.preventDefault(),this.confirm()},n=t=>{t&&L(t.preventDefault)&&t.preventDefault(),this.cancel()};O.addEventListener("keydown",d),b.addEventListener("click",s),u.addEventListener("click",n),this.#u.push(()=>{O.removeEventListener("keydown",d),b.removeEventListener("click",s),u.removeEventListener("click",n)})}#b(O,b){const u=this.#t&&this.#t.announce;L(u)&&u.call(this.#t,O,b)}destroy(){for(const O of this.#u)O();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),xe("packages/dom/src/rangeselect.js",function(e,K){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/model/selection.js"),Q=_.extendSeries,G=_.resolveSelectionConfig,H=K("packages/dom/src/renderer/textentry.js"),U=H.isTextEntry,z=H.isFindBarControl,O=K("packages/dom/src/pastepreview.js").PastePreview,b=K("packages/dom/src/columnmenu.js"),u=b.chartableRange,d=b.rangeChartConfig,s="lat-cell--range",n="lat-cell--range-edge",t=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),r=3;class o{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document,this.#a=i.preview||null}mount(){const i=this.#t.viewport.root,g=m=>this.#c(m),c=m=>this.#d(m),h=()=>this.#f(),a=m=>this.#h(m);i.addEventListener("pointerdown",g),this.#n.addEventListener("pointermove",c),this.#n.addEventListener("pointerup",h),i.addEventListener("keydown",a),this.#o.push(()=>{i.removeEventListener("pointerdown",g),this.#n.removeEventListener("pointermove",c),this.#n.removeEventListener("pointerup",h),i.removeEventListener("keydown",a)});for(const m of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(m,()=>this.paint()));this.paint()}#c(i){if(i.button!==0)return;const g=i.target;if(!g||!L(g.closest))return;if(this.#r=!1,g.closest('[data-role="fill-handle"]')){if(this.#E())return;this.#i={mode:"fill",fromX:i.clientX,fromY:i.clientY,armed:!0};return}if(g.closest('[data-role="row-drag"]'))return;const c=this.#N(g);if(!c)return;if(i.shiftKey&&this.#e.selection.corner()){const a=this.#j(c);this.#e.selection.extendRange(a.rowIndex,a.colId),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!0};return}const h=this.#M(c);this.#u=h,this.#e.selection.startRange(h.rowIndex,h.colId,{additive:i.ctrlKey||i.metaKey}),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!1}}#d(i){const g=this.#i;if(!g)return;if(!g.armed){if(Math.abs(i.clientX-g.fromX)+Math.abs(i.clientY-g.fromY)<r)return;g.armed=!0}const c=this.#H(i.clientX,i.clientY);if(!c)return;if(g.mode==="fill"){this.#l=c,this.paint();return}const h=this.#j(c);this.#e.selection.extendRange(h.rowIndex,h.colId)}#f(){const i=this.#i;if(this.#i=null,!!i){if(i.mode==="fill"&&this.#l){const g=this.#l;this.#l=null,this.fillTo(g.rowIndex)}this.#l=null,this.paint()}}#h(i){if(this.#x()||z(i.target)||U(i.target))return;const g=i.ctrlKey||i.metaKey,c=i.key;if(g&&(c==="c"||c==="C")){this.copy(),i.preventDefault();return}if(g&&(c==="v"||c==="V")){this.paste(),i.preventDefault();return}if(g&&(c==="d"||c==="D")){this.fillDown(),i.preventDefault();return}if(c==="Delete"||c==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),i.preventDefault();return}this.clear(),i.preventDefault();return}if(i.altKey&&c==="F1"){this.chartSelection()&&i.preventDefault();return}if(!i.shiftKey)return;const h={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[c];if(!h)return;if(g){const P=this.#$();if(!P)return;if(!this.#r){const $=this.#M(P);this.#u=$,this.#e.selection.startRange($.rowIndex,$.colId,{additive:!0}),this.#r=!0}const x=this.#e.columns.visible().map($=>$.id),E=x.indexOf(P.colId),j=this.#e.selection.corner()||{row:P.rowIndex,colId:P.colId},A=this.#j({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,j.row+h[0])),colId:x[Math.min(x.length-1,Math.max(0,(E<0?0:E)+h[1]))]});this.#e.selection.extendRange(A.rowIndex,A.colId),i.preventDefault();return}this.#r=!1;const a=this.#e.selection.corner(),m=this.#$(),w=a||m;if(!w)return;if(!a&&m){const P=this.#M(m);this.#u=P,this.#e.selection.startRange(P.rowIndex,P.colId)}const v=this.#e.columns.visible().map(P=>P.id),p=v.indexOf(w.colId??w.colId),y=v[Math.min(v.length-1,Math.max(0,p+h[1]))],C=Math.min(this.#e.rows.count()-1,Math.max(0,(a?a.row:m.rowIndex)+h[0])),T=this.#j({rowIndex:C,colId:y});this.#e.selection.extendRange(T.rowIndex,T.colId),i.preventDefault()}async copy(){const i=this.#e.export.rangeText();if(!i)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const g=globalThis.navigator&&globalThis.navigator.clipboard;if(!g||!L(g.writeText))return!1;try{return await g.writeText(i),this.#e.emit("clipboard:copy",{text:i,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:i,ok:!1,rows:"range"},"user"),!1}}async paste(){const i=globalThis.navigator&&globalThis.navigator.clipboard;if(!i||!L(i.readText))return 0;let g="";try{g=await i.readText()}catch{return 0}return this.pasteText(g)}pasteText(i){if(!i)return 0;const g=this.#e.selection.cells(),c=g.length?g[0]:this.#k();if(!c)return 0;const h=g.length>1?{rows:new Set(g.map(a=>a.key)).size,columns:new Set(g.map(a=>a.colId)).size}:void 0;if(this.#p()){const a=this.#e.edit.previewPaste(c,i,h);if(a.changes.length+a.rejected.length>1)return this.#m().show(a,{onConfirm:()=>this.#g(c,i,h)}),0}return this.#g(c,i,h)}#p(){const i=this.#e.edit;return!!(i&&i.pastePreview&&L(i.previewPaste))}#m(){return this.#a||(this.#a=new O({grid:this.#e,renderer:this.#t})),this.#a}#g(i,g,c){const h=this.#e.edit.pasteInto(i,g,c);return this.#w(h?this.#y("a11y.range.written",{count:h}):this.#y("a11y.range.refused"),{repeat:!0}),h}#y(i,g){const c=this.#e;return(c&&c.messages?c.messages:F).t(i,g)}#w(i,g){const c=this.#t&&this.#t.announce;L(c)&&c.call(this.#t,i,g)}#k(){const i=this.#$();if(!i)return null;const g=this.#e.rows.get(i.rowIndex);return g?{key:g.key,colId:i.colId}:null}clear(){const i=this.#e.selection.cells();return i.length?this.#e.edit.setCells(i.map(g=>({...g,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const i=this.#e.selection.cells();if(i.length<2)return 0;const g=[...new Set(i.map(a=>a.key))];if(g.length<2)return 0;const c=g[0],h=[];for(const{key:a,colId:m}of i)a!==c&&h.push({key:a,colId:m,value:this.#e.rows.value(c,m)});return this.#e.edit.setCells(h)}chartSelection(){const i=d(this.#e);if(!i.handler)return!1;const g=u(this.#e);return g?(i.handler(this.#e,g),!0):!1}fillTo(i){if(this.#e.selection.ranges().length>1)return 0;const g=this.#e.selection.cells();if(!g.length)return 0;const c=[...new Set(g.map(y=>y.key))],h=[...new Set(g.map(y=>y.colId))],a=this.#z(c[c.length-1]);if(a<0||i<=a)return 0;const m=[];for(let y=a+1;y<=i;y++){const C=this.#e.rows.get(y);if(!C)break;m.push(C)}if(!m.length)return 0;const w=[];for(const y of h){const C=c.map(P=>this.#e.rows.value(P,y)),T=this.#b(C,m,y);for(let P=0;P<m.length;P++)w.push({key:m[P].key,colId:y,value:T[P]})}const v=this.#e.edit.setCells(w),p=this.#e.selection.corner();return p&&this.#e.selection.extendRange(i,p.colId),v}#b(i,g,c){const h=this.#e.get("selection"),a=h&&typeof h=="object"?h.fill:void 0;if(L(a)){const m=this.#e.columns.get(c),w=g.map(p=>({row:p,column:m})),v=a({source:i,target:w,direction:"down"});if(Array.isArray(v)&&v.length===g.length)return v}return Q(i,g.length)}paint(){const i=this.#t.viewport.root;if(!i||!i.querySelectorAll)return;const g=this.#e.selection,c=g.ranges().length>0,h=this.#l;for(const a of i.querySelectorAll("[data-col]")){const m=a.getAttribute("data-col"),w=a.parentNode,v=a.getAttribute?a.getAttribute("data-index"):null,p=v!==null&&v!==""?v:w&&w.getAttribute?w.getAttribute("data-index"):null;if(p===null||p==="")continue;const y=Number(p);if(!Number.isFinite(y)||y<0)continue;const C=c&&g.inRange(y,m),T=!!h&&this.#O(y,m,h);a.classList.toggle(s,C||T);const P=C||T?this.#A(y,m,g):null;a.classList.toggle(n,!!P&&P.any);for(const[x,E]of Object.entries(t))a.classList.toggle(E,!!P&&P[x])}this.#P()}#O(i,g,c){const h=this.#e.selection.cells();if(!h.length||!new Set(h.map(w=>w.colId)).has(g))return!1;const m=this.#z([...new Set(h.map(w=>w.key))].pop());return i>m&&i<=c.rowIndex}#A(i,g,c){const h=this.#e.columns.visible().map(p=>p.id),a=h.indexOf(g),m=a>0?h[a-1]:null,w=a>=0&&a<h.length-1?h[a+1]:null,v={top:!c.inRange(i-1,g),bottom:!c.inRange(i+1,g),left:!m||!c.inRange(i,m),right:!w||!c.inRange(i,w)};return v.any=v.top||v.bottom||v.left||v.right,v}#P(){const i=this.#e.selection.corner(),g=this.#t.viewport.overlays;if(!g)return;if(!i||this.#L()===!1||this.#e.selection.ranges().length>1||this.#E()){this.#s&&(this.#s.style.display="none");return}const c=this.#B(i.row,i.colId);if(!c||!L(c.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#y("a11y.fillHandle")),g.appendChild(this.#s));const h=c.getBoundingClientRect(),a=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const w=this.#t.viewport.rtl===!0?h.left:h.right;this.#s.style.left=`${Math.round(w-a.left)-4}px`,this.#s.style.top=`${Math.round(h.bottom-a.top)-4}px`}#S(i){const g=this.#t;return!i||typeof g.spanAt!="function"?null:g.spanAt(i.rowIndex,i.colId)}#M(i){const g=this.#S(i);return g?{rowIndex:g.row,colId:g.columnId}:i}#j(i){const g=this.#S(i);if(!g)return i;const c=this.#u,h=!!c&&c.rowIndex>=g.row+g.rows,a=this.#R(),m=c?a.indexOf(c.colId):-1,w=m>=0&&m>=g.col+g.cols;return{rowIndex:h?g.row:g.row+g.rows-1,colId:w?g.columnId:g.endColumnId}}#E(){const i=this.#e.selection.corner();if(!i)return!1;const g=this.#S({rowIndex:i.row,colId:i.colId});return!!g&&(g.rows>1||g.cols>1)}#R(){const i=this.#e.columns;return i&&L(i.visible)?i.visible().map(g=>g.id):[]}#L(){return G(this.#e.get("selection")).fillHandle}#x(){const i=this.#t.viewport.root;return!!(i&&i.querySelector&&i.querySelector(".lat-editor-host, .lat-editor--popup"))}#I(){const i=this.#e.selection.cells();return i.length?i[0]:null}#z(i){for(let g=0;g<this.#e.rows.count();g++){const c=this.#e.rows.get(g);if(c&&c.key===i)return g}return-1}#$(){const i=this.#t.viewport.root,g=i&&i.querySelector?i.querySelector('[data-col][tabindex="0"]'):null;return g?this.#N(g):null}#N(i){if(!i||!L(i.closest))return null;const g=i.closest("[data-col]");if(!g||!g.classList.contains("lat-cell"))return null;const c=g.closest("[data-index]");if(!c)return null;const h=Number(c.getAttribute("data-index"));return!Number.isFinite(h)||h<0?null:{rowIndex:h,colId:g.getAttribute("data-col")}}#H(i,g){const c=this.#n.elementFromPoint?this.#n.elementFromPoint(i,g):null;return c?this.#N(c):null}#B(i,g){const c=this.#t.viewport.root;if(!c||!c.querySelectorAll)return null;for(const h of c.querySelectorAll(`[data-col="${g}"]`)){const a=h.closest?h.closest("[data-index]"):null;if(a&&Number(a.getAttribute("data-index"))===i)return h}return null}destroy(){for(const i of this.#o)i();this.#o=[],this.#s&&L(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&L(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const f=o}),xe("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return o}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/import/index.js"),Q=_.parseDelimited,G=_.inferColumns,H=_.mapRecords,U=_.readXlsx,z=_.looksLikeXlsx,S=K("packages/dom/src/editors/common.js"),O=S.el,b=S.clear,u=S.on,s=K("packages/dom/src/renderer/textentry.js").isTextEntry,n="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',r=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class o{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document;const i=l.settings&&typeof l.settings=="object"?l.settings:{};this.#r={file:i.file!==!1,drop:i.drop!==!1,paste:i.paste!==!1,mode:i.mode==="replace"?"replace":"append"},this.#u()}#u(){const l=this.#t&&this.#t.viewport?this.#t.viewport.root:null;l&&(this.#r.drop&&(this.#o.push(u(l,"dragover",i=>{i.dataTransfer&&[...i.dataTransfer.types||[]].includes("Files")&&(i.preventDefault(),l.classList.add("lat-import--dropzone"))})),this.#o.push(u(l,"dragleave",()=>l.classList.remove("lat-import--dropzone"))),this.#o.push(u(l,"drop",i=>{l.classList.remove("lat-import--dropzone");const g=i.dataTransfer&&i.dataTransfer.files&&i.dataTransfer.files[0];g&&(i.preventDefault(),this.#c(g))}))),this.#r.paste&&this.#o.push(u(l,"paste",i=>{if(s(i.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const g=i.clipboardData&&i.clipboardData.getData("text/plain");!g||!g.includes(`
57
- `)||(i.preventDefault(),this.fromText(g))})))}openFile(){const l=O(this.#n,"input",{attrs:{type:"file",accept:r}});l.style.display="none",this.#o.push(u(l,"change",()=>{const i=l.files&&l.files[0];i&&this.#c(i),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(L(l.arrayBuffer)){l.arrayBuffer().then(g=>{const c=new Uint8Array(g);if(z(c)){this.fromXlsx(c,l.name);return}this.fromText(new TextDecoder().decode(c),l.name)});return}if(L(l.text)){l.text().then(g=>this.fromText(g,l.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),l.name),i.readAsText(l)}async fromXlsx(l,i){const{header:g,rows:c}=await U(l);if(!g.length)return;const h=G(g,c,{columns:this.#e.columns.all()}),a=c.filter(m=>m.length!==g.length).length;this.#l={rows:c,columns:h,delimiter:null,name:i,warnings:a?[`${a} row(s) do not have ${g.length} columns`]:[]},this.#d()}fromText(l,i){const{header:g,rows:c,delimiter:h}=Q(l);if(!g.length)return;const a=G(g,c,{columns:this.#e.columns.all()}),m=c.filter(w=>w.length!==g.length).length;this.#l={rows:c,columns:a,delimiter:h,name:i,warnings:m?[`${m} row(s) do not have ${g.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(t);l&&L(l.focus)&&l.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(l,i){const g=this.#t&&this.#t.announce;L(g)&&g.call(this.#t,l,i)}#h(l,i){return(this.#e&&this.#e.messages?this.#e.messages:F).t(l,i)}#p(){const l=this.#n,i=O(l,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),g=O(l,"div",{class:`${n}__panel`});g.appendChild(O(l,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=O(l,"div",{class:`${n}__body`}),g.appendChild(this.#s);const c=O(l,"div",{class:`${n}__footer`}),h=O(l,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),a=O(l,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(u(h,"click",()=>this.close())),this.#o.push(u(a,"click",()=>this.#g())),c.appendChild(h),c.appendChild(a),g.appendChild(c),i.appendChild(g),this.#o.push(u(i,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...i.querySelectorAll(t)].filter(C=>!C.hidden);if(!v.length)return;const p=v[0],y=v[v.length-1];w.shiftKey&&this.#n.activeElement===p?(w.preventDefault(),y.focus()):!w.shiftKey&&this.#n.activeElement===y&&(w.preventDefault(),p.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const l=this.#n,i=b(this.#s),{rows:g,columns:c,name:h,warnings:a}=this.#l;i.appendChild(O(l,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:g.length,name:h||this.#h("import.clipboard")})}));for(const C of a)i.appendChild(O(l,"p",{class:`${n}__warning`,text:C}));const m=this.#e.columns.all().map(C=>C.field||C.id).filter(Boolean),w=O(l,"table",{class:`${n}__map`}),v=O(l,"tr",{});for(const C of["import.colSource","import.colField","import.colType"])v.appendChild(O(l,"th",{text:this.#h(C)}));w.appendChild(v),c.forEach((C,T)=>{const P=O(l,"tr",{});P.appendChild(O(l,"td",{text:C.source}));const x=O(l,"select",{attrs:{"data-col":String(T),"aria-label":this.#h("import.mapLabel",{source:C.source})}});x.appendChild(O(l,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const j of m)x.appendChild(O(l,"option",{text:j,attrs:{value:j,selected:j===C.field?!0:null}}));C.field&&!m.includes(C.field)&&x.appendChild(O(l,"option",{text:C.field,attrs:{value:C.field,selected:!0}}));const E=O(l,"td",{});E.appendChild(x),P.appendChild(E),P.appendChild(O(l,"td",{class:`${n}__type`,text:C.type})),w.appendChild(P)}),i.appendChild(w);const p=O(l,"div",{class:`${n}__mode`}),y=O(l,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});y.appendChild(O(l,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(O(l,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),p.appendChild(O(l,"label",{text:this.#h("import.modeLabel")})),p.appendChild(y),i.appendChild(p)}#g(){const{rows:l,columns:i}=this.#l;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));i[w]&&m.value!==void 0&&m.value!==null&&(i[w].field=m.value)}const g=this.#i.querySelector("select[data-mode]"),c=g?g.value:void 0,h=c==="replace"||c==="append"?c:this.#r.mode,a=H(l,i);this.#e.import.apply(a,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:a.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&L(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),xe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),Q=_.el,G=_.on,H=_.clear,U=_.documentFor,z="lat-history";class S{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(u,d)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||F;const d=u||{};if(this.doc=U(d),this.host=d.host||{},this.props=d.props||{},this.root=Q(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const s=Q(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(G(s,"click",()=>this.toggle())),this.root.appendChild(s),this.toggleButton=s,this.menu=Q(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,d,s){const n=Q(this.doc,"button",{class:`${z}__${u}`,attrs:{type:"button"},children:[Q(this.doc,"span",{class:`${z}__glyph`,text:s,attrs:{"aria-hidden":"true"}}),Q(this.doc,"span",{class:`${z}__label`,text:d})]});return this.off.push(G(n,"click",()=>{const t=this.host[u];L(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,d=L(u.canUndo)?u.canUndo():!1,s=L(u.canRedo)?u.canRedo():!1,n=L(u.peek)?u.peek("undo"):null,t=L(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",d,n),this.#t(this.redoButton,"redo",s,t),this.open&&this.#n()}#t(u,d,s,n){if(!u)return;u.disabled=!s;const t=d==="undo",r=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${z}__label`);o&&(o.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;u.setAttribute("title",s?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",s?f:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;H(u);const d=L(this.host.list)?this.host.list():[];if(!d.length){u.appendChild(Q(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((s,n)=>{const t=Q(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":s.type,"data-undone":s.undone?"true":null},children:[Q(this.doc,"span",{class:`${z}__kind`,text:s.type}),Q(this.doc,"span",{class:`${z}__text`,text:s.label||s.type})]});this.off.push(G(t,"click",()=>{const r=n+1;for(let o=0;o<r;o++)L(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&L(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const O=S}),xe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,Q={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},G="lat-cell--changed",H="lat-cell--added-column";class U{#e;#t;#n=[];constructor(b){this.#e=b.grid,this.#t=b.renderer}mount(){for(const b of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(b,()=>this.paint()));this.paint()}paint(){const b=this.#t.viewport.root;if(!b||!b.querySelectorAll)return;const u=this.#e.diff,d=u&&u.enabled;for(const s of b.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key"),t=d?u.statusOf(n):"unchanged";for(const o of Object.values(Q))s.classList.remove(o);d&&Q[t]&&s.classList.add(Q[t]),s.setAttribute("data-diff",d?t:"");const r=d&&t==="changed";for(const o of s.querySelectorAll("[data-col]")){const f=o.getAttribute("data-col");if(o.classList.remove(G,H),o.removeAttribute("data-before"),!r)continue;const l=u.cellStatus(n,f);if(l==="changed"){o.classList.add(G);const i=this.#r(u,n,f);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else l==="added-column"&&o.classList.add(H)}}}#r(b,u,d){const s=this.#e,n=s&&s.columns,t=n&&L(n.get)?n.get(d):null,r=s&&s.permissions;if(t&&r&&L(r.isSecret)&&r.isSecret(t))return null;const o=b.before(u,d);if(o==null)return this.#o("diff.empty");if(!t||!L(t.formatValue))return String(o);const f=L(b.beforeRow)?b.beforeRow(u):void 0,i={...(s.rows&&L(s.rows.byKey)?s.rows.byKey(u):null)||{},data:f===void 0?{}:f};try{const g=t.formatValue(o,i,i.data);return g==null?"":String(g)}catch(g){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,g),String(o)}}#o(b,u){const d=this.#e;return(d&&d.messages?d.messages:_).t(b,u)}destroy(){for(const u of this.#n)u();this.#n=[];const b=this.#t.viewport.root;if(!(!b||!b.querySelectorAll)){for(const u of b.querySelectorAll("[data-key]")){for(const d of Object.values(Q))u.classList.remove(d);u.removeAttribute("data-diff")}for(const u of b.querySelectorAll("[data-col]"))u.classList.remove(G,H),u.removeAttribute("data-before")}}}function z(O){return!!(O&&O.diff&&(L(O.diff)||typeof O.diff=="object"))}const S=U}),xe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",F="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const H=()=>{this.#o=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):L(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#l();if(U){U.sweep();for(const z of H.querySelectorAll("[data-key]")){const S=z.getAttribute("data-key");for(const O of z.querySelectorAll("[data-col]")){const b=U.active?U.colourFor(S,O.getAttribute("data-col")):null;b?(O.classList.add(B),O.style.setProperty(F,b)):O.classList.contains(B)&&(O.classList.remove(B),O.style.removeProperty(F))}}this.#s(U)}}#s(H){this.#r!==null&&L(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const U=H.nextExpiry;if(!Number.isFinite(U)||!L(this.#i.setTimeout))return;const z=Math.max(0,U-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&L(H.model)?H.model():null}destroy(){this.#r!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B),U.style.removeProperty(F)}}const Q=_}),xe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",F="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const H=()=>{this.#r=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):L(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#e.find;if(!U||!L(U.stateFor))return;const z=L(U.model)?U.model():null,S=!!z&&z.active;if(!S&&!this.#o)return;let O=!1;for(const b of H.querySelectorAll("[data-key]")){const u=b.getAttribute("data-key");for(const d of b.querySelectorAll("[data-col]")){const s=S?U.stateFor(u,d.getAttribute("data-col")):null;s?(O=!0,d.classList.add(B),d.classList.toggle(F,s==="current")):d.classList.contains(B)&&d.classList.remove(B,F)}}this.#o=O}destroy(){for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B,F);this.#o=!1}}}const Q=_}),xe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const X=K("packages/dom/src/editors/common.js"),L=X.el,B=X.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z="lat-find",S=12,O=120;class b{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!1;#p=!1;#m=null;#g=[];#y=null;#w=null;#k=!1;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#n=s.document||s.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=s.settings&&typeof s.settings=="object"?s.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(s,n){const t=this.#e;return(t&&t.messages&&U(t.messages.t)?t.messages:G).t(s,n)}mount(){const s=this.#O();if(!s)return;s.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),s.attachDriver({run:()=>this.#E()});const n=this.#t.viewport?.root;if(n&&U(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const o=r.target;if(this.#s&&o===this.#s){r.preventDefault(),r.stopPropagation(),U(this.#s.select)&&this.#s.select();return}_(o)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#P())),this.#g.push(this.#e.on("column:visible",()=>this.#P()))}show(s){const n=this.#A();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#b(),this.#O().setOpen(!0),s!=null&&(this.#s.value=String(s),this.#M()),this.#s.focus(),U(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#z();const s=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#b()),s&&(s.clear(),s.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&U(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(U(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;U(o.focus)&&o.focus()}search(){this.#M()}destroy(){this.#k=!0,this.#z();for(const n of this.#g)n();this.#g=[];const s=this.#O();s&&(s.attachUi(null),s.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#b(){const s=this.#t;s&&U(s.invalidate)&&s.invalidate("size")}#O(){const s=this.#e&&this.#e.find;return s&&U(s.model)?s.model():null}#A(){if(this.#i)return this.#i;const s=this.#t.viewport,n=s?.root,t=this.#n;if(!n||!t||!U(n.insertBefore))return null;const r=L(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=L(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=L(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=L(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=L(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=L(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=L(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=L(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=L(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=L(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=L(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=L(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#f]});for(const c of[this.#s,this.#l,this.#a,this.#u,o,f,l,i])r.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),this.#M()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#M()})),this.#g.push(B(this.#f,"change",()=>{const c=this.#f.value;this.#m=c?String(c):null,this.#M()})),this.#g.push(B(l,"click",()=>this.hide()));const g=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#y!==null&&(this.#x(),this.#M()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",g),this.#g.push(()=>r.removeEventListener("keydown",g)),r.style.display="none",n.insertBefore(r,s.header||n.firstChild),this.#i=r,this.#P(),r}#P(){const s=this.#f;if(!s)return;const n=this.#n;for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(L(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&U(t.visible)?t.visible():[];let o=!1;for(const f of r){if(!f||f.id===void 0)continue;const l=String(f.id);s.appendChild(L(n,"option",{text:f.title||l,attrs:{value:l}})),l===this.#m&&(o=!0)}o||(this.#m=null),s.value=this.#m||""}#S(){const s=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):O;if(this.#x(),s===0||!U(this.#r.setTimeout)){this.#M();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#M()},s)}#M(){const s=this.#O();if(!s||this.#k)return;const n=this.#s?this.#s.value:"";if(!n){this.#I(),s.clear();return}s.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#j()}),this.#E()}#j(){const s=this.#t&&this.#t.window,n=s&&Number.isFinite(s.first)?s.first:0;return Math.max(0,n)}#E(){if(this.#w!==null||this.#k)return;const s=()=>{this.#w=null,this.#R()};U(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(s):U(this.#r.setTimeout)?this.#w=this.#r.setTimeout(s,0):s()}#R(){const s=this.#O();!s||this.#k||!s.active||(s.stale&&s.rescan({from:this.#j()}),!s.complete&&(s.step(S)||this.#E()))}#L(){if(!this.#i||this.#k)return;const s=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(s.total===0?(t=s.complete?this.t("find.none"):this.t("find.searching"),r=s.complete?"none":"searching"):(t=this.t(s.complete?"find.count":"find.countPartial",{current:s.current,total:s.total}),r=s.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const o=n&&s.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",n?s.complete&&(this.#u.textContent=s.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:s.current,count:s.total})):this.#u.textContent=""}#x(){this.#y!==null&&U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#I(){this.#w!==null&&(U(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#z(){this.#x(),this.#I()}}const u=b}),xe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const X="lat-cell--redacted",L="lat-cell";class B{#e;#t;#n=[];constructor(Q){this.#e=Q.grid,this.#t=Q.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Q=this.#t.viewport?.root;if(!Q||!Q.querySelectorAll)return;const G=this.#e.redaction;if(!G)return;const H=G.active;for(const U of Q.querySelectorAll(`.${L}[data-col]`))H&&G.has(U.getAttribute("data-col"))?U.classList.add(X):U.classList.contains(X)&&U.classList.remove(X)}destroy(){for(const Q of this.#n)Q();this.#n=[]}}const F=B}),xe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function F(G,H){let U=G;for(;U;){if(H(U))return U;U=U.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const U=F(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return U?U.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${B}[data-col]`)){const S=z.getAttribute("data-col"),O=this.#r(z),b=O?H.errorFor(O,S):null;L(z,b?b.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const Q=_}),xe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/dom/src/renderer/textentry.js").isTextEntry,Q=K("packages/dom/src/renderer/viewport.js").CLASS,G="lat-presenting",H="lat-presenting--changing",U="lat-presenting__progress",z="lat-cell--dimmed",S=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class O{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),this.#r.push(this.#e.on("presentation:view",s=>this.#a(s))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&L(this.#n.watch)&&this.#r.push(this.#n.watch(s=>{s||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const d=this.#t.viewport?.root;if(d&&L(d.addEventListener)){const s=n=>this.#l(n);d.addEventListener("keydown",s),this.#r.push(()=>d.removeEventListener("keydown",s))}}#l(d){const s=this.#e.presentation;if(!s?.active)return;const n=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(s.stop(),d.preventDefault?.());return}if(n){t==="="||t==="+"?(s.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(s.nudge(-1),d.preventDefault?.()):t==="0"&&(s.setScale(1.5),d.preventDefault?.());return}if(!s.views.length||F(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(s.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(s.step(-1),d.preventDefault?.()):t==="Home"?(s.goTo(0),d.preventDefault?.()):t==="End"?(s.goTo(s.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(s.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const s=this.#t.viewport?.overlays;if(!s||!this.#e.presentation.views.length)return;const n=s.ownerDocument;if(!n?.createElement)return;if(!this.#i){const o=n.createElement("div");o.className=U,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),s.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(d.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#h();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const s=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of S){if(s.has(r)||r==="toolPanel"&&this.#k())continue;const o=this.#b(r);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",n.push(o))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:d,hidden:n},this.#t.viewport?.root?.classList?.add(G),this.#h(),this.#m()}#f(){const d=this.#o;this.#o=null;const s=this.#t.viewport?.root;if(s?.classList?.remove(G),s?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),s?.classList?.remove(H),this.#p(),d){const n=this.#e.toolPanel;n&&L(n.presentRestore)&&n.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const s=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=s&&s.keys.length?new Set(s.keys):null,t=s&&s.colIds.length?new Set(s.colIds):null;for(const r of d.querySelectorAll("[data-key]")){const o=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!s||o&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(z):f.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const s=this.#t.viewport?.root?.ownerDocument?.defaultView;s?.setInterval&&(this.#s=s.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const d=this.#e.element;return!d||!L(d.querySelector)?null:d.querySelector(`.${Q.statusBar}`)}#w(d){const s=d.children||[];for(const n of s)if(!n.style||n.style.display!=="none")return!1;return!0}#k(){const d=this.#e.toolPanel;return!!(d&&L(d.presentOnly)&&d.presentOnly())}#b(d){const s=this.#e.element;if(!s||!L(s.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return n?s.querySelector(n):null}destroy(){this.#o&&this.#f();for(const d of this.#r)d();this.#r=[]}}const b=O}),xe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const L=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(U,z,S){const O=S.getComputedStyle(U),b=z.style;if(b)for(let u=0;u<O.length;u++){const d=O[u];B.has(d)||b.setProperty(d,O.getPropertyValue(d),O.getPropertyPriority(d))}}function _(U,z,S){if(F(U,z,S),U.tagName==="CANVAS"&&L(U.toDataURL))try{const u=U.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${u})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const O=U.children||[],b=z.children||[];for(let u=0;u<O.length&&u<b.length;u++)_(O[u],b[u],S)}function Q(U,z){if(!U||U.startsWith("data:")||U.startsWith("blob:"))return!0;try{return new URL(U,z).origin===z}catch{return!0}}async function G(U,z={}){const S=U.ownerDocument,O=S?.defaultView;if(!O||typeof O.getComputedStyle!="function")throw new Error("capture needs a browser document");const b=U.getBoundingClientRect(),u=Math.max(1,Math.ceil(b.width)),d=Math.max(1,Math.ceil(b.height)),s=Math.max(.1,Number(z.scale)||2),n=O.location?.origin||"";for(const g of U.querySelectorAll("img")){const c=g.getAttribute("src")||"";if(!Q(c,n))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=U.cloneNode(!0);_(U,t,O),t.style.width=`${u}px`,t.style.height=`${d}px`,t.style.margin="0";const r=new O.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new O.Image;await new Promise((g,c)=>{f.onload=()=>g(void 0),f.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const l=S.createElement("canvas");l.width=Math.round(u*s),l.height=Math.round(d*s);const i=l.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||O.getComputedStyle(U).backgroundColor||"#ffffff",i.fillRect(0,0,l.width,l.height),i.drawImage(f,0,0,l.width,l.height),new Promise((g,c)=>{l.toBlob(h=>h?g({blob:h,width:l.width,height:l.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=G}),xe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.uid,F=X.warnOnce,Q=K("packages/dom/src/renderer/direction.js").signedX,G=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),S=14,O="system-ui, -apple-system, sans-serif";function b(h,a){if(!h||typeof h!="object")return null;const m=U[h.type];if(!m)return null;const w=typeof h.id=="string"&&h.id?h.id:B("mark"),v=Array.isArray(h.points)?h.points:[],p=[];for(const C of v){const T=Number(C&&C.x),P=Number(C&&C.y);Number.isFinite(T)&&Number.isFinite(P)&&p.push({x:T,y:P})}const y=typeof h.colour=="string"&&h.colour?h.colour:a;if(m==="text"){const C=typeof h.text=="string"?h.text:"";if(!p.length||!C)return null;const T={id:w,tool:m,colour:y,points:[p[0]],text:C,region:u(h.region)},P=Number(h.fontSize);return Number.isFinite(P)&&P>0&&(T.fontSize=P),typeof h.background=="string"&&h.background&&(T.background=h.background),T}return p.length<2?null:{id:w,tool:m,colour:y,points:p,region:u(h.region)}}function u(h){return h==="start"||h==="end"?h:"centre"}function d(h){const a={id:h.id,type:z[h.tool]||h.tool,colour:h.colour,points:h.points.map(m=>({x:m.x,y:m.y}))};return(h.region==="start"||h.region==="end")&&(a.region=h.region),h.tool==="text"&&(a.text=h.text,h.fontSize!==void 0&&(a.fontSize=h.fontSize),h.background!==void 0&&(a.background=h.background)),a}const s="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,a){return{id:h,count:a,valueOf(){return this.count}}}const o=10;function f(h,a,m){const w=m.x-a.x,v=m.y-a.y,p=w*w+v*v;let y=p?((h.x-a.x)*w+(h.y-a.y)*v)/p:0;y=Math.max(0,Math.min(1,y));const C=a.x+y*w,T=a.y+y*v;return Math.hypot(h.x-C,h.y-T)}function l(h){const a=h.points;if(!a.length)return null;if(h.tool==="text"){const y=h.fontSize||S,C=(h.text||"").length*y*.6;return{x1:a[0].x,y1:a[0].y,x2:a[0].x+C,y2:a[0].y+y*1.2}}let m=1/0,w=1/0,v=-1/0,p=-1/0;for(const y of a)m=Math.min(m,y.x),w=Math.min(w,y.y),v=Math.max(v,y.x),p=Math.max(p,y.y);return{x1:m,y1:w,x2:v,y2:p}}function i(h,a){const m=l(h);if(!m)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(a.x>=m.x1&&a.x<=m.x2&&a.y>=m.y1&&a.y<=m.y2)return 0;if(h.tool==="text")return 1/0}const w=h.points;if(h.tool==="rect"){const p=[{x:m.x1,y:m.y1},{x:m.x2,y:m.y1},{x:m.x2,y:m.y2},{x:m.x1,y:m.y2}];let y=1/0;for(let C=0;C<4;C++)y=Math.min(y,f(a,p[C],p[(C+1)%4]));return y}if(w.length===1)return Math.hypot(a.x-w[0].x,a.y-w[0].y);let v=1/0;for(let p=0;p<w.length-1;p++)v=Math.min(v,f(a,w[p],w[p+1]));return v}class g{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#u=Array.isArray(a.seed)?a.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(a){const m=b(a,this.#i);return m?(m.durable=!0,this.#s.push(m),this.#M(),this.redraw(),this.#R(),r(m.id,this.#s.length)):(F("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(d)}remove(a){const m=this.#s.findIndex(w=>w.id===a);return m<0?(F("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${a}".`),!1):(this.#s.splice(m,1),this.#c===a&&(this.#c=null),this.redraw(),this.#R(),!0)}replaceAll(a){const m=Array.isArray(a)?a:[];this.#s=m.map(w=>b(w,this.#i)).filter(Boolean);for(const w of this.#s)w.durable=!0;this.#s.length&&this.#M(),this.redraw(),this.#R()}#d(){const a=this.#t.viewport?.root;if(!a||!L(a.addEventListener))return;const m=w=>{if(!(!this.#o||!w)){if(w.key==="Escape"){this.use(null),w.preventDefault?.();return}if(this.#o==="erase"){if(w.key==="Tab"){this.#f(w);return}(w.key==="Delete"||w.key==="Backspace")&&this.#h(w)}}};a.addEventListener("keydown",m,!0),this.#a.push(()=>a.removeEventListener("keydown",m,!0))}#f(a){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}a.preventDefault?.();const m=this.#c?this.#s.findIndex(p=>p.id===this.#c):-1,w=a.shiftKey?-1:1,v=m<0?w>0?0:this.#s.length-1:(m+w+this.#s.length)%this.#s.length;this.#c=this.#s[v].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:v+1,of:this.#s.length})}#h(a){if(!this.#c)return;a.preventDefault?.();const m=this.#c;this.remove(m),this.#x("a11y.annotate.erased")}#p(){const a=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!a||!L(a.matchMedia))return;let m=null;const w=()=>{const v=a.devicePixelRatio||1;let p;try{p=a.matchMedia(`(resolution: ${v}dppx)`)}catch{return}m=p;const y=()=>{this.redraw(),w()};L(p.addEventListener)?p.addEventListener("change",y,{once:!0}):L(p.addListener)&&p.addListener(y)};w(),this.#a.push(()=>{m=null})}use(a,m={}){const w=!!m.colour&&a===this.#o;m.colour&&(this.#i=String(m.colour));const v=a&&G.includes(a)?a:null;this.#o=v&&v===this.#o&&!w?null:v,this.#o!=="erase"&&(this.#c=null);const p=this.#o?this.#M():this.#n;return p&&(p.style.pointerEvents=this.#o?"auto":"none",p.style.cursor=this.#o?"crosshair":""),this.#R(),this.#o}undo(){const a=this.#s.pop();return a&&this.#c===a.id&&(this.#c=null),this.redraw(),this.#R(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#R())}#m(){const a=this.#s.filter(m=>m.durable);a.length!==this.#s.length&&(this.#s=a,this.redraw(),this.#R())}redraw(){!this.#n&&this.#s.length&&this.#M();const a=this.#n,m=this.#r;if(!a||!m)return;this.#j();const{left:w,top:v}=this.#S();m.clearRect(0,0,a.width,a.height);const p=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const C=p.filter(T=>u(T.region)===y);if(C.length){m.save(),this.#g(m,y),m.translate((y==="centre"?-w:0)||0,-v||0);for(const T of C)this.#b(m,T),T.id===this.#c&&this.#A(m,T);m.restore()}}}#g(a,m="centre"){const w=this.#n,v=this.#t.viewport?.bodyViewport;if(!L(w?.getBoundingClientRect)||!L(v?.getBoundingClientRect))return;const p=w.getBoundingClientRect(),y=v.getBoundingClientRect();if(!y.width||!y.height)return;const C=this.#y(m,y);C&&(a.beginPath(),a.rect(C.left-p.left,y.top-p.top,C.width,y.height),a.clip())}#y(a,m){const w=P=>{if(!L(P?.getBoundingClientRect))return null;const x=P.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},v=w(this.#t.viewport?.bodyStart),p=w(this.#t.viewport?.bodyEnd);if(a==="start")return v;if(a==="end")return p;let y=m.left,C=m.left+m.width;const T=m.left+m.width/2;for(const P of[v,p]){if(!P)continue;const x=P.left+P.width;P.left+P.width/2<T?y=Math.max(y,x):C=Math.min(C,P.left)}return C>y?{left:y,width:C-y}:null}#w(a){for(const[m,w]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!L(w?.getBoundingClientRect))continue;const v=w.getBoundingClientRect();if(v&&v.width>0&&a>=v.left&&a<v.left+v.width)return m}return"centre"}#k(a){const m=this.#t.viewport?.bodyViewport;if(!L(m?.getBoundingClientRect))return!0;const w=m.getBoundingClientRect();return!w.width||!w.height?!0:a.clientX>=w.left&&a.clientX<=w.right&&a.clientY>=w.top&&a.clientY<=w.bottom}#b(a,m){const w=m.points;if(!w.length)return;const v=this.#e.presentation?.scale||1;a.lineWidth=(n[m.tool]||3)*v,a.strokeStyle=m.colour,a.fillStyle=m.colour,a.lineCap="round",a.lineJoin="round",a.globalAlpha=m.tool==="highlight"?.32:1;const p=w[0],y=w[w.length-1];if(m.tool==="text"){const C=(m.fontSize||S)*v;a.font=`${C}px ${O}`,a.textBaseline="top";const T=m.text||"";if(m.background){let P=T.length*C*.6;if(typeof a.measureText=="function"){const x=a.measureText(T);x&&Number.isFinite(x.width)&&(P=x.width)}a.fillStyle=m.background,a.fillRect(p.x-C*.15,p.y-C*.1,P+C*.3,C*1.2)}a.fillStyle=m.colour,a.fillText(T,p.x,p.y),a.globalAlpha=1;return}if(m.tool==="rect")a.strokeRect(p.x,p.y,y.x-p.x,y.y-p.y);else if(m.tool==="arrow")a.beginPath(),a.moveTo(p.x,p.y),a.lineTo(y.x,y.y),a.stroke(),this.#O(a,p,y,a.lineWidth);else{a.beginPath(),a.moveTo(p.x,p.y);for(let C=1;C<w.length;C++)a.lineTo(w[C].x,w[C].y);a.stroke()}a.globalAlpha=1}#O(a,m,w,v){const p=Math.atan2(w.y-m.y,w.x-m.x),y=Math.max(8,v*3);a.beginPath(),a.moveTo(w.x,w.y),a.lineTo(w.x-y*Math.cos(p-Math.PI/7),w.y-y*Math.sin(p-Math.PI/7)),a.lineTo(w.x-y*Math.cos(p+Math.PI/7),w.y-y*Math.sin(p+Math.PI/7)),a.closePath(),a.fill()}#A(a,m){const w=l(m);if(!w||!L(a.strokeRect))return;const v=6;a.save(),a.setLineDash?.([4,3]),a.strokeStyle="#1a73e8",a.lineWidth=2,a.globalAlpha=1,a.strokeRect(w.x1-v,w.y1-v,w.x2-w.x1+v*2,w.y2-w.y1+v*2),a.restore()}#P(a,m){const w=this.#e.presentation?.scale||1,v=o*w;for(let p=this.#s.length-1;p>=0;p--){const y=this.#s[p];if(u(y.region)===m&&i(y,a)<=v)return y}return null}#S(){const a=L(this.#t.scrollPosition)?this.#t.scrollPosition():null,m=this.#t.viewport?.rtl===!0;return{left:Q(a?.left||0,m),top:a?.top||0}}#M(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,m=a?.ownerDocument;if(!a||!m?.createElement)return null;const w=m.createElement("canvas");return w.className=s,w.style.position="absolute",w.style.inset="0",w.style.pointerEvents="none",a.appendChild(w),this.#n=w,this.#r=w.getContext?w.getContext("2d"):null,this.#j(),this.#E(w),w}#j(){const a=this.#n,m=this.#t.viewport?.root;if(!a||!m?.getBoundingClientRect)return;const w=m.getBoundingClientRect(),p=a.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(w.width*p)),C=Math.max(1,Math.round(w.height*p));a.width===y&&a.height===C||(a.width=y,a.height=C,a.style&&(a.style.width=`${Math.max(1,w.width)}px`,a.style.height=`${Math.max(1,w.height)}px`),this.#r?.setTransform(p,0,0,p,0,0))}#E(a){const m=(C,T="centre")=>{const P=a.getBoundingClientRect(),{left:x,top:E}=this.#S();return{x:C.clientX-P.left+(T==="centre"?x:0),y:C.clientY-P.top+E}},w=C=>{if(!this.#o||!this.#k(C))return;const T=this.#w(C.clientX);if(this.#o==="erase"){const P=this.#P(m(C,T),T);P&&(this.remove(P.id),this.#x("a11y.annotate.erased")),C.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[m(C,T)],region:T},a.setPointerCapture?.(C.pointerId),C.preventDefault?.()},v=C=>{if(!this.#l)return;const T=m(C,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(T),this.redraw()},p=C=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,a.releasePointerCapture?.(C.pointerId),this.redraw(),this.#R())},y=C=>{if(!this.#o)return;const T=this.#t.viewport?.bodyViewport;if(!T)return;let P=!1;C.deltaY&&typeof T.scrollTop=="number"&&(T.scrollTop+=C.deltaY,P=!0),C.deltaX&&typeof T.scrollLeft=="number"&&(T.scrollLeft+=C.deltaX,P=!0),P&&C.preventDefault?.()};a.addEventListener("pointerdown",w),a.addEventListener("pointermove",v),a.addEventListener("pointerup",p),a.addEventListener("pointercancel",p),a.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{a.removeEventListener("pointerdown",w),a.removeEventListener("pointermove",v),a.removeEventListener("pointerup",p),a.removeEventListener("pointercancel",p),a.removeEventListener("wheel",y)})}#R(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(a,m){const w=this.#e.messages;return w&&L(w.t)?w.t(a,m):a}#x(a,m){this.#t.announce?.(this.#L(a,m),{repeat:!0})}destroy(){for(const a of this.#a)a();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=g}),xe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function Q(z){if(!Number.isFinite(z)||z<1e3)return"now";const S=Math.round(z/1e3);if(S<60)return`${S}s ago`;const O=Math.round(S/60);return O<60?`${O}m ago`:`${Math.round(O/60)}h ago`}function G(z,S){return Number.isFinite(z)?new Date(z).toLocaleTimeString(S||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class H{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(S){this.#e=S.grid,this.#t=S.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const S=this.#e.timeline,O=S.depth,b=S.position;this.#r.max=String(Math.max(1,O)),this.#r.value=String(Math.max(0,O-b)),this.#r.disabled=O===0;const u=S.at(),d=S.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):Q(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=O===0?this.#l("timeline.recording"):G(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(S,O){const b=this.#e;return(b&&b.messages?b.messages:F).t(S,O)}#a(){if(this.#n)return;const S=this.#t.viewport?.overlays,O=S?.ownerDocument;if(!S||!O?.createElement)return;const b=O.createElement("div");b.className=_;const u=O.createElement("span");u.className=`${_}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const d=O.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const s=O.createElement("span");s.className=`${_}__clock`;const n=O.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),b.appendChild(u),b.appendChild(d),b.appendChild(s),b.appendChild(n),S.appendChild(b),this.#n=b,this.#r=d,this.#o=u,this.#i=s;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(d.value))};d.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const o=f=>f.stopPropagation();d.addEventListener("keydown",o),this.#s.push(()=>{d.removeEventListener("input",t),n.removeEventListener("click",r),d.removeEventListener("keydown",o)})}#u(){this.#n&&(L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const S of this.#s)S();this.#s=[],this.#u()}}const U=H}),xe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/renderer/direction.js").isRtlElement,G="lat-comment-mark",H="lat-cell--commented",U="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(b){this.#e=b.grid,this.#t=b.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const b=this.#e.comments;if(!b||!b.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const d=[];for(const s of u.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key");if(n){d.push(n);for(const t of s.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),o=b.at(n,r),f=!!(o&&o.count);t.classList.toggle(H,f),t.classList.toggle(U,f&&o.unresolved>0),this.#i(t,o,r)}}}(d.length!==this.#r.length||d.some((s,n)=>s!==this.#r[n]))&&(this.#r=d,b.request(d))}#o(b,u){const d=this.#e;return(d&&d.messages?d.messages:F).t(b,u)}#i(b,u,d){if(!u||!u.count){b.hasAttribute("aria-description")&&b.removeAttribute("aria-description");return}const s=u.count,n=u.unresolved,t=this.#o("count.comments",{count:s});b.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const b=this.#t.viewport?.root;if(!b||!L(b.addEventListener))return;const u=s=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=s.target&&L(s.target.closest)?s.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,s))return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.stopPropagation(),s.preventDefault(),n.open(o,t.getAttribute("data-col")))},d=s=>{const n=this.#e.comments;if(!n||!n.enabled||!s.altKey||s.key!=="m"&&s.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&L(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.preventDefault(),s.stopPropagation(),n.open(o,t.getAttribute("data-col")))};b.addEventListener("click",u,!0),b.addEventListener("keydown",d,!0),this.#n.push(()=>{b.removeEventListener("click",u,!0),b.removeEventListener("keydown",d,!0)})}#l(b,u){if(!L(b.getBoundingClientRect))return!1;const d=b.getBoundingClientRect(),s=Math.max(14,Math.min(24,d.height*.6));return(Q(b)?u.clientX<=d.left+s:u.clientX>=d.right-s)&&u.clientY<=d.top+s}destroy(){for(const b of this.#n)b();this.#n=[]}}const S=z}),xe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,U="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(b){this.#e=b.grid,this.#t=b.renderer}mount(){const b=this.#e.presence;if(!(!b||!b.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,d=>this.#l(u,d)));this.#a(),this.paint()}}#l(b,u){if(this.#f(),b==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const s=u&&u.peer;s&&(this.#r.textContent=this.#h(b==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:s.name}))}#a(){const b=this.#t.viewport?.overlays,u=b?.ownerDocument;if(!b||!u?.createElement)return;const d=this.#e.get("presence")||{},s=u.createElement("span");if(s.className=`${U}__live`,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),b.appendChild(s),this.#r=s,d.roster===!1)return;const n=u.createElement("div");n.className=U,d.roster&&d.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",b.appendChild(n),this.#n=n}paint(){const b=this.#e.presence,u=this.#t.viewport?.root;if(!b||!b.enabled||!u?.querySelectorAll)return;this.#d(u);const d=b.peers(),s=[...d].sort((n,t)=>n.at-t.at);for(const n of s)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const o of t.columns||[])this.#c(u,r,o,n,"range");for(const n of s)n.cursor&&this.#c(u,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of s)n.editing&&this.#c(u,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(d)}#u(b){if(this.#s!==null)return;const u=b.filter(n=>n.cursorFresh);if(!u.length)return;const s=Math.max(...u.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,s))}#c(b,u,d,s,n){const t=b.querySelector(`[data-key="${Q(u)}"]`),r=t&&t.querySelector(`[data-col="${Q(d)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",s.colour),r.setAttribute("data-peer-name",s.name),r.setAttribute("data-peer-initial",s.initials||(s.name||"?").slice(0,1).toUpperCase()),s.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&s.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${d}`))}#d(b){if(this.#o.size){for(const u of b.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const b=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const s of u){const n=b.createElement("button");n.className=`${U}__peer`,n.type="button",n.style.setProperty("--lat-peer",s.colour),n.toggleAttribute("data-idle",!!s.idle),n.toggleAttribute("data-hidden",!!s.hidden);let t="presence.peer";s.hidden?t="presence.peerHidden":s.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:s.name}));const r=b.createElement("span");r.className=`${U}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=s.initials||(s.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const o=b.createElement("span");o.className=`${U}__name`,o.textContent=s.name,n.appendChild(o),n.addEventListener("click",()=>this.#e.presence.jumpTo(s.id)),this.#n.appendChild(n)}const d=u.filter(s=>s.hidden).length;if(d){const s=b.createElement("span");s.className=`${U}__hidden`,s.textContent=this.#h("presence.hidden",{count:d}),this.#n.appendChild(s)}}announceRefusal(b){if(!this.#r)return;const u=b&&b.name?b.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:u})}#h(b,u){const d=this.#e;return(d&&d.messages?d.messages:F).t(b,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const b=this.#t.viewport?.root;b?.querySelectorAll&&this.#d(b),this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const S=z}),xe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,U="lat-comments",z=/^(https?:|mailto:)/i,S='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function O(s,n){if(!Number.isFinite(s))return"";const t=Math.max(0,Math.round((n-s)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function b(s,n,t,r){n.textContent="";const o=String(t??"");if(!r){n.textContent=o;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,i=f.exec(o);for(;i;){i.index>l&&n.appendChild(s.createTextNode(o.slice(l,i.index)));const g=i[0];if(g.startsWith("*")){const c=s.createElement("em");c.textContent=g.slice(1,-1),n.appendChild(c)}else if(g.startsWith("`")){const c=s.createElement("code");c.textContent=g.slice(1,-1),n.appendChild(c)}else{const c=g.indexOf("]("),h=g.slice(1,c),a=g.slice(c+2,-1);if(z.test(a)){const m=s.createElement("a");m.href=a,m.textContent=h,m.rel="noopener noreferrer",m.target="_blank",n.appendChild(m)}else n.appendChild(s.createTextNode(h))}l=i.index+g.length,i=f.exec(o)}l<o.length&&n.appendChild(s.createTextNode(o.slice(l)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#b()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#b(),this.#o&&L(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&L(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${U}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const o=r.querySelector(`[data-key="${Q(n)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:F).t(n,t)}#p(n){const t=n.createElement("div");t.className=U,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${U}__head`;const o=n.createElement("div");o.className=`${U}__title`,r.appendChild(o);const f=n.createElement("button");f.className=`${U}__resolve`,f.type="button",r.appendChild(f);const l=n.createElement("button");l.className=`${U}__close`,l.type="button",l.setAttribute("aria-label",this.#h("comments.close")),l.textContent="×",r.appendChild(l);const i=n.createElement("div");i.className=`${U}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const g=n.createElement("form");g.className=`${U}__composer`;const c=n.createElement("textarea");c.className=`${U}__input`,c.rows=2,c.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${U}__send`,h.type="submit",h.textContent=this.#h("comments.post"),g.appendChild(c),g.appendChild(h),t.appendChild(r),t.appendChild(i),t.appendChild(g),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=o,this.#g=f;const a=p=>{p.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},m=()=>this.#e.comments.close(),w=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.#e.comments.close();return}if(p.key!=="Tab")return;const y=[...t.querySelectorAll(S)].filter(x=>x.offsetParent!==null||x===c);if(!y.length)return;const C=y[0],T=y[y.length-1],P=t.ownerDocument.activeElement;p.shiftKey&&P===C?(p.preventDefault(),T.focus()):!p.shiftKey&&P===T&&(p.preventDefault(),C.focus())};g.addEventListener("submit",a),l.addEventListener("click",m),f.addEventListener("click",w),t.addEventListener("keydown",v),this.#l.push(()=>{g.removeEventListener("submit",a),l.removeEventListener("click",m),f.removeEventListener("click",w),t.removeEventListener("keydown",v)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},o=Date.now(),f=n.openKey,{rowId:l,field:i}=H(f),g=this.#e.columns.get(i),c=this.#e.rows.byKey(l),h=L(r.rowLabel)&&c?r.rowLabel(c):l;if(this.#m.textContent=this.#h("comments.cellTitle",{column:g&&(g.title??g.id)||i,row:h}),this.#g.textContent=this.#y()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const a=n.thread||[];if(!a.length){this.#d(this.#h("comments.empty"));return}const m=c&&g?g.getValue(c.data,c):void 0;for(const w of a)this.#r.appendChild(this.#k(t,w,o,m,r))}#k(n,t,r,o,f){const l=n.createElement("article");l.className=`${U}__item`,t.pending&&l.setAttribute("data-pending","true"),t.resolved&&l.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${U}__meta`;const g=n.createElement("span");g.className=`${U}__author`,g.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),i.appendChild(g);const c=n.createElement("time");c.className=`${U}__time`;const h=O(t.at,r);c.textContent=t.edited?this.#h("comments.edited",{time:h}):h,i.appendChild(c),l.appendChild(i);const a=n.createElement("div");if(a.className=`${U}__body`,b(n,a,t.body,!!f.markdown),l.appendChild(a),t.value!==void 0&&!Object.is(t.value,o)){const v=n.createElement("p");v.className=`${U}__moved`,v.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(o)}),l.appendChild(v)}const m=t.can||{},w=v=>m[v]!==!1;if(w("edit")||w("delete")){const v=n.createElement("div");if(v.className=`${U}__actions`,w("delete")){const p=n.createElement("button");p.type="button",p.className=`${U}__action`,p.textContent=this.#h("comments.delete"),p.addEventListener("click",()=>this.#e.comments.remove(t.id)),v.appendChild(p)}l.appendChild(v)}return l}#b(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:o}=H(t),f=this.#f(r,o)||this.#i,l=this.#t.viewport?.root;if(!f||!l||!L(f.getBoundingClientRect))return;const i=f.getBoundingClientRect(),g=l.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let h=i.bottom-g.top+4;h+c.height>g.height&&i.top-g.top>c.height&&(h=i.top-g.top-c.height-4);let a=i.left-g.left;a+c.width>g.width&&(a=Math.max(0,g.width-c.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,a)}px`;const m=i.bottom<g.top||i.top>g.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=u}),xe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),Q=_.el,G=_.on,H="lat-watermark",U="https://www.latticegrid.dev",z=["br","bl","tl","tr"],S=4e3;class O{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),L(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&L(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#f(),this.#u()):!d&&this.#r&&(this.#h(),this.#c())}#a(){const d=this.#i;if(!d||!L(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),L(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%z.length,this.#h(),this.#f(),this.#u()},S)))}#c(){this.#l!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&L(d.watermark)&&d.watermark())}#f(){const d=Q(this.#t,"a",{class:`${H}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:U,target:"_blank",rel:"noopener noreferrer"}});this.#r=Q(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[d]}),this.#o.push(G(this.#r,"pointerdown",s=>{L(s.stopPropagation)&&s.stopPropagation()})),this.#n&&L(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#h()}}const b=O}),xe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=K("packages/dom/src/editors/common.js"),_=F.el,Q=F.on,H=K("packages/dom/src/themeof.js").themeOf,U="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},S="lat-maximised-host",O="lat-maximise-placeholder";class b{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(s){this.#e=s.element,this.#t=s.document,this.#n=B(s.onChange)?s.onChange:null,this.#r=B(s.captureScroll)?s.captureScroll:null,this.#o=B(s.restoreScroll)?s.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const s=this.#e.parentNode;if(!s||!this.#t.body)return L("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:O}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(s):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),s.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,l]of Object.entries(z))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=l;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(U),this.#t.body.classList&&this.#t.body.classList.add(S),r&&this.#o&&this.#o(r),this.#s=Q(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const s=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,o]of Object.entries(this.#a))this.#e.style[r]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(U),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(S),s&&this.#o&&this.#o(s),this.#s&&this.#s(),this.#s=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(s){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;s(),t&&B(t.focus)&&t.focus()}#f(s){!s||s.key!=="Escape"||s.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const s of this.#l)s(this.active())}watch(s){return B(s)?(this.#l.add(s),()=>this.#l.delete(s)):()=>{}}destroy(){this.exit()}}const u=b}),xe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,_=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),S=z.describeGrid,O=z.promptText,b=K("packages/core/src/ai/intent.js"),u=b.applyPlan,d=b.buildPrompt,s=b.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#y="idle";#w=0;#k=!1;#b=[];t(l,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:G).t(l,i)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||G,this.#e=L(l),this.#t=l.grid||null,this.#n=U(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:U(l.onPlan)?l.onPlan:null,onApply:U(l.onApply)?l.onApply:null,onError:U(l.onError)?l.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(l)}element(){return this.#s}refresh(){this.#k||!this.#s||this.#y!=="busy"&&this.#M()}destroy(){this.#k=!0,this.#w++;for(const l of this.#b)l();this.#b.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(l){if(this.#k||this.#y==="busy")return null;const i=String(l??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const g=++this.#w;this.#A("busy"),this.#j("Thinking…");let c;try{const h=S(this.#t,this.#r),a=O(h);if(c=await this.#n({prompt:i,schema:h,schemaText:a,message:d(i,a),context:this.#o}),this.#k||g!==this.#w)return null;const m=s(c,h);return this.#P(m),m}catch(h){return this.#k||g!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#E(h instanceof Error?h.message:String(h))),null}}apply(){const l=this.#g;if(this.#k||!l||!l.ok)return null;const i=this.#t?.ai,g=U(i?.apply)?i.apply(l):u(l,this.#t);return this.#i.onApply&&this.#i.onApply(g,l),this.#M(),this.#l&&(this.#l.value=""),g.failed.length?this.#E(`Applied ${g.applied.length}; ${g.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#j(`Applied: ${l.describe()}`),g}discard(){this.#k||(this.#M(),this.#j("Discarded."))}#O(l){const i=this.#e,g=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#b.push(F(this.#l,"keydown",h=>{const a=h&&h.key;a==="Enter"?(U(h.preventDefault)&&h.preventDefault(),this.ask()):a==="Escape"&&this.#g&&(U(h.preventDefault)&&h.preventDefault(),this.discard())})),g.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#b.push(F(this.#a,"click",()=>{this.ask()})),g.appendChild(this.#a),this.#s.appendChild(g),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const c=B(i,"div",{class:`${n}__buttons`});this.#f=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#b.push(F(this.#f,"click",()=>{this.apply()})),this.#b.push(F(this.#h,"click",()=>{this.discard()})),c.appendChild(this.#f),c.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#A(l){if(this.#y=l,!this.#s)return;this.#s.setAttribute("data-state",l);const i=l==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,l!=="preview"),o(this.#m,l!=="error")}#P(l){const i=l;if(this.#i.onPlan&&this.#i.onPlan(l),!i.ok){this.#g=null;const g=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${g}`);return}this.#g=l,this.#j(""),this.#c&&(this.#c.textContent=i.describe()),this.#S(i.rejected),this.#A("preview")}#S(l){const i=this.#d;if(i){_(i),o(i,!l.length);for(const g of l.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:g.reason}));l.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#M(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#A("idle")}#j(l){this.#p&&(this.#p.textContent=l)}#E(l){this.#g=null,this.#j(""),this.#m&&(this.#m.textContent=l),this.#A("error")}}function r(f,l){f&&(f.disabled=l,l?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function o(f,l){f&&(f.hidden=l,l?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),xe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.isObject,F=X.warnOnce,Q=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,O=K("packages/dom/src/cell/icons.js").renderIconInto,b={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",d=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),s=Object.freeze({direction:"flat",change:null,percent:null});function n(a,m){if(!Number.isFinite(a)||!Number.isFinite(m))return s;const w=a-m,v=w>0?"up":w<0?"down":"flat",p=m===0?null:w/Math.abs(m)*100;return{direction:v,change:w,percent:p}}function t(a,m){return a==="flat"||m==="neither"?"flat":a===m?"good":"bad"}function r(a,m,w=null){if(L(m)){const P=m(a,w);return P==="good"||P==="warn"||P==="bad"?P:null}if(!B(m))return null;const v=typeof a=="number"&&Number.isFinite(a)?a:null;if(v===null)return null;const p=Number.isFinite(Number(m.good))?Number(m.good):null,y=Number.isFinite(Number(m.warn))?Number(m.warn):null,C=String(m.direction||"up")==="down",T=P=>C?v<=P:v>=P;return p!==null&&T(p)?"good":y!==null&&T(y)?"warn":p===null&&y===null?null:"bad"}function o(a){return!(L(a.value)||a.value!==void 0&&!B(a.value))}function f(a){return!a||!a.rows||!L(a.rows.totalCount)?!0:a.rows.totalCount()>0}function l(a){const m=B(a)?a:{},w=m.grid||null,v=c(m.container,w);if(!v)return F("stat.container","createStat needs a `container`: an element or a selector."),h();const p=v.ownerDocument||(typeof document>"u"?null:document);if(!p)return F("stat.document","createStat needs a document; it draws DOM."),h();const y=p.createElement("div");y.className=["lattice",b.root,m.class].filter(Boolean).join(" "),y.setAttribute("role","group");const C=p.createElement("div");C.className=b.title;const T=p.createElement("div");T.className=b.value;const P=p.createElement("div");P.className=b.interval;const x=p.createElement("div");x.className=b.delta;const E=p.createElement("div");E.className=b.footer;const j=p.createElement("div");if(j.className=b.note,j.hidden=!0,m.icon!=null&&m.icon!==""){const ee=p.createElement("span");ee.className=b.icon,ee.setAttribute("aria-hidden","true"),O(ee,m.icon,`stat:${m.title||"stat"}`),y.appendChild(ee);const te=p.createElement("div");te.className=b.body,te.appendChild(C),te.appendChild(T),te.appendChild(j),te.appendChild(P),te.appendChild(x),te.appendChild(E),y.appendChild(te)}else y.appendChild(C),y.appendChild(T),y.appendChild(j),y.appendChild(P),y.appendChild(x),y.appendChild(E);v.appendChild(y);let $=null;const D=[];let M=!1;function R(){if(L(m.value))return m.value(w);if(m.value!==void 0&&!B(m.value))return m.value;const ee=B(m.value)?m.value:m,te=ee.of,ne=ee.fn||"sum",ae=ee.show;return w?ne==="count"?I().length:te?ae?q(String(te),String(ne),String(ae)):k()==="filtered"&&w.statistics&&L(w.statistics.reduce)?w.statistics.reduce(String(te),String(ne)):Q(I().map(de=>g(de,String(te))),String(ne)):null:null}function k(){return String(m.scope||"filtered")}function I(){if(!w||!w.rows)return[];const ee=k();if(ee==="all"){const ne=[];return L(w.rows.forEachAll)&&w.rows.forEachAll(ae=>{ae.group||ne.push(i(ae))}),ne}if(ee==="selected")return(w.selection&&L(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(i);const te=[];return L(w.rows.forEach)&&w.rows.forEach(ne=>{ne.group||te.push(i(ne))}),te}function q(ee,te,ne){if(te!=="min"&&te!=="max")return F(`stat.show.${te}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${te}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ae=null,de=null;for(const ie of I()){const oe=Number(g(ie,ee));Number.isFinite(oe)&&(ae===null||(te==="max"?oe>ae:oe<ae))&&(ae=oe,de=ie)}return de===null?null:g(de,ne)}function Z(ee){if(L(m.format))return String(m.format(ee,w));if(ee==null)return m.empty??"—";const te=B(m.value)?m.value:m,ne=te.show||te.of;if((te.show?!0:d.has(String(te.fn||"sum")))&&w&&ne&&L(w.columns?.get)){const de=w.columns.get(String(ne));if(de&&L(de.formatValue))return de.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(m.decimals??2):String(ee)}function W(ee){return ee?(w&&w.messages||z).t(`stat.tone.${ee}`):""}function J(){if(M)return;const ee=R(),te=o(m)&&!!w&&!f(w),ne=te?null:ee,ae=L(m.baseline)?m.baseline(w):m.baseline;$=ne,C.textContent=m.title??"",C.hidden=!m.title,T.textContent=Z(ne),j.hidden=!te,te&&(j.textContent=w.messages.t("stat.noData"));const de=te||ae===void 0||ae===null?s:n(typeof ne=="number"?ne:null,Number(ae)),ie=t(de.direction,m.goodWhen||"up");if(x.hidden=de.change===null,de.change!==null){const ke=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Re=de.percent===null?Z(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;x.textContent=`${ke} ${Re}`,x.setAttribute("data-tone",ie),x.setAttribute("data-direction",de.direction)}const oe=L(m.interval)?m.interval(ne,w):null,ce=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);P.hidden=!ce,ce&&(P.textContent=`${Z(oe.lower)} – ${Z(oe.upper)}`,Number.isFinite(oe.confidence)&&P.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const fe=te?u:m.bands?r(ne,m.bands,w):null;fe?y.setAttribute("data-tone",fe):y.removeAttribute("data-tone"),E.textContent=L(m.footer)?String(m.footer(ne,w)):m.footer??"",E.hidden=!E.textContent,y.setAttribute("aria-label",[m.title,T.textContent,te?j.textContent:"",ce?P.textContent:"",de.change===null?"":x.textContent,de.change===null?"":W(ie),E.textContent].filter(Boolean).join(", "))}if(w&&L(w.on)&&m.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const te=ne=>{ee==="model:changed"&&!H(ne)||J()};w.on(ee,te),D.push(()=>L(w.off)&&w.off(ee,te))}return J(),{element:()=>y,value:()=>$,refresh:J,destroy(){M=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(a){return B(a)&&"data"in a?a.data:a}function g(a,m){if(!B(a))return;if(!m.includes("."))return a[m];let w=a;for(const v of m.split(".")){if(!B(w))return;w=w[v]}return w}function c(a,m){if(a&&typeof a=="object")return a;if(typeof a!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(a):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),xe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isObject,F=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class Q{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:U,kpis:z}){this.#e=H,this.#t=U,this.#n=Array.isArray(z)?z.filter(L):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const U=this.#t.createElement("div");U.className=`lattice ${_.band}`,U.setAttribute("role","group"),U.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=U;for(const z of this.#n){const S=F({...z,grid:this.#e,container:U});this.#o.push(S)}}destroy(){for(const H of this.#o)try{H.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),xe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const L=K("packages/core/src/index.js").createHeadlessGrid,F=K("packages/core/src/defaults.js").applyDefaults,Q=K("packages/core/src/export/download.js").downloadBlob,G=K("packages/core/src/internal/util.js"),H=G.fail,U=G.isFunction,z=G.warnOnce,O=K("packages/dom/src/localviews.js").createLocalViewStorage,u=K("packages/dom/src/renderer/index.js").DomRenderer,s=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,g=K("packages/dom/src/ui/index.js"),c=g.StatusBar,h=g.TooltipManager,a=g.Pagination,m=g.GroupByZone,v=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,T=K("packages/dom/src/columnmenu.js").ColumnMenu,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,j=K("packages/dom/src/rowreorder.js").RowReorder,$=K("packages/dom/src/alignedgrids.js").AlignedGrids,M=K("packages/dom/src/columntagbar.js").ColumnTagBar,k=K("packages/dom/src/anomalychip.js").AnomalyChip,q=K("packages/dom/src/rowform.js").RowForm,Z=K("packages/dom/src/toolpanelmount.js"),W=Z.ToolPanelDock,J=Z.panelHost,te=K("packages/dom/src/celledit.js").CellEditController,ae=K("packages/dom/src/editbar.js").EditBar,ie=K("packages/dom/src/rangeselect.js").RangeController,ce=K("packages/core/src/model/selection.js").resolveSelectionConfig,ke=K("packages/dom/src/importer.js").ImportController,Ee=K("packages/dom/src/historybar.js").HistoryBar,ye=K("packages/dom/src/diffpaint.js").DiffPainter,Se=K("packages/dom/src/detailhost.js").DetailHost,Ie=K("packages/dom/src/highlightpaint.js").HighlightPainter,Xe=K("packages/dom/src/findpaint.js").FindPainter,Te=K("packages/dom/src/findbar.js").FindBar,Ke=K("packages/dom/src/redactpaint.js").RedactionPainter,ot=K("packages/dom/src/validationpaint.js").ValidationPainter,bt=K("packages/dom/src/presentation.js").PresentationController,Pt=K("packages/dom/src/capture.js").captureElement,Mt=K("packages/dom/src/annotate.js").AnnotationLayer,Bt=K("packages/dom/src/timelinebar.js").TimelineBar,Ge=K("packages/dom/src/commentpaint.js").CommentPainter,pe=K("packages/dom/src/presencepaint.js").PresencePainter,Ue=K("packages/dom/src/commentpanel.js").CommentPanel,rt=K("packages/dom/src/watermark.js").Watermark,we=K("packages/dom/src/maximise.js").Maximiser,Ae=K("packages/dom/src/promptbar.js").PromptBar,me=K("packages/dom/src/kpistrip.js").KpiStrip;function Me(He,ut,it){const kt=ut==="redo"?"toolbar.redo":"toolbar.undo";return!it||!it.label?He(kt):He(ut==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:it.label})}const je=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ne=2e3;function De(He,ut,it,kt){const Rt=ut.annotate===!0?qe(He,kt):[];if(ut.actions===!1)return[];if(ut.actions===void 0&&ut.side!=="left")return Rt;const It=Array.isArray(ut.actions)?ut.actions:je,yt=(Ut,Jt)=>He.messages.t(Ut,Jt),Lt={undo:{name:"undo",title:()=>Me(yt,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>Me(yt,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>yt("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:ut.exportName})},excel:{name:"excel",title:()=>yt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:ut.exportName})},clipboard:{name:"clipboard",title:()=>yt("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>yt("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return yt("toolbar.pause");const Ut=He.updates.stats().pending;return Ut?yt("toolbar.applyHeld",{count:Ut}):yt("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>yt("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>yt(it&&it.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>it&&it.active()?"minimise":"maximise",run:()=>it.toggle()}};return it||delete Lt.maximise,It.map(Ut=>Ut==="-"?{name:"-",separator:!0}:typeof Ut=="string"?Lt[Ut]:!Ut||typeof Ut!="object"||!Ut.name?null:{...Ut,run:U(Ut.run)?()=>Ut.run({grid:He,keys:He.selection&&U(He.selection.keys)?He.selection.keys():[],cells:He.selection&&U(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(Rt)}function qe(He,ut){const it={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},kt=(It,yt)=>He.messages.t(It,yt),Rt=["pen","arrow","rect","highlight","erase"].map(It=>({name:It,title:()=>kt(`toolbar.annotate.${It}`),icon:it[It],run:()=>He.annotate?.use(It),active:()=>He.annotate?.tool===It,annotation:!0}));return Rt.push(st(He,kt,ut)),Rt}function st(He,ut,it){return{name:"clearAll",title:()=>ut("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>ct(He,ut,it)}}function ct(He,ut,it){const kt=He.toolPanel;if(!kt)return;const Rt=yt=>it?.announce?.(ut(yt),{repeat:!0});kt.removeAction("clearAll");const It=()=>{kt.removeAction("clearAllConfirm"),kt.removeAction("clearAllKeep"),kt.addAction(st(He,ut,it))};kt.addAction({name:"clearAllConfirm",title:()=>ut("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),It(),Rt("a11y.annotate.cleared")}}),kt.addAction({name:"clearAllKeep",title:()=>ut("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>It()}),Rt("a11y.annotate.confirmClear")}const ft=["pen","arrow","rect","highlight","erase","clearAll"];function at(He){let ut=null;return{rowCount:()=>{if(U(He.rows.matchCount))return He.rows.matchCount();const it=He.pagination&&U(He.pagination.get)?He.pagination.get():null;return it&&Number.isFinite(it.total)?it.total:He.rows.count()},totalRowCount:()=>U(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{ut||(ut=U(He.rendererHost)?He.rendererHost():{});const it=U(ut.selectionSummary)?ut.selectionSummary():null;return it&&it.predicate?{count:it.count}:null},selectedCount:()=>{const it=He.selection&&He.selection.keys?He.selection.keys():null;return it?it.length:0},rangeValues:()=>{const it=He.selection;return!it||!U(it.cells)?[]:it.cells().map(({key:kt,colId:Rt})=>He.rows.value(kt,Rt))},hiddenUnresolved:()=>U(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>U(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function vt(He,ut){for(const[it,kt]of Object.entries(f||{}))He.register("editor",it,kt);for(const[it,kt]of Object.entries(i||{}))He.register("filter",it,kt);for(const[it,kt]of Object.entries(ut.components||{}))He.register("component",it,kt);for(const[it,kt]of Object.entries(ut.pipes||{}))He.register("pipe",it,kt);for(const[it,kt]of Object.entries(ut.totalFns||{}))He.register("totalFn",it,kt)}function dt(He,ut,it,kt,Rt,It){const yt=[],Lt=ut.viewport;let Ut=null;if(it.maximise!==!1&&(Ut=new we({element:It,document:kt,onChange:()=>ut.invalidate("all"),captureScroll:()=>ut.scrollState(),restoreScroll:lt=>ut.restoreScroll(lt)}),He.maximise=Ut,yt.push(()=>Ut.destroy())),it.statusBar){const lt=typeof it.statusBar=="object"?it.statusBar:{},wt=new c;wt.init({document:kt,host:at(He),panels:lt.panels,registry:lt.registry,locale:He.get("locale"),messages:He.messages}),Lt.statusBar.appendChild(wt.element());const Nt=()=>{const tn=Lt.statusBar.offsetHeight||Lt.statusBar.getBoundingClientRect?.().height||0;Lt.root.style.setProperty("--lattice-status-height",`${Math.ceil(tn)}px`)},Gt=()=>{wt.refresh(),Nt()},Wt=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(tn=>He.on(tn,Gt));Gt(),Nt(),yt.push(()=>{for(const tn of Wt)tn();Lt.root.style.removeProperty("--lattice-status-height"),wt.destroy?.()})}const Jt=ce(it.selection);if(Jt.ranges){const lt=new ie({grid:He,renderer:ut,document:kt});lt.mount(),He.ranges=lt,yt.push(()=>lt.destroy())}if(it.import){const lt=new ke({grid:He,renderer:ut,document:kt,settings:typeof it.import=="object"?it.import:{}});He.importer=lt,yt.push(()=>lt.destroy())}if(it.historyBar){const lt=typeof it.historyBar=="object"?it.historyBar.element:null,wt=new Ee;wt.init({document:kt,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Gt=>He.history.peek(Gt),list:()=>He.history.list()},props:typeof it.historyBar=="object"?it.historyBar:{}}),(lt||Lt.root).appendChild(wt.element());const Nt=[He.on("history:changed",()=>wt.refresh())];He.historyBar=wt,yt.push(()=>{for(const Gt of Nt)Gt();wt.destroy()})}if(it.diff){const lt=new ye({grid:He,renderer:ut});lt.mount(),He.diffPainter=lt,yt.push(()=>lt.destroy())}if(it.ai&&U(it.ai.ask)){const lt=new Ae;lt.init({document:kt,grid:He,ask:it.ai.ask,schemaOptions:it.ai.schemaOptions,context:it.ai.context,placeholder:it.ai.placeholder});const wt=it.ai.element||Lt.root;wt===Lt.root?wt.insertBefore(lt.element(),wt.firstChild):wt.appendChild(lt.element()),He.promptBar=lt,yt.push(()=>lt.destroy())}if(it.groupPanel){const lt=typeof it.groupPanel=="object"?it.groupPanel:{},wt=new m;wt.init({document:kt,grid:He,host:J(He,kt,(Nt,Gt)=>ut.announce?.(Nt,Gt)),props:{header:Lt.header,hint:lt.hint}}),Lt.root.insertBefore(wt.element(),Lt.header),He.groupPanel=wt;for(const Nt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])U(He.on)&&yt.push(He.on(Nt,()=>wt.refresh()));yt.push(()=>wt.destroy())}if(it.kpis){const lt=new me({grid:He,document:kt,kpis:it.kpis});lt.active&&(lt.mount(),Lt.root.insertBefore(lt.element(),Lt.header),He.kpiStrip=lt,yt.push(()=>lt.destroy()))}if(it.toolPanel){const lt=typeof it.toolPanel=="object"?it.toolPanel:{},wt=new W({grid:He,document:kt,root:Lt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:De(He,lt,Ut,ut),announce:(Nt,Gt)=>ut.announce?.(Nt,Gt)});wt.mount(),He.toolPanel=wt,yt.push(()=>wt.destroy()),lt.annotate===void 0&&(yt.push(He.on("presentation:started",()=>{for(const Nt of qe(He,ut))wt.addAction(Nt)})),yt.push(He.on("presentation:ended",()=>{for(const Nt of ft)wt.removeAction(Nt)})))}if(!!it.pagination&&(()=>{const lt=typeof it.pagination=="object"?it.pagination:{};return He.pagination.set({pageSize:Number(lt.pageSize)||100}),He.pagination.get().pageSize>0})()){const lt=typeof it.pagination=="object"?it.pagination:{},wt=new a;wt.init({document:kt,pageSize:lt.pageSize,pageSizes:lt.pageSizes,page:lt.page,total:lt.total,locale:He.get("locale"),messages:He.messages,onChange:({page:Wt,pageSize:tn})=>He.pagination.set({page:Wt,pageSize:tn})});const Nt=()=>{const Wt=He.pagination.get();wt.total=Wt.total,wt.counting=Wt.counting===!0,wt.hasMore=Wt.total==null&&Wt.pageCount>Wt.page+1,wt.page=Wt.page,wt.paint()};He.pagination.set({pageSize:wt.pageSize}),Nt();const Gt=["rows:changed","filter:changed","model:changed"].map(Wt=>He.on(Wt,Nt));Lt.statusBar.appendChild(wt.element()),yt.push(()=>{for(const Wt of Gt)Wt();wt.destroy?.()})}if(it.edit!==!1)if(it.editBar){const lt=new ae({grid:He,document:kt,root:Lt.root});lt.mount(),He.editBar=lt,yt.push(()=>lt.destroy())}else{const lt=new te({grid:He,document:kt,renderer:ut,registry:Rt,cellLayer:ut.cellLayer});lt.mount(),yt.push(()=>lt.destroy())}const dn=new y({grid:He,document:kt,layer:Lt.overlays,registry:Rt});dn.mount(),yt.push(()=>dn.destroy());const qt=new T({grid:He,document:kt,host:Lt.root,cellMenu:it.contextMenu!==!1,headerMenu:it.columnMenu!==!1,items:U(it.contextMenu)?it.contextMenu:void 0,headerItems:U(it.columnMenu)?it.columnMenu:void 0});if(qt.mount(),yt.push(()=>qt.destroy()),Array.isArray(it.alignedGrids)&&it.alignedGrids.length){const lt=new $;lt.add(He);for(const wt of it.alignedGrids)wt&&wt!==He&&lt.add(wt);yt.push(()=>lt.destroy())}const _t=new q({grid:He,renderer:ut,document:kt,registry:Rt});_t.active&&(_t.mount(),yt.push(()=>_t.destroy())),Object.defineProperty(He,"form",{configurable:!0,value:Object.freeze({open(lt){return _t.active?_t.openRow(lt):!1},openNew(lt){return _t.active?_t.openNew(lt):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){_t.active&&_t.close()},save(){return _t.active?_t.save():!1},isOpen(){return _t.active?_t.open:!1}})}),yt.push(()=>{delete He.form}),Object.defineProperty(He,"icons",{configurable:!0,value:Object.freeze({get(lt){const wt=t(lt);return wt?{viewBox:wt.viewBox,paths:wt.paths.slice(),paint:wt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),yt.push(()=>{delete He.icons});const Ct=new M({grid:He,renderer:ut,document:kt});Ct.active&&(Ct.mount(),yt.push(()=>Ct.destroy()));const xt=new k({grid:He,renderer:ut,document:kt});xt.active&&(xt.mount(),yt.push(()=>xt.destroy()));const zt=new j({grid:He,renderer:ut,document:kt});if(zt.active){zt.mount(),zt.paint();const lt=He.on("render:done",()=>zt.paint());yt.push(()=>{lt(),zt.destroy()})}if(it.shortcuts!==!1){const lt=new x({grid:He,renderer:ut});lt.mount(),yt.push(()=>lt.destroy())}const Kt=new Ie({grid:He,renderer:ut,window:kt.defaultView||void 0});Kt.mount(),yt.push(()=>Kt.destroy());const Xt=new Xe({grid:He,renderer:ut,window:kt.defaultView||void 0});if(Xt.mount(),yt.push(()=>Xt.destroy()),it.find!==!1){const lt=new Te({grid:He,renderer:ut,document:kt,settings:it.find});lt.mount(),yt.push(()=>lt.destroy())}const Yt=new Ke({grid:He,renderer:ut});Yt.mount(),yt.push(()=>Yt.destroy());const Qt=new ot({grid:He,renderer:ut});Qt.mount(),yt.push(()=>Qt.destroy());const rn=new bt({grid:He,renderer:ut,maximiser:Ut});rn.mount(),yt.push(()=>rn.destroy());const en=new Bt({grid:He,renderer:ut});en.mount(),yt.push(()=>en.destroy()),it.environment||He.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let cn=null;for(const[lt,wt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])yt.push(He.on(lt,()=>{cn=wt}));yt.push(He.on("render:done",lt=>{He.diagnostics.render(cn||lt.cause,lt.phases),cn=null}));const ln=kt.defaultView;if(ln&&U(ln.requestAnimationFrame)){let lt=ln.requestAnimationFrame(function wt(Nt){He.diagnostics.frame(Nt),lt=ln.requestAnimationFrame(wt)});yt.push(()=>{U(ln.cancelAnimationFrame)&&ln.cancelAnimationFrame(lt)})}const yn=new pe({grid:He,renderer:ut});if(yn.mount(),yt.push(()=>yn.destroy()),yt.push(He.on("presence:lockRefused",lt=>yn.announceRefusal(lt.peer))),He.presence&&He.presence.enabled){for(const Nt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])yt.push(He.on(Nt,()=>He.presence.publish()));let lt="";yt.push(He.on("render:done",()=>{const Nt=ut.focusState&&ut.focusState(),Gt=Nt?`${Nt.rowKey}${Nt.colId}`:"";Gt!==lt&&(lt=Gt,He.presence.publish())}));const wt=It.ownerDocument;if(wt&&U(wt.addEventListener)){const Nt=()=>He.presence.setPaused(wt.visibilityState==="hidden");wt.addEventListener("visibilitychange",Nt),Nt(),yt.push(()=>wt.removeEventListener("visibilitychange",Nt))}}const bn=new Ge({grid:He,renderer:ut});bn.mount(),yt.push(()=>bn.destroy());const wn=new Ue({grid:He,renderer:ut});wn.mount(),yt.push(()=>wn.destroy()),yt.push(He.on("facet:computed",()=>ut.refreshHeader?.())),Jt&&Jt.headerCheckbox===!0&&yt.push(He.on("selection:changed",()=>ut.refreshHeader?.())),yt.push(He.on("facet:expanded",()=>ut.invalidate("columns"))),yt.push(He.on("model:changed",()=>ut.invalidate("rows")));const Zt=(lt,wt)=>ut.announce?.(lt,wt),mn=He.messages,Vt=(lt,wt)=>mn.t(lt,wt),gn=lt=>Vt("count.rows",{count:lt});yt.push(He.on("sort:changed",()=>{const lt=He.sort.get();if(!lt.length){Zt(Vt("a11y.sort.cleared"));return}const wt=lt.map(Nt=>{const Gt=He.columns.get(Nt.col);return Vt("a11y.sort.column",{column:Gt&&Gt.title||Nt.col,direction:Vt(Nt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Vt("a11y.sort.by",{columns:mn.list(wt)}))})),yt.push(He.on("filter:changed",()=>{const lt=He.rows.matchCount?He.rows.matchCount():He.rows.count(),wt=He.rows.totalCount?He.rows.totalCount():lt;Zt(lt===wt?Vt("a11y.filter.cleared",{rows:gn(wt)}):Vt("a11y.filter.applied",{shown:gn(lt),total:gn(wt)}))})),yt.push(He.on("selection:changed",()=>{const lt=He.selection.keys().length;Zt(lt===0?Vt("a11y.selection.cleared"):Vt("a11y.selection.count",{count:lt}))})),yt.push(He.on("group:toggled",lt=>{const wt=He.rows.byKey?He.rows.byKey(lt.key):null,Nt=(wt&&(wt.groupLabel??wt.groupValue))??lt.key;Zt(Vt(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Nt,rows:gn(He.rows.count())}))})),yt.push(He.on("column:grouped",lt=>{const wt=Array.isArray(lt.columns)?lt.columns:[];if(!wt.length){Zt(Vt("a11y.group.cleared"));return}const Nt=wt.map(Gt=>{const Wt=He.columns.get(Gt);return Wt&&Wt.title||Gt});Zt(Vt("a11y.group.by",{columns:mn.list(Nt)}))})),yt.push(He.on("page:changed",lt=>{const wt=Number(lt.size)||0,Nt=Number(lt.total)||0,Gt=wt>0?Math.max(1,Math.ceil(Nt/wt)):1;Zt(Vt("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Gt}))}));let on={added:0,removed:0},sn=null;const Cn=()=>{sn=null;const lt=[];on.added&&lt.push(Vt("count.rowsAdded",{count:on.added})),on.removed&&lt.push(Vt("count.rowsRemoved",{count:on.removed})),on={added:0,removed:0},lt.length&&Zt(mn.list(lt))};yt.push(He.on("rows:changed",lt=>{if(!lt||typeof lt.added!="number")return;const wt=Number(lt.added)||0,Nt=Number(lt.removed)||0;!wt&&!Nt||(on.added+=wt,on.removed+=Nt,sn||(sn=setTimeout(Cn,Ne)))})),yt.push(()=>{sn&&clearTimeout(sn)}),yt.push(He.on("rows:paused",()=>{sn&&(clearTimeout(sn),sn=null),on={added:0,removed:0},Zt(Vt("a11y.updates.paused"),{repeat:!0})})),yt.push(He.on("rows:resumed",()=>Zt(Vt("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const Kn=()=>{hn=null;const{count:lt,first:wt}=fn;if(fn={count:0,first:null},!lt||!wt)return;const Nt=He.columns.get(wt.colId),Gt=Nt&&Nt.title||wt.colId,Wt=wt.reason?Vt("a11y.edit.reason",{reason:wt.reason}):"";if(lt===1){const tn=wt.restored===void 0||wt.restored===null||wt.restored===""?Vt("value.empty"):String(wt.restored);Zt(Vt("a11y.edit.refusedOne",{column:Gt,value:tn,reason:Wt}),{repeat:!0});return}Zt(Vt("a11y.edit.refusedMany",{count:lt,reason:Wt}),{repeat:!0})};yt.push(He.on("cell:reverted",lt=>{!lt||!lt.applied||(fn.count+=1,fn.first||(fn.first=lt),hn||(hn=setTimeout(Kn,150)))})),yt.push(()=>{hn&&clearTimeout(hn)}),yt.push(He.on("history:applied",lt=>{const wt=!!(lt&&lt.direction==="redo"),Nt=lt&&lt.step&&lt.step.label;Zt(Nt?Vt(wt?"a11y.history.redo":"a11y.history.undo",{label:Nt}):Vt(wt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Mt({grid:He,renderer:ut,seed:it.state&&Array.isArray(it.state.annotations)?it.state.annotations:null});vn.mount(),yt.push(()=>vn.destroy()),He.annotate=vn,He.capture=async(lt={})=>{const{blob:wt,width:Nt,height:Gt}=await Pt(ut.viewport.root,lt);return(lt.download===!0||lt.download!==!1&&lt.fileName)&&Q(wt,lt.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Nt,height:Gt,bytes:wt.size,mimeType:wt.type,fileName:lt.fileName||null},"api"),wt};const kn=new rt({grid:He,document:kt,element:Lt.overlays,window:kt.defaultView||void 0});kn.mount(),yt.push(()=>kn.destroy());const En=new h({grid:He,document:kt,element:Lt.overlays});En.mount?.(),yt.push(()=>En.destroy?.());const Tn=new v({grid:He,host:He.rendererHost(),viewport:Lt,document:kt});return Tn.mount(),yt.push(()=>Tn.destroy()),yt}function mt(He){const ut=[],it=kt=>{if(kt&&(kt.__lattice&&ut.push(kt),kt.children))for(const Rt of kt.children)it(Rt)};return it(He),ut}function jt(He,ut={}){(!He||typeof He!="object"||!("appendChild"in He))&&H("createGrid needs a host element as its first argument."),ut=F(ut);const it=He.ownerDocument||(typeof document<"u"?document:null);it||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const kt=it.documentElement&&it.documentElement.lang,Rt=!ut.licence&&U(it.querySelector)?it.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,It={...ut};if(!ut.locale&&kt&&(It.locale=kt),Rt&&(It.licence=Rt),ut.views&&ut.views.local)if(ut.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=ut.views.local===!0?{}:ut.views.local;It.views={...ut.views,storage:O(qt)}}const yt=L(It),Lt=yt.rendererHost();Lt.document=it,vt(Lt.registry,ut),Lt.cellLayer=s(Lt),Lt.detailHost=new Se({grid:yt,document:He.ownerDocument||globalThis.document,createGrid:(qt,_t)=>jt(qt,_t)});const Ut=new u(He,Lt),Jt=yt.on("detail:toggled",()=>{Lt.detailHost.syncTarget(),Lt.detailHost.prune()}),pn=yt.on("config:changed",qt=>{qt&&qt.key==="detail"&&Lt.detailHost.reconfigure()});yt.on("destroy",()=>{Jt(),pn(),Lt.detailHost.destroy()}),Lt.detailHost.syncTarget(),yt.attachRenderer(Ut),Ut.mount();const an=dt(yt,Ut,ut,it,Lt.registry,He),dn=yt.destroy.bind(yt);return yt.destroy=()=>{for(const qt of an)try{qt()}catch{}He.__lattice===yt&&(He.__lattice=null),dn()},He.__lattice=yt,yt}}),xe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return s}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,G=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,U=K("packages/dom/src/createGrid.js").createGrid,z=new Set([...Object.keys(_),...Object.keys(G)]);function S(n,t){for(const r of n.children)if(r.tagName===t.toUpperCase())return r;return null}function O(n,t){const r=[];for(const o of n.children)o.tagName===t.toUpperCase()&&r.push(o);return r}function b(n,t){const r=L(n.getAttribute)?n.getAttribute("data-field"):null;return r||String(n.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${t}`}function u(n){const t=n.trim();if(t==="")return null;if(t==="true"||t==="false")return t==="true";const r=Number(t);return Number.isFinite(r)&&t!==""?r:t}function d(n){const t=S(n,"thead"),r=S(t||n,"tr"),f=(r?O(r,"th").length?O(r,"th"):O(r,"td"):[]).map((c,h)=>{const a=b(c,h),m={id:a,field:a,title:String(c.textContent||"").trim()||a},w=L(c.getAttribute)?c.getAttribute("data-type"):null;w&&(z.has(w)?m.type=w:B(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${a}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const v=L(c.getAttribute)?c.getAttribute("data-format"):null;return v&&(m.format=v),m}),l=S(n,"tbody"),g=(l?O(l,"tr"):O(n,"tr").filter(c=>c!==r)).map((c,h)=>{const a=O(c,"td"),w={__row:(L(c.getAttribute)?c.getAttribute("data-id"):null)||`row${h}`};return f.forEach((v,p)=>{w[v.field]=a[p]?u(String(a[p].textContent||"")):null}),w});return{columns:f,rows:g}}function s(n,t={}){const{columns:r,rows:o}=d(n),f=n.ownerDocument.createElement("div");return n.parentNode.insertBefore(f,n),n.parentNode.removeChild(n),U(f,{rowKey:"__row",columns:r,rows:o,...t,columns:t.columns!==void 0?t.columns:r,rows:t.rows!==void 0?t.rows:o})}}),xe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/dom/src/createGrid.js").createGrid,Q=K("packages/dom/src/hydrate.js").hydrateTable;function G(S,O){const b=[];return L(S.hasAttribute)&&S.hasAttribute(O)&&b.push(S),L(S.querySelectorAll)&&b.push(...S.querySelectorAll(`[${O}]`)),b}function H(S){const O=S.parentNode;if(!O||!O.children)return null;const b=[...O.children],u=b.indexOf(S),d=[b[u+1],b[u-1]];for(const s of d)if(s&&s.tagName==="SCRIPT"&&L(s.getAttribute)&&s.hasAttribute("data-lattice-config"))return s;return null}function U(S){const O=H(S);if(!O)return{};try{return JSON.parse(O.textContent||"{}")}catch(b){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",b),{}}}function z(S){const O=S||(typeof document<"u"?document:null);if(!O)return[];const b=[];for(const u of G(O,"data-lattice-grid")){if(u.__lattice)continue;const d=U(u);b.push(u.tagName==="TABLE"?Q(u,d):F(u,d))}return b}}),xe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const X=K("packages/dom/src/createGrid.js"),L=X.createGrid,B=K("packages/dom/src/hydrate.js"),F=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),Q=_.autoInit,G=K("packages/dom/src/localviews.js"),H=G.createLocalViewStorage,U=K("packages/core/src/index.js"),z=U.createHeadlessGrid,S=U.registerModules,O=U.setLicence,b=U.version,u=U.getVersion,d=U.serialiseState,s=U.restoreState,n=U.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return X.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return X.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return G.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return G.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return U.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return U.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return U.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return U.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return U.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return U.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return U.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return U.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return U.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return U.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return U.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return U.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return U.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return U.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return U.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return U.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return U.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return U.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return U.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return U.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return U.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return U.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return U.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return U.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return U.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return U.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return U.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return U.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return U.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return U.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return U.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return U.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return U.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return U.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return U.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return U.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return U.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return U.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return U.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return U.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return U.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return U.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return U.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return U.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return U.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return U.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return U.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return U.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return U.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return U.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return U.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return U.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return U.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return U.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return U.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return U.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return U.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return U.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return U.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return U.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return U.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return U.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return U.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return U.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return U.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return U.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return U.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return U.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return U.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return U.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return U.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return U.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return U.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return U.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return U.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return U.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return U.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return U.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return U.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return U.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return U.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return U.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return U.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return U.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return U.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return U.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return U.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return U.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return U.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return U.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return U.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return U.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return U.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return U.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return U.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return U.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return U.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return U.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return U.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return U.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return U.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return U.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return U.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return U.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return U.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return U.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return U.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return U.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return U.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return U.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return U.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return U.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return U.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return U.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return U.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return U.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return U.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return U.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return U.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return U.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return U.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return U.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return U.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return U.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const f=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return f.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return f.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return f.autoGroupMenuItems}});const l=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const g=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const h=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return h.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return h.HISTORY_CLS}});const a=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return a.DiffPainter}});const m=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return m.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return m.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return m.summariseDiff}});const w=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return w.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return w.PROMPT_CLASS}});const v=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return v.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return v.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return v.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return v.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return v.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return v.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return v.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return v.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return v.sanitiseHtml}});const p=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return p.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return p.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return p.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return p.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const C=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return C.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return C.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return C.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return C.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return C.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return C.OverlayLayer}});const T=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return T.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return T.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return T.licenceState}});const P=Object.freeze({createGrid:L,createHeadlessGrid:z,defaults:n,registerModules:S,setLicence:O,version:b,autoInit:Q,hydrateTable:F,serialiseState:d,restoreState:s,createLocalViewStorage:H}),x=P});try{Gn("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return oe}});const fe="1.80.0";async function he(){return fe}const Q="1.80.0",z=new Set,ne=2e3;function _(w){if(z.add(w),z.size>ne){const v=z.values().next().value;v!==void 0&&z.delete(v)}}const T=[],K=500;function ie(w,v,Z){T.push({key:w,level:v,message:Z.map(x=>typeof x=="string"?x:J(x)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function le(){return T.map(w=>({...w}))}function ue(w){if(w.length===0||typeof w[0]!="string")return w;const v=w[0].replace(/^\\[lattice\\]\\s*/,"");return v===w[0]?w:[v,...w.slice(1)]}function W(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"warn",Z),console.warn("[lattice]",...Z)}function L(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"info",Z),console.info("[lattice]",...Z)}function Y(){z.clear(),T.length=0}function ee(w,v){const Z=new Error(`[lattice] ${w}`);throw v!==void 0&&(Z.cause=v),Z}function C(w,v){w||ee(v)}const A=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function s(w){return typeof w=="function"}function u(w){return w==null}function f(w){return w==null||w===""}function l(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const t=new Map;function a(w){let v=t.get(w);if(v)return v;if(!w.includes("."))v=Z=>Z?.[w];else{const Z=w.split("."),x=Z.length;v=de=>{let we=de;for(let ge=0;ge<x;ge++){if(we==null)return;we=we[Z[ge]]}return we}}return t.set(w,v),v}const m=new Map;function e(w){let v=m.get(w);if(v)return v;if(!w.includes("."))v=(Z,x)=>{Z!=null&&(Z[w]=x)};else{const Z=w.split("."),x=Z.length-1;v=(de,we)=>{let ge=de;for(let pe=0;pe<x;pe++){if(ge==null)return;const Te=Z[pe];ge[Te]==null&&(ge[Te]={}),ge=ge[Te]}ge!=null&&(ge[Z[x]]=we)}}return m.set(w,v),v}function d(w,v){return a(v)(w)}function h(w,v,Z){e(v)(w,Z)}function r(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,Z=>Z.toUpperCase()):""}const n={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function c(w){const v=w==null?"":String(w);return/[&<>"\']/.test(v)?v.replace(/[&<>"\']/g,Z=>n[Z]):v}function g(w){return String(w).replace(/\\w\\S*/g,v=>v[0].toUpperCase()+v.slice(1).toLowerCase())}function M(w,v,Z){if(w!==void 0)return w===!0?{enabled:!0,...Z}:w===!1?{enabled:!1}:i(w)?w:{[v]:w,enabled:!0}}function N(w){return w==null?[]:Array.isArray(w)?w:[w]}const G=Object.freeze(new Set(["__proto__","constructor","prototype"]));function F(w,v){if(!i(w))return i(v)?{...v}:v;if(!i(v))return v===void 0?w:v;const Z={...w};for(const x of Object.keys(v)){if(G.has(x))continue;const de=v[x];de!==void 0&&(Z[x]=i(de)&&i(Z[x])?F(Z[x],de):de)}return Z}function R(w,v){if(!i(w)||!i(v)||w===v)return v;const Z=Object.create(Object.getPrototypeOf(w));return Object.assign(Z,w,v),Z}class X{#t;#e=new Map;#n;constructor(v=256,Z=null){this.#t=v,this.#n=Z}get size(){return this.#e.size}get max(){return this.#t}set max(v){this.#t=v,this.#r()}has(v){return this.#e.has(v)}get(v){const Z=this.#e;if(!Z.has(v))return;const x=Z.get(v);return Z.delete(v),Z.set(v,x),x}peek(v){return this.#e.get(v)}set(v,Z){const x=this.#e;return x.has(v)&&x.delete(v),x.set(v,Z),this.#r(),Z}delete(v){const Z=this.#e.get(v);return this.#e.delete(v)&&this.#n&&this.#n(Z,v),Z}clear(){if(this.#n)for(const[v,Z]of this.#e)this.#n(Z,v);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const v=this.#e;for(;v.size>this.#t;){const Z=v.keys().next().value,x=v.get(Z);v.delete(Z),this.#n&&this.#n(x,Z)}}}const E=new Map;function S(w,v){const Z=`${w||""}|${v?JSON.stringify(v):""}`;let x=E.get(Z);return x||(x=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...v}),E.set(Z,x)),x}function U(w,v){if(w===v)return 0;if(w==null)return 1;if(v==null)return-1;if(typeof w=="number"&&typeof v=="number")return Number.isNaN(w)?Number.isNaN(v)?0:1:Number.isNaN(v)||w<v?-1:w>v?1:0;const Z=String(w),x=String(v);return Z<x?-1:Z>x?1:0}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const $=typeof requestAnimationFrame=="function";function re(w){return $?requestAnimationFrame(w):setTimeout(()=>w(H()),16)}function te(w){w!=null&&($?cancelAnimationFrame(w):clearTimeout(w))}function ae(w){let v=null,Z=null;const x=()=>{v=null;const we=Z;Z=null,w(...we||[])},de=(...we)=>{Z=we,v===null&&(v=re(x))};return de.cancel=()=>{te(v),v=null,Z=null},de.flush=()=>{v!==null&&(te(v),x())},de}function p(w,v){let Z=null,x=null;const de=()=>{if(Z=null,x===null)return;const pe=x;x=null,w(...pe),we()},we=()=>{Z=setTimeout(de,v),typeof Z?.unref=="function"&&Z.unref()},ge=(...pe)=>{Z===null?(w(...pe),we()):(x=pe,clearTimeout(Z),we())};return ge.flush=()=>{if(Z!==null&&clearTimeout(Z),Z=null,x===null)return;const pe=x;x=null,w(...pe)},ge.cancel=()=>{Z!==null&&clearTimeout(Z),Z=null,x=null},ge.pending=()=>Z!==null||x!==null,ge}function B(w,v=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:v}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let q=0;function oe(w="l"){return`${w}${(++q).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.isFunction,z=1,ne=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ie(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ie(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class le{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let l=0;l<u.length;l++){let t=u[l];for(;t;)t&=t-1,f++}return f}}class ue{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const f=this.#e.get(u);if(f!==void 0)return f;const l=this.#t.length;return this.#t.push(u),this.#e.set(u,l),this.#n++,l}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",l=this.#r.get(f);if(l&&l.version===this.#n)return l.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const m=he(u).compare,e=this.#t,d=Array.from(a).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function W(s){if(s==null)return null;const u=s.presence?new le(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ue(s.dict):null,l=s.values,t=s.offsets??null,a=s.kind,m=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(l[e]):l[e];case"bitset":return(l[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=f?f.valueOf(l[n]):l[n];return r}default:return l[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:l,presence:u,dict:f,offsets:t,get:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=W(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let l=0;l<s.length;l++)if(s[l].length>=f){const t=s.splice(l,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let l=0;l<u.length;l++)if(u[l].length>=f)return u.splice(l,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=l=>{if(!ee(l))return;const t=l.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const l of s)f(l);return u}if(typeof s=="object")for(const l of Object.keys(s)){const t=s[l];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function A(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const l of s)if(!A(l,u+1))return!1;return!0}for(const l of Object.keys(s))if(!A(s[l],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const l=f.conditions;if(Array.isArray(l))for(const t of l)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const ne=Math.max(0,z|0);this.#n=ne,this.#e=new Uint8Array(Math.ceil(ne/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,ne){return ne?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const ne=Math.max(0,z|0);if(ne<=this.#n)return this;const _=Math.ceil(ne/fe);if(_>this.#e.length){const T=new Uint8Array(_);T.set(this.#e),this.#e=T}return this.#n=ne,this}count(){const z=this.#e,ne=he.#t;let _=0;for(let T=0;T<z.length;T++)_+=ne[z[T]];return _}and(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]&=ne[K];for(let K=T;K<_.length;K++)_[K]=0;return this}or(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]|=ne[K];return this}not(){const z=this.#e;for(let ne=0;ne<z.length;ne++)z[ne]=~z[ne]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const ne=this.#n>>3;ne<this.#e.length&&(this.#e[ne]&=(1<<z)-1)}static from(z){const ne=Array.isArray(z)?z:Array.from(z),_=new he(ne.length);for(let T=0;T<ne.length;T++)ne[T]&&_.set(T);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let T=0;T<_.length;T++){const K=_[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(_+=K.length*2),_+=16}return _}codeOf(_){const T=this.#e.get(_);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(_),this.#e.set(_,K),this.#n++,K}lookup(_){const T=this.#e.get(_);return T===void 0?-1:T}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const T=_||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,ie=new Array(K);for(let W=0;W<K;W++)ie[W]=W;const J=he(_).compare,le=this.#t;ie.sort((W,L)=>this.#h(le[W],le[L],J));const ue=new Uint32Array(K);for(let W=0;W<K;W++)ue[ie[W]]=W;return this.#r=ue,this.#i=this.#n,this.#s=T,ue}#h(_,T,K){return typeof _=="string"&&typeof T=="string"?K(_,T):Q(_,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(Q={}){const z=Math.max(1,Q.rows??16),ne=Math.max(1,Q.values??z);this.#t=new Int32Array(ne),this.#e=new Uint32Array(z+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,z){if(Q<0||Q>=this.#n)return!1;const ne=this.#t,_=this.#e[Q+1];for(let T=this.#e[Q];T<_;T++)if(ne[T]===z)return!0;return!1}hasAny(Q,z){for(let ne=0;ne<z.length;ne++)if(this.has(Q,z[ne]))return!0;return!1}hasAll(Q,z){for(let ne=0;ne<z.length;ne++)if(!this.has(Q,z[ne]))return!1;return!0}hasNone(Q,z){return!this.hasAny(Q,z)}push(Q){const z=this.#n,ne=Q.length;this.#i(z+1),this.#s(this.#r+ne);const _=this.#r;for(let T=0;T<ne;T++)this.#t[_+T]=Q[T]|0;return this.#r+=ne,this.#n=z+1,this.#e[z]=_,this.#e[z+1]=this.#r,z}write(Q,z){if(Q===this.#n){this.push(z);return}if(Q<0||Q>this.#n)return;const ne=this.#e[Q],_=this.#e[Q+1],T=z.length;if(_-ne===T){for(let K=0;K<T;K++)this.#t[ne+K]=z[K]|0;return}this.#h(Q,z)}compact(Q,z,ne){const _=this.#t,T=this.#e,K=this.#n,ie=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let le=0;for(let ue=0;ue<K;ue++){if(Q[ue]===ne)continue;const W=T[ue],L=T[ue+1];J[Q[ue]]=le;for(let Y=W;Y<L;Y++)ie[le++]=_[Y];J[Q[ue]+1]=le}this.#t=ie,this.#e=J,this.#n=z,this.#r=le}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<Q;)z=z*2||16;const ne=new Uint32Array(z+1);ne.set(this.#e),this.#e=ne}#s(Q){if(Q<=this.#t.length)return;let z=this.#t.length;for(;z<Q;)z=z*2||16;const ne=new Int32Array(z);ne.set(this.#t),this.#t=ne}#h(Q,z){const ne=this.#t,_=this.#e,T=this.#n,K=z.length-(_[Q+1]-_[Q]),ie=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(_.length);let le=0;for(let ue=0;ue<T;ue++){if(J[ue]=le,ue===Q)for(let W=0;W<z.length;W++)ie[le++]=z[W]|0;else for(let W=_[ue];W<_[ue+1];W++)ie[le++]=ne[W];J[ue+1]=le}this.#t=ie,this.#e=J,this.#r=le}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return A}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare,z=fe.warnOnce;function ne(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(z(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.get(s);if(u)return u;let f="unknown";try{let l=null;typeof s.from=="function"?l=s.from([!1,!0]):(l=new s(8),l.set(1));const t=l&&l.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function ie(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function J(i){return!i||!i.presence?null:ie(i.presence)}function le(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ue(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function W(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const l=u[s],t=u[s+1];if(!(t>l))return[];const a=i.dict,m=new Array(t-l);for(let e=l;e<t;e++)m[e-l]=a?ue(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const l=i.dict;return u?t=>u(t)?ue(l,s[t]):null:t=>ue(l,s[t])}if(f==="bitset"){const l=ie(s);return u?t=>u(t)?l(t)===1:null:t=>l(t)===1}if(f==="multi")return u?l=>u(l)?W(i,l):null:l=>W(i,l);if(!s&&typeof i.get=="function"){const l=i.get.bind(i);return t=>{const a=l(t);return a===void 0?null:a}}return u?l=>{if(!u(l))return null;const t=s[l];return t===void 0?null:t}:l=>{const t=s[l];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const l=Object.is(i,-0),t=Object.is(s,-0);return l===t?0:l?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const l=typeof u,t=typeof f;if(l==="string"&&t==="string")return s.compare(u,f);if(l==="number"&&t==="number")return Y(u,f);if(l==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),m=f instanceof Date?f.getTime():Number(f);return Y(a,m)}return Q(u,f)}}function C(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,l=ee(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>l(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function A(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return R}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,Q=fe.dictRanks,z=fe.dictSize,ne=fe.identity,_=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,ie=fe.valueComparator,J=fe.valueReader,le=new Uint32Array(0),ue=new ArrayBuffer(8),W=new Float64Array(ue),L=new Uint32Array(ue),Y=(W[0]=-1,(L[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function C(E,S){W[0]=E;let U=L[Y],H=L[ee];(U&2147483648)!==0?(U=~U>>>0,H=~H>>>0):U=(U^2147483648)>>>0,S[0]=H,S[1]=U}function A(E,S,U,H){if(H<2)return E;const $=new Uint32Array(256*8);for(let w=0;w<H;w++){const v=S[w],Z=U[w];$[v&255]++,$[256+(v>>>8&255)]++,$[512+(v>>>16&255)]++,$[768+(v>>>24&255)]++,$[1024+(Z&255)]++,$[1280+(Z>>>8&255)]++,$[1536+(Z>>>16&255)]++,$[1792+(Z>>>24&255)]++}let re=E,te=S,ae=U,p=new Uint32Array(H),B=new Uint32Array(H),q=new Uint32Array(H);const oe=new Uint32Array(256);for(let w=0;w<8;w++){const v=w<<8,Z=(w&3)<<3,x=w>=4;let de=!1;for(let pe=0;pe<256;pe++)if($[v+pe]===H){de=!0;break}if(de)continue;let we=0;for(let pe=0;pe<256;pe++)oe[pe]=we,we+=$[v+pe];for(let pe=0;pe<H;pe++){const Te=te[pe],Le=ae[pe],Be=(x?Le:Te)>>>Z&255,ze=oe[Be]++;p[ze]=re[pe],B[ze]=Te,q[ze]=Le}let ge=re;re=p,p=ge,ge=te,te=B,B=ge,ge=ae,ae=q,q=ge}return re}function i(E,S,U){if(U<2)return E;const H=new Uint32Array(256*4);for(let B=0;B<U;B++){const q=S[B];H[q&255]++,H[256+(q>>>8&255)]++,H[512+(q>>>16&255)]++,H[768+(q>>>24&255)]++}let $=E,re=S,te=new Uint32Array(U),ae=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const q=B<<8,oe=B<<3;let w=!1;for(let x=0;x<256;x++)if(H[q+x]===U){w=!0;break}if(w)continue;let v=0;for(let x=0;x<256;x++)p[x]=v,v+=H[q+x];for(let x=0;x<U;x++){const de=re[x],we=p[de>>>oe&255]++;te[we]=$[x],ae[we]=de}let Z=$;$=te,te=Z,Z=re,re=ae,ae=Z}return $}function s(E,S,U,H){const $=new Uint32Array(H+1);for(let ae=0;ae<U;ae++)$[S[ae]]++;let re=0;for(let ae=0;ae<=H;ae++){const p=$[ae];$[ae]=re,re+=p}const te=new Uint32Array(U);for(let ae=0;ae<U;ae++)te[$[S[ae]]++]=E[ae];return te}function u(E,S,U,H){return U<2?E:H<=65536||H<=U*2?s(E,S,U,H):i(E,S,U)}function f(E,S){return E.length===S&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,S)}function l(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=new Uint32Array($),te=new Uint32Array($),ae=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let q=0,oe=0;for(let Z=0;Z<$;Z++){const x=H[Z],de=E[x];if(Number.isNaN(de)){p[oe++]=x;continue}C(de,B),U?(te[q]=~B[0]>>>0,ae[q]=~B[1]>>>0):(te[q]=B[0],ae[q]=B[1]),re[q++]=x}const w=A(re.subarray(0,q),te.subarray(0,q),ae.subarray(0,q),q);if(oe===0)return f(w,q);const v=new Uint32Array($);return v.set(w.subarray(0,q),0),v.set(p.subarray(0,oe),q),v}function t(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=Uint32Array.from(H),te=new Uint32Array($);for(let ae=0;ae<$;ae++){const p=(E[re[ae]]^2147483648)>>>0;te[ae]=U?~p>>>0:p}return f(i(re,te,$),$)}function a(E,S,U={}){const H=S||ne(K(E,U)),$=H.length;if($<2)return Uint32Array.from(H);const re=Q(E.dict,U.locale),te=E.values,ae=T(E),p=Math.max(z(E.dict),re.length),B=p,q=Uint32Array.from(H),oe=new Uint32Array($),w=!!U.descending;for(let v=0;v<$;v++){const Z=q[v];let x=ae&&ae(Z)===0?B:re[te[Z]];x===void 0&&(x=B),oe[v]=w?B-x:x}return f(u(q,oe,$,p+1),$)}function m(E,S,U){const H=S.length;let $=Uint32Array.from(S);if(H<2)return $;let re=new Uint32Array(H);for(let te=1;te<H;te<<=1){for(let p=0;p<H;p+=te<<1){const B=Math.min(p+te,H),q=Math.min(p+(te<<1),H);let oe=p,w=B,v=p;for(;oe<B&&w<q;)re[v++]=U(E[$[oe]],E[$[w]])<=0?$[oe++]:$[w++];for(;oe<B;)re[v++]=$[oe++];for(;w<q;)re[v++]=$[w++]}const ae=$;$=re,re=ae}return $}function e(E,S,U){const H=he(E.values),$=S.length,re=new Uint32Array($),te=U?1:0;let ae=0;for(let p=0;p<$;p++)H(S[p])===te&&(re[ae++]=S[p]);for(let p=0;p<$;p++)H(S[p])!==te&&(re[ae++]=S[p]);return re}function d(E,S){const U=E.values,H=E.kind;if((H==="object"||H===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!E.presence)return U;const re=J(E),te=new Array(K(E)||0);for(let ae=0;ae<S.length;ae++){const p=S[ae];te[p]=re(p)}return te}function h(E,S){for(let U=0;U<S.length;U++)if(typeof E[S[U]]!="string")return!1;return!0}function r(E,S,U,H,$){const re=E.length,te=Uint32Array.from(E);if(re<2||H<1)return te;const ae=new Uint32Array(re),p=H-1;for(let B=0;B<re;B++){const q=U[S[B]];ae[B]=$?p-q:q}return f(u(te,ae,re,H),re)}function n(E,S,U){const H=ie(U),$=new Array(S);for(let te=0;te<S;te++)$[te]=te;$.sort((te,ae)=>H(E[te],E[ae])||te-ae);const re=new Uint32Array(S);for(let te=0;te<S;te++)re[$[te]]=te;return re}function c(E,S,U){const H=S.length,$=new Map,re=[],te=new Uint32Array(H);for(let B=0;B<H;B++){const q=E[S[B]];let oe=$.get(q);oe===void 0&&(oe=re.length,$.set(q,oe),re.push(q)),te[B]=oe}const ae=re.length,p=n(re,ae,U.locale);return r(S,te,p,ae,!!U.descending)}function g(E,S,U){const H=d(E,S);if(S.length>=2&&h(H,S)){const te=E.stringRank;return te&&te.version===E.version&&te.usable(S,H,U.locale)?te.sort(S,U):c(H,S,U)}const $=ie(U.locale),re=U.descending?(te,ae)=>$(ae,te):$;return m(H,S,re)}function M(E,S,U){const H=d(E,S),$=U.compare,te=!!U.descending?(ae,p)=>-$(ae,p,void 0,void 0,!0):(ae,p)=>$(ae,p,void 0,void 0,!1);return m(H,S,te)}function N(E,S){const U=S.length,H=T(E),$=E.values,re=E.kind==="float64"&&!!$,te=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!H&&!re&&!te)return{present:S,absent:le};const ae=new Uint32Array(U),p=new Uint32Array(U);let B=0,q=0;if(H&&re)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1&&!Number.isNaN($[w])?ae[B++]=w:p[q++]=w}else if(re&&!H)for(let oe=0;oe<U;oe++){const w=S[oe];Number.isNaN($[w])?p[q++]=w:ae[B++]=w}else if(H&&!te)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1?ae[B++]=w:p[q++]=w}else{const oe=J(E);for(let w=0;w<U;w++){const v=S[w];_(oe(v))?p[q++]=v:ae[B++]=v}}return q===0?{present:S,absent:le}:{present:ae.subarray(0,B),absent:p.subarray(0,q)}}function G(E,S,U){if(S.length===0)return E;const H=new Uint32Array(E.length+S.length);return U?(H.set(S,0),H.set(E,S.length)):(H.set(E,0),H.set(S,E.length)),H}function F(E,S,U={}){const H=S||ne(K(E,U));if(!E||H.length<2)return Uint32Array.from(H);const{present:$,absent:re}=N(E,H);if($.length===0)return Uint32Array.from(H);const te=!!U.descending;let ae;if(typeof U.compare=="function")ae=M(E,$,U);else switch(E.kind){case"float64":ae=l(E.values,$,te);break;case"int32":ae=t(E.values,$,te);break;case"dictionary":ae=a(E,$,U);break;case"bitset":ae=e(E,$,te);break;default:ae=g(E,$,U);break}return G(ae,re,!!U.nullsFirst)}function R(E,S,U,H={}){const $=S||[],re=$.length&&($[0].handle||X(E,$[0].col))||E&&E[0];let te=U||ne(K(re,H));for(let ae=$.length-1;ae>=0;ae--){const p=$[ae],B=p.handle||X(E,p.col)||E&&E[ae];B&&(te=F(B,te,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:H.locale,compare:p.compare}))}return te instanceof Uint32Array?te:Uint32Array.from(te)}function X(E,S){if(!(!E||S===void 0)){for(let U=0;U<E.length;U++)if(E[U]&&E[U].id===S)return E[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return ne}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,Q=fe.rankSortStrings,z=1e5;class ne{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let ie=0;ie<K.length;ie++)T+=K[ie].length*2+24;return T}#a(T,K){const ie=this.#e.get(T);if(ie!==void 0)return ie;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const ie=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ie);for(let J=0;J<ie;J++){const le=T[J],ue=typeof le=="string"?this.#a(le,!1):-1;this.#n[J]=ue<0?0:ue}this.#r=ie}append(T,K,ie){const J=(K|0)+(ie|0);if(J>this.#n.length){const le=new Uint32Array(J);le.set(this.#n.subarray(0,this.#r)),this.#n=le}for(let le=K|0;le<J;le++){const ue=T[le],W=typeof ue=="string"?this.#a(ue,!0):-1;this.#n[le]=W<0?0:W}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const ie=he(this.#t,this.#t.length,T);return this.#o=ie,this.#c=this.#i,this.#l=K,ie}usable(T,K,ie){if(this.#u||this.#t.length===0)return!1;const J=this.#n,le=this.#t,ue=this.#r;for(let W=0;W<T.length;W++){const L=T[W];if(L>=ue||le[J[L]]!==K[L])return!1}return!0}sort(T,K){const ie=this.ranks(K.locale),J=this.#t.length,le=T.length,ue=new Uint32Array(le),W=this.#n;for(let L=0;L<le;L++)ue[L]=W[T[L]];return Q(T,ue,ie,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return a}});const fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,Q=fe.isFunction,z=fe.pathGetter,_=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,ue=me("packages/core/src/store/stringrank.js").StringRankIndex,W=4294967295,L=1024,Y=5e3,ee=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function A(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return A(m)?[]:Array.isArray(m)?m:[m]}function f(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function l(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let c=d;c<h;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=Q(e.read)?e.read:z(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const h=new ue(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,h){if(this.#g||h<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]);if(typeof G=="number"){n&&c.set(d+N),M[d+N]=G;continue}const F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?NaN:i(G)}break}case"int32":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?0:s(G)}break}case"bitset":{const M=this.#c;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M.assign(d+N,!F&&!!G)}break}case"dictionary":{const M=this.#o,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0),M[d+G]=R?0:N.codeOf(F)}break}case"multi":{const M=this.#l,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0);const X=u(F),E=new Array(X.length);for(let S=0;S<X.length;S++)E[S]=N.codeOf(X[S]);M.write(d+G,E)}break}default:{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?null:G}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let M=0;M<h;M++)this.#c.assign(d+M,(g[M>>3]&1<<(M&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],M=new Uint32Array(g.length);for(let R=0;R<g.length;R++)M[R]=this.#a.codeOf(g[R]);const N=e.values,G=this.#o,F=r;for(let R=0;R<h;R++){if(F&&(n&&(n[R>>3]&1<<(R&7))===0)){G[d+R]=0;continue}G[d+R]=M[N[R]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],M=new Uint32Array(g.length);for(let F=0;F<g.length;F++)M[F]=this.#a.codeOf(g[F]);const N=e.values,G=e.offsets;for(let F=0;F<h;F++){const R=G[F],X=G[F+1],E=new Array(X-R);for(let S=R;S<X;S++)E[S-R]=M[N[S]]??0;this.#l.write(d+F,E)}this.#f++;return}for(let g=0;g<h;g++){const M=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,M?null:l(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!C.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==W&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==W&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,W);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new _(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new _(d)),this.#p=d}#A(e,d){const h=A(d);switch(this.#r?this.#m.assign(e,!h):h&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=h?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),h=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!A(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Y:0,this.#w=d.compactRatio??ee;const h={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,h);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[h+c]=d[c];this.#i=h+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,h,r):c.grow(this.#s)}return{from:h,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,h)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?W:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)h[c]!==W&&(n[h[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),h}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,Q=fe.nextFrame,z=fe.infoOnce,ne=fe.warnOnce,_=fe.isFunction,T=fe.pathGetter,ie=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function le(A,i={}){if(i.multi)return"multi";if(A.length===0)return"object";let s=0,u=0,f=0,l=0,t=0;for(let m=0;m<A.length;m++){const e=A[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?l++:Array.isArray(e)&&t++}const a=A.length;return s===a?"float64":u===a?"bitset":l===a?"float64":f===a?"text":t===a?"multi":"object"}function ue(A,i,s){return i<=0||A<s*i?"dictionary":"object"}function W(A,i,s){const u=new Map,f=new Map;for(const c of A){if(c.computed)continue;const g=_(c.read)?c.read:T(c.field||c.id);f.set(c.id,g),u.set(c.id,g)}const l=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=l.filter(c=>_(t[c])),d=e.some(c=>a[c]==="*");let h=new WeakMap;const r=c=>{const g={};if(d)for(const[M,N]of f)g[M]=N(c);for(const M of e){const N=a[M];let G;if(N==="*")G=g;else{G={};const F=N||[];for(let R=0;R<F.length;R++){const X=F[R];G[X]=X in g?g[X]:f.get(X)?.(c)}}g[M]=t[M](m?m(G,M):G,{data:c,row:null,column:null,grid:null,context:s})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=h.get(c);return g===void 0&&(g=r(c),h.set(c,g)),g};for(const c of e)u.set(c,g=>n(g)[c]);return{readers:u,reset(){h=new WeakMap}}}class L{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=W(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ie(this.#e.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const l=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,l)),this.#a(this.#i,l),this.#i=l,this.#r.reset(),this.#w(!1)}while(this.#i<f&&he()-i<s);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),l=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){ne(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(a.id)??(_(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=le(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=ue(r,d.length,l),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`ingest.mixed.${a.id}`,`column "${a.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const l=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&l.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const l=this.#d(f);if(f.kind==="dictionary"&&l>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&l>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&l<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${l} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(A,i={},s={}){const u=new Y(A,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(l=>{f(l)});return u.result()}function C(A,i={},s={}){const u=new Y(A,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const he=me("packages/core/src/internal/util.js").pathGetter,Q=me("packages/core/src/store/ingest.js"),z=Q.inferKind,ne=Q.decideText,_=Q.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,ie=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const C of ee)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!ie.has(C.kind))return!1;return!0}function le(ee){const C=K(ee);return Number.isFinite(C)?C|0:0}function ue(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function W(ee,C,A,i){if(ee.kind)return ee.kind;const s=[];for(let l=0;l<C.length&&s.length<_.sampleSize;l++){const t=C[l];t!=null&&s.push(t)}const u=z(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return ne(f,s.length,i)}function L(ee,C,A={}){const i=C.length|0,s=A.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const l=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=l(C[r]);a[r]=n===void 0?null:n}const m=W(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),r[n]=g?NaN:K(c)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),r[n]=g?0:le(c)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const M=a[g];if(M===null){r[g]=0;continue}d(g);let N=c.get(M);N===void 0&&(N=n.length,n.push(M),c.set(M,N)),r[g]=N}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let M=0;M<i;M++){const N=a[M];c[M]=g.length,N===null||d(M);const F=ue(N);for(let R=0;R<F.length;R++){const X=F[R];let E=n.get(X);E===void 0&&(E=r.length,r.push(X),n.set(X,E)),g.push(E)}}c[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=a[n];c!==null&&d(n),r[n]=c}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Y(ee){const C=[];if(!ee||!Array.isArray(ee.columns))return C;const A=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of ee.columns)A(i.values),A(i.presence),A(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ne}});function fe(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function he(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let T=0;T<_.length;T++)if(!he(_[T]))return!1;return!0}function z(_,T){const K=_.col!==void 0?_.col:_.handle&&_.handle.id,ie=_.locale!==void 0?_.locale:T;return{col:K,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:fe(ie)}}function ne(_,T){const K=_||[],ie=new Array(K.length);for(let J=0;J<K.length;J++)ie[J]=z(K[J],T);return ie}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,Q=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(A){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<A.length;){const l=A[s];if(l==="\'"){if(A[s+1]==="\'"){u+="\'",s+=2;continue}const a=A.indexOf("\'",s+1);if(a===-1){u+=A.slice(s+1),s=A.length;continue}u+=A.slice(s+1,a),s=a+1;continue}const t=z.find(a=>A.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(l)&&Q(`date.pattern.token:${l}`,`the date pattern "${A}" contains \'${l}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=l,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(A){if(he(A)||A==="")return null;if(A instanceof Date)return Number.isNaN(A.getTime())?null:A;if(typeof A=="number")return Number.isNaN(A)?null:new Date(A);if(typeof A=="string"){const i=_.exec(A.trim());if(i){const[,u,f,l,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+l,+t,+a,+m)}const s=new Date(A);return Number.isNaN(s.getTime())?null:s}return null}function K(A,i){return String(A).padStart(i,"0")}function ie(A){if(!A)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:A,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const l of i.formatToParts(u))switch(l.type){case"year":f.year=Number(l.value);break;case"month":f.month=Number(l.value);break;case"day":f.day=Number(l.value);break;case"hour":f.hour=Number(l.value)%24;break;case"minute":f.minute=Number(l.value);break;case"second":f.second=Number(l.value);break;case"weekday":f.weekday=s[l.value]??0;break;default:break}return f}}function J(A,i,s){const u=ne(A),f=ie(s),l=new Set(u.filter(d=>d.token).map(d=>d.token)),t=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=l.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const le=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ue(A,i){const s=A||{},u=s.locale||i||void 0,f=s.nullDisplay??"",l=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,l);else if(s.dateStyle||s.timeStyle){const h={timeZone:l};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:l});t=r=>h.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[M,N]of le)if(Math.abs(g)>=N||M==="second")return a.format(Math.round(g/N),M)}}return t(n)};return d.spec=s,d}function W(A){if(he(A)||A==="")return null;if(typeof A=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(A.trim());if(u)return u[1];const f=T(A);return f?W(f):null}const i=T(A);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(A,i){if(he(A)||A==="")return null;if(typeof A=="string"){const u=A.trim();if(Y.test(u)){const t=T(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const l=T(u);return l?L(l):null}const s=T(A);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(A,i){const s=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(A).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const u=`${A.getFullYear()}-${s(A.getMonth()+1)}-${s(A.getDate())}`,f=A.getSeconds(),l=`${s(A.getHours())}:${s(A.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${l}`}function C(A,i){const s=he(A)||A===""?null:String(A),u=he(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ae}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,Q=fe.toArray,z=fe.warnOnce,_=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,ie=T.dictSize,J=T.dictValue,le=T.presenceReader,ue=T.valueComparator,W=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(p,B){const q=p&&p.pool;if(q){const oe=q.mask||q.acquireMask||q.acquire||q.take;if(typeof oe=="function"){const w=oe.call(q,B);if(w&&w.length>=B)return w}}return new Uint8Array(B)}function C(p,B){const q=p&&p.pool;if(!q||!B)return;const oe=q.release||q.releaseMask||q.free||q.recycle;typeof oe=="function"&&oe.call(q,B)}function A(p,B,q){return p.fill(q,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const q=_(p);return q===null?u(p):q}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function l(p,B){const q=typeof p=="string"?p:String(p);return B?q:q.toLowerCase()}function t(p,B){return p==null?Y:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,q){const oe=new Set;for(const w of Q(p)){const v=s(w,q);oe.add(t(v,B)),typeof v=="string"&&v!==""&&Number.isFinite(Number(v))?oe.add(Number(v)):typeof v=="number"&&Number.isFinite(v)&&oe.add(t(String(v),B))}return oe}function m(p,B,q){if(p==null||B===null||B===void 0)return p==null&&B==null;const oe=typeof p,w=typeof B;return oe==="string"&&w==="string"?q?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):oe==="number"&&w==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):oe==="number"&&w==="string"?p===Number(B):oe==="string"&&w==="number"?Number(p)===B:oe==="boolean"||w==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((v,Z)=>m(v,B[Z],q)):p===B}function e(p,B){try{if(p instanceof RegExp){const q=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||q.includes("i")?q:`${q}i`)}return new RegExp(String(p),B?"":"i")}catch(q){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,q),null}}function d(p,B){const q=h(p,B),oe=p&&p.type;return oe!=="date"&&oe!=="dateString"?q:w=>q(typeof w=="string"&&L.test(w)?w:_(w)??w)}function h(p,B){const q=p&&p.op,oe=!!(p&&p.caseSensitive),w=p&&p.type,v=ue(B),Z=x=>de=>!x(de);switch(q){case"eq":{const x=s(p.value,w);return de=>m(de,x,oe)}case"ne":{const x=s(p.value,w);return de=>!m(de,x,oe)}case"lt":case"lte":case"gt":case"gte":{const x=s(p.value,w);if(i(x))return()=>!1;const de=q==="lt"?-1:q==="lte"?0:q==="gt"?1:2;return we=>{if(i(we))return!1;const ge=v(we,x);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const x=Q(p.value),de=s(x[0],w),we=s(x[1],w),ge=p.bounds||"[]",pe=ge.charAt(0)!=="(",Te=ge.charAt(1)!==")";if(i(de)||i(we))return q==="between"?()=>!1:()=>!0;const Le=Be=>{if(i(Be))return!1;const ze=v(Be,de),Ke=v(Be,we);return(pe?ze>=0:ze>0)&&(Te?Ke<=0:Ke<0)};return q==="between"?Le:Z(Le)}case"in":case"notIn":{const x=a(p.value,oe,w),de=we=>x.has(t(we,oe));return q==="in"?de:Z(de)}case"contains":case"notContains":{const x=l(s(p.value,w),oe),de=we=>we==null?!1:l(we,oe).includes(x);return q==="contains"?de:Z(de)}case"startsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).startsWith(x)}case"endsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).endsWith(x)}case"matches":{const x=e(p.value,oe);return x?de=>de==null?!1:x.test(String(de)):()=>!1}case"blank":return x=>he(x)||Array.isArray(x)&&x.length===0;case"notBlank":return x=>!(he(x)||Array.isArray(x)&&x.length===0);case"containsAny":case"containsNone":{const x=a(p.value,oe,w),de=we=>{const ge=we==null?[]:Q(we);for(let pe=0;pe<ge.length;pe++)if(x.has(t(ge[pe],oe)))return!0;return!1};return q==="containsAny"?de:Z(de)}case"containsAll":{const x=Q(p.value).map(de=>t(s(de,w),oe));return de=>{const we=de==null?[]:Q(de);if(x.length===0)return!0;const ge=new Set(we.map(pe=>t(pe,oe)));for(let pe=0;pe<x.length;pe++)if(!ge.has(x[pe]))return!1;return!0}}default:{const x=ae(q);return x?x.compile(p.value):(z(`op:${String(q)}`,`unknown filter operator "${String(q)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,q){return d(B,q)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,q){const oe=p&&p.op,w=n[oe]||oe,v=d({...p,op:w,type:B.type},q),Z=B.items,x=de=>{const we=Z(de);if(!we)return!1;for(let ge=0;ge<we.length;ge++)if(v(we[ge]))return!0;return!1};return n[oe]?de=>!x(de):x}function M(p,B,q,oe){const w=le(p);if(w){const x=B?1:0;for(let de=0;de<oe;de++)q[de]=w(de)===x?1:0;return q}const v=p.kind;if(v==="float64"||v==="int32"||v==="bitset")return A(q,oe,B?1:0);const Z=W(p);for(let x=0;x<oe;x++){const de=Z(x),we=he(de)||Array.isArray(de)&&de.length===0;q[x]=we===B?0:1}return q}function N(p,B,q,oe){const w=p.dict,v=ie(w),Z=new Uint8Array(v);for(let ge=0;ge<v;ge++)Z[ge]=B(J(w,ge))?1:0;const x=p.values,de=le(p);if(!de){for(let ge=0;ge<oe;ge++)q[ge]=Z[x[ge]];return q}const we=B(null)?1:0;for(let ge=0;ge<oe;ge++)q[ge]=de(ge)===1?Z[x[ge]]:we;return q}function G(p,B,q,oe){const w=K(p.values),v=B(!0)?1:0,Z=B(!1)?1:0,x=le(p);if(!x){for(let we=0;we<oe;we++)q[we]=w(we)===1?v:Z;return q}const de=B(null)?1:0;for(let we=0;we<oe;we++)q[we]=x(we)===0?de:w(we)===1?v:Z;return q}function F(p,B,q,oe,w){const v=p.values,Z=B.type,x=B.op;let de=!0;switch(x){case"eq":case"ne":{const ge=f(s(B.value,Z)),pe=typeof B.value=="number"&&Number.isNaN(B.value),Te=x==="ne"?1:0;if(pe)for(let Le=0;Le<w;Le++)oe[Le]=(Number.isNaN(v[Le])?1:0)^Te;else for(let Le=0;Le<w;Le++)oe[Le]=(v[Le]===ge?1:0)^Te;break}case"lt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<ge?1:0;break}case"lte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>ge?1:0;break}case"gte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>=ge?1:0;break}case"between":case"notBetween":{const ge=Q(B.value),pe=f(s(ge[0],Z)),Te=f(s(ge[1],Z)),Le=B.bounds||"[]",Be=Le.charAt(0)!=="(",ze=Le.charAt(1)!==")",Ke=x==="notBetween"?1:0;if(Be&&ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<=Te?1:0)^Ke;else if(Be)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<Te?1:0)^Ke;else if(ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<=Te?1:0)^Ke;else for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<Te?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Te of Q(B.value)){const Le=f(s(Te,Z));Number.isNaN(Le)||ge.add(Le)}const pe=x==="notIn"?1:0;for(let Te=0;Te<w;Te++)oe[Te]=(ge.has(v[Te])?1:0)^pe;break}default:de=!1;break}if(!de)return!1;const we=le(p);if(we){const ge=q(null)?1:0;for(let pe=0;pe<w;pe++)we(pe)===0&&(oe[pe]=ge)}return!0}function R(p,B,q,oe){const w=W(p);for(let v=0;v<oe;v++)q[v]=B(w(v))?1:0;return q}function X(p,B,q){const oe=B.count|0,w=q||ee(B,oe);if(!p)return A(w,oe,1);const v=typeof B.handle=="function"?B.handle(p.col):void 0,Z=typeof B.custom=="function"?B.custom:null;if(!v){if(Z){for(let ge=0;ge<oe;ge++)w[ge]=Z(p,ge)?1:0;return w}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),A(w,oe,0)}const x=p.op;if(x==="blank"||x==="notBlank")return M(v,x==="notBlank",w,oe);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ae(x)&&!c.has(x))return R(v,g(p,de,B.locale),w,oe);const we=d(p,B.locale);switch(v.kind){case"dictionary":return N(v,we,w,oe);case"bitset":return G(v,we,w,oe);case"float64":case"int32":return F(v,p,we,w,oe)?w:R(v,we,w,oe);default:return R(v,we,w,oe)}}function E(p,B,q){if(!p)return A(ee(B,q),q,1);if(Array.isArray(p.conditions)){const oe=p.conditions.filter(Z=>Z!=null),w=p.op==="or"?"or":p.op==="not"?"not":"and";if(oe.length===0)return A(ee(B,q),q,1);const v=E(oe[0],B,q);for(let Z=1;Z<oe.length;Z++){const x=E(oe[Z],B,q);if(w==="or")for(let de=0;de<q;de++)v[de]|=x[de];else for(let de=0;de<q;de++)v[de]&=x[de];C(B,x)}if(w==="not")for(let Z=0;Z<q;Z++)v[Z]^=1;return v}return X(p,B,ee(B,q))}function S(p,B){return E(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const q=p;if(Array.isArray(q.conditions)){if((q.op==="or"?"or":q.op==="not"?"not":"and")!=="and")return H(q,B)?null:p;const w=[];for(const v of q.conditions){const Z=U(v,B);Z&&w.push(Z)}return w.length?{...q,op:"and",conditions:w}:null}return q.col===B?null:p}function H(p,B){if(!p||typeof p!="object")return!1;const q=p;if(q.col===B)return!0;if(Array.isArray(q.conditions)){for(const oe of q.conditions)if(H(oe,B))return!0}return!1}function $(p,B,q){if(q&&q.length>=B){let Z=0;for(let x=0;x<B;x++)p[x]&&(q[Z++]=x);return q.subarray(0,Z)}let oe=0;for(let Z=0;Z<B;Z++)oe+=p[Z]?1:0;const w=new Uint32Array(oe);let v=0;for(let Z=0;Z<B;Z++)p[Z]&&(w[v++]=Z);return w}const re=new Map;function te(p){if(!(!p||typeof p!="object"))for(const[B,q]of Object.entries(p))q&&typeof q.compile=="function"&&re.set(B,q)}function ae(p){return typeof p=="string"?re.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ue}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,Q=fe.identity,z=fe.presenceReader,ne=fe.rowCount,_=fe.valueReader,T="",K="\\0",ie=1<<20;function J(W,L,Y,ee){const C=W.length,A=W.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?A.map((t,a)=>ee[a]?m=>ee[a](t(m)):t):A;if(!i&&C>0&&W.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=W.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=W.map(r=>r.values),e=W.map(r=>z(r)),d=r=>{let n=0;for(let c=0;c<C;c++){const g=e[c],M=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+M}return n},h=new Float64Array(Y);for(let r=0;r<Y;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},l=new Array(Y);for(let t=0;t<Y;t++)l[t]=f(L[t]);return{packed:null,strings:l,product:1/0,readers:s,keyOf:f}}function le(W,L,Y,ee){const C=new Uint32Array(ee+1);for(let u=0;u<Y;u++)C[L[u]+1]++;for(let u=0;u<ee;u++)C[u+1]+=C[u];const A=new Uint32Array(Y),i=C.slice(0,ee);for(let u=0;u<Y;u++)A[i[L[u]]++]=W[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=A.subarray(C[u],C[u+1]);return s}function ue(W,L,Y={}){const ee=W||[],C=L||Q(ne(ee[0],Y)),A=C.length;if(ee.length===0||A===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(ee,C,A,Y.project),l=new Uint32Array(A);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ie,A*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<A;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<A;n++)l[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<A;r++){const n=i[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<A;r++){const n=s[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}}const m=le(C,l,A,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let c=0;c<f.length;c++)n[c]=f[c](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=fe.dictSize,ne=fe.dictValue,_=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,ie=50,J=1e4;function le(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const M=c&&c.base;if(M==="date"||M==="datetime"||M==="time"||M==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function ue(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return N=>c[N];const M=Q(n);return N=>W(M(N))}function W(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,c,g,M=ie){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const N=Q(n),G=c?c.length:g,F=new Set;for(let R=0;R<G;R++){const X=N(c?c[R]:R);if(X!=null&&(F.add(X),F.size>M))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Y=36e5,ee=864e5;function C(n,c=K){const g=Number.isFinite(n)&&n>0?n:0,M=Math.max(1,c)*2;return g/Y<=M?"hour":g/ee<=M?"day":g/(7*ee)<=M?"week":g/(30*ee)<=M?"month":g/(91*ee)<=M?"quarter":"year"}function A(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const M=(g.getDay()+6)%7;return g.setDate(g.getDate()-M),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,c,g){const M=ue(n),N=he(n),G=c?c.length:g;let F=1/0,R=-1/0,X=0,E=0;for(let S=0;S<G;S++){const U=c?c[S]:S;if(N&&!N(U)){X++;continue}const H=M(U);if(!Number.isFinite(H)){X++;continue}H<F&&(F=H),H>R&&(R=H),E++}return{min:F,max:R,nulls:X,finite:E}}function u(n,c,g,M){const N=ue(n),G=he(n),F=c?c.length:g,R=F>M?F/M:1,X=[];for(let S=0;S<F;S+=R){const U=c?c[Math.floor(S)]:Math.floor(S);if(G&&!G(U))continue;const H=N(U);Number.isFinite(H)&&X.push(H)}const E=Float64Array.from(X);return E.sort(),E}function f(n,c,g,M={}){const N=M.kind||le(n,M.type);return N==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:N==="boolean"?l(n,c,g):N==="category"?t(n,c,g,M):a(n,c,g,N,M)}function l(n,c,g){const M=he(n);let N=0;if(M){const F=c?c.length:g;for(let R=0;R<F;R++)M(c?c[R]:R)||N++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return N>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,c,g,M){const N=M.cardinalityLimit??ie,{cardinality:G}=L(n,c,g,N);if(G>N&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=Q(n),R=c?c.length:g,X=new Map;let E=0;for(let re=0;re<R;re++){const te=F(c?c[re]:re);if(te==null||te===""){E++;continue}if(Array.isArray(te)){if(!te.length){E++;continue}for(const ae of te)X.set(ae,(X.get(ae)||0)+1);continue}X.set(te,(X.get(te)||0)+1)}let S=[...X.entries()];M.order==="alpha"?S.sort((re,te)=>String(re[0]).localeCompare(String(te[0]))):S.sort((re,te)=>te[1]-re[1]);let U=0,H=0;if(S.length>N){H=S.length-N;for(let re=N;re<S.length;re++)U+=S[re][1];S=S.slice(0,N)}const $=S.map(([re])=>({value:re,label:String(re)}));return U>0&&$.push({remainder:!0,label:`Other (${H} values)`}),E>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,c,g,M,N){const{min:G,max:F,nulls:R,finite:X}=s(n,c,g);if(!X)return{kind:M,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(N.buckets||K));let S=[];if(M==="date"){const H=T.includes(N.granularity)?N.granularity:C(F-G,E);let $=A(G,H);for(;$<=F&&S.length<4096;){const re=i($,H);if(!(re>$))break;S.push({from:$,to:re}),$=re}return{kind:M,buckets:m(S,R),granularity:H}}const U=_.includes(N.strategy)?N.strategy:"equal";if(U==="quantile"){const H=u(n,c,g,J);if(H.length){const $=[H[0]];for(let re=1;re<E;re++){const te=H[Math.min(H.length-1,Math.floor(re/E*H.length))];te>$[$.length-1]&&$.push(te)}$.push(F);for(let re=0;re<$.length-1;re++)S.push({from:$[re],to:$[re+1]})}}else if(U==="log"&&G>0){const H=Math.log10(G),re=(Math.log10(F)-H)/E||1;for(let te=0;te<E;te++)S.push({from:10**(H+te*re),to:10**(H+(te+1)*re)})}if(!S.length){const H=(F-G)/E||1;for(let $=0;$<E;$++)S.push({from:G+$*H,to:G+($+1)*H})}return S[S.length-1].to=F,{kind:M,buckets:m(S,R),strategy:U,min:G,max:F}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,M,N){const G=M&&M.buckets||[],F=N&&N.length>=G.length?N.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const R=G.length-1,X=!!G[R]&&G[R].null===!0,E=c?c.length:g;if(M.kind==="boolean"){const re=Q(n);for(let te=0;te<E;te++){const ae=re(c?c[te]:te);if(ae==null){X&&F[R]++;continue}F[ae?1:0]++}return F}if(M.kind==="category"){const re=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&re.set(G[p].value,p);const te=G.findIndex(p=>p.remainder),ae=Q(n);for(let p=0;p<E;p++){const B=ae(c?c[p]:p);if(B==null||B===""){X&&F[R]++;continue}if(Array.isArray(B)){if(!B.length){X&&F[R]++;continue}for(const oe of B){const w=re.get(oe);w!==void 0?F[w]++:te>=0&&F[te]++}continue}const q=re.get(B);q!==void 0?F[q]++:te>=0&&F[te]++}return F}const S=X?G.length-1:G.length,U=new Float64Array(S+1);for(let re=0;re<S;re++)U[re]=G[re].from;U[S]=S?G[S-1].to:0;const H=ue(n),$=he(n);for(let re=0;re<E;re++){const te=c?c[re]:re;if($&&!$(te)){X&&F[R]++;continue}const ae=H(te);if(!Number.isFinite(ae)){X&&F[R]++;continue}const p=d(U,S,ae);p>=0&&F[p]++}return F}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let M=0,N=c-1;for(;M<N;){const G=M+N+1>>>1;g>=n[G]?M=G:N=G-1}return M}function h(n,c,g,M={}){const N=M.bounds||f(n,M.boundsIndices??c,g,M);return{bounds:N,counts:e(n,c,g,N)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,Q=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const A=C-1;let i=.9999999999998099;const s=A+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(A+u+1);return .5*Math.log(2*Math.PI)+(A+.5)*Math.log(s)-s+Math.log(i)}function ne(C,A,i){const s=C+A,u=C+1,f=C-1;let l=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(A-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t,a*=t*l,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t;const h=t*l;if(a*=h,Math.abs(h-1)<he)break}return a}function _(C,A,i){if(!(C>0)||!(A>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+A)-z(C)-z(A)+C*Math.log(i)+A*Math.log(1-i));return i<(C+1)/(C+A+2)?s*ne(C,A,i)/C:1-s*ne(A,C,1-i)/A}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const A=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let l,t,a;C<f?(l=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1)):C<=1-f?(l=C-.5,t=l*l,a=(((((A[0]*t+A[1])*t+A[2])*t+A[3])*t+A[4])*t+A[5])*l/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(l=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1));const e=(.5*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const A=Math.abs(C),i=2/(2+A),s=4*i-2,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let f=0,l=0,t;for(let m=u.length-1;m>0;m--)t=l,l=s*l-f+u[m],f=t;const a=i*Math.exp(-A*A+.5*(u[0]+s*l)-f);return C>=0?a:2-a}function ie(C){return .5*K(-C/Math.SQRT2)}function J(C,A){if(!(A>0)||!Number.isFinite(C))return Number.NaN;const i=.5*_(A/2,.5,A/(A+C*C));return C>0?1-i:i}function le(C,A){if(!(C>0)||!(C<1)||!(A>0))return Number.NaN;if(A>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(A/2)+z(.5)-z((A+1)/2);for(let l=0;l<60;l++){const t=J(u,A);t<C?i=u:s=u;const a=Math.exp(-((A+1)/2)*Math.log(1+u*u/A)-f)/Math.sqrt(A),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ue(C,A){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=A/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-A+C*Math.log(A)-z(C))}function W(C,A){let i=A+1-C,s=1/Q,u=1/i,f=u;for(let l=1;l<=300;l++){const t=-l*(l-C);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-A+C*Math.log(A)-z(C))*f}function L(C,A){return!(C>0)||!(A>=0)||!Number.isFinite(A)?Number.NaN:A===0?0:A<C+1?ue(C,A):1-W(C,A)}function Y(C,A){return A>0?L(A/2,C/2):Number.NaN}function ee(C,A){const i=Y(C,A);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function fe(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let le=0;le<=J;le++){let ue=T[J][le];for(let W=0;W<le;W++)ue-=ie[J][W]*ie[le][W];if(J===le){if(!(ue>0))return null;ie[J][le]=Math.sqrt(ue)}else ie[J][le]=ue/ie[le][le]}return ie}function he(T,K){const ie=T.length,J=new Array(ie).fill(0);for(let ue=0;ue<ie;ue++){let W=K[ue];for(let L=0;L<ue;L++)W-=T[ue][L]*J[L];J[ue]=W/T[ue][ue]}const le=new Array(ie).fill(0);for(let ue=ie-1;ue>=0;ue--){let W=J[ue];for(let L=ue+1;L<ie;L++)W-=T[L][ue]*le[L];le[ue]=W/T[ue][ue]}return le}function Q(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const le=new Array(K).fill(0);le[J]=1;const ue=he(T,le);for(let W=0;W<K;W++)ie[W][J]=ue[W]}return ie}function z(T,K,ie){const J=T.length,le=J?T[0].length:0,ue=Array.from({length:le},()=>new Array(le).fill(0)),W=new Array(le).fill(0);for(let L=0;L<J;L++){const Y=ie?ie[L]:1,ee=T[L];for(let C=0;C<le;C++){const A=Y*ee[C];W[C]+=A*K[L];for(let i=C;i<le;i++)ue[C][i]+=A*ee[i]}}for(let L=0;L<le;L++)for(let Y=0;Y<L;Y++)ue[L][Y]=ue[Y][L];return{xtwx:ue,xtwy:W}}function ne(T,K){return T.map(ie=>ie.reduce((J,le,ue)=>J+le*K[ue],0))}function _(T,K){let ie=0;for(let J=0;J<T.length;J++){let le=0;for(let ue=0;ue<T.length;ue++)le+=K[J][ue]*T[ue];ie+=T[J]*le}return ie}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ue}});class fe{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(L){if(!Number.isFinite(L))return;this.#t++;const Y=L-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Y=this.#t+L.#t,ee=L.#e-this.#e;this.#e+=ee*(L.#t/Y),this.#n+=L.#n+ee*ee*(this.#t*L.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Y=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Y of this.#t)L+=Y;return L/this.#t.length}quantile(L){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const C=(Y-1)*Math.min(1,Math.max(0,L)),A=Math.floor(C),i=Math.ceil(C);return A===i?ee[A]:ee[A]+(C-A)*(ee[i]-ee[A])}}function Q(W){return W^=W>>>16,W=Math.imul(W,2246822507),W^=W>>>13,W=Math.imul(W,3266489909),W^=W>>>15,W>>>0}function z(W){if(typeof W=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,W===0?0:W),Q(ee.getUint32(0)^ee.getUint32(4))}const L=typeof W=="string"?W:String(W);let Y=2166136261;for(let ee=0;ee<L.length;ee++)Y^=L.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class ne{#t;#e;#n;constructor(L=14){const Y=Math.floor(L);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Y=1<<Math.floor(L),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return ne.errorBoundFor(this.#t)}add(L){const Y=z(L),ee=Y&this.#e-1,C=Y>>>this.#t|1<<32-this.#t;let A=1,i=C;for(;(i&1)===0;)A++,i>>>=1;A>this.#n[ee]&&(this.#n[ee]=A)}count(){const L=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<L;i++)ee[this.#n[i]]++;let C=L*K(1-ee[Y+1]/L);for(let i=Y;i>=1;i--)C=.5*(C+ee[i]);C+=L*T(ee[0]/L);const A=_*L*L/C;return Math.round(A)}}const _=.5/Math.log(2);function T(W){if(W===1)return 1/0;let L=1,Y=W,ee;do W*=W,ee=Y,Y+=W*L,L+=L;while(Y!==ee);return Y}function K(W){if(W===0||W===1)return 0;let L=1,Y=1-W,ee;do W=Math.sqrt(W),ee=Y,L*=.5,Y-=(1-W)**2*L;while(Y!==ee);return Y/3}class ie{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Y=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Y=this.#t.get(L);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let ee,C=1/0;for(const[A,i]of this.#t)i.count<C&&(C=i.count,ee=A);this.#t.delete(ee),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([ee,C])=>({item:ee,count:C.count,error:C.error})).sort((ee,C)=>C.count-ee.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Y=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Y,this.#i=2/3}static errorBoundFor(L=200){const Y=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const ee=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**ee);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Y=this.#e[L];Y.sort((A,i)=>A-i),L+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[L+1],C=this.#r()<.5?0:1;for(let A=C;A<Y.length;A+=2)ee.push(Y[A]);this.#e[L]=[];for(let A=0;A<this.#e.length;A++)if(this.#e[A].length>=this.#s(A)){this.#h(A);return}}#u(){const L=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const C of this.#e[Y])L.push({v:C,w:ee})}return L}quantile(L){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const C=Math.min(1,Math.max(0,L))*ee;let A=0;for(const i of Y)if(A+=i.w,A>=C)return i.v;return Y[Y.length-1].v}rank(L){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const C=1<<ee;for(const A of this.#e[ee])A<=L&&(Y+=C)}return Y}}const le=Object.freeze({distinct:ne.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),ue={Welford:fe,Reservoir:he,HyperLogLog:ne,SpaceSaving:ie,KLL:J,hash32:z,SKETCH_BOUNDS:le}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=me("packages/core/src/compute/special.js"),ne=z.studentTQuantile,_=z.studentT,T=z.normalQuantile,K=z.normalCdf,ie=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),le=J.cholesky,ue=J.choleskySolve,W=J.choleskyInverse,L=J.normalEquations,Y=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,A=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let se=0;se<y;se++){const ce=j[se];if(D&&D(ce)!==1)continue;const Oe=I[ce];Number.isNaN(Oe)||(O[k++]=Oe)}return O.subarray(0,k)}const V=Q(b);for(let I=0;I<y;I++){const D=V(j[I]);if(D==null||D==="")continue;const se=typeof D=="number"?D:Number(D);Number.isFinite(se)&&(O[k++]=se)}return O.subarray(0,k)}function l(b,j){const y=new Map,O=Q(b);let k=0;for(let V=0;V<j.length;V++){const I=O(j[V]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const P=[...y.values()].sort((V,I)=>I-V);return{counts:P,total:k,distinct:P.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=l(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=l(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let P=0;for(let V=0;V<Math.min(k,O.counts.length);V++)P+=O.counts[V];return P/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let P=0,V=0;for(let I=0;I<O;I++)P+=k[I],V+=(I+1)*k[I];return P===0?0:2*V/(O*P)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const P=b[k];j++;const V=P-y;y+=V/j,O+=V*(P-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),P=Math.ceil(O);return k===P?b[k]:b[k]+(O-k)*(b[P]-b[k])}function c(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=Q(b);let O=0,k=0,P=0;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&P++}return{pass:O+P,fail:k,warn:P,judged:O+P+k}}const M=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>X(f(b,j),.1),winsorizedMean:(b,j)=>E(f(b,j),.1),robustOutliers:(b,j)=>S(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?c(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?c(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?c(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?c(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?c(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?c(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=c(y,.5),k=new Float64Array(y.length);for(let P=0;P<y.length;P++)k[P]=Math.abs(y[P]-O);return c(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let P=0;P<y.length;P++)y[P]<O&&(O=y[P]),y[P]>k&&(k=y[P]);return k-O},distinct:(b,j)=>{const y=Q(b),O=new Set;for(let k=0;k<j.length;k++){const P=y(j[k]);P==null||P===""||O.add(P instanceof Date?P.getTime():P)}return O.size},mode:(b,j)=>{const y=Q(b),O=new Map;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,P=1;for(const[V,I]of O)I>P&&(P=I,k=V);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<3||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/V)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<4||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let ce=0;ce<y.length;ce++)I+=((y[ce]-k)/V)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),se=3*(O-1)**2/((O-2)*(O-3));return D*I-se},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).fail}),N=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function G(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0;for(let I=0;I<y.length;I++){const D=y[I],se=Number(O(D)),ce=Number(k(D));!Number.isFinite(se)||!Number.isFinite(ce)||(P+=se*ce,V+=ce)}return V===0?null:P/V}function F(b,j,y){const O=Q(b);let k=null,P=y?-1/0:1/0;for(let V=0;V<j.length;V++){const I=j[V],D=Number(O(I));Number.isFinite(D)&&(y?D>P:D<P)&&(P=D,k=I)}return k}function R(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0,I=0,D=0,se=0,ce=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(P++,V+=Pe,I+=ye,D+=Pe*Pe,se+=ye*ye,ce+=Pe*ye)}if(P<2)return null;const Oe=P*ce-V*I,ke=Math.sqrt((P*D-V*V)*(P*se-I*I));if(ke===0)return null;const je=Oe/ke;return Math.max(-1,Math.min(1,je))}function X(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O.slice(k,y-k);if(!P.length)return n(O,.5);let V=0;for(const I of P)V+=I;return V/P.length}function E(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,se)=>D-se),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O[k],V=O[y-1-k];let I=0;for(const D of O)I+=Math.min(V,Math.max(P,D));return I/y}function S(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,se)=>D-se),k=n(O,.5),P=O.map(D=>Math.abs(D-k)).sort((D,se)=>D-se),V=n(P,.5);if(V===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/V)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,P=0;for(const D of b){const se=D-y;O+=se*se,k+=se*se*se,P+=se*se*se*se}if(O/=j,k/=j,P/=j,O===0)return null;const V=k/O**1.5,I=P/(O*O)-3;return j/6*(V*V+I*I/4)}function H(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const se=Number(b[D]),ce=Number(j[D]);!Number.isFinite(se)||!Number.isFinite(ce)||ce<=0||(O.push([se,ce]),k+=ce)}if(!O.length||k<=0)return null;if(O.sort((D,se)=>D[0]-se[0]),O.length===1)return O[0][0];const P=[];let V=0;for(const[,D]of O)P.push((V+D/2)/k),V+=D;const I=Math.max(0,Math.min(1,y));if(I<=P[0])return O[0][0];if(I>=P[P.length-1])return O[O.length-1][0];for(let D=1;D<P.length;D++){if(I>P[D])continue;const se=P[D]-P[D-1],ce=se>0?(I-P[D-1])/se:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*ce}return O[O.length-1][0]}function $(b,j,y){const O=Q(b),k=Q(j),P=new Float64Array(y.length),V=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const se=y[D],ce=Number(O(se)),Oe=Number(k(se));!Number.isFinite(ce)||!Number.isFinite(Oe)||(P[I]=ce,V[I]=Oe,I++)}return{xs:P.subarray(0,I),ys:V.subarray(0,I),n:I}}function re(b,j,y,O=!1){const{xs:k,ys:P,n:V}=$(b,j,y);if(V<2)return null;let I=0,D=0;for(let ce=0;ce<V;ce++)I+=k[ce],D+=P[ce];I/=V,D/=V;let se=0;for(let ce=0;ce<V;ce++)se+=(k[ce]-I)*(P[ce]-D);return se/(O?V:V-1)}function te(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;let V=0,I=0;for(let Pe=0;Pe<P;Pe++)V+=O[Pe],I+=k[Pe];V/=P,I/=P;let D=0,se=0,ce=0;for(let Pe=0;Pe<P;Pe++){const ye=O[Pe]-V,ve=k[Pe]-I;D+=ye*ye,se+=ye*ve,ce+=ve*ve}if(D===0)return null;const Oe=se/D,ke=I-Oe*V,je=ce===0?1:Math.max(0,Math.min(1,se*se/(D*ce))),be=Math.max(0,ce-Oe*se),Ae=P>2?Math.sqrt(be/(P-2)/D):0;return{slope:Oe,intercept:ke,r2:je,stdError:Ae,n:P}}const ae=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),q=1.345;function oe(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),P=le(O);if(!P)return null;const V=ue(P,k),I=W(P),D=w(b,V),se=j.map((ce,Oe)=>ce-D[Oe]);return{beta:V,cov:I,fitted:D,residuals:se}}function w(b,j){return b.map(y=>y.reduce((O,k,P)=>O+k*j[P],0))}function v(b,j){const y=b.length,O=b.map(se=>se[j]),k=b.map(se=>[1,...se.filter((ce,Oe)=>Oe!==j)]),P=oe(k,O,null);if(!P)return 1;const V=O.reduce((se,ce)=>se+ce,0)/y;let I=0,D=0;for(let se=0;se<y;se++)I+=P.residuals[se]**2,D+=(O[se]-V)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function Z(b){const j=[...b].sort((k,P)=>k-P),y=x(j),O=b.map(k=>Math.abs(k-y)).sort((k,P)=>k-P);return x(O)/.6745}function x(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ae.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,P=k&&Array.isArray(b[0])?b[0].length:0,V=P+1;if(!(k>V))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==P)return null;for(let Ne=0;Ne<P;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let se,ce=null;if(O==="robust"){if(se=oe(D,j,null),!se)return null;for(let Me=0;Me<50;Me++){const Ne=Z(se.residuals);if(!(Ne>0))break;const Re=se.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=q?1:q/We}),Ce=oe(D,j,Re);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-se.beta[Je])),0);if(se=Ce,ce=Re,Ve<1e-10)break}}else if(se=oe(D,j,I),!se)return null;const Oe=O==="robust"?ce:I,{beta:ke,cov:je,fitted:be,residuals:Ae}=se;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-V,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===P?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?ne(1-(1-He)/2,De):1/0,Lt=ke.map((Me,Ne)=>{const Re=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Re>0?Me/Re:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-_(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Re:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Re,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1,Re=Math.max(0,Math.min(1,Ne*Y(D[Me],je)));dt[Me]=Re;const Ce=(1-Re)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(V*qe)*(Re/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(P<2)return 1;const Re=v(b,Ne);return Re>=1?1/0:1/(1-Re)});let gt=null;{const Me=Ae.map(Re=>Re*Re),Ne=oe(D,Me,null);if(Ne){const Re=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Re)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=ie(We,P);gt={statistic:We,df:P,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(P===1){const Me=b.map((Ne,Re)=>Re).sort((Ne,Re)=>b[Ne][0]-b[Re][0]);bt={confidence:He,points:Me.map(Ne=>{const Re=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Y(Re,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:Oe?[...Oe]:null}}function we(b){const j=b.length,y=Array.from({length:j},(P,V)=>V).sort((P,V)=>b[P]-b[V]),O=new Float64Array(j);let k=0;for(;k<j;){let P=k;for(;P+1<j&&b[y[P+1]]===b[y[k]];)P++;const V=(k+P)/2+1;for(let I=k;I<=P;I++)O[y[I]]=V;k=P+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const P=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+P*(b-y[0]))))}if(b>=y[2]){const P=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+P*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Te(b,j,y,O){const k=y-O,P=O+3,V=new Array(k),I=new Array(k);let D=!0,se=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(P);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<P;ye++)Number.isFinite(Pe[ye])||(se=Math.min(se,ye-3));V[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:ce,xtwy:Oe}=L(V,I,null);let ke=0,je=1/0;for(let be=0;be<=se;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=ce[Ue].slice(0,Ae);const ye=le(Pe);if(!ye)continue;const ve=ue(ye,Oe.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=V[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,ke=be)}return ke}function Le(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const P=new Array(k);for(let je=0;je<k;je++)P[je]=y[je+1]-y[je];let V=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);V=Math.max(0,Math.min(V,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(P[ye-Fe]);Ae.push(ve),Pe.push(P[ye])}return de(Ae,Pe,{method:"ols"})},D=Te(y,P,k,V),se=I(D,D);if(!se||!se.coefficients[2])return null;const ce=se.coefficients[2].t,Oe=pe(ce),ke=ce<ge["5%"];return{statistic:ce,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:Oe,pApproximate:!0,stationary:ke,verdict:ke?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let ke=0;ke<b.length;ke++){const je=Number(b[ke]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let P=0;for(const ke of y)P+=ke;P/=O;const V=y.map(ke=>ke-P);let I=0;for(const ke of V)I+=ke*ke;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let ke=1;ke<=k;ke++){let je=0;for(let be=ke;be<O;be++)je+=V[be]*V[be-ke];D[ke]=I>0?je/O/I:0}const se=new Array(k+1).fill(0);se[0]=1;let ce=[];for(let ke=1;ke<=k;ke++){let je=D[ke];for(let ye=1;ye<ke;ye++)je-=ce[ye-1]*D[ke-ye];let be=1;for(let ye=1;ye<ke;ye++)be-=ce[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(ke);for(let ye=1;ye<ke;ye++)Pe[ye-1]=ce[ye-1]-Ae*ce[ke-1-ye];Pe[ke-1]=Ae,se[ke]=Ae,ce=Pe}const Oe=1.96/Math.sqrt(O);return{acf:D,pacf:se,bounds:{upper:Oe,lower:-Oe},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;const V=we(O),I=we(k);let D=0,se=0;for(let je=0;je<P;je++)D+=V[je],se+=I[je];D/=P,se/=P;let ce=0,Oe=0,ke=0;for(let je=0;je<P;je++){const be=V[je]-D,Ae=I[je]-se;ce+=be*Ae,Oe+=be*be,ke+=Ae*Ae}return Oe===0||ke===0?null:Math.max(-1,Math.min(1,ce/Math.sqrt(Oe*ke)))}function Ke(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2||P>A)return null;let V=0,I=0,D=0,se=0;for(let ke=0;ke<P;ke++)for(let je=ke+1;je<P;je++){const be=Math.sign(O[ke]-O[je]),Ae=Math.sign(k[ke]-k[je]),Pe=be*Ae;Pe>0?V++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:se++)}const ce=V+I+se,Oe=V+I+D;return ce===0||Oe===0?null:(V-I)/Math.sqrt(ce*Oe)}function Ee(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],P=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&P.push((b[ye]-ve)/Math.abs(ve))}let V=null;if(P.length>1){let ye=0;for(const Fe of P)ye+=Fe;ye/=P.length;let ve=0;for(const Fe of P)ve+=(Fe-ye)**2;V=Math.sqrt(ve/(P.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],se=0,ce=0,Oe=0,ke=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],se=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>ce&&(ce=ve,Oe=se,ke=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of P)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:V,annualisedVolatility:V!==null&&I?V*Math.sqrt(I):null,growth:Pe,maxDrawdown:ce,maxDrawdownFrom:Oe,maxDrawdownTo:ke,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,P)=>k+P,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let P=0;for(let be=0;be<y;be++)P+=b[be];P/=y;let V=0;for(let be=0;be<y;be++)V+=(b[be]-P)**2;const I=Math.sqrt(V/(y-1)),D=xe(b),se=D?D.sigma:null,ce=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-P)/(3*be):1/0,ve=O!==null?(P-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},Oe=ce(se),ke=ce(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:P,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:se,sigmaOverall:I,cp:Oe.index,cpk:Oe.k,pp:ke.index,ppk:ke.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=I=>(b[I]-O)/k,V=[];for(let I=0;I<y;I++){if(Math.abs(P(I))>3&&V.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let se=0;for(let ce=I-2;ce<=I;ce++)P(ce)*D>2&&se++;if(se>=2){V.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let se=0;for(let ce=I-4;ce<=I;ce++)P(ce)*D>1&&se++;if(se>=4){V.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let se=!0;for(let ce=I-7;ce<=I;ce++)if(P(ce)*D<=0){se=!1;break}if(se){V.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return V}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=D=>(b[D]-O)/k,V=(D,se,ce,Oe)=>{for(const ke of[1,-1]){let je=0;for(let be=D;be<=se;be++)P(be)*ke>ce&&je++;if(je>=Oe)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(P(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const se of[1,-1]){let ce=!0;for(let Oe=D-8;Oe<=D;Oe++)if(P(Oe)*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const se of[1,-1]){let ce=!0;for(let Oe=D-4;Oe<=D;Oe++)if((b[Oe]-b[Oe-1])*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:3,description:se>0?"six rising":"six falling"});break}}if(D>=13){let se=!0;for(let ce=D-12;ce<=D;ce++){const Oe=b[ce]-b[ce-1],ke=b[ce+1<=D?ce+1:ce]-b[ce];if(ce+1>D)break;if(Oe===0||ke===0||Oe>0==ke>0){se=!1;break}}se&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&V(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&V(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let se=!0;for(let ce=D-14;ce<=D;ce++)if(Math.abs(P(ce))>=1){se=!1;break}se&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let se=!0;for(let ce=D-7;ce<=D;ce++)if(Math.abs(P(ce))<=1){se=!1;break}se&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const P=b[0],V=b[k-1];if(V===P)return[{from:P,to:V,count:k}];const I=y-j,D=1.5*I;let se=I>0?Math.max(P,j-D):P,ce=I>0?Math.min(V,y+D):V;ce>se||(se=P,ce=V);const Oe=I>0?2*I/Math.cbrt(k):(ce-se)/(Math.ceil(Math.log2(k))+1),ke=Oe>0?Math.min(O,Math.max(1,Math.ceil((ce-se)/Oe))):1,je=(ce-se)/ke,be=[];for(let Ae=0;Ae<ke;Ae++)be.push({from:se+Ae*je,to:se+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(ke-1,Math.max(0,Math.floor((b[Ae]-se)/je)));be[Pe].count++}return be[0].from=P,be[ke-1].to=V,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let ce=0;ce<y;ce++)O+=b[ce];const k=O/y;let P=0;for(let ce=0;ce<y;ce++){const Oe=b[ce]-k;P+=Oe*Oe}const V=Math.sqrt(P/(y-1)),I=Qe(j),se=ne(1-(1-I)/2,y-1)*V/Math.sqrt(y);return{mean:k,lower:k-se,upper:k+se,margin:se,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const P=Qe(y),V=T(1-(1-P)/2),I=O/k,D=V*V,se=1+D/k,ce=(I+D/(2*k))/se,Oe=V/se*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,ce-Oe),upper:Math.min(1,ce+Oe),n:k,confidence:P}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=ne(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const P=Qe(y),I=T(1-(1-P)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:P}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=Q(b);let k=0;for(let P=0;P<j.length;P++){const V=O(j[P]);if(V==null||V===""||typeof V=="number"&&Number.isNaN(V))continue;const I=V instanceof Date?V.getTime():typeof V=="object"?String(V):V;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const P=new Set(b.keys());for(const V of y.keys())P.add(V);for(const V of P){const I=(b.get(V)||0)/j,D=(y.get(V)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:se}=r(I),ce=D>0?lt({mean:y.mean,sd:y.sd},se):null;return{measure:"standardizedMeanDifference",magnitude:ce,distance:ce===null?0:at(ce),direction:ce===null?0:Math.sign(ce),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:P}=_e(b,j),V=ft(k,P,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:V,distance:V===null?0:V,direction:0,subsetN:P,populationN:y.total||0,reliable:P>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=Q(b);let O=0,k=0;for(let P=0;P<j.length&&O<200;P++){const V=y(j[P]);if(V==null||V==="")continue;if(V instanceof Date)return!1;O++;const I=typeof V=="number"?V:Number(V);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:P,mean:V,m2:I}=r(k);return{numeric:!0,mean:V,sd:P>0?Math.sqrt(I/P):0,n:P}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,Q=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),ne=z.presenceReader,_=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),ie=K.STAT_FNS,J=K.STAT_LABELS;function le(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ue(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++){const R=N[n[F]];Number.isNaN(R)||(g+=R)}return g}for(let F=0;F<c;F++){const R=n[F];if(G(R)===1){const X=N[R];Number.isNaN(X)||(g+=X)}}return g}const M=T(r);for(let N=0;N<c;N++){const G=u(M(n[N]));G!==null&&(g+=G)}return g}ue.kernel=!0;function W(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++)Number.isNaN(N[n[F]])||g++;return g}for(let F=0;F<c;F++){const R=n[F];G(R)===1&&!Number.isNaN(N[R])&&g++}return g}const M=T(r);for(let N=0;N<c;N++){const G=M(n[N]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}W.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Y(r,n){const c=W(r,n);return c===0?null:ue(r,n)/c}Y.kernel=!0;function ee(r,n,c,g){const M=n.length;if(le(r)){const R=r.values,X=ne(r);let E=null;if(!X){for(let S=0;S<M;S++){const U=R[n[S]];Number.isNaN(U)||(E===null||(c<0?U<E:U>E))&&(E=U)}return E}for(let S=0;S<M;S++){const U=n[S];if(X(U)===0)continue;const H=R[U];Number.isNaN(H)||(E===null||(c<0?H<E:H>E))&&(E=H)}return E}const N=T(r),G=_(g);let F=null;for(let R=0;R<M;R++){const X=N(n[R]);X==null||typeof X=="number"&&Number.isNaN(X)||(F===null||(c<0?G(X,F)<0:G(X,F)>0))&&(F=X)}return F}function C(r,n,c){return ee(r,n,-1,c&&c.locale)}C.kernel=!0;function A(r,n,c){return ee(r,n,1,c&&c.locale)}A.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(r)(n[n.length-1])}s.kernel=!0;function u(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const f={sum:ue,min:C,max:A,avg:Y,count:L,first:i,last:s,countValues:W,...ie},l=Object.freeze({...J,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?l[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=a.filter(g=>g in f);for(const g of Object.keys(f))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=T(r),g=[];for(let M=0;M<n.length;M++){const N=c(n[M]);N!=null&&g.push(N)}return g}function h(r,n,c,g){const M=n||[];if(typeof c=="string"){const N=f[c];return N?N(r,M,g):(Q(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,M,g):c(d(r,M),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,_=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,ie="|",J="/",le=2e3;function ue(u,f,l){return`${u}${ie}${f}${ie}${l}`}function W(u,f){let l="";for(let t=0;t<u.length;t++){const a=u[t];l+=(t===0?"":f)+(a==null?"":String(a))}return l}function L(u,f,l={}){const t=l.separator||J,a=f.length,{keyOf:m,readers:e}=_(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const R=f[F],X=m(R);if(d.has(X))continue;d.set(X,h.length),r.push(X);const E=new Array(e.length);for(let S=0;S<e.length;S++)E[S]=e[S](R);h.push(E)}const n=z(l.locale),c=h.map((F,R)=>R);c.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=Y(X[S],E[S],n);if(U!==0)return U}return F-R});const g=new Array(c.length),M=new Array(c.length),N=new Map;for(let F=0;F<c.length;F++){const R=c[F];g[F]=h[R],M[F]=W(h[R],t),N.set(r[R],F)}return{keys:g,paths:M,idOf:F=>{const R=N.get(m(F));return R===void 0?-1:R}}}function Y(u,f,l){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:l(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const l=typeof u.handle=="function"?u.handle:null;if(!l)return f.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=l(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,l){if(Array.isArray(u)){const t=l||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function A(u,f,l){const t=C(u,f,l),a=t.separator||J,m=ee(t),e=t.maxColumns===void 0?le:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(X=>W(X,a)):[""]),n=s(h),{keys:c,paths:g,idOf:M}=L(t.pivotHandles||[],n,t),N=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&N>e){const X=new Map;return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${N} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:N,maxColumns:e}}}const F=new Map,R=g.length;for(let X=0;X<h.length;X++){const E=h[X],S=r[X]===void 0?"":r[X],U=E.length;if(U===0)continue;const H=new Int32Array(U),$=new Uint32Array(R+1);for(let ae=0;ae<U;ae++){const p=M(E[ae]);H[ae]=p,p>=0&&$[p+1]++}for(let ae=0;ae<R;ae++)$[ae+1]+=$[ae];const re=new Uint32Array(U),te=$.slice(0,R);for(let ae=0;ae<U;ae++){const p=H[ae];p>=0&&(re[te[p]++]=E[ae])}for(let ae=0;ae<R;ae++){const p=$[ae],B=$[ae+1];if(B===p)continue;const q=re.subarray(p,B);for(let oe=0;oe<m.length;oe++){const w=m[oe],v=K(w.handle,q,w.fn,t.totalContext||{locale:t.locale});F.set(ue(S,g[ae],w.colId),v)}}}return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:F,cells:F,error:null}}function i(u,f,l){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${l}${m.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const l=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(l.set(a,t),t+=a.length);return l}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,_=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,ie=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,le="";function ue(i,s,u={}){const f=u.separator||ie,l=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(l.length===0)return{tuples:[[]],paths:[le],buckets:[t]};const{keyOf:m,readers:e}=_(l,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const R=t[F],X=m(R);let E=d.get(X);if(E===void 0){E=h.length,d.set(X,E),r.push(X);const S=new Array(e.length);for(let U=0;U<e.length;U++)S[U]=e[U](R);h.push(S),n.push([])}n[E].push(R)}const c=he(u.locale),g=h.map((F,R)=>R);g.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=W(X[S],E[S],c);if(U!==0)return U}return F-R});const M=new Array(g.length),N=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const R=g[F];M[F]=h[R],N[F]=K(h[R],f),G[F]=Uint32Array.from(n[R])}return{tuples:M,paths:N,buckets:G}}function W(i,s,u){const f=i==null,l=s==null;return f||l?f&&l?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let l=0;l<i.length;l++)u.has(i[l])&&f.push(i[l]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ie,f=s.totalContext||{locale:s.locale},l=(i.measures||[]).filter(N=>N&&N.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ue(i.rowHandles||[],t,{...s,separator:u}),m=ue(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,l.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,M=m.buckets.map(N=>new Set(N));for(let N=0;N<m.paths.length;N++){const G=m.buckets[N],F=m.paths[N];for(const R of l)c.set(A(F,R.colId),Y(R.handle,G,R.fn,f))}for(let N=0;N<a.paths.length;N++){const G=a.buckets[N],F=a.paths[N];for(const R of l)n.set(A(F,R.colId),Y(R.handle,G,R.fn,f));for(let R=0;R<m.paths.length;R++){const X=L(G,m.buckets[R],M[R]);if(X.length===0)continue;const E=m.paths[R];for(const S of l)r.set(C(F,E,S.colId),Y(S.handle,X,S.fn,f))}}for(const N of l)g.set(N.colId,Y(N.handle,t,N.fn,f));return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function A(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const he=me("packages/core/src/internal/util.js").getPath,Q=me("packages/core/src/compute/handle.js"),z=Q.isMissing,ne=Q.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",ie="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function le(i,s,u={}){const f=s||[];let l=i.map((t,a)=>a);if(f.length===0)return l;for(let t=f.length-1;t>=0;t--)l=ue(i,l,f[t],u);return l}function ue(i,s,u,f){const l=u.locale!==void 0?u.locale:f.locale,t=ne(l),a=u.descending!==void 0?!!u.descending:u.dir==="desc",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const h=(r,n)=>{const c=J(i[r],u.col),g=J(i[n],u.col);let M;return typeof u.compare=="function"?(M=u.compare(c,g,i[r],i[n],a),a&&(M=-M)):M=a?t(g,c):t(c,g),M!==0?M:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function W(i,s,u={}){const f=[];for(let l=0;l<i.length;l++)L(i[l],s,u,l)&&f.push(l);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const l=s.conditions.filter(a=>a!=null);if(l.length===0)return!0;if(s.op==="or")return l.some(a=>L(i,a,u,f));const t=l.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Y(i,s,u,f){const l=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of l){const d=s.map((n,c)=>{const g=J(i[e],n);return f&&f[c]?f[c](g):g}),h=d.map(n=>n==null?ie:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function ee(i,s,u={}){const f=ne(u.locale),l=i.filter(a=>!z(a)),t=l.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return l.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return l.length===0?null:t.reduce((a,m)=>a+m,0)/l.length;case"min":return l.length===0?null:l.reduce((a,m)=>f(m,a)<0?m:a);case"max":return l.length===0?null:l.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:A(i[0]);case"last":return i.length===0?null:A(i[i.length-1]);default:return null}}function C(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function A(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(K,ie=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(ie>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(ie),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,ie=this.#r()){Number.isFinite(K)&&(this.#n.push({t:ie,v:K}),this.#s(ie))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ie=K-this.#e;for(;this.#n.length&&this.#n[0].t<ie;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ie=new he;let J=0,le=1/0,ue=-1/0;for(const{v:W}of this.#n)J+=W,W<le&&(le=W),W>ue&&(ue=W),ie.add(W);return{over:K,count:this.#n.length,sum:J,mean:ie.mean(),min:le,max:ue,variance:ie.variance(),stddev:ie.stddev()}}reduce(K){const ie=this.aggregate(),J={sum:ie.sum,avg:ie.mean,mean:ie.mean,min:ie.min,max:ie.max,count:ie.count,variance:ie.variance,stddev:ie.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:ie.over}}}const z=Object.freeze(["count","time","session"]);function ne(T,K=Date.now){const ie=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new Q(T.kind,ie,K)}const _={Window:Q,WINDOW_KINDS:z,openWindow:ne}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,ne=.6745,_=3.5,T=1.5,K=.975,ie=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(l){if(!l.length)return null;const a=Array.from(l,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function le(l,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,m=l.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let c=0;c<m;c++){const g=Number(l[c]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(l[c]);if(!Number.isFinite(g))continue;const M=ne*(g-r.median)/r.mad;e[c]=M,Math.abs(M)>a&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function ue(l,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<l.length;n++){const c=Number(l[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function W(l,t){if(t<=0)return 0;const a=z(l);if(t<l+1){let c=l,g=1/l,M=g;for(let N=0;N<1e3&&(c+=1,M*=t/c,g+=M,!(Math.abs(M)<Math.abs(g)*1e-15));N++);return g*Math.exp(-t+l*Math.log(t)-a)}const m=1e-300;let e=t+1-l,d=1/m,h=1/e,r=h;for(let c=1;c<1e3;c++){const g=-c*(c-l);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const M=h*d;if(r*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-t+l*Math.log(t)-a)*r}function L(l,t){return l<=0?0:W(t/2,l/2)}function Y(l,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,l);for(;L(m,l)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,l)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function ee(l){const t=l.length,a=l.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(l,t){const a=l.length,m=new Array(t).fill(0);for(const h of l)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of l)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(h[c]-m[c])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function A(l,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=l.length;if(!e)return null;const d=l[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let S=0;S<e;S++){const U=l[S];let H=U.length===d;const $=new Array(d);for(let re=0;H&&re<d;re++){const te=Number(U[re]);Number.isFinite(te)?$[re]=te:H=!1}H&&(c.push(S),g.push($))}const M=d,N=Y(M,a);if(g.length<=d)return{center:[],df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let R=ee(F),X=!1;if(!R){X=!0;let S=0;for(let $=0;$<d;$++)S+=F[$][$];const U=S/d*m||m,H=F.map(($,re)=>$.map((te,ae)=>re===ae?te+U:te));if(R=ee(H),!R)return{center:G,df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let E=0;for(let S=0;S<g.length;S++){const U=g[S],H=new Array(d);for(let te=0;te<d;te++)H[te]=U[te]-G[te];let $=0;for(let te=0;te<d;te++){let ae=0;for(let p=0;p<d;p++)ae+=R[te][p]*H[p];$+=H[te]*ae}$<0&&($=0);const re=c[S];r[re]=$,h[re]=Math.sqrt($),$>N&&(n[re]=!0,E++)}return{center:G,df:M,cutoff:N,singular:X,used:g.length,distances:h,squared:r,flags:n,flagged:E}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(l,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=l.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let M=0;M<r;M++){const N=Number(l[M]);if(!Number.isFinite(N))continue;const G=Math.max(0,M-m+1),F=[];for(let R=G;R<=M;R++){const X=Number(l[R]);Number.isFinite(X)&&F.push(X)}if(!(F.length<h))if(a==="rollingIqr"){const R=ue(F,{k:d});if(!R)continue;(N<R.lower||N>R.upper)&&(c[M]=!0,g++)}else{const R=J(F);if(!R||R.mad===0)continue;const X=ne*(N-R.median)/R.mad;n[M]=X,Math.abs(X)>e&&(c[M]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:c,flagged:g}}function f(l={}){const t=l||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(ie.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=c=>Number(c==null?NaN:c[a]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((R,X)=>{const E=R?.[d],S=X?.[d];return E===S?0:E==null?-1:S==null?1:E<S?-1:1});const M=g.map(n);let N,G;if(r)({flags:N,scores:G}=u(M,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const R=ue(M,{k:t.k});N=M.map(X=>R?Number.isFinite(X)&&(X<R.lower||X>R.upper):!1),G=M.map(()=>null)}else({flags:N,scores:G}=le(M,{threshold:t.threshold}));if(h){const R=N.length-1;return R<0||!N[R]?!1:{method:m,field:a,flagged:[{row:g[R],score:G[R]}]}}const F=[];for(let R=0;R<N.length;R++)N[R]&&F.push({row:g[R],score:G[R]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return l}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,Q=fe.studentTQuantile,ne=me("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function ie(t){const a=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function le(t){return Math.min(K,Math.max(T,t))}function ue(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),c=h+d*(r-h),g=t(n),M=t(c);for(let N=0;N<e;N++)g<M?(r=c,c=n,M=g,n=r-d*(r-h),g=t(n)):(h=n,n=c,g=M,c=h+d*(r-h),M=t(c));return(h+r)/2}function W(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;h+=(c-g)**2,r+=1;const M=e;e=a*c+(1-a)*(M+d),d=m*(e-M)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Y(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=X=>{let E=0,S=0;for(let U=X;U<X+a&&U<h;U++)t[U]!==null&&(E+=t[U],S+=1);return S?E/S:null},n=r(0),c=r(a);if(n===null||c===null)return null;let g=n,M=(c-n)/a;const N=new Array(a).fill(0);for(let X=0;X<a;X++)N[X]=t[X]===null?0:t[X]-g;const G=N.reduce((X,E)=>X+E,0)/a;for(let X=0;X<a;X++)N[X]-=G;let F=0,R=0;for(let X=a;X<h;X++){const E=X%a,S=N[E],U=t[X];if(U===null){g+=M;continue}const H=g+M+S;F+=(U-H)**2,R+=1;const $=g;g=m*(U-S)+(1-m)*(g+M),M=e*(g-$)+(1-e)*M,N[E]=d*(U-g)+(1-d)*S}return{level:g,trend:M,season:N,phase:(h-1)%a,sse:F,count:R}}function ee(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=ie(t),n=r.map(F=>F.value),c=n.filter(F=>F!==null),g=c.length,{lastAt:M,step:N}=g?J(r):{lastAt:0,step:1},G=F=>M+F*N;return m==="linear"?A(r,g,e,d,h,G):m==="movingAverage"?i(c,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function A(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let c=0,g=0,M=0;for(const U of t){if(U.value===null)continue;const H=U.at-r,$=U.value-n;c+=H*H,g+=H*$,M+=$*$}if(c===0)return null;const N=g/c,G=n-N*r,F=M===0?1:Math.max(0,Math.min(1,g*g/(c*M))),R=Math.max(0,M-N*g),X=a>2?Math.sqrt(R/(a-2)):null,E=a>2?Q(d,a-2):null,S=[];for(let U=1;U<=m;U++){const H=h(U),$=G+N*H;let re=null,te=null,ae=null,p=null,B=null;if(X!==null){const q=1/a+(H-r)**2/c,oe=X*Math.sqrt(1+q),w=X*Math.sqrt(q);B=oe,re=$-E*oe,te=$+E*oe,ae=$-E*w,p=$+E*w}S.push({step:U,at:H,mean:$,lower:re,upper:te,lowerMean:ae,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:X,r2:F,params:{slope:N,intercept:G},points:S}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),c=t.slice(a-n);let g=0;for(const X of c)g+=X;const M=g/n;let N=null,G=null;if(n>1){let X=0;for(const S of c)X+=(S-M)**2;N=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),G=Q(d,n-1)}const F=N===null?null:G*N,R=[];for(let X=1;X<=m;X++)R.push({step:X,at:r(X),mean:M,lower:F===null?null:M-F,upper:F===null?null:M+F,se:N});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:N===null?null:N,params:{windowLen:n},points:R}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null;n===null&&(n=ue(G=>W(t,G).sse));const c=W(t,n),g=he(d),M=c.m>0?c.sse/c.m:null,N=[];for(let G=1;G<=m;G++){const F=c.level;let R=null,X=null,E=null;if(M!==null){const S=[];for(let H=1;H<G;H++)S.push(n);const U=ee(M,S,g);E=U.se,R=F-U.margin,X=F+U.margin}N.push({step:G,at:r(G),mean:F,lower:R,upper:X,se:E})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:M===null?null:Math.sqrt(M),params:{alpha:n},points:N}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null,c=Number.isFinite(h.beta)?le(h.beta):null;if(n===null||c===null){let R=n===null?.5:n,X=c===null?.5:c;for(let E=0;E<6;E++)n===null&&(R=ue(S=>L(t,S,X).sse)),c===null&&(X=ue(S=>L(t,R,S).sse));n=n===null?R:n,c=c===null?X:c}const g=L(t,n,c),M=he(d),N=g.m>0?g.sse/g.m:null,G=n*c,F=[];for(let R=1;R<=m;R++){const X=g.level+R*g.trend;let E=null,S=null,U=null;if(N!==null){const H=[];for(let re=1;re<R;re++)H.push(n+re*G);const $=ee(N,H,M);U=$.se,E=X-$.margin,S=X+$.margin}F.push({step:R,at:r(R),mean:X,lower:E,upper:S,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:N===null?null:Math.sqrt(N),params:{alpha:n,beta:c},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return ne("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let c=Number.isFinite(h.alpha)?le(h.alpha):null,g=Number.isFinite(h.beta)?le(h.beta):null,M=Number.isFinite(h.gamma)?le(h.gamma):null;const N=(U,H,$)=>{const re=Y(t,n,U,H,$);return re?re.sse:1/0};if(c===null||g===null||M===null){let U=c===null?.5:c,H=g===null?.5:g,$=M===null?.5:M;for(let re=0;re<8;re++)c===null&&(U=ue(te=>N(te,H,$))),g===null&&(H=ue(te=>N(U,te,$))),M===null&&($=ue(te=>N(U,H,te)));c=c===null?U:c,g=g===null?H:g,M=M===null?$:M}const G=Y(t,n,c,g,M);if(!G)return null;const F=he(d),R=G.count>0?G.sse/G.count:null,X=c*g,E=M*(1-c),S=[];for(let U=1;U<=m;U++){const H=G.season[(G.phase+U)%n],$=G.level+U*G.trend+H;let re=null,te=null,ae=null;if(R!==null){const p=[];for(let q=1;q<U;q++)p.push(c+q*X+(q%n===0?E:0));const B=ee(R,p,F);ae=B.se,re=$-B.margin,te=$+B.margin}S.push({step:U,at:r(U),mean:$,lower:re,upper:te,se:ae})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:R===null?null:Math.sqrt(R),params:{alpha:c,beta:g,gamma:M,period:n},points:S}}const l={FORECAST_METHODS:_,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const Q=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const ne=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return ne.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return ne.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return ne.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return ne.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ne.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return ne.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return ne.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return ne.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return ne.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return ne.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return ne.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return ne.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return ne.QUANTILE_SAMPLE}});const _=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const ie=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ie.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ie.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ie.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ie.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ie.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ie.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const le=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return le.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return le.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return le.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return le.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return le.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le.SKETCH_BOUNDS}});const ue=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ue.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ue.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ue.openWindow}});const W=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return W.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return W.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return W.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Y=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,Q=fe.OPS,z=fe.CONTROL,ne=fe.ERRORS,_=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,ie=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),le=J.packChunk,ue=J.packedTransfers;let W=null,L=null,Y=null;async function ee(f){if(W)return W;if(!L){const l=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(l).then(t=>(W=t,t)).catch(t=>(Y=t,W=null,null))}return L}function C(f){W=f,L=f?Promise.resolve(f):null,Y=f?null:Y}function A(f,l,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:l,pool:K(),locale:t}}function i(f,l){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return le(a.schema||[],a.rows||[],a.opts||{});const m=l[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=ne.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return m(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case Q.EVALUATE_FILTERS:return m(a.filters,A(T(a.handles||[]),a.count,a.locale));case Q.COMPACT:return m(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return m(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return m(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=ne.PROTOCOL,e}}}async function s(f,l={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return l.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(l.cancelled?.has(t))return l.cancelled.delete(t),null;try{const e=le(f.args.schema||[],f.args.rows||[],f.args.opts||{});return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ue(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ee(l.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:ne.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(l.cancelled?.has(t))return l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,l={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:l.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(l.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Ye=Gn("packages/dom/src/index.js"),Qi=Ye.createGrid,Ji=Ye.gridElementsWithin,eo=Ye.createStat,to=Ye.deltaOf,no=Ye.toneOf,ro=Ye.readTable,io=Ye.hydrateTable,oo=Ye.autoInit,so=Ye.createLocalViewStorage,ao=Ye.DEFAULT_VIEWS_KEY,lo=Ye.createHeadlessGrid,uo=Ye.defaults,co=Ye.version,fo=Ye.getVersion,ho=Ye.Grid,po=Ye.EventBus,mo=Ye.Registry,go=Ye.sharedRegistry,yo=Ye.registerModules,bo=Ye.parseLicence,wo=Ye.verifyLicence,vo=Ye.licenceInfo,ko=Ye.watermark,So=Ye.setLicence,Oo=Ye.licenceState,Ao=Ye.isLocalHost,jo=Ye.matchesDomain,Po=Ye.LicenceHolder,Co=Ye.ColumnModel,Eo=Ye.buildGraph,To=Ye.Lookup,Mo=Ye.ValuePipeline,No=Ye.compileFormat,Ro=Ye.compileMask,Lo=Ye.specToOoxml,Fo=Ye.EXTENDED_TYPES,xo=Ye.createRadixType,$o=Ye.RADIX_PRESETS,Io=Ye.parseRadix,Do=Ye.formatRadix,zo=Ye.createUnitType,Bo=Ye.registerUnitSystem,Uo=Ye.defineUnit,Vo=Ye.UNIT_SYSTEMS,Ho=Ye.parseUnit,Go=Ye.formatUnit,Ko=Ye.createCurrencyType,Wo=Ye.parseMoney,_o=Ye.formatMoney,qo=Ye.convertMoney,Zo=Ye.rateFunction,Yo=Ye.MISSING_RATE,Xo=Ye.Messages,Qo=Ye.createMessages,Jo=Ye.auditCatalogue,es=Ye.EN_GB,ts=Ye.MESSAGE_KEYS,ns=Ye.DEFAULT_LOCALE,rs=Ye.formatList,is=Ye.resolveLocale,os=Ye.LOCALES,ss=Ye.resolveCatalogue,as=Ye.EN_US,ls=Ye.FR_FR,us=Ye.FR_CA,cs=Ye.IT_IT,ds=Ye.ES_ES,fs=Ye.PT_BR,hs=Ye.DE_DE,ps=Ye.NL_NL,ms=Ye.SV_SE,gs=Ye.DA_DK,ys=Ye.NB_NO,bs=Ye.FI_FI,ws=Ye.PL_PL,vs=Ye.CS_CZ,ks=Ye.HU_HU,Ss=Ye.RO_RO,Os=Ye.UK_UA,As=Ye.EL_GR,js=Ye.JA_JP,Ps=Ye.AR,Cs=Ye.AR_SA,Es=Ye.ColumnStore,Ts=Ye.Bitset,Ms=Ye.Dictionary,Ns=Ye.MultiValue,Rs=Ye.MaskPool,Ls=Ye.sortColumn,Fs=Ye.sortMulti,xs=Ye.evaluateFilters,$s=Ye.compact,Is=Ye.testValue,Ds=Ye.groupByColumns,zs=Ye.total,Bs=Ye.TOTAL_FNS,Us=Ye.pivot,Vs=Ye.Window,Hs=Ye.openWindow,Gs=Ye.WINDOW_KINDS,Ks=Ye.ANOMALY_METHODS,Ws=Ye.modifiedZScores,_s=Ye.iqrFences,qs=Ye.mahalanobis,Zs=Ye.ROLLING_ANOMALY_METHODS,Ys=Ye.rollingAnomalies,Xs=Ye.anomalyCondition,Qs=Ye.FORECAST_METHODS,Js=Ye.forecast,ea=Ye.evaluateFormula,ta=Ye.parseFormula,na=Ye.referencesOf,ra=Ye.looksLikeFormula,ia=Ye.FormulaError,oa=Ye.FUNCTIONS,sa=Ye.compileRules,aa=Ye.ingest,la=Ye.ingestSync,ua=Ye.createSource,ca=Ye.createMemorySource,da=Ye.createPagedSource,fa=Ye.createRemoteSource,ha=Ye.createStreamSource,pa=Ye.createUrlSource,ma=Ye.PROTOCOL,ga=Ye.createPushdownSource,ya=Ye.planQuery,ba=Ye.splitFilters,wa=Ye.applyResidual,va=Ye.capabilitiesOf,ka=Ye.resolveMutate,Sa=Ye.NO_CAPABILITIES,Oa=Ye.odataAdapter,Aa=Ye.filtersToOData,ja=Ye.conditionToOData,Pa=Ye.restAdapter,Ca=Ye.DEFAULT_PARAMS,Ea=Ye.dfqlAdapter,Ta=Ye.duckdbAdapter,Ma=Ye.filtersToSql,Na=Ye.graphqlAdapter,Ra=Ye.splunkAdapter,La=Ye.clickhouseAdapter,Fa=Ye.elasticsearchAdapter,xa=Ye.RowModel,$a=Ye.createRowKey,Ia=Ye.SelectionModel,Da=Ye.RangeModel,za=Ye.EditModel,Ba=Ye.ChangeModel,Ua=Ye.StateModel,Va=Ye.STATE_VERSION,Ha=Ye.serialiseState,Ga=Ye.restoreState,Ka=Ye.VERSION,Wa=Ye.DomRenderer,_a=Ye.FilterMenu,qa=Ye.mergeColumnFilter,Za=Ye.branchFor,Ya=Ye.ColumnMenu,Xa=Ye.columnMenuItems,Qa=Ye.cellMenuItems,Ja=Ye.autoGroupMenuItems,el=Ye.AlignedGrids,tl=Ye.alignGrids,nl=Ye.layoutState,rl=Ye.ToolPanelDock,il=Ye.panelHost,ol=Ye.mountPanel,sl=Ye.CellEditController,al=Ye.EditBar,ll=Ye.HistoryBar,ul=Ye.HISTORY_CLS,cl=Ye.DiffPainter,dl=Ye.ViewPicker,fl=Ye.VIEW_CLS,hl=Ye.summariseDiff,pl=Ye.PromptBar,ml=Ye.PROMPT_CLASS,gl=Ye.createCellLayer,yl=Ye.compileTemplate,bl=Ye.compileVariant,wl=Ye.checkVariant,vl=Ye.VariantRegistry,kl=Ye.BUILTIN_RENDERERS,Sl=Ye.BUILTIN_VARIANTS,Ol=Ye.BUILTIN_PIPES,Al=Ye.sanitiseHtml,jl=Ye.editors,Pl=Ye.createEditor,Cl=Ye.editorFor,El=Ye.BaseEditor,Tl=Ye.filters,Ml=Ye.createFilter,Nl=Ye.filterFor,Rl=Ye.parseExpression,Ll=Ye.ConditionFilter,Fl=Ye.StatusBar,xl=Ye.ContextMenu,$l=Ye.ToolPanel,Il=Ye.TooltipManager,Dl=Ye.Pagination,zl=Ye.OverlayLayer,Bl=Ye.LatticeGrid,Ul=Ye.setLicense,Vl=Ye.licenseInfo,Hl=Ye.licenseState;var Gl=Ye.default;export{Ks as ANOMALY_METHODS,Ps as AR,Cs as AR_SA,el as AlignedGrids,Ol as BUILTIN_PIPES,kl as BUILTIN_RENDERERS,Sl as BUILTIN_VARIANTS,El as BaseEditor,Ts as Bitset,vs as CS_CZ,sl as CellEditController,Ba as ChangeModel,Ya as ColumnMenu,Co as ColumnModel,Es as ColumnStore,Ll as ConditionFilter,xl as ContextMenu,gs as DA_DK,ns as DEFAULT_LOCALE,Ca as DEFAULT_PARAMS,ao as DEFAULT_VIEWS_KEY,hs as DE_DE,Ms as Dictionary,cl as DiffPainter,Wa as DomRenderer,As as EL_GR,es as EN_GB,as as EN_US,ds as ES_ES,Fo as EXTENDED_TYPES,al as EditBar,za as EditModel,po as EventBus,bs as FI_FI,Qs as FORECAST_METHODS,us as FR_CA,ls as FR_FR,oa as FUNCTIONS,_a as FilterMenu,ia as FormulaError,ho as Grid,ul as HISTORY_CLS,ks as HU_HU,ll as HistoryBar,cs as IT_IT,js as JA_JP,os as LOCALES,Bl as LatticeGrid,Po as LicenceHolder,To as Lookup,ts as MESSAGE_KEYS,Yo as MISSING_RATE,Rs as MaskPool,Xo as Messages,Ns as MultiValue,ys as NB_NO,ps as NL_NL,Sa as NO_CAPABILITIES,zl as OverlayLayer,ws as PL_PL,ml as PROMPT_CLASS,ma as PROTOCOL,fs as PT_BR,Dl as Pagination,pl as PromptBar,$o as RADIX_PRESETS,Zs as ROLLING_ANOMALY_METHODS,Ss as RO_RO,Da as RangeModel,mo as Registry,xa as RowModel,Va as STATE_VERSION,ms as SV_SE,Ia as SelectionModel,Ua as StateModel,Fl as StatusBar,Bs as TOTAL_FNS,$l as ToolPanel,rl as ToolPanelDock,Il as TooltipManager,Os as UK_UA,Vo as UNIT_SYSTEMS,Ka as VERSION,fl as VIEW_CLS,Mo as ValuePipeline,vl as VariantRegistry,dl as ViewPicker,Gs as WINDOW_KINDS,Vs as Window,tl as alignGrids,Xs as anomalyCondition,wa as applyResidual,Jo as auditCatalogue,Ja as autoGroupMenuItems,oo as autoInit,Za as branchFor,Eo as buildGraph,va as capabilitiesOf,Qa as cellMenuItems,wl as checkVariant,La as clickhouseAdapter,Xa as columnMenuItems,$s as compact,No as compileFormat,Ro as compileMask,sa as compileRules,yl as compileTemplate,bl as compileVariant,ja as conditionToOData,qo as convertMoney,gl as createCellLayer,Ko as createCurrencyType,Pl as createEditor,Ml as createFilter,Qi as createGrid,lo as createHeadlessGrid,so as createLocalViewStorage,ca as createMemorySource,Qo as createMessages,da as createPagedSource,ga as createPushdownSource,xo as createRadixType,fa as createRemoteSource,$a as createRowKey,ua as createSource,eo as createStat,ha as createStreamSource,zo as createUnitType,pa as createUrlSource,Gl as default,uo as defaults,Uo as defineUnit,to as deltaOf,Ea as dfqlAdapter,Ta as duckdbAdapter,Cl as editorFor,jl as editors,Fa as elasticsearchAdapter,xs as evaluateFilters,ea as evaluateFormula,Nl as filterFor,Tl as filters,Aa as filtersToOData,Ma as filtersToSql,Js as forecast,rs as formatList,_o as formatMoney,Do as formatRadix,Go as formatUnit,fo as getVersion,Na as graphqlAdapter,Ji as gridElementsWithin,Ds as groupByColumns,io as hydrateTable,aa as ingest,la as ingestSync,_s as iqrFences,Ao as isLocalHost,nl as layoutState,vo as licenceInfo,Oo as licenceState,Vl as licenseInfo,Hl as licenseState,ra as looksLikeFormula,qs as mahalanobis,jo as matchesDomain,qa as mergeColumnFilter,Ws as modifiedZScores,ol as mountPanel,Oa as odataAdapter,Hs as openWindow,il as panelHost,Rl as parseExpression,ta as parseFormula,bo as parseLicence,Wo as parseMoney,Io as parseRadix,Ho as parseUnit,Us as pivot,ya as planQuery,Zo as rateFunction,ro as readTable,na as referencesOf,yo as registerModules,Bo as registerUnitSystem,ss as resolveCatalogue,is as resolveLocale,ka as resolveMutate,Pa as restAdapter,Ga as restoreState,Ys as rollingAnomalies,Al as sanitiseHtml,Ha as serialiseState,So as setLicence,Ul as setLicense,go as sharedRegistry,Ls as sortColumn,Fs as sortMulti,Lo as specToOoxml,ba as splitFilters,Ra as splunkAdapter,hl as summariseDiff,Is as testValue,no as toneOf,zs as total,wo as verifyLicence,co as version,ko as watermark};
57
+ `)||(i.preventDefault(),this.fromText(g))})))}openFile(){const l=O(this.#n,"input",{attrs:{type:"file",accept:r}});l.style.display="none",this.#o.push(u(l,"change",()=>{const i=l.files&&l.files[0];i&&this.#c(i),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(L(l.arrayBuffer)){l.arrayBuffer().then(g=>{const c=new Uint8Array(g);if(z(c)){this.fromXlsx(c,l.name);return}this.fromText(new TextDecoder().decode(c),l.name)});return}if(L(l.text)){l.text().then(g=>this.fromText(g,l.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),l.name),i.readAsText(l)}async fromXlsx(l,i){const{header:g,rows:c}=await U(l);if(!g.length)return;const h=G(g,c,{columns:this.#e.columns.all()}),a=c.filter(m=>m.length!==g.length).length;this.#l={rows:c,columns:h,delimiter:null,name:i,warnings:a?[`${a} row(s) do not have ${g.length} columns`]:[]},this.#d()}fromText(l,i){const{header:g,rows:c,delimiter:h}=Q(l);if(!g.length)return;const a=G(g,c,{columns:this.#e.columns.all()}),m=c.filter(w=>w.length!==g.length).length;this.#l={rows:c,columns:a,delimiter:h,name:i,warnings:m?[`${m} row(s) do not have ${g.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(t);l&&L(l.focus)&&l.focus(),this.#f(this.#h("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#f(l,i){const g=this.#t&&this.#t.announce;L(g)&&g.call(this.#t,l,i)}#h(l,i){return(this.#e&&this.#e.messages?this.#e.messages:F).t(l,i)}#p(){const l=this.#n,i=O(l,"div",{class:n,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#h("import.title"),hidden:!0}}),g=O(l,"div",{class:`${n}__panel`});g.appendChild(O(l,"h2",{class:`${n}__title`,text:this.#h("import.title")})),this.#s=O(l,"div",{class:`${n}__body`}),g.appendChild(this.#s);const c=O(l,"div",{class:`${n}__footer`}),h=O(l,"button",{class:`${n}__cancel`,text:this.#h("import.cancel"),attrs:{type:"button"}}),a=O(l,"button",{class:`${n}__confirm`,text:this.#h("import.confirm"),attrs:{type:"button"}});this.#o.push(u(h,"click",()=>this.close())),this.#o.push(u(a,"click",()=>this.#g())),c.appendChild(h),c.appendChild(a),g.appendChild(c),i.appendChild(g),this.#o.push(u(i,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...i.querySelectorAll(t)].filter(C=>!C.hidden);if(!v.length)return;const p=v[0],y=v[v.length-1];w.shiftKey&&this.#n.activeElement===p?(w.preventDefault(),y.focus()):!w.shiftKey&&this.#n.activeElement===y&&(w.preventDefault(),p.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const l=this.#n,i=b(this.#s),{rows:g,columns:c,name:h,warnings:a}=this.#l;i.appendChild(O(l,"p",{class:`${n}__summary`,text:this.#h("import.summary",{count:g.length,name:h||this.#h("import.clipboard")})}));for(const C of a)i.appendChild(O(l,"p",{class:`${n}__warning`,text:C}));const m=this.#e.columns.all().map(C=>C.field||C.id).filter(Boolean),w=O(l,"table",{class:`${n}__map`}),v=O(l,"tr",{});for(const C of["import.colSource","import.colField","import.colType"])v.appendChild(O(l,"th",{text:this.#h(C)}));w.appendChild(v),c.forEach((C,T)=>{const P=O(l,"tr",{});P.appendChild(O(l,"td",{text:C.source}));const x=O(l,"select",{attrs:{"data-col":String(T),"aria-label":this.#h("import.mapLabel",{source:C.source})}});x.appendChild(O(l,"option",{text:this.#h("import.skip"),attrs:{value:""}}));for(const j of m)x.appendChild(O(l,"option",{text:j,attrs:{value:j,selected:j===C.field?!0:null}}));C.field&&!m.includes(C.field)&&x.appendChild(O(l,"option",{text:C.field,attrs:{value:C.field,selected:!0}}));const E=O(l,"td",{});E.appendChild(x),P.appendChild(E),P.appendChild(O(l,"td",{class:`${n}__type`,text:C.type})),w.appendChild(P)}),i.appendChild(w);const p=O(l,"div",{class:`${n}__mode`}),y=O(l,"select",{attrs:{"aria-label":this.#h("import.modeLabel"),"data-mode":"mode"}});y.appendChild(O(l,"option",{text:this.#h("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(O(l,"option",{text:this.#h("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),p.appendChild(O(l,"label",{text:this.#h("import.modeLabel")})),p.appendChild(y),i.appendChild(p)}#g(){const{rows:l,columns:i}=this.#l;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));i[w]&&m.value!==void 0&&m.value!==null&&(i[w].field=m.value)}const g=this.#i.querySelector("select[data-mode]"),c=g?g.value:void 0,h=c==="replace"||c==="append"?c:this.#r.mode,a=H(l,i);this.#e.import.apply(a,{mode:h}),this.close(),this.#f(this.#h("import.done",{count:a.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&L(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),xe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),Q=_.el,G=_.on,H=_.clear,U=_.documentFor,z="lat-history";class S{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,d){return(this.messages&&typeof this.messages.t=="function"?this.messages:F).t(u,d)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||F;const d=u||{};if(this.doc=U(d),this.host=d.host||{},this.props=d.props||{},this.root=Q(this.doc,"div",{class:["lattice-tokens",z],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const s=Q(this.doc,"button",{class:`${z}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(G(s,"click",()=>this.toggle())),this.root.appendChild(s),this.toggleButton=s,this.menu=Q(this.doc,"div",{class:`${z}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,d,s){const n=Q(this.doc,"button",{class:`${z}__${u}`,attrs:{type:"button"},children:[Q(this.doc,"span",{class:`${z}__glyph`,text:s,attrs:{"aria-hidden":"true"}}),Q(this.doc,"span",{class:`${z}__label`,text:d})]});return this.off.push(G(n,"click",()=>{const t=this.host[u];L(t)&&t(),this.refresh()})),n}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,d=L(u.canUndo)?u.canUndo():!1,s=L(u.canRedo)?u.canRedo():!1,n=L(u.peek)?u.peek("undo"):null,t=L(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",d,n),this.#t(this.redoButton,"redo",s,t),this.open&&this.#n()}#t(u,d,s,n){if(!u)return;u.disabled=!s;const t=d==="undo",r=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${z}__label`);o&&(o.textContent=r);const f=n&&n.label?this.t("history.described",{action:r,label:n.label}):r;u.setAttribute("title",s?f:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",s?f:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;H(u);const d=L(this.host.list)?this.host.list():[];if(!d.length){u.appendChild(Q(this.doc,"p",{class:`${z}__empty`,text:this.t("history.empty")}));return}d.forEach((s,n)=>{const t=Q(this.doc,"button",{class:`${z}__item`,attrs:{type:"button",role:"menuitem","data-type":s.type,"data-undone":s.undone?"true":null},children:[Q(this.doc,"span",{class:`${z}__kind`,text:s.type}),Q(this.doc,"span",{class:`${z}__text`,text:s.label||s.type})]});this.off.push(G(t,"click",()=>{const r=n+1;for(let o=0;o<r;o++)L(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&L(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const O=S}),xe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,Q={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},G="lat-cell--changed",H="lat-cell--added-column";class U{#e;#t;#n=[];constructor(b){this.#e=b.grid,this.#t=b.renderer}mount(){for(const b of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(b,()=>this.paint()));this.paint()}paint(){const b=this.#t.viewport.root;if(!b||!b.querySelectorAll)return;const u=this.#e.diff,d=u&&u.enabled;for(const s of b.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key"),t=d?u.statusOf(n):"unchanged";for(const o of Object.values(Q))s.classList.remove(o);d&&Q[t]&&s.classList.add(Q[t]),s.setAttribute("data-diff",d?t:"");const r=d&&t==="changed";for(const o of s.querySelectorAll("[data-col]")){const f=o.getAttribute("data-col");if(o.classList.remove(G,H),o.removeAttribute("data-before"),!r)continue;const l=u.cellStatus(n,f);if(l==="changed"){o.classList.add(G);const i=this.#r(u,n,f);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else l==="added-column"&&o.classList.add(H)}}}#r(b,u,d){const s=this.#e,n=s&&s.columns,t=n&&L(n.get)?n.get(d):null,r=s&&s.permissions;if(t&&r&&L(r.isSecret)&&r.isSecret(t))return null;const o=b.before(u,d);if(o==null)return this.#o("diff.empty");if(!t||!L(t.formatValue))return String(o);const f=L(b.beforeRow)?b.beforeRow(u):void 0,i={...(s.rows&&L(s.rows.byKey)?s.rows.byKey(u):null)||{},data:f===void 0?{}:f};try{const g=t.formatValue(o,i,i.data);return g==null?"":String(g)}catch(g){return B(`diff-before-format:${d}`,`the formatter for column "${d}" threw while formatting a previous value, so the diff hover shows the raw one.`,g),String(o)}}#o(b,u){const d=this.#e;return(d&&d.messages?d.messages:_).t(b,u)}destroy(){for(const u of this.#n)u();this.#n=[];const b=this.#t.viewport.root;if(!(!b||!b.querySelectorAll)){for(const u of b.querySelectorAll("[data-key]")){for(const d of Object.values(Q))u.classList.remove(d);u.removeAttribute("data-diff")}for(const u of b.querySelectorAll("[data-col]"))u.classList.remove(G,H),u.removeAttribute("data-before")}}}function z(O){return!!(O&&O.diff&&(L(O.diff)||typeof O.diff=="object"))}const S=U}),xe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--highlight",F="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const H=()=>{this.#o=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):L(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#l();if(U){U.sweep();for(const z of H.querySelectorAll("[data-key]")){const S=z.getAttribute("data-key");for(const O of z.querySelectorAll("[data-col]")){const b=U.active?U.colourFor(S,O.getAttribute("data-col")):null;b?(O.classList.add(B),O.style.setProperty(F,b)):O.classList.contains(B)&&(O.classList.remove(B),O.style.removeProperty(F))}}this.#s(U)}}#s(H){this.#r!==null&&L(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const U=H.nextExpiry;if(!Number.isFinite(U)||!L(this.#i.setTimeout))return;const z=Math.max(0,U-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},z)}#l(){const H=this.#e.highlight;return H&&L(H.model)?H.model():null}destroy(){this.#r!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B),U.style.removeProperty(F)}}const Q=_}),xe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isFunction,B="lat-cell--find",F="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(H){this.#e=H.grid,this.#t=H.renderer,this.#i=H.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const H=()=>{this.#r=!1,this.paint()};L(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(H):L(this.#i.setTimeout)?this.#i.setTimeout(H,0):H()}paint(){const H=this.#t.viewport?.root;if(!H||!H.querySelectorAll)return;const U=this.#e.find;if(!U||!L(U.stateFor))return;const z=L(U.model)?U.model():null,S=!!z&&z.active;if(!S&&!this.#o)return;let O=!1;for(const b of H.querySelectorAll("[data-key]")){const u=b.getAttribute("data-key");for(const d of b.querySelectorAll("[data-col]")){const s=S?U.stateFor(u,d.getAttribute("data-col")):null;s?(O=!0,d.classList.add(B),d.classList.toggle(F,s==="current")):d.classList.contains(B)&&d.classList.remove(B,F)}}this.#o=O}destroy(){for(const U of this.#n)U();this.#n=[];const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll)){for(const U of H.querySelectorAll(`.${B}`))U.classList.remove(B,F);this.#o=!1}}}const Q=_}),xe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const X=K("packages/dom/src/editors/common.js"),L=X.el,B=X.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z="lat-find",S=12,O=120;class b{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=!1;#p=!1;#m=null;#g=[];#y=null;#w=null;#k=!1;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#n=s.document||s.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=s.settings&&typeof s.settings=="object"?s.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(s,n){const t=this.#e;return(t&&t.messages&&U(t.messages.t)?t.messages:G).t(s,n)}mount(){const s=this.#O();if(!s)return;s.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),s.attachDriver({run:()=>this.#E()});const n=this.#t.viewport?.root;if(n&&U(n.addEventListener)&&this.#o.shortcut!==!1){const t=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey||r.shiftKey||r.key!=="f"&&r.key!=="F")return;const o=r.target;if(this.#s&&o===this.#s){r.preventDefault(),r.stopPropagation(),U(this.#s.select)&&this.#s.select();return}_(o)||(r.preventDefault(),r.stopPropagation(),this.show())};n.addEventListener("keydown",t,!0),this.#g.push(()=>n.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#L())),this.#g.push(this.#e.on("columns:changed",()=>this.#P())),this.#g.push(this.#e.on("column:visible",()=>this.#P()))}show(s){const n=this.#A();if(!n)return;const t=n.style.display!=="none";n.style.display="",t||this.#b(),this.#O().setOpen(!0),s!=null&&(this.#s.value=String(s),this.#M()),this.#s.focus(),U(this.#s.select)&&this.#s.select(),this.#L()}hide(){this.#z();const s=this.#O();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#b()),s&&(s.clear(),s.setOpen(!1));const n=this.#t.viewport?.root;if(!n||!(this.#i&&this.#n&&this.#n.activeElement&&U(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(U(n.querySelector)?n.querySelector('[tabindex="0"]'):null)||n;U(o.focus)&&o.focus()}search(){this.#M()}destroy(){this.#k=!0,this.#z();for(const n of this.#g)n();this.#g=[];const s=this.#O();s&&(s.attachUi(null),s.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#b(){const s=this.#t;s&&U(s.invalidate)&&s.invalidate("size")}#O(){const s=this.#e&&this.#e.find;return s&&U(s.model)?s.model():null}#A(){if(this.#i)return this.#i;const s=this.#t.viewport,n=s?.root,t=this.#n;if(!n||!t||!U(n.insertBefore))return null;const r=L(t,"div",{class:z,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=L(t,"input",{class:`${z}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=L(t,"span",{class:`${z}__count`,attrs:{"aria-hidden":"true"}}),this.#a=L(t,"span",{class:`${z}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=L(t,"span",{class:`${z}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=L(t,"button",{class:`${z}__nav ${z}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),f=L(t,"button",{class:`${z}__nav ${z}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=L(t,"button",{class:`${z}__toggle ${z}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=L(t,"button",{class:`${z}__toggle ${z}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#f=L(t,"select",{class:`${z}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=L(t,"button",{class:`${z}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=L(t,"div",{class:`${z}__options`,children:[this.#c,this.#d,this.#f]});for(const c of[this.#s,this.#l,this.#a,this.#u,o,f,l,i])r.appendChild(c);this.#g.push(B(this.#s,"input",()=>this.#S())),this.#g.push(B(o,"click",()=>this.#e.find.prev())),this.#g.push(B(f,"click",()=>this.#e.find.next())),this.#g.push(B(this.#c,"click",()=>{this.#h=!this.#h,this.#c.setAttribute("aria-pressed",String(this.#h)),this.#M()})),this.#g.push(B(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#M()})),this.#g.push(B(this.#f,"change",()=>{const c=this.#f.value;this.#m=c?String(c):null,this.#M()})),this.#g.push(B(l,"click",()=>this.hide()));const g=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#y!==null&&(this.#x(),this.#M()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return r.addEventListener("keydown",g),this.#g.push(()=>r.removeEventListener("keydown",g)),r.style.display="none",n.insertBefore(r,s.header||n.firstChild),this.#i=r,this.#P(),r}#P(){const s=this.#f;if(!s)return;const n=this.#n;for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(L(n,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,r=t&&U(t.visible)?t.visible():[];let o=!1;for(const f of r){if(!f||f.id===void 0)continue;const l=String(f.id);s.appendChild(L(n,"option",{text:f.title||l,attrs:{value:l}})),l===this.#m&&(o=!0)}o||(this.#m=null),s.value=this.#m||""}#S(){const s=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):O;if(this.#x(),s===0||!U(this.#r.setTimeout)){this.#M();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#M()},s)}#M(){const s=this.#O();if(!s||this.#k)return;const n=this.#s?this.#s.value:"";if(!n){this.#I(),s.clear();return}s.begin(n,{caseSensitive:this.#h,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#j()}),this.#E()}#j(){const s=this.#t&&this.#t.window,n=s&&Number.isFinite(s.first)?s.first:0;return Math.max(0,n)}#E(){if(this.#w!==null||this.#k)return;const s=()=>{this.#w=null,this.#R()};U(this.#r.requestAnimationFrame)?this.#w=this.#r.requestAnimationFrame(s):U(this.#r.setTimeout)?this.#w=this.#r.setTimeout(s,0):s()}#R(){const s=this.#O();!s||this.#k||!s.active||(s.stale&&s.rescan({from:this.#j()}),!s.complete&&(s.step(S)||this.#E()))}#L(){if(!this.#i||this.#k)return;const s=this.#e.find.count(),n=this.#O().active;let t="",r="idle";n&&(s.total===0?(t=s.complete?this.t("find.none"):this.t("find.searching"),r=s.complete?"none":"searching"):(t=this.t(s.complete?"find.count":"find.countPartial",{current:s.current,total:s.total}),r=s.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",r);const o=n&&s.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",n?s.complete&&(this.#u.textContent=s.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:s.current,count:s.total})):this.#u.textContent=""}#x(){this.#y!==null&&U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#I(){this.#w!==null&&(U(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#w):U(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null)}#z(){this.#x(),this.#I()}}const u=b}),xe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const X="lat-cell--redacted",L="lat-cell";class B{#e;#t;#n=[];constructor(Q){this.#e=Q.grid,this.#t=Q.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Q=this.#t.viewport?.root;if(!Q||!Q.querySelectorAll)return;const G=this.#e.redaction;if(!G)return;const H=G.active;for(const U of Q.querySelectorAll(`.${L}[data-col]`))H&&G.has(U.getAttribute("data-col"))?U.classList.add(X):U.classList.contains(X)&&U.classList.remove(X)}destroy(){for(const Q of this.#n)Q();this.#n=[]}}const F=B}),xe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Q}});const L=K("packages/dom/src/editors/common.js").markInvalid,B="lat-cell";function F(G,H){let U=G;for(;U;){if(H(U))return U;U=U.parentNode}return null}class _{#e;#t;#n=[];constructor(H){this.#e=H.grid,this.#t=H.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const H of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(H,()=>this.paint()));this.paint()}#r(H){const U=F(H,z=>z.getAttribute&&z.getAttribute("data-key")!==null);return U?U.getAttribute("data-key"):null}paint(){const H=this.#e.validation;if(!H||!H.active)return;const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${B}[data-col]`)){const S=z.getAttribute("data-col"),O=this.#r(z),b=O?H.errorFor(O,S):null;L(z,b?b.message:null)}}destroy(){for(const H of this.#n)H();this.#n=[]}}const Q=_}),xe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/dom/src/renderer/textentry.js").isTextEntry,Q=K("packages/dom/src/renderer/viewport.js").CLASS,G="lat-presenting",H="lat-presenting--changing",U="lat-presenting__progress",z="lat-cell--dimmed",S=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class O{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#h())),this.#r.push(this.#e.on("presentation:scale",()=>this.#h())),this.#r.push(this.#e.on("presentation:ended",()=>this.#f())),this.#r.push(this.#e.on("presentation:view",s=>this.#a(s))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&L(this.#n.watch)&&this.#r.push(this.#n.watch(s=>{s||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const d=this.#t.viewport?.root;if(d&&L(d.addEventListener)){const s=n=>this.#l(n);d.addEventListener("keydown",s),this.#r.push(()=>d.removeEventListener("keydown",s))}}#l(d){const s=this.#e.presentation;if(!s?.active)return;const n=d.ctrlKey||d.metaKey,t=d.key;if(t==="Escape"&&!this.#n){d.defaultPrevented||(s.stop(),d.preventDefault?.());return}if(n){t==="="||t==="+"?(s.nudge(1),d.preventDefault?.()):t==="-"||t==="_"?(s.nudge(-1),d.preventDefault?.()):t==="0"&&(s.setScale(1.5),d.preventDefault?.());return}if(!s.views.length||F(d.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(s.step(1),d.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(s.step(-1),d.preventDefault?.()):t==="Home"?(s.goTo(0),d.preventDefault?.()):t==="End"?(s.goTo(s.views.length-1),d.preventDefault?.()):(t==="r"||t==="R")&&(s.reset(),d.preventDefault?.())}#a(d){!d||!d.viewId||(this.#u(),this.#e.views?.apply?.(d.viewId),this.#c(d))}#u(){const d=this.#t.viewport?.root;d?.classList&&(d.classList.remove(H),d.offsetWidth,d.classList.add(H))}#c(d){const s=this.#t.viewport?.overlays;if(!s||!this.#e.presentation.views.length)return;const n=s.ownerDocument;if(!n?.createElement)return;if(!this.#i){const o=n.createElement("div");o.className=U,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),s.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(d.viewId),r=t&&t.name?t.name:"";this.#i.textContent=r?`${r} · ${(d.index||0)+1} / ${d.count||0}`:`${(d.index||0)+1} / ${d.count||0}`}#d(){if(this.#o){this.#h();return}const d=!!(this.#n&&this.#n.active());this.#n&&!d&&this.#n.enter();const s=new Set(this.#e.presentation?.options?.chrome||[]),n=[];for(const r of S){if(s.has(r)||r==="toolPanel"&&this.#k())continue;const o=this.#b(r);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",n.push(o))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#w(t)&&(t.style.display="none",n.push(t)),this.#o={maximised:d,hidden:n},this.#t.viewport?.root?.classList?.add(G),this.#h(),this.#m()}#f(){const d=this.#o;this.#o=null;const s=this.#t.viewport?.root;if(s?.classList?.remove(G),s?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),s?.classList?.remove(H),this.#p(),d){const n=this.#e.toolPanel;n&&L(n.presentRestore)&&n.presentRestore();for(const t of d.hidden)t.style.display="";this.#n&&!d.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#h(){const d=this.#t.viewport?.root;!d||!d.style||(d.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const d=this.#t.viewport?.root;if(!d?.querySelectorAll)return;const s=this.#e.presentation?.active?this.#e.presentation.spotlight:null,n=s&&s.keys.length?new Set(s.keys):null,t=s&&s.colIds.length?new Set(s.colIds):null;for(const r of d.querySelectorAll("[data-key]")){const o=!n||n.has(r.getAttribute("data-key"));for(const f of r.querySelectorAll("[data-col]"))!s||o&&(!t||t.has(f.getAttribute("data-col")))?f.classList.remove(z):f.classList.add(z)}}#m(){this.#g();const d=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(d)||d<=0||!this.#e.presentation.views.length)return;const s=this.#t.viewport?.root?.ownerDocument?.defaultView;s?.setInterval&&(this.#s=s.setInterval(()=>{const n=this.#e.presentation;n.active&&n.goTo(n.index>=n.views.length-1?0:n.index+1)},Math.max(1e3,d)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const d=this.#e.element;return!d||!L(d.querySelector)?null:d.querySelector(`.${Q.statusBar}`)}#w(d){const s=d.children||[];for(const n of s)if(!n.style||n.style.display!=="none")return!1;return!0}#k(){const d=this.#e.toolPanel;return!!(d&&L(d.presentOnly)&&d.presentOnly())}#b(d){const s=this.#e.element;if(!s||!L(s.querySelector))return null;const n={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[d];return n?s.querySelector(n):null}destroy(){this.#o&&this.#f();for(const d of this.#r)d();this.#r=[]}}const b=O}),xe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const L=K("packages/core/src/internal/util.js").isFunction,B=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function F(U,z,S){const O=S.getComputedStyle(U),b=z.style;if(b)for(let u=0;u<O.length;u++){const d=O[u];B.has(d)||b.setProperty(d,O.getPropertyValue(d),O.getPropertyPriority(d))}}function _(U,z,S){if(F(U,z,S),U.tagName==="CANVAS"&&L(U.toDataURL))try{const u=U.toDataURL("image/png"),d=z.style;d&&(d.setProperty("background-image",`url(${u})`),d.setProperty("background-size","100% 100%"),d.setProperty("background-repeat","no-repeat"))}catch{}const O=U.children||[],b=z.children||[];for(let u=0;u<O.length&&u<b.length;u++)_(O[u],b[u],S)}function Q(U,z){if(!U||U.startsWith("data:")||U.startsWith("blob:"))return!0;try{return new URL(U,z).origin===z}catch{return!0}}async function G(U,z={}){const S=U.ownerDocument,O=S?.defaultView;if(!O||typeof O.getComputedStyle!="function")throw new Error("capture needs a browser document");const b=U.getBoundingClientRect(),u=Math.max(1,Math.ceil(b.width)),d=Math.max(1,Math.ceil(b.height)),s=Math.max(.1,Number(z.scale)||2),n=O.location?.origin||"";for(const g of U.querySelectorAll("img")){const c=g.getAttribute("src")||"";if(!Q(c,n))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=U.cloneNode(!0);_(U,t,O),t.style.width=`${u}px`,t.style.height=`${d}px`,t.style.margin="0";const r=new O.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${d}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${r}</div></foreignObject></svg>`,f=new O.Image;await new Promise((g,c)=>{f.onload=()=>g(void 0),f.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),f.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const l=S.createElement("canvas");l.width=Math.round(u*s),l.height=Math.round(d*s);const i=l.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=z.background||O.getComputedStyle(U).backgroundColor||"#ffffff",i.fillRect(0,0,l.width,l.height),i.drawImage(f,0,0,l.width,l.height),new Promise((g,c)=>{l.toBlob(h=>h?g({blob:h,width:l.width,height:l.height}):c(new Error("capture produced no image")),z.type||"image/png",z.quality)})}const H=G}),xe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.uid,F=X.warnOnce,Q=K("packages/dom/src/renderer/direction.js").signedX,G=Object.freeze(["pen","arrow","rect","highlight","erase"]),H=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),z=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),S=14,O="system-ui, -apple-system, sans-serif";function b(h,a){if(!h||typeof h!="object")return null;const m=U[h.type];if(!m)return null;const w=typeof h.id=="string"&&h.id?h.id:B("mark"),v=Array.isArray(h.points)?h.points:[],p=[];for(const C of v){const T=Number(C&&C.x),P=Number(C&&C.y);Number.isFinite(T)&&Number.isFinite(P)&&p.push({x:T,y:P})}const y=typeof h.colour=="string"&&h.colour?h.colour:a;if(m==="text"){const C=typeof h.text=="string"?h.text:"";if(!p.length||!C)return null;const T={id:w,tool:m,colour:y,points:[p[0]],text:C,region:u(h.region)},P=Number(h.fontSize);return Number.isFinite(P)&&P>0&&(T.fontSize=P),typeof h.background=="string"&&h.background&&(T.background=h.background),T}return p.length<2?null:{id:w,tool:m,colour:y,points:p,region:u(h.region)}}function u(h){return h==="start"||h==="end"?h:"centre"}function d(h){const a={id:h.id,type:z[h.tool]||h.tool,colour:h.colour,points:h.points.map(m=>({x:m.x,y:m.y}))};return(h.region==="start"||h.region==="end")&&(a.region=h.region),h.tool==="text"&&(a.text=h.text,h.fontSize!==void 0&&(a.fontSize=h.fontSize),h.background!==void 0&&(a.background=h.background)),a}const s="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(h){return h==="arrow"||h==="rect"}function r(h,a){return{id:h,count:a,valueOf(){return this.count}}}const o=10;function f(h,a,m){const w=m.x-a.x,v=m.y-a.y,p=w*w+v*v;let y=p?((h.x-a.x)*w+(h.y-a.y)*v)/p:0;y=Math.max(0,Math.min(1,y));const C=a.x+y*w,T=a.y+y*v;return Math.hypot(h.x-C,h.y-T)}function l(h){const a=h.points;if(!a.length)return null;if(h.tool==="text"){const y=h.fontSize||S,C=(h.text||"").length*y*.6;return{x1:a[0].x,y1:a[0].y,x2:a[0].x+C,y2:a[0].y+y*1.2}}let m=1/0,w=1/0,v=-1/0,p=-1/0;for(const y of a)m=Math.min(m,y.x),w=Math.min(w,y.y),v=Math.max(v,y.x),p=Math.max(p,y.y);return{x1:m,y1:w,x2:v,y2:p}}function i(h,a){const m=l(h);if(!m)return 1/0;if(h.tool==="text"||h.tool==="rect"){if(a.x>=m.x1&&a.x<=m.x2&&a.y>=m.y1&&a.y<=m.y2)return 0;if(h.tool==="text")return 1/0}const w=h.points;if(h.tool==="rect"){const p=[{x:m.x1,y:m.y1},{x:m.x2,y:m.y1},{x:m.x2,y:m.y2},{x:m.x1,y:m.y2}];let y=1/0;for(let C=0;C<4;C++)y=Math.min(y,f(a,p[C],p[(C+1)%4]));return y}if(w.length===1)return Math.hypot(a.x-w[0].x,a.y-w[0].y);let v=1/0;for(let p=0;p<w.length-1;p++)v=Math.min(v,f(a,w[p],w[p+1]));return v}class g{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#u=Array.isArray(a.seed)?a.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(a){const m=b(a,this.#i);return m?(m.durable=!0,this.#s.push(m),this.#M(),this.redraw(),this.#R(),r(m.id,this.#s.length)):(F("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),r(null,this.#s.length))}list(){return this.#s.map(d)}remove(a){const m=this.#s.findIndex(w=>w.id===a);return m<0?(F("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${a}".`),!1):(this.#s.splice(m,1),this.#c===a&&(this.#c=null),this.redraw(),this.#R(),!0)}replaceAll(a){const m=Array.isArray(a)?a:[];this.#s=m.map(w=>b(w,this.#i)).filter(Boolean);for(const w of this.#s)w.durable=!0;this.#s.length&&this.#M(),this.redraw(),this.#R()}#d(){const a=this.#t.viewport?.root;if(!a||!L(a.addEventListener))return;const m=w=>{if(!(!this.#o||!w)){if(w.key==="Escape"){this.use(null),w.preventDefault?.();return}if(this.#o==="erase"){if(w.key==="Tab"){this.#f(w);return}(w.key==="Delete"||w.key==="Backspace")&&this.#h(w)}}};a.addEventListener("keydown",m,!0),this.#a.push(()=>a.removeEventListener("keydown",m,!0))}#f(a){if(!this.#s.length){this.#x("a11y.annotate.noMarks");return}a.preventDefault?.();const m=this.#c?this.#s.findIndex(p=>p.id===this.#c):-1,w=a.shiftKey?-1:1,v=m<0?w>0?0:this.#s.length-1:(m+w+this.#s.length)%this.#s.length;this.#c=this.#s[v].id,this.redraw(),this.#x("a11y.annotate.focusedMark",{at:v+1,of:this.#s.length})}#h(a){if(!this.#c)return;a.preventDefault?.();const m=this.#c;this.remove(m),this.#x("a11y.annotate.erased")}#p(){const a=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!a||!L(a.matchMedia))return;let m=null;const w=()=>{const v=a.devicePixelRatio||1;let p;try{p=a.matchMedia(`(resolution: ${v}dppx)`)}catch{return}m=p;const y=()=>{this.redraw(),w()};L(p.addEventListener)?p.addEventListener("change",y,{once:!0}):L(p.addListener)&&p.addListener(y)};w(),this.#a.push(()=>{m=null})}use(a,m={}){const w=!!m.colour&&a===this.#o;m.colour&&(this.#i=String(m.colour));const v=a&&G.includes(a)?a:null;this.#o=v&&v===this.#o&&!w?null:v,this.#o!=="erase"&&(this.#c=null);const p=this.#o?this.#M():this.#n;return p&&(p.style.pointerEvents=this.#o?"auto":"none",p.style.cursor=this.#o?"crosshair":""),this.#R(),this.#o}undo(){const a=this.#s.pop();return a&&this.#c===a.id&&(this.#c=null),this.redraw(),this.#R(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#R())}#m(){const a=this.#s.filter(m=>m.durable);a.length!==this.#s.length&&(this.#s=a,this.redraw(),this.#R())}redraw(){!this.#n&&this.#s.length&&this.#M();const a=this.#n,m=this.#r;if(!a||!m)return;this.#j();const{left:w,top:v}=this.#S();m.clearRect(0,0,a.width,a.height);const p=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const C=p.filter(T=>u(T.region)===y);if(C.length){m.save(),this.#g(m,y),m.translate((y==="centre"?-w:0)||0,-v||0);for(const T of C)this.#b(m,T),T.id===this.#c&&this.#A(m,T);m.restore()}}}#g(a,m="centre"){const w=this.#n,v=this.#t.viewport?.bodyViewport;if(!L(w?.getBoundingClientRect)||!L(v?.getBoundingClientRect))return;const p=w.getBoundingClientRect(),y=v.getBoundingClientRect();if(!y.width||!y.height)return;const C=this.#y(m,y);C&&(a.beginPath(),a.rect(C.left-p.left,y.top-p.top,C.width,y.height),a.clip())}#y(a,m){const w=P=>{if(!L(P?.getBoundingClientRect))return null;const x=P.getBoundingClientRect();return x&&x.width>0?{left:x.left,width:x.width}:null},v=w(this.#t.viewport?.bodyStart),p=w(this.#t.viewport?.bodyEnd);if(a==="start")return v;if(a==="end")return p;let y=m.left,C=m.left+m.width;const T=m.left+m.width/2;for(const P of[v,p]){if(!P)continue;const x=P.left+P.width;P.left+P.width/2<T?y=Math.max(y,x):C=Math.min(C,P.left)}return C>y?{left:y,width:C-y}:null}#w(a){for(const[m,w]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!L(w?.getBoundingClientRect))continue;const v=w.getBoundingClientRect();if(v&&v.width>0&&a>=v.left&&a<v.left+v.width)return m}return"centre"}#k(a){const m=this.#t.viewport?.bodyViewport;if(!L(m?.getBoundingClientRect))return!0;const w=m.getBoundingClientRect();return!w.width||!w.height?!0:a.clientX>=w.left&&a.clientX<=w.right&&a.clientY>=w.top&&a.clientY<=w.bottom}#b(a,m){const w=m.points;if(!w.length)return;const v=this.#e.presentation?.scale||1;a.lineWidth=(n[m.tool]||3)*v,a.strokeStyle=m.colour,a.fillStyle=m.colour,a.lineCap="round",a.lineJoin="round",a.globalAlpha=m.tool==="highlight"?.32:1;const p=w[0],y=w[w.length-1];if(m.tool==="text"){const C=(m.fontSize||S)*v;a.font=`${C}px ${O}`,a.textBaseline="top";const T=m.text||"";if(m.background){let P=T.length*C*.6;if(typeof a.measureText=="function"){const x=a.measureText(T);x&&Number.isFinite(x.width)&&(P=x.width)}a.fillStyle=m.background,a.fillRect(p.x-C*.15,p.y-C*.1,P+C*.3,C*1.2)}a.fillStyle=m.colour,a.fillText(T,p.x,p.y),a.globalAlpha=1;return}if(m.tool==="rect")a.strokeRect(p.x,p.y,y.x-p.x,y.y-p.y);else if(m.tool==="arrow")a.beginPath(),a.moveTo(p.x,p.y),a.lineTo(y.x,y.y),a.stroke(),this.#O(a,p,y,a.lineWidth);else{a.beginPath(),a.moveTo(p.x,p.y);for(let C=1;C<w.length;C++)a.lineTo(w[C].x,w[C].y);a.stroke()}a.globalAlpha=1}#O(a,m,w,v){const p=Math.atan2(w.y-m.y,w.x-m.x),y=Math.max(8,v*3);a.beginPath(),a.moveTo(w.x,w.y),a.lineTo(w.x-y*Math.cos(p-Math.PI/7),w.y-y*Math.sin(p-Math.PI/7)),a.lineTo(w.x-y*Math.cos(p+Math.PI/7),w.y-y*Math.sin(p+Math.PI/7)),a.closePath(),a.fill()}#A(a,m){const w=l(m);if(!w||!L(a.strokeRect))return;const v=6;a.save(),a.setLineDash?.([4,3]),a.strokeStyle="#1a73e8",a.lineWidth=2,a.globalAlpha=1,a.strokeRect(w.x1-v,w.y1-v,w.x2-w.x1+v*2,w.y2-w.y1+v*2),a.restore()}#P(a,m){const w=this.#e.presentation?.scale||1,v=o*w;for(let p=this.#s.length-1;p>=0;p--){const y=this.#s[p];if(u(y.region)===m&&i(y,a)<=v)return y}return null}#S(){const a=L(this.#t.scrollPosition)?this.#t.scrollPosition():null,m=this.#t.viewport?.rtl===!0;return{left:Q(a?.left||0,m),top:a?.top||0}}#M(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,m=a?.ownerDocument;if(!a||!m?.createElement)return null;const w=m.createElement("canvas");return w.className=s,w.style.position="absolute",w.style.inset="0",w.style.pointerEvents="none",a.appendChild(w),this.#n=w,this.#r=w.getContext?w.getContext("2d"):null,this.#j(),this.#E(w),w}#j(){const a=this.#n,m=this.#t.viewport?.root;if(!a||!m?.getBoundingClientRect)return;const w=m.getBoundingClientRect(),p=a.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(w.width*p)),C=Math.max(1,Math.round(w.height*p));a.width===y&&a.height===C||(a.width=y,a.height=C,a.style&&(a.style.width=`${Math.max(1,w.width)}px`,a.style.height=`${Math.max(1,w.height)}px`),this.#r?.setTransform(p,0,0,p,0,0))}#E(a){const m=(C,T="centre")=>{const P=a.getBoundingClientRect(),{left:x,top:E}=this.#S();return{x:C.clientX-P.left+(T==="centre"?x:0),y:C.clientY-P.top+E}},w=C=>{if(!this.#o||!this.#k(C))return;const T=this.#w(C.clientX);if(this.#o==="erase"){const P=this.#P(m(C,T),T);P&&(this.remove(P.id),this.#x("a11y.annotate.erased")),C.preventDefault?.();return}this.#l={id:B("mark"),tool:this.#o,colour:this.#i,points:[m(C,T)],region:T},a.setPointerCapture?.(C.pointerId),C.preventDefault?.()},v=C=>{if(!this.#l)return;const T=m(C,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(T),this.redraw()},p=C=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,a.releasePointerCapture?.(C.pointerId),this.redraw(),this.#R())},y=C=>{if(!this.#o)return;const T=this.#t.viewport?.bodyViewport;if(!T)return;let P=!1;C.deltaY&&typeof T.scrollTop=="number"&&(T.scrollTop+=C.deltaY,P=!0),C.deltaX&&typeof T.scrollLeft=="number"&&(T.scrollLeft+=C.deltaX,P=!0),P&&C.preventDefault?.()};a.addEventListener("pointerdown",w),a.addEventListener("pointermove",v),a.addEventListener("pointerup",p),a.addEventListener("pointercancel",p),a.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{a.removeEventListener("pointerdown",w),a.removeEventListener("pointermove",v),a.removeEventListener("pointerup",p),a.removeEventListener("pointercancel",p),a.removeEventListener("wheel",y)})}#R(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#L(a,m){const w=this.#e.messages;return w&&L(w.t)?w.t(a,m):a}#x(a,m){this.#t.announce?.(this.#L(a,m),{repeat:!0})}destroy(){for(const a of this.#a)a();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=g}),xe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function Q(z){if(!Number.isFinite(z)||z<1e3)return"now";const S=Math.round(z/1e3);if(S<60)return`${S}s ago`;const O=Math.round(S/60);return O<60?`${O}m ago`:`${Math.round(O/60)}h ago`}function G(z,S){return Number.isFinite(z)?new Date(z).toLocaleTimeString(S||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class H{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(S){this.#e=S.grid,this.#t=S.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const S=this.#e.timeline,O=S.depth,b=S.position;this.#r.max=String(Math.max(1,O)),this.#r.value=String(Math.max(0,O-b)),this.#r.disabled=O===0;const u=S.at(),d=S.live;this.#o&&(this.#o.textContent=d?this.#l("timeline.live"):Q(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",d?"true":"false")),this.#i&&(this.#i.textContent=O===0?this.#l("timeline.recording"):G(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",d?"true":"false")}#l(S,O){const b=this.#e;return(b&&b.messages?b.messages:F).t(S,O)}#a(){if(this.#n)return;const S=this.#t.viewport?.overlays,O=S?.ownerDocument;if(!S||!O?.createElement)return;const b=O.createElement("div");b.className=_;const u=O.createElement("span");u.className=`${_}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const d=O.createElement("input");d.className=`${_}__range`,d.type="range",d.min="0",d.step="1",d.setAttribute("aria-label",this.#l("timeline.scrub"));const s=O.createElement("span");s.className=`${_}__clock`;const n=O.createElement("button");n.className=`${_}__live`,n.type="button",n.textContent=this.#l("timeline.goLive"),n.setAttribute("aria-label",this.#l("timeline.returnToPresent")),b.appendChild(u),b.appendChild(d),b.appendChild(s),b.appendChild(n),S.appendChild(b),this.#n=b,this.#r=d,this.#o=u,this.#i=s;const t=()=>{const f=this.#e.timeline.depth;this.#e.timeline.seek(f-Number(d.value))};d.addEventListener("input",t);const r=()=>this.#e.timeline.toLive();n.addEventListener("click",r);const o=f=>f.stopPropagation();d.addEventListener("keydown",o),this.#s.push(()=>{d.removeEventListener("input",t),n.removeEventListener("click",r),d.removeEventListener("keydown",o)})}#u(){this.#n&&(L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const S of this.#s)S();this.#s=[],this.#u()}}const U=H}),xe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/renderer/direction.js").isRtlElement,G="lat-comment-mark",H="lat-cell--commented",U="lat-cell--commented-open";class z{#e;#t;#n=[];#r=[];constructor(b){this.#e=b.grid,this.#t=b.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const b=this.#e.comments;if(!b||!b.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const d=[];for(const s of u.querySelectorAll("[data-key]")){const n=s.getAttribute("data-key");if(n){d.push(n);for(const t of s.querySelectorAll("[data-col]")){const r=t.getAttribute("data-col"),o=b.at(n,r),f=!!(o&&o.count);t.classList.toggle(H,f),t.classList.toggle(U,f&&o.unresolved>0),this.#i(t,o,r)}}}(d.length!==this.#r.length||d.some((s,n)=>s!==this.#r[n]))&&(this.#r=d,b.request(d))}#o(b,u){const d=this.#e;return(d&&d.messages?d.messages:F).t(b,u)}#i(b,u,d){if(!u||!u.count){b.hasAttribute("aria-description")&&b.removeAttribute("aria-description");return}const s=u.count,n=u.unresolved,t=this.#o("count.comments",{count:s});b.setAttribute("aria-description",n>0?this.#o("comments.someUnresolved",{comments:t,unresolved:n}):this.#o("comments.allResolved",{comments:t}))}#s(){const b=this.#t.viewport?.root;if(!b||!L(b.addEventListener))return;const u=s=>{const n=this.#e.comments;if(!n||!n.enabled)return;const t=s.target&&L(s.target.closest)?s.target.closest("[data-col]"):null;if(!t||!t.classList.contains(H)||!this.#l(t,s))return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.stopPropagation(),s.preventDefault(),n.open(o,t.getAttribute("data-col")))},d=s=>{const n=this.#e.comments;if(!n||!n.enabled||!s.altKey||s.key!=="m"&&s.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&L(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const r=t.closest("[data-key]"),o=r&&r.getAttribute("data-key");o&&(s.preventDefault(),s.stopPropagation(),n.open(o,t.getAttribute("data-col")))};b.addEventListener("click",u,!0),b.addEventListener("keydown",d,!0),this.#n.push(()=>{b.removeEventListener("click",u,!0),b.removeEventListener("keydown",d,!0)})}#l(b,u){if(!L(b.getBoundingClientRect))return!1;const d=b.getBoundingClientRect(),s=Math.max(14,Math.min(24,d.height*.6));return(Q(b)?u.clientX<=d.left+s:u.clientX>=d.right-s)&&u.clientY<=d.top+s}destroy(){for(const b of this.#n)b();this.#n=[]}}const S=z}),xe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,U="lat-presence";class z{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(b){this.#e=b.grid,this.#t=b.renderer}mount(){const b=this.#e.presence;if(!(!b||!b.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,d=>this.#l(u,d)));this.#a(),this.paint()}}#l(b,u){if(this.#f(),b==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const s=u&&u.peer;s&&(this.#r.textContent=this.#h(b==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:s.name}))}#a(){const b=this.#t.viewport?.overlays,u=b?.ownerDocument;if(!b||!u?.createElement)return;const d=this.#e.get("presence")||{},s=u.createElement("span");if(s.className=`${U}__live`,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),b.appendChild(s),this.#r=s,d.roster===!1)return;const n=u.createElement("div");n.className=U,d.roster&&d.roster.side==="start"&&n.setAttribute("data-side","start"),n.style.pointerEvents="auto",b.appendChild(n),this.#n=n}paint(){const b=this.#e.presence,u=this.#t.viewport?.root;if(!b||!b.enabled||!u?.querySelectorAll)return;this.#d(u);const d=b.peers(),s=[...d].sort((n,t)=>n.at-t.at);for(const n of s)for(const t of n.ranges||[])for(const r of t.rowIds||[])for(const o of t.columns||[])this.#c(u,r,o,n,"range");for(const n of s)n.cursor&&this.#c(u,n.cursor.rowId,n.cursor.colId,n,"cursor");for(const n of s)n.editing&&this.#c(u,n.editing.rowId,n.editing.colId,n,"edit");this.#f(),this.#u(d)}#u(b){if(this.#s!==null)return;const u=b.filter(n=>n.cursorFresh);if(!u.length)return;const s=Math.max(...u.map(n=>n.cursorAt||0))+H-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,s))}#c(b,u,d,s,n){const t=b.querySelector(`[data-key="${Q(u)}"]`),r=t&&t.querySelector(`[data-col="${Q(d)}"]`);r&&(r.setAttribute("data-presence",n),r.style.setProperty("--lat-peer",s.colour),r.setAttribute("data-peer-name",s.name),r.setAttribute("data-peer-initial",s.initials||(s.name||"?").slice(0,1).toUpperCase()),s.idle?r.setAttribute("data-peer-idle","true"):r.removeAttribute("data-peer-idle"),n==="cursor"&&s.cursorFresh&&r.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${d}`))}#d(b){if(this.#o.size){for(const u of b.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#f(){if(!this.#n)return;const b=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const s of u){const n=b.createElement("button");n.className=`${U}__peer`,n.type="button",n.style.setProperty("--lat-peer",s.colour),n.toggleAttribute("data-idle",!!s.idle),n.toggleAttribute("data-hidden",!!s.hidden);let t="presence.peer";s.hidden?t="presence.peerHidden":s.idle&&(t="presence.peerIdle"),n.setAttribute("aria-label",this.#h(t,{name:s.name}));const r=b.createElement("span");r.className=`${U}__dot`,r.setAttribute("aria-hidden","true"),r.textContent=s.initials||(s.name||"?").slice(0,1).toUpperCase(),n.appendChild(r);const o=b.createElement("span");o.className=`${U}__name`,o.textContent=s.name,n.appendChild(o),n.addEventListener("click",()=>this.#e.presence.jumpTo(s.id)),this.#n.appendChild(n)}const d=u.filter(s=>s.hidden).length;if(d){const s=b.createElement("span");s.className=`${U}__hidden`,s.textContent=this.#h("presence.hidden",{count:d}),this.#n.appendChild(s)}}announceRefusal(b){if(!this.#r)return;const u=b&&b.name?b.name:this.#h("presence.someoneElse");this.#r.textContent=this.#h("a11y.presence.refused",{name:u})}#h(b,u){const d=this.#e;return(d&&d.messages?d.messages:F).t(b,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const b=this.#t.viewport?.root;b?.querySelectorAll&&this.#d(b),this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const S=z}),xe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,Q=K("packages/dom/src/editors/common.js").cssEscape,H=K("packages/core/src/model/comments.js").parseCellKey,U="lat-comments",z=/^(https?:|mailto:)/i,S='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function O(s,n){if(!Number.isFinite(s))return"";const t=Math.max(0,Math.round((n-s)/1e3));if(t<60)return"just now";const r=Math.round(t/60);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function b(s,n,t,r){n.textContent="";const o=String(t??"");if(!r){n.textContent=o;return}const f=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,i=f.exec(o);for(;i;){i.index>l&&n.appendChild(s.createTextNode(o.slice(l,i.index)));const g=i[0];if(g.startsWith("*")){const c=s.createElement("em");c.textContent=g.slice(1,-1),n.appendChild(c)}else if(g.startsWith("`")){const c=s.createElement("code");c.textContent=g.slice(1,-1),n.appendChild(c)}else{const c=g.indexOf("]("),h=g.slice(1,c),a=g.slice(c+2,-1);if(z.test(a)){const m=s.createElement("a");m.href=a,m.textContent=h,m.rel="noopener noreferrer",m.target="_blank",n.appendChild(m)}else n.appendChild(s.createTextNode(h))}l=i.index+g.length,i=f.exec(o)}l<o.length&&n.appendChild(s.createTextNode(o.slice(l)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(n){this.#e=n.grid,this.#t=n.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",n=>this.#a(n))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#w(),this.#b()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(n){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#f(n.rowId,n.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#w(),this.#b(),this.#o&&L(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const n=this.#s;this.#s=null,n&&L(n.focus)&&n.focus()}#c(){const n=this.#e.comments.openKey;if(!n)return;const{rowId:t}=H(n);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(n){if(!this.#r)return;const r=this.#r.ownerDocument.createElement("p");r.className=`${U}__note`,r.setAttribute("role","status"),r.textContent=n,this.#r.appendChild(r)}#f(n,t){const r=this.#t.viewport?.root;if(!r||!r.querySelector)return null;const o=r.querySelector(`[data-key="${Q(n)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#h(n,t){const r=this.#e;return(r&&r.messages?r.messages:F).t(n,t)}#p(n){const t=n.createElement("div");t.className=U,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#h("comments.panel"));const r=n.createElement("header");r.className=`${U}__head`;const o=n.createElement("div");o.className=`${U}__title`,r.appendChild(o);const f=n.createElement("button");f.className=`${U}__resolve`,f.type="button",r.appendChild(f);const l=n.createElement("button");l.className=`${U}__close`,l.type="button",l.setAttribute("aria-label",this.#h("comments.close")),l.textContent="×",r.appendChild(l);const i=n.createElement("div");i.className=`${U}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const g=n.createElement("form");g.className=`${U}__composer`;const c=n.createElement("textarea");c.className=`${U}__input`,c.rows=2,c.setAttribute("aria-label",this.#h("comments.write"));const h=n.createElement("button");h.className=`${U}__send`,h.type="submit",h.textContent=this.#h("comments.post"),g.appendChild(c),g.appendChild(h),t.appendChild(r),t.appendChild(i),t.appendChild(g),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=o,this.#g=f;const a=p=>{p.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},m=()=>this.#e.comments.close(),w=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.#e.comments.close();return}if(p.key!=="Tab")return;const y=[...t.querySelectorAll(S)].filter(x=>x.offsetParent!==null||x===c);if(!y.length)return;const C=y[0],T=y[y.length-1],P=t.ownerDocument.activeElement;p.shiftKey&&P===C?(p.preventDefault(),T.focus()):!p.shiftKey&&P===T&&(p.preventDefault(),C.focus())};g.addEventListener("submit",a),l.addEventListener("click",m),f.addEventListener("click",w),t.addEventListener("keydown",v),this.#l.push(()=>{g.removeEventListener("submit",a),l.removeEventListener("click",m),f.removeEventListener("click",w),t.removeEventListener("keydown",v)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#w(){const n=this.#e.comments;if(!this.#n||!n.openKey)return;const t=this.#n.ownerDocument,r=this.#e.get("comments")||{},o=Date.now(),f=n.openKey,{rowId:l,field:i}=H(f),g=this.#e.columns.get(i),c=this.#e.rows.byKey(l),h=L(r.rowLabel)&&c?r.rowLabel(c):l;if(this.#m.textContent=this.#h("comments.cellTitle",{column:g&&(g.title??g.id)||i,row:h}),this.#g.textContent=this.#y()>0?this.#h("comments.resolve"):this.#h("comments.reopen"),this.#r.textContent="",n.loading){this.#d(this.#h("comments.loading"));return}const a=n.thread||[];if(!a.length){this.#d(this.#h("comments.empty"));return}const m=c&&g?g.getValue(c.data,c):void 0;for(const w of a)this.#r.appendChild(this.#k(t,w,o,m,r))}#k(n,t,r,o,f){const l=n.createElement("article");l.className=`${U}__item`,t.pending&&l.setAttribute("data-pending","true"),t.resolved&&l.setAttribute("data-resolved","true");const i=n.createElement("div");i.className=`${U}__meta`;const g=n.createElement("span");g.className=`${U}__author`,g.textContent=t.author&&(t.author.name||t.author.initials)||this.#h("comments.unknownAuthor"),i.appendChild(g);const c=n.createElement("time");c.className=`${U}__time`;const h=O(t.at,r);c.textContent=t.edited?this.#h("comments.edited",{time:h}):h,i.appendChild(c),l.appendChild(i);const a=n.createElement("div");if(a.className=`${U}__body`,b(n,a,t.body,!!f.markdown),l.appendChild(a),t.value!==void 0&&!Object.is(t.value,o)){const v=n.createElement("p");v.className=`${U}__moved`,v.textContent=this.#h("comments.valueMoved",{was:String(t.value),now:String(o)}),l.appendChild(v)}const m=t.can||{},w=v=>m[v]!==!1;if(w("edit")||w("delete")){const v=n.createElement("div");if(v.className=`${U}__actions`,w("delete")){const p=n.createElement("button");p.type="button",p.className=`${U}__action`,p.textContent=this.#h("comments.delete"),p.addEventListener("click",()=>this.#e.comments.remove(t.id)),v.appendChild(p)}l.appendChild(v)}return l}#b(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const t=this.#e.comments.openKey,{rowId:r,field:o}=H(t),f=this.#f(r,o)||this.#i,l=this.#t.viewport?.root;if(!f||!l||!L(f.getBoundingClientRect))return;const i=f.getBoundingClientRect(),g=l.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let h=i.bottom-g.top+4;h+c.height>g.height&&i.top-g.top>c.height&&(h=i.top-g.top-c.height-4);let a=i.left-g.left;a+c.width>g.width&&(a=Math.max(0,g.width-c.width-4)),this.#n.style.top=`${Math.max(0,h)}px`,this.#n.style.left=`${Math.max(0,a)}px`;const m=i.bottom<g.top||i.top>g.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const n of this.#l)n();this.#l=[],this.#n&&L(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const d=u}),xe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),Q=_.el,G=_.on,H="lat-watermark",U="https://www.latticegrid.dev",z=["br","bl","tl","tr"],S=4e3;class O{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(d){this.#e=d.grid,this.#t=d.document,this.#n=d.element,this.#i=d.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),L(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const d=this.#e.licence&&this.#e.licence.ready;d&&L(d.then)&&d.then(()=>this.refresh(),()=>this.refresh())}refresh(){const d=this.#d();d&&!this.#r?(this.#f(),this.#u()):!d&&this.#r&&(this.#h(),this.#c())}#a(){const d=this.#i;if(!d||!L(d.matchMedia))return!1;try{return!!d.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),L(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#h();return}this.#s=(this.#s+1)%z.length,this.#h(),this.#f(),this.#u()},S)))}#c(){this.#l!==null&&L(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const d=this.#e.licence;return!!(d&&L(d.watermark)&&d.watermark())}#f(){const d=Q(this.#t,"a",{class:`${H}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:F).t("licence.watermark"),attrs:{href:U,target:"_blank",rel:"noopener noreferrer"}});this.#r=Q(this.#t,"div",{class:`${H} ${H}--${z[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[d]}),this.#o.push(G(this.#r,"pointerdown",s=>{L(s.stopPropagation)&&s.stopPropagation()})),this.#n&&L(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#h(){this.#r&&L(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const d of this.#o)d();this.#o=[],this.#h()}}const b=O}),xe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const X=K("packages/core/src/internal/util.js"),L=X.warnOnce,B=X.isFunction,F=K("packages/dom/src/editors/common.js"),_=F.el,Q=F.on,H=K("packages/dom/src/themeof.js").themeOf,U="lat-maximised",z={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},S="lat-maximised-host",O="lat-maximise-placeholder";class b{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(s){this.#e=s.element,this.#t=s.document,this.#n=B(s.onChange)?s.onChange:null,this.#r=B(s.captureScroll)?s.captureScroll:null,this.#o=B(s.restoreScroll)?s.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const s=this.#e.parentNode;if(!s||!this.#t.body)return L("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:O}),this.#i.style.visibility="hidden";const n=this.#e.offsetWidth,t=this.#e.offsetHeight;n&&(this.#i.style.width=`${n}px`),t&&(this.#i.style.height=`${t}px`);const r=this.#r?this.#r():null,o=B(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?H(s):null;o&&(this.#e.setAttribute("data-theme",o),this.#u=!0),s.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[f,l]of Object.entries(z))this.#a[f]=this.#e.style[f]||"",this.#e.style[f]=l;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(U),this.#t.body.classList&&this.#t.body.classList.add(S),r&&this.#o&&this.#o(r),this.#s=Q(this.#t,"keydown",f=>this.#f(f)),this.#h(),!0}exit(){if(!this.active())return!1;const s=this.#r?this.#r():null,n=this.#i,t=n.parentNode;if(t&&B(t.insertBefore)&&this.#d(()=>t.insertBefore(this.#e,n)),B(n.remove)&&n.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[r,o]of Object.entries(this.#a))this.#e.style[r]=o;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(U),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(S),s&&this.#o&&this.#o(s),this.#s&&this.#s(),this.#s=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(s){const n=this.#t.activeElement,t=n&&n!==this.#t.body&&B(this.#e.contains)&&this.#e.contains(n)?n:null;s(),t&&B(t.focus)&&t.focus()}#f(s){!s||s.key!=="Escape"||s.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const s of this.#l)s(this.active())}watch(s){return B(s)?(this.#l.add(s),()=>this.#l.delete(s)):()=>{}}destroy(){this.exit()}}const u=b}),xe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const X=K("packages/dom/src/editors/common.js"),L=X.documentFor,B=X.el,F=X.on,_=X.clear,G=K("packages/core/src/i18n/index.js").defaultMessages,U=K("packages/core/src/internal/util.js").isFunction,z=K("packages/core/src/ai/schema.js"),S=z.describeGrid,O=z.promptText,b=K("packages/core/src/ai/intent.js"),u=b.applyPlan,d=b.buildPrompt,s=b.planIntent,n="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#f=null;#h=null;#p=null;#m=null;#g=null;#y="idle";#w=0;#k=!1;#b=[];t(l,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:G).t(l,i)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||G,this.#e=L(l),this.#t=l.grid||null,this.#n=U(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:U(l.onPlan)?l.onPlan:null,onApply:U(l.onApply)?l.onApply:null,onError:U(l.onError)?l.onError:null},this.#s=B(this.#e,"div",{class:n,attrs:{"data-state":"idle",role:"search"}}),this.#O(l)}element(){return this.#s}refresh(){this.#k||!this.#s||this.#y!=="busy"&&this.#M()}destroy(){this.#k=!0,this.#w++;for(const l of this.#b)l();this.#b.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#f=null,this.#h=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(l){if(this.#k||this.#y==="busy")return null;const i=String(l??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const g=++this.#w;this.#A("busy"),this.#j("Thinking…");let c;try{const h=S(this.#t,this.#r),a=O(h);if(c=await this.#n({prompt:i,schema:h,schemaText:a,message:d(i,a),context:this.#o}),this.#k||g!==this.#w)return null;const m=s(c,h);return this.#P(m),m}catch(h){return this.#k||g!==this.#w||(this.#i.onError&&this.#i.onError(h),this.#E(h instanceof Error?h.message:String(h))),null}}apply(){const l=this.#g;if(this.#k||!l||!l.ok)return null;const i=this.#t?.ai,g=U(i?.apply)?i.apply(l):u(l,this.#t);return this.#i.onApply&&this.#i.onApply(g,l),this.#M(),this.#l&&(this.#l.value=""),g.failed.length?this.#E(`Applied ${g.applied.length}; ${g.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#j(`Applied: ${l.describe()}`),g}discard(){this.#k||(this.#M(),this.#j("Discarded."))}#O(l){const i=this.#e,g=B(i,"div",{class:`${n}__row`});this.#l=B(i,"input",{class:`${n}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#b.push(F(this.#l,"keydown",h=>{const a=h&&h.key;a==="Enter"?(U(h.preventDefault)&&h.preventDefault(),this.ask()):a==="Escape"&&this.#g&&(U(h.preventDefault)&&h.preventDefault(),this.discard())})),g.appendChild(this.#l),this.#a=B(i,"button",{class:`${n}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#b.push(F(this.#a,"click",()=>{this.ask()})),g.appendChild(this.#a),this.#s.appendChild(g),this.#u=B(i,"div",{class:`${n}__preview`,attrs:{hidden:!0}}),this.#c=B(i,"p",{class:`${n}__summary`}),this.#d=B(i,"ul",{class:`${n}__notes`});const c=B(i,"div",{class:`${n}__buttons`});this.#f=B(i,"button",{class:`${n}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#h=B(i,"button",{class:`${n}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#b.push(F(this.#f,"click",()=>{this.apply()})),this.#b.push(F(this.#h,"click",()=>{this.discard()})),c.appendChild(this.#f),c.appendChild(this.#h),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=B(i,"p",{class:`${n}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=B(i,"p",{class:`${n}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#A(l){if(this.#y=l,!this.#s)return;this.#s.setAttribute("data-state",l);const i=l==="busy";r(this.#l,i),r(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,l!=="preview"),o(this.#m,l!=="error")}#P(l){const i=l;if(this.#i.onPlan&&this.#i.onPlan(l),!i.ok){this.#g=null;const g=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${g}`);return}this.#g=l,this.#j(""),this.#c&&(this.#c.textContent=i.describe()),this.#S(i.rejected),this.#A("preview")}#S(l){const i=this.#d;if(i){_(i),o(i,!l.length);for(const g of l.slice(0,6))i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:g.reason}));l.length>6&&i.appendChild(B(this.#e,"li",{class:`${n}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#M(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#A("idle")}#j(l){this.#p&&(this.#p.textContent=l)}#E(l){this.#g=null,this.#j(""),this.#m&&(this.#m.textContent=l),this.#A("error")}}function r(f,l){f&&(f.disabled=l,l?f.setAttribute("disabled",""):f.removeAttribute("disabled"))}function o(f,l){f&&(f.hidden=l,l?f.setAttribute("hidden",""):f.removeAttribute("hidden"))}}),xe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.isObject,F=X.warnOnce,Q=K("packages/core/src/source/derive.js").reduceValues,H=K("packages/core/src/source/memory.js").isPipelineSettle,z=K("packages/core/src/i18n/index.js").defaultMessages,O=K("packages/dom/src/cell/icons.js").renderIconInto,b={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",d=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),s=Object.freeze({direction:"flat",change:null,percent:null});function n(a,m){if(!Number.isFinite(a)||!Number.isFinite(m))return s;const w=a-m,v=w>0?"up":w<0?"down":"flat",p=m===0?null:w/Math.abs(m)*100;return{direction:v,change:w,percent:p}}function t(a,m){return a==="flat"||m==="neither"?"flat":a===m?"good":"bad"}function r(a,m,w=null){if(L(m)){const P=m(a,w);return P==="good"||P==="warn"||P==="bad"?P:null}if(!B(m))return null;const v=typeof a=="number"&&Number.isFinite(a)?a:null;if(v===null)return null;const p=Number.isFinite(Number(m.good))?Number(m.good):null,y=Number.isFinite(Number(m.warn))?Number(m.warn):null,C=String(m.direction||"up")==="down",T=P=>C?v<=P:v>=P;return p!==null&&T(p)?"good":y!==null&&T(y)?"warn":p===null&&y===null?null:"bad"}function o(a){return!(L(a.value)||a.value!==void 0&&!B(a.value))}function f(a){return!a||!a.rows||!L(a.rows.totalCount)?!0:a.rows.totalCount()>0}function l(a){const m=B(a)?a:{},w=m.grid||null,v=c(m.container,w);if(!v)return F("stat.container","createStat needs a `container`: an element or a selector."),h();const p=v.ownerDocument||(typeof document>"u"?null:document);if(!p)return F("stat.document","createStat needs a document; it draws DOM."),h();const y=p.createElement("div");y.className=["lattice",b.root,m.class].filter(Boolean).join(" "),y.setAttribute("role","group");const C=p.createElement("div");C.className=b.title;const T=p.createElement("div");T.className=b.value;const P=p.createElement("div");P.className=b.interval;const x=p.createElement("div");x.className=b.delta;const E=p.createElement("div");E.className=b.footer;const j=p.createElement("div");if(j.className=b.note,j.hidden=!0,m.icon!=null&&m.icon!==""){const ee=p.createElement("span");ee.className=b.icon,ee.setAttribute("aria-hidden","true"),O(ee,m.icon,`stat:${m.title||"stat"}`),y.appendChild(ee);const te=p.createElement("div");te.className=b.body,te.appendChild(C),te.appendChild(T),te.appendChild(j),te.appendChild(P),te.appendChild(x),te.appendChild(E),y.appendChild(te)}else y.appendChild(C),y.appendChild(T),y.appendChild(j),y.appendChild(P),y.appendChild(x),y.appendChild(E);v.appendChild(y);let $=null;const D=[];let M=!1;function R(){if(L(m.value))return m.value(w);if(m.value!==void 0&&!B(m.value))return m.value;const ee=B(m.value)?m.value:m,te=ee.of,ne=ee.fn||"sum",ae=ee.show;return w?ne==="count"?I().length:te?ae?q(String(te),String(ne),String(ae)):k()==="filtered"&&w.statistics&&L(w.statistics.reduce)?w.statistics.reduce(String(te),String(ne)):Q(I().map(de=>g(de,String(te))),String(ne)):null:null}function k(){return String(m.scope||"filtered")}function I(){if(!w||!w.rows)return[];const ee=k();if(ee==="all"){const ne=[];return L(w.rows.forEachAll)&&w.rows.forEachAll(ae=>{ae.group||ne.push(i(ae))}),ne}if(ee==="selected")return(w.selection&&L(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(i);const te=[];return L(w.rows.forEach)&&w.rows.forEach(ne=>{ne.group||te.push(i(ne))}),te}function q(ee,te,ne){if(te!=="min"&&te!=="max")return F(`stat.show.${te}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${te}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ae=null,de=null;for(const ie of I()){const oe=Number(g(ie,ee));Number.isFinite(oe)&&(ae===null||(te==="max"?oe>ae:oe<ae))&&(ae=oe,de=ie)}return de===null?null:g(de,ne)}function Z(ee){if(L(m.format))return String(m.format(ee,w));if(ee==null)return m.empty??"—";const te=B(m.value)?m.value:m,ne=te.show||te.of;if((te.show?!0:d.has(String(te.fn||"sum")))&&w&&ne&&L(w.columns?.get)){const de=w.columns.get(String(ne));if(de&&L(de.formatValue))return de.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(m.decimals??2):String(ee)}function W(ee){return ee?(w&&w.messages||z).t(`stat.tone.${ee}`):""}function J(){if(M)return;const ee=R(),te=o(m)&&!!w&&!f(w),ne=te?null:ee,ae=L(m.baseline)?m.baseline(w):m.baseline;$=ne,C.textContent=m.title??"",C.hidden=!m.title,T.textContent=Z(ne),j.hidden=!te,te&&(j.textContent=w.messages.t("stat.noData"));const de=te||ae===void 0||ae===null?s:n(typeof ne=="number"?ne:null,Number(ae)),ie=t(de.direction,m.goodWhen||"up");if(x.hidden=de.change===null,de.change!==null){const ke=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Re=de.percent===null?Z(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;x.textContent=`${ke} ${Re}`,x.setAttribute("data-tone",ie),x.setAttribute("data-direction",de.direction)}const oe=L(m.interval)?m.interval(ne,w):null,ce=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);P.hidden=!ce,ce&&(P.textContent=`${Z(oe.lower)} – ${Z(oe.upper)}`,Number.isFinite(oe.confidence)&&P.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const fe=te?u:m.bands?r(ne,m.bands,w):null;fe?y.setAttribute("data-tone",fe):y.removeAttribute("data-tone"),E.textContent=L(m.footer)?String(m.footer(ne,w)):m.footer??"",E.hidden=!E.textContent,y.setAttribute("aria-label",[m.title,T.textContent,te?j.textContent:"",ce?P.textContent:"",de.change===null?"":x.textContent,de.change===null?"":W(ie),E.textContent].filter(Boolean).join(", "))}if(w&&L(w.on)&&m.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const te=ne=>{ee==="model:changed"&&!H(ne)||J()};w.on(ee,te),D.push(()=>L(w.off)&&w.off(ee,te))}return J(),{element:()=>y,value:()=>$,refresh:J,destroy(){M=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(a){return B(a)&&"data"in a?a.data:a}function g(a,m){if(!B(a))return;if(!m.includes("."))return a[m];let w=a;for(const v of m.split(".")){if(!B(w))return;w=w[v]}return w}function c(a,m){if(a&&typeof a=="object")return a;if(typeof a!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(a):null}function h(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),xe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Q}});const L=K("packages/core/src/internal/util.js").isObject,F=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class Q{#e;#t;#n;#r=null;#o=[];constructor({grid:H,document:U,kpis:z}){this.#e=H,this.#t=U,this.#n=Array.isArray(z)?z.filter(L):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const U=this.#t.createElement("div");U.className=`lattice ${_.band}`,U.setAttribute("role","group"),U.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=U;for(const z of this.#n){const S=F({...z,grid:this.#e,container:U});this.#o.push(S)}}destroy(){for(const H of this.#o)try{H.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),xe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return jt}});const L=K("packages/core/src/index.js").createHeadlessGrid,F=K("packages/core/src/defaults.js").applyDefaults,Q=K("packages/core/src/export/download.js").downloadBlob,G=K("packages/core/src/internal/util.js"),H=G.fail,U=G.isFunction,z=G.warnOnce,O=K("packages/dom/src/localviews.js").createLocalViewStorage,u=K("packages/dom/src/renderer/index.js").DomRenderer,s=K("packages/dom/src/cell/index.js").createCellLayer,n=K("packages/dom/src/cell/icons.js"),t=n.icon,r=n.iconNames,f=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,g=K("packages/dom/src/ui/index.js"),c=g.StatusBar,h=g.TooltipManager,a=g.Pagination,m=g.GroupByZone,v=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,T=K("packages/dom/src/columnmenu.js").ColumnMenu,x=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,j=K("packages/dom/src/rowreorder.js").RowReorder,$=K("packages/dom/src/alignedgrids.js").AlignedGrids,M=K("packages/dom/src/columntagbar.js").ColumnTagBar,k=K("packages/dom/src/anomalychip.js").AnomalyChip,q=K("packages/dom/src/rowform.js").RowForm,Z=K("packages/dom/src/toolpanelmount.js"),W=Z.ToolPanelDock,J=Z.panelHost,te=K("packages/dom/src/celledit.js").CellEditController,ae=K("packages/dom/src/editbar.js").EditBar,ie=K("packages/dom/src/rangeselect.js").RangeController,ce=K("packages/core/src/model/selection.js").resolveSelectionConfig,ke=K("packages/dom/src/importer.js").ImportController,Ee=K("packages/dom/src/historybar.js").HistoryBar,ye=K("packages/dom/src/diffpaint.js").DiffPainter,Se=K("packages/dom/src/detailhost.js").DetailHost,Ie=K("packages/dom/src/highlightpaint.js").HighlightPainter,Xe=K("packages/dom/src/findpaint.js").FindPainter,Te=K("packages/dom/src/findbar.js").FindBar,Ke=K("packages/dom/src/redactpaint.js").RedactionPainter,ot=K("packages/dom/src/validationpaint.js").ValidationPainter,bt=K("packages/dom/src/presentation.js").PresentationController,Pt=K("packages/dom/src/capture.js").captureElement,Mt=K("packages/dom/src/annotate.js").AnnotationLayer,Bt=K("packages/dom/src/timelinebar.js").TimelineBar,Ge=K("packages/dom/src/commentpaint.js").CommentPainter,pe=K("packages/dom/src/presencepaint.js").PresencePainter,Ue=K("packages/dom/src/commentpanel.js").CommentPanel,rt=K("packages/dom/src/watermark.js").Watermark,we=K("packages/dom/src/maximise.js").Maximiser,Ae=K("packages/dom/src/promptbar.js").PromptBar,me=K("packages/dom/src/kpistrip.js").KpiStrip;function Me(He,ut,it){const kt=ut==="redo"?"toolbar.redo":"toolbar.undo";return!it||!it.label?He(kt):He(ut==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:it.label})}const je=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Ne=2e3;function De(He,ut,it,kt){const Rt=ut.annotate===!0?qe(He,kt):[];if(ut.actions===!1)return[];if(ut.actions===void 0&&ut.side!=="left")return Rt;const It=Array.isArray(ut.actions)?ut.actions:je,yt=(Ut,Jt)=>He.messages.t(Ut,Jt),Lt={undo:{name:"undo",title:()=>Me(yt,"undo",He.history.peek("undo")),icon:"undo",run:()=>He.history.undo(),enabled:()=>He.history.canUndo()},redo:{name:"redo",title:()=>Me(yt,"redo",He.history.peek("redo")),icon:"redo",run:()=>He.history.redo(),enabled:()=>He.history.canRedo()},export:{name:"export",title:()=>yt("toolbar.exportCsv"),icon:"download",run:()=>He.export.csv({download:!0,fileName:ut.exportName})},excel:{name:"excel",title:()=>yt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>He.export.excel({download:!0,fileName:ut.exportName})},clipboard:{name:"clipboard",title:()=>yt("toolbar.clipboard"),icon:"copy",run:()=>He.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>yt("toolbar.print"),icon:"print",run:()=>He.export.print()},pause:{name:"pause",title:()=>{if(!He.updates.paused)return yt("toolbar.pause");const Ut=He.updates.stats().pending;return Ut?yt("toolbar.applyHeld",{count:Ut}):yt("toolbar.resume")},icon:()=>He.updates.paused?"play":"pause",run:()=>He.updates.paused?He.updates.resume():He.updates.pause()},restore:{name:"restore",title:()=>yt("toolbar.restoreView"),icon:"restore",run:()=>He.state.reset(),enabled:()=>He.state.modified()},maximise:{name:"maximise",title:()=>yt(it&&it.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>it&&it.active()?"minimise":"maximise",run:()=>it.toggle()}};return it||delete Lt.maximise,It.map(Ut=>Ut==="-"?{name:"-",separator:!0}:typeof Ut=="string"?Lt[Ut]:!Ut||typeof Ut!="object"||!Ut.name?null:{...Ut,run:U(Ut.run)?()=>Ut.run({grid:He,keys:He.selection&&U(He.selection.keys)?He.selection.keys():[],cells:He.selection&&U(He.selection.cells)?He.selection.cells():[]}):void 0}).filter(Boolean).concat(Rt)}function qe(He,ut){const it={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},kt=(It,yt)=>He.messages.t(It,yt),Rt=["pen","arrow","rect","highlight","erase"].map(It=>({name:It,title:()=>kt(`toolbar.annotate.${It}`),icon:it[It],run:()=>He.annotate?.use(It),active:()=>He.annotate?.tool===It,annotation:!0}));return Rt.push(st(He,kt,ut)),Rt}function st(He,ut,it){return{name:"clearAll",title:()=>ut("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(He.annotate?.count||0)>0,annotation:!0,run:()=>ct(He,ut,it)}}function ct(He,ut,it){const kt=He.toolPanel;if(!kt)return;const Rt=yt=>it?.announce?.(ut(yt),{repeat:!0});kt.removeAction("clearAll");const It=()=>{kt.removeAction("clearAllConfirm"),kt.removeAction("clearAllKeep"),kt.addAction(st(He,ut,it))};kt.addAction({name:"clearAllConfirm",title:()=>ut("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{He.annotate?.clear(),It(),Rt("a11y.annotate.cleared")}}),kt.addAction({name:"clearAllKeep",title:()=>ut("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>It()}),Rt("a11y.annotate.confirmClear")}const ft=["pen","arrow","rect","highlight","erase","clearAll"];function at(He){let ut=null;return{rowCount:()=>{if(U(He.rows.matchCount))return He.rows.matchCount();const it=He.pagination&&U(He.pagination.get)?He.pagination.get():null;return it&&Number.isFinite(it.total)?it.total:He.rows.count()},totalRowCount:()=>U(He.rows.totalCount)?He.rows.totalCount():He.rows.count(),selectedAcrossSource:()=>{ut||(ut=U(He.rendererHost)?He.rendererHost():{});const it=U(ut.selectionSummary)?ut.selectionSummary():null;return it&&it.predicate?{count:it.count}:null},selectedCount:()=>{const it=He.selection&&He.selection.keys?He.selection.keys():null;return it?it.length:0},rangeValues:()=>{const it=He.selection;return!it||!U(it.cells)?[]:it.cells().map(({key:kt,colId:Rt})=>He.rows.value(kt,Rt))},hiddenUnresolved:()=>U(He.comments&&He.comments.hiddenUnresolved)?He.comments.hiddenUnresolved():0,progress:()=>U(He.source&&He.source.progress)?He.source.progress():null,updateStats:()=>He.updates?He.updates.stats():null}}function vt(He,ut){for(const[it,kt]of Object.entries(f||{}))He.register("editor",it,kt);for(const[it,kt]of Object.entries(i||{}))He.register("filter",it,kt);for(const[it,kt]of Object.entries(ut.components||{}))He.register("component",it,kt);for(const[it,kt]of Object.entries(ut.pipes||{}))He.register("pipe",it,kt);for(const[it,kt]of Object.entries(ut.totalFns||{}))He.register("totalFn",it,kt)}function dt(He,ut,it,kt,Rt,It){const yt=[],Lt=ut.viewport;let Ut=null;if(it.maximise!==!1&&(Ut=new we({element:It,document:kt,onChange:()=>ut.invalidate("all"),captureScroll:()=>ut.scrollState(),restoreScroll:lt=>ut.restoreScroll(lt)}),He.maximise=Ut,yt.push(()=>Ut.destroy())),it.statusBar){const lt=typeof it.statusBar=="object"?it.statusBar:{},wt=new c;wt.init({document:kt,host:at(He),panels:lt.panels,registry:lt.registry,locale:He.get("locale"),messages:He.messages}),Lt.statusBar.appendChild(wt.element());const Nt=()=>{const tn=Lt.statusBar.offsetHeight||Lt.statusBar.getBoundingClientRect?.().height||0;Lt.root.style.setProperty("--lattice-status-height",`${Math.ceil(tn)}px`)},Gt=()=>{wt.refresh(),Nt()},Wt=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(tn=>He.on(tn,Gt));Gt(),Nt(),yt.push(()=>{for(const tn of Wt)tn();Lt.root.style.removeProperty("--lattice-status-height"),wt.destroy?.()})}const Jt=ce(it.selection);if(Jt.ranges){const lt=new ie({grid:He,renderer:ut,document:kt});lt.mount(),He.ranges=lt,yt.push(()=>lt.destroy())}if(it.import){const lt=new ke({grid:He,renderer:ut,document:kt,settings:typeof it.import=="object"?it.import:{}});He.importer=lt,yt.push(()=>lt.destroy())}if(it.historyBar){const lt=typeof it.historyBar=="object"?it.historyBar.element:null,wt=new Ee;wt.init({document:kt,host:{undo:()=>He.history.undo(),redo:()=>He.history.redo(),canUndo:()=>He.history.canUndo(),canRedo:()=>He.history.canRedo(),peek:Gt=>He.history.peek(Gt),list:()=>He.history.list()},props:typeof it.historyBar=="object"?it.historyBar:{}}),(lt||Lt.root).appendChild(wt.element());const Nt=[He.on("history:changed",()=>wt.refresh())];He.historyBar=wt,yt.push(()=>{for(const Gt of Nt)Gt();wt.destroy()})}if(it.diff){const lt=new ye({grid:He,renderer:ut});lt.mount(),He.diffPainter=lt,yt.push(()=>lt.destroy())}if(it.ai&&U(it.ai.ask)){const lt=new Ae;lt.init({document:kt,grid:He,ask:it.ai.ask,schemaOptions:it.ai.schemaOptions,context:it.ai.context,placeholder:it.ai.placeholder});const wt=it.ai.element||Lt.root;wt===Lt.root?wt.insertBefore(lt.element(),wt.firstChild):wt.appendChild(lt.element()),He.promptBar=lt,yt.push(()=>lt.destroy())}if(it.groupPanel){const lt=typeof it.groupPanel=="object"?it.groupPanel:{},wt=new m;wt.init({document:kt,grid:He,host:J(He,kt,(Nt,Gt)=>ut.announce?.(Nt,Gt)),props:{header:Lt.header,hint:lt.hint}}),Lt.root.insertBefore(wt.element(),Lt.header),He.groupPanel=wt;for(const Nt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])U(He.on)&&yt.push(He.on(Nt,()=>wt.refresh()));yt.push(()=>wt.destroy())}if(it.kpis){const lt=new me({grid:He,document:kt,kpis:it.kpis});lt.active&&(lt.mount(),Lt.root.insertBefore(lt.element(),Lt.header),He.kpiStrip=lt,yt.push(()=>lt.destroy()))}if(it.toolPanel){const lt=typeof it.toolPanel=="object"?it.toolPanel:{},wt=new W({grid:He,document:kt,root:Lt.root,panels:lt.panels,openPanel:lt.openPanel,side:lt.side,icons:lt.icons,actions:De(He,lt,Ut,ut),announce:(Nt,Gt)=>ut.announce?.(Nt,Gt)});wt.mount(),He.toolPanel=wt,yt.push(()=>wt.destroy()),lt.annotate===void 0&&(yt.push(He.on("presentation:started",()=>{for(const Nt of qe(He,ut))wt.addAction(Nt)})),yt.push(He.on("presentation:ended",()=>{for(const Nt of ft)wt.removeAction(Nt)})))}if(!!it.pagination&&(()=>{const lt=typeof it.pagination=="object"?it.pagination:{};return He.pagination.set({pageSize:Number(lt.pageSize)||100}),He.pagination.get().pageSize>0})()){const lt=typeof it.pagination=="object"?it.pagination:{},wt=new a;wt.init({document:kt,pageSize:lt.pageSize,pageSizes:lt.pageSizes,page:lt.page,total:lt.total,locale:He.get("locale"),messages:He.messages,onChange:({page:Wt,pageSize:tn})=>He.pagination.set({page:Wt,pageSize:tn})});const Nt=()=>{const Wt=He.pagination.get();wt.total=Wt.total,wt.counting=Wt.counting===!0,wt.hasMore=Wt.total==null&&Wt.pageCount>Wt.page+1,wt.page=Wt.page,wt.paint()};He.pagination.set({pageSize:wt.pageSize}),Nt();const Gt=["rows:changed","filter:changed","model:changed"].map(Wt=>He.on(Wt,Nt));Lt.statusBar.appendChild(wt.element()),yt.push(()=>{for(const Wt of Gt)Wt();wt.destroy?.()})}if(it.edit!==!1)if(it.editBar){const lt=new ae({grid:He,document:kt,root:Lt.root});lt.mount(),He.editBar=lt,yt.push(()=>lt.destroy())}else{const lt=new te({grid:He,document:kt,renderer:ut,registry:Rt,cellLayer:ut.cellLayer});lt.mount(),yt.push(()=>lt.destroy())}const dn=new y({grid:He,document:kt,layer:Lt.overlays,registry:Rt});dn.mount(),yt.push(()=>dn.destroy());const qt=new T({grid:He,document:kt,host:Lt.root,cellMenu:it.contextMenu!==!1,headerMenu:it.columnMenu!==!1,items:U(it.contextMenu)?it.contextMenu:void 0,headerItems:U(it.columnMenu)?it.columnMenu:void 0});if(qt.mount(),yt.push(()=>qt.destroy()),Array.isArray(it.alignedGrids)&&it.alignedGrids.length){const lt=new $;lt.add(He);for(const wt of it.alignedGrids)wt&&wt!==He&&lt.add(wt);yt.push(()=>lt.destroy())}const _t=new q({grid:He,renderer:ut,document:kt,registry:Rt});_t.active&&(_t.mount(),yt.push(()=>_t.destroy())),Object.defineProperty(He,"form",{configurable:!0,value:Object.freeze({open(lt){return _t.active?_t.openRow(lt):!1},openNew(lt){return _t.active?_t.openNew(lt):(z("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){_t.active&&_t.close()},save(){return _t.active?_t.save():!1},isOpen(){return _t.active?_t.open:!1}})}),yt.push(()=>{delete He.form}),Object.defineProperty(He,"icons",{configurable:!0,value:Object.freeze({get(lt){const wt=t(lt);return wt?{viewBox:wt.viewBox,paths:wt.paths.slice(),paint:wt.paint==="stroke"?"stroke":"fill"}:null},names(){return r()}})}),yt.push(()=>{delete He.icons});const Ct=new M({grid:He,renderer:ut,document:kt});Ct.active&&(Ct.mount(),yt.push(()=>Ct.destroy()));const xt=new k({grid:He,renderer:ut,document:kt});xt.active&&(xt.mount(),yt.push(()=>xt.destroy()));const zt=new j({grid:He,renderer:ut,document:kt});if(zt.active){zt.mount(),zt.paint();const lt=He.on("render:done",()=>zt.paint());yt.push(()=>{lt(),zt.destroy()})}if(it.shortcuts!==!1){const lt=new x({grid:He,renderer:ut});lt.mount(),yt.push(()=>lt.destroy())}const Kt=new Ie({grid:He,renderer:ut,window:kt.defaultView||void 0});Kt.mount(),yt.push(()=>Kt.destroy());const Xt=new Xe({grid:He,renderer:ut,window:kt.defaultView||void 0});if(Xt.mount(),yt.push(()=>Xt.destroy()),it.find!==!1){const lt=new Te({grid:He,renderer:ut,document:kt,settings:it.find});lt.mount(),yt.push(()=>lt.destroy())}const Yt=new Ke({grid:He,renderer:ut});Yt.mount(),yt.push(()=>Yt.destroy());const Qt=new ot({grid:He,renderer:ut});Qt.mount(),yt.push(()=>Qt.destroy());const rn=new bt({grid:He,renderer:ut,maximiser:Ut});rn.mount(),yt.push(()=>rn.destroy());const en=new Bt({grid:He,renderer:ut});en.mount(),yt.push(()=>en.destroy()),it.environment||He.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let cn=null;for(const[lt,wt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])yt.push(He.on(lt,()=>{cn=wt}));yt.push(He.on("render:done",lt=>{He.diagnostics.render(cn||lt.cause,lt.phases),cn=null}));const ln=kt.defaultView;if(ln&&U(ln.requestAnimationFrame)){let lt=ln.requestAnimationFrame(function wt(Nt){He.diagnostics.frame(Nt),lt=ln.requestAnimationFrame(wt)});yt.push(()=>{U(ln.cancelAnimationFrame)&&ln.cancelAnimationFrame(lt)})}const yn=new pe({grid:He,renderer:ut});if(yn.mount(),yt.push(()=>yn.destroy()),yt.push(He.on("presence:lockRefused",lt=>yn.announceRefusal(lt.peer))),He.presence&&He.presence.enabled){for(const Nt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])yt.push(He.on(Nt,()=>He.presence.publish()));let lt="";yt.push(He.on("render:done",()=>{const Nt=ut.focusState&&ut.focusState(),Gt=Nt?`${Nt.rowKey}${Nt.colId}`:"";Gt!==lt&&(lt=Gt,He.presence.publish())}));const wt=It.ownerDocument;if(wt&&U(wt.addEventListener)){const Nt=()=>He.presence.setPaused(wt.visibilityState==="hidden");wt.addEventListener("visibilitychange",Nt),Nt(),yt.push(()=>wt.removeEventListener("visibilitychange",Nt))}}const bn=new Ge({grid:He,renderer:ut});bn.mount(),yt.push(()=>bn.destroy());const wn=new Ue({grid:He,renderer:ut});wn.mount(),yt.push(()=>wn.destroy()),yt.push(He.on("facet:computed",()=>ut.refreshHeader?.())),Jt&&Jt.headerCheckbox===!0&&yt.push(He.on("selection:changed",()=>ut.refreshHeader?.())),yt.push(He.on("facet:expanded",()=>ut.invalidate("columns"))),yt.push(He.on("model:changed",()=>ut.invalidate("rows")));const Zt=(lt,wt)=>ut.announce?.(lt,wt),mn=He.messages,Vt=(lt,wt)=>mn.t(lt,wt),gn=lt=>Vt("count.rows",{count:lt});yt.push(He.on("sort:changed",()=>{const lt=He.sort.get();if(!lt.length){Zt(Vt("a11y.sort.cleared"));return}const wt=lt.map(Nt=>{const Gt=He.columns.get(Nt.col);return Vt("a11y.sort.column",{column:Gt&&Gt.title||Nt.col,direction:Vt(Nt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Zt(Vt("a11y.sort.by",{columns:mn.list(wt)}))})),yt.push(He.on("filter:changed",()=>{const lt=He.rows.matchCount?He.rows.matchCount():He.rows.count(),wt=He.rows.totalCount?He.rows.totalCount():lt;Zt(lt===wt?Vt("a11y.filter.cleared",{rows:gn(wt)}):Vt("a11y.filter.applied",{shown:gn(lt),total:gn(wt)}))})),yt.push(He.on("selection:changed",()=>{const lt=He.selection.keys().length;Zt(lt===0?Vt("a11y.selection.cleared"):Vt("a11y.selection.count",{count:lt}))})),yt.push(He.on("group:toggled",lt=>{const wt=He.rows.byKey?He.rows.byKey(lt.key):null,Nt=(wt&&(wt.groupLabel??wt.groupValue))??lt.key;Zt(Vt(lt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Nt,rows:gn(He.rows.count())}))})),yt.push(He.on("column:grouped",lt=>{const wt=Array.isArray(lt.columns)?lt.columns:[];if(!wt.length){Zt(Vt("a11y.group.cleared"));return}const Nt=wt.map(Gt=>{const Wt=He.columns.get(Gt);return Wt&&Wt.title||Gt});Zt(Vt("a11y.group.by",{columns:mn.list(Nt)}))})),yt.push(He.on("page:changed",lt=>{const wt=Number(lt.size)||0,Nt=Number(lt.total)||0,Gt=wt>0?Math.max(1,Math.ceil(Nt/wt)):1;Zt(Vt("a11y.page.position",{page:(Number(lt.page)||0)+1,pages:Gt}))}));let on={added:0,removed:0},sn=null;const Cn=()=>{sn=null;const lt=[];on.added&&lt.push(Vt("count.rowsAdded",{count:on.added})),on.removed&&lt.push(Vt("count.rowsRemoved",{count:on.removed})),on={added:0,removed:0},lt.length&&Zt(mn.list(lt))};yt.push(He.on("rows:changed",lt=>{if(!lt||typeof lt.added!="number")return;const wt=Number(lt.added)||0,Nt=Number(lt.removed)||0;!wt&&!Nt||(on.added+=wt,on.removed+=Nt,sn||(sn=setTimeout(Cn,Ne)))})),yt.push(()=>{sn&&clearTimeout(sn)}),yt.push(He.on("rows:paused",()=>{sn&&(clearTimeout(sn),sn=null),on={added:0,removed:0},Zt(Vt("a11y.updates.paused"),{repeat:!0})})),yt.push(He.on("rows:resumed",()=>Zt(Vt("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const Kn=()=>{hn=null;const{count:lt,first:wt}=fn;if(fn={count:0,first:null},!lt||!wt)return;const Nt=He.columns.get(wt.colId),Gt=Nt&&Nt.title||wt.colId,Wt=wt.reason?Vt("a11y.edit.reason",{reason:wt.reason}):"";if(lt===1){const tn=wt.restored===void 0||wt.restored===null||wt.restored===""?Vt("value.empty"):String(wt.restored);Zt(Vt("a11y.edit.refusedOne",{column:Gt,value:tn,reason:Wt}),{repeat:!0});return}Zt(Vt("a11y.edit.refusedMany",{count:lt,reason:Wt}),{repeat:!0})};yt.push(He.on("cell:reverted",lt=>{!lt||!lt.applied||(fn.count+=1,fn.first||(fn.first=lt),hn||(hn=setTimeout(Kn,150)))})),yt.push(()=>{hn&&clearTimeout(hn)}),yt.push(He.on("history:applied",lt=>{const wt=!!(lt&&lt.direction==="redo"),Nt=lt&&lt.step&&lt.step.label;Zt(Nt?Vt(wt?"a11y.history.redo":"a11y.history.undo",{label:Nt}):Vt(wt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Mt({grid:He,renderer:ut,seed:it.state&&Array.isArray(it.state.annotations)?it.state.annotations:null});vn.mount(),yt.push(()=>vn.destroy()),He.annotate=vn,He.capture=async(lt={})=>{const{blob:wt,width:Nt,height:Gt}=await Pt(ut.viewport.root,lt);return(lt.download===!0||lt.download!==!1&&lt.fileName)&&Q(wt,lt.fileName||`${He.get("exportName")||"grid"}.png`),He.emit("presentation:captured",{width:Nt,height:Gt,bytes:wt.size,mimeType:wt.type,fileName:lt.fileName||null},"api"),wt};const kn=new rt({grid:He,document:kt,element:Lt.overlays,window:kt.defaultView||void 0});kn.mount(),yt.push(()=>kn.destroy());const En=new h({grid:He,document:kt,element:Lt.overlays});En.mount?.(),yt.push(()=>En.destroy?.());const Tn=new v({grid:He,host:He.rendererHost(),viewport:Lt,document:kt});return Tn.mount(),yt.push(()=>Tn.destroy()),yt}function mt(He){const ut=[],it=kt=>{if(kt&&(kt.__lattice&&ut.push(kt),kt.children))for(const Rt of kt.children)it(Rt)};return it(He),ut}function jt(He,ut={}){(!He||typeof He!="object"||!("appendChild"in He))&&H("createGrid needs a host element as its first argument."),ut=F(ut);const it=He.ownerDocument||(typeof document<"u"?document:null);it||H("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const kt=it.documentElement&&it.documentElement.lang,Rt=!ut.licence&&U(it.querySelector)?it.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,It={...ut};if(!ut.locale&&kt&&(It.locale=kt),Rt&&(It.licence=Rt),ut.views&&ut.views.local)if(ut.views.storage)z("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const qt=ut.views.local===!0?{}:ut.views.local;It.views={...ut.views,storage:O(qt)}}const yt=L(It),Lt=yt.rendererHost();Lt.document=it,vt(Lt.registry,ut),Lt.cellLayer=s(Lt),Lt.detailHost=new Se({grid:yt,document:He.ownerDocument||globalThis.document,createGrid:(qt,_t)=>jt(qt,_t)});const Ut=new u(He,Lt),Jt=yt.on("detail:toggled",()=>{Lt.detailHost.syncTarget(),Lt.detailHost.prune()}),pn=yt.on("config:changed",qt=>{qt&&qt.key==="detail"&&Lt.detailHost.reconfigure()});yt.on("destroy",()=>{Jt(),pn(),Lt.detailHost.destroy()}),Lt.detailHost.syncTarget(),yt.attachRenderer(Ut),Ut.mount();const an=dt(yt,Ut,ut,it,Lt.registry,He),dn=yt.destroy.bind(yt);return yt.destroy=()=>{for(const qt of an)try{qt()}catch{}He.__lattice===yt&&(He.__lattice=null),dn()},He.__lattice=yt,yt}}),xe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return s}});const X=K("packages/core/src/internal/util.js"),L=X.isFunction,B=X.warnOnce,_=K("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,G=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,U=K("packages/dom/src/createGrid.js").createGrid,z=new Set([...Object.keys(_),...Object.keys(G)]);function S(n,t){for(const r of n.children)if(r.tagName===t.toUpperCase())return r;return null}function O(n,t){const r=[];for(const o of n.children)o.tagName===t.toUpperCase()&&r.push(o);return r}function b(n,t){const r=L(n.getAttribute)?n.getAttribute("data-field"):null;return r||String(n.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${t}`}function u(n){const t=n.trim();if(t==="")return null;if(t==="true"||t==="false")return t==="true";const r=Number(t);return Number.isFinite(r)&&t!==""?r:t}function d(n){const t=S(n,"thead"),r=S(t||n,"tr"),f=(r?O(r,"th").length?O(r,"th"):O(r,"td"):[]).map((c,h)=>{const a=b(c,h),m={id:a,field:a,title:String(c.textContent||"").trim()||a},w=L(c.getAttribute)?c.getAttribute("data-type"):null;w&&(z.has(w)?m.type=w:B(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${a}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const v=L(c.getAttribute)?c.getAttribute("data-format"):null;return v&&(m.format=v),m}),l=S(n,"tbody"),g=(l?O(l,"tr"):O(n,"tr").filter(c=>c!==r)).map((c,h)=>{const a=O(c,"td"),w={__row:(L(c.getAttribute)?c.getAttribute("data-id"):null)||`row${h}`};return f.forEach((v,p)=>{w[v.field]=a[p]?u(String(a[p].textContent||"")):null}),w});return{columns:f,rows:g}}function s(n,t={}){const{columns:r,rows:o}=d(n),f=n.ownerDocument.createElement("div");return n.parentNode.insertBefore(f,n),n.parentNode.removeChild(n),U(f,{rowKey:"__row",columns:r,rows:o,...t,columns:t.columns!==void 0?t.columns:r,rows:t.rows!==void 0?t.rows:o})}}),xe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return z}});const L=K("packages/core/src/internal/util.js").isFunction,F=K("packages/dom/src/createGrid.js").createGrid,Q=K("packages/dom/src/hydrate.js").hydrateTable;function G(S,O){const b=[];return L(S.hasAttribute)&&S.hasAttribute(O)&&b.push(S),L(S.querySelectorAll)&&b.push(...S.querySelectorAll(`[${O}]`)),b}function H(S){const O=S.parentNode;if(!O||!O.children)return null;const b=[...O.children],u=b.indexOf(S),d=[b[u+1],b[u-1]];for(const s of d)if(s&&s.tagName==="SCRIPT"&&L(s.getAttribute)&&s.hasAttribute("data-lattice-config"))return s;return null}function U(S){const O=H(S);if(!O)return{};try{return JSON.parse(O.textContent||"{}")}catch(b){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",b),{}}}function z(S){const O=S||(typeof document<"u"?document:null);if(!O)return[];const b=[];for(const u of G(O,"data-lattice-grid")){if(u.__lattice)continue;const d=U(u);b.push(u.tagName==="TABLE"?Q(u,d):F(u,d))}return b}}),xe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const X=K("packages/dom/src/createGrid.js"),L=X.createGrid,B=K("packages/dom/src/hydrate.js"),F=B.hydrateTable,_=K("packages/dom/src/autoinit.js"),Q=_.autoInit,G=K("packages/dom/src/localviews.js"),H=G.createLocalViewStorage,U=K("packages/core/src/index.js"),z=U.createHeadlessGrid,S=U.registerModules,O=U.setLicence,b=U.version,u=U.getVersion,d=U.serialiseState,s=U.restoreState,n=U.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return X.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return X.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return B.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return B.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return G.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return G.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return U.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return U.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return U.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return U.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return U.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return U.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return U.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return U.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return U.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return U.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return U.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return U.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return U.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return U.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return U.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return U.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return U.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return U.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return U.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return U.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return U.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return U.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return U.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return U.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return U.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return U.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return U.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return U.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return U.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return U.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return U.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return U.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return U.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return U.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return U.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return U.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return U.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return U.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return U.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return U.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return U.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return U.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return U.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return U.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return U.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return U.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return U.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return U.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return U.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return U.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return U.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return U.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return U.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return U.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return U.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return U.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return U.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return U.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return U.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return U.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return U.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return U.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return U.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return U.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return U.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return U.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return U.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return U.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return U.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return U.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return U.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return U.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return U.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return U.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return U.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return U.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return U.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return U.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return U.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return U.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return U.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return U.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return U.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return U.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return U.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return U.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return U.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return U.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return U.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return U.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return U.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return U.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return U.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return U.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return U.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return U.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return U.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return U.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return U.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return U.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return U.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return U.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return U.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return U.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return U.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return U.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return U.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return U.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return U.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return U.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return U.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return U.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return U.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return U.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return U.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return U.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return U.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return U.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return U.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return U.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return U.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return U.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return U.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return U.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return U.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return U.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return U.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return U.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return U.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return U.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return U.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return U.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return U.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return U.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return U.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return U.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return U.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return U.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return U.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return U.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return U.VERSION}});const r=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return r.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const f=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return f.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return f.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return f.autoGroupMenuItems}});const l=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const g=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const h=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return h.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return h.HISTORY_CLS}});const a=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return a.DiffPainter}});const m=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return m.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return m.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return m.summariseDiff}});const w=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return w.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return w.PROMPT_CLASS}});const v=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return v.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return v.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return v.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return v.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return v.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return v.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return v.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return v.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return v.sanitiseHtml}});const p=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return p.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return p.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return p.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return p.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const C=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return C.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return C.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return C.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return C.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return C.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return C.OverlayLayer}});const T=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return T.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return T.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return T.licenceState}});const P=Object.freeze({createGrid:L,createHeadlessGrid:z,defaults:n,registerModules:S,setLicence:O,version:b,autoInit:Q,hydrateTable:F,serialiseState:d,restoreState:s,createLocalViewStorage:H}),x=P});try{Gn("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return oe}});const fe="1.81.0";async function he(){return fe}const Q="1.81.0",z=new Set,ne=2e3;function _(w){if(z.add(w),z.size>ne){const v=z.values().next().value;v!==void 0&&z.delete(v)}}const T=[],K=500;function ie(w,v,Z){T.push({key:w,level:v,message:Z.map(x=>typeof x=="string"?x:J(x)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function le(){return T.map(w=>({...w}))}function ue(w){if(w.length===0||typeof w[0]!="string")return w;const v=w[0].replace(/^\\[lattice\\]\\s*/,"");return v===w[0]?w:[v,...w.slice(1)]}function W(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"warn",Z),console.warn("[lattice]",...Z)}function L(w,...v){if(z.has(w))return;_(w);const Z=ue(v);ie(w,"info",Z),console.info("[lattice]",...Z)}function Y(){z.clear(),T.length=0}function ee(w,v){const Z=new Error(`[lattice] ${w}`);throw v!==void 0&&(Z.cause=v),Z}function C(w,v){w||ee(v)}const A=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function s(w){return typeof w=="function"}function u(w){return w==null}function f(w){return w==null||w===""}function l(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const t=new Map;function a(w){let v=t.get(w);if(v)return v;if(!w.includes("."))v=Z=>Z?.[w];else{const Z=w.split("."),x=Z.length;v=de=>{let we=de;for(let ge=0;ge<x;ge++){if(we==null)return;we=we[Z[ge]]}return we}}return t.set(w,v),v}const m=new Map;function e(w){let v=m.get(w);if(v)return v;if(!w.includes("."))v=(Z,x)=>{Z!=null&&(Z[w]=x)};else{const Z=w.split("."),x=Z.length-1;v=(de,we)=>{let ge=de;for(let pe=0;pe<x;pe++){if(ge==null)return;const Te=Z[pe];ge[Te]==null&&(ge[Te]={}),ge=ge[Te]}ge!=null&&(ge[Z[x]]=we)}}return m.set(w,v),v}function d(w,v){return a(v)(w)}function h(w,v,Z){e(v)(w,Z)}function r(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,Z=>Z.toUpperCase()):""}const n={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function c(w){const v=w==null?"":String(w);return/[&<>"\']/.test(v)?v.replace(/[&<>"\']/g,Z=>n[Z]):v}function g(w){return String(w).replace(/\\w\\S*/g,v=>v[0].toUpperCase()+v.slice(1).toLowerCase())}function M(w,v,Z){if(w!==void 0)return w===!0?{enabled:!0,...Z}:w===!1?{enabled:!1}:i(w)?w:{[v]:w,enabled:!0}}function N(w){return w==null?[]:Array.isArray(w)?w:[w]}const G=Object.freeze(new Set(["__proto__","constructor","prototype"]));function F(w,v){if(!i(w))return i(v)?{...v}:v;if(!i(v))return v===void 0?w:v;const Z={...w};for(const x of Object.keys(v)){if(G.has(x))continue;const de=v[x];de!==void 0&&(Z[x]=i(de)&&i(Z[x])?F(Z[x],de):de)}return Z}function R(w,v){if(!i(w)||!i(v)||w===v)return v;const Z=Object.create(Object.getPrototypeOf(w));return Object.assign(Z,w,v),Z}class X{#t;#e=new Map;#n;constructor(v=256,Z=null){this.#t=v,this.#n=Z}get size(){return this.#e.size}get max(){return this.#t}set max(v){this.#t=v,this.#r()}has(v){return this.#e.has(v)}get(v){const Z=this.#e;if(!Z.has(v))return;const x=Z.get(v);return Z.delete(v),Z.set(v,x),x}peek(v){return this.#e.get(v)}set(v,Z){const x=this.#e;return x.has(v)&&x.delete(v),x.set(v,Z),this.#r(),Z}delete(v){const Z=this.#e.get(v);return this.#e.delete(v)&&this.#n&&this.#n(Z,v),Z}clear(){if(this.#n)for(const[v,Z]of this.#e)this.#n(Z,v);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const v=this.#e;for(;v.size>this.#t;){const Z=v.keys().next().value,x=v.get(Z);v.delete(Z),this.#n&&this.#n(x,Z)}}}const E=new Map;function S(w,v){const Z=`${w||""}|${v?JSON.stringify(v):""}`;let x=E.get(Z);return x||(x=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...v}),E.set(Z,x)),x}function U(w,v){if(w===v)return 0;if(w==null)return 1;if(v==null)return-1;if(typeof w=="number"&&typeof v=="number")return Number.isNaN(w)?Number.isNaN(v)?0:1:Number.isNaN(v)||w<v?-1:w>v?1:0;const Z=String(w),x=String(v);return Z<x?-1:Z>x?1:0}function H(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const $=typeof requestAnimationFrame=="function";function re(w){return $?requestAnimationFrame(w):setTimeout(()=>w(H()),16)}function te(w){w!=null&&($?cancelAnimationFrame(w):clearTimeout(w))}function ae(w){let v=null,Z=null;const x=()=>{v=null;const we=Z;Z=null,w(...we||[])},de=(...we)=>{Z=we,v===null&&(v=re(x))};return de.cancel=()=>{te(v),v=null,Z=null},de.flush=()=>{v!==null&&(te(v),x())},de}function p(w,v){let Z=null,x=null;const de=()=>{if(Z=null,x===null)return;const pe=x;x=null,w(...pe),we()},we=()=>{Z=setTimeout(de,v),typeof Z?.unref=="function"&&Z.unref()},ge=(...pe)=>{Z===null?(w(...pe),we()):(x=pe,clearTimeout(Z),we())};return ge.flush=()=>{if(Z!==null&&clearTimeout(Z),Z=null,x===null)return;const pe=x;x=null,w(...pe)},ge.cancel=()=>{Z!==null&&clearTimeout(Z),Z=null,x=null},ge.pending=()=>Z!==null||x!==null,ge}function B(w,v=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:v}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let q=0;function oe(w="l"){return`${w}${(++q).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.isFunction,z=1,ne=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ie(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ie(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class le{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let l=0;l<u.length;l++){let t=u[l];for(;t;)t&=t-1,f++}return f}}class ue{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const f=this.#e.get(u);if(f!==void 0)return f;const l=this.#t.length;return this.#t.push(u),this.#e.set(u,l),this.#n++,l}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",l=this.#r.get(f);if(l&&l.version===this.#n)return l.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const m=he(u).compare,e=this.#t,d=Array.from(a).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function W(s){if(s==null)return null;const u=s.presence?new le(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ue(s.dict):null,l=s.values,t=s.offsets??null,a=s.kind,m=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(l[e]):l[e];case"bitset":return(l[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=f?f.valueOf(l[n]):l[n];return r}default:return l[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:l,presence:u,dict:f,offsets:t,get:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=W(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let l=0;l<s.length;l++)if(s[l].length>=f){const t=s.splice(l,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let l=0;l<u.length;l++)if(u[l].length>=f)return u.splice(l,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=l=>{if(!ee(l))return;const t=l.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const l of s)f(l);return u}if(typeof s=="object")for(const l of Object.keys(s)){const t=s[l];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function A(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const l of s)if(!A(l,u+1))return!1;return!0}for(const l of Object.keys(s))if(!A(s[l],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const l=f.conditions;if(Array.isArray(l))for(const t of l)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const ne=Math.max(0,z|0);this.#n=ne,this.#e=new Uint8Array(Math.ceil(ne/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,ne){return ne?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const ne=Math.max(0,z|0);if(ne<=this.#n)return this;const _=Math.ceil(ne/fe);if(_>this.#e.length){const T=new Uint8Array(_);T.set(this.#e),this.#e=T}return this.#n=ne,this}count(){const z=this.#e,ne=he.#t;let _=0;for(let T=0;T<z.length;T++)_+=ne[z[T]];return _}and(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]&=ne[K];for(let K=T;K<_.length;K++)_[K]=0;return this}or(z){const ne=z instanceof he?z.words:z,_=this.#e,T=Math.min(_.length,ne.length);for(let K=0;K<T;K++)_[K]|=ne[K];return this}not(){const z=this.#e;for(let ne=0;ne<z.length;ne++)z[ne]=~z[ne]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const ne=this.#n>>3;ne<this.#e.length&&(this.#e[ne]&=(1<<z)-1)}static from(z){const ne=Array.isArray(z)?z:Array.from(z),_=new he(ne.length);for(let T=0;T<ne.length;T++)ne[T]&&_.set(T);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let T=0;T<_.length;T++){const K=_[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(_+=K.length*2),_+=16}return _}codeOf(_){const T=this.#e.get(_);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(_),this.#e.set(_,K),this.#n++,K}lookup(_){const T=this.#e.get(_);return T===void 0?-1:T}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const T=_||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,ie=new Array(K);for(let W=0;W<K;W++)ie[W]=W;const J=he(_).compare,le=this.#t;ie.sort((W,L)=>this.#h(le[W],le[L],J));const ue=new Uint32Array(K);for(let W=0;W<K;W++)ue[ie[W]]=W;return this.#r=ue,this.#i=this.#n,this.#s=T,ue}#h(_,T,K){return typeof _=="string"&&typeof T=="string"?K(_,T):Q(_,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(Q={}){const z=Math.max(1,Q.rows??16),ne=Math.max(1,Q.values??z);this.#t=new Int32Array(ne),this.#e=new Uint32Array(z+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,z){if(Q<0||Q>=this.#n)return!1;const ne=this.#t,_=this.#e[Q+1];for(let T=this.#e[Q];T<_;T++)if(ne[T]===z)return!0;return!1}hasAny(Q,z){for(let ne=0;ne<z.length;ne++)if(this.has(Q,z[ne]))return!0;return!1}hasAll(Q,z){for(let ne=0;ne<z.length;ne++)if(!this.has(Q,z[ne]))return!1;return!0}hasNone(Q,z){return!this.hasAny(Q,z)}push(Q){const z=this.#n,ne=Q.length;this.#i(z+1),this.#s(this.#r+ne);const _=this.#r;for(let T=0;T<ne;T++)this.#t[_+T]=Q[T]|0;return this.#r+=ne,this.#n=z+1,this.#e[z]=_,this.#e[z+1]=this.#r,z}write(Q,z){if(Q===this.#n){this.push(z);return}if(Q<0||Q>this.#n)return;const ne=this.#e[Q],_=this.#e[Q+1],T=z.length;if(_-ne===T){for(let K=0;K<T;K++)this.#t[ne+K]=z[K]|0;return}this.#h(Q,z)}compact(Q,z,ne){const _=this.#t,T=this.#e,K=this.#n,ie=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let le=0;for(let ue=0;ue<K;ue++){if(Q[ue]===ne)continue;const W=T[ue],L=T[ue+1];J[Q[ue]]=le;for(let Y=W;Y<L;Y++)ie[le++]=_[Y];J[Q[ue]+1]=le}this.#t=ie,this.#e=J,this.#n=z,this.#r=le}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<Q;)z=z*2||16;const ne=new Uint32Array(z+1);ne.set(this.#e),this.#e=ne}#s(Q){if(Q<=this.#t.length)return;let z=this.#t.length;for(;z<Q;)z=z*2||16;const ne=new Int32Array(z);ne.set(this.#t),this.#t=ne}#h(Q,z){const ne=this.#t,_=this.#e,T=this.#n,K=z.length-(_[Q+1]-_[Q]),ie=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(_.length);let le=0;for(let ue=0;ue<T;ue++){if(J[ue]=le,ue===Q)for(let W=0;W<z.length;W++)ie[le++]=z[W]|0;else for(let W=_[ue];W<_[ue+1];W++)ie[le++]=ne[W];J[ue+1]=le}this.#t=ie,this.#e=J,this.#r=le}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return A}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,Q=fe.defaultCompare,z=fe.warnOnce;function ne(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(z(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.get(s);if(u)return u;let f="unknown";try{let l=null;typeof s.from=="function"?l=s.from([!1,!0]):(l=new s(8),l.set(1));const t=l&&l.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function ie(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function J(i){return!i||!i.presence?null:ie(i.presence)}function le(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ue(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function W(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const l=u[s],t=u[s+1];if(!(t>l))return[];const a=i.dict,m=new Array(t-l);for(let e=l;e<t;e++)m[e-l]=a?ue(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const l=i.dict;return u?t=>u(t)?ue(l,s[t]):null:t=>ue(l,s[t])}if(f==="bitset"){const l=ie(s);return u?t=>u(t)?l(t)===1:null:t=>l(t)===1}if(f==="multi")return u?l=>u(l)?W(i,l):null:l=>W(i,l);if(!s&&typeof i.get=="function"){const l=i.get.bind(i);return t=>{const a=l(t);return a===void 0?null:a}}return u?l=>{if(!u(l))return null;const t=s[l];return t===void 0?null:t}:l=>{const t=s[l];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const l=Object.is(i,-0),t=Object.is(s,-0);return l===t?0:l?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const l=typeof u,t=typeof f;if(l==="string"&&t==="string")return s.compare(u,f);if(l==="number"&&t==="number")return Y(u,f);if(l==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),m=f instanceof Date?f.getTime():Number(f);return Y(a,m)}return Q(u,f)}}function C(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,l=ee(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>l(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function A(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return R}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,Q=fe.dictRanks,z=fe.dictSize,ne=fe.identity,_=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,ie=fe.valueComparator,J=fe.valueReader,le=new Uint32Array(0),ue=new ArrayBuffer(8),W=new Float64Array(ue),L=new Uint32Array(ue),Y=(W[0]=-1,(L[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function C(E,S){W[0]=E;let U=L[Y],H=L[ee];(U&2147483648)!==0?(U=~U>>>0,H=~H>>>0):U=(U^2147483648)>>>0,S[0]=H,S[1]=U}function A(E,S,U,H){if(H<2)return E;const $=new Uint32Array(256*8);for(let w=0;w<H;w++){const v=S[w],Z=U[w];$[v&255]++,$[256+(v>>>8&255)]++,$[512+(v>>>16&255)]++,$[768+(v>>>24&255)]++,$[1024+(Z&255)]++,$[1280+(Z>>>8&255)]++,$[1536+(Z>>>16&255)]++,$[1792+(Z>>>24&255)]++}let re=E,te=S,ae=U,p=new Uint32Array(H),B=new Uint32Array(H),q=new Uint32Array(H);const oe=new Uint32Array(256);for(let w=0;w<8;w++){const v=w<<8,Z=(w&3)<<3,x=w>=4;let de=!1;for(let pe=0;pe<256;pe++)if($[v+pe]===H){de=!0;break}if(de)continue;let we=0;for(let pe=0;pe<256;pe++)oe[pe]=we,we+=$[v+pe];for(let pe=0;pe<H;pe++){const Te=te[pe],Le=ae[pe],Be=(x?Le:Te)>>>Z&255,ze=oe[Be]++;p[ze]=re[pe],B[ze]=Te,q[ze]=Le}let ge=re;re=p,p=ge,ge=te,te=B,B=ge,ge=ae,ae=q,q=ge}return re}function i(E,S,U){if(U<2)return E;const H=new Uint32Array(256*4);for(let B=0;B<U;B++){const q=S[B];H[q&255]++,H[256+(q>>>8&255)]++,H[512+(q>>>16&255)]++,H[768+(q>>>24&255)]++}let $=E,re=S,te=new Uint32Array(U),ae=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const q=B<<8,oe=B<<3;let w=!1;for(let x=0;x<256;x++)if(H[q+x]===U){w=!0;break}if(w)continue;let v=0;for(let x=0;x<256;x++)p[x]=v,v+=H[q+x];for(let x=0;x<U;x++){const de=re[x],we=p[de>>>oe&255]++;te[we]=$[x],ae[we]=de}let Z=$;$=te,te=Z,Z=re,re=ae,ae=Z}return $}function s(E,S,U,H){const $=new Uint32Array(H+1);for(let ae=0;ae<U;ae++)$[S[ae]]++;let re=0;for(let ae=0;ae<=H;ae++){const p=$[ae];$[ae]=re,re+=p}const te=new Uint32Array(U);for(let ae=0;ae<U;ae++)te[$[S[ae]]++]=E[ae];return te}function u(E,S,U,H){return U<2?E:H<=65536||H<=U*2?s(E,S,U,H):i(E,S,U)}function f(E,S){return E.length===S&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,S)}function l(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=new Uint32Array($),te=new Uint32Array($),ae=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let q=0,oe=0;for(let Z=0;Z<$;Z++){const x=H[Z],de=E[x];if(Number.isNaN(de)){p[oe++]=x;continue}C(de,B),U?(te[q]=~B[0]>>>0,ae[q]=~B[1]>>>0):(te[q]=B[0],ae[q]=B[1]),re[q++]=x}const w=A(re.subarray(0,q),te.subarray(0,q),ae.subarray(0,q),q);if(oe===0)return f(w,q);const v=new Uint32Array($);return v.set(w.subarray(0,q),0),v.set(p.subarray(0,oe),q),v}function t(E,S,U=!1){const H=S||ne(E.length),$=H.length;if($<2)return Uint32Array.from(H);const re=Uint32Array.from(H),te=new Uint32Array($);for(let ae=0;ae<$;ae++){const p=(E[re[ae]]^2147483648)>>>0;te[ae]=U?~p>>>0:p}return f(i(re,te,$),$)}function a(E,S,U={}){const H=S||ne(K(E,U)),$=H.length;if($<2)return Uint32Array.from(H);const re=Q(E.dict,U.locale),te=E.values,ae=T(E),p=Math.max(z(E.dict),re.length),B=p,q=Uint32Array.from(H),oe=new Uint32Array($),w=!!U.descending;for(let v=0;v<$;v++){const Z=q[v];let x=ae&&ae(Z)===0?B:re[te[Z]];x===void 0&&(x=B),oe[v]=w?B-x:x}return f(u(q,oe,$,p+1),$)}function m(E,S,U){const H=S.length;let $=Uint32Array.from(S);if(H<2)return $;let re=new Uint32Array(H);for(let te=1;te<H;te<<=1){for(let p=0;p<H;p+=te<<1){const B=Math.min(p+te,H),q=Math.min(p+(te<<1),H);let oe=p,w=B,v=p;for(;oe<B&&w<q;)re[v++]=U(E[$[oe]],E[$[w]])<=0?$[oe++]:$[w++];for(;oe<B;)re[v++]=$[oe++];for(;w<q;)re[v++]=$[w++]}const ae=$;$=re,re=ae}return $}function e(E,S,U){const H=he(E.values),$=S.length,re=new Uint32Array($),te=U?1:0;let ae=0;for(let p=0;p<$;p++)H(S[p])===te&&(re[ae++]=S[p]);for(let p=0;p<$;p++)H(S[p])!==te&&(re[ae++]=S[p]);return re}function d(E,S){const U=E.values,H=E.kind;if((H==="object"||H===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!E.presence)return U;const re=J(E),te=new Array(K(E)||0);for(let ae=0;ae<S.length;ae++){const p=S[ae];te[p]=re(p)}return te}function h(E,S){for(let U=0;U<S.length;U++)if(typeof E[S[U]]!="string")return!1;return!0}function r(E,S,U,H,$){const re=E.length,te=Uint32Array.from(E);if(re<2||H<1)return te;const ae=new Uint32Array(re),p=H-1;for(let B=0;B<re;B++){const q=U[S[B]];ae[B]=$?p-q:q}return f(u(te,ae,re,H),re)}function n(E,S,U){const H=ie(U),$=new Array(S);for(let te=0;te<S;te++)$[te]=te;$.sort((te,ae)=>H(E[te],E[ae])||te-ae);const re=new Uint32Array(S);for(let te=0;te<S;te++)re[$[te]]=te;return re}function c(E,S,U){const H=S.length,$=new Map,re=[],te=new Uint32Array(H);for(let B=0;B<H;B++){const q=E[S[B]];let oe=$.get(q);oe===void 0&&(oe=re.length,$.set(q,oe),re.push(q)),te[B]=oe}const ae=re.length,p=n(re,ae,U.locale);return r(S,te,p,ae,!!U.descending)}function g(E,S,U){const H=d(E,S);if(S.length>=2&&h(H,S)){const te=E.stringRank;return te&&te.version===E.version&&te.usable(S,H,U.locale)?te.sort(S,U):c(H,S,U)}const $=ie(U.locale),re=U.descending?(te,ae)=>$(ae,te):$;return m(H,S,re)}function M(E,S,U){const H=d(E,S),$=U.compare,te=!!U.descending?(ae,p)=>-$(ae,p,void 0,void 0,!0):(ae,p)=>$(ae,p,void 0,void 0,!1);return m(H,S,te)}function N(E,S){const U=S.length,H=T(E),$=E.values,re=E.kind==="float64"&&!!$,te=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!H&&!re&&!te)return{present:S,absent:le};const ae=new Uint32Array(U),p=new Uint32Array(U);let B=0,q=0;if(H&&re)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1&&!Number.isNaN($[w])?ae[B++]=w:p[q++]=w}else if(re&&!H)for(let oe=0;oe<U;oe++){const w=S[oe];Number.isNaN($[w])?p[q++]=w:ae[B++]=w}else if(H&&!te)for(let oe=0;oe<U;oe++){const w=S[oe];H(w)===1?ae[B++]=w:p[q++]=w}else{const oe=J(E);for(let w=0;w<U;w++){const v=S[w];_(oe(v))?p[q++]=v:ae[B++]=v}}return q===0?{present:S,absent:le}:{present:ae.subarray(0,B),absent:p.subarray(0,q)}}function G(E,S,U){if(S.length===0)return E;const H=new Uint32Array(E.length+S.length);return U?(H.set(S,0),H.set(E,S.length)):(H.set(E,0),H.set(S,E.length)),H}function F(E,S,U={}){const H=S||ne(K(E,U));if(!E||H.length<2)return Uint32Array.from(H);const{present:$,absent:re}=N(E,H);if($.length===0)return Uint32Array.from(H);const te=!!U.descending;let ae;if(typeof U.compare=="function")ae=M(E,$,U);else switch(E.kind){case"float64":ae=l(E.values,$,te);break;case"int32":ae=t(E.values,$,te);break;case"dictionary":ae=a(E,$,U);break;case"bitset":ae=e(E,$,te);break;default:ae=g(E,$,U);break}return G(ae,re,!!U.nullsFirst)}function R(E,S,U,H={}){const $=S||[],re=$.length&&($[0].handle||X(E,$[0].col))||E&&E[0];let te=U||ne(K(re,H));for(let ae=$.length-1;ae>=0;ae--){const p=$[ae],B=p.handle||X(E,p.col)||E&&E[ae];B&&(te=F(B,te,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:H.locale,compare:p.compare}))}return te instanceof Uint32Array?te:Uint32Array.from(te)}function X(E,S){if(!(!E||S===void 0)){for(let U=0;U<E.length;U++)if(E[U]&&E[U].id===S)return E[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return ne}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,Q=fe.rankSortStrings,z=1e5;class ne{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let ie=0;ie<K.length;ie++)T+=K[ie].length*2+24;return T}#a(T,K){const ie=this.#e.get(T);if(ie!==void 0)return ie;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const ie=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ie);for(let J=0;J<ie;J++){const le=T[J],ue=typeof le=="string"?this.#a(le,!1):-1;this.#n[J]=ue<0?0:ue}this.#r=ie}append(T,K,ie){const J=(K|0)+(ie|0);if(J>this.#n.length){const le=new Uint32Array(J);le.set(this.#n.subarray(0,this.#r)),this.#n=le}for(let le=K|0;le<J;le++){const ue=T[le],W=typeof ue=="string"?this.#a(ue,!0):-1;this.#n[le]=W<0?0:W}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const ie=he(this.#t,this.#t.length,T);return this.#o=ie,this.#c=this.#i,this.#l=K,ie}usable(T,K,ie){if(this.#u||this.#t.length===0)return!1;const J=this.#n,le=this.#t,ue=this.#r;for(let W=0;W<T.length;W++){const L=T[W];if(L>=ue||le[J[L]]!==K[L])return!1}return!0}sort(T,K){const ie=this.ranks(K.locale),J=this.#t.length,le=T.length,ue=new Uint32Array(le),W=this.#n;for(let L=0;L<le;L++)ue[L]=W[T[L]];return Q(T,ue,ie,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return a}});const fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,Q=fe.isFunction,z=fe.pathGetter,_=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,ue=me("packages/core/src/store/stringrank.js").StringRankIndex,W=4294967295,L=1024,Y=5e3,ee=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function A(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return A(m)?[]:Array.isArray(m)?m:[m]}function f(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function l(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let c=d;c<h;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=Q(e.read)?e.read:z(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const h=new ue(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,h){if(this.#g||h<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]);if(typeof G=="number"){n&&c.set(d+N),M[d+N]=G;continue}const F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?NaN:i(G)}break}case"int32":{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?0:s(G)}break}case"bitset":{const M=this.#c;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M.assign(d+N,!F&&!!G)}break}case"dictionary":{const M=this.#o,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0),M[d+G]=R?0:N.codeOf(F)}break}case"multi":{const M=this.#l,N=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),R=F==null;n?c.assign(d+G,!R):R&&(g=!0);const X=u(F),E=new Array(X.length);for(let S=0;S<X.length;S++)E[S]=N.codeOf(X[S]);M.write(d+G,E)}break}default:{const M=this.#o;for(let N=0;N<h;N++){const G=r(e[N]),F=G==null;n?c.assign(d+N,!F):F&&(g=!0),M[d+N]=F?null:G}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let M=0;M<h;M++)this.#c.assign(d+M,(g[M>>3]&1<<(M&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],M=new Uint32Array(g.length);for(let R=0;R<g.length;R++)M[R]=this.#a.codeOf(g[R]);const N=e.values,G=this.#o,F=r;for(let R=0;R<h;R++){if(F&&(n&&(n[R>>3]&1<<(R&7))===0)){G[d+R]=0;continue}G[d+R]=M[N[R]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],M=new Uint32Array(g.length);for(let F=0;F<g.length;F++)M[F]=this.#a.codeOf(g[F]);const N=e.values,G=e.offsets;for(let F=0;F<h;F++){const R=G[F],X=G[F+1],E=new Array(X-R);for(let S=R;S<X;S++)E[S-R]=M[N[S]]??0;this.#l.write(d+F,E)}this.#f++;return}for(let g=0;g<h;g++){const M=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,M?null:l(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!C.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==W&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==W&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,W);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==W&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new _(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new _(d)),this.#p=d}#A(e,d){const h=A(d);switch(this.#r?this.#m.assign(e,!h):h&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=h?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),h=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!A(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Y:0,this.#w=d.compactRatio??ee;const h={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,h);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[h+c]=d[c];this.#i=h+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,h,r):c.grow(this.#s)}return{from:h,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,h)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?W:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)h[c]!==W&&(n[h[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),h}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,Q=fe.nextFrame,z=fe.infoOnce,ne=fe.warnOnce,_=fe.isFunction,T=fe.pathGetter,ie=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function le(A,i={}){if(i.multi)return"multi";if(A.length===0)return"object";let s=0,u=0,f=0,l=0,t=0;for(let m=0;m<A.length;m++){const e=A[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?l++:Array.isArray(e)&&t++}const a=A.length;return s===a?"float64":u===a?"bitset":l===a?"float64":f===a?"text":t===a?"multi":"object"}function ue(A,i,s){return i<=0||A<s*i?"dictionary":"object"}function W(A,i,s){const u=new Map,f=new Map;for(const c of A){if(c.computed)continue;const g=_(c.read)?c.read:T(c.field||c.id);f.set(c.id,g),u.set(c.id,g)}const l=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=l.filter(c=>_(t[c])),d=e.some(c=>a[c]==="*");let h=new WeakMap;const r=c=>{const g={};if(d)for(const[M,N]of f)g[M]=N(c);for(const M of e){const N=a[M];let G;if(N==="*")G=g;else{G={};const F=N||[];for(let R=0;R<F.length;R++){const X=F[R];G[X]=X in g?g[X]:f.get(X)?.(c)}}g[M]=t[M](m?m(G,M):G,{data:c,row:null,column:null,grid:null,context:s})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=h.get(c);return g===void 0&&(g=r(c),h.set(c,g)),g};for(const c of e)u.set(c,g=>n(g)[c]);return{readers:u,reset(){h=new WeakMap}}}class L{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=W(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ie(this.#e.map(l=>({id:l.spec.id,kind:l.kind,nullable:l.nullable,read:l.read,dictionary:l.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const l=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,l)),this.#a(this.#i,l),this.#i=l,this.#r.reset(),this.#w(!1)}while(this.#i<f&&he()-i<s);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),l=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){ne(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(a.id)??(_(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=le(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=ue(r,d.length,l),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`ingest.mixed.${a.id}`,`column "${a.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const l=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&l.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const l=this.#d(f);if(f.kind==="dictionary"&&l>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&l>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${l} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&l<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${l} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(A,i={},s={}){const u=new Y(A,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(l=>{f(l)});return u.result()}function C(A,i={},s={}){const u=new Y(A,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const he=me("packages/core/src/internal/util.js").pathGetter,Q=me("packages/core/src/store/ingest.js"),z=Q.inferKind,ne=Q.decideText,_=Q.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,ie=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const C of ee)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!ie.has(C.kind))return!1;return!0}function le(ee){const C=K(ee);return Number.isFinite(C)?C|0:0}function ue(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function W(ee,C,A,i){if(ee.kind)return ee.kind;const s=[];for(let l=0;l<C.length&&s.length<_.sampleSize;l++){const t=C[l];t!=null&&s.push(t)}const u=z(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return ne(f,s.length,i)}function L(ee,C,A={}){const i=C.length|0,s=A.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const l=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=l(C[r]);a[r]=n===void 0?null:n}const m=W(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),r[n]=g?NaN:K(c)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),r[n]=g?0:le(c)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=a[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const M=a[g];if(M===null){r[g]=0;continue}d(g);let N=c.get(M);N===void 0&&(N=n.length,n.push(M),c.set(M,N)),r[g]=N}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let M=0;M<i;M++){const N=a[M];c[M]=g.length,N===null||d(M);const F=ue(N);for(let R=0;R<F.length;R++){const X=F[R];let E=n.get(X);E===void 0&&(E=r.length,r.push(X),n.set(X,E)),g.push(E)}}c[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=a[n];c!==null&&d(n),r[n]=c}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Y(ee){const C=[];if(!ee||!Array.isArray(ee.columns))return C;const A=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of ee.columns)A(i.values),A(i.presence),A(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ne}});function fe(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function he(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let T=0;T<_.length;T++)if(!he(_[T]))return!1;return!0}function z(_,T){const K=_.col!==void 0?_.col:_.handle&&_.handle.id,ie=_.locale!==void 0?_.locale:T;return{col:K,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:fe(ie)}}function ne(_,T){const K=_||[],ie=new Array(K.length);for(let J=0;J<K.length;J++)ie[J]=z(K[J],T);return ie}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,Q=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function ne(A){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<A.length;){const l=A[s];if(l==="\'"){if(A[s+1]==="\'"){u+="\'",s+=2;continue}const a=A.indexOf("\'",s+1);if(a===-1){u+=A.slice(s+1),s=A.length;continue}u+=A.slice(s+1,a),s=a+1;continue}const t=z.find(a=>A.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(l)&&Q(`date.pattern.token:${l}`,`the date pattern "${A}" contains \'${l}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=l,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(A){if(he(A)||A==="")return null;if(A instanceof Date)return Number.isNaN(A.getTime())?null:A;if(typeof A=="number")return Number.isNaN(A)?null:new Date(A);if(typeof A=="string"){const i=_.exec(A.trim());if(i){const[,u,f,l,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+l,+t,+a,+m)}const s=new Date(A);return Number.isNaN(s.getTime())?null:s}return null}function K(A,i){return String(A).padStart(i,"0")}function ie(A){if(!A)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:A,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const l of i.formatToParts(u))switch(l.type){case"year":f.year=Number(l.value);break;case"month":f.month=Number(l.value);break;case"day":f.day=Number(l.value);break;case"hour":f.hour=Number(l.value)%24;break;case"minute":f.minute=Number(l.value);break;case"second":f.second=Number(l.value);break;case"weekday":f.weekday=s[l.value]??0;break;default:break}return f}}function J(A,i,s){const u=ne(A),f=ie(s),l=new Set(u.filter(d=>d.token).map(d=>d.token)),t=l.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=l.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=l.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=l.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const le=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ue(A,i){const s=A||{},u=s.locale||i||void 0,f=s.nullDisplay??"",l=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,l);else if(s.dateStyle||s.timeStyle){const h={timeZone:l};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:l});t=r=>h.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[M,N]of le)if(Math.abs(g)>=N||M==="second")return a.format(Math.round(g/N),M)}}return t(n)};return d.spec=s,d}function W(A){if(he(A)||A==="")return null;if(typeof A=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(A.trim());if(u)return u[1];const f=T(A);return f?W(f):null}const i=T(A);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(A,i){if(he(A)||A==="")return null;if(typeof A=="string"){const u=A.trim();if(Y.test(u)){const t=T(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const l=T(u);return l?L(l):null}const s=T(A);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(A,i){const s=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(A).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const u=`${A.getFullYear()}-${s(A.getMonth()+1)}-${s(A.getDate())}`,f=A.getSeconds(),l=`${s(A.getHours())}:${s(A.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${l}`}function C(A,i){const s=he(A)||A===""?null:String(A),u=he(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ae}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,Q=fe.toArray,z=fe.warnOnce,_=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,ie=T.dictSize,J=T.dictValue,le=T.presenceReader,ue=T.valueComparator,W=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(p,B){const q=p&&p.pool;if(q){const oe=q.mask||q.acquireMask||q.acquire||q.take;if(typeof oe=="function"){const w=oe.call(q,B);if(w&&w.length>=B)return w}}return new Uint8Array(B)}function C(p,B){const q=p&&p.pool;if(!q||!B)return;const oe=q.release||q.releaseMask||q.free||q.recycle;typeof oe=="function"&&oe.call(q,B)}function A(p,B,q){return p.fill(q,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const q=_(p);return q===null?u(p):q}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function l(p,B){const q=typeof p=="string"?p:String(p);return B?q:q.toLowerCase()}function t(p,B){return p==null?Y:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,q){const oe=new Set;for(const w of Q(p)){const v=s(w,q);oe.add(t(v,B)),typeof v=="string"&&v!==""&&Number.isFinite(Number(v))?oe.add(Number(v)):typeof v=="number"&&Number.isFinite(v)&&oe.add(t(String(v),B))}return oe}function m(p,B,q){if(p==null||B===null||B===void 0)return p==null&&B==null;const oe=typeof p,w=typeof B;return oe==="string"&&w==="string"?q?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):oe==="number"&&w==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):oe==="number"&&w==="string"?p===Number(B):oe==="string"&&w==="number"?Number(p)===B:oe==="boolean"||w==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((v,Z)=>m(v,B[Z],q)):p===B}function e(p,B){try{if(p instanceof RegExp){const q=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||q.includes("i")?q:`${q}i`)}return new RegExp(String(p),B?"":"i")}catch(q){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,q),null}}function d(p,B){const q=h(p,B),oe=p&&p.type;return oe!=="date"&&oe!=="dateString"?q:w=>q(typeof w=="string"&&L.test(w)?w:_(w)??w)}function h(p,B){const q=p&&p.op,oe=!!(p&&p.caseSensitive),w=p&&p.type,v=ue(B),Z=x=>de=>!x(de);switch(q){case"eq":{const x=s(p.value,w);return de=>m(de,x,oe)}case"ne":{const x=s(p.value,w);return de=>!m(de,x,oe)}case"lt":case"lte":case"gt":case"gte":{const x=s(p.value,w);if(i(x))return()=>!1;const de=q==="lt"?-1:q==="lte"?0:q==="gt"?1:2;return we=>{if(i(we))return!1;const ge=v(we,x);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const x=Q(p.value),de=s(x[0],w),we=s(x[1],w),ge=p.bounds||"[]",pe=ge.charAt(0)!=="(",Te=ge.charAt(1)!==")";if(i(de)||i(we))return q==="between"?()=>!1:()=>!0;const Le=Be=>{if(i(Be))return!1;const ze=v(Be,de),Ke=v(Be,we);return(pe?ze>=0:ze>0)&&(Te?Ke<=0:Ke<0)};return q==="between"?Le:Z(Le)}case"in":case"notIn":{const x=a(p.value,oe,w),de=we=>x.has(t(we,oe));return q==="in"?de:Z(de)}case"contains":case"notContains":{const x=l(s(p.value,w),oe),de=we=>we==null?!1:l(we,oe).includes(x);return q==="contains"?de:Z(de)}case"startsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).startsWith(x)}case"endsWith":{const x=l(s(p.value,w),oe);return de=>de==null?!1:l(de,oe).endsWith(x)}case"matches":{const x=e(p.value,oe);return x?de=>de==null?!1:x.test(String(de)):()=>!1}case"blank":return x=>he(x)||Array.isArray(x)&&x.length===0;case"notBlank":return x=>!(he(x)||Array.isArray(x)&&x.length===0);case"containsAny":case"containsNone":{const x=a(p.value,oe,w),de=we=>{const ge=we==null?[]:Q(we);for(let pe=0;pe<ge.length;pe++)if(x.has(t(ge[pe],oe)))return!0;return!1};return q==="containsAny"?de:Z(de)}case"containsAll":{const x=Q(p.value).map(de=>t(s(de,w),oe));return de=>{const we=de==null?[]:Q(de);if(x.length===0)return!0;const ge=new Set(we.map(pe=>t(pe,oe)));for(let pe=0;pe<x.length;pe++)if(!ge.has(x[pe]))return!1;return!0}}default:{const x=ae(q);return x?x.compile(p.value):(z(`op:${String(q)}`,`unknown filter operator "${String(q)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,q){return d(B,q)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,q){const oe=p&&p.op,w=n[oe]||oe,v=d({...p,op:w,type:B.type},q),Z=B.items,x=de=>{const we=Z(de);if(!we)return!1;for(let ge=0;ge<we.length;ge++)if(v(we[ge]))return!0;return!1};return n[oe]?de=>!x(de):x}function M(p,B,q,oe){const w=le(p);if(w){const x=B?1:0;for(let de=0;de<oe;de++)q[de]=w(de)===x?1:0;return q}const v=p.kind;if(v==="float64"||v==="int32"||v==="bitset")return A(q,oe,B?1:0);const Z=W(p);for(let x=0;x<oe;x++){const de=Z(x),we=he(de)||Array.isArray(de)&&de.length===0;q[x]=we===B?0:1}return q}function N(p,B,q,oe){const w=p.dict,v=ie(w),Z=new Uint8Array(v);for(let ge=0;ge<v;ge++)Z[ge]=B(J(w,ge))?1:0;const x=p.values,de=le(p);if(!de){for(let ge=0;ge<oe;ge++)q[ge]=Z[x[ge]];return q}const we=B(null)?1:0;for(let ge=0;ge<oe;ge++)q[ge]=de(ge)===1?Z[x[ge]]:we;return q}function G(p,B,q,oe){const w=K(p.values),v=B(!0)?1:0,Z=B(!1)?1:0,x=le(p);if(!x){for(let we=0;we<oe;we++)q[we]=w(we)===1?v:Z;return q}const de=B(null)?1:0;for(let we=0;we<oe;we++)q[we]=x(we)===0?de:w(we)===1?v:Z;return q}function F(p,B,q,oe,w){const v=p.values,Z=B.type,x=B.op;let de=!0;switch(x){case"eq":case"ne":{const ge=f(s(B.value,Z)),pe=typeof B.value=="number"&&Number.isNaN(B.value),Te=x==="ne"?1:0;if(pe)for(let Le=0;Le<w;Le++)oe[Le]=(Number.isNaN(v[Le])?1:0)^Te;else for(let Le=0;Le<w;Le++)oe[Le]=(v[Le]===ge?1:0)^Te;break}case"lt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<ge?1:0;break}case"lte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>ge?1:0;break}case"gte":{const ge=f(s(B.value,Z));for(let pe=0;pe<w;pe++)oe[pe]=v[pe]>=ge?1:0;break}case"between":case"notBetween":{const ge=Q(B.value),pe=f(s(ge[0],Z)),Te=f(s(ge[1],Z)),Le=B.bounds||"[]",Be=Le.charAt(0)!=="(",ze=Le.charAt(1)!==")",Ke=x==="notBetween"?1:0;if(Be&&ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<=Te?1:0)^Ke;else if(Be)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>=pe&v[Ee]<Te?1:0)^Ke;else if(ze)for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<=Te?1:0)^Ke;else for(let Ee=0;Ee<w;Ee++)oe[Ee]=(v[Ee]>pe&v[Ee]<Te?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Te of Q(B.value)){const Le=f(s(Te,Z));Number.isNaN(Le)||ge.add(Le)}const pe=x==="notIn"?1:0;for(let Te=0;Te<w;Te++)oe[Te]=(ge.has(v[Te])?1:0)^pe;break}default:de=!1;break}if(!de)return!1;const we=le(p);if(we){const ge=q(null)?1:0;for(let pe=0;pe<w;pe++)we(pe)===0&&(oe[pe]=ge)}return!0}function R(p,B,q,oe){const w=W(p);for(let v=0;v<oe;v++)q[v]=B(w(v))?1:0;return q}function X(p,B,q){const oe=B.count|0,w=q||ee(B,oe);if(!p)return A(w,oe,1);const v=typeof B.handle=="function"?B.handle(p.col):void 0,Z=typeof B.custom=="function"?B.custom:null;if(!v){if(Z){for(let ge=0;ge<oe;ge++)w[ge]=Z(p,ge)?1:0;return w}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),A(w,oe,0)}const x=p.op;if(x==="blank"||x==="notBlank")return M(v,x==="notBlank",w,oe);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ae(x)&&!c.has(x))return R(v,g(p,de,B.locale),w,oe);const we=d(p,B.locale);switch(v.kind){case"dictionary":return N(v,we,w,oe);case"bitset":return G(v,we,w,oe);case"float64":case"int32":return F(v,p,we,w,oe)?w:R(v,we,w,oe);default:return R(v,we,w,oe)}}function E(p,B,q){if(!p)return A(ee(B,q),q,1);if(Array.isArray(p.conditions)){const oe=p.conditions.filter(Z=>Z!=null),w=p.op==="or"?"or":p.op==="not"?"not":"and";if(oe.length===0)return A(ee(B,q),q,1);const v=E(oe[0],B,q);for(let Z=1;Z<oe.length;Z++){const x=E(oe[Z],B,q);if(w==="or")for(let de=0;de<q;de++)v[de]|=x[de];else for(let de=0;de<q;de++)v[de]&=x[de];C(B,x)}if(w==="not")for(let Z=0;Z<q;Z++)v[Z]^=1;return v}return X(p,B,ee(B,q))}function S(p,B){return E(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const q=p;if(Array.isArray(q.conditions)){if((q.op==="or"?"or":q.op==="not"?"not":"and")!=="and")return H(q,B)?null:p;const w=[];for(const v of q.conditions){const Z=U(v,B);Z&&w.push(Z)}return w.length?{...q,op:"and",conditions:w}:null}return q.col===B?null:p}function H(p,B){if(!p||typeof p!="object")return!1;const q=p;if(q.col===B)return!0;if(Array.isArray(q.conditions)){for(const oe of q.conditions)if(H(oe,B))return!0}return!1}function $(p,B,q){if(q&&q.length>=B){let Z=0;for(let x=0;x<B;x++)p[x]&&(q[Z++]=x);return q.subarray(0,Z)}let oe=0;for(let Z=0;Z<B;Z++)oe+=p[Z]?1:0;const w=new Uint32Array(oe);let v=0;for(let Z=0;Z<B;Z++)p[Z]&&(w[v++]=Z);return w}const re=new Map;function te(p){if(!(!p||typeof p!="object"))for(const[B,q]of Object.entries(p))q&&typeof q.compile=="function"&&re.set(B,q)}function ae(p){return typeof p=="string"?re.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ue}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,Q=fe.identity,z=fe.presenceReader,ne=fe.rowCount,_=fe.valueReader,T="",K="\\0",ie=1<<20;function J(W,L,Y,ee){const C=W.length,A=W.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?A.map((t,a)=>ee[a]?m=>ee[a](t(m)):t):A;if(!i&&C>0&&W.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=W.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=W.map(r=>r.values),e=W.map(r=>z(r)),d=r=>{let n=0;for(let c=0;c<C;c++){const g=e[c],M=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+M}return n},h=new Float64Array(Y);for(let r=0;r<Y;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},l=new Array(Y);for(let t=0;t<Y;t++)l[t]=f(L[t]);return{packed:null,strings:l,product:1/0,readers:s,keyOf:f}}function le(W,L,Y,ee){const C=new Uint32Array(ee+1);for(let u=0;u<Y;u++)C[L[u]+1]++;for(let u=0;u<ee;u++)C[u+1]+=C[u];const A=new Uint32Array(Y),i=C.slice(0,ee);for(let u=0;u<Y;u++)A[i[L[u]]++]=W[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=A.subarray(C[u],C[u+1]);return s}function ue(W,L,Y={}){const ee=W||[],C=L||Q(ne(ee[0],Y)),A=C.length;if(ee.length===0||A===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(ee,C,A,Y.project),l=new Uint32Array(A);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ie,A*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<A;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<A;n++)l[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<A;r++){const n=i[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<A;r++){const n=s[r];let c=h.get(n);c===void 0&&(c=t++,h.set(n,c)),l[r]=c}}const m=le(C,l,A,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let c=0;c<f.length;c++)n[c]=f[c](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=fe.dictSize,ne=fe.dictValue,_=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,ie=50,J=1e4;function le(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const M=c&&c.base;if(M==="date"||M==="datetime"||M==="time"||M==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return M==="number"?"numeric":M==="boolean"?"boolean":M==="text"?"category":"none"}}function ue(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return N=>c[N];const M=Q(n);return N=>W(M(N))}function W(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,c,g,M=ie){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const N=Q(n),G=c?c.length:g,F=new Set;for(let R=0;R<G;R++){const X=N(c?c[R]:R);if(X!=null&&(F.add(X),F.size>M))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Y=36e5,ee=864e5;function C(n,c=K){const g=Number.isFinite(n)&&n>0?n:0,M=Math.max(1,c)*2;return g/Y<=M?"hour":g/ee<=M?"day":g/(7*ee)<=M?"week":g/(30*ee)<=M?"month":g/(91*ee)<=M?"quarter":"year"}function A(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const M=(g.getDay()+6)%7;return g.setDate(g.getDate()-M),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,c,g){const M=ue(n),N=he(n),G=c?c.length:g;let F=1/0,R=-1/0,X=0,E=0;for(let S=0;S<G;S++){const U=c?c[S]:S;if(N&&!N(U)){X++;continue}const H=M(U);if(!Number.isFinite(H)){X++;continue}H<F&&(F=H),H>R&&(R=H),E++}return{min:F,max:R,nulls:X,finite:E}}function u(n,c,g,M){const N=ue(n),G=he(n),F=c?c.length:g,R=F>M?F/M:1,X=[];for(let S=0;S<F;S+=R){const U=c?c[Math.floor(S)]:Math.floor(S);if(G&&!G(U))continue;const H=N(U);Number.isFinite(H)&&X.push(H)}const E=Float64Array.from(X);return E.sort(),E}function f(n,c,g,M={}){const N=M.kind||le(n,M.type);return N==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:N==="boolean"?l(n,c,g):N==="category"?t(n,c,g,M):a(n,c,g,N,M)}function l(n,c,g){const M=he(n);let N=0;if(M){const F=c?c.length:g;for(let R=0;R<F;R++)M(c?c[R]:R)||N++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return N>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,c,g,M){const N=M.cardinalityLimit??ie,{cardinality:G}=L(n,c,g,N);if(G>N&&(M.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=Q(n),R=c?c.length:g,X=new Map;let E=0;for(let re=0;re<R;re++){const te=F(c?c[re]:re);if(te==null||te===""){E++;continue}if(Array.isArray(te)){if(!te.length){E++;continue}for(const ae of te)X.set(ae,(X.get(ae)||0)+1);continue}X.set(te,(X.get(te)||0)+1)}let S=[...X.entries()];M.order==="alpha"?S.sort((re,te)=>String(re[0]).localeCompare(String(te[0]))):S.sort((re,te)=>te[1]-re[1]);let U=0,H=0;if(S.length>N){H=S.length-N;for(let re=N;re<S.length;re++)U+=S[re][1];S=S.slice(0,N)}const $=S.map(([re])=>({value:re,label:String(re)}));return U>0&&$.push({remainder:!0,label:`Other (${H} values)`}),E>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,c,g,M,N){const{min:G,max:F,nulls:R,finite:X}=s(n,c,g);if(!X)return{kind:M,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(N.buckets||K));let S=[];if(M==="date"){const H=T.includes(N.granularity)?N.granularity:C(F-G,E);let $=A(G,H);for(;$<=F&&S.length<4096;){const re=i($,H);if(!(re>$))break;S.push({from:$,to:re}),$=re}return{kind:M,buckets:m(S,R),granularity:H}}const U=_.includes(N.strategy)?N.strategy:"equal";if(U==="quantile"){const H=u(n,c,g,J);if(H.length){const $=[H[0]];for(let re=1;re<E;re++){const te=H[Math.min(H.length-1,Math.floor(re/E*H.length))];te>$[$.length-1]&&$.push(te)}$.push(F);for(let re=0;re<$.length-1;re++)S.push({from:$[re],to:$[re+1]})}}else if(U==="log"&&G>0){const H=Math.log10(G),re=(Math.log10(F)-H)/E||1;for(let te=0;te<E;te++)S.push({from:10**(H+te*re),to:10**(H+(te+1)*re)})}if(!S.length){const H=(F-G)/E||1;for(let $=0;$<E;$++)S.push({from:G+$*H,to:G+($+1)*H})}return S[S.length-1].to=F,{kind:M,buckets:m(S,R),strategy:U,min:G,max:F}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,M,N){const G=M&&M.buckets||[],F=N&&N.length>=G.length?N.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const R=G.length-1,X=!!G[R]&&G[R].null===!0,E=c?c.length:g;if(M.kind==="boolean"){const re=Q(n);for(let te=0;te<E;te++){const ae=re(c?c[te]:te);if(ae==null){X&&F[R]++;continue}F[ae?1:0]++}return F}if(M.kind==="category"){const re=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&re.set(G[p].value,p);const te=G.findIndex(p=>p.remainder),ae=Q(n);for(let p=0;p<E;p++){const B=ae(c?c[p]:p);if(B==null||B===""){X&&F[R]++;continue}if(Array.isArray(B)){if(!B.length){X&&F[R]++;continue}for(const oe of B){const w=re.get(oe);w!==void 0?F[w]++:te>=0&&F[te]++}continue}const q=re.get(B);q!==void 0?F[q]++:te>=0&&F[te]++}return F}const S=X?G.length-1:G.length,U=new Float64Array(S+1);for(let re=0;re<S;re++)U[re]=G[re].from;U[S]=S?G[S-1].to:0;const H=ue(n),$=he(n);for(let re=0;re<E;re++){const te=c?c[re]:re;if($&&!$(te)){X&&F[R]++;continue}const ae=H(te);if(!Number.isFinite(ae)){X&&F[R]++;continue}const p=d(U,S,ae);p>=0&&F[p]++}return F}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let M=0,N=c-1;for(;M<N;){const G=M+N+1>>>1;g>=n[G]?M=G:N=G-1}return M}function h(n,c,g,M={}){const N=M.bounds||f(n,M.boundsIndices??c,g,M);return{bounds:N,counts:e(n,c,g,N)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,Q=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const A=C-1;let i=.9999999999998099;const s=A+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(A+u+1);return .5*Math.log(2*Math.PI)+(A+.5)*Math.log(s)-s+Math.log(i)}function ne(C,A,i){const s=C+A,u=C+1,f=C-1;let l=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(A-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t,a*=t*l,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<Q&&(t=Q),l=1+d/l,Math.abs(l)<Q&&(l=Q),t=1/t;const h=t*l;if(a*=h,Math.abs(h-1)<he)break}return a}function _(C,A,i){if(!(C>0)||!(A>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+A)-z(C)-z(A)+C*Math.log(i)+A*Math.log(1-i));return i<(C+1)/(C+A+2)?s*ne(C,A,i)/C:1-s*ne(A,C,1-i)/A}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const A=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let l,t,a;C<f?(l=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1)):C<=1-f?(l=C-.5,t=l*l,a=(((((A[0]*t+A[1])*t+A[2])*t+A[3])*t+A[4])*t+A[5])*l/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(l=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*l+s[1])*l+s[2])*l+s[3])*l+s[4])*l+s[5])/((((u[0]*l+u[1])*l+u[2])*l+u[3])*l+1));const e=(.5*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const A=Math.abs(C),i=2/(2+A),s=4*i-2,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let f=0,l=0,t;for(let m=u.length-1;m>0;m--)t=l,l=s*l-f+u[m],f=t;const a=i*Math.exp(-A*A+.5*(u[0]+s*l)-f);return C>=0?a:2-a}function ie(C){return .5*K(-C/Math.SQRT2)}function J(C,A){if(!(A>0)||!Number.isFinite(C))return Number.NaN;const i=.5*_(A/2,.5,A/(A+C*C));return C>0?1-i:i}function le(C,A){if(!(C>0)||!(C<1)||!(A>0))return Number.NaN;if(A>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(A/2)+z(.5)-z((A+1)/2);for(let l=0;l<60;l++){const t=J(u,A);t<C?i=u:s=u;const a=Math.exp(-((A+1)/2)*Math.log(1+u*u/A)-f)/Math.sqrt(A),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ue(C,A){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=A/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-A+C*Math.log(A)-z(C))}function W(C,A){let i=A+1-C,s=1/Q,u=1/i,f=u;for(let l=1;l<=300;l++){const t=-l*(l-C);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-A+C*Math.log(A)-z(C))*f}function L(C,A){return!(C>0)||!(A>=0)||!Number.isFinite(A)?Number.NaN:A===0?0:A<C+1?ue(C,A):1-W(C,A)}function Y(C,A){return A>0?L(A/2,C/2):Number.NaN}function ee(C,A){const i=Y(C,A);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function fe(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let le=0;le<=J;le++){let ue=T[J][le];for(let W=0;W<le;W++)ue-=ie[J][W]*ie[le][W];if(J===le){if(!(ue>0))return null;ie[J][le]=Math.sqrt(ue)}else ie[J][le]=ue/ie[le][le]}return ie}function he(T,K){const ie=T.length,J=new Array(ie).fill(0);for(let ue=0;ue<ie;ue++){let W=K[ue];for(let L=0;L<ue;L++)W-=T[ue][L]*J[L];J[ue]=W/T[ue][ue]}const le=new Array(ie).fill(0);for(let ue=ie-1;ue>=0;ue--){let W=J[ue];for(let L=ue+1;L<ie;L++)W-=T[L][ue]*le[L];le[ue]=W/T[ue][ue]}return le}function Q(T){const K=T.length,ie=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const le=new Array(K).fill(0);le[J]=1;const ue=he(T,le);for(let W=0;W<K;W++)ie[W][J]=ue[W]}return ie}function z(T,K,ie){const J=T.length,le=J?T[0].length:0,ue=Array.from({length:le},()=>new Array(le).fill(0)),W=new Array(le).fill(0);for(let L=0;L<J;L++){const Y=ie?ie[L]:1,ee=T[L];for(let C=0;C<le;C++){const A=Y*ee[C];W[C]+=A*K[L];for(let i=C;i<le;i++)ue[C][i]+=A*ee[i]}}for(let L=0;L<le;L++)for(let Y=0;Y<L;Y++)ue[L][Y]=ue[Y][L];return{xtwx:ue,xtwy:W}}function ne(T,K){return T.map(ie=>ie.reduce((J,le,ue)=>J+le*K[ue],0))}function _(T,K){let ie=0;for(let J=0;J<T.length;J++){let le=0;for(let ue=0;ue<T.length;ue++)le+=K[J][ue]*T[ue];ie+=T[J]*le}return ie}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ue}});class fe{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(L){if(!Number.isFinite(L))return;this.#t++;const Y=L-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Y=this.#t+L.#t,ee=L.#e-this.#e;this.#e+=ee*(L.#t/Y),this.#n+=L.#n+ee*ee*(this.#t*L.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Y=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Y of this.#t)L+=Y;return L/this.#t.length}quantile(L){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const C=(Y-1)*Math.min(1,Math.max(0,L)),A=Math.floor(C),i=Math.ceil(C);return A===i?ee[A]:ee[A]+(C-A)*(ee[i]-ee[A])}}function Q(W){return W^=W>>>16,W=Math.imul(W,2246822507),W^=W>>>13,W=Math.imul(W,3266489909),W^=W>>>15,W>>>0}function z(W){if(typeof W=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,W===0?0:W),Q(ee.getUint32(0)^ee.getUint32(4))}const L=typeof W=="string"?W:String(W);let Y=2166136261;for(let ee=0;ee<L.length;ee++)Y^=L.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class ne{#t;#e;#n;constructor(L=14){const Y=Math.floor(L);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Y=1<<Math.floor(L),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return ne.errorBoundFor(this.#t)}add(L){const Y=z(L),ee=Y&this.#e-1,C=Y>>>this.#t|1<<32-this.#t;let A=1,i=C;for(;(i&1)===0;)A++,i>>>=1;A>this.#n[ee]&&(this.#n[ee]=A)}count(){const L=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<L;i++)ee[this.#n[i]]++;let C=L*K(1-ee[Y+1]/L);for(let i=Y;i>=1;i--)C=.5*(C+ee[i]);C+=L*T(ee[0]/L);const A=_*L*L/C;return Math.round(A)}}const _=.5/Math.log(2);function T(W){if(W===1)return 1/0;let L=1,Y=W,ee;do W*=W,ee=Y,Y+=W*L,L+=L;while(Y!==ee);return Y}function K(W){if(W===0||W===1)return 0;let L=1,Y=1-W,ee;do W=Math.sqrt(W),ee=Y,L*=.5,Y-=(1-W)**2*L;while(Y!==ee);return Y/3}class ie{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Y=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Y=this.#t.get(L);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let ee,C=1/0;for(const[A,i]of this.#t)i.count<C&&(C=i.count,ee=A);this.#t.delete(ee),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([ee,C])=>({item:ee,count:C.count,error:C.error})).sort((ee,C)=>C.count-ee.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Y=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Y,this.#i=2/3}static errorBoundFor(L=200){const Y=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const ee=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**ee);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Y=this.#e[L];Y.sort((A,i)=>A-i),L+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[L+1],C=this.#r()<.5?0:1;for(let A=C;A<Y.length;A+=2)ee.push(Y[A]);this.#e[L]=[];for(let A=0;A<this.#e.length;A++)if(this.#e[A].length>=this.#s(A)){this.#h(A);return}}#u(){const L=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const C of this.#e[Y])L.push({v:C,w:ee})}return L}quantile(L){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const C=Math.min(1,Math.max(0,L))*ee;let A=0;for(const i of Y)if(A+=i.w,A>=C)return i.v;return Y[Y.length-1].v}rank(L){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const C=1<<ee;for(const A of this.#e[ee])A<=L&&(Y+=C)}return Y}}const le=Object.freeze({distinct:ne.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),ue={Welford:fe,Reservoir:he,HyperLogLog:ne,SpaceSaving:ie,KLL:J,hash32:z,SKETCH_BOUNDS:le}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,Q=fe.valueReader,z=me("packages/core/src/compute/special.js"),ne=z.studentTQuantile,_=z.studentT,T=z.normalQuantile,K=z.normalCdf,ie=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),le=J.cholesky,ue=J.choleskySolve,W=J.choleskyInverse,L=J.normalEquations,Y=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,A=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let se=0;se<y;se++){const ce=j[se];if(D&&D(ce)!==1)continue;const Oe=I[ce];Number.isNaN(Oe)||(O[k++]=Oe)}return O.subarray(0,k)}const V=Q(b);for(let I=0;I<y;I++){const D=V(j[I]);if(D==null||D==="")continue;const se=typeof D=="number"?D:Number(D);Number.isFinite(se)&&(O[k++]=se)}return O.subarray(0,k)}function l(b,j){const y=new Map,O=Q(b);let k=0;for(let V=0;V<j.length;V++){const I=O(j[V]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const P=[...y.values()].sort((V,I)=>I-V);return{counts:P,total:k,distinct:P.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=l(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=l(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=l(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let P=0;for(let V=0;V<Math.min(k,O.counts.length);V++)P+=O.counts[V];return P/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let P=0,V=0;for(let I=0;I<O;I++)P+=k[I],V+=(I+1)*k[I];return P===0?0:2*V/(O*P)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const P=b[k];j++;const V=P-y;y+=V/j,O+=V*(P-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),P=Math.ceil(O);return k===P?b[k]:b[k]+(O-k)*(b[P]-b[k])}function c(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=Q(b);let O=0,k=0,P=0;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&P++}return{pass:O+P,fail:k,warn:P,judged:O+P+k}}const M=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>X(f(b,j),.1),winsorizedMean:(b,j)=>E(f(b,j),.1),robustOutliers:(b,j)=>S(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?c(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?c(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?c(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?c(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?c(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?c(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=c(y,.5),k=new Float64Array(y.length);for(let P=0;P<y.length;P++)k[P]=Math.abs(y[P]-O);return c(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let P=0;P<y.length;P++)y[P]<O&&(O=y[P]),y[P]>k&&(k=y[P]);return k-O},distinct:(b,j)=>{const y=Q(b),O=new Set;for(let k=0;k<j.length;k++){const P=y(j[k]);P==null||P===""||O.add(P instanceof Date?P.getTime():P)}return O.size},mode:(b,j)=>{const y=Q(b),O=new Map;for(let V=0;V<j.length;V++){const I=y(j[V]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,P=1;for(const[V,I]of O)I>P&&(P=I,k=V);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<3||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/V)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:P}=r(y);if(O<4||P<=0)return null;const V=Math.sqrt(P/(O-1));let I=0;for(let ce=0;ce<y.length;ce++)I+=((y[ce]-k)/V)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),se=3*(O-1)**2/((O-2)*(O-3));return D*I-se},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).fail}),N=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function G(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0;for(let I=0;I<y.length;I++){const D=y[I],se=Number(O(D)),ce=Number(k(D));!Number.isFinite(se)||!Number.isFinite(ce)||(P+=se*ce,V+=ce)}return V===0?null:P/V}function F(b,j,y){const O=Q(b);let k=null,P=y?-1/0:1/0;for(let V=0;V<j.length;V++){const I=j[V],D=Number(O(I));Number.isFinite(D)&&(y?D>P:D<P)&&(P=D,k=I)}return k}function R(b,j,y){const O=Q(b),k=Q(j);let P=0,V=0,I=0,D=0,se=0,ce=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(P++,V+=Pe,I+=ye,D+=Pe*Pe,se+=ye*ye,ce+=Pe*ye)}if(P<2)return null;const Oe=P*ce-V*I,ke=Math.sqrt((P*D-V*V)*(P*se-I*I));if(ke===0)return null;const je=Oe/ke;return Math.max(-1,Math.min(1,je))}function X(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O.slice(k,y-k);if(!P.length)return n(O,.5);let V=0;for(const I of P)V+=I;return V/P.length}function E(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,se)=>D-se),k=Math.floor(y*Math.min(.49,Math.max(0,j))),P=O[k],V=O[y-1-k];let I=0;for(const D of O)I+=Math.min(V,Math.max(P,D));return I/y}function S(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,se)=>D-se),k=n(O,.5),P=O.map(D=>Math.abs(D-k)).sort((D,se)=>D-se),V=n(P,.5);if(V===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/V)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,P=0;for(const D of b){const se=D-y;O+=se*se,k+=se*se*se,P+=se*se*se*se}if(O/=j,k/=j,P/=j,O===0)return null;const V=k/O**1.5,I=P/(O*O)-3;return j/6*(V*V+I*I/4)}function H(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const se=Number(b[D]),ce=Number(j[D]);!Number.isFinite(se)||!Number.isFinite(ce)||ce<=0||(O.push([se,ce]),k+=ce)}if(!O.length||k<=0)return null;if(O.sort((D,se)=>D[0]-se[0]),O.length===1)return O[0][0];const P=[];let V=0;for(const[,D]of O)P.push((V+D/2)/k),V+=D;const I=Math.max(0,Math.min(1,y));if(I<=P[0])return O[0][0];if(I>=P[P.length-1])return O[O.length-1][0];for(let D=1;D<P.length;D++){if(I>P[D])continue;const se=P[D]-P[D-1],ce=se>0?(I-P[D-1])/se:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*ce}return O[O.length-1][0]}function $(b,j,y){const O=Q(b),k=Q(j),P=new Float64Array(y.length),V=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const se=y[D],ce=Number(O(se)),Oe=Number(k(se));!Number.isFinite(ce)||!Number.isFinite(Oe)||(P[I]=ce,V[I]=Oe,I++)}return{xs:P.subarray(0,I),ys:V.subarray(0,I),n:I}}function re(b,j,y,O=!1){const{xs:k,ys:P,n:V}=$(b,j,y);if(V<2)return null;let I=0,D=0;for(let ce=0;ce<V;ce++)I+=k[ce],D+=P[ce];I/=V,D/=V;let se=0;for(let ce=0;ce<V;ce++)se+=(k[ce]-I)*(P[ce]-D);return se/(O?V:V-1)}function te(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;let V=0,I=0;for(let Pe=0;Pe<P;Pe++)V+=O[Pe],I+=k[Pe];V/=P,I/=P;let D=0,se=0,ce=0;for(let Pe=0;Pe<P;Pe++){const ye=O[Pe]-V,ve=k[Pe]-I;D+=ye*ye,se+=ye*ve,ce+=ve*ve}if(D===0)return null;const Oe=se/D,ke=I-Oe*V,je=ce===0?1:Math.max(0,Math.min(1,se*se/(D*ce))),be=Math.max(0,ce-Oe*se),Ae=P>2?Math.sqrt(be/(P-2)/D):0;return{slope:Oe,intercept:ke,r2:je,stdError:Ae,n:P}}const ae=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),q=1.345;function oe(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),P=le(O);if(!P)return null;const V=ue(P,k),I=W(P),D=w(b,V),se=j.map((ce,Oe)=>ce-D[Oe]);return{beta:V,cov:I,fitted:D,residuals:se}}function w(b,j){return b.map(y=>y.reduce((O,k,P)=>O+k*j[P],0))}function v(b,j){const y=b.length,O=b.map(se=>se[j]),k=b.map(se=>[1,...se.filter((ce,Oe)=>Oe!==j)]),P=oe(k,O,null);if(!P)return 1;const V=O.reduce((se,ce)=>se+ce,0)/y;let I=0,D=0;for(let se=0;se<y;se++)I+=P.residuals[se]**2,D+=(O[se]-V)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function Z(b){const j=[...b].sort((k,P)=>k-P),y=x(j),O=b.map(k=>Math.abs(k-y)).sort((k,P)=>k-P);return x(O)/.6745}function x(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ae.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,P=k&&Array.isArray(b[0])?b[0].length:0,V=P+1;if(!(k>V))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==P)return null;for(let Ne=0;Ne<P;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let se,ce=null;if(O==="robust"){if(se=oe(D,j,null),!se)return null;for(let Me=0;Me<50;Me++){const Ne=Z(se.residuals);if(!(Ne>0))break;const Re=se.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=q?1:q/We}),Ce=oe(D,j,Re);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-se.beta[Je])),0);if(se=Ce,ce=Re,Ve<1e-10)break}}else if(se=oe(D,j,I),!se)return null;const Oe=O==="robust"?ce:I,{beta:ke,cov:je,fitted:be,residuals:Ae}=se;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-V,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===P?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?ne(1-(1-He)/2,De):1/0,Lt=ke.map((Me,Ne)=>{const Re=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Re>0?Me/Re:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-_(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Re:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Re,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=Oe?Oe[Me]:1,Re=Math.max(0,Math.min(1,Ne*Y(D[Me],je)));dt[Me]=Re;const Ce=(1-Re)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(V*qe)*(Re/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(P<2)return 1;const Re=v(b,Ne);return Re>=1?1/0:1/(1-Re)});let gt=null;{const Me=Ae.map(Re=>Re*Re),Ne=oe(D,Me,null);if(Ne){const Re=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Re)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=ie(We,P);gt={statistic:We,df:P,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(P===1){const Me=b.map((Ne,Re)=>Re).sort((Ne,Re)=>b[Ne][0]-b[Re][0]);bt={confidence:He,points:Me.map(Ne=>{const Re=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Y(Re,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:Oe?[...Oe]:null}}function we(b){const j=b.length,y=Array.from({length:j},(P,V)=>V).sort((P,V)=>b[P]-b[V]),O=new Float64Array(j);let k=0;for(;k<j;){let P=k;for(;P+1<j&&b[y[P+1]]===b[y[k]];)P++;const V=(k+P)/2+1;for(let I=k;I<=P;I++)O[y[I]]=V;k=P+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const P=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+P*(b-y[0]))))}if(b>=y[2]){const P=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+P*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Te(b,j,y,O){const k=y-O,P=O+3,V=new Array(k),I=new Array(k);let D=!0,se=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(P);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<P;ye++)Number.isFinite(Pe[ye])||(se=Math.min(se,ye-3));V[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:ce,xtwy:Oe}=L(V,I,null);let ke=0,je=1/0;for(let be=0;be<=se;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=ce[Ue].slice(0,Ae);const ye=le(Pe);if(!ye)continue;const ve=ue(ye,Oe.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=V[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,ke=be)}return ke}function Le(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const P=new Array(k);for(let je=0;je<k;je++)P[je]=y[je+1]-y[je];let V=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);V=Math.max(0,Math.min(V,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(P[ye-Fe]);Ae.push(ve),Pe.push(P[ye])}return de(Ae,Pe,{method:"ols"})},D=Te(y,P,k,V),se=I(D,D);if(!se||!se.coefficients[2])return null;const ce=se.coefficients[2].t,Oe=pe(ce),ke=ce<ge["5%"];return{statistic:ce,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:Oe,pApproximate:!0,stationary:ke,verdict:ke?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let ke=0;ke<b.length;ke++){const je=Number(b[ke]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let P=0;for(const ke of y)P+=ke;P/=O;const V=y.map(ke=>ke-P);let I=0;for(const ke of V)I+=ke*ke;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let ke=1;ke<=k;ke++){let je=0;for(let be=ke;be<O;be++)je+=V[be]*V[be-ke];D[ke]=I>0?je/O/I:0}const se=new Array(k+1).fill(0);se[0]=1;let ce=[];for(let ke=1;ke<=k;ke++){let je=D[ke];for(let ye=1;ye<ke;ye++)je-=ce[ye-1]*D[ke-ye];let be=1;for(let ye=1;ye<ke;ye++)be-=ce[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(ke);for(let ye=1;ye<ke;ye++)Pe[ye-1]=ce[ye-1]-Ae*ce[ke-1-ye];Pe[ke-1]=Ae,se[ke]=Ae,ce=Pe}const Oe=1.96/Math.sqrt(O);return{acf:D,pacf:se,bounds:{upper:Oe,lower:-Oe},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2)return null;const V=we(O),I=we(k);let D=0,se=0;for(let je=0;je<P;je++)D+=V[je],se+=I[je];D/=P,se/=P;let ce=0,Oe=0,ke=0;for(let je=0;je<P;je++){const be=V[je]-D,Ae=I[je]-se;ce+=be*Ae,Oe+=be*be,ke+=Ae*Ae}return Oe===0||ke===0?null:Math.max(-1,Math.min(1,ce/Math.sqrt(Oe*ke)))}function Ke(b,j,y){const{xs:O,ys:k,n:P}=$(b,j,y);if(P<2||P>A)return null;let V=0,I=0,D=0,se=0;for(let ke=0;ke<P;ke++)for(let je=ke+1;je<P;je++){const be=Math.sign(O[ke]-O[je]),Ae=Math.sign(k[ke]-k[je]),Pe=be*Ae;Pe>0?V++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:se++)}const ce=V+I+se,Oe=V+I+D;return ce===0||Oe===0?null:(V-I)/Math.sqrt(ce*Oe)}function Ee(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],P=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&P.push((b[ye]-ve)/Math.abs(ve))}let V=null;if(P.length>1){let ye=0;for(const Fe of P)ye+=Fe;ye/=P.length;let ve=0;for(const Fe of P)ve+=(Fe-ye)**2;V=Math.sqrt(ve/(P.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],se=0,ce=0,Oe=0,ke=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],se=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>ce&&(ce=ve,Oe=se,ke=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of P)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:V,annualisedVolatility:V!==null&&I?V*Math.sqrt(I):null,growth:Pe,maxDrawdown:ce,maxDrawdownFrom:Oe,maxDrawdownTo:ke,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,P)=>k+P,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let P=0;for(let be=0;be<y;be++)P+=b[be];P/=y;let V=0;for(let be=0;be<y;be++)V+=(b[be]-P)**2;const I=Math.sqrt(V/(y-1)),D=xe(b),se=D?D.sigma:null,ce=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-P)/(3*be):1/0,ve=O!==null?(P-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},Oe=ce(se),ke=ce(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:P,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:se,sigmaOverall:I,cp:Oe.index,cpk:Oe.k,pp:ke.index,ppk:ke.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=I=>(b[I]-O)/k,V=[];for(let I=0;I<y;I++){if(Math.abs(P(I))>3&&V.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let se=0;for(let ce=I-2;ce<=I;ce++)P(ce)*D>2&&se++;if(se>=2){V.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let se=0;for(let ce=I-4;ce<=I;ce++)P(ce)*D>1&&se++;if(se>=4){V.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let se=!0;for(let ce=I-7;ce<=I;ce++)if(P(ce)*D<=0){se=!1;break}if(se){V.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return V}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,P=D=>(b[D]-O)/k,V=(D,se,ce,Oe)=>{for(const ke of[1,-1]){let je=0;for(let be=D;be<=se;be++)P(be)*ke>ce&&je++;if(je>=Oe)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(P(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const se of[1,-1]){let ce=!0;for(let Oe=D-8;Oe<=D;Oe++)if(P(Oe)*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const se of[1,-1]){let ce=!0;for(let Oe=D-4;Oe<=D;Oe++)if((b[Oe]-b[Oe-1])*se<=0){ce=!1;break}if(ce){I.push({index:D,rule:3,description:se>0?"six rising":"six falling"});break}}if(D>=13){let se=!0;for(let ce=D-12;ce<=D;ce++){const Oe=b[ce]-b[ce-1],ke=b[ce+1<=D?ce+1:ce]-b[ce];if(ce+1>D)break;if(Oe===0||ke===0||Oe>0==ke>0){se=!1;break}}se&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&V(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&V(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let se=!0;for(let ce=D-14;ce<=D;ce++)if(Math.abs(P(ce))>=1){se=!1;break}se&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let se=!0;for(let ce=D-7;ce<=D;ce++)if(Math.abs(P(ce))<=1){se=!1;break}se&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const P=b[0],V=b[k-1];if(V===P)return[{from:P,to:V,count:k}];const I=y-j,D=1.5*I;let se=I>0?Math.max(P,j-D):P,ce=I>0?Math.min(V,y+D):V;ce>se||(se=P,ce=V);const Oe=I>0?2*I/Math.cbrt(k):(ce-se)/(Math.ceil(Math.log2(k))+1),ke=Oe>0?Math.min(O,Math.max(1,Math.ceil((ce-se)/Oe))):1,je=(ce-se)/ke,be=[];for(let Ae=0;Ae<ke;Ae++)be.push({from:se+Ae*je,to:se+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(ke-1,Math.max(0,Math.floor((b[Ae]-se)/je)));be[Pe].count++}return be[0].from=P,be[ke-1].to=V,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let ce=0;ce<y;ce++)O+=b[ce];const k=O/y;let P=0;for(let ce=0;ce<y;ce++){const Oe=b[ce]-k;P+=Oe*Oe}const V=Math.sqrt(P/(y-1)),I=Qe(j),se=ne(1-(1-I)/2,y-1)*V/Math.sqrt(y);return{mean:k,lower:k-se,upper:k+se,margin:se,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const P=Qe(y),V=T(1-(1-P)/2),I=O/k,D=V*V,se=1+D/k,ce=(I+D/(2*k))/se,Oe=V/se*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,ce-Oe),upper:Math.min(1,ce+Oe),n:k,confidence:P}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=ne(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const P=Qe(y),I=T(1-(1-P)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:P}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=Q(b);let k=0;for(let P=0;P<j.length;P++){const V=O(j[P]);if(V==null||V===""||typeof V=="number"&&Number.isNaN(V))continue;const I=V instanceof Date?V.getTime():typeof V=="object"?String(V):V;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const P=new Set(b.keys());for(const V of y.keys())P.add(V);for(const V of P){const I=(b.get(V)||0)/j,D=(y.get(V)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:se}=r(I),ce=D>0?lt({mean:y.mean,sd:y.sd},se):null;return{measure:"standardizedMeanDifference",magnitude:ce,distance:ce===null?0:at(ce),direction:ce===null?0:Math.sign(ce),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:P}=_e(b,j),V=ft(k,P,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:V,distance:V===null?0:V,direction:0,subsetN:P,populationN:y.total||0,reliable:P>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=Q(b);let O=0,k=0;for(let P=0;P<j.length&&O<200;P++){const V=y(j[P]);if(V==null||V==="")continue;if(V instanceof Date)return!1;O++;const I=typeof V=="number"?V:Number(V);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:P,mean:V,m2:I}=r(k);return{numeric:!0,mean:V,sd:P>0?Math.sqrt(I/P):0,n:P}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,Q=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),ne=z.presenceReader,_=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),ie=K.STAT_FNS,J=K.STAT_LABELS;function le(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ue(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++){const R=N[n[F]];Number.isNaN(R)||(g+=R)}return g}for(let F=0;F<c;F++){const R=n[F];if(G(R)===1){const X=N[R];Number.isNaN(X)||(g+=X)}}return g}const M=T(r);for(let N=0;N<c;N++){const G=u(M(n[N]));G!==null&&(g+=G)}return g}ue.kernel=!0;function W(r,n){const c=n.length;let g=0;if(le(r)){const N=r.values,G=ne(r);if(!G){for(let F=0;F<c;F++)Number.isNaN(N[n[F]])||g++;return g}for(let F=0;F<c;F++){const R=n[F];G(R)===1&&!Number.isNaN(N[R])&&g++}return g}const M=T(r);for(let N=0;N<c;N++){const G=M(n[N]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}W.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Y(r,n){const c=W(r,n);return c===0?null:ue(r,n)/c}Y.kernel=!0;function ee(r,n,c,g){const M=n.length;if(le(r)){const R=r.values,X=ne(r);let E=null;if(!X){for(let S=0;S<M;S++){const U=R[n[S]];Number.isNaN(U)||(E===null||(c<0?U<E:U>E))&&(E=U)}return E}for(let S=0;S<M;S++){const U=n[S];if(X(U)===0)continue;const H=R[U];Number.isNaN(H)||(E===null||(c<0?H<E:H>E))&&(E=H)}return E}const N=T(r),G=_(g);let F=null;for(let R=0;R<M;R++){const X=N(n[R]);X==null||typeof X=="number"&&Number.isNaN(X)||(F===null||(c<0?G(X,F)<0:G(X,F)>0))&&(F=X)}return F}function C(r,n,c){return ee(r,n,-1,c&&c.locale)}C.kernel=!0;function A(r,n,c){return ee(r,n,1,c&&c.locale)}A.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(r)(n[n.length-1])}s.kernel=!0;function u(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const f={sum:ue,min:C,max:A,avg:Y,count:L,first:i,last:s,countValues:W,...ie},l=Object.freeze({...J,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?l[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=a.filter(g=>g in f);for(const g of Object.keys(f))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=T(r),g=[];for(let M=0;M<n.length;M++){const N=c(n[M]);N!=null&&g.push(N)}return g}function h(r,n,c,g){const M=n||[];if(typeof c=="string"){const N=f[c];return N?N(r,M,g):(Q(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,M,g):c(d(r,M),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,_=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,ie="|",J="/",le=2e3;function ue(u,f,l){return`${u}${ie}${f}${ie}${l}`}function W(u,f){let l="";for(let t=0;t<u.length;t++){const a=u[t];l+=(t===0?"":f)+(a==null?"":String(a))}return l}function L(u,f,l={}){const t=l.separator||J,a=f.length,{keyOf:m,readers:e}=_(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const R=f[F],X=m(R);if(d.has(X))continue;d.set(X,h.length),r.push(X);const E=new Array(e.length);for(let S=0;S<e.length;S++)E[S]=e[S](R);h.push(E)}const n=z(l.locale),c=h.map((F,R)=>R);c.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=Y(X[S],E[S],n);if(U!==0)return U}return F-R});const g=new Array(c.length),M=new Array(c.length),N=new Map;for(let F=0;F<c.length;F++){const R=c[F];g[F]=h[R],M[F]=W(h[R],t),N.set(r[R],F)}return{keys:g,paths:M,idOf:F=>{const R=N.get(m(F));return R===void 0?-1:R}}}function Y(u,f,l){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:l(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const l=typeof u.handle=="function"?u.handle:null;if(!l)return f.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=l(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,l){if(Array.isArray(u)){const t=l||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function A(u,f,l){const t=C(u,f,l),a=t.separator||J,m=ee(t),e=t.maxColumns===void 0?le:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(X=>W(X,a)):[""]),n=s(h),{keys:c,paths:g,idOf:M}=L(t.pivotHandles||[],n,t),N=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&N>e){const X=new Map;return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${N} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:N,maxColumns:e}}}const F=new Map,R=g.length;for(let X=0;X<h.length;X++){const E=h[X],S=r[X]===void 0?"":r[X],U=E.length;if(U===0)continue;const H=new Int32Array(U),$=new Uint32Array(R+1);for(let ae=0;ae<U;ae++){const p=M(E[ae]);H[ae]=p,p>=0&&$[p+1]++}for(let ae=0;ae<R;ae++)$[ae+1]+=$[ae];const re=new Uint32Array(U),te=$.slice(0,R);for(let ae=0;ae<U;ae++){const p=H[ae];p>=0&&(re[te[p]++]=E[ae])}for(let ae=0;ae<R;ae++){const p=$[ae],B=$[ae+1];if(B===p)continue;const q=re.subarray(p,B);for(let oe=0;oe<m.length;oe++){const w=m[oe],v=K(w.handle,q,w.fn,t.totalContext||{locale:t.locale});F.set(ue(S,g[ae],w.colId),v)}}}return{keys:c,paths:g,fields:G,groupPaths:r,columns:N,values:F,cells:F,error:null}}function i(u,f,l){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${l}${m.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const l=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(l.set(a,t),t+=a.length);return l}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return A}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,_=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,ie=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,le="";function ue(i,s,u={}){const f=u.separator||ie,l=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(l.length===0)return{tuples:[[]],paths:[le],buckets:[t]};const{keyOf:m,readers:e}=_(l,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const R=t[F],X=m(R);let E=d.get(X);if(E===void 0){E=h.length,d.set(X,E),r.push(X);const S=new Array(e.length);for(let U=0;U<e.length;U++)S[U]=e[U](R);h.push(S),n.push([])}n[E].push(R)}const c=he(u.locale),g=h.map((F,R)=>R);g.sort((F,R)=>{const X=h[F],E=h[R];for(let S=0;S<X.length;S++){const U=W(X[S],E[S],c);if(U!==0)return U}return F-R});const M=new Array(g.length),N=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const R=g[F];M[F]=h[R],N[F]=K(h[R],f),G[F]=Uint32Array.from(n[R])}return{tuples:M,paths:N,buckets:G}}function W(i,s,u){const f=i==null,l=s==null;return f||l?f&&l?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let l=0;l<i.length;l++)u.has(i[l])&&f.push(i[l]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ie,f=s.totalContext||{locale:s.locale},l=(i.measures||[]).filter(N=>N&&N.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ue(i.rowHandles||[],t,{...s,separator:u}),m=ue(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,l.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,M=m.buckets.map(N=>new Set(N));for(let N=0;N<m.paths.length;N++){const G=m.buckets[N],F=m.paths[N];for(const R of l)c.set(A(F,R.colId),Y(R.handle,G,R.fn,f))}for(let N=0;N<a.paths.length;N++){const G=a.buckets[N],F=a.paths[N];for(const R of l)n.set(A(F,R.colId),Y(R.handle,G,R.fn,f));for(let R=0;R<m.paths.length;R++){const X=L(G,m.buckets[R],M[R]);if(X.length===0)continue;const E=m.paths[R];for(const S of l)r.set(C(F,E,S.colId),Y(S.handle,X,S.fn,f))}}for(const N of l)g.set(N.colId,Y(N.handle,t,N.fn,f));return{rowAxis:a,columnAxis:m,measures:l.map(N=>({colId:N.colId,fn:N.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function A(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const he=me("packages/core/src/internal/util.js").getPath,Q=me("packages/core/src/compute/handle.js"),z=Q.isMissing,ne=Q.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",ie="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function le(i,s,u={}){const f=s||[];let l=i.map((t,a)=>a);if(f.length===0)return l;for(let t=f.length-1;t>=0;t--)l=ue(i,l,f[t],u);return l}function ue(i,s,u,f){const l=u.locale!==void 0?u.locale:f.locale,t=ne(l),a=u.descending!==void 0?!!u.descending:u.dir==="desc",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const h=(r,n)=>{const c=J(i[r],u.col),g=J(i[n],u.col);let M;return typeof u.compare=="function"?(M=u.compare(c,g,i[r],i[n],a),a&&(M=-M)):M=a?t(g,c):t(c,g),M!==0?M:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function W(i,s,u={}){const f=[];for(let l=0;l<i.length;l++)L(i[l],s,u,l)&&f.push(l);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const l=s.conditions.filter(a=>a!=null);if(l.length===0)return!0;if(s.op==="or")return l.some(a=>L(i,a,u,f));const t=l.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Y(i,s,u,f){const l=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of l){const d=s.map((n,c)=>{const g=J(i[e],n);return f&&f[c]?f[c](g):g}),h=d.map(n=>n==null?ie:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function ee(i,s,u={}){const f=ne(u.locale),l=i.filter(a=>!z(a)),t=l.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return l.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return l.length===0?null:t.reduce((a,m)=>a+m,0)/l.length;case"min":return l.length===0?null:l.reduce((a,m)=>f(m,a)<0?m:a);case"max":return l.length===0?null:l.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:A(i[0]);case"last":return i.length===0?null:A(i[i.length-1]);default:return null}}function C(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function A(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(K,ie=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(ie>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(ie),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,ie=this.#r()){Number.isFinite(K)&&(this.#n.push({t:ie,v:K}),this.#s(ie))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ie=K-this.#e;for(;this.#n.length&&this.#n[0].t<ie;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ie=new he;let J=0,le=1/0,ue=-1/0;for(const{v:W}of this.#n)J+=W,W<le&&(le=W),W>ue&&(ue=W),ie.add(W);return{over:K,count:this.#n.length,sum:J,mean:ie.mean(),min:le,max:ue,variance:ie.variance(),stddev:ie.stddev()}}reduce(K){const ie=this.aggregate(),J={sum:ie.sum,avg:ie.mean,mean:ie.mean,min:ie.min,max:ie.max,count:ie.count,variance:ie.variance,stddev:ie.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:ie.over}}}const z=Object.freeze(["count","time","session"]);function ne(T,K=Date.now){const ie=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new Q(T.kind,ie,K)}const _={Window:Q,WINDOW_KINDS:z,openWindow:ne}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,ne=.6745,_=3.5,T=1.5,K=.975,ie=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(l){if(!l.length)return null;const a=Array.from(l,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function le(l,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,m=l.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let c=0;c<m;c++){const g=Number(l[c]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(l[c]);if(!Number.isFinite(g))continue;const M=ne*(g-r.median)/r.mad;e[c]=M,Math.abs(M)>a&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function ue(l,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<l.length;n++){const c=Number(l[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function W(l,t){if(t<=0)return 0;const a=z(l);if(t<l+1){let c=l,g=1/l,M=g;for(let N=0;N<1e3&&(c+=1,M*=t/c,g+=M,!(Math.abs(M)<Math.abs(g)*1e-15));N++);return g*Math.exp(-t+l*Math.log(t)-a)}const m=1e-300;let e=t+1-l,d=1/m,h=1/e,r=h;for(let c=1;c<1e3;c++){const g=-c*(c-l);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const M=h*d;if(r*=M,Math.abs(M-1)<1e-15)break}return 1-Math.exp(-t+l*Math.log(t)-a)*r}function L(l,t){return l<=0?0:W(t/2,l/2)}function Y(l,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,l);for(;L(m,l)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,l)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function ee(l){const t=l.length,a=l.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(l,t){const a=l.length,m=new Array(t).fill(0);for(const h of l)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of l)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(h[c]-m[c])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function A(l,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=l.length;if(!e)return null;const d=l[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let S=0;S<e;S++){const U=l[S];let H=U.length===d;const $=new Array(d);for(let re=0;H&&re<d;re++){const te=Number(U[re]);Number.isFinite(te)?$[re]=te:H=!1}H&&(c.push(S),g.push($))}const M=d,N=Y(M,a);if(g.length<=d)return{center:[],df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let R=ee(F),X=!1;if(!R){X=!0;let S=0;for(let $=0;$<d;$++)S+=F[$][$];const U=S/d*m||m,H=F.map(($,re)=>$.map((te,ae)=>re===ae?te+U:te));if(R=ee(H),!R)return{center:G,df:M,cutoff:N,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let E=0;for(let S=0;S<g.length;S++){const U=g[S],H=new Array(d);for(let te=0;te<d;te++)H[te]=U[te]-G[te];let $=0;for(let te=0;te<d;te++){let ae=0;for(let p=0;p<d;p++)ae+=R[te][p]*H[p];$+=H[te]*ae}$<0&&($=0);const re=c[S];r[re]=$,h[re]=Math.sqrt($),$>N&&(n[re]=!0,E++)}return{center:G,df:M,cutoff:N,singular:X,used:g.length,distances:h,squared:r,flags:n,flagged:E}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(l,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=l.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let M=0;M<r;M++){const N=Number(l[M]);if(!Number.isFinite(N))continue;const G=Math.max(0,M-m+1),F=[];for(let R=G;R<=M;R++){const X=Number(l[R]);Number.isFinite(X)&&F.push(X)}if(!(F.length<h))if(a==="rollingIqr"){const R=ue(F,{k:d});if(!R)continue;(N<R.lower||N>R.upper)&&(c[M]=!0,g++)}else{const R=J(F);if(!R||R.mad===0)continue;const X=ne*(N-R.median)/R.mad;n[M]=X,Math.abs(X)>e&&(c[M]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:c,flagged:g}}function f(l={}){const t=l||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(ie.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=c=>Number(c==null?NaN:c[a]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((R,X)=>{const E=R?.[d],S=X?.[d];return E===S?0:E==null?-1:S==null?1:E<S?-1:1});const M=g.map(n);let N,G;if(r)({flags:N,scores:G}=u(M,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const R=ue(M,{k:t.k});N=M.map(X=>R?Number.isFinite(X)&&(X<R.lower||X>R.upper):!1),G=M.map(()=>null)}else({flags:N,scores:G}=le(M,{threshold:t.threshold}));if(h){const R=N.length-1;return R<0||!N[R]?!1:{method:m,field:a,flagged:[{row:g[R],score:G[R]}]}}const F=[];for(let R=0;R<N.length;R++)N[R]&&F.push({row:g[R],score:G[R]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return l}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,Q=fe.studentTQuantile,ne=me("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function ie(t){const a=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function le(t){return Math.min(K,Math.max(T,t))}function ue(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),c=h+d*(r-h),g=t(n),M=t(c);for(let N=0;N<e;N++)g<M?(r=c,c=n,M=g,n=r-d*(r-h),g=t(n)):(h=n,n=c,g=M,c=h+d*(r-h),M=t(c));return(h+r)/2}function W(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;h+=(c-g)**2,r+=1;const M=e;e=a*c+(1-a)*(M+d),d=m*(e-M)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Y(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=X=>{let E=0,S=0;for(let U=X;U<X+a&&U<h;U++)t[U]!==null&&(E+=t[U],S+=1);return S?E/S:null},n=r(0),c=r(a);if(n===null||c===null)return null;let g=n,M=(c-n)/a;const N=new Array(a).fill(0);for(let X=0;X<a;X++)N[X]=t[X]===null?0:t[X]-g;const G=N.reduce((X,E)=>X+E,0)/a;for(let X=0;X<a;X++)N[X]-=G;let F=0,R=0;for(let X=a;X<h;X++){const E=X%a,S=N[E],U=t[X];if(U===null){g+=M;continue}const H=g+M+S;F+=(U-H)**2,R+=1;const $=g;g=m*(U-S)+(1-m)*(g+M),M=e*(g-$)+(1-e)*M,N[E]=d*(U-g)+(1-d)*S}return{level:g,trend:M,season:N,phase:(h-1)%a,sse:F,count:R}}function ee(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=ie(t),n=r.map(F=>F.value),c=n.filter(F=>F!==null),g=c.length,{lastAt:M,step:N}=g?J(r):{lastAt:0,step:1},G=F=>M+F*N;return m==="linear"?A(r,g,e,d,h,G):m==="movingAverage"?i(c,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function A(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let c=0,g=0,M=0;for(const U of t){if(U.value===null)continue;const H=U.at-r,$=U.value-n;c+=H*H,g+=H*$,M+=$*$}if(c===0)return null;const N=g/c,G=n-N*r,F=M===0?1:Math.max(0,Math.min(1,g*g/(c*M))),R=Math.max(0,M-N*g),X=a>2?Math.sqrt(R/(a-2)):null,E=a>2?Q(d,a-2):null,S=[];for(let U=1;U<=m;U++){const H=h(U),$=G+N*H;let re=null,te=null,ae=null,p=null,B=null;if(X!==null){const q=1/a+(H-r)**2/c,oe=X*Math.sqrt(1+q),w=X*Math.sqrt(q);B=oe,re=$-E*oe,te=$+E*oe,ae=$-E*w,p=$+E*w}S.push({step:U,at:H,mean:$,lower:re,upper:te,lowerMean:ae,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:X,r2:F,params:{slope:N,intercept:G},points:S}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),c=t.slice(a-n);let g=0;for(const X of c)g+=X;const M=g/n;let N=null,G=null;if(n>1){let X=0;for(const S of c)X+=(S-M)**2;N=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),G=Q(d,n-1)}const F=N===null?null:G*N,R=[];for(let X=1;X<=m;X++)R.push({step:X,at:r(X),mean:M,lower:F===null?null:M-F,upper:F===null?null:M+F,se:N});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:N===null?null:N,params:{windowLen:n},points:R}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null;n===null&&(n=ue(G=>W(t,G).sse));const c=W(t,n),g=he(d),M=c.m>0?c.sse/c.m:null,N=[];for(let G=1;G<=m;G++){const F=c.level;let R=null,X=null,E=null;if(M!==null){const S=[];for(let H=1;H<G;H++)S.push(n);const U=ee(M,S,g);E=U.se,R=F-U.margin,X=F+U.margin}N.push({step:G,at:r(G),mean:F,lower:R,upper:X,se:E})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:M===null?null:Math.sqrt(M),params:{alpha:n},points:N}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?le(h.alpha):null,c=Number.isFinite(h.beta)?le(h.beta):null;if(n===null||c===null){let R=n===null?.5:n,X=c===null?.5:c;for(let E=0;E<6;E++)n===null&&(R=ue(S=>L(t,S,X).sse)),c===null&&(X=ue(S=>L(t,R,S).sse));n=n===null?R:n,c=c===null?X:c}const g=L(t,n,c),M=he(d),N=g.m>0?g.sse/g.m:null,G=n*c,F=[];for(let R=1;R<=m;R++){const X=g.level+R*g.trend;let E=null,S=null,U=null;if(N!==null){const H=[];for(let re=1;re<R;re++)H.push(n+re*G);const $=ee(N,H,M);U=$.se,E=X-$.margin,S=X+$.margin}F.push({step:R,at:r(R),mean:X,lower:E,upper:S,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:N===null?null:Math.sqrt(N),params:{alpha:n,beta:c},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return ne("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let c=Number.isFinite(h.alpha)?le(h.alpha):null,g=Number.isFinite(h.beta)?le(h.beta):null,M=Number.isFinite(h.gamma)?le(h.gamma):null;const N=(U,H,$)=>{const re=Y(t,n,U,H,$);return re?re.sse:1/0};if(c===null||g===null||M===null){let U=c===null?.5:c,H=g===null?.5:g,$=M===null?.5:M;for(let re=0;re<8;re++)c===null&&(U=ue(te=>N(te,H,$))),g===null&&(H=ue(te=>N(U,te,$))),M===null&&($=ue(te=>N(U,H,te)));c=c===null?U:c,g=g===null?H:g,M=M===null?$:M}const G=Y(t,n,c,g,M);if(!G)return null;const F=he(d),R=G.count>0?G.sse/G.count:null,X=c*g,E=M*(1-c),S=[];for(let U=1;U<=m;U++){const H=G.season[(G.phase+U)%n],$=G.level+U*G.trend+H;let re=null,te=null,ae=null;if(R!==null){const p=[];for(let q=1;q<U;q++)p.push(c+q*X+(q%n===0?E:0));const B=ee(R,p,F);ae=B.se,re=$-B.margin,te=$+B.margin}S.push({step:U,at:r(U),mean:$,lower:re,upper:te,se:ae})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:R===null?null:Math.sqrt(R),params:{alpha:c,beta:g,gamma:M,period:n},points:S}}const l={FORECAST_METHODS:_,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const Q=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const ne=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return ne.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return ne.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return ne.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return ne.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ne.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return ne.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return ne.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return ne.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return ne.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return ne.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return ne.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return ne.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return ne.QUANTILE_SAMPLE}});const _=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const ie=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ie.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ie.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ie.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ie.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ie.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ie.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const le=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return le.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return le.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return le.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return le.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return le.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return le.SKETCH_BOUNDS}});const ue=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ue.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ue.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ue.openWindow}});const W=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return W.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return W.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return W.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Y=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,Q=fe.OPS,z=fe.CONTROL,ne=fe.ERRORS,_=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,ie=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),le=J.packChunk,ue=J.packedTransfers;let W=null,L=null,Y=null;async function ee(f){if(W)return W;if(!L){const l=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(l).then(t=>(W=t,t)).catch(t=>(Y=t,W=null,null))}return L}function C(f){W=f,L=f?Promise.resolve(f):null,Y=f?null:Y}function A(f,l,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:l,pool:K(),locale:t}}function i(f,l){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return le(a.schema||[],a.rows||[],a.opts||{});const m=l[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=ne.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return m(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case Q.EVALUATE_FILTERS:return m(a.filters,A(T(a.handles||[]),a.count,a.locale));case Q.COMPACT:return m(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return m(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return m(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=ne.PROTOCOL,e}}}async function s(f,l={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return l.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(l.cancelled?.has(t))return l.cancelled.delete(t),null;try{const e=le(f.args.schema||[],f.args.rows||[],f.args.opts||{});return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ue(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ee(l.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:ne.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(l.cancelled?.has(t))return l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return l.cancelled?.has(t)?(l.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:ne.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||ne.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,l={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:l.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(l.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Ye=Gn("packages/dom/src/index.js"),Qi=Ye.createGrid,Ji=Ye.gridElementsWithin,eo=Ye.createStat,to=Ye.deltaOf,no=Ye.toneOf,ro=Ye.readTable,io=Ye.hydrateTable,oo=Ye.autoInit,so=Ye.createLocalViewStorage,ao=Ye.DEFAULT_VIEWS_KEY,lo=Ye.createHeadlessGrid,uo=Ye.defaults,co=Ye.version,fo=Ye.getVersion,ho=Ye.Grid,po=Ye.EventBus,mo=Ye.Registry,go=Ye.sharedRegistry,yo=Ye.registerModules,bo=Ye.parseLicence,wo=Ye.verifyLicence,vo=Ye.licenceInfo,ko=Ye.watermark,So=Ye.setLicence,Oo=Ye.licenceState,Ao=Ye.isLocalHost,jo=Ye.matchesDomain,Po=Ye.LicenceHolder,Co=Ye.ColumnModel,Eo=Ye.buildGraph,To=Ye.Lookup,Mo=Ye.ValuePipeline,No=Ye.compileFormat,Ro=Ye.compileMask,Lo=Ye.specToOoxml,Fo=Ye.EXTENDED_TYPES,xo=Ye.createRadixType,$o=Ye.RADIX_PRESETS,Io=Ye.parseRadix,Do=Ye.formatRadix,zo=Ye.createUnitType,Bo=Ye.registerUnitSystem,Uo=Ye.defineUnit,Vo=Ye.UNIT_SYSTEMS,Ho=Ye.parseUnit,Go=Ye.formatUnit,Ko=Ye.createCurrencyType,Wo=Ye.parseMoney,_o=Ye.formatMoney,qo=Ye.convertMoney,Zo=Ye.rateFunction,Yo=Ye.MISSING_RATE,Xo=Ye.Messages,Qo=Ye.createMessages,Jo=Ye.auditCatalogue,es=Ye.EN_GB,ts=Ye.MESSAGE_KEYS,ns=Ye.DEFAULT_LOCALE,rs=Ye.formatList,is=Ye.resolveLocale,os=Ye.LOCALES,ss=Ye.resolveCatalogue,as=Ye.EN_US,ls=Ye.FR_FR,us=Ye.FR_CA,cs=Ye.IT_IT,ds=Ye.ES_ES,fs=Ye.PT_BR,hs=Ye.DE_DE,ps=Ye.NL_NL,ms=Ye.SV_SE,gs=Ye.DA_DK,ys=Ye.NB_NO,bs=Ye.FI_FI,ws=Ye.PL_PL,vs=Ye.CS_CZ,ks=Ye.HU_HU,Ss=Ye.RO_RO,Os=Ye.UK_UA,As=Ye.EL_GR,js=Ye.JA_JP,Ps=Ye.AR,Cs=Ye.AR_SA,Es=Ye.ColumnStore,Ts=Ye.Bitset,Ms=Ye.Dictionary,Ns=Ye.MultiValue,Rs=Ye.MaskPool,Ls=Ye.sortColumn,Fs=Ye.sortMulti,xs=Ye.evaluateFilters,$s=Ye.compact,Is=Ye.testValue,Ds=Ye.groupByColumns,zs=Ye.total,Bs=Ye.TOTAL_FNS,Us=Ye.pivot,Vs=Ye.Window,Hs=Ye.openWindow,Gs=Ye.WINDOW_KINDS,Ks=Ye.ANOMALY_METHODS,Ws=Ye.modifiedZScores,_s=Ye.iqrFences,qs=Ye.mahalanobis,Zs=Ye.ROLLING_ANOMALY_METHODS,Ys=Ye.rollingAnomalies,Xs=Ye.anomalyCondition,Qs=Ye.FORECAST_METHODS,Js=Ye.forecast,ea=Ye.evaluateFormula,ta=Ye.parseFormula,na=Ye.referencesOf,ra=Ye.looksLikeFormula,ia=Ye.FormulaError,oa=Ye.FUNCTIONS,sa=Ye.compileRules,aa=Ye.ingest,la=Ye.ingestSync,ua=Ye.createSource,ca=Ye.createMemorySource,da=Ye.createPagedSource,fa=Ye.createRemoteSource,ha=Ye.createStreamSource,pa=Ye.createUrlSource,ma=Ye.PROTOCOL,ga=Ye.createPushdownSource,ya=Ye.planQuery,ba=Ye.splitFilters,wa=Ye.applyResidual,va=Ye.capabilitiesOf,ka=Ye.resolveMutate,Sa=Ye.NO_CAPABILITIES,Oa=Ye.odataAdapter,Aa=Ye.filtersToOData,ja=Ye.conditionToOData,Pa=Ye.restAdapter,Ca=Ye.DEFAULT_PARAMS,Ea=Ye.dfqlAdapter,Ta=Ye.duckdbAdapter,Ma=Ye.filtersToSql,Na=Ye.graphqlAdapter,Ra=Ye.splunkAdapter,La=Ye.clickhouseAdapter,Fa=Ye.elasticsearchAdapter,xa=Ye.RowModel,$a=Ye.createRowKey,Ia=Ye.SelectionModel,Da=Ye.RangeModel,za=Ye.EditModel,Ba=Ye.ChangeModel,Ua=Ye.StateModel,Va=Ye.STATE_VERSION,Ha=Ye.serialiseState,Ga=Ye.restoreState,Ka=Ye.VERSION,Wa=Ye.DomRenderer,_a=Ye.FilterMenu,qa=Ye.mergeColumnFilter,Za=Ye.branchFor,Ya=Ye.ColumnMenu,Xa=Ye.columnMenuItems,Qa=Ye.cellMenuItems,Ja=Ye.autoGroupMenuItems,el=Ye.AlignedGrids,tl=Ye.alignGrids,nl=Ye.layoutState,rl=Ye.ToolPanelDock,il=Ye.panelHost,ol=Ye.mountPanel,sl=Ye.CellEditController,al=Ye.EditBar,ll=Ye.HistoryBar,ul=Ye.HISTORY_CLS,cl=Ye.DiffPainter,dl=Ye.ViewPicker,fl=Ye.VIEW_CLS,hl=Ye.summariseDiff,pl=Ye.PromptBar,ml=Ye.PROMPT_CLASS,gl=Ye.createCellLayer,yl=Ye.compileTemplate,bl=Ye.compileVariant,wl=Ye.checkVariant,vl=Ye.VariantRegistry,kl=Ye.BUILTIN_RENDERERS,Sl=Ye.BUILTIN_VARIANTS,Ol=Ye.BUILTIN_PIPES,Al=Ye.sanitiseHtml,jl=Ye.editors,Pl=Ye.createEditor,Cl=Ye.editorFor,El=Ye.BaseEditor,Tl=Ye.filters,Ml=Ye.createFilter,Nl=Ye.filterFor,Rl=Ye.parseExpression,Ll=Ye.ConditionFilter,Fl=Ye.StatusBar,xl=Ye.ContextMenu,$l=Ye.ToolPanel,Il=Ye.TooltipManager,Dl=Ye.Pagination,zl=Ye.OverlayLayer,Bl=Ye.LatticeGrid,Ul=Ye.setLicense,Vl=Ye.licenseInfo,Hl=Ye.licenseState;var Gl=Ye.default;export{Ks as ANOMALY_METHODS,Ps as AR,Cs as AR_SA,el as AlignedGrids,Ol as BUILTIN_PIPES,kl as BUILTIN_RENDERERS,Sl as BUILTIN_VARIANTS,El as BaseEditor,Ts as Bitset,vs as CS_CZ,sl as CellEditController,Ba as ChangeModel,Ya as ColumnMenu,Co as ColumnModel,Es as ColumnStore,Ll as ConditionFilter,xl as ContextMenu,gs as DA_DK,ns as DEFAULT_LOCALE,Ca as DEFAULT_PARAMS,ao as DEFAULT_VIEWS_KEY,hs as DE_DE,Ms as Dictionary,cl as DiffPainter,Wa as DomRenderer,As as EL_GR,es as EN_GB,as as EN_US,ds as ES_ES,Fo as EXTENDED_TYPES,al as EditBar,za as EditModel,po as EventBus,bs as FI_FI,Qs as FORECAST_METHODS,us as FR_CA,ls as FR_FR,oa as FUNCTIONS,_a as FilterMenu,ia as FormulaError,ho as Grid,ul as HISTORY_CLS,ks as HU_HU,ll as HistoryBar,cs as IT_IT,js as JA_JP,os as LOCALES,Bl as LatticeGrid,Po as LicenceHolder,To as Lookup,ts as MESSAGE_KEYS,Yo as MISSING_RATE,Rs as MaskPool,Xo as Messages,Ns as MultiValue,ys as NB_NO,ps as NL_NL,Sa as NO_CAPABILITIES,zl as OverlayLayer,ws as PL_PL,ml as PROMPT_CLASS,ma as PROTOCOL,fs as PT_BR,Dl as Pagination,pl as PromptBar,$o as RADIX_PRESETS,Zs as ROLLING_ANOMALY_METHODS,Ss as RO_RO,Da as RangeModel,mo as Registry,xa as RowModel,Va as STATE_VERSION,ms as SV_SE,Ia as SelectionModel,Ua as StateModel,Fl as StatusBar,Bs as TOTAL_FNS,$l as ToolPanel,rl as ToolPanelDock,Il as TooltipManager,Os as UK_UA,Vo as UNIT_SYSTEMS,Ka as VERSION,fl as VIEW_CLS,Mo as ValuePipeline,vl as VariantRegistry,dl as ViewPicker,Gs as WINDOW_KINDS,Vs as Window,tl as alignGrids,Xs as anomalyCondition,wa as applyResidual,Jo as auditCatalogue,Ja as autoGroupMenuItems,oo as autoInit,Za as branchFor,Eo as buildGraph,va as capabilitiesOf,Qa as cellMenuItems,wl as checkVariant,La as clickhouseAdapter,Xa as columnMenuItems,$s as compact,No as compileFormat,Ro as compileMask,sa as compileRules,yl as compileTemplate,bl as compileVariant,ja as conditionToOData,qo as convertMoney,gl as createCellLayer,Ko as createCurrencyType,Pl as createEditor,Ml as createFilter,Qi as createGrid,lo as createHeadlessGrid,so as createLocalViewStorage,ca as createMemorySource,Qo as createMessages,da as createPagedSource,ga as createPushdownSource,xo as createRadixType,fa as createRemoteSource,$a as createRowKey,ua as createSource,eo as createStat,ha as createStreamSource,zo as createUnitType,pa as createUrlSource,Gl as default,uo as defaults,Uo as defineUnit,to as deltaOf,Ea as dfqlAdapter,Ta as duckdbAdapter,Cl as editorFor,jl as editors,Fa as elasticsearchAdapter,xs as evaluateFilters,ea as evaluateFormula,Nl as filterFor,Tl as filters,Aa as filtersToOData,Ma as filtersToSql,Js as forecast,rs as formatList,_o as formatMoney,Do as formatRadix,Go as formatUnit,fo as getVersion,Na as graphqlAdapter,Ji as gridElementsWithin,Ds as groupByColumns,io as hydrateTable,aa as ingest,la as ingestSync,_s as iqrFences,Ao as isLocalHost,nl as layoutState,vo as licenceInfo,Oo as licenceState,Vl as licenseInfo,Hl as licenseState,ra as looksLikeFormula,qs as mahalanobis,jo as matchesDomain,qa as mergeColumnFilter,Ws as modifiedZScores,ol as mountPanel,Oa as odataAdapter,Hs as openWindow,il as panelHost,Rl as parseExpression,ta as parseFormula,bo as parseLicence,Wo as parseMoney,Io as parseRadix,Ho as parseUnit,Us as pivot,ya as planQuery,Zo as rateFunction,ro as readTable,na as referencesOf,yo as registerModules,Bo as registerUnitSystem,ss as resolveCatalogue,is as resolveLocale,ka as resolveMutate,Pa as restAdapter,Ga as restoreState,Ys as rollingAnomalies,Al as sanitiseHtml,Ha as serialiseState,So as setLicence,Ul as setLicense,go as sharedRegistry,Ls as sortColumn,Fs as sortMulti,Lo as specToOoxml,ba as splitFilters,Ra as splunkAdapter,hl as summariseDiff,Is as testValue,no as toneOf,zs as total,wo as verifyLicence,co as version,ko as watermark};
58
58
 
59
59
  //# sourceMappingURL=lattice-grid.esm.min.js.map