@toclocoinc/lattice-grid 1.71.1 → 1.71.3

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 (195) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +42 -8
  5. package/docs/api/adapters.html +1 -1
  6. package/docs/api/ai.html +1 -1
  7. package/docs/api/alarms.html +1 -1
  8. package/docs/api/charts.html +39 -5
  9. package/docs/api/data-router.html +1 -1
  10. package/docs/api/gantt.html +1 -1
  11. package/docs/api/grid.html +2 -2
  12. package/docs/api/index.html +2 -2
  13. package/docs/api/kanban.html +1 -1
  14. package/docs/api/kpi.html +1 -1
  15. package/docs/api/layout.html +1 -1
  16. package/docs/api/mock-socket.html +1 -1
  17. package/docs/api/tabs.html +1 -1
  18. package/docs/api/types.html +1 -1
  19. package/docs/api-detail.html +4 -4
  20. package/docs/warnings.json +13 -2
  21. package/lattice-grid.d.ts +31 -7
  22. package/lattice-grid.esm.min.js +3 -3
  23. package/lattice-grid.min.cjs +3 -3
  24. package/lattice-grid.min.js +3 -3
  25. package/modules/ai.d.ts +1 -1
  26. package/modules/ai.esm.min.js +2 -2
  27. package/modules/ai.min.cjs +2 -2
  28. package/modules/ai.min.js +2 -2
  29. package/modules/alarms.d.ts +1 -1
  30. package/modules/alarms.esm.min.js +2 -2
  31. package/modules/alarms.min.cjs +2 -2
  32. package/modules/alarms.min.js +2 -2
  33. package/modules/angular.d.ts +1 -1
  34. package/modules/angular.esm.min.js +2 -2
  35. package/modules/angular.min.cjs +2 -2
  36. package/modules/angular.min.js +2 -2
  37. package/modules/chart-alluvial.d.ts +1 -1
  38. package/modules/chart-alluvial.esm.min.js +1 -1
  39. package/modules/chart-alluvial.min.cjs +1 -1
  40. package/modules/chart-alluvial.min.js +1 -1
  41. package/modules/chart-arc.d.ts +1 -1
  42. package/modules/chart-arc.esm.min.js +1 -1
  43. package/modules/chart-arc.min.cjs +1 -1
  44. package/modules/chart-arc.min.js +1 -1
  45. package/modules/chart-bubblemap.d.ts +1 -1
  46. package/modules/chart-bubblemap.esm.min.js +1 -1
  47. package/modules/chart-bubblemap.min.cjs +1 -1
  48. package/modules/chart-bubblemap.min.js +1 -1
  49. package/modules/chart-bump.d.ts +1 -1
  50. package/modules/chart-bump.esm.min.js +1 -1
  51. package/modules/chart-bump.min.cjs +1 -1
  52. package/modules/chart-bump.min.js +1 -1
  53. package/modules/chart-calendar.d.ts +1 -1
  54. package/modules/chart-calendar.esm.min.js +1 -1
  55. package/modules/chart-calendar.min.cjs +1 -1
  56. package/modules/chart-calendar.min.js +1 -1
  57. package/modules/chart-decomposition.d.ts +1 -1
  58. package/modules/chart-decomposition.esm.min.js +1 -1
  59. package/modules/chart-decomposition.min.cjs +1 -1
  60. package/modules/chart-decomposition.min.js +1 -1
  61. package/modules/chart-diverging.d.ts +1 -1
  62. package/modules/chart-diverging.esm.min.js +1 -1
  63. package/modules/chart-diverging.min.cjs +1 -1
  64. package/modules/chart-diverging.min.js +1 -1
  65. package/modules/chart-dumbbell.d.ts +1 -1
  66. package/modules/chart-dumbbell.esm.min.js +1 -1
  67. package/modules/chart-dumbbell.min.cjs +1 -1
  68. package/modules/chart-dumbbell.min.js +1 -1
  69. package/modules/chart-fan.d.ts +1 -1
  70. package/modules/chart-fan.esm.min.js +1 -1
  71. package/modules/chart-fan.min.cjs +1 -1
  72. package/modules/chart-fan.min.js +1 -1
  73. package/modules/chart-hexbin.d.ts +1 -1
  74. package/modules/chart-hexbin.esm.min.js +1 -1
  75. package/modules/chart-hexbin.min.cjs +1 -1
  76. package/modules/chart-hexbin.min.js +1 -1
  77. package/modules/chart-hexmap.d.ts +1 -1
  78. package/modules/chart-hexmap.esm.min.js +1 -1
  79. package/modules/chart-hexmap.min.cjs +1 -1
  80. package/modules/chart-hexmap.min.js +1 -1
  81. package/modules/chart-icicle.d.ts +1 -1
  82. package/modules/chart-icicle.esm.min.js +1 -1
  83. package/modules/chart-icicle.min.cjs +1 -1
  84. package/modules/chart-icicle.min.js +1 -1
  85. package/modules/chart-markermap.d.ts +1 -1
  86. package/modules/chart-markermap.esm.min.js +1 -1
  87. package/modules/chart-markermap.min.cjs +1 -1
  88. package/modules/chart-markermap.min.js +1 -1
  89. package/modules/chart-parallel.d.ts +1 -1
  90. package/modules/chart-parallel.esm.min.js +1 -1
  91. package/modules/chart-parallel.min.cjs +1 -1
  92. package/modules/chart-parallel.min.js +1 -1
  93. package/modules/chart-ridgeline.d.ts +1 -1
  94. package/modules/chart-ridgeline.esm.min.js +1 -1
  95. package/modules/chart-ridgeline.min.cjs +1 -1
  96. package/modules/chart-ridgeline.min.js +1 -1
  97. package/modules/chart-roc.d.ts +1 -1
  98. package/modules/chart-roc.esm.min.js +1 -1
  99. package/modules/chart-roc.min.cjs +1 -1
  100. package/modules/chart-roc.min.js +1 -1
  101. package/modules/chart-slope.d.ts +1 -1
  102. package/modules/chart-slope.esm.min.js +1 -1
  103. package/modules/chart-slope.min.cjs +1 -1
  104. package/modules/chart-slope.min.js +1 -1
  105. package/modules/chart-splom.d.ts +1 -1
  106. package/modules/chart-splom.esm.min.js +1 -1
  107. package/modules/chart-splom.min.cjs +1 -1
  108. package/modules/chart-splom.min.js +1 -1
  109. package/modules/chart-waffle.d.ts +1 -1
  110. package/modules/chart-waffle.esm.min.js +1 -1
  111. package/modules/chart-waffle.min.cjs +1 -1
  112. package/modules/chart-waffle.min.js +1 -1
  113. package/modules/charts.d.ts +1 -1
  114. package/modules/charts.esm.min.js +13 -9
  115. package/modules/charts.esm.min.js.map +2 -2
  116. package/modules/charts.min.cjs +141 -137
  117. package/modules/charts.min.js +141 -137
  118. package/modules/charts.min.js.map +2 -2
  119. package/modules/data-router.d.ts +1 -1
  120. package/modules/data-router.esm.min.js +2 -2
  121. package/modules/data-router.min.cjs +2 -2
  122. package/modules/data-router.min.js +2 -2
  123. package/modules/devtools.d.ts +1 -1
  124. package/modules/devtools.esm.min.js +1 -1
  125. package/modules/devtools.min.cjs +1 -1
  126. package/modules/devtools.min.js +1 -1
  127. package/modules/dhtmlx-compat.d.ts +1 -1
  128. package/modules/dhtmlx-compat.esm.min.js +2 -2
  129. package/modules/dhtmlx-compat.min.cjs +2 -2
  130. package/modules/dhtmlx-compat.min.js +2 -2
  131. package/modules/gantt.d.ts +1 -1
  132. package/modules/gantt.esm.min.js +2 -2
  133. package/modules/gantt.min.cjs +2 -2
  134. package/modules/gantt.min.js +2 -2
  135. package/modules/geo-europe-nuts.d.ts +1 -1
  136. package/modules/geo-europe-nuts.esm.min.js +1 -1
  137. package/modules/geo-europe-nuts.min.cjs +1 -1
  138. package/modules/geo-europe-nuts.min.js +1 -1
  139. package/modules/geo-uk.d.ts +1 -1
  140. package/modules/geo-uk.esm.min.js +1 -1
  141. package/modules/geo-uk.min.cjs +1 -1
  142. package/modules/geo-uk.min.js +1 -1
  143. package/modules/geo-us-states.d.ts +1 -1
  144. package/modules/geo-us-states.esm.min.js +1 -1
  145. package/modules/geo-us-states.min.cjs +1 -1
  146. package/modules/geo-us-states.min.js +1 -1
  147. package/modules/geo-world-110m.d.ts +1 -1
  148. package/modules/geo-world-110m.esm.min.js +1 -1
  149. package/modules/geo-world-110m.min.cjs +1 -1
  150. package/modules/geo-world-110m.min.js +1 -1
  151. package/modules/geo-world-50m.d.ts +1 -1
  152. package/modules/geo-world-50m.esm.min.js +1 -1
  153. package/modules/geo-world-50m.min.cjs +1 -1
  154. package/modules/geo-world-50m.min.js +1 -1
  155. package/modules/htmx.d.ts +1 -1
  156. package/modules/htmx.esm.min.js +3 -3
  157. package/modules/htmx.min.cjs +3 -3
  158. package/modules/htmx.min.js +3 -3
  159. package/modules/kanban.d.ts +1 -1
  160. package/modules/kanban.esm.min.js +2 -2
  161. package/modules/kanban.min.cjs +2 -2
  162. package/modules/kanban.min.js +2 -2
  163. package/modules/kpi.d.ts +1 -1
  164. package/modules/kpi.esm.min.js +2 -2
  165. package/modules/kpi.min.cjs +2 -2
  166. package/modules/kpi.min.js +2 -2
  167. package/modules/layout.d.ts +1 -1
  168. package/modules/layout.esm.min.js +2 -2
  169. package/modules/layout.min.cjs +2 -2
  170. package/modules/layout.min.js +2 -2
  171. package/modules/mock-socket.d.ts +1 -1
  172. package/modules/mock-socket.esm.min.js +1 -1
  173. package/modules/mock-socket.min.cjs +1 -1
  174. package/modules/mock-socket.min.js +1 -1
  175. package/modules/react.d.ts +1 -1
  176. package/modules/react.esm.min.js +2 -2
  177. package/modules/react.min.cjs +2 -2
  178. package/modules/react.min.js +2 -2
  179. package/modules/svelte.d.ts +1 -1
  180. package/modules/svelte.esm.min.js +2 -2
  181. package/modules/svelte.min.cjs +2 -2
  182. package/modules/svelte.min.js +2 -2
  183. package/modules/tabs.d.ts +1 -1
  184. package/modules/tabs.esm.min.js +2 -2
  185. package/modules/tabs.min.cjs +2 -2
  186. package/modules/tabs.min.js +2 -2
  187. package/modules/vue.d.ts +1 -1
  188. package/modules/vue.esm.min.js +2 -2
  189. package/modules/vue.min.cjs +2 -2
  190. package/modules/vue.min.js +2 -2
  191. package/modules/webcomponent.d.ts +1 -1
  192. package/modules/webcomponent.esm.min.js +3 -3
  193. package/modules/webcomponent.min.cjs +3 -3
  194. package/modules/webcomponent.min.js +3 -3
  195. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, webcomponent module
2
+ * Lattice Grid 1.71.3, webcomponent module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- (function(Hn){"use strict";var Vn=Object.create(null),Gn=Object.create(null);function Se(e,V){Vn[e]=V}function En(e){var V=Gn[e];if(V)return V;var _=Object.create(null);Gn[e]=_;var N=Vn[e];if(!N)throw new Error("[lattice] missing module: "+e);return N(_,En),_}Se("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return re}});const _="1.71.1";async function N(){return _}const $="1.71.1",L=new Set,W=2e3;function Z(ie){if(L.add(ie),L.size>W){const ae=L.values().next().value;ae!==void 0&&L.delete(ae)}}const H=[],U=500;function z(ie,ae,ee){H.push({key:ie,level:ae,message:ee.map(J=>typeof J=="string"?J:F(J)).join(" "),at:Date.now()}),H.length>U&&H.shift()}function F(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function k(){return H.map(ie=>({...ie}))}function S(ie,...ae){L.has(ie)||(Z(ie),z(ie,"warn",ae),console.warn("[lattice]",...ae))}function b(ie,...ae){L.has(ie)||(Z(ie),z(ie,"info",ae),console.info("[lattice]",...ae))}function a(){L.clear(),H.length=0}function l(ie,ae){const ee=new Error(`[lattice] ${ie}`);throw ae!==void 0&&(ee.cause=ae),ee}function r(ie,ae){ie||l(ae)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(ie){return ie!==null&&typeof ie=="object"&&!Array.isArray(ie)}function i(ie){return typeof ie=="function"}function o(ie){return ie==null}function c(ie){return ie==null||ie===""}function d(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const f=new Map;function h(ie){let ae=f.get(ie);if(ae)return ae;if(!ie.includes("."))ae=ee=>ee?.[ie];else{const ee=ie.split("."),J=ee.length;ae=se=>{let le=se;for(let oe=0;oe<J;oe++){if(le==null)return;le=le[ee[oe]]}return le}}return f.set(ie,ae),ae}const g=new Map;function y(ie){let ae=g.get(ie);if(ae)return ae;if(!ie.includes("."))ae=(ee,J)=>{ee!=null&&(ee[ie]=J)};else{const ee=ie.split("."),J=ee.length-1;ae=(se,le)=>{let oe=se;for(let he=0;he<J;he++){if(oe==null)return;const fe=ee[he];oe[fe]==null&&(oe[fe]={}),oe=oe[fe]}oe!=null&&(oe[ee[J]]=le)}}return g.set(ie,ae),ae}function p(ie,ae){return h(ae)(ie)}function m(ie,ae,ee){y(ae)(ie,ee)}function w(ie){return ie?(ie.includes(".")?ie.slice(ie.lastIndexOf(".")+1):ie).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(/^./,ee=>ee.toUpperCase()):""}const v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function u(ie){const ae=ie==null?"":String(ie);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,ee=>v[ee]):ae}function s(ie){return String(ie).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function O(ie,ae,ee){if(ie!==void 0)return ie===!0?{enabled:!0,...ee}:ie===!1?{enabled:!1}:n(ie)?ie:{[ae]:ie,enabled:!0}}function E(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const A=Object.freeze(new Set(["__proto__","constructor","prototype"]));function M(ie,ae){if(!n(ie))return n(ae)?{...ae}:ae;if(!n(ae))return ae===void 0?ie:ae;const ee={...ie};for(const J of Object.keys(ae)){if(A.has(J))continue;const se=ae[J];se!==void 0&&(ee[J]=n(se)&&n(ee[J])?M(ee[J],se):se)}return ee}function C(ie,ae){if(!n(ie)||!n(ae)||ie===ae)return ae;const ee=Object.create(Object.getPrototypeOf(ie));return Object.assign(ee,ie,ae),ee}class P{#e;#t=new Map;#n;constructor(ae=256,ee=null){this.#e=ae,this.#n=ee}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 ee=this.#t;if(!ee.has(ae))return;const J=ee.get(ae);return ee.delete(ae),ee.set(ae,J),J}peek(ae){return this.#t.get(ae)}set(ae,ee){const J=this.#t;return J.has(ae)&&J.delete(ae),J.set(ae,ee),this.#r(),ee}delete(ae){const ee=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(ee,ae),ee}clear(){if(this.#n)for(const[ae,ee]of this.#t)this.#n(ee,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 ee=ae.keys().next().value,J=ae.get(ee);ae.delete(ee),this.#n&&this.#n(J,ee)}}}const D=new Map;function K(ie,ae){const ee=`${ie||""}|${ae?JSON.stringify(ae):""}`;let J=D.get(ee);return J||(J=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...ae}),D.set(ee,J)),J}function x(ie,ae){if(ie===ae)return 0;if(ie==null)return 1;if(ae==null)return-1;if(typeof ie=="number"&&typeof ae=="number")return Number.isNaN(ie)?Number.isNaN(ae)?0:1:Number.isNaN(ae)||ie<ae?-1:ie>ae?1:0;const ee=String(ie),J=String(ae);return ee<J?-1:ee>J?1:0}function I(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function T(ie){return j?requestAnimationFrame(ie):setTimeout(()=>ie(I()),16)}function B(ie){ie!=null&&(j?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let ae=null,ee=null;const J=()=>{ae=null;const le=ee;ee=null,ie(...le||[])},se=(...le)=>{ee=le,ae===null&&(ae=T(J))};return se.cancel=()=>{B(ae),ae=null,ee=null},se.flush=()=>{ae!==null&&(B(ae),J())},se}function X(ie,ae){let ee=null,J=null;const se=()=>{if(ee=null,J===null)return;const he=J;J=null,ie(...he),le()},le=()=>{ee=setTimeout(se,ae),typeof ee?.unref=="function"&&ee.unref()},oe=(...he)=>{ee===null?(ie(...he),le()):(J=he,clearTimeout(ee),le())};return oe.flush=()=>{if(ee!==null&&clearTimeout(ee),ee=null,J===null)return;const he=J;J=null,ie(...he)},oe.cancel=()=>{ee!==null&&clearTimeout(ee),ee=null,J=null},oe.pending=()=>ee!==null||J!==null,oe}function Q(ie,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:ae}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let te=0;function re(ie="l"){return`${ie}${(++te).toString(36)}`}}),Se("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return O}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,L=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Z=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function H(E,A){const M=Number(E),C=Number(A);if(E!==null&&E!==""&&A!==null&&A!==""&&Number.isFinite(M)&&Number.isFinite(C))return M<C?-1:M>C?1:0;const D=String(E??"").toLowerCase(),K=String(A??"").toLowerCase();return D<K?-1:D>K?1:0}function U(E){return E==null||E===""}function z(E,A){if(!A||typeof A!="object")return!1;const{op:M}=A,C=A.value,P=A.value2;switch(M){case"blank":return U(E);case"notBlank":return!U(E);case"true":return E===!0;case"false":return E===!1;default:break}if(U(E))return!1;switch(M){case"eq":return H(E,C)===0;case"ne":return H(E,C)!==0;case"gt":return H(E,C)>0;case"gte":return H(E,C)>=0;case"lt":return H(E,C)<0;case"lte":return H(E,C)<=0;case"between":return H(E,C)>=0&&H(E,P)<=0;case"outside":return H(E,C)<0||H(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function F(E,A,M){const C=q=>{const X=String(q).replace("#",""),Q=X.length===3?X.split("").map(te=>te+te).join(""):X;return[0,2,4].map(te=>parseInt(Q.slice(te,te+2),16)||0)},[P,D,K]=C(E),[x,I,j]=C(A),T=Math.max(0,Math.min(1,M)),B=(q,X)=>Math.round(q+(X-q)*T);return`#${[B(P,x),B(D,I),B(K,j)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(E){const A=[];for(const x of E||[]){if(x==null||x==="")continue;const I=x instanceof Date?x.getTime():Number(x);Number.isFinite(I)&&A.push(I)}if(!A.length)return null;A.sort((x,I)=>x-I);let M=0,C=0,P=0;for(const x of A){M++;const I=x-C;C+=I/M,P+=I*(x-C)}const D=S(A,.25),K=S(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(P/(A.length-1)):0,median:S(A,.5),q1:D,q3:K,iqr:K-D,sorted:A}}function S(E,A){if(!E.length)return 0;const M=(E.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(M),P=Math.ceil(M);return C===P?E[C]:E[C]+(M-C)*(E[P]-E[C])}function b(E){for(const A of Array.isArray(E)?E:[])if(!(!A||typeof A!="object")&&(A.when&&W.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function a(E,A){const M=Number(E.value),C=P=>S(A.sorted,P);switch(E.op){case"topPercent":{const P=l(M,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=l(M,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(M)||1),D=Math.max(0,A.sorted.length-P);return{op:"gte",value:A.sorted[D]}}case"bottomN":{const P=Math.max(1,Math.floor(M)||1),D=Math.min(A.sorted.length-1,P-1);return{op:"lte",value:A.sorted[D]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(M)?M:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(M)?M:2)*A.stddev}:null;case"outlier":{const P=(Number.isFinite(M)&&M>0?M:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-P,value2:A.q3+P}:null}default:return null}}function l(E,A){const M=Number.isFinite(E)?E:A,C=M>1?M/100:M;return Math.max(0,Math.min(1,C))}function r(E,A){if(E.from==="minmax")return{...E,min:A.min,max:A.max};if(E.from==="quantile")return{...E,min:S(A.sorted,l(Number(E.low),5)),max:S(A.sorted,l(Number(E.high),95))};if(E.from==="stddev"){const M=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:A.mean-M*A.stddev,max:A.mean+M*A.stddev}}return E}function t(E,A){const M=Array.isArray(E)?E:[];return!A||!A.n?M.map(C=>C&&b([C])?{...C,enabled:!1}:C):M.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:r(C.scale,A)};if(C.dataBar)return{...C,dataBar:n(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:i(C.iconSet,A)};if(!C.when||!W.includes(C.when.op))return C;const P=a(C.when,A);return P?{...C,when:P}:{...C,enabled:!1}})}function n(E,A){const M=Number.isFinite(Number(E.min))?Number(E.min):void 0,C=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(M!==void 0&&C!==void 0)return{...E,min:M,max:C};if(E.from==="quantile")return{...E,min:M??S(A.sorted,l(Number(E.low),5)),max:C??S(A.sorted,l(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:M??A.mean-P*A.stddev,max:C??A.mean+P*A.stddev}}return{...E,min:M??A.min,max:C??A.max}}function i(E,A){if(Array.isArray(E.thresholds))return E;const M=o(E),C=[];for(let P=1;P<M;P++)C.push(S(A.sorted,P/M));return{...E,thresholds:C}}function o(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const A=p[E.set];return A?A.length:3}function c(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function d(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function f(E,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function h(E,A){const M="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let P=0;P<A;P++){const D=P<E?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${M}" fill="${D}"/>`}return`${C}</svg>`}const g=Object.freeze([f("#c0392b","down"),f("#e0a800","right"),f("#2e7d32","up")]),y=Object.freeze([d("#d13438"),d("#f5a623"),d("#2e9e44")]),p=Object.freeze({arrows:g,trafficLights:y,ratings:Object.freeze([1,2,3,4,5].map(E=>h(E,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?c(String(C)):String(C));const A=E.set||"arrows";if(A==="ratings"){const C=o(E),P=[];for(let D=1;D<=C;D++)P.push(c(h(D,C)));return P}const M=p[A];return M?M.map(c):($(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),g.map(c))}function v(E){const A=Number(E.min),C=Number(E.max)-A,P=E.colour||E.color||"#5b9bd5",D=E.negativeColour||E.negativeColor||"#d13438",K=E.direction==="rtl"?"left":"right",x=j=>Math.max(0,Math.min(1,(j-A)/C))*100,I=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return j=>{if(U(j))return null;const T=Number(j);if(!Number.isFinite(T)||!C)return null;const B=x(T),q=Math.min(B,I),X=Math.max(B,I),Q=T>=0?P:D;return{backgroundImage:`linear-gradient(to ${K}, transparent ${q}%, ${Q} ${q}%, ${Q} ${X}%, transparent ${X}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function u(E){const A=w(E),M=E.reverse?[...A].reverse():A,C=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,D=E.set==="ratings"?P*o(E):P;return K=>{if(U(K))return null;const x=Number(K);if(!Number.isFinite(x))return null;let I=0;for(const T of C)x>=T&&I++;const j=M[Math.min(I,M.length-1)];return j?{backgroundImage:j,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${D}px ${P}px`,paddingLeft:`${D+4}px`}:null}}function s(E){const A=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],M=Number(E.min),C=Number(E.max),P=C-M,D=A.length-1,K=[];for(let I=0;I<=D;I++)K.push(D?I/D:0);const x=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(A.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(x)&&P&&x>Math.min(M,C)&&x<Math.max(M,C)){const I=D/2,j=Math.max(0,Math.min(1,(x-M)/P));for(let T=0;T<=D;T++)K[T]=T<=I?I?T/I*j:j:j+(T-I)/(D-I)*(1-j)}else Number.isFinite(x)&&$("formatting.scale.mid.range",`a scale's "mid" (${x}) is outside its min..max range, so it was ignored.`);return I=>{const j=Number(I);if(!Number.isFinite(j)||!P)return null;const T=Math.max(0,Math.min(1,(j-M)/P));let B=0;for(;B<D-1&&T>K[B+1];)B++;const q=K[B+1]-K[B],X=q>0?(T-K[B])/q:0;return{background:F(A[B],A[B+1],Math.max(0,Math.min(1,X)))}}}function O(E,A=null){const M=b(E)?t(E,A):E,C=(Array.isArray(M)?M:[]).filter(D=>D&&typeof D=="object");if(!C.length)return()=>null;const P=C.map(D=>D.scale?{scale:s(D.scale),enabled:D.enabled!==!1}:D.dataBar?{scale:v(D.dataBar),enabled:D.enabled!==!1}:D.iconSet?{scale:u(D.iconSet),enabled:D.enabled!==!1}:{when:D.when,style:D.style,stop:D.stopIfTrue!==!1,enabled:D.enabled!==!1});return D=>{const K=D?D.value:void 0;let x=null;for(const I of P){if(!I.enabled)continue;if(I.scale){const T=I.scale(K);T&&(x={...x||{},...T});continue}if(!z(K,I.when))continue;const j=N(I.style)?I.style(D):I.style;if(j&&(x={...x||{},...j}),I.stop)break}return x}}}),Se("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return n}});const _="num",N="str",$="ref",L="name",W="op",Z="end",H=["<=",">=","<>","!="],U="+-*/^%(),<>=";class z extends Error{constructor(o,c){super(o),this.name="FormulaError",this.at=c}}function F(i){const o=[];let c=0;for(;c<i.length;){const d=i[c];if(d===" "||d===" "||d===`
6
+ (function(Hn){"use strict";var Vn=Object.create(null),Gn=Object.create(null);function Se(e,V){Vn[e]=V}function En(e){var V=Gn[e];if(V)return V;var _=Object.create(null);Gn[e]=_;var N=Vn[e];if(!N)throw new Error("[lattice] missing module: "+e);return N(_,En),_}Se("packages/core/src/internal/util.js",function(e,V){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return re}});const _="1.71.3";async function N(){return _}const $="1.71.3",L=new Set,W=2e3;function Z(ie){if(L.add(ie),L.size>W){const ae=L.values().next().value;ae!==void 0&&L.delete(ae)}}const H=[],U=500;function z(ie,ae,ee){H.push({key:ie,level:ae,message:ee.map(J=>typeof J=="string"?J:F(J)).join(" "),at:Date.now()}),H.length>U&&H.shift()}function F(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function k(){return H.map(ie=>({...ie}))}function S(ie,...ae){L.has(ie)||(Z(ie),z(ie,"warn",ae),console.warn("[lattice]",...ae))}function b(ie,...ae){L.has(ie)||(Z(ie),z(ie,"info",ae),console.info("[lattice]",...ae))}function a(){L.clear(),H.length=0}function l(ie,ae){const ee=new Error(`[lattice] ${ie}`);throw ae!==void 0&&(ee.cause=ae),ee}function r(ie,ae){ie||l(ae)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(ie){return ie!==null&&typeof ie=="object"&&!Array.isArray(ie)}function i(ie){return typeof ie=="function"}function o(ie){return ie==null}function c(ie){return ie==null||ie===""}function d(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const f=new Map;function h(ie){let ae=f.get(ie);if(ae)return ae;if(!ie.includes("."))ae=ee=>ee?.[ie];else{const ee=ie.split("."),J=ee.length;ae=se=>{let le=se;for(let oe=0;oe<J;oe++){if(le==null)return;le=le[ee[oe]]}return le}}return f.set(ie,ae),ae}const g=new Map;function y(ie){let ae=g.get(ie);if(ae)return ae;if(!ie.includes("."))ae=(ee,J)=>{ee!=null&&(ee[ie]=J)};else{const ee=ie.split("."),J=ee.length-1;ae=(se,le)=>{let oe=se;for(let he=0;he<J;he++){if(oe==null)return;const fe=ee[he];oe[fe]==null&&(oe[fe]={}),oe=oe[fe]}oe!=null&&(oe[ee[J]]=le)}}return g.set(ie,ae),ae}function p(ie,ae){return h(ae)(ie)}function m(ie,ae,ee){y(ae)(ie,ee)}function w(ie){return ie?(ie.includes(".")?ie.slice(ie.lastIndexOf(".")+1):ie).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(/^./,ee=>ee.toUpperCase()):""}const v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function u(ie){const ae=ie==null?"":String(ie);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,ee=>v[ee]):ae}function s(ie){return String(ie).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function O(ie,ae,ee){if(ie!==void 0)return ie===!0?{enabled:!0,...ee}:ie===!1?{enabled:!1}:n(ie)?ie:{[ae]:ie,enabled:!0}}function E(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const A=Object.freeze(new Set(["__proto__","constructor","prototype"]));function M(ie,ae){if(!n(ie))return n(ae)?{...ae}:ae;if(!n(ae))return ae===void 0?ie:ae;const ee={...ie};for(const J of Object.keys(ae)){if(A.has(J))continue;const se=ae[J];se!==void 0&&(ee[J]=n(se)&&n(ee[J])?M(ee[J],se):se)}return ee}function C(ie,ae){if(!n(ie)||!n(ae)||ie===ae)return ae;const ee=Object.create(Object.getPrototypeOf(ie));return Object.assign(ee,ie,ae),ee}class P{#e;#t=new Map;#n;constructor(ae=256,ee=null){this.#e=ae,this.#n=ee}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 ee=this.#t;if(!ee.has(ae))return;const J=ee.get(ae);return ee.delete(ae),ee.set(ae,J),J}peek(ae){return this.#t.get(ae)}set(ae,ee){const J=this.#t;return J.has(ae)&&J.delete(ae),J.set(ae,ee),this.#r(),ee}delete(ae){const ee=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(ee,ae),ee}clear(){if(this.#n)for(const[ae,ee]of this.#t)this.#n(ee,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 ee=ae.keys().next().value,J=ae.get(ee);ae.delete(ee),this.#n&&this.#n(J,ee)}}}const D=new Map;function K(ie,ae){const ee=`${ie||""}|${ae?JSON.stringify(ae):""}`;let J=D.get(ee);return J||(J=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...ae}),D.set(ee,J)),J}function x(ie,ae){if(ie===ae)return 0;if(ie==null)return 1;if(ae==null)return-1;if(typeof ie=="number"&&typeof ae=="number")return Number.isNaN(ie)?Number.isNaN(ae)?0:1:Number.isNaN(ae)||ie<ae?-1:ie>ae?1:0;const ee=String(ie),J=String(ae);return ee<J?-1:ee>J?1:0}function I(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const j=typeof requestAnimationFrame=="function";function T(ie){return j?requestAnimationFrame(ie):setTimeout(()=>ie(I()),16)}function B(ie){ie!=null&&(j?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let ae=null,ee=null;const J=()=>{ae=null;const le=ee;ee=null,ie(...le||[])},se=(...le)=>{ee=le,ae===null&&(ae=T(J))};return se.cancel=()=>{B(ae),ae=null,ee=null},se.flush=()=>{ae!==null&&(B(ae),J())},se}function X(ie,ae){let ee=null,J=null;const se=()=>{if(ee=null,J===null)return;const he=J;J=null,ie(...he),le()},le=()=>{ee=setTimeout(se,ae),typeof ee?.unref=="function"&&ee.unref()},oe=(...he)=>{ee===null?(ie(...he),le()):(J=he,clearTimeout(ee),le())};return oe.flush=()=>{if(ee!==null&&clearTimeout(ee),ee=null,J===null)return;const he=J;J=null,ie(...he)},oe.cancel=()=>{ee!==null&&clearTimeout(ee),ee=null,J=null},oe.pending=()=>ee!==null||J!==null,oe}function Q(ie,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:ae}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let te=0;function re(ie="l"){return`${ie}${(++te).toString(36)}`}}),Se("packages/core/src/formatting/rules.js",function(e,V){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return O}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,L=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Z=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function H(E,A){const M=Number(E),C=Number(A);if(E!==null&&E!==""&&A!==null&&A!==""&&Number.isFinite(M)&&Number.isFinite(C))return M<C?-1:M>C?1:0;const D=String(E??"").toLowerCase(),K=String(A??"").toLowerCase();return D<K?-1:D>K?1:0}function U(E){return E==null||E===""}function z(E,A){if(!A||typeof A!="object")return!1;const{op:M}=A,C=A.value,P=A.value2;switch(M){case"blank":return U(E);case"notBlank":return!U(E);case"true":return E===!0;case"false":return E===!1;default:break}if(U(E))return!1;switch(M){case"eq":return H(E,C)===0;case"ne":return H(E,C)!==0;case"gt":return H(E,C)>0;case"gte":return H(E,C)>=0;case"lt":return H(E,C)<0;case"lte":return H(E,C)<=0;case"between":return H(E,C)>=0&&H(E,P)<=0;case"outside":return H(E,C)<0||H(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function F(E,A,M){const C=q=>{const X=String(q).replace("#",""),Q=X.length===3?X.split("").map(te=>te+te).join(""):X;return[0,2,4].map(te=>parseInt(Q.slice(te,te+2),16)||0)},[P,D,K]=C(E),[x,I,j]=C(A),T=Math.max(0,Math.min(1,M)),B=(q,X)=>Math.round(q+(X-q)*T);return`#${[B(P,x),B(D,I),B(K,j)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(E){const A=[];for(const x of E||[]){if(x==null||x==="")continue;const I=x instanceof Date?x.getTime():Number(x);Number.isFinite(I)&&A.push(I)}if(!A.length)return null;A.sort((x,I)=>x-I);let M=0,C=0,P=0;for(const x of A){M++;const I=x-C;C+=I/M,P+=I*(x-C)}const D=S(A,.25),K=S(A,.75);return{n:A.length,min:A[0],max:A[A.length-1],mean:C,stddev:A.length>1?Math.sqrt(P/(A.length-1)):0,median:S(A,.5),q1:D,q3:K,iqr:K-D,sorted:A}}function S(E,A){if(!E.length)return 0;const M=(E.length-1)*Math.max(0,Math.min(1,A)),C=Math.floor(M),P=Math.ceil(M);return C===P?E[C]:E[C]+(M-C)*(E[P]-E[C])}function b(E){for(const A of Array.isArray(E)?E:[])if(!(!A||typeof A!="object")&&(A.when&&W.includes(A.when.op)||A.scale&&A.scale.from||A.dataBar&&!(Number.isFinite(Number(A.dataBar.min))&&Number.isFinite(Number(A.dataBar.max)))||A.iconSet&&!Array.isArray(A.iconSet.thresholds)))return!0;return!1}function a(E,A){const M=Number(E.value),C=P=>S(A.sorted,P);switch(E.op){case"topPercent":{const P=l(M,10);return{op:"gte",value:C(1-P)}}case"bottomPercent":{const P=l(M,10);return{op:"lte",value:C(P)}}case"topN":{const P=Math.max(1,Math.floor(M)||1),D=Math.max(0,A.sorted.length-P);return{op:"gte",value:A.sorted[D]}}case"bottomN":{const P=Math.max(1,Math.floor(M)||1),D=Math.min(A.sorted.length-1,P-1);return{op:"lte",value:A.sorted[D]}}case"aboveMean":return{op:"gt",value:A.mean};case"belowMean":return{op:"lt",value:A.mean};case"aboveMedian":return{op:"gt",value:A.median};case"belowMedian":return{op:"lt",value:A.median};case"zAbove":return A.stddev?{op:"gte",value:A.mean+(Number.isFinite(M)?M:2)*A.stddev}:null;case"zBelow":return A.stddev?{op:"lte",value:A.mean-(Number.isFinite(M)?M:2)*A.stddev}:null;case"outlier":{const P=(Number.isFinite(M)&&M>0?M:1.5)*A.iqr;return A.iqr?{op:"outside",value:A.q1-P,value2:A.q3+P}:null}default:return null}}function l(E,A){const M=Number.isFinite(E)?E:A,C=M>1?M/100:M;return Math.max(0,Math.min(1,C))}function r(E,A){if(E.from==="minmax")return{...E,min:A.min,max:A.max};if(E.from==="quantile")return{...E,min:S(A.sorted,l(Number(E.low),5)),max:S(A.sorted,l(Number(E.high),95))};if(E.from==="stddev"){const M=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:A.mean-M*A.stddev,max:A.mean+M*A.stddev}}return E}function t(E,A){const M=Array.isArray(E)?E:[];return!A||!A.n?M.map(C=>C&&b([C])?{...C,enabled:!1}:C):M.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:r(C.scale,A)};if(C.dataBar)return{...C,dataBar:n(C.dataBar,A)};if(C.iconSet)return{...C,iconSet:i(C.iconSet,A)};if(!C.when||!W.includes(C.when.op))return C;const P=a(C.when,A);return P?{...C,when:P}:{...C,enabled:!1}})}function n(E,A){const M=Number.isFinite(Number(E.min))?Number(E.min):void 0,C=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(M!==void 0&&C!==void 0)return{...E,min:M,max:C};if(E.from==="quantile")return{...E,min:M??S(A.sorted,l(Number(E.low),5)),max:C??S(A.sorted,l(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:M??A.mean-P*A.stddev,max:C??A.mean+P*A.stddev}}return{...E,min:M??A.min,max:C??A.max}}function i(E,A){if(Array.isArray(E.thresholds))return E;const M=o(E),C=[];for(let P=1;P<M;P++)C.push(S(A.sorted,P/M));return{...E,thresholds:C}}function o(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const A=p[E.set];return A?A.length:3}function c(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function d(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function f(E,A){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${A==="up"?"8,2 14,13 2,13":A==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function h(E,A){const M="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A*16} 16">`;for(let P=0;P<A;P++){const D=P<E?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${P*16},0)" d="${M}" fill="${D}"/>`}return`${C}</svg>`}const g=Object.freeze([f("#c0392b","down"),f("#e0a800","right"),f("#2e7d32","up")]),y=Object.freeze([d("#d13438"),d("#f5a623"),d("#2e9e44")]),p=Object.freeze({arrows:g,trafficLights:y,ratings:Object.freeze([1,2,3,4,5].map(E=>h(E,5)))}),m=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?c(String(C)):String(C));const A=E.set||"arrows";if(A==="ratings"){const C=o(E),P=[];for(let D=1;D<=C;D++)P.push(c(h(D,C)));return P}const M=p[A];return M?M.map(c):($(`iconSet:${A}`,`unknown icon set '${A}'; falling back to arrows.`),g.map(c))}function v(E){const A=Number(E.min),C=Number(E.max)-A,P=E.colour||E.color||"#5b9bd5",D=E.negativeColour||E.negativeColor||"#d13438",K=E.direction==="rtl"?"left":"right",x=j=>Math.max(0,Math.min(1,(j-A)/C))*100,I=C?Math.max(0,Math.min(100,(0-A)/C*100)):0;return j=>{if(U(j))return null;const T=Number(j);if(!Number.isFinite(T)||!C)return null;const B=x(T),q=Math.min(B,I),X=Math.max(B,I),Q=T>=0?P:D;return{backgroundImage:`linear-gradient(to ${K}, transparent ${q}%, ${Q} ${q}%, ${Q} ${X}%, transparent ${X}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function u(E){const A=w(E),M=E.reverse?[...A].reverse():A,C=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,D=E.set==="ratings"?P*o(E):P;return K=>{if(U(K))return null;const x=Number(K);if(!Number.isFinite(x))return null;let I=0;for(const T of C)x>=T&&I++;const j=M[Math.min(I,M.length-1)];return j?{backgroundImage:j,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${D}px ${P}px`,paddingLeft:`${D+4}px`}:null}}function s(E){const A=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],M=Number(E.min),C=Number(E.max),P=C-M,D=A.length-1,K=[];for(let I=0;I<=D;I++)K.push(D?I/D:0);const x=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(A.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${A.length} were given, so "mid" was ignored.`);else if(Number.isFinite(x)&&P&&x>Math.min(M,C)&&x<Math.max(M,C)){const I=D/2,j=Math.max(0,Math.min(1,(x-M)/P));for(let T=0;T<=D;T++)K[T]=T<=I?I?T/I*j:j:j+(T-I)/(D-I)*(1-j)}else Number.isFinite(x)&&$("formatting.scale.mid.range",`a scale's "mid" (${x}) is outside its min..max range, so it was ignored.`);return I=>{const j=Number(I);if(!Number.isFinite(j)||!P)return null;const T=Math.max(0,Math.min(1,(j-M)/P));let B=0;for(;B<D-1&&T>K[B+1];)B++;const q=K[B+1]-K[B],X=q>0?(T-K[B])/q:0;return{background:F(A[B],A[B+1],Math.max(0,Math.min(1,X)))}}}function O(E,A=null){const M=b(E)?t(E,A):E,C=(Array.isArray(M)?M:[]).filter(D=>D&&typeof D=="object");if(!C.length)return()=>null;const P=C.map(D=>D.scale?{scale:s(D.scale),enabled:D.enabled!==!1}:D.dataBar?{scale:v(D.dataBar),enabled:D.enabled!==!1}:D.iconSet?{scale:u(D.iconSet),enabled:D.enabled!==!1}:{when:D.when,style:D.style,stop:D.stopIfTrue!==!1,enabled:D.enabled!==!1});return D=>{const K=D?D.value:void 0;let x=null;for(const I of P){if(!I.enabled)continue;if(I.scale){const T=I.scale(K);T&&(x={...x||{},...T});continue}if(!z(K,I.when))continue;const j=N(I.style)?I.style(D):I.style;if(j&&(x={...x||{},...j}),I.stop)break}return x}}}),Se("packages/core/src/formula/parse.js",function(e,V){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return n}});const _="num",N="str",$="ref",L="name",W="op",Z="end",H=["<=",">=","<>","!="],U="+-*/^%(),<>=";class z extends Error{constructor(o,c){super(o),this.name="FormulaError",this.at=c}}function F(i){const o=[];let c=0;for(;c<i.length;){const d=i[c];if(d===" "||d===" "||d===`
7
7
  `||d==="\r"){c++;continue}if(d>="0"&&d<="9"){c=S(i,c,o);continue}if(d==="."&&i[c+1]>="0"&&i[c+1]<="9"){c=S(i,c,o);continue}if(d==='"'||d==="'"){c=b(i,c,o);continue}if(d==="["){const h=i.indexOf("]",c+1);if(h<0)throw new z("a [column reference] was opened and never closed",c);o.push({kind:$,value:i.slice(c+1,h).trim(),at:c}),c=h+1;continue}if(k(d)){c=a(i,c,o);continue}const f=i.slice(c,c+2);if(H.includes(f)){o.push({kind:W,value:f==="!="?"<>":f,at:c}),c+=2;continue}if(U.includes(d)){o.push({kind:W,value:d,at:c}),c++;continue}throw new z(`unexpected character ${JSON.stringify(d)}`,c)}return o.push({kind:Z,value:null,at:i.length}),o}function k(i){return/[A-Za-z_À-￿]/.test(i)}function S(i,o,c){let d=o,f=!1;for(;d<i.length;){const h=i[d];if(h>="0"&&h<="9"){d++;continue}if(h==="."&&!f){f=!0,d++;continue}if((h==="e"||h==="E")&&/[0-9+-]/.test(i[d+1]||"")){for(d+=2;d<i.length&&i[d]>="0"&&i[d]<="9";)d++;break}break}return c.push({kind:_,value:Number(i.slice(o,d)),at:o}),d}function b(i,o,c){const d=i[o];let f=o+1,h="";for(;f<i.length;){if(i[f]===d){if(i[f+1]===d){h+=d,f+=2;continue}return c.push({kind:N,value:h,at:o}),f+1}h+=i[f],f++}throw new z("a string was opened and never closed",o)}function a(i,o,c){let d=o;for(;d<i.length&&/[A-Za-z0-9_.À-￿]/.test(i[d]);)d++;const f=i.slice(o,d);let h=d;for(;h<i.length&&i[h]===" ";)h++;return c.push({kind:i[h]==="("?L:$,value:f,at:o}),d}const l={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function r(i){const o=String(i??"").replace(/^\s*=/,"");if(!o.trim())throw new z("the formula is empty");const c=F(o);let d=0;const f=()=>c[d],h=()=>c[d++],g=s=>{const O=f();if(O.kind!==W||O.value!==s)throw new z(`expected ${JSON.stringify(s)}`,O.at);d++},y=s=>{let O=p();for(;;){const E=f();if(E.kind!==W)break;const A=l[E.value];if(!A||A<s)break;d++;const M=y(E.value==="^"?A:A+1);O={kind:"bin",op:E.value,left:O,right:M}}return O},p=()=>{const s=f();return s.kind===W&&(s.value==="-"||s.value==="+")?(d++,{kind:"unary",op:s.value,arg:p()}):m()},m=()=>{let s=w();for(;f().kind===W&&f().value==="%";)d++,s={kind:"unary",op:"%",arg:s};return s},w=()=>{const s=h();if(s.kind===_)return{kind:"num",value:s.value};if(s.kind===N)return{kind:"str",value:s.value};if(s.kind===$)return{kind:"ref",name:s.value};if(s.kind===L){g("(");const O=[];if(!(f().kind===W&&f().value===")"))for(;;){if(O.push(y(1)),f().kind===W&&f().value===","){d++;continue}break}return g(")"),{kind:"call",name:String(s.value).toUpperCase(),args:O}}if(s.kind===W&&s.value==="("){const O=y(1);return g(")"),O}throw s.kind===Z?new z("the formula ends unexpectedly",s.at):new z(`unexpected ${JSON.stringify(s.value)}`,s.at)},v=y(1),u=f();if(u.kind!==Z)throw new z(`unexpected ${JSON.stringify(u.value)}: is an operator missing?`,u.at);return v}function t(i){const o=new Set,c=d=>{if(!(!d||typeof d!="object")){if(d.kind==="ref"){o.add(String(d.name));return}if(d.kind==="bin"){c(d.left),c(d.right);return}if(d.kind==="unary"){c(d.arg);return}if(d.kind==="call")for(const f of d.args)c(f)}};return c(i),[...o]}function n(i){return typeof i=="string"&&/^\s*=/.test(i)&&i.trim()!=="="}}),Se("packages/core/src/formula/evaluate.js",function(e,V){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/formula/parse.js").FormulaError;function $(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const a=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(a))throw new N(`${JSON.stringify(b)} is not a number`);return a}function L(b){return b==null?"":String(b)}function W(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const a=String(b).trim().toLowerCase();return a==="false"||a==="no"||a==="0"?!1:a!==""}function Z(b){const a=[];for(const l of b){if(Array.isArray(l)){for(const r of l)r!=null&&r!==""&&a.push($(r));continue}l==null||l===""||a.push($(l))}return a}function H(b,a){const l=10**a,r=b*l;return Math.sign(r)*Math.round(Math.abs(r)+Number.EPSILON*Math.abs(r))/l}function U(b,a){if(!b.length)return 0;const l=b.slice().sort((i,o)=>i-o),r=(l.length-1)*Math.min(1,Math.max(0,a)),t=Math.floor(r),n=Math.ceil(r);return t===n?l[t]:l[t]+(r-t)*(l[n]-l[t])}function z(b,a){let l=0,r=0,t=0;for(const i of b){l++;const o=i-r;r+=o/l,t+=o*(i-r)}const n=a?l-1:l;return n>0?Math.sqrt(t/n):0}const F={SUM:b=>Z(b).reduce((a,l)=>a+l,0),AVERAGE:b=>{const a=Z(b);return a.length?a.reduce((l,r)=>l+r,0)/a.length:0},MIN:b=>{const a=Z(b);return a.length?Math.min(...a):0},MAX:b=>{const a=Z(b);return a.length?Math.max(...a):0},COUNT:b=>Z(b).length,PRODUCT:b=>Z(b).reduce((a,l)=>a*l,1),ROUND:b=>H($(b[0]),b.length>1?$(b[1]):0),ROUNDDOWN:b=>{const a=10**(b.length>1?$(b[1]):0),l=$(b[0])*a;return(l<0?Math.ceil(l):Math.floor(l))/a},ROUNDUP:b=>{const a=10**(b.length>1?$(b[1]):0),l=$(b[0])*a;return(l<0?Math.floor(l):Math.ceil(l))/a},ABS:b=>Math.abs($(b[0])),FLOOR:b=>Math.floor($(b[0])),CEILING:b=>Math.ceil($(b[0])),SQRT:b=>Math.sqrt($(b[0])),POWER:b=>$(b[0])**$(b[1]),MOD:b=>{const a=$(b[1]);if(a===0)throw new N("MOD by zero");return($(b[0])%a+a)%a},IF:b=>W(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(W),OR:b=>b.some(W),NOT:b=>!W(b[0]),COALESCE:b=>b.find(a=>a!=null&&a!=="")??null,CONCAT:b=>b.map(L).join(""),LEN:b=>L(b[0]).length,UPPER:b=>L(b[0]).toUpperCase(),LOWER:b=>L(b[0]).toLowerCase(),TRIM:b=>L(b[0]).trim(),LEFT:b=>L(b[0]).slice(0,b.length>1?$(b[1]):1),RIGHT:b=>{const a=b.length>1?$(b[1]):1;return a<=0?"":L(b[0]).slice(-a)},MEDIAN:b=>U(Z(b),.5),PERCENTILE:b=>{const a=$(b[b.length-1]);return U(Z(b.slice(0,-1)),a>1?a/100:a)},QUARTILE1:b=>U(Z(b),.25),QUARTILE3:b=>U(Z(b),.75),STDEV:b=>z(Z(b),!0),STDEVP:b=>z(Z(b),!1),VAR:b=>{const a=z(Z(b),!0);return a*a},VARP:b=>{const a=z(Z(b),!1);return a*a},COUNTDISTINCT:b=>{const a=new Set;for(const l of b){const r=Array.isArray(l)?l:[l];for(const t of r)t!=null&&t!==""&&a.add(t)}return a.size},IQR:b=>{const a=Z(b);return U(a,.75)-U(a,.25)}};F.AVG=F.AVERAGE,F.CEIL=F.CEILING,F.POW=F.POWER,F.STDEVS=F.STDEV,F.PERCENTILEINC=F.PERCENTILE;function k(b,a){const l=Number(b),r=Number(a);if(b!==null&&b!==""&&a!==null&&a!==""&&Number.isFinite(l)&&Number.isFinite(r))return l<r?-1:l>r?1:0;const n=L(b).toLowerCase(),i=L(a).toLowerCase();return n<i?-1:n>i?1:0}function S(b,a={}){const l=typeof a.lookup=="function"?a.lookup:null,r=a.functions?{...F,...a.functions}:F,t=n=>{switch(n.kind){case"num":return n.value;case"str":return n.value;case"ref":{if(!l)throw new N(`there is no column called ${JSON.stringify(n.name)} here`);const i=l(String(n.name));if(i===void 0)throw new N(`there is no column called ${JSON.stringify(n.name)}`);return i}case"unary":{if(n.op==="%")return $(t(n.arg))/100;const i=$(t(n.arg));return n.op==="-"?-i:i}case"bin":{const i=n.op;if(i==="=")return k(t(n.left),t(n.right))===0;if(i==="<>")return k(t(n.left),t(n.right))!==0;if(i==="<")return k(t(n.left),t(n.right))<0;if(i==="<=")return k(t(n.left),t(n.right))<=0;if(i===">")return k(t(n.left),t(n.right))>0;if(i===">=")return k(t(n.left),t(n.right))>=0;const o=$(t(n.left)),c=$(t(n.right));if(i==="+")return o+c;if(i==="-")return o-c;if(i==="*")return o*c;if(i==="^")return o**c;if(i==="/"){if(c===0)throw new N("division by zero");return o/c}throw new N(`unknown operator ${JSON.stringify(i)}`)}case"call":{const i=r[n.name];if(typeof i!="function")throw new N(`there is no function called ${n.name}`);return i(n.args.map(t),a)}default:throw new N("the formula could not be read")}};return t(b)}}),Se("packages/core/src/formula/index.js",function(e,V){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/formula/parse.js"),N=_.parseFormula,$=_.referencesOf,L=_.looksLikeFormula,W=_.FormulaError,Z=_.tokenise,H=V("packages/core/src/formula/evaluate.js"),U=H.evaluateAst,z=H.FUNCTIONS;function F(S){const{grid:b,row:a,data:l}=S||{},r=c=>String(c).toLowerCase().replace(/[\s_-]/g,""),t=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],n=b&&b.permissions,i=n&&typeof n.isReadable=="function"?c=>n.isReadable(c):()=>!0,o=new Set;for(const c of t)i(c)||(o.add(r(c.id)),c.field&&o.add(r(c.field)),c.title&&o.add(r(c.title)));return c=>{const d=r(c);if(o.has(d))throw new W(`"${c}" cannot be read`);for(const f of t)if(r(f.id)===d||f.field&&r(f.field)===d||f.title&&r(f.title)===d)return a&&b.rows&&typeof b.rows.value=="function"?b.rows.value(a.key,f.id):l?l[f.field||f.id]:void 0;if(l&&typeof l=="object"){for(const f of Object.keys(l))if(r(f)===d){if(!i(f))throw new W(`"${c}" cannot be read`);return l[f]}}}}function k(S,b={}){try{const a=N(S);return{ok:!0,value:U(a,{lookup:F(b),functions:b.formulaFunctions}),references:$(a)}}catch(a){return{ok:!1,error:a instanceof W?a.message:"the formula could not be read",at:a instanceof W?a.at:void 0}}}}),Se("packages/core/src/defaults.js",function(e,V){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const _=V("packages/core/src/internal/util.js"),N=_.isObject,$=_.merge,L=_.warnOnce;let W=null;function Z(z){if(Array.isArray(z))return z.map(Z);if(!N(z)||Object.getPrototypeOf(z)!==Object.prototype&&Object.getPrototypeOf(z)!==null)return z;const F={};for(const[k,S]of Object.entries(z))F[k]=Z(S);return F}function H(z){return z===void 0?Z(W??{}):z===null?(W=null,{}):N(z)?(W=Z(z),Z(W)):(L("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.`),Z(W??{}))}function U(z){return W===null?z:$(Z(W),z)}}),Se("packages/core/src/events/names.js",function(e,V){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return $}});const _=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),N=new Set(_);function $(L){return L==="*"||N.has(L)}}),Se("packages/core/src/events/bus.js",function(e,V){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return a}});const _=V("packages/core/src/internal/util.js"),N=_.warnOnce,$=_.uid,L=_.DEV,Z=V("packages/core/src/events/names.js").isKnownEvent,H="*";function U(l,r){!L||Z(r)||N(`bus.unknown:${r}`,`${l}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const z=new Set(["api","user","init","ai"]),F=new WeakMap;function k(l){let r=F.get(l);return r||(r=$("h"),F.set(l,r)),r}function S(){return typeof performance=="object"&&performance?performance.now():Date.now()}function b(l){if(!l||typeof l!="object")return{};const r={};for(const[t,n]of Object.entries(l))t!=="grid"&&(n==null?r[t]=String(n):Array.isArray(n)?r[t]=`[${n.length}]`:typeof n=="object"?r[t]=n.key?`row ${n.key}`:"{…}":typeof n=="function"?r[t]="[function]":r[t]=String(n).slice(0,60));return r}class a{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#a=!1;#s=0;constructor(r=null){this.#i=r}attach(r){this.#i=r}get grid(){return this.#i}get destroyed(){return this.#a}on(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};U("on",r);let n=this.#e.get(r);return n||(n=[],this.#e.set(r,n)),n.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return N(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};U("once",r);const n=i=>{this.off(r,t),t(i)};return this.#o.set(t,n),this.on(r,n)}off(r,t){if(t===void 0){this.#e.delete(r);return}const n=this.#e.get(r);if(!n)return;const i=this.#o.get(t),o=i&&n.includes(i)?i:t,c=n.indexOf(o);c>=0&&n.splice(c,1),i&&o===i&&this.#o.delete(t),n.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),n=r===H?null:this.#e.get(H);return(t?t.length:0)+(n?n.length:0)}#l(r,t,n,i,o){this.#n.push({type:r,origin:t,listeners:(i?i.length:0)+(o?o.length:0),payload:b(n),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,n]of this.#e)r[t]=n.length;return r}emit(r,t,n){const i=n??(t&&t.origin),o=z.has(i)?i:"api",c={...t||null,type:r,origin:o,grid:this.#i};if(this.#a)return c;const d=this.#e.get(r),f=r===H?void 0:this.#e.get(H);if(this.#t&&this.#l(r,o,t,d,f),!d&&!f)return c;const h=this.#t?S():0;this.#s++;try{d&&this.#u(d.slice(),c,r),f&&this.#u(f.slice(),c,H)}finally{this.#s--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=S()-h)}return c}emitBefore(r,t,n){const i=n??(t&&t.origin),o=z.has(i)?i:"user";let c=!1,d=null;const f=w=>{c=!0,w!=null&&d===null&&(d=String(w))},h={...t||null,type:r,origin:o,grid:this.#i,get defaultPrevented(){return c},get reason(){return d},preventDefault(w){f(w)}};if(this.#a)return!0;const g=this.#e.get(r);this.#t&&this.#l(r,o,t,g,void 0);const y=g?g.slice():[];if(y.length===0)return!0;const p=()=>(c&&d===null&&(d="prevented"),c&&t&&typeof t=="object"&&(t.reason=d),!c),m=[];for(const w of y)try{const v=w(h);v&&typeof v.then=="function"?m.push(v):v===!1&&f("prevented")}catch(v){f("error"),N(`bus.beforeThrow:${r}:${k(w)}`,`a '${r}' before-handler threw; the action was cancelled.`,v)}return m.length===0?p():Promise.allSettled(m).then(w=>{for(const v of w)v.status==="rejected"?(f("error"),N(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,v.reason)):v.value===!1&&f("prevented");return p()})}#u(r,t,n){for(let i=0;i<r.length;i++)try{r[i](t)}catch(o){N(`bus.throw:${n}:${k(r[i])}`,`a '${n}' handler threw; other handlers were unaffected.`,o)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#a=!0,this.#i=null}}}),Se("packages/core/src/registry/licence.js",function(e,V){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return O}});const N=V("packages/core/src/internal/util.js").warnOnce,$="lattice-grid",L=1,W="LG1",Z=64,H="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",z=(()=>{const E=new Int16Array(128).fill(-1);for(let A=0;A<U.length;A++)E[U.charCodeAt(A)]=A;return E[43]=62,E[47]=63,E})();function F(E){if(typeof E!="string")return null;let A="";for(let x=0;x<E.length;x++){const I=E.charCodeAt(x);if(I!==61){if(I>127||z[I]<0)return null;A+=E[x]}}const M=A.length;if(M%4===1)return null;const C=new Uint8Array(Math.floor(M*3/4));let P=0,D=0,K=0;for(let x=0;x<M;x++)P=P<<6|z[A.charCodeAt(x)],D+=6,D>=8&&(D-=8,C[K++]=P>>D&255);return K===C.length?C:C.subarray(0,K)}function k(E){let A="",M=0;for(;M+2<E.length;M+=3){const P=E[M]<<16|E[M+1]<<8|E[M+2];A+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]+U[P&63]}const C=E.length-M;if(C===1){const P=E[M]<<16;A+=U[P>>18&63]+U[P>>12&63]}else if(C===2){const P=E[M]<<16|E[M+1]<<8;A+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]}return A}function S(E){const A=new Uint8Array(E.length);for(let M=0;M<E.length;M++)A[M]=E.charCodeAt(M)&127;return A}function b(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let A="";for(let M=0;M<E.length;M++)A+=String.fromCharCode(E[M]);return A}function a(E){const A={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof E=="string"?E:""};if(typeof E!="string"||E.length===0)return{...A,reason:"missing"};const M=E.trim(),C=M.split(".");if(C.length!==3)return A;const[P,D,K]=C;if(P!==W)return{...A,reason:"prefix"};const x=F(D),I=F(K);if(!x||!I)return A;let j;try{j=JSON.parse(b(x))}catch{return A}return j===null||typeof j!="object"?A:{ok:!0,reason:null,product:typeof j.p=="string"?j.p:null,issuedTo:typeof j.t=="string"?j.t:null,expires:typeof j.e=="string"?j.e:null,features:Array.isArray(j.f)?j.f.slice():[],deployments:Array.isArray(j.d)?j.d.slice():[],version:typeof j.v=="number"?j.v:0,message:S(D),signature:I,raw:M}}function l(E,A){if(!E)return!1;const M=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(M)?!0:A>M}let r=null,t=null,n=null;function i(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function o(E){if(r&&t===E)return r;const A=i();if(!A)return null;const M=F(E);if(!M)return null;try{const C=await A.importKey("raw",M,{name:"Ed25519"},!1,["verify"]);return r=C,t=E,C}catch{return null}}async function c(){return n!==null||(n=await o(H)!==null),n}async function d(E,A={}){const M=A.warn!==!1,C=A.product||$,P=A.publicKey||H,D=A.now??Date.now(),K=a(E);if(!K.ok){const q=K.reason==="missing"?"missing":"malformed";return M&&N(`licence.${q}`,q==="missing"?"no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.":"licence key could not be read. The grid will render with a watermark."),{valid:!1,reason:q}}const x={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0};if(K.product!==C)return M&&N("licence.product",`licence key is for '${K.product}', not '${C}'. The grid will render with a watermark.`),{valid:!1,...x,reason:"product"};if(l(K.expires,D))return M&&N("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...x,reason:"expired"};const I=A.host??h(),j=K.deployments||[];if(j.length&&I&&!f(I)&&!g(I,j))return M&&N("licence.domain",`licence key is not valid for ${I}; it covers ${j.join(", ")}. The grid will render with a watermark.`),{valid:!1,...x,reason:"domain"};const T=await o(P);if(!T){const q=!!K.signature&&K.signature.length===Z;return M&&N("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),q?{valid:!0,...x,reason:"unverified"}:{valid:!1,...x,reason:"signature"}}let B=!1;try{B=await i().verify({name:"Ed25519"},T,K.signature,K.message)}catch{B=!1}return B?{valid:!0,...x}:(M&&N("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...x,reason:"signature"})}function f(E){const A=String(E??h()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function h(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function g(E,A){const M=y(E);return!M||!Array.isArray(A)?!1:A.some(C=>{const P=y(C);if(!P)return!1;if(P==="*")return!0;if(P.startsWith("*.")){const D=P.slice(2);return M===D||M.endsWith(`.${D}`)}return M===P})}function y(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(A={}){this.#o=A}set(A){this.#e=typeof A=="string"?A.trim():"";const M=a(this.#e);return this.#t=M.ok?{valid:!l(M.expires,Date.now())&&M.product===(this.#o.product||$),product:M.product||void 0,issuedTo:M.issuedTo||void 0,expires:M.expires||void 0,reason:"pending"}:{valid:!1,reason:M.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=d(A,this.#o).then(M=>{if(this.#e===A){this.#t=M;for(const C of this.#i)C(M)}return M}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!f(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":f(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const m=new p;function w(E){return m.set(E)}function v(){return m.info()}function u(){return m.watermark()}function s(){return m.state()}function O(){return m}}),Se("packages/core/src/registry/registry.js",function(e,V){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return n}});const _=V("packages/core/src/internal/util.js"),N=_.warnOnce,$=_.isFunction,L=_.DEV,W=V("packages/core/src/registry/licence.js"),Z=W.LicenceHolder,H=W.sharedLicence,U=["renderer","editor","filter","dataType","totalFn","pipe","component"],z=["all","header","body","totals","panels"];class F{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#a=null;#s=new Set;#l=new Map;constructor(o={}){for(const c of U)this.#t.set(c,new Map);this.#o=o.holder||H(),this.#a=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,c={}){c.licence&&this.setLicence(c.licence),c.grid!==void 0&&(this.#a=c.grid);const d=Array.isArray(o)?o:[o],f=[];for(const h of d){if(!h||typeof h!="object"||typeof h.name!="string"||!h.name){N("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(h.name)){L&&this.#c(this.#e.get(h.name),h);continue}if(!$(h.install)){N(`registry.module.install:${h.name}`,`module '${h.name}' has no install() and was ignored.`);continue}const g={registry:this,grid:this.#a};try{h.install(g)}catch(y){N(`registry.module.throw:${h.name}`,`module '${h.name}' threw during install; it was not registered.`,y);continue}this.#e.set(h.name,h);for(const y of k(h))this.#n.add(y);f.push(h.name),this.#d({reason:"module",name:h.name,capabilities:this.capabilities(),regions:a(h)})}return f}unregisterModule(o){const c=this.#e.get(o);if(!c)return!1;if($(c.uninstall))try{c.uninstall({registry:this,grid:this.#a})}catch(d){N(`registry.module.uninstall:${o}`,`module '${o}' threw during uninstall.`,d)}return this.#e.delete(o),this.#u(),this.#d({reason:"unmodule",name:o,capabilities:this.capabilities(),regions:a(c)}),!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 c of k(o))this.#n.add(c)}#c(o,c){!o||o===c||S(o,c)||N(`registry.module.reconfigure:${c.name}`,`module '${c.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(o){return this.#n.has(o)}onChange(o){return $(o)?(this.#r.add(o),this.#l.set(o,this.#a),()=>{this.#r.delete(o),this.#l.delete(o)}):()=>{}}#d(o){for(const c of[...this.#r])try{c(o)}catch(d){N("registry.onChange.throw","a registry change handler threw.",d)}}register(o,c,d){const f=this.#t.get(o);if(!f){N(`registry.kind:${o}`,`unknown registry kind '${o}'; expected one of ${U.join(", ")}.`);return}if(!c||typeof c!="string"){N(`registry.name:${o}`,`register('${o}', ...) needs a name.`);return}f.has(c)&&f.get(c)!==d&&N(`registry.replace:${o}:${c}`,`'${c}' was already registered as a ${o} and has been replaced.`),f.set(c,d),this.#d({reason:"register",name:c,kind:o,capabilities:this.capabilities(),regions:l(o)})}registerAll(o,c){if(c)for(const d of Object.keys(c))this.register(o,d,c[d])}get(o,c){const d=this.#t.get(o);return d?d.get(c):void 0}names(o){const c=this.#t.get(o);return c?[...c.keys()]:[]}#h(o,c){const d=this.#t.get(o).get(c);return d!==void 0?d:this.#t.get("component").get(c)}renderer(o){return this.#h("renderer",o)}editor(o){return this.#h("editor",o)}filter(o){return this.#h("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.#s.add(o),this.#a=o)}detach(o){if(o!=null){this.#s.delete(o);for(const[c,d]of[...this.#l])d===o&&(this.#r.delete(c),this.#l.delete(c));if(this.#a===o){const c=this.#s.size?[...this.#s][this.#s.size-1]:null;this.#a=c}this.#s.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(o){if(o!=null){this.detach(o);return}for(const c of[...this.#e.keys()])this.unregisterModule(c);this.#r.clear(),this.#l.clear(),this.#s.clear(),this.#i&&this.#i(),this.#i=null,this.#a=null}}function k(i){const o=i.capabilities,c=Array.isArray(o)?o.filter(d=>typeof d=="string"):[];return[i.name,...c]}function S(i,o){return i.install!==o.install||i.uninstall!==o.uninstall||(i.version||"")!==(o.version||"")?!1:b(k(i),k(o))&&b(a(i),a(o))}function b(i,o){const c=new Set(i),d=new Set(o);if(c.size!==d.size)return!1;for(const f of c)if(!d.has(f))return!1;return!0}function a(i){const o=i.regions;return!Array.isArray(o)||o.length===0?["all"]:o.filter(c=>z.includes(c))}function l(i){switch(i){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new F;function t(){return r}function n(i,o={}){return r.registerModules(i,o)}}),Se("packages/core/src/format/number.js",function(e,V){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return $}});const N=V("packages/core/src/internal/util.js").isNil;function $(L,W){const Z=L||{},H=Z.locale||W||void 0,U=Z.style||"decimal",z=typeof Z.scale=="number"?Z.scale:1,F=Z.nullDisplay??"",k=Z.zeroDisplay,S=Z.prefix||"",b=Z.suffix||"",a=Z.negative||"minus",l=Z.signed===!0,r={style:U,notation:Z.notation||"standard"};U==="currency"&&(r.currency=Z.currency||"USD",Z.currencyDisplay&&(r.currencyDisplay=Z.currencyDisplay)),typeof Z.decimals=="number"?(r.minimumFractionDigits=Z.decimals,r.maximumFractionDigits=Z.decimals):(typeof Z.minDecimals=="number"&&(r.minimumFractionDigits=Z.minDecimals),typeof Z.maxDecimals=="number"&&(r.maximumFractionDigits=Z.maxDecimals),r.minimumFractionDigits>(r.maximumFractionDigits??20)&&(r.maximumFractionDigits=r.minimumFractionDigits)),Z.thousandsSeparator===!1&&(r.useGrouping=!1),r.notation==="compact"&&(r.compactDisplay=Z.compactDisplay||"short");const t=new Intl.NumberFormat(H,r),n=typeof Z.thousandsSeparator=="string"?Z.thousandsSeparator:null,i=typeof Z.decimalSeparator=="string"?Z.decimalSeparator:null;let o=",",c=".";if(n||i)for(const p of t.formatToParts(12345.6))p.type==="group"?o=p.value:p.type==="decimal"&&(c=p.value);const d=p=>{let m=p;return n&&(m=m.split(o).join("")),i&&(m=m.split(c).join("")),n&&(m=m.split("").join(n)),i&&(m=m.split("").join(i)),m},f=!!(n||i),h=S!==""&&U==="currency",g=p=>{let m;if(h){const w=t.formatToParts(p);let v=!1;m="";for(const u of w)m+=u.value,!v&&u.type==="currency"&&(m+=S,v=!0);v||(m=S+m)}else m=S+t.format(p);return f&&(m=d(m)),m+b},y=p=>{if(N(p)||p==="")return F;const m=typeof p=="number"?p:Number(p);if(Number.isNaN(m))return F;const w=z===1?m:m*z;return w===0&&k!==void 0?k:w<0?a==="parentheses"?`(${g(-w)})`:a==="suffix"?`${g(-w)}-`:g(w):l&&w>0?`+${g(w)}`:g(w)};return y.negativeClass=Z.negativeClass||null,y.spec=Z,y}}),Se("packages/core/src/format/date.js",function(e,V){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.warnOnce,L=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(n){const i=[];let o=0,c="";const d=()=>{c&&(i.push({token:null,text:c}),c="")};for(;o<n.length;){const f=n[o];if(f==="'"){if(n[o+1]==="'"){c+="'",o+=2;continue}const g=n.indexOf("'",o+1);if(g===-1){c+=n.slice(o+1),o=n.length;continue}c+=n.slice(o+1,g),o=g+1;continue}const h=L.find(g=>n.startsWith(g,o));if(h){d(),i.push({token:h,text:h}),o+=h.length;continue}/[A-Za-z]/.test(f)&&$(`date.pattern.token:${f}`,`the date pattern "${n}" contains '${f}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${L.join(" ")}.`),c+=f,o+=1}return d(),i}const Z=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function H(n){if(N(n)||n==="")return null;if(n instanceof Date)return Number.isNaN(n.getTime())?null:n;if(typeof n=="number")return Number.isNaN(n)?null:new Date(n);if(typeof n=="string"){const i=Z.exec(n.trim());if(i){const[,c,d,f,h="0",g="0",y="0"]=i;return new Date(+c,+d-1,+f,+h,+g,+y)}const o=new Date(n);return Number.isNaN(o.getTime())?null:o}return null}function U(n,i){return String(n).padStart(i,"0")}function z(n){if(!n)return c=>({year:c.getFullYear(),month:c.getMonth()+1,day:c.getDate(),hour:c.getHours(),minute:c.getMinutes(),second:c.getSeconds(),ms:c.getMilliseconds(),weekday:c.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),o={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return c=>{const d={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:c.getMilliseconds(),weekday:0};for(const f of i.formatToParts(c))switch(f.type){case"year":d.year=Number(f.value);break;case"month":d.month=Number(f.value);break;case"day":d.day=Number(f.value);break;case"hour":d.hour=Number(f.value)%24;break;case"minute":d.minute=Number(f.value);break;case"second":d.second=Number(f.value);break;case"weekday":d.weekday=o[f.value]??0;break;default:break}return d}}function F(n,i,o){const c=W(n),d=z(o),f=new Set(c.filter(m=>m.token).map(m=>m.token)),h=f.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:o}):null,g=f.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:o}):null,y=f.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:o}):null,p=f.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:o}):null;return m=>{const w=d(m);let v="";for(const u of c){if(!u.token){v+=u.text;continue}switch(u.token){case"yyyy":v+=U(w.year,4);break;case"yy":v+=U(w.year%100,2);break;case"MMMM":v+=g.format(m);break;case"MMM":v+=h.format(m);break;case"MM":v+=U(w.month,2);break;case"M":v+=String(w.month);break;case"dd":v+=U(w.day,2);break;case"d":v+=String(w.day);break;case"EEEE":v+=p.format(m);break;case"EEE":v+=y.format(m);break;case"HH":v+=U(w.hour,2);break;case"H":v+=String(w.hour);break;case"hh":v+=U(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+=U(w.minute,2);break;case"m":v+=String(w.minute);break;case"ss":v+=U(w.second,2);break;case"s":v+=String(w.second);break;case"SSS":v+=U(w.ms,3);break;case"a":v+=w.hour<12?"AM":"PM";break;default:v+=u.text;break}}return v}}const k=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function S(n,i){const o=n||{},c=o.locale||i||void 0,d=o.nullDisplay??"",f=o.timeZone;let h;if(o.pattern)h=F(o.pattern,c,f);else if(o.dateStyle||o.timeStyle){const w={timeZone:f};o.dateStyle&&(w.dateStyle=o.dateStyle),o.timeStyle&&(w.timeStyle=o.timeStyle);const v=new Intl.DateTimeFormat(c,w);h=u=>v.format(u)}else{const w=new Intl.DateTimeFormat(c,{dateStyle:"medium",timeZone:f});h=v=>w.format(v)}const g=o.relative?new Intl.RelativeTimeFormat(c,{numeric:"auto"}):null,p=(typeof o.relative=="object"&&o.relative?o.relative.threshold??7:7)*24*36e5,m=(w,v)=>{const u=H(w);if(!u)return d;if(g){const s=v&&typeof v.now=="number"?v.now:Date.now(),O=u.getTime()-s;if(Math.abs(O)<p){for(const[E,A]of k)if(Math.abs(O)>=A||E==="second")return g.format(Math.round(O/A),E)}}return h(u)};return m.spec=o,m}function b(n){if(N(n)||n==="")return null;if(typeof n=="string"){const c=/^(\d{4}-\d{2}-\d{2})/.exec(n.trim());if(c)return c[1];const d=H(n);return d?b(d):null}const i=H(n);if(!i)return null;const o=c=>String(c).padStart(2,"0");return`${i.getFullYear()}-${o(i.getMonth()+1)}-${o(i.getDate())}`}function a(n,i){if(N(n)||n==="")return null;if(typeof n=="string"){const c=n.trim();if(l.test(c)){const h=H(c);return h?r(h,i):null}const d=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(c);if(d){const[,h,g,y,p]=d;return`${h}T${g}:${y}${p&&p!=="00"?`:${p}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(c))return`${c}T00:00`;const f=H(c);return f?a(f):null}const o=H(n);return o?r(o,i):null}const l=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(n,i){const o=h=>String(h).padStart(2,"0");if(i)try{const h=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(n).reduce((p,m)=>(m.type!=="literal"&&(p[m.type]=m.value),p),{}),g=h.hour==="24"?"00":h.hour,y=Number(h.second);return`${h.year}-${h.month}-${h.day}T${g}:${h.minute}`+(y?`:${h.second}`:"")}catch{}const c=`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())}`,d=n.getSeconds(),f=`${o(n.getHours())}:${o(n.getMinutes())}${d?`:${o(d)}`:""}`;return`${c}T${f}`}function t(n,i){const o=N(n)||n===""?null:String(n),c=N(i)||i===""?null:String(i);return o===null?c===null?0:1:c===null||o<c?-1:o>c?1:0}}),Se("packages/core/src/format/boolean.js",function(e,V){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/internal/util.js").isNil,$={true:"☑",false:"☐",null:""},L={true:"◉",false:"◯",null:""};function W(H){if(N(H)||H==="")return null;if(typeof H=="boolean")return H;if(typeof H=="number")return H!==0;const U=String(H).trim().toLowerCase();return U==="true"||U==="yes"||U==="y"||U==="1"?!0:U==="false"||U==="no"||U==="n"||U==="0"?!1:null}function Z(H,U){const z=H||{},F=z.display||"text",k=z.trueLabel??"Yes",S=z.falseLabel??"No",b=z.nullLabel??"";let a=k,l=S;const r=b;F==="checkbox"?(a=$.true,l=$.false):F==="switch"?(a=L.true,l=L.false):F==="icon"&&(a=z.trueIcon??k,l=z.falseIcon??S);const t=n=>{const i=W(n);return i===null?r:i?a:l};return t.display=F,t.labels={true:k,false:S,null:b},t.locale=U,t.spec=z,t}}),Se("packages/core/src/format/text.js",function(e,V){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return L}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.titleCase;function L(W,Z){const H=W||{},U=H.locale||Z||void 0,z=H.nullDisplay??"",F=H.emptyDisplay??"",k=H.transform||"none",S=typeof H.truncate=="number"?{chars:H.truncate}:H.truncate||null,b=S?S.chars:0,a=S?S.ellipsis??"…":"",l=t=>{switch(k){case"upper":return U?t.toLocaleUpperCase(U):t.toUpperCase();case"lower":return U?t.toLocaleLowerCase(U):t.toLowerCase();case"title":return $(t);default:return t}},r=t=>{if(N(t))return z;let n=typeof t=="string"?t:String(t);return n===""?F:(k!=="none"&&(n=l(n)),b>0&&n.length>b&&(n=n.slice(0,b)+a),n)};return r.spec=H,r}}),Se("packages/core/src/format/mask.js",function(e,V){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const _=new Set(["0","#","?",",","."]),N="\0";function $(U){const z=[];let F="",k=!1;for(let S=0;S<U.length;S++){const b=U[S];if(b==="\\"){F+=b+(U[S+1]??""),S+=1;continue}if(b==='"'){k=!k,F+=b;continue}if(b===";"&&!k){z.push(F),F="";continue}F+=b}return z.push(F),z}function L(U){let z="",F="",k="",S=1,b=!1,a=!1;const l=h=>{a?F+=h:z+=h};for(let h=0;h<U.length;h++){const g=U[h];if(g==="\\"){l(U[h+1]??""),h+=1;continue}if(g==='"'){const y=U.indexOf('"',h+1);l(y===-1?U.slice(h+1):U.slice(h+1,y)),h=y===-1?U.length:y;continue}if(g==="%"){S*=100,l("%");continue}if(g==="@"){b=!0,l("\0");continue}if(_.has(g)){k+=g,a=!0;continue}l(g)}let r=-1;for(let h=k.length-1;h>=0;h--){const g=k[h];if(g==="0"||g==="#"||g==="?"){r=h;break}}let t=!1,n="";for(let h=0;h<k.length;h++){const g=k[h];if(g===","){h>r?S/=1e3:t=!0;continue}n+=g}const i=n.indexOf("."),o=i===-1?n:n.slice(0,i),c=i===-1?"":n.slice(i+1);let d=0;for(const h of o)h==="0"&&(d+=1);let f=0;for(const h of c)h==="0"&&(f+=1);return{prefix:z,suffix:F,minInt:d,minDec:f,maxDec:c.length,grouping:t,scale:S,hasNumber:r!==-1,isText:b}}function W(U,z){const F=new Intl.NumberFormat(z,{minimumIntegerDigits:Math.max(U.minInt,1),minimumFractionDigits:U.minDec,maximumFractionDigits:Math.max(U.maxDec,U.minDec),useGrouping:U.grouping}),{prefix:k,suffix:S,scale:b,hasNumber:a}=U;return l=>{if(!a)return k+S;const r=b===1?l:l*b;return k+F.format(r)+S}}function Z(U,z){const k=$(String(U)).map(L),S=k.map(n=>W(n,z)),b=0,a=k.length>1?1:-1,l=k.length>2?2:-1,r=k.length>3?3:-1,t=n=>{if(n==null||n==="")return"";if(typeof n!="number"||Number.isNaN(n)){const i=Number(n);if(Number.isNaN(i))return r===-1?String(n):(k[r].prefix+k[r].suffix).split("\0").join(String(n));n=i}return n===0&&l!==-1?S[l](0):n<0&&a!==-1?S[a](-n):S[b](n)};return t.spec={mask:U},{format:t,ooxml:H(String(U))}}function H(U){return U.trim()}}),Se("packages/core/src/format/shorthand.js",function(e,V){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return H}});const _=["currency","number","percent","date","boolean","text","relative"],N=/[#0?@;"\\]/,$=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function L(U){return typeof U!="string"||U===""||Z(U)?!1:N.test(U)}function W(U){return typeof U!="string"||U===""||Z(U)?!1:$.test(U)}function Z(U){const z=U.indexOf(":"),F=z===-1?U:U.slice(0,z);return _.includes(F)?F:null}function H(U){const z=Z(U);if(!z)return null;const F=U.indexOf(":"),k=F===-1?"":U.slice(F+1),S=k===""?[]:k.split(":");switch(z){case"currency":{const b={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(b.decimals=Number(S[1])),b}case"number":{const b={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(b.decimals=Number(S[0])),b}case"percent":{const b={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(b.decimals=Number(S[0])),b}case"date":return{type:"date",pattern:k||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=k.split("/"),a={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(a.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(a.falseLabel=b[1]),b[2]!==void 0&&(a.nullLabel=b[2]),a}case"text":{const b={type:"text"};return S[0]&&(b.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(b.truncate=Number(S[1])),b}default:return null}}}),Se("packages/core/src/format/index.js",function(e,V){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return m}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.isObject,L=_.warnOnce,W=V("packages/core/src/format/number.js"),Z=W.compileNumber,H=V("packages/core/src/format/date.js"),U=H.compileDate,z=H.scanPattern,F=V("packages/core/src/format/boolean.js"),k=F.compileBoolean,S=V("packages/core/src/format/text.js"),b=S.compileText,a=V("packages/core/src/format/mask.js"),l=a.compileMask,r=V("packages/core/src/format/shorthand.js"),t=r.parseShorthand,n=r.looksLikeMask,i=r.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return H.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return H.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return H.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return H.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return F.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return F.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return S.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return a.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return a.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return a.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),c=new Set(["type","locale"]),d={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])};function f(s,O,E){const A=d[O],M=E?`"${E}"`:"with no id";for(const C of s){if(c.has(C)||A.has(C))continue;const P=Object.keys(d).find(D=>D!==O&&d[D].has(C));P?L(`format:inapplicable:${E||""}:${C}`,`column ${M} has format key "${C}", which applies to a ${P} column, not the ${O} column it was applied to; it is ignored.`):L(`format:unknown:${E||""}:${C}`,`column ${M} has an unrecognised format key "${C}" for its ${O} format; it is ignored.`)}}function h(s){if(s.type==="number"||s.type==="date"||s.type==="boolean"||s.type==="text")return!0;const O=o.has(String(s.style));return!!(s.pattern||s.dateStyle||s.timeStyle||s.relative||s.timeZone||s.trueLabel||s.falseLabel||s.display||s.trueIcon||s.falseIcon||s.transform||s.truncate||s.emptyDisplay||O||s.currency||s.decimals!==void 0||s.minDecimals!==void 0||s.maxDecimals!==void 0||s.notation||s.negative||s.scale!==void 0||s.prefix||s.suffix||s.zeroDisplay!==void 0)}function g(s,O){if(s.type==="number"||s.type==="date"||s.type==="boolean"||s.type==="text")return s.type;if(s.pattern||s.dateStyle||s.timeStyle||s.relative||s.timeZone)return"date";if(s.trueLabel||s.falseLabel||s.display||s.trueIcon||s.falseIcon)return"boolean";if(s.transform||s.truncate||s.emptyDisplay)return"text";if(s.style||s.currency||s.decimals!==void 0||s.minDecimals!==void 0||s.maxDecimals!==void 0||s.notation||s.negative||s.scale!==void 0||s.prefix||s.suffix||s.zeroDisplay!==void 0)return"number";const E=O&&O.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function y(s,O=null,E=void 0,A=void 0,M=void 0){if(s==null||s==="")return null;const C=$(s)?Object.keys(s):null;if(A&&s&&typeof s=="object"&&s.timeZone===void 0&&(s={...s,timeZone:A}),typeof s=="function"){const K=(x,I)=>String(s({...I||{},value:x,locale:E})??"");return K.ooxml=O&&O.excel||"General",K}if(typeof s=="string"){if(n(s)){const{format:x,ooxml:I}=l(s,E);return x.ooxml=I,x}const K=t(s)||(i(s)?{type:"date",pattern:s}:null);return K?y(K,O,E,A,M):(L(`format:${s}`,`unrecognised format string "${s}"; the value will be stringified`),null)}if(!$(s))return L("format:shape","format must be a spec object or a string; ignoring",s),null;if(O&&N(O.format)&&!h(s))return null;const P=g(s,O);f(C||Object.keys(s),P,M);let D;switch(P){case"number":D=Z(s,E);break;case"date":D=U(s,E);break;case"boolean":D=k(s,E);break;default:D=b(s,E);break}return D.ooxml=m(s,P,E,O),D.kind=P,D}const p={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function m(s,O,E=void 0,A=null){if(O==="date"){if(s.pattern){let K="";for(const x of z(s.pattern))K+=x.token?p[x.token]??x.text:x.text;return K}return A&&A.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(s.notation==="compact"||s.notation==="scientific")return"General";const M=typeof s.decimals=="number"?s.decimals:typeof s.minDecimals=="number"?s.minDecimals:s.style==="currency"?2:0;let P=`${s.thousandsSeparator===!1?"":"#,#"}#0${M>0?`.${"0".repeat(M)}`:""}`,D="";return s.style==="currency"&&(D+=w(u(s.currency||"USD",E))),s.prefix&&(D+=w(s.prefix)),P=D+P,s.style==="percent"&&(P=`${P}%`),s.suffix&&(P+=w(s.suffix)),s.negative==="parentheses"?`${P};(${P})`:s.negative==="suffix"?`${P};${P}-`:P}function w(s){return`"${String(s).split('"').join("")}"`}const v=new Map;function u(s,O){const E=`${s}|${O||""}`;let A=v.get(E);if(A!==void 0)return A;A=s;try{const C=new Intl.NumberFormat(O,{style:"currency",currency:s}).formatToParts(0).find(P=>P.type==="currency");C&&(A=C.value)}catch{}return v.set(E,A),A}}),Se("packages/core/src/columns/types/temporal.js",function(e,V){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return at}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.isFunction,L=V("packages/core/src/format/date.js"),W=L.toDate,Z=L.compilePattern,H=L.compileDate,U=L.toIsoDateTime,z=L.compareIso,F=864e5,k=Object.freeze({}),S=1e3,b=60*S,a=60*b,l=24*a,r=7*l,t=new WeakMap;function n(Ae,We){const Ge=Ae&&Ae.locale||"",Qe=Ae&&Ae.column;if(!Qe)return Ge?{locale:Ge}:k;const lt=t.get(Qe);if(lt&&lt.locale===Ge)return lt.bag;const wt=Qe.typeOptions||Qe[We]||(i(Qe.format)?Qe.format:null),Pt={...wt||k,locale:wt&&wt.locale||Ge||void 0};return t.set(Qe,{locale:Ge,bag:Pt}),Pt}function i(Ae){return Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)&&!(Ae instanceof Date)}function o(Ae,We){const Ge=Ae===null||Number.isNaN(Ae)?null:Ae,Qe=We===null||Number.isNaN(We)?null:We;return Ge===null?Qe===null?0:1:Qe===null||Ge<Qe?-1:Ge>Qe?1:0}const c=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,d=/^(\d{3,6})$/;function f(Ae,We,Ge,Qe){return!(Ae>=0&&Ae<=23)||!(We>=0&&We<=59)||!(Ge>=0&&Ge<=59)||!(Qe>=0&&Qe<=999)?null:Ae*a+We*b+Ge*S+Qe}function h(Ae){if(N(Ae))return null;const We=String(Ae).trim();if(We==="")return null;const Ge=d.exec(We);if(Ge){const $t=Ge[1];if($t.length===5)return null;const zt=$t.length===3?1:2;return f(Number($t.slice(0,zt)),Number($t.slice(zt,zt+2)),Number($t.slice(zt+2,zt+4)||0),0)}const Qe=c.exec(We);if(!Qe)return null;let lt=Number(Qe[1]);const wt=Number(Qe[2]||0),Pt=Number(Qe[3]||0),Ft=Qe[4]?Number(Qe[4].padEnd(3,"0")):0,Rt=Qe[5]?Qe[5][0].toLowerCase():null;if(Rt){if(lt<1||lt>12)return null;lt=lt%12,Rt==="p"&&(lt+=12)}return f(lt,wt,Pt,Ft)}function g(Ae){return N(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?(Ae%l+l)%l:null:Ae instanceof Date?Number.isNaN(Ae.getTime())?null:Ae.getHours()*a+Ae.getMinutes()*b+Ae.getSeconds()*S+Ae.getMilliseconds():h(Ae)}const y=new Map;function p(Ae){const We=Ae.pattern||"",Ge=Ae.timeStyle||(Ae.seconds?"medium":"short"),Qe=`${Ae.locale||""}|${We}|${Ge}`;let lt=y.get(Qe);if(lt)return lt;if(We)lt=Z(We,Ae.locale||void 0,"UTC");else{const wt=new Intl.DateTimeFormat(Ae.locale||void 0,{timeStyle:Ge,timeZone:"UTC"});lt=Pt=>wt.format(Pt)}return y.set(Qe,lt),lt}function m(Ae,We){const Ge=We||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ge.nullDisplay??"";const Qe=(Ae%l+l)%l;return p(Ge)(new Date(Qe))}function w(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae=="number"?Number.isFinite(Ae)&&Ae>=0&&Ae<l:typeof Ae!="string"||!Ae.includes(":")?!1:h(Ae)!==null}function v(Ae){const We=g(Ae);return We==null?"":m(We,{pattern:We%S===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const u=new Map;function s(Ae){const We=Ae||"";let Ge=u.get(We);return Ge||(Ge=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),u.set(We,Ge)),Ge}function O(Ae,We){const Ge={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Qe of s(We).formatToParts(new Date(Ae)))Qe.type==="year"?Ge.year=Number(Qe.value):Qe.type==="month"?Ge.month=Number(Qe.value):Qe.type==="day"?Ge.day=Number(Qe.value):Qe.type==="hour"?Ge.hour=Number(Qe.value)%24:Qe.type==="minute"?Ge.minute=Number(Qe.value):Qe.type==="second"&&(Ge.second=Number(Qe.value));return Ge}function E(Ae,We){const Ge=O(Ae,We);return Date.UTC(Ge.year,Ge.month-1,Ge.day,Ge.hour,Ge.minute,Ge.second,0)-Math.floor(Ae/1e3)*1e3}function A(Ae,We){const Ge=Ae.hour||0,Qe=Ae.minute||0,lt=Ae.second||0,wt=Ae.ms||0;if(!We)return new Date(Ae.year,Ae.month-1,Ae.day,Ge,Qe,lt,wt).getTime();const Pt=Date.UTC(Ae.year,Ae.month-1,Ae.day,Ge,Qe,lt,wt);let Ft=Pt-E(Pt,We);return Ft=Pt-E(Ft,We),Ft}const M=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ae,We){if(N(Ae))return null;const Ge=String(Ae).trim();if(Ge==="")return null;const Qe=We&&We.timeZone||void 0;if(!M.test(Ge)){const lt=C.exec(Ge);if(lt){const wt=(lt[4]||"").trim(),Pt=wt===""?0:h(wt);if(Pt===null)return null;const Ft=A({year:Number(lt[1]),month:Number(lt[2]),day:Number(lt[3]),hour:Math.floor(Pt/a),minute:Math.floor(Pt/b)%60,second:Math.floor(Pt/S)%60,ms:Pt%S},Qe);return Number.isNaN(Ft)?null:new Date(Ft)}}return W(Ge)}function D(Ae){if(typeof Ae=="number")return Number.isFinite(Ae)?Ae:null;const We=W(Ae);return We?We.getTime():null}const K=new Map;function x(Ae){const We=[Ae.locale||"",Ae.pattern||"",Ae.dateStyle||"",Ae.timeStyle||"",Ae.timeZone||"",Ae.seconds?"1":""].join("|");let Ge=K.get(We);if(Ge)return Ge;const Qe=Ae.pattern?{type:"date",pattern:Ae.pattern,timeZone:Ae.timeZone}:{type:"date",dateStyle:Ae.dateStyle||"medium",timeStyle:Ae.timeStyle||(Ae.seconds?"medium":"short"),timeZone:Ae.timeZone};return Ge=H(Qe,Ae.locale||void 0),K.set(We,Ge),Ge}function I(Ae,We){const Ge=We||k,Qe=D(Ae);return Qe==null?Ge.nullDisplay??"":x(Ge)(Qe)}function j(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae!="string"||!C.test(Ae.trim())?!1:P(Ae)!==null}const T=Object.freeze([{key:"w",ms:r,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:l,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:a,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:S,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),B=new Map;for(const Ae of T)for(const We of Ae.names)B.set(We,Ae);const q=Object.freeze(T.filter(Ae=>Ae.key!=="w")),X=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Q=/^\d+(?:\.\d+)?$/,te=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function re(Ae){const We=Ae&&Ae.defaultUnit?B.get(String(Ae.defaultUnit).toLowerCase()):null;return We?We.ms:b}function ie(Ae){return(Ae&&Ae.defaultUnit?B.get(String(Ae.defaultUnit).toLowerCase()):null)||B.get("m")}function ae(Ae,We){if(N(Ae))return null;let Ge=String(Ae).trim().toLowerCase();if(Ge==="")return null;let Qe=1;if(Ge[0]==="-"?(Qe=-1,Ge=Ge.slice(1).trim()):Ge[0]==="+"&&(Ge=Ge.slice(1).trim()),Ge==="")return null;const lt=te.exec(Ge);if(lt){const Rt=lt[3]!==void 0,$t=Number(lt[1])*a+Number(lt[2])*b+(Rt?Number(lt[3])*S:0)+(lt[4]?Number(lt[4].padEnd(3,"0")):0);return Qe*$t}if(Q.test(Ge))return Math.round(Qe*Number(Ge)*re(We||k));let wt=Ge,Pt=0,Ft=0;for(;wt!=="";){const Rt=X.exec(wt);if(!Rt)return null;const $t=B.get(Rt[2]);if(!$t)return null;Pt+=Number(Rt[1])*$t.ms,wt=wt.slice(Rt[0].length),Ft++}return Ft===0?null:Math.round(Qe*Pt)}function ee(Ae){return N(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?Ae:null:ae(Ae)}const J=new Map;function se(Ae,We,Ge){const Qe=`${Ge||""}|${We.intl}`;let lt=J.get(Qe);if(lt===void 0){try{lt=new Intl.NumberFormat(Ge||void 0,{style:"unit",unit:We.intl,unitDisplay:"long"})}catch{lt=null}J.set(Qe,lt)}return lt?lt.format(Ae):`${Ae} ${Ae===1?We.long[0]:We.long[1]}`}function le(Ae,We){return String(Ae).padStart(We,"0")}function oe(Ae,We){const Ge=We||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ge.nullDisplay??"";const Qe=Ge.style||"short",lt=Ae<0;let wt=Math.round(Math.abs(Ae));const Pt=lt?"-":"";if(wt===0&&Ge.zeroDisplay!=null)return Ge.zeroDisplay;if(Qe==="clock"){const zt=Math.floor(wt/a),_t=Math.floor(wt/b)%60,Qt=Math.floor(wt/S)%60;return`${Pt}${le(zt,2)}:${le(_t,2)}:${le(Qt,2)}`}if(wt===0){const zt=ie(Ge);return Qe==="long"?se(0,zt,Ge.locale):`0${zt.key}`}const Ft=Ge.weeks===!0?T:q,Rt=typeof Ge.maxUnits=="number"&&Ge.maxUnits>0?Ge.maxUnits:Ge.maxUnits===void 0?2:1/0,$t=[];for(const zt of Ft){if($t.length>=Rt)break;const _t=Math.floor(wt/zt.ms);_t!==0&&(wt-=_t*zt.ms,$t.push(Qe==="long"?se(_t,zt,Ge.locale):`${_t}${zt.key}`))}return Pt+$t.join(" ")}function he(Ae){if(typeof Ae!="string")return!1;const We=Ae.trim();return We===""||te.test(We)||!/[a-z]/i.test(We)?!1:ae(We)!==null}const fe=Date.UTC(1899,11,30),ve=new Map;function be(Ae,We){const Ge=Ae||"";let Qe=ve.get(Ge);Qe||(Qe=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),ve.set(Ge,Qe));const lt=typeof We=="number"?We:Date.now();for(const wt of Qe.formatToParts(new Date(lt)))if(wt.type==="timeZoneName")return wt.value;return""}function Re(Ae){if(Ae)return Ae;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function He(Ae,We){const Ge=Re(Ae),Qe=be(Ae,We);return Qe?`${Ge} (${Qe})`:Ge}function Oe(Ae,We){if(Ae&&Ae.timeZone)return Ae.timeZone;const Ge=We&&We.grid;return(Ge&&$(Ge.get)?Ge.get("timeZone"):void 0)||void 0}function Ie(Ae,We){const Ge=We||k,Qe=D(Ae);if(Qe==null)return Ge.nullDisplay??"";const lt=x(Ge)(Qe);if(!Ge.showOrigin)return lt;const wt=Ge.originZone;return wt?wt===(Ge.timeZone||Re(Ge.timeZone))?lt:`${lt} (${He(wt,Qe)})`:`${lt} (no origin recorded)`}function $e(Ae,We,Ge,Qe){if(We==="instant"||!We)return Ae;const lt=O(Ae,Ge);if(We==="month")return A({year:lt.year,month:lt.month,day:1},Ge);if(We==="week"){const wt=Qe>=1&&Qe<=7?Qe:1,Ft=((new Date(Date.UTC(lt.year,lt.month-1,lt.day)).getUTCDay()+6)%7+1-wt+7)%7,Rt=new Date(Date.UTC(lt.year,lt.month-1,lt.day-Ft));return A({year:Rt.getUTCFullYear(),month:Rt.getUTCMonth()+1,day:Rt.getUTCDate()},Ge)}return A({year:lt.year,month:lt.month,day:lt.day},Ge)}function qe(Ae,We){const Ge=Ae&&Ae.group,Qe=Ge&&Ge.granularity||"day";if(Qe==="instant")return null;const lt=Ge&&Ge.weekStart;return wt=>typeof wt=="number"?$e(wt,Qe,We,lt):wt}const Ue={time:{base:"number",storage:"float64",matches:w,format:Ae=>m(g(Ae.value),n(Ae,"time")),parse:Ae=>h(Ae.text),compare:(Ae,We)=>o(g(Ae),g(We)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ae=>{const We=g(Ae);return We===null?null:We/F},toStorage:Ae=>g(Ae),toClipboard:v,fromClipboard:h},datetime:{base:"dateString",storage:"dictionary",matches:j,format:Ae=>I(Ae.value,n(Ae,"datetime")),parse:Ae=>U(P(Ae.text,n(Ae,"datetime"))??Ae.text),compare:z,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ae,We)=>U(Ae,We&&We.timeZone),toClipboard:Ae=>N(Ae)?"":String(Ae),fromClipboard:Ae=>U(Ae)},duration:{base:"number",storage:"float64",matches:he,format:Ae=>oe(ee(Ae.value),n(Ae,"duration")),parse:Ae=>ae(Ae.text,n(Ae,"duration")),compare:(Ae,We)=>o(ee(Ae),ee(We)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ae=>{const We=ee(Ae);return We===null?null:We/F},toStorage:Ae=>ee(Ae),toClipboard:Ae=>oe(ee(Ae),{style:"short",maxUnits:-1}),fromClipboard:Ae=>ae(Ae)},timestamp:{base:"number",storage:"float64",format:Ae=>{const We=n(Ae,"timestamp");return Ie(Ae.value,{...We,timeZone:Oe(We,Ae)})},parse:Ae=>{const We=n(Ae,"timestamp"),Ge=P(Ae.text,{timeZone:Oe(We,Ae)});return Ge?Ge.getTime():null},compare:(Ae,We)=>o(D(Ae),D(We)),groupProjector:(Ae,We)=>qe(Ae,We),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ae,We)=>{const Ge=D(Ae);if(Ge==null)return null;const Qe=O(Ge,We&&We.timeZone||void 0);return(Date.UTC(Qe.year,Qe.month-1,Qe.day,Qe.hour,Qe.minute,Qe.second)-fe)/F},toStorage:Ae=>D(Ae),toClipboard:Ae=>{const We=D(Ae);return We==null?"":new Date(We).toISOString()},fromClipboard:Ae=>D(Ae)}},Je=["datetime","time","duration"],at=Ue}),Se("packages/core/src/columns/types/network.js",function(e,V){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.Lru,L=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Z(D){if(N(D))return null;if(typeof D=="string")return H(D);const K=Number(D);return Number.isFinite(K)?K<0?K<-2147483648?null:K>>>0:K>L?null:Math.trunc(K)>>>0:null}function H(D){if(N(D))return null;const K=String(D).trim();if(K==="")return null;const x=W.exec(K);if(!x)return null;let I=0;for(let j=1;j<=4;j++){const T=x[j];if(T.length>1&&T.charCodeAt(0)===48)return null;const B=Number(T);if(B>255)return null;I=I*256+B}return I}function U(D){const K=Z(D);return K===null?"":`${K>>>24&255}.${K>>>16&255}.${K>>>8&255}.${K&255}`}function z(D){return typeof D=="string"&&H(D)!==null}function F(D,K){const x=Z(D),I=Z(K);return x===null?I===null?0:1:I===null||x<I?-1:x>I?1:0}const k=64,S=L*k+32,b=/^(?:0|[1-9]\d?)$/;function a(D,K){return D*k+K}function l(D){if(N(D))return null;if(typeof D=="string"){const I=r(D);return I===null?null:l(I)}if(typeof D=="object"){const I=Z(D.address),j=Number(D.prefix);return I===null||!Number.isInteger(j)||j<0||j>32?null:{address:I,prefix:j}}const K=Number(D);if(!Number.isInteger(K)||K<0||K>S)return null;const x=K%k;return x>32?null:{address:(K-x)/k,prefix:x}}function r(D){if(N(D))return null;const K=String(D).trim();if(K==="")return null;const x=K.indexOf("/");if(x<0)return null;const I=H(K.slice(0,x));if(I===null)return null;const j=K.slice(x+1).trim();if(!b.test(j))return null;const T=Number(j);return T>32?null:a(I,T)}function t(D){const K=l(D);return K?`${U(K.address)}/${K.prefix}`:""}function n(D){return typeof D=="string"&&r(D)!==null}function i(D,K){const x=l(D),I=l(K);return x?I?x.address!==I.address?x.address<I.address?-1:1:x.prefix-I.prefix:-1:I?1:0}function o(D){return D===0?0:4294967295<<32-D>>>0}function c(D){const K=l(D);return K?(K.address&o(K.prefix))>>>0:null}function d(D){const K=l(D);return K?(K.address&o(K.prefix)|~o(K.prefix)>>>0)>>>0:null}function f(D){const K=l(D);return K?2**(32-K.prefix):null}function h(D){const K=l(D);return K?K.prefix===32?1:K.prefix===31?2:2**(32-K.prefix)-2:null}function g(D,K){const x=l(D);if(!x)return!1;const I=Z(K);if(I===null)return!1;const j=o(x.prefix);return(I&j)>>>0===(x.address&j)>>>0}function y(D,K){const x=c(D),I=c(K);return x===null||I===null?!1:x<=d(K)&&I<=d(D)}const p=/^[0-9a-fA-F]{1,4}$/,m=new $(512);function w(D){if(N(D))return null;let K=String(D).trim();if(K==="")return null;const x=K.indexOf("%");if(x>=0&&(K=K.slice(0,x)),K==="")return null;if(K.indexOf(".")>=0){const X=K.lastIndexOf(":");if(X<0)return null;const Q=H(K.slice(X+1));if(Q===null)return null;K=`${K.slice(0,X+1)}${(Q>>>16&65535).toString(16)}:${(Q&65535).toString(16)}`}const I=K.split("::");if(I.length>2)return null;const j=v(I[0]);if(j===null)return null;if(I.length===1)return j.length===8?j:null;const T=v(I[1]);if(T===null)return null;const B=8-j.length-T.length;if(B<1)return null;const q=j.slice();for(let X=0;X<B;X++)q.push(0);for(const X of T)q.push(X);return q}function v(D){if(D==="")return[];const K=[];for(const x of D.split(":")){if(!p.test(x))return null;K.push(parseInt(x,16))}return K}function u(D){if(typeof D!="string")return w(D);if(m.has(D))return m.get(D);const K=w(D);return m.set(D,K),K}function s(D){if(D[0]===0&&D[1]===0&&D[2]===0&&D[3]===0&&D[4]===0&&D[5]===65535)return`::ffff:${U((D[6]<<16|D[7])>>>0)}`;let K=-1,x=0,I=-1,j=0;for(let q=0;q<8;q++)D[q]===0?(I<0?(I=q,j=1):j++,j>x&&(x=j,K=I)):(I=-1,j=0);if(x<2)return D.map(q=>q.toString(16)).join(":");const T=D.slice(0,K).map(q=>q.toString(16)).join(":"),B=D.slice(K+x).map(q=>q.toString(16)).join(":");return`${T}::${B}`}function O(D){const K=w(D);return K===null?null:s(K)}function E(D){return O(D)??""}function A(D){return typeof D=="string"&&D.indexOf(":")>=0&&w(D)!==null}function M(D,K){const x=u(D),I=u(K);if(!x)return I?1:0;if(!I)return-1;for(let j=0;j<8;j++)if(x[j]!==I[j])return x[j]<I[j]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:z,parse:D=>H(D.text),compare:F,format:D=>U(D.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:D=>Z(D),toClipboard:D=>U(D),fromClipboard:D=>H(D)},cidr:{base:"number",storage:"float64",matches:n,parse:D=>r(D.text),compare:i,format:D=>t(D.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:D=>{const K=l(D);return K===null?null:a(K.address,K.prefix)},toClipboard:D=>t(D),fromClipboard:D=>r(D)},ipv6:{base:"text",storage:"dictionary",matches:A,parse:D=>O(D.text),compare:M,format:D=>E(D.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:D=>O(D),toClipboard:D=>E(D),fromClipboard:D=>O(D)}}),P=C}),Se("packages/core/src/i18n/catalogue.js",function(e,V){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return N}});const _=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Next / previous cell, wrapping across rows","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.dataTable":"Chart data","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown"}),N=Object.freeze(Object.keys(_))}),Se("packages/core/src/i18n/format.js",function(e,V){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,$=/\{(\w+)\}/g,L=new Map,W=new Map;function Z(b){const a=b||"";if(L.has(a))return L.get(a);let l=null;try{l=new Intl.PluralRules(b||void 0)}catch{l=null}return L.set(a,l),l}function H(b,a,l="conjunction"){const r=Array.isArray(b)?b.filter(i=>i!=null&&i!==""):[];if(r.length===0)return"";if(r.length===1)return String(r[0]);const t=`${a||""}|${l}`;let n=W.get(t);if(n===void 0){try{n=new Intl.ListFormat(a||void 0,{style:"long",type:l})}catch{n=null}W.set(t,n)}return n?n.format(r.map(String)):r.map(String).join(", ")}function U(b,a){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(a||void 0,{maximumFractionDigits:20}):"":String(b)}function z(b,a,l){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const r=a&&typeof a.count=="number"?a.count:null;if(r===null)return b.other??"";const t=Z(l),n=t?t.select(r):r===1?"one":"other";return b[n]??b.other??""}function F(b,a={},l){const r=z(b,a,l);return r?r.replace($,(t,n)=>Object.prototype.hasOwnProperty.call(a,n)?U(a[n],l):t):""}function k(b,a,l="en-GB"){return typeof b=="string"&&b?b:typeof a=="string"&&a?a:l}function S(b,a){const l=b?b[a]:void 0;return l==null||N(l)?a:l}}),Se("packages/core/src/i18n/index.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return r}});const _=V("packages/core/src/i18n/catalogue.js"),N=_.EN_GB,$=_.MESSAGE_KEYS,L=V("packages/core/src/i18n/format.js"),W=L.formatMessage,Z=L.formatList,H=L.lookup,U=L.resolveLocale,z=V("packages/core/src/internal/util.js"),F=z.isFunction,k=z.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return _.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return L.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return L.resolveLocale}});const S="en-GB";class b{#e=S;#t=N;constructor(n={}){this.configure(n)}configure(n={}){this.#e=U(n.locale,n.declared,S);const i=n.messages;if(!i||typeof i!="object"){this.#t=N;return}const o=Object.keys(i).filter(c=>!(c in N));o.length&&k(`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={...N,...i}}get locale(){return this.#e}t(n,i){return W(H(this.#t,n),i||{},this.#e)}list(n,i){return Z(n,this.#e,i)}number(n,i){const o=Number(n);return Number.isFinite(o)?o.toLocaleString(this.#e,i||{maximumFractionDigits:20}):""}}const a=new b;function l(t){return t instanceof b?t:new b(t||{})}function r(t){const n=t&&typeof t=="object"?t:{},i=$.filter(c=>{const d=n[c];return d==null||d===""||F(d)}),o=Object.keys(n).filter(c=>!(c in N));return{missing:i,unknown:o}}}),Se("packages/core/src/columns/types/structured.js",function(e,V){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.isObject,W=V("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function H(t,n){const i=n||{},o=i.emptyDisplay??Z.emptyDisplay;if(N(t)||t==="")return o;const d=[...typeof i.char=="string"&&i.char!==""?i.char:Z.char][0]||Z.char,f=i.fixedLength??Z.fixedLength,h=Number.isFinite(i.length)&&Number(i.length)>0?Math.floor(Number(i.length)):Z.length,g=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let y=0;if(g!==null){const p=Number.isFinite(i.lastVisible)?Math.floor(Number(i.lastVisible)):Z.lastVisible,m=[...g];if(y=p>0&&p<m.length?p:0,y>0){const w=m.slice(m.length-y).join(""),v=Math.max(1,(f?h:m.length)-y);return d.repeat(v)+w}return d.repeat(f?h:Math.max(1,m.length))}return d.repeat(h)}const U=48;function z(t){try{const n=JSON.stringify(t);return n===void 0?null:n}catch{return null}}function F(t,n){if(N(t))return"";const i=Number.isFinite(n&&n.inlineLimit)?Number(n.inlineLimit):U;if(typeof t=="string")return t.length>i?`${t.slice(0,i-1)}…`:t;if(typeof t!="object")return String(t);const o=z(t);if(o!==null&&o.length<=i)return o;if(Array.isArray(t)){const d=t.length;return`[${W.t("count.items",{count:d})}]`}const c=Object.keys(t).length;return`{${W.t("count.keys",{count:c})}}`}function k(t,n){if(t==null)return"null";const i=typeof t;if(i==="number"||i==="boolean"||i==="bigint")return String(t);if(i==="string")return JSON.stringify(t);if(i!=="object")return JSON.stringify(String(t));const o=n||new WeakSet;return o.has(t)?'"[circular]"':(o.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(f=>k(f,o)).join(",")}]`:`{${Object.keys(t).sort().map(f=>`${JSON.stringify(f)}:${k(t[f],o)}`).join(",")}}`)}function S(t,n){if(N(t))return N(n)?0:1;if(N(n))return-1;const i=k(t),o=k(n);return i<o?-1:i>o?1:0}function b(t){if(N(t))return null;const n=String(t);if(n.trim()==="")return null;try{return JSON.parse(n)}catch{return n}}function a(t){const n=t&&t.cell&&t.cell.props;return $(n)?n:{}}const l=Object.freeze({json:{base:"object",storage:"object",format:t=>F(t&&t.value,a(t&&t.column)),parse:t=>b(t&&t.text),compare:S,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(N(t))return"";if(typeof t=="string")return t;try{const n=JSON.stringify(t,null,2);return n===void 0?String(t):n}catch{return String(t)}},fromClipboard:t=>b(t)},secret:{base:"text",storage:"object",format:t=>H(t&&t.value,a(t&&t.column)),parse:t=>{const n=t&&t.text;return N(n)||String(n)===""?null:String(n)},compare:(t,n)=>{const i=N(t)||t==="",o=N(n)||n==="";return i===o?0:i?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>H(t),fromClipboard:t=>N(t)||String(t)===""?null:String(t)}}),r=l}),Se("packages/core/src/columns/types/unit.js",function(e,V){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.warnOnce;function L(j,T,B,q){return Object.freeze({symbol:j,factor:T,aliases:Object.freeze(B||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(j,T,B,q){return L(j,T,B,q)}const Z=Object.freeze({data:Object.freeze([L("B",1,["byte","bytes"]),L("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),L("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),L("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),L("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),L("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),L("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),L("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),L("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),L("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([L("bps",1,["bit","bits","bit/s","b/s"]),L("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),L("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),L("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),L("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([L("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),L("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),L("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),L("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),L("in",.0254,["inch","inches"],{auto:!1}),L("ft",.3048,["foot","feet"],{auto:!1}),L("yd",.9144,["yard","yards"],{auto:!1}),L("m",1,["metre","metres","meter","meters"]),L("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),L("mi",1609.344,["mile","miles"],{auto:!1}),L("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([L("mg",.001,["milligram","milligrams"]),L("g",1,["gram","grams"]),L("oz",28.349523125,["ounce","ounces"],{auto:!1}),L("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),L("kg",1e3,["kilogram","kilograms"]),L("st",6350.29318,["stone"],{auto:!1}),L("t",1e6,["tonne","tonnes","ton"],{auto:!1}),L("ton (US)",907184.74,["ton","shortton"],{auto:!1}),L("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([L("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),L("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),L("ms",.001,["msec","msecs","millisecond","milliseconds"]),L("s",1,["sec","secs","second","seconds"]),L("m",60,["min","mins","minute","minutes"]),L("h",3600,["hr","hrs","hour","hours"]),L("d",86400,["day","days"])]),speed:Object.freeze([L("mm/s",.001,["millimetre/s","millimeter/s"]),L("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),L("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),L("mph",.44704,["mile/h","miles/h"],{auto:!1}),L("kn",1852/3600,["knot","knots"],{auto:!1}),L("m/s",1,["metre/s","meter/s","mps"]),L("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([L("mm/s²",.001,["mm/s2"]),L("ft/s²",.3048,["ft/s2"],{auto:!1}),L("m/s²",1,["m/s2","metre/s2","meter/s2"]),L("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([L("mm²",1e-6,["mm2"]),L("cm²",1e-4,["cm2"]),L("in²",64516e-8,["in2","sqin"],{auto:!1}),L("ft²",.09290304,["ft2","sqft"],{auto:!1}),L("yd²",.83612736,["yd2","sqyd"],{auto:!1}),L("m²",1,["m2","sqm"]),L("ha",1e4,["hectare","hectares"],{auto:!1}),L("ac",4046.8564224,["acre","acres"],{auto:!1}),L("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([L("µL",1e-6,["ul","microlitre","microliter"]),L("mL",.001,["millilitre","milliliter"]),L("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),L("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),L("L",1,["litre","litres","liter","liters"]),L("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),L("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),L("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),L("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([L("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),L("J",1,["joule","joules"]),L("cal",4.184,["calorie","calories"],{auto:!1}),L("kJ",1e3,["kilojoule","kilojoules"]),L("BTU",1055.05585262,["btu"],{auto:!1}),L("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),L("MJ",1e6,["megajoule","megajoules"]),L("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),L("GJ",1e9,["gigajoule","gigajoules"]),L("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([L("mW",.001,["milliwatt","milliwatts"]),L("W",1,["watt","watts"]),L("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),L("kW",1e3,["kilowatt","kilowatts"]),L("hp",745.6998715822702,["horsepower"],{auto:!1}),L("MW",1e6,["megawatt","megawatts"]),L("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([L("mN",.001,["millinewton","millinewtons"]),L("N",1,["newton","newtons"]),L("lbf",4.4482216152605,["poundforce"],{auto:!1}),L("kgf",9.80665,["kilogramforce"],{auto:!1}),L("kN",1e3,["kilonewton","kilonewtons"]),L("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([L("Pa",1,["pascal","pascals"]),L("mbar",100,["millibar"],{auto:!1}),L("inH₂O",249.0889,["inh2o"],{auto:!1}),L("mmHg",133.322387415,["torr"],{auto:!1}),L("kPa",1e3,["kilopascal","kilopascals"]),L("inHg",3386.388640341,["inhg"],{auto:!1}),L("psi",6894.757293168361,["lbf/in2"],{auto:!1}),L("bar",1e5,[],{auto:!1}),L("atm",101325,["atmosphere","atmospheres"],{auto:!1}),L("MPa",1e6,["megapascal","megapascals"]),L("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([L("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),L("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),L("kN·m",1e3,["knm","kn.m"],{auto:!1}),L("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([L("kg/m³",1,["kg/m3"]),L("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),L("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),L("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([L("L/min",1/6e4,["lpm","l/min"],{auto:!1}),L("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),L("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),L("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),L("cfm",.0004719474432,["ft3/min"],{auto:!1}),L("L/s",.001,["lps","l/s"],{auto:!1}),L("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([L("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),L("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),L("mrad",.001,["milliradian","milliradians"],{auto:!1}),L("mil",Math.PI/3200,["nato-mil"],{auto:!1}),L("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),L("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),L("rad",1,["radian","radians"]),L("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([L("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),L("rad/s",1,["radps","radians/s"]),L("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),L("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([L("ppt",1e-12,["partspertrillion"],{auto:!1}),L("ppb",1e-9,["partsperbillion"]),L("ppm",1e-6,["partspermillion"]),L("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),L("‰",.001,["permille","permil"],{auto:!1}),L("%",.01,["pct","percent"]),L("×",1,["x","ratio","times"])]),molarity:Object.freeze([L("pM",1e-12,["picomolar","picomolarity"]),L("nM",1e-9,["nanomolar","nanomolarity"]),L("µM",1e-6,["um-molar","micromolar","micromolarity"]),L("mM",.001,["millimolar","millimolarity"]),L("M",1,["molar","mol/l","mol/L","molarity"]),L("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([L("mg/s",1e-6,["milligrams/s"]),L("g/s",.001,["grams/s"]),L("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),L("kg/s",1,["kilograms/s","kgps"]),L("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),L("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),L("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([L("µPa·s",1e-6,["upas","micropascalsecond"]),L("cP",.001,["centipoise"],{auto:!1}),L("mPa·s",.001,["mpas","millipascalsecond"]),L("P",.1,["poise"],{auto:!1}),L("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([L("cSt",1e-6,["centistokes","centistoke"]),L("mm²/s",1e-6,["mm2/s"],{auto:!1}),L("St",1e-4,["stokes","stoke"],{auto:!1}),L("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([L("mW/(m·K)",.001,["mw/mk"]),L("W/(m·K)",1,["w/mk","wmk"]),L("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),L("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([L("J/(kg·K)",1,["j/kgk","jkgk"]),L("kJ/(kg·K)",1e3,["kj/kgk"]),L("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([L("nSv/h",1e-9,["nsvh"]),L("µSv/h",1e-6,["usv/h","usvh"]),L("mSv/h",.001,["msvh"]),L("Sv/h",1,["svh"]),L("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),H=Symbol("ambiguous"),U=new Map,z=new Map;function F(j,T){const B=String(j||"").trim();if(!B)throw new Error("[lattice] a unit system needs a name");if(Z[B]||z.has(B))throw new Error(`[lattice] unit system "${B}" already exists`);const q=[...T||[]];if(!q.length)throw new Error(`[lattice] unit system "${B}" has no units`);if(!q.some(Q=>Q.factor===1))throw new Error(`[lattice] unit system "${B}" has no base unit (none with factor 1)`);const X=new Set;for(const Q of q){if(X.has(Q.symbol))throw new Error(`[lattice] unit system "${B}" declares "${Q.symbol}" twice`);X.add(Q.symbol)}return z.set(B,Object.freeze(q)),U.delete(B),B}function k(){return[...Object.keys(Z),...z.keys()]}function S(j){const T=b(j);return T?T.units:[]}function b(j){const T=String(j||""),B=U.get(T);if(B!==void 0)return B;const q=Z[T]||z.get(T);if(!q)return U.set(T,null),null;const X=Object.freeze([...q].sort((ae,ee)=>ae.factor-ee.factor)),Q=new Map,te=new Map,re=(ae,ee)=>{const J=Q.get(ae);J===void 0?Q.set(ae,ee):J!==ee&&Q.set(ae,H)};for(const ae of X){re(ae.symbol.toLowerCase(),ae);for(const ee of ae.aliases)re(ee.toLowerCase(),ae);if(ae.prefix){const ee=te.get(ae.prefix)||[];ee.push(ae),te.set(ae.prefix,ee)}}const ie={units:X,byToken:Q,byPrefix:te,decimal:X.filter(ae=>!ae.binary&&ae.auto),binary:X.some(ae=>ae.binary)?X.filter(ae=>(ae.binary||ae.factor===1)&&ae.auto):null};return U.set(T,ie),ie}function a(j,T){return T&&j.binary||j.decimal}function l(j,T){const B=b(j);if(!B||N(T))return null;const q=B.units.find(Q=>Q.symbol===String(T));if(q)return q;const X=B.byToken.get(String(T).trim().toLowerCase());return X&&X!==H?X:null}const r=new WeakMap;function t(j){const T=j||{};if(typeof T=="object"&&T!==null){const Q=r.get(T);if(Q!==void 0)return Q}const B=T.system||"data",q=b(B);let X=null;if(!q)$(`unit:system:${B}`,`unknown unit system "${B}"; known systems are ${k().join(", ")}`);else{let Q=T.unit?l(B,T.unit):null;Q||(T.unit&&$(`unit:unit:${B}:${T.unit}`,`unknown unit "${T.unit}" in system "${B}"; falling back to ${q.units[0].symbol}`),Q=q.units.find(te=>te.factor===1)||q.units[0]),X={index:q,base:Q,binary:T.binary===!0}}return typeof T=="object"&&T!==null&&r.set(T,X),X}const n=new WeakMap;function i(j,T){if(!j||!T||!Array.isArray(j.compound)||j.compound.length===0)return null;const B=n.get(j);if(B!==void 0)return B;const q=new Set,X=[];for(const te of j.compound){const re=l(j.system||"data",te);if(!re){$(`unit:compound:${j.system}:${te}`,`unknown compound unit "${te}" in system "${j.system||"data"}"; ignoring it`);continue}q.has(re.symbol)||(q.add(re.symbol),X.push(re))}X.sort((te,re)=>re.factor-te.factor);const Q=X.length>=2?X:null;return n.set(j,Q),Q}function o(j,T,B){return T===B||T.factor===B.factor?j:j*T.factor/B.factor}const c=new Map;function d(j){const T=j||"",B=c.get(T);if(B)return B;const q={group:",",decimal:"."};try{for(const X of new Intl.NumberFormat(j||void 0).formatToParts(12345.6))X.type==="group"?q.group=X.value:X.type==="decimal"&&(q.decimal=X.value)}catch{}return c.set(T,q),q}const f=/[\s   ]/g,h=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,g=/^[^\d+\-(.,\s]+\s*/,y=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function p(j,T){const{group:B,decimal:q}=d(T);let X=String(j).replace(f,"");if(X==="")return null;const Q=q?X.indexOf(q):-1;if(B&&B!==q){if(Q>=0&&X.indexOf(B,Q+q.length)>=0)return null;X=X.split(B).join("")}if(q&&q!=="."&&(X=X.split(q).join(".")),!y.test(X))return null;const te=Number(X);return Number.isFinite(te)?te:null}function m(j,T,B){const q=String(j).trim().replace(/\.$/,"");if(q==="")return null;const X=T.units.find(ee=>ee.symbol===q);if(X)return X;const Q=q.toLowerCase(),te=T.byToken.get(Q);if(te===H)return null;if(te)return te;const re=T.byPrefix.get(Q);if(!re||!re.length)return null;const ie=a(T,B),ae=re.filter(ee=>ie.includes(ee));return ae.length===1?ae[0]:null}function w(j,T,B,q){let X=j,Q=0,te=!1,re=!1;for(;X!=="";){const ie=h.exec(X)[0];if(ie==="")return null;const ae=p(ie,q&&q.locale);if(ae===null)return null;X=X.slice(ie.length).trim();const ee=X.search(/[+-]?[\d]/),J=(ee>=0?X.slice(0,ee):X).trim();if(X=ee>=0?X.slice(ee).trim():"",J===""){if(te)return null;re=!0,Q+=o(ae,B[0],T.base)}else{const se=m(J,T.index,T.binary);if(!se)return null;Q+=o(ae,se,T.base)}if(te=!0,re&&X!=="")return null}return te?Q:null}function v(j,T){if(N(j))return null;if(typeof j=="number")return Number.isFinite(j)?j:null;const B=t(T);if(!B)return null;let q=String(j).trim();if(q==="")return null;let X=!1;q.startsWith("(")&&q.endsWith(")")&&(X=!0,q=q.slice(1,-1).trim());const Q=i(T,B);if(Q){q.startsWith("-")&&(X=!0,q=q.slice(1).trim());const le=w(q,B,Q,T);return le===null?null:X?-le:le}let te=null;const re=g.exec(q);if(re&&re[0]){const le=m(re[0].trim(),B.index,B.binary);le&&(te=le,q=q.slice(re[0].length).trim())}const ie=h.exec(q)[0],ae=p(ie,T&&T.locale);if(ae===null)return null;const ee=q.slice(ie.length).trim();if(te&&ee!=="")return null;const J=te||(ee===""?B.base:m(ee,B.index,B.binary));if(!J)return null;const se=o(ae,J,B.base);return X?-se:se}const u=new Map;function s(j,T,B,q){const X=`${j||""}|${T}|${B}|${q?1:0}`;let Q=u.get(X);return Q||(Q=new Intl.NumberFormat(j||void 0,{minimumFractionDigits:T,maximumFractionDigits:B,useGrouping:q}),u.set(X,Q)),Q}function O(j,T){if(!Number.isFinite(j)||j===0)return Math.max(0,T-1);const B=Math.floor(Math.log10(Math.abs(j)));return Math.min(20,Math.max(0,T-1-B))}function E(j,T){if(!Number.isFinite(j)||j===0)return j;const B=Math.ceil(Math.log10(Math.abs(j))),q=10**(T-B);return Math.round(j*q)/q}function A(j,T,B){if(!B||B===T.base.symbol)return T.base;if(B!=="auto")return M(T,B);if(j===0||!Number.isFinite(j))return T.base;const q=Math.abs(j)*T.base.factor,X=a(T.index,T.binary);let Q=X[0];for(const ie of X)q>=ie.factor&&(Q=ie);if(q>=Q.factor)return Q;let te=Q;for(const ie of T.index.units)ie.binary!==T.binary&&ie.factor!==1||ie.factor<=q&&ie.factor>(te===Q?0:te.factor)&&(te=ie);if(te!==Q)return te;let re=Q;for(const ie of T.index.units)ie.binary!==T.binary&&ie.factor!==1||ie.factor<re.factor&&(re=ie);return re.factor<T.base.factor?re:T.base}function M(j,T){const B=j.index.units.find(X=>X.symbol===T);if(B)return B;const q=j.index.byToken.get(String(T).toLowerCase());return q&&q!==H?q:($(`unit:display:${T}`,`unknown display unit "${T}"; rendering in ${j.base.symbol}`),j.base)}function C(j,T,B,q){const X=j<0;let Q=Math.abs(j)*T.base.factor;const te=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,re=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(te,2),ie=q.space??" ",ae=[];for(let J=0;J<B.length;J++){const se=B[J],le=J===B.length-1;let oe=le?Q/se.factor:Math.floor(Q/se.factor);if(Q-=oe*se.factor,le){const fe=10**re;oe=Math.round(oe*fe)/fe+0}const he=le?s(q.locale,te,re,q.group!==!1):s(q.locale,0,0,q.group!==!1);ae.push(`${he.format(oe)}${ie}${se.symbol}`)}const ee=ae.join(" ");return X?`-${ee}`:ee}function P(j,T){const B=T||{},q=B.nullDisplay??"";if(N(j)||j==="")return q;const X=typeof j=="number"?j:Number(j);if(!Number.isFinite(X))return q;const Q=t(B);if(!Q)return String(X);const te=i(B,Q);if(te)return C(X,Q,te,B);const re=typeof B.significantFigures=="number"&&B.significantFigures>0?B.significantFigures:0,ie=re?E(X,re):X,ae=A(ie,Q,B.display),ee=o(ie,Q.base,ae);let J=typeof B.decimals=="number"?B.decimals:B.minDecimals??0,se=typeof B.decimals=="number"?B.decimals:B.maxDecimals??Math.max(J,2);re&&(J=O(ee,re),se=J);const le=s(B.locale,J,se,B.group!==!1).format(ee),oe=B.space??" ";return B.placement==="prefix"?`${ae.symbol}${B.space??""}${le}`:`${le}${oe}${ae.symbol}`}function D(j,T){const B=N(j)||Number.isNaN(j)?null:Number(j),q=N(T)||Number.isNaN(T)?null:Number(T);return B===null||Number.isNaN(B)?q===null||Number.isNaN(q)?0:1:q===null||Number.isNaN(q)||B<q?-1:B>q?1:0}function K(j){const T=typeof j.decimals=="number"&&j.decimals>0?`.${"0".repeat(j.decimals)}`:"";return`${typeof j.decimals=="number"?`#,##0${T}`:"#,##0.##"}" ${j.symbol}"`}function x(j){const T={system:"data",...j||{}},B=t(T),q=B?B.base.symbol:String(T.unit||""),X=Object.freeze({...T,unit:q}),Q=Object.freeze({...X,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),te=new Map([[X.locale||"",X]]),re=ie=>{const ae=ie||"";let ee=te.get(ae);return ee||(ee=Object.freeze({...X,locale:ie||void 0}),te.set(ae,ee)),ee};return{base:"number",extends:"number",storage:"float64",unitConfig:X,format:ie=>P(ie.value,ie.locale?re(ie.locale):X),parse:ie=>v(ie.text,ie.locale?re(ie.locale):X),compare:D,defaults:{filter:"number",editor:"unit",align:"end",total:T.total||"sum"},...T.totals?{totals:T.totals}:{},excel:T.excel||K({decimals:T.decimals,symbol:q}),toStorage:ie=>typeof ie=="number"?Number.isFinite(ie)?ie:null:typeof ie=="string"?v(ie,X):N(ie)?null:v(String(ie),X),toClipboard:ie=>P(ie,Q),fromClipboard:ie=>v(ie,X)}}const I=x}),Se("packages/core/src/columns/types/engineering.js",function(e,V){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").isNil,L=V("packages/core/src/columns/types/unit.js").createUnitType;function W(U){const z=2*Math.PI/U;return F=>{let k=0,S=0,b=0;for(const l of F||[]){if(N(l))continue;const r=Number(l);Number.isFinite(r)&&(k+=Math.cos(r*z),S+=Math.sin(r*z),b+=1)}return!b||Math.hypot(k,S)/b<1e-12?null:(Math.atan2(S,k)/z%U+U)%U}}function Z(U){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(U)}}}const H=Object.freeze({metres:L({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:L({system:"length",unit:"mm",maxDecimals:2}),kilometres:L({system:"length",unit:"km",maxDecimals:3}),grams:L({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:L({system:"mass",unit:"kg",maxDecimals:3}),tonnes:L({system:"mass",unit:"t",maxDecimals:3}),seconds:L({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:L({system:"duration",unit:"ms",maxDecimals:3}),hours:L({system:"duration",unit:"h",maxDecimals:2}),speed:L({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:L({system:"speed",unit:"km/h",maxDecimals:1}),mph:L({system:"speed",unit:"mph",maxDecimals:1}),knots:L({system:"speed",unit:"kn",maxDecimals:1}),acceleration:L({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:L({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:L({system:"area",unit:"ha",maxDecimals:4}),volume:L({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:L({system:"volume",unit:"m³",maxDecimals:3}),energy:L({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:L({system:"energy",unit:"kWh",maxDecimals:2}),power:L({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:L({system:"power",unit:"kW",maxDecimals:2}),force:L({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:L({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:L({system:"pressure",unit:"bar",maxDecimals:3}),psi:L({system:"pressure",unit:"psi",maxDecimals:1}),torque:L({system:"torque",unit:"N·m",maxDecimals:2}),density:L({system:"density",unit:"kg/m³",maxDecimals:2}),flow:L({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:L({system:"flow",unit:"L/min",maxDecimals:1}),radians:L({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:L({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:L({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:L({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:L({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:L({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:L({system:"fraction",unit:"bp",maxDecimals:1}),molarity:L({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:L({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:L({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:L({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:L({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:L({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:L({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:L({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Se("packages/core/src/columns/types/si.js",function(e,V){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/columns/types/unit.js"),N=_.defineUnit,$=_.registerUnitSystem,L=_.createUnitType,W=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function H(S){const b=String(S.base),a=new Set([...S.prefixes||Z,""]),l=[];for(const r of W){if(!a.has(r.symbol))continue;const t=`${r.symbol}${b}`,n=[];if(S.name){n.push(`${r.name}${S.name}`,`${r.name}${S.name}s`);const i=r.name.slice(-1);if(i&&S.name.startsWith(i)){const o=`${r.name.slice(0,-1)}${S.name}`;n.push(o,`${o}s`)}}r.symbol==="µ"&&n.push(`u${b}`),r.factor===1&&S.aliases&&n.push(...S.aliases),l.push(N(t,r.factor,n))}for(const r of S.extra||[])l.push(r);return l}function U(S,b){const a=H(b);return $(S,a)}function z(S,b,a){return U(S,b),L({system:S,unit:b.base,display:"auto",maxDecimals:3,...a||{}})}const F=Object.freeze({voltage:z("voltage",{base:"V",name:"volt"}),current:z("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:z("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:z("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:z("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:z("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[N("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),N("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:z("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:z("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[N("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:z("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:z("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:z("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:z("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:z("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:z("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:z("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[N("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:z("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),k=z}),Se("packages/core/src/columns/types/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const N=V("packages/core/src/internal/util.js").isNil,$=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:l=>l+273.15,fromKelvin:l=>l-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:l=>(l+459.67)*(5/9),fromKelvin:l=>l*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:l=>l,fromKelvin:l=>l}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:l=>l*(5/9),fromKelvin:l=>l*(9/5)})});function L(l){if(N(l))return null;const r=String(l).trim();if(r==="")return null;for(const[n,i]of Object.entries($))if(r===n||r===i.symbol)return{key:n,scale:i};const t=r.toLowerCase();for(const[n,i]of Object.entries($))if(i.aliases.includes(t))return{key:n,scale:i};return null}function W(l,r,t){const n=L(r),i=L(t);return!n||!i||!Number.isFinite(Number(l))?null:n.key===i.key?Number(l):i.scale.fromKelvin(n.scale.toKelvin(Number(l)))}const Z=new Map;function H(l,r,t){const n=`${l||""}|${r}|${t}`;let i=Z.get(n);return i||(i=new Intl.NumberFormat(l||void 0,{minimumFractionDigits:r,maximumFractionDigits:t}),Z.set(n,i)),i}function U(l,r){const t=r||{},n=t.nullDisplay??"";if(N(l)||l==="")return n;const i=Number(l);if(!Number.isFinite(i))return n;const o=L(t.scale||"C");if(!o)return String(i);const c=L(t.display||t.scale||"C")||o,d=c.key===o.key?i:c.scale.fromKelvin(o.scale.toKelvin(i)),f=typeof t.decimals=="number"?t.decimals:null,h=f??t.minDecimals??0,g=f??t.maxDecimals??1;return`${H(t.locale,h,g).format(d)}${t.space??" "}${c.scale.symbol}`}const z=/^[+-]?[\d\s.,  ]*\d/;function F(l,r){const t=String(l).trim();if(t==="")return null;const n=new Intl.NumberFormat(r||void 0).formatToParts(1.1).find(d=>d.type==="decimal")?.value||".",i=n===","?".":",",o=t.split(i).join("").split(/[\s  ]/).join("").replace(n,"."),c=Number(o);return Number.isFinite(c)?c:null}function k(l,r){if(N(l))return null;const t=r||{},n=L(t.scale||"C");if(!n)return null;if(typeof l=="number")return Number.isFinite(l)?l:null;let i=String(l).trim();if(i==="")return null;let o=!1;i.startsWith("(")&&i.endsWith(")")&&(o=!0,i=i.slice(1,-1).trim());const c=z.exec(i);if(!c)return null;const d=F(c[0],t.locale);if(d===null)return null;const f=i.slice(c[0].length).trim();if(f==="")return o?-d:d;const h=L(f);if(!h)return null;const g=h.key===n.key?d:n.scale.fromKelvin(h.scale.toKelvin(d));return o?-g:g}function S(l){const r=Object.freeze({scale:"C",...l||{}}),n=(L(r.scale)||L("C")).scale.symbol,i=Object.freeze({...r,display:r.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),o=new Map([[r.locale||"",r]]),c=d=>{const f=d||"";let h=o.get(f);return h||(h=Object.freeze({...r,locale:d||void 0}),o.set(f,h)),h};return{base:"number",extends:"number",storage:"float64",temperatureConfig:r,format:d=>U(d.value,d.locale?c(d.locale):r),parse:d=>k(d.text,d.locale?c(d.locale):r),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:r.excel||`#,##0${typeof r.decimals=="number"&&r.decimals>0?`.${"0".repeat(r.decimals)}`:".#"}" ${n}"`,toStorage:d=>typeof d=="number"?Number.isFinite(d)?d:null:typeof d=="string"?k(d,r):N(d)?null:k(String(d),r),toClipboard:d=>U(d,i),fromClipboard:d=>k(d,r)}}const b=Object.freeze({celsius:S({scale:"C"}),fahrenheit:S({scale:"F"}),kelvin:S({scale:"K"})}),a=S}),Se("packages/core/src/columns/types/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const _=V("packages/core/src/internal/util.js"),N=_.isNil,$=_.warnOnce,L=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),W=Object.freeze({2:1,8:3,16:4}),Z=Object.freeze({2:"0b",8:"0o",16:"0x"}),H=Object.freeze({2:4,8:3,16:2}),U=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),z=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),F=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,S=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,b=Object.freeze([8,16,32,53]),a=new WeakSet,l=new WeakMap,r=new Map,t=new WeakMap,n=new WeakMap,i=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function o(P){if(P==null)return 16;const D=typeof P=="string"?P.toLowerCase():P,K=L[D];return K||($(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function c(P,D){return Math.ceil(P/W[D])}function d(P,D){if(!P)return D?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!D)return{min:0,max:2**P-1};const K=2**(P-1);return{min:-K,max:K-1}}function f(P){return z[P]||"hexadecimal"}function h(P){if(typeof P=="string"){const D=i[P];return D||$(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(i).join(", ")}`),{...D||{}}}if(P&&typeof P.preset=="string"){const D=i[P.preset];return D||$(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(i).join(", ")}`),{...D||{},...P}}return P||{}}function g(P){const D=h(P),K=o(D.radix),x=W[K];let I=null;if(D.bitWidth!==void 0&&D.bitWidth!==null&&D.bitWidth!==!1){const ie=Number(D.bitWidth);b.includes(ie)?I=ie:$(`radix:width:${String(D.bitWidth)}`,`unsupported bitWidth ${String(D.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let j=D.signed!==!1;!j&&I===null&&($("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),I=32);const T=D.prefix===void 0||D.prefix===!0?Z[K]:D.prefix===!1?"":String(D.prefix);let B=0;D.pad===!0?B=I?c(I,K):0:typeof D.pad=="number"&&D.pad>0&&(B=Math.floor(D.pad));let q=0;D.group===!0?q=H[K]:typeof D.group=="number"&&D.group>0&&(q=Math.floor(D.group));const X=d(I,j),Q=typeof D.min=="number"?Math.max(X.min,D.min):X.min,te=typeof D.max=="number"?Math.min(X.max,D.max):X.max,re=Object.freeze({radix:K,bits:x,prefix:T,uppercase:D.uppercase!==!1,pad:B,group:q,groupSeparator:typeof D.groupSeparator=="string"?D.groupSeparator:" ",bitWidth:I,signed:j,min:Q,max:te<Q?Q:te,nullDisplay:typeof D.nullDisplay=="string"?D.nullDisplay:"",name:f(K)});return a.add(re),re}function y(P){if(P&&a.has(P))return P;if(typeof P=="string"){let D=r.get(P);return D||(D=g(P),r.set(P,D)),D}if(P&&typeof P=="object"){let D=l.get(P);return D||(D=g(P),l.set(P,D)),D}return y("hex")}function p(P){return P<0?-Math.round(-P):Math.round(P)}function m(P,D,K){if(D<=0||P.length<=D)return P;const x=P.length%D||D,I=[P.slice(0,x)];for(let j=x;j<P.length;j+=D)I.push(P.slice(j,j+D));return I.join(K)}function w(P){const D=y(P),{radix:K,prefix:x,uppercase:I,pad:j,group:T,groupSeparator:B,signed:q,bitWidth:X,nullDisplay:Q}=D,te=X?2**X:0,re=ie=>{if(N(ie)||ie==="")return Q;const ae=typeof ie=="number"?ie:Number(ie);if(!Number.isFinite(ae))return Q;const ee=p(ae);let J="",se=ee;ee<0&&(q?(J="-",se=-ee):se=(ee%te+te)%te);let le=se.toString(K);return le=I?le.toUpperCase():le.toLowerCase(),j>0&&le.length<j&&(le=le.padStart(j,"0")),T>0&&(le=m(le,T,B)),J+x+le};return re.options=D,re}function v(P,D){const K=y(D);let x=t.get(K);return x||(x=w(K),t.set(K,x)),x(P)}function u(P){const D=y(P),{radix:K,groupSeparator:x,signed:I,min:j,max:T}=D,B=U[K],q=X=>{if(N(X))return{ok:!0,value:null,reason:"blank"};let Q=String(X);if(x&&x!==""&&(Q=Q.split(x).join("")),Q=Q.replace(k,""),Q==="")return{ok:!0,value:null,reason:"blank"};let te=!1;if((Q[0]==="-"||Q[0]==="+")&&(te=Q[0]==="-",Q=Q.slice(1)),Q==="")return{ok:!1,value:null,reason:"digits"};let re=null;for(const[ae,ee]of F){const J=ae.exec(Q);if(!J)continue;const se=Q.slice(J[0].length);if(se==="")break;if(!U[ee].test(se))return{ok:!1,value:null,reason:"digits"};re=parseInt(se,ee);break}if(re===null)if(B.test(Q))re=parseInt(Q,K);else if(S.test(Q))re=Number(Q);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(re))return{ok:!1,value:null,reason:"digits"};const ie=p(te?-re:re);return!I&&ie<0?{ok:!1,value:ie,reason:"negative"}:ie<j||ie>T?{ok:!1,value:ie,reason:"range"}:{ok:!0,value:ie,reason:"ok"}};return q.options=D,q}function s(P,D){const K=y(D);let x=n.get(K);return x||(x=u(K),n.set(K,x)),x(P)}function O(P,D){const K=s(P,D);return K.ok?K.value:null}function E(P,D){const K=N(P)||Number.isNaN(P)?null:Number(P),x=N(D)||Number.isNaN(D)?null:Number(D);return K===null?x===null?0:1:x===null||K<x?-1:K>x?1:0}function A(P){const D=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&D?"int32":"float64"}function M(P){const D=g(P),K=w(D),x=u(D);return{base:"number",extends:"number",storage:A(D),matches:null,format:I=>K(I.value),parse:I=>{const j=x(I.text);return j.ok?j.value:null},compare:E,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:I=>K(I),fromClipboard:I=>{const j=x(I);return j.ok?j.value:null},radix:D,formatValue:K,parseText:x}}const C=M}),Se("packages/core/src/columns/types/aggregable.js",function(e,V){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").isNil;function $(F){const k=[];for(const S of F||[]){if(N(S))continue;const b=Number(S);Number.isFinite(b)&&k.push(b)}return k}function L(F){return k=>{const S=$(k);if(!S.length)return null;let b=0;for(const a of S)b+=10**(a/F);return F*Math.log10(b)}}function W(F){return k=>{const S=$(k);if(!S.length)return null;let b=0;for(const a of S)b+=10**(a/F);return F*Math.log10(b/S.length)}}function Z(F,k){const S=k&&k.column,a=(S&&S.typeOptions||{}).weight,l=k&&k.valueAt;if(!a||typeof l!="function")return null;let r=0,t=0;for(let n=0;n<F.length;n++){if(N(F[n]))continue;const i=Number(F[n]);if(!Number.isFinite(i))continue;const o=l(a,n);if(N(o))continue;const c=Number(o);!Number.isFinite(c)||c<=0||(r+=i*c,t+=c)}return t===0?null:r/t}function H(F={}){const k=F.factor===20?20:10,S=typeof F.suffix=="string"?F.suffix:"",b=Number.isInteger(F.decimals)?F.decimals:1;return{base:"number",storage:"float64",name:F.name||"logarithmic",format:a=>{const l=a&&a.value;return N(l)||!Number.isFinite(Number(l))?"":`${Number(l).toFixed(b)}${S}`},parse:a=>{const l=String((a&&a.text)??"").replace(S,"").trim();if(!l)return null;const r=Number(l);return Number.isFinite(r)?r:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:L(k),avg:W(k)}}}}function U(F={}){const k=Number.isInteger(F.decimals)?F.decimals:1,S=F.percent===!0;return{base:"number",storage:"float64",name:F.name||"ratio",format:b=>{const a=b&&b.value;return N(a)||!Number.isFinite(Number(a))?"":S?`${Number(a).toFixed(k)}%`:Number(a).toFixed(k)},parse:b=>{const a=String((b&&b.text)??"").replace("%","").trim();if(!a)return null;const l=Number(a);return Number.isFinite(l)?l:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const z=Object.freeze({decibel:H({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:H({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:U({name:"ratio"}),percentRate:U({name:"percentRate",percent:!0})})}),Se("packages/core/src/columns/types/currency.js",function(e,V){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const N=V("packages/core/src/internal/util.js").isNil,$="⚠ no rate";function L(d){if(N(d))return null;const f=String(d).trim().toUpperCase();return f===""?null:f}function W(d){if(N(d))return null;if(typeof d=="object"&&!Array.isArray(d)){const f=Number(d.amount),h=L(d.code);return!h||!Number.isFinite(f)?null:{amount:f,code:h}}if(Array.isArray(d)&&d.length===2){const f=Number(d[0]),h=L(d[1]);return!h||!Number.isFinite(f)?null:{amount:f,code:h}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),H=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),U=/[+-]?[\d\s., ]*\d/;function z(d,f){const h=String(d).trim();if(h==="")return null;const g=new Intl.NumberFormat(f||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",y=g===","?".":",",p=h.split(y).join("").split(/[\s ]/).join("").replace(g,"."),m=Number(p);return Number.isFinite(m)?m:null}function F(d,f){const h=f||{},g=L(h.code);if(N(d))return null;const y=W(d);if(y)return y;if(typeof d=="number")return Number.isFinite(d)&&g?{amount:d,code:g}:null;let p=String(d).trim();if(p==="")return null;let m=!1;p.startsWith("(")&&p.endsWith(")")&&(m=!0,p=p.slice(1,-1).trim());let w=null;for(const[A,M]of Object.entries(Z)){if(p.startsWith(A)){w=M,p=p.slice(A.length).trim();break}if(p.endsWith(A)){w=M,p=p.slice(0,-A.length).trim();break}}const v=U.exec(p);if(!v)return null;const u=z(v[0],h.locale);if(u===null)return null;const s=(p.slice(0,v.index)+" "+p.slice(v.index+v[0].length)).trim();!w&&s!==""&&(w=L(s));const O=w||g;return O?{amount:m?-u:u,code:O}:null}function k(d,f){if(typeof d=="function")return(h,g)=>{if(h===g)return 1;const y=d(h,g);return typeof y=="number"&&Number.isFinite(y)&&y>0?y:null};if(d&&typeof d=="object"){const h=d;return(g,y)=>{if(g===y)return 1;const p=Number(h[g]),m=Number(h[y]);return!Number.isFinite(p)||!Number.isFinite(m)||p<=0||m<=0?null:m/p}}return(h,g)=>h===g?1:null}function S(d,f,h){if(!d)return null;if(d.code===f)return d.amount;const g=h(d.code,f);return g===null?null:d.amount*g}const b=new Map;function a(d,f,h){const g=`${d||""}|${f}|${h??""}`;let y=b.get(g);if(!y){const p={style:"currency",currency:f};typeof h=="number"&&(p.minimumFractionDigits=h,p.maximumFractionDigits=h);try{y={fmt:new Intl.NumberFormat(d||void 0,p),currency:!0}}catch{y={fmt:new Intl.NumberFormat(d||void 0,typeof h=="number"?{minimumFractionDigits:h,maximumFractionDigits:h}:{}),currency:!1}}b.set(g,y)}return y}function l(d,f){const h=f||{},g=h.nullDisplay??"",y=W(d);if(!y)return g;const p=L(h.display)||y.code;let m=y.amount,w=y.code;if(p!==y.code){const s=h.rateFn||k(h.rates,h.rateBase),O=S(y,p,s);if(O===null)return`${h.missingRate??$} ${y.code}→${p}`;m=O,w=p}const{fmt:v,currency:u}=a(h.locale,w,h.decimals);return u?v.format(m):`${v.format(m)} ${w}`}function r(d){const f=W(d);return f?`${f.amount} ${f.code}`:""}function t(d){const f=d||{},h=L(f.display),g=f.rateFn||k(f.rates,f.rateBase);return(y,p)=>{const m=W(y),w=W(p);if(!m&&!w)return 0;if(!m)return 1;if(!w)return-1;if(h){const v=S(m,h,g),u=S(w,h,g);if(v!==null&&u!==null)return v===u?0:v<u?-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 n(d){const f=d||{},h=(y,p)=>{const m=[];for(const O of y||[]){const E=W(O);E&&m.push(E)}if(!m.length)return null;if(new Set(m.map(O=>O.code)).size===1){const O=m[0].code;return{amount:p(m.map(E=>E.amount)),code:O}}const v=L(f.display);if(!v)return`${f.missingRate??$}: mixed currencies, no display currency set`;const u=f.rateFn||k(f.rates,f.rateBase),s=[];for(const O of m){const E=S(O,v,u);if(E===null)return`${f.missingRate??$}: ${O.code}→${v}`;s.push(E)}return{amount:p(s),code:v}},g=y=>y.reduce((p,m)=>p+m,0);return{sum:y=>h(y,g),avg:y=>h(y,p=>g(p)/p.length),min:y=>h(y,p=>Math.min(...p)),max:y=>h(y,p=>Math.max(...p))}}function i(d){const f=Object.freeze({code:"USD",...d||{}}),h=k(f.rates,f.rateBase),g=Object.freeze({...f,rateFn:h}),y=n(g),p=t(g),m=new Map([[f.locale||"",g]]),w=s=>{const O=s||"";let E=m.get(O);return E||(E=Object.freeze({...g,locale:s||void 0}),m.set(O,E)),E},v=H[L(f.display||f.code)]||"",u=typeof f.decimals=="number"&&f.decimals>0?`.${"0".repeat(f.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:g,format:s=>l(s.value,s.locale?w(s.locale):g),parse:s=>F(s.text,s.locale?w(s.locale):g),compare:p,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:y},excel:f.excel||(v?`"${v}"#,##0${u}`:`#,##0${u}`),toStorage:s=>{const O=W(s);return O||(typeof s=="string"||typeof s=="number"?F(s,g):null)},toClipboard:s=>r(s),fromClipboard:s=>F(s,g)}}const o=Object.freeze({currency:i({code:"USD"}),usd:i({code:"USD"}),eur:i({code:"EUR"}),gbp:i({code:"GBP"}),jpy:i({code:"JPY",decimals:0})}),c=i}),Se("packages/core/src/columns/types/index.js",function(e,V){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return A}});const _=V("packages/core/src/columns/types/temporal.js"),N=_.TEMPORAL_TYPES,$=V("packages/core/src/columns/types/network.js"),L=$.NETWORK_TYPES,W=V("packages/core/src/columns/types/structured.js"),Z=W.STRUCTURED_TYPES,H=V("packages/core/src/columns/types/unit.js"),U=H.createUnitType,z=H.UNIT_SYSTEMS,F=H.parseUnit,k=H.formatUnit,S=H.registerUnitSystem,b=H.unitSystemNames,a=H.unitsOf,l=H.defineUnit,r=V("packages/core/src/columns/types/engineering.js"),t=r.ENGINEERING_TYPES,n=V("packages/core/src/columns/types/si.js"),i=n.SI_TYPES,o=n.createSiType,c=n.createSiSystem,d=n.siUnits,f=n.SI_PREFIXES,h=V("packages/core/src/columns/types/temperature.js"),g=h.TEMPERATURE_TYPES,y=h.createTemperatureType,p=h.convertTemperature,m=h.formatTemperature,w=h.parseTemperature,v=h.TEMPERATURE_SCALES,u=V("packages/core/src/columns/types/radix.js"),s=u.createRadixType,O=u.RADIX_PRESETS,E=u.parseRadix,A=u.formatRadix,M=V("packages/core/src/columns/types/aggregable.js"),C=M.AGGREGABLE_TYPES,P=V("packages/core/src/columns/types/currency.js"),D=P.CURRENCY_TYPES,K=P.createCurrencyType,x=P.parseMoney,I=P.formatMoney,j=P.convertMoney,T=P.toMoney,B=P.rateFunction,q=P.moneyComparator,X=P.normaliseCode,Q=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return H.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return r.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return r.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return h.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return h.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return h.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return h.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return h.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return h.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return h.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return P.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return P.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return P.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return P.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return P.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return P.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return P.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return P.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return P.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return _.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return $.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return W.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return M.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return M.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return M.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return _.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return _.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return _.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return _.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return _.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return _.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return $.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return $.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return $.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return $.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return $.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return $.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return $.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return $.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return $.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return $.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return $.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return W.summariseJson}});const te=Object.freeze({...N,...L,...Z,...C,hex:s(O.hex),hex8:s(O.hex8),hex16:s(O.hex16),hex32:s(O.hex32),binary:s(O.binary),binary8:s(O.binary8),octal:s(O.octal),bytes:U({system:"data",unit:"B",display:"auto"}),megabytes:U({system:"data",unit:"MB"}),gigabytes:U({system:"data",unit:"GB"}),bitrate:U({system:"bitrate",unit:"Mbps"}),gigabits:U({system:"bitrate",unit:"Gbps"}),...t,...i,...g,...D});{const re=new Set;for(const ie of[N,L,Z,C,t,i,g,D])for(const ae of Object.keys(ie)){if(re.has(ae))throw new Error(`[lattice] data type "${ae}" is declared twice`);re.add(ae)}}}),Se("packages/core/src/columns/datatypes.js",function(e,V){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return C}});const _=V("packages/core/src/internal/util.js"),N=_.collator,$=_.defaultCompare,L=_.isNil,W=_.isObject,Z=_.isFunction,H=_.fail,U=_.titleCase,z=V("packages/core/src/format/date.js"),F=z.toDate,k=z.toIsoDate,S=z.compareIso,a=V("packages/core/src/format/boolean.js").toTriState,r=V("packages/core/src/columns/types/index.js").EXTENDED_TYPES,t=V("packages/core/src/formula/index.js"),n=t.evaluateFormula,i=t.looksLikeFormula,o=/^\d{4}-\d{2}-\d{2}$/;function c(P){return P.getHours()===0&&P.getMinutes()===0&&P.getSeconds()===0&&P.getMilliseconds()===0}const d=new Map;function f(P){const D=P||"",K=d.get(D);if(K)return K;const x={group:",",decimal:"."};try{for(const I of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))I.type==="group"?x.group=I.value:I.type==="decimal"&&(x.decimal=I.value)}catch{}return d.set(D,x),x}const h=/\d\s*[*/^]\s*[\d.(]/;function g(P,D){if(L(P))return null;let K=String(P).trim();if(K===""||K.startsWith("=")||h.test(K))return null;let x=1;K.startsWith("(")&&K.endsWith(")")&&(x=-1,K=K.slice(1,-1));const I=K.endsWith("%"),{group:j,decimal:T}=f(D);if(K=K.replace(/[\s\u00a0\u202f\u2009']/g,""),j&&j!=="."&&j!==","&&(K=K.split(j).join("")),K=K.replace(/[^0-9eE+\-.,]/g,""),T===","?K=K.split(".").join("").replace(",","."):K=K.split(",").join(""),K===""||K==="-"||K==="+")return null;const B=Number(K);return Number.isNaN(B)?null:x*(I?B/100:B)}function y(P,D){const K=L(P)||Number.isNaN(P)?null:Number(P),x=L(D)||Number.isNaN(D)?null:Number(D);return K===null?x===null?0:1:x===null||K<x?-1:K>x?1:0}function p(P,D){const K=a(P),x=a(D);return K===null?x===null?0:1:x===null?-1:K===x?0:K?1:-1}function m(P,D){const K=F(P),x=F(D);if(!K)return x?1:0;if(!x)return-1;const I=K.getTime(),j=x.getTime();return I<j?-1:I>j?1:0}const w=new Map;function v(P){const D=F(P.value);if(!D)return"";const K=P.locale||"";let x=w.get(K);return x||(x=new Intl.DateTimeFormat(P.locale||void 0,{dateStyle:"medium"}),w.set(K,x)),x.format(D)}const u={boolean:{base:"boolean",storage:"bitset",matches:P=>typeof P=="boolean",parse:P=>a(P.text),compare:p,format:P=>a(P.value)===null?"":a(P.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:P=>a(P)===null?"":String(a(P)),fromClipboard:P=>a(P)},number:{base:"number",storage:"float64",matches:P=>typeof P=="number"&&!Number.isNaN(P),parse:P=>{if(i(P.text)){const D=n(P.text,P);if(!D.ok)return null;const K=Number(D.value);return Number.isFinite(K)?K:null}return g(P.text,P.locale)},compare:y,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:P=>L(P)?"":String(P),fromClipboard:(P,D)=>g(P,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&o.test(P)&&!Number.isNaN(Date.parse(P))||P instanceof Date&&!Number.isNaN(P.getTime())&&c(P),parse:P=>k(P.text),compare:S,format:v,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>k(P),toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>k(P)},dateString:{base:"dateString",storage:"dictionary",matches:P=>typeof P=="string"&&o.test(P)&&!Number.isNaN(Date.parse(P)),parse:P=>k(P.text),compare:S,format:v,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:P=>k(P),toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>k(P)},text:{base:"text",storage:"dictionary",matches:P=>typeof P=="string",parse:P=>P.text===""?null:String(P.text),compare:(P,D)=>L(P)?L(D)?0:1:L(D)?-1:N().compare(String(P),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>P},image:{base:"text",storage:"dictionary",parse:P=>P.text===""||P.text==null?null:String(P.text).trim(),compare:(P,D)=>L(P)?L(D)?0:1:L(D)?-1:N().compare(String(P),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>P},lookup:{base:"text",storage:"dictionary",parse:P=>{if(P.text===""||P.text==null)return null;const D=P.column&&P.column.lookup,K=D&&Z(D.options)?D.options():null;if(!K)return P.text;const x=String(P.text),I=K.find(B=>String(B.id)===x);if(I)return I.id;const j=x.trim().toLowerCase(),T=K.find(B=>String(B.label).toLowerCase()===j);return T?T.id:P.text},compare:$,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:P=>L(P)?"":String(P),fromClipboard:P=>P},object:{base:"object",storage:"object",matches:P=>P!==null&&typeof P=="object"&&!(P instanceof Date),parse:P=>{try{return P.text===""?null:JSON.parse(P.text)}catch{return P.text}},compare:(P,D)=>$(P,D),format:P=>{const D=P.value;if(L(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:P=>L(P)?"":typeof P=="string"?P:JSON.stringify(P),fromClipboard:P=>P}},s=["boolean","number","date","dateString","datetime","text","object"];function O(P,D,K,x){const I=K.get(P);if(I)return I;x.includes(P)&&H(`circular data type extends chain: ${[...x,P].join(" → ")}`);const j=D[P];j||H(`unknown data type "${P}"`);let T=null;j.extends&&(T=O(j.extends,D,K,[...x,P]));const B={...T||{},...j,name:P,defaults:{...T&&T.defaults||{},...j.defaults||{}}};return B.base||(B.base=T&&T.base||"text"),B.storage||(B.storage=T&&T.storage||"object"),K.set(P,B),B}function E(P,D){const K={...u,...r};if(D&&typeof D.dataType=="function"&&Array.isArray(D.dataTypeNames))for(const I of D.dataTypeNames()){const j=D.dataType(I);j&&(K[I]=j)}if(W(P))for(const[I,j]of Object.entries(P))K[I]=j;const x=new Map;for(const I of s)O(I,K,x,[]);O("lookup",K,x,[]);for(const I of Object.keys(K))O(I,K,x,[]);return x}function A(P,D){if(P.base==="text"&&(!P.compare||P.compare===u.text.compare)){const K=N(D);return(x,I)=>L(x)?L(I)?0:1:L(I)?-1:K.compare(String(x),String(I))}return P.compare||$}function M(P,D){return D?P.multiStorage||"multi":P.storage||"object"}function C(P){return U(String(P).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Se("packages/core/src/columns/infer.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Z}});const _=V("packages/core/src/internal/util.js"),N=_.infoOnce,$=_.isNil,L=100;function W(H,U,z={}){const F=z.sampleSize??L,k=[];for(let S=0;S<H.length&&k.length<F;S++){const b=H[S];$(b)||typeof b=="number"&&Number.isNaN(b)||k.push(b)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[S,b]of U){if(typeof b.matches!="function")continue;let a=!0;for(let l=0;l<k.length;l++)if(!b.matches(k[l])){a=!1;break}if(a)return{type:S,unanimous:!0,sampled:k.length}}return z.quiet||N(`infer:${z.colId||"?"}`,`column "${z.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:k.length}}function Z(H,U,z,F,k={}){const S=k.sampleSize??L,b=[];for(let a=0;a<U.length&&b.length<S;a++){const l=z(U[a]);$(l)||typeof l=="number"&&Number.isNaN(l)||b.push(l)}return W(b,F,{...k,colId:H}).type}}),Se("packages/core/src/columns/graph.js",function(e,V){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return F}});const _=V("packages/core/src/internal/util.js"),N=_.DEV,$=_.fail,L=_.isFunction,W=_.warnOnce,Z="*";function H(k){const S=k.value||{};if(!L(S.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const a=S.pure!==!1;return S.deps===Z?{computed:!0,wholeRow:!0,deps:[],pure:a}:Array.isArray(S.deps)?{computed:!0,wholeRow:!1,deps:S.deps.slice(),pure:a}:(W(`deps:missing:${k.id}`,`computed column "${k.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:a})}function U(k){const S=new Map;for(const h of k)S.set(h.id,h);const b=new Map,a=new Map,l=new Set,r=new Set,t=new Set,n=new Set;for(const h of k){const g=H(h);if(!g.computed){b.set(h.id,[]);continue}r.add(h.id),(g.pure?t:n).add(h.id),g.wholeRow&&l.add(h.id);const y=[],p=[];for(const m of g.deps)(S.has(m)?y:p).push(m);b.set(h.id,y),p.length&&a.set(h.id,p)}for(const h of t)for(const g of b.get(h))n.has(g)&&$(`pure computed column "${h}" depends on impure column "${g}". Mark it \`value.pure: false\` or make the dependency pure.`);const i=[],o=new Map,c=[],d=h=>{const g=o.get(h);if(g!=="done"){if(g==="open"){const y=c.indexOf(h);$(`circular column dependency: ${[...c.slice(y),h].join(" → ")}`)}o.set(h,"open"),c.push(h);for(const y of b.get(h)||[])S.has(y)&&d(y);c.pop(),o.set(h,"done"),i.push(h)}};for(const h of k)d(h.id);const f=new Map;for(const h of k)f.set(h.id,[]);for(const h of k)for(const g of b.get(h.id)||[]){const y=f.get(g);y&&!y.includes(h.id)&&y.push(h.id)}if(l.size)for(const h of k){if(r.has(h.id))continue;const g=f.get(h.id);for(const y of l)g.includes(y)||g.push(y)}return{order:i,dependents:f,pure:t,impure:n,computed:r,deps:b,wholeRow:l,external:a,index:S}}function z(k,S){const b=Array.isArray(S)?S:[S],a=new Set,l=[...b];for(;l.length;){const r=l.shift();for(const t of k.dependents.get(r)||[])a.has(t)||(a.add(t),l.push(t))}for(const r of b)a.delete(r);return k.order.filter(r=>a.has(r))}function F(k,S,b){if(!N)return k;const a=S instanceof Set?S:new Set(S);return new Proxy(k,{get(l,r){return typeof r=="string"&&!a.has(r)&&!Object.hasOwn(l,r)&&W(`undeclared:${b}:${r}`,`computed column "${b}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),l[r]}})}}),Se("packages/core/src/columns/lookup.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return b}});const _=V("packages/core/src/internal/util.js"),N=_.collator,$=_.defaultCompare,L=_.isFunction,W=_.isNil,Z=_.warnOnce,H=", ",U="";function z(a,l,r,t){if(a===null||typeof a!="object")return{id:a,label:a==null?"":String(a)};const n=a[l],i=a[r],o={id:n,label:i==null?String(n??""):String(i)};a.disabled&&(o.disabled=!0),a.variant&&(o.variant=a.variant),a.icon&&(o.icon=a.icon);const c=t?a[t]:a.group;return c!==void 0&&(o.group=c),o}function F(a,l,r=0,t=[],n=[]){for(const i of a||[]){const o=i&&typeof i=="object"?i[l]:null;if(n.push({raw:i,depth:r,path:t}),Array.isArray(o)&&o.length){const c=String(i&&typeof i=="object"?i.label??i.name??i.id??"":i);F(o,l,r+1,[...t,c],n)}}return n}class k{#e;#t;#n;#r;#o=[];#i=new Map;#a=new Map;#s=0;#l="idle";#u=null;#c;constructor(l,r={}){this.#e=l||{},this.#t=r.colId||"?",this.#n=r.locale,this.#r=r.onChange||null,this.#c=N(this.#n),Array.isArray(this.#e.options)?this.#d(this.#e.options):this.#e.options===void 0&&(this.#l="ready")}get colId(){return this.#t}get version(){return this.#s}get state(){return this.#l}get ready(){return this.#l==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??H}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(l){this.#n=l,this.#c=N(l)}#d(l){const r=this.#e,t=r.valueKey||"id",n=r.labelKey||"label",i=r.childrenKey||"children";this.#o=F(l,i).map(o=>{const c=z(o.raw,t,n,r.groupKey);return o.depth&&(c.depth=o.depth,c.path=o.path),c}),this.#i=new Map,this.#a=new Map,this.#o.forEach((o,c)=>{this.#i.set(o.id,o),this.#a.set(o.id,c)}),this.#l="ready",this.#s+=1}load(){if(this.#u)return this.#u;const l=this.#e.options;if(Array.isArray(l)||l===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(!L(l))return Z(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array or a function`),this.#l="ready",this.#u=Promise.resolve([]),this.#u;this.#l="loading";let r;try{r=l()}catch(t){return this.#l="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),this.#u=Promise.resolve([]),this.#u}return!r||!L(r.then)?(this.#d(r),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=r.then(t=>(this.#d(t),this.#r&&this.#r(this),this.#o),t=>(this.#l="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#d(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}search(l,r){const t=this.#e;if(!L(t.search)){const o=String(l||"").toLowerCase();return Promise.resolve(o===""?this.#o:this.#o.filter(c=>c.label.toLowerCase().includes(o)))}const n=t.valueKey||"id",i=t.labelKey||"label";return Promise.resolve(t.search(l,r)).then(o=>(o||[]).map(c=>z(c,n,i,t.groupKey)))}option(l){return this.#i.get(l)}has(l){return this.#i.has(l)}label(l){if(W(l)||l==="")return"";const r=this.#i.get(l);if(r)return r.label;if(this.#l==="loading"||this.#l==="idle")return"";this.allowCustom||Z(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(l)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const t=this.#e.unknownLabel;return L(t)?String(t(l)??""):typeof t=="string"?t:String(l)}text(l){if(this.multiple){const r=S(l);return r.length===0?"":r.map(t=>this.label(t)).join(this.separator)}return this.label(l)}dictionary(){return this.#o.map(l=>l.id)}sorted(){const l=this.sortBy;if(l==="optionOrder"||l==="count")return this.#o.slice();if(l==="value")return this.#o.slice().sort((t,n)=>$(t.id,n.id));const r=this.#c;return this.#o.slice().sort((t,n)=>r.compare(t.label,n.label))}comparator(){const l=this.sortBy,r=this.multiple,t=this.#c,n=this.#a;if(r&&l==="count")return(o,c)=>S(o).length-S(c).length;const i=r?o=>S(o)[0]:o=>o;return l==="value"?(o,c)=>$(i(o),i(c)):l==="optionOrder"?(o,c)=>{const d=n.has(i(o))?n.get(i(o)):Number.MAX_SAFE_INTEGER,f=n.has(i(c))?n.get(i(c)):Number.MAX_SAFE_INTEGER;return d-f}:(o,c)=>{const d=i(o),f=i(c);return W(d)?W(f)?0:1:W(f)?-1:t.compare(this.label(d),this.label(f))}}groupKey(l){return this.multiple?S(l).map(t=>String(t)).sort().join(U):W(l)?"":String(l)}countValues(l){return this.multiple?S(l).length:W(l)?0:1}contains(l,r,t){const n=this.multiple?S(l):W(l)?[]:[l],i=Array.isArray(r)?r:[r];switch(t){case"containsAll":return i.every(o=>n.includes(o));case"containsNone":return!i.some(o=>n.includes(o));default:return i.some(o=>n.includes(o))}}exportText(l,r="label"){return r==="value"?this.multiple?S(l).join(this.separator):W(l)?"":String(l):this.text(l)}exportColumns(){const l=this.multiple;return this.#o.map(r=>({id:r.id,label:r.label,has:t=>l?S(t).includes(r.id):t===r.id}))}}function S(a){return Array.isArray(a)?a:W(a)||a===""?[]:[a]}function b(a,l={}){const r=a.lookup;if(!r)return null;const t=new k(r,{colId:a.id,locale:l.locale,onChange:l.onChange});return!Array.isArray(r.options)&&r.options!==void 0&&t.load(),t}}),Se("packages/core/src/columns/value.js",function(e,V){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return b}});const _=V("packages/core/src/internal/util.js"),N=_.getPath,$=_.isFunction,L=_.isNil,W=_.Lru,Z=_.warnOnce,U=V("packages/core/src/columns/graph.js").depsProxy,z="\0";function F(t,n={}){const i=n.locale,o=n.grid??null,c=n.context,d=t.value&&t.value.format,f=t.formatter||null,h=t.dataType&&t.dataType.format,g=t.lookup||null,y=(p,m,w)=>({value:p,data:w,row:m,column:t,colId:t.id,grid:o,context:c,locale:i});if($(d))return(p,m,w)=>{const v=d(y(p,m,w));return v==null?"":String(v)};if(f){if(g){const p=f.kind==="text";return(m,w,v)=>f(p?g.text(m):m,y(m,w,v))}return(p,m,w)=>f(p,y(p,m,w))}return $(h)?(p,m,w)=>{const v=h(y(p,m,w));return v==null?"":String(v)}:g?p=>g.text(p):p=>L(p)?"":typeof p=="string"?p:String(p)}function k(t,n){!t||!t.value||t.value.pure!==!1||Z(`impure:${n}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class S{#e;#t;#n;#r;#o;#i;#a=new W(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(i=>[i.id,i])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#o=n.rowKey||b}get graph(){return this.#t}setGraph(n){this.#t=n,this.#a.clear()}beginPass(){this.#a.clear()}endPass(){this.#a.clear()}invalidate(n){if(this.#a.size===0)return;const i=n&&n.rows?new Set([...n.rows].map(String)):null,o=n&&n.columns?[...n.columns]:null;if(!i&&!o){this.#a.clear();return}const c=o?this.#s(o):null;for(const d of[...this.#a.keys()]){const f=String(d).split(z);f.length===3&&(i&&!i.has(f[0])||c&&!c.has(f[2])||this.#a.delete(d))}}#s(n){const i=new Set,o=this.#t,c=[...n];for(;c.length;){const d=c.pop();if(!i.has(d)){i.add(d);for(const f of o?o.dependents.get(d)||[]:[])c.push(f)}}return i}value(n,i,o){const c=typeof n=="string"?this.#e.get(n):n;if(!c)return;if(!c.computed)return this.#u(c,i,o);if(c.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(c.id))return this.#i.get(c.id,o.physical);if(c.volatile)return this.compute(c,i,o);if(c.value.pure===!1)return this.compute(c,i,o);const d=`${this.#l(i,o)}${z}${c.id}`;if(this.#a.has(d))return this.#a.get(d);const f=this.compute(c,i,o);return this.#a.set(d,f),f}#l(n,i){return`${this.#o(n,i)}${z}${a(n)}`}#u(n,i,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,o.physical);if(n.field)return n.read?n.read(i):N(i,n.field)}compute(n,i,o){const c=this.#t,d=c&&c.wholeRow.has(n.id);let f;if(d)f=i??{};else{f={};const g=c&&c.deps.get(n.id)||[];for(const p of g)f[p]=this.value(p,i,o);const y=c&&c.external.get(n.id)||[];for(const p of y)f[p]=N(i,p);f=U(f,[...g,...y],n.id)}const h={data:i,row:o,column:n,grid:this.#n,context:this.#r};return n.value.compute(f,h)}values(n,i){const o={},c=this.#t?this.#t.order:[...this.#e.keys()];for(const d of c)o[d]=this.value(d,n,i);return o}text(n,i,o){const c=typeof n=="string"?this.#e.get(n):n;return c?c.formatValue(this.value(c,i,o),o,i):""}key(n,i,o){const c=typeof n=="string"?this.#e.get(n):n;if(!c)return"";const d=this.value(c,i,o);return $(c.value.key)?String(c.value.key(this.#c(c,d,i,o))):c.lookup?c.lookup.groupKey(d):L(d)?"":String(d)}quickFilterText(n,i,o){const c=typeof n=="string"?this.#e.get(n):n;if(!c)return"";if($(c.value.quickFilterText)){const d=this.value(c,i,o);return String(c.value.quickFilterText(this.#c(c,d,i,o))??"")}return this.text(c,i,o)}#c(n,i,o,c){return{value:i,data:o,row:c,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,i,o,c){const d=typeof n=="string"?this.#e.get(n):n;if(!d)return i;const f={text:i,value:this.value(d,o,c),data:o,row:c,column:d,grid:this.#n,context:this.#r,locale:this.#n&&$(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&$(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return $(d.value.parse)?d.value.parse(f):d.dataType&&$(d.dataType.parse)?d.dataType.parse(f):i}validate(n,i,o,c,d){const f=typeof n=="string"?this.#e.get(n):n;if(!f||!$(f.edit.validate))return!0;const h=f.edit.validate({value:i,oldValue:o,data:c,row:d,column:f,grid:this.#n,context:this.#r});return h===!0||h===void 0?!0:String(h)}apply(n,i,o,c){const d=typeof n=="string"?this.#e.get(n):n;if(!d)return!1;const f=this.value(d,o,c);if($(d.value.apply)){const h=d.value.apply({value:i,oldValue:f,data:o,row:c,column:d,grid:this.#n,context:this.#r});return this.#d(d,o,c),h!==!1}return d.field?f===i?!1:(d.write(o,i),this.#d(d,o,c),!0):(Z(`apply:${d.id}`,`column "${d.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,i,o,c){const d=typeof n=="string"?this.#e.get(n):n;if(!d)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const f=this.value(d,o,c),h=this.parse(d,i,o,c),g=this.validate(d,h,f,o,c);if(g!==!0)return{ok:!1,value:h,oldValue:f,changed:!1,error:g};const y=this.apply(d,h,o,c);return{ok:!0,value:h,oldValue:f,changed:y}}#d(n,i,o){if(this.#a.size===0)return;const c=this.#l(i,o);this.#a.delete(`${c}${z}${n.id}`);for(const d of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#a.delete(`${c}${z}${d}`)}}function b(t,n){return n&&n.key!=null?String(n.key):a(t)}function a(t){if(t&&typeof t=="object"){let n=l.get(t);return n===void 0&&(n=`#${r++}`,l.set(t,n)),n}return String(t)}const l=new WeakMap;let r=0}),Se("packages/core/src/model/shadow.js",function(e,V){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return f}});const N=V("packages/core/src/internal/util.js").warnOnce,$=2e5,L=20,W=1e3,Z=50;function H(h){return Math.min(W,Math.max(Z,Math.floor(h)))}const U=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"]),z=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),F=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),k=.6745,S=3.5,b=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),a=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),l=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function r(h,g){if(!g)return null;const y=Number.isFinite(Number(g.lower))?Number(g.lower):null,p=Number.isFinite(Number(g.upper))?Number(g.upper):null;if(y===null&&p===null||!Number.isFinite(h))return null;if(y!==null&&h<y||p!==null&&h>p)return b.FAIL;const m=Number.isFinite(Number(g.warnLower))?Number(g.warnLower):null,w=Number.isFinite(Number(g.warnUpper))?Number(g.warnUpper):null;return m!==null&&h<m||w!==null&&h>w?b.WARN:b.PASS}function t(h,g,y){if(!g||typeof g!="object")return null;if(g.kind!=="time")return g.kind!==void 0&&N(`shadow.history.window.kind:${h}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${g.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const p=g.minutes!=null?Number(g.minutes)*6e4:Number(g.span);if(!(p>0))return N(`shadow.history.window.span:${h}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const m=Math.max(2,Math.floor(y)||L);return{span:p,bucketMs:Math.max(1,Math.floor(p/m))}}class n{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#a=new Map;#s=0;#l;#u;#c;#d;#h=new Map;#f=null;#m=null;#p=null;constructor(g){this.#e=g.colId,this.#l=Math.max(2,g.depth||L),this.#u=Math.max(1,g.max||$),this.#c=g.now||(()=>Date.now()),this.#d=t(this.#e,g.historyWindow,this.#l),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#s}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(g,y){const p=d(y);if(p===null)return;if(!this.#n.has(g)){this.#m=null,this.#p=null,this.#g(),this.#t.set(g,p),this.#n.set(g,p),this.#r.set(g,0),this.#o.set(g,this.#c()),this.#i.set(g,[p]),this.#d&&this.#h.set(g,[p]),this.#a.set(g,0);return}const m=this.#n.get(g);if(m===p)return;this.#m=null,this.#p=null,this.#n.set(g,p),this.#r.set(g,(this.#r.get(g)||0)+1),this.#o.set(g,this.#c());const w=this.#i.get(g)||[];w.push(p),w.length>this.#l&&w.splice(0,w.length-this.#l),this.#i.set(g,w);const v=Math.sign(p-m),u=this.#a.get(g)||0;this.#a.set(g,Math.sign(u)===v?u+v:v)}#g(){if(this.#n.size<this.#u)return;const g=this.#n.keys().next().value;g!==void 0&&(this.#t.delete(g),this.#n.delete(g),this.#r.delete(g),this.#o.delete(g),this.#i.delete(g),this.#h.delete(g),this.#a.delete(g),this.#s++)}rebase(){for(const[g,y]of this.#n)this.#t.set(g,y);this.#m=null,this.#p=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#a.clear(),this.#s=0,this.#m=null,this.#p=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(g){const y=g instanceof Set?g:new Set(g);let p=0;for(const m of[...this.#n.keys()])y.has(m)||(this.#t.delete(m),this.#n.delete(m),this.#r.delete(m),this.#o.delete(m),this.#i.delete(m),this.#h.delete(m),this.#a.delete(m),p++);return p&&(this.#m=null,this.#p=null),p}advanceHistoryWindow(g=this.#c()){const y=this.#d;if(!y)return 0;const p=Math.floor(g/y.bucketMs),m=p-this.#f;if(!(m>0))return 0;const w=Math.min(m,this.#l);for(const[v,u]of this.#h){const s=this.#n.get(v);for(let O=0;O<w;O++)u.push(s);u.length>this.#l&&u.splice(0,u.length-this.#l)}return this.#f=p,m}read(g,y,p,m){switch(g){case"updates":return this.#r.has(y)?this.#r.get(y):0;case"updatedAt":{const w=this.#o.get(y);return w===void 0?null:new Date(w)}case"sinceUpdate":{const w=this.#o.get(y);return w===void 0?null:this.#c()-w}case"firstValue":return this.#t.has(y)?this.#t.get(y):null;case"delta":return this.#n.has(y)?this.#n.get(y)-this.#t.get(y):null;case"deltaPercent":{if(!this.#n.has(y))return null;const w=this.#t.get(y);return w?(this.#n.get(y)-w)/Math.abs(w)*100:null}case"rate":{const w=this.#i.get(y),v=this.#o.get(y);if(!w||w.length<2||v===void 0)return null;const u=this.#c()-v,s=w[w.length-1]-w[w.length-2];return u>0?s/u*1e3:s}case"history":return this.#d?this.#h.has(y)?[...this.#h.get(y)]:null:this.#i.has(y)?[...this.#i.get(y)]:null;case"streak":return this.#a.has(y)?this.#a.get(y):0;case"specStatus":return this.#n.has(y)?r(this.#n.get(y),m):null;default:return a.includes(g)?this.#b(g,y,p,m):null}}#v(g){if(g){if(this.#p&&this.#p.only===g)return this.#p.view;const y=this.#y(g);return this.#p={only:g,view:y},y}return this.#m?this.#m:(this.#m=this.#y(null),this.#m)}#y(g){const y=[];for(const[M,C]of this.#n)g&&!g.has(M)||y.push(C);const p=y.sort((M,C)=>M-C);let m=0,w=0,v=0,u=0;for(const M of p){u+=M,m++;const C=M-w;w+=C/m,v+=C*(M-w)}const s=[];for(const[M,C]of this.#t)g&&!g.has(M)||s.push(C);const O=m?i(p):0,E=p.map(M=>Math.abs(M-O)).sort((M,C)=>M-C),A=m?i(E):0;return{sorted:p,baseline:s.sort((M,C)=>M-C),sum:u,mean:m?w:0,sd:m>1?Math.sqrt(v/(m-1)):0,median:O,mad:A}}#b(g,y,p,m){if(!this.#n.has(y)||p&&!p.has(y))return null;const w=this.#n.get(y),v=this.#v(p),u=v.sorted.length;if(!u)return null;switch(g){case"rank":return u-c(v.sorted,w)+1;case"rankAsc":return o(v.sorted,w)+1;case"rankChange":{if(!this.#t.has(y)||!v.baseline.length)return null;const s=v.baseline.length-c(v.baseline,this.#t.get(y))+1,O=u-c(v.sorted,w)+1;return s-O}case"percentile":return c(v.sorted,w)/u*100;case"quartile":{const s=c(v.sorted,w)/u;return Math.min(4,Math.max(1,Math.ceil(s*4)))}case"zScore":return v.sd?(w-v.mean)/v.sd:null;case"anomalyScore":return v.mad?k*(w-v.median)/v.mad:null;case"anomalyFlag":{if(!v.mad)return null;const s=m&&Number.isFinite(Number(m.threshold))?Number(m.threshold):S;return Math.abs(k*(w-v.median)/v.mad)>s}case"shareOfTotal":return v.sum?w/v.sum*100:null;default:return null}}}function i(h){const g=h.length;if(!g)return 0;const y=(g-1)*.5,p=Math.floor(y),m=Math.ceil(y);return p===m?h[p]:h[p]+(y-p)*(h[m]-h[p])}function o(h,g){let y=0,p=h.length;for(;y<p;){const m=y+p>>1;h[m]<g?y=m+1:p=m}return y}function c(h,g){let y=0,p=h.length;for(;y<p;){const m=y+p>>1;h[m]<=g?y=m+1:p=m}return y}function d(h){if(h==null||h==="")return null;if(h instanceof Date){const y=h.getTime();return Number.isFinite(y)?y:null}const g=typeof h=="number"?h:Number(h);return Number.isFinite(g)?g:null}function f(h){const g=[];for(const y of h||[]){const p=y.shadow;if(!p)continue;const m=typeof p=="string"?{kind:p}:p,w=m.kind;U.includes(w)&&(z.includes(w)||F.includes(w)||g.push({colId:y.id||y.field,of:m.of||y.field||y.id,kind:w,depth:m.depth,historyWindow:w==="history"?m.window:void 0}))}return g}}),Se("packages/core/src/columns/model.js",function(e,V){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ie}});const _=V("packages/core/src/internal/util.js"),N=_.expand,$=_.fail,L=_.getPath,W=_.humanise,Z=_.isFunction,H=_.isObject,U=_.merge,z=_.pathGetter,F=_.pathSetter,k=_.toArray,S=_.uid,b=_.warnOnce,l=V("packages/core/src/format/index.js").compileFormat,r=V("packages/core/src/columns/datatypes.js"),t=r.comparatorFor,n=r.createTypeRegistry,i=r.storageKind,o=V("packages/core/src/columns/infer.js"),c=o.inferColumnType,d=o.DEFAULT_SAMPLE,f=V("packages/core/src/columns/graph.js"),h=f.buildGraph,g=f.affectedBy,p=V("packages/core/src/columns/lookup.js").createLookup,m=V("packages/core/src/columns/value.js"),w=m.compileDisplay,v=m.ValuePipeline,u=m.warnImpureUse,O=V("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,E={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},A={centre:"center"},M=new Set(["start","center","end","left","right"]);function C(ee){if(typeof ee!="string")return;const J=ee.toLowerCase();return A[J]?A[J]:M.has(J)?J:void 0}function P(ee){if(typeof ee!="string")return;const J=ee.toLowerCase();return J==="center"||J==="centre"?"middle":J==="top"||J==="middle"||J==="bottom"?J:void 0}const D=["cell","layout","header"];function K(ee){if(!H(ee))return{};const J={...ee},se=(le,oe)=>{if(ee[le]===void 0)return;const he=N(ee[le],oe);he&&D.includes(le)&&!H(ee[le])&&delete he.enabled,J[le]=he};return se("sort","direction"),se("filter","type"),se("cell","render"),se("edit","editor"),se("layout","width"),se("group","index"),se("pivot","index"),se("header","render"),se("facet","strategy"),J}function x(ee,J){const se={...ee||{}},le=H(J)&&H(J.layout)&&J.layout.width!==void 0;return se.fit==="content"&&!le&&delete se.width,se}const I=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","edit","export","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","validation","value","verticalAlign"]),j=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function T(ee,J,se,le){const oe=se==="columnGroup"?"column group":"column";for(const he of Object.keys(ee))J.has(he)||b(`${se}.unknown:${he}`,`'${he}' is not a configuration key this grid recognises, so it had no effect on ${oe} "${le}". Check the spelling against the reference.`)}function B(ee){const J=ee.defaults||{},se={};return J.align&&(se.align=J.align,se.cell={align:J.align},se.header={align:J.align}),J.filter&&(se.filter=J.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:J.filter}),J.editor&&(se.edit=J.editor==="none"?{editor:null}:{editor:J.editor}),J.total&&(se.total=J.total),J.render&&(se.cell={...se.cell||{},render:J.render}),ee.export&&(se.export={...ee.export}),se}function q(ee){if(typeof ee=="string")return ee.trim()?[ee.trim()]:[];if(!Array.isArray(ee))return[];const J=[];for(const se of ee){if(typeof se!="string")continue;const le=se.trim();le&&!J.includes(le)&&J.push(le)}return J}class X{#e=new Map;#t=[];#n=[];#r;#o;#i;#a;#s;#l;#u(J,se,le){const oe=this.#c(J,se,le);if(typeof oe!="string"||!this.#d)return oe??null;const he=se&&se.totals&&se.totals.implement;if(he&&Z(he[oe])){const ve=he[oe];return ve.totalName=oe,ve}const fe=this.#d.totalFn?.(oe);return Z(fe)?fe:oe}#c(J,se,le){if(typeof J!="string")return J;const oe=se&&se.totals&&se.totals.supported;if(!Array.isArray(oe)||oe.includes(J))return J;const he=oe.length?oe.join(", "):"none";return $(`column "${le}" is typed ${se.name||"a type"}, for which the total "${J}" is not meaningful. Supported: ${he}. Aggregating it anyway would produce a confident wrong number.`),J}#d;#h;#f;#m;#p;#g;#v=!1;#y;#b;constructor(J={}){this.#o=K(J.columnDefaults||{}),this.#i=J.columnPresets||{},this.#s=J.locale,this.#a=J.timeZone,this.#l=P(J.verticalAlign),this.#d=J.registry||null,this.#h=J.grid||null,this.#f=J.context,this.#y=J.sampleSize??d,this.#b=J.onChange||null,this.#g=Z(J.rowKey)?J.rowKey:void 0,this.#r=n(J.dataTypes,this.#d);const{leaves:se,groups:le}=ie(J.columns||[]);this.#n=le;for(const oe of se){const he=this.#w(oe.def,null);if(he.groupPath=oe.path,this.#e.has(he.id)){b(`columns.duplicate:${he.id}`,`two columns resolve to the id '${he.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}oe.column=he,this.#e.set(he.id,he),this.#t.push(he.id)}this.#A(J.stored||null)}#w(J,se){T(J,I,"column",J.id||J.field||"(unnamed)");const le=K(J),oe=k(J.preset),he=oe.map(Ue=>{const Je=this.#i[Ue];return Je?K(Je):(b(`preset:${Ue}`,`unknown column preset "${Ue}"; ignoring`),{})}),fe=this.#j(le,he,se),ve=this.#r.get(fe)||this.#r.get("text");!this.#r.has(fe)&&J.type&&b(`type:${fe}`,`unknown data type "${fe}"; falling back to "text"`);let be=E;be=U(be,this.#o),J.type!==!1&&(be=U(be,B(ve)));for(const Ue of he)be=U(be,Ue);be=U(be,le);const Re=be.edit;Re&&Re.editor&&Re.enabled!==!0&&!Z(Re.enabled)&&(J.edit||{}).editor&&b(`column.editor-not-enabled:${J.id||J.field}`,`column '${J.id||J.field}' names the editor '${Re.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const He=J.id||J.field||S("col");if(J.shadow&&!Z(be.value&&be.value.compute)){const Ue=typeof J.shadow=="string"?{kind:J.shadow}:J.shadow,Je=Ue.of||J.field||He,at=O.includes(Ue.kind),Ae=at?Ue.model||Ue:null,We=at&&Ae?[...Array.isArray(Ae.predictors)?Ae.predictors:[],Ae.response].filter(Boolean):null;be.value={...be.value||{},deps:We&&We.length?We:Ue.orderBy&&Ue.orderBy!==Je?[Je,Ue.orderBy]:[Je],pure:!1,compute:(Ge,Qe)=>{const lt=Qe.grid&&Qe.grid.statistics;if(!lt)return null;const wt=Qe.row&&Qe.row.key||lt.keyOf(Qe.data);if(!wt)return null;if(at){if(!Z(lt.fitShadow))return null;const Pt=Ue.model?{...Ue.model,threshold:Ue.threshold}:Ue;return lt.fitShadow(Ue.kind,wt,Pt)}return lt.shadow(Je,Ue.kind,wt,Ue.scope,Ue)}}}if(J.running&&!Z(be.value&&be.value.compute)){const Ue=typeof J.running=="string"?{kind:J.running}:J.running,Je=Ue.of||J.field||He;be.value={...be.value||{},deps:[Je],pure:!1,compute:(at,Ae)=>{const We=Ae.grid&&Ae.grid.statistics;if(!We||!Z(We.running))return null;const Ge=Ae.row&&Ae.row.key||We.keyOf(Ae.data);return Ge?We.running(Je,Ue.kind||"total",Ge):null}},J.sort===void 0&&(be.sort={...be.sort||{},enabled:!1})}const Oe=J.field??(Z(be.value&&be.value.compute)?null:J.id??null),Ie=Z(be.value&&be.value.compute),$e={id:He,field:Oe,shadow:J.shadow||null,running:J.running||null,spec:J.spec||null,validation:J.validation||null,volatile:!!(J.shadow||J.running),title:be.title??W(Oe||He),type:ve.name,dataType:ve,nullable:be.nullable!==!1,align:C(le.cell&&le.cell.align||le.align||be.cell&&be.cell.align||be.align||ve.defaults&&ve.defaults.align)||"start",verticalAlign:P(le.cell&&le.cell.verticalAlign||le.verticalAlign||be.cell&&be.cell.verticalAlign||be.verticalAlign)||this.#l,rowSpan:Z(be.rowSpan)?be.rowSpan:null,colSpan:Z(be.colSpan)?be.colSpan:null,value:{pure:!0,...be.value||{}},cell:{...be.cell||{}},edit:{...be.edit||{}},sort:{...be.sort||{}},filter:{...be.filter||{}},group:{enabled:!1,index:-1,explode:!1,...be.group||{}},pivot:{enabled:!1,index:-1,...be.pivot||{}},total:this.#u(be.total,ve,J.id||J.field||"(unnamed)"),groupTotal:be.groupTotal===void 0?null:this.#u(be.groupTotal,ve,J.id||J.field||"(unnamed)"),grandTotal:be.grandTotal===void 0?null:this.#u(be.grandTotal,ve,J.id||J.field||"(unnamed)"),tags:q(be.tags),typeOptions:be.typeOptions??null,...H(be[fe])?{[fe]:be[fe]}:{},layout:x(be.layout,le),header:{...be.header||{}},contextMenu:be.contextMenu===void 0?null:be.contextMenu,facet:{...be.facet||{}},export:{...be.export||{}},allowGroup:be.allowGroup!==!1,allowPivot:be.allowPivot!==!1,allowTotal:be.allowTotal!==!1,quickFilter:be.quickFilter!==!1,def:J,format:be.format,presets:oe,inferred:se!=null&&!J.type,computed:Ie,read:Oe?z(Oe):null,write:Oe?F(Oe):null};$e.cell.align=C(le.cell&&le.cell.align)||$e.align,$e.header.align=C(le.header&&le.header.align)||$e.align;const qe=be.lookup||null;return $e.lookup=qe?p({id:He,lookup:qe},{locale:this.#s,onChange:()=>{this.#b&&this.#b("lookup",{colId:He})}}):null,$e.group.explode&&$e.lookup&&$e.lookup.multiple&&b(`explode:${He}`,`column "${He}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#S($e),$e}#S(J){J.formatter=l(J.format,J.dataType,this.#s,this.#a,J.id),J.formatValue=w(J,{locale:this.#s,grid:this.#h,context:this.#f}),J.compare=Z(J.value.compare)?J.value.compare:J.lookup?J.lookup.comparator():t(J.dataType,this.#s),J.excel=J.formatter&&J.formatter.ooxml||J.dataType&&J.dataType.excel||"General",J.storeKind=i(J.dataType,!!(J.lookup&&J.lookup.multiple))}#j(J,se,le){if(J.type===!1)return"text";if(J.type)return J.type;for(let oe=se.length-1;oe>=0;oe--)if(se[oe].type)return se[oe].type;if(this.#o.type)return this.#o.type;if(J.shadow){const oe=typeof J.shadow=="string"?J.shadow:J.shadow.kind;if(oe==="fitInfluence")return"boolean";if(oe==="fitPredicted"||oe==="fitResidual"||oe==="fitStdResidual"||oe==="fitLeverage"||oe==="fitCooksD"||oe==="tsTrend"||oe==="tsSeasonal"||oe==="tsResidual"||oe==="tsCoverage"||oe==="tsSmoothed"||oe==="tsSmoothingAlpha"||oe==="tsSmoothingBeta")return"number"}return le||(J.lookup?"lookup":"text")}#A(J){const se=this.all();this.#m=h(se),this.#p?this.#p.setGraph(this.#m):this.#p=new v({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#f,stored:J||null,rowKey:this.#g});const le=this.#p;for(const oe of se)oe.getValue=(he,fe)=>le.value(oe,he,fe)}all(){return this.#t.map(J=>this.#e.get(J))}visible(){return this.all().filter(J=>!J.layout.hidden)}get(J){return this.#e.get(J)}groups(){const J=se=>{const le=[];for(const oe of se)Array.isArray(oe.columns)?le.push({...oe,columns:J(oe.columns)}):oe.column&&le.push(oe.column);return le};return J(this.#n)}graph(){return this.#m}pipeline(){return this.#p}types(){return this.#r}affectedBy(J){return g(this.#m,J)}value(J,se,le){return this.#p.value(J,se,le)}text(J,se,le){return this.#p.text(J,se,le)}checkImpure(J,se){u(this.#e.get(J),se)}setLocale(J){this.#s=J;for(const se of this.all())se.lookup&&se.lookup.setLocale(J),this.#S(se);this.#b&&this.#b("locale",{locale:J})}infer(J){const se={};if(this.#v||!Array.isArray(J)||J.length===0)return se;this.#v=!0;let le=!1;for(const oe of this.all()){const he=oe.def;if(he.type!==void 0||!oe.field||oe.computed||oe.lookup||this.#O(oe))continue;const fe=oe.read||(Re=>L(Re,oe.field)),ve=c(oe.id,J,fe,this.#r,{sampleSize:this.#y});if(ve===oe.type)continue;se[oe.id]=ve;const be=this.#w(he,ve);be.groupPath=oe.groupPath,be.layout={...be.layout,...Q(oe.layout)},this.#e.set(oe.id,be),ae(this.#n,oe.id,be),le=!0}return le&&this.#A(null),se}redecorate(J,se,le={}){const oe=this.#e.get(J);if(!oe){b(`redecorate:${J}`,`columns.decorate('${J}', …): no column with id '${J}'.`);return}const he=oe.def||{},fe={...H(he.cell)?he.cell:{}};fe.decoration=se??void 0,le&&"variant"in le&&(fe.variant=le.variant);const ve={...he,cell:fe},be=this.#w(ve,oe.type);return be.groupPath=oe.groupPath,be.layout={...be.layout,...Q(oe.layout)},this.#e.set(J,be),ae(this.#n,J,be),this.#A(null),this.#b&&this.#b("decorate",{colId:J}),be}#O(J){for(const se of J.presets){const le=this.#i[se];if(le&&le.type)return!0}return!!this.#o.type}#C(J){return!J.computed&&Z(J.dataType&&J.dataType.toStorage)}storeReader(J){if(J.computed)return se=>this.#p.value(J,se,null);if(this.#C(J)){const se=J.dataType.toStorage,le={timeZone:J.timeZone||this.#a};return oe=>se(J.read(oe),le)}return J.read}storeValue(J,se){if(!(!J||J.computed)&&Z(J.read))return this.storeReader(J)(se)}storeSchema(){const J=[];for(const se of this.all()){if(se.computed&&se.value.pure===!1||!se.computed&&!se.field)continue;const le=this.storeReader(se);let oe=null;!se.computed&&!this.#C(se)&&typeof se.field=="string"&&!se.lookup&&(oe=se.field);const he={id:se.id,kind:se.storeKind,nullable:se.nullable,read:le};oe!==null&&(he.field=oe),se.lookup&&(he.dictionary=se.lookup.dictionary()),J.push(he)}return J}state(){return this.all().map(J=>({id:J.id,width:J.layout.width,flex:J.layout.flex||void 0,hidden:!!J.layout.hidden,pin:J.layout.pin??null,sort:J.sort.direction??null,sortIndex:J.sort.direction?J.sort.order??0:null,groupIndex:J.group.enabled?J.group.index??0:null,pivotIndex:J.pivot.enabled?J.pivot.index??0:null,total:typeof J.total=="string"?J.total:null,groupTotal:typeof J.groupTotal=="string"?J.groupTotal:void 0,grandTotal:typeof J.grandTotal=="string"?J.grandTotal:void 0,decoration:J.cell&&J.cell.decoration!=null?te(J.cell.decoration):void 0,variant:J.cell&&J.cell.variant!=null?te(J.cell.variant):void 0}))}applyState(J){const se={applied:[],skipped:[]},le=Array.isArray(J)?J:J&&J.columns||[],oe=!Array.isArray(J)&&J&&J.columnOrder||null;for(const fe of le){if(!fe||!fe.id){se.skipped.push({key:"?",reason:"no id"});continue}let ve=this.#e.get(fe.id);if(!ve){se.skipped.push({key:fe.id,reason:"unknown column"});continue}if(Object.hasOwn(fe,"decoration")||Object.hasOwn(fe,"variant")){const be=ve.cell?ve.cell.decoration:void 0,Re=fe.decoration??null,He=Object.hasOwn(fe,"variant"),Oe=He&&!re(ve.cell?ve.cell.variant:void 0,fe.variant);(!re(be,Re)||Oe)&&(this.redecorate(fe.id,Re,He?{variant:fe.variant??void 0}:{}),ve=this.#e.get(fe.id)||ve)}fe.width!=null&&(ve.layout.width=fe.width),fe.flex!=null&&(ve.layout.flex=fe.flex),fe.hidden!=null&&(ve.layout.hidden=!!fe.hidden),fe.pin!==void 0&&(ve.layout.pin=fe.pin),fe.sort!==void 0&&(ve.sort.direction=fe.sort),fe.sortIndex!=null&&(ve.sort.order=fe.sortIndex),fe.groupIndex!=null&&(ve.group.enabled=!0,ve.group.index=fe.groupIndex),fe.pivotIndex!=null&&(ve.pivot.enabled=!0,ve.pivot.index=fe.pivotIndex),fe.total!==void 0&&(ve.total=fe.total),fe.groupTotal!==void 0&&(ve.groupTotal=fe.groupTotal),fe.grandTotal!==void 0&&(ve.grandTotal=fe.grandTotal),se.applied.push(fe.id)}const he=oe||le.map(fe=>fe&&fe.id).filter(Boolean);if(he.length){const fe=he.filter(be=>this.#e.has(be)),ve=this.#t.filter(be=>!fe.includes(be));this.#t=[...fe,...ve]}return this.#b&&this.#b("state",se),se}move(J,se){const le=this.#t.indexOf(J);if(le===-1)return;const oe=this.#e.get(J);if(oe.layout.movable===!1||oe.layout.lockPosition){b(`move:${J}`,`column "${J}" is not movable; the move was ignored`);return}const he=this.#E(J,se);if(he){b(`move.married:${he}`,`band "${he}" declares marryChildren, so its columns stay together; the move was ignored`);return}this.#t.splice(le,1),this.#t.splice(Math.max(0,Math.min(se,this.#t.length)),0,J),this.#T(),this.#b&&this.#b("move",{id:J,to:se})}#E(J,se){if(!this.#n||!this.#n.length)return null;const le=this.#t.filter(ve=>ve!==J),oe=Math.max(0,Math.min(se,le.length)),he=(ve,be)=>{if(Array.isArray(ve.columns)){for(const He of ve.columns)he(He,be);return be}const Re=ve.column?ve.column.id:ve.id;return Re&&be.push(Re),be},fe=ve=>{for(const be of ve){if(!Array.isArray(be.columns))continue;if(be.marryChildren===!0){const He=he(be,[]),Oe=He.includes(J),Ie=He.map($e=>le.indexOf($e)).filter($e=>$e>=0);if(Ie.length){const $e=Math.min(...Ie),qe=Math.max(...Ie);if(Oe?oe<$e||oe>qe+1:oe>$e&&oe<=qe)return be.id}}const Re=fe(be.columns);if(Re)return Re}return null};return fe(this.#n)}#T(){const J=new Map(this.#t.map((oe,he)=>[oe,he])),se=oe=>{if(!Array.isArray(oe.columns)){const fe=oe.column?oe.column.id:oe.id;return J.has(fe)?J.get(fe):1/0}let he=1/0;for(const fe of oe.columns)he=Math.min(he,se(fe));return he},le=oe=>{oe.sort((he,fe)=>se(he)-se(fe));for(const he of oe)Array.isArray(he.columns)&&le(he.columns)};le(this.#n)}#D(J){const se=le=>{for(let oe=0;oe<le.length;oe++){const he=le[oe];if(Array.isArray(he.columns)){const fe=se(he.columns);if(fe)return fe}else if(he.column&&he.column.id===J)return le.splice(oe,1)[0]}return null};return se(this.#n)}#R(J){const se=[];for(let le=J.length-1;le>=0;le--){const oe=J[le];Array.isArray(oe.columns)&&(se.push(...this.#R(oe.columns)),oe.columns.length===0&&(se.push(oe.id),J.splice(le,1)))}return se}#N(){const J=(se,le)=>{for(const oe of se)Array.isArray(oe.columns)?J(oe.columns,[...le,oe.id]):oe.column&&(oe.column.groupPath=le)};J(this.#n,[])}#M(J){const se=new Set(J),le=this.#t.filter(ve=>se.has(ve));if(!le.length)return;const oe=Math.min(...le.map(ve=>this.#t.indexOf(ve))),he=this.#t.slice(0,oe).filter(ve=>!se.has(ve)),fe=this.#t.slice(oe).filter(ve=>!se.has(ve));this.#t=[...he,...le,...fe]}#_(J){const se=[],le=oe=>{if(Array.isArray(oe.columns))for(const he of oe.columns)le(he);else oe.column&&se.push(oe.column.id)};return le(J),se}#U(J){const se=le=>{for(const oe of le){if(!Array.isArray(oe.columns))continue;if(oe.id===J)return{node:oe,parent:le};const he=se(oe.columns);if(he)return he}return null};return se(this.#n)}groupColumns(J,se={}){const le=k(J).filter(be=>this.#e.has(be));if(!le.length)return b("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const be of le)if(this.#e.get(be).layout.lockPosition)return b(`columns.group.locked:${be}`,`column "${be}" is position-locked and cannot be grouped.`),null;const oe=se.groupId?this.#U(se.groupId):null;if(se.groupId&&!oe)return b(`columns.group.unknown:${se.groupId}`,`no band "${se.groupId}" to add to; nothing was grouped.`),null;let he=null;if(!oe&&se.id!=null&&(he=String(se.id),this.#U(he)||this.#e.has(he)))return b(`columns.group.idtaken:${he}`,`band id "${he}" is already in use; nothing was grouped.`),null;const fe=le.map(be=>this.#D(be)).filter(Boolean);if(!fe.length)return null;let ve;if(oe)oe.node.columns.push(...fe),ve=oe.node.id;else{const be={id:he||S("grp"),title:se.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:fe},Re=Number.isInteger(se.at)?Math.max(0,Math.min(se.at,this.#n.length)):this.#n.length;this.#n.splice(Re,0,be),ve=be.id}return this.#R(this.#n),this.#M(le),this.#N(),this.#T(),this.#b&&this.#b("columngroup",{action:"formed",groupId:ve,ids:le}),ve}ungroupColumn(J){const se=this.#e.get(J);if(!se){b(`columns.ungroup.unknown:${J}`,`no column "${J}" to ungroup.`);return}const le=se.groupPath||[];if(!le.length)return;const oe=le[le.length-1],he=this.#U(oe);if(!he)return;const fe=this.#D(J);if(!fe)return;const ve=he.parent.indexOf(he.node);he.parent.splice(ve+1,0,fe);const be=this.#R(this.#n),Re=this.#_(he.node);if(Re.length){this.#M(Re);const He=Math.max(...Re.map(Ie=>this.#t.indexOf(Ie))),Oe=this.#t.filter(Ie=>Ie!==J);Oe.splice(He+1,0,J),this.#t=Oe}this.#N(),this.#T(),this.#b&&this.#b("columngroup",{action:"removed",id:J,dissolved:be})}renameGroup(J,se){const le=this.#U(J);if(!le){b(`columns.group.rename:${J}`,`no band "${J}" to rename.`);return}le.node.title=String(se??""),this.#b&&this.#b("columngroup",{action:"renamed",groupId:J,title:le.node.title})}dissolveGroup(J){const se=this.#U(J);if(!se){b(`columns.group.dissolve:${J}`,`no band "${J}" to dissolve.`);return}const le=se.parent.indexOf(se.node);se.parent.splice(le,1,...se.node.columns),this.#N(),this.#T(),this.#b&&this.#b("columngroup",{action:"dissolved",groupId:J})}moveGroup(J,se){const le=this.#U(J);if(!le){b(`columns.group.move:${J}`,`no band "${J}" to move.`);return}const oe=le.parent,he=oe.indexOf(le.node);he!==-1&&(oe.splice(he,1),oe.splice(Math.max(0,Math.min(se,oe.length)),0,le.node),this.#F(),this.#N(),this.#b&&this.#b("columngroup",{action:"moved",groupId:J,to:se}))}#F(){const J=[],se=oe=>{for(const he of oe)Array.isArray(he.columns)?se(he.columns):he.column&&J.push(he.column.id)};se(this.#n);const le=new Set(J);this.#t=[...J,...this.#t.filter(oe=>!le.has(oe))]}groupTree(){const J=le=>le.map(oe=>Array.isArray(oe.columns)?{id:oe.id,title:oe.title||"",collapsible:!!oe.collapsible,openByDefault:oe.openByDefault!==!1,columns:J(oe.columns)}:oe.column?oe.column.id:null).filter(oe=>oe!==null),se=J(this.#n);return se.some(le=>le&&typeof le=="object")?se:[]}applyGroupTree(J){if(!Array.isArray(J))return;const se=new Set,le=he=>{const fe=[];for(const ve of he)if(ve&&typeof ve=="object"&&Array.isArray(ve.columns)){const be=le(ve.columns);if(!be.length)continue;fe.push({id:ve.id||S("grp"),title:ve.title||"",collapsible:ve.collapsible===!0,openByDefault:ve.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:be})}else if(typeof ve=="string"){const be=this.#e.get(ve);be&&!se.has(ve)&&(se.add(ve),fe.push({column:be,path:[]}))}return fe},oe=le(J);for(const he of this.#t){if(se.has(he))continue;const fe=this.#e.get(he);fe&&oe.push({column:fe,path:[]})}this.#n=oe,this.#N(),this.#T(),this.#b&&this.#b("columngroup",{action:"applied"})}show(J){this.#Y(J,!1)}hide(J){this.#Y(J,!0)}#Y(J,se){const le=[];for(const oe of k(J)){const he=this.#e.get(oe);if(he){if(se&&he.layout.lockVisible){b(`lockVisible:${oe}`,`column "${oe}" is \`layout.lockVisible\` and cannot be hidden`);continue}he.layout.hidden!==se&&(he.layout.hidden=se,le.push(oe))}}le.length&&this.#b&&this.#b("visible",{ids:le,hidden:se})}pin(J,se){const le=this.#e.get(J);le&&(le.layout.pin=se??null,this.#b&&this.#b("pin",{id:J,side:le.layout.pin}))}resize(J,se){const le=this.#e.get(J);if(!le)return;if(le.layout.resizable===!1){b(`resize:${J}`,`column "${J}" is not resizable; the resize was ignored`);return}const oe=le.layout.min??0,he=le.layout.max;let fe=Math.max(oe,se);he!=null&&(fe=Math.min(he,fe)),le.layout.width=fe,le.layout.flex=0,this.#b&&this.#b("resize",{id:J,width:fe})}}function Q(ee){const J={};return ee.width!=null&&(J.width=ee.width),ee.hidden!=null&&(J.hidden=ee.hidden),ee.pin!==void 0&&(J.pin=ee.pin),J}function te(ee){if(ee===null||typeof ee!="object")return ee;try{return structuredClone(ee)}catch{}try{return JSON.parse(JSON.stringify(ee))}catch{return ee}}function re(ee,J){const se=ee??null,le=J??null;if(se===le)return!0;if(se===null||le===null)return!1;if(typeof se!="object"||typeof le!="object")return se===le;try{return JSON.stringify(se)===JSON.stringify(le)}catch{return!1}}function ie(ee){const J=[],se=(oe,he)=>{const fe=[];for(const ve of oe){if(!H(ve)){$("a column definition must be an object");continue}if(Array.isArray(ve.columns)){T(ve,j,"columnGroup",ve.title||ve.id||"(unnamed)");const be={id:ve.id||S("grp"),title:ve.title||"",collapsible:ve.collapsible===!0,openByDefault:ve.openByDefault!==!1,showWhen:ve.showWhen||"always",marryChildren:ve.marryChildren===!0,header:ve.header||{},def:ve,columns:[]};be.columns=se(ve.columns,[...he,be.id]),fe.push(be)}else{const be={def:ve,path:he};J.push(be),fe.push(be)}}return fe},le=se(ee,[]);return{leaves:J,groups:le}}function ae(ee,J,se){for(const le of ee){if(le.columns){if(ae(le.columns,J,se))return!0;continue}if(le.column&&le.column.id===J)return le.column=se,!0}return!1}}),Se("packages/core/src/columns/autogroup.js",function(e,V){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/internal/util.js").warnOnce,$="__lattice_group",L=240,W=.5;function Z(U){const{columns:z,groupBy:F}=U,k=F.map(a=>z.get(a)).filter(Boolean),S=k.length?k.map(a=>a.title||a.id).join(" > "):"Group",b=U.config&&U.config.autoGroupColumnWidth||L;return{id:$,field:null,title:S,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:F.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:b,min:120,pin:U.config&&U.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(a,l){return l&&l.group?l.groupValue:null},formatValue(a,l){if(!l||!l.group)return"";if(l.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";const r=k[Math.min(l.level||0,k.length-1)];return r&&typeof r.formatValue=="function"?r.formatValue(a,l):a==null?"":String(a)}}}function H(U,z,F){!U.length||F<100||z<F*W||N(`grouping.cardinality:${U.join(",")}`,`grouping by ${U.join(", ")} produced ${z} groups for ${F} 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.`)}}),Se("packages/core/src/columns/selectcolumn.js",function(e,V){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="__lattice_select",N=44;function $(W){const Z=W.selection||{},H=W.config&&W.config.selectionColumnWidth||N;return{id:_,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:H,min:H,max:H,pin:W.config&&W.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Z.headerCheckbox===!0,def:{},getValue(U,z){return z?z.selected:!1},formatValue(){return""}}}const L=$}),Se("packages/core/src/columns/rownumbercolumn.js",function(e,V){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const N=V("packages/core/src/internal/util.js").isFunction,$="__lattice_rownumber",L=40,W=9,Z=22;function H(F){const k=String(Math.max(1,Math.trunc(Math.abs(F))||1)).length;return Math.max(L,k*W+Z)}function U(F){const k=F.rowNumbers,S=k&&typeof k=="object"?k:{},b=Number.isFinite(S.start)?S.start:1,a=Number.isFinite(S.width)?S.width:H((F.maxNumber||0)+b),l=N(F.rank)?F.rank:()=>null;return{id:$,field:null,title:typeof S.title=="string"?S.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:a,min:a,max:a,pin:"start",hidden:!1,resizable:S.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(r,t){const n=l(t);return n==null?null:n-1+b},formatValue(r){return r==null?"":String(r)}}}const z=U}),Se("packages/core/src/model/detail.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,L=240,W=10;function Z(z){if(!z)return null;const F=z===!0?{}:z;return F.enabled===!1?null:!N(F.rows)&&!F.render?($("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:F.render||null,config:F.config||null,rows:N(F.rows)?F.rows:null,height:F.height??L,cacheLimit:Number.isFinite(F.cacheLimit)?Math.max(0,F.cacheLimit):W,isMaster:N(F.isMaster)?F.isMaster:null,target:F.target||null,onCreate:N(F.onCreate)?F.onCreate:null,path:typeof F.path=="string"?F.path:null}}class H{#e;#t=new Set;#n;#r=0;constructor(F){this.#e=F.config,this.#n=N(F.onChange)?F.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(F){if(!F||F.group||F.detail)return!1;const k=this.#e.isMaster;return k?!!k(F.data,F):!0}isOpen(F){return this.#t.has(F)}keys(){return[...this.#t]}activeKey(){for(const F of this.#t)return F;return null}heightOf(F){const k=this.#e.height;return N(k)?Number(k(F))||L:k==="auto"?L:Number(k)||L}open(F){return this.#t.has(F)?!1:(this.inline||this.#t.clear(),this.#t.add(F),this.#o(),!0)}close(F){return this.#t.delete(F)?(this.#o(),!0):!1}toggle(F){return this.#t.has(F)?(this.close(F),!1):(this.open(F),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(F){if(!this.#t.size||!N(F))return;let k=!1;for(const S of[...this.#t])F(S)||(this.#t.delete(S),k=!0);k&&this.#o()}signature(){return`${this.#r}`}set(F){this.#t.clear();const k=Array.isArray(F)?F:[];for(const S of this.inline?k:k.slice(0,1))this.#t.add(S);this.#o()}#o(){this.#r++,this.#n()}}const U=H}),Se("packages/core/src/compute/handle.js",function(e,V){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return n}});const _=V("packages/core/src/internal/util.js"),N=_.collator,$=_.defaultCompare,L=_.warnOnce;function W(i){const o=new Uint32Array(i);for(let c=0;c<i;c++)o[c]=c;return o}function Z(i,o){if(o&&typeof o.count=="number")return o.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const c=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):c?i.kind==="bitset"?typeof c.size=="number"?c.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(L(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${c.length*8}`),c.length*8):c.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const H=new WeakMap;function U(i){const o=i.constructor;if(!o)return"unknown";const c=H.get(o);if(c)return c;let d="unknown";try{let f=null;typeof o.from=="function"?f=o.from([!1,!0]):(f=new o(8),f.set(1));const h=f&&f.words;h&&h.length&&(h[0]===2?d="lsb":h[0]===64&&(d="msb"))}catch{d="unknown"}return H.set(o,d),d}function z(i){if(!i)return()=>0;const o=i instanceof Uint8Array?i:i.words;if(o instanceof Uint8Array){const c=i instanceof Uint8Array?"lsb":U(i);if(c==="lsb")return d=>o[d>>>3]>>>(d&7)&1;if(c==="msb")return d=>o[d>>>3]>>>7-(d&7)&1}return typeof i.get=="function"?c=>i.get(c)?1:0:()=>0}function F(i){return!i||!i.presence?null:z(i.presence)}function k(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function S(i,o){return i?typeof i.valueOf=="function"?i.valueOf(o):typeof i.values=="function"?i.values()[o]:null:null}function b(i,o){const c=i.offsets,d=i.values;if(!c||!d)return[];const f=c[o],h=c[o+1];if(!(h>f))return[];const g=i.dict,y=new Array(h-f);for(let p=f;p<h;p++)y[p-f]=g?S(g,d[p]):d[p];return y}function a(i){if(!i)return()=>{};const o=i.values,c=F(i),d=i.kind;if(d==="dictionary"){const f=i.dict;return c?h=>c(h)?S(f,o[h]):null:h=>S(f,o[h])}if(d==="bitset"){const f=z(o);return c?h=>c(h)?f(h)===1:null:h=>f(h)===1}if(d==="multi")return c?f=>c(f)?b(i,f):null:f=>b(i,f);if(!o&&typeof i.get=="function"){const f=i.get.bind(i);return h=>{const g=f(h);return g===void 0?null:g}}return c?f=>{if(!c(f))return null;const h=o[f];return h===void 0?null:h}:f=>{const h=o[f];return h===void 0?null:h}}function l(i,o){if(i<o)return-1;if(i>o)return 1;if(i===o){const f=Object.is(i,-0),h=Object.is(o,-0);return f===h?0:f?-1:1}const c=Number.isNaN(i),d=Number.isNaN(o);return c&&d?0:c?1:-1}function r(i){const o=N(i);return(c,d)=>{if(c===d)return 0;const f=typeof c,h=typeof d;if(f==="string"&&h==="string")return o.compare(c,d);if(f==="number"&&h==="number")return l(c,d);if(f==="boolean"&&h==="boolean")return c===d?0:c?1:-1;if(c instanceof Date||d instanceof Date){const g=c instanceof Date?c.getTime():Number(c),y=d instanceof Date?d.getTime():Number(d);return l(g,y)}return $(c,d)}}function t(i,o){if(i&&typeof i.ranks=="function")return i.ranks(o);const c=i&&typeof i.values=="function"?i.values():[],d=c.length,f=r(o),h=new Array(d);for(let y=0;y<d;y++)h[y]=y;h.sort((y,p)=>f(c[y],c[p])||y-p);const g=new Uint32Array(d);for(let y=0;y<d;y++)g[h[y]]=y;return g}function n(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/special.js",function(e,V){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return r}});const _=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),N=3e-12,$=1e-300;function L(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-L(1-t);const n=t-1;let i=.9999999999998099;const o=n+7.5;for(let c=0;c<_.length;c++)i+=_[c]/(n+c+1);return .5*Math.log(2*Math.PI)+(n+.5)*Math.log(o)-o+Math.log(i)}function W(t,n,i){const o=t+n,c=t+1,d=t-1;let f=1,h=1-o*i/c;Math.abs(h)<$&&(h=$),h=1/h;let g=h;for(let y=1;y<=300;y++){const p=2*y;let m=y*(n-y)*i/((d+p)*(t+p));h=1+m*h,Math.abs(h)<$&&(h=$),f=1+m/f,Math.abs(f)<$&&(f=$),h=1/h,g*=h*f,m=-(t+y)*(o+y)*i/((t+p)*(c+p)),h=1+m*h,Math.abs(h)<$&&(h=$),f=1+m/f,Math.abs(f)<$&&(f=$),h=1/h;const w=h*f;if(g*=w,Math.abs(w-1)<N)break}return g}function Z(t,n,i){if(!(t>0)||!(n>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const o=Math.exp(L(t+n)-L(t)-L(n)+t*Math.log(i)+n*Math.log(1-i));return i<(t+1)/(t+n+2)?o*W(t,n,i)/t:1-o*W(n,t,1-i)/n}function H(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const n=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],o=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],c=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],d=.02425;let f,h,g;t<d?(f=Math.sqrt(-2*Math.log(t)),g=(((((o[0]*f+o[1])*f+o[2])*f+o[3])*f+o[4])*f+o[5])/((((c[0]*f+c[1])*f+c[2])*f+c[3])*f+1)):t<=1-d?(f=t-.5,h=f*f,g=(((((n[0]*h+n[1])*h+n[2])*h+n[3])*h+n[4])*h+n[5])*f/(((((i[0]*h+i[1])*h+i[2])*h+i[3])*h+i[4])*h+1)):(f=Math.sqrt(-2*Math.log(1-t)),g=-(((((o[0]*f+o[1])*f+o[2])*f+o[3])*f+o[4])*f+o[5])/((((c[0]*f+c[1])*f+c[2])*f+c[3])*f+1));const p=(.5*U(-g/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(g*g/2);return g-p/(1+g*p/2)}function U(t){const n=Math.abs(t),i=2/(2+n),o=4*i-2,c=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let d=0,f=0,h;for(let y=c.length-1;y>0;y--)h=f,f=o*f-d+c[y],d=h;const g=i*Math.exp(-n*n+.5*(c[0]+o*f)-d);return t>=0?g:2-g}function z(t){return .5*U(-t/Math.SQRT2)}function F(t,n){if(!(n>0)||!Number.isFinite(t))return Number.NaN;const i=.5*Z(n/2,.5,n/(n+t*t));return t>0?1-i:i}function k(t,n){if(!(t>0)||!(t<1)||!(n>0))return Number.NaN;if(n>1e7)return H(t);let i=-1e4,o=1e4,c=H(t);const d=L(n/2)+L(.5)-L((n+1)/2);for(let f=0;f<60;f++){const h=F(c,n);h<t?i=c:o=c;const g=Math.exp(-((n+1)/2)*Math.log(1+c*c/n)-d)/Math.sqrt(n),y=g>0?(h-t)/g:0;if(Math.abs(y)<1e-12)break;const p=c-y;if(c=p>i&&p<o&&Number.isFinite(p)?p:(i+o)/2,o-i<1e-12)break}return c}function S(t,n){let i=t,o=1/t,c=o;for(let d=0;d<300&&(i+=1,c*=n/i,o+=c,!(Math.abs(c)<Math.abs(o)*N));d++);return o*Math.exp(-n+t*Math.log(n)-L(t))}function b(t,n){let i=n+1-t,o=1/$,c=1/i,d=c;for(let f=1;f<=300;f++){const h=-f*(f-t);i+=2,c=h*c+i,Math.abs(c)<$&&(c=$),o=i+h/o,Math.abs(o)<$&&(o=$),c=1/c;const g=c*o;if(d*=g,Math.abs(g-1)<N)break}return Math.exp(-n+t*Math.log(n)-L(t))*d}function a(t,n){return!(t>0)||!(n>=0)||!Number.isFinite(n)?Number.NaN:n===0?0:n<t+1?S(t,n):1-b(t,n)}function l(t,n){return n>0?a(n/2,t/2):Number.NaN}function r(t,n){const i=l(t,n);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(e,V){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function _(H){const U=H.length,z=Array.from({length:U},()=>new Array(U).fill(0));for(let F=0;F<U;F++)for(let k=0;k<=F;k++){let S=H[F][k];for(let b=0;b<k;b++)S-=z[F][b]*z[k][b];if(F===k){if(!(S>0))return null;z[F][k]=Math.sqrt(S)}else z[F][k]=S/z[k][k]}return z}function N(H,U){const z=H.length,F=new Array(z).fill(0);for(let S=0;S<z;S++){let b=U[S];for(let a=0;a<S;a++)b-=H[S][a]*F[a];F[S]=b/H[S][S]}const k=new Array(z).fill(0);for(let S=z-1;S>=0;S--){let b=F[S];for(let a=S+1;a<z;a++)b-=H[a][S]*k[a];k[S]=b/H[S][S]}return k}function $(H){const U=H.length,z=Array.from({length:U},()=>new Array(U).fill(0));for(let F=0;F<U;F++){const k=new Array(U).fill(0);k[F]=1;const S=N(H,k);for(let b=0;b<U;b++)z[b][F]=S[b]}return z}function L(H,U,z){const F=H.length,k=F?H[0].length:0,S=Array.from({length:k},()=>new Array(k).fill(0)),b=new Array(k).fill(0);for(let a=0;a<F;a++){const l=z?z[a]:1,r=H[a];for(let t=0;t<k;t++){const n=l*r[t];b[t]+=n*U[a];for(let i=t;i<k;i++)S[t][i]+=n*r[i]}}for(let a=0;a<k;a++)for(let l=0;l<a;l++)S[a][l]=S[l][a];return{xtwx:S,xtwy:b}}function W(H,U){return H.map(z=>z.reduce((F,k,S)=>F+k*U[S],0))}function Z(H,U){let z=0;for(let F=0;F<H.length;F++){let k=0;for(let S=0;S<H.length;S++)k+=U[F][S]*H[S];z+=H[F]*k}return z}}),Se("packages/core/src/compute/sketch.js",function(e,V){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});class _{#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(a){if(!Number.isFinite(a))return;this.#e++;const l=a-this.#t;this.#t+=l/this.#e,this.#n+=l*(a-this.#t)}merge(a){if(a.#e===0)return;if(this.#e===0){this.#e=a.#e,this.#t=a.#t,this.#n=a.#n;return}const l=this.#e+a.#e,r=a.#t-this.#t;this.#t+=r*(a.#e/l),this.#n+=a.#n+r*r*(this.#e*a.#e/l),this.#e=l}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 a=this.variance();return a===null?null:Math.sqrt(a)}stddevP(){const a=this.varianceP();return a===null?null:Math.sqrt(a)}}class N{#e=[];#t=0;#n;#r;constructor(a,l=Math.random){if(!(a>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(a),this.#r=l}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(a){if(!Number.isFinite(a))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(a);return}const l=Math.floor(this.#r()*this.#t);l<this.#n&&(this.#e[l]=a)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let a=0;for(const l of this.#e)a+=l;return a/this.#e.length}quantile(a){const l=this.#e.length;if(!l)return null;const r=this.#e.slice().sort((o,c)=>o-c);if(l===1)return r[0];const t=(l-1)*Math.min(1,Math.max(0,a)),n=Math.floor(t),i=Math.ceil(t);return n===i?r[n]:r[n]+(t-n)*(r[i]-r[n])}}function $(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function L(b){if(typeof b=="number"){const r=new DataView(new ArrayBuffer(8));return r.setFloat64(0,b===0?0:b),$(r.getUint32(0)^r.getUint32(4))}const a=typeof b=="string"?b:String(b);let l=2166136261;for(let r=0;r<a.length;r++)l^=a.charCodeAt(r),l=Math.imul(l,16777619);return $(l)}class W{#e;#t;#n;constructor(a=14){const l=Math.floor(a);if(l<4||l>16)throw new RangeError("HLL precision must be 4..16");this.#e=l,this.#t=1<<l,this.#n=new Uint8Array(this.#t)}static errorBoundFor(a=14){const l=1<<Math.floor(a),r=1.04/Math.sqrt(l);return Object.freeze({kind:"probabilistic",metric:"relative",value:r,statement:`distinct count within ~${(r*100).toFixed(2)}% relative standard error (m=${l} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(a){const l=L(a),r=l&this.#t-1,t=l>>>this.#e|1<<32-this.#e;let n=1,i=t;for(;(i&1)===0;)n++,i>>>=1;n>this.#n[r]&&(this.#n[r]=n)}count(){const a=this.#t,l=32-this.#e,r=new Float64Array(l+2);for(let i=0;i<a;i++)r[this.#n[i]]++;let t=a*U(1-r[l+1]/a);for(let i=l;i>=1;i--)t=.5*(t+r[i]);t+=a*H(r[0]/a);const n=Z*a*a/t;return Math.round(n)}}const Z=.5/Math.log(2);function H(b){if(b===1)return 1/0;let a=1,l=b,r;do b*=b,r=l,l+=b*a,a+=a;while(l!==r);return l}function U(b){if(b===0||b===1)return 0;let a=1,l=1-b,r;do b=Math.sqrt(b),r=l,a*=.5,l-=(1-b)**2*a;while(l!==r);return l/3}class z{#e=new Map;#t;#n=0;constructor(a){if(!(a>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(a)}errorBoundFor(a){const l=a/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:l,statement:`each count overestimates the truth by at most N/m = ${l.toFixed(2)} (N=${a}, m=${this.#t})`})}get seen(){return this.#n}add(a){this.#n++;const l=this.#e.get(a);if(l){l.count++;return}if(this.#e.size<this.#t){this.#e.set(a,{count:1,error:0});return}let r,t=1/0;for(const[n,i]of this.#e)i.count<t&&(t=i.count,r=n);this.#e.delete(r),this.#e.set(a,{count:t+1,error:t})}top(a=this.#t){return[...this.#e.entries()].map(([r,t])=>({item:r,count:t.count,error:t.error})).sort((r,t)=>t.count-r.count).slice(0,Math.max(0,Math.floor(a)))}}class F{#e;#t=[[]];#n=0;#r;#o;constructor(a=200,l=Math.random){this.#e=Math.max(8,Math.floor(a)),this.#r=l,this.#o=2/3}static errorBoundFor(a=200){const l=1/Math.max(8,Math.floor(a));return Object.freeze({kind:"probabilistic",metric:"rank",value:l,statement:`queried quantile's true rank within ~${(l*100).toFixed(2)}% of N of the requested rank (k=${a})`})}errorBound(){return F.errorBoundFor(this.#e)}get count(){return this.#n}#i(a){const r=this.#t.length-1-a,t=Math.ceil(this.#e*this.#o**r);return Math.max(2,t)}add(a){Number.isFinite(a)&&(this.#n++,this.#t[0].push(a),this.#t[0].length>=this.#i(0)&&this.#a(0))}#a(a){const l=this.#t[a];l.sort((n,i)=>n-i),a+1>=this.#t.length&&this.#t.push([]);const r=this.#t[a+1],t=this.#r()<.5?0:1;for(let n=t;n<l.length;n+=2)r.push(l[n]);this.#t[a]=[];for(let n=0;n<this.#t.length;n++)if(this.#t[n].length>=this.#i(n)){this.#a(n);return}}#s(){const a=[];for(let l=0;l<this.#t.length;l++){const r=1<<l;for(const t of this.#t[l])a.push({v:t,w:r})}return a}quantile(a){const l=this.#s();if(!l.length)return null;l.sort((i,o)=>i.v-o.v);let r=0;for(const i of l)r+=i.w;const t=Math.min(1,Math.max(0,a))*r;let n=0;for(const i of l)if(n+=i.w,n>=t)return i.v;return l[l.length-1].v}rank(a){let l=0;for(let r=0;r<this.#t.length;r++){const t=1<<r;for(const n of this.#t[r])n<=a&&(l+=t)}return l}}const k=Object.freeze({distinct:W.errorBoundFor(14),median:F.errorBoundFor(200),p25:F.errorBoundFor(200),p75:F.errorBoundFor(200),p90:F.errorBoundFor(200),p95:F.errorBoundFor(200),p99:F.errorBoundFor(200),iqr:F.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),S={Welford:_,Reservoir:N,HyperLogLog:W,SpaceSaving:z,KLL:F,hash32:L,SKETCH_BOUNDS:k}}),Se("packages/core/src/compute/statistics.js",function(e,V){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return at}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return dt}});const _=V("packages/core/src/compute/handle.js"),N=_.presenceReader,$=_.valueReader,L=V("packages/core/src/compute/special.js"),W=L.studentTQuantile,Z=L.studentT,H=L.normalQuantile,U=L.normalCdf,z=L.chiSquareUpperTail,F=V("packages/core/src/compute/linalg.js"),k=F.cholesky,S=F.choleskySolve,b=F.choleskyInverse,a=F.normalEquations,l=F.quadForm,t=V("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,n=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),o=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function c(me){const ke=me==="sum"||me==="avg"||me==="countValues"||me==="min"||me==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,me)?i[me]:null,we=Object.prototype.hasOwnProperty.call(o,me)?o[me]:null;return{stat:me,exact:ke,approximate:we}}function d(me,ke){const we=ke.length,je=new Float64Array(we);let Pe=0;if(me&&(me.kind==="float64"||me.kind==="int32")){const Fe=me.values,De=N(me);for(let Ze=0;Ze<we;Ze++){const Ye=ke[Ze];if(De&&De(Ye)!==1)continue;const mt=Fe[Ye];Number.isNaN(mt)||(je[Pe++]=mt)}return je.subarray(0,Pe)}const Le=$(me);for(let Fe=0;Fe<we;Fe++){const De=Le(ke[Fe]);if(De==null||De==="")continue;const Ze=typeof De=="number"?De:Number(De);Number.isFinite(Ze)&&(je[Pe++]=Ze)}return je.subarray(0,Pe)}function f(me,ke){const we=new Map,je=$(me);let Pe=0;for(let Le=0;Le<ke.length;Le++){const Fe=je(ke[Le]);if(Fe==null||Fe===""||typeof Fe=="number"&&Number.isNaN(Fe))continue;const De=typeof Fe=="object"?String(Fe):Fe;we.set(De,(we.get(De)||0)+1),Pe++}const Ne=[...we.values()].sort((Le,Fe)=>Fe-Le);return{counts:Ne,total:Pe,distinct:Ne.length}}function h(me){return me.total>0?me.counts.map(ke=>ke/me.total):[]}function g(me,ke){const we=f(me,ke);if(!we.total)return null;let je=0;for(const Pe of h(we))je+=Pe*Pe;return je}function y(me,ke){const we=f(me,ke);if(!we.total)return null;let je=0;for(const Pe of h(we))Pe>0&&(je-=Pe*Math.log2(Pe));return je}function p(me,ke){const we=f(me,ke);if(!we.total||we.distinct<2)return we.total?1:null;let je=0;for(const Pe of h(we))Pe>0&&(je-=Pe*Math.log2(Pe));return je/Math.log2(we.distinct)}function m(me,ke,we=3){const je=f(me,ke);if(!je.total)return null;const Pe=Math.max(1,Math.floor(we));let Ne=0;for(let Le=0;Le<Math.min(Pe,je.counts.length);Le++)Ne+=je.counts[Le];return Ne/je.total}function w(me,ke){const we=d(me,ke),je=we.length;if(!je)return null;const Pe=we.slice().sort();if(Pe[0]<0)return null;let Ne=0,Le=0;for(let Fe=0;Fe<je;Fe++)Ne+=Pe[Fe],Le+=(Fe+1)*Pe[Fe];return Ne===0?0:2*Le/(je*Ne)-(je+1)/je}function v(me){let ke=0,we=0,je=0;for(let Pe=0;Pe<me.length;Pe++){const Ne=me[Pe];ke++;const Le=Ne-we;we+=Le/ke,je+=Le*(Ne-we)}return{n:ke,mean:we,m2:je}}function u(me,ke){const we=me.length;if(!we)return NaN;if(we===1)return me[0];const je=(we-1)*Math.min(1,Math.max(0,ke)),Pe=Math.floor(je),Ne=Math.ceil(je);return Pe===Ne?me[Pe]:me[Pe]+(je-Pe)*(me[Ne]-me[Pe])}function s(me,ke){if(!me.length)return NaN;const we=me.slice().sort();return u(we,ke)}function O(me,ke){const we=$(me);let je=0,Pe=0,Ne=0;for(let Le=0;Le<ke.length;Le++){const Fe=we(ke[Le]);if(Fe==null||Fe==="")continue;const De=String(Fe).toUpperCase();De==="PASS"?je++:De==="FAIL"?Pe++:De==="WARN"&&Ne++}return{pass:je+Ne,fail:Pe,warn:Ne,judged:je+Ne+Pe}}const E=Object.freeze({hhi:(me,ke)=>g(me,ke),entropy:(me,ke)=>y(me,ke),evenness:(me,ke)=>p(me,ke),top3Share:(me,ke)=>m(me,ke,3),top10Share:(me,ke)=>m(me,ke,10),gini:(me,ke)=>w(me,ke),trimmedMean:(me,ke)=>D(d(me,ke),.1),winsorizedMean:(me,ke)=>K(d(me,ke),.1),robustOutliers:(me,ke)=>x(d(me,ke),3.5),jarqueBera:(me,ke)=>I(d(me,ke)),variance:(me,ke)=>{const{n:we,m2:je}=v(d(me,ke));return we>1?je/(we-1):null},varianceP:(me,ke)=>{const{n:we,m2:je}=v(d(me,ke));return we>0?je/we:null},stddev:(me,ke)=>{const{n:we,m2:je}=v(d(me,ke));return we>1?Math.sqrt(je/(we-1)):null},stddevP:(me,ke)=>{const{n:we,m2:je}=v(d(me,ke));return we>0?Math.sqrt(je/we):null},median:(me,ke)=>{const we=d(me,ke);return we.length?s(we,.5):null},p25:(me,ke)=>{const we=d(me,ke);return we.length?s(we,.25):null},p75:(me,ke)=>{const we=d(me,ke);return we.length?s(we,.75):null},p90:(me,ke)=>{const we=d(me,ke);return we.length?s(we,.9):null},p95:(me,ke)=>{const we=d(me,ke);return we.length?s(we,.95):null},p99:(me,ke)=>{const we=d(me,ke);return we.length?s(we,.99):null},iqr:(me,ke)=>{const we=d(me,ke);if(!we.length)return null;const je=we.slice().sort();return u(je,.75)-u(je,.25)},mad:(me,ke)=>{const we=d(me,ke);if(!we.length)return null;const je=s(we,.5),Pe=new Float64Array(we.length);for(let Ne=0;Ne<we.length;Ne++)Pe[Ne]=Math.abs(we[Ne]-je);return s(Pe,.5)},range:(me,ke)=>{const we=d(me,ke);if(!we.length)return null;let je=1/0,Pe=-1/0;for(let Ne=0;Ne<we.length;Ne++)we[Ne]<je&&(je=we[Ne]),we[Ne]>Pe&&(Pe=we[Ne]);return Pe-je},distinct:(me,ke)=>{const we=$(me),je=new Set;for(let Pe=0;Pe<ke.length;Pe++){const Ne=we(ke[Pe]);Ne==null||Ne===""||je.add(Ne instanceof Date?Ne.getTime():Ne)}return je.size},mode:(me,ke)=>{const we=$(me),je=new Map;for(let Le=0;Le<ke.length;Le++){const Fe=we(ke[Le]);if(Fe==null||Fe==="")continue;const De=Fe instanceof Date?Fe.getTime():Fe;je.set(De,(je.get(De)||0)+1)}let Pe=null,Ne=1;for(const[Le,Fe]of je)Fe>Ne&&(Ne=Fe,Pe=Le);return Pe},skewness:(me,ke)=>{const we=d(me,ke),{n:je,mean:Pe,m2:Ne}=v(we);if(je<3||Ne<=0)return null;const Le=Math.sqrt(Ne/(je-1));let Fe=0;for(let De=0;De<we.length;De++)Fe+=((we[De]-Pe)/Le)**3;return je/((je-1)*(je-2))*Fe},kurtosis:(me,ke)=>{const we=d(me,ke),{n:je,mean:Pe,m2:Ne}=v(we);if(je<4||Ne<=0)return null;const Le=Math.sqrt(Ne/(je-1));let Fe=0;for(let Ye=0;Ye<we.length;Ye++)Fe+=((we[Ye]-Pe)/Le)**4;const De=je*(je+1)/((je-1)*(je-2)*(je-3)),Ze=3*(je-1)**2/((je-2)*(je-3));return De*Fe-Ze},geomean:(me,ke)=>{const we=d(me,ke);if(!we.length)return null;let je=0;for(let Pe=0;Pe<we.length;Pe++){if(we[Pe]<=0)return null;je+=Math.log(we[Pe])}return Math.exp(je/we.length)},harmean:(me,ke)=>{const we=d(me,ke);if(!we.length)return null;let je=0;for(let Pe=0;Pe<we.length;Pe++){if(we[Pe]===0)return null;je+=1/we[Pe]}return we.length/je},sumSquares:(me,ke)=>{const we=d(me,ke);let je=0;for(let Pe=0;Pe<we.length;Pe++)je+=we[Pe]*we[Pe];return je},passRate:(me,ke)=>{const{pass:we,judged:je}=O(me,ke);return je?we/je:null},failureCount:(me,ke)=>O(me,ke).fail}),A=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function M(me,ke,we){const je=$(me),Pe=$(ke);let Ne=0,Le=0;for(let Fe=0;Fe<we.length;Fe++){const De=we[Fe],Ze=Number(je(De)),Ye=Number(Pe(De));!Number.isFinite(Ze)||!Number.isFinite(Ye)||(Ne+=Ze*Ye,Le+=Ye)}return Le===0?null:Ne/Le}function C(me,ke,we){const je=$(me);let Pe=null,Ne=we?-1/0:1/0;for(let Le=0;Le<ke.length;Le++){const Fe=ke[Le],De=Number(je(Fe));Number.isFinite(De)&&(we?De>Ne:De<Ne)&&(Ne=De,Pe=Fe)}return Pe}function P(me,ke,we){const je=$(me),Pe=$(ke);let Ne=0,Le=0,Fe=0,De=0,Ze=0,Ye=0;for(let ft=0;ft<we.length;ft++){const kt=we[ft],St=Number(je(kt)),Ee=Number(Pe(kt));!Number.isFinite(St)||!Number.isFinite(Ee)||(Ne++,Le+=St,Fe+=Ee,De+=St*St,Ze+=Ee*Ee,Ye+=St*Ee)}if(Ne<2)return null;const mt=Ne*Ye-Le*Fe,pt=Math.sqrt((Ne*De-Le*Le)*(Ne*Ze-Fe*Fe));if(pt===0)return null;const bt=mt/pt;return Math.max(-1,Math.min(1,bt))}function D(me,ke=.1){const we=me.length;if(!we)return null;const je=Array.from(me).sort((Fe,De)=>Fe-De),Pe=Math.floor(we*Math.min(.49,Math.max(0,ke))),Ne=je.slice(Pe,we-Pe);if(!Ne.length)return u(je,.5);let Le=0;for(const Fe of Ne)Le+=Fe;return Le/Ne.length}function K(me,ke=.1){const we=me.length;if(!we)return null;const je=Array.from(me).sort((De,Ze)=>De-Ze),Pe=Math.floor(we*Math.min(.49,Math.max(0,ke))),Ne=je[Pe],Le=je[we-1-Pe];let Fe=0;for(const De of je)Fe+=Math.min(Le,Math.max(Ne,De));return Fe/we}function x(me,ke=3.5){if(!me.length)return null;const je=Array.from(me).sort((De,Ze)=>De-Ze),Pe=u(je,.5),Ne=je.map(De=>Math.abs(De-Pe)).sort((De,Ze)=>De-Ze),Le=u(Ne,.5);if(Le===0)return null;let Fe=0;for(const De of je)Math.abs(.6745*(De-Pe)/Le)>ke&&Fe++;return Fe}function I(me){const ke=me.length;if(ke<8)return null;let we=0;for(const De of me)we+=De;we/=ke;let je=0,Pe=0,Ne=0;for(const De of me){const Ze=De-we;je+=Ze*Ze,Pe+=Ze*Ze*Ze,Ne+=Ze*Ze*Ze*Ze}if(je/=ke,Pe/=ke,Ne/=ke,je===0)return null;const Le=Pe/je**1.5,Fe=Ne/(je*je)-3;return ke/6*(Le*Le+Fe*Fe/4)}function j(me,ke,we){const je=[];let Pe=0;for(let De=0;De<me.length;De++){const Ze=Number(me[De]),Ye=Number(ke[De]);!Number.isFinite(Ze)||!Number.isFinite(Ye)||Ye<=0||(je.push([Ze,Ye]),Pe+=Ye)}if(!je.length||Pe<=0)return null;if(je.sort((De,Ze)=>De[0]-Ze[0]),je.length===1)return je[0][0];const Ne=[];let Le=0;for(const[,De]of je)Ne.push((Le+De/2)/Pe),Le+=De;const Fe=Math.max(0,Math.min(1,we));if(Fe<=Ne[0])return je[0][0];if(Fe>=Ne[Ne.length-1])return je[je.length-1][0];for(let De=1;De<Ne.length;De++){if(Fe>Ne[De])continue;const Ze=Ne[De]-Ne[De-1],Ye=Ze>0?(Fe-Ne[De-1])/Ze:0;return je[De-1][0]+(je[De][0]-je[De-1][0])*Ye}return je[je.length-1][0]}function T(me,ke,we){const je=$(me),Pe=$(ke),Ne=new Float64Array(we.length),Le=new Float64Array(we.length);let Fe=0;for(let De=0;De<we.length;De++){const Ze=we[De],Ye=Number(je(Ze)),mt=Number(Pe(Ze));!Number.isFinite(Ye)||!Number.isFinite(mt)||(Ne[Fe]=Ye,Le[Fe]=mt,Fe++)}return{xs:Ne.subarray(0,Fe),ys:Le.subarray(0,Fe),n:Fe}}function B(me,ke,we,je=!1){const{xs:Pe,ys:Ne,n:Le}=T(me,ke,we);if(Le<2)return null;let Fe=0,De=0;for(let Ye=0;Ye<Le;Ye++)Fe+=Pe[Ye],De+=Ne[Ye];Fe/=Le,De/=Le;let Ze=0;for(let Ye=0;Ye<Le;Ye++)Ze+=(Pe[Ye]-Fe)*(Ne[Ye]-De);return Ze/(je?Le:Le-1)}function q(me,ke,we){const{xs:je,ys:Pe,n:Ne}=T(me,ke,we);if(Ne<2)return null;let Le=0,Fe=0;for(let St=0;St<Ne;St++)Le+=je[St],Fe+=Pe[St];Le/=Ne,Fe/=Ne;let De=0,Ze=0,Ye=0;for(let St=0;St<Ne;St++){const Ee=je[St]-Le,tt=Pe[St]-Fe;De+=Ee*Ee,Ze+=Ee*tt,Ye+=tt*tt}if(De===0)return null;const mt=Ze/De,pt=Fe-mt*Le,bt=Ye===0?1:Math.max(0,Math.min(1,Ze*Ze/(De*Ye))),ft=Math.max(0,Ye-mt*Ze),kt=Ne>2?Math.sqrt(ft/(Ne-2)/De):0;return{slope:mt,intercept:pt,r2:bt,stdError:kt,n:Ne}}const X=new Set(["ols","wls","robust"]),Q=new Set(["quantile"]),te=new Set(["ridge","lasso","elasticnet","mixed","gls"]),re=1.345;function ie(me,ke,we){const{xtwx:je,xtwy:Pe}=a(me,ke,we),Ne=k(je);if(!Ne)return null;const Le=S(Ne,Pe),Fe=b(Ne),De=ae(me,Le),Ze=ke.map((Ye,mt)=>Ye-De[mt]);return{beta:Le,cov:Fe,fitted:De,residuals:Ze}}function ae(me,ke){return me.map(we=>we.reduce((je,Pe,Ne)=>je+Pe*ke[Ne],0))}function ee(me,ke){const we=me.length,je=me.map(Ze=>Ze[ke]),Pe=me.map(Ze=>[1,...Ze.filter((Ye,mt)=>mt!==ke)]),Ne=ie(Pe,je,null);if(!Ne)return 1;const Le=je.reduce((Ze,Ye)=>Ze+Ye,0)/we;let Fe=0,De=0;for(let Ze=0;Ze<we;Ze++)Fe+=Ne.residuals[Ze]**2,De+=(je[Ze]-Le)**2;return De===0?1:Math.max(0,Math.min(1,1-Fe/De))}function J(me){const ke=[...me].sort((Pe,Ne)=>Pe-Ne),we=se(ke),je=me.map(Pe=>Math.abs(Pe-we)).sort((Pe,Ne)=>Pe-Ne);return se(je)/.6745}function se(me){const ke=me.length;if(!ke)return 0;const we=Math.floor(ke/2);return ke%2?me[we]:(me[we-1]+me[we])/2}function le(me,ke,we={}){const je=we.method||"ols";if(te.has(je))throw new Error(`[lattice] regression method "${je}" is out of scope; use ols, wls or robust.`);if(Q.has(je))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!X.has(je))throw new Error(`[lattice] unknown regression method "${je}"; use ols, wls or robust.`);const Pe=Array.isArray(ke)?ke.length:0,Ne=Pe&&Array.isArray(me[0])?me[0].length:0,Le=Ne+1;if(!(Pe>Le))return null;for(let yt=0;yt<Pe;yt++){if(!Number.isFinite(ke[yt])||!Array.isArray(me[yt])||me[yt].length!==Ne)return null;for(let Ct=0;Ct<Ne;Ct++)if(!Number.isFinite(me[yt][Ct]))return null}let Fe=null;if(je==="wls"){if(Fe=we.weights,!Array.isArray(Fe)||Fe.length!==Pe)return null;for(let yt=0;yt<Pe;yt++)if(!(Fe[yt]>0)||!Number.isFinite(Fe[yt]))return null}const De=me.map(yt=>[1,...yt]);let Ze,Ye=null;if(je==="robust"){if(Ze=ie(De,ke,null),!Ze)return null;for(let yt=0;yt<50;yt++){const Ct=J(Ze.residuals);if(!(Ct>0))break;const Tt=Ze.residuals.map(Kt=>{const qt=Math.abs(Kt/Ct);return qt<=re?1:re/qt}),Bt=ie(De,ke,Tt);if(!Bt)return null;const Yt=Bt.beta.reduce((Kt,qt,Jt)=>Math.max(Kt,Math.abs(qt-Ze.beta[Jt])),0);if(Ze=Bt,Ye=Tt,Yt<1e-10)break}}else if(Ze=ie(De,ke,Fe),!Ze)return null;const mt=je==="robust"?Ye:Fe,{beta:pt,cov:bt,fitted:ft,residuals:kt}=Ze;let St=0,Ee=0,tt=0;for(let yt=0;yt<Pe;yt++){const Ct=mt?mt[yt]:1;St+=Ct*kt[yt]**2,Ee+=Ct,tt+=Ct*ke[yt]}const rt=tt/Ee;let ht=0;for(let yt=0;yt<Pe;yt++){const Ct=mt?mt[yt]:1;ht+=Ct*(ke[yt]-rt)**2}const It=Pe-Le,Nt=St/It,ot=ht===0?1:Math.max(0,Math.min(1,1-St/ht)),vt=1-(1-ot)*(Pe-1)/It,Ht=Array.isArray(we.names)&&we.names.length===Ne?we.names:me[0].map((yt,Ct)=>`x${Ct+1}`),Gt=Rt(we.confidence),on=It>0?W(1-(1-Gt)/2,It):1/0,sn=pt.map((yt,Ct)=>{const Tt=Math.sqrt(Math.max(0,Nt*bt[Ct][Ct])),Bt=Tt>0?yt/Tt:yt===0?0:1/0,Yt=Number.isFinite(Bt)?2*(1-Z(Math.abs(Bt),It)):0,Kt=Number.isFinite(on)?on*Tt:null;return{name:Ct===0?"(intercept)":Ht[Ct-1],estimate:yt,stdError:Tt,t:Bt,p:Math.max(0,Math.min(1,Yt)),lower:Kt===null?null:yt-Kt,upper:Kt===null?null:yt+Kt}}),an=new Array(Pe),Dt=new Array(Pe);for(let yt=0;yt<Pe;yt++){const Ct=mt?mt[yt]:1,Tt=Math.max(0,Math.min(1,Ct*l(De[yt],bt)));an[yt]=Tt;const Bt=(1-Tt)**2;Dt[yt]=Bt>0&&Nt>0?kt[yt]**2/(Le*Nt)*(Tt/Bt):null}const ln=me[0].map((yt,Ct)=>{if(Ne<2)return 1;const Tt=ee(me,Ct);return Tt>=1?1/0:1/(1-Tt)});let un=null;{const yt=kt.map(Tt=>Tt*Tt),Ct=ie(De,yt,null);if(Ct){const Tt=yt.reduce((Zt,cn)=>Zt+cn,0)/Pe;let Bt=0,Yt=0;for(let Zt=0;Zt<Pe;Zt++)Bt+=Ct.residuals[Zt]**2,Yt+=(yt[Zt]-Tt)**2;const Kt=Yt===0?0:Math.max(0,Math.min(1,1-Bt/Yt)),qt=Pe*Kt,Jt=z(qt,Ne);un={statistic:qt,df:Ne,p:Jt,heteroscedastic:Jt<.05}}}let nn=null;if(Ne===1){const yt=me.map((Ct,Tt)=>Tt).sort((Ct,Tt)=>me[Ct][0]-me[Tt][0]);nn={confidence:Gt,points:yt.map(Ct=>{const Tt=De[Ct],Bt=Math.sqrt(Math.max(0,Nt*l(Tt,bt)));return{x:me[Ct][0],yhat:ft[Ct],lower:ft[Ct]-on*Bt,upper:ft[Ct]+on*Bt}})}}return{method:je,coefficients:sn,r2:ot,adjR2:vt,n:Pe,df:It,sigma2:Nt,fitted:ft,residuals:kt,leverage:an,cooksD:Dt,vif:ln,heteroscedasticity:un,band:nn,weights:mt?[...mt]:null}}function oe(me){const ke=me.length,we=Array.from({length:ke},(Ne,Le)=>Le).sort((Ne,Le)=>me[Ne]-me[Le]),je=new Float64Array(ke);let Pe=0;for(;Pe<ke;){let Ne=Pe;for(;Ne+1<ke&&me[we[Ne+1]]===me[we[Pe]];)Ne++;const Le=(Pe+Ne)/2+1;for(let Fe=Pe;Fe<=Ne;Fe++)je[we[Fe]]=Le;Pe=Ne+1}return je}const he=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function fe(me){const ke=[.01,.05,.1],we=[he["1%"],he["5%"],he["10%"]];if(me<=we[0]){const Ne=(Math.log(ke[1])-Math.log(ke[0]))/(we[1]-we[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ke[0])+Ne*(me-we[0]))))}if(me>=we[2]){const Ne=(Math.log(ke[2])-Math.log(ke[1]))/(we[2]-we[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ke[2])+Ne*(me-we[2]))))}const je=me<we[1]?0:1,Pe=(me-we[je])/(we[je+1]-we[je]);return Math.exp(Math.log(ke[je])+Pe*(Math.log(ke[je+1])-Math.log(ke[je])))}function ve(me,ke,we,je){const Pe=we-je,Ne=je+3,Le=new Array(Pe),Fe=new Array(Pe);let De=!0,Ze=je;for(let ft=0;ft<Pe;ft++){const kt=je+ft,St=new Float64Array(Ne);St[0]=1,St[1]=ft+1,St[2]=me[kt];for(let Ee=1;Ee<=je;Ee++)St[2+Ee]=ke[kt-Ee];for(let Ee=1;Ee<Ne;Ee++)Number.isFinite(St[Ee])||(Ze=Math.min(Ze,Ee-3));Le[ft]=St,Fe[ft]=ke[kt],Number.isFinite(Fe[ft])||(De=!1)}if(!De)return 0;const{xtwx:Ye,xtwy:mt}=a(Le,Fe,null);let pt=0,bt=1/0;for(let ft=0;ft<=Ze;ft++){const kt=ft+3;if(!(Pe>kt))continue;const St=new Array(kt);for(let ot=0;ot<kt;ot++)St[ot]=Ye[ot].slice(0,kt);const Ee=k(St);if(!Ee)continue;const tt=S(Ee,mt.slice(0,kt));let rt=0;for(let ot=0;ot<Pe;ot++){const vt=Le[ot];let Ht=0;for(let Gt=0;Gt<kt;Gt++)Ht+=vt[Gt]*tt[Gt];rt+=(Fe[ot]-Ht)**2}const It=rt/(Pe-kt)*(Pe-kt);if(!(It>0))continue;const Nt=Pe*Math.log(It/Pe)+2*kt;Nt<bt&&(bt=Nt,pt=ft)}return pt}function be(me,ke={}){const we=[];for(let bt=0;bt<me.length;bt++){const ft=Number(me[bt]);Number.isFinite(ft)&&we.push(ft)}const je=we.length,Pe=je-1;if(je<8||Pe<6)return null;const Ne=new Array(Pe);for(let bt=0;bt<Pe;bt++)Ne[bt]=we[bt+1]-we[bt];let Le=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.ceil(12*(je/100)**.25);Le=Math.max(0,Math.min(Le,Math.floor((Pe-5)/2)));const Fe=(bt,ft)=>{const kt=[],St=[];for(let Ee=ft;Ee<Pe;Ee++){const tt=[Ee-ft+1,we[Ee]];for(let rt=1;rt<=bt;rt++)tt.push(Ne[Ee-rt]);kt.push(tt),St.push(Ne[Ee])}return le(kt,St,{method:"ols"})},De=ve(we,Ne,Pe,Le),Ze=Fe(De,De);if(!Ze||!Ze.coefficients[2])return null;const Ye=Ze.coefficients[2].t,mt=fe(Ye),pt=Ye<he["5%"];return{statistic:Ye,usedLag:De,nobs:Pe-De,criticalValues:{...he},pValue:mt,pApproximate:!0,stationary:pt,verdict:pt?"stationary":"non-stationary",regression:"ct"}}function Re(me,ke={}){const we=[];for(let pt=0;pt<me.length;pt++){const bt=Number(me[pt]);Number.isFinite(bt)&&we.push(bt)}const je=we.length;if(je<3)return null;let Pe=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.min(10,je-1);Pe=Math.max(1,Math.min(Pe,je-1));let Ne=0;for(const pt of we)Ne+=pt;Ne/=je;const Le=we.map(pt=>pt-Ne);let Fe=0;for(const pt of Le)Fe+=pt*pt;Fe/=je;const De=new Array(Pe+1).fill(0);De[0]=1;for(let pt=1;pt<=Pe;pt++){let bt=0;for(let ft=pt;ft<je;ft++)bt+=Le[ft]*Le[ft-pt];De[pt]=Fe>0?bt/je/Fe:0}const Ze=new Array(Pe+1).fill(0);Ze[0]=1;let Ye=[];for(let pt=1;pt<=Pe;pt++){let bt=De[pt];for(let Ee=1;Ee<pt;Ee++)bt-=Ye[Ee-1]*De[pt-Ee];let ft=1;for(let Ee=1;Ee<pt;Ee++)ft-=Ye[Ee-1]*De[Ee];const kt=ft!==0?bt/ft:0,St=new Array(pt);for(let Ee=1;Ee<pt;Ee++)St[Ee-1]=Ye[Ee-1]-kt*Ye[pt-1-Ee];St[pt-1]=kt,Ze[pt]=kt,Ye=St}const mt=1.96/Math.sqrt(je);return{acf:De,pacf:Ze,bounds:{upper:mt,lower:-mt},n:je,nlags:Pe,approximate:!0}}function He(me,ke,we){const{xs:je,ys:Pe,n:Ne}=T(me,ke,we);if(Ne<2)return null;const Le=oe(je),Fe=oe(Pe);let De=0,Ze=0;for(let bt=0;bt<Ne;bt++)De+=Le[bt],Ze+=Fe[bt];De/=Ne,Ze/=Ne;let Ye=0,mt=0,pt=0;for(let bt=0;bt<Ne;bt++){const ft=Le[bt]-De,kt=Fe[bt]-Ze;Ye+=ft*kt,mt+=ft*ft,pt+=kt*kt}return mt===0||pt===0?null:Math.max(-1,Math.min(1,Ye/Math.sqrt(mt*pt)))}function Oe(me,ke,we){const{xs:je,ys:Pe,n:Ne}=T(me,ke,we);if(Ne<2||Ne>n)return null;let Le=0,Fe=0,De=0,Ze=0;for(let pt=0;pt<Ne;pt++)for(let bt=pt+1;bt<Ne;bt++){const ft=Math.sign(je[pt]-je[bt]),kt=Math.sign(Pe[pt]-Pe[bt]),St=ft*kt;St>0?Le++:St<0?Fe++:ft===0&&kt===0||(ft===0?De++:Ze++)}const Ye=Le+Fe+Ze,mt=Le+Fe+De;return Ye===0||mt===0?null:(Le-Fe)/Math.sqrt(Ye*mt)}function Ie(me,ke={}){const we=me.length;if(we<2)return null;const je=me[0],Pe=me[we-1],Ne=[];for(let Ee=1;Ee<we;Ee++){const tt=me[Ee-1];tt!==0&&Ne.push((me[Ee]-tt)/Math.abs(tt))}let Le=null;if(Ne.length>1){let Ee=0;for(const rt of Ne)Ee+=rt;Ee/=Ne.length;let tt=0;for(const rt of Ne)tt+=(rt-Ee)**2;Le=Math.sqrt(tt/(Ne.length-1))}const Fe=Number(ke.periodsPerYear)>0?Number(ke.periodsPerYear):null;let De=me[0],Ze=0,Ye=0,mt=0,pt=0;for(let Ee=1;Ee<we;Ee++){if(me[Ee]>De){De=me[Ee],Ze=Ee;continue}if(De<=0)continue;const tt=(De-me[Ee])/De;tt>Ye&&(Ye=tt,mt=Ze,pt=Ee)}let bt=null;if(we>2){let Ee=0;for(let ht=0;ht<we;ht++)Ee+=me[ht];Ee/=we;let tt=0,rt=0;for(let ht=0;ht<we;ht++){const It=me[ht]-Ee;rt+=It*It,ht>0&&(tt+=It*(me[ht-1]-Ee))}bt=rt>0?tt/rt:null}let ft=0,kt=0;for(const Ee of Ne)Ee>0?ft++:Ee<0&&kt++;let St=null;if(je>0&&Pe>0){const Ee=(Pe/je)**(1/(we-1))-1;St=Fe?(1+Ee)**Fe-1:Ee}return{n:we,first:je,last:Pe,change:Pe-je,changePercent:je===0?null:(Pe-je)/Math.abs(je)*100,volatility:Le,annualisedVolatility:Le!==null&&Fe?Le*Math.sqrt(Fe):null,growth:St,maxDrawdown:Ye,maxDrawdownFrom:mt,maxDrawdownTo:pt,autocorrelation:bt,upDays:ft,downDays:kt}}const $e=1.128,qe=3.267;function Ue(me){const ke=me.length;if(ke<2)return null;const we=[];for(let Pe=1;Pe<ke;Pe++)we.push(Math.abs(me[Pe]-me[Pe-1]));const je=we.reduce((Pe,Ne)=>Pe+Ne,0)/we.length;return{ranges:we,centre:je,upper:qe*je,lower:0}}function Je(me){const ke=me.length;if(ke<2)return null;let we=0;for(let Pe=1;Pe<ke;Pe++)we+=Math.abs(me[Pe]-me[Pe-1]);const je=we/(ke-1);return{sigma:je/$e,meanRange:je}}function at(me,ke){const we=me.length;if(we<2||!ke)return null;const je=Number.isFinite(Number(ke.lower))?Number(ke.lower):null,Pe=Number.isFinite(Number(ke.upper))?Number(ke.upper):null;if(je===null&&Pe===null)return null;let Ne=0;for(let ft=0;ft<we;ft++)Ne+=me[ft];Ne/=we;let Le=0;for(let ft=0;ft<we;ft++)Le+=(me[ft]-Ne)**2;const Fe=Math.sqrt(Le/(we-1)),De=Je(me),Ze=De?De.sigma:null,Ye=ft=>{if(!ft||ft<=0)return{index:null,k:null};const St=je!==null&&Pe!==null?(Pe-je)/(6*ft):null,Ee=Pe!==null?(Pe-Ne)/(3*ft):1/0,tt=je!==null?(Ne-je)/(3*ft):1/0;return{index:St,k:Math.min(Ee,tt)}},mt=Ye(Ze),pt=Ye(Fe);let bt=0;for(let ft=0;ft<we;ft++){if(je!==null&&me[ft]<je){bt++;continue}Pe!==null&&me[ft]>Pe&&bt++}return{n:we,mean:Ne,lower:je,upper:Pe,target:Number.isFinite(Number(ke.target))?Number(ke.target):null,sigmaWithin:Ze,sigmaOverall:Fe,cp:mt.index,cpk:mt.k,pp:pt.index,ppk:pt.k,outOfSpec:bt,defectRate:we?bt/we:null}}function Ae(me){const ke=me.length;if(ke<2)return null;const we=Je(me);if(!we||!(we.sigma>0))return null;let je=0;for(let Pe=0;Pe<ke;Pe++)je+=me[Pe];return je/=ke,{centre:je,sigma:we.sigma,upper:je+3*we.sigma,lower:je-3*we.sigma}}function We(me,ke){if(!ke||!(ke.sigma>0))return[];const we=me.length,{centre:je,sigma:Pe}=ke,Ne=Fe=>(me[Fe]-je)/Pe,Le=[];for(let Fe=0;Fe<we;Fe++){if(Math.abs(Ne(Fe))>3&&Le.push({index:Fe,rule:1,description:"beyond three sigma"}),Fe>=2)for(const De of[1,-1]){let Ze=0;for(let Ye=Fe-2;Ye<=Fe;Ye++)Ne(Ye)*De>2&&Ze++;if(Ze>=2){Le.push({index:Fe,rule:2,description:"two of three past two sigma"});break}}if(Fe>=4)for(const De of[1,-1]){let Ze=0;for(let Ye=Fe-4;Ye<=Fe;Ye++)Ne(Ye)*De>1&&Ze++;if(Ze>=4){Le.push({index:Fe,rule:3,description:"four of five past one sigma"});break}}if(Fe>=7)for(const De of[1,-1]){let Ze=!0;for(let Ye=Fe-7;Ye<=Fe;Ye++)if(Ne(Ye)*De<=0){Ze=!1;break}if(Ze){Le.push({index:Fe,rule:4,description:"eight in a row on one side"});break}}}return Le}function Ge(me,ke){if(!ke||!(ke.sigma>0))return[];const we=me.length,{centre:je,sigma:Pe}=ke,Ne=De=>(me[De]-je)/Pe,Le=(De,Ze,Ye,mt)=>{for(const pt of[1,-1]){let bt=0;for(let ft=De;ft<=Ze;ft++)Ne(ft)*pt>Ye&&bt++;if(bt>=mt)return!0}return!1},Fe=[];for(let De=0;De<we;De++){if(Math.abs(Ne(De))>3&&Fe.push({index:De,rule:1,description:"beyond three sigma"}),De>=8)for(const Ze of[1,-1]){let Ye=!0;for(let mt=De-8;mt<=De;mt++)if(Ne(mt)*Ze<=0){Ye=!1;break}if(Ye){Fe.push({index:De,rule:2,description:"nine in a row on one side"});break}}if(De>=5)for(const Ze of[1,-1]){let Ye=!0;for(let mt=De-4;mt<=De;mt++)if((me[mt]-me[mt-1])*Ze<=0){Ye=!1;break}if(Ye){Fe.push({index:De,rule:3,description:Ze>0?"six rising":"six falling"});break}}if(De>=13){let Ze=!0;for(let Ye=De-12;Ye<=De;Ye++){const mt=me[Ye]-me[Ye-1],pt=me[Ye+1<=De?Ye+1:Ye]-me[Ye];if(Ye+1>De)break;if(mt===0||pt===0||mt>0==pt>0){Ze=!1;break}}Ze&&Fe.push({index:De,rule:4,description:"fourteen alternating"})}if(De>=2&&Le(De-2,De,2,2)&&Fe.push({index:De,rule:5,description:"two of three past two sigma"}),De>=4&&Le(De-4,De,1,4)&&Fe.push({index:De,rule:6,description:"four of five past one sigma"}),De>=14){let Ze=!0;for(let Ye=De-14;Ye<=De;Ye++)if(Math.abs(Ne(Ye))>=1){Ze=!1;break}Ze&&Fe.push({index:De,rule:7,description:"fifteen within one sigma"})}if(De>=7){let Ze=!0;for(let Ye=De-7;Ye<=De;Ye++)if(Math.abs(Ne(Ye))<=1){Ze=!1;break}Ze&&Fe.push({index:De,rule:8,description:"eight beyond one sigma"})}}return Fe}const Qe=Object.freeze(["westernElectric","nelson"]);function lt(me,ke,we="westernElectric"){return String(we)==="nelson"?Ge(me,ke):We(me,ke)}function wt(me,ke,we){let je=0;for(let Pe=0;Pe<me.length;Pe++)(me[Pe]<ke||me[Pe]>we)&&je++;return je}function Pt(me,ke,we,je=20){const Pe=me.length;if(!Pe)return[];const Ne=me[0],Le=me[Pe-1];if(Le===Ne)return[{from:Ne,to:Le,count:Pe}];const Fe=we-ke,De=1.5*Fe;let Ze=Fe>0?Math.max(Ne,ke-De):Ne,Ye=Fe>0?Math.min(Le,we+De):Le;Ye>Ze||(Ze=Ne,Ye=Le);const mt=Fe>0?2*Fe/Math.cbrt(Pe):(Ye-Ze)/(Math.ceil(Math.log2(Pe))+1),pt=mt>0?Math.min(je,Math.max(1,Math.ceil((Ye-Ze)/mt))):1,bt=(Ye-Ze)/pt,ft=[];for(let kt=0;kt<pt;kt++)ft.push({from:Ze+kt*bt,to:Ze+(kt+1)*bt,count:0});for(let kt=0;kt<Pe;kt++){const St=Math.min(pt-1,Math.max(0,Math.floor((me[kt]-Ze)/bt)));ft[St].count++}return ft[0].from=Ne,ft[pt-1].to=Le,ft}const Ft=.95;function Rt(me){const ke=Number(me);return Number.isFinite(ke)&&ke>0&&ke<1?ke:Ft}function $t(me,ke=Ft){const we=me.length;if(we<2)return null;let je=0;for(let Ye=0;Ye<we;Ye++)je+=me[Ye];const Pe=je/we;let Ne=0;for(let Ye=0;Ye<we;Ye++){const mt=me[Ye]-Pe;Ne+=mt*mt}const Le=Math.sqrt(Ne/(we-1)),Fe=Rt(ke),Ze=W(1-(1-Fe)/2,we-1)*Le/Math.sqrt(we);return{mean:Pe,lower:Pe-Ze,upper:Pe+Ze,margin:Ze,n:we,confidence:Fe}}function zt(me,ke,we=Ft){const je=Number(me),Pe=Number(ke);if(!(Pe>0)||!(je>=0)||je>Pe)return null;const Ne=Rt(we),Le=H(1-(1-Ne)/2),Fe=je/Pe,De=Le*Le,Ze=1+De/Pe,Ye=(Fe+De/(2*Pe))/Ze,mt=Le/Ze*Math.sqrt(Fe*(1-Fe)/Pe+De/(4*Pe*Pe));return{proportion:Fe,lower:Math.max(0,Ye-mt),upper:Math.min(1,Ye+mt),n:Pe,confidence:Ne}}function _t(me,ke=Ft){if(!me||!(me.n>2)||!Number.isFinite(me.stdError))return null;const we=Rt(ke),Pe=W(1-(1-we)/2,me.n-2)*me.stdError;return{slope:me.slope,lower:me.slope-Pe,upper:me.slope+Pe,margin:Pe,confidence:we}}function Qt(me,ke,we=Ft){const je=Number(me),Pe=Number(ke);if(!Number.isFinite(je)||!(Pe>1))return null;const Ne=Rt(we),Fe=H(1-(1-Ne)/2)*Math.sqrt(1/(9*Pe)+je*je/(2*(Pe-1)));return{index:je,lower:je-Fe,upper:je+Fe,margin:Fe,n:Pe,confidence:Ne}}function ct(me,ke){return!me||!(me.sd>0)||!Number.isFinite(ke)||!Number.isFinite(me.mean)?null:(ke-me.mean)/me.sd}function de(me){return Number.isFinite(me)?Math.min(1,Math.max(0,2*U(Math.abs(me)/2)-1)):0}function ge(me,ke){const we=new Map,je=$(me);let Pe=0;for(let Ne=0;Ne<ke.length;Ne++){const Le=je(ke[Ne]);if(Le==null||Le===""||typeof Le=="number"&&Number.isNaN(Le))continue;const Fe=Le instanceof Date?Le.getTime():typeof Le=="object"?String(Le):Le;we.set(Fe,(we.get(Fe)||0)+1),Pe++}return{map:we,total:Pe}}function Te(me,ke,we,je){if(!(ke>0)||!(je>0))return null;let Pe=0;const Ne=new Set(me.keys());for(const Le of we.keys())Ne.add(Le);for(const Le of Ne){const Fe=(me.get(Le)||0)/ke,De=(we.get(Le)||0)/je;Pe+=Math.abs(Fe-De)}return Pe/2}const Be=10;function Ve(me,ke,we){if(we&&we.numeric){const Fe=d(me,ke),{n:De,mean:Ze}=v(Fe),Ye=De>0?ct({mean:we.mean,sd:we.sd},Ze):null;return{measure:"standardizedMeanDifference",magnitude:Ye,distance:Ye===null?0:de(Ye),direction:Ye===null?0:Math.sign(Ye),subsetN:De,populationN:we.n||0,reliable:De>=Be}}const{map:Pe,total:Ne}=ge(me,ke),Le=Te(Pe,Ne,we.map,we.total);return{measure:"categoricalTotalVariation",magnitude:Le,distance:Le===null?0:Le,direction:0,subsetN:Ne,populationN:we.total||0,reliable:Ne>=Be}}function it(me,ke){if(me&&(me.kind==="float64"||me.kind==="int32"))return!0;const we=$(me);let je=0,Pe=0;for(let Ne=0;Ne<ke.length&&je<200;Ne++){const Le=we(ke[Ne]);if(Le==null||Le==="")continue;if(Le instanceof Date)return!1;je++;const Fe=typeof Le=="number"?Le:Number(Le);Number.isFinite(Fe)&&Pe++}return je===0?!1:Pe/je>=.9}function dt(me,ke){if(it(me,ke)){const Pe=d(me,ke),{n:Ne,mean:Le,m2:Fe}=v(Pe);return{numeric:!0,mean:Le,sd:Ne>0?Math.sqrt(Fe/Ne):0,n:Ne}}const{map:we,total:je}=ge(me,ke);return{numeric:!1,map:we,total:je}}}),Se("packages/core/src/compute/total.js",function(e,V){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,L=V("packages/core/src/compute/handle.js"),W=L.presenceReader,Z=L.valueComparator,H=L.valueReader,U=V("packages/core/src/compute/statistics.js"),z=U.STAT_FNS,F=U.STAT_LABELS;function k(v){return!!v&&(v.kind==="float64"||v.kind==="int32")}function S(v,u){const s=u.length;let O=0;if(k(v)){const A=v.values,M=W(v);if(!M){for(let C=0;C<s;C++){const P=A[u[C]];Number.isNaN(P)||(O+=P)}return O}for(let C=0;C<s;C++){const P=u[C];if(M(P)===1){const D=A[P];Number.isNaN(D)||(O+=D)}}return O}const E=H(v);for(let A=0;A<s;A++){const M=c(E(u[A]));M!==null&&(O+=M)}return O}S.kernel=!0;function b(v,u){const s=u.length;let O=0;if(k(v)){const A=v.values,M=W(v);if(!M){for(let C=0;C<s;C++)Number.isNaN(A[u[C]])||O++;return O}for(let C=0;C<s;C++){const P=u[C];M(P)===1&&!Number.isNaN(A[P])&&O++}return O}const E=H(v);for(let A=0;A<s;A++){const M=E(u[A]);M!=null&&!(typeof M=="number"&&Number.isNaN(M))&&O++}return O}b.kernel=!0;function a(v,u){return u.length}a.kernel=!0;function l(v,u){const s=b(v,u);return s===0?null:S(v,u)/s}l.kernel=!0;function r(v,u,s,O){const E=u.length;if(k(v)){const P=v.values,D=W(v);let K=null;if(!D){for(let x=0;x<E;x++){const I=P[u[x]];Number.isNaN(I)||(K===null||(s<0?I<K:I>K))&&(K=I)}return K}for(let x=0;x<E;x++){const I=u[x];if(D(I)===0)continue;const j=P[I];Number.isNaN(j)||(K===null||(s<0?j<K:j>K))&&(K=j)}return K}const A=H(v),M=Z(O);let C=null;for(let P=0;P<E;P++){const D=A(u[P]);D==null||typeof D=="number"&&Number.isNaN(D)||(C===null||(s<0?M(D,C)<0:M(D,C)>0))&&(C=D)}return C}function t(v,u,s){return r(v,u,-1,s&&s.locale)}t.kernel=!0;function n(v,u,s){return r(v,u,1,s&&s.locale)}n.kernel=!0;function i(v,u){return u.length===0?null:H(v)(u[0])}i.kernel=!0;function o(v,u){return u.length===0?null:H(v)(u[u.length-1])}o.kernel=!0;function c(v){if(typeof v=="number")return Number.isNaN(v)?null:v;if(v==null||v===""||typeof v=="boolean")return null;if(v instanceof Date)return v.getTime();const u=Number(v);return Number.isNaN(u)?null:u}const d={sum:S,min:t,max:n,avg:l,count:a,first:i,last:o,countValues:b,...z},f=Object.freeze({...F,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function h(v){return v?typeof v=="string"?f[v]||v:"Total":""}const g=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function y(v){const u=v&&v.dataType&&v.dataType.totals&&v.dataType.totals.supported;if(Array.isArray(u))return u.slice();const s=g.filter(O=>O in d);for(const O of Object.keys(d))s.includes(O)||s.push(O);return s}function p(v,u){return typeof u!="string"?!0:y(v).includes(u)}function m(v,u){const s=H(v),O=[];for(let E=0;E<u.length;E++){const A=s(u[E]);A!=null&&O.push(A)}return O}function w(v,u,s,O){const E=u||[];if(typeof s=="string"){const A=d[s];return A?A(v,E,O):($(`total:${s}`,`unknown total function "${s}"; register it in config.totalFns`),null)}return N(s)?s.kernel===!0?s(v,E,O):s(m(v,E),O||{}):null}}),Se("packages/core/src/compute/windowed.js",function(e,V){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/compute/sketch.js").Welford;class ${#e;#t;#n=[];#r;#o;constructor(U,z=0,F=Date.now){if(U!=="count"&&U!=="time"&&U!=="session")throw new RangeError(`unknown window kind: ${U}`);if((U==="count"||U==="time")&&!(z>0))throw new RangeError(`a ${U} window needs a positive span`);this.#e=U,this.#t=Math.floor(z),this.#r=F,this.#o=F()}get size(){return this.#n.length}push(U,z=this.#r()){Number.isFinite(U)&&(this.#n.push({t:z,v:U}),this.#i(z))}#i(U){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const z=U-this.#t;for(;this.#n.length&&this.#n[0].t<z;)this.#n.shift()}}spec(){const U=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:U,size:this.#n.length}}values(){return this.#n.map(U=>U.v)}aggregate(){const U=this.spec();if(!this.#n.length)return{over:U,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const z=new N;let F=0,k=1/0,S=-1/0;for(const{v:b}of this.#n)F+=b,b<k&&(k=b),b>S&&(S=b),z.add(b);return{over:U,count:this.#n.length,sum:F,mean:z.mean(),min:k,max:S,variance:z.variance(),stddev:z.stddev()}}reduce(U){const z=this.aggregate(),F={sum:z.sum,avg:z.mean,mean:z.mean,min:z.min,max:z.max,count:z.count,variance:z.variance,stddev:z.stddev};if(!(U in F))throw new RangeError(`unknown windowed aggregate: ${U}`);return{value:F[U],over:z.over}}}const L=Object.freeze(["count","time","session"]);function W(H,U=Date.now){const z=H.kind==="time"&&H.minutes!=null?H.minutes*6e4:H.span??0;return new $(H.kind,z,U)}const Z={Window:$,WINDOW_KINDS:L,openWindow:W}}),Se("packages/core/src/compute/rolling.js",function(e,V){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const N=V("packages/core/src/compute/windowed.js").openWindow,L=V("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(f,h,g,y){if(f.kind==="count"){const p=Math.max(1,Math.floor(f.span||0));return{coverage:Math.min(1,h/p),partial:h<p}}if(f.kind==="time"){const p=f.minutes!=null?f.minutes*6e4:f.span||0;if(!(p>0))return{coverage:1,partial:!1};const m=g-y;return{coverage:Math.min(1,m/p),partial:m<p}}return{coverage:null,partial:!1}}function H(f,h){const g=N(h),y=new Map,p=f.length?f[0].at:0;for(let m=0;m<f.length;m++){const{key:w,at:v,value:u}=f[m];Number.isFinite(u)&&g.push(u,v);const s=g.aggregate(),O=Z(h,s.count,v,p);w!=null&&y.set(String(w),{sum:s.sum,avg:s.mean,min:s.min,max:s.max,count:s.count,coverage:O.coverage,partial:O.partial})}return y}function U(f){const h=new Map;let g=0;for(const{key:y,value:p}of f)Number.isFinite(p)&&(g+=p),y!=null&&h.set(String(y),g);return h}function z(f,h=1){const g=new Map,y=Math.max(1,Math.floor(h));for(let p=0;p<f.length;p++){const{key:m,value:w}=f[p];if(m==null)continue;const v=p>=y?f[p-y].value:null,u=Number.isFinite(w)?w:null,s=Number.isFinite(v)?v:null;g.set(String(m),u!==null&&s!==null?u-s:null)}return g}const F=4096;function k(f){let h=f>>>0;return()=>{h+=1831565813;let g=h;return g=Math.imul(g^g>>>15,g|1),g^=g+Math.imul(g^g>>>7,g|61),((g^g>>>14)>>>0)/4294967296}}function S(f,h){const g=f.length;if(g===1)return f[0];const y=(g-1)*h,p=Math.floor(y),m=Math.ceil(y);return p===m?f[p]:f[p]+(y-p)*(f[m]-f[p])}function b(f,h,g={}){const y=Math.min(1,Math.max(0,g.q==null?.5:g.q)),p=Math.max(1,Math.floor(g.cap==null?F:g.cap)),m=k(g.seed==null?2654435769:g.seed),w=new Map,v=f.length?f[0].at:0;if(h.kind==="session"){const s=new L(200,m);let O=0;for(const{key:E,value:A}of f)Number.isFinite(A)&&(s.add(A),O++),E!=null&&w.set(String(E),{value:O?s.quantile(y):null,approx:O>0,count:O,coverage:null,partial:!1});return w}const u=N(h);for(const{key:s,at:O,value:E}of f){Number.isFinite(E)&&u.push(E,O);const A=u.values(),M=A.length;let C=null,P=!1;if(M)if(M<=p)C=S([...A].sort((K,x)=>K-x),y);else{const K=new L(200,m);for(const x of A)K.add(x);C=K.quantile(y),P=!0}const D=Z(h,M,O,v);s!=null&&w.set(String(s),{value:C,approx:P,count:M,coverage:D.coverage,partial:D.partial})}return w}function a(f,h){const g=f.length,y=new Array(g).fill(null),p=Math.floor(h/2),m=h%2===0;for(let w=0;w<g;w++){if(w-p<0||w+p>=g)continue;let v=0,u=!0;if(m)for(let s=-p;s<=p;s++){const O=f[w+s];if(!Number.isFinite(O)){u=!1;break}v+=s===-p||s===p?O*.5:O}else for(let s=-p;s<=p;s++){const O=f[w+s];if(!Number.isFinite(O)){u=!1;break}v+=O}u&&(y[w]=v/h)}return y}function l(f,h){const g=new Map,y=Math.floor(Number(h&&h.period));if(!(y>=2))return g;const p=h&&h.model==="multiplicative",m=f.length,w=f.map(P=>Number.isFinite(P.value)?P.value:null),v=a(w,y),u=new Array(m).fill(null);for(let P=0;P<m;P++){const D=v[P],K=w[P];D===null||K===null||(p?D!==0&&(u[P]=K/D):u[P]=K-D)}const s=new Array(y).fill(0),O=new Array(y).fill(0);for(let P=0;P<m;P++){if(u[P]===null)continue;const D=P%y;s[D]+=u[P],O[D]+=1}const E=p?1:0,A=s.map((P,D)=>O[D]?P/O[D]:E),M=A.reduce((P,D)=>P+D,0)/y,C=p?A.map(P=>M!==0?P/M:1):A.map(P=>P-M);for(let P=0;P<m;P++){const{key:D}=f[P];if(D==null)continue;const K=v[P],x=C[P%y],I=w[P];let j=null;K!==null&&I!==null&&(j=p?K*x!==0?I/(K*x):null:I-K-x),g.set(String(D),{trend:K,seasonal:I===null?null:x,residual:j,coverage:K===null?0:1,partial:K===null})}return g}function r(f,h,g,y=80){const p=(Math.sqrt(5)-1)/2;let m=h,w=g,v=w-p*(w-m),u=m+p*(w-m),s=f(v),O=f(u);for(let E=0;E<y;E++)s<O?(w=u,u=v,O=s,v=w-p*(w-m),s=f(v)):(m=v,v=u,s=O,u=m+p*(w-m),O=f(u));return(m+w)/2}const t=1e-4,n=1-1e-4;function i(f,h){const g=f.length,y=new Array(g).fill(null),p=new Array(g).fill(null);let m=null,w=0;for(let v=0;v<g;v++){const u=f[v];if(!Number.isFinite(u)){m!==null&&(p[v]=m,y[v]=m);continue}if(m===null){m=u,p[v]=u,y[v]=u;continue}p[v]=m,w+=(u-m)**2,m=h*u+(1-h)*m,y[v]=m}return{smoothed:y,fitted:p,sse:w}}function o(f,h,g){const y=f.length,p=new Array(y).fill(null),m=new Array(y).fill(null);let w=null,v=null,u=0;for(let s=0;s<y;s++){const O=f[s];if(!Number.isFinite(O)){w!==null&&(w+=v,p[s]=w);continue}if(w===null){w=O,p[s]=O;continue}if(v===null){v=O-w;const M=w+v;m[s]=M,u+=(O-M)**2;const C=w;w=h*O+(1-h)*(C+v),v=g*(w-C)+(1-g)*v,p[s]=w;continue}const E=w+v;m[s]=E,u+=(O-E)**2;const A=w;w=h*O+(1-h)*(A+v),v=g*(w-A)+(1-g)*v,p[s]=w}return{smoothed:p,fitted:m,sse:u}}function c(f,h={}){const g=new Map,y=h.method==="holt",p=f.map(E=>Number.isFinite(E.value)?E.value:null),m=p.filter(E=>E!==null).length,w=E=>Math.min(n,Math.max(t,E)),v=()=>{for(const{key:E}of f)E!=null&&g.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return g};if(m<(y?2:1))return v();let u=Number.isFinite(h.alpha)?w(h.alpha):null,s=y&&Number.isFinite(h.beta)?w(h.beta):null;if(y){if(u===null||s===null){let E=u===null?.5:u,A=s===null?.5:s;for(let M=0;M<6;M++)u===null&&(E=r(C=>o(p,C,A).sse,t,n)),s===null&&(A=r(C=>o(p,E,C).sse,t,n));u=u===null?E:u,s=s===null?A:s}}else u===null&&(u=r(E=>i(p,E).sse,t,n));const O=y?o(p,u,s):i(p,u);for(let E=0;E<f.length;E++){const{key:A}=f[E];A!=null&&g.set(String(A),{smoothed:O.smoothed[E],fitted:O.fitted[E],alpha:u,beta:y?s:null,sse:O.sse})}return g}const d={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:F,rollingWindow:H,rollingQuantile:b,cumulativeToDate:U,periodOverPeriod:z,seasonalDecompose:l,exponentialSmoothing:c}}),Se("packages/core/src/compute/compare.js",function(e,V){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return a}});const _=V("packages/core/src/compute/statistics.js"),N=_.numbers,$=_.moments,L=_.frequencyMap,W=_.categoricalDistance,Z=_.normalTotalVariation,H=_.isNumericColumn,U=_.SUBSET_RELIABILITY_FLOOR,z=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function F(l,r){if(!l||!r||!(l.n>0)||!(r.n>0)||!Number.isFinite(l.mean)||!Number.isFinite(r.mean))return null;const t=(l.n*l.sd*l.sd+r.n*r.sd*r.sd)/(l.n+r.n);return t>0?(l.mean-r.mean)/Math.sqrt(t):null}function k(l,r){const t=N(l,r),{n,mean:i,m2:o}=$(t),c=n>0?Math.sqrt(o/n):0;return{mean:i,sd:c,n}}function S(l,r,t,n){return H(l,r)&&H(t,n)}function b(l,r,t,n){if(S(l,r,t,n)){const d=k(l,r),f=k(t,n),h=F(d,f);return{measure:z.numeric,magnitude:h,distance:h===null?0:Z(h),direction:h===null?0:Math.sign(h),nA:d.n,nB:f.n,reliable:d.n>=U&&f.n>=U}}const i=L(l,r),o=L(t,n),c=W(i.map,i.total,o.map,o.total);return{measure:z.categorical,magnitude:c,distance:c===null?0:c,direction:0,nA:i.total,nB:o.total,reliable:i.total>=U&&o.total>=U}}function a(l,r,t={}){const n=new Set(l.columns),i=new Set(r.columns),o=l.columns.filter(g=>i.has(g)),c=Array.isArray(t.columns)&&t.columns.length?o.filter(g=>t.columns.includes(g)):o,d=l.indices(),f=r.indices(),h=[];for(const g of c){const y=l.handle(g),p=r.handle(g);if(!y||!p)continue;const m=b(y,d,p,f);h.push({column:g,name:l.name&&l.name(g)||r.name&&r.name(g)||g,measure:m.measure,magnitude:m.magnitude,distance:m.distance,direction:m.direction,nA:m.nA,nB:m.nB,reliable:m.reliable})}return h.sort((g,y)=>y.distance-g.distance||Math.abs(y.magnitude||0)-Math.abs(g.magnitude||0)),{ranked:h,nA:d.length,nB:f.length,unmatched:{onlyA:l.columns.filter(g=>!i.has(g)),onlyB:r.columns.filter(g=>!n.has(g))},measures:z}}}),Se("packages/core/src/compute/anomaly.js",function(e,V){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return d}});const N=V("packages/core/src/compute/statistics.js").quantileSorted,L=V("packages/core/src/compute/special.js").logGamma,W=.6745,Z=3.5,H=1.5,U=.975,z=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function F(f){if(!f.length)return null;const g=Array.from(f,Number).sort((w,v)=>w-v),y=N(g,.5),p=g.map(w=>Math.abs(w-y)).sort((w,v)=>w-v),m=N(p,.5);return{median:y,mad:m}}function k(f,h={}){const g=Number.isFinite(h.threshold)?h.threshold:Z,y=f.length,p=new Array(y).fill(null),m=new Array(y).fill(!1),w=[];for(let s=0;s<y;s++){const O=Number(f[s]);Number.isFinite(O)&&w.push(O)}if(!w.length)return{median:null,mad:null,threshold:g,scores:p,flags:m,flagged:0};const v=F(w);if(v.mad===0)return{median:v.median,mad:0,threshold:g,scores:p,flags:m,flagged:0};let u=0;for(let s=0;s<y;s++){const O=Number(f[s]);if(!Number.isFinite(O))continue;const E=W*(O-v.median)/v.mad;p[s]=E,Math.abs(E)>g&&(m[s]=!0,u++)}return{median:v.median,mad:v.mad,threshold:g,scores:p,flags:m,flagged:u}}function S(f,h={}){const g=Number.isFinite(h.k)?h.k:H,y=[];for(let u=0;u<f.length;u++){const s=Number(f[u]);Number.isFinite(s)&&y.push(s)}if(!y.length)return null;const p=y.sort((u,s)=>u-s),m=N(p,.25),w=N(p,.75),v=w-m;return{q1:m,q3:w,iqr:v,lower:m-g*v,upper:w+g*v,k:g}}function b(f,h){if(h<=0)return 0;const g=L(f);if(h<f+1){let s=f,O=1/f,E=O;for(let A=0;A<1e3&&(s+=1,E*=h/s,O+=E,!(Math.abs(E)<Math.abs(O)*1e-15));A++);return O*Math.exp(-h+f*Math.log(h)-g)}const y=1e-300;let p=h+1-f,m=1/y,w=1/p,v=w;for(let s=1;s<1e3;s++){const O=-s*(s-f);p+=2,w=O*w+p,Math.abs(w)<y&&(w=y),m=p+O/m,Math.abs(m)<y&&(m=y),w=1/w;const E=w*m;if(v*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-h+f*Math.log(h)-g)*v}function a(f,h){return f<=0?0:b(h/2,f/2)}function l(f,h=U){if(!(h>0)||!(h<1))return NaN;let g=0,y=Math.max(1,f);for(;a(y,f)<h;)y*=2;for(let p=0;p<200;p++){const m=(g+y)/2;if(a(m,f)<h?g=m:y=m,y-g<1e-10)break}return(g+y)/2}function r(f){const h=f.length,g=f.map((y,p)=>{const m=y.slice();for(let w=0;w<h;w++)m.push(p===w?1:0);return m});for(let y=0;y<h;y++){let p=y;for(let w=y+1;w<h;w++)Math.abs(g[w][y])>Math.abs(g[p][y])&&(p=w);if(Math.abs(g[p][y])<1e-12)return null;if(p!==y){const w=g[p];g[p]=g[y],g[y]=w}const m=g[y][y];for(let w=0;w<2*h;w++)g[y][w]/=m;for(let w=0;w<h;w++){if(w===y)continue;const v=g[w][y];if(v!==0)for(let u=0;u<2*h;u++)g[w][u]-=v*g[y][u]}}return g.map(y=>y.slice(h))}function t(f,h){const g=f.length,y=new Array(h).fill(0);for(const w of f)for(let v=0;v<h;v++)y[v]+=w[v];for(let w=0;w<h;w++)y[w]/=g;const p=Array.from({length:h},()=>new Array(h).fill(0));for(const w of f)for(let v=0;v<h;v++){const u=w[v]-y[v];for(let s=v;s<h;s++)p[v][s]+=u*(w[s]-y[s])}const m=g>1?g-1:1;for(let w=0;w<h;w++)for(let v=w;v<h;v++)p[w][v]/=m,p[v][w]=p[w][v];return{mean:y,cov:p}}function n(f,h={}){const g=Number.isFinite(h.p)?h.p:U,y=Number.isFinite(h.ridge)?h.ridge:1e-6,p=f.length;if(!p)return null;const m=f[0].length;if(!m)return null;const w=new Array(p).fill(null),v=new Array(p).fill(null),u=new Array(p).fill(!1),s=[],O=[];for(let x=0;x<p;x++){const I=f[x];let j=I.length===m;const T=new Array(m);for(let B=0;j&&B<m;B++){const q=Number(I[B]);Number.isFinite(q)?T[B]=q:j=!1}j&&(s.push(x),O.push(T))}const E=m,A=l(E,g);if(O.length<=m)return{center:[],df:E,cutoff:A,singular:!0,used:O.length,distances:w,squared:v,flags:u,flagged:0};const{mean:M,cov:C}=t(O,m);let P=r(C),D=!1;if(!P){D=!0;let x=0;for(let T=0;T<m;T++)x+=C[T][T];const I=x/m*y||y,j=C.map((T,B)=>T.map((q,X)=>B===X?q+I:q));if(P=r(j),!P)return{center:M,df:E,cutoff:A,singular:!0,used:O.length,distances:w,squared:v,flags:u,flagged:0}}let K=0;for(let x=0;x<O.length;x++){const I=O[x],j=new Array(m);for(let q=0;q<m;q++)j[q]=I[q]-M[q];let T=0;for(let q=0;q<m;q++){let X=0;for(let Q=0;Q<m;Q++)X+=P[q][Q]*j[Q];T+=j[q]*X}T<0&&(T=0);const B=s[x];v[B]=T,w[B]=Math.sqrt(T),T>A&&(u[B]=!0,K++)}return{center:M,df:E,cutoff:A,singular:D,used:O.length,distances:w,squared:v,flags:u,flagged:K}}const i=20,o=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function c(f,h={}){const g=h.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",y=Number.isFinite(h.windowLen)&&h.windowLen>=1?Math.floor(h.windowLen):i,p=Number.isFinite(h.threshold)?h.threshold:Z,m=Number.isFinite(h.k)?h.k:H,w=Number.isFinite(h.minPeriods)&&h.minPeriods>=1?Math.floor(h.minPeriods):y,v=f.length,u=new Array(v).fill(null),s=new Array(v).fill(!1);let O=0;for(let E=0;E<v;E++){const A=Number(f[E]);if(!Number.isFinite(A))continue;const M=Math.max(0,E-y+1),C=[];for(let P=M;P<=E;P++){const D=Number(f[P]);Number.isFinite(D)&&C.push(D)}if(!(C.length<w))if(g==="rollingIqr"){const P=S(C,{k:m});if(!P)continue;(A<P.lower||A>P.upper)&&(s[E]=!0,O++)}else{const P=F(C);if(!P||P.mad===0)continue;const D=W*(A-P.median)/P.mad;u[E]=D,Math.abs(D)>p&&(s[E]=!0,O++)}}return{method:g,windowLen:y,minPeriods:w,threshold:p,k:m,scores:u,flags:s,flagged:O}}function d(f={}){const h=f||{},g=h.field;if(typeof g!="string"||!g)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const y=h.method||"modifiedZScore";if(!(z.includes(y)||o.includes(y))||y==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${y}'`);const m=typeof h.orderBy=="string"?h.orderBy:null,w=h.latest===!0,v=o.includes(y),u=s=>Number(s==null?NaN:s[g]);return s=>{const O=Array.isArray(s)?s.slice():[...s];m&&O.sort((P,D)=>{const K=P?.[m],x=D?.[m];return K===x?0:K==null?-1:x==null?1:K<x?-1:1});const E=O.map(u);let A,M;if(v)({flags:A,scores:M}=c(E,{method:y,windowLen:h.windowLen,threshold:h.threshold,k:h.k,minPeriods:h.minPeriods}));else if(y==="iqr"){const P=S(E,{k:h.k});A=E.map(D=>P?Number.isFinite(D)&&(D<P.lower||D>P.upper):!1),M=E.map(()=>null)}else({flags:A,scores:M}=k(E,{threshold:h.threshold}));if(w){const P=A.length-1;return P<0||!A[P]?!1:{method:y,field:g,flagged:[{row:O[P],score:M[P]}]}}const C=[];for(let P=0;P<A.length;P++)A[P]&&C.push({row:O[P],score:M[P]});return C.length?{method:y,field:g,flagged:C}:!1}}}),Se("packages/core/src/compute/forecast.js",function(e,V){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const _=V("packages/core/src/compute/special.js"),N=_.normalQuantile,$=_.studentTQuantile,W=V("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),H=1e-4,U=1-1e-4;function z(h){const g=[];for(let y=0;y<h.length;y++){const p=h[y];if(p!==null&&typeof p=="object"){const m=Number.isFinite(p.at)?p.at:y,w=Number.isFinite(p.value)?p.value:null;g.push({at:m,value:w})}else g.push({at:y,value:Number.isFinite(p)?Number(p):null})}return g}function F(h){const g=h.filter(v=>v.value!==null),y=g[0],p=g[g.length-1],m=p.at-y.at,w=g.length>1&&m>0?m/(g.length-1):1;return{lastAt:p.at,step:w}}function k(h){return Math.min(U,Math.max(H,h))}function S(h,g=H,y=U,p=80){const m=(Math.sqrt(5)-1)/2;let w=g,v=y,u=v-m*(v-w),s=w+m*(v-w),O=h(u),E=h(s);for(let A=0;A<p;A++)O<E?(v=s,s=u,E=O,u=v-m*(v-w),O=h(u)):(w=u,u=s,O=E,s=w+m*(v-w),E=h(s));return(w+v)/2}function b(h,g){let y=null,p=0,m=0;for(let w=0;w<h.length;w++){const v=h[w];if(v!==null){if(y===null){y=v;continue}p+=(v-y)**2,m+=1,y=g*v+(1-g)*y}}return{level:y,sse:p,m}}function a(h,g,y){let p=null,m=null,w=0,v=0;for(let u=0;u<h.length;u++){const s=h[u];if(s===null){p!==null&&m!==null&&(p+=m);continue}if(p===null){p=s;continue}m===null&&(m=s-p);const O=p+m;w+=(s-O)**2,v+=1;const E=p;p=g*s+(1-g)*(E+m),m=y*(p-E)+(1-y)*m}return{level:p,trend:m,sse:w,m:v}}function l(h,g,y,p,m){const w=h.length;if(w<2*g)return null;const v=D=>{let K=0,x=0;for(let I=D;I<D+g&&I<w;I++)h[I]!==null&&(K+=h[I],x+=1);return x?K/x:null},u=v(0),s=v(g);if(u===null||s===null)return null;let O=u,E=(s-u)/g;const A=new Array(g).fill(0);for(let D=0;D<g;D++)A[D]=h[D]===null?0:h[D]-O;const M=A.reduce((D,K)=>D+K,0)/g;for(let D=0;D<g;D++)A[D]-=M;let C=0,P=0;for(let D=g;D<w;D++){const K=D%g,x=A[K],I=h[D];if(I===null){O+=E;continue}const j=O+E+x;C+=(I-j)**2,P+=1;const T=O;O=y*(I-x)+(1-y)*(O+E),E=p*(O-T)+(1-p)*E,A[K]=m*(I-O)+(1-m)*x}return{level:O,trend:E,season:A,phase:(w-1)%g,sse:C,count:P}}function r(h,g,y){let p=1;for(const w of g)p+=w*w;const m=Math.sqrt(h*p);return{se:m,margin:y*m}}function t(h,g={}){if(!h||typeof h.length!="number"||h.length===0)return null;const y=Z.includes(g.method)?g.method:"linear",p=Math.max(1,Math.floor(Number(g.horizon)||1)),m=Number.isFinite(g.confidence)&&g.confidence>0&&g.confidence<1?g.confidence:.95,w=1-(1-m)/2,v=z(h),u=v.map(C=>C.value),s=u.filter(C=>C!==null),O=s.length,{lastAt:E,step:A}=O?F(v):{lastAt:0,step:1},M=C=>E+C*A;return y==="linear"?n(v,O,p,m,w,M):y==="movingAverage"?i(s,O,p,m,w,g,M):y==="ses"?o(u,O,p,m,w,g,M):y==="holt"?c(u,O,p,m,w,g,M):d(u,O,p,m,w,g,M)}function n(h,g,y,p,m,w){if(g<2)return null;let v=0,u=0;for(const I of h)I.value!==null&&(v+=I.at,u+=I.value);v/=g,u/=g;let s=0,O=0,E=0;for(const I of h){if(I.value===null)continue;const j=I.at-v,T=I.value-u;s+=j*j,O+=j*T,E+=T*T}if(s===0)return null;const A=O/s,M=u-A*v,C=E===0?1:Math.max(0,Math.min(1,O*O/(s*E))),P=Math.max(0,E-A*O),D=g>2?Math.sqrt(P/(g-2)):null,K=g>2?$(m,g-2):null,x=[];for(let I=1;I<=y;I++){const j=w(I),T=M+A*j;let B=null,q=null,X=null,Q=null,te=null;if(D!==null){const re=1/g+(j-v)**2/s,ie=D*Math.sqrt(1+re),ae=D*Math.sqrt(re);te=ie,B=T-K*ie,q=T+K*ie,X=T-K*ae,Q=T+K*ae}x.push({step:I,at:j,mean:T,lower:B,upper:q,lowerMean:X,upperMean:Q,se:te})}return{method:"linear",horizon:y,confidence:p,n:g,sigma:D,r2:C,params:{slope:A,intercept:M},points:x}}function i(h,g,y,p,m,w,v){if(g<1)return null;const u=Math.max(1,Math.min(g,Math.floor(Number(w.windowLen)||g))),s=h.slice(g-u);let O=0;for(const D of s)O+=D;const E=O/u;let A=null,M=null;if(u>1){let D=0;for(const x of s)D+=(x-E)**2;A=Math.sqrt(D/(u-1))*Math.sqrt(1+1/u),M=$(m,u-1)}const C=A===null?null:M*A,P=[];for(let D=1;D<=y;D++)P.push({step:D,at:v(D),mean:E,lower:C===null?null:E-C,upper:C===null?null:E+C,se:A});return{method:"movingAverage",horizon:y,confidence:p,n:g,sigma:A===null?null:A,params:{windowLen:u},points:P}}function o(h,g,y,p,m,w,v){if(g<1)return null;let u=Number.isFinite(w.alpha)?k(w.alpha):null;u===null&&(u=S(M=>b(h,M).sse));const s=b(h,u),O=N(m),E=s.m>0?s.sse/s.m:null,A=[];for(let M=1;M<=y;M++){const C=s.level;let P=null,D=null,K=null;if(E!==null){const x=[];for(let j=1;j<M;j++)x.push(u);const I=r(E,x,O);K=I.se,P=C-I.margin,D=C+I.margin}A.push({step:M,at:v(M),mean:C,lower:P,upper:D,se:K})}return{method:"ses",horizon:y,confidence:p,n:g,sigma:E===null?null:Math.sqrt(E),params:{alpha:u},points:A}}function c(h,g,y,p,m,w,v){if(g<2)return null;let u=Number.isFinite(w.alpha)?k(w.alpha):null,s=Number.isFinite(w.beta)?k(w.beta):null;if(u===null||s===null){let P=u===null?.5:u,D=s===null?.5:s;for(let K=0;K<6;K++)u===null&&(P=S(x=>a(h,x,D).sse)),s===null&&(D=S(x=>a(h,P,x).sse));u=u===null?P:u,s=s===null?D:s}const O=a(h,u,s),E=N(m),A=O.m>0?O.sse/O.m:null,M=u*s,C=[];for(let P=1;P<=y;P++){const D=O.level+P*O.trend;let K=null,x=null,I=null;if(A!==null){const j=[];for(let B=1;B<P;B++)j.push(u+B*M);const T=r(A,j,E);I=T.se,K=D-T.margin,x=D+T.margin}C.push({step:P,at:v(P),mean:D,lower:K,upper:x,se:I})}return{method:"holt",horizon:y,confidence:p,n:g,sigma:A===null?null:Math.sqrt(A),params:{alpha:u,beta:s},points:C}}function d(h,g,y,p,m,w,v){const u=Math.floor(Number(w.period));if(!(u>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(g<2*u)return null;let s=Number.isFinite(w.alpha)?k(w.alpha):null,O=Number.isFinite(w.beta)?k(w.beta):null,E=Number.isFinite(w.gamma)?k(w.gamma):null;const A=(I,j,T)=>{const B=l(h,u,I,j,T);return B?B.sse:1/0};if(s===null||O===null||E===null){let I=s===null?.5:s,j=O===null?.5:O,T=E===null?.5:E;for(let B=0;B<8;B++)s===null&&(I=S(q=>A(q,j,T))),O===null&&(j=S(q=>A(I,q,T))),E===null&&(T=S(q=>A(I,j,q)));s=s===null?I:s,O=O===null?j:O,E=E===null?T:E}const M=l(h,u,s,O,E);if(!M)return null;const C=N(m),P=M.count>0?M.sse/M.count:null,D=s*O,K=E*(1-s),x=[];for(let I=1;I<=y;I++){const j=M.season[(M.phase+I)%u],T=M.level+I*M.trend+j;let B=null,q=null,X=null;if(P!==null){const Q=[];for(let re=1;re<I;re++)Q.push(s+re*D+(re%u===0?K:0));const te=r(P,Q,C);X=te.se,B=T-te.margin,q=T+te.margin}x.push({step:I,at:v(I),mean:T,lower:B,upper:q,se:X})}return{method:"holtWinters",horizon:y,confidence:p,n:g,sigma:P===null?null:Math.sqrt(P),params:{alpha:s,beta:O,gamma:E,period:u},points:x}}const f={FORECAST_METHODS:Z,forecast:t}}),Se("packages/core/src/compute/hypothesis.js",function(e,V){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const N=V("packages/core/src/internal/util.js").warnOnce,L=V("packages/core/src/compute/handle.js").valueReader,W=V("packages/core/src/compute/statistics.js"),Z=W.numbers,H=W.moments,U=W.frequencyMap,z=W.categoricalDistance,F=W.isNumericColumn,k=W.jarqueBera,S=W.proportionInterval,b=W.SUBSET_RELIABILITY_FLOOR,l=V("packages/core/src/compute/compare.js").pooledStandardMeanDifference,r=V("packages/core/src/compute/special.js"),t=r.studentT,n=r.studentTQuantile,i=r.normalCdf,o=r.normalQuantile,c=r.chiSquareUpperTail,d=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),f=.05,h=2e6;function g(P){const D=Number(P);return Number.isFinite(D)&&D>0&&D<1?D:.95}function y(P){const{n:D,mean:K,m2:x}=H(P);return{mean:K,sd:D>0?Math.sqrt(x/D):0,n:D}}function p(P,D){const K=P.length;if(K<2)return 0;let x=0;for(let I=0;I<K;I++){const j=P[I]-D;x+=j*j}return x/(K-1)}function m(P,D){return{name:"pooledStandardMeanDifference",value:l(y(P),y(D))}}function w(P,D,K){const x=P.length,I=D.length;if(x<2||I<2)return null;const j=g(K),{mean:T}=H(P),{mean:B}=H(D),q=p(P,T),X=p(D,B),Q=q/x+X/I;if(!(Q>0))return null;const te=Math.sqrt(Q),re=(T-B)/te,ie=q/x*(q/x)/(x-1),ae=X/I*(X/I)/(I-1),ee=Q*Q/(ie+ae),J=Math.min(1,Math.max(0,2*(1-t(Math.abs(re),ee)))),se=T-B,le=n(1-(1-j)/2,ee)*te;return{test:d.WELCH,statistic:re,statisticName:"t",df:ee,pValue:J,interval:{estimate:se,lower:se-le,upper:se+le,confidence:j,method:"welch-t (difference of means)"},effectSize:m(P,D),nA:x,nB:I,reliable:x>=b&&I>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function v(P){const D=P.length;if(D===0)return Number.NaN;const K=D>>1;return D%2?P[K]:(P[K-1]+P[K])/2}function u(P,D,K){const x=P.length,I=D.length,j=x*I;if(j===0||j>h)return null;const T=new Float64Array(j);let B=0;for(let ie=0;ie<x;ie++)for(let ae=0;ae<I;ae++)T[B++]=P[ie]-D[ae];T.sort();const q=v(T),X=Math.sqrt(x*I*(x+I+1)/12),Q=o(1-(1-K)/2);let te=Math.round(j/2-Q*X);te>=0||(te=0);const re=Math.floor((j-1)/2);return te>re&&(te=re),{estimate:q,lower:T[te],upper:T[j-1-te],confidence:K,method:"hodges-lehmann (normal approximation)"}}function s(P,D,K){const x=P.length,I=D.length;if(x<1||I<1)return null;const j=g(K),T=x+I,B=new Array(T);for(let J=0;J<x;J++)B[J]={v:P[J],g:0};for(let J=0;J<I;J++)B[x+J]={v:D[J],g:1};B.sort((J,se)=>J.v-se.v);let q=0,X=0,Q=0;for(;Q<T;){let J=Q;for(;J<T&&B[J].v===B[Q].v;)J++;const se=J-Q,le=(Q+1+J)/2;for(let oe=Q;oe<J;oe++)B[oe].g===0&&(q+=le);X+=se*se*se-se,Q=J}const te=q-x*(x+1)/2,re=x*I/2,ie=x*I/12*(T+1-X/(T*(T-1)));let ae=1;if(ie>0){const J=Math.max(0,Math.abs(te-re)-.5);ae=Math.min(1,2*i(-J/Math.sqrt(ie)))}const ee=u(P,D,j);return{test:d.MANN_WHITNEY,statistic:te,statisticName:"U",df:null,pValue:ae,interval:ee,effectSize:m(P,D),nA:x,nB:I,reliable:x>=b&&I>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function O(P,D,K,x,I){const j=S(P,D,I),T=S(K,x,I);if(!j||!T)return null;const B=j.proportion-T.proportion,q=B-Math.sqrt((j.proportion-j.lower)**2+(T.upper-T.proportion)**2),X=B+Math.sqrt((j.upper-j.proportion)**2+(T.proportion-T.lower)**2);return{lower:q,upper:X}}function E(P,D,K,x,I,j={}){if(!(D>0)||!(x>0))return null;const T=new Set([...P.keys(),...K.keys()]),B=T.size;if(B<2)return null;const q=D+x;let X=0;for(const ae of T){const ee=P.get(ae)||0,J=K.get(ae)||0,se=ee+J,le=D*se/q,oe=x*se/q;le>0&&(X+=(ee-le)*(ee-le)/le),oe>0&&(X+=(J-oe)*(J-oe)/oe)}const Q=B-1,te=c(X,Q);let re=null;j.category!==void 0&&T.has(j.category)?re=j.category:B===2&&([re]=[...T]);let ie=null;if(re!==null){const ae=O(P.get(re)||0,D,K.get(re)||0,x,g(I));ae&&(ie={estimate:(P.get(re)||0)/D-(K.get(re)||0)/x,lower:ae.lower,upper:ae.upper,confidence:g(I),method:"newcombe (difference in this category's share)",category:re})}return{test:d.CHI_SQUARE,statistic:X,statisticName:"chiSquare",df:Q,pValue:te,interval:ie,effectSize:{name:"categoricalTotalVariation",value:z(P,D,K,x)},nA:D,nB:x,reliable:D>=b&&x>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function A(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function M(P,D,K){if(K===d.WELCH||K===d.MANN_WHITNEY)return{test:K,chosenBy:"override",reason:`caller override: ${K}`};const x=k(P),I=k(D),j=x===null?null:Math.exp(-x/2),T=I===null?null:Math.exp(-I/2);return j!==null&&j<f||T!==null&&T<f?{test:d.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${f})`}:{test:d.WELCH,chosenBy:"auto",reason:j!==null||T!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(P,D,K,x={}){if(!P||!D)return null;const I=g(x.confidence),j=L(D);let T;if(Array.isArray(x.groups)&&x.groups.length===2)T=[A(x.groups[0]),A(x.groups[1])];else{const{map:J}=U(D,K),se=[...J.entries()].sort((le,oe)=>oe[1]-le[1]).slice(0,2).map(le=>le[0]);if(se.length<2)return N("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;T=se}const[B,q]=T;if(B===null||q===null||B===q)return N("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const X=[],Q=[];for(let J=0;J<K.length;J++){const se=A(j(K[J]));se===B?X.push(K[J]):se===q&&Q.push(K[J])}if(X.length===0||Q.length===0)return N("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const te=x.test&&x.test!=="auto"?String(x.test):null,re=F(P,X.concat(Q));let ie,ae,ee;if(te===d.CHI_SQUARE||!te&&!re){ae=te?"override":"auto",ee=te?"caller override: chiSquare":"column family: categorical";const J=U(P,X),se=U(P,Q);ie=E(J.map,J.total,se.map,se.total,I,{category:x.category})}else{if((te===d.WELCH||te===d.MANN_WHITNEY)&&!re)return N("compareGroups:numeric-override",`[lattice] compareGroups: ${te} needs a numeric column, but the column is not numeric.`),null;const J=Z(P,X),se=Z(P,Q),le=M(J,se,te);ae=le.chosenBy,ee=le.reason,ie=le.test===d.MANN_WHITNEY?s(J,se,I):w(J,se,I)}return ie?{...ie,chosenBy:ae,reason:ee,groups:[B,q]}:(N("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Se("packages/core/src/columns/detailcolumn.js",function(e,V){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="__lattice_detail",N=36;function $(W){const Z=W.config&&W.config.detailColumnWidth||N;return{id:_,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:Z,min:Z,max:Z,pin:W.config&&W.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(H,U){return!!(U&&U.expanded)},formatValue(){return""}}}const L=$}),Se("packages/core/src/columns/treecolumn.js",function(e,V){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/internal/util.js").isFunction,$="__lattice_tree",L=260;function W(H){const U=H.tree||{},z=H.config&&H.config.treeColumnWidth||L,F=()=>(H.columns&&N(H.columns.visible)?H.columns.visible():[]).find(a=>!a.generated)||null,k=(b,a)=>{if(a&&a.group)return a.groupValue;if(N(U.label))return U.label(b,a);if(typeof U.label=="string")return b==null?null:b[U.label];const l=F();return l&&N(l.getValue)?l.getValue(b,a):null},S=()=>{if(U.title)return U.title;const b=typeof U.label=="string"?H.columns&&N(H.columns.get)?H.columns.get(U.label):null:F();return b&&(b.title||b.id)||"Hierarchy"};return{id:$,get title(){return S()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:z,min:140,pin:H.config&&H.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(b,a){return k(b,a)},formatValue(b,a){if(a&&a.grandTotal)return H.config&&H.config.grandTotalLabel||"Total";if(b==null)return"";if(!U.label){const l=F();if(l&&N(l.formatValue))return l.formatValue(b,a)}return String(b)}}}const Z=W}),Se("packages/core/src/columns/pivotcolumns.js",function(e,V){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const N=V("packages/core/src/internal/util.js").warnOnce,$="__lattice_pivot",L=500;function W(z){const{pivot:F,valueColumns:k,config:S}=z,b=F&&F.paths||[],a=z.separator||S&&S.pivot&&S.pivot.separator||" | ",l=S&&S.pivot&&S.pivot.maxColumns||L;if(!b.length||!k.length)return{tree:[],leaves:[],error:null};const r=Z(S),t=b.length*k.length+(r?k.length:0);if(t>l){const o=`pivot would generate ${t} columns, above the limit of ${l}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return N(`pivot.maxColumns:${t}`,o),{tree:[],leaves:[],error:o}}const n=[],i=[];for(const o of b){const c=[];for(const d of k){const f=U(o,d,a);c.push(f),i.push(f)}c.length===1?(c[0].title=String(o),n.push(c[0])):n.push({id:`${$}:group:${o}`,title:String(o),columns:c,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(r){const o=k.map(d=>H(d,S));i.push(...o);const c=S&&S.pivot&&S.pivot.totalsLabel||"Total";if(o.length===1)o[0].title=c,r==="before"?n.unshift(o[0]):n.push(o[0]);else{const d={id:`${$}:group:__totals`,title:c,columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};r==="before"?n.unshift(d):n.push(d)}}return{tree:n,leaves:i,error:null}}function Z(z){const F=z&&z.pivot&&z.pivot.groupTotals;return F==="before"||F==="after"?F:null}function H(z,F){return{id:`${$}:__total${F&&F.pivot&&F.pivot.separator||" | "}${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,sourceId:z.id,total:!0},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(k,S){const b=S&&S.totals;return b&&Object.hasOwn(b,z.id)?b[z.id]:null},formatValue(k,S){return k==null?"":z.formatValue?z.formatValue(k,S):String(k)}}}function U(z,F,k){return{id:`${$}:${z}${k}${F.id}`,field:null,title:F.title||F.id,type:F.type,dataType:F.dataType,nullable:!0,align:F.align,generated:!0,pivot:{enabled:!1,index:0,path:z,sourceId:F.id},value:{pure:!0},cell:{align:F.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:F.total,lookup:null,layout:{width:F.layout&&F.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(S,b){return S==null?"":F.formatValue?F.formatValue(S,b):String(S)}}}}),Se("packages/core/src/compute/group.js",function(e,V){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return S}});const _=V("packages/core/src/compute/handle.js"),N=_.dictSize,$=_.identity,L=_.presenceReader,W=_.rowCount,Z=_.valueReader,H="",U="\0",z=1<<20;function F(b,a,l,r){const t=b.length,n=b.map(h=>Z(h)),i=Array.isArray(r)&&r.some(Boolean),o=i?n.map((h,g)=>r[g]?y=>r[g](h(y)):h):n;if(!i&&t>0&&b.every(h=>h&&h.kind==="dictionary"&&h.dict)){const h=b.map(y=>N(y.dict)+1);let g=1;for(let y=0;y<t;y++)g*=h[y];if(g<=Number.MAX_SAFE_INTEGER){const y=b.map(v=>v.values),p=b.map(v=>L(v)),m=v=>{let u=0;for(let s=0;s<t;s++){const O=p[s],E=O&&O(v)===0?h[s]-1:y[s][v];u=u*h[s]+E}return u},w=new Float64Array(l);for(let v=0;v<l;v++)w[v]=m(a[v]);return{packed:w,strings:null,product:g,readers:o,keyOf:m}}}const d=h=>{let g="";for(let y=0;y<t;y++){const p=o[y](h);g+=(y===0?"":H)+(p==null?U:String(p))}return g},f=new Array(l);for(let h=0;h<l;h++)f[h]=d(a[h]);return{packed:null,strings:f,product:1/0,readers:o,keyOf:d}}function k(b,a,l,r){const t=new Uint32Array(r+1);for(let c=0;c<l;c++)t[a[c]+1]++;for(let c=0;c<r;c++)t[c+1]+=t[c];const n=new Uint32Array(l),i=t.slice(0,r);for(let c=0;c<l;c++)n[i[a[c]]++]=b[c];const o=new Array(r);for(let c=0;c<r;c++)o[c]=n.subarray(t[c],t[c+1]);return o}function S(b,a,l={}){const r=b||[],t=a||$(W(r[0],l)),n=t.length;if(r.length===0||n===0)return{keys:[],buckets:[]};const{packed:i,strings:o,product:c,readers:d}=F(r,t,n,l.project),f=new Uint32Array(n);let h=0,g=null;if(i&&c<=Math.max(1024,Math.min(z,n*4))){const w=c,v=new Int32Array(w).fill(-1);for(let u=0;u<n;u++)v[i[u]]=0;for(let u=0;u<w;u++)v[u]===0&&(v[u]=h++);for(let u=0;u<n;u++)f[u]=v[i[u]];g=new Float64Array(h);for(let u=0;u<w;u++)v[u]>=0&&(g[v[u]]=u)}else if(i){const w=new Map;for(let v=0;v<n;v++){const u=i[v];let s=w.get(u);s===void 0&&(s=h++,w.set(u,s)),f[v]=s}g=new Float64Array(h);for(const[v,u]of w)g[u]=v}else{const w=new Map;for(let v=0;v<n;v++){const u=o[v];let s=w.get(u);s===void 0&&(s=h++,w.set(u,s)),f[v]=s}}const y=k(t,f,n,h),p=new Array(h);for(let w=0;w<h;w++){const v=y[w][0],u=new Array(d.length);for(let s=0;s<d.length;s++)u[s]=d[s](v);p[w]=u}const m={keys:p,buckets:y};return g&&(m.packed=g),m}}),Se("packages/core/src/compute/pivot.js",function(e,V){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return n}});const N=V("packages/core/src/internal/util.js").warnOnce,L=V("packages/core/src/compute/handle.js").valueComparator,Z=V("packages/core/src/compute/group.js").packKeys,U=V("packages/core/src/compute/total.js").total,z="|",F="/",k=2e3;function S(c,d,f){return`${c}${z}${d}${z}${f}`}function b(c,d){let f="";for(let h=0;h<c.length;h++){const g=c[h];f+=(h===0?"":d)+(g==null?"":String(g))}return f}function a(c,d,f={}){const h=f.separator||F,g=d.length,{keyOf:y,readers:p}=Z(c,d,0),m=new Map,w=[],v=[];for(let C=0;C<g;C++){const P=d[C],D=y(P);if(m.has(D))continue;m.set(D,w.length),v.push(D);const K=new Array(p.length);for(let x=0;x<p.length;x++)K[x]=p[x](P);w.push(K)}const u=L(f.locale),s=w.map((C,P)=>P);s.sort((C,P)=>{const D=w[C],K=w[P];for(let x=0;x<D.length;x++){const I=l(D[x],K[x],u);if(I!==0)return I}return C-P});const O=new Array(s.length),E=new Array(s.length),A=new Map;for(let C=0;C<s.length;C++){const P=s[C];O[C]=w[P],E[C]=b(w[P],h),A.set(v[P],C)}return{keys:O,paths:E,idOf:C=>{const P=A.get(y(C));return P===void 0?-1:P}}}function l(c,d,f){const h=c==null,g=d==null;return h||g?h&&g?0:h?1:-1:f(c,d)}function r(c){const d=c.values||c.totals||[];if(d.length&&typeof d[0]=="object"&&d[0]!==null)return d.filter(y=>y&&y.handle);const f=typeof c.handle=="function"?c.handle:null;if(!f)return d.length&&N("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const h=typeof c.totalOf=="function"?c.totalOf:null,g=[];for(const y of d){const p=f(y);p&&g.push({colId:y,handle:p,fn:h?h(y):"sum"})}return g}function t(c,d,f){if(Array.isArray(c)){const h=f||{};return{...h,pivotHandles:c,order:d||null,groups:h.groups||null}}return c||{}}function n(c,d,f){const h=t(c,d,f),g=h.separator||F,y=r(h),p=h.maxColumns===void 0?k:h.maxColumns,m=h.groups&&h.groups.buckets?h.groups:null,w=m?m.buckets:[h.order||new Uint32Array(0)],v=h.groupPaths||(m?m.keys.map(D=>b(D,g)):[""]),u=o(w),{keys:s,paths:O,idOf:E}=a(h.pivotHandles||[],u,h),A=O.length*Math.max(1,y.length),M=i(O,y,g);if(p&&A>p){const D=new Map;return{keys:s,paths:O,fields:M,groupPaths:v,columns:A,values:D,cells:D,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${A} columns, above pivot.maxColumns of ${p}. Narrow the pivot columns or raise the limit.`,columns:A,maxColumns:p}}}const C=new Map,P=O.length;for(let D=0;D<w.length;D++){const K=w[D],x=v[D]===void 0?"":v[D],I=K.length;if(I===0)continue;const j=new Int32Array(I),T=new Uint32Array(P+1);for(let X=0;X<I;X++){const Q=E(K[X]);j[X]=Q,Q>=0&&T[Q+1]++}for(let X=0;X<P;X++)T[X+1]+=T[X];const B=new Uint32Array(I),q=T.slice(0,P);for(let X=0;X<I;X++){const Q=j[X];Q>=0&&(B[q[Q]++]=K[X])}for(let X=0;X<P;X++){const Q=T[X],te=T[X+1];if(te===Q)continue;const re=B.subarray(Q,te);for(let ie=0;ie<y.length;ie++){const ae=y[ie],ee=U(ae.handle,re,ae.fn,h.totalContext||{locale:h.locale});C.set(S(x,O[X],ae.colId),ee)}}}return{keys:s,paths:O,fields:M,groupPaths:v,columns:A,values:C,cells:C,error:null}}function i(c,d,f){if(d.length===0)return c.slice();const h=[];for(const g of c)for(const y of d)h.push(`${g}${f}${y.colId}`);return h}function o(c){if(c.length===1)return c[0]||new Uint32Array(0);let d=0;for(const g of c)d+=g?g.length:0;const f=new Uint32Array(d);let h=0;for(const g of c)!g||g.length===0||(f.set(g,h),h+=g.length);return f}}),Se("packages/core/src/store/bitset.js",function(e,V){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return N}});const _=8;class N{static#e=new Uint8Array(256);static{for(let L=1;L<256;L++)N.#e[L]=N.#e[L>>1]+(L&1)}#t;#n;constructor(L=0){const W=Math.max(0,L|0);this.#n=W,this.#t=new Uint8Array(Math.ceil(W/_))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(L){return L<0||L>=this.#n?0:this.#t[L>>3]>>(L&7)&1}set(L){return L>=0&&L<this.#n&&(this.#t[L>>3]|=1<<(L&7)),this}clear(L){return L>=0&&L<this.#n&&(this.#t[L>>3]&=~(1<<(L&7))),this}assign(L,W){return W?this.set(L):this.clear(L)}fill(L=!1){return this.#t.fill(L?255:0),L&&this.#r(),this}grow(L){const W=Math.max(0,L|0);if(W<=this.#n)return this;const Z=Math.ceil(W/_);if(Z>this.#t.length){const H=new Uint8Array(Z);H.set(this.#t),this.#t=H}return this.#n=W,this}count(){const L=this.#t,W=N.#e;let Z=0;for(let H=0;H<L.length;H++)Z+=W[L[H]];return Z}and(L){const W=L instanceof N?L.words:L,Z=this.#t,H=Math.min(Z.length,W.length);for(let U=0;U<H;U++)Z[U]&=W[U];for(let U=H;U<Z.length;U++)Z[U]=0;return this}or(L){const W=L instanceof N?L.words:L,Z=this.#t,H=Math.min(Z.length,W.length);for(let U=0;U<H;U++)Z[U]|=W[U];return this}not(){const L=this.#t;for(let W=0;W<L.length;W++)L[W]=~L[W]&255;return this.#r(),this}clone(){const L=new N(this.#n);return L.words.set(this.#t.subarray(0,L.words.length)),L}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const L=this.#n&7;if(L===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<L)-1)}static from(L){const W=Array.isArray(L)?L:Array.from(L),Z=new N(W.length);for(let H=0;H<W.length;H++)W[H]&&Z.set(H);return Z}}}),Se("packages/core/src/store/dictionary.js",function(e,V){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return L}});const _=V("packages/core/src/internal/util.js"),N=_.collator,$=_.defaultCompare;class L{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let H=0;H<Z.length;H++){const U=Z[H];this.#t.has(U)||(this.#t.set(U,this.#e.length),this.#e.push(U))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let H=0;H<this.#e.length;H++){const U=this.#e[H];typeof U=="string"&&(Z+=U.length*2),Z+=16}return Z}codeOf(Z){const H=this.#t.get(Z);if(H!==void 0)return H;const U=this.#e.length;return this.#e.push(Z),this.#t.set(Z,U),this.#n++,U}lookup(Z){const H=this.#t.get(Z);return H===void 0?-1:H}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const H=Z||"";if(this.#r&&this.#o===this.#n&&this.#i===H)return this.#r;const U=this.#e.length,z=new Array(U);for(let b=0;b<U;b++)z[b]=b;const F=N(Z).compare,k=this.#e;z.sort((b,a)=>this.#a(k[b],k[a],F));const S=new Uint32Array(U);for(let b=0;b<U;b++)S[z[b]]=b;return this.#r=S,this.#o=this.#n,this.#i=H,S}#a(Z,H,U){return typeof Z=="string"&&typeof H=="string"?U(Z,H):$(Z,H)}}}),Se("packages/core/src/store/multivalue.js",function(e,V){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return _}});class _{#e;#t;#n=0;#r=0;constructor($={}){const L=Math.max(1,$.rows??16),W=Math.max(1,$.values??L);this.#e=new Int32Array(W),this.#t=new Uint32Array(L+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($){return $<0||$>=this.#n?0:this.#t[$+1]-this.#t[$]}at($){return $<0||$>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[$],this.#t[$+1])}has($,L){if($<0||$>=this.#n)return!1;const W=this.#e,Z=this.#t[$+1];for(let H=this.#t[$];H<Z;H++)if(W[H]===L)return!0;return!1}hasAny($,L){for(let W=0;W<L.length;W++)if(this.has($,L[W]))return!0;return!1}hasAll($,L){for(let W=0;W<L.length;W++)if(!this.has($,L[W]))return!1;return!0}hasNone($,L){return!this.hasAny($,L)}push($){const L=this.#n,W=$.length;this.#o(L+1),this.#i(this.#r+W);const Z=this.#r;for(let H=0;H<W;H++)this.#e[Z+H]=$[H]|0;return this.#r+=W,this.#n=L+1,this.#t[L]=Z,this.#t[L+1]=this.#r,L}write($,L){if($===this.#n){this.push(L);return}if($<0||$>this.#n)return;const W=this.#t[$],Z=this.#t[$+1],H=L.length;if(Z-W===H){for(let U=0;U<H;U++)this.#e[W+U]=L[U]|0;return}this.#a($,L)}compact($,L,W){const Z=this.#e,H=this.#t,U=this.#n,z=new Int32Array(Math.max(1,this.#r)),F=new Uint32Array(L+1);let k=0;for(let S=0;S<U;S++){if($[S]===W)continue;const b=H[S],a=H[S+1];F[$[S]]=k;for(let l=b;l<a;l++)z[k++]=Z[l];F[$[S]+1]=k}this.#e=z,this.#t=F,this.#n=L,this.#r=k}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o($){if($+1<=this.#t.length)return;let L=this.#t.length-1;for(;L<$;)L=L*2||16;const W=new Uint32Array(L+1);W.set(this.#t),this.#t=W}#i($){if($<=this.#e.length)return;let L=this.#e.length;for(;L<$;)L=L*2||16;const W=new Int32Array(L);W.set(this.#e),this.#e=W}#a($,L){const W=this.#e,Z=this.#t,H=this.#n,U=L.length-(Z[$+1]-Z[$]),z=new Int32Array(Math.max(1,this.#r+U)),F=new Uint32Array(Z.length);let k=0;for(let S=0;S<H;S++){if(F[S]=k,S===$)for(let b=0;b<L.length;b++)z[k++]=L[b]|0;else for(let b=Z[S];b<Z[S+1];b++)z[k++]=W[b];F[S+1]=k}this.#e=z,this.#t=F,this.#r=k}}}),Se("packages/core/src/compute/sort.js",function(e,V){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const _=V("packages/core/src/compute/handle.js"),N=_.bitReader,$=_.dictRanks,L=_.dictSize,W=_.identity,Z=_.isMissing,H=_.presenceReader,U=_.rowCount,z=_.valueComparator,F=_.valueReader,k=new Uint32Array(0),S=new ArrayBuffer(8),b=new Float64Array(S),a=new Uint32Array(S),l=(b[0]=-1,(a[1]&2147483648)!==0?1:0),r=l===1?0:1;function t(K,x){b[0]=K;let I=a[l],j=a[r];(I&2147483648)!==0?(I=~I>>>0,j=~j>>>0):I=(I^2147483648)>>>0,x[0]=j,x[1]=I}function n(K,x,I,j){if(j<2)return K;const T=new Uint32Array(256*8);for(let ae=0;ae<j;ae++){const ee=x[ae],J=I[ae];T[ee&255]++,T[256+(ee>>>8&255)]++,T[512+(ee>>>16&255)]++,T[768+(ee>>>24&255)]++,T[1024+(J&255)]++,T[1280+(J>>>8&255)]++,T[1536+(J>>>16&255)]++,T[1792+(J>>>24&255)]++}let B=K,q=x,X=I,Q=new Uint32Array(j),te=new Uint32Array(j),re=new Uint32Array(j);const ie=new Uint32Array(256);for(let ae=0;ae<8;ae++){const ee=ae<<8,J=(ae&3)<<3,se=ae>=4;let le=!1;for(let fe=0;fe<256;fe++)if(T[ee+fe]===j){le=!0;break}if(le)continue;let oe=0;for(let fe=0;fe<256;fe++)ie[fe]=oe,oe+=T[ee+fe];for(let fe=0;fe<j;fe++){const ve=q[fe],be=X[fe],Re=(se?be:ve)>>>J&255,He=ie[Re]++;Q[He]=B[fe],te[He]=ve,re[He]=be}let he=B;B=Q,Q=he,he=q,q=te,te=he,he=X,X=re,re=he}return B}function i(K,x,I){if(I<2)return K;const j=new Uint32Array(256*4);for(let te=0;te<I;te++){const re=x[te];j[re&255]++,j[256+(re>>>8&255)]++,j[512+(re>>>16&255)]++,j[768+(re>>>24&255)]++}let T=K,B=x,q=new Uint32Array(I),X=new Uint32Array(I);const Q=new Uint32Array(256);for(let te=0;te<4;te++){const re=te<<8,ie=te<<3;let ae=!1;for(let se=0;se<256;se++)if(j[re+se]===I){ae=!0;break}if(ae)continue;let ee=0;for(let se=0;se<256;se++)Q[se]=ee,ee+=j[re+se];for(let se=0;se<I;se++){const le=B[se],oe=Q[le>>>ie&255]++;q[oe]=T[se],X[oe]=le}let J=T;T=q,q=J,J=B,B=X,X=J}return T}function o(K,x,I,j){const T=new Uint32Array(j+1);for(let X=0;X<I;X++)T[x[X]]++;let B=0;for(let X=0;X<=j;X++){const Q=T[X];T[X]=B,B+=Q}const q=new Uint32Array(I);for(let X=0;X<I;X++)q[T[x[X]]++]=K[X];return q}function c(K,x,I,j){return I<2?K:j<=65536||j<=I*2?o(K,x,I,j):i(K,x,I)}function d(K,x){return K.length===x&&K.byteOffset===0?K:Uint32Array.prototype.slice.call(K,0,x)}function f(K,x,I=!1){const j=x||W(K.length),T=j.length;if(T<2)return Uint32Array.from(j);const B=new Uint32Array(T),q=new Uint32Array(T),X=new Uint32Array(T),Q=new Uint32Array(T),te=new Uint32Array(2);let re=0,ie=0;for(let J=0;J<T;J++){const se=j[J],le=K[se];if(Number.isNaN(le)){Q[ie++]=se;continue}t(le,te),I?(q[re]=~te[0]>>>0,X[re]=~te[1]>>>0):(q[re]=te[0],X[re]=te[1]),B[re++]=se}const ae=n(B.subarray(0,re),q.subarray(0,re),X.subarray(0,re),re);if(ie===0)return d(ae,re);const ee=new Uint32Array(T);return ee.set(ae.subarray(0,re),0),ee.set(Q.subarray(0,ie),re),ee}function h(K,x,I=!1){const j=x||W(K.length),T=j.length;if(T<2)return Uint32Array.from(j);const B=Uint32Array.from(j),q=new Uint32Array(T);for(let X=0;X<T;X++){const Q=(K[B[X]]^2147483648)>>>0;q[X]=I?~Q>>>0:Q}return d(i(B,q,T),T)}function g(K,x,I={}){const j=x||W(U(K,I)),T=j.length;if(T<2)return Uint32Array.from(j);const B=$(K.dict,I.locale),q=K.values,X=H(K),Q=Math.max(L(K.dict),B.length),te=Q,re=Uint32Array.from(j),ie=new Uint32Array(T),ae=!!I.descending;for(let ee=0;ee<T;ee++){const J=re[ee];let se=X&&X(J)===0?te:B[q[J]];se===void 0&&(se=te),ie[ee]=ae?te-se:se}return d(c(re,ie,T,Q+1),T)}function y(K,x,I){const j=x.length;let T=Uint32Array.from(x);if(j<2)return T;let B=new Uint32Array(j);for(let q=1;q<j;q<<=1){for(let Q=0;Q<j;Q+=q<<1){const te=Math.min(Q+q,j),re=Math.min(Q+(q<<1),j);let ie=Q,ae=te,ee=Q;for(;ie<te&&ae<re;)B[ee++]=I(K[T[ie]],K[T[ae]])<=0?T[ie++]:T[ae++];for(;ie<te;)B[ee++]=T[ie++];for(;ae<re;)B[ee++]=T[ae++]}const X=T;T=B,B=X}return T}function p(K,x,I){const j=N(K.values),T=x.length,B=new Uint32Array(T),q=I?1:0;let X=0;for(let Q=0;Q<T;Q++)j(x[Q])===q&&(B[X++]=x[Q]);for(let Q=0;Q<T;Q++)j(x[Q])!==q&&(B[X++]=x[Q]);return B}function m(K,x){const I=K.values,j=K.kind;if((j==="object"||j===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!K.presence)return I;const B=F(K),q=new Array(U(K)||0);for(let X=0;X<x.length;X++){const Q=x[X];q[Q]=B(Q)}return q}function w(K,x){for(let I=0;I<x.length;I++)if(typeof K[x[I]]!="string")return!1;return!0}function v(K,x,I,j,T){const B=K.length,q=Uint32Array.from(K);if(B<2||j<1)return q;const X=new Uint32Array(B),Q=j-1;for(let te=0;te<B;te++){const re=I[x[te]];X[te]=T?Q-re:re}return d(c(q,X,B,j),B)}function u(K,x,I){const j=z(I),T=new Array(x);for(let q=0;q<x;q++)T[q]=q;T.sort((q,X)=>j(K[q],K[X])||q-X);const B=new Uint32Array(x);for(let q=0;q<x;q++)B[T[q]]=q;return B}function s(K,x,I){const j=x.length,T=new Map,B=[],q=new Uint32Array(j);for(let te=0;te<j;te++){const re=K[x[te]];let ie=T.get(re);ie===void 0&&(ie=B.length,T.set(re,ie),B.push(re)),q[te]=ie}const X=B.length,Q=u(B,X,I.locale);return v(x,q,Q,X,!!I.descending)}function O(K,x,I){const j=m(K,x);if(x.length>=2&&w(j,x)){const q=K.stringRank;return q&&q.version===K.version&&q.usable(x,j,I.locale)?q.sort(x,I):s(j,x,I)}const T=z(I.locale),B=I.descending?(q,X)=>T(X,q):T;return y(j,x,B)}function E(K,x,I){const j=m(K,x),T=I.compare,q=!!I.descending?(X,Q)=>-T(X,Q,void 0,void 0,!0):(X,Q)=>T(X,Q,void 0,void 0,!1);return y(j,x,q)}function A(K,x){const I=x.length,j=H(K),T=K.values,B=K.kind==="float64"&&!!T,q=K.kind==="object"||K.kind==="multi"||K.kind===void 0;if(!j&&!B&&!q)return{present:x,absent:k};const X=new Uint32Array(I),Q=new Uint32Array(I);let te=0,re=0;if(j&&B)for(let ie=0;ie<I;ie++){const ae=x[ie];j(ae)===1&&!Number.isNaN(T[ae])?X[te++]=ae:Q[re++]=ae}else if(B&&!j)for(let ie=0;ie<I;ie++){const ae=x[ie];Number.isNaN(T[ae])?Q[re++]=ae:X[te++]=ae}else if(j&&!q)for(let ie=0;ie<I;ie++){const ae=x[ie];j(ae)===1?X[te++]=ae:Q[re++]=ae}else{const ie=F(K);for(let ae=0;ae<I;ae++){const ee=x[ae];Z(ie(ee))?Q[re++]=ee:X[te++]=ee}}return re===0?{present:x,absent:k}:{present:X.subarray(0,te),absent:Q.subarray(0,re)}}function M(K,x,I){if(x.length===0)return K;const j=new Uint32Array(K.length+x.length);return I?(j.set(x,0),j.set(K,x.length)):(j.set(K,0),j.set(x,K.length)),j}function C(K,x,I={}){const j=x||W(U(K,I));if(!K||j.length<2)return Uint32Array.from(j);const{present:T,absent:B}=A(K,j);if(T.length===0)return Uint32Array.from(j);const q=!!I.descending;let X;if(typeof I.compare=="function")X=E(K,T,I);else switch(K.kind){case"float64":X=f(K.values,T,q);break;case"int32":X=h(K.values,T,q);break;case"dictionary":X=g(K,T,I);break;case"bitset":X=p(K,T,q);break;default:X=O(K,T,I);break}return M(X,B,!!I.nullsFirst)}function P(K,x,I,j={}){const T=x||[],B=T.length&&(T[0].handle||D(K,T[0].col))||K&&K[0];let q=I||W(U(B,j));for(let X=T.length-1;X>=0;X--){const Q=T[X],te=Q.handle||D(K,Q.col)||K&&K[X];te&&(q=C(te,q,{descending:Q.descending!==void 0?!!Q.descending:Q.dir==="desc",nullsFirst:!!Q.nullsFirst,locale:Q.locale!==void 0?Q.locale:j.locale,compare:Q.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function D(K,x){if(!(!K||x===void 0)){for(let I=0;I<K.length;I++)if(K[I]&&K[I].id===x)return K[I]}}}),Se("packages/core/src/store/stringrank.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const _=V("packages/core/src/compute/sort.js"),N=_.collateStringRanks,$=_.rankSortStrings,L=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#a;#s=!1;#l=null;#u=-1;#c="\0";constructor(H=L){this.#a=H>0?H:L,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(H){this.#i=H}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#s}get length(){return this.#r}get bytes(){let H=this.#n.byteLength;const U=this.#e;for(let z=0;z<U.length;z++)H+=U[z].length*2+24;return H}#d(H,U){const z=this.#t.get(H);if(z!==void 0)return z;if(this.#s)return-1;if(U&&this.#e.length>=this.#a)return this.#s=!0,-1;const F=this.#e.length;return this.#e.push(H),this.#t.set(H,F),this.#o++,F}build(H,U){const z=U|0;this.#e=[],this.#t=new Map,this.#o=0,this.#s=!1,this.#l=null,this.#u=-1,this.#n=new Uint32Array(z);for(let F=0;F<z;F++){const k=H[F],S=typeof k=="string"?this.#d(k,!1):-1;this.#n[F]=S<0?0:S}this.#r=z}append(H,U,z){const F=(U|0)+(z|0);if(F>this.#n.length){const k=new Uint32Array(F);k.set(this.#n.subarray(0,this.#r)),this.#n=k}for(let k=U|0;k<F;k++){const S=H[k],b=typeof S=="string"?this.#d(S,!0):-1;this.#n[k]=b<0?0:b}this.#r=Math.max(this.#r,F)}ranks(H){const U=H||"";if(this.#l&&this.#u===this.#o&&this.#c===U)return this.#l;const z=N(this.#e,this.#e.length,H);return this.#l=z,this.#u=this.#o,this.#c=U,z}usable(H,U,z){if(this.#s||this.#e.length===0)return!1;const F=this.#n,k=this.#e,S=this.#r;for(let b=0;b<H.length;b++){const a=H[b];if(a>=S||k[F[a]]!==U[a])return!1}return!0}sort(H,U){const z=this.ranks(U.locale),F=this.#e.length,k=H.length,S=new Uint32Array(k),b=this.#n;for(let a=0;a<k;a++)S[a]=b[H[a]];return $(H,S,z,F,!!U.descending)}}}),Se("packages/core/src/store/columnstore.js",function(e,V){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return g}});const _=V("packages/core/src/internal/util.js"),N=_.warnOnce,$=_.isFunction,L=_.pathGetter,Z=V("packages/core/src/store/bitset.js").Bitset,U=V("packages/core/src/store/dictionary.js").Dictionary,F=V("packages/core/src/store/multivalue.js").MultiValue,S=V("packages/core/src/store/stringrank.js").StringRankIndex,b=4294967295,a=1024,l=5e3,r=.2,t=new Set(["float64","int32","bitset","dictionary","object","multi"]);function n(y){return y==null}function i(y){if(typeof y=="number")return y;if(y instanceof Date)return y.getTime();if(typeof y=="boolean")return y?1:0;const p=Number(y);return Number.isNaN(p)&&typeof y=="string"?Date.parse(y):p}function o(y){const p=i(y);return Number.isFinite(p)?p|0:0}function c(y){return n(y)?[]:Array.isArray(y)?y:[y]}function d(y,p){switch(y.kind){case"float64":case"int32":return y.buf[p];case"bitset":return y.bits.get(p)===1;case"dictionary":return y.dict.valueOf(y.buf[p]);case"multi":{const m=y.mv.at(p),w=new Array(m.length);for(let v=0;v<m.length;v++)w[v]=y.dict.valueOf(m[v]);return w}default:return y.buf[p]}}function f(y,p){switch(y.kind){case"float64":case"int32":return y.values[p];case"bitset":return(y.values[p>>3]&1<<(p&7))!==0;case"dictionary":return(y.table||[])[y.values[p]];case"multi":{const m=y.offsets[p],w=y.offsets[p+1],v=y.table||[],u=new Array(w-m);for(let s=m;s<w;s++)u[s-m]=v[y.values[s]];return u}default:return y.values[p]}}class h{#e;#t;#n;#r;#o;#i;#a;#s=!1;#l=null;#u=null;#c=null;#d=null;#h=null;#f;#m;#p=-1;#g=null;#v=0;#y=0;#b=null;#w=null;#S=!1;constructor(p,m){this.#e=p.id;const w=t.has(p.kind)?p.kind:"object";p.kind&&!t.has(p.kind)&&N(`store.kind.${p.id}`,`column "${p.id}" declares unknown storage kind "${p.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=p.nullable!==!1,this.#a=p.dictionary??null,this.#i=m,this.#o=$(p.read)?p.read:L(p.field||p.id),this.#f=p.stringRankIndex!=="off",this.#m=typeof p.stringRankMaxDistinct=="number"?p.stringRankMaxDistinct:0,this.#b=new Map}get id(){return this.#e}get kind(){return this.#s?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#s?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#l:this.#T().values}get presence(){return this.#S||!this.#r?null:this.#s?this.#g:this.#T().presence}get dict(){return this.#S||!this.#s?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#f||this.kind!=="object")return null;const p=this.values,m=this.#i.physical();if(!p||m===0)return null;if(this.#h===null){if(typeof p[0]!="string")return null;const w=new S(this.#j());return w.build(p,m),w.version=this.#y,this.#h=w,this.#p=this.#y,w.capped?null:w}return this.#h.length<m&&this.#h.append(p,this.#h.length,m-this.#h.length),this.#h.version=this.#y,this.#p=this.#y,this.#h.capped?null:this.#h}#j(){return this.#m}#A(){this.#h=null,this.#p=-1}get offsets(){return this.#S||!this.#s||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#y}get bytes(){let p=0;return this.#l&&(p+=this.#l.byteLength??this.#l.length*8),this.#u&&(p+=this.#u.bytes),this.#c&&(p+=this.#c.bytes),this.#g&&(p+=this.#g.bytes),this.#d&&(p+=this.#d.bytes),this.#b&&(p+=this.#b.size*24),p}get(p){if(!this.#S&&!(p<0||p>=this.#i.physical())){if(!this.#s)return this.#E(p);if(this.#r&&this.#g.get(p)===0)return null;switch(this.#t){case"float64":case"int32":return this.#l[p];case"bitset":return this.#u.get(p)===1;case"dictionary":return this.#d.valueOf(this.#l[p]);case"multi":{const m=this.#c.at(p),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.#l[p]}}}set(p,m){this.#S||(this.#s?this.#C(p,m):this.#b.set(p,m===void 0?null:m),this.#h&&this.#A(),this.#y++)}read(p){return this.#o(p)}appendColumn(p,m,w){if(this.#S||w<=0)return;if(!this.#s){this.#y++;return}const v=this.#o,u=this.#r,s=this.#g;let O=!1;switch(this.#t){case"float64":{const E=this.#l;for(let A=0;A<w;A++){const M=v(p[A]);if(typeof M=="number"){u&&s.set(m+A),E[m+A]=M;continue}const C=M==null;u?s.assign(m+A,!C):C&&(O=!0),E[m+A]=C?NaN:i(M)}break}case"int32":{const E=this.#l;for(let A=0;A<w;A++){const M=v(p[A]),C=M==null;u?s.assign(m+A,!C):C&&(O=!0),E[m+A]=C?0:o(M)}break}case"bitset":{const E=this.#u;for(let A=0;A<w;A++){const M=v(p[A]),C=M==null;u?s.assign(m+A,!C):C&&(O=!0),E.assign(m+A,!C&&!!M)}break}case"dictionary":{const E=this.#l,A=this.#d;for(let M=0;M<w;M++){const C=v(p[M]),P=C==null;u?s.assign(m+M,!P):P&&(O=!0),E[m+M]=P?0:A.codeOf(C)}break}case"multi":{const E=this.#c,A=this.#d;for(let M=0;M<w;M++){const C=v(p[M]),P=C==null;u?s.assign(m+M,!P):P&&(O=!0);const D=c(C),K=new Array(D.length);for(let x=0;x<D.length;x++)K[x]=A.codeOf(D[x]);E.write(m+M,K)}break}default:{const E=this.#l;for(let A=0;A<w;A++){const M=v(p[A]),C=M==null;u?s.assign(m+A,!C):C&&(O=!0),E[m+A]=C?null:M}break}}O&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#l,m,w),this.#h.version=this.#y+1,this.#p=this.#y+1),this.#y++}appendPacked(p,m,w){if(this.#S||w<=0||!p)return;if(!this.#s){this.#y++;return}const v=this.#g,u=p.presence;if(v)if(u)for(let O=0;O<w;O++)v.assign(m+O,(u[O>>3]&1<<(O&7))!==0);else for(let O=0;O<w;O++)v.set(m+O);const s=p.kind===this.#t;if(s&&(this.#t==="float64"||this.#t==="int32")){this.#l.set(p.values,m),this.#y++;return}if(s&&this.#t==="bitset"){const O=p.values;for(let E=0;E<w;E++)this.#u.assign(m+E,(O[E>>3]&1<<(E&7))!==0);this.#y++;return}if(s&&this.#t==="dictionary"){const O=p.table||[],E=new Uint32Array(O.length);for(let P=0;P<O.length;P++)E[P]=this.#d.codeOf(O[P]);const A=p.values,M=this.#l,C=v;for(let P=0;P<w;P++){if(C&&(u&&(u[P>>3]&1<<(P&7))===0)){M[m+P]=0;continue}M[m+P]=E[A[P]]??0}this.#y++;return}if(s&&this.#t==="multi"){const O=p.table||[],E=new Uint32Array(O.length);for(let C=0;C<O.length;C++)E[C]=this.#d.codeOf(O[C]);const A=p.values,M=p.offsets;for(let C=0;C<w;C++){const P=M[C],D=M[C+1],K=new Array(D-P);for(let x=P;x<D;x++)K[x-P]=E[A[x]]??0;this.#c.write(m+C,K)}this.#y++;return}for(let O=0;O<w;O++){const E=u?(u[O>>3]&1<<(O&7))===0:p.kind==="object"?p.values[O]===null:!1;this.#C(m+O,E?null:f(p,O))}this.#y++}touch(){this.#y++}columnarise(p,m){if(this.#s||this.#S)return;const w=new Array(m);for(let v=0;v<m;v++)w[v]=this.#E(v);this.#t=this.#n,this.#s=!0,this.#O(p);for(let v=0;v<m;v++)this.#C(v,w[v]);this.#b.clear(),this.#w=null,this.#A(),this.#y++}grow(p){if(!(!this.#s||this.#S||p<=this.#v)){switch(this.#t){case"float64":case"int32":case"dictionary":{const m=new this.#l.constructor(p);m.set(this.#l),this.#l=m;break}case"bitset":this.#u.grow(p);break;case"multi":break;default:this.#l.length=p;break}this.#g&&this.#g.grow(p),this.#v=p,this.#y++}}convert(p){if(this.#S||!t.has(p)||(this.#n=p,!this.#s||p===this.#t))return!1;const m={kind:this.#t,buf:this.#l,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),v=this.#g;this.#t=p,this.#O(this.#v);for(let u=0;u<w;u++){const s=v!==null&&v.get(u)===0;s&&p!=="multi"||this.#C(u,s?null:d(m,u))}return this.#A(),this.#y++,!0}compact(p,m,w){if(!this.#S){if(this.#A(),!this.#s){const v=this.#b;if(v.size){const u=new Map;for(const[s,O]of v)p[s]!==b&&u.set(p[s],O);this.#b=u}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#l;for(let u=0;u<m;u++)p[u]!==b&&(v[p[u]]=v[u]);if(this.#t==="object")for(let u=w;u<m;u++)v[u]=void 0;break}case"bitset":{const v=this.#u;for(let u=0;u<m;u++)p[u]!==b&&v.assign(p[u],v.get(u)===1);for(let u=w;u<m;u++)v.clear(u);break}case"multi":this.#c.compact(p,w,b);break;default:break}if(this.#g){const v=this.#g;for(let u=0;u<m;u++)p[u]!==b&&v.assign(p[u],v.get(u)===1);for(let u=w;u<m;u++)v.clear(u)}this.#y++}}release(){this.#S||(this.#S=!0,this.#l=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#b=new Map,this.#w=null,this.#v=0,this.#y++)}#O(p){const m=Math.max(1,p);switch(this.#l=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#l=new Float64Array(m);break;case"int32":this.#l=new Int32Array(m);break;case"bitset":this.#u=new Z(m);break;case"dictionary":this.#l=new Uint32Array(m),this.#d=this.#d??new U(this.#a??[]);break;case"multi":this.#c=new F({rows:m,values:m}),this.#d=this.#d??new U(this.#a??[]);break;default:this.#l=new Array(m);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(m):this.#g=new Z(m)),this.#v=m}#C(p,m){const w=n(m);switch(this.#r?this.#g.assign(p,!w):w&&N(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#l[p]=w?NaN:i(m);break;case"int32":this.#l[p]=w?0:o(m);break;case"bitset":this.#u.assign(p,!w&&!!m);break;case"dictionary":this.#l[p]=w?0:this.#d.codeOf(m);break;case"multi":{const v=c(m),u=new Array(v.length);for(let s=0;s<v.length;s++)u[s]=this.#d.codeOf(v[s]);this.#c.write(p,u);break}default:this.#l[p]=w?null:m;break}}#E(p){if(this.#b.has(p))return this.#b.get(p);const m=this.#o(this.#i.rowAt(p));return m===void 0?null:m}#T(){if(this.#w&&this.#w.version===this.#y)return this.#w;const p=this.#i.physical(),m=new Array(p),w=this.#r?new Z(p):null;for(let v=0;v<p;v++){const u=this.#E(v);m[v]=u,w&&!n(u)&&w.set(v)}return this.#w={version:this.#y,values:m,presence:w},this.#w}}class g{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#a=0;#s=0;#l=new Z(0);#u=!1;#c=!0;#d;#h;#f;#m=!1;constructor(p,m={}){this.#e=Array.isArray(p)?p:[],this.#h=Math.max(1,m.initialCapacity??a),this.#c=m.retainSource!==!1,this.#d=this.#c?m.columnarBelow??l:0,this.#f=m.compactRatio??r;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)){N(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const u=new h(v,w);this.#t.set(v.id,u),this.#n.push(u)}this.#d<=0&&this.#v()}get count(){return this.#a}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#s}get columnar(){return this.#u}get destroyed(){return this.#m}get bytes(){let p=this.#l.bytes+this.#r.length*8;for(const m of this.#n)p+=m.bytes;return p}append(p){const m=this.#o;if(this.#m||!p)return{from:m,to:m};const w=p.length|0;if(w===0)return{from:m,to:m};if(this.#c)for(let u=0;u<w;u++)this.#r[m+u]=p[u];if(this.#o=m+w,this.#a+=w,this.#l.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#v();else for(const u of this.#n)u.touch();return{from:m,to:this.#o}}this.#p(this.#o);const v=this.#n;for(let u=0;u<v.length;u++)v[u].appendColumn(p,m,w);return{from:m,to:this.#o}}appendPacked(p,m){const w=this.#o;if(this.#m||!p)return{from:w,to:w};const v=p.count|0;if(v===0)return{from:w,to:w};if(this.#c&&m)for(let s=0;s<v;s++)this.#r[w+s]=m[s];this.#o=w+v,this.#a+=v,this.#l.grow(this.#o),this.#u||this.#v(),this.#p(this.#o);const u=new Map;for(const s of p.columns)u.set(s.id,s);for(const s of this.#n){const O=u.get(s.id);O?s.appendPacked(O,w,v):s.grow(this.#i)}return{from:w,to:this.#o}}source(p){if(this.#c)return this.#r[p];if(!(p<0||p>=this.#o))return this.#g(p)}setSource(p,m){this.#m||p<0||p>=this.#o||this.#c&&(this.#r[p]=m)}get(p,m){const w=this.#t.get(p);return w?w.get(m):void 0}set(p,m,w){if(this.#m||m<0||m>=this.#o)return;const v=this.#t.get(p);if(!v){N(`store.set.${p}`,`set() on unknown column "${p}"`);return}v.set(m,w)}remove(p){return this.#m||p<0||p>=this.#o||this.#l.get(p)===1?!1:(this.#l.set(p),this.#s++,this.#a--,!0)}live(p){return p<0||p>=this.#o?!1:this.#l.get(p)===0}compact(p={}){if(this.#m||this.#s===0||!p.force&&this.#s/this.#o<this.#f)return null;const m=this.#o,w=new Uint32Array(m);let v=0;for(let u=0;u<m;u++)w[u]=this.#l.get(u)===1?b:v++;for(const u of this.#n)u.compact(w,m,v);if(this.#c){const u=this.#r;for(let s=0;s<m;s++)w[s]!==b&&(u[w[s]]=u[s]);u.length=v}return this.#o=v,this.#a=v,this.#s=0,this.#l=new Z(Math.max(this.#i,v)),w}column(p){return this.#t.get(p)}columns(){return this.#n.slice()}liveIndices(){const p=new Uint32Array(this.#a);if(this.#s===0){for(let w=0;w<this.#o;w++)p[w]=w;return p}let m=0;for(let w=0;w<this.#o;w++)this.#l.get(w)===0&&(p[m++]=w);return p}convert(p,m){const w=this.#t.get(p);return w?w.convert(m):!1}destroy(){if(!this.#m){this.#m=!0;for(const p of this.#n)p.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#l.release(),this.#o=0,this.#a=0,this.#s=0,this.#i=0}}#p(p){if(p<=this.#i)return;let m=this.#i||this.#h;for(;m<p;)m*=2;for(const w of this.#n)w.grow(m);this.#l.grow(m),this.#i=m}#g(p){const m={};for(const w of this.#n)m[w.id]=w.get(p);return m}#v(){if(this.#u)return;let p=this.#h;for(;p<this.#o;)p*=2;this.#u=!0,this.#i=p,this.#l.grow(p);for(const m of this.#n)m.columnarise(p,this.#o)}}}),Se("packages/core/src/store/pool.js",function(e,V){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const _=64,N=8;function $(H){let U=_;for(;U<H;)U*=2;return U}class L{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(U={}){this.#n=U.limit??N}get bytes(){return this.#r}mask(U){const z=new Uint8Array(this.#i(U),0,U);return z.fill(0),z}indices(U){return new Uint32Array(this.#i(U*4),0,U)}release(U){if(!U||!U.buffer)return!1;const z=U.buffer;if(!this.#t.has(z))return!1;this.#t.delete(z),this.#o.released++;const F=z.byteLength;let k=this.#e.get(F);return k||this.#e.set(F,k=[]),k.length>=this.#n||(k.push(z),this.#r+=F),!0}releaseAll(U){for(const z of U)this.release(z)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(U){const z=$(U),F=this.#e.get(z);this.#o.acquired++;let k;return F&&F.length?(k=F.pop(),this.#r-=z,this.#o.reused++):k=new ArrayBuffer(z),this.#t.add(k),k}}function W(){return Z??=new L,Z}let Z=null}),Se("packages/core/src/compute/sortspec.js",function(e,V){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return W}});function _(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function N(Z){return!!Z&&typeof Z.compare!="function"}function $(Z){if(!Z)return!0;for(let H=0;H<Z.length;H++)if(!N(Z[H]))return!1;return!0}function L(Z,H){const U=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,z=Z.locale!==void 0?Z.locale:H;return{col:U,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:_(z)}}function W(Z,H){const U=Z||[],z=new Array(U.length);for(let F=0;F<U.length;F++)z[F]=L(U[F],H);return z}}),Se("packages/core/src/compute/filter.js",function(e,V){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return x}});const _=V("packages/core/src/internal/util.js"),N=_.isBlank,$=_.toArray,L=_.warnOnce,Z=V("packages/core/src/format/date.js").toIsoDate,H=V("packages/core/src/compute/handle.js"),U=H.bitReader,z=H.dictSize,F=H.dictValue,k=H.presenceReader,S=H.valueComparator,b=H.valueReader,a=/^\d{4}-\d{2}-\d{2}$/,l="\0null\0";function r(I,j){const T=I&&I.pool;if(T){const B=T.mask||T.acquireMask||T.acquire||T.take;if(typeof B=="function"){const q=B.call(T,j);if(q&&q.length>=j)return q}}return new Uint8Array(j)}function t(I,j){const T=I&&I.pool;if(!T||!j)return;const B=T.release||T.releaseMask||T.free||T.recycle;typeof B=="function"&&B.call(T,j)}function n(I,j,T){return I.fill(T,0,j),I}function i(I){return I==null||typeof I=="number"&&Number.isNaN(I)}function o(I,j){if(I==null)return I;if(j==="number")return typeof I=="number"?I:Number(I);if(j==="date"||j==="dateString"){const T=Z(I);return T===null?c(I):T}return j==="boolean"?typeof I=="boolean"?I:I==="true"||I===1?!0:I==="false"||I===0?!1:!!I:I}function c(I){return I instanceof Date?I.getTime():typeof I=="number"?I:Date.parse(String(I))}function d(I){return typeof I=="number"?I:I instanceof Date?I.getTime():I==null||I===""?NaN:Number(I)}function f(I,j){const T=typeof I=="string"?I:String(I);return j?T:T.toLowerCase()}function h(I,j){return I==null?l:typeof I=="string"?j?I:I.toLowerCase():I instanceof Date?I.getTime():I}function g(I,j,T){const B=new Set;for(const q of $(I)){const X=o(q,T);B.add(h(X,j)),typeof X=="string"&&X!==""&&Number.isFinite(Number(X))?B.add(Number(X)):typeof X=="number"&&Number.isFinite(X)&&B.add(h(String(X),j))}return B}function y(I,j,T){if(I==null||j===null||j===void 0)return I==null&&j==null;const B=typeof I,q=typeof j;return B==="string"&&q==="string"?T?I===j:I.toLowerCase()===j.toLowerCase():I instanceof Date||j instanceof Date?c(I)===c(j):B==="number"&&q==="number"?I===j||Number.isNaN(I)&&Number.isNaN(j):B==="number"&&q==="string"?I===Number(j):B==="string"&&q==="number"?Number(I)===j:B==="boolean"||q==="boolean"?I===j:Array.isArray(I)&&Array.isArray(j)?I.length===j.length&&I.every((X,Q)=>y(X,j[Q],T)):I===j}function p(I,j){try{if(I instanceof RegExp){const T=I.flags.replace(/[gy]/g,"");return new RegExp(I.source,j||T.includes("i")?T:`${T}i`)}return new RegExp(String(I),j?"":"i")}catch(T){return L(`regex:${String(I)}`,`filter operator "matches" received an invalid pattern: ${String(I)}`,T),null}}function m(I,j){const T=w(I,j),B=I&&I.type;return B!=="date"&&B!=="dateString"?T:q=>T(typeof q=="string"&&a.test(q)?q:Z(q)??q)}function w(I,j){const T=I&&I.op,B=!!(I&&I.caseSensitive),q=I&&I.type,X=S(j),Q=te=>re=>!te(re);switch(T){case"eq":{const te=o(I.value,q);return re=>y(re,te,B)}case"ne":{const te=o(I.value,q);return re=>!y(re,te,B)}case"lt":case"lte":case"gt":case"gte":{const te=o(I.value,q);if(i(te))return()=>!1;const re=T==="lt"?-1:T==="lte"?0:T==="gt"?1:2;return ie=>{if(i(ie))return!1;const ae=X(ie,te);return re===-1?ae<0:re===0?ae<=0:re===1?ae>0:ae>=0}}case"between":case"notBetween":{const te=$(I.value),re=o(te[0],q),ie=o(te[1],q),ae=I.bounds||"[]",ee=ae.charAt(0)!=="(",J=ae.charAt(1)!==")";if(i(re)||i(ie))return T==="between"?()=>!1:()=>!0;const se=le=>{if(i(le))return!1;const oe=X(le,re),he=X(le,ie);return(ee?oe>=0:oe>0)&&(J?he<=0:he<0)};return T==="between"?se:Q(se)}case"in":case"notIn":{const te=g(I.value,B,q),re=ie=>te.has(h(ie,B));return T==="in"?re:Q(re)}case"contains":case"notContains":{const te=f(o(I.value,q),B),re=ie=>ie==null?!1:f(ie,B).includes(te);return T==="contains"?re:Q(re)}case"startsWith":{const te=f(o(I.value,q),B);return re=>re==null?!1:f(re,B).startsWith(te)}case"endsWith":{const te=f(o(I.value,q),B);return re=>re==null?!1:f(re,B).endsWith(te)}case"matches":{const te=p(I.value,B);return te?re=>re==null?!1:te.test(String(re)):()=>!1}case"blank":return te=>N(te)||Array.isArray(te)&&te.length===0;case"notBlank":return te=>!(N(te)||Array.isArray(te)&&te.length===0);case"containsAny":case"containsNone":{const te=g(I.value,B,q),re=ie=>{const ae=ie==null?[]:$(ie);for(let ee=0;ee<ae.length;ee++)if(te.has(h(ae[ee],B)))return!0;return!1};return T==="containsAny"?re:Q(re)}case"containsAll":{const te=$(I.value).map(re=>h(o(re,q),B));return re=>{const ie=re==null?[]:$(re);if(te.length===0)return!0;const ae=new Set(ie.map(ee=>h(ee,B)));for(let ee=0;ee<te.length;ee++)if(!ae.has(te[ee]))return!1;return!0}}default:return L(`op:${String(T)}`,`unknown filter operator "${String(T)}"; the condition passes every row`),()=>!0}}function v(I,j,T){return m(j,T)(I)}function u(I,j,T,B){const q=k(I);if(q){const te=j?1:0;for(let re=0;re<B;re++)T[re]=q(re)===te?1:0;return T}const X=I.kind;if(X==="float64"||X==="int32"||X==="bitset")return n(T,B,j?1:0);const Q=b(I);for(let te=0;te<B;te++){const re=Q(te),ie=N(re)||Array.isArray(re)&&re.length===0;T[te]=ie===j?0:1}return T}function s(I,j,T,B){const q=I.dict,X=z(q),Q=new Uint8Array(X);for(let ae=0;ae<X;ae++)Q[ae]=j(F(q,ae))?1:0;const te=I.values,re=k(I);if(!re){for(let ae=0;ae<B;ae++)T[ae]=Q[te[ae]];return T}const ie=j(null)?1:0;for(let ae=0;ae<B;ae++)T[ae]=re(ae)===1?Q[te[ae]]:ie;return T}function O(I,j,T,B){const q=U(I.values),X=j(!0)?1:0,Q=j(!1)?1:0,te=k(I);if(!te){for(let ie=0;ie<B;ie++)T[ie]=q(ie)===1?X:Q;return T}const re=j(null)?1:0;for(let ie=0;ie<B;ie++)T[ie]=te(ie)===0?re:q(ie)===1?X:Q;return T}function E(I,j,T,B,q){const X=I.values,Q=j.type,te=j.op;let re=!0;switch(te){case"eq":case"ne":{const ae=d(o(j.value,Q)),ee=typeof j.value=="number"&&Number.isNaN(j.value),J=te==="ne"?1:0;if(ee)for(let se=0;se<q;se++)B[se]=(Number.isNaN(X[se])?1:0)^J;else for(let se=0;se<q;se++)B[se]=(X[se]===ae?1:0)^J;break}case"lt":{const ae=d(o(j.value,Q));for(let ee=0;ee<q;ee++)B[ee]=X[ee]<ae?1:0;break}case"lte":{const ae=d(o(j.value,Q));for(let ee=0;ee<q;ee++)B[ee]=X[ee]<=ae?1:0;break}case"gt":{const ae=d(o(j.value,Q));for(let ee=0;ee<q;ee++)B[ee]=X[ee]>ae?1:0;break}case"gte":{const ae=d(o(j.value,Q));for(let ee=0;ee<q;ee++)B[ee]=X[ee]>=ae?1:0;break}case"between":case"notBetween":{const ae=$(j.value),ee=d(o(ae[0],Q)),J=d(o(ae[1],Q)),se=j.bounds||"[]",le=se.charAt(0)!=="(",oe=se.charAt(1)!==")",he=te==="notBetween"?1:0;if(le&&oe)for(let fe=0;fe<q;fe++)B[fe]=(X[fe]>=ee&X[fe]<=J?1:0)^he;else if(le)for(let fe=0;fe<q;fe++)B[fe]=(X[fe]>=ee&X[fe]<J?1:0)^he;else if(oe)for(let fe=0;fe<q;fe++)B[fe]=(X[fe]>ee&X[fe]<=J?1:0)^he;else for(let fe=0;fe<q;fe++)B[fe]=(X[fe]>ee&X[fe]<J?1:0)^he;break}case"in":case"notIn":{const ae=new Set;for(const J of $(j.value)){const se=d(o(J,Q));Number.isNaN(se)||ae.add(se)}const ee=te==="notIn"?1:0;for(let J=0;J<q;J++)B[J]=(ae.has(X[J])?1:0)^ee;break}default:re=!1;break}if(!re)return!1;const ie=k(I);if(ie){const ae=T(null)?1:0;for(let ee=0;ee<q;ee++)ie(ee)===0&&(B[ee]=ae)}return!0}function A(I,j,T,B){const q=b(I);for(let X=0;X<B;X++)T[X]=j(q(X))?1:0;return T}function M(I,j,T){const B=j.count|0,q=T||r(j,B);if(!I)return n(q,B,1);const X=typeof j.handle=="function"?j.handle(I.col):void 0,Q=typeof j.custom=="function"?j.custom:null;if(!X){if(Q){for(let ie=0;ie<B;ie++)q[ie]=Q(I,ie)?1:0;return q}return L(`filter:col:${String(I.col)}`,`filter references unknown column "${String(I.col)}"; the condition passes every row`),n(q,B,1)}const te=I.op;if(te==="blank"||te==="notBlank")return u(X,te==="notBlank",q,B);const re=m(I,j.locale);switch(X.kind){case"dictionary":return s(X,re,q,B);case"bitset":return O(X,re,q,B);case"float64":case"int32":return E(X,I,re,q,B)?q:A(X,re,q,B);default:return A(X,re,q,B)}}function C(I,j,T){if(!I)return n(r(j,T),T,1);if(Array.isArray(I.conditions)){const B=I.conditions.filter(Q=>Q!=null),q=I.op==="or"?"or":I.op==="not"?"not":"and";if(B.length===0)return n(r(j,T),T,1);const X=C(B[0],j,T);for(let Q=1;Q<B.length;Q++){const te=C(B[Q],j,T);if(q==="or")for(let re=0;re<T;re++)X[re]|=te[re];else for(let re=0;re<T;re++)X[re]&=te[re];t(j,te)}if(q==="not")for(let Q=0;Q<T;Q++)X[Q]^=1;return X}return M(I,j,r(j,T))}function P(I,j){return C(I,j,j.count|0)}function D(I,j){if(!I||!j)return I||null;const T=I;if(Array.isArray(T.conditions)){if((T.op==="or"?"or":T.op==="not"?"not":"and")!=="and")return K(T,j)?null:I;const q=[];for(const X of T.conditions){const Q=D(X,j);Q&&q.push(Q)}return q.length?{...T,op:"and",conditions:q}:null}return T.col===j?null:I}function K(I,j){if(!I||typeof I!="object")return!1;const T=I;if(T.col===j)return!0;if(Array.isArray(T.conditions)){for(const B of T.conditions)if(K(B,j))return!0}return!1}function x(I,j,T){if(T&&T.length>=j){let Q=0;for(let te=0;te<j;te++)I[te]&&(T[Q++]=te);return T.subarray(0,Q)}let B=0;for(let Q=0;Q<j;Q++)B+=I[Q]?1:0;const q=new Uint32Array(B);let X=0;for(let Q=0;Q<j;Q++)I[Q]&&(q[X++]=Q);return q}}),Se("packages/core/src/compute/facet.js",function(e,V){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const _=V("packages/core/src/compute/handle.js"),N=_.presenceReader,$=_.valueReader,L=_.dictSize,W=_.dictValue,Z=Object.freeze(["equal","quantile","log"]),H=Object.freeze(["hour","day","week","month","quarter","year"]),U=20,z=50,F=1e4;function k(u,s){if(!u)return"none";const O=s&&s.base;if(O==="date"||O==="datetime"||O==="time"||O==="dateString")return"date";switch(u.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return O==="number"?"numeric":O==="boolean"?"boolean":O==="text"?"category":"none"}}function S(u){const s=u.values,O=u.kind;if((O==="float64"||O==="int32")&&s)return A=>s[A];const E=$(u);return A=>b(E(A))}function b(u){if(typeof u=="number")return u;if(u instanceof Date)return u.getTime();if(u==null||u==="")return NaN;if(typeof u=="boolean")return u?1:0;if(typeof u=="string"){const s=Number(u);if(Number.isFinite(s))return s;const O=Date.parse(u);return Number.isFinite(O)?O:NaN}return NaN}function a(u,s,O,E=z){if(!u)return{cardinality:0,exact:!0};if(u.dict)return{cardinality:L(u.dict),exact:!0};if(u.kind==="bitset")return{cardinality:2,exact:!0};const A=$(u),M=s?s.length:O,C=new Set;for(let P=0;P<M;P++){const D=A(s?s[P]:P);if(D!=null&&(C.add(D),C.size>E))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const l=36e5,r=864e5;function t(u,s=U){const O=Number.isFinite(u)&&u>0?u:0,E=Math.max(1,s)*2;return O/l<=E?"hour":O/r<=E?"day":O/(7*r)<=E?"week":O/(30*r)<=E?"month":O/(91*r)<=E?"quarter":"year"}function n(u,s){if(!Number.isFinite(u))return NaN;const O=new Date(u);switch(s){case"hour":return O.setMinutes(0,0,0),O.getTime();case"day":return O.setHours(0,0,0,0),O.getTime();case"week":{O.setHours(0,0,0,0);const E=(O.getDay()+6)%7;return O.setDate(O.getDate()-E),O.getTime()}case"month":return O.setDate(1),O.setHours(0,0,0,0),O.getTime();case"quarter":return O.setMonth(Math.floor(O.getMonth()/3)*3,1),O.setHours(0,0,0,0),O.getTime();default:return O.setMonth(0,1),O.setHours(0,0,0,0),O.getTime()}}function i(u,s){const O=new Date(u);switch(s){case"hour":O.setHours(O.getHours()+1);break;case"day":O.setDate(O.getDate()+1);break;case"week":O.setDate(O.getDate()+7);break;case"month":O.setMonth(O.getMonth()+1);break;case"quarter":O.setMonth(O.getMonth()+3);break;default:O.setFullYear(O.getFullYear()+1);break}return O.getTime()}function o(u,s,O){const E=S(u),A=N(u),M=s?s.length:O;let C=1/0,P=-1/0,D=0,K=0;for(let x=0;x<M;x++){const I=s?s[x]:x;if(A&&!A(I)){D++;continue}const j=E(I);if(!Number.isFinite(j)){D++;continue}j<C&&(C=j),j>P&&(P=j),K++}return{min:C,max:P,nulls:D,finite:K}}function c(u,s,O,E){const A=S(u),M=N(u),C=s?s.length:O,P=C>E?C/E:1,D=[];for(let x=0;x<C;x+=P){const I=s?s[Math.floor(x)]:Math.floor(x);if(M&&!M(I))continue;const j=A(I);Number.isFinite(j)&&D.push(j)}const K=Float64Array.from(D);return K.sort(),K}function d(u,s,O,E={}){const A=E.kind||k(u,E.type);return A==="none"||!u?{kind:"none",buckets:[],suppressed:"type"}:A==="boolean"?f(u,s,O):A==="category"?h(u,s,O,E):g(u,s,O,A,E)}function f(u,s,O){const E=N(u);let A=0;if(E){const C=s?s.length:O;for(let P=0;P<C;P++)E(s?s[P]:P)||A++}const M=[{value:!1,label:"false"},{value:!0,label:"true"}];return A>0&&M.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:M}}function h(u,s,O,E){const A=E.cardinalityLimit??z,{cardinality:M}=a(u,s,O,A);if(M>A&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:M};const C=$(u),P=s?s.length:O,D=new Map;let K=0;for(let B=0;B<P;B++){const q=C(s?s[B]:B);if(q==null||q===""){K++;continue}if(Array.isArray(q)){if(!q.length){K++;continue}for(const X of q)D.set(X,(D.get(X)||0)+1);continue}D.set(q,(D.get(q)||0)+1)}let x=[...D.entries()];E.order==="alpha"?x.sort((B,q)=>String(B[0]).localeCompare(String(q[0]))):x.sort((B,q)=>q[1]-B[1]);let I=0,j=0;if(x.length>A){j=x.length-A;for(let B=A;B<x.length;B++)I+=x[B][1];x=x.slice(0,A)}const T=x.map(([B])=>({value:B,label:String(B)}));return I>0&&T.push({remainder:!0,label:`Other (${j} values)`}),K>0&&T.push({null:!0,label:"Empty"}),{kind:"category",buckets:T,cardinality:M}}function g(u,s,O,E,A){const{min:M,max:C,nulls:P,finite:D}=o(u,s,O);if(!D)return{kind:E,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const K=Math.max(1,Math.floor(A.buckets||U));let x=[];if(E==="date"){const j=H.includes(A.granularity)?A.granularity:t(C-M,K);let T=n(M,j);for(;T<=C&&x.length<4096;){const B=i(T,j);if(!(B>T))break;x.push({from:T,to:B}),T=B}return{kind:E,buckets:y(x,P),granularity:j}}const I=Z.includes(A.strategy)?A.strategy:"equal";if(I==="quantile"){const j=c(u,s,O,F);if(j.length){const T=[j[0]];for(let B=1;B<K;B++){const q=j[Math.min(j.length-1,Math.floor(B/K*j.length))];q>T[T.length-1]&&T.push(q)}T.push(C);for(let B=0;B<T.length-1;B++)x.push({from:T[B],to:T[B+1]})}}else if(I==="log"&&M>0){const j=Math.log10(M),B=(Math.log10(C)-j)/K||1;for(let q=0;q<K;q++)x.push({from:10**(j+q*B),to:10**(j+(q+1)*B)})}if(!x.length){const j=(C-M)/K||1;for(let T=0;T<K;T++)x.push({from:M+T*j,to:M+(T+1)*j})}return x[x.length-1].to=C,{kind:E,buckets:y(x,P),strategy:I,min:M,max:C}}function y(u,s){return s>0?[...u,{null:!0,label:"Empty"}]:u}function p(u,s,O,E,A){const M=E&&E.buckets||[],C=A&&A.length>=M.length?A.subarray(0,M.length):new Uint32Array(M.length);if(C.fill(0),!u||!M.length)return C;const P=M.length-1,D=!!M[P]&&M[P].null===!0,K=s?s.length:O;if(E.kind==="boolean"){const B=$(u);for(let q=0;q<K;q++){const X=B(s?s[q]:q);if(X==null){D&&C[P]++;continue}C[X?1:0]++}return C}if(E.kind==="category"){const B=new Map;for(let Q=0;Q<M.length;Q++)!M[Q].null&&!M[Q].remainder&&B.set(M[Q].value,Q);const q=M.findIndex(Q=>Q.remainder),X=$(u);for(let Q=0;Q<K;Q++){const te=X(s?s[Q]:Q);if(te==null||te===""){D&&C[P]++;continue}if(Array.isArray(te)){if(!te.length){D&&C[P]++;continue}for(const ie of te){const ae=B.get(ie);ae!==void 0?C[ae]++:q>=0&&C[q]++}continue}const re=B.get(te);re!==void 0?C[re]++:q>=0&&C[q]++}return C}const x=D?M.length-1:M.length,I=new Float64Array(x+1);for(let B=0;B<x;B++)I[B]=M[B].from;I[x]=x?M[x-1].to:0;const j=S(u),T=N(u);for(let B=0;B<K;B++){const q=s?s[B]:B;if(T&&!T(q)){D&&C[P]++;continue}const X=j(q);if(!Number.isFinite(X)){D&&C[P]++;continue}const Q=m(I,x,X);Q>=0&&C[Q]++}return C}function m(u,s,O){if(!s||O<u[0])return-1;if(O>=u[s])return O===u[s]?s-1:-1;let E=0,A=s-1;for(;E<A;){const M=E+A+1>>>1;O>=u[M]?E=M:A=M-1}return E}function w(u,s,O,E={}){const A=E.bounds||d(u,E.boundsIndices??s,O,E);return{bounds:A,counts:p(u,s,O,A)}}const v=w}),Se("packages/core/src/compute/pivotmatrix.js",function(e,V){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return n}});const N=V("packages/core/src/compute/handle.js").valueComparator,L=V("packages/core/src/compute/total.js").total,Z=V("packages/core/src/compute/group.js").packKeys,H=V("packages/core/src/compute/pivot.js"),U=H.joinPath,z=H.DEFAULT_PATH_SEPARATOR,F=H.DEFAULT_MAX_COLUMNS,k="";function S(i,o,c={}){const d=c.separator||z,f=i||[],h=o instanceof Uint32Array?o:Uint32Array.from(o||[]),g=h.length;if(f.length===0)return{tuples:[[]],paths:[k],buckets:[h]};const{keyOf:y,readers:p}=Z(f,h,0),m=new Map,w=[],v=[],u=[];for(let C=0;C<g;C++){const P=h[C],D=y(P);let K=m.get(D);if(K===void 0){K=w.length,m.set(D,K),v.push(D);const x=new Array(p.length);for(let I=0;I<p.length;I++)x[I]=p[I](P);w.push(x),u.push([])}u[K].push(P)}const s=N(c.locale),O=w.map((C,P)=>P);O.sort((C,P)=>{const D=w[C],K=w[P];for(let x=0;x<D.length;x++){const I=b(D[x],K[x],s);if(I!==0)return I}return C-P});const E=new Array(O.length),A=new Array(O.length),M=new Array(O.length);for(let C=0;C<O.length;C++){const P=O[C];E[C]=w[P],A[C]=U(w[P],d),M[C]=Uint32Array.from(u[P])}return{tuples:E,paths:A,buckets:M}}function b(i,o,c){const d=i==null,f=o==null;return d||f?d&&f?0:d?1:-1:c(i,o)}function a(i,o,c){const d=[];for(let f=0;f<i.length;f++)c.has(i[f])&&d.push(i[f]);return Uint32Array.from(d)}function l(i,o,c,d){return{value:o.length?L(i,o,c,d):null,leaves:o,count:o.length}}function r(i){const o=i&&i.opts||{},c=o.separator||z,d=o.totalContext||{locale:o.locale},f=(i.measures||[]).filter(A=>A&&A.handle),h=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),g=S(i.rowHandles||[],h,{...o,separator:c}),y=S(i.columnHandles||[],h,{...o,separator:c}),p=o.maxColumns===void 0?F:o.maxColumns,m=y.paths.length*Math.max(1,f.length),w=new Map;if(p&&m>p)return{rowAxis:g,columnAxis:y,measures:f.map(A=>({colId:A.colId,fn:A.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 ${p}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:p}};const v=new Map,u=new Map,s=new Map,O=new Map,E=y.buckets.map(A=>new Set(A));for(let A=0;A<y.paths.length;A++){const M=y.buckets[A],C=y.paths[A];for(const P of f)s.set(n(C,P.colId),l(P.handle,M,P.fn,d))}for(let A=0;A<g.paths.length;A++){const M=g.buckets[A],C=g.paths[A];for(const P of f)u.set(n(C,P.colId),l(P.handle,M,P.fn,d));for(let P=0;P<y.paths.length;P++){const D=a(M,y.buckets[P],E[P]);if(D.length===0)continue;const K=y.paths[P];for(const x of f)v.set(t(C,K,x.colId),l(x.handle,D,x.fn,d))}}for(const A of f)O.set(A.colId,l(A.handle,h,A.fn,d));return{rowAxis:g,columnAxis:y,measures:f.map(A=>({colId:A.colId,fn:A.fn})),body:v,rowMargin:u,columnMargin:s,grand:O,columns:m,error:null}}function t(i,o,c){return`${i}\0${o}\0${c}`}function n(i,o){return`${i}\0${o}`}}),Se("packages/core/src/compute/reference.js",function(e,V){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return r}});const N=V("packages/core/src/internal/util.js").getPath,$=V("packages/core/src/compute/handle.js"),L=$.isMissing,W=$.valueComparator,H=V("packages/core/src/compute/filter.js").testValue,U="",z="\0";function F(i,o){const c=o.includes(".")?N(i,o):i?.[o];return c===void 0?null:c}function k(i,o,c={}){const d=o||[];let f=i.map((h,g)=>g);if(d.length===0)return f;for(let h=d.length-1;h>=0;h--)f=S(i,f,d[h],c);return f}function S(i,o,c,d){const f=c.locale!==void 0?c.locale:d.locale,h=W(f),g=c.descending!==void 0?!!c.descending:c.dir==="desc",y=[],p=[];for(const v of o){const u=F(i[v],c.col);L(u)?p.push(v):y.push(v)}const m=new Map;for(let v=0;v<y.length;v++)m.set(y[v],v);const w=(v,u)=>{const s=F(i[v],c.col),O=F(i[u],c.col);let E;return typeof c.compare=="function"?(E=c.compare(s,O,i[v],i[u],g),g&&(E=-E)):E=g?h(O,s):h(s,O),E!==0?E:m.get(v)-m.get(u)};return y.sort(w),c.nullsFirst?p.concat(y):y.concat(p)}function b(i,o,c={}){const d=[];for(let f=0;f<i.length;f++)a(i[f],o,c,f)&&d.push(f);return d}function a(i,o,c,d){if(!o)return!0;if(Array.isArray(o.conditions)){const f=o.conditions.filter(g=>g!=null);if(f.length===0)return!0;if(o.op==="or")return f.some(g=>a(i,g,c,d));const h=f.every(g=>a(i,g,c,d));return o.op==="not"?!h:h}return o.col===void 0&&typeof c.custom=="function"?!!c.custom(o,i,d):H(F(i,o.col),o,c.locale)}function l(i,o,c,d){const f=c||i.map((p,m)=>m),h=new Map,g=[],y=[];for(const p of f){const m=o.map((u,s)=>{const O=F(i[p],u);return d&&d[s]?d[s](O):O}),w=m.map(u=>u==null?z:String(u)).join(U);let v=h.get(w);v===void 0&&(v=g.length,h.set(w,v),g.push(m),y.push([])),y[v].push(p)}return{keys:g,buckets:y}}function r(i,o,c={}){const d=W(c.locale),f=i.filter(g=>!L(g)),h=f.map(t).filter(g=>g!==null);switch(o){case"count":return i.length;case"countValues":return f.length;case"sum":return h.reduce((g,y)=>g+y,0);case"avg":return f.length===0?null:h.reduce((g,y)=>g+y,0)/f.length;case"min":return f.length===0?null:f.reduce((g,y)=>d(y,g)<0?y:g);case"max":return f.length===0?null:f.reduce((g,y)=>d(y,g)>0?y:g);case"first":return i.length===0?null:n(i[0]);case"last":return i.length===0?null:n(i[i.length-1]);default:return null}}function t(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const o=Number(i);return Number.isNaN(o)?null:o}function n(i){return i===void 0?null:i}}),Se("packages/core/src/compute/index.js",function(e,V){"use strict";const _=V("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return _.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return _.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return _.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return _.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return _.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return _.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return _.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return _.rankSortStrings}});const N=V("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return N.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return N.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return N.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return N.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return N.describeSort}});const $=V("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return $.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return $.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return $.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return $.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return $.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return $.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return $.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return $.mentionsColumn}});const L=V("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return L.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return L.packKeys}});const W=V("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return W.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return W.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return W.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return W.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return W.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return W.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return W.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return W.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return W.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return W.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return W.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return W.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return W.QUANTILE_SAMPLE}});const Z=V("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const H=V("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return H.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return H.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return H.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return H.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return H.DEFAULT_MAX_COLUMNS}});const U=V("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return U.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return U.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return U.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return U.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return U.GRAND_PATH}});const z=V("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return z.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return z.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return z.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return z.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return z.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z.referenceValue}});const F=V("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return F.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return F.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return F.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return F.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return F.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return F.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return F.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return F.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return F.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return F.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return F.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return F.isMissing}});const k=V("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return k.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return k.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return k.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return k.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return k.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return k.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k.SKETCH_BOUNDS}});const S=V("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return S.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return S.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return S.openWindow}});const b=V("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 a=V("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return a.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return a.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return a.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return a.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return a.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return a.anomalyCondition}});const l=V("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return l.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return l.forecast}})}),Se("packages/core/src/source/rows.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return a}});const _=V("packages/core/src/internal/util.js"),N=_.warnOnce,$=_.isFunction,L=32,W="\0";function Z(l){return new H(l)}class H{#e;#t;constructor(r){this.#e=$(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||$(t)?t:L}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const n=this.#e(r);if(n!=null)return String(n)}else N("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(r){return $(this.#t)?Number(this.#t(r))||L:this.#t}leaf(r,t,n=0,i=null){const o={key:this.keyOf(r,t),data:r,level:n,parent:i,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return o.height=this.heightOf(o),o}group(r){const t={key:b(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${W}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${W}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const n={key:`${W}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return n.height=this.heightOf(n),n}skeleton(r,t=0){const n={key:`${W}pending${W}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null};return n.height=this.heightOf(n),n}}function U(l,r,t,n){return{key:`${W}pinned${W}${t}${W}${r}`,data:l,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:n,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function z(l,r){return new Proxy([],{get(t,n,i){if(n==="length")return l();if(typeof n=="string"){const o=Number(n);if(Number.isInteger(o)&&o>=0)return r(o)}return Reflect.get(t,n,i)},has(t,n){if(typeof n=="string"){const i=Number(n);if(Number.isInteger(i)&&i>=0)return i<l()}return Reflect.has(t,n)}})}function F(l){return l==null?"":String(l)}const k="";function S(l){if(l==null)return k;const r=String(l);return r.startsWith(k)?k+r:r}function b(l){const r=l||[];let t="g";for(let n=0;n<r.length;n++)t+=W+S(r[n]);return t}function a(l){const r=new Array(l.length),t=[];for(let n=0;n<l.length;n++)t.push(l[n]),r[n]=b(t);return r}}),Se("packages/core/src/source/handles.js",function(e,V){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce;class L{#e;#t;#n;#r=new Map;#o=0;constructor(H,U,z){this.#e=H,this.#t=U,this.#n=N(z)?z:()=>!1}get store(){const H=this.#e.store;return H&&N(H.column)?H:null}invalidate(){this.#o++}handle(H){const U=this.store;if(U){const S=U.column(H);if(S)return S}const z=this.#r.get(H);if(z&&z.builtAt===this.#o)return z.handle;const F=this.#i(H);if(!F)return;if(U&&this.#n()){$(`source.dropped.${H}`,`column "${H}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const k=this.#a(F);return this.#r.set(H,{handle:k,builtAt:this.#o}),k}#i(H){const U=this.#e.columns;return U&&N(U.get)?U.get(H):void 0}#a(H){const U=this.#t()||[],z=U.length,F=new Array(z),k=N(H.getValue)?b=>H.getValue(b):b=>b?.[H.field||H.id];for(let b=0;b<z;b++)F[b]=U[b]===void 0?void 0:k(U[b]);const S=this.#o;return{id:H.id,kind:"object",nullable:!1,values:F,presence:null,dict:null,offsets:null,get(b){return F[b]},version:S}}}function W(Z,H,U){return new L(Z,H,U)}}),Se("packages/core/src/compute/incremental.js",function(e,V){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const N=V("packages/core/src/store/columnstore.js").toFloat,$=Object.freeze(["sum","avg","countValues","min","max"]),L=Object.freeze(["float64"]),W=1e15;function Z(F,k){return typeof F!="string"||!$.includes(F)?!1:!!k&&L.includes(k.kind)}function H(F){if(F==null)return null;const k=N(F);return Number.isNaN(k)?null:k}class U{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#a=!1;#s=!1;constructor(k){this.#e=k}get valid(){return this.#a&&!this.#s}get fn(){return this.#e}seed(k){this.#l();for(let S=0;S<k.length;S++){const b=H(k[S]);b!==null&&this.#u(b)}this.#a=!0}seedColumn(k,S,b){this.#l();for(let a=0;a<b.length;a++){const l=b[a];if(S&&S(l)===0)continue;const r=k[l];Number.isNaN(r)||this.#u(r)}this.#a=!0}#l(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#s=!1}#u(k){if(!Number.isFinite(k)){this.#s=!0;return}const S=this.#t+k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-S+k:k-S+this.#t,this.#t=S,this.#r++,k<this.#o&&(this.#o=k),k>this.#i&&(this.#i=k)}#c(k){const S=this.#t-k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-S-k:-k-S+this.#t,this.#t=S,this.#r--}update(k,S){if(!this.#a)return!1;const b=H(k),a=H(S);return b===null&&a===null?!0:b!==null&&!Number.isFinite(b)||a!==null&&!Number.isFinite(a)?!1:this.#e==="min"||this.#e==="max"?b===null||a===null?!1:this.#e==="min"?a<this.#o?(this.#o=a,!0):b>this.#o:a>this.#i?(this.#i=a,!0):b<this.#i:Math.abs(this.#t)>W?!1:(b!==null&&this.#c(b),a!==null&&this.#u(a),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#a=!1}}const z=U}),Se("packages/core/src/source/filterwire.js",function(e,V){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return p}}),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 u}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return s}});const N=V("packages/core/src/internal/util.js").warnOnce,$="source.remote.hostFilter",L="source.where.pageRelative";function W(A,M){!Array.isArray(A)||!A.length||N(L,`filters.where (${A.join(", ")}) runs over the rows the ${M} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(A){const M=(A||{}).config;!M||!M.hostFilter||N($,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function U(A,M){N(`${H}:${A}`,`filters.where("${A}") is registered but the ${M} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const z="source.where.overThreshold";function F(A,M,C,P){!Array.isArray(A)||!A.length||N(`${z}:${M}`,`filters.where (${A.join(", ")}) is not applied to the ${M} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${P.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const k=new Map;function S(A){let M=k.get(A);return M||(M=new Intl.DateTimeFormat("en-US",{timeZone:A,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),k.set(A,M)),M}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function a(A,M){const C=S(M).formatToParts(new Date(A)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const D of C)D.type==="year"?P.y=+D.value:D.type==="month"?P.m=+D.value:D.type==="day"?P.d=+D.value:D.type==="hour"?P.h=+D.value%24:D.type==="minute"?P.mi=+D.value:D.type==="second"&&(P.s=+D.value);return P}function l(A,M){const C=a(A,M);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(A/1e3)*1e3}function r(A,M,C,P){const D=Date.UTC(A,M-1,C),K=D-l(D,P);return D-l(K,P)}function t(A,M,C){const P=new Date(Date.UTC(A.y,A.m-1,A.d+M));return r(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),C)}const n=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(A,M){if(typeof A!="string")return null;const C=A.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(C);if(P){const D=P[1]==="n"?"":P[1],K=Number(D||M);return!Number.isFinite(K)||K<=0?null:{kind:"lastNDays",n:Math.floor(K)}}switch(C){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function o(A,M={}){const C=i(A,M.n);if(!C)return null;const P=M.tz||b(),D=M.now instanceof Date?M.now.getTime():typeof M.now=="number"?M.now:Date.now(),K=a(D,P),x=r(K.y,K.m,K.d,P),I=t(K,1,P);let j=x,T=I;switch(C.kind){case"today":break;case"yesterday":j=t(K,-1,P),T=x;break;case"lastNDays":T=M.includeToday?I:x,j=t(K,M.includeToday?-(C.n-1):-C.n,P);break;case"thisWeek":{const B=Number.isFinite(M.weekStartsOn)?Number(M.weekStartsOn):1,X=(new Date(Date.UTC(K.y,K.m-1,K.d)).getUTCDay()-B+7)%7;j=t(K,-X,P),T=t(K,-X+7,P);break}case"thisMonth":j=r(K.y,K.m,1,P),T=r(K.m===12?K.y+1:K.y,K.m===12?1:K.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const B=Math.floor((K.m-1)/3)*3+1;j=r(K.y,B,1,P),T=C.kind==="quarterToDate"?I:B===10?r(K.y+1,1,1,P):r(K.y,B+3,1,P);break}case"thisYear":case"yearToDate":j=r(K.y,1,1,P),T=C.kind==="yearToDate"?I:r(K.y+1,1,1,P);break;default:return null}return{from:new Date(j).toISOString(),to:new Date(T).toISOString(),bounds:"[)",tz:P,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function c(A){if(!A||typeof A!="object")return null;const M=A.value;if(M&&typeof M=="object"&&!Array.isArray(M)&&"relative"in M)return{token:String(M.relative),n:typeof M.n=="number"?M.n:void 0};if(A.op==="relative"&&typeof A.value=="string")return{token:A.value,n:void 0};const C=A.meta;return C&&typeof C.relative=="string"&&A.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function d(){return`Known tokens: ${n.filter(M=>M!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function f(A){const M=c(A);return M?i(M.token,M.n)!==null:!1}function h(A,M={}){const C=c(A);if(!C)return A;const P=o(C.token,{...M,n:C.n});return P?{...A,type:A.type||"date",op:"between",value:[P.from,P.to],bounds:A.bounds||P.bounds,meta:{...A.meta||{},relative:P.relative,tz:P.tz}}:(N(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,d()),A)}function g(A){return!!A&&typeof A=="object"&&Array.isArray(A.conditions)}function y(A,M){if(A){if(g(A)){for(const C of A.conditions)y(C,M);return}M(A)}}function p(A,M){if(!A)return null;if(!g(A))return M(A);const C=A;let P=!1;const D=[];for(const K of C.conditions){const x=p(K,M);x!==K&&(P=!0),x&&D.push(x)}return!P&&D.length===C.conditions.length?A:D.length?{...C,conditions:D}:null}function m(A){if(!A)return null;if(!g(A))return A;const M=A,C=[];for(const P of M.conditions){const D=m(P);D&&C.push(D)}return C.length?{op:M.op,conditions:C}:null}function w(A){const M=m(A);return M?g(M)&&M.op==="and"?M:{op:"and",conditions:[M]}:null}function v(A){const M=(A||[]).filter(Boolean);return M.length?{op:"and",conditions:M}:null}function u(A,M={}){const C=p(A,P=>h(P,M));return w(C)}function s(A){const M=O(A.filters??null);return JSON.stringify([M,A.sort??null,A.quick??"",A.groupBy??null,A.pivotBy??null,E(A.context)])}function O(A){if(!A)return null;if(g(A)){const P=A;return{op:P.op,conditions:P.conditions.map(O)}}const M=A,C=M.meta&&typeof M.meta.relative=="string"?M.meta.relative:c(M)?.token;return{col:M.col,op:M.op,bounds:M.bounds??null,caseSensitive:M.caseSensitive??!1,value:C?`rel:${C}`:M.value??null}}function E(A){if(A==null)return null;try{return JSON.parse(JSON.stringify(A))}catch{return N("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Se("packages/core/src/source/tree.js",function(e,V){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return b}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,L="",W="\0tree:";function Z(a,l){return{physical:a,key:l,level:0,children:[],value:void 0}}function H(a,l){const r=[],t=new Map;for(let n=0;n<a.length;n++){const i=a[n],o=l.pathOf(i),c=Array.isArray(o)?o.map(f=>String(f)):[];if(!c.length){const f=Z(i,l.keyOf(i));r.push(f);continue}let d=null;for(let f=0;f<c.length;f++){const h=c.slice(0,f+1).join(L),g=f===c.length-1;let y=t.get(h);y&&g&&y.physical===-1&&(y.physical=i,y.key=l.keyOf(i)),y||(y=Z(g?i:-1,g?l.keyOf(i):W+h),y.level=f,y.value=c[f],t.set(h,y),d?d.children.push(y):r.push(y)),d=y}}return{roots:r,nodes:t}}function U(a,l){const r=new Map,t=[];for(let c=0;c<a.length;c++){const d=a[c],f=l.keyOf(d),h=Z(d,f);r.set(f,h);const g=l.parentOf(d);g!=null&&g!==""&&t.push({node:h,parent:String(g)})}let n=null;const i=new Map;for(const{node:c,parent:d}of t){const f=r.get(d);if(f){i.set(c.key,f);continue}l.orphans&&l.orphans!=="root"&&(n||(n=Z(-1,`${W}orphans`),n.value=l.orphans),i.set(c.key,n))}const o=[];for(const c of r.values()){const d=i.get(c.key);d?d.children.push(c):o.push(c)}return n&&n.children.length&&o.push(n),{roots:z(o,r,l.orphans,n),nodes:r}}function z(a,l,r,t){const n=new Set,i=[...a];for(;i.length;){const h=i.pop();if(!n.has(h.key)){n.add(h.key);for(const g of h.children)i.push(g)}}const o=[];for(const h of l.values())n.has(h.key)||o.push(h);if(!o.length)return a;const c=!!r&&r!=="root";$("tree.cycle",`tree.parentKey produced ${o.length} row(s) inside a parent cycle; `+(c?`they are shown under "${r}".`:"they are shown at the root."));for(const h of o)h.children=h.children.filter(g=>n.has(g.key));if(!c)return[...a,...o];let d=t;const f=[...a];return d||(d=Z(-1,`${W}orphans`),d.value=r,f.push(d)),d.children.push(...o),f}function F(a){let l=0;const r=(t,n)=>{for(const i of t)i.level=n,n>l&&(l=n),i.children.length&&r(i.children,n+1)};return r(a,0),l}function k(a,l){if(!a||typeof a!="object")return null;const r=a.path,t=a.parentKey,n=N(a.hasChildren)?i=>!!a.hasChildren(l.dataAt(i)):null;if(N(r))return{mode:"path",pathOf:i=>r(l.dataAt(i)),keyOf:l.keyOf,declaresChildren:n};if(t!=null){const i=N(t)?t:o=>o?.[t];return{mode:"parentKey",parentOf:o=>i(l.dataAt(o)),keyOf:l.keyOf,orphans:a.orphans||"root",declaresChildren:n}}return $("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function S(a,l){const r=l.mode==="path"?H(a,l):U(a,l),t=F(r.roots);return{...r,depth:t}}function b(a,l){const r=new Map,t=n=>{for(let i=0;i<n.length;i++){const o=n[i];if(o.physical>=0){const c=l?l(o.physical):!1,d=c&&o.children.length===0;r.set(o.physical,{level:o.level,posinset:i+1,setsize:n.length,hasChildren:o.children.length>0||c,lazy:d})}o.children.length&&t(o.children)}};return t(a),r}}),Se("packages/core/src/source/memory.js",function(e,V){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return x}});const _=V("packages/core/src/internal/util.js"),N=_.Lru,$=_.warnOnce,L=_.fail,W=_.isFunction,Z=_.defaultCompare,H=_.mergeRow,U=V("packages/core/src/source/rows.js"),z=U.createRowFactory,F=U.groupKey,k=U.groupPathElement,S=U.groupPrefixKeys,b=U.lazyRowView,l=V("packages/core/src/source/handles.js").createHandleProvider,r=V("packages/core/src/compute/incremental.js"),t=r.RunningTotal,n=r.isIncremental,o=V("packages/core/src/compute/handle.js").presenceReader,c=V("packages/core/src/source/filterwire.js"),d=c.querySignature,f=c.mapConditions,h=c.resolveRelativeCondition,g=V("packages/core/src/source/tree.js"),y=g.buildTree,p=g.resolveTree,m=g.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),v=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function u(I){const j=I&&typeof I=="object"?I.reason:null;return typeof j=="string"&&v.includes(j)}const s=Object.freeze([]);function O(I,j){if(!I)return null;const T=j==="grand"?I.grandTotal:I.groupTotal;return T??I.total}function E(I){return!!I&&!I.running}function A(I){if(I)return I.value&&W(I.value.compare)?I.value.compare:W(I.compare)?I.compare:void 0}function M(I){return!!I&&(typeof I=="object"||typeof I=="function")&&W(I.then)}const C=new Uint32Array(0),P=4096;function D(I,j){return new x(I,j)}function K(I,j){if(j==="regex")try{const T=new RegExp(I,"iu");return B=>T.test(B)}catch{return T=>T.includes(I)}if(j==="fuzzy"){const T=[...I].filter(B=>B!==" ");return T.length?B=>{let q=0;for(let X=0;X<B.length&&q<T.length;X++)B[X]===T[q]&&q++;return q===T.length}:()=>!0}if(j==="words"){const T=I.split(/\s+/).filter(Boolean);return T.length?B=>T.every(q=>B.includes(q)):()=>!0}return T=>T.includes(I)}class x{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#a;#s=new Map;#l=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#m=null;#p=x.#g();static#g(){return{slots:[],groupHeadings:s,unnumbered:s,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#v=new Map;#y=null;#b=new Map;#w=-1;#S=[];#j=new Map;#A=-1;#O=[];#C=null;#E=null;#T=null;#D=null;#R=null;#N=null;#M=null;#_=null;#U=Symbol("unset");#F=new Map;#Y=null;get#I(){return this.#p.slots}set#I(j){this.#p.slots=j}get#Z(){return this.#p.inlineLeaves}set#Z(j){this.#p.inlineLeaves=j}get#te(){return this.#p.groupHeadings}set#te(j){this.#p.groupHeadings=j}get#le(){return this.#p.unnumbered}set#le(j){this.#p.unnumbered=j}get#se(){return this.#p.pivot}set#se(j){this.#p.pivot=j}constructor(j,T){this.#t=j||{mode:"memory"},this.#e=T||{};const B=this.#e.config||{};this.#n=this.#t.rows||B.rows||[],this.#i=z(this.#e),this.#a=l(this.#e,()=>this.#n,()=>this.#r),this.#f=new N(Number(B.rowCacheSize)||P);for(const q of w)this.#s.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#W();const j=this.#ne();return j?j.length:this.#I.length}#ne(){const j=Number(this.#B("pageSize",0))||0;if(j<=0)return null;const T=this.#I.length,B=Math.max(1,Math.ceil(T/j)),X=Math.min(Math.max(0,Number(this.#B("page",0))||0),B-1)*j;return{offset:X,length:Math.max(0,Math.min(j,T-X))}}pageInfo(){this.#W();const j=Number(this.#B("pageSize",0))||0,T=this.#I.length;if(j<=0)return{page:0,pageSize:0,total:T,pageCount:1};const B=Math.max(1,Math.ceil(T/j));return{page:Math.min(Math.max(0,Number(this.#B("page",0))||0),B-1),pageSize:j,total:T,pageCount:B}}totalCount(){return this.#Ae().length}matchCount(){return this.#W(),this.#p.matchCount}at(j){this.#W();const T=this.#ne();if(T)return j<0||j>=T.length?void 0:this.#pt(T.offset+j,j);if(!(j<0||j>=this.#I.length))return this.#pt(j,j)}byKey(j){this.#W(),this.#m||this.#X();const T=this.#m.get(j);if(T!==void 0)return this.#Pe(T);for(let B=0;B<this.#I.length;B++){const q=this.#I[B];if(typeof q!="number"&&q&&q.key===j)return this.#pt(B)}}loaded(j){return j>=0&&j<this.count()}hint(j,T){}display(){return this.#W(),this.#Y||(this.#Y=this.#Et()),this.#Y}invalidateQuickText(){this.#F.clear(),this.invalidate("filter")}invalidate(j){const T=w.indexOf(j);T<0&&L(`unknown pipeline stage "${j}"; expected one of ${w.join(", ")}`);for(let B=T;B<w.length;B++){const q=this.#s.get(w[B]);q.key=null,q.computed=!1}this.#Y=null}apply(j){const T=[],B={added:[],updated:[],removed:[],rejected:T};if(!j)return B;let q=!1;const X=new Set;if(j.remove&&j.remove.length)for(const Q of j.remove){const te=this.#we(Q);if(te===void 0){T.push({operation:"remove",id:this.#G(Q),reason:"unknown-id"});continue}B.removed.push(this.#i.keyOf(this.#r?this.#ze(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#f.delete(te),this.#F.delete(te),q=!0}if(j.update&&j.update.length){const Q=this.#b.size||this.#nt()?this.#qe():null,te=this.#j.size?this.#yt():null,re=te&&te.length?this.#qe():null;for(const ie of j.update){const ae=this.#we(ie);if(ae===void 0){T.push({operation:"update",id:this.#K(ie),reason:"unknown-id"});continue}const ee=this.#r?this.#o&&this.#o.has(ae)?this.#o.get(ae):this.#ze(ae):this.#n[ae],J=H(ee,ie);for(const se of this.#Se(ee,J))X.add(se);if(this.#r||(this.#n[ae]=J),Q&&this.#ye(Q,ae,ee,J),re&&this.#P(te,re,ae,ee,J),this.#m){const se=this.#i.keyOf(ee,ae),le=this.#i.keyOf(J,ae);se!==le&&(this.#m.delete(se),this.#m.set(le,ae))}this.#f.delete(ae),this.#F.delete(ae),B.updated.push(this.#Pe(ae))}}if(j.add&&j.add.length&&this.#r){typeof j.at=="number"&&j.at<this.#mt()&&(this.#f.clear(),this.#F.clear()),this.#m=null;for(const Q of j.add){const te=this.#z(this.#K(Q));te!==void 0&&B.added.push(this.#Pe(te))}q=!0}else if(j.add&&j.add.length){const Q=typeof j.at=="number"?j.at:this.#n.length,te=this.#n.length;let re=j.add===this.#n?j.add.slice():j.add;if(this.#i.keyed){const ie=[];for(const ae of re){const ee=this.#K(ae);if(this.#we(ee)!==void 0){T.push({operation:"add",id:ee,reason:"duplicate-id"});continue}ie.push(ae)}ie.length!==re.length&&(re=ie)}if(!re.length)return B;if(Q>=te)for(let ie=0;ie<re.length;ie++)this.#n.push(re[ie]);else this.#n.splice(Q,0,...re),this.#f.clear(),this.#F.clear();for(let ie=0;ie<re.length;ie++)B.added.push(this.#Pe(Q>=te?te+ie:Q+ie));q=!0}return this.#u++,q&&(this.#m=null,this.#Be()),this.#a.invalidate(),this.#Y=null,q||this.#ve(X)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:B.added.length,updated:B.updated.length,removed:B.removed.length}),this.#o=null,B}groupHeadingsAt(j){this.#W();const T=this.#te;if(!T.length||!Number.isInteger(j)||j<0)return s;let B=0,q=T.length-1,X=-1;for(;B<=q;){const te=B+q>>1;T[te].at<=j?(X=te,B=te+1):q=te-1}if(X<0)return s;const Q=[];for(let te=T[X].row;te;te=te.parent)Q.push(te);return Q.reverse(),Q}unnumberedRowCount(j){this.#W();const T=this.#le;if(!T.length||!Number.isInteger(j)||j<0)return 0;let B=0,q=T.length-1,X=-1;for(;B<=q;){const Q=B+q>>1;T[Q].at<=j?(X=Q,B=Q+1):q=Q-1}return X+1}moveRow(j,T){if(this.#r)return $("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 B=this.#n;if(!Number.isInteger(j)||!Number.isInteger(T)||j<0||j>=B.length)return!1;const q=Math.max(0,Math.min(B.length-1,T));if(q===j)return!1;const[X]=B.splice(j,1);return B.splice(q,0,X),this.#u++,this.#c++,this.#m=null,this.#f.clear(),this.#F.clear(),this.#Be(),this.#a.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(j){this.#ge(),this.#u++,this.#c++,this.#m=null,this.#F.clear(),this.#f.clear(),this.#Be(),this.#a.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#ge(),this.#f.clear(),this.#F.clear(),this.#m=null,this.#I=[],this.#Z=null,this.#Y=null,this.#Be();for(const j of w)this.#s.set(j,{key:null,result:null,id:0,computed:!1})}#ge(){for(const{controller:j}of this.#v.values())try{j.abort()}catch{}this.#v.clear()}setRows(j){this.#n=j||[],this.#r=!1,this.#u++,this.#c++,this.#m=null,this.#F.clear(),this.#f.clear(),this.#Be(),this.#a.invalidate(),this.invalidate("filter")}notePriorRows(j){this.#o=j||null}releaseSource(){this.#r=!0,this.#n=[],this.#m=null,this.#f.clear(),this.#F.clear(),this.#a.invalidate()}data(){if(!this.#r)return this.#n;const j=this.#e.store;if(!j||!W(j.source))return this.#n;const T=j.physical||0,B=new Array(T);for(let q=0;q<T;q++)B[q]=j.live&&!j.live(q)?void 0:j.source(q);return B}#V(){const j=this.#B("detail",null);return!j||!W(j.isOpen)||j.inline===!1?null:j}#ee(){const j=(this.#e.config||{}).tree;return this.#U!==j&&(this.#U=j,this.#_=p(j,{dataAt:T=>this.#ze(T),keyOf:T=>this.#i.keyOf(this.#ze(T),T)})),this.#_}#x(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#x())return null;this.#W();const j=this.#p.grand;return j?this.#i.grandTotal(j,this.#ke(this.#p.grandLeaves)):null}pivot(){return this.#W(),this.#se}pivotMatrix(){this.#W();const j=this.#p.groupLeaves,T=(this.#e.compute||{}).pivotMatrix;if(!W(T))return null;const B=this.#B("groupBy",[]),q=this.#B("pivotBy",[]);if(!B.length&&!q.length)return null;const X=this.#qe().map(te=>({colId:te.id,handle:this.#a.handle(te.id),fn:O(te,"group")})).filter(te=>te.handle&&te.fn),Q=this.#e.config||{};return T({rowHandles:B.map(te=>this.#a.handle(te)).filter(Boolean),columnHandles:q.map(te=>this.#a.handle(te)).filter(Boolean),measures:X,leaves:j||new Uint32Array(0),opts:{locale:Q.locale,separator:(Q.pivot||{}).separator,maxColumns:(Q.pivot||{}).maxColumns}})}keysForLeaves(j){const T=[];if(!j)return T;for(let B=0;B<j.length;B++){const q=this.#Pe(j[B]);q&&q.key!=null&&T.push(String(q.key))}return T}leavesOf(j){this.#W();const T=this.#s.get("group"),B=T&&T.result;if(!B||!B.nodes)return[];const q=B.nodes.get(j);if(!q)return[];const X=[],Q=te=>{const re=te.row&&te.row.children;if(re&&re.length){for(const ie of re){const ae=B.nodes.get(ie.key);ae&&Q(ae)}return}if(te.leaves)for(let ie=0;ie<te.leaves.length;ie++)X.push(this.#Pe(te.leaves[ie]))};return Q(q),X}#G(j){return typeof j=="string"?j:this.#K(j)}#K(j){try{return this.#i.keyOf(j,-1)}catch{return"(unkeyed)"}}#we(j){if(typeof j=="string")return this.#z(j);if(this.#i.keyed){const B=this.#i.keyOf(j,-1),q=this.#z(B);if(q!==void 0)return q}if(this.#r)return;const T=this.#n.indexOf(j);return T>=0?T:void 0}#z(j){return this.#m||this.#X(),this.#m.get(j)}#X(){this.#m=new Map;const j=this.#mt(),T=this.#e.store,B=T&&W(T.live)?q=>T.live(q):null;for(let q=0;q<j;q++){if(B&&!B(q))continue;const X=this.#ze(q);X!==void 0&&this.#m.set(this.#i.keyOf(X,q),q)}}#Se(j,T){const B=[];for(const q of this.#be())this.#Ne(q)&&this.#Oe(q,j,T,new Set)&&B.push(q);return B}#Oe(j,T,B,q){if(q.has(j))return!1;q.add(j);const X=this.#Ne(j);if(!X)return!1;const Q=X.value&&X.value.deps;return Array.isArray(Q)&&Q.length?Q.some(te=>this.#Oe(String(te),T,B,q)):W(X.getValue)?!Object.is(X.getValue(T),X.getValue(B)):!1}#be(){const j=new Set;for(const B of this.#B("sort",[]))j.add(B.col);for(const B of this.#B("groupBy",[]))j.add(B);const T=B=>{if(B){if(Array.isArray(B.conditions)){B.conditions.forEach(T);return}B.col&&j.add(B.col)}};return T(this.#B("filters",null)),[...j]}#ve(j){if(!j.size)return!1;if(this.#B("quick",""))return!0;for(const T of this.#be())if(j.has(T))return!0;return!1}#W(){if(!this.#l){this.#l=!0;try{this.#Re()}finally{this.#l=!1}}}pipelineRunning(){return this.#l}#Re(){const j=this.#k("filter",()=>this.#Te(),()=>this.#me()),T=this.#re(j),B=this.#k("group",()=>this.#Le(),()=>this.#q(T)),q=this.#k("total",()=>this.#Fe(),()=>this.#Je(B));this.#k("pivot",()=>this.#De(),()=>this.#it(B)),this.#k("flatten",()=>this.#Ve(),()=>this.#ot(B)),this.#ae(B,q)}#re(j){const T=this.#s.get("sort"),B=this.#je();if(T.computed&&T.key===B&&!this.#v.has("sort"))return T.result;const q=this.#v.get("sort");return q&&q.key===B?T.result:T.result&&this.#H(j)?(this.#$(j,B),T.result):this.#k("sort",()=>B,()=>this.#Ge(j))}#fe(){if(this.#y===null){const j=this.#e.pipelineWorker,T=W(j)?j():null;this.#y=T||!1}return this.#y||null}#ie(){const j=this.#B("sort",[]);if(!Array.isArray(j)||!j.length)return null;const T=(this.#e.config||{}).locale,B=[],q=[];for(const X of j){const Q=this.#Ne(X.col);if(Q&&Q.running)continue;if(Q&&Q.value&&W(Q.value.compare))return null;const te=this.#a.handle(X.col);if(!te)return null;B.push({col:X.col,descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,locale:T}),q.push(te)}return B.length?{entries:B,handles:q,locale:T}:null}#H(j){const T=this.#fe();if(!T)return!1;const B=Number(T.threshold);return Number.isFinite(B)&&j.length<B?!1:!!this.#ie()}#$(j,T){const B=this.#fe(),q=B&&this.#ie();if(!q){this.#k("sort",()=>T,()=>this.#Ge(j));return}const X=new AbortController;this.#v.set("sort",{key:T,controller:X});const Q=q.entries.length===1?B.sortColumn(q.handles[0],j,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:X.signal,key:"sort"}):B.sortMulti(q.handles,q.entries.map((te,re)=>({...te,handle:q.handles[re]})),j,{signal:X.signal,key:"sort"});if(!M(Q)){this.#v.delete("sort"),this.#k("sort",()=>T,()=>Q);return}Q.then(te=>this.#oe(T,te),te=>this.#ue("sort",T,te))}#oe(j,T){const B=this.#v.get("sort");if(!(!B||B.key!==j)){if(this.#je()!==j){this.#v.delete("sort");return}this.#v.delete("sort"),this.#k("sort",()=>j,()=>T),this.#Y=null,this.#W(),this.#Qe("model:changed",{reason:v[0]})}}#ue(j,T,B){const q=this.#v.get(j);if(!(!q||q.key!==T)&&(this.#v.delete(j),!(B&&B.name==="AbortError")&&j==="sort"&&this.#je()===T)){const X=this.#k("filter",()=>this.#Te(),()=>this.#me());this.#k("sort",()=>T,()=>this.#Ge(X)),this.#Y=null,this.#W(),$("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",B),this.#Qe("model:changed",{reason:v[1]})}}#ae(j,T){const B=j&&j.leaves?j.leaves.length:this.#p.slots.length;this.#p.matchCount=B,this.#p.grand=T&&T.grand||null,this.#p.grandLeaves=j&&j.leaves?j.leaves.length:0,this.#p.groupLeaves=j&&j.leaves?j.leaves:null}#k(j,T,B){const q=this.#s.get(j),X=T();return q.computed&&q.key===X||(q.result=B(),q.key=X,q.computed=!0,q.id++,j==="flatten"&&(this.#Y=null)),q.result}#ce(j){return this.#s.get(j).id}#Te(){const j=(this.#e.config||{}).hostFilter,T=j&&W(j.active)&&j.active()?1:0,B=this.#B("where",null),q=B?B.version:0,X=this.#at("filter.sig",`${this.#Ye()}`,()=>d({filters:this.#B("filters",null),quick:this.#B("quick",""),quickMode:this.#B("quickMode","contains")}));return`${this.#c}|${X}|${T}|${q}`}#je(){return`${this.#ce("filter")}|${JSON.stringify(this.#B("sort",[]))}`}#Le(){return`${this.#ce("sort")}|${JSON.stringify(this.#B("groupBy",[]))}`}#Fe(){const j=this.#de()?"f":"a",T=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#ce("group")}|${JSON.stringify(this.#B("totals",[]))}|${j}${T}|${this.#u}`}#De(){return`${this.#ce("group")}|${JSON.stringify(this.#B("pivotBy",[]))}`}#Ve(){const T=this.#Ze()||!this.#x()?this.#ce("total"):"x",B=`${this.#Ye()}`,q=this.#at("flatten.keys",B,()=>{const Q=this.#B("expanded",null);return Q?[...Q].sort().join(""):"*"}),X=this.#at("flatten.detail",B,()=>{const Q=this.#B("detail",null);return Q&&W(Q.signature)?Q.signature():""});return`${T}|${this.#ce("pivot")}|${q}|${X}`}#Ze(){const j=this.#B("groupBy",[]);return Array.isArray(j)&&j.length>0}stageState(){const j=[];for(const[T,B]of this.#s){const q=B.result;j.push({stage:T,materialised:!!B.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:B.id})}return j}facetIndices(j){return this.#me(j||null)}facetRows(j){const T=this.facetIndices(j),B=[];for(let q=0;q<T.length;q++){const X=this.#Pe(T[q]);X&&B.push(X)}return B}invalidateRows(){this.#f.clear(),this.#F.clear(),this.#Y=null}invalidateHandles(){this.#a.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#Ae()}filteredIndices(){const j=this.#s.get("filter");if(j&&j.computed&&j.key===this.#Te())return j.result||this.#Ae();this.#W();const T=this.#s.get("filter");return(T&&T.computed?T.result:null)||this.#Ae()}unfilteredRows(){const j=this.#Ae(),T=[];for(let B=0;B<j.length;B++){const q=this.#Pe(j[B]);q&&T.push(q)}return T}#me(j=null){const T=this.#Ae(),B=this.#B("filters",null),q=j?this.#Xe("pruneColumn")(B,j):B,X=this.#vt(q),Q=String(this.#B("quick","")||"").trim().toLowerCase(),te=Q?K(Q,String(this.#B("quickMode","contains")||"contains")):null,re=(this.#e.config||{}).hostFilter,ie=!!(re&&W(re.active)&&re.active()),ae=this.#B("where",null),ee=!!(ae&&ae.active);if(!X&&!Q&&!ie&&!ee)return T;let J=null;X&&(J=this.#Xe("evaluateFilters")(X,{handle:he=>this.#a.handle(he),count:this.#mt(),pool:this.#e.pool,locale:(this.#e.config||{}).locale}));const se=new Uint32Array(T.length);let le=0;for(let oe=0;oe<T.length;oe++){const he=T[oe];if(!(J&&!J[he])&&!(te&&!this.#gt(he,te))){if(ie||ee){const fe=this.#Pe(he);if(ie&&!re.passes(fe)||ee&&!ae.passes(fe.data,fe.key))continue}se[le++]=he}}if(J){const oe=(this.#e.compute||{}).releaseMask;W(oe)&&oe({pool:this.#e.pool},J)}return se.subarray(0,le)}handleFor(j){return this.#a.handle(j)}#Ge(j){const T=this.#B("sort",[]).filter(X=>{const Q=this.#Ne(X.col);return!Q||!Q.running?!0:($(`source.sort.running.${X.col}`,`sort ignores "${X.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!T.length)return j;const B=(this.#e.config||{}).locale;if(T.length===1){const X=T[0],Q=this.#a.handle(X.col);if(!Q)return $(`source.sort.${X.col}`,`sort ignores unknown column "${X.col}".`),j;const te=this.#Ne(X.col);return this.#Xe("sortColumn")(Q,j,{descending:X.dir==="desc",nullsFirst:X.nullsFirst,locale:B,compare:A(te)})}const q=[];for(const X of T){const Q=this.#a.handle(X.col);if(!Q){$(`source.sort.${X.col}`,`sort ignores unknown column "${X.col}".`);continue}q.push({handle:Q,descending:X.dir==="desc",nullsFirst:X.nullsFirst,locale:B,compare:A(this.#Ne(X.col))})}return q.length?this.#Xe("sortMulti")(q.map(X=>X.handle),q,j):j}#q(j){const T=this.#B("groupBy",[]),B=this.#ee();if(B&&!T.length){const oe=y(j,B);return this.#N=m(oe.roots,B.declaresChildren),{roots:null,leaves:j,nodes:new Map,tree:oe}}if(this.#N=null,B&&T.length&&$("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!T.length)return{roots:null,leaves:j,nodes:new Map};const q=(this.#e.config||{}).timeZone,X=[],Q=[];let te=!1;for(const oe of T){const he=this.#a.handle(oe);if(!he){$(`source.group.${oe}`,`grouping ignores unknown column "${oe}".`);continue}X.push(he);const fe=this.#Ne(oe),ve=fe&&fe.dataType;if(ve&&W(ve.groupProjector)){const be=fe.typeOptions&&fe.typeOptions.timeZone||fe.timeZone||q||void 0,Re=ve.groupProjector(fe,be);Q.push(Re||null),Re&&(te=!0)}else Q.push(null)}if(!X.length)return{roots:null,leaves:j,nodes:new Map};const{keys:re,buckets:ie}=this.#Xe("groupByColumns")(X,j,{locale:(this.#e.config||{}).locale,project:te?Q:void 0}),ae=this.#B("pivotBy",[]).length>0,ee=[],J=new Map;for(let oe=0;oe<ie.length;oe++){const he=re[oe];let fe=null;const ve=[];for(let be=0;be<he.length;be++){ve.push(k(he[be]));const Re=F(ve),He=be===he.length-1;let Oe=J.get(Re);if(!Oe){const Ie=this.#i.group({path:[...ve],column:T[be],value:he[be],level:be,parent:fe,expanded:ae&&He?!1:this.#Ie(Re,{key:Re,column:T[be],value:he[be],level:be,path:[...ve]}),hasChildren:!(ae&&He)});Oe={row:Ie,leaves:null},J.set(Re,Oe),fe?fe.children.push(Ie):ee.push(Ie)}Oe.row.leafCount+=ie[oe].length,be===he.length-1&&(Oe.leaves=ie[oe]),fe=Oe.row}}const se=this.#B("sort",[])||[],le=(oe,he)=>{if(!oe||oe.length<2){if(oe)for(const Re of oe)le(Re.children,he+1);return}const fe=T[he],ve=se.find(Re=>Re.col===fe),be=ve&&ve.dir==="desc"?-1:1;oe.sort((Re,He)=>be*Z(Re.groupValue,He.groupValue));for(const Re of oe)le(Re.children,he+1)};return le(ee,0),{roots:ee,leaves:j,nodes:J,keys:re,buckets:ie}}#$e(j,T){const B=new Map,q=new Map,X=Q=>{const te=Q.physical>=0?[Q.physical]:[];for(const re of Q.children)te.push(...X(re));if(Q.children.length){const re=this.#Ue(T,Uint32Array.from(te),null);Q.physical>=0?B.set(Q.physical,re):q.set(Q.key,re)}return te};for(const Q of j.roots)X(Q);return{byPhysical:B,byKey:q}}#Je(j){const T=this.#qe();if(!T.length)return this.#E=null,this.#T=null,{grand:null};const B={id:this.#ce("group"),columns:T.map(se=>se.id).join("")},q=this.#E&&this.#E.id===B.id&&this.#E.columns===B.columns,X=this.#nt()&&q?this.#C:null,Q=X?T.filter(se=>X.has(se.id)):T,te=q?this.#T:null,re=this.#de()?null:this.#ht(),ie=this.#et(T),ae=se=>{const le=j.nodes.get(se.key);let oe=le&&le.leaves?le.leaves:null;if(se.children&&se.children.length){const ve=se.children.map(ae);let be=0;for(const Oe of ve)be+=Oe.length;const Re=new Uint32Array(be);let He=0;for(const Oe of ve)Re.set(Oe,He),He+=Oe.length;oe=Re}oe=oe||new Uint32Array(0);const he=re?re.get(se.key)||C:oe,fe=this.#he(se,X?Q:T,he,ie);return se.totals=X?{...se.totals,...fe}:fe,oe};if(j.roots&&Q.length)for(const se of j.roots)ae(se);if(this.#M=j.tree?this.#$e(j.tree,T):null,this.#E=B,this.#C=this.#nt()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#T=null,{grand:null};const J=re?this.#We():j.leaves;return this.#T=this.#Ke(T,J,X,te),{grand:this.#T}}#Ke(j,T,B,q){const X={},Q=this.#ce("group");Q!==this.#w&&(this.#rt(),this.#w=Q);const te=this.#S;this.#S=[];for(const re of j){if(!E(re))continue;const ie=this.#a.handle(re.id);if(!ie)continue;const ae=O(re,"grand");if(!n(ae,ie)){if(B&&!B.has(re.id)&&q&&re.id in q){X[re.id]=q[re.id];continue}X[re.id]=this.#Ue([re],T,null,"grand")[re.id];continue}let ee=this.#b.get(re.id);if((!ee||ee.fn!==ae)&&(ee=new t(ae),this.#b.set(re.id,ee)),ee.valid){let J=!0;for(const se of te)if(se.colId===re.id&&!ee.update(se.before,se.after)){J=!1;break}if(J){X[re.id]=ee.value();continue}ee.invalidate()}ee.seedColumn(ie.values,o(ie),T),X[re.id]=ee.valid?ee.value():this.#Ue([re],T,null,"grand")[re.id]}return X}#et(j){const T=this.#ce("group");T!==this.#A&&(this.#j.clear(),this.#A=T);const B=new Map;for(const X of j){if(!E(X))continue;const Q=this.#a.handle(X.id),te=O(X,"group");n(te,Q)&&B.set(X.id,{fn:te})}if(!B.size)return this.#O.length=0,B;const q=this.#O;this.#O=[];for(const X of q){const{beforeKeys:Q,afterKeys:te,colDeltas:re}=X,ie=Q.length?new Set(Q):null,ae=te.length?new Set(te):null;for(const{colId:ee,before:J,after:se}of re)if(B.has(ee)){for(const le of Q)ae&&ae.has(le)||this.#Me(le,ee,J,null);for(const le of te)ie&&ie.has(le)||this.#Me(le,ee,null,se);for(const le of Q)ae&&!ae.has(le)||this.#Me(le,ee,J,se)}}return B}#Me(j,T,B,q){const X=this.#j.get(j),Q=X&&X.get(T);!Q||!Q.valid||Q.update(B,q)||Q.invalidate()}#he(j,T,B,q){if(!q||!q.size)return this.#Ue(T,B,j);const X={};let Q=null,te=this.#j.get(j.key);for(const re of T){const ie=q.get(re.id);if(!ie){(Q||(Q=[])).push(re);continue}const ae=this.#a.handle(re.id);if(!ae)continue;te||(te=new Map,this.#j.set(j.key,te));let ee=te.get(re.id);if((!ee||ee.fn!==ie.fn)&&(ee=new t(ie.fn),te.set(re.id,ee)),ee.valid||ee.seedColumn(ae.values,o(ae),B),ee.valid){X[re.id]=ee.value();continue}(Q||(Q=[])).push(re)}return Q&&Object.assign(X,this.#Ue(Q,B,j)),X}#ye(j,T,B,q){const X=!this.#de()||this.#xe(T);for(const Q of j){const te=Q.getValue;if(!W(te))continue;const re=te(B),ie=te(q);Object.is(re,ie)||(this.#C&&this.#C.add(Q.id),X&&this.#b.has(Q.id)&&this.#S.push({colId:Q.id,before:re,after:ie}))}}#yt(){const j=this.#B("groupBy",[]),T=[];for(const B of j){const q=this.#Ne(B);q&&T.push(q)}return T}#ft(j,T){const B=new Array(j.length);for(let q=0;q<j.length;q++){const X=j[q].getValue;B[q]=k(W(X)?X(T):void 0)}return B}#P(j,T,B,q,X){if(this.#de()&&!this.#xe(B))return;const Q=S(this.#ft(j,q)),te=S(this.#ft(j,X)),re=Q.length!==te.length||Q.some((ae,ee)=>ae!==te[ee]),ie=[];for(const ae of T){const ee=ae.getValue;if(!W(ee))continue;const J=ee(q),se=ee(X);!re&&Object.is(J,se)||ie.push({colId:ae.id,before:J,after:se})}!ie.length&&!re||this.#O.push({beforeKeys:Q,afterKeys:te,colDeltas:ie})}#xe(j){const T=this.#s.get("filter"),B=T&&T.computed?T.result:null;if(!B)return!0;let q=0,X=B.length-1;for(;q<=X;){const Q=q+X>>1,te=B[Q];if(te===j)return!0;te<j?q=Q+1:X=Q-1}return!1}#de(){return(this.#e.config||{}).totalFilteredOnly!==!1}#ke(j){return this.#de()?j:this.#We().length}#We(){return(!this.#D||this.#D.version!==this.#c)&&(this.#D={version:this.#c,indices:this.#Ae()}),this.#D.indices}#ht(){const j=this.#B("groupBy",[]),T=`${this.#c}|${JSON.stringify(j)}`;if(this.#R&&this.#R.key===T)return this.#R.map;const B=new Map,q=[];for(const X of j){const Q=this.#a.handle(X);Q&&q.push(Q)}if(q.length){const X=this.#We(),{keys:Q,buckets:te}=this.#Xe("groupByColumns")(q,X,{locale:(this.#e.config||{}).locale}),re=new Map;for(let ie=0;ie<te.length;ie++){const ae=Q[ie],ee=[];for(let J=0;J<ae.length;J++){ee.push(k(ae[J]));const se=F(ee);let le=re.get(se);le||(le=[],re.set(se,le));for(let oe=0;oe<te[ie].length;oe++)le.push(te[ie][oe])}}for(const[ie,ae]of re)B.set(ie,Uint32Array.from(ae))}return this.#R={key:T,map:B},B}#nt(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#Be(){this.#rt(),this.#tt(),this.#C=null,this.#E=null,this.#T=null}#rt(){this.#b.clear(),this.#S.length=0,this.#w=-1}#tt(){this.#j.clear(),this.#O.length=0,this.#A=-1}#it(j){const T=this.#B("pivotBy",[]);if(!T.length)return this.#se=null,null;const B=(this.#e.compute||{}).pivot;if(!W(B))return $("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#se=null,null;const q=T.map(Q=>this.#a.handle(Q)).filter(Boolean),X=this.#qe();return this.#se=B(q,j.leaves,{groups:j.keys&&j.buckets?{keys:j.keys,buckets:j.buckets}:null,totals:X.map(Q=>Q.id),handle:Q=>this.#a.handle(Q),totalOf:Q=>O(X.find(te=>te.id===Q),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#se}#ot(j){const T=this.#s.get("total").result,B=!!(this.#e.config||{}).groupFooter,q=this.#V();if(j.tree)return this.#wt(j,T,q);if(!j.roots&&!q){if(T&&T.grand&&!this.#x()){const ae=this.#i.grandTotal(T.grand,this.#ke(j.leaves.length));if(this.#Z===j.leaves&&Array.isArray(this.#I))this.#I[this.#I.length-1]=ae;else{const ee=Array.from(j.leaves);ee.push(ae),this.#I=ee,this.#Z=j.leaves}this.#le=[{at:this.#I.length-1}]}else this.#Z=null,this.#I=j.leaves,this.#le=s;return this.#te=s,this.#I}const X=[],Q=[],te=[],re=ae=>{if(X.push(ae),!q)return;const ee=this.#Pe(ae);!ee||!q.isOpen(ee.key)||(ee.master=!0,ee.expanded=!0,te.push({at:X.length}),X.push(this.#i.detail(ee,q.heightOf(ee))))};if(!j.roots){for(let ae=0;ae<j.leaves.length;ae++)re(j.leaves[ae]);return T&&T.grand&&!this.#x()&&(te.push({at:X.length}),X.push(this.#i.grandTotal(T.grand,this.#ke(j.leaves.length)))),this.#Z=null,this.#te=s,this.#le=te.length?te:s,this.#I=X,X}const ie=(ae,ee,J)=>{if(ae.expanded=ae.hasChildren===!1?!1:this.#Ie(ae.key,{key:ae.key,column:ae.groupColumn,value:ae.groupValue,level:ae.level,path:ae.groupPath}),ae.posinset=ee+1,ae.setsize=J,Q.push({at:X.length,row:ae}),te.push({at:X.length}),X.push(ae),!!ae.expanded){if(ae.children&&ae.children.length)for(let se=0;se<ae.children.length;se++)ie(ae.children[se],se,ae.children.length);else{const se=j.nodes.get(ae.key),le=se&&se.leaves?se.leaves:null;if(le)for(let oe=0;oe<le.length;oe++)re(le[oe])}B&&ae.totals&&(te.push({at:X.length}),X.push(this.#i.footer(ae)))}};for(let ae=0;ae<j.roots.length;ae++)ie(j.roots[ae],ae,j.roots.length);return T&&T.grand&&!this.#x()&&(te.push({at:X.length}),X.push(this.#i.grandTotal(T.grand,this.#ke(j.leaves.length)))),this.#te=Q,this.#le=te,this.#I=X,X}#Ae(){const j=this.#e.store;if(j&&W(j.liveIndices))return j.liveIndices();const T=new Uint32Array(this.#n.length);let B=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(T[B++]=q);return T.subarray(0,B)}#mt(){const j=this.#e.store;return j&&typeof j.physical=="number"?j.physical:this.#n.length}#ze(j){const T=this.#e.store;return T&&W(T.source)?T.source(j):this.#n[j]}#pt(j,T=j){const B=this.#I[j];if(typeof B!="number")return B.index=T,B;const q=this.#Pe(B);return q.index=T,q}#Pe(j){let T=this.#f.get(j);T||(T=this.#i.leaf(this.#ze(j),j),this.#f.set(j,T));const B=this.#N?this.#N.get(j):null;if(B){T.level=B.level,T.posinset=B.posinset,T.setsize=B.setsize,T.hasChildren=B.hasChildren,T.expanded=B.hasChildren&&!B.lazy&&this.#Ie(T.key);const q=this.#M?this.#M.byPhysical.get(j):void 0;q?T.totals=q:T.totals&&(T.totals=null)}else T.hasChildren&&(T.level=0,T.hasChildren=!1,T.expanded=!1,T.posinset=void 0,T.setsize=void 0);return T}#wt(j,T,B){const q=[],X=[],Q=re=>{if(re.leafCount!==void 0)return re.leafCount;let ie=re.physical>=0?1:0;for(const ae of re.children)ie+=Q(ae);return re.leafCount=ie,ie},te=re=>{const ie=this.#Ie(re.key);if(re.physical>=0){if(q.push(re.physical),B&&B.isOpen(this.#Pe(re.physical).key)){const ae=this.#Pe(re.physical);X.push({at:q.length}),q.push(this.#i.detail(ae,B.heightOf(ae)))}}else q.push(this.#i.group({path:[re.key],column:null,value:re.value,level:re.level,parent:null,expanded:ie,hasChildren:re.children.length>0,leafCount:Q(re),totals:this.#M?this.#M.byKey.get(re.key):void 0}));if(ie)for(const ae of re.children)te(ae)};for(const re of j.tree.roots)te(re);return T&&T.grand&&!this.#x()&&(X.push({at:q.length}),q.push(this.#i.grandTotal(T.grand,this.#ke(j.leaves.length)))),this.#Z=null,this.#te=s,this.#le=X.length?X:s,this.#I=q,q}#Et(){return b(()=>this.count(),j=>this.at(j))}#gt(j,T){let B=this.#F.get(j);if(B===void 0){const q=this.#ze(j),X=this.#kt(),Q=[],te=this.#e.columnHidden;for(const re of X){if(re.quickFilter===!1||W(te)&&te(re.id))continue;const ie=re.value&&W(re.value.quickFilterText)?re.value.quickFilterText({value:void 0,data:q,row:null,column:re,colId:re.id,grid:null,context:this.#B("context",null)}):null,ae=ie??(W(re.formatValue)?re.formatValue(W(re.getValue)?re.getValue(q):void 0):"");ae!=null&&ae!==""&&Q.push(String(ae))}B=Q.join(" ").toLowerCase(),this.#F.set(j,B)}return T(B)}#qe(){const j=this.#B("totals",[]),T=j&&j.length?new Set(j):null;return this.#kt().filter(B=>T?T.has(B.id):!!(B.total||B.groupTotal||B.grandTotal))}#Ue(j,T,B,q="group"){const X={},Q=(this.#e.compute||{}).total;for(const te of j){if(!E(te))continue;const re=this.#a.handle(te.id);if(!re)continue;const ie=O(te,q);if(ie)if(W(ie)){const ae=new Array(T.length);for(let ee=0;ee<T.length;ee++)ae[ee]=re.get(T[ee]);X[te.id]=ie(ae,{row:B,column:te,grid:this.#e.grid||null,context:this.#B("context",null),valueAt:(ee,J)=>{const se=this.#a.handle(ee);return se&&J>=0&&J<T.length?se.get(T[J]):null}})}else W(Q)&&(X[te.id]=Q(re,T,ie))}return X}#vt(j){if(!j)return j;const T=this.#e.config||{},B={tz:T.timeZone,weekStartsOn:T.weekStartsOn};return f(j,q=>{const X=h(q,B);if(X&&X.type)return X;const Q=this.#Ne(X&&X.col),te=Q&&(Q.dataType?.base||Q.type);return te?{...X,type:te}:X})}#Ie(j,T){const B=this.#B("expanded",null);return B?W(B.has)?B.has(j,T):Array.prototype.includes.call(B,j):!0}#B(j,T){if(j==="context"||!W(this.#e.stateVersion))return this.#st(j,T);const B=this.#Mt(j),q=this.#d.get(j);if(q&&q.version===B)return q.value;const X=this.#st(j,T);return this.#d.set(j,{version:B,value:X}),X}#st(j,T){const B=this.#e.state;if(B&&W(B[j])){const q=B[j]();return q??T}return T}#Ye(){const j=this.#e.stateVersion;return W(j)?j():0}#Tt(){const j=this.#e.columnsVersion,T=this.#e.permissionsVersion;return`${W(j)?j():0}|${W(T)?T():0}`}#Mt(j){return j==="totals"?this.#Tt():`${this.#Ye()}`}#at(j,T,B){if(!W(this.#e.stateVersion))return B();const q=this.#h.get(j);if(q&&q.version===T)return q.key;const X=B();return this.#h.set(j,{version:T,key:X}),X}#Xe(j){const T=(this.#e.compute||{})[j];return W(T)||L(`ctx.compute.${j} is required by the memory source pipeline`),T}#kt(){const j=this.#e.columns;return j&&W(j.all)?j.all():[]}#Ne(j){const T=this.#e.columns;return T&&W(T.get)?T.get(j):void 0}#Qe(j,T){const B=this.#e.emit;W(B)&&B(j,T)}}}),Se("packages/core/src/source/abort.js",function(e,V){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class _ extends Error{constructor(H,U="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${U}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class N{#e;constructor(H,U,z,F){this.#e=H,this.key=U,this.controller=z,this.signal=z.signal,this.seq=F}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new _(this.key,H)),this.#e.settle(this)}}class ${#e=new Map;#t=0;begin(H="",U="superseded"){const z=this.#e.get(H);z&&!z.signal.aborted&&z.controller.abort(new _(H,U));const F=new N(this,H,new AbortController,++this.#t);return this.#e.set(H,F),F}tokenFor(H){return this.#e.get(H)}pending(H=""){const U=this.#e.get(H);return!!U&&!U.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",U="superseded"){const z=this.#e.get(H);z&&z.abort(U)}abortAll(H="superseded"){for(const U of[...this.#e.values()])U.abort(H);this.#e.clear()}}function L(){return new $}function W(Z){if(!Z||typeof Z!="object")return!1;const H=Z;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),Se("packages/core/src/source/blockcache.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return L}});const _=100,N=32;class ${constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class L{#e=new Map;#t;#n;#r=0;#o=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||_)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||N))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const H=this.#e.get(Z);return!!H&&H.state==="pending"}loaded(Z){const H=this.#e.get(Z);return!!H&&H.state==="loaded"}begin(Z,H){let U=this.#e.get(Z);return U||(U=new $(Z)),U.state="pending",U.token=H,U.error=null,this.#i(Z,U),U}fill(Z,H){const U=this.#e.get(Z)||new $(Z);U.rows=H,U.state="loaded",U.token=null,this.#i(Z,U)}failed(Z,H){const U=this.#e.get(Z)||new $(Z);U.state="error",U.error=H,U.token=null,this.#i(Z,U)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const H=this.blockOf(Z),U=this.#e.get(H);if(!(!U||U.state!=="loaded"||!U.rows))return this.#i(H,U),U.rows[Z-H*this.#t]}rowLoaded(Z){const H=this.blockOf(Z),U=this.#e.get(H);return!!U&&U.state==="loaded"&&!!U.rows&&Z-H*this.#t<U.rows.length}loadedExtent(){let Z=0;for(const H of this.#e.values()){if(H.state!=="loaded"||!H.rows)continue;const U=H.id*this.#t+H.rows.length;U>Z&&(Z=U)}return Z}fillOf(Z){const H=this.#e.get(Z);return H&&H.state==="loaded"&&H.rows?H.rows.length:null}protect(Z,H){this.#r=this.blockOf(Math.max(0,Z)),this.#o=this.blockOf(Math.max(0,H))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[H,U]of this.#e){if(this.#e.size-Z.length<=this.#n)break;H>=this.#r&&H<=this.#o||U.state!=="pending"&&Z.push(H)}for(const H of Z)this.#e.delete(H);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,H){this.#e.delete(Z),this.#e.set(Z,H)}}}),Se("packages/core/src/source/paged.js",function(e,V){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return c}});const _=V("packages/core/src/internal/util.js"),N=_.Lru,$=_.isFunction,L=_.warnOnce,W=_.settleDebounce,Z=V("packages/core/src/source/abort.js"),H=Z.createAbortScope,U=Z.isAbortError,z=V("packages/core/src/source/blockcache.js"),F=z.BlockCache,k=z.DEFAULT_PAGE_SIZE,S=z.DEFAULT_MAX_CACHED_PAGES,a=V("packages/core/src/source/rows.js").createRowFactory,l=V("packages/core/src/source/filterwire.js"),r=l.wireFilters,t=l.querySignature,n=l.warnHostFilterNotApplied,i=120;function o(d,f){return new c(d,f)}class c{mode="paged";#e;#t;#n;#r=H();#o;#i;#a=new Map;#s=null;#l=!1;#u=0;#c="";#d={start:0,end:0};#h;#f=!1;constructor(f,h){this.#e=f||{mode:"paged"},this.#t=h||{},this.#n=new F({pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||S}),this.#o=a(this.#t),this.#i=new N(this.#n.pageSize*4),this.#h=W((g,y)=>this.#m(g,y),i),this.#c=this.#b(),$(this.#e.fetch)||L("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){if(this.#v(),this.#s!==null)return this.#s;const f=Math.max(this.#u,this.#n.loadedExtent());return this.#l?f:f+this.#n.pageSize}at(f){if(this.#v(),f<0||f>=this.count())return;const h=this.#i.get(f);if(h&&(h.data!==null||!this.#n.rowLoaded(f)))return h;const g=this.#n.rowAt(f);if(g===void 0){const p=this.#o.skeleton(f);return this.#i.set(f,p),p}const y=this.#o.leaf(g,f);return y.index=f,this.#i.set(f,y),this.#a.set(y.key,f),y}byKey(f){const h=this.#a.get(f);return h===void 0?void 0:this.at(h)}loaded(f){return this.#n.rowLoaded(f)}hint(f,h){if(this.#f)return;const g=this.#v(),y=Math.max(0,Math.floor(f)),p=Math.max(y,Math.floor(h));this.#d={start:y,end:p},this.#n.protect(y,p);for(const m of this.#n.evict())this.#g(m);this.#h(y,p),g&&this.#h.flush()}#m(f,h){if(this.#f)return;this.#n.protect(f,h);const g=this.#n.blockOf(f),y=this.#n.blockOf(h);for(let p=g;p<=y&&!(this.#s!==null&&p*this.#n.pageSize>=this.#s);p++)this.#n.has(p)||this.#p(p)}apply(f){const h={added:[],updated:[],removed:[]};if(!f)return h;if(f.update)for(const g of f.update){const y=this.#o.keyOf(g,-1),p=this.#a.get(y);if(p===void 0)continue;const m=this.#o.leaf(g,p);m.index=p,this.#i.set(p,m),h.updated.push(m)}return(f.add&&f.add.length||f.remove&&f.remove.length)&&this.reload(),h}reload(f){this.#y("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#f=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#a.clear()}exact(){return this.#s!==null||this.#l}pending(){return this.#r.size}async#p(f){if(!$(this.#e.fetch))return;const h=this.#r.begin(`block:${f}`);this.#n.begin(f,h);const{start:g,end:y}=this.#n.rangeOf(f),p=this.#c;try{const m=await this.#e.fetch({range:{start:g,end:y},sort:this.#S("sort",[]),filters:r(this.#S("filters",null),this.#w()),quick:this.#S("quick","")||void 0,context:this.#S("context",null),signal:h.signal});if(!h.current||p!==this.#c||this.#f)return;h.settle();const w=m&&m.rows||[];this.#n.fill(f,w);for(let u=0;u<w.length;u++)this.#i.delete(g+u);const v=m&&typeof m.total=="number"?m.total:m&&typeof m.count=="number"?m.count:null;v!==null?(this.#s=v,this.#l=!0):w.length<this.#n.pageSize?(this.#l=!0,this.#s=g+w.length):this.#u=Math.max(this.#u,g+w.length),this.#j("model:changed",{reason:"page",block:f,from:g,to:g+w.length})}catch(m){if(h.settle(),U(m))return;this.#n.failed(f,m),this.#j("source:error",{error:m,block:f,range:{start:g,end:y}})}}#g(f){const{start:h,end:g}=this.#n.rangeOf(f);for(let y=h;y<g;y++){const p=this.#i.peek(y);p&&this.#a.delete(p.key),this.#i.delete(y)}}#v(){const f=this.#b();return f===this.#c?!1:(this.#c=f,this.#y("query"),!0)}#y(f){this.#r.abortAll(f),this.#n.clear(),this.#i.clear(),this.#a.clear(),this.#s=null,this.#l=!1,this.#u=0,this.#j("model:changed",{reason:f})}#b(){return t({filters:this.#S("filters",null),sort:this.#S("sort",[]),quick:this.#S("quick",""),context:this.#S("context",null)})}#w(){const f=this.#t.config||{};return{tz:f.timeZone,weekStartsOn:f.weekStartsOn}}#S(f,h){const g=this.#t.state;if(g&&$(g[f])){const y=g[f]();return y??h}return h}#j(f,h){const g=this.#t.emit;$(g)&&g(f,h)}}}),Se("packages/core/src/source/remote.js",function(e,V){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return y}});const _=V("packages/core/src/internal/util.js"),N=_.Lru,$=_.isFunction,L=_.warnOnce,W=_.settleDebounce,Z=V("packages/core/src/source/abort.js"),H=Z.createAbortScope,U=Z.isAbortError,z=V("packages/core/src/source/blockcache.js"),F=z.BlockCache,k=z.DEFAULT_PAGE_SIZE,S=z.DEFAULT_MAX_CACHED_PAGES,b=V("packages/core/src/source/rows.js"),a=b.createRowFactory,l=b.groupKey,r=V("packages/core/src/source/filterwire.js"),t=r.wireFilters,n=r.querySignature,i=r.warnHostFilterNotApplied,c=V("packages/core/src/source/memory.js").MemorySource,d=1,f=120;function h(p,m){return new y(p,m)}class g{constructor(m,w,v,u){this.path=m,this.keyPath=u||m,this.values=[],this.level=w,this.key=l(this.keyPath),this.cache=new F(v),this.count=null,this.complete=!1,this.counting=!1,this.children=new Map,this.row=null}}class y{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#a=H();#s;#l;#u=new Map;#c=[];#d="";#h;#f=!1;#m=null;#p=-1;constructor(m,w){this.#e=m||{mode:"remote"},this.#t=w||{},$(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#S(),this.unfilteredIndices=()=>this.#j(),this.handleFor=s=>this.#A(s),this.display=()=>this.#O(),this.grandTotalRow=()=>this.#E(),this.unfilteredRows=()=>this.#R(),this.facetIndices=s=>this.#C(s));const v=this.#e.counts;$(v)&&(this.matchCount=()=>this.#T("match"),this.totalCount=()=>this.#T("total"));const u=this.#e.grandTotals;$(u)&&(this.grandTotalRow=()=>this.#D()),this.#n={pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||S},this.#s=a(this.#t),this.#l=new N(this.#n.pageSize*4),this.#h=W((s,O)=>this.#v(s,O),f),this.#r=new g([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#d=this.#ge(),$(this.#e.fetch)||L("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#K()}count(){const m=this.#b();return m?m.count():(this.#se(),this.#F(this.#r))}at(m){const w=this.#b();if(w)return w.at(m);if(this.#se(),m<0||m>=this.count())return;const v=this.#I(this.#r,m);if(!v)return;const u=this.#Z(v.node,v.local);return u&&(u.index=m),u||this.#s.skeleton(m,v.node.level)}byKey(m){const w=this.#b();if(w)return w.byKey(m);const v=this.#u.get(m);if(!v)return;const u=v.lastIndexOf(":"),s=this.#o.get(v.slice(0,u));return s&&this.#Z(s,Number(v.slice(u+1)))||void 0}loaded(m){const w=this.#b();if(w)return w.loaded(m);if(m<0||m>=this.count())return!1;const v=this.#I(this.#r,m);return!!v&&v.node.cache.rowLoaded(v.local)}hint(m,w){if(this.#f)return;const v=this.#se(),u=Math.max(0,Math.floor(m)),s=Math.max(u,Math.floor(w));for(const[O,E]of this.#g(u,s)){O.cache.protect(E.min,E.max);for(const A of O.cache.evict())this.#le(O,A)}this.#h(u,s),v&&this.#h.flush()}#g(m,w){const v=this.count(),u=new Map;for(let s=m;s<=w&&s<v;s++){const O=this.#I(this.#r,s);if(!O)continue;const E=u.get(O.node);E?(E.min=Math.min(E.min,O.local),E.max=Math.max(E.max,O.local)):u.set(O.node,{min:O.local,max:O.local})}return u.size||u.set(this.#r,{min:m,max:m}),u}#v(m,w){if(!this.#f)for(const[v,u]of this.#g(m,w)){v.cache.protect(u.min,u.max);const s=v.cache.blockOf(u.min),O=v.cache.blockOf(u.max);for(let E=s;E<=O&&!(v.count!==null&&E*v.cache.pageSize>=v.count);E++)v.cache.has(E)||this.#M(v,E)}}apply(m){const w={added:[],updated:[],removed:[]};if(!m)return w;if(m.update)for(const v of m.update){const u=this.#u.get(this.#s.keyOf(v,-1));if(!u)continue;this.#l.delete(u);const s=u.lastIndexOf(":"),O=this.#o.get(u.slice(0,s));if(!O)continue;const E=Number(u.slice(s+1)),A=O.cache.blockOf(E);if(!O.cache.loaded(A))continue;const{start:M}=O.cache.rangeOf(A),C=[];for(let D=M;D<M+O.cache.pageSize;D++){const K=O.cache.rowAt(D);if(K===void 0)break;C.push(D===E?v:K)}O.cache.fill(A,C);const P=this.#Z(O,E);P&&w.updated.push(P)}return(m.add&&m.add.length||m.remove&&m.remove.length)&&this.reload({keepExpanded:!0}),w}reload(m){this.#a.abortAll("reload"),this.#h.cancel(),m&&m.keepExpanded===!1&&this.#i.clear(),this.#ne(),this.#X("model:changed",{reason:"reload"})}destroy(){this.#f=!0,this.#h.cancel(),this.#a.abortAll("destroyed"),this.#ne(),this.#o.clear(),this.#i.clear(),this.#m&&$(this.#m.destroy)&&this.#m.destroy(),this.#m=null}expand(m){this.#i.has(m)||(this.#i.add(m),this.#X("group:toggled",{key:m,expanded:!0}),this.#X("model:changed",{reason:"expand",key:m}))}collapse(m){this.#i.delete(m)&&(this.#X("group:toggled",{key:m,expanded:!1}),this.#X("model:changed",{reason:"collapse",key:m}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}invalidateHandles(){this.#m&&($(this.#m.invalidateHandles)&&this.#m.invalidateHandles(),$(this.#m.invalidate)&&this.#m.invalidate("filter"))}#y(){const m=this.#e.fullFrame;return $(m)?m():null}#b(){const m=this.#y();return m?(this.#m||(this.#m=new c({mode:"memory"},this.#w())),m.version!==this.#p&&(this.#m.setRows(m.rows),this.#p=m.version),this.#m):null}#w(){const m=this.#t,w=m.state||{};return{...m,state:{...w,page:()=>0,pageSize:()=>0}}}#S(){const m=this.#b();return m?m.filteredIndices():new Uint32Array(0)}#j(){const m=this.#b();return m?m.unfilteredIndices():new Uint32Array(0)}#A(m){const w=this.#b();return w?w.handleFor(m):void 0}#O(){const m=this.#b();return m?m.display():[]}#C(m){const w=this.#b();return w&&$(w.facetIndices)?w.facetIndices(m):new Uint32Array(0)}#E(){const m=this.#b();return m&&$(m.grandTotalRow)?m.grandTotalRow():null}#T(m){const w=this.#b();if(w){const O=m==="match"?w.matchCount:w.totalCount;if($(O))return O.call(w)}const v=this.#e.counts,u=$(v)?v():null,s=u?u[m]:null;return typeof s=="number"?s:this.count()}#D(){const m=this.#b();if(m&&$(m.grandTotalRow))return m.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const v=this.#e.grandTotals,u=$(v)?v():null;return!u||!u.totals?null:this.#s.grandTotal(u.totals,u.leafCount||0)}#R(){const m=this.#b();if(m&&$(m.unfilteredRows))return m.unfilteredRows();const w=[],v=this.count();for(let u=0;u<v;u++){const s=this.at(u);s&&w.push(s)}return w}#N(m,w,v){const{start:u,end:s}=m.cache.rangeOf(w),O=this.#z("groupBy",[]),E=this.#z("pivotBy",[]),A=this.#z("quick",""),M=this.#ee(),C={protocol:d,range:{start:u,end:s},groupPath:m.path,groupValues:m.values,groupBy:O,totals:M,totalFns:this.#x(M),pivotBy:E,pivotMode:E.length>0,filters:t(this.#z("filters",null),this.#we()),sort:this.#z("sort",[]),context:this.#z("context",null),signal:v};A&&(C.quick=A);const P=this.#z("where",null);return P&&P.active&&(C.where=P),C}async#M(m,w){if(!$(this.#e.fetch))return;const v=this.#a.begin(`${m.key}:${w}`);m.cache.begin(w,v);const u=this.#d,{start:s}=m.cache.rangeOf(w);try{const O=await this.#e.fetch(this.#N(m,w,v.signal));if(!v.current||u!==this.#d||this.#f)return;v.settle();const E=O&&O.rows||[];m.cache.fill(w,E);for(let C=0;C<E.length;C++)this.#l.delete(`${m.key}:${s+C}`);const A=O&&typeof O.count=="number"?O.count:O&&typeof O.total=="number"?O.total:null,M=O&&$(O.pendingTotal?.then)?O.pendingTotal:null;A!==null?(m.count=A,m.complete=!0):E.length<m.cache.pageSize?(m.count=s+E.length,m.complete=!0):M&&(m.counting=!0),O&&Array.isArray(O.pivotFields)&&this.#U(O.pivotFields),this.#X("model:changed",{reason:"page",groupPath:m.path,block:w}),M&&this.#_(m,M,u)}catch(O){if(v.settle(),U(O))return;m.cache.failed(w,O),this.#X("source:error",{error:O,groupPath:m.path,block:w})}}async#_(m,w,v){let u;try{u=await w}catch(s){if(v!==this.#d||this.#f)return;m.counting=!1,U(s)||this.#X("source:error",{error:s,groupPath:m.path});return}v!==this.#d||this.#f||(m.counting=!1,typeof u=="number"&&(m.count=u,m.complete=!0,this.#X("source:total",{total:u,groupPath:m.path}),this.#X("model:changed",{reason:"total",count:u,groupPath:m.path})))}totalPending(){return this.#r.counting===!0}#U(m){m.length===this.#c.length&&m.every((w,v)=>w===this.#c[v])||(this.#c=m,this.#X("column:pivoted",{pivotFields:m,remote:!0}))}#F(m){let w=this.#Y(m);for(const v of m.children.values())this.#V(v.key)&&(w+=this.#F(v));return w}#Y(m){if(m.count!==null)return m.count;const w=m.cache.loadedExtent();return m.complete?w:m.row&&m.row.leafCount>0?Math.max(w,m.row.leafCount):w+m.cache.pageSize}#I(m,w){let v=w,u=0;const s=[...m.children.entries()].filter(([,E])=>this.#V(E.key)).sort((E,A)=>E[0]-A[0]);for(const[E,A]of s){const M=E-u+1;if(v<M)return{node:m,local:u+v};v-=M,u=E+1;const C=this.#F(A);if(v<C)return this.#I(A,v);v-=C}const O=this.#Y(m);return u+v<O?{node:m,local:u+v}:null}#Z(m,w){const v=`${m.key}:${w}`,u=this.#l.get(v);if(u)return u;const s=m.cache.rowAt(w);if(s===void 0)return null;const O=this.#z("groupBy",[]);let E;if(m.level<O.length){const A=O[m.level],M=this.#G(s,A),C=M==null,P=[...m.path,C?"":String(M)],D=[...m.keyPath,C?null:String(M)];E=this.#s.group({path:P,keyPath:D,column:A,value:M,level:m.level,parent:m.row,leafCount:Number(s.leafCount)||0,expanded:this.#V(l(D))}),E.totals=this.#te(s),E.data=s;let K=this.#o.get(E.key);K?K.row=E:(K=new g(P,m.level+1,this.#n,D),K.row=E,this.#o.set(K.key,K)),K.values=[...m.values,M],m.children.set(w,K)}else E=this.#s.leaf(s,w,m.level,m.row);return this.#l.set(v,E),this.#u.set(E.key,v),E}#te(m){const w=m||{};if(w.totals&&typeof w.totals=="object")return w.totals;const v={};for(const u of this.#ee())Object.hasOwn(w,u)&&(v[u]=w[u]);return v}#le(m,w){const{start:v,end:u}=m.cache.rangeOf(w);for(let s=v;s<u;s++){const O=`${m.key}:${s}`,E=this.#l.peek(O);E&&this.#u.delete(E.key),this.#l.delete(O)}}#se(){const m=this.#ge();return m===this.#d?!1:(this.#d=m,this.#a.abortAll("query"),this.#ne(),this.#X("model:changed",{reason:"query"}),!0)}#ne(){for(const m of this.#o.values())m.cache.clear(),m.count=null,m.complete=!1,m.counting=!1,m.children.clear();this.#l.clear(),this.#u.clear()}#ge(){const m=this.#z("where",null);return`${n({filters:this.#z("filters",null),sort:this.#z("sort",[]),quick:this.#z("quick",""),groupBy:this.#z("groupBy",[]),pivotBy:this.#z("pivotBy",[]),context:this.#z("context",null)})}|${m?m.version:0}`}#V(m){const w=this.#z("expanded",null);return w?$(w.has)?w.has(m):Array.prototype.includes.call(w,m):this.#i.has(m)}#ee(){const m=this.#z("totals",[]);if(m&&m.length)return[...m];const w=this.#t.columns;return!w||!$(w.all)?[]:w.all().filter(v=>!!v.total).map(v=>v.id)}#x(m){const w=this.#t.columns,v={};if(!w||!$(w.get))return v;for(const u of m){const s=w.get(u);if(!s)continue;const O=s.groupTotal!=null?s.groupTotal:s.total;typeof O=="string"&&(v[u]=O)}return v}#G(m,w){const v=this.#t.columns,u=v&&$(v.get)?v.get(w):void 0;return u&&$(u.getValue)?u.getValue(m):m?.[w]}#K(){i(this.#t)}#we(){const m=this.#t.config||{};return{tz:m.timeZone,weekStartsOn:m.weekStartsOn}}#z(m,w){const v=this.#t.state;if(v&&$(v[m])){const u=v[m]();return u??w}return w}#X(m,w){const v=this.#t.emit;$(v)&&v(m,w)}}}),Se("packages/core/src/source/gapbuffer.js",function(e,V){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return N}});const _=64;class N{#e;#t=0;#n=0;constructor(L=_){this.#e=new Uint32Array(Math.max(1,L)),this.#n=this.#e.length}static from(L,W=_){const Z=new N(L.length+Math.max(1,W));return Z.#e.set(L,0),Z.#t=L.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(L){return L<0||L>=this.length?0:L<this.#t?this.#e[L]:this.#e[L+(this.#n-this.#t)]}insert(L,W){const Z=L<0?0:L>this.length?this.length:L;this.#r(Z),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(L){this.insert(this.length,L)}removeAt(L){return!Number.isInteger(L)||L<0||L>=this.length?!1:(this.#r(L),this.#n++,!0)}toArray(){const L=new Uint32Array(this.length);return L.set(this.#e.subarray(0,this.#t),0),L.set(this.#e.subarray(this.#n),this.#t),L}clear(){this.#t=0,this.#n=this.#e.length}#r(L){if(L!==this.#t)if(L<this.#t){const W=this.#t-L;this.#e.copyWithin(this.#n-W,L,this.#t),this.#t=L,this.#n-=W}else{const W=L-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=L,this.#n+=W}}#o(){const L=this.#e.length-this.#n,W=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+_));W.set(this.#e.subarray(0,this.#t),0),W.set(this.#e.subarray(this.#n),W.length-L),this.#e=W,this.#n=W.length-L}}}),Se("packages/core/src/store/ingest.js",function(e,V){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return t}});const _=V("packages/core/src/internal/util.js"),N=_.now,$=_.nextFrame,L=_.infoOnce,W=_.warnOnce,Z=_.isFunction,H=_.pathGetter,z=V("packages/core/src/store/columnstore.js").ColumnStore,F=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function k(n,i={}){if(i.multi)return"multi";if(n.length===0)return"object";let o=0,c=0,d=0,f=0,h=0;for(let y=0;y<n.length;y++){const p=n[y];typeof p=="number"?o++:typeof p=="boolean"?c++:typeof p=="string"?d++:p instanceof Date?f++:Array.isArray(p)&&h++}const g=n.length;return o===g?"float64":c===g?"bitset":f===g?"float64":d===g?"text":h===g?"multi":"object"}function S(n,i,o){return i<=0||n<o*i?"dictionary":"object"}function b(n,i,o){const c=new Map,d=new Map;for(const s of n){if(s.computed)continue;const O=Z(s.read)?s.read:H(s.field||s.id);d.set(s.id,O),c.set(s.id,O)}const f=i?.order??[],h=i?.fns??{},g=i?.deps??{},y=i?.wrapDeps??null,p=f.filter(s=>Z(h[s])),m=p.some(s=>g[s]==="*");let w=new WeakMap;const v=s=>{const O={};if(m)for(const[E,A]of d)O[E]=A(s);for(const E of p){const A=g[E];let M;if(A==="*")M=O;else{M={};const C=A||[];for(let P=0;P<C.length;P++){const D=C[P];M[D]=D in O?O[D]:d.get(D)?.(s)}}O[E]=h[E](y?y(M,E):M,{data:s,row:null,column:null,grid:null,context:o})}return O},u=s=>{if(s===null||typeof s!="object"&&typeof s!="function")return v(s);let O=w.get(s);return O===void 0&&(O=v(s),w.set(s,O)),O};for(const s of p)c.set(s,O=>u(O)[s]);return{readers:c,reset(){w=new WeakMap}}}class a{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,o){this.spec=i,this.read=o,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class l{#e;#t=[];#n=null;#r;#o=0;#i;#a=!1;#s=!1;#l=0;#u;constructor(i,o={},c={}){this.#e=Array.isArray(i)?i:Array.from(i||[]),this.#i={...F,...c};const d=o.columns??[];this.#r=b(d,o.computed??null,o.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(d,o.computed??null),this.#n=new z(this.#t.map(f=>({id:f.spec.id,kind:f.kind,nullable:f.nullable,read:f.read,dictionary:f.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#a||this.#s}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#s=!0,!1;const i=N(),{chunkMs:o,chunkRows:c}=this.#i,d=this.#e.length;do{const f=Math.min(this.#o+c,d);this.#n.append(this.#e.slice(this.#o,f)),this.#d(this.#o,f),this.#o=f,this.#r.reset(),this.#f(!1)}while(this.#o<d&&N()-i<o);return this.#l+=N()-i,this.#i.onProgress?.({loaded:this.#o,total:d}),this.#o>=d?(this.#f(!0),this.#a=!0,!1):!0}cancel(){this.#s=!0}result(){return{store:this.#n,schema:this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#h(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#l,cancelled:this.#s}}#c(i,o){const c=this.#e,d=Math.min(this.#i.sampleSize,c.length),f=this.#i.dictionaryRatio,h=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const g of i){if(!g||!g.id)continue;if(g.computed&&(g.pure===!1||o&&!h.has(g.id))){W(`ingest.impure.${g.id}`,`column "${g.id}" is an impure computed column and is not materialised into the store`);continue}const y=this.#r.readers.get(g.id)??(Z(g.read)?g.read:H(g.field||g.id)),p=new a(g,y);if(g.kind)p.kind=g.kind,p.reason="declared by the caller";else if(g.dictionary)p.kind=g.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const m=[];for(let v=0;v<d&&m.length<this.#i.sampleSize;v++){const u=y(c[v]);u!=null&&m.push(u)}p.inferred=!0;const w=k(m,{multi:g.multi});if(w==="text"){const v=new Set(m).size;p.kind=S(v,m.length,f),p.candidate=this.#u,p.reason=`sampled ${v} distinct in ${m.length}`}else p.kind=w,p.reason=`inferred from ${m.length} sampled values`,w==="object"&&m.length&&L(`ingest.mixed.${g.id}`,`column "${g.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(m))}this.#t.push(p)}}#d(i,o){const c=this.#e;for(const d of this.#t){if(!d.candidate||!d.distinct)continue;const f=d.distinct;for(let h=i;h<o;h++){const g=d.read(c[h]);g!=null&&f.add(g)}}}#h(i){if(i.distinct)return i.distinct.size;const o=this.#n.column(i.spec.id);return o?.dict?o.dict.size:0}#f(i){const o=this.#i.dictionaryRatio,c=this.#e.length;for(const d of this.#t){if(!d.candidate)continue;const f=this.#h(d);if(d.kind==="dictionary"&&f>=o*c){const h=this.#n.column(d.spec.id);d.distinct=new Set(h?.dict?h.dict.values():[]),this.#n.convert(d.spec.id,"object"),d.kind="object",d.change="demoted",d.reason=`${f} distinct values is at or above ${o*100}% of ${c} rows`;continue}if(d.kind==="object"&&f>=o*c){d.candidate=!1,d.distinct=null,d.reason=`${f} distinct values is at or above ${o*100}% of ${c} rows`;continue}i&&d.kind==="object"&&f<o*c&&(this.#n.convert(d.spec.id,"dictionary"),d.kind="dictionary",d.change=d.change==="demoted"?null:"promoted",d.reason=`${f} distinct values is below ${o*100}% of ${c} rows`,d.distinct=null),i&&(d.candidate=!1)}}}async function r(n,i={},o={}){const c=new l(n,i,o),d=o.scheduler?.frame??$;for(;c.slice();)await new Promise(f=>{d(f)});return c.result()}function t(n,i={},o={}){const c=new l(n,i,{...o,chunkMs:1/0});for(;c.slice(););return c.result()}}),Se("packages/core/src/store/columnpack.js",function(e,V){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return l}});const N=V("packages/core/src/internal/util.js").pathGetter,$=V("packages/core/src/store/ingest.js"),L=$.inferKind,W=$.decideText,Z=$.INGEST_DEFAULTS,U=V("packages/core/src/store/columnstore.js").toFloat,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function F(r){if(!Array.isArray(r)||r.length===0)return!1;for(const t of r)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!z.has(t.kind))return!1;return!0}function k(r){const t=U(r);return Number.isFinite(t)?t|0:0}function S(r){return r==null?[]:Array.isArray(r)?r:[r]}function b(r,t,n,i){if(r.kind)return r.kind;const o=[];for(let f=0;f<t.length&&o.length<Z.sampleSize;f++){const h=t[f];h!=null&&o.push(h)}const c=L(o,{multi:r.multi});if(c!=="text")return c;const d=new Set(o).size;return W(d,o.length,i)}function a(r,t,n={}){const i=t.length|0,o=n.dictionaryRatio??Z.dictionaryRatio,c=[];for(const d of r){const f=N(d.field||d.id),h=d.nullable!==!1,g=new Array(i);for(let v=0;v<i;v++){const u=f(t[v]);g[v]=u===void 0?null:u}const y=b(d,g,i,o),p=h?new Uint8Array(i+7>>3):null,m=v=>{p&&(p[v>>3]|=1<<(v&7))};let w;switch(y){case"float64":{const v=new Float64Array(i);for(let u=0;u<i;u++){const s=g[u],O=s===null;O||m(u),v[u]=O?NaN:U(s)}w={id:d.id,kind:y,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"int32":{const v=new Int32Array(i);for(let u=0;u<i;u++){const s=g[u],O=s===null;O||m(u),v[u]=O?0:k(s)}w={id:d.id,kind:y,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"bitset":{const v=new Uint8Array(i+7>>3);for(let u=0;u<i;u++){const s=g[u],O=s===null;O||m(u),!O&&s&&(v[u>>3]|=1<<(u&7))}w={id:d.id,kind:y,nullable:h,values:v,presence:p,offsets:null,table:null};break}case"dictionary":{const v=new Uint32Array(i),u=[],s=new Map;for(let O=0;O<i;O++){const E=g[O];if(E===null){v[O]=0;continue}m(O);let A=s.get(E);A===void 0&&(A=u.length,u.push(E),s.set(E,A)),v[O]=A}w={id:d.id,kind:y,nullable:h,values:v,presence:p,offsets:null,table:u};break}case"multi":{const v=[],u=new Map,s=new Uint32Array(i+1),O=[];for(let E=0;E<i;E++){const A=g[E];s[E]=O.length,A===null||m(E);const C=S(A);for(let P=0;P<C.length;P++){const D=C[P];let K=u.get(D);K===void 0&&(K=v.length,v.push(D),u.set(D,K)),O.push(K)}}s[i]=O.length,w={id:d.id,kind:y,nullable:h,values:Int32Array.from(O),presence:p,offsets:s,table:v};break}default:{const v=new Array(i);for(let u=0;u<i;u++){const s=g[u];s!==null&&m(u),v[u]=s}w={id:d.id,kind:"object",nullable:h,values:v,presence:p,offsets:null,table:null};break}}c.push(w)}return{count:i,columns:c}}function l(r){const t=[];if(!r||!Array.isArray(r.columns))return t;const n=i=>{ArrayBuffer.isView(i)&&i.buffer&&!t.includes(i.buffer)&&t.push(i.buffer)};for(const i of r.columns)n(i.values),n(i.presence),n(i.offsets);return t}}),Se("packages/core/src/source/stream.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return A}});const _=V("packages/core/src/internal/util.js"),N=_.Lru,$=_.isFunction,L=_.now,W=_.nextFrame,Z=_.cancelFrame,H=_.whenIdle,U=_.defaultCompare,z=_.warnOnce,F=_.infoOnce,k=_.getPath,S=V("packages/core/src/source/abort.js"),b=S.createAbortScope,a=S.isAbortError,l=V("packages/core/src/source/rows.js"),r=l.createRowFactory,t=l.lazyRowView,i=V("packages/core/src/source/gapbuffer.js").GapBuffer,c=V("packages/core/src/source/memory.js").createMemorySource,f=V("packages/core/src/source/filterwire.js").querySignature,g=V("packages/core/src/store/columnpack.js").isPortableSchema,y=25e4,p=Symbol("lattice.stream.storeBacked"),m=8,w=.1,v=1e3,u=50;function s(M){return Math.min(v,Math.max(u,Math.floor(M/4)))}function O(M){if(M instanceof Date)return M.getTime();if(typeof M=="number")return Number.isFinite(M)?M:NaN;if(typeof M=="string"){const C=M.trim();if(!C)return NaN;const P=Date.parse(C);return Number.isNaN(P)?Number(C):P}return NaN}function E(M,C){return new A(M,C)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#a;#s;#l=new Map;#u=b();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#m=0;#p=0;#g=null;#v=null;#y=null;#b=!1;#w=!1;#S=!1;#j=!1;#A="";#O=0;#C=0;#E=0;#T=null;#D=1/0;#R=!1;#N=null;#M=null;#_=null;#U=null;#F=!1;#Y=0;#I=0;#Z=!1;constructor(C,P){this.#e=C||{mode:"stream"},this.#t=P||{},this.#a=r(this.#t),this.#s=new N(4096),this.#A=this.#Me();const D=(this.#t.config||{}).ingest;this.#F=!!D&&D.retainSource===!1,$(this.#e.open)||z("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const K=Number(this.#e.poll);Number.isFinite(K)&&K>0&&(this.#U=setInterval(()=>{this.#j||this.reload()},K),this.#U&&$(this.#U.unref)&&this.#U.unref()),this.#le()}#te(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#le(){const C=this.#te();if(!C)return;const P=this.#e.ageBy;$(P)?this.#M=P:typeof P=="string"&&P?this.#M=D=>k(D,P):this.#M=null,this.#T=[],this.#N=setInterval(()=>{this.#j||this.#se()&&(this.#re(),this.#Le())},s(C)),this.#N&&$(this.#N.unref)&&this.#N.unref()}#se(){const C=this.#te();return!C||!this.#T?!1:this.#R?!0:this.#D<Date.now()-C*(1+w)}#ne(C,P){if(!this.#T)return;const D=this.#M?O(this.#M(P)):Date.now();this.#T[C]=D,Number.isNaN(D)||(D<this.#D&&(this.#D=D),D<Date.now()-this.#te()&&(this.#R=!0))}#ge(){return this.#he("groupBy",[]).length>0?!0:!!this.#he("pivotMode",!1)&&this.#he("pivotBy",[]).length>0}#V(){if(this.#g||this.#j)return;const C=this.#ge();if(C&&!this.#v){this.#v=c({mode:"memory",rows:this.#n},this.#ee()),this.#b=!1;return}!C&&this.#v&&(this.#v.destroy(),this.#v=null)}#ee(){if(this.#y)return this.#y;const C=this,P={liveIndices:()=>C.#x(),live:D=>C.#n[D]!==void 0,source:D=>C.#me(D),get physical(){return C.#n.length}};return this.#F&&(P.column=D=>{const K=C.#t.store;return K&&$(K.column)?K.column(D):void 0}),this.#y=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#y}#x(){const C=new Uint32Array(this.#n.length);let P=0;for(let D=0;D<this.#n.length;D++)this.#n[D]!==void 0&&(C[P++]=D);return C.subarray(0,P)}#G(){return this.#g?this.#g:this.#v?(this.#b&&(this.#b=!1,this.#v.setRows(this.#n)),this.#v):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#V(),this.#v&&this.#v.invalidate(C),(C==="filter"||C==="sort")&&this.#$()}count(){const C=this.#G();return C?C.count():this.#r?this.#r.length:this.#O}matchCount(){const C=this.#G();return C&&$(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const C=this.#G();return C&&$(C.totalCount)?C.totalCount():this.#O}unfilteredRows(){const C=this.#G();if(C&&$(C.unfilteredRows))return C.unfilteredRows();const P=[];for(let D=0;D<this.#n.length;D++){if(!this.#n[D])continue;const K=this.#q(D);K&&P.push(K)}return P}at(C){const P=this.#G();if(P)return P.at(C);if(C<0||C>=this.count())return;const D=this.#r?this.#r.at(C):C,K=this.#q(D);return K.index=C,K}byKey(C){const P=this.#G();if(P)return P.byKey(C);const D=this.#l.get(C);return D===void 0?void 0:this.#q(D)}leavesOf(C){const P=this.#G();return P&&$(P.leavesOf)?P.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,P){if(this.#g){this.#g.hint(C,P);return}this.#K(),this.#m=Math.max(0,Math.floor(C))}#K(){this.#j||this.#Me()===this.#A||this.reload()}display(){const C=this.#G();return C?C.display():t(()=>this.count(),P=>this.at(P))}apply(C){if(this.#g)return this.#g.apply(C);const P={added:[],updated:[],removed:[]};if(!C)return P;if(C.update){let D=!1;for(const K of C.update){const x=this.#l.get(this.#a.keyOf(K,-1));if(x===void 0)continue;const I=this.#ae(x);this.#F?this.#Ge(x,K):this.#n[x]=K,this.#s.delete(x),this.#k(x,I),this.#T&&(this.#ne(x,K),D=!0),this.#b=!0,P.updated.push(this.#q(x))}D&&this.#re()}if(C.add&&C.add.length){const D=this.#W(C.add);for(const K of D)P.added.push(this.#q(K))}return C.remove&&C.remove.length&&z("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#Le(),P}reload(C){this.#u.abortAll("reload"),this.#et(),this.#v&&(this.#v.destroy(),this.#v=null),this.#b=!1,this.#n=[],this.#r=null,this.#l.clear(),this.#s.clear(),this.#g=null,this.#O=0,this.#C=0,this.#E=0,this.#T&&(this.#T=[]),this.#D=1/0,this.#R=!1,this.#w=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#A=this.#Me(),this.#ye("model:changed",{reason:"reload"}),this.start()}destroy(){this.#j=!0,this.#U!==null&&(clearInterval(this.#U),this.#U=null),this.#N!==null&&(clearInterval(this.#N),this.#N=null),this.#T=null,this.#u.abortAll("destroyed"),this.#et(),this.#d!==null&&(this.#Ze(this.#d),this.#d=null),this.#v&&(this.#v.destroy(),this.#v=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#l.clear(),this.#s.clear()}async start(){if(this.#S||this.#j||!$(this.#e.open))return;this.#S=!0;const C=this.#u.begin("stream");this.#$(),this.#V();let P;try{P=this.#e.open({sort:this.#he("sort",[]),filters:this.#he("filters",null),quick:this.#he("quick","")||void 0,context:this.#he("context",null),signal:C.signal})}catch(K){this.#ye("source:error",{error:K});return}const D=$(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#_=D;try{for(;;){const K=await D.next();if(!C.current||this.#j)return;if(K.done){this.#je();return}if(await this.#we(K.value,C),!C.current||this.#j)return;if(K.value&&K.value.done){this.#je();return}if(await this.#Fe(),!C.current||this.#j)return}}catch(K){if(a(K))return;this.#ye("source:error",{error:K})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#w,live:this.#O,evicted:this.#C}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#G();C&&($(C.invalidateHandles)&&C.invalidateHandles(),$(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#Y,inline:this.#I,storeBacked:this.#F}}#we(C,P){if(!C)return;const D=C.rows;if(D&&D.length&&this.#X(D))return this.#Oe(C,P);const K=L();D&&D.length&&(this.#W(D),this.#I++),this.#z(C),this.#f+=L()-K,this.#Le()}#z(C){this.#c.loaded=C.progress&&typeof C.progress.loaded=="number"?C.progress.loaded:this.#n.length,C.progress&&typeof C.progress.estimated=="number"&&(this.#c.estimated=C.progress.estimated)}#X(C){if(this.#Z||this.#g)return!1;const P=this.#be();if(!P)return!1;const D=this.#t.store;if(!D||!$(D.appendPacked))return!1;const K=this.#ve();return!K||!g(K)?(this.#Z=!0,F("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):C.length<P.threshold?!1:!this.#Se(C)}#Se(C){if(!this.#a.keyed)return!1;const P=new Set;for(let D=0;D<C.length;D++){const K=this.#a.keyOf(C[D],this.#n.length+D);if(K!=null){if(P.has(K)||this.#l.has(K))return!0;P.add(K)}}return!1}async#Oe(C,P){const D=C.rows,K=this.#be(),x=this.#ve();let I;try{I=await K.columnize(x,D,{key:"ingest:stream",signal:P&&P.signal})}catch(X){if(a(X)||(z("source.stream.columnize","worker columnization failed; columnizing on the main thread",X),this.#Z=!0,P&&(!P.current||this.#j)))return;this.#W(D),this.#I++,this.#z(C),this.#Le();return}if(P&&(!P.current||this.#j))return;const j=this.#t.store,T=this.#F?void 0:D,{from:B}=j.appendPacked(I,T),q=I.count|0;for(let X=0;X<q;X++){const Q=B+X,te=D[X],re=this.#a.keyed?this.#a.keyOf(te,Q):null;if(this.#n[Q]=this.#F?p:te,this.#O++,this.#ne(Q,te),re!==null&&this.#l.set(re,Q),!this.#r||!this.#oe(Q))continue;const ie=this.#ce(Q);this.#r.insert(ie,Q),ie<=this.#m&&this.#p++}this.#b=!0,this.#re(),this.#Y++,this.#z(C),this.#Le()}#be(){const C=this.#t.ingestWorker;return $(C)?C():null}#ve(){const C=this.#t.storeSchema;return $(C)?C():null}#W(C){const P=[],D=this.#t.store,K=new Array(C.length),x=[],I=new Set;for(let T=0;T<C.length;T++){const B=this.#a.keyed?this.#a.keyOf(C[T],this.#n.length+x.length):null;K[T]=B,!(B!==null&&(this.#l.has(B)||I.has(B)))&&(B!==null&&I.add(B),x.push(C[T]))}let j=x.length&&D&&$(D.append)?D.append(x).from:this.#n.length;for(let T=0;T<C.length;T++){const B=C[T],q=K[T];if(q!==null&&this.#l.has(q)){const te=this.#l.get(q),re=this.#ae(te);this.#F||(this.#n[te]=B,D&&$(D.setSource)&&D.setSource(te,B)),this.#Ge(te,B),this.#s.delete(te),this.#ne(te,B),this.#k(te,re);continue}const X=j++;if(this.#n[X]=this.#F?p:B,this.#O++,this.#ne(X,B),q!==null&&this.#l.set(q,X),P.push(X),!this.#r||!this.#oe(X))continue;const Q=this.#ce(X);this.#r.insert(Q,X),Q<=this.#m&&this.#p++}return this.#b=!0,this.#re(),P}#Re(C){const P=this.#n[C];let D=!1;if(this.#r){const j=this.#H(C);j>=0&&j<=this.#m&&(D=!0)}else C<=this.#m&&(D=!0);const K=P===p?this.#me(C):P,x=this.#a.keyed?this.#a.keyOf(K,C):null;x!==null&&this.#l.get(x)===C&&this.#l.delete(x),this.#n[C]=void 0,this.#T&&(this.#T[C]=NaN),this.#s.delete(C);const I=this.#t.store;return I&&$(I.remove)&&I.remove(C),this.#O--,D}#re(){let C=0,P=0;const D=this.#ie();C+=D.dropped,P+=D.aboveAnchor;const K=this.#fe();C+=K.dropped,P+=K.aboveAnchor,C&&(this.#b=!0,this.#C+=C,this.#$(),this.#p-=P,this.#ye("stream:evicted",{evicted:C,total:this.#C,live:this.#O}))}#fe(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#O<=C)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(C*(1-w)));let D=0,K=0;for(;this.#O>P&&this.#E<this.#n.length;){const x=this.#E++;this.#n[x]!==void 0&&(this.#Re(x)&&K++,D++)}return{dropped:D,aboveAnchor:K}}#ie(){const C=this.#te();if(!C||!this.#T||!this.#se())return{dropped:0,aboveAnchor:0};const P=Date.now()-C;let D=0,K=0,x=1/0;for(let I=this.#E;I<this.#n.length;I++){if(this.#n[I]===void 0)continue;const j=this.#T[I];if(!(Number.isNaN(j)||j===void 0)){if(j>=P){j<x&&(x=j);continue}this.#Re(I)&&K++,D++}}for(this.#D=x,this.#R=!1;this.#E<this.#n.length&&this.#n[this.#E]===void 0;)this.#E++;return{dropped:D,aboveAnchor:K}}#H(C){if(!this.#r)return C;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===C)return P;return-1}#$(){this.#o=this.#he("sort",[]),this.#i=this.#he("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#te()>0,P=this.#he("where",null),D=(this.#t.config||{}).hostFilter,K=!!(P&&P.active)||!!(D&&$(D.active)&&D.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#he("quick","")||K)){this.#r=null;return}this.#r=new i(Math.max(64,this.#n.length+64));for(let I=0;I<this.#n.length;I++)this.#n[I]!==void 0&&this.#oe(I)&&this.#r.insert(this.#ce(I),I)}#oe(C){const P=this.#me(C);if(this.#i&&!this.#ue(this.#i,P))return!1;const D=String(this.#he("quick","")||"").toLowerCase();if(D&&!this.#Je(P).includes(D))return!1;const K=(this.#t.config||{}).hostFilter;if(K&&$(K.active)&&K.active()&&!K.passes(this.#q(C)))return!1;const x=this.#he("where",null);if(x&&x.active){const I=this.#q(C);if(!x.passes(I.data,I.key))return!1}return!0}#ue(C,P){if(!C)return!0;const D=C;if(Array.isArray(D.conditions))return D.op==="or"?D.conditions.some(I=>this.#ue(I,P)):D.op==="not"?!D.conditions.some(I=>this.#ue(I,P)):D.conditions.every(I=>this.#ue(I,P));const K=C,x=(this.#t.compute||{}).testValue;return $(x)?!!x(this.#$e(P,K.col),K,(this.#t.config||{}).locale):(z("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#ae(C){if(!this.#r)return-1;if(!this.#o.length)return this.#H(C);let P=0,D=this.#r.length;for(;P<D;){const K=P+D>>>1;this.#Te(this.#r.at(K),C)<0?P=K+1:D=K}for(let K=P;K<this.#r.length;K++){const x=this.#r.at(K);if(x===C)return K;if(this.#Te(x,C)>0)break}return this.#H(C)}#k(C,P){if(!this.#r||!this.#o.length)return;const D=this.#oe(C);if(P>=0&&this.#r.at(P)===C)this.#r.removeAt(P),P<=this.#m&&this.#p--;else if(P>=0)return;if(!D)return;const K=this.#ce(C);this.#r.insert(K,C),K<=this.#m&&this.#p++}#ce(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,D=this.#r.length;for(;P<D;){const K=P+D>>>1;this.#Te(C,this.#r.at(K))<0?D=K:P=K+1}return P}#Te(C,P){const D=this.#me(C),K=this.#me(P);for(const x of this.#o){const I=this.#Ke(x.col),j=this.#$e(D,x.col),T=this.#$e(K,x.col),q=(I&&I.value&&$(I.value.compare)?I.value.compare:U)(j,T);if(q!==0)return x.dir==="desc"?-q:q}return 0}#je(){this.#w=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:y;!this.#F&&this.#n.length<C&&(this.#g=c({mode:"memory",rows:this.#n},this.#t),this.#N!==null&&(clearInterval(this.#N),this.#N=null),this.#v&&(this.#v.destroy(),this.#v=null)),this.#Le(),this.#ye("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#Le(){this.#d!==null||this.#j||(this.#d=this.#Ve(()=>{this.#d=null,this.#h++;const C=this.#p;this.#p=0,this.#f=0,this.#ye("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#ye("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#m})}))}#Fe(){return this.#h===0||this.#f<this.#De()?Promise.resolve():(this.#f=0,new Promise(C=>{const P=(this.#t.scheduler||{}).idle;$(P)?P(()=>C()):H(()=>C())}))}#De(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:m}#Ve(C){const P=this.#t.scheduler||{};return $(P.frame)?P.frame(C):W(C)}#Ze(C){const P=this.#t.scheduler||{};$(P.cancel)?P.cancel(C):Z(C)}#me(C){const P=this.#n[C];if(P!==void 0&&P!==p)return P;if(P===void 0)return;const D=this.#t.store;return D&&$(D.source)?D.source(C):void 0}#Ge(C,P){const D=this.#t.store;if(!D||!$(D.set))return;const K=this.#ve();if(Array.isArray(K))for(const x of K){if(!x||!x.id)continue;const I=$(x.read)?x.read:j=>k(j,x.field||x.id);D.set(x.id,C,I(P))}}#q(C){let P=this.#s.get(C);return P||(P=this.#a.leaf(this.#me(C),C),this.#s.set(C,P)),P}#$e(C,P){const D=this.#Ke(P);return D&&$(D.getValue)?D.getValue(C):C?.[P]}#Je(C){const P=this.#t.columns,D=P&&$(P.all)?P.all():[],K=[];for(const x of D){const I=$(x.getValue)?x.getValue(C):void 0;I!=null&&I!==""&&K.push(String(I))}return K.join(" ").toLowerCase()}#Ke(C){const P=this.#t.columns;return P&&$(P.get)?P.get(C):void 0}#et(){const C=this.#_;if(this.#_=null,C&&$(C.return))try{C.return()}catch{}}#Me(){return f({context:this.#he("context",null)})}#he(C,P){const D=this.#t.state;if(D&&$(D[C])){const K=D[C]();return K??P}return P}#ye(C,P){const D=this.#t.emit;$(D)&&D(C,P)}}}),Se("packages/core/src/source/url.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/internal/util.js"),N=_.warnOnce,$=_.isObject,L=_.isFunction,W=_.getPath,H=V("packages/core/src/source/abort.js").isAbortError,U=500,z=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),F=Symbol("lattice.url.skip");function k(g,y={}){const p=$(y)?y:{},m=L(p.fetch)?p.fetch:typeof globalThis<"u"&&L(globalThis.fetch)?globalThis.fetch:null,w=p.format==="json"||p.format==="ndjson"?p.format:void 0,v=typeof p.rowsPath=="string"&&p.rowsPath?p.rowsPath:void 0,u=L(p.map)?p.map:void 0,s=$(p.headers)?p.headers:void 0,O=Number.isFinite(p.batchSize)&&p.batchSize>0?Math.floor(p.batchSize):U,E=p.lenient===!0,A=Number.isFinite(p.poll)&&p.poll>0?Math.floor(p.poll):void 0,M=typeof g=="string"&&g.length>0;M||N("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(D={}){if(!M)return;if(!m)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const K=D&&D.signal;let x;try{x=await m(g,s?{signal:K,headers:s}:{signal:K})}catch(T){throw H(T)?T:new Error(`[lattice] createUrlSource: request to ${g} failed — ${T&&T.message||T}`)}if(!x||!x.ok){const T=x?x.status:"no response";throw new Error(`[lattice] createUrlSource: ${T} for ${g}`)}const I=S(g,w,x),j=x.body&&L(x.body.getReader)?x.body.getReader():null;try{if(!j){const q=await x.text();(I||l(q,g))==="ndjson"?yield*c(null,null,q,0,x,g,O,E):yield*o(q,g,v,u);return}const T=new TextDecoder("utf-8");if(I==="json"){yield*o(await i(j,T,""),g,v,u);return}if(I==="ndjson"){yield*c(j,T,"",0,x,g,O,E);return}const B=await r(j,T,g);B.format==="json"?yield*o(await i(j,T,B.seed),g,v,u):yield*c(j,T,B.seed,B.bytes,x,g,O,E)}finally{if(j&&L(j.cancel))try{await j.cancel()}catch{}}}const P={mode:"stream",open:C,autoStart:p.autoStart!==!1};return A!==void 0&&(P.poll=A),Number.isFinite(p.maxRows)&&(P.maxRows=p.maxRows),Number.isFinite(p.maxAge)&&(P.maxAge=p.maxAge),(typeof p.ageBy=="string"||L(p.ageBy))&&(P.ageBy=p.ageBy),Number.isFinite(p.coalesceMs)&&(P.coalesceMs=p.coalesceMs),Number.isFinite(p.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=p.promoteToMemoryBelow),P}function S(g,y,p){if(y)return y;const m=b(g);if(m)return m;const w=p&&p.headers&&L(p.headers.get)?p.headers.get("content-type"):null;return a(w)}function b(g){const y=String(g).split(/[?#]/)[0].toLowerCase();if(y.endsWith(".ndjson")||y.endsWith(".jsonl"))return"ndjson";if(y.endsWith(".json"))return"json"}function a(g){if(!g)return;const y=g.split(";")[0].trim().toLowerCase();if(z.has(y))return"ndjson";if(y==="application/json"||y==="text/json"||y.endsWith("+json"))return"json"}function l(g,y){const p=g.replace(/^\s+/,""),m=t(p);if(m==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${y} — pass opts.format: 'json' | 'ndjson'.`);return m}async function r(g,y,p){let m="",w=0;for(;;){const{value:u,done:s}=await g.read();if(u&&(w+=u.byteLength,m+=y.decode(u,{stream:!0})),s){m+=y.decode();break}const O=m.replace(/^\s+/,"");if(O){if(O[0]==="[")return{format:"json",seed:m,bytes:w};if(O[0]!=="{"||m.indexOf(`
8
8
  `)!==-1)break}}const v=t(m.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${p} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:m,bytes:w}}function t(g){if(!g||g[0]==="[")return"json";if(g[0]!=="{")return"error";const y=g.indexOf(`
9
9
  `);if(y===-1)return"json";let p=g.slice(0,y);return p.endsWith("\r")&&(p=p.slice(0,-1)),n(p)?"ndjson":"json"}function n(g){try{return JSON.parse(g),!0}catch{return!1}}async function i(g,y,p){let m=p;for(;;){const{value:w,done:v}=await g.read();if(w&&(m+=y.decode(w,{stream:!0})),v)break}return m+=y.decode(),m}function*o(g,y,p,m){let w;try{w=JSON.parse(g)}catch(u){throw new Error(`[lattice] createUrlSource: ${y} is not valid JSON — ${u.message}`)}let v=p!==void 0?W(w,p):w;if(m&&(v=m(v)),!Array.isArray(v)){const u=p!==void 0||m?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${y} did not resolve to an array${u}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*c(g,y,p,m,w,v,u,s){const O=h(w);let E=p||"",A=m||0,M=0,C=0,P=[];function*D(){let x;for(;(x=E.indexOf(`
@@ -53,6 +53,6 @@ ${re}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
53
53
  `);return C===E?!1:(y.value=p.slice(0,s)+C+p.slice(O),this.#r(Math.max(s,m+(g?-v.length:v.length)),Math.max(s,w+M)),this.revalidate(),!0)}#r(g,y){const p=this.input;p&&(p.selectionStart=g,p.selectionEnd=y===void 0?g:y,H(p.setSelectionRange)&&p.setSelectionRange(p.selectionStart,p.selectionEnd))}format(g){const y=this.input;if(!y||this.language!=="json")return!1;const p=r(y.value);if(!p.ok)return this.revalidate(),!1;if(p.value===null&&y.value.trim()==="")return!1;try{const m=JSON.stringify(p.value,null,g===void 0?this.indent:g);return m===void 0?!1:(y.value=m,this.#r(m.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const g=this.input?this.input.value:"",y=o(g,this.language);this.lastResult=y;const p=this.errorNode;return p&&(p.textContent=y.ok?"":c(y),p.classList.toggle(k.errorOn,!y.ok)),this.input&&(y.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),y.ok||!p?this.input.removeAttribute("aria-errormessage"):(p.id||(p.id=U("lat-err")),this.input.setAttribute("aria-errormessage",p.id))),y}text(){return this.input?this.input.value:""}readValue(){const g=this.text();if(g.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return g;const p=r(g);return p.ok?p.value:g}checkValue(g){if(this.props.allowInvalid===!0)return!0;const y=this.revalidate();return y.ok?!0:c(y)}toClipboard(){return this.text()}fromClipboard(g){const y=g==null?"":String(g);return this.input&&(this.input.value=y),this.revalidate(),y.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:y}:{ok:!0,value:F(y)}}destroy(){for(const g of this.#e)g();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const f=d}),Se("packages/dom/src/editors/unit.js",function(e,V){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/core/src/internal/util.js").isFunction,U=V("packages/core/src/columns/types/unit.js"),z=U.parseUnit,F=U.formatUnit,k=U.findUnit;function S(l,r){return F(l,r)}class b extends N{input=null;hint=null;opts=null;#e=[];buildOptions(){const r=this.props,t=this.params.column&&this.params.column.dataType||null,n=t&&t.unitConfig||{};return{system:r.system||n.system||"data",unit:r.unit??n.unit,binary:r.binary===!0||r.binary===void 0&&n.binary===!0,display:r.display??n.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const r=this.props;this.opts=this.buildOptions();const t=this.symbol(),n=`${this.id}-unit`,i=L(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?n:null}});i.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const o=typeof r.step=="number"?r.step:0;return o>0&&this.#e.push(W(i,"keydown",c=>{c.key==="ArrowUp"?(H(c.preventDefault)&&c.preventDefault(),this.nudge(o)):c.key==="ArrowDown"&&(H(c.preventDefault)&&c.preventDefault(),this.nudge(-o))})),this.hint=L(this.doc,"span",{class:`${$.editor}__suffix`,text:t,attrs:{id:n,"aria-hidden":"true"}}),L(this.doc,"div",{class:`${$.editor}__unit`,children:[i,this.hint]})}symbol(){const r=k(this.opts.system,this.opts.unit);return r?r.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&H(r.select)&&r.select()}nudge(r){const t=z(this.input?this.input.value:"",this.opts);let n=(t??0)+r;const{min:i,max:o}=this.props;typeof i=="number"&&n<i&&(n=i),typeof o=="number"&&n>o&&(n=o),this.input&&(this.input.value=S(n,this.opts))}readValue(){const r=this.input?this.input.value:"";if(String(r).trim()==="")return null;const t=z(r,this.opts);if(t===null)return NaN;if(this.mode()!=="clamp")return t;const{min:n,max:i}=this.props;let o=t;return typeof n=="number"&&o<n&&(o=n),typeof i=="number"&&o>i&&(o=i),o}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(r){if(r===null)return!0;if(typeof r!="number"||Number.isNaN(r)){const t=this.symbol();return t?`Enter a value such as 10 ${t}`:"Enter a value"}if(this.mode()==="reject"){const{min:t,max:n}=this.props;if(typeof t=="number"&&r<t)return`Must be ${this.describe(t)} or more`;if(typeof n=="number"&&r>n)return`Must be ${this.describe(n)} or less`}return!0}describe(r){return F(r,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return F(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(r){const t=r==null?"":String(r);if(t.trim()==="")return{ok:!0,value:null};const n=z(t,this.opts),i=n===null?NaN:n,o=this.checkValue(i);return o!==!0?{ok:!1,message:o}:{ok:!0,value:i}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const a=b}),Se("packages/dom/src/editors/radix.js",function(e,V){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=V("packages/core/src/internal/util.js"),H=Z.isFunction,U=Z.uid,z=V("packages/core/src/columns/types/radix.js"),F=z.compileRadixFormat,k=z.compileRadixParse,S=z.normaliseRadixOptions,b=z.radixRange,a=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),l=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),r=new Map;function t(c){const d=c||"";let f=r.get(d);if(f)return f;try{f=new Intl.NumberFormat(c||void 0,{maximumFractionDigits:0})}catch{f={format:h=>String(h)}}return r.set(d,f),f}function n(c,d){const f=d||{},h={};if(c){for(const y of l)c[y]!==void 0&&(h[y]=c[y]);const g=b(c.bitWidth??null,c.signed!==!1);typeof c.min=="number"&&c.min>g.min&&(h.min=c.min),typeof c.max=="number"&&c.max<g.max&&(h.max=c.max)}for(const g of l)f[g]!==void 0&&(h[g]=f[g]);return typeof f.min=="number"&&(h.min=f.min),typeof f.max=="number"&&(h.max=f.max),S(h)}class i extends N{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const d=this.params.column&&this.params.column.dataType;this.options=n(d&&d.radix||null,this.props),this.format=F(this.options),this.parse=k(this.options);const f=L(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});f.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(f.value=this.params.key),this.input=f;const h=L(this.doc,"span",{class:a.hint,attrs:{"aria-live":"polite"}});this.hint=h,this.#e.push(W(f,"input",()=>this.refresh())),this.#e.push(W(f,"keydown",y=>this.#n(y)));const g=L(this.doc,"div",{class:a.root,children:[f,h]});return this.refresh(),g}focusTarget(){return this.input}attached(){super.attached();const d=this.input;d&&!this.params.key&&this.props.selectOnFocus!==!1&&H(d.select)&&d.select()}#t(d){return d.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(d)}#n(d){const f=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;d.key==="ArrowUp"?(H(d.preventDefault)&&d.preventDefault(),this.nudge(f)):d.key==="ArrowDown"&&(H(d.preventDefault)&&d.preventDefault(),this.nudge(-f))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(d){const{min:f,max:h}=this.options;return d<f?f:d>h?h:d}evaluate(){const d=this.input?String(this.input.value):"";if(d.trim()==="")return{value:null,message:null};const f=this.parse(d);return f.ok?{value:this.mode()==="clamp"?this.clamp(f.value):f.value,message:null}:this.mode()==="clamp"&&typeof f.value=="number"&&(f.reason==="range"||f.reason==="negative")?{value:this.clamp(f.value),message:null}:{value:NaN,message:this.messageFor(f.reason)}}messageFor(d){const f=this.options;return d==="negative"?`This column holds an unsigned ${f.bitWidth}-bit pattern; enter ${this.format(0)} or more`:d==="range"?`Must be between ${this.format(f.min)} and ${this.format(f.max)}`:`Enter a ${f.name} value, e.g. ${this.format(f.radix===2?5:26)}`}refresh(){const{value:d,message:f}=this.evaluate();if(this.input&&this.input.classList&&(f?this.input.classList.add($.invalid):this.input.classList.remove($.invalid),this.input.setAttribute("aria-invalid",f?"true":"false"),f&&this.hint?(this.hint.id||(this.hint.id=U("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(f){this.hint.textContent=f,this.hint.classList&&this.hint.classList.add(a.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(a.hintInvalid),this.hint.textContent=d===null?"":`= ${t(this.params.locale).format(d)}`}}nudge(d){if(!this.input)return;const f=this.parse(this.input.value);let h;typeof f.value=="number"?h=f.value:typeof this.params.value=="number"?h=this.params.value:h=0,this.input.value=this.format(this.clamp(h+d)),this.refresh()}readValue(){return this.evaluate().value}checkValue(d){return d===null?!0:typeof d!="number"||Number.isNaN(d)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&d<0?this.messageFor("negative"):this.mode()==="reject"&&(d<this.options.min||d>this.options.max)?this.messageFor("range"):!0}toClipboard(){const d=this.readValue();return d===null||Number.isNaN(d)?this.input?String(this.input.value):"":this.format(d)}fromClipboard(d){const f=d==null?"":String(d);if(f.trim()==="")return{ok:!0,value:null};const h=this.parse(f);let g;if(h.ok)g=h.value;else if(this.mode()==="clamp"&&typeof h.value=="number"&&(h.reason==="range"||h.reason==="negative"))g=this.clamp(h.value);else return{ok:!1,message:this.messageFor(h.reason)};const y=this.checkValue(g);return y!==!0?{ok:!1,message:y}:{ok:!0,value:g}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const o=i}),Se("packages/dom/src/editors/segmented.js",function(e,V){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=_.keyOf,H=_.normaliseLookup,U=_.documentFor,z=_.lookupFor,k=V("packages/dom/src/editors/select.js").SelectEditor,b=V("packages/core/src/internal/util.js").isFunction,l=V("packages/dom/src/cell/icons.js").createIcon,r=6;class t extends N{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(c){const d=c||{},f=n(d),h=z(d,f,{colId:d.column&&(d.column.id||d.column.field)}),g=Number(f.max??r),y=h.options().length;if(Number.isFinite(g)&&y>g){const p=new k;p.init(d),this.#e=p,this.params=d,this.doc=U(d),this.props=f,this.lookup=h,this.popup=p.popup;return}super.init(d),(!this.lookup||!this.lookup.options().length)&&(this.lookup=h)}usesFallback(){return this.#e!==null}build(){const c=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const d=L(c,"div",{class:`${$.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let f=0;f<this.options.length;f++)d.appendChild(this.buildSegment(this.options[f],f));return this.props.allowClear===!0&&d.appendChild(this.buildClear()),this.#t.push(W(d,"keydown",f=>this.onKeyDown(f))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),d}buildSegment(c,d){const f=this.doc,h=L(f,"button",{class:`${$.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":d,"data-variant":c.variant??null,"aria-disabled":c.disabled===!0?"true":null}});return c.icon&&h.appendChild(l(f,c.icon,{className:$.icon})),h.appendChild(L(f,"span",{class:`${$.editor}__segment-label`,text:c.label})),this.#t.push(W(h,"mousedown",g=>{g&&b(g.preventDefault)&&g.preventDefault(),c.disabled!==!0&&(this.focused=d,this.select(d,{commit:!0}))})),this.segments.push(h),h}buildClear(){const c=L(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(c,"mousedown",d=>{d&&b(d.preventDefault)&&d.preventDefault(),this.clearSelection()})),c}indexOf(c){if(c==null)return-1;const d=Z(c);for(let f=0;f<this.options.length;f++)if(Z(this.options[f].id)===d)return f;return-1}paint(){for(let c=0;c<this.segments.length;c++){const d=c===this.indexOf(this.selected),f=this.segments[c];f.setAttribute("aria-checked",d?"true":"false"),f.setAttribute("tabindex",c===this.focused?"0":"-1"),f.classList.toggle(`${$.editor}__segment--active`,d),f.classList.toggle(`${$.editor}__segment--disabled`,this.options[c].disabled===!0)}}select(c,d){const f=this.options[c];!f||f.disabled===!0||(this.selected=f.id,this.paint(),d&&d.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(c){const d=this.segments.length;if(!d)return;let f=this.focused;for(let h=0;h<d;h++)if(f=(f+c+d)%d,this.options[f].disabled!==!0){this.focusAt(f);return}}focusAt(c){if(c<0||c>=this.segments.length)return;this.focused=c,this.paint();const d=this.segments[c];d&&b(d.focus)&&d.focus()}edgeIndex(c){const d=this.options.length;for(let f=0;f<d;f++){const h=c===1?f:d-1-f;if(this.options[h].disabled!==!0)return h}return-1}onKeyDown(c){const d=()=>{b(c.preventDefault)&&c.preventDefault()};switch(c.key){case"ArrowRight":case"ArrowDown":d(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":d(),this.moveFocus(-1);break;case"Home":d(),this.focusAt(this.edgeIndex(1));break;case"End":d(),this.focusAt(this.edgeIndex(-1));break;case"Enter":d(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":d(),this.select(this.focused);break;case"Escape":d(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(d(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(c){return c==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(c)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(c)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const c=this.indexOf(this.selected);return this.segments[c>=0?c:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const c=this.lookup.ready();!c||!b(c.then)||c.then(()=>{if(!super.element()||this.options.length)return;const d=super.element();this.options=this.lookup.options();for(let f=0;f<this.options.length;f++)d.appendChild(this.buildSegment(this.options[f],f));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(c){return this.#e?this.#e.validate(c):super.validate(c)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(c){return this.#e?this.#e.fromClipboard(c):super.fromClipboard(c)}destroy(){for(const c of this.#t)c();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function n(o){return{...o.column&&o.column.edit&&o.column.edit.props||{},...o.props||{}}}const i=t}),Se("packages/dom/src/editors/rating.js",function(e,V){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/dom/src/cell/icons.js").createIcon,U=V("packages/dom/src/cell/renderers/rating.js"),z=U.ratingFills,F=U.fillState,k=U.ratingText,S=U.clampRating,b=U.DEFAULT_RATING_ICON,a=U.DEFAULT_RATING_MAX,r=V("packages/core/src/internal/util.js").isFunction;class t extends N{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const c=Math.floor(Number(this.props.max??a));return Number.isFinite(c)&&c>0?c:a}step(){return this.props.allowHalf===!0?.5:1}build(){const c=this.doc,d=this.max();this.rating=n(this.params.value,d,this.props.allowHalf===!0);const f=L(c,"div",{class:`${$.editor}__rating`}),h=L(c,"div",{class:`${$.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(d),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let y=0;y<d;y++)h.appendChild(this.buildItem(y));f.appendChild(h),this.slider=h;const g=L(c,"span",{class:`${$.editor}__rating-value`});return f.appendChild(g),this.readout=g,this.props.allowClear===!0&&f.appendChild(this.buildClear()),this.#e.push(W(h,"keydown",y=>this.onKeyDown(y))),this.props.hoverPreview!==!1&&this.#e.push(W(h,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),d)),this.paint(),f}buildItem(c){const d=this.doc,f=String(this.props.icon??b),h=L(d,"span",{class:`${$.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[H(d,f,{className:$.icon})]}),g=L(d,"span",{class:`${$.editor}__rating-item`,attrs:{"data-index":c,"data-icon":f,"aria-hidden":"true"},children:[H(d,f,{className:$.icon}),h]});return this.fills.push(h),this.#e.push(W(g,"mousedown",y=>{y&&r(y.preventDefault)&&y.preventDefault(),this.setRating(this.ratingAt(c,y),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(g,"mousemove",y=>{const p=this.ratingAt(c,y);p!==this.preview&&(this.preview=p,this.paint())})),this.items.push(g),g}buildClear(){const c=L(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(c,"mousedown",d=>{d&&r(d.preventDefault)&&d.preventDefault(),this.setRating(null)})),c}ratingAt(c,d){if(this.props.allowHalf!==!0)return c+1;const f=this.items[c],h=f&&Number(f.offsetWidth),g=d&&Number(d.offsetX);return!Number.isFinite(h)||h<=0||!Number.isFinite(g)?c+1:g*2<h?c+.5:c+1}focusTarget(){return this.slider}setRating(c,d){this.rating=c===null?null:S(c,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),d&&d.commit&&this.commit()}nudge(c){const d=this.rating===null?0:this.rating;this.setRating(d+c)}paint(){const c=this.max(),d=this.props.allowHalf===!0,f=this.preview===null?this.rating:this.preview,h=z(f===null?0:f,c,{allowHalf:d});for(let p=0;p<this.items.length;p++){const m=F(h[p]);this.items[p].setAttribute("data-fill",m),this.items[p].classList.toggle(`${$.editor}__rating-item--filled`,m!=="empty"),this.fills[p]&&this.fills[p].style.setProperty("--lat-rating-fill",`${(h[p]*100).toFixed(2)}%`)}const g=f===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:k(f),max:c}),y=this.slider;y&&(y.setAttribute("aria-valuenow",f===null?"0":String(f)),y.setAttribute("aria-valuetext",g),y.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=g)}onKeyDown(c){const d=()=>{r(c.preventDefault)&&c.preventDefault()},f=this.step();if(/^[0-9]$/.test(c.key)){d(),this.setRating(Math.min(Number(c.key),this.max()));return}switch(c.key){case"ArrowRight":case"ArrowUp":d(),this.nudge(f);break;case"ArrowLeft":case"ArrowDown":d(),this.nudge(-f);break;case"Home":d(),this.setRating(0);break;case"End":d(),this.setRating(this.max());break;case"Enter":d(),this.commit();break;case"Escape":d(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(d(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(c){if(c==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof c!="number"||!Number.isFinite(c))return"Enter a rating";const d=this.max();return c<0?"Must be 0 or more":c>d?`Must be ${d} or less`:this.props.allowHalf!==!0&&!Number.isInteger(c)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":k(this.rating)}fromClipboard(c){const d=String(c??"").trim();if(d==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const f=Number(d);if(!Number.isFinite(f))return{ok:!1,message:`"${d}" is not a rating`};const h=this.checkValue(f);return h!==!0?{ok:!1,message:h}:{ok:!0,value:f}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function n(o,c,d){if(o==null||o==="")return null;const f=Number(o);return Number.isFinite(f)?S(f,c,d,!1):null}const i=t}),Se("packages/dom/src/editors/slider.js",function(e,V){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=V("packages/dom/src/editors/number.js"),H=Z.parseNumberText,U=Z.presentNumber,F=V("packages/core/src/internal/util.js").isFunction,k=0,S=100;class b extends N{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const i=Number(this.props.min??k);return Number.isFinite(i)?i:k}max(){const i=Number(this.props.max??S);return Number.isFinite(i)?i:S}step(){const i=Number(this.props.step??1);return Number.isFinite(i)&&i>0?i:1}build(){const i=this.doc,o=this.min(),c=this.max(),d=this.step(),f=r(this.props.marks);this.marks=f,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const h=L(i,"div",{class:`${$.editor}__slider`});this.root=h;const g=L(i,"input",{class:`${$.editor}__slider-input`,attrs:{type:"range",min:String(o),max:String(c),step:String(d),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:f.length?`${this.id}-marks`:null}});if(this.range=g,h.appendChild(g),f.length){const p=L(i,"datalist",{attrs:{id:`${this.id}-marks`}}),m=L(i,"div",{class:`${$.editor}__slider-marks`});for(const w of f){p.appendChild(L(i,"option",{attrs:{value:String(w.value),label:w.label}}));const v=L(i,"span",{class:`${$.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});v.style&&F(v.style.setProperty)&&v.style.setProperty("--lat-slider-mark",`${(a(w.value,o,c)*100).toFixed(2)}%`),m.appendChild(v)}h.appendChild(p),h.appendChild(m)}const y=L(i,"input",{class:`${$.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=y,h.appendChild(y),this.props.showValue!==!1){const p=L(i,"span",{class:`${$.editor}__slider-value`});h.appendChild(p),this.readout=p}return this.#e.push(W(g,"input",()=>this.setAmount(Number(g.value),"range"))),this.#e.push(W(g,"change",()=>this.setAmount(Number(g.value),"range"))),this.#e.push(W(g,"keydown",p=>this.onKeyDown(p))),this.#e.push(W(y,"input",()=>this.onFieldInput())),this.#e.push(W(y,"change",()=>this.paint())),this.#e.push(W(y,"keydown",p=>this.onKeyDown(p))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(y.value=this.params.key,this.onFieldInput()),this.paint(),h}focusTarget(){return this.field}attached(){super.attached();const i=this.field;i&&!this.params.key&&this.props.selectOnFocus!==!1&&F(i.select)&&i.select()}snap(i){if(!Number.isFinite(i))return this.min();const o=this.min(),c=this.max(),d=this.step(),f=Math.min(Math.max(i,o),c),h=o+Math.round((f-o)/d)*d,g=l(d),y=g>0?Number(h.toFixed(g)):Math.round(h);return Math.min(Math.max(y,o),c)}setAmount(i,o){this.amount=i===null?null:this.snap(i),this.paint(o)}onFieldInput(){const i=this.field?String(this.field.value):"";if(i.trim()===""){this.amount=null,this.paint("field");return}const o=H(i,this.params.locale);if(o===null||Number.isNaN(o)){this.paint("field");return}this.setAmount(o,"field")}paint(i){const o=this.min(),c=this.max(),d=this.amount,f=d===null?o:d;this.range&&i!=="range"&&(this.range.value=String(f)),this.field&&i!=="field"&&(this.field.value=d===null?"":U(d,this.props));const h=this.root;h&&h.style&&F(h.style.setProperty)&&h.style.setProperty("--lat-slider-pos",`${(a(f,o,c)*100).toFixed(2)}%`),h&&h.setAttribute&&h.setAttribute("data-empty",d===null?"true":"false");const g=this.labelFor(d);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",g),this.readout&&(this.readout.textContent=g)}labelFor(i){if(i===null)return String(this.props.emptyLabel??"");const o=this.marks.find(d=>d.value===i),c=U(i,this.props);return o&&o.label!==c?`${c} (${o.label})`:c}onKeyDown(i){if(i.key==="Escape"){F(i.preventDefault)&&i.preventDefault(),this.cancel();return}if(i.key==="Enter"){F(i.preventDefault)&&i.preventDefault(),this.commit();return}i.key==="Tab"&&this.commit()}readValue(){const i=this.field?String(this.field.value):"";if(i.trim()==="")return null;const o=H(i,this.params.locale);return o===null||Number.isNaN(o)?NaN:this.snap(o)}checkValue(i){return i==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof i!="number"||Number.isNaN(i)?"Enter a number":i<this.min()?`Must be ${this.min()} or more`:i>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(i){const o=String(i??"").trim();if(o==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const c=H(o,this.params.locale);if(c===null||Number.isNaN(c))return{ok:!1,message:"Enter a number"};const d=this.snap(c),f=this.checkValue(d);return f!==!0?{ok:!1,message:f}:{ok:!0,value:d}}destroy(){for(const i of this.#e)i();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function a(n,i,o){const c=o-i;return!Number.isFinite(c)||c===0?0:Math.min(1,Math.max(0,(Number(n)-i)/c))}function l(n){if(!Number.isFinite(n))return 0;const i=String(n),o=i.indexOf("e");if(o>=0){const d=i.slice(0,o),f=d.indexOf("."),h=f<0?0:d.length-f-1;return Math.min(15,Math.max(0,h-Number(i.slice(o+1))))}const c=i.indexOf(".");return c<0?0:Math.min(15,i.length-c-1)}function r(n){if(!n)return[];const i=[];if(Array.isArray(n)){for(const o of n){if(o&&typeof o=="object"){const d=Number(o.value);Number.isFinite(d)&&i.push({value:d,label:String(o.label??d)});continue}const c=Number(o);Number.isFinite(c)&&i.push({value:c,label:String(c)})}return i}if(typeof n=="object")for(const[o,c]of Object.entries(n)){const d=Number(o);Number.isFinite(d)&&i.push({value:d,label:String(c)})}return i}const t=b}),Se("packages/dom/src/editors/colour.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,Z=V("packages/dom/src/cell/renderers/colour.js"),H=Z.normaliseColour,U=Z.parseColour,F=V("packages/core/src/internal/util.js").isFunction,k=Object.freeze(["neutral","info","success","warning","danger","accent"]),S=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function b(i){if(i==null)return null;if(typeof i=="object"){const d=i,f=b(d.token??d.value??d.colour??d.color);return f?{...f,label:d.label==null?f.label:String(d.label)}:null}const o=String(i).trim();if(o==="")return null;const c=H(o);return c?{token:null,hex:c,label:c}:Object.hasOwn(S,o)?{token:o,hex:S[o],label:o}:null}function a(i,o){const c=i&&i.ownerDocument,d=c&&c.defaultView;if(!d||!F(d.getComputedStyle))return null;try{const f=d.getComputedStyle(i);return!f||!F(f.getPropertyValue)?null:H(String(f.getPropertyValue(`--lattice-variant-${o}-solid`)).trim())}catch{return null}}class l extends N{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=r(this.props.swatches);const c=L(o,"div",{class:`${$.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=L(o,"span",{class:`${$.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),c.appendChild(this.preview),this.swatches.length){const f=L(o,"div",{class:`${$.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let h=0;h<this.swatches.length;h++)f.appendChild(this.buildSwatch(this.swatches[h],h));c.appendChild(f)}this.native=L(o,"input",{class:`${$.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),c.appendChild(this.native),this.hex=L(o,"input",{class:`${$.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),c.appendChild(this.hex),this.props.allowClear===!0&&c.appendChild(this.buildClear()),this.#e.push(W(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.hex,"input",()=>this.paint())),this.#e.push(W(this.hex,"change",()=>this.paint())),this.#e.push(W(this.hex,"keydown",f=>this.onKeyDown(f))),this.#e.push(W(c,"keydown",f=>this.onKeyDown(f)));const d=H(this.params.value,{alpha:this.alpha()});return this.hex.value=d===null?this.params.value==null?"":String(this.params.value):d,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),c}buildSwatch(o,c){const d=L(this.doc,"button",{class:`${$.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":o.label,"data-index":c,"data-variant":o.token}});return o.token||t(d,o.hex),this.#e.push(W(d,"mousedown",f=>{f&&F(f.preventDefault)&&f.preventDefault(),this.setColour(this.swatches[c].hex)})),this.buttons.push(d),d}buildClear(){const o=L(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(o,"mousedown",c=>{c&&F(c.preventDefault)&&c.preventDefault(),this.setColour(null)})),o}focusTarget(){return this.hex}attached(){super.attached();for(let o=0;o<this.swatches.length;o++){const c=this.swatches[o];if(!c.token)continue;const d=a(this.buttons[o]||this.element(),c.token);d&&(c.hex=d)}this.paint()}setColour(o){const c=o===null?null:H(o,{alpha:this.alpha()});this.hex&&(this.hex.value=c===null?"":c),this.paint()}current(){const o=this.hex?String(this.hex.value).trim():"";return o===""?null:H(o,{alpha:this.alpha()})}paint(){const o=this.current(),c=o===null?null:o.slice(0,7);t(this.preview,c),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",o===null?"true":"false"),this.native&&(this.native.value=c===null?"#000000":c);for(let d=0;d<this.buttons.length;d++){const f=o!==null&&this.swatches[d].hex.toLowerCase()===o.toLowerCase();this.buttons[d].setAttribute("aria-checked",f?"true":"false"),this.buttons[d].classList.toggle(`${$.editor}__colour-swatch--selected`,f),this.swatches[d].token||t(this.buttons[d],this.swatches[d].hex)}}onKeyDown(o){if(o.key==="Escape"){F(o.preventDefault)&&o.preventDefault(),this.cancel();return}if(o.key==="Enter"){F(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 c=H(o,{alpha:this.alpha()});return c===null?o:c}checkValue(o){if(o==null||o==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const c=U(o);return c?!this.alpha()&&c.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 c=String(o??"").trim();if(c==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const d=H(c,{alpha:this.alpha()});if(d===null)return{ok:!1,message:`"${c}" is not a colour`};const f=this.checkValue(d);return f!==!0?{ok:!1,message:f}:{ok:!0,value:d}}destroy(){for(const 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 r(i){const o=Array.isArray(i)&&i.length?i:i===!1?[]:k,c=[];for(const d of o){const f=b(d);f&&c.push(f)}return c}function t(i,o){const c=i&&i.style;if(c){if(o===null){F(c.removeProperty)&&c.removeProperty("--lat-swatch");return}F(c.setProperty)&&c.setProperty("--lat-swatch",o)}}const n=l}),Se("packages/dom/src/editors/treeselect.js",function(e,V){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const N=V("packages/dom/src/editors/select.js").SelectEditorBase,L=V("packages/dom/src/cell/icons.js").createIcon,W=V("packages/dom/src/editors/common.js"),Z=W.CLS,H=W.el,U=W.on,z=W.clear,F=W.keyOf,k=W.rawOptions,S=W.lookupKey,b=V("packages/core/src/internal/util.js"),a=b.isFunction,l=b.isObject,r="\0";class t extends N{static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const 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 c=o.parent;c;c=c.parent)this.expanded.add(c.key)}rebuild(){const o=k(this.params,this.props),c=this.props.keys||{},d=c.value||S(this.params,"valueKey")||"id",f=c.label||S(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const h of o){if(!l(h)){this.addNode(null,String(h??""),h,null);continue}Array.isArray(h.path)&&h.path.length?this.addByPath(h,d,f):this.addByChildren(h,null,d,f)}if(this.props.defaultExpanded===!0)for(const h of this.nodes.keys())this.expanded.add(h)}addNode(o,c,d,f){const h=o?`${o.key}${r}${c}`:c;let g=this.nodes.get(h);return g?g.id===void 0&&d!==void 0&&(g.id=d):(g={id:d,label:c,key:h,parent:o,children:[],depth:o?o.depth+1:0,disabled:!1},this.nodes.set(h,g),(o?o.children:this.roots).push(g)),f&&(f.disabled===!0&&(g.disabled=!0),f.icon!==void 0&&(g.icon=f.icon),f.variant!==void 0&&(g.variant=f.variant)),g}addByPath(o,c,d){const f=o.path;let h=null;for(let g=0;g<f.length;g++){const y=g===f.length-1,p=String(f[g]),m=y&&o[d]!=null?String(o[d]):p,w=this.addNode(h,p,y?o[c]:void 0,y?o:null);y&&(w.label=m),h=w}}addByChildren(o,c,d,f){const h=o[d],g=o[f]!=null?String(o[f]):String(h??""),y=this.addNode(c,g,h,o),p=Array.isArray(o.children)?o.children:[];for(const m of p)l(m)?this.addByChildren(m,y,d,f):this.addNode(y,String(m??""),m,null)}nodeById(o){if(o==null)return;const c=F(o);for(const d of this.nodes.values())if(d.id!==void 0&&F(d.id)===c)return d}filterOptions(o){const c=String(o||"").trim().toLowerCase(),d=c!=="";this.matched=d?this.computeMatches(c):new Set;const f=[],h=g=>{for(const y of g)d&&!this.matched.has(y.key)||(f.push(y),y.children.length&&(d||this.expanded.has(y.key))&&h(y.children))};return h(this.roots),f}computeMatches(o){const c=new Set,d=f=>{let h=f.label.toLowerCase().includes(o);for(const g of f.children)d(g)&&(h=!0);return h&&c.add(f.key),h};for(const f of this.roots)d(f);return c}repaint(o){if(this.refreshOptions(),!o||!this.list)return;const c=this.visible.findIndex(d=>d.key===o);c>=0&&this.list.setActive(c)}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,c){this.isBranch(o)&&(c?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&&F(o.id)===F(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 c=this.nodeById(o);return c&&this.isSelectable(c)?!0:c?`"${c.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(o)}" is not a valid option`}renderOption(o,c,d){z(c),c.setAttribute("role","treeitem"),c.setAttribute("aria-level",String(o.depth+1)),c.setAttribute("data-depth",String(o.depth));const f=H(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<o.depth;w++)f.appendChild(H(this.doc,"span",{class:"lat-tree__guide"}));c.appendChild(f);const h=this.isBranch(o),g=h&&(this.expanded.has(o.key)||this.query.trim()!==""),y=h?g?"chevronDown":"chevronRight":"blank",p=H(this.doc,"span",{class:h?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[L(this.doc,y,{className:Z.icon})],attrs:{"data-icon":h?y:null,"aria-hidden":"true"}});h&&U(p,"mousedown",w=>{a(w.preventDefault)&&w.preventDefault(),a(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(o,!this.expanded.has(o.key))}),c.appendChild(p),o.icon&&c.appendChild(L(this.doc,o.icon,{className:Z.icon})),c.appendChild(H(this.doc,"span",{class:`${Z.option}__label`,text:o.label})),o.variant?c.setAttribute("data-variant",o.variant):c.removeAttribute("data-variant"),h?c.setAttribute("aria-expanded",g?"true":"false"):c.removeAttribute("aria-expanded");const m=this.isSelected(o);c.classList.toggle(Z.optionSelected,m),c.classList.toggle(Z.optionDisabled,!this.isSelectable(o)),c.classList.toggle("lat-tree__row--branch",h),c.setAttribute("aria-selected",m?"true":"false"),this.isSelectable(o)?c.removeAttribute("aria-disabled"):c.setAttribute("aria-disabled","true")}paintDisplay(){const o=this.display;if(!o)return;if(z(o),this.selected==null){o.removeAttribute("data-variant");return}const c=this.nodeById(this.selected);if(!c){o.appendChild(H(this.doc,"span",{text:String(this.selected)}));return}c.icon&&o.appendChild(L(this.doc,c.icon,{className:Z.icon})),o.appendChild(H(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(c)})),c.variant?o.setAttribute("data-variant",c.variant):o.removeAttribute("data-variant")}pathLabel(o){const c=[];for(let d=o;d;d=d.parent)c.unshift(d.label);return c.join(String(this.props.pathSeparator??" / "))}onKeyDown(o){const c=this.list,d=c&&c.active>=0?this.visible[c.active]:null;switch(o.key){case"ArrowRight":{if(a(o.preventDefault)&&o.preventDefault(),!d)return;this.isBranch(d)&&!this.expanded.has(d.key)?this.setExpanded(d,!0):this.isBranch(d)&&c&&c.setActive(Math.min(this.visible.length-1,c.active+1));return}case"ArrowLeft":{if(a(o.preventDefault)&&o.preventDefault(),!d)return;this.isBranch(d)&&this.expanded.has(d.key)?this.setExpanded(d,!1):d.parent&&this.focusNode(d.parent.key);return}case"Home":a(o.preventDefault)&&o.preventDefault(),c&&this.visible.length&&c.setActive(0);return;case"End":a(o.preventDefault)&&o.preventDefault(),c&&this.visible.length&&c.setActive(this.visible.length-1);return;default:super.onKeyDown(o)}}focusNode(o){if(!this.list)return;const c=this.visible.findIndex(d=>d.key===o);c>=0&&this.list.setActive(c)}acceptHighlight(o){const c=this.list,d=c&&c.active>=0?this.visible[c.active]:null;if(!d){o&&o.commit&&this.commit();return}if(this.isSelectable(d)){this.choose(d);return}this.isBranch(d)?this.setExpanded(d,!this.expanded.has(d.key)):o&&o.commit&&this.commit()}moveHighlight(o){const c=this.list;if(!c)return;let d=c.active;for(let f=0;f<this.visible.length;f++){if(d+=o,d<0||d>=this.visible.length)return;if(!this.visible[d].disabled){c.setActive(d);return}}}}const n=t}),Se("packages/dom/src/editors/objectpicker.js",function(e,V){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const N=V("packages/dom/src/editors/select.js").SelectEditorBase,$=V("packages/dom/src/editors/common.js"),L=$.CLS,W=$.el,Z=$.on,H=$.clear,U=$.keyOf,z=$.debounce,F=$.rawOptions,k=$.optionSource,S=$.lookupSearch,b=$.lookupKey,a=V("packages/core/src/internal/util.js"),l=a.isFunction,r=a.isObject,t=a.getPath,i=V("packages/dom/src/cell/icons.js").createIcon;class o extends N{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const y=super.build();if(y.classList.add("lat-objectpicker"),l(this.props.search)&&!(this.lookup&&this.lookup.search)){const p=Number(this.props.searchDebounce)||200;this.#n=z(m=>this.runRemoteSearch(String(m)),p)}return y}onQuery(y){super.onQuery(y),this.#n&&this.#n(y)}initSelection(){const y=F(this.params,this.props).map(p=>this.toOption(p));(y.length||!this.all.length)&&(this.all=y),this.selected=this.params.value??null}toOption(y){if(!r(y)){const s=y==null?"":String(y);return{id:y,label:s,secondary:"",avatar:"",initials:d(s),disabled:!1,raw:{}}}const p=this.props.valueKey||b(this.params,"valueKey")||"id",m=this.props.labelKey||b(this.params,"labelKey")||"label",w=c(y,this.props.template??m,""),v=c(y,this.props.secondary,""),u=c(y,this.props.avatar,"");return{id:y[p],label:w||String(y[p]??""),secondary:v,avatar:u,initials:d(w||String(y[p]??"")),disabled:y.disabled===!0,icon:y.icon,variant:y.variant,raw:y}}attached(){if(super.attached(),this.#t||this.all.length)return;const y=k(this.params,this.props);l(y)&&(this.#t=!0,Promise.resolve(y()).then(p=>{!this.element()||!Array.isArray(p)||(this.all=p.map(m=>this.toOption(m)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(y){const p=String(y||"").trim().toLowerCase();if(p==="")return this.all;const m=f(this.props.searchFields);return this.all.filter(w=>{if(!m)return w.label.toLowerCase().includes(p)||w.secondary.toLowerCase().includes(p);for(const v of m){const u=l(v)?v(w.raw):t(w.raw,v);if(u!=null&&String(u).toLowerCase().includes(p))return!0}return!1})}async runRemoteSearch(y){const p=S(this.params,this.props);if(!p)return;this.#e&&this.#e.abort();const m=new AbortController;this.#e=m;try{const w=await p(y,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(y){!y||y.disabled||(this.selected=y.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(y){return this.selected!=null&&y!=null&&U(y.id)===U(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(y){if(y==null)return;const p=U(y);return this.all.find(m=>U(m.id)===p)}checkValue(y){return y==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(y)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(y)}" is not a valid option`}renderOption(y,p,m){H(p),p.appendChild(this.buildAvatar(y));const w=W(this.doc,"span",{class:"lat-object__text"});w.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:y.label})),y.secondary&&w.appendChild(W(this.doc,"span",{class:"lat-object__secondary",text:y.secondary})),p.appendChild(w),y.icon&&p.appendChild(i(this.doc,y.icon,{className:L.icon})),y.variant?p.setAttribute("data-variant",y.variant):p.removeAttribute("data-variant");const v=this.isSelected(y);p.classList.add("lat-object__row"),p.classList.toggle(L.optionSelected,v),p.classList.toggle(L.optionDisabled,y.disabled===!0),p.setAttribute("aria-selected",v?"true":"false"),y.disabled?p.setAttribute("aria-disabled","true"):p.removeAttribute("aria-disabled")}buildAvatar(y){const p=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!y.avatar)return p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:y.initials})),p.setAttribute("data-fallback","initials"),p;const m=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:y.avatar,alt:"",loading:"lazy",decoding:"async"}});return Z(m,"error",()=>{m.parentNode===p&&(p.removeChild(m),p.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:y.initials})),p.setAttribute("data-fallback","initials"))}),p.appendChild(m),p}paintDisplay(){const y=this.display;if(!y)return;if(H(y),this.selected==null){y.removeAttribute("data-variant");return}const p=this.optionById(this.selected);if(!p){y.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}y.appendChild(this.buildAvatar(p)),y.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:p.label})),p.variant?y.setAttribute("data-variant",p.variant):y.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function c(g,y,p){if(y==null)return p;const m=l(y)?y(g):t(g,String(y));return m==null?p:String(m)}function d(g){const y=String(g||"").trim().split(/\s+/).filter(w=>w!=="");if(!y.length)return"";const p=[...y[0]][0]||"";if(y.length===1)return p.toUpperCase();const m=[...y[y.length-1]][0]||"";return(p+m).toUpperCase()}function f(g){if(g==null)return null;const p=(Array.isArray(g)?g:[g]).filter(m=>typeof m=="string"||l(m));return p.length?p:null}const h=o}),Se("packages/dom/src/editors/iconpicker.js",function(e,V){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.VirtualList,W=_.el,Z=_.on,H=_.clear,U=V("packages/dom/src/cell/icons.js"),z=U.createIcon,F=U.iconNames,S=V("packages/core/src/internal/util.js").isFunction;class b extends N{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const t=this.props;this.columns=Math.max(1,Math.floor(Number(t.columns)||8)),this.names=a(t.icons),this.selected=this.params.value==null?null:String(this.params.value);const n=W(this.doc,"div",{class:["lat-iconpicker",`${$.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${$.editor}__display`}),this.input=W(this.doc,"input",{class:$.input,attrs:{type:"text",autocomplete:"off",placeholder:t.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new L({document:this.doc,itemHeight:Number(t.rowHeight)||34,height:Number(t.listHeight)||204,renderItem:(i,o,c)=>this.renderRow(i,o,c)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),n.appendChild(this.display),n.appendChild(this.input),t.allowClear===!0&&n.appendChild(this.buildClearButton()),n.appendChild(this.list.element()),this.off.push(Z(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(Z(this.input,"keydown",i=>this.onKeyDown(i))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),n}buildClearButton(){const t=W(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(Z(t,"mousedown",n=>{S(n.preventDefault)&&n.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),t}focusTarget(){return this.input}onQuery(t){this.query=t,this.refreshIcons()}refreshIcons(){const t=this.query.trim().toLowerCase();this.matches=t===""?this.names.slice():this.names.filter(i=>i.toLowerCase().includes(t)),this.rows=[];for(let i=0;i<this.matches.length;i+=this.columns)this.rows.push(this.matches.slice(i,i+this.columns));const n=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=n>=0?n:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(t){return t<0?-1:Math.floor(t/this.columns)}moveCursor(t){if(!this.matches.length)return-1;const n=Math.max(0,Math.min(this.matches.length-1,this.cursor+t));return this.setCursor(n)}setCursor(t){return this.cursor=t,this.list&&this.list.setActive(this.rowOf(t)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(t,n,i){n.setAttribute("role","row"),n.classList.add("lat-iconpicker__row");let o=n.__latIconCells;if(!o){o=[],H(n);for(let c=0;c<this.columns;c++){const d=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});Z(d,"mousedown",f=>{S(f.preventDefault)&&f.preventDefault();const h=d.getAttribute("data-icon");h&&this.choose(h)}),n.appendChild(d),o.push(d)}n.__latIconCells=o}for(let c=0;c<o.length;c++){const d=o[c],f=t[c];if(f===void 0){d.setAttribute("aria-hidden","true"),d.removeAttribute("data-icon"),d.removeAttribute("title"),d.removeAttribute("aria-label"),d.classList.add("lat-iconpicker__cell--empty"),d.classList.remove("lat-iconpicker__cell--active"),d.classList.remove("lat-iconpicker__cell--selected"),d.__latIconName!==void 0&&(H(d),d.__latIconName=void 0);continue}const h=i*this.columns+c;d.removeAttribute("aria-hidden"),d.classList.remove("lat-iconpicker__cell--empty"),d.setAttribute("data-icon",f),d.setAttribute("title",f),d.setAttribute("aria-label",f),d.__latIconName!==f&&(H(d),d.appendChild(z(this.doc,f,{className:$.icon})),d.__latIconName=f);const g=this.selected===f;d.classList.toggle("lat-iconpicker__cell--active",h===this.cursor),d.classList.toggle("lat-iconpicker__cell--selected",g),d.setAttribute("aria-selected",g?"true":"false")}}paintDisplay(){const t=this.display;if(t){if(H(t),this.selected==null){t.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}t.appendChild(z(this.doc,this.selected,{className:$.icon})),t.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(t){this.selected=t;const n=this.matches.indexOf(t);n>=0&&(this.cursor=n),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(t){return t==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(t))?!0:`"${String(t)}" is not a known icon name`}onKeyDown(t){const n=()=>{S(t.preventDefault)&&t.preventDefault()};switch(t.key){case"ArrowRight":n(),this.moveCursor(1);return;case"ArrowLeft":n(),this.moveCursor(-1);return;case"ArrowDown":n(),this.moveCursor(this.columns);return;case"ArrowUp":n(),this.moveCursor(-this.columns);return;case"PageDown":n(),this.moveCursor(this.columns*5);return;case"PageUp":n(),this.moveCursor(-this.columns*5);return;case"Home":n(),this.setCursor(this.matches.length?0:-1);return;case"End":n(),this.setCursor(this.matches.length-1);return;case"Enter":{n();const i=this.cursorName();i&&this.choose(i);return}case"Escape":n(),this.cancel();return;case"Tab":{const i=this.cursorName();i&&(this.selected=i),this.commit();return}default:break}}destroy(){for(const t of this.off)t();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function a(r){const t=F();if(Array.isArray(r)&&r.length){const n=new Set(t);return r.map(i=>String(i)).filter(i=>n.has(i))}return t.filter(n=>n!=="blank")}const l=b}),Se("packages/dom/src/editors/temperature.js",function(e,V){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/core/src/internal/util.js").isFunction,U=V("packages/core/src/columns/types/temperature.js"),z=U.formatTemperature,F=U.parseTemperature,k=U.findScale;function S(l,r){return z(l,{...r,decimals:void 0,minDecimals:0,maxDecimals:20})}class b extends N{input=null;hint=null;opts=null;#e=[];buildOptions(){const r=this.params.column&&this.params.column.dataType||null,t=r&&r.temperatureConfig||{};return{scale:this.props.scale||t.scale||"C",locale:this.params.locale}}build(){const r=this.props;this.opts=this.buildOptions();const t=k(this.opts.scale),n=t?t.scale.symbol:"",i=`${this.id}-scale`,o=L(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":n?i:null}});o.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(o.value=this.params.key),this.input=o;const c=typeof r.step=="number"?r.step:0;return c>0&&this.#e.push(W(o,"keydown",d=>{d.key==="ArrowUp"?(H(d.preventDefault)&&d.preventDefault(),this.nudge(c)):d.key==="ArrowDown"&&(H(d.preventDefault)&&d.preventDefault(),this.nudge(-c))})),this.hint=L(this.doc,"span",{class:`${$.editor}__suffix`,text:n,attrs:{id:i,"aria-hidden":"true"}}),L(this.doc,"div",{class:`${$.editor}__unit`,children:[o,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&H(r.select)&&r.select()}nudge(r){const t=F(this.input?this.input.value:"",this.opts);let n=(t??0)+r;const{min:i,max:o}=this.props;typeof i=="number"&&n<i&&(n=i),typeof o=="number"&&n>o&&(n=o),this.input&&(this.input.value=S(n,this.opts))}readValue(){const r=this.input?String(this.input.value).trim():"";if(r==="")return null;const t=F(r,this.opts);return t===null?Number.NaN:t}checkValue(r){if(r===null)return!0;if(typeof r!="number"||Number.isNaN(r))return"Enter a temperature";const{min:t,max:n}=this.props;return typeof t=="number"&&r<t?`Must be ${t} or more`:typeof n=="number"&&r>n?`Must be ${n} or less`:!0}destroy(){for(const r of this.#e)r();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const a=b}),Se("packages/dom/src/editors/currency.js",function(e,V){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const _=V("packages/dom/src/editors/common.js"),N=_.BaseEditor,$=_.CLS,L=_.el,W=_.on,H=V("packages/core/src/internal/util.js").isFunction,U=V("packages/core/src/columns/types/currency.js"),z=U.parseMoney,F=U.toMoney,k=U.normaliseCode,S=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function b(r){const t=F(r);return t?String(t.amount):""}class a extends N{input=null;picker=null;opts=null;#e=[];buildOptions(){const t=this.params.column&&this.params.column.dataType||null,n=t&&t.currencyConfig||{},i=F(this.params.value),o=k(this.props.code)||i&&i.code||k(n.code)||"USD";let c=this.props.codes||n.codes||S;return c=c.map(d=>k(d)).filter(Boolean),c.includes(o)||(c=[o,...c]),{code:o,codes:c,locale:this.params.locale}}build(){const t=this.props;this.opts=this.buildOptions();const n=L(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:t.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});n.value=b(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(n.value=this.params.key),this.input=n;const i=L(this.doc,"select",{class:`${$.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const o of this.opts.codes){const c=L(this.doc,"option",{text:o,attrs:{value:o}});o===this.opts.code&&(c.selected=!0),i.appendChild(c)}return this.picker=i,L(this.doc,"div",{class:`${$.editor}__unit`,children:[n,i]})}focusTarget(){return this.input}attached(){super.attached();const t=this.input;t&&!this.params.key&&this.props.selectOnFocus!==!1&&H(t.select)&&t.select()}readValue(){const t=this.input?String(this.input.value).trim():"";if(t==="")return null;const n=this.picker?this.picker.value:this.opts.code,i=z(t,{...this.opts,code:n});return i===null?Number.NaN:i}checkValue(t){if(t===null)return!0;if(!t||typeof t!="object"||!Number.isFinite(t.amount))return"Enter an amount";const n=t.amount,{min:i,max:o}=this.props;return typeof i=="number"&&n<i?`Must be ${i} or more`:typeof o=="number"&&n>o?`Must be ${o} or less`:!0}destroy(){for(const t of this.#e)t();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const l=a}),Se("packages/dom/src/editors/index.js",function(e,V){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return y}}),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 s}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return he}});const N=V("packages/dom/src/editors/text.js").TextEditor,L=V("packages/dom/src/editors/textarea.js").TextareaEditor,Z=V("packages/dom/src/editors/number.js").NumberEditor,U=V("packages/dom/src/editors/date.js").DateEditor,F=V("packages/dom/src/editors/checkbox.js").CheckboxEditor,S=V("packages/dom/src/editors/select.js").SelectEditor,a=V("packages/dom/src/editors/multiselect.js").MultiSelectEditor,r=V("packages/dom/src/editors/time.js").TimeEditor,n=V("packages/dom/src/editors/datetime.js").DateTimeEditor,o=V("packages/dom/src/editors/duration.js").DurationEditor,d=V("packages/dom/src/editors/ipaddress.js").IpAddressEditor,h=V("packages/dom/src/editors/password.js").PasswordEditor,y=V("packages/dom/src/editors/code.js").CodeEditor,m=V("packages/dom/src/editors/unit.js").UnitEditor,v=V("packages/dom/src/editors/radix.js").RadixEditor,s=V("packages/dom/src/editors/segmented.js").SegmentedEditor,E=V("packages/dom/src/editors/rating.js").RatingEditor,M=V("packages/dom/src/editors/slider.js").SliderEditor,P=V("packages/dom/src/editors/colour.js").ColourEditor,K=V("packages/dom/src/editors/treeselect.js").TreeSelectEditor,I=V("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,T=V("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=V("packages/dom/src/editors/temperature.js").TemperatureEditor,Q=V("packages/dom/src/editors/currency.js").CurrencyEditor,te=V("packages/core/src/internal/util.js"),re=te.isCtor,ie=te.isFunction,ae=te.warnOnce,ee=V("packages/dom/src/editors/common.js");for(const fe of Object.keys(ee))fe!=="default"&&Object.defineProperty(e,fe,{enumerable:!0,get:function(){return ee[fe]}});const J=Object.freeze({text:N,textarea:L,number:Z,date:U,checkbox:F,select:S,multiSelect:a,temperature:q,currency:Q,time:r,datetime:n,duration:o,ipaddress:d,password:h,code:y,unit:m,radix:v,slider:M,rating:E,segmented:s,treeSelect:K,objectPicker:I,iconPicker:T,colour:P}),se=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function le(fe,ve){const be=fe&&fe.edit&&fe.edit.editor,Re=ve&&ve.editors||{},He=!!(fe&&fe.lookup&&fe.lookup.multiple);if(re(be)||ie(be))return be;if(typeof be=="string"){if(He&&be==="select")return a;const $e=Re[be]||J[be];if($e)return $e;ae(`editor:missing:${be}`,`unknown editor "${be}"; falling back to the data type default`)}const Oe=fe&&fe.type||"text";if(Oe==="lookup"||fe&&fe.lookup)return He?a:S;const Ie=se[Oe];return Ie&&(Re[Ie]||J[Ie])||null}function oe(fe,ve){const be=le(fe.column||{},ve);if(!be)return null;const Re=new be;return Re.init(fe),ie(Re.cancelBeforeStart)&&Re.cancelBeforeStart()===!0?(ie(Re.destroy)&&Re.destroy(),null):Re}const he=J}),Se("packages/dom/src/ui/statusbar.js",function(e,V){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.documentFor,L=_.el,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction;function F(g){let y=0,p=0,m=0,w=null,v=null;for(const u of g||[]){if(u==null||u==="")continue;y++;const s=typeof u=="number"?u:Number(u);Number.isFinite(s)&&(p++,m+=s,(w===null||s<w)&&(w=s),(v===null||s>v)&&(v=s))}return{count:y,numericCount:p,sum:p?m:null,min:w,max:v,avg:p?m/p:null}}class k{root=null;valueNode=null;init(y){this.ctx=y,this.doc=y.document,this.root=L(this.doc,"div",{class:`${N.statusBar}__panel`,attrs:{"data-align":y.align||"end"}}),y.label&&this.root.appendChild(L(this.doc,"span",{class:`${N.statusBar}__label`,text:y.label})),this.valueNode=L(this.doc,"span",{class:`${N.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(y,p){const m=this.ctx&&this.ctx.messages;return(m&&z(m.t)?m:H).t(y,p)}element(){return this.root}refresh(){const y=this.read();this.valueNode&&this.valueNode.textContent!==y&&(this.valueNode.textContent=y)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class S extends k{read(){const y=this.ctx.host||{},p=z(y.totalRowCount)?y.totalRowCount():0;if(p==null)return this.t("status.counting");const m=z(y.rowCount)?y.rowCount():p,w=this.ctx.noun,v=u=>w===void 0?this.t("count.rows",{count:u}):`${c(u,this.ctx.locale)}${w?` ${w}`:""}`;return m===p?this.t("status.total",{rows:v(p)}):this.t("status.shownOfTotal",{shown:c(m,this.ctx.locale),total:v(p)})}}class b extends k{read(){const y=this.ctx.host||{},p=z(y.selectedCount)?y.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class a extends k{read(){const y=this.ctx.host||{},p=z(y.rangeValues)?y.rangeValues():[],m=F(p);if(!m.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],v=[];for(const u of w){if(u==="count"){v.push(this.t("status.count",{count:m.count}));continue}const s=m[u];s!==null&&v.push(`${this.t(`status.stat.${u}`)} ${f(s,this.ctx.locale)}`)}return v.join(" ")}}class l extends k{read(){const y=this.ctx.host||{},p=z(y.progress)?y.progress():null;if(!p)return"";const{loaded:m,estimated:w,done:v}=p;if(v)return"";if(!w)return this.t("status.loading",{count:m||0});const u=Math.min(100,Math.round((m||0)/w*100));return this.t("status.loadingOf",{loaded:m||0,total:w,percent:u})}}class r extends k{read(){const y=this.ctx.host||{},p=z(y.updateStats)?y.updateStats():null;return p?p.paused?p.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:p.pending})}):this.t("status.paused"):p.coalescedTotal?this.t("status.coalesced",{count:p.coalescedTotal}):"":""}}class t extends k{read(){const y=this.ctx.host||{},p=z(y.hiddenUnresolved)?y.hiddenUnresolved():0;return p?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:p})}):""}}const n=Object.freeze({rowCount:S,selectedCount:b,aggregation:a,progress:l,updates:r,comments:t});class i{panels=[];root=null;init(y){const p=y||{};this.doc=$(p),this.host=p.host||{},this.messages=p.messages||null,this.root=L(this.doc,"div",{class:N.statusBar,attrs:{role:"status","aria-live":"polite"}});const m=p.registry||{},w=Array.isArray(p.panels)&&p.panels.length?p.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const v of w){const u=typeof v=="string"?v:v.name,s=typeof v=="function"?v:m[u]||n[u];if(!s)continue;const O=new s;O.init({document:this.doc,host:this.host,locale:p.locale,messages:this.messages,...typeof v=="object"?v.props||{}:{}}),this.panels.push({name:String(u||"panel"),panel:O}),this.root.appendChild(O.element())}this.refresh()}element(){return this.root}addPanel(y,p,m){const w=new p;return w.init({document:this.doc,host:this.host,messages:this.messages,...m||{}}),this.panels.push({name:y,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(y){const p=this.panels.findIndex(v=>v.name===y);if(p<0)return!1;const[m]=this.panels.splice(p,1),w=m.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),z(m.panel.destroy)&&m.panel.destroy(),!0}refresh(){for(const y of this.panels)y.panel.refresh()}destroy(){for(const y of this.panels)z(y.panel.destroy)&&y.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const o=new Map;function c(g,y){const p=y||"";let m=o.get(p);return m||(m=new Intl.NumberFormat(y||void 0,{maximumFractionDigits:0}),o.set(p,m)),m.format(Number(g)||0)}const d=new Map;function f(g,y){const p=y||"";let m=d.get(p);return m||(m=new Intl.NumberFormat(y||void 0,{maximumFractionDigits:3}),d.set(p,m)),m.format(Number(g)||0)}const h=i}),Se("packages/dom/src/ui/contextmenu.js",function(e,V){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/renderer/direction.js").isRtlElement,S=V("packages/dom/src/cell/icons.js").renderIconInto;function b(n,i){const o=[];for(const c of n||[]){const d=U(c)?c(i):c;if(d==null||d===!1)continue;if(d==="separator"){o.push({separator:!0});continue}if(typeof d=="string"){o.push({name:d});continue}const f=d,h=f.subMenu||f.children;h?o.push({...f,subMenu:b(h,i)}):o.push(f)}return o.filter((c,d,f)=>c.separator?d===0||d===f.length-1?!1:!f[d-1].separator:!0)}class a{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(i){const o=i||{};this.doc=$(o),this.host=o.host||this.doc.body,this.ctx=o.ctx||{},this.onClose=o.onClose||null,this.parent=o.parent||null}place(i){const o=this.host,c=U(o.getBoundingClientRect)?o.getBoundingClientRect():{left:0,top:0},d=U(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},f=this.doc.defaultView||{innerWidth:0,innerHeight:0},h=f.innerWidth||0,g=f.innerHeight||0;let y=i.x||0,p=i.y||0;const m=F(o);if(i.anchor&&U(i.anchor.getBoundingClientRect)){const u=i.anchor.getBoundingClientRect();i.placement==="below"?(y=m?u.right-d.width:u.left,p=u.bottom):(y=m?u.left-d.width:u.right,p=u.top)}else m&&(y-=d.width);const w={left:Math.max(0,c.left||0),top:Math.max(0,c.top||0),right:Math.min(h||1/0,(c.left||0)+(c.width||1/0)),bottom:Math.min(g||1/0,(c.top||0)+(c.height||1/0))};y+d.width>w.right&&(y-=d.width),y<w.left&&(y=w.left),p+d.height>w.bottom&&(p-=d.height),p<w.top&&(p=w.top);const v=w.bottom-p;d.height>v&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(v))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(y-c.left+(o.scrollLeft||0))}px`,this.root.style.top=`${Math.round(p-c.top+(o.scrollTop||0))}px`}show(i){return this.hide(),i.ctx&&(this.ctx={...this.ctx||{},...i.ctx}),this.items=b(i.items,this.ctx),this.returnFocus=i.returnFocus||null,this.anchor=i.anchor&&U(i.anchor.setAttribute)&&i.anchor.getAttribute&&i.anchor.getAttribute("aria-haspopup")?i.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=L(this.doc,"div",{class:N.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((o,c)=>{if(o.separator){this.root.appendChild(L(this.doc,"div",{class:N.menuSeparator,attrs:{role:"separator"}}));return}const d=L(this.doc,"div",{class:[N.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":c}});if(o.icon!=null&&o.icon!==""){const h=L(this.doc,"span",{class:N.icon});S(h,o.icon,`menu:${o.name||c}`),d.appendChild(h)}d.appendChild(L(this.doc,"span",{class:`${N.menuItem}__label`,text:o.name||""})),o.shortcut&&d.appendChild(L(this.doc,"span",{class:`${N.menuItem}__shortcut`,text:o.shortcut})),o.subMenu&&d.appendChild(L(this.doc,"span",{class:`${N.menuItem}__arrow`,text:"›"}));const f=this.itemNodes.length;this.off.push(W(d,"click",()=>this.invoke(f))),this.off.push(W(d,"mouseenter",()=>{this.focus(f),o.subMenu?this.openSubMenu(f):this.closeChild()})),this.itemNodes.push(d),this.root.appendChild(d)}),this.host.appendChild(this.root),this.place(i),this.open=!0,this.off.push(W(this.root,"keydown",o=>this.onKeyDown(o))),U(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=o=>{this.root&&!r(this.root,o.target)&&!(this.child&&this.child.root&&r(this.child.root,o.target))&&this.hide()},!0)),U(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let i=0;i<this.itemNodes.length;i++)if(!this.itemAt(i).disabled)return i;return-1}itemAt(i){const o=this.itemNodes[i];return o?this.items[Number(o.getAttribute("data-index"))]||{}:{}}focus(i){if(i<0||i>=this.itemNodes.length)return;const o=this.itemNodes[this.focused];o&&o.classList.remove(`${N.menuItem}--focused`),this.focused=i;const c=this.itemNodes[i];c.classList.add(`${N.menuItem}--focused`),U(c.focus)&&c.focus(),U(c.scrollIntoView)&&c.scrollIntoView({block:"nearest",inline:"nearest"})}move(i){const o=this.itemNodes.length;if(!o)return;let c=this.focused;for(let d=0;d<o;d++)if(c=(c+i+o)%o,!this.itemAt(c).disabled){this.focus(c);return}}invoke(i){const o=this.itemAt(i);if(!(!o||o.disabled)){if(o.subMenu){this.openSubMenu(i);return}U(o.action)&&o.action({...this.ctx,item:o}),this.hideRoot()}}openSubMenu(i){const o=this.itemAt(i);o.subMenu&&(this.closeChild(),this.child=new a({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:o.subMenu,anchor:this.itemNodes[i]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(i){switch(i.key){case"ArrowDown":l(i),this.move(1);break;case"ArrowUp":l(i),this.move(-1);break;case"Home":l(i),this.focus(this.firstEnabled());break;case"End":l(i),this.focus(this.itemNodes.length-1);break;case"ArrowRight":l(i),this.openSubMenu(this.focused);break;case"ArrowLeft":l(i),this.parent&&(this.hide(),U(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":l(i),this.invoke(this.focused);break;case"Escape":l(i),this.hideRoot();break;default:i.key&&i.key.length===1&&this.jumpTo(i.key);break}}jumpTo(i){const o=i.toLowerCase(),c=this.itemNodes.length;for(let d=1;d<=c;d++){const f=(this.focused+d+c)%c,h=this.itemAt(f);if(!h.disabled&&(h.name||"").toLowerCase().startsWith(o)){this.focus(f);return}}}hideRoot(){let i=this;for(;i.parent;)i=i.parent;i.hide()}hide(){this.closeChild();for(const i of this.off)i();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&U(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&U(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,U(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function l(n){U(n.preventDefault)&&n.preventDefault(),U(n.stopPropagation)&&n.stopPropagation()}function r(n,i){let o=i;for(;o;){if(o===n)return!0;o=o.parentNode}return!1}const t=a}),Se("packages/dom/src/viewpicker.js",function(e,V){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const _=V("packages/dom/src/editors/common.js"),N=_.documentFor,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,k=V("packages/dom/src/cell/icons.js").createIcon,S=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class b{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(t,n){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(t,n)}init(t){this.messages=t&&t.messages||t&&t.grid&&t.grid.messages||H;const n=t||{};this.doc=N(n),this.host=n.host||{},this.props=n.props||{},this.root=$(this.doc,"div",{class:S.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const t=this.root;if(!t)return;for(const d of this.off)d();this.off.length=0,W(t),this.diffs=new Map;const n=this.views(),i=n.filter(d=>d.builtin),o=n.filter(d=>!d.builtin);i.length&&(t.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),i.length)),t.appendChild(this.buildList(i))),t.appendChild(this.buildHead(String(this.props.title||"Saved views"),o.length)),o.length?t.appendChild(this.buildList(o)):t.appendChild($(this.doc,"p",{class:S.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const c=this.buildFoot();c&&t.appendChild(c)}buildList(t){const n=$(this.doc,"div",{class:S.list,attrs:{role:"list"}});for(const i of t)n.appendChild(this.buildItem(i));return n}views(){const t=z(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?t:t.slice().sort((n,i)=>String(n.name||"").localeCompare(String(i.name||"")))}activeId(){return z(this.host.activeId)?this.host.activeId():null}buildHead(t,n){return $(this.doc,"div",{class:S.head,children:[$(this.doc,"span",{class:S.title,text:String(t)}),$(this.doc,"span",{class:S.count,text:String(n)})]})}buildItem(t){const n=String(t.id),i=this.activeId()===n,o=z(this.host.canEdit)?this.host.canEdit(t)!==!1:!0,c=$(this.doc,"div",{class:[S.item,i?S.itemActive:"",this.editing===n?S.itemEditing:""],attrs:{role:"listitem","data-view":n,"data-shared":t.shared?"true":"false"}});if(this.editing===n)return c.appendChild(this.buildRenameRow(t)),c;const d=$(this.doc,"button",{class:S.apply,attrs:{type:"button","aria-current":i?"true":null,title:[i?`${t.name} is applied`:`Apply ${t.name}`,t.shared?"Shared with everyone":"Private to you"].join(": ")},children:[$(this.doc,"span",{class:S.name,text:String(t.name||"")}),t.isDefault?this.buildBadges(t):null].filter(Boolean)});z(this.host.apply)?this.off.push(L(d,"click",()=>this.applyView(n))):d.setAttribute("disabled",""),t.description&&d.appendChild($(this.doc,"span",{class:S.description,text:String(t.description)}));const f=this.buildDiff(n,i);return f&&d.appendChild(f),c.appendChild(d),t.builtin||c.appendChild(this.confirming===n?this.buildConfirm(t):this.buildActions(t,o)),c}buildBadges(t){const n=$(this.doc,"span",{class:S.badges});return t.isDefault&&n.appendChild($(this.doc,"span",{class:[S.badge,S.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),n}buildDiff(t,n){if(this.props.showDiff!==!0||!z(this.host.diff))return null;const i=this.diffOf(t);if(!i)return null;if(!i.changed)return $(this.doc,"span",{class:[S.diff,S.diffClean],text:this.t(n?"views.applied":"views.matchesGrid")});const o=a(i);return o.length?$(this.doc,"span",{class:S.diff,text:o.join(" · ")}):null}diffOf(t){if(!z(this.host.diff))return null;if(this.diffs.has(t))return this.diffs.get(t);let n=null;try{n=this.host.diff(t)}catch{n=null}return this.diffs.set(t,n),n}buildActions(t,n){const i=String(t.id),o=$(this.doc,"span",{class:S.actions});if(n&&z(this.host.rename)&&o.appendChild(this.buildAction("Rename",`Rename ${t.name}`,()=>{this.editing=i,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),t.isDefault&&z(this.host.clearDefault)?o.appendChild(this.buildAction("Unset default",`Stop applying ${t.name} at load`,()=>{this.host.clearDefault(i),this.refresh()},"pin")):!t.isDefault&&z(this.host.setDefault)&&o.appendChild(this.buildAction("Make default",`Apply ${t.name} when the grid loads`,()=>{this.host.setDefault(i),this.refresh()},"pin")),z(this.host.export)&&o.appendChild(this.buildAction("Share",`Export ${t.name}`,()=>this.host.export(i),"share")),n&&z(this.host.remove)){const c=this.buildAction("Delete",`Delete ${t.name}`,()=>{this.confirming=i,this.refresh()},"trash");c.classList.add(S.actionDanger),o.appendChild(c)}return o}buildConfirm(t){const n=String(t.id),i=$(this.doc,"span",{class:S.confirm});i.appendChild($(this.doc,"span",{text:this.t("views.confirmDelete",{name:t.name})}));const o=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:t.name}),()=>{this.confirming=null,this.host.remove(n),this.refresh()});return o.classList.add(S.actionDanger),i.appendChild(o),i.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),i}buildRenameRow(t){const n=String(t.id),i=$(this.doc,"span",{class:S.confirm}),o=$(this.doc,"input",{class:S.input,attrs:{type:"text","aria-label":`New name for ${t.name}`}});o.value=String(t.name||""),this.input=o;const c=()=>{const f=String(o.value||"").trim();this.editing=null,f&&f!==t.name&&this.host.rename(n,f),this.refresh()},d=()=>{this.editing=null,this.refresh()};return this.off.push(L(o,"keydown",f=>{f.key==="Enter"?c():f.key==="Escape"&&d()})),i.appendChild(o),i.appendChild(this.buildAction("Save","Save the new name",c)),i.appendChild(this.buildAction("Cancel","Leave the name alone",d)),i}buildFoot(){if(this.props.allowSave===!1||!z(this.host.saveAs))return null;const t=$(this.doc,"div",{class:S.foot}),n=$(this.doc,"input",{class:S.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});n.value=this.draft,this.editing===null&&(this.input=n);const i=()=>{const c=String(n.value||"").trim();if(!c){z(n.focus)&&n.focus();return}this.draft="",this.host.saveAs(c),this.refresh()};this.off.push(L(n,"input",()=>{this.draft=String(n.value||"")})),this.off.push(L(n,"keydown",c=>{c.key==="Enter"&&i()}));const o=$(this.doc,"button",{class:S.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(L(o,"click",i)),t.appendChild(n),t.appendChild(o),t}buildAction(t,n,i,o){const c=$(this.doc,"button",{class:S.action,text:o?null:t,attrs:{type:"button",title:n,"aria-label":n,"data-action":t}});return o&&c.appendChild(k(this.doc,o,{className:S.actionIcon})),this.off.push(L(c,"click",i)),c}applyView(t){this.confirming=null,this.host.apply(t),this.refresh()}focusInput(){const t=this.input;t&&z(t.focus)&&t.focus(),t&&z(t.select)&&t.select()}destroy(){for(const t of this.off)t();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function a(r,t=3){if(!r||!r.changed)return[];const n=r.counts||{},i=[],o=(c,d,f)=>{c&&i.push((c===1?d:f).replace("%",String(c)))};if(o(n.columnsHidden,"hides % column","hides % columns"),o(n.columnsShown,"shows % column","shows % columns"),o(n.columnsMoved,"moves % column","moves % columns"),o(n.columnsPinned,"repins % column","repins % columns"),o(n.columnsResized,"resizes % column","resizes % columns"),r.filters&&r.filters.changed){const c=n.filterColumns||0;i.push(c?`changes ${c} filter${c===1?"":"s"}`:"changes the filter")}return r.quick&&r.quick.changed&&i.push("changes the search"),r.sort&&r.sort.changed&&i.push("changes the sort"),r.group&&r.group.changed&&i.push("changes the grouping"),r.pivot&&r.pivot.changed&&i.push("changes the pivot"),o(n.columnsTotalled,"changes % total","changes % totals"),r.pagination&&r.pagination.changed&&i.push("changes the page size"),i.length<=t?i:[...i.slice(0,t),`and ${i.length-t} more`]}const l=b}),Se("packages/dom/src/ui/panelbase.js",function(e,V){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return Z}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.el,W=V("packages/core/src/i18n/index.js").defaultMessages;class Z{root=null;off=[];init(U){this.ctx=U,this.doc=U.document,this.host=U.host||{},this.props=U.props||{},this.root=$(this.doc,"div",{class:`${N.panel}__body`}),this.refresh()}t(U,z){const F=this.host||{};if(typeof F.t=="function")return F.t(U,z);const k=this.ctx||{};if(k.messages&&typeof k.messages.t=="function")return k.messages.t(U,z);const S=k.grid;return(S&&S.messages?S.messages:W).t(U,z)}element(){return this.root}refresh(){}destroy(){for(const U of this.off)U();this.off.length=0,this.root=null}}}),Se("packages/dom/src/formattingpanel.js",function(e,V){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/internal/util.js").isFunction,F=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,k=V("packages/core/src/formatting/rules.js"),S=k.compileRules,b=k.summariseColumn,a=k.needsDistribution,l=k.DISTRIBUTION_LABELS,r="*",t=8,n=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),i=Object.freeze([{op:"topPercent",label:l.topPercent,values:1},{op:"bottomPercent",label:l.bottomPercent,values:1},{op:"topN",label:l.topN,values:1},{op:"bottomN",label:l.bottomN,values:1},{op:"aboveMean",label:l.aboveMean,values:0},{op:"belowMean",label:l.belowMean,values:0},{op:"aboveMedian",label:l.aboveMedian,values:0},{op:"belowMedian",label:l.belowMedian,values:0},{op:"zAbove",label:l.zAbove,values:1},{op:"zBelow",label:l.zBelow,values:1},{op:"outlier",label:l.outlier,values:0}]),o=Object.freeze([...n,...i]),c=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),d=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),f=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function h(w){const v=o.find(u=>u.op===w);return v?v.values:1}function g(w){if(!w)return"";if(w.scale){const{min:O,max:E,from:A}=w.scale;if(Number.isFinite(O)&&Number.isFinite(E))return`Colour scale, ${O} to ${E}`;const M=f.find(C=>C.from===A);return M?`Colour scale ${M.label}`:"Colour scale"}const v=w.when||{},u=o.find(O=>O.op===v.op),s=u?u.label:v.op;return!u||u.values===0?`Value ${s}`:u.values===2?`Value ${s} ${v.value} and ${v.value2}`:`Value ${s} ${v.value}`}class y extends F{scope=r;mode="condition";refresh(){const v=this.root;if(v){for(const u of this.off)u();this.off.length=0,Z(v),v.appendChild(this.#o()),v.appendChild(this.#i()),v.appendChild(this.#s())}}#e(){const v=U(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:r,title:"All columns"},...v]}#t(){return U(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(v){if(!U(this.host.columnSamples))return[];const u=this.host.columnSamples(v);return Array.isArray(u)?u:[...u||[]]}#r(v,u,s){const O=a(v)?b(u):null;return S(v,O)({value:s})}#o(){const v=L(this.doc,"div",{class:`${N.panel}__row`});v.appendChild(L(this.doc,"label",{class:`${N.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const u=L(this.doc,"select",{class:`${N.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const s of this.#e()){const O=L(this.doc,"option",{text:s.title,attrs:{value:s.id}});s.id===this.scope&&O.setAttribute("selected","selected"),u.appendChild(O)}return u.value=this.scope,this.off.push(W(u,"change",()=>{this.scope=u.value||r,this.refresh()})),v.appendChild(u),v}#i(){const v=L(this.doc,"ul",{class:`${N.panel}__list`}),u=this.#t();if(!u.length)return v.appendChild(L(this.doc,"li",{class:`${N.panel}__empty`,text:this.t("formatting.noRules")})),v;u.forEach((E,A)=>{const M=L(this.doc,"li",{class:`${N.panel}__item`,attrs:{"data-rule":E.id}}),C=L(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${g(E)}`}});C.checked=E.enabled!==!1,this.off.push(W(C,"change",()=>{this.#c("updateRule",this.scope,E.id,{enabled:C.checked})})),M.appendChild(C);const P=L(this.doc,"span",{class:`${N.panel}__swatch`}),D=E.style||{};if(D.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(D.background));else if(E.scale&&E.scale.colours&&P.style&&P.style.setProperty){const j=E.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${j[0]}, ${j[j.length-1]})`)}M.appendChild(P),M.appendChild(L(this.doc,"span",{class:`${N.panel}__text`,text:g(E)}));const K=L(this.doc,"button",{class:`${N.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...A===0?{disabled:"disabled"}:{}}});this.off.push(W(K,"click",()=>this.#c("moveRule",this.scope,E.id,A-1))),M.appendChild(K);const x=L(this.doc,"button",{class:`${N.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...A===u.length-1?{disabled:"disabled"}:{}}});this.off.push(W(x,"click",()=>this.#c("moveRule",this.scope,E.id,A+1))),M.appendChild(x);const I=L(this.doc,"button",{class:`${N.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${g(E)}`}});this.off.push(W(I,"click",()=>this.#c("removeRule",this.scope,E.id))),M.appendChild(I),v.appendChild(M)});const s=this.#a(u);s&&v.appendChild(s);const O=L(this.doc,"button",{class:`${N.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(O,"click",()=>this.#c("clearRules",this.scope))),v.appendChild(O),v}#a(v){const u=this.#n(this.scope);if(!u.length)return null;const s=v.filter(E=>E.enabled!==!1);if(!s.length)return null;const O=L(this.doc,"div",{class:`${N.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const E of u.slice(0,t)){const A=this.#r(s,u,E),M=L(this.doc,"span",{class:`${N.panel}__previewcell`,text:String(E)});A&&M.style&&M.style.setProperty&&(A.background&&M.style.setProperty("background",String(A.background)),A.color&&M.style.setProperty("color",String(A.color))),O.appendChild(M)}return O}#s(){const v=L(this.doc,"div",{class:`${N.panel}__form`}),u=L(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return u.appendChild(L(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),u.appendChild(L(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),u.value=this.mode,this.off.push(W(u,"change",()=>{this.mode=u.value==="scale"?"scale":"condition",this.refresh()})),v.appendChild(u),this.mode==="scale"?v.appendChild(this.#u()):v.appendChild(this.#l()),v}#l(){const v=L(this.doc,"div",{class:`${N.panel}__form`}),u=L(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),s=L(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const I of n)s.appendChild(L(this.doc,"option",{text:I.label,attrs:{value:I.op}}));u.appendChild(s);const O=L(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const I of i)O.appendChild(L(this.doc,"option",{text:I.label,attrs:{value:I.op}}));u.appendChild(O),u.value="gt",v.appendChild(u);const E=L(this.doc,"input",{class:`${N.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),A=L(this.doc,"input",{class:`${N.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});v.appendChild(E),v.appendChild(A);const M=()=>{const I=h(u.value);E.style.setProperty("display",I>=1?"":"none"),A.style.setProperty("display",I>=2?"":"none"),K()};this.off.push(W(u,"change",M));const C=L(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const I of c)C.appendChild(L(this.doc,"option",{text:I.name,attrs:{value:I.name}}));C.value=c[0].name,v.appendChild(C);const P=L(this.doc,"div",{class:`${N.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(P);const D=()=>{const I=c.find(B=>B.name===C.value)||c[0],j=h(u.value),T={op:u.value};return j>=1&&(T.value=E.value),j>=2&&(T.value2=A.value),{when:T,style:{background:I.background,color:I.color}}},K=()=>{Z(P);const I=this.#n(this.scope);if(I.length)for(const j of I.slice(0,t)){const T=this.#r([D()],I,j),B=L(this.doc,"span",{class:`${N.panel}__previewcell`,text:String(j)});T&&B.style&&B.style.setProperty&&(T.background&&B.style.setProperty("background",String(T.background)),T.color&&B.style.setProperty("color",String(T.color))),P.appendChild(B)}};this.off.push(W(E,"input",K)),this.off.push(W(A,"input",K)),this.off.push(W(C,"change",K)),M();const x=L(this.doc,"button",{class:`${N.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(x,"click",()=>{this.#c("addRule",this.scope,D()),E.value="",A.value=""})),v.appendChild(x),v}#u(){const v=L(this.doc,"div",{class:`${N.panel}__form`}),u=L(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of d)u.appendChild(L(this.doc,"option",{text:C.name,attrs:{value:C.name}}));u.value=d[0].name,v.appendChild(u);const s=L(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of f)s.appendChild(L(this.doc,"option",{text:C.label,attrs:{value:C.from}}));s.value=f[0].from,v.appendChild(s);const O=L(this.doc,"div",{class:`${N.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(O);const E=()=>{const C=d.find(P=>P.name===u.value)||d[0];return{scale:{from:s.value,colours:[...C.colours]}}},A=()=>{Z(O);const C=this.#n(this.scope);if(C.length)for(const P of C.slice(0,t)){const D=this.#r([E()],C,P),K=L(this.doc,"span",{class:`${N.panel}__previewcell`,text:String(P)});D&&D.background&&K.style&&K.style.setProperty&&K.style.setProperty("background",String(D.background)),O.appendChild(K)}};this.off.push(W(u,"change",A)),this.off.push(W(s,"change",A)),A();const M=L(this.doc,"button",{class:`${N.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(M,"click",()=>{this.#c("addRule",this.scope,E())})),v.appendChild(M),v}#c(v,...u){U(this.host[v])&&this.host[v](...u),this.refresh()}}function p(w={}){const v=new y;return v.init({document:$(w),host:w.host||{}}),v}const m=y}),Se("packages/dom/src/statisticspanel.js",function(e,V){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return a}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,F=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"},{key:"min",label:"stats.min",kind:"value"},{key:"max",label:"stats.max",kind:"value"},{key:"mean",label:"stats.mean",kind:"value"},{key:"median",label:"stats.median",kind:"value"},{key:"q1",label:"stats.q1",kind:"value"},{key:"q3",label:"stats.q3",kind:"value"},{key:"iqr",label:"stats.iqr",kind:"value"},{key:"stddev",label:"stats.stddev",kind:"value"},{key:"outliers",label:"stats.outliers",kind:"count"}]),k=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),S=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function b(l){if(l==null||!Number.isFinite(l))return"—";if(Number.isInteger(l))return String(l);const r=Math.abs(l);return r!==0&&(r<.001||r>=1e7)?l.toExponential(2):String(Number(l.toPrecision(4)))}class a extends z{column=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const r=this.root;if(!r)return;for(const o of this.off)o();this.off.length=0,W(r);const t=this.#e();if(!t.length){r.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("stats.noColumns")}));return}t.some(o=>o.id===this.column)||(this.column=t[0].id),r.appendChild(this.#t(t));const n=H(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!n||!n.present){r.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("stats.noValues")}));return}if(r.appendChild($(this.doc,"p",{class:`${N.panel}__count`,text:this.t("stats.filtered",{count:n.rows})})),Array.isArray(n.topValues)){r.appendChild(this.#o(n,k)),r.appendChild(this.#i(n.topValues));return}r.appendChild(this.#o(n));for(const o of S){const c=this.#n(o);c&&r.appendChild(c)}const i=this.#r();i&&r.appendChild(i),n.histogram&&n.histogram.length>1&&r.appendChild(this.#a(n.histogram))}#t(r){const t=$(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const n of r){const i=$(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===this.column?!0:null}});t.appendChild(i)}return t.value=this.column,this.off.push(L(t,"change",()=>{this.column=t.value,this.refresh()})),$(this.doc,"label",{class:`${N.panel}__field`,children:[$(this.doc,"span",{class:`${N.panel}__label`,text:this.t("stats.column")}),t]})}#n(r){const t=this.host.reduceColumn;if(!H(t)||!this.column)return null;const n=[];for(const c of r.kernels){const d=t(this.column,c);d==null||Number.isNaN(d)||n.push([c,d])}if(!n.length)return null;const i=this.doc.createElement("div");i.appendChild($(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t(r.label)}));const o=$(this.doc,"dl",{class:`${N.panel}__stats`});for(const[c,d]of n)o.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(`total.${c}`)})),o.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,text:typeof d=="number"?b(d):String(d)}));return i.appendChild(o),i}#r(){const r=this.host.columnCapability;if(!H(r)||!this.column)return null;const t=r(this.column);if(!t)return null;const n=this.doc.createElement("div");n.appendChild($(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t("stats.section.capability")}));const i=$(this.doc,"dl",{class:`${N.panel}__stats`}),o=[["stats.cp",t.cp,null],["stats.cpk",t.cpk,t.interval],["stats.pp",t.pp,null],["stats.ppk",t.ppk,t.intervalPp],["stats.outOfSpec",t.outOfSpec,null]];for(const[c,d,f]of o){if(d==null)continue;i.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(c)}));const h=[$(this.doc,"span",{text:b(d)})];f&&Number.isFinite(f.lower)&&h.push($(this.doc,"span",{class:`${N.panel}__stat-interval`,text:`${b(f.lower)} – ${b(f.upper)}`,attrs:{title:`${Math.round(f.confidence*100)}%`}})),i.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,children:h}))}return n.appendChild(i),n}#o(r,t=F){const n=$(this.doc,"dl",{class:`${N.panel}__stats`});for(const i of t){const o=r[i.key];n.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(i.label)})),n.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,text:i.kind==="count"?String(o??0):b(o)}))}return n}#i(r){const t=this.doc.createElement("div");t.appendChild($(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t("stats.topValues")}));const n=$(this.doc,"dl",{class:`${N.panel}__stats`});for(const i of r)n.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:String(i.value)})),n.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,children:[$(this.doc,"span",{text:String(i.count)}),$(this.doc,"span",{class:`${N.panel}__stat-interval`,text:`${Math.round(i.share*100)}%`})]}));return t.appendChild(n),t}#a(r){const t=r.reduce((i,o)=>Math.max(i,o.count),0)||1,n=$(this.doc,"div",{class:`${N.panel}__histogram`});n.appendChild($(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t("stats.distribution")}));for(const i of r){const o=$(this.doc,"div",{class:`${N.panel}__bar`,style:{width:`${i.count?Math.max(2,i.count/t*100):0}%`}});n.appendChild($(this.doc,"div",{class:`${N.panel}__bin`,attrs:{title:this.t("stats.bin",{count:i.count,from:b(i.from),to:b(i.to)})},children:[o]}))}return n}}}),Se("packages/dom/src/regressionpanel.js",function(e,V){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.el,L=_.clear,Z=V("packages/core/src/internal/util.js").isFunction,U=V("packages/dom/src/ui/panelbase.js").ToolPanelBase;function z(S,b=4){const a=Number(S);return Number.isFinite(a)?a.toFixed(b):a===1/0?"∞":"—"}class F extends U{#e(){const b=this.props||{};if(Array.isArray(b.predictors)&&b.predictors.length&&b.response)return b;const a=this.ctx&&this.ctx.grid,l=a&&Z(a.get)?a.get("regression"):null;return l&&Array.isArray(l.predictors)&&l.response?l:null}refresh(){const b=this.root;if(!b)return;L(b);const a=this.#e();if(!a){b.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("regression.noModel")}));return}const l=Z(this.host.regressionModel)?this.host.regressionModel(a):null;if(!l){b.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("regression.cannotFit")}));return}b.appendChild($(this.doc,"p",{class:`${N.panel}__count`,text:this.t("regression.observations",{count:l.n})})),b.appendChild(this.#t(l)),b.appendChild(this.#n(l));const r=this.#r(l,a);r&&b.appendChild(r),b.appendChild(this.#o(l))}#t(b){const a=$(this.doc,"dl",{class:`${N.panel}__stats`}),l=(r,t)=>{a.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-label`,text:r})),a.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,text:t}))};return l(this.t("regression.r2"),z(b.r2,4)),l(this.t("regression.adjR2"),z(b.adjR2,4)),a}#n(b){const a=$(this.doc,"div",{class:`${N.panel}__section`});a.appendChild($(this.doc,"h4",{class:`${N.panel}__heading`,text:this.t("regression.coefficients")}));const l=$(this.doc,"table",{class:`${N.panel}__coef-table`}),r=$(this.doc,"tr");for(const t of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])r.appendChild($(this.doc,"th",{text:this.t(t)}));l.appendChild(r);for(const t of b.coefficients){const n=$(this.doc,"tr");n.appendChild($(this.doc,"td",{text:t.name})),n.appendChild($(this.doc,"td",{text:`${z(t.estimate)} ± ${z(t.stdError)}`})),n.appendChild($(this.doc,"td",{text:z(t.stdError)})),n.appendChild($(this.doc,"td",{text:z(t.t,3)})),n.appendChild($(this.doc,"td",{text:z(t.p,4)})),l.appendChild(n)}return a.appendChild(l),a}#r(b,a){if(!Array.isArray(b.vif)||b.vif.length<2)return null;const l=$(this.doc,"div",{class:`${N.panel}__section`});l.appendChild($(this.doc,"h4",{class:`${N.panel}__heading`,text:this.t("regression.vif")}));const r=$(this.doc,"dl",{class:`${N.panel}__stats`});return b.vif.forEach((t,n)=>{r.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-label`,text:a.predictors[n]})),r.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,text:z(t,3)}))}),l.appendChild(r),l}#o(b){const a=b.heteroscedasticity,l=$(this.doc,"div",{class:`${N.panel}__section`});return l.appendChild($(this.doc,"h4",{class:`${N.panel}__heading`,text:this.t("regression.heteroscedasticity")})),a?(l.appendChild($(this.doc,"p",{class:`${N.panel}__flag`,attrs:{"data-heteroscedastic":a.heteroscedastic?"true":"false"},text:this.t(a.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:z(a.statistic,3),p:z(a.p,4)})})),l):(l.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("regression.cannotFit")})),l)}}const k=F}),Se("packages/dom/src/comparepanel.js",function(e,V){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return S}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,F=Object.freeze([{key:"pearson",label:"compare.pearson"},{key:"spearman",label:"compare.spearman"},{key:"kendall",label:"compare.kendall"},{key:"slope",label:"compare.slope"},{key:"intercept",label:"compare.intercept"},{key:"r2",label:"compare.r2"},{key:"stdError",label:"compare.stdError"},{key:"covariance",label:"compare.covariance"},{key:"weighted",label:"compare.weighted"}]);function k(b){if(b==null||!Number.isFinite(b))return"—";if(Number.isInteger(b))return String(b);const a=Math.abs(b);return a!==0&&(a<.001||a>=1e7)?b.toExponential(2):String(Number(b.toPrecision(4)))}class S extends z{first=null;second=null;#e(){return H(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const a=this.root;if(!a)return;for(const n of this.off)n();this.off.length=0,W(a);const l=this.#e();if(l.length<2){a.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("compare.needTwo")}));return}l.some(n=>n.id===this.first)||(this.first=l[0].id),(!l.some(n=>n.id===this.second)||this.second===this.first)&&(this.second=(l.find(n=>n.id!==this.first)||l[0]).id),a.appendChild(this.#t("compare.first",l,this.first,n=>{this.first=n,this.second===n&&(this.second=(l.find(i=>i.id!==n)||l[0]).id),this.refresh()})),a.appendChild(this.#t("compare.second",l,this.second,n=>{this.second=n,this.first===n&&(this.first=(l.find(i=>i.id!==n)||l[0]).id),this.refresh()}));const r=H(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!r||!r.n){a.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("compare.noPairs")}));return}a.appendChild($(this.doc,"p",{class:`${N.panel}__count`,text:this.t("compare.pairs",{count:r.n})}));const t=$(this.doc,"dl",{class:`${N.panel}__stats`});for(const n of F){const i=r[n.key];i!=null&&(t.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(n.label)})),t.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,text:k(i)})))}a.appendChild(t)}#t(a,l,r,t){const n=$(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t(a)}});for(const i of l)n.appendChild($(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===r?!0:null}}));return n.value=r,this.off.push(L(n,"change",()=>t(n.value))),$(this.doc,"label",{class:`${N.panel}__field`,children:[$(this.doc,"span",{class:`${N.panel}__label`,text:this.t(a)}),n]})}}}),Se("packages/dom/src/insightspanel.js",function(e,V){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return S}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,F=Object.freeze([{key:"stats.cp",field:"cp",interval:null},{key:"stats.cpk",field:"cpk",interval:"interval"},{key:"stats.pp",field:"pp",interval:null},{key:"stats.ppk",field:"ppk",interval:"intervalPp"},{key:"stats.outOfSpec",field:"outOfSpec",interval:null}]);function k(b){if(b==null||!Number.isFinite(b))return"—";if(Number.isInteger(b))return String(b);const a=Math.abs(b);return a!==0&&(a<.001||a>=1e7)?b.toExponential(2):String(Number(b.toPrecision(4)))}class S extends z{column=null;by=null;#e(){return H(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const a=this.root;if(!a)return;for(const o of this.off)o();this.off.length=0,W(a);const l=this.#e();if(!l.length){a.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("insights.empty")}));return}const r=this.#t();r&&a.appendChild(r);const t=this.#n();t&&a.appendChild(t),a.appendChild(this.#o(l));const n=this.#a();n&&a.appendChild(n);const i=this.#u();i&&a.appendChild(i)}#t(){if(!H(this.host.subsetVsPopulation))return null;const a=this.host.subsetVsPopulation();if(!a)return null;const l=this.#c("insights.subset");return a.filtered?(l.appendChild($(this.doc,"p",{class:`${N.panel}__count`,text:this.t("stats.filtered",{count:a.subsetN})})),l.appendChild(this.#r(a.ranked)),l):(l.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("insights.noFilter")})),l)}#n(){const a=this.props&&this.props.other;if(!a||!H(this.host.datasetVsDataset))return null;let l;try{l=this.host.datasetVsDataset(a)}catch{return null}if(!l||!l.ranked)return null;const r=this.#c("insights.dataset");return r.appendChild(this.#r(l.ranked)),r}#r(a){const l=$(this.doc,"dl",{class:`${N.panel}__stats`});for(const r of a||[]){const t=$(this.doc,"dt",{class:`${N.panel}__stat-name`});t.appendChild($(this.doc,"span",{text:String(r.name??r.column)})),t.appendChild($(this.doc,"span",{class:`${N.panel}__stat-interval`,text:String(r.measure||"")}));const n=$(this.doc,"dd",{class:`${N.panel}__stat-value`});n.appendChild($(this.doc,"span",{text:k(r.magnitude)})),r.reliable===!1&&n.appendChild($(this.doc,"span",{class:`${N.panel}__stat-interval`,text:this.t("insights.smallSample")})),l.appendChild(t),l.appendChild(n)}return l}#o(a){const l=this.#c("insights.groups");a.some(t=>t.id===this.column)||(this.column=a[0].id),(!a.some(t=>t.id===this.by)||this.by===this.column)&&(this.by=(a.find(t=>t.id!==this.column)||a[0]).id),l.appendChild(this.#d("stats.column",a,this.column,t=>{this.column=t,this.by===t&&(this.by=(a.find(n=>n.id!==t)||a[0]).id),this.refresh()})),l.appendChild(this.#d("insights.by",a,this.by,t=>{this.by=t,this.column===t&&(this.column=(a.find(n=>n.id!==t)||a[0]).id),this.refresh()}));const r=H(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return r?(l.appendChild(this.#i(r)),l):(l.appendChild($(this.doc,"p",{class:`${N.panel}__empty`,text:this.t("insights.needGroups")})),l)}#i(a){const l=$(this.doc,"dl",{class:`${N.panel}__stats`});Array.isArray(a.groups)&&a.groups.length===2&&this.#l(l,"insights.groups",`${a.groups[0]} · ${a.groups[1]}`),this.#l(l,"insights.test",String(a.method||a.test||""));const r=a.effectSize||{};this.#l(l,"insights.effect",`${r.name||""} ${k(r.value)}`.trim());const t=a.interval;let n="—";if(t&&Number.isFinite(t.lower)&&Number.isFinite(t.upper)){const o=Number.isFinite(t.confidence)?` (${Math.round(t.confidence*100)}%)`:"";n=`${k(t.lower)} – ${k(t.upper)}${o}`}const i=this.#l(l,"insights.interval",n);return t&&t.method&&i.appendChild($(this.doc,"span",{class:`${N.panel}__stat-interval`,text:String(t.method)})),Number.isFinite(a.pValue)&&this.#l(l,"insights.pValue",k(a.pValue)),l}#a(){if(!H(this.host.anomalies))return null;let a;try{a=this.host.anomalies()}catch{return null}if(!a)return null;const l=this.#c("insights.anomalies");l.appendChild($(this.doc,"p",{class:`${N.panel}__count`,text:this.t("insights.anomalyCount",{count:a.flagged||0,n:a.n||0})}));const r=$(this.doc,"dl",{class:`${N.panel}__stats`});this.#l(r,"insights.anomalyMethod",String(a.method||""));const t=this.#s(a);t!==null&&this.#l(r,"insights.anomalyThreshold",k(t)),l.appendChild(r);const n=(a.rows||[]).map(i=>({name:i.rowKey!=null?String(i.rowKey):`#${i.index}`,measure:(i.why||[]).map(o=>o.name||o.column).join(", "),magnitude:i.score}));return l.appendChild(this.#r(n)),l}#s(a){if(a.method==="mahalanobis")return Number.isFinite(a.cutoff)?a.cutoff:null;if(a.method==="iqr")return Number.isFinite(a.k)?a.k:null;const l=Array.isArray(a.columns)?a.columns[0]:null;return l&&Number.isFinite(l.threshold)?l.threshold:null}#l(a,l,r){a.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(l)}));const t=$(this.doc,"dd",{class:`${N.panel}__stat-value`});return t.appendChild($(this.doc,"span",{text:r})),a.appendChild(t),t}#u(){if(!H(this.host.columnCapability)||!this.column)return null;const a=this.host.columnCapability(this.column);if(!a)return null;const l=this.#c("stats.section.capability"),r=$(this.doc,"dl",{class:`${N.panel}__stats`});for(const t of F){const n=a[t.field];if(n==null)continue;r.appendChild($(this.doc,"dt",{class:`${N.panel}__stat-name`,text:this.t(t.key)}));const i=[$(this.doc,"span",{text:k(n)})],o=t.interval?a[t.interval]:null;o&&Number.isFinite(o.lower)&&i.push($(this.doc,"span",{class:`${N.panel}__stat-interval`,text:`${k(o.lower)} – ${k(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),r.appendChild($(this.doc,"dd",{class:`${N.panel}__stat-value`,children:i}))}return l.appendChild(r),l}#c(a){const l=this.doc.createElement("div");return l.appendChild($(this.doc,"h4",{class:`${N.panel}__subtitle`,text:this.t(a)})),l}#d(a,l,r,t){const n=$(this.doc,"select",{class:`${N.panel}__select`,attrs:{"aria-label":this.t(a)}});for(const i of l)n.appendChild($(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===r?!0:null}}));return n.value=r,this.off.push(L(n,"change",()=>t(n.value))),$(this.doc,"label",{class:`${N.panel}__field`,children:[$(this.doc,"span",{class:`${N.panel}__label`,text:this.t(a)}),n]})}}}),Se("packages/dom/src/ui/toolpanel.js",function(e,V){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return K}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.cssEscape,L=_.documentFor,W=_.el,Z=_.on,H=_.clear,z=V("packages/core/src/i18n/index.js").defaultMessages,F=V("packages/core/src/internal/util.js"),k=F.isFunction,S=F.nextFrame,b=V("packages/dom/src/cell/icons.js"),a=b.createIcon,l=b.updateIcon,r=b.icon,n=V("packages/dom/src/viewpicker.js").ViewPicker,o=V("packages/dom/src/formattingpanel.js").FormattingPanel,d=V("packages/dom/src/statisticspanel.js").StatisticsPanel,h=V("packages/dom/src/regressionpanel.js").RegressionPanel,y=V("packages/dom/src/comparepanel.js").ComparePanel,m=V("packages/dom/src/insightspanel.js").InsightsPanel,v=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,s=V("packages/core/src/compute/total.js").TOTAL_LABELS;class O extends v{dragging=null;refresh(){const j=this.root;if(!j)return;for(const Q of this.off)Q();this.off.length=0,H(j);const T=W(this.doc,"input",{class:`${N.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(Z(T,"input",()=>{this.query=T.value,this.paintList()})),j.appendChild(T),j.appendChild(this.buildZone("group","Row groups")),j.appendChild(this.buildZone("values","Grouped row calculation")),j.appendChild(this.buildZone("pivot","Pivot"));const B=W(this.doc,"div",{class:`${N.panel}__heading`});B.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${N.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),X=W(this.doc,"button",{class:`${N.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(Z(q,"click",()=>{const Q=this.columns().filter(te=>!(te.layout&&te.layout.lockVisible)).map(te=>te.id);k(this.host.showColumns)&&this.host.showColumns(Q),this.refresh()})),this.off.push(Z(X,"click",()=>{const Q=this.columns().filter(te=>!(te.layout&&te.layout.lockVisible)).map(te=>te.id);k(this.host.hideColumns)&&this.host.hideColumns(Q),this.refresh()})),B.appendChild(q),B.appendChild(X),j.appendChild(B),this.list=W(this.doc,"div",{class:`${N.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),j.appendChild(this.list),this.paintList()}columns(){const j=this.host;return k(j.columns)?j.columns()||[]:j.columns&&k(j.columns.all)?j.columns.all():[]}paintList(){const j=this.list;if(!j)return;H(j);const T=String(this.query||"").trim().toLowerCase();for(const B of this.columns()){const q=String(B.title||B.id||"");if(T&&!q.toLowerCase().includes(T))continue;const X=W(this.doc,"div",{class:`${N.panel}__column`,attrs:{"data-col":B.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});X.appendChild(W(this.doc,"span",{class:`${N.panel}__grip`,attrs:{"aria-hidden":"true"}}));const Q=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});Q.checked=!(B.layout&&B.layout.hidden),B.layout&&B.layout.lockVisible&&Q.setAttribute("disabled",""),this.off.push(Z(Q,"change",()=>this.setVisible(B.id,Q.checked))),X.appendChild(Q),X.appendChild(W(this.doc,"span",{text:q})),X.setAttribute("tabindex","0"),X.setAttribute("role","listitem"),this.off.push(Z(X,"keydown",te=>this.onRowKey(te,B))),this.off.push(Z(X,"dragstart",()=>{this.dragging=B.id})),this.off.push(Z(X,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(Z(X,"dragover",te=>{if(!this.dragging||this.dragging===B.id)return;k(te.preventDefault)&&te.preventDefault();const re=x(te,X);X.setAttribute("data-drop",re?"before":"after")})),this.off.push(Z(X,"dragleave",()=>X.removeAttribute("data-drop"))),this.off.push(Z(X,"drop",te=>{k(te.preventDefault)&&te.preventDefault();const re=this.dragging;this.dragging=null,this.clearDropMark(),!(!re||re===B.id)&&this.moveColumn(re,B.id,x(te,X))})),j.appendChild(X)}}onRowKey(j,T){const B=j&&j.key,q=O.zoneKeys[String(B).toLowerCase()];if(q&&!j.ctrlKey&&!j.metaKey&&!j.altKey){k(j.preventDefault)&&j.preventDefault(),this.toggleZone(q,T);return}if(B!=="ArrowUp"&&B!=="ArrowDown")return;const X=B==="ArrowUp",Q=this.columns().map(J=>J.id),te=Q.indexOf(T.id);if(te<0)return;if(k(j.preventDefault)&&j.preventDefault(),!j.shiftKey){const J=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],se=J.findIndex(oe=>oe.getAttribute("data-col")===T.id),le=J[se+(X?-1:1)];le&&k(le.focus)&&le.focus();return}const re=T.layout&&(T.layout.movable===!1||T.layout.lockPosition),ie=String(T.title||T.id||"");if(re){this.announce(this.t("a11y.panel.cannotMove",{column:ie}),{repeat:!0});return}const ae=Q[te+(X?-1:1)];if(!ae){this.announce(this.t(X?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ie}),{repeat:!0});return}this.moveColumn(T.id,ae,X),this.announce(this.t("a11y.panel.moved",{column:ie,at:X?te:te+2,of:Q.length}),{repeat:!0});const ee=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(T.id)}"]`):null;ee&&k(ee.focus)&&ee.focus()}toggleZone(j,T){const B=this.titleOf(T.id),q=this.t(O.zoneLabel[j]||"panel.zone.group");if(this.zoneColumns(j).includes(T.id)){this.dropFromZone(j,T.id),this.announce(this.t("a11y.panel.removedFrom",{column:B,list:q}),{repeat:!0}),this.restoreFocus(T.id);return}if(this.addToZone(j,T.id)){this.announce(this.t("a11y.panel.addedTo",{column:B,list:q}),{repeat:!0}),this.restoreFocus(T.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:B,list:q}),{repeat:!0})}restoreFocus(j){const T=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(j)}"]`):null;T&&k(T.focus)&&T.focus()}announce(j,T){const B=this.host||{};k(B.announce)&&B.announce(j,T)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const j of this.list.querySelectorAll("[data-drop]"))j.removeAttribute("data-drop")}moveColumn(j,T,B){const q=this.host||{};k(q.moveColumn)&&(q.moveColumn(j,T,B),this.refresh())}buildZone(j,T){const B=W(this.doc,"div",{class:`${N.panel}__zone`,attrs:{"data-zone":j,role:"group","aria-label":T}});B.appendChild(W(this.doc,"div",{class:`${N.panel}__zoneTitle`,text:T}));const q=this.zoneColumns(j);let X=O.zoneAbout[j]||"";j==="values"&&q.length&&!this.zoneColumns("group").length&&(X+=" Add a row group to see them."),X&&B.appendChild(W(this.doc,"div",{class:`${N.panel}__zoneAbout`,text:X}));const Q=W(this.doc,"div",{class:`${N.panel}__zoneBody`});q.length||Q.appendChild(W(this.doc,"span",{class:`${N.panel}__zoneHint`,text:this.t(O.zoneHint[j]||"panel.zoneHint.any")})),j==="values"&&Q.classList.add(`${N.panel}__zoneBody--rows`);for(const te of q){const re=W(this.doc,"span",{class:[N.chip,j==="values"?`${N.chip}--row`:""]});if(re.appendChild(W(this.doc,"span",{class:`${N.chip}__label`,text:this.titleOf(te)})),j==="values"&&k(this.host.setValueAggregation)){const ae=k(this.host.valueAggregation)?this.host.valueAggregation(te):"sum",ee=W(this.doc,"select",{class:`${N.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(te)}`}});for(const J of O.aggregations)ee.appendChild(W(this.doc,"option",{text:this.t(`total.${J.name}`),attrs:{value:J.name,selected:J.name===ae?"":null}}));ee.value=ae,this.off.push(Z(ee,"change",()=>{this.host.setValueAggregation(te,ee.value),this.refresh()})),re.appendChild(ee)}const ie=W(this.doc,"button",{class:N.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(te)}`}});this.off.push(Z(ie,"click",()=>this.dropFromZone(j,te))),re.appendChild(ie),Q.appendChild(re)}return this.off.push(Z(B,"dragover",te=>{k(te.preventDefault)&&te.preventDefault(),B.setAttribute("data-over","true")})),this.off.push(Z(B,"dragleave",()=>B.removeAttribute("data-over"))),this.off.push(Z(B,"drop",te=>{k(te.preventDefault)&&te.preventDefault(),B.removeAttribute("data-over"),this.dragging&&this.addToZone(j,this.dragging)})),B.appendChild(Q),B}static aggregations=Object.freeze(Object.keys(s).map(j=>({name:j})));static zoneAbout=Object.freeze({group:"Rows are grouped by these columns, in order.",values:"Each column here is calculated for every group. Pick the calculation on its chip.",pivot:"Generates a column for each distinct value."});static zoneHint=Object.freeze({group:"panel.zoneHint.group",values:"panel.zoneHint.values",pivot:"panel.zoneHint.pivot"});static zoneKeys=Object.freeze({g:"group",v:"values",p:"pivot"});static zoneLabel=Object.freeze({group:"panel.zone.group",values:"panel.zone.values",pivot:"panel.zone.pivot"});static zoneApi=Object.freeze({group:{read:"groupBy",write:"setGroupBy",permission:"allowGroup"},values:{read:"valueColumns",write:"setValueColumns",permission:"allowTotal"},pivot:{read:"pivotBy",write:"setPivotBy",permission:"allowPivot"}});zoneColumns(j){const T=O.zoneApi[j],B=this.host;return T&&k(B[T.read])?B[T.read]()||[]:[]}titleOf(j){const T=this.columns().find(B=>B.id===j);return String(T&&(T.title||T.id)||j)}addToZone(j,T){const B=O.zoneApi[j],q=this.columns().find(Q=>Q.id===T);if(!B||!q||q[B.permission]===!1||!k(this.host[B.write]))return!1;const X=this.zoneColumns(j);return X.includes(T)?!1:(this.host[B.write]([...X,T]),this.refresh(),!0)}dropFromZone(j,T){const B=O.zoneApi[j];return!B||!k(this.host[B.write])?!1:(this.host[B.write](this.zoneColumns(j).filter(q=>q!==T)),this.refresh(),!0)}setVisible(j,T){const B=this.host;T&&k(B.showColumns)?B.showColumns([j]):!T&&k(B.hideColumns)&&B.hideColumns([j])}}class E extends v{open=new Set;query="";#e=!1;#t=!1;refresh(){if(this.#e){this.#t=!0;return}this.#e=!0;try{do this.#t=!1,this.#n();while(this.#t)}finally{this.#e=!1}}#n(){const j=this.root;if(!j)return;for(const re of this.off)re();this.off.length=0,H(j);const T=this.host,B=(k(T.columns)?T.columns():[]).filter(re=>!(re.filter&&re.filter.enabled===!1));if(!k(T.filterFor))return;const q=B.filter(re=>this.isFiltered(re.id));j.appendChild(this.buildSearch()),j.appendChild(this.buildSummary(q.length,B.length));const X=this.query.trim().toLowerCase(),Q=X?B.filter(re=>String(re.title||re.id).toLowerCase().includes(X)):B;if(!Q.length){j.appendChild(W(this.doc,"p",{class:`${N.panel}__empty`,text:X?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const te=W(this.doc,"div",{class:`${N.panel}__filters`});for(const re of Q)te.appendChild(this.buildSection(re));j.appendChild(te)}isFiltered(j){const T=this.host;return k(T.isFiltered)?T.isFiltered(j)===!0:!1}buildSearch(){const j=W(this.doc,"input",{class:`${N.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return j.value=this.query,this.off.push(Z(j,"input",()=>{this.query=j.value||"",this.refresh();const T=this.root&&this.root.querySelector?this.root.querySelector(`.${N.panel}__search`):null;T&&k(T.focus)&&T.focus()})),j}buildSummary(j,T){const B=W(this.doc,"div",{class:`${N.panel}__filterSummary`});if(B.appendChild(W(this.doc,"span",{class:`${N.panel}__filterCount`,text:j?this.t("panel.filterSummaryActive",{active:j,total:T}):this.t("panel.filterSummaryNone",{total:T}),attrs:{"data-active":j?"true":"false"}})),!j)return B;const q=W(this.doc,"button",{class:`${N.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(Z(q,"click",()=>{k(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),B.appendChild(q),B}buildSection(j){const T=j.id,B=String(j.title||T),q=this.isFiltered(T),X=this.open.has(T),Q=W(this.doc,"section",{class:`${N.panel}__filter`,attrs:{"data-col":T,"data-filtered":q?"true":null}}),te=W(this.doc,"button",{class:`${N.panel}__filterTitle`,attrs:{type:"button","aria-expanded":X?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:B})},children:[a(this.doc,X?"chevronDown":"chevronRight",{className:`${N.panel}__twisty`}),W(this.doc,"span",{class:`${N.panel}__filterName`,text:B})]});q&&te.appendChild(W(this.doc,"span",{class:`${N.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const re=W(this.doc,"div",{class:`${N.panel}__filterBody`,style:{display:X?"":"none"}}),ie=()=>{if(re.firstChild)return;const ae=this.host.filterFor(T);ae&&k(ae.element)&&re.appendChild(ae.element())};if(this.off.push(Z(te,"click",()=>{const ae=this.open.has(T);ae?this.open.delete(T):this.open.add(T),te.setAttribute("aria-expanded",ae?"false":"true"),re.style.display=ae?"none":"";const ee=te.firstElementChild;ee&&l(ee,ae?"chevronRight":"chevronDown"),ae||ie()})),Q.appendChild(te),q){const ae=W(this.doc,"button",{class:`${N.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:B}),title:this.t("panel.clearFilter")},children:[a(this.doc,"close",{className:N.icon})]});this.off.push(Z(ae,"click",ee=>{k(ee.stopPropagation)&&ee.stopPropagation(),k(this.host.clearFilter)&&this.host.clearFilter(T),this.refresh()})),Q.appendChild(ae)}return Q.appendChild(re),X&&ie(),Q}}class A extends v{refresh(){const j=this.root;if(!j)return;if(this.box){const X=k(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==X&&(this.box.value=X),this.paintCount();return}for(const X of this.off)X();this.off.length=0,H(j);const T=k(this.host.quickFilter)?this.host.quickFilter():"",B=W(this.doc,"input",{class:`${N.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});B.value=T||"",this.off.push(Z(B,"input",()=>{k(this.host.setQuickFilter)&&this.host.setQuickFilter(B.value),this.paintCount()})),j.appendChild(B),this.box=B;const q=W(this.doc,"button",{class:`${N.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(Z(q,"click",()=>{B.value="",k(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),k(B.focus)&&B.focus()})),j.appendChild(q),this.count=W(this.doc,"p",{class:`${N.panel}__count`}),j.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){S(()=>{this.box&&k(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const j=k(this.host.rowCount)?this.host.rowCount():null,T=k(this.host.totalRowCount)?this.host.totalRowCount():null;if(j===null||T===null){this.count.textContent="";return}this.count.textContent=j===T?this.t("count.rows",{count:T}):this.t("panel.rowsOf",{shown:j,total:T})}}const M=Object.freeze({columns:O,filters:E,views:n,quick:A,formatting:o,statistics:d,regression:h,compare:y,insights:m}),C=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class D{panels=[];actions=[];root=null;openPanel=null;off=[];t(j,T){return(this.messages&&typeof this.messages.t=="function"?this.messages:z).t(j,T)}init(j){const T=j||{};this.doc=L(T),this.host=T.host||{},this.messages=T.messages||T.grid&&T.grid.messages||z,this.icons=T.icons===void 0?T.side==="left":!!T.icons,this.side=T.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[N.panel,`${N.panel}--${this.side}`,this.icons?`${N.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${N.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${N.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=W(this.doc,"div",{class:`${N.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const X of Array.isArray(T.actions)?T.actions:[])this.registerAction(X);const B=T.registry||{},q=Array.isArray(T.panels)&&T.panels.length?T.panels:["columns","filters"];for(const X of q){const Q=typeof X=="string"?X:X.name,te=typeof X=="function"?X:B[Q]||M[Q];te&&this.registerPanel(String(Q),te,typeof X=="object"?X:{})}T.openPanel&&this.show(T.openPanel)}registerPanel(j,T,B){const q=new T;q.init({document:this.doc,host:this.host,props:B&&B.props||{}});const X=B&&B.title||j,Q=B&&B.icon||j,te=W(this.doc,"button",{class:`${N.panel}__tab`,text:this.icons?null:X,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":j,title:this.icons?X:null,"aria-label":this.icons?X:null}});return this.icons&&te.appendChild(a(this.doc,Q,{className:`${N.panel}__icon`})),this.off.push(Z(te,"click",()=>this.toggle(j))),this.tabs.appendChild(te),this.panels.push({name:j,title:X,panel:q}),q}registerAction(j){if(!j||!j.name)return null;if(j.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${N.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const T=W(this.doc,"button",{class:`${N.panel}__action`,text:this.icons?null:k(j.title)?String(j.title()):j.title,attrs:{type:"button","data-action":j.name,title:k(j.title)?null:j.title,"aria-label":k(j.title)?null:j.title}});if(this.icons){const X=(k(j.icon)?j.icon():j.icon)||(r(j.name)?j.name:"blank");T.appendChild(a(this.doc,X,{className:`${N.panel}__icon`})),T.setAttribute("data-icon",X)}const B=Z(T,"click",()=>{k(j.enabled)&&!j.enabled()||(k(j.run)&&j.run(),this.paintActions())});return this.off.push(B),this.actionGroup.appendChild(T),this.actions.push({...j,button:T,offClick:B}),this.paintActions(),T}removeAction(j){const T=this.actions.findIndex(q=>q.name===j);if(T<0)return!1;const B=this.actions[T];return k(B.offClick)&&B.offClick(),B.button&&B.button.parentNode&&B.button.parentNode.removeChild(B.button),this.actions.splice(T,1),!0}paintActions(){for(const j of this.actions){if(!j.button)continue;const T=k(j.enabled)?!!j.enabled():!0;if(j.button.disabled=!T,j.button.setAttribute("aria-disabled",T?"false":"true"),k(j.active)&&j.button.setAttribute("aria-pressed",j.active()?"true":"false"),k(j.title)){const B=String(j.title());j.button.setAttribute("title",B),j.button.setAttribute("aria-label",B),!this.icons&&j.button.textContent!==B&&(j.button.textContent=B)}if(this.icons&&k(j.icon)){const B=String(j.icon());j.button.getAttribute("data-icon")!==B&&(H(j.button),j.button.appendChild(a(this.doc,B,{className:`${N.panel}__icon`})),j.button.setAttribute("data-icon",B))}}}show(j){const T=this.panels.find(B=>B.name===j);return T?(H(this.body),k(T.panel.refresh)&&T.panel.refresh(),this.body.appendChild(T.panel.element()),this.openPanel=j,this.paintTabs(),k(T.panel.focus)&&T.panel.focus(),!0):!1}hide(){H(this.body),this.openPanel=null,this.paintTabs()}toggle(j){this.openPanel===j?this.hide():this.show(j)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let j=0;j<this.tabs.childNodes.length;j++){const T=this.tabs.childNodes[j];T&&T.setAttribute&&T.setAttribute("aria-selected",T.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const j=this.panels.find(T=>T.name===this.openPanel);j&&k(j.panel.refresh)&&!this.#e(j.panel)&&j.panel.refresh(),this.paintActions()}#e(j){const T=this.doc&&this.doc.activeElement;if(!T||T===this.doc.body)return!1;const B=k(j.element)?j.element():null;return!!(B&&k(B.contains)&&B.contains(T))}destroy(){for(const j of this.off)j();this.off.length=0;for(const j of this.panels)k(j.panel.destroy)&&j.panel.destroy();this.panels=[],this.root=null}}const K=D;function x(I,j){if(!j.getBoundingClientRect||typeof I.clientY!="number")return!0;const T=j.getBoundingClientRect();return I.clientY<T.top+T.height/2}}),Se("packages/dom/src/ui/groupbyzone.js",function(e,V){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return S}});const N=V("packages/dom/src/ui/panelbase.js").ToolPanelBase,$=V("packages/dom/src/editors/common.js"),L=$.CLS,W=$.el,Z=$.on,H=$.clear,U=$.cssEscape,F=V("packages/core/src/internal/util.js").isFunction,k="text/x-lattice-col";class S extends N{dragging=null;#e=[];init(a){this.ctx=a,this.doc=a.document,this.host=a.host||{},this.props=a.props||{},this.root=W(this.doc,"div",{class:L.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const a=this.host;return F(a.columns)?a.columns()||[]:a.columns&&F(a.columns.all)?a.columns.all():[]}groups(){return F(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(a){F(this.host.setGroupBy)&&this.host.setGroupBy(a)}titleOf(a){const l=this.columns().find(r=>r.id===a);return String(l&&(l.title||l.id)||a)}canGroup(a){const l=this.columns().find(r=>r.id===a);return!!l&&l.allowGroup!==!1&&!l.generated}announce(a,l){F(this.host.announce)&&this.host.announce(a,l)}refresh(){const a=this.root;if(!a)return;for(const t of this.off)t();this.off.length=0,H(a),a.appendChild(W(this.doc,"span",{class:L.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const l=this.groups(),r=W(this.doc,"div",{class:L.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});l.length||r.appendChild(W(this.doc,"span",{class:L.groupZoneHint,text:this.t("groupZone.hint")})),l.forEach((t,n)=>r.appendChild(this.#t(t,n,l.length))),a.appendChild(r),this.chips=r,a.appendChild(this.#i(l)),this.off.push(Z(a,"dragover",t=>{this.dragging==null&&!this.#s(t)||(F(t.preventDefault)&&t.preventDefault(),a.setAttribute("data-over","true"))})),this.off.push(Z(a,"dragleave",()=>a.removeAttribute("data-over"))),this.off.push(Z(a,"drop",t=>{F(t.preventDefault)&&t.preventDefault(),a.removeAttribute("data-over");const n=this.#s(t)||this.dragging;n!=null&&this.#o(n,this.groups().length)})),this.#a()}#t(a,l,r){const t=this.titleOf(a),n=W(this.doc,"div",{class:[L.chip,L.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":a,"aria-label":this.t("groupZone.chip",{column:t,at:l+1,of:r})}});n.appendChild(W(this.doc,"span",{class:L.groupZoneChipText,text:t}));const i=W(this.doc,"button",{class:L.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:t})}});return this.off.push(Z(i,"click",()=>this.#r(a))),n.appendChild(i),this.off.push(Z(n,"dragstart",o=>{this.dragging=a,o.dataTransfer&&F(o.dataTransfer.setData)&&o.dataTransfer.setData(k,a)})),this.off.push(Z(n,"dragend",()=>{this.dragging=null})),this.off.push(Z(n,"dragover",o=>{const c=this.#s(o)||this.dragging;c==null||c===a||F(o.preventDefault)&&o.preventDefault()})),this.off.push(Z(n,"drop",o=>{const c=this.#s(o)||this.dragging;c!=null&&(F(o.preventDefault)&&o.preventDefault(),F(o.stopPropagation)&&o.stopPropagation(),this.#o(c,l))})),this.off.push(Z(n,"keydown",o=>this.#n(o,a,l))),n}#n(a,l,r){const t=a&&a.key,n=this.groups();if(t==="Delete"||t==="Backspace"){F(a.preventDefault)&&a.preventDefault(),this.#r(l,n,r);return}const i=t==="ArrowLeft"||t==="ArrowUp",o=t==="ArrowRight"||t==="ArrowDown",c=t==="Home",d=t==="End";if(!i&&!o&&!c&&!d)return;if(F(a.preventDefault)&&a.preventDefault(),a.shiftKey&&(i||o)){const g=r+(i?-1:1);if(g<0||g>=n.length){this.announce(this.t(i?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(l)}),{repeat:!0});return}const y=n.slice();y.splice(r,1),y.splice(g,0,l),this.setGroups(y),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(l),at:g+1,of:y.length}),{repeat:!0}),this.#l(l);return}let f=r+(i?-1:o?1:0);c&&(f=0),d&&(f=n.length-1);const h=n[f];h&&this.#l(h)}#r(a,l=this.groups(),r=l.indexOf(a)){const t=this.titleOf(a);this.setGroups(l.filter(i=>i!==a)),this.announce(this.t("a11y.panel.removedFrom",{column:t,list:this.t("panel.zone.group")}),{repeat:!0});const n=this.groups();n.length?this.#l(n[Math.min(r,n.length-1)]):this.#u()}#o(a,l){if(!this.canGroup(a)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(a),list:this.t("panel.zone.group")}),{repeat:!0});return}const r=this.groups(),t=r.indexOf(a),n=r.slice();t>=0&&(n.splice(t,1),t<l&&(l-=1)),n.splice(Math.max(0,Math.min(l,n.length)),0,a),this.setGroups(n);const i=n.indexOf(a);this.announce(this.t(t>=0?"a11y.panel.moved":"a11y.panel.addedTo",t>=0?{column:this.titleOf(a),at:i+1,of:n.length}:{column:this.titleOf(a),list:this.t("panel.zone.group")}),{repeat:!0}),this.#l(a)}#i(a){const l=new Set(a),r=W(this.doc,"label",{class:L.groupZoneAdd}),t=W(this.doc,"select",{class:L.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});t.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const n of this.columns())l.has(n.id)||!this.canGroup(n.id)||t.appendChild(W(this.doc,"option",{text:this.titleOf(n.id),attrs:{value:n.id}}));return this.off.push(Z(t,"change",()=>{const n=t.value;n&&this.#o(n,this.groups().length)})),this.adderSelect=t,r.appendChild(t),r}#a(){for(const l of this.#e)l();this.#e.length=0;const a=this.props&&this.props.header;if(!(!a||!F(a.querySelectorAll)))for(const l of a.querySelectorAll("[data-col]")){const r=F(l.getAttribute)?l.getAttribute("data-col"):null;!r||!this.canGroup(r)||(F(l.setAttribute)&&l.setAttribute("draggable","true"),this.#e.push(Z(l,"dragstart",t=>{this.dragging=r,t.dataTransfer&&F(t.dataTransfer.setData)&&t.dataTransfer.setData(k,r)})),this.#e.push(Z(l,"dragend",()=>{this.dragging=null})))}}#s(a){const l=a&&a.dataTransfer;if(l&&F(l.getData)){const r=l.getData(k);if(r)return r}return null}#l(a){const l=this.chips&&F(this.chips.querySelector)?this.chips.querySelector(`[data-col="${U(a)}"]`):null;l&&F(l.focus)&&l.focus()}#u(){this.adderSelect&&F(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const a of this.#e)a();this.#e.length=0,super.destroy()}}}),Se("packages/dom/src/ui/tooltip.js",function(e,V){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/internal/util.js").isFunction;class z{root=null;init(b){this.doc=b.document,this.root=L(this.doc,"div",{class:`${N.tooltip}__text`}),this.update(b.content)}update(b){if(!this.root)return;const a=b==null?"":String(b);this.root.textContent!==a&&(this.root.textContent=a)}element(){return this.root}destroy(){this.root=null}}class F{root=null;component=null;timer=null;target=null;off=[];constructor(b){const a=b||{};this.doc=$(a),this.host=a.host||this.doc.body,this.delay=a.delay??400,this.hideDelay=a.hideDelay??0,this.components={text:z,...a.components||{}}}show(b){this.cancelTimer();const a=b.delay??this.delay;if(!a){this.showNow(b);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(b)},a)}showNow(b){const a=b.component||"text",l=typeof a=="function"?a:this.components[a]||z;return this.root||(this.root=L(this.doc,"div",{class:N.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==l?(this.component&&U(this.component.destroy)&&this.component.destroy(),Z(this.root),this.component=new l,this.componentCtor=l,this.component.init({document:this.doc,content:b.content,...b.props||{}}),this.root.appendChild(this.component.element())):U(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||!U(this.target.getBoundingClientRect))return;const b=this.target.getBoundingClientRect(),a=this.doc.defaultView||{};this.root.style.left=`${b.left+(a.scrollX||0)}px`,this.root.style.top=`${b.bottom+(a.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,a,l){const r=()=>this.show({target:b,content:a(),...l||{}}),t=()=>this.hide(),n=[W(b,"mouseenter",r),W(b,"mouseleave",t),W(b,"focus",r),W(b,"blur",t)],i=()=>{for(const o of n)o()};return this.off.push(i),i}destroy(){this.hide();for(const b of this.off)b();this.off.length=0,this.component&&U(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const k=F}),Se("packages/dom/src/ui/pagination.js",function(e,V){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.documentFor,L=_.el,W=_.on,Z=_.clear,U=V("packages/core/src/i18n/index.js").defaultMessages,F=V("packages/core/src/internal/util.js").isFunction;function k(a){const l=Math.max(1,Number(a.pageSize)||100),r=a.total==null?null:Math.max(0,Number(a.total)),t=r==null?null:Math.max(1,Math.ceil(r/l)),n=Math.max(0,t==null?Number(a.page)||0:Math.min(Number(a.page)||0,t-1)),i=r===0?0:n*l+1,o=r==null?(n+1)*l:Math.min(r,(n+1)*l);return{page:n,pageSize:l,pageCount:t,from:i,to:o,first:n===0,last:t==null?a.hasMore!==!0:n>=t-1,total:r}}class S{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(l){const r=l||{};this.doc=$(r),this.host=r.host||{},this.pageSize=Number(r.pageSize)||100;const t=Array.isArray(r.pageSizes)&&r.pageSizes.length?[...r.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!t.includes(this.pageSize)&&t.push(this.pageSize),this.pageSizes=t.sort((n,i)=>n-i),this.page=Number(r.page)||0,this.total=r.total===void 0?null:r.total,this.locale=r.locale,this.messages=r.messages||null,this.onChange=r.onChange||null,this.root=L(this.doc,"nav",{class:N.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(l,r){const t=this.messages;return(t&&typeof t.t=="function"?t:U).t(l,r)}element(){return this.root}model(){return k({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(l){l.total!==void 0&&(this.total=l.total),l.counting!==void 0&&(this.counting=l.counting===!0),l.hasMore!==void 0&&(this.hasMore=l.hasMore===!0),l.page!==void 0&&(this.page=Number(l.page)||0),this.paint()}goTo(l){const r=this.page;this.page=l;const t=this.model();return this.page=t.page,this.paint(),this.page!==r&&F(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 l=this.model();return l.pageCount==null?this.page:this.goTo(l.pageCount-1)}setPageSize(l){const r=this.page*this.pageSize;this.pageSize=Math.max(1,Number(l)||1),this.page=Math.floor(r/this.pageSize),this.paint(),F(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const l=this.root;if(!l)return;for(const f of this.off)f();this.off.length=0,Z(l);const r=this.model(),t=L(this.doc,"select",{class:`${N.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const f of this.pageSizes)t.appendChild(L(this.doc,"option",{text:String(f),attrs:{value:f}}));t.value=String(this.pageSize),this.off.push(W(t,"change",()=>this.setPageSize(Number(t.value)))),l.appendChild(t);const n=r.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:r.from,to:r.to}):this.t("pagination.summary",{from:r.from,to:r.to,total:r.total});l.appendChild(L(this.doc,"span",{class:`${N.pagination}__summary`,text:n}));const i=(f,h,g,y)=>{const p=L(this.doc,"button",{class:`${N.pagination}__button`,text:f,attrs:{type:"button","aria-label":y,disabled:g?"":null}});return g||this.off.push(W(p,"click",h)),p};l.appendChild(i("«",()=>this.goTo(0),r.first,this.t("pagination.first"))),l.appendChild(i("‹",()=>this.previous(),r.first,this.t("pagination.previous")));const o=L(this.doc,"span",{class:`${N.pagination}__page`});o.appendChild(L(this.doc,"span",{text:`${this.t("pagination.page")} `}));const c=L(this.doc,"input",{class:`${N.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":r.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:r.pageCount}),size:String(Math.max(2,String(r.pageCount??r.page+1).length))}});c.value=String(r.page+1);const d=()=>{const f=parseInt(String(c.value).trim(),10);if(!Number.isFinite(f)){c.value=String(this.model().page+1);return}this.goTo(f-1)};this.off.push(W(c,"keydown",f=>{f.key==="Enter"?(d(),f.preventDefault?.()):f.key==="Escape"?(c.value=String(this.model().page+1),c.blur?.()):f.stopPropagation?.()})),this.off.push(W(c,"blur",()=>d())),this.off.push(W(c,"focus",()=>c.select?.())),o.appendChild(c),r.pageCount!=null&&o.appendChild(L(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:r.pageCount})}`})),l.appendChild(o),l.appendChild(i("›",()=>this.next(),r.last,this.t("pagination.next"))),l.appendChild(i("»",()=>this.last(),r.last||r.pageCount==null,this.t("pagination.last")))}destroy(){for(const l of this.off)l();this.off.length=0,this.root=null}}const b=S}),Se("packages/dom/src/ui/overlay.js",function(e,V){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const _=V("packages/dom/src/editors/common.js"),N=_.CLS,$=_.documentFor,L=_.el,W=_.clear,H=V("packages/core/src/internal/util.js").isFunction,z=V("packages/core/src/i18n/index.js").defaultMessages;function F(r,t){const n=r&&r.grid&&r.grid.messages;return(n&&H(n.t)?n:z).t(t)}class k{root=null;init(t){this.doc=t.document,this.root=L(this.doc,"div",{class:`${N.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[L(this.doc,"span",{class:`${N.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),L(this.doc,"span",{class:`${N.overlay}__message`,text:t.message||F(t,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class S{root=null;init(t){this.doc=t.document,this.root=L(this.doc,"div",{class:`${N.overlay}__empty`,attrs:{role:"status"},children:[L(this.doc,"span",{class:`${N.overlay}__message`,text:t.message||F(t,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const b=Object.freeze({loading:k,empty:S});class a{root=null;slot=null;component=null;current=null;init(t){const n=t||{};this.doc=$(n),this.components={...b,...n.components||{}},this.root=L(this.doc,"div",{class:N.overlay,attrs:{"data-open":"false"}}),this.slot=L(this.doc,"div",{class:`${N.overlay}__slot`}),this.root.appendChild(this.slot),n.host&&n.host.appendChild(this.root)}element(){return this.root}show(t,n){const i=typeof t=="function"?t:this.components[t];return i?(this.hide(),this.component=new i,this.component.init({document:this.doc,message:n&&n.message,...n&&n.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof t=="string"?t:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&H(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&W(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(t,n){this.components[t]=n}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const l=a}),Se("packages/dom/src/ui/index.js",function(e,V){"use strict";const _=V("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return _.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return _.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return _.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return _.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return _.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return _.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return _.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return _.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return _.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return _.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return _.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return _.formatNumber}});const N=V("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return N.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return N.resolveMenuItems}});const $=V("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return $.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return $.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return $.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return $.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return $.toolPanels}});const L=V("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return L.GroupByZone}});const W=V("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return W.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return W.TextTooltip}});const Z=V("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return Z.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return Z.pageModel}});const H=V("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return H.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return H.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return H.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return H.overlays}})}),Se("packages/dom/src/ui/celltooltip.js",function(e,V){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const _=V("packages/dom/src/editors/common.js"),N=_.documentFor,$=_.el,L=_.on,W=_.clear,Z=V("packages/core/src/internal/util.js"),H=Z.isFunction,U=Z.warnOnce,F=V("packages/dom/src/cell/sanitise.js").sanitiseHtml,S=V("packages/dom/src/detailhost.js").insideDetail,a=V("packages/dom/src/renderer/renderer.js").displayIndexOf,l=V("packages/dom/src/renderer/viewport.js"),r=l.CLASS,t=l.NAMESPACE,n={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},i=400,o=140,c=6;let d=0;class f{#e;#t;#n;#r;#o=null;#i=null;#a;#s=!1;#l=null;#u=null;#c=null;#d=null;#h=null;#f=[];#m=!1;constructor(y){const p=y||{};this.#e=p.grid,this.#t=p.host,this.#n=p.viewport,this.#r=N(p),d+=1,this.#a=`lat-cell-tooltip-${d}`}mount(){const y=this.#n&&this.#n.root;if(!y||!H(y.addEventListener))return;const p=this.#e.on("cell:mouseover",v=>this.#y(v));H(p)&&this.#f.push(p);const m=this.#e.on("cell:mouseout",()=>this.#j());H(m)&&this.#f.push(m),this.#f.push(L(y,"focusin",v=>this.#b(v))),this.#f.push(L(y,"focusout",()=>this.#j())),this.#f.push(L(this.#r,"keydown",v=>this.#w(v),!0));const w=this.#r.defaultView;w&&H(w.addEventListener)&&this.#f.push(L(w,"scroll",()=>this.hide(),!0))}#p(){const y=H(this.#e.get)?this.#e.get("tooltip"):null,p=y&&typeof y=="object"?y:{},m=Number.isFinite(p.delay)&&p.delay>=0?Number(p.delay):i,w=p.maxWidth;return{delay:m,hideDelay:o,maxWidth:typeof w=="number"&&Number.isFinite(w)?`${w}px`:typeof w=="string"&&w?w:null}}#g(y){const p=y&&y.cell?y.cell.tooltip:null;return!p||typeof p!="object"||Array.isArray(p)||!H(p.render)&&!H(p.mount)?null:p}#v(y){if(!y||!H(y.closest))return null;const p=y.closest(`.${r.row}`);if(!p)return null;const m=a(p);if(m<0)return null;const w=this.#t.rowAt(m);if(!w)return null;const v=y.getAttribute("data-col");if(!v)return null;const u=this.#t.columns.get(v);return u?{row:w,key:w.key,index:m,colId:v,column:u,value:this.#t.cellValue?this.#t.cellValue(w,u):void 0,text:this.#t.cellText?this.#t.cellText(w,u):"",cell:y,grid:this.#e}:null}#y(y){const p=y&&y.target;if(!this.#g(y&&y.column)){this.#j();return}this.#S(p)}#b(y){const p=y&&y.target;if(!p||!H(p.closest)||S(p,this.#n.root))return;const m=p.closest(`.${r.cell}`);if(!m||m!==p){this.#j();return}const w=m.getAttribute("data-col"),v=w?this.#t.columns.get(w):null;if(!this.#g(v)){this.#j();return}this.#S(m)}#w(y){!y||y.key!=="Escape"||y.defaultPrevented||this.#s&&(H(y.preventDefault)&&y.preventDefault(),this.hide())}#S(y){if(this.#m||!y||(this.#N(),this.#s&&this.#l===y))return;this.#R();const{delay:p}=this.#p();if(!p){this.#E(y);return}this.#d=setTimeout(()=>{this.#d=null,this.#E(y)},p)}#j(){if(this.#R(),!this.#s||this.#h!==null)return;const{hideDelay:y}=this.#p();this.#h=setTimeout(()=>{this.#h=null,this.hide()},y)}#A(){if(this.#o)return this.#o;const y=this.#r,p=$(y,"div",{class:[t,n.tooltip],attrs:{id:this.#a,role:"tooltip","data-open":"false"}});this.#i=$(y,"div",{class:n.body}),p.appendChild(this.#i),this.#f.push(L(p,"mouseenter",()=>this.#N())),this.#f.push(L(p,"mouseleave",()=>this.#j()));const m=y.body;return m&&H(m.appendChild)&&m.appendChild(p),this.#o=p,p}#O(y,p){const m=this.#i;if(W(m),y==null||y==="")return!1;if(typeof y=="string")return m.textContent=y,!0;if(typeof y=="object"){if(typeof y.nodeType=="number")return m.appendChild(y),!0;const w=y;if(typeof w.html=="string")return m.innerHTML=F(w.html),!0;if(w.title!==void 0||w.rows!==void 0||w.note!==void 0)return this.#C(w),!0}return U(`tooltip-content:${p}`,`Column '${p}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#C(y){const p=this.#r,m=this.#i,w=u=>u==null?"":String(u);y.title!==void 0&&y.title!==null&&y.title!==""&&m.appendChild($(p,"div",{class:n.title,text:w(y.title)}));const v=Array.isArray(y.rows)?y.rows:[];if(v.length){const u=$(p,"div",{class:n.rows});for(const s of v){if(!s||typeof s!="object")continue;const O=$(p,"div",{class:n.row});O.appendChild($(p,"span",{class:n.label,text:w(s.label)})),O.appendChild($(p,"span",{class:n.value,text:w(s.value)})),u.appendChild(O)}m.appendChild(u)}y.note!==void 0&&y.note!==null&&y.note!==""&&m.appendChild($(p,"div",{class:n.note,text:w(y.note)}))}#E(y){if(this.#m)return;const p=this.#v(y);if(!p){this.hide();return}const m=this.#g(p.column);if(!m){this.hide();return}this.hide();const w=this.#A();let v;if(H(m.render))try{v=m.render(p)}catch(O){U(`tooltip-render:${p.colId}`,`Column '${p.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const u=this.#O(v,p.colId);if(H(m.mount))try{m.mount(this.#i,p),this.#u=m}catch(O){U(`tooltip-mount:${p.colId}`,`Column '${p.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!u)return;const{maxWidth:s}=this.#p();s&&(w.style.maxWidth=s),this.#l=y,this.#s=!0,w.setAttribute("data-open","true"),this.#T(y),this.#D(y)}#T(y){if(!H(y.setAttribute))return;const p=H(y.getAttribute)?y.getAttribute("aria-describedby"):null;this.#c={cell:y,previous:p},y.setAttribute("aria-describedby",p?`${p} ${this.#a}`:this.#a)}#D(y){const p=this.#o;if(!p||!H(y.getBoundingClientRect))return;const m=this.#r.defaultView;if(!m)return;const w=y.getBoundingClientRect(),v=H(p.getBoundingClientRect)?p.getBoundingClientRect():{width:0,height:0},u=m.innerWidth||0,s=m.innerHeight||0,O=v.width||0,E=v.height||0;let A=w.bottom+c;const M=w.top-c-E;A+E>s-c&&M>=c&&(A=M),s&&(A=Math.max(c,Math.min(A,Math.max(c,s-E-c))));let C=w.left;u&&(C=Math.min(C,Math.max(c,u-O-c))),C=Math.max(c,C),p.style.left=`${Math.round(C)}px`,p.style.top=`${Math.round(A)}px`}hide(){if(this.#R(),this.#N(),!this.#s)return;if(this.#s=!1,this.#u&&H(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(p){U("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",p)}this.#u=null,this.#i&&W(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const y=this.#c;y&&H(y.cell.setAttribute)&&(y.previous?y.cell.setAttribute("aria-describedby",y.previous):H(y.cell.removeAttribute)&&y.cell.removeAttribute("aria-describedby")),this.#c=null,this.#l=null}#R(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#N(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#m=!0;for(const y of this.#f)y();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const h=f}),Se("packages/dom/src/platform.js",function(e,V){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return _}});function _(){const N=globalThis.navigator,$=String(N&&(N.userAgentData?.platform||N.platform)||"");return/mac|iphone|ipad/i.test($)}}),Se("packages/dom/src/columnmenu.js",function(e,V){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/platform.js").macLike,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/dom/src/ui/contextmenu.js").ContextMenu,F=V("packages/core/src/compute/total.js"),k=F.aggregatesFor,S=F.totalLabel,b=10,a=150;function l(v,u){const s=(re,ie)=>(v&&v.messages?v.messages:H).t(re,ie),O=v.columns.get(u);if(!O)return[];const E=v.sort.get(),A=E.find(re=>re.col===u),M=O.layout&&O.layout.pin,C=v.state.get().group||[],P=C.includes(u);if(O.generated&&Array.isArray(O.groupedIds))return i(v,O,C);const D=!O.sort||O.sort.enabled!==!1,K=!O.filter||O.filter.enabled!==!1,x=[];D&&x.push({name:s("menu.sortAscending"),icon:"↑",disabled:A&&A.dir==="asc",action:()=>v.sort.set([{col:u,dir:"asc"}])},{name:s("menu.sortDescending"),icon:"↓",disabled:A&&A.dir==="desc",action:()=>v.sort.set([{col:u,dir:"desc"}])},{name:s("menu.clearSort"),disabled:!A,action:()=>v.sort.set(E.filter(re=>re.col!==u))},{separator:!0}),K&&x.push({name:s("menu.filterEllipsis"),action:()=>v.emit("column:filter:open",{colId:u})},{separator:!0}),x.push({name:s("menu.columnStatistics"),action:()=>v.emit("column:profile:open",{colId:u})},{separator:!0}),x.push({name:s("menu.pinColumn"),children:[{name:s("menu.pinStart"),disabled:M==="start",action:()=>v.columns.pin(u,"start")},{name:s("menu.pinEnd"),disabled:M==="end",action:()=>v.columns.pin(u,"end")},{name:s("menu.unpin"),disabled:!M,action:()=>v.columns.pin(u,null)}]});const I=!(O.layout&&(O.layout.movable===!1||O.layout.lockPosition)),j=!(O.layout&&O.layout.resizable===!1),T=re=>{const ie=v.columns.get(re);return Number(ie&&ie.layout&&ie.layout.width)||a},B=v.columns.visible().filter(re=>!re.generated).map(re=>re.id),q=B.indexOf(u);if(x.push({name:s("menu.sizeToFit"),action:()=>v.columns.autoSize(u)},{name:s("menu.sizeAllToFit"),action:()=>v.columns.fit()},{name:s("menu.width"),disabled:!j,children:[{name:s("menu.narrower"),disabled:!j,action:()=>v.columns.resize(u,Math.max(1,T(u)-b))},{name:s("menu.wider"),disabled:!j,action:()=>v.columns.resize(u,T(u)+b)},{name:s("menu.autosize"),disabled:!j,action:()=>v.columns.autoSize(u)}]},{separator:!0},{name:s("menu.moveColumn"),disabled:!I,children:[{name:s("menu.moveLeft"),disabled:!I||q<=0,action:()=>v.columns.move(u,Math.max(0,q-1))},{name:s("menu.moveRight"),disabled:!I||q<0||q>=B.length-1,action:()=>v.columns.move(u,Math.min(B.length-1,q+1))},{name:s("menu.moveToStart"),disabled:!I||q<=0,action:()=>v.columns.move(u,0)},{name:s("menu.moveToEnd"),disabled:!I||q<0||q>=B.length-1,action:()=>v.columns.move(u,B.length-1)}]},{separator:!0}),O.allowGroup!==!1&&x.push({name:s(P?"menu.ungroup":"menu.groupBy"),action:()=>v.columns.group(P?C.filter(re=>re!==u):[...C,u])}),C.length&&x.push({name:s("menu.expandAll"),action:()=>v.rows.expandAll()},{name:s("menu.collapseAll"),action:()=>v.rows.collapseAll()}),N(v.columns.groupColumns)){const re=O.groupPath||[],ie=re.length?re[re.length-1]:null,ae=[{name:s("columngroup.group"),disabled:B.length<2||q<0,action:()=>{const ee=B[q+1]??B[q-1];if(!ee)return;const J=(v.columns.get(ee)||{}).groupPath||[],se=J.length?J[J.length-1]:null;se?v.columns.groupColumns([u],{groupId:se}):v.columns.groupColumns([u,ee],{title:s("columngroup.newGroup")})}}];ie&&ae.push({name:s("columngroup.dissolve"),action:()=>v.columns.dissolveGroup(ie)}),x.push({separator:!0},...ae)}const X=v.state&&N(v.state.get)?v.state.get().pivot:null,Q=X&&X.columns||[],te=Q.includes(u);if(O.allowPivot!==!1&&x.push({name:s(te?"menu.unpivot":"menu.pivotBy"),action:()=>v.columns.pivot(te?Q.filter(re=>re!==u):[...Q,u])}),O.allowTotal!==!1)if(N(v.get)&&v.get("aggregateChooser")===!0)x.push(r(v,O,s));else{const ie=!!O.total;x.push({name:s(ie?"menu.stopTotalling":"menu.totalColumn"),action:()=>v.columns.setTotal(u,ie?null:"sum")})}return x.push({name:s("menu.hideColumn"),disabled:O.layout&&O.layout.lockVisible===!0,action:()=>v.columns.hide(u)}),x}function r(v,u,s){const O=u.id,E=typeof u.total=="string"?u.total:null,A=[{name:s("menu.aggregateNone"),checked:!u.total,action:()=>v.columns.setTotal(O,null)},{separator:!0},...k(u).map(M=>({name:S(M),checked:E===M,action:()=>v.columns.setTotal(O,M)})),{separator:!0},t(v,u,s,"group",s("menu.aggregateGroup")),t(v,u,s,"grand",s("menu.aggregateGrand"))];return{name:s("menu.aggregate"),children:A}}function t(v,u,s,O,E){const A=u.id,M=O==="grand"?u.grandTotal:u.groupTotal,C=typeof M=="string"?M:null,P=[{name:s("menu.aggregateSame"),checked:M==null,action:()=>v.columns.setTotal(A,null,{scope:O})},{separator:!0},...k(u).map(D=>({name:S(D),checked:C===D,action:()=>v.columns.setTotal(A,D,{scope:O})}))];return{name:E,children:P}}function n(v,u){const s=(C,P)=>(v&&v.messages?v.messages:H).t(C,P),O=v.columns.get(u);if(!O)return[];const E=v.redaction,A=!!(E&&E.has(u)),M=[];return E&&(M.push({name:s(A?"menu.stopRedacting":"menu.redactColumn"),action:()=>E.toggle(u)}),(E.list().length>1||E.active&&!A)&&M.push({name:s("menu.stopRedactingAll"),action:()=>E.clear()}),M.push({separator:!0})),M.push({name:s("menu.hideColumn"),disabled:O.layout&&O.layout.lockVisible===!0,action:()=>v.columns.hide(u)}),M}function i(v,u,s){const O=(P,D)=>(v&&v.messages?v.messages:H).t(P,D),E=s[0],A=v.sort.get(),M=E?A.find(P=>P.col===E):null,C=[];E&&C.push({name:O("menu.sortGroupsAscending"),icon:"↑",disabled:M&&M.dir==="asc",action:()=>v.sort.set([{col:E,dir:"asc"}])},{name:O("menu.sortGroupsDescending"),icon:"↓",disabled:M&&M.dir==="desc",action:()=>v.sort.set([{col:E,dir:"desc"}])},{separator:!0},{name:O("menu.filterGroups"),action:()=>v.emit("column:filter:open",{colId:u.id})},{separator:!0}),C.push({name:O("menu.expandAll"),action:()=>v.rows.expandAll()},{name:O("menu.collapseAll"),action:()=>v.rows.collapseAll()},{separator:!0});for(const P of s){const D=v.columns.get(P);C.push({name:`Remove "${D&&D.title||P}" from grouping`,action:()=>v.columns.group(s.filter(K=>K!==P))})}return C.push({name:O("menu.clearGrouping"),disabled:!s.length,action:()=>v.columns.group([])}),C}function o(){const v=globalThis.navigator&&globalThis.navigator.clipboard;return!!(v&&typeof v.readText=="function")}function c(v){return N(v.get)&&v.get("edit")===!1?!1:(v.columns&&N(v.columns.visible)?v.columns.visible():[]).some(s=>{const O=s&&s.edit;return O?O.enabled===void 0||N(O.enabled)?!0:O.enabled!==!1:!1})}function d(v,u){if(N(v.get)&&v.get("edit")===!1)return!1;const s=u&&u.edit;return s?s.enabled===void 0||N(s.enabled)?!0:s.enabled!==!1:!1}const f=new Set(["number","currency","percent","integer"]);function h(v){const u=N(v.get)?v.get("rangeChart"):void 0;return u?N(u)?{enabled:!0,handler:u}:u&&typeof u=="object"&&N(u.onChart)?{enabled:!0,handler:u.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function g(v){const u=v.selection&&N(v.selection.ranges)?v.selection.ranges():[];if(!Array.isArray(u)||!u.length)return null;const s=u[u.length-1],O=N(v.columns.visible)?v.columns.visible():[],E=new Set(O.filter(A=>A&&f.has(A.type)).map(A=>A.id));return(s.columns||[]).some(A=>E.has(A))?s:null}function y(v,u){const s=(Q,te)=>(v&&v.messages?v.messages:H).t(Q,te),{colId:O,row:E}=u,A=v.selection.keys().length,M=v.selection.cells().length,C=(v.state&&N(v.state.get)?v.state.get().group:null)||[],P=v.ranges||null,D=W()?"Cmd":"Ctrl",K=()=>M||A||0,x=Q=>v.columns&&N(v.columns.get)?v.columns.get(Q):null,I=N(v.selection.cells)?v.selection.cells():[],j=[...new Set(I.map(Q=>Q&&Q.colId).filter(Boolean))];!j.length&&O&&j.push(O);const T=j.length?j.some(Q=>d(v,x(Q))):c(v),B=O?d(v,x(O)):!1,q=h(v),X=q.enabled?g(v):null;return[{name:M>1?`Copy ${M} cells`:s("menu.copy"),shortcut:`${D}+C`,disabled:!K(),action:()=>P&&M?P.copy():v.export.clipboard({rows:A?"selected":"range"})},{name:s("menu.copyWithHeaders"),disabled:!K(),action:()=>v.export.clipboard({headers:!0,rows:A?"selected":"range"})},...O==null?[]:[{name:s("menu.paste"),shortcut:`${D}+V`,disabled:!P||!T||!o(),action:()=>P&&P.paste()},{separator:!0},{name:s("menu.clearCells",{count:M||1}),shortcut:"Delete",disabled:!P||!T||!M,action:()=>P&&P.clear()},{name:s("menu.fillDown"),shortcut:`${D}+D`,disabled:!P||!T||M<2,action:()=>P&&P.fillDown()}],...X&&q.handler?[{name:"Chart selection",action:()=>q.handler(v,X)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>v.export.csv({rows:"visible",download:!0})},{name:`Export ${A} selected row${A===1?"":"s"} to CSV`,disabled:!A,action:()=>v.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>v.export.excel({rows:"visible",download:!0})},{name:`Export ${A} selected row${A===1?"":"s"} to Excel`,disabled:!A,action:()=>v.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>v.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>v.export.print()},...v.importer&&N(v.importer.openFile)?[{name:s("menu.importCsv"),action:()=>v.importer.openFile()}]:[],{separator:!0},...C.length?[{name:s("menu.expandAll"),action:()=>v.rows.expandAll()},{name:s("menu.collapseAll"),action:()=>v.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!A,action:()=>v.selection.clear()},...N(v.get)&&v.get("rowDelete")===!0?[{name:s("menu.deleteRow",{count:A||1}),disabled:!A&&!E,action:()=>v.edit.deleteRows(A?void 0:E?E.key:void 0)}]:[],...O==null?[]:[{name:"Edit cell",disabled:!E||!O||!B,action:()=>E&&O&&v.edit.start(E.key,O)}]]}function p(v,u,s,O){if(v==null)return{items:u,spoke:!1,suppress:!1};if(v===!1)return{items:u,spoke:!0,suppress:!0};if(v===!0)return{items:u,spoke:!0,suppress:!1};if(Array.isArray(v))return{items:[...u,...v],spoke:!0,suppress:!1};if(N(v)){const E=v(s,u);return{items:Array.isArray(E)?E:u,spoke:!0,suppress:!1}}return $(`menu-layer:${O}`,`${O} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof v}. Ignoring it.`),{items:u,spoke:!1,suppress:!1}}function m(v,u,s){let O=Array.isArray(v)?v:[],E=!1;for(const A of u){if(!A)continue;const M=p(A.layer,O,s,A.where);O=M.items,M.spoke&&(E=M.suppress)}return E?null:O}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#a=null;constructor(u){this.#n=u.grid,this.#e=u.cellMenu!==!1,this.#t=u.headerMenu!==!1,this.#i=N(u.items)?u.items:null,this.#a=N(u.headerItems)?u.headerItems:null,this.#r=new z({document:u.document,host:u.host,ctx:{grid:u.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",u=>{const s=String(u.colId),O=this.#c(s,l(this.#n,s));O.length&&this.#r.show({items:O,ctx:this.#u(s),anchor:u.element,placement:"below",returnFocus:u.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",u=>{const s=String(u.colId),O=this.#c(s,n(this.#n,s));O.length&&this.#r.show({items:O,ctx:this.#u(s),x:u.x,y:u.y,returnFocus:u.element})})),this.#o.push(this.#n.on("cell:contextmenu",u=>{const s=u.event;this.#e&&s&&N(s.preventDefault)&&s.preventDefault();const O=this.#s(u),E=y(this.#n,O),A=m(E,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#l(O.column),where:`column '${O.colId}' contextMenu`}],O);!A||!A.length||(!this.#e&&s&&N(s.preventDefault)&&s.preventDefault(),this.#r.show({items:A,ctx:O,x:s?s.clientX:void 0,y:s?s.clientY:void 0}))}))}#s(u){const s=this.#n.columns,O=u.column||(u.colId!=null&&s&&N(s.get)?s.get(u.colId):void 0),E=u.row,A=this.#n.rows,M=u.key!==void 0?u.key:E?E.key:void 0;return{key:M,colId:u.colId,value:u.value!==void 0||M===void 0||u.colId==null?u.value:A&&N(A.value)?A.value(M,u.colId):void 0,row:E,data:E?E.data:void 0,column:O,index:u.index!==void 0?u.index:u.rowIndex,grid:this.#n}}#l(u){if(!(!u||u.contextMenu===void 0||u.contextMenu===null))return u.contextMenu}#u(u){return{colId:u,column:this.#n.columns.get(u),grid:this.#n}}#c(u,s){return this.#a?m(s,[{layer:this.#a,where:"columnMenu"}],this.#u(u))||[]:s}destroy(){for(const u of this.#o)u();this.#o=[],this.#r.destroy()}}}),Se("packages/dom/src/shortcutshelp.js",function(e,V){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/renderer/keyboard.js"),Z=W.groupedShortcuts,H=W.SHORTCUT_IDS,z=V("packages/dom/src/platform.js").macLike,F="lat-shortcuts",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class S{#e;#t;#n=null;#r=null;#o=[];constructor(a){this.#e=a.grid,this.#t=a.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(a,l){const r=this.#e;return(r&&r.messages?r.messages:L).t(a,l)}#a(a){const l=H[a.combo];if(!l)return a.meaning;const r=`shortcut.${l}`,t=this.#i(r);return t===r?a.meaning:t}mount(){const a=this.#t.viewport?.root;if(!a||!N(a.addEventListener))return;const l=r=>{if(this.open||r.key!=="?")return;const t=r.target,n=t&&t.tagName;n==="INPUT"||n==="TEXTAREA"||t&&t.isContentEditable||(r.preventDefault(),r.stopPropagation(),this.show())};a.addEventListener("keydown",l,!0),this.#o.push(()=>a.removeEventListener("keydown",l,!0))}show(){const a=this.#s();if(!a)return;const l=a.ownerDocument;this.#r=l&&l.activeElement,a.style.display="",N(a.focus)&&a.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const a=this.#r;this.#r=null,a&&N(a.focus)&&a.focus(),this.#e.emit?.("shortcuts:closed",{})}#s(){if(this.#n)return this.#n;const a=this.#t.viewport?.overlays,l=a?.ownerDocument;if(!a||!l?.createElement)return null;const r=l.createElement("div");r.className=F,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabindex","-1");const t=`${F}-title`;r.setAttribute("aria-labelledby",t);const n=l.createElement("div");n.className=`${F}__head`;const i=l.createElement("h2");i.className=`${F}__title`,i.id=t,i.textContent=this.#i("shortcuts.title");const o=l.createElement("button");o.className=`${F}__close`,o.type="button",o.setAttribute("aria-label",this.#i("shortcuts.close")),o.textContent="×",n.appendChild(i),n.appendChild(o),r.appendChild(n);const c=l.createElement("div");c.className=`${F}__body`;for(const f of Z())f.items.length&&c.appendChild(this.#l(l,f));r.appendChild(c);const d=l.createElement("p");return d.className=`${F}__hint`,d.textContent=this.#i("shortcuts.hint"),r.appendChild(d),a.appendChild(r),this.#n=r,this.#u(r,o),r}#l(a,l){const r=a.createElement("section");r.className=`${F}__group`;const t=a.createElement("h3");t.className=`${F}__group-title`,t.textContent=this.#i(l.messageKey),r.appendChild(t);const n=a.createElement("dl");n.className=`${F}__list`;const i=z();for(const o of l.items){const c=a.createElement("dt");c.className=`${F}__keys`,o.alternatives.forEach((f,h)=>{if(h>0){const g=a.createElement("span");g.className=`${F}__or`,g.textContent=this.#i("shortcuts.or"),c.appendChild(g)}f.forEach((g,y)=>{y>0&&c.appendChild(a.createTextNode("+"));const p=a.createElement("kbd");p.textContent=i&&g==="Ctrl"?this.#i("shortcuts.key.cmd"):g,c.appendChild(p)})});const d=a.createElement("dd");d.className=`${F}__meaning`,d.textContent=this.#a(o),n.appendChild(c),n.appendChild(d)}return r.appendChild(n),r}#u(a,l){const r=n=>{if(n.stopPropagation(),n.key==="Escape"){n.preventDefault(),this.hide();return}if(n.key!=="Tab")return;const i=[...a.querySelectorAll(k)];if(!i.length){n.preventDefault();return}const o=i[0],c=i[i.length-1],d=a.ownerDocument.activeElement;n.shiftKey&&(d===o||d===a)?(n.preventDefault(),c.focus()):!n.shiftKey&&d===c&&(n.preventDefault(),o.focus())},t=n=>{n.preventDefault?.(),this.hide()};a.addEventListener("keydown",r),l.addEventListener("click",t),this.#o.push(()=>{a.removeEventListener("keydown",r),l.removeEventListener("click",t)})}destroy(){for(const a of this.#o)a();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),Se("packages/dom/src/rowreorder.js",function(e,V){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return a}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/renderer/renderer.js").displayIndexOf,H="lat-rowdrag",U="lat-rowdrag-marker",z="lat-rowdrag-lifted",F=4,k=new Set;function S(l){if(!l)return null;const r=l===!0?{}:typeof l=="object"?l:null;return r?{send:r.send!==!1,receive:r.receive!==!1,mode:r.mode==="copy"?"copy":"move",group:typeof r.group=="string"?r.group:null}:null}function b(l){return l===!0?{column:null}:!l||typeof l!="object"?null:{column:typeof l.column=="string"?l.column:null}}class a{#e;#t;#n;#r=null;#o=null;#i=null;#a=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document,this.#r=b(r.grid.get("rowReorder")),this.#o=S(r.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(r){if(!this.#o||!this.#o.receive)return!1;const t=r&&r.transfer;return!t||!t.send?!1:t.group===this.#o.group}get transfer(){return this.#o}#u(r,t){const n=this.#e;return(n&&n.messages?n.messages:L).t(r,t)}#c(r,t){const n=this.#t&&this.#t.announce;N(n)&&n.call(this.#t,r,t)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const r=this.#e.columns.visible().filter(t=>!t.generated);return r.length?r[0].id:null}paint(){if(!this.draggable)return;const r=this.#d(),t=this.#t.viewport?.root;if(!r||!t)return;const n=t.querySelectorAll(`.lat-cell[data-col="${r}"]`);for(const i of n){if(i.querySelector(`.${H}`))continue;const o=i.parentNode;if(o&&N(o.getAttribute)&&o.getAttribute("data-pinned"))continue;const c=this.#n.createElement("span");c.className=H,c.setAttribute("data-role","row-drag"),c.setAttribute("aria-hidden","true"),c.setAttribute("title",this.#u("a11y.reorder.grab")),c.textContent="⠿",i.insertBefore(c,i.firstChild||null)}}mount(){if(!this.active)return;k.add(this);const r=this.#t.viewport?.root;if(!r||!N(r.addEventListener))return;const t=d=>this.#h(d),n=d=>this.#f(d),i=()=>this.#m(),o=d=>this.#A(d);r.addEventListener("pointerdown",t),r.addEventListener("keydown",o);const c=this.#n.defaultView||this.#n;c.addEventListener?.("pointermove",n),c.addEventListener?.("pointerup",i),this.#l.push(()=>{r.removeEventListener("pointerdown",t),r.removeEventListener("keydown",o),c.removeEventListener?.("pointermove",n),c.removeEventListener?.("pointerup",i)})}#h(r){const t=r.target;if(!t||!N(t.closest)||!t.closest('[data-role="row-drag"]'))return;const n=t.closest(".lat-row"),i=n?Z(n):-1;if(i<0)return;const o=this.#e.rows.get(i);if(!o)return;const c=this.#C();if(c&&!(this.#o&&this.#o.send)){this.#c(this.#u(c),{repeat:!0});return}r.preventDefault?.(),this.#i={key:o.key,from:i,at:i,x:r.clientX,y:r.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#f(r){const t=this.#i;if(!t)return;if(!t.armed){if(Math.abs(r.clientX-t.x)+Math.abs(r.clientY-t.y)<F)return;t.armed=!0,this.#T(t),t.over=this,this.#e.emit("rowDrag:started",this.#p(t,this,t.from,t.key),"user")}this.#s&&this.#D(r.clientX,r.clientY);const n=this.#j(r.clientX,r.clientY);if(t.target=n,n!==this){this.#M(),n&&n.accepts(this)?(n.showDropTarget(r.clientX,r.clientY),t.hit=n.hitAt(r.clientX,r.clientY)):t.hit=null,this.#v(t,n),this.#y(t,n,t.hit?t.hit.at:null,t.hit?t.hit.overKey:null);return}const i=this.#E(r.clientX,r.clientY);if(this.#v(t,n),i<0){this.#y(t,this,null,null);return}t.at=i,this.#N(i);const o=this.#e.rows.get(i);this.#y(t,this,i,o?o.key:null)}#m(){const r=this.#i;this.#i=null,this.#M(),this.#R();for(const i of k)i.hideDropTarget();if(!r||(this.#b(r),!r.armed))return;const t=r.target;if(this.#e.emit("rowDrag:ended",this.#g(r),"user"),t&&t!==this){this.#S(r,t);return}if(r.at===r.from)return;const n=this.#C();if(n){this.#c(this.#u(n),{repeat:!0});return}this.#O(r.key,r.at)}#p(r,t,n,i){const o=this.#e.rows.byKey(r.key);return{key:r.key,data:o?o.data:null,over:t?t.grid:null,at:n,overKey:i}}#g(r){const t=r.target||null;if(t&&t!==this){if(!t.accepts(this))return{...this.#p(r,t,null,null),dropped:!1};const n=r.hit||{at:t.grid.rows.count(),overKey:null};return{...this.#p(r,t,n.at,n.overKey),dropped:!0}}if(t===this){const n=this.#e.rows.get(r.at);return{...this.#p(r,this,r.at,n?n.key:null),dropped:r.at!==r.from&&this.#C()===null}}return{...this.#p(r,null,null,null),dropped:!1}}#v(r,t){if(r.over===t)return;const n=r.over;r.over=t,n&&(this.#b(r),this.#e.emit("rowDrag:left",this.#p(r,n,null,null),"user"))}#y(r,t,n,i){r.pending={over:t,at:n,overKey:i},r.frame===null&&(r.frame=this.#w(()=>{r.frame=null;const o=r.pending;r.pending=null,!(!o||this.#i!==r)&&this.#e.emit("rowDrag:moved",this.#p(r,o.over,o.at,o.overKey),"user")}))}#b(r){r.pending=null,r.frame!==null&&(r.frame(),r.frame=null)}#w(r){const t=this.#n.defaultView||globalThis;if(N(t.requestAnimationFrame)){const i=t.requestAnimationFrame(r);return()=>{N(t.cancelAnimationFrame)&&t.cancelAnimationFrame(i)}}const n=setTimeout(r,16);return()=>clearTimeout(n)}#S(r,t){if(!t.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const n=this.#e.rows.byKey(r.key);if(!n)return;const i=this.#o.mode,o=r.key,c=r.hit||{at:t.grid.rows.count(),overKey:null};let d=null;const f=t.receive(n.data,c.at,{overKey:c.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(o),onCancel:g=>{d=g}}),h=g=>{if(g!==!0){const y=g===!1?"a11y.transfer.refused":d==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(y),{repeat:!0});return}i==="move"?(this.#e.rows.apply({remove:[o]}),this.#e.emit("row:sent",{key:o,data:n.data,mode:i})):this.#e.emit("row:copied",{key:o,data:n.data,mode:i}),this.#c(this.#u(i==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};f&&N(f.then)?f.then(h):h(f)}receive(r,t,n={}){const i=this.#e,o=r&&typeof r=="object"?{...r}:r,c=n.overKey??null,d=n.source||null,f=N(n.onCancel)?n.onCancel:null,h=()=>{const w=i.rows.totalCount(),v=i.rows.apply({add:[o],at:Math.max(0,t||0)}),u=i.rows.totalCount()>w;return u&&i.emit("row:received",{data:o,at:t,overKey:c,rejected:v?.rejected||[]}),u},g=()=>{if(c!==null){const w=i.rows.get(t);if(!w||w.key!==c)return!1}return!N(n.revalidate)||n.revalidate()},y=N(i.rendererHost)?i.rendererHost():null;if(!y||!N(y.gateBefore))return h();const p=f?i.on("rowReceive:cancelled",w=>f(w.reason)):null,m=y.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:o,at:t,overKey:c,source:d,origin:"user"},h,g);return p&&(m&&N(m.then)?m.then(p,p):p()),m}hitAt(r,t){const n=this.#E(r,t);if(n<0)return{at:this.#e.rows.count(),overKey:null};const i=this.#e.rows.get(n);return{at:n,overKey:i?i.key:null}}showDropTarget(r,t){const n=this.root;n&&N(n.setAttribute)&&n.setAttribute("data-drop-target","")}hideDropTarget(){const r=this.root;r&&N(r.removeAttribute)&&r.removeAttribute("data-drop-target")}#j(r,t){const n=this.#n.elementFromPoint?this.#n.elementFromPoint(r,t):null,i=n&&N(n.closest)?n.closest(".lattice"):null;if(!i)return null;for(const o of k)if(o.root===i)return o;return null}#A(r){if(!r.altKey||!r.shiftKey)return;const t=r.key==="ArrowUp"?-1:r.key==="ArrowDown"?1:0;if(!t)return;const n=this.#n.activeElement,i=n&&N(n.closest)?n.closest(".lat-row"):null,o=i?Z(i):-1;if(o<0)return;r.preventDefault?.(),r.stopPropagation?.();const c=this.#C();if(c){this.#c(this.#u(c),{repeat:!0});return}const d=this.#e.rows.get(o);d&&this.#O(d.key,o+t)}#O(r,t){const n=this.#e.rows.count(),i=Math.max(0,Math.min(n-1,t)),o=this.#e.rows.move(r,i);if(!o.moved){o.reason&&o.reason!=="unchanged"&&this.#c(this.#u(`a11y.reorder.${o.reason}`),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:o.to+1,total:n}),{repeat:!0})}#C(){const r=this.#e;if(r.sort.get().length)return"a11y.reorder.sorted";if((r.state.get().group||[]).length)return"a11y.reorder.grouped";const t=r.filters.get();return t&&Object.keys(t).length?"a11y.reorder.filtered":null}#E(r,t){const n=this.#n.elementFromPoint?this.#n.elementFromPoint(r,t):null,i=n&&N(n.closest)?n.closest(".lat-row"):null;return!i||N(i.getAttribute)&&i.getAttribute("data-pinned")?-1:Z(i)}#T(r){const t=this.root,n=t&&N(t.querySelector)?t.querySelector(`.lat-row[data-index="${r.from}"]`):null;n&&N(n.classList?.add)&&n.classList.add(z);const i=this.#n.body;if(!i||!N(i.appendChild))return;const o=this.#d(),c=o&&N(this.#e.rows?.text)&&this.#e.rows.text(r.key,o)||this.#u("a11y.reorder.grab"),d=t&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(t):null,f=(g,y)=>d&&d.getPropertyValue(g).trim()||y,h=this.#n.createElement("div");h.textContent=String(c),h.setAttribute("aria-hidden","true"),h.setAttribute("data-role","row-drag-ghost"),h.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${f("--lattice-space","4px")} calc(${f("--lattice-space","4px")} * 2)`,`border-radius:${f("--lattice-radius-sm",f("--lattice-radius","4px"))}`,`border:${f("--lattice-border-width","1px")} solid ${f("--lattice-border-strong","#0003")}`,`background:${f("--lattice-background","#fff")}`,`color:${f("--lattice-foreground","#000")}`,`box-shadow:${f("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${f("--lattice-font-size","13px")} ${f("--lattice-font-family","system-ui, sans-serif")}`].join(";"),i.appendChild(h),this.#s=h}#D(r,t){this.#s&&(this.#s.style.transform=`translate(${Math.round(r)+14}px, ${Math.round(t)+16}px)`)}#R(){this.#s&&(this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null);const r=this.root,t=r&&N(r.querySelectorAll)?r.querySelectorAll(`.${z}`):[];for(const n of t)n.classList.remove(z)}#N(r){const t=this.#t.viewport?.overlays;if(!t)return;this.#a||(this.#a=this.#n.createElement("div"),this.#a.className=U,t.appendChild(this.#a));const n=this.#t.viewport.root,i=n.querySelector(`.lat-row[data-index="${r}"]`)||n.querySelectorAll(".lat-row")[0];if(!i||!N(i.getBoundingClientRect))return;const o=i.getBoundingClientRect(),c=n.getBoundingClientRect(),d=this.#i&&r>this.#i.from;this.#a.style.display="",this.#a.style.top=`${Math.round((d?o.bottom:o.top)-c.top)}px`}#M(){this.#a&&(this.#a.style.display="none")}destroy(){k.delete(this);for(const r of this.#l)r();this.#l=[],this.#i&&this.#b(this.#i),this.#i=null,this.#R(),this.#a&&this.#a.parentNode&&this.#a.parentNode.removeChild(this.#a),this.#a=null}}}),Se("packages/dom/src/alignedgrids.js",function(e,V){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/internal/util.js").isFunction,$=["column:resized","column:moved","column:visible","column:pinned"];function L(H){return(H||[]).map(U=>({id:U.id,width:U.width,flex:U.flex,hidden:U.hidden,pin:U.pin===void 0?null:U.pin}))}class W{#e=new Set;#t=new Map;#n=!1;add(U){if(!U||this.#e.has(U))return;this.#e.add(U);const z=[];for(const k of $)z.push(U.on(k,()=>this.#r(U)));z.push(U.on("scroll",k=>this.#i(U,k))),z.push(U.on("destroy",()=>this.remove(U))),this.#t.set(U,z);const[F]=this.#e;F!==U&&this.#o(U,L(F.columns.state()))}remove(U){const z=this.#t.get(U);if(z)for(const F of z)F();this.#t.delete(U),this.#e.delete(U)}get size(){return this.#e.size}destroy(){for(const U of[...this.#e])this.remove(U)}#r(U){if(this.#n)return;const z=L(U.columns.state());this.#n=!0;try{for(const F of this.#e)F!==U&&this.#o(F,z)}finally{this.#n=!1}}#o(U,z){if(!U.columns||!N(U.columns.apply))return;const F=new Map((U.columns.state()||[]).map(S=>[S.id,S])),k=[];for(const S of z){const b=F.get(S.id);b&&(k.push({...b,...S}),F.delete(S.id))}for(const S of F.values())k.push(S);U.columns.apply(k)}#i(U,z){if(this.#n)return;const F=z&&typeof z.left=="number"?z.left:null;if(F!==null){this.#n=!0;try{for(const k of this.#e)k!==U&&k.scroll?.to?.({left:F})}finally{this.#n=!1}}}}function Z(H){const U=new W;for(const z of H||[])U.add(z);return U}}),Se("packages/dom/src/columntagbar.js",function(e,V){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return H}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function Z(z){if(!z)return null;const F=z===!0?{}:typeof z=="object"?z:null;return F?{multiple:F.multiple===!0,label:typeof F.label=="string"?F.label:null}:null}class H{#e;#t;#n;#r=null;#o=null;#i=null;#a="\0";#s=[];constructor(F){this.#e=F.grid,this.#t=F.renderer,this.#n=F.document,this.#r=Z(F.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#l(F,k){const S=this.#e;return(S&&S.messages?S.messages:L).t(F,k)}mount(){if(!this.active)return;const F=this.#t.viewport,k=F?.root;if(!k||!N(k.insertBefore))return;const S=this.#n.createElement("div");S.className=W,S.setAttribute("role","toolbar"),S.setAttribute("aria-label",this.#l("tags.label"));const b=this.#n.createElement("label");b.className=`${W}__label`,b.textContent=this.#r.label||this.#l("tags.label");const a=this.#n.createElement("select");a.className=`${W}__select`,this.#r.multiple&&a.setAttribute("multiple","");const l=`${W}-select-${Math.abs(U(String(k.className)))}`;a.id=l,b.setAttribute("for",l),S.appendChild(b),S.appendChild(a),k.insertBefore(S,F.header||k.firstChild),this.#o=S,this.#i=a;const r=()=>{const n=this.#r.multiple?[...a.selectedOptions||[]].map(i=>i.value).filter(Boolean):a.value?[a.value]:[];this.#e.columns.showTagged(n),this.#u(n)};a.addEventListener("change",r),this.#s.push(()=>a.removeEventListener("change",r));const t=this.#e.on("model:changed",()=>this.refresh());this.#s.push(t),this.refresh()}#u(F){const k=this.#t&&this.#t.announce;if(!N(k))return;const S=F.length?F.join(", "):this.#l("tags.all");k.call(this.#t,this.#l("tags.showing",{tag:S}))}refresh(){if(!this.#i||!this.#o)return;const F=this.#e.columns.tags();if(this.#o.style.display=F.length?"":"none",!F.length)return;const k=F.join("\0");if(k===this.#a)return;this.#a=k;const S=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const b=this.#n.createElement("option");b.value="",b.textContent=this.#l("tags.all"),this.#i.appendChild(b)}for(const b of F){const a=this.#n.createElement("option");a.value=b,a.textContent=b,S.includes(b)&&(a.selected=!0),this.#i.appendChild(a)}this.#r.multiple||(this.#i.value=S.length?S[0]:"")}destroy(){for(const F of this.#s)F();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function U(z){let F=0;for(let k=0;k<z.length;k++)F=F*31+z.charCodeAt(k)|0;return F}}),Se("packages/dom/src/anomalychip.js",function(e,V){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return z}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function Z(F){if(!F)return null;const k=F===!0?{}:typeof F=="object"?F:null;return k?{column:typeof k.column=="string"?k.column:null,label:typeof k.label=="string"?k.label:null}:null}function H(F){return F?typeof F=="string"?{kind:F}:typeof F=="object"?F:null:null}function U(F,k){return F?Array.isArray(F.conditions)?F.conditions.some(S=>U(S,k)):F.col===k&&F.op==="eq"&&F.value===!0:!1}class z{#e;#t;#n;#r=null;#o=null;#i=null;#a=[];#s=!1;#l=!1;#u=null;#c=0;#d=null;constructor(k){this.#e=k.grid,this.#t=k.renderer,this.#n=k.document,this.#r=Z(k.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(k,S){const b=this.#e;return(b&&b.messages?b.messages:L).t(k,S)}#f(){const k=this.#r&&this.#r.column;let S=null;for(const b of this.#e.columns.all()){const a=H(b.shadow);if(!a||a.kind!=="anomalyFlag")continue;const l=a.of||b.field||b.id;if(k){if(b.id===k||l===k)return this.#d=b.id,b}else S||(S=b,this.#d=b.id)}return k?null:S}#m(){if(!this.#d||!N(this.#e.rows&&this.#e.rows.forEach))return 0;let k=0;try{this.#e.rows.forEach(S=>{!S||S.group||S.key==null||this.#e.rows.value(S.key,this.#d)===!0&&k++})}catch{return 0}return k}mount(){if(!this.active)return;const k=this.#t.viewport,S=k&&k.root;if(!S||!N(S.insertBefore))return;const b=this.#n.createElement("div");b.className=W,b.setAttribute("role","status");const a=this.#n.createElement("button");a.className=`${W}__button`,a.setAttribute("type","button"),a.setAttribute("aria-pressed","false"),b.appendChild(a),S.insertBefore(b,k.header||S.firstChild),this.#o=b,this.#i=a;const l=()=>this.toggle();a.addEventListener("click",l),this.#a.push(()=>a.removeEventListener("click",l));for(const r of["filter:changed","rows:changed","model:changed"])this.#a.push(this.#e.on(r,()=>{this.#l||this.refresh()}));this.refresh()}toggle(){this.#s?this.#g():this.#p()}#p(){if(!this.#d)return;this.#u=this.#e.filters.get();const k={col:this.#d,op:"eq",value:!0},S=this.#u?{op:"and",conditions:[this.#u,k]}:k;this.#s=!0,this.#l=!0;try{this.#e.filters.set(S)}finally{this.#l=!1}this.refresh()}#g(){this.#s=!1,this.#l=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#l=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#s&&!U(this.#e.filters.get(),this.#d)&&(this.#s=!1,this.#u=null),this.#s){this.#v(this.#c,!0);return}const S=this.#m();if(this.#c=S,!S){this.#o.style.display="none";return}this.#v(S,!1)}#v(k,S){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",S?"true":"false"),this.#i.setAttribute("aria-pressed",S?"true":"false");const b=this.#r&&this.#r.label,a=S?this.#h("anomaly.chipActive",{count:k}):b||this.#h("anomaly.chip",{count:k});this.#i.textContent=a}destroy(){for(const k of this.#a)k();this.#a=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),Se("packages/dom/src/rowform.js",function(e,V){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return r}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,H=V("packages/dom/src/editors/index.js").createEditor,z=V("packages/dom/src/renderer/renderer.js").displayIndexOf,F="lat-rowform",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function S(t){if(!t)return null;const n=t===!0?{}:typeof t=="object"?t:null;if(!n)return null;const i=N(n.load)?n.load:null,o=Array.isArray(n.fields)&&n.fields.length?n.fields:null;return{timeout:l(n.timeout),container:n.container??null,mode:n.container?"inline":n.mode==="dialog"?"dialog":"drawer",load:i,fields:o,title:n.title??null,width:typeof n.width=="string"?n.width:null,trigger:n.trigger===!1?"none":"dblclick"}}function b(t,n){const i=N(t)?t():t;return i?typeof i=="string"?n&&N(n.querySelector)?n.querySelector(i):null:i&&N(i.appendChild)?i:null:null}const a=2e3;function l(t){return t===!1||t===0?0:typeof t!="number"||!Number.isFinite(t)||t<=0?a:t}class r{#e;#t;#n;#r;#o=null;#i=null;#a=null;#s=null;#l=null;#u=[];#c=null;#d=0;#h=null;#f=!1;#m=[];constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document,this.#r=n.registry||null,this.#o=S(n.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#p(n,i){const o=this.#e;return(o&&o.messages?o.messages:W).t(n,i)}mount(){if(!this.active)return;const n=this.#t.viewport?.root;if(!n||!N(n.addEventListener)||this.#o.trigger==="none")return;const i=o=>{const c=o.target;if(!c||!N(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const d=c.closest(".lat-row"),f=d?z(d):-1;if(f<0)return;const h=this.#e.rows.get(f);!h||h.group||h.detail||(o.preventDefault?.(),o.stopPropagation?.(),this.openRow(h.key))};n.addEventListener("dblclick",i,!0),this.#m.push(()=>n.removeEventListener("dblclick",i,!0))}openRow(n){const i=this.#e.rows.byKey(n);if(!i)return!1;const o=this.#g();if(!o)return!1;this.#l=i,this.#c=this.#n.activeElement,o.style.display="",this.#E(o),this.#y(i);const c=this.#o.load;if(!c)this.#C(i.data);else{this.#j();const d=++this.#d;this.#b(d,n),Promise.resolve().then(()=>c({row:i,data:i.data,key:n,grid:this.#e})).then(f=>{d!==this.#d||!this.open||(this.#S(),this.#C(f||i.data))}).catch(f=>{d!==this.#d||!this.open||(this.#S(),this.#A(f,n))})}return N(o.focus)&&o.focus(),this.#e.emit("form:opened",{key:n,row:i}),!0}close(){if(!this.#i)return;this.#d+=1,this.#S(),this.#F(),this.#i.style.display="none";const n=this.#l?this.#l.key:null;this.#l=null;const i=this.#c;this.#c=null,i&&N(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:n})}save(){if(!this.#l||!this.#u.length)return!1;const n=this.#l.key,i={},o={},c=[],d=[];for(const f of this.#u){const h=N(f.editor.commit)?f.editor.commit():{ok:!0,value:void 0};if(!h.ok)return this.#R(f,h.message),!1;i[f.field]=h.value;const g=f.initial;Object.is(g,h.value)||(o[f.field]=h.value,f.colId?c.push({key:n,colId:f.colId,value:h.value}):d.push(f.field))}return c.length&&this.#e.edit.setCells(c),this.#e.emit("form:saved",{key:n,values:i,changed:o,unmapped:d}),this.close(),!0}#g(){if(this.#i)return this.#i;const n=this.#t.viewport?.overlays,i=this.#n||n?.ownerDocument;if(!i?.createElement)return null;const o=b(this.#o.container,i),c=o||n;if(!c)return null;this.#o.container&&!o&&$("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#f=!!o;const d=i.createElement("div"),f=this.#f?"lattice ":"";d.className=`${f}${F} ${F}--${this.#f?"inline":this.#o.mode}`,d.setAttribute("role",this.#f?"region":"dialog"),this.#f||d.setAttribute("aria-modal","true"),d.setAttribute("tabindex","-1"),this.#o.width&&d.style.setProperty("--lattice-rowform-width",this.#o.width);const h=`${F}-title`;d.setAttribute("aria-labelledby",h);const g=i.createElement("div");g.className=`${F}__head`;const y=i.createElement("h2");y.className=`${F}__title`,y.id=h,g.appendChild(y);const p=i.createElement("div");p.className=`${F}__body`;const m=i.createElement("div");m.className=`${F}__foot`;const w=i.createElement("button");w.className=`${F}__cancel`,w.type="button",w.textContent=this.#p("form.cancel");const v=i.createElement("button");return v.className=`${F}__save`,v.type="button",v.textContent=this.#p("form.save"),m.appendChild(w),m.appendChild(v),d.appendChild(g),d.appendChild(p),d.appendChild(m),c.appendChild(d),this.#i=d,this.#a=p,this.#s=v,this.#v(d,v,w),d}#v(n,i,o){const c=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.close();return}if(h.key!=="Tab"||this.#f)return;const g=[...n.querySelectorAll(k)];if(!g.length){h.preventDefault();return}const y=g[0],p=g[g.length-1],m=n.ownerDocument.activeElement;h.shiftKey&&(m===y||m===n)?(h.preventDefault(),p.focus()):!h.shiftKey&&m===p&&(h.preventDefault(),y.focus())},d=h=>{h.preventDefault?.(),this.save()},f=h=>{h.preventDefault?.(),this.close()};n.addEventListener("keydown",c),i.addEventListener("click",d),o.addEventListener("click",f),this.#m.push(()=>{n.removeEventListener("keydown",c),i.removeEventListener("click",d),o.removeEventListener("click",f)})}#y(n){const i=this.#i.querySelector(`.${F}__title`);if(!i)return;const o=this.#o.title;N(o)?i.textContent=String(o({row:n,data:n.data})??""):typeof o=="string"?i.textContent=o:i.textContent=this.#p("form.title")}#b(n,i){this.#S();const o=this.#o.timeout;if(!o)return;const c=this.#n.defaultView||globalThis;N(c.setTimeout)&&(this.#h=c.setTimeout(()=>{this.#h=null,!(n!==this.#d||!this.open)&&(this.#d+=1,this.#A(new Error(`Loading the record timed out after ${o}ms`),i,"form.loadTimeout"))},o))}#w(n){this.#s&&(this.#s.disabled=!n,n?this.#s.removeAttribute("aria-disabled"):this.#s.setAttribute("aria-disabled","true"))}#S(){if(this.#h===null)return;const n=this.#n.defaultView||globalThis;N(n.clearTimeout)&&n.clearTimeout(this.#h),this.#h=null}#j(){this.#F(),this.#w(!1),this.#a.replaceChildren&&this.#a.replaceChildren();const n=this.#n.createElement("p");n.className=`${F}__note`,n.setAttribute("role","status"),n.textContent=this.#p("form.loading"),this.#a.appendChild(n)}#A(n,i,o="form.loadFailed"){this.#F(),this.#w(!1),this.#a.replaceChildren&&this.#a.replaceChildren();const c=this.#n.createElement("p");c.className=`${F}__note ${F}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#p(o);const d=this.#n.createElement("button");d.className=`${F}__retry`,d.type="button",d.textContent=this.#p("form.retry"),d.addEventListener("click",()=>this.openRow(i)),this.#a.appendChild(c),this.#a.appendChild(d),this.#e.emit("form:error",{key:i,error:n,timedOut:o==="form.loadTimeout"})}#O(){return this.#o.fields?this.#o.fields.map(n=>typeof n=="string"?{field:n}:n):this.#e.columns.all().filter(n=>!n.generated&&n.field).map(n=>({field:n.field,label:n.title,colId:n.id}))}#C(n){this.#F(),this.#w(!0),this.#a.replaceChildren&&this.#a.replaceChildren();const i=n&&typeof n=="object"?n:{};for(const o of this.#O()){const c=o.field;if(!c)continue;const d=o.colId?this.#e.columns.get(o.colId):this.#U(c),f=this.#_(o,d,c),h=Object.hasOwn(i,c)?i[c]:null,g=this.#n.createElement("div");g.className=`${F}__field`;const y=this.#n.createElement("label");y.className=`${F}__label`,y.textContent=String(o.label??(d&&d.title)??c);const p=this.#n.createElement("div");p.className=`${F}__control`,g.appendChild(y),g.appendChild(p),this.#a.appendChild(g);const m={field:c,colId:d?d.id:null,editor:null,initial:h,opener:null,wrap:g},w=H({grid:this.#e,column:f,colId:d?d.id:c,row:this.#l,data:i,value:h,text:h==null?"":String(h),locale:this.#e.get("locale"),props:o.props||d&&d.edit&&d.edit.props,lookup:o.lookup||d&&d.lookup,document:this.#n,cell:p,overlay:this.#T(),stop:()=>this.#N(m)},this.#r);if(w){m.editor=w;try{N(w.value)&&(m.initial=w.value())}catch{}if(this.#u.push(m),w.popup===!0)this.#D(p,m);else{const v=N(w.element)?w.element():null;v&&p.appendChild(v)}}}}#E(n){if(!this.#f)return;const i=this.#t.viewport?.root;if(!(!i||!N(i.getAttribute)))for(const o of["data-theme","data-density","dir"]){const c=i.getAttribute(o);c?n.setAttribute(o,c):N(n.removeAttribute)&&n.removeAttribute(o)}}#T(){return this.#f?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#D(n,i){const o=this.#n.createElement("button");o.className=`${F}__opener`,o.type="button",i.opener=o,this.#M(i);const c=()=>{N(i.editor.attached)&&i.editor.attached()};o.addEventListener("click",c),this.#m.push(()=>o.removeEventListener("click",c)),n.appendChild(o)}#R(n,i){const o=n.wrap;o&&N(o.scrollIntoView)&&o.scrollIntoView({block:"nearest"});const c=n.opener||(N(n.editor.focusTarget)?n.editor.focusTarget():null);c&&N(c.focus)&&c.focus();const d=this.#t&&this.#t.announce;N(d)&&i&&d.call(this.#t,String(i))}#N(n){if(!n.opener||!n.editor)return;const i=N(n.editor.popupHandle)?n.editor.popupHandle():null;i&&N(i.hide)&&i.hide(),this.#M(n),N(n.opener.focus)&&n.opener.focus()}#M(n){if(!n.opener)return;let i="";try{const c=n.colId?this.#e.columns.get(n.colId):null,d=c&&c.dataType&&c.dataType.format;N(d)&&(i=d({value:N(n.editor.value)?n.editor.value():null,column:c,row:this.#l,data:this.#l?this.#l.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&N(n.editor.toClipboard)&&(i=n.editor.toClipboard())}catch{i=""}const o=i===""||i==null;n.opener.textContent=o?this.#p("form.choose"):String(i),n.opener.classList.toggle(`${F}__opener--empty`,o)}#_(n,i,o){const c=n.editor||n.type||n.lookup||n.props;if(i&&!c)return i;const d={...i&&i.edit?i.edit:{}};return n.editor&&(d.editor=n.editor),n.props&&(d.props=n.props),{...i||{id:o,field:o},type:n.type||i&&i.type||"text",lookup:n.lookup||i&&i.lookup||void 0,edit:d}}#U(n){for(const i of this.#e.columns.all())if(!i.generated&&i.field===n)return i;return null}#F(){for(const n of this.#u)N(n.editor.destroy)&&n.editor.destroy();this.#u=[]}destroy(){this.#d+=1,this.#S(),this.#F();for(const n of this.#m)n();this.#m=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null,this.#l=null}}}),Se("packages/dom/src/toolpanelmount.js",function(e,V){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return p}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,L=V("packages/dom/src/ui/toolpanel.js"),W=L.ToolPanel,Z=L.toolPanels,H=L.toolPanelTitles,U=L.toolPanelIcons,F=V("packages/dom/src/filters/index.js").createFilter,k=V("packages/dom/src/editors/common.js"),S=k.CLS,b=k.documentFor,a=k.scannableRows,l=V("packages/dom/src/filtermenu.js"),r=l.mergeColumnFilter,t=l.branchFor,n=Object.freeze(["column:visible","column:moved","column:pinned","column:grouped","column:pivoted","filter:changed","model:changed","views:changed","sort:changed","history:changed","state:reset","cell:changed","formatting:changed"]);function i(m){const{grid:w,container:v}=m||{};if(!w)throw new Error("[lattice] mountPanel needs a grid");if(!v||!v.appendChild)throw new Error("[lattice] mountPanel needs a container element");const u=N(m.panel)?m.panel:Z[String(m.panel)];if(!u)throw new Error(`[lattice] unknown panel "${m.panel}"; known panels are ${Object.keys(Z).join(", ")}`);const s=v.ownerDocument||b(v),O=y(w,s,m.announce),E=new u;E.init({document:s,host:O,grid:w,props:m.props||{}});const A=E.element();v.appendChild(A);const M=[];for(const C of n)N(w.on)&&M.push(w.on(C,()=>E.refresh()));return{element:A,refresh(){E.refresh()},destroy(){for(const C of M)C();M.length=0,N(E.destroy)&&E.destroy(),A&&A.parentNode&&A.parentNode.removeChild(A)}}}const o=260,c=30,d=`${S.panel}-dock`;function f(m,w,v){if(!m||!N(m.set))return;const u=t(v.filters.get(),w)||null,s=N(m.get)&&(!N(m.active)||m.active())&&m.get()||null;JSON.stringify(s)!==JSON.stringify(u)&&(u?m.set(u):N(m.clear)?m.clear():m.set(null))}function h(m,w){if(m==="insights"){const s=w&&N(w.get)?w.get("insights"):null;return{other:(s&&typeof s=="object"?s:{}).compareWith||null}}if(m!=="views")return{};const v=w&&N(w.get)?w.get("views"):null,u=v&&typeof v=="object"?v:{};return{allowSave:u.allowSave!==!1,showDiff:u.showDiff===!0,builtinTitle:u.builtinTitle,savedTitle:u.savedTitle}}function g(m){const w=m.pagination&&N(m.pagination.get)?m.pagination.get():null;return w&&Number.isFinite(w.total)?w.total:m.rows.count()}function y(m,w,v){const u=new Map;return{announce(s,O){N(v)&&v(s,O)},t(s,O){return m.messages.t(s,O)},grid:m,document:w,columns:()=>m.columns.all(),showColumns:s=>m.columns.show(s),hideColumns:s=>m.columns.hide(s),groupBy:()=>m.state.get().group||[],setGroupBy:s=>m.columns.group(s),pivotBy:()=>(m.state.get().pivot||{}).columns||[],setPivotBy:s=>m.columns.pivot(s),valueColumns:()=>m.columns.all().filter(s=>s.total).map(s=>s.id),setValueColumns:s=>m.columns.totals(s),valueAggregation(s){const O=m.columns.get(s);return!O||!O.total?"sum":typeof O.total=="string"?O.total:"custom"},setValueAggregation(s,O){m.columns.setTotal(s,O)},quickFilter:()=>m.state.get().quick||"",setQuickFilter:s=>m.filters.quick(s),rowCount:()=>g(m),totalRowCount:()=>N(m.rows.totalCount)?m.rows.totalCount():m.rows.count(),formattableColumns:()=>m.columns.visible().filter(s=>!s.generated).map(s=>({id:s.id,title:String(s.title??s.id)})),formattingRules:s=>m.formatting.list(s),columnSamples:s=>{let O=s;if(!O||O==="*"){const M=m.columns.visible().find(C=>!C.generated);O=M?M.id:null}if(!O)return[];const E=[],A=new Set;for(const M of a(m)){const C=m.rows.value(M.key,O);if(C==null||C==="")continue;const P=typeof C=="object"?E.length:C;if(!A.has(P)&&(A.add(P),E.push(C),E.length>=24))break}return E},profilableColumns:()=>m.columns.visible().filter(s=>!s.generated).map(s=>({id:s.id,title:String(s.title??s.id)})),columnProfile:s=>m.statistics.profile(s),reduceColumn:(s,O)=>m.statistics.reduce(s,O),columnCapability:s=>m.statistics.capability(s),regressionModel:s=>N(m.statistics.regressionModel)?m.statistics.regressionModel(s):null,insightsColumns:()=>m.columns.visible().filter(s=>!s.generated).map(s=>({id:s.id,title:String(s.title??s.id),type:s.type})),subsetVsPopulation:()=>m.statistics.subsetVsPopulation(),datasetVsDataset:s=>m.statistics.datasetVsDataset(s),compareGroups:(s,O)=>m.statistics.compareGroups(s,O),anomalies:s=>m.statistics.anomalies(s||{}),compareColumns:(s,O)=>{if(!s||!O||s===O)return null;const E=m.statistics.regression(s,O);return{n:E?E.n:0,pearson:m.statistics.correlation(s,O),spearman:m.statistics.spearman(s,O),kendall:m.statistics.kendall(s,O),covariance:m.statistics.covariance(s,O),slope:E?E.slope:null,intercept:E?E.intercept:null,r2:E?E.r2:null,stdError:E?E.stdError:null,weighted:m.statistics.weightedAverage(s,O)}},addRule:(s,O)=>m.formatting.add(s,O),removeRule:(s,O)=>m.formatting.remove(s,O),updateRule:(s,O,E)=>m.formatting.update(s,O,E),moveRule:(s,O,E)=>m.formatting.move(s,O,E),clearRules:s=>m.formatting.clear(s),views:()=>m.views.list(),activeId:()=>m.views.activeId,apply:s=>{m.views.apply(s)},saveAs:s=>m.views.save(s),rename:(s,O)=>m.views.rename(s,O),setDefault:s=>m.views.setDefault(s),clearDefault:()=>m.views.setDefault(null),remove:s=>m.views.remove(s),export:s=>m.views.export(s),diff:s=>m.views.diff(s),moveColumn(s,O,E){const A=m.columns.all().map(D=>D.id),M=A.indexOf(s),C=A.indexOf(O);if(M<0||C<0)return;let P=E?C:C+1;M<P&&(P-=1),P!==M&&m.columns.move(s,P)},isFiltered(s){return t(m.filters.get(),s)!==null},clearFilter(s){m.filters.set(r(m.filters.get(),s,null));const O=u.get(s);O&&N(O.clear)?O.clear():O&&N(O.set)&&O.set(null)},clearAllFilters(){m.filters.set(null);for(const s of u.values())N(s.clear)?s.clear():N(s.set)&&s.set(null)},filterFor(s){if(u.has(s))return f(u.get(s),s,m),u.get(s);const O=m.columns.get(s);if(!O)return null;const E=F({grid:m,column:O,colId:s,type:O.type,locale:m.get("locale"),props:{...O.filter&&O.filter.props,values:O.filter&&O.filter.props&&O.filter.props.values||(O.lookup?void 0:()=>m.columns.distinct(s))},lookup:O.lookup,document:w,value:A=>m.rows.value(A.row&&A.row.key,s),rows:O.lookup?void 0:()=>a(m),changed:()=>{const M=(N(E.active)?E.active():!0)&&N(E.get)?E.get():null;m.filters.set(r(m.filters.get(),s,M||null))}});return E&&(f(E,s,m),u.set(s,E)),E},destroyFilters(){for(const s of u.values())N(s.destroy)&&s.destroy();u.clear()}}}class p{#e;#t;#n;#r;#o;#i=null;#a=[];#s="right";#l=null;#u=!1;#c=!1;constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root,this.#o=y(w.grid,w.document,w.announce);const u=(w.panels||["columns","filters"]).map(s=>Z[s]?{name:s,title:H[s]?w.grid.messages.t(H[s]):s,icon:U[s]||s,Ctor:Z[s],props:h(s,w.grid)}:($(`toolpanel:${s}`,`unknown tool panel "${s}"`),null)).filter(Boolean);this.#s=w.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:w.document,host:this.#o,grid:w.grid,panels:u,actions:w.actions,icons:w.icons,side:this.#s,openPanel:w.openPanel})}mount(){const w=this.#t.createElement("div");w.className=`${d} ${d}--${this.#s}`,w.appendChild(this.#r.element()),this.#n.appendChild(w),this.#i=w;const v=this.#r.show.bind(this.#r),u=this.#r.hide.bind(this.#r);this.#r.show=s=>{const O=v(s);return this.#f(),O},this.#r.hide=()=>{u(),this.#f()};for(const s of[...n,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#a.push(this.#e.on(s,()=>this.#r.refresh()));this.#a.push(this.#e.on("presentation:started",s=>{this.#u=!0;const O=s&&s.options&&Array.isArray(s.options.chrome)?s.options.chrome:[];this.#c=O.includes("toolPanel")})),this.#a.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#a.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#a.push(this.#e.on("column:profile:open",s=>{const O=s&&s.colId,E=this.#r.panels.find(A=>A.name==="statistics");E&&O!=null&&(E.panel.column=String(O)),this.open("statistics")})),this.#f()}open(w){this.#r.show(w),this.#f()}close(){this.#r.hide(),this.#f()}toggle(w){this.#r.toggle(w),this.#f()}addAction(w){if(!(!w||!w.name)&&!this.#r.actions.some(v=>v.name===w.name)){if(this.#r.registerAction(w),this.#l&&!w.annotation){const v=this.#r.actions.find(u=>u.name===w.name);v&&this.#h(v.button)}else!this.#l&&w.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(w){this.#r.removeAction(w)&&this.#f()}presentOnly(){return this.#l?!0:this.#r.actions.some(w=>w.annotation&&w.button)?(this.#d(),!0):!1}#d(){const w=this.#r;this.#l={hidden:[],reopen:w.openPanel||null},this.#l.reopen&&w.hide(),this.#h(w.body);for(const v of[...w.tabs?.children||[]])v!==w.actionGroup&&this.#h(v);for(const v of[...w.actionGroup?.children||[]]){const u=w.actions.find(s=>s.button===v);(!u||!u.annotation)&&this.#h(v)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const w=this.#l;if(!w)return!1;this.#l=null;for(const v of w.hidden)v.el&&v.el.style&&(v.el.style.display=v.display);return w.reopen&&this.#r.show(w.reopen),this.#f(),!0}#h(w){if(!w||!w.style||!this.#l)return;const v=w.style.display||"";v!=="none"&&(w.style.display="none",this.#l.hidden.push({el:w,display:v}))}#f(){if(!this.#i)return;const w=!!this.#r.openPanel;this.#i.setAttribute("data-open",w?"true":"false"),this.#i.style.width=w?`${o}px`:"";const v=`${w?o:this.#m()}px`;this.#n.style.paddingLeft=this.#s==="left"?v:"",this.#n.style.paddingRight=this.#s==="left"?"":v,this.#n.style.setProperty("--lattice-dock-left",this.#s==="left"?v:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#s==="left"?"0px":v)}#m(){const w=this.#r&&N(this.#r.element)?this.#r.element().querySelector?.(`.${S.panel}__tabs`):null,v=w&&(w.offsetWidth||w.getBoundingClientRect?.().width)||0;return v>0?Math.ceil(v):c}destroy(){for(const w of this.#a)w();this.#a=[],this.#l=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),Se("packages/dom/src/celledit.js",function(e,V){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return S}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,Z=V("packages/dom/src/editors/common.js"),H=Z.CLS,U=Z.markInvalid,F=V("packages/dom/src/detailhost.js").insideDetail,k=`${H.editor}-host`;class S{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=-1;#u=[];#c=null;#d=!1;constructor(t){this.#e=t.grid,this.#t=t.document,this.#n=t.renderer,this.#r=t.registry||null,this.#o=t.cellLayer||null}mount(){this.#u.push(this.#e.on("cell:edit:start",f=>this.open(f))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,n=this.#e.get("edit"),i=n&&typeof n=="object"&&n.start||"double",o=f=>{if(F(f.target,t))return;const h=b(f.target,w=>w.getAttribute&&w.getAttribute("data-col"));if(!h)return;const g=b(h,w=>w.getAttribute&&w.getAttribute("data-key"));if(!g)return;const y=this.#e.rows.byKey(g.getAttribute("data-key"));if(!y||y.group)return;const p=h.getAttribute("data-col"),m=this.#e.columns.get(p);!m||!m.edit||!m.edit.enabled||this.#e.edit.start(y.key,p)},c=i==="key"?null:i==="single"?"click":"dblclick";c&&(t.addEventListener(c,o),this.#u.push(()=>t.removeEventListener(c,o)));const d=f=>{!this.#i||!this.#s||this.#m(f.target)||this.commit()};this.#t.addEventListener("mousedown",d,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",d,!0))}get target(){return this.#s}open(t){this.close();const n=t.key||t.row&&t.row.key,i=t.colId;if(!n||!i)return;const o=this.#e.columns.get(i),c=this.#e.rows.byKey(n);if(!o||!c)return;const d=this.#y(n,i);if(this.#c=d,!d){$("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const f=this.#e.permissions,h=!!(f&&N(f.isSecret)&&f.isSecret(i)),g=W({grid:this.#e,column:o,colId:i,row:c,data:c.data,value:h?null:this.#e.rows.value(n,i),text:h?"":this.#e.rows.text(n,i),locale:this.#e.get("locale"),props:o.edit&&o.edit.props,lookup:o.lookup,document:this.#t,cell:d,overlay:this.#n.viewport.overlays,onCommit:m=>this.#f({value:m,key:n,colId:i}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:m=>{this.#d||this.#e.edit.stop(m)}},this.#r);if(!g){$(`celledit.noeditor:${i}`,`column "${i}" has no editor.`);return}this.#i=g,this.#a=d,this.#s={key:n,colId:i},this.#d=!1,this.#l=this.#v(d);const y=g.element();g.popup?(this.#n.viewport.overlays.appendChild(y),a(y,d,this.#n.viewport.root)):d.replaceChildren(y),d.classList.add(k),N(g.attached)&&g.attached(),l(y);const p=m=>this.#h(m);y.addEventListener("keydown",p),this.#u.push(()=>y.removeEventListener("keydown",p))}#h(t){const n=t.key;if(n!=="Enter"&&n!=="Tab"&&n!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),n==="Escape"){this.#e.edit.stop(!0);return}const i=n==="Enter"?this.#p(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&i&&this.#e.edit.start(i.key,i.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#s)return!1;if(this.#d)return!0;if(N(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:n}=this.#s;if(N(this.#i.value)){const i=this.#i.value();if(N(this.#i.validate)){const o=this.#i.validate(i);if(o!==!0){if(U(this.#c,o),N(this.#i.focusTarget)){const c=this.#i.focusTarget();c&&N(c.focus)&&c.focus()}return!1}U(this.#c,null)}this.#f({value:i,key:t,colId:n})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(t){if(!t)return!1;const n=N(this.#i.element)?this.#i.element():null;if(n&&N(n.contains)&&n.contains(t))return!0;const i=this.#c;return!!(i&&N(i.contains)&&i.contains(t))}#p(t){if(!this.#s||this.#l<0)return null;for(let n=this.#l+t;n>=0&&n<this.#e.rows.count();n+=t){const i=this.#e.rows.get(n);if(i&&!i.group)return{key:i.key,colId:this.#s.colId}}return null}#g(t){if(!this.#s)return null;const n=this.#e.columns.visible(),i=n.findIndex(o=>o.id===this.#s.colId);for(let o=i+t;o>=0&&o<n.length;o+=t){const c=n[o];if(c.edit&&c.edit.enabled)return{key:this.#s.key,colId:c.id}}return null}#v(t){const n=b(t,o=>o.getAttribute&&o.getAttribute("data-index"));if(!n)return-1;const i=Number(n.getAttribute("data-index"));return Number.isFinite(i)?i:-1}#y(t,n){const i=this.#n.viewport.root;if(!i||!i.querySelectorAll)return null;for(const o of i.querySelectorAll(`[data-col="${n}"]`)){const c=b(o,d=>d.getAttribute&&d.getAttribute("data-key"));if(c&&c.getAttribute("data-key")===t)return o}return null}close(){this.#c&&U(this.#c,null);const t=this.#b();if(this.#i&&N(this.#i.destroy)&&this.#i.destroy(),this.#a){if(this.#a.classList.remove(k),this.#o&&N(this.#o.releaseCell)){const n=this.#s?this.#e.columns.get(this.#s.colId):null;this.#o.releaseCell(this.#a,n)}this.#a.replaceChildren&&this.#a.replaceChildren(),t&&this.#w(this.#a),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#a=null,this.#s=null,this.#l=-1,this.#d=!1}#b(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const n=this.#i&&N(this.#i.element)?this.#i.element():null,i=o=>!!o&&N(o.contains)&&o.contains(t);return i(n)||i(this.#a)}#w(t){const i=N(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;i&&N(i.focus)&&i.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function b(r,t){let n=r;for(;n;){if(t(n))return n;n=n.parentNode}return null}function a(r,t,n){if(!N(t.getBoundingClientRect))return;const i=t.getBoundingClientRect(),o=n.getBoundingClientRect();r.style.position="absolute",r.style.top=`${Math.round(i.top-o.top)}px`,r.style.minWidth=`${Math.round(i.width)}px`,r.style.left=`${Math.round(i.left-o.left)}px`;const c=r.offsetWidth||Math.round(i.width),d=Math.round(i.left-o.left)+c-Math.round(o.width);d>0&&(r.style.left=`${Math.max(0,Math.round(i.left-o.left)-d)}px`)}function l(r){const t=r.querySelector&&r.querySelector("input, select, textarea, [tabindex]")||r;N(t.focus)&&t.focus(),N(t.select)&&t.select()}}),Se("packages/dom/src/editbar.js",function(e,V){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return z}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/editors/index.js").createEditor,U=`${V("packages/dom/src/editors/common.js").CLS.editor}-bar`;class z{#e;#t;#n;#r=null;#o=null;#i=null;#a=null;#s=null;#l=null;#u=!1;#c=null;#d=[];constructor(k){this.#e=k.grid,this.#t=k.document,this.#n=k.root}mount(){const k=this.#t,S=k.createElement("div");S.className=U;const b=k.createElement("span");b.className=`${U}__ref`,b.textContent="";const a=k.createElement("div");a.className=`${U}__slot`;const l=k.createElement("span");l.className=`${U}__readonly`,S.appendChild(b),S.appendChild(a),this.#n.insertBefore(S,this.#n.firstChild),this.#r=S,this.#o=b,this.#i=a,this.#s=l;for(const r of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(r,t=>this.#f(t)))}bind(k,S){const b=this.#e.columns.get(S),a=k?this.#e.rows.byKey(k):null;this.#l=a&&b&&!a.group?{key:k,colId:S}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#l){this.#o.textContent="";return}const{key:k,colId:S}=this.#l,b=this.#e.columns.get(S);if(!b)return;if(this.#o.textContent=b.title||S,!!!(b.edit&&b.edit.enabled)){this.#s.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#s);return}const l=this.#e.rows.byKey(k);if(!l)return;const r=W({grid:this.#e,column:b,colId:S,row:l,data:l.data,value:this.#e.rows.value(k,S),text:this.#e.rows.text(k,S),locale:this.#e.get("locale"),props:b.edit&&b.edit.props,lookup:b.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:c=>c?this.cancel():this.commit(!0)});if(!r){$(`editbar.noeditor:${S}`,`column "${S}" has no editor.`),this.#s.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#s);return}this.#a=r;const t=r.element();r.popup?(this.#s.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#s)):this.#i.appendChild(t),N(r.attached)&&r.attached();const n=c=>this.#m(c),i=()=>{this.#u=!0},o=[t,this.#i];for(const c of o)c.addEventListener("keydown",n),c.addEventListener("input",i),c.addEventListener("change",i);this.#c=()=>{for(const c of o)c.removeEventListener("keydown",n),c.removeEventListener("input",i),c.removeEventListener("change",i)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#a&&N(this.#a.destroy)&&this.#a.destroy(),this.#a=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(k){if(k&&k.colId&&(k.key||k.row&&k.row.key)){this.bind(k.key||k.row.key,k.colId);return}this.refresh()}#m(k){if(k.key==="Enter"){k.preventDefault(),this.commit();return}k.key==="Escape"&&(k.preventDefault(),this.cancel())}commit(k){if(!this.#l||!this.#u&&!k)return!1;const{key:S,colId:b}=this.#l;if(!this.#a||!N(this.#a.value))return!1;const a=this.#a.value();return this.#u=!1,this.#e.edit.start(S,b),this.#e.edit.stop(!1,{value:a,key:S,colId:b}),this.refresh(),!0}destroy(){this.#h();for(const k of this.#d)k();this.#d=[],this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#l=null}}}),Se("packages/dom/src/pastepreview.js",function(e,V){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return F}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.clear,U="lat-pastepreview",z='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class F{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=null;#l=null;#u=[];constructor(S){this.#e=S.grid,this.#t=S.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(S,b){const a=this.#e;return(a&&a.messages?a.messages:L).t(S,b)}#d(S){const b=`paste.preview.reason.${S}`,a=this.#c(b);return a===b?S:a}#h(S){return S==null||S===""?"":String(S)}#f(S,b){const a=this.#e.columns&&N(this.#e.columns.get)?this.#e.columns.get(b):null;return`${a&&(a.title||a.headerName)||b} · ${S}`}show(S,b){const a=this.#y();if(!a)return!1;this.#s=b&&b.onConfirm,this.#l=b&&b.onCancel||null;const l=S&&S.changes||[],r=S&&S.rejected||[],t=l.filter(i=>i.changed);this.#m(t,r);const n=a.ownerDocument;return this.#a=n&&n.activeElement,a.style.display="",N(a.focus)&&a.focus(),this.#w(this.#c("a11y.paste.previewOpened",{count:t.length,changes:t.length,rejected:r.length}),{repeat:!0}),!0}#m(S,b){const a=this.#r.ownerDocument;H(this.#r);const l=Z(a,"p",{class:`${U}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:S.length,changes:S.length,rejected:b.length})});if(this.#r.appendChild(l),!S.length&&!b.length){this.#r.appendChild(Z(a,"p",{class:`${U}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!S.length;return}this.#o.disabled=!S.length,S.length&&(this.#r.appendChild(Z(a,"h3",{class:`${U}__heading`,text:this.#c("paste.preview.changesHeading",{count:S.length})})),this.#r.appendChild(this.#p(a,S))),b.length&&(this.#r.appendChild(Z(a,"h3",{class:`${U}__heading ${U}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:b.length})})),this.#r.appendChild(this.#g(a,b)))}#p(S,b){const a=Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),l=b.map(r=>Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"row"},text:this.#f(r.key,r.colId)}),Z(S,"td",{class:`${U}__old`,text:this.#h(r.oldValue)}),Z(S,"td",{class:`${U}__new`,text:this.#h(r.newValue)})]}));return Z(S,"table",{class:`${U}__table`,children:[Z(S,"thead",{children:[a]}),Z(S,"tbody",{children:l})]})}#g(S,b){const a=Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),l=b.map(r=>Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"row"},text:this.#f(r.key,r.colId)}),Z(S,"td",{class:`${U}__reason`,text:this.#d(r.reason)})]}));return Z(S,"table",{class:`${U}__table ${U}__table--rejected`,children:[Z(S,"thead",{children:[a]}),Z(S,"tbody",{children:l})]})}confirm(){const S=this.#s;this.#v(),N(S)&&S()}cancel(){const S=this.#l;this.#v(),this.#w(this.#c("a11y.paste.cancelled"),{repeat:!0}),N(S)&&S()}#v(){if(!this.#n)return;this.#n.style.display="none",this.#s=null,this.#l=null;const S=this.#a;this.#a=null,S&&N(S.focus)&&S.focus()}#y(){if(this.#n)return this.#n;const S=this.#t.viewport&&this.#t.viewport.overlays,b=S&&S.ownerDocument;if(!S||!b||!N(b.createElement))return null;const a=`${U}-title`,l=Z(b,"h2",{class:`${U}__title`,attrs:{id:a},text:this.#c("paste.preview.title")}),r=Z(b,"div",{class:`${U}__body`}),t=Z(b,"button",{class:`${U}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),n=Z(b,"button",{class:`${U}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),i=Z(b,"div",{class:`${U}__foot`,children:[n,t]}),o=Z(b,"div",{class:U,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":a},children:[Z(b,"div",{class:`${U}__head`,children:[l]}),r,i]});return S.appendChild(o),this.#n=o,this.#r=r,this.#o=t,this.#i=n,this.#b(o,t,n),o}#b(S,b,a){const l=n=>{if(n.stopPropagation(),n.key==="Escape"){n.preventDefault(),this.cancel();return}if(n.key!=="Tab")return;const i=[...S.querySelectorAll(z)].filter(f=>!f.disabled);if(!i.length){n.preventDefault();return}const o=i[0],c=i[i.length-1],d=S.ownerDocument.activeElement;n.shiftKey&&(d===o||d===S)?(n.preventDefault(),c.focus()):!n.shiftKey&&d===c&&(n.preventDefault(),o.focus())},r=n=>{n&&N(n.preventDefault)&&n.preventDefault(),this.confirm()},t=n=>{n&&N(n.preventDefault)&&n.preventDefault(),this.cancel()};S.addEventListener("keydown",l),b.addEventListener("click",r),a.addEventListener("click",t),this.#u.push(()=>{S.removeEventListener("keydown",l),b.removeEventListener("click",r),a.removeEventListener("click",t)})}#w(S,b){const a=this.#t&&this.#t.announce;N(a)&&a.call(this.#t,S,b)}destroy(){for(const S of this.#u)S();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#a=null,this.#s=null,this.#l=null}}}),Se("packages/dom/src/rangeselect.js",function(e,V){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/model/selection.js"),Z=W.extendSeries,H=W.resolveSelectionConfig,U=V("packages/dom/src/renderer/textentry.js"),z=U.isTextEntry,F=U.isFindBarControl,S=V("packages/dom/src/pastepreview.js").PastePreview,b=V("packages/dom/src/columnmenu.js"),a=b.chartableRange,l=b.rangeChartConfig,r="lat-cell--range",t="lat-cell--range-edge",n=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),i=3;class o{#e;#t;#n;#r=!1;#o=[];#i=null;#a=null;#s=null;#l=null;#u=null;constructor(f){this.#e=f.grid,this.#t=f.renderer,this.#n=f.document,this.#l=f.preview||null}mount(){const f=this.#t.viewport.root,h=m=>this.#c(m),g=m=>this.#d(m),y=()=>this.#h(),p=m=>this.#f(m);f.addEventListener("pointerdown",h),this.#n.addEventListener("pointermove",g),this.#n.addEventListener("pointerup",y),f.addEventListener("keydown",p),this.#o.push(()=>{f.removeEventListener("pointerdown",h),this.#n.removeEventListener("pointermove",g),this.#n.removeEventListener("pointerup",y),f.removeEventListener("keydown",p)});for(const m of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(m,()=>this.paint()));this.paint()}#c(f){if(f.button!==0)return;const h=f.target;if(!h||!N(h.closest))return;if(this.#r=!1,h.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:f.clientX,fromY:f.clientY,armed:!0};return}if(h.closest('[data-role="row-drag"]'))return;const g=this.#F(h);if(!g)return;if(f.shiftKey&&this.#e.selection.corner()){const p=this.#E(g);this.#e.selection.extendRange(p.rowIndex,p.colId),this.#i={mode:"select",fromX:f.clientX,fromY:f.clientY,armed:!0};return}const y=this.#C(g);this.#u=y,this.#e.selection.startRange(y.rowIndex,y.colId,{additive:f.ctrlKey||f.metaKey}),this.#i={mode:"select",fromX:f.clientX,fromY:f.clientY,armed:!1}}#d(f){const h=this.#i;if(!h)return;if(!h.armed){if(Math.abs(f.clientX-h.fromX)+Math.abs(f.clientY-h.fromY)<i)return;h.armed=!0}const g=this.#Y(f.clientX,f.clientY);if(!g)return;if(h.mode==="fill"){this.#s=g,this.paint();return}const y=this.#E(g);this.#e.selection.extendRange(y.rowIndex,y.colId)}#h(){const f=this.#i;if(this.#i=null,!!f){if(f.mode==="fill"&&this.#s){const h=this.#s;this.#s=null,this.fillTo(h.rowIndex)}this.#s=null,this.paint()}}#f(f){if(this.#N()||F(f.target)||z(f.target))return;const h=f.ctrlKey||f.metaKey,g=f.key;if(h&&(g==="c"||g==="C")){this.copy(),f.preventDefault();return}if(h&&(g==="v"||g==="V")){this.paste(),f.preventDefault();return}if(h&&(g==="d"||g==="D")){this.fillDown(),f.preventDefault();return}if(g==="Delete"||g==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),f.preventDefault();return}this.clear(),f.preventDefault();return}if(f.altKey&&g==="F1"){this.chartSelection()&&f.preventDefault();return}if(!f.shiftKey)return;const y={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[g];if(!y)return;if(h){const A=this.#U();if(!A)return;if(!this.#r){const K=this.#C(A);this.#u=K,this.#e.selection.startRange(K.rowIndex,K.colId,{additive:!0}),this.#r=!0}const M=this.#e.columns.visible().map(K=>K.id),C=M.indexOf(A.colId),P=this.#e.selection.corner()||{row:A.rowIndex,colId:A.colId},D=this.#E({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+y[0])),colId:M[Math.min(M.length-1,Math.max(0,(C<0?0:C)+y[1]))]});this.#e.selection.extendRange(D.rowIndex,D.colId),f.preventDefault();return}this.#r=!1;const p=this.#e.selection.corner(),m=this.#U(),w=p||m;if(!w)return;if(!p&&m){const A=this.#C(m);this.#u=A,this.#e.selection.startRange(A.rowIndex,A.colId)}const v=this.#e.columns.visible().map(A=>A.id),u=v.indexOf(w.colId??w.colId),s=v[Math.min(v.length-1,Math.max(0,u+y[1]))],O=Math.min(this.#e.rows.count()-1,Math.max(0,(p?p.row:m.rowIndex)+y[0])),E=this.#E({rowIndex:O,colId:s});this.#e.selection.extendRange(E.rowIndex,E.colId),f.preventDefault()}async copy(){const f=this.#e.export.rangeText();if(!f)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const h=globalThis.navigator&&globalThis.navigator.clipboard;if(!h||!N(h.writeText))return!1;try{return await h.writeText(f),this.#e.emit("clipboard:copy",{text:f,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:f,ok:!1,rows:"range"},"user"),!1}}async paste(){const f=globalThis.navigator&&globalThis.navigator.clipboard;if(!f||!N(f.readText))return 0;let h="";try{h=await f.readText()}catch{return 0}return this.pasteText(h)}pasteText(f){if(!f)return 0;const h=this.#e.selection.cells(),g=h.length?h[0]:this.#b();if(!g)return 0;const y=h.length>1?{rows:new Set(h.map(p=>p.key)).size,columns:new Set(h.map(p=>p.colId)).size}:void 0;if(this.#m()){const p=this.#e.edit.previewPaste(g,f,y);if(p.changes.length+p.rejected.length>1)return this.#p().show(p,{onConfirm:()=>this.#g(g,f,y)}),0}return this.#g(g,f,y)}#m(){const f=this.#e.edit;return!!(f&&f.pastePreview&&N(f.previewPaste))}#p(){return this.#l||(this.#l=new S({grid:this.#e,renderer:this.#t})),this.#l}#g(f,h,g){const y=this.#e.edit.pasteInto(f,h,g);return this.#y(y?this.#v("a11y.range.written",{count:y}):this.#v("a11y.range.refused"),{repeat:!0}),y}#v(f,h){const g=this.#e;return(g&&g.messages?g.messages:L).t(f,h)}#y(f,h){const g=this.#t&&this.#t.announce;N(g)&&g.call(this.#t,f,h)}#b(){const f=this.#U();if(!f)return null;const h=this.#e.rows.get(f.rowIndex);return h?{key:h.key,colId:f.colId}:null}clear(){const f=this.#e.selection.cells();return f.length?this.#e.edit.setCells(f.map(h=>({...h,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const f=this.#e.selection.cells();if(f.length<2)return 0;const h=[...new Set(f.map(p=>p.key))];if(h.length<2)return 0;const g=h[0],y=[];for(const{key:p,colId:m}of f)p!==g&&y.push({key:p,colId:m,value:this.#e.rows.value(g,m)});return this.#e.edit.setCells(y)}chartSelection(){const f=l(this.#e);if(!f.handler)return!1;const h=a(this.#e);return h?(f.handler(this.#e,h),!0):!1}fillTo(f){if(this.#e.selection.ranges().length>1)return 0;const h=this.#e.selection.cells();if(!h.length)return 0;const g=[...new Set(h.map(s=>s.key))],y=[...new Set(h.map(s=>s.colId))],p=this.#_(g[g.length-1]);if(p<0||f<=p)return 0;const m=[];for(let s=p+1;s<=f;s++){const O=this.#e.rows.get(s);if(!O)break;m.push(O)}if(!m.length)return 0;const w=[];for(const s of y){const O=g.map(A=>this.#e.rows.value(A,s)),E=this.#w(O,m,s);for(let A=0;A<m.length;A++)w.push({key:m[A].key,colId:s,value:E[A]})}const v=this.#e.edit.setCells(w),u=this.#e.selection.corner();return u&&this.#e.selection.extendRange(f,u.colId),v}#w(f,h,g){const y=this.#e.get("selection"),p=y&&typeof y=="object"?y.fill:void 0;if(N(p)){const m=this.#e.columns.get(g),w=h.map(u=>({row:u,column:m})),v=p({source:f,target:w,direction:"down"});if(Array.isArray(v)&&v.length===h.length)return v}return Z(f,h.length)}paint(){const f=this.#t.viewport.root;if(!f||!f.querySelectorAll)return;const h=this.#e.selection,g=h.ranges().length>0,y=this.#s;for(const p of f.querySelectorAll("[data-col]")){const m=p.getAttribute("data-col"),w=p.parentNode,v=p.getAttribute?p.getAttribute("data-index"):null,u=v!==null&&v!==""?v:w&&w.getAttribute?w.getAttribute("data-index"):null;if(u===null||u==="")continue;const s=Number(u);if(!Number.isFinite(s)||s<0)continue;const O=g&&h.inRange(s,m),E=!!y&&this.#S(s,m,y);p.classList.toggle(r,O||E);const A=O||E?this.#j(s,m,h):null;p.classList.toggle(t,!!A&&A.any);for(const[M,C]of Object.entries(n))p.classList.toggle(C,!!A&&A[M])}this.#A()}#S(f,h,g){const y=this.#e.selection.cells();if(!y.length||!new Set(y.map(w=>w.colId)).has(h))return!1;const m=this.#_([...new Set(y.map(w=>w.key))].pop());return f>m&&f<=g.rowIndex}#j(f,h,g){const y=this.#e.columns.visible().map(u=>u.id),p=y.indexOf(h),m=p>0?y[p-1]:null,w=p>=0&&p<y.length-1?y[p+1]:null,v={top:!g.inRange(f-1,h),bottom:!g.inRange(f+1,h),left:!m||!g.inRange(f,m),right:!w||!g.inRange(f,w)};return v.any=v.top||v.bottom||v.left||v.right,v}#A(){const f=this.#e.selection.corner(),h=this.#t.viewport.overlays;if(!h)return;if(!f||this.#R()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#a&&(this.#a.style.display="none");return}const g=this.#I(f.row,f.colId);if(!g||!N(g.getBoundingClientRect)){this.#a&&(this.#a.style.display="none");return}this.#a||(this.#a=this.#n.createElement("div"),this.#a.className="lat-fill-handle",this.#a.setAttribute("data-role","fill-handle"),this.#a.setAttribute("title",this.#v("a11y.fillHandle")),h.appendChild(this.#a));const y=g.getBoundingClientRect(),p=this.#t.viewport.root.getBoundingClientRect();this.#a.style.display="";const w=this.#t.viewport.rtl===!0?y.left:y.right;this.#a.style.left=`${Math.round(w-p.left)-4}px`,this.#a.style.top=`${Math.round(y.bottom-p.top)-4}px`}#O(f){const h=this.#t;return!f||typeof h.spanAt!="function"?null:h.spanAt(f.rowIndex,f.colId)}#C(f){const h=this.#O(f);return h?{rowIndex:h.row,colId:h.columnId}:f}#E(f){const h=this.#O(f);if(!h)return f;const g=this.#u,y=!!g&&g.rowIndex>=h.row+h.rows,p=this.#D(),m=g?p.indexOf(g.colId):-1,w=m>=0&&m>=h.col+h.cols;return{rowIndex:y?h.row:h.row+h.rows-1,colId:w?h.columnId:h.endColumnId}}#T(){const f=this.#e.selection.corner();if(!f)return!1;const h=this.#O({rowIndex:f.row,colId:f.colId});return!!h&&(h.rows>1||h.cols>1)}#D(){const f=this.#e.columns;return f&&N(f.visible)?f.visible().map(h=>h.id):[]}#R(){return H(this.#e.get("selection")).fillHandle}#N(){const f=this.#t.viewport.root;return!!(f&&f.querySelector&&f.querySelector(".lat-editor-host, .lat-editor--popup"))}#M(){const f=this.#e.selection.cells();return f.length?f[0]:null}#_(f){for(let h=0;h<this.#e.rows.count();h++){const g=this.#e.rows.get(h);if(g&&g.key===f)return h}return-1}#U(){const f=this.#t.viewport.root,h=f&&f.querySelector?f.querySelector('[data-col][tabindex="0"]'):null;return h?this.#F(h):null}#F(f){if(!f||!N(f.closest))return null;const h=f.closest("[data-col]");if(!h||!h.classList.contains("lat-cell"))return null;const g=h.closest("[data-index]");if(!g)return null;const y=Number(g.getAttribute("data-index"));return!Number.isFinite(y)||y<0?null:{rowIndex:y,colId:h.getAttribute("data-col")}}#Y(f,h){const g=this.#n.elementFromPoint?this.#n.elementFromPoint(f,h):null;return g?this.#F(g):null}#I(f,h){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return null;for(const y of g.querySelectorAll(`[data-col="${h}"]`)){const p=y.closest?y.closest("[data-index]"):null;if(p&&Number(p.getAttribute("data-index"))===f)return y}return null}destroy(){for(const f of this.#o)f();this.#o=[],this.#a&&N(this.#a.remove)&&this.#a.remove(),this.#a=null,this.#i=null,this.#s=null,this.#l&&N(this.#l.destroy)&&this.#l.destroy(),this.#l=null}}const c=o}),Se("packages/dom/src/importer.js",function(e,V){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return o}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/core/src/import/index.js"),Z=W.parseDelimited,H=W.inferColumns,U=W.mapRecords,z=W.readXlsx,F=W.looksLikeXlsx,k=V("packages/dom/src/editors/common.js"),S=k.el,b=k.clear,a=k.on,r=V("packages/dom/src/renderer/textentry.js").isTextEntry,t="lat-import",n='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',i=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class o{#e;#t;#n;#r;#o=[];#i=null;#a=null;#s=null;#l=null;constructor(d){this.#e=d.grid,this.#t=d.renderer,this.#n=d.document;const f=d.settings&&typeof d.settings=="object"?d.settings:{};this.#r={file:f.file!==!1,drop:f.drop!==!1,paste:f.paste!==!1,mode:f.mode==="replace"?"replace":"append"},this.#u()}#u(){const d=this.#t&&this.#t.viewport?this.#t.viewport.root:null;d&&(this.#r.drop&&(this.#o.push(a(d,"dragover",f=>{f.dataTransfer&&[...f.dataTransfer.types||[]].includes("Files")&&(f.preventDefault(),d.classList.add("lat-import--dropzone"))})),this.#o.push(a(d,"dragleave",()=>d.classList.remove("lat-import--dropzone"))),this.#o.push(a(d,"drop",f=>{d.classList.remove("lat-import--dropzone");const h=f.dataTransfer&&f.dataTransfer.files&&f.dataTransfer.files[0];h&&(f.preventDefault(),this.#c(h))}))),this.#r.paste&&this.#o.push(a(d,"paste",f=>{if(r(f.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const h=f.clipboardData&&f.clipboardData.getData("text/plain");!h||!h.includes(`
54
54
  `)||(f.preventDefault(),this.fromText(h))})))}openFile(){const d=S(this.#n,"input",{attrs:{type:"file",accept:i}});d.style.display="none",this.#o.push(a(d,"change",()=>{const f=d.files&&d.files[0];f&&this.#c(f),d.parentNode&&d.parentNode.removeChild(d)})),this.#n.body.appendChild(d),d.click()}#c(d){if(N(d.arrayBuffer)){d.arrayBuffer().then(h=>{const g=new Uint8Array(h);if(F(g)){this.fromXlsx(g,d.name);return}this.fromText(new TextDecoder().decode(g),d.name)});return}if(N(d.text)){d.text().then(h=>this.fromText(h,d.name));return}const f=new this.#n.defaultView.FileReader;f.onload=()=>this.fromText(String(f.result||""),d.name),f.readAsText(d)}async fromXlsx(d,f){const{header:h,rows:g}=await z(d);if(!h.length)return;const y=H(h,g,{columns:this.#e.columns.all()}),p=g.filter(m=>m.length!==h.length).length;this.#s={rows:g,columns:y,delimiter:null,name:f,warnings:p?[`${p} row(s) do not have ${h.length} columns`]:[]},this.#d()}fromText(d,f){const{header:h,rows:g,delimiter:y}=Z(d);if(!h.length)return;const p=H(h,g,{columns:this.#e.columns.all()}),m=g.filter(w=>w.length!==h.length).length;this.#s={rows:g,columns:p,delimiter:y,name:f,warnings:m?[`${m} row(s) do not have ${h.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#l=this.#n.activeElement,this.#i.hidden=!1;const d=this.#i.querySelector(n);d&&N(d.focus)&&d.focus(),this.#h(this.#f("import.opened",{count:this.#s.rows.length}),{repeat:!0})}#h(d,f){const h=this.#t&&this.#t.announce;N(h)&&h.call(this.#t,d,f)}#f(d,f){return(this.#e&&this.#e.messages?this.#e.messages:L).t(d,f)}#m(){const d=this.#n,f=S(d,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),h=S(d,"div",{class:`${t}__panel`});h.appendChild(S(d,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#a=S(d,"div",{class:`${t}__body`}),h.appendChild(this.#a);const g=S(d,"div",{class:`${t}__footer`}),y=S(d,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),p=S(d,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(a(y,"click",()=>this.close())),this.#o.push(a(p,"click",()=>this.#g())),g.appendChild(y),g.appendChild(p),h.appendChild(g),f.appendChild(h),this.#o.push(a(f,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...f.querySelectorAll(n)].filter(O=>!O.hidden);if(!v.length)return;const u=v[0],s=v[v.length-1];w.shiftKey&&this.#n.activeElement===u?(w.preventDefault(),s.focus()):!w.shiftKey&&this.#n.activeElement===s&&(w.preventDefault(),u.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(f),this.#i=f}#p(){const d=this.#n,f=b(this.#a),{rows:h,columns:g,name:y,warnings:p}=this.#s;f.appendChild(S(d,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:h.length,name:y||this.#f("import.clipboard")})}));for(const O of p)f.appendChild(S(d,"p",{class:`${t}__warning`,text:O}));const m=this.#e.columns.all().map(O=>O.field||O.id).filter(Boolean),w=S(d,"table",{class:`${t}__map`}),v=S(d,"tr",{});for(const O of["import.colSource","import.colField","import.colType"])v.appendChild(S(d,"th",{text:this.#f(O)}));w.appendChild(v),g.forEach((O,E)=>{const A=S(d,"tr",{});A.appendChild(S(d,"td",{text:O.source}));const M=S(d,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:O.source})}});M.appendChild(S(d,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of m)M.appendChild(S(d,"option",{text:P,attrs:{value:P,selected:P===O.field?!0:null}}));O.field&&!m.includes(O.field)&&M.appendChild(S(d,"option",{text:O.field,attrs:{value:O.field,selected:!0}}));const C=S(d,"td",{});C.appendChild(M),A.appendChild(C),A.appendChild(S(d,"td",{class:`${t}__type`,text:O.type})),w.appendChild(A)}),f.appendChild(w);const u=S(d,"div",{class:`${t}__mode`}),s=S(d,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});s.appendChild(S(d,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),s.appendChild(S(d,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),u.appendChild(S(d,"label",{text:this.#f("import.modeLabel")})),u.appendChild(s),f.appendChild(u)}#g(){const{rows:d,columns:f}=this.#s;for(const m of this.#i.querySelectorAll("select[data-col]")){const w=Number(m.getAttribute("data-col"));f[w]&&m.value!==void 0&&m.value!==null&&(f[w].field=m.value)}const h=this.#i.querySelector("select[data-mode]"),g=h?h.value:void 0,y=g==="replace"||g==="append"?g:this.#r.mode,p=U(d,f);this.#e.import.apply(p,{mode:y}),this.close(),this.#h(this.#f("import.done",{count:p.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#s=null,this.#l&&N(this.#l.focus)&&this.#l.focus(),this.#l=null}destroy(){for(const d of this.#o)d();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#a=null,this.#s=null}}}),Se("packages/dom/src/historybar.js",function(e,V){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.on,U=W.clear,z=W.documentFor,F="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(a,l){return(this.messages&&typeof this.messages.t=="function"?this.messages:L).t(a,l)}init(a){this.messages=a&&a.messages||a&&a.grid&&a.grid.messages||L;const l=a||{};if(this.doc=z(l),this.host=l.host||{},this.props=l.props||{},this.root=Z(this.doc,"div",{class:["lattice-tokens",F],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const r=Z(this.doc,"button",{class:`${F}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(H(r,"click",()=>this.toggle())),this.root.appendChild(r),this.toggleButton=r,this.menu=Z(this.doc,"div",{class:`${F}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(a,l,r){const t=Z(this.doc,"button",{class:`${F}__${a}`,attrs:{type:"button"},children:[Z(this.doc,"span",{class:`${F}__glyph`,text:r,attrs:{"aria-hidden":"true"}}),Z(this.doc,"span",{class:`${F}__label`,text:l})]});return this.off.push(H(t,"click",()=>{const n=this.host[a];N(n)&&n(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const a=this.host,l=N(a.canUndo)?a.canUndo():!1,r=N(a.canRedo)?a.canRedo():!1,t=N(a.peek)?a.peek("undo"):null,n=N(a.peek)?a.peek("redo"):null;this.#t(this.undoButton,"undo",l,t),this.#t(this.redoButton,"redo",r,n),this.open&&this.#n()}#t(a,l,r,t){if(!a)return;a.disabled=!r;const n=l==="undo",i=this.t(n?"history.undo":"history.redo"),o=a.querySelector(`.${F}__label`);o&&(o.textContent=i);const c=t&&t.label?this.t("history.described",{action:i,label:t.label}):i;a.setAttribute("title",r?c:this.t(n?"history.nothingToUndo":"history.nothingToRedo")),a.setAttribute("aria-label",r?c:this.t(n?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const a=this.menu;if(!a)return;U(a);const l=N(this.host.list)?this.host.list():[];if(!l.length){a.appendChild(Z(this.doc,"p",{class:`${F}__empty`,text:this.t("history.empty")}));return}l.forEach((r,t)=>{const n=Z(this.doc,"button",{class:`${F}__item`,attrs:{type:"button",role:"menuitem","data-type":r.type,"data-undone":r.undone?"true":null},children:[Z(this.doc,"span",{class:`${F}__kind`,text:r.type}),Z(this.doc,"span",{class:`${F}__text`,text:r.label||r.type})]});this.off.push(H(n,"click",()=>{const i=t+1;for(let o=0;o<i;o++)N(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),a.appendChild(n)})}destroy(){for(const a of this.off)a();this.off=[],this.root&&N(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=k}),Se("packages/dom/src/diffpaint.js",function(e,V){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,W=V("packages/core/src/i18n/index.js").defaultMessages,Z={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},H="lat-cell--changed",U="lat-cell--added-column";class z{#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 a=this.#e.diff,l=a&&a.enabled;for(const r of b.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key"),n=l?a.statusOf(t):"unchanged";for(const o of Object.values(Z))r.classList.remove(o);l&&Z[n]&&r.classList.add(Z[n]),r.setAttribute("data-diff",l?n:"");const i=l&&n==="changed";for(const o of r.querySelectorAll("[data-col]")){const c=o.getAttribute("data-col");if(o.classList.remove(H,U),o.removeAttribute("data-before"),!i)continue;const d=a.cellStatus(t,c);if(d==="changed"){o.classList.add(H);const f=this.#r(a,t,c);f===null?o.removeAttribute("title"):(o.setAttribute("data-before",f),o.setAttribute("title",this.#o("diff.before",{value:f})))}else d==="added-column"&&o.classList.add(U)}}}#r(b,a,l){const r=this.#e,t=r&&r.columns,n=t&&N(t.get)?t.get(l):null,i=r&&r.permissions;if(n&&i&&N(i.isSecret)&&i.isSecret(n))return null;const o=b.before(a,l);if(o==null)return this.#o("diff.empty");if(!n||!N(n.formatValue))return String(o);const c=N(b.beforeRow)?b.beforeRow(a):void 0,f={...(r.rows&&N(r.rows.byKey)?r.rows.byKey(a):null)||{},data:c===void 0?{}:c};try{const h=n.formatValue(o,f,f.data);return h==null?"":String(h)}catch(h){return $(`diff-before-format:${l}`,`the formatter for column "${l}" threw while formatting a previous value, so the diff hover shows the raw one.`,h),String(o)}}#o(b,a){const l=this.#e;return(l&&l.messages?l.messages:W).t(b,a)}destroy(){for(const a of this.#n)a();this.#n=[];const b=this.#t.viewport.root;if(!(!b||!b.querySelectorAll)){for(const a of b.querySelectorAll("[data-key]")){for(const l of Object.values(Z))a.classList.remove(l);a.removeAttribute("data-diff")}for(const a of b.querySelectorAll("[data-col]"))a.classList.remove(H,U),a.removeAttribute("data-before")}}}function F(S){return!!(S&&S.diff&&(N(S.diff)||typeof S.diff=="object"))}const k=z}),Se("packages/dom/src/highlightpaint.js",function(e,V){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/internal/util.js").isFunction,$="lat-cell--highlight",L="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.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 U=()=>{this.#o=!1,this.paint()};N(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):N(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const z=this.#s();if(z){z.sweep();for(const F of U.querySelectorAll("[data-key]")){const k=F.getAttribute("data-key");for(const S of F.querySelectorAll("[data-col]")){const b=z.active?z.colourFor(k,S.getAttribute("data-col")):null;b?(S.classList.add($),S.style.setProperty(L,b)):S.classList.contains($)&&(S.classList.remove($),S.style.removeProperty(L))}}this.#a(z)}}#a(U){this.#r!==null&&N(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const z=U.nextExpiry;if(!Number.isFinite(z)||!N(this.#i.setTimeout))return;const F=Math.max(0,z-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},F)}#s(){const U=this.#e.highlight;return U&&N(U.model)?U.model():null}destroy(){this.#r!==null&&N(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const z of this.#n)z();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const z of U.querySelectorAll(`.${$}`))z.classList.remove($),z.style.removeProperty(L)}}const Z=W}),Se("packages/dom/src/findpaint.js",function(e,V){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/internal/util.js").isFunction,$="lat-cell--find",L="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.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 U=()=>{this.#r=!1,this.paint()};N(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):N(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const z=this.#e.find;if(!z||!N(z.stateFor))return;const F=N(z.model)?z.model():null,k=!!F&&F.active;if(!k&&!this.#o)return;let S=!1;for(const b of U.querySelectorAll("[data-key]")){const a=b.getAttribute("data-key");for(const l of b.querySelectorAll("[data-col]")){const r=k?z.stateFor(a,l.getAttribute("data-col")):null;r?(S=!0,l.classList.add($),l.classList.toggle(L,r==="current")):l.classList.contains($)&&l.classList.remove($,L)}}this.#o=S}destroy(){for(const z of this.#n)z();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll)){for(const z of U.querySelectorAll(`.${$}`))z.classList.remove($,L);this.#o=!1}}}const Z=W}),Se("packages/dom/src/findbar.js",function(e,V){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const _=V("packages/dom/src/editors/common.js"),N=_.el,$=_.on,W=V("packages/dom/src/renderer/textentry.js").isTextEntry,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,F="lat-find",k=12,S=120;class b{#e;#t;#n;#r;#o;#i=null;#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#v=null;#y=null;#b=!1;constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document||r.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=r.settings&&typeof r.settings=="object"?r.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(r,t){const n=this.#e;return(n&&n.messages&&z(n.messages.t)?n.messages:H).t(r,t)}mount(){const r=this.#S();if(!r)return;r.attachUi({open:n=>this.show(n),close:()=>this.hide(),focus:()=>{this.#a&&this.#a.focus()}}),r.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&z(t.addEventListener)&&this.#o.shortcut!==!1){const n=i=>{if(!(i.ctrlKey||i.metaKey)||i.altKey||i.shiftKey||i.key!=="f"&&i.key!=="F")return;const o=i.target;if(this.#a&&o===this.#a){i.preventDefault(),i.stopPropagation(),z(this.#a.select)&&this.#a.select();return}W(o)||(i.preventDefault(),i.stopPropagation(),this.show())};t.addEventListener("keydown",n,!0),this.#g.push(()=>t.removeEventListener("keydown",n,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#R())),this.#g.push(this.#e.on("columns:changed",()=>this.#A())),this.#g.push(this.#e.on("column:visible",()=>this.#A()))}show(r){const t=this.#j();if(!t)return;const n=t.style.display!=="none";t.style.display="",n||this.#w(),this.#S().setOpen(!0),r!=null&&(this.#a.value=String(r),this.#C()),this.#a.focus(),z(this.#a.select)&&this.#a.select(),this.#R()}hide(){this.#_();const r=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),r&&(r.clear(),r.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&z(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(z(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;z(o.focus)&&o.focus()}search(){this.#C()}destroy(){this.#b=!0,this.#_();for(const t of this.#g)t();this.#g=[];const r=this.#S();r&&(r.attachUi(null),r.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const r=this.#t;r&&z(r.invalidate)&&r.invalidate("size")}#S(){const r=this.#e&&this.#e.find;return r&&z(r.model)?r.model():null}#j(){if(this.#i)return this.#i;const r=this.#t.viewport,t=r?.root,n=this.#n;if(!t||!n||!z(t.insertBefore))return null;const i=N(n,"div",{class:F,attrs:{role:"search","aria-label":this.t("find.label")}});this.#a=N(n,"input",{class:`${F}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#s=N(n,"span",{class:`${F}__count`,attrs:{"aria-hidden":"true"}}),this.#l=N(n,"span",{class:`${F}__scope`,attrs:{"aria-hidden":"true"}}),this.#l.style.display="none",this.#u=N(n,"span",{class:`${F}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=N(n,"button",{class:`${F}__nav ${F}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),c=N(n,"button",{class:`${F}__nav ${F}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=N(n,"button",{class:`${F}__toggle ${F}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=N(n,"button",{class:`${F}__toggle ${F}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=N(n,"select",{class:`${F}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const d=N(n,"button",{class:`${F}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),f=N(n,"div",{class:`${F}__options`,children:[this.#c,this.#d,this.#h]});for(const g of[this.#a,this.#s,this.#l,this.#u,o,c,d,f])i.appendChild(g);this.#g.push($(this.#a,"input",()=>this.#O())),this.#g.push($(o,"click",()=>this.#e.find.prev())),this.#g.push($(c,"click",()=>this.#e.find.next())),this.#g.push($(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#C()})),this.#g.push($(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#C()})),this.#g.push($(this.#h,"change",()=>{const g=this.#h.value;this.#p=g?String(g):null,this.#C()})),this.#g.push($(d,"click",()=>this.hide()));const h=g=>{if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),this.hide();return}g.key==="Enter"&&g.target===this.#a&&(g.preventDefault(),g.stopPropagation(),this.#v!==null&&(this.#N(),this.#C()),g.shiftKey?this.#e.find.prev():this.#e.find.next())};return i.addEventListener("keydown",h),this.#g.push(()=>i.removeEventListener("keydown",h)),i.style.display="none",t.insertBefore(i,r.header||t.firstChild),this.#i=i,this.#A(),i}#A(){const r=this.#h;if(!r)return;const t=this.#n;for(;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(N(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const n=this.#e.columns,i=n&&z(n.visible)?n.visible():[];let o=!1;for(const c of i){if(!c||c.id===void 0)continue;const d=String(c.id);r.appendChild(N(t,"option",{text:c.title||d,attrs:{value:d}})),d===this.#p&&(o=!0)}o||(this.#p=null),r.value=this.#p||""}#O(){const r=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#N(),r===0||!z(this.#r.setTimeout)){this.#C();return}this.#v=this.#r.setTimeout(()=>{this.#v=null,this.#C()},r)}#C(){const r=this.#S();if(!r||this.#b)return;const t=this.#a?this.#a.value:"";if(!t){this.#M(),r.clear();return}r.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#E()}),this.#T()}#E(){const r=this.#t&&this.#t.window,t=r&&Number.isFinite(r.first)?r.first:0;return Math.max(0,t)}#T(){if(this.#y!==null||this.#b)return;const r=()=>{this.#y=null,this.#D()};z(this.#r.requestAnimationFrame)?this.#y=this.#r.requestAnimationFrame(r):z(this.#r.setTimeout)?this.#y=this.#r.setTimeout(r,0):r()}#D(){const r=this.#S();!r||this.#b||!r.active||(r.stale&&r.rescan({from:this.#E()}),!r.complete&&(r.step(k)||this.#T()))}#R(){if(!this.#i||this.#b)return;const r=this.#e.find.count(),t=this.#S().active;let n="",i="idle";t&&(r.total===0?(n=r.complete?this.t("find.none"):this.t("find.searching"),i=r.complete?"none":"searching"):(n=this.t(r.complete?"find.count":"find.countPartial",{current:r.current,total:r.total}),i=r.complete?"matches":"searching")),this.#s.textContent=n,this.#i.setAttribute("data-state",i);const o=t&&r.windowed;this.#l.textContent=o?this.t("find.loadedRows"):"",this.#l.style.display=o?"":"none",t?r.complete&&(this.#u.textContent=r.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:r.current,count:r.total})):this.#u.textContent=""}#N(){this.#v!==null&&z(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#v),this.#v=null}#M(){this.#y!==null&&(z(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#y):z(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null)}#_(){this.#N(),this.#M()}}const a=b}),Se("packages/dom/src/redactpaint.js",function(e,V){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return L}});const _="lat-cell--redacted",N="lat-cell";class ${#e;#t;#n=[];constructor(Z){this.#e=Z.grid,this.#t=Z.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Z=this.#t.viewport?.root;if(!Z||!Z.querySelectorAll)return;const H=this.#e.redaction;if(!H)return;const U=H.active;for(const z of Z.querySelectorAll(`.${N}[data-col]`))U&&H.has(z.getAttribute("data-col"))?z.classList.add(_):z.classList.contains(_)&&z.classList.remove(_)}destroy(){for(const Z of this.#n)Z();this.#n=[]}}const L=$}),Se("packages/dom/src/validationpaint.js",function(e,V){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const N=V("packages/dom/src/editors/common.js").markInvalid,$="lat-cell";function L(H,U){let z=H;for(;z;){if(U(z))return z;z=z.parentNode}return null}class W{#e;#t;#n=[];constructor(U){this.#e=U.grid,this.#t=U.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const U of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(U,()=>this.paint()));this.paint()}#r(U){const z=L(U,F=>F.getAttribute&&F.getAttribute("data-key")!==null);return z?z.getAttribute("data-key"):null}paint(){const U=this.#e.validation;if(!U||!U.active)return;const z=this.#t.viewport?.root;if(!(!z||!z.querySelectorAll))for(const F of z.querySelectorAll(`.${$}[data-col]`)){const k=F.getAttribute("data-col"),S=this.#r(F),b=S?U.errorFor(S,k):null;N(F,b?b.message:null)}}destroy(){for(const U of this.#n)U();this.#n=[]}}const Z=W}),Se("packages/dom/src/presentation.js",function(e,V){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/renderer/textentry.js").isTextEntry,Z=V("packages/dom/src/renderer/viewport.js").CLASS,H="lat-presenting",U="lat-presenting--changing",z="lat-presenting__progress",F="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#a=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",r=>this.#l(r))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&N(this.#n.watch)&&this.#r.push(this.#n.watch(r=>{r||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const l=this.#t.viewport?.root;if(l&&N(l.addEventListener)){const r=t=>this.#s(t);l.addEventListener("keydown",r),this.#r.push(()=>l.removeEventListener("keydown",r))}}#s(l){const r=this.#e.presentation;if(!r?.active)return;const t=l.ctrlKey||l.metaKey,n=l.key;if(n==="Escape"&&!this.#n){l.defaultPrevented||(r.stop(),l.preventDefault?.());return}if(t){n==="="||n==="+"?(r.nudge(1),l.preventDefault?.()):n==="-"||n==="_"?(r.nudge(-1),l.preventDefault?.()):n==="0"&&(r.setScale(1.5),l.preventDefault?.());return}if(!r.views.length||L(l.target))return;n==="ArrowRight"||n==="ArrowDown"||n==="PageDown"||n===" "?(r.step(1),l.preventDefault?.()):n==="ArrowLeft"||n==="ArrowUp"||n==="PageUp"?(r.step(-1),l.preventDefault?.()):n==="Home"?(r.goTo(0),l.preventDefault?.()):n==="End"?(r.goTo(r.views.length-1),l.preventDefault?.()):(n==="r"||n==="R")&&(r.reset(),l.preventDefault?.())}#l(l){!l||!l.viewId||(this.#u(),this.#e.views?.apply?.(l.viewId),this.#c(l))}#u(){const l=this.#t.viewport?.root;l?.classList&&(l.classList.remove(U),l.offsetWidth,l.classList.add(U))}#c(l){const r=this.#t.viewport?.overlays;if(!r||!this.#e.presentation.views.length)return;const t=r.ownerDocument;if(!t?.createElement)return;if(!this.#i){const o=t.createElement("div");o.className=z,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),r.appendChild(o),this.#i=o}const n=this.#e.views?.get?.(l.viewId),i=n&&n.name?n.name:"";this.#i.textContent=i?`${i} · ${(l.index||0)+1} / ${l.count||0}`:`${(l.index||0)+1} / ${l.count||0}`}#d(){if(this.#o){this.#f();return}const l=!!(this.#n&&this.#n.active());this.#n&&!l&&this.#n.enter();const r=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const i of k){if(r.has(i)||i==="toolPanel"&&this.#b())continue;const o=this.#w(i);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",t.push(o))}const n=this.#v();n&&n.style&&n.style.display!=="none"&&this.#y(n)&&(n.style.display="none",t.push(n)),this.#o={maximised:l,hidden:t},this.#t.viewport?.root?.classList?.add(H),this.#f(),this.#p()}#h(){const l=this.#o;this.#o=null;const r=this.#t.viewport?.root;if(r?.classList?.remove(H),r?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),r?.classList?.remove(U),this.#m(),l){const t=this.#e.toolPanel;t&&N(t.presentRestore)&&t.presentRestore();for(const n of l.hidden)n.style.display="";this.#n&&!l.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const l=this.#t.viewport?.root;!l||!l.style||(l.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const l=this.#t.viewport?.root;if(!l?.querySelectorAll)return;const r=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=r&&r.keys.length?new Set(r.keys):null,n=r&&r.colIds.length?new Set(r.colIds):null;for(const i of l.querySelectorAll("[data-key]")){const o=!t||t.has(i.getAttribute("data-key"));for(const c of i.querySelectorAll("[data-col]"))!r||o&&(!n||n.has(c.getAttribute("data-col")))?c.classList.remove(F):c.classList.add(F)}}#p(){this.#g();const l=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(l)||l<=0||!this.#e.presentation.views.length)return;const r=this.#t.viewport?.root?.ownerDocument?.defaultView;r?.setInterval&&(this.#a=r.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,l)))}#g(){if(this.#a===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#a),this.#a=null}#v(){const l=this.#e.element;return!l||!N(l.querySelector)?null:l.querySelector(`.${Z.statusBar}`)}#y(l){const r=l.children||[];for(const t of r)if(!t.style||t.style.display!=="none")return!1;return!0}#b(){const l=this.#e.toolPanel;return!!(l&&N(l.presentOnly)&&l.presentOnly())}#w(l){const r=this.#e.element;if(!r||!N(r.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[l];return t?r.querySelector(t):null}destroy(){this.#o&&this.#h();for(const l of this.#r)l();this.#r=[]}}const b=S}),Se("packages/dom/src/capture.js",function(e,V){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const N=V("packages/core/src/internal/util.js").isFunction,$=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function L(z,F,k){const S=k.getComputedStyle(z),b=F.style;if(b)for(let a=0;a<S.length;a++){const l=S[a];$.has(l)||b.setProperty(l,S.getPropertyValue(l),S.getPropertyPriority(l))}}function W(z,F,k){if(L(z,F,k),z.tagName==="CANVAS"&&N(z.toDataURL))try{const a=z.toDataURL("image/png"),l=F.style;l&&(l.setProperty("background-image",`url(${a})`),l.setProperty("background-size","100% 100%"),l.setProperty("background-repeat","no-repeat"))}catch{}const S=z.children||[],b=F.children||[];for(let a=0;a<S.length&&a<b.length;a++)W(S[a],b[a],k)}function Z(z,F){if(!z||z.startsWith("data:")||z.startsWith("blob:"))return!0;try{return new URL(z,F).origin===F}catch{return!0}}async function H(z,F={}){const k=z.ownerDocument,S=k?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const b=z.getBoundingClientRect(),a=Math.max(1,Math.ceil(b.width)),l=Math.max(1,Math.ceil(b.height)),r=Math.max(.1,Number(F.scale)||2),t=S.location?.origin||"";for(const h of z.querySelectorAll("img")){const g=h.getAttribute("src")||"";if(!Z(g,t))throw new Error(`capture refused: the image at ${g} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const n=z.cloneNode(!0);W(z,n,S),n.style.width=`${a}px`,n.style.height=`${l}px`,n.style.margin="0";const i=new S.XMLSerializer().serializeToString(n),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${l}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${i}</div></foreignObject></svg>`,c=new S.Image;await new Promise((h,g)=>{c.onload=()=>h(void 0),c.onerror=()=>g(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),c.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const d=k.createElement("canvas");d.width=Math.round(a*r),d.height=Math.round(l*r);const f=d.getContext("2d");if(!f)throw new Error("capture could not get a 2d context");return f.fillStyle=F.background||S.getComputedStyle(z).backgroundColor||"#ffffff",f.fillRect(0,0,d.width,d.height),f.drawImage(c,0,0,d.width,d.height),new Promise((h,g)=>{d.toBlob(y=>y?h({blob:y,width:d.width,height:d.height}):g(new Error("capture produced no image")),F.type||"image/png",F.quality)})}const U=H}),Se("packages/dom/src/annotate.js",function(e,V){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.warnOnce,W=V("packages/dom/src/renderer/direction.js").signedX,Z=Object.freeze(["pen","arrow","rect","highlight"]),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"}),F=14,k="system-ui, -apple-system, sans-serif";function S(o,c){if(!o||typeof o!="object")return null;const d=U[o.type];if(!d)return null;const f=Array.isArray(o.points)?o.points:[],h=[];for(const y of f){const p=Number(y&&y.x),m=Number(y&&y.y);Number.isFinite(p)&&Number.isFinite(m)&&h.push({x:p,y:m})}const g=typeof o.colour=="string"&&o.colour?o.colour:c;if(d==="text"){const y=typeof o.text=="string"?o.text:"";if(!h.length||!y)return null;const p={tool:d,colour:g,points:[h[0]],text:y,region:b(o.region)},m=Number(o.fontSize);return Number.isFinite(m)&&m>0&&(p.fontSize=m),typeof o.background=="string"&&o.background&&(p.background=o.background),p}return h.length<2?null:{tool:d,colour:g,points:h,region:b(o.region)}}function b(o){return o==="start"||o==="end"?o:"centre"}function a(o){const c={type:z[o.tool]||o.tool,colour:o.colour,points:o.points.map(d=>({x:d.x,y:d.y}))};return(o.region==="start"||o.region==="end")&&(c.region=o.region),o.tool==="text"&&(c.text=o.text,o.fontSize!==void 0&&(c.fontSize=o.fontSize),o.background!==void 0&&(c.background=o.background)),c}const l="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(o){return o==="arrow"||o==="rect"}class n{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#a=[];#s=null;#l=[];#u=null;constructor(c){this.#e=c.grid,this.#t=c.renderer,this.#u=Array.isArray(c.seed)?c.seed:null}get tool(){return this.#o}get count(){return this.#a.length}mount(){this.#l.push(this.#e.on("scroll",()=>this.redraw())),this.#l.push(this.#e.on("render:done",()=>this.redraw())),this.#l.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(c){const d=S(c,this.#i);return d?(d.durable=!0,this.#a.push(d),this.#w(),this.redraw(),this.#A(),this.#a.length):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${H.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#a.length)}list(){return this.#a.map(a)}replaceAll(c){const d=Array.isArray(c)?c:[];this.#a=d.map(f=>S(f,this.#i)).filter(Boolean);for(const f of this.#a)f.durable=!0;this.#a.length&&this.#w(),this.redraw(),this.#A()}#c(){const c=this.#t.viewport?.root;if(!c||!N(c.addEventListener))return;const d=f=>{!this.#o||!f||f.key!=="Escape"||(this.use(null),f.preventDefault?.())};c.addEventListener("keydown",d,!0),this.#l.push(()=>c.removeEventListener("keydown",d,!0))}#d(){const c=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!c||!N(c.matchMedia))return;let d=null;const f=()=>{const h=c.devicePixelRatio||1;let g;try{g=c.matchMedia(`(resolution: ${h}dppx)`)}catch{return}d=g;const y=()=>{this.redraw(),f()};N(g.addEventListener)?g.addEventListener("change",y,{once:!0}):N(g.addListener)&&g.addListener(y)};f(),this.#l.push(()=>{d=null})}use(c,d={}){const f=!!d.colour&&c===this.#o;d.colour&&(this.#i=String(d.colour));const h=c&&Z.includes(c)?c:null;this.#o=h&&h===this.#o&&!f?null:h;const g=this.#o?this.#w():this.#n;return g&&(g.style.pointerEvents=this.#o?"auto":"none",g.style.cursor=this.#o?"crosshair":""),this.#A(),this.#o}undo(){return this.#a.pop(),this.redraw(),this.#A(),this.#a.length}clear(){this.#a.length&&(this.#a=[],this.redraw(),this.#A())}#h(){const c=this.#a.filter(d=>d.durable);c.length!==this.#a.length&&(this.#a=c,this.redraw(),this.#A())}redraw(){!this.#n&&this.#a.length&&this.#w();const c=this.#n,d=this.#r;if(!c||!d)return;this.#S();const{left:f,top:h}=this.#b();d.clearRect(0,0,c.width,c.height);const g=this.#s?[...this.#a,this.#s]:this.#a;for(const y of["centre","start","end"]){const p=g.filter(m=>b(m.region)===y);if(p.length){d.save(),this.#f(d,y),d.translate((y==="centre"?-f:0)||0,-h||0);for(const m of p)this.#v(d,m);d.restore()}}}#f(c,d="centre"){const f=this.#n,h=this.#t.viewport?.bodyViewport;if(!N(f?.getBoundingClientRect)||!N(h?.getBoundingClientRect))return;const g=f.getBoundingClientRect(),y=h.getBoundingClientRect();if(!y.width||!y.height)return;const p=this.#m(d,y);p&&(c.beginPath(),c.rect(p.left-g.left,y.top-g.top,p.width,y.height),c.clip())}#m(c,d){const f=w=>{if(!N(w?.getBoundingClientRect))return null;const v=w.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},h=f(this.#t.viewport?.bodyStart),g=f(this.#t.viewport?.bodyEnd);if(c==="start")return h;if(c==="end")return g;let y=d.left,p=d.left+d.width;const m=d.left+d.width/2;for(const w of[h,g]){if(!w)continue;const v=w.left+w.width;w.left+w.width/2<m?y=Math.max(y,v):p=Math.min(p,w.left)}return p>y?{left:y,width:p-y}:null}#p(c){for(const[d,f]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!N(f?.getBoundingClientRect))continue;const h=f.getBoundingClientRect();if(h&&h.width>0&&c>=h.left&&c<h.left+h.width)return d}return"centre"}#g(c){const d=this.#t.viewport?.bodyViewport;if(!N(d?.getBoundingClientRect))return!0;const f=d.getBoundingClientRect();return!f.width||!f.height?!0:c.clientX>=f.left&&c.clientX<=f.right&&c.clientY>=f.top&&c.clientY<=f.bottom}#v(c,d){const f=d.points;if(!f.length)return;const h=this.#e.presentation?.scale||1;c.lineWidth=(r[d.tool]||3)*h,c.strokeStyle=d.colour,c.fillStyle=d.colour,c.lineCap="round",c.lineJoin="round",c.globalAlpha=d.tool==="highlight"?.32:1;const g=f[0],y=f[f.length-1];if(d.tool==="text"){const p=(d.fontSize||F)*h;c.font=`${p}px ${k}`,c.textBaseline="top";const m=d.text||"";if(d.background){let w=m.length*p*.6;if(typeof c.measureText=="function"){const v=c.measureText(m);v&&Number.isFinite(v.width)&&(w=v.width)}c.fillStyle=d.background,c.fillRect(g.x-p*.15,g.y-p*.1,w+p*.3,p*1.2)}c.fillStyle=d.colour,c.fillText(m,g.x,g.y),c.globalAlpha=1;return}if(d.tool==="rect")c.strokeRect(g.x,g.y,y.x-g.x,y.y-g.y);else if(d.tool==="arrow")c.beginPath(),c.moveTo(g.x,g.y),c.lineTo(y.x,y.y),c.stroke(),this.#y(c,g,y,c.lineWidth);else{c.beginPath(),c.moveTo(g.x,g.y);for(let p=1;p<f.length;p++)c.lineTo(f[p].x,f[p].y);c.stroke()}c.globalAlpha=1}#y(c,d,f,h){const g=Math.atan2(f.y-d.y,f.x-d.x),y=Math.max(8,h*3);c.beginPath(),c.moveTo(f.x,f.y),c.lineTo(f.x-y*Math.cos(g-Math.PI/7),f.y-y*Math.sin(g-Math.PI/7)),c.lineTo(f.x-y*Math.cos(g+Math.PI/7),f.y-y*Math.sin(g+Math.PI/7)),c.closePath(),c.fill()}#b(){const c=N(this.#t.scrollPosition)?this.#t.scrollPosition():null,d=this.#t.viewport?.rtl===!0;return{left:W(c?.left||0,d),top:c?.top||0}}#w(){if(this.#n)return this.#n;const c=this.#t.viewport?.overlays,d=c?.ownerDocument;if(!c||!d?.createElement)return null;const f=d.createElement("canvas");return f.className=l,f.style.position="absolute",f.style.inset="0",f.style.pointerEvents="none",c.appendChild(f),this.#n=f,this.#r=f.getContext?f.getContext("2d"):null,this.#S(),this.#j(f),f}#S(){const c=this.#n,d=this.#t.viewport?.root;if(!c||!d?.getBoundingClientRect)return;const f=d.getBoundingClientRect(),g=c.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(f.width*g)),p=Math.max(1,Math.round(f.height*g));c.width===y&&c.height===p||(c.width=y,c.height=p,c.style&&(c.style.width=`${Math.max(1,f.width)}px`,c.style.height=`${Math.max(1,f.height)}px`),this.#r?.setTransform(g,0,0,g,0,0))}#j(c){const d=(p,m="centre")=>{const w=c.getBoundingClientRect(),{left:v,top:u}=this.#b();return{x:p.clientX-w.left+(m==="centre"?v:0),y:p.clientY-w.top+u}},f=p=>{if(!this.#o||!this.#g(p))return;const m=this.#p(p.clientX);this.#s={tool:this.#o,colour:this.#i,points:[d(p,m)],region:m},c.setPointerCapture?.(p.pointerId),p.preventDefault?.()},h=p=>{if(!this.#s)return;const m=d(p,this.#s.region);t(this.#s.tool)&&this.#s.points.length>1&&this.#s.points.pop(),this.#s.points.push(m),this.redraw()},g=p=>{this.#s&&(this.#s.points.length>1&&this.#a.push(this.#s),this.#s=null,c.releasePointerCapture?.(p.pointerId),this.redraw(),this.#A())},y=p=>{if(!this.#o)return;const m=this.#t.viewport?.bodyViewport;if(!m)return;let w=!1;p.deltaY&&typeof m.scrollTop=="number"&&(m.scrollTop+=p.deltaY,w=!0),p.deltaX&&typeof m.scrollLeft=="number"&&(m.scrollLeft+=p.deltaX,w=!0),w&&p.preventDefault?.()};c.addEventListener("pointerdown",f),c.addEventListener("pointermove",h),c.addEventListener("pointerup",g),c.addEventListener("pointercancel",g),c.addEventListener("wheel",y,{passive:!1}),this.#l.push(()=>{c.removeEventListener("pointerdown",f),c.removeEventListener("pointermove",h),c.removeEventListener("pointerup",g),c.removeEventListener("pointercancel",g),c.removeEventListener("wheel",y)})}#A(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#a.length},"user")}destroy(){for(const c of this.#l)c();this.#l=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#a=[]}}const i=n}),Se("packages/dom/src/timelinebar.js",function(e,V){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Z(F){if(!Number.isFinite(F)||F<1e3)return"now";const k=Math.round(F/1e3);if(k<60)return`${k}s ago`;const S=Math.round(k/60);return S<60?`${S}m ago`:`${Math.round(S/60)}h ago`}function H(F,k){return Number.isFinite(F)?new Date(F).toLocaleTimeString(k||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class U{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#a.push(this.#e.on("timeline:attached",()=>{this.#l(),this.refresh()})),this.#a.push(this.#e.on("timeline:detached",()=>this.#u())),this.#a.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#a.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,S=k.depth,b=k.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-b)),this.#r.disabled=S===0;const a=k.at(),l=k.live;this.#o&&(this.#o.textContent=l?this.#s("timeline.live"):Z(Date.now()-(a||Date.now())),this.#o.setAttribute("data-live",l?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#s("timeline.recording"):H(a,this.#e.get("locale"))),this.#n.setAttribute("data-live",l?"true":"false")}#s(k,S){const b=this.#e;return(b&&b.messages?b.messages:L).t(k,S)}#l(){if(this.#n)return;const k=this.#t.viewport?.overlays,S=k?.ownerDocument;if(!k||!S?.createElement)return;const b=S.createElement("div");b.className=W;const a=S.createElement("span");a.className=`${W}__ago`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const l=S.createElement("input");l.className=`${W}__range`,l.type="range",l.min="0",l.step="1",l.setAttribute("aria-label",this.#s("timeline.scrub"));const r=S.createElement("span");r.className=`${W}__clock`;const t=S.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#s("timeline.goLive"),t.setAttribute("aria-label",this.#s("timeline.returnToPresent")),b.appendChild(a),b.appendChild(l),b.appendChild(r),b.appendChild(t),k.appendChild(b),this.#n=b,this.#r=l,this.#o=a,this.#i=r;const n=()=>{const c=this.#e.timeline.depth;this.#e.timeline.seek(c-Number(l.value))};l.addEventListener("input",n);const i=()=>this.#e.timeline.toLive();t.addEventListener("click",i);const o=c=>c.stopPropagation();l.addEventListener("keydown",o),this.#a.push(()=>{l.removeEventListener("input",n),t.removeEventListener("click",i),l.removeEventListener("keydown",o)})}#u(){this.#n&&(N(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#a)k();this.#a=[],this.#u()}}const z=U}),Se("packages/dom/src/commentpaint.js",function(e,V){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/renderer/direction.js").isRtlElement,H="lat-comment-mark",U="lat-cell--commented",z="lat-cell--commented-open";class F{#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.#a(),this.paint()}paint(){const b=this.#e.comments;if(!b||!b.enabled)return;const a=this.#t.viewport?.root;if(!a||!a.querySelectorAll)return;const l=[];for(const r of a.querySelectorAll("[data-key]")){const t=r.getAttribute("data-key");if(t){l.push(t);for(const n of r.querySelectorAll("[data-col]")){const i=n.getAttribute("data-col"),o=b.at(t,i),c=!!(o&&o.count);n.classList.toggle(U,c),n.classList.toggle(z,c&&o.unresolved>0),this.#i(n,o,i)}}}(l.length!==this.#r.length||l.some((r,t)=>r!==this.#r[t]))&&(this.#r=l,b.request(l))}#o(b,a){const l=this.#e;return(l&&l.messages?l.messages:L).t(b,a)}#i(b,a,l){if(!a||!a.count){b.hasAttribute("aria-description")&&b.removeAttribute("aria-description");return}const r=a.count,t=a.unresolved,n=this.#o("count.comments",{count:r});b.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:n,unresolved:t}):this.#o("comments.allResolved",{comments:n}))}#a(){const b=this.#t.viewport?.root;if(!b||!N(b.addEventListener))return;const a=r=>{const t=this.#e.comments;if(!t||!t.enabled)return;const n=r.target&&N(r.target.closest)?r.target.closest("[data-col]"):null;if(!n||!n.classList.contains(U)||!this.#s(n,r))return;const i=n.closest("[data-key]"),o=i&&i.getAttribute("data-key");o&&(r.stopPropagation(),r.preventDefault(),t.open(o,n.getAttribute("data-col")))},l=r=>{const t=this.#e.comments;if(!t||!t.enabled||!r.altKey||r.key!=="m"&&r.key!=="M")return;const n=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&N(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!n)return;const i=n.closest("[data-key]"),o=i&&i.getAttribute("data-key");o&&(r.preventDefault(),r.stopPropagation(),t.open(o,n.getAttribute("data-col")))};b.addEventListener("click",a,!0),b.addEventListener("keydown",l,!0),this.#n.push(()=>{b.removeEventListener("click",a,!0),b.removeEventListener("keydown",l,!0)})}#s(b,a){if(!N(b.getBoundingClientRect))return!1;const l=b.getBoundingClientRect(),r=Math.max(14,Math.min(24,l.height*.6));return(Z(b)?a.clientX<=l.left+r:a.clientX>=l.right-r)&&a.clientY<=l.top+r}destroy(){for(const b of this.#n)b();this.#n=[]}}const k=F}),Se("packages/dom/src/presencepaint.js",function(e,V){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/editors/common.js").cssEscape,U=V("packages/core/src/model/presence.js").CURSOR_LABEL_MS,z="lat-presence";class F{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#a=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 a of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(a,l=>this.#s(a,l)));this.#l(),this.paint()}}#s(b,a){if(this.#h(),b==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const r=a&&a.peer;r&&(this.#r.textContent=this.#f(b==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:r.name}))}#l(){const b=this.#t.viewport?.overlays,a=b?.ownerDocument;if(!b||!a?.createElement)return;const l=this.#e.get("presence")||{},r=a.createElement("span");if(r.className=`${z}__live`,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),b.appendChild(r),this.#r=r,l.roster===!1)return;const t=a.createElement("div");t.className=z,l.roster&&l.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",b.appendChild(t),this.#n=t}paint(){const b=this.#e.presence,a=this.#t.viewport?.root;if(!b||!b.enabled||!a?.querySelectorAll)return;this.#d(a);const l=b.peers(),r=[...l].sort((t,n)=>t.at-n.at);for(const t of r)for(const n of t.ranges||[])for(const i of n.rowIds||[])for(const o of n.columns||[])this.#c(a,i,o,t,"range");for(const t of r)t.cursor&&this.#c(a,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of r)t.editing&&this.#c(a,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(l)}#u(b){if(this.#a!==null)return;const a=b.filter(t=>t.cursorFresh);if(!a.length)return;const r=Math.max(...a.map(t=>t.cursorAt||0))+U-Date.now();this.#a=setTimeout(()=>{this.#a=null,this.paint()},Math.max(50,r))}#c(b,a,l,r,t){const n=b.querySelector(`[data-key="${Z(a)}"]`),i=n&&n.querySelector(`[data-col="${Z(l)}"]`);i&&(i.setAttribute("data-presence",t),i.style.setProperty("--lat-peer",r.colour),i.setAttribute("data-peer-name",r.name),i.setAttribute("data-peer-initial",r.initials||(r.name||"?").slice(0,1).toUpperCase()),r.idle?i.setAttribute("data-peer-idle","true"):i.removeAttribute("data-peer-idle"),t==="cursor"&&r.cursorFresh&&i.setAttribute("data-peer-fresh","true"),this.#o.add(`${a}${l}`))}#d(b){if(this.#o.size){for(const a of b.querySelectorAll("[data-presence]"))a.removeAttribute("data-presence"),a.removeAttribute("data-peer-name"),a.removeAttribute("data-peer-initial"),a.removeAttribute("data-peer-fresh"),a.removeAttribute("data-peer-idle"),a.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const b=this.#n.ownerDocument,a=this.#e.presence.peers();if(this.#n.textContent="",!a.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const r of a){const t=b.createElement("button");t.className=`${z}__peer`,t.type="button",t.style.setProperty("--lat-peer",r.colour),t.toggleAttribute("data-idle",!!r.idle),t.toggleAttribute("data-hidden",!!r.hidden);let n="presence.peer";r.hidden?n="presence.peerHidden":r.idle&&(n="presence.peerIdle"),t.setAttribute("aria-label",this.#f(n,{name:r.name}));const i=b.createElement("span");i.className=`${z}__dot`,i.setAttribute("aria-hidden","true"),i.textContent=r.initials||(r.name||"?").slice(0,1).toUpperCase(),t.appendChild(i);const o=b.createElement("span");o.className=`${z}__name`,o.textContent=r.name,t.appendChild(o),t.addEventListener("click",()=>this.#e.presence.jumpTo(r.id)),this.#n.appendChild(t)}const l=a.filter(r=>r.hidden).length;if(l){const r=b.createElement("span");r.className=`${z}__hidden`,r.textContent=this.#f("presence.hidden",{count:l}),this.#n.appendChild(r)}}announceRefusal(b){if(!this.#r)return;const a=b&&b.name?b.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:a})}#f(b,a){const l=this.#e;return(l&&l.messages?l.messages:L).t(b,a)}destroy(){for(const a of this.#i)a();this.#i=[],this.#a!==null&&clearTimeout(this.#a),this.#a=null;const b=this.#t.viewport?.root;b?.querySelectorAll&&this.#d(b),this.#n&&N(this.#n.remove)&&this.#n.remove(),this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=F}),Se("packages/dom/src/commentpanel.js",function(e,V){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,Z=V("packages/dom/src/editors/common.js").cssEscape,U=V("packages/core/src/model/comments.js").parseCellKey,z="lat-comments",F=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(r,t){if(!Number.isFinite(r))return"";const n=Math.max(0,Math.round((t-r)/1e3));if(n<60)return"just now";const i=Math.round(n/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function b(r,t,n,i){t.textContent="";const o=String(n??"");if(!i){t.textContent=o;return}const c=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let d=0,f=c.exec(o);for(;f;){f.index>d&&t.appendChild(r.createTextNode(o.slice(d,f.index)));const h=f[0];if(h.startsWith("*")){const g=r.createElement("em");g.textContent=h.slice(1,-1),t.appendChild(g)}else if(h.startsWith("`")){const g=r.createElement("code");g.textContent=h.slice(1,-1),t.appendChild(g)}else{const g=h.indexOf("]("),y=h.slice(1,g),p=h.slice(g+2,-1);if(F.test(p)){const m=r.createElement("a");m.href=p,m.textContent=y,m.rel="noopener noreferrer",m.target="_blank",t.appendChild(m)}else t.appendChild(r.createTextNode(y))}d=f.index+h.length,f=c.exec(o)}d<o.length&&t.appendChild(r.createTextNode(o.slice(d)))}class a{#e;#t;#n=null;#r=null;#o=null;#i=null;#a=null;#s=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#s.push(this.#e.on("comment:threadOpened",t=>this.#l(t))),this.#s.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#s.push(this.#e.on("render:done",()=>{this.#y(),this.#w()})),this.#s.push(this.#e.on("stream:evicted",()=>this.#c()))}#l(t){const n=this.#t.viewport?.root?.ownerDocument;n&&(this.#a=n.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(n),this.#n.setAttribute("data-open","true"),this.#y(),this.#w(),this.#o&&N(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#a;this.#a=null,t&&N(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:n}=U(t);this.#e.rows.byKey(n)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(t){if(!this.#r)return;const i=this.#r.ownerDocument.createElement("p");i.className=`${z}__note`,i.setAttribute("role","status"),i.textContent=t,this.#r.appendChild(i)}#h(t,n){const i=this.#t.viewport?.root;if(!i||!i.querySelector)return null;const o=i.querySelector(`[data-key="${Z(t)}"]`);return o?o.querySelector(`[data-col="${n}"]`):null}#f(t,n){const i=this.#e;return(i&&i.messages?i.messages:L).t(t,n)}#m(t){const n=t.createElement("div");n.className=z,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",this.#f("comments.panel"));const i=t.createElement("header");i.className=`${z}__head`;const o=t.createElement("div");o.className=`${z}__title`,i.appendChild(o);const c=t.createElement("button");c.className=`${z}__resolve`,c.type="button",i.appendChild(c);const d=t.createElement("button");d.className=`${z}__close`,d.type="button",d.setAttribute("aria-label",this.#f("comments.close")),d.textContent="×",i.appendChild(d);const f=t.createElement("div");f.className=`${z}__list`,f.setAttribute("role","log"),f.setAttribute("aria-live","polite");const h=t.createElement("form");h.className=`${z}__composer`;const g=t.createElement("textarea");g.className=`${z}__input`,g.rows=2,g.setAttribute("aria-label",this.#f("comments.write"));const y=t.createElement("button");y.className=`${z}__send`,y.type="submit",y.textContent=this.#f("comments.post"),h.appendChild(g),h.appendChild(y),n.appendChild(i),n.appendChild(f),n.appendChild(h),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(n),this.#n=n,this.#r=f,this.#o=g,this.#p=o,this.#g=c;const p=u=>{u.preventDefault();const s=String(g.value||"").trim();s&&(g.value="",this.#e.comments.add(s))},m=()=>this.#e.comments.close(),w=()=>{this.#v()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=u=>{if(u.stopPropagation(),u.key==="Escape"){u.preventDefault(),this.#e.comments.close();return}if(u.key!=="Tab")return;const s=[...n.querySelectorAll(k)].filter(M=>M.offsetParent!==null||M===g);if(!s.length)return;const O=s[0],E=s[s.length-1],A=n.ownerDocument.activeElement;u.shiftKey&&A===O?(u.preventDefault(),E.focus()):!u.shiftKey&&A===E&&(u.preventDefault(),O.focus())};h.addEventListener("submit",p),d.addEventListener("click",m),c.addEventListener("click",w),n.addEventListener("keydown",v),this.#s.push(()=>{h.removeEventListener("submit",p),d.removeEventListener("click",m),c.removeEventListener("click",w),n.removeEventListener("keydown",v)})}#p=null;#g=null;#v(){return(this.#e.comments.thread||[]).filter(n=>!n.resolved).length}#y(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const n=this.#n.ownerDocument,i=this.#e.get("comments")||{},o=Date.now(),c=t.openKey,{rowId:d,field:f}=U(c),h=this.#e.columns.get(f),g=this.#e.rows.byKey(d),y=N(i.rowLabel)&&g?i.rowLabel(g):d;if(this.#p.textContent=this.#f("comments.cellTitle",{column:h&&(h.title??h.id)||f,row:y}),this.#g.textContent=this.#v()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const p=t.thread||[];if(!p.length){this.#d(this.#f("comments.empty"));return}const m=g&&h?h.getValue(g.data,g):void 0;for(const w of p)this.#r.appendChild(this.#b(n,w,o,m,i))}#b(t,n,i,o,c){const d=t.createElement("article");d.className=`${z}__item`,n.pending&&d.setAttribute("data-pending","true"),n.resolved&&d.setAttribute("data-resolved","true");const f=t.createElement("div");f.className=`${z}__meta`;const h=t.createElement("span");h.className=`${z}__author`,h.textContent=n.author&&(n.author.name||n.author.initials)||this.#f("comments.unknownAuthor"),f.appendChild(h);const g=t.createElement("time");g.className=`${z}__time`;const y=S(n.at,i);g.textContent=n.edited?this.#f("comments.edited",{time:y}):y,f.appendChild(g),d.appendChild(f);const p=t.createElement("div");if(p.className=`${z}__body`,b(t,p,n.body,!!c.markdown),d.appendChild(p),n.value!==void 0&&!Object.is(n.value,o)){const v=t.createElement("p");v.className=`${z}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(n.value),now:String(o)}),d.appendChild(v)}const m=n.can||{},w=v=>m[v]!==!1;if(w("edit")||w("delete")){const v=t.createElement("div");if(v.className=`${z}__actions`,w("delete")){const u=t.createElement("button");u.type="button",u.className=`${z}__action`,u.textContent=this.#f("comments.delete"),u.addEventListener("click",()=>this.#e.comments.remove(n.id)),v.appendChild(u)}d.appendChild(v)}return d}#w(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const n=this.#e.comments.openKey,{rowId:i,field:o}=U(n),c=this.#h(i,o)||this.#i,d=this.#t.viewport?.root;if(!c||!d||!N(c.getBoundingClientRect))return;const f=c.getBoundingClientRect(),h=d.getBoundingClientRect(),g=this.#n.getBoundingClientRect();let y=f.bottom-h.top+4;y+g.height>h.height&&f.top-h.top>g.height&&(y=f.top-h.top-g.height-4);let p=f.left-h.left;p+g.width>h.width&&(p=Math.max(0,h.width-g.width-4)),this.#n.style.top=`${Math.max(0,y)}px`,this.#n.style.left=`${Math.max(0,p)}px`;const m=f.bottom<h.top||f.top>h.bottom;this.#n.toggleAttribute("data-offscreen",m)}destroy(){for(const t of this.#s)t();this.#s=[],this.#n&&N(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const l=a}),Se("packages/dom/src/watermark.js",function(e,V){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/core/src/i18n/index.js").defaultMessages,W=V("packages/dom/src/editors/common.js"),Z=W.el,H=W.on,U="lat-watermark",z="https://www.latticegrid.dev",F=["br","bl","tl","tr"],k=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#a=0;#s=null;constructor(l){this.#e=l.grid,this.#t=l.document,this.#n=l.element,this.#i=l.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),N(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const l=this.#e.licence&&this.#e.licence.ready;l&&N(l.then)&&l.then(()=>this.refresh(),()=>this.refresh())}refresh(){const l=this.#d();l&&!this.#r?(this.#h(),this.#u()):!l&&this.#r&&(this.#f(),this.#c())}#l(){const l=this.#i;if(!l||!N(l.matchMedia))return!1;try{return!!l.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),N(this.#i.setTimeout)&&(this.#l()||(this.#s=this.#i.setTimeout(()=>{if(this.#s=null,!this.#d()){this.#f();return}this.#a=(this.#a+1)%F.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#s!==null&&N(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#s),this.#s=null}#d(){const l=this.#e.licence;return!!(l&&N(l.watermark)&&l.watermark())}#h(){const l=Z(this.#t,"a",{class:`${U}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:L).t("licence.watermark"),attrs:{href:z,target:"_blank",rel:"noopener noreferrer"}});this.#r=Z(this.#t,"div",{class:`${U} ${U}--${F[this.#a]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[l]}),this.#o.push(H(this.#r,"pointerdown",r=>{N(r.stopPropagation)&&r.stopPropagation()})),this.#n&&N(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&N(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const l of this.#o)l();this.#o=[],this.#f()}}const b=S}),Se("packages/dom/src/maximise.js",function(e,V){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const _=V("packages/core/src/internal/util.js"),N=_.warnOnce,$=_.isFunction,L=V("packages/dom/src/editors/common.js"),W=L.el,Z=L.on,H="lat-maximised",U={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"},z="lat-maximised-host",F="lat-maximise-placeholder";class k{#e;#t;#n;#r;#o;#i=null;#a=null;#s=new Set;#l=null;#u=null;constructor(a){this.#e=a.element,this.#t=a.document,this.#n=$(a.onChange)?a.onChange:null,this.#r=$(a.captureScroll)?a.captureScroll:null,this.#o=$(a.restoreScroll)?a.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const a=this.#e.parentNode;if(!a||!this.#t.body)return N("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:F}),this.#i.style.visibility="hidden";const l=this.#e.offsetWidth,r=this.#e.offsetHeight;l&&(this.#i.style.width=`${l}px`),r&&(this.#i.style.height=`${r}px`);const t=this.#r?this.#r():null;a.insertBefore(this.#i,this.#e),this.#c(()=>this.#t.body.appendChild(this.#e)),this.#l={};for(const[n,i]of Object.entries(U))this.#l[n]=this.#e.style[n]||"",this.#e.style[n]=i;return this.#u=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(z),t&&this.#o&&this.#o(t),this.#a=Z(this.#t,"keydown",n=>this.#d(n)),this.#h(),!0}exit(){if(!this.active())return!1;const a=this.#r?this.#r():null,l=this.#i,r=l.parentNode;if(r&&$(r.insertBefore)&&this.#c(()=>r.insertBefore(this.#e,l)),$(l.remove)&&l.remove(),this.#i=null,this.#l){for(const[t,n]of Object.entries(this.#l))this.#e.style[t]=n;this.#l=null}return this.#u!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#u),this.#u=null,this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(z),a&&this.#o&&this.#o(a),this.#a&&this.#a(),this.#a=null,this.#h(),!0}toggle(){return this.active()?!this.exit():this.enter()}#c(a){const l=this.#t.activeElement,r=l&&l!==this.#t.body&&$(this.#e.contains)&&this.#e.contains(l)?l:null;a(),r&&$(r.focus)&&r.focus()}#d(a){!a||a.key!=="Escape"||a.defaultPrevented||this.exit()}#h(){this.#n&&this.#n();for(const a of this.#s)a(this.active())}watch(a){return $(a)?(this.#s.add(a),()=>this.#s.delete(a)):()=>{}}destroy(){this.exit()}}const S=k}),Se("packages/dom/src/promptbar.js",function(e,V){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return n}});const _=V("packages/dom/src/editors/common.js"),N=_.documentFor,$=_.el,L=_.on,W=_.clear,H=V("packages/core/src/i18n/index.js").defaultMessages,z=V("packages/core/src/internal/util.js").isFunction,F=V("packages/core/src/ai/schema.js"),k=F.describeGrid,S=F.promptText,b=V("packages/core/src/ai/intent.js"),a=b.applyPlan,l=b.buildPrompt,r=b.planIntent,t="lat-prompt";class n{#e;#t=null;#n=null;#r={};#o;#i={};#a=null;#s=null;#l=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#v="idle";#y=0;#b=!1;#w=[];t(d,f){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(d,f)}init(d={}){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||H,this.#e=N(d),this.#t=d.grid||null,this.#n=z(d.ask)?d.ask:null,this.#r=d.schemaOptions||{},this.#o=d.context,this.#i={onPlan:z(d.onPlan)?d.onPlan:null,onApply:z(d.onApply)?d.onApply:null,onError:z(d.onError)?d.onError:null},this.#a=$(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(d)}element(){return this.#a}refresh(){this.#b||!this.#a||this.#v!=="busy"&&this.#C()}destroy(){this.#b=!0,this.#y++;for(const d of this.#w)d();this.#w.length=0,this.#g=null,this.#a=null,this.#s=null,this.#l=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(d){if(this.#b||this.#v==="busy")return null;const f=String(d??(this.#s&&this.#s.value)??"").trim();if(!f)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const h=++this.#y;this.#j("busy"),this.#E("Thinking…");let g;try{const y=k(this.#t,this.#r),p=S(y);if(g=await this.#n({prompt:f,schema:y,schemaText:p,message:l(f,p),context:this.#o}),this.#b||h!==this.#y)return null;const m=r(g,y);return this.#A(m),m}catch(y){return this.#b||h!==this.#y||(this.#i.onError&&this.#i.onError(y),this.#T(y instanceof Error?y.message:String(y))),null}}apply(){const d=this.#g;if(this.#b||!d||!d.ok)return null;const f=this.#t?.ai,h=z(f?.apply)?f.apply(d):a(d,this.#t);return this.#i.onApply&&this.#i.onApply(h,d),this.#C(),this.#s&&(this.#s.value=""),h.failed.length?this.#T(`Applied ${h.applied.length}; ${h.failed.map(g=>`${g.type} failed: ${g.reason}`).join("; ")}`):this.#E(`Applied: ${d.describe()}`),h}discard(){this.#b||(this.#C(),this.#E("Discarded."))}#S(d){const f=this.#e,h=$(f,"div",{class:`${t}__row`});this.#s=$(f,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:d.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":d.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push(L(this.#s,"keydown",y=>{const p=y&&y.key;p==="Enter"?(z(y.preventDefault)&&y.preventDefault(),this.ask()):p==="Escape"&&this.#g&&(z(y.preventDefault)&&y.preventDefault(),this.discard())})),h.appendChild(this.#s),this.#l=$(f,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push(L(this.#l,"click",()=>{this.ask()})),h.appendChild(this.#l),this.#a.appendChild(h),this.#u=$(f,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=$(f,"p",{class:`${t}__summary`}),this.#d=$(f,"ul",{class:`${t}__notes`});const g=$(f,"div",{class:`${t}__buttons`});this.#h=$(f,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=$(f,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push(L(this.#h,"click",()=>{this.apply()})),this.#w.push(L(this.#f,"click",()=>{this.discard()})),g.appendChild(this.#h),g.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(g),this.#a.appendChild(this.#u),this.#m=$(f,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=$(f,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#a.appendChild(this.#m),this.#a.appendChild(this.#p)}#j(d){if(this.#v=d,!this.#a)return;this.#a.setAttribute("data-state",d);const f=d==="busy";i(this.#s,f),i(this.#l,f),this.#l&&(this.#l.textContent=this.t(f?"prompt.asking":"prompt.ask")),o(this.#u,d!=="preview"),o(this.#p,d!=="error")}#A(d){const f=d;if(this.#i.onPlan&&this.#i.onPlan(d),!f.ok){this.#g=null;const h=f.rejected.length?f.rejected.map(g=>g.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${h}`);return}this.#g=d,this.#E(""),this.#c&&(this.#c.textContent=f.describe()),this.#O(f.rejected),this.#j("preview")}#O(d){const f=this.#d;if(f){W(f),o(f,!d.length);for(const h of d.slice(0,6))f.appendChild($(this.#e,"li",{class:`${t}__note`,text:h.reason}));d.length>6&&f.appendChild($(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:d.length-6})}))}}#C(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#j("idle")}#E(d){this.#m&&(this.#m.textContent=d)}#T(d){this.#g=null,this.#E(""),this.#p&&(this.#p.textContent=d),this.#j("error")}}function i(c,d){c&&(c.disabled=d,d?c.setAttribute("disabled",""):c.removeAttribute("disabled"))}function o(c,d){c&&(c.hidden=d,d?c.setAttribute("hidden",""):c.removeAttribute("hidden"))}}),Se("packages/dom/src/stat.js",function(e,V){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return d}});const _=V("packages/core/src/internal/util.js"),N=_.isFunction,$=_.isObject,L=_.warnOnce,Z=V("packages/core/src/source/derive.js").reduceValues,U=V("packages/core/src/source/memory.js").isPipelineSettle,F=V("packages/core/src/i18n/index.js").defaultMessages,S=V("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"},a="unknown",l=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),r=Object.freeze({direction:"flat",change:null,percent:null});function t(p,m){if(!Number.isFinite(p)||!Number.isFinite(m))return r;const w=p-m,v=w>0?"up":w<0?"down":"flat",u=m===0?null:w/Math.abs(m)*100;return{direction:v,change:w,percent:u}}function n(p,m){return p==="flat"||m==="neither"?"flat":p===m?"good":"bad"}function i(p,m,w=null){if(N(m)){const A=m(p,w);return A==="good"||A==="warn"||A==="bad"?A:null}if(!$(m))return null;const v=typeof p=="number"&&Number.isFinite(p)?p:null;if(v===null)return null;const u=Number.isFinite(Number(m.good))?Number(m.good):null,s=Number.isFinite(Number(m.warn))?Number(m.warn):null,O=String(m.direction||"up")==="down",E=A=>O?v<=A:v>=A;return u!==null&&E(u)?"good":s!==null&&E(s)?"warn":u===null&&s===null?null:"bad"}function o(p){return!(N(p.value)||p.value!==void 0&&!$(p.value))}function c(p){return!p||!p.rows||!N(p.rows.totalCount)?!0:p.rows.totalCount()>0}function d(p){const m=$(p)?p:{},w=m.grid||null,v=g(m.container,w);if(!v)return L("stat.container","createStat needs a `container`: an element or a selector."),y();const u=v.ownerDocument||(typeof document>"u"?null:document);if(!u)return L("stat.document","createStat needs a document; it draws DOM."),y();const s=u.createElement("div");s.className=["lattice",b.root,m.class].filter(Boolean).join(" "),s.setAttribute("role","group");const O=u.createElement("div");O.className=b.title;const E=u.createElement("div");E.className=b.value;const A=u.createElement("div");A.className=b.interval;const M=u.createElement("div");M.className=b.delta;const C=u.createElement("div");C.className=b.footer;const P=u.createElement("div");if(P.className=b.note,P.hidden=!0,m.icon!=null&&m.icon!==""){const re=u.createElement("span");re.className=b.icon,re.setAttribute("aria-hidden","true"),S(re,m.icon,`stat:${m.title||"stat"}`),s.appendChild(re);const ie=u.createElement("div");ie.className=b.body,ie.appendChild(O),ie.appendChild(E),ie.appendChild(P),ie.appendChild(A),ie.appendChild(M),ie.appendChild(C),s.appendChild(ie)}else s.appendChild(O),s.appendChild(E),s.appendChild(P),s.appendChild(A),s.appendChild(M),s.appendChild(C);v.appendChild(s);let K=null;const x=[];let I=!1;function j(){if(N(m.value))return m.value(w);if(m.value!==void 0&&!$(m.value))return m.value;const re=$(m.value)?m.value:m,ie=re.of,ae=re.fn||"sum",ee=re.show;return w?ae==="count"?B().length:ie?ee?q(String(ie),String(ae),String(ee)):T()==="filtered"&&w.statistics&&N(w.statistics.reduce)?w.statistics.reduce(String(ie),String(ae)):Z(B().map(J=>h(J,String(ie))),String(ae)):null:null}function T(){return String(m.scope||"filtered")}function B(){if(!w||!w.rows)return[];const re=T();if(re==="all"){const ae=[];return N(w.rows.forEachAll)&&w.rows.forEachAll(ee=>{ee.group||ae.push(f(ee))}),ae}if(re==="selected")return(w.selection&&N(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(f);const ie=[];return N(w.rows.forEach)&&w.rows.forEach(ae=>{ae.group||ie.push(f(ae))}),ie}function q(re,ie,ae){if(ie!=="min"&&ie!=="max")return L(`stat.show.${ie}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ie}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ee=null,J=null;for(const se of B()){const le=Number(h(se,re));Number.isFinite(le)&&(ee===null||(ie==="max"?le>ee:le<ee))&&(ee=le,J=se)}return J===null?null:h(J,ae)}function X(re){if(N(m.format))return String(m.format(re,w));if(re==null)return m.empty??"—";const ie=$(m.value)?m.value:m,ae=ie.show||ie.of;if((ie.show?!0:l.has(String(ie.fn||"sum")))&&w&&ae&&N(w.columns?.get)){const J=w.columns.get(String(ae));if(J&&N(J.formatValue))return J.formatValue(re)}return typeof re=="number"?Number.isInteger(re)?String(re):re.toFixed(m.decimals??2):String(re)}function Q(re){return re?(w&&w.messages||F).t(`stat.tone.${re}`):""}function te(){if(I)return;const re=j(),ie=o(m)&&!!w&&!c(w),ae=ie?null:re,ee=N(m.baseline)?m.baseline(w):m.baseline;K=ae,O.textContent=m.title??"",O.hidden=!m.title,E.textContent=X(ae),P.hidden=!ie,ie&&(P.textContent=w.messages.t("stat.noData"));const J=ie||ee===void 0||ee===null?r:t(typeof ae=="number"?ae:null,Number(ee)),se=n(J.direction,m.goodWhen||"up");if(M.hidden=J.change===null,J.change!==null){const fe=J.direction==="up"?"↑":J.direction==="down"?"↓":"→",ve=J.percent===null?X(Math.abs(J.change)):`${Math.abs(J.percent).toFixed(1)}%`;M.textContent=`${fe} ${ve}`,M.setAttribute("data-tone",se),M.setAttribute("data-direction",J.direction)}const le=N(m.interval)?m.interval(ae,w):null,oe=!!le&&Number.isFinite(le.lower)&&Number.isFinite(le.upper);A.hidden=!oe,oe&&(A.textContent=`${X(le.lower)} – ${X(le.upper)}`,Number.isFinite(le.confidence)&&A.setAttribute("title",`${Math.round(le.confidence*100)}%`));const he=ie?a:m.bands?i(ae,m.bands,w):null;he?s.setAttribute("data-tone",he):s.removeAttribute("data-tone"),C.textContent=N(m.footer)?String(m.footer(ae,w)):m.footer??"",C.hidden=!C.textContent,s.setAttribute("aria-label",[m.title,E.textContent,ie?P.textContent:"",oe?A.textContent:"",J.change===null?"":M.textContent,J.change===null?"":Q(se),C.textContent].filter(Boolean).join(", "))}if(w&&N(w.on)&&m.live!==!1)for(const re of["rows:changed","filter:changed","selection:changed","model:changed"]){const ie=ae=>{re==="model:changed"&&!U(ae)||te()};w.on(re,ie),x.push(()=>N(w.off)&&w.off(re,ie))}return te(),{element:()=>s,value:()=>K,refresh:te,destroy(){I=!0;for(const re of x)try{re()}catch{}x.length=0,s.remove()}}}function f(p){return $(p)&&"data"in p?p.data:p}function h(p,m){if(!$(p))return;if(!m.includes("."))return p[m];let w=p;for(const v of m.split(".")){if(!$(w))return;w=w[v]}return w}function g(p,m){if(p&&typeof p=="object")return p;if(typeof p!="string")return null;const w=m&&m.element&&m.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(p):null}function y(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Se("packages/dom/src/kpistrip.js",function(e,V){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Z}});const N=V("packages/core/src/internal/util.js").isObject,L=V("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Z{#e;#t;#n;#r=null;#o=[];constructor({grid:U,document:z,kpis:F}){this.#e=U,this.#t=z,this.#n=Array.isArray(F)?F.filter(N):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const z=this.#t.createElement("div");z.className=`lattice ${W.band}`,z.setAttribute("role","group"),z.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=z;for(const F of this.#n){const k=L({...F,grid:this.#e,container:z});this.#o.push(k)}}destroy(){for(const U of this.#o)try{U.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Se("packages/dom/src/createGrid.js",function(e,V){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const N=V("packages/core/src/index.js").createHeadlessGrid,L=V("packages/core/src/defaults.js").applyDefaults,Z=V("packages/core/src/export/download.js").downloadBlob,H=V("packages/core/src/internal/util.js"),U=H.fail,z=H.isFunction,F=H.warnOnce,S=V("packages/dom/src/localviews.js").createLocalViewStorage,a=V("packages/dom/src/renderer/index.js").DomRenderer,r=V("packages/dom/src/cell/index.js").createCellLayer,t=V("packages/dom/src/cell/icons.js"),n=t.icon,i=t.iconNames,c=V("packages/dom/src/editors/index.js").editors,f=V("packages/dom/src/filters/index.js").filters,h=V("packages/dom/src/ui/index.js"),g=h.StatusBar,y=h.TooltipManager,p=h.Pagination,m=h.GroupByZone,v=V("packages/dom/src/ui/celltooltip.js").CellTooltips,s=V("packages/dom/src/filtermenu.js").FilterMenu,E=V("packages/dom/src/columnmenu.js").ColumnMenu,M=V("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=V("packages/dom/src/rowreorder.js").RowReorder,K=V("packages/dom/src/alignedgrids.js").AlignedGrids,I=V("packages/dom/src/columntagbar.js").ColumnTagBar,T=V("packages/dom/src/anomalychip.js").AnomalyChip,q=V("packages/dom/src/rowform.js").RowForm,X=V("packages/dom/src/toolpanelmount.js"),Q=X.ToolPanelDock,te=X.panelHost,ie=V("packages/dom/src/celledit.js").CellEditController,ee=V("packages/dom/src/editbar.js").EditBar,se=V("packages/dom/src/rangeselect.js").RangeController,oe=V("packages/core/src/model/selection.js").resolveSelectionConfig,fe=V("packages/dom/src/importer.js").ImportController,be=V("packages/dom/src/historybar.js").HistoryBar,He=V("packages/dom/src/diffpaint.js").DiffPainter,Ie=V("packages/dom/src/detailhost.js").DetailHost,qe=V("packages/dom/src/highlightpaint.js").HighlightPainter,Je=V("packages/dom/src/findpaint.js").FindPainter,Ae=V("packages/dom/src/findbar.js").FindBar,Ge=V("packages/dom/src/redactpaint.js").RedactionPainter,lt=V("packages/dom/src/validationpaint.js").ValidationPainter,Pt=V("packages/dom/src/presentation.js").PresentationController,Rt=V("packages/dom/src/capture.js").captureElement,zt=V("packages/dom/src/annotate.js").AnnotationLayer,Qt=V("packages/dom/src/timelinebar.js").TimelineBar,de=V("packages/dom/src/commentpaint.js").CommentPainter,Te=V("packages/dom/src/presencepaint.js").PresencePainter,Ve=V("packages/dom/src/commentpanel.js").CommentPanel,dt=V("packages/dom/src/watermark.js").Watermark,ke=V("packages/dom/src/maximise.js").Maximiser,je=V("packages/dom/src/promptbar.js").PromptBar,Ne=V("packages/dom/src/kpistrip.js").KpiStrip;function Le(Ee,tt,rt){const ht=tt==="redo"?"toolbar.redo":"toolbar.undo";return!rt||!rt.label?Ee(ht):Ee(tt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:rt.label})}const Fe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],De=2e3;function Ze(Ee,tt,rt){const ht=tt.annotate===!0?Ye(Ee):[];if(tt.actions===!1)return[];if(tt.actions===void 0&&tt.side!=="left")return ht;const It=Array.isArray(tt.actions)?tt.actions:Fe,Nt=(vt,Ht)=>Ee.messages.t(vt,Ht),ot={undo:{name:"undo",title:()=>Le(Nt,"undo",Ee.history.peek("undo")),icon:"undo",run:()=>Ee.history.undo(),enabled:()=>Ee.history.canUndo()},redo:{name:"redo",title:()=>Le(Nt,"redo",Ee.history.peek("redo")),icon:"redo",run:()=>Ee.history.redo(),enabled:()=>Ee.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Ee.export.csv({download:!0,fileName:tt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ee.export.excel({download:!0,fileName:tt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Ee.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Ee.export.print()},pause:{name:"pause",title:()=>{if(!Ee.updates.paused)return Nt("toolbar.pause");const vt=Ee.updates.stats().pending;return vt?Nt("toolbar.applyHeld",{count:vt}):Nt("toolbar.resume")},icon:()=>Ee.updates.paused?"play":"pause",run:()=>Ee.updates.paused?Ee.updates.resume():Ee.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Ee.state.reset(),enabled:()=>Ee.state.modified()},maximise:{name:"maximise",title:()=>Nt(rt&&rt.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>rt&&rt.active()?"minimise":"maximise",run:()=>rt.toggle()}};return rt||delete ot.maximise,It.map(vt=>vt==="-"?{name:"-",separator:!0}:typeof vt=="string"?ot[vt]:!vt||typeof vt!="object"||!vt.name?null:{...vt,run:z(vt.run)?()=>vt.run({grid:Ee,keys:Ee.selection&&z(Ee.selection.keys)?Ee.selection.keys():[],cells:Ee.selection&&z(Ee.selection.cells)?Ee.selection.cells():[]}):void 0}).filter(Boolean).concat(ht)}function Ye(Ee){const tt=ht=>Ee.messages.t(ht),rt={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(ht=>({name:ht,title:()=>tt(`toolbar.annotate.${ht}`),icon:rt[ht],run:()=>Ee.annotate?.use(ht),active:()=>Ee.annotate?.tool===ht,annotation:!0}))}const mt=["pen","arrow","rect","highlight"];function pt(Ee){return{rowCount:()=>{if(z(Ee.rows.matchCount))return Ee.rows.matchCount();const tt=Ee.pagination&&z(Ee.pagination.get)?Ee.pagination.get():null;return tt&&Number.isFinite(tt.total)?tt.total:Ee.rows.count()},totalRowCount:()=>z(Ee.rows.totalCount)?Ee.rows.totalCount():Ee.rows.count(),selectedCount:()=>{const tt=Ee.selection&&Ee.selection.keys?Ee.selection.keys():null;return tt?tt.length:0},rangeValues:()=>{const tt=Ee.selection;return!tt||!z(tt.cells)?[]:tt.cells().map(({key:rt,colId:ht})=>Ee.rows.value(rt,ht))},hiddenUnresolved:()=>z(Ee.comments&&Ee.comments.hiddenUnresolved)?Ee.comments.hiddenUnresolved():0,progress:()=>z(Ee.source&&Ee.source.progress)?Ee.source.progress():null,updateStats:()=>Ee.updates?Ee.updates.stats():null}}function bt(Ee,tt){for(const[rt,ht]of Object.entries(c||{}))Ee.register("editor",rt,ht);for(const[rt,ht]of Object.entries(f||{}))Ee.register("filter",rt,ht);for(const[rt,ht]of Object.entries(tt.components||{}))Ee.register("component",rt,ht);for(const[rt,ht]of Object.entries(tt.pipes||{}))Ee.register("pipe",rt,ht);for(const[rt,ht]of Object.entries(tt.totalFns||{}))Ee.register("totalFn",rt,ht)}function ft(Ee,tt,rt,ht,It,Nt){const ot=[],vt=tt.viewport;let Ht=null;if(rt.maximise!==!1&&(Ht=new ke({element:Nt,document:ht,onChange:()=>tt.invalidate("all"),captureScroll:()=>tt.scrollState(),restoreScroll:Xe=>tt.restoreScroll(Xe)}),Ee.maximise=Ht,ot.push(()=>Ht.destroy())),rt.statusBar){const Xe=typeof rt.statusBar=="object"?rt.statusBar:{},st=new g;st.init({document:ht,host:pt(Ee),panels:Xe.panels,registry:Xe.registry,locale:Ee.get("locale"),messages:Ee.messages}),vt.statusBar.appendChild(st.element());const Ot=()=>{const tn=vt.statusBar.offsetHeight||vt.statusBar.getBoundingClientRect?.().height||0;vt.root.style.setProperty("--lattice-status-height",`${Math.ceil(tn)}px`)},Lt=()=>{st.refresh(),Ot()},Ut=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(tn=>Ee.on(tn,Lt));Lt(),Ot(),ot.push(()=>{for(const tn of Ut)tn();vt.root.style.removeProperty("--lattice-status-height"),st.destroy?.()})}const Gt=oe(rt.selection);if(Gt.ranges){const Xe=new se({grid:Ee,renderer:tt,document:ht});Xe.mount(),Ee.ranges=Xe,ot.push(()=>Xe.destroy())}if(rt.import){const Xe=new fe({grid:Ee,renderer:tt,document:ht,settings:typeof rt.import=="object"?rt.import:{}});Ee.importer=Xe,ot.push(()=>Xe.destroy())}if(rt.historyBar){const Xe=typeof rt.historyBar=="object"?rt.historyBar.element:null,st=new be;st.init({document:ht,host:{undo:()=>Ee.history.undo(),redo:()=>Ee.history.redo(),canUndo:()=>Ee.history.canUndo(),canRedo:()=>Ee.history.canRedo(),peek:Lt=>Ee.history.peek(Lt),list:()=>Ee.history.list()},props:typeof rt.historyBar=="object"?rt.historyBar:{}}),(Xe||vt.root).appendChild(st.element());const Ot=[Ee.on("history:changed",()=>st.refresh())];Ee.historyBar=st,ot.push(()=>{for(const Lt of Ot)Lt();st.destroy()})}if(rt.diff){const Xe=new He({grid:Ee,renderer:tt});Xe.mount(),Ee.diffPainter=Xe,ot.push(()=>Xe.destroy())}if(rt.ai&&z(rt.ai.ask)){const Xe=new je;Xe.init({document:ht,grid:Ee,ask:rt.ai.ask,schemaOptions:rt.ai.schemaOptions,context:rt.ai.context,placeholder:rt.ai.placeholder});const st=rt.ai.element||vt.root;st===vt.root?st.insertBefore(Xe.element(),st.firstChild):st.appendChild(Xe.element()),Ee.promptBar=Xe,ot.push(()=>Xe.destroy())}if(rt.groupPanel){const Xe=typeof rt.groupPanel=="object"?rt.groupPanel:{},st=new m;st.init({document:ht,grid:Ee,host:te(Ee,ht,(Ot,Lt)=>tt.announce?.(Ot,Lt)),props:{header:vt.header,hint:Xe.hint}}),vt.root.insertBefore(st.element(),vt.header),Ee.groupPanel=st;for(const Ot of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])z(Ee.on)&&ot.push(Ee.on(Ot,()=>st.refresh()));ot.push(()=>st.destroy())}if(rt.kpis){const Xe=new Ne({grid:Ee,document:ht,kpis:rt.kpis});Xe.active&&(Xe.mount(),vt.root.insertBefore(Xe.element(),vt.header),Ee.kpiStrip=Xe,ot.push(()=>Xe.destroy()))}if(rt.toolPanel){const Xe=typeof rt.toolPanel=="object"?rt.toolPanel:{},st=new Q({grid:Ee,document:ht,root:vt.root,panels:Xe.panels,openPanel:Xe.openPanel,side:Xe.side,icons:Xe.icons,actions:Ze(Ee,Xe,Ht),announce:(Ot,Lt)=>tt.announce?.(Ot,Lt)});st.mount(),Ee.toolPanel=st,ot.push(()=>st.destroy()),Xe.annotate===void 0&&(ot.push(Ee.on("presentation:started",()=>{for(const Ot of Ye(Ee))st.addAction(Ot)})),ot.push(Ee.on("presentation:ended",()=>{for(const Ot of mt)st.removeAction(Ot)})))}if(rt.pagination){const Xe=typeof rt.pagination=="object"?rt.pagination:{},st=new p;st.init({document:ht,pageSize:Xe.pageSize,pageSizes:Xe.pageSizes,page:Xe.page,total:Xe.total,locale:Ee.get("locale"),messages:Ee.messages,onChange:({page:Ut,pageSize:tn})=>Ee.pagination.set({page:Ut,pageSize:tn})});const Ot=()=>{const Ut=Ee.pagination.get();st.total=Ut.total,st.counting=Ut.counting===!0,st.page=Ut.page,st.paint()};Ee.pagination.set({pageSize:st.pageSize}),Ot();const Lt=["rows:changed","filter:changed","model:changed"].map(Ut=>Ee.on(Ut,Ot));vt.statusBar.appendChild(st.element()),ot.push(()=>{for(const Ut of Lt)Ut();st.destroy?.()})}if(rt.edit!==!1)if(rt.editBar){const Xe=new ee({grid:Ee,document:ht,root:vt.root});Xe.mount(),Ee.editBar=Xe,ot.push(()=>Xe.destroy())}else{const Xe=new ie({grid:Ee,document:ht,renderer:tt,registry:It,cellLayer:tt.cellLayer});Xe.mount(),ot.push(()=>Xe.destroy())}const sn=new s({grid:Ee,document:ht,layer:vt.overlays,registry:It});sn.mount(),ot.push(()=>sn.destroy());const an=new E({grid:Ee,document:ht,host:vt.root,cellMenu:rt.contextMenu!==!1,headerMenu:rt.columnMenu!==!1,items:z(rt.contextMenu)?rt.contextMenu:void 0,headerItems:z(rt.columnMenu)?rt.columnMenu:void 0});if(an.mount(),ot.push(()=>an.destroy()),Array.isArray(rt.alignedGrids)&&rt.alignedGrids.length){const Xe=new K;Xe.add(Ee);for(const st of rt.alignedGrids)st&&st!==Ee&&Xe.add(st);ot.push(()=>Xe.destroy())}const Dt=new q({grid:Ee,renderer:tt,document:ht,registry:It});Dt.active&&(Dt.mount(),ot.push(()=>Dt.destroy())),Object.defineProperty(Ee,"form",{configurable:!0,value:Object.freeze({open(Xe){return Dt.active?Dt.openRow(Xe):!1},close(){Dt.active&&Dt.close()},save(){return Dt.active?Dt.save():!1},isOpen(){return Dt.active?Dt.open:!1}})}),ot.push(()=>{delete Ee.form}),Object.defineProperty(Ee,"icons",{configurable:!0,value:Object.freeze({get(Xe){const st=n(Xe);return st?{viewBox:st.viewBox,paths:st.paths.slice(),paint:st.paint==="stroke"?"stroke":"fill"}:null},names(){return i()}})}),ot.push(()=>{delete Ee.icons});const ln=new I({grid:Ee,renderer:tt,document:ht});ln.active&&(ln.mount(),ot.push(()=>ln.destroy()));const un=new T({grid:Ee,renderer:tt,document:ht});un.active&&(un.mount(),ot.push(()=>un.destroy()));const nn=new P({grid:Ee,renderer:tt,document:ht});if(nn.active){nn.mount(),nn.paint();const Xe=Ee.on("render:done",()=>nn.paint());ot.push(()=>{Xe(),nn.destroy()})}if(rt.shortcuts!==!1){const Xe=new M({grid:Ee,renderer:tt});Xe.mount(),ot.push(()=>Xe.destroy())}const yt=new qe({grid:Ee,renderer:tt,window:ht.defaultView||void 0});yt.mount(),ot.push(()=>yt.destroy());const Ct=new Je({grid:Ee,renderer:tt,window:ht.defaultView||void 0});if(Ct.mount(),ot.push(()=>Ct.destroy()),rt.find!==!1){const Xe=new Ae({grid:Ee,renderer:tt,document:ht,settings:rt.find});Xe.mount(),ot.push(()=>Xe.destroy())}const Tt=new Ge({grid:Ee,renderer:tt});Tt.mount(),ot.push(()=>Tt.destroy());const Bt=new lt({grid:Ee,renderer:tt});Bt.mount(),ot.push(()=>Bt.destroy());const Yt=new Pt({grid:Ee,renderer:tt,maximiser:Ht});Yt.mount(),ot.push(()=>Yt.destroy());const Kt=new Qt({grid:Ee,renderer:tt});Kt.mount(),ot.push(()=>Kt.destroy()),rt.environment||Ee.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let qt=null;for(const[Xe,st]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])ot.push(Ee.on(Xe,()=>{qt=st}));ot.push(Ee.on("render:done",Xe=>{Ee.diagnostics.render(qt||Xe.cause,Xe.phases),qt=null}));const Jt=new Te({grid:Ee,renderer:tt});if(Jt.mount(),ot.push(()=>Jt.destroy()),ot.push(Ee.on("presence:lockRefused",Xe=>Jt.announceRefusal(Xe.peer))),Ee.presence&&Ee.presence.enabled){for(const Ot of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])ot.push(Ee.on(Ot,()=>Ee.presence.publish()));let Xe="";ot.push(Ee.on("render:done",()=>{const Ot=tt.focusState&&tt.focusState(),Lt=Ot?`${Ot.rowKey}${Ot.colId}`:"";Lt!==Xe&&(Xe=Lt,Ee.presence.publish())}));const st=Nt.ownerDocument;if(st&&z(st.addEventListener)){const Ot=()=>Ee.presence.setPaused(st.visibilityState==="hidden");st.addEventListener("visibilitychange",Ot),Ot(),ot.push(()=>st.removeEventListener("visibilitychange",Ot))}}const Zt=new de({grid:Ee,renderer:tt});Zt.mount(),ot.push(()=>Zt.destroy());const cn=new Ve({grid:Ee,renderer:tt});cn.mount(),ot.push(()=>cn.destroy()),ot.push(Ee.on("facet:computed",()=>tt.refreshHeader?.())),Gt&&Gt.headerCheckbox===!0&&ot.push(Ee.on("selection:changed",()=>tt.refreshHeader?.())),ot.push(Ee.on("facet:expanded",()=>tt.invalidate("columns"))),ot.push(Ee.on("model:changed",()=>tt.invalidate("rows")));const Vt=(Xe,st)=>tt.announce?.(Xe,st),dn=Ee.messages,xt=(Xe,st)=>dn.t(Xe,st),mn=Xe=>xt("count.rows",{count:Xe});ot.push(Ee.on("sort:changed",()=>{const Xe=Ee.sort.get();if(!Xe.length){Vt(xt("a11y.sort.cleared"));return}const st=Xe.map(Ot=>{const Lt=Ee.columns.get(Ot.col);return xt("a11y.sort.column",{column:Lt&&Lt.title||Ot.col,direction:xt(Ot.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Vt(xt("a11y.sort.by",{columns:dn.list(st)}))})),ot.push(Ee.on("filter:changed",()=>{const Xe=Ee.rows.matchCount?Ee.rows.matchCount():Ee.rows.count(),st=Ee.rows.totalCount?Ee.rows.totalCount():Xe;Vt(Xe===st?xt("a11y.filter.cleared",{rows:mn(st)}):xt("a11y.filter.applied",{shown:mn(Xe),total:mn(st)}))})),ot.push(Ee.on("selection:changed",()=>{const Xe=Ee.selection.keys().length;Vt(Xe===0?xt("a11y.selection.cleared"):xt("a11y.selection.count",{count:Xe}))})),ot.push(Ee.on("group:toggled",Xe=>{const st=Ee.rows.byKey?Ee.rows.byKey(Xe.key):null,Ot=(st&&(st.groupLabel??st.groupValue))??Xe.key;Vt(xt(Xe.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Ot,rows:mn(Ee.rows.count())}))})),ot.push(Ee.on("column:grouped",Xe=>{const st=Array.isArray(Xe.columns)?Xe.columns:[];if(!st.length){Vt(xt("a11y.group.cleared"));return}const Ot=st.map(Lt=>{const Ut=Ee.columns.get(Lt);return Ut&&Ut.title||Lt});Vt(xt("a11y.group.by",{columns:dn.list(Ot)}))})),ot.push(Ee.on("page:changed",Xe=>{const st=Number(Xe.size)||0,Ot=Number(Xe.total)||0,Lt=st>0?Math.max(1,Math.ceil(Ot/st)):1;Vt(xt("a11y.page.position",{page:(Number(Xe.page)||0)+1,pages:Lt}))}));let en={added:0,removed:0},Wt=null;const Mn=()=>{Wt=null;const Xe=[];en.added&&Xe.push(xt("count.rowsAdded",{count:en.added})),en.removed&&Xe.push(xt("count.rowsRemoved",{count:en.removed})),en={added:0,removed:0},Xe.length&&Vt(dn.list(Xe))};ot.push(Ee.on("rows:changed",Xe=>{if(!Xe||typeof Xe.added!="number")return;const st=Number(Xe.added)||0,Ot=Number(Xe.removed)||0;!st&&!Ot||(en.added+=st,en.removed+=Ot,Wt||(Wt=setTimeout(Mn,De)))})),ot.push(()=>{Wt&&clearTimeout(Wt)}),ot.push(Ee.on("rows:paused",()=>{Wt&&(clearTimeout(Wt),Wt=null),en={added:0,removed:0},Vt(xt("a11y.updates.paused"),{repeat:!0})})),ot.push(Ee.on("rows:resumed",()=>Vt(xt("a11y.updates.resumed"),{repeat:!0})));let fn={count:0,first:null},hn=null;const Sn=()=>{hn=null;const{count:Xe,first:st}=fn;if(fn={count:0,first:null},!Xe||!st)return;const Ot=Ee.columns.get(st.colId),Lt=Ot&&Ot.title||st.colId,Ut=st.reason?xt("a11y.edit.reason",{reason:st.reason}):"";if(Xe===1){const tn=st.restored===void 0||st.restored===null||st.restored===""?xt("value.empty"):String(st.restored);Vt(xt("a11y.edit.refusedOne",{column:Lt,value:tn,reason:Ut}),{repeat:!0});return}Vt(xt("a11y.edit.refusedMany",{count:Xe,reason:Ut}),{repeat:!0})};ot.push(Ee.on("cell:reverted",Xe=>{!Xe||!Xe.applied||(fn.count+=1,fn.first||(fn.first=Xe),hn||(hn=setTimeout(Sn,150)))})),ot.push(()=>{hn&&clearTimeout(hn)}),ot.push(Ee.on("history:applied",Xe=>{const st=!!(Xe&&Xe.direction==="redo"),Ot=Xe&&Xe.step&&Xe.step.label;Vt(Ot?xt(st?"a11y.history.redo":"a11y.history.undo",{label:Ot}):xt(st?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const pn=new zt({grid:Ee,renderer:tt,seed:rt.state&&Array.isArray(rt.state.annotations)?rt.state.annotations:null});pn.mount(),ot.push(()=>pn.destroy()),Ee.annotate=pn,Ee.capture=async(Xe={})=>{const{blob:st,width:Ot,height:Lt}=await Rt(tt.viewport.root,Xe);return(Xe.download===!0||Xe.download!==!1&&Xe.fileName)&&Z(st,Xe.fileName||`${Ee.get("exportName")||"grid"}.png`),Ee.emit("presentation:captured",{width:Ot,height:Lt,bytes:st.size,mimeType:st.type,fileName:Xe.fileName||null},"api"),st};const On=new dt({grid:Ee,document:ht,element:vt.overlays,window:ht.defaultView||void 0});On.mount(),ot.push(()=>On.destroy());const Nn=new y({grid:Ee,document:ht,element:vt.overlays});Nn.mount?.(),ot.push(()=>Nn.destroy?.());const jn=new v({grid:Ee,host:Ee.rendererHost(),viewport:vt,document:ht});return jn.mount(),ot.push(()=>jn.destroy()),ot}function kt(Ee){const tt=[],rt=ht=>{if(ht&&(ht.__lattice&&tt.push(ht),ht.children))for(const It of ht.children)rt(It)};return rt(Ee),tt}function St(Ee,tt={}){(!Ee||typeof Ee!="object"||!("appendChild"in Ee))&&U("createGrid needs a host element as its first argument."),tt=L(tt);const rt=Ee.ownerDocument||(typeof document<"u"?document:null);rt||U("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ht=rt.documentElement&&rt.documentElement.lang,It=!tt.licence&&z(rt.querySelector)?rt.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...tt};if(!tt.locale&&ht&&(Nt.locale=ht),It&&(Nt.licence=It),tt.views&&tt.views.local)if(tt.views.storage)F("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const Dt=tt.views.local===!0?{}:tt.views.local;Nt.views={...tt.views,storage:S(Dt)}}const ot=N(Nt),vt=ot.rendererHost();vt.document=rt,bt(vt.registry,tt),vt.cellLayer=r(vt),vt.detailHost=new Ie({grid:ot,document:Ee.ownerDocument||globalThis.document,createGrid:(Dt,ln)=>St(Dt,ln)});const Ht=new a(Ee,vt),Gt=ot.on("detail:toggled",()=>{vt.detailHost.syncTarget(),vt.detailHost.prune()}),on=ot.on("config:changed",Dt=>{Dt&&Dt.key==="detail"&&vt.detailHost.reconfigure()});ot.on("destroy",()=>{Gt(),on(),vt.detailHost.destroy()}),vt.detailHost.syncTarget(),ot.attachRenderer(Ht),Ht.mount();const sn=ft(ot,Ht,tt,rt,vt.registry,Ee),an=ot.destroy.bind(ot);return ot.destroy=()=>{for(const Dt of sn)try{Dt()}catch{}Ee.__lattice===ot&&(Ee.__lattice=null),an()},Ee.__lattice=ot,ot}}),Se("packages/dom/src/hydrate.js",function(e,V){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return F}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/createGrid.js").createGrid;function W(k,S){for(const b of k.children)if(b.tagName===S.toUpperCase())return b;return null}function Z(k,S){const b=[];for(const a of k.children)a.tagName===S.toUpperCase()&&b.push(a);return b}function H(k,S){const b=N(k.getAttribute)?k.getAttribute("data-field"):null;return b||String(k.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${S}`}function U(k){const S=k.trim();if(S==="")return null;if(S==="true"||S==="false")return S==="true";const b=Number(S);return Number.isFinite(b)&&S!==""?b:S}function z(k){const S=W(k,"thead"),b=W(S||k,"tr"),l=(b?Z(b,"th").length?Z(b,"th"):Z(b,"td"):[]).map((i,o)=>{const c=H(i,o);return{id:c,field:c,title:String(i.textContent||"").trim()||c}}),r=W(k,"tbody"),n=(r?Z(r,"tr"):Z(k,"tr").filter(i=>i!==b)).map((i,o)=>{const c=Z(i,"td"),f={__row:(N(i.getAttribute)?i.getAttribute("data-id"):null)||`row${o}`};return l.forEach((h,g)=>{f[h.field]=c[g]?U(String(c[g].textContent||"")):null}),f});return{columns:l,rows:n}}function F(k,S={}){const{columns:b,rows:a}=z(k),l=k.ownerDocument.createElement("div");return k.parentNode.insertBefore(l,k),k.parentNode.removeChild(k),L(l,{rowKey:"__row",columns:b,rows:a,...S,columns:S.columns!==void 0?S.columns:b,rows:S.rows!==void 0?S.rows:a})}}),Se("packages/dom/src/autoinit.js",function(e,V){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return F}});const N=V("packages/core/src/internal/util.js").isFunction,L=V("packages/dom/src/createGrid.js").createGrid,Z=V("packages/dom/src/hydrate.js").hydrateTable;function H(k,S){const b=[];return N(k.hasAttribute)&&k.hasAttribute(S)&&b.push(k),N(k.querySelectorAll)&&b.push(...k.querySelectorAll(`[${S}]`)),b}function U(k){const S=k.parentNode;if(!S||!S.children)return null;const b=[...S.children],a=b.indexOf(k),l=[b[a+1],b[a-1]];for(const r of l)if(r&&r.tagName==="SCRIPT"&&N(r.getAttribute)&&r.hasAttribute("data-lattice-config"))return r;return null}function z(k){const S=U(k);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(b){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",b),{}}}function F(k){const S=k||(typeof document<"u"?document:null);if(!S)return[];const b=[];for(const a of H(S,"data-lattice-grid")){if(a.__lattice)continue;const l=z(a);b.push(a.tagName==="TABLE"?Z(a,l):L(a,l))}return b}}),Se("packages/dom/src/index.js",function(e,V){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const _=V("packages/dom/src/createGrid.js"),N=_.createGrid,$=V("packages/dom/src/hydrate.js"),L=$.hydrateTable,W=V("packages/dom/src/autoinit.js"),Z=W.autoInit,H=V("packages/dom/src/localviews.js"),U=H.createLocalViewStorage,z=V("packages/core/src/index.js"),F=z.createHeadlessGrid,k=z.registerModules,S=z.setLicence,b=z.version,a=z.getVersion,l=z.serialiseState,r=z.restoreState,t=z.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return _.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return _.gridElementsWithin}});const n=V("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return n.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return n.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return n.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return $.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return $.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return H.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return H.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return z.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return z.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return z.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return z.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return z.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return z.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return z.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return z.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return z.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return z.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return z.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return z.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return z.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return z.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return z.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return z.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return z.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return z.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return z.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return z.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return z.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return z.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return z.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return z.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return z.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return z.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return z.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return z.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return z.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return z.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return z.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return z.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return z.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return z.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return z.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return z.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return z.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return z.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return z.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return z.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return z.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return z.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return z.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return z.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return z.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return z.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return z.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return z.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return z.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return z.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return z.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return z.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return z.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return z.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return z.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return z.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return z.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return z.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return z.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return z.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return z.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return z.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return z.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return z.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return z.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return z.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return z.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return z.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return z.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return z.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return z.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return z.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return z.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return z.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return z.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return z.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return z.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return z.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return z.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return z.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return z.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return z.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return z.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return z.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return z.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return z.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return z.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return z.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return z.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return z.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return z.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return z.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return z.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return z.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return z.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return z.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return z.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return z.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return z.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return z.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return z.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return z.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return z.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return z.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return z.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return z.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return z.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return z.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return z.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return z.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return z.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return z.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return z.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return z.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return z.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return z.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return z.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return z.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return z.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return z.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return z.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return z.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return z.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return z.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return z.graphqlAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return z.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return z.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return z.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return z.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return z.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return z.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return z.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return z.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return z.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return z.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z.VERSION}});const i=V("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return i.DomRenderer}});const o=V("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 c=V("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return c.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return c.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return c.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return c.autoGroupMenuItems}});const d=V("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return d.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return d.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return d.layoutState}});const f=V("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return f.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return f.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return f.mountPanel}});const h=V("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return h.CellEditController}});const g=V("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return g.EditBar}});const y=V("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return y.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return y.HISTORY_CLS}});const p=V("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return p.DiffPainter}});const m=V("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=V("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=V("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 u=V("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return u.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return u.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return u.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return u.BaseEditor}});const s=V("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return s.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return s.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return s.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return s.parseExpression}});const O=V("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return O.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return O.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return O.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return O.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return O.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return O.OverlayLayer}});const E=V("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return E.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return E.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return E.licenceState}});const A=Object.freeze({createGrid:N,createHeadlessGrid:F,defaults:t,registerModules:k,setLicence:S,version:b,autoInit:Z,hydrateTable:L,serialiseState:l,restoreState:r,createLocalViewStorage:U}),M=A}),Se("packages/modules/shared/adapter.js",function(e,V){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"handlerName",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"CONFIG_KEY_ALIASES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"aliasConfigKey",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"isHandlerProp",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"partition",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createGridController",{enumerable:!0,get:function(){return F}});const _=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","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","validation:failed","validation:cleared","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),N=Object.freeze({sort:(k,S)=>k.sort.set(S||[]),filters:(k,S)=>k.filters.set(S||null),quickFilter:(k,S)=>{if(S&&typeof S=="object"){k.filters.quick(S.text||"",{mode:S.mode});return}k.filters.quick(typeof S=="string"?S:"")},selectedKeys:(k,S)=>k.selection.set(Array.isArray(S)?S:[])});function $(k){return`on${String(k).split(":").map(b=>b.charAt(0).toUpperCase()+b.slice(1)).join("")}`}function L(k){return String(k).replace(/:/g,"-")}const W=Object.freeze({"row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight"});function Z(k){return Object.hasOwn(W,k)?W[k]:k}const H=Object.freeze(Object.fromEntries(_.map(k=>[$(k),k])));function U(k){return Object.hasOwn(H,k)}function z(k){const S={},b={},a={};for(const[l,r]of Object.entries(k||{})){if(U(l)){a[l]=r;continue}if(Object.hasOwn(N,l)){b[l]=r;continue}S[l]=r}return{config:S,imperative:b,handlers:a}}function F(k){const S=k.createGrid;if(typeof S!="function")throw new TypeError("createGridController needs createGrid; pass it in from the grid package.");const b=z(k.props||{}),a=S(k.element,{...b.config});let l=b.handlers,r=b.config,t={};const n=c=>{if(!c||typeof c.type!="string")return;const d=l[$(c.type)];typeof d=="function"&&d(c)},i=a.on("*",n);for(const[c,d]of Object.entries(b.imperative))d!==void 0&&(N[c](a,d),t[c]=d);let o=!1;return{grid:a,update(c){if(o)return;const d=z(c||{});l=d.handlers;const f={};for(const[h,g]of Object.entries(d.config))Object.is(r[h],g)||(f[h]=g);for(const h of Object.keys(r))Object.hasOwn(d.config,h)||(f[h]=void 0);Object.keys(f).length&&a.setAll(f),r=d.config;for(const[h,g]of Object.entries(N)){const y=d.imperative[h];Object.is(t[h],y)||y===void 0&&!Object.hasOwn(t,h)||(g(a,y),t[h]=y)}},destroy(){o||(o=!0,i(),a.destroy())}}}}),Se("packages/modules/react/viewers.js",function(e,V){"use strict";Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"VIEWER_BULK_UPDATE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"partitionViewerProps",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return z}});const N=V("packages/core/src/internal/util.js").warnOnce,$=Object.freeze({kpi:Object.freeze(["tile:click","tile:dblclick","tile:contextmenu","node:toggle","change","tile:status"]),kanban:Object.freeze(["card:click","card:dblclick","card:contextmenu","card:move","card:reverted","card:confirmed","selection:changed","column:collapse","card:add","drag:start","drag:end","swimlane:collapse","swimlane:reorder","column:reorder","filter:changed","sprint:changed","epic:changed","card:expand","card:drill","card:edit","card:sla","beforeMove","beforeAdd","beforeEdit","beforeLaneReorder","beforeColumnReorder","beforeColumnChange","move:cancelled","add:cancelled","edit:cancelled","laneReorder:cancelled","columnReorder:cancelled","columnChange:cancelled"]),tabs:Object.freeze(["beforeTabChange","tab:changed","tabChange:cancelled"]),chart:Object.freeze(["click","hover","leave","draw","legend"]),gantt:Object.freeze(["schedule","error"]),layout:Object.freeze(["layout:changed","window:moved","window:resized","window:closed","beforeWindowClose","windowClose:cancelled"]),router:Object.freeze(["metrics"])}),L=Object.freeze({kpi:Object.freeze({rows:(F,k)=>F.setRows(Array.isArray(k)?k:[])}),kanban:Object.freeze({rows:(F,k)=>F.setRows(Array.isArray(k)?k:[]),quickFilter:(F,k)=>F.setQuickFilter(typeof k=="string"?k:""),sprint:(F,k)=>F.setSprint(k),epic:(F,k)=>F.setEpic(k),loading:(F,k)=>F.setLoading(!!k),error:(F,k)=>F.setError(k??null)}),gantt:Object.freeze({tasks:(F,k)=>F.setTasks(Array.isArray(k)?k:[]),dependencies:(F,k)=>F.setDependencies(Array.isArray(k)?k:[])}),tabs:Object.freeze({active:(F,k)=>{typeof k=="string"&&F.activate(k)}}),chart:Object.freeze({}),layout:Object.freeze({})}),W=Object.freeze({chart:"update"});function Z(F){return`on${String(F).split(":").map(S=>S.charAt(0).toUpperCase()+S.slice(1)).join("")}`}const H=Object.freeze(Object.fromEntries(Object.entries($).map(([F,k])=>[F,Object.freeze(Object.fromEntries(k.map(S=>[Z(S),S])))])));function U(F,k){const S=H[F]||{},b=L[F]||{},a={},l={},r={};for(const[t,n]of Object.entries(k||{})){if(Object.hasOwn(S,t)){r[t]=n;continue}if(Object.hasOwn(b,t)){l[t]=n,a[t]=n;continue}a[t]=n}return{config:a,live:l,handlers:r}}function z(F){const k=String(F.viewer),S=F.mount,b=F.name||k;if(typeof S!="function")throw new TypeError(`createViewerController needs a mount factory for "${k}"; pass the module's own factory in, e.g. { createKPI } from lattice-grid/modules/kpi.`);const a=U(k,F.props||{}),l=S(F.element,{...a.config});if(!l||typeof l!="object")throw new TypeError(`the ${b} factory returned no instance; nothing can be driven.`);let r=a.handlers,t=a.config;const n={...a.live},i=[];if(typeof l.on=="function")for(const f of $[k]||[]){const h=Z(f),g=l.on(f,y=>{const p=r[h];typeof p=="function"&&p(y)});typeof g=="function"&&i.push(g)}const o=W[k],c=L[k]||{};let d=!1;return{instance:l,update(f){if(d)return;const h=U(k,f||{});r=h.handlers;const g={};for(const[p,m]of Object.entries(h.config))Object.is(t[p],m)||(g[p]=m);if(t=h.config,!Object.keys(g).length)return;const y=[];for(const p of Object.keys(g)){const m=c[p];if(m){m(l,g[p]),n[p]=g[p];continue}o&&typeof l[o]=="function"||y.push(p)}if(o&&typeof l[o]=="function"){const p={};for(const m of Object.keys(g))c[m]||(p[m]=g[m]);Object.keys(p).length&&l[o](p)}y.length&&N(`react.viewer.${k}.mountOnly.${y.join(".")}`,`${b}: ${y.map(p=>`\`${p}\``).join(", ")} changed, but ${b} takes ${y.length===1?"it":"them"} only when the viewer is created. Nothing was applied and the viewer was NOT rebuilt — rebuilding it silently would throw away scroll position, selection and expansion. Give the component a \`key\` that changes when this must take effect, so the rebuild is yours and visible, or drive the instance through the ref.`)},destroy(){if(!d){d=!0;for(const f of i)try{f()}catch{}i.length=0,typeof l.destroy=="function"&&l.destroy()}}}}}),Se("packages/modules/webcomponent/controller.js",function(e,V){"use strict";Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"ELEMENT_STYLE_ID",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"coerceAttribute",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"injectElementStyle",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return k}});const _="lattice-",N="lattice-grid-element-styles",$=Object.freeze({theme:"theme",density:"density",locale:"locale","row-key":"rowKey","row-height":"rowHeight","header-height":"headerHeight","auto-height":"autoHeight","filter-row":"filterRow",selection:"selection",rows:"rows",columns:"columns"}),L=new Set(["rowHeight","headerHeight"]),W=new Set(["autoHeight","filterRow"]),Z=new Set(["rows","columns"]);function H(){return Object.keys($)}function U(S){return _+String(S).replace(/:/g,"-")}function z(S,b){if(W.has(S))return b!==null&&b!=="false";if(b!==null){if(L.has(S)){const a=Number(b);return Number.isFinite(a)?a:void 0}if(Z.has(S))try{return JSON.parse(b)}catch{return}return b}}function F(S){if(!S||!S.createElement||S.getElementById&&S.getElementById(N))return;const b=S.createElement("style");b.setAttribute("id",N),b.appendChild(S.createTextNode(`lattice-grid{display:block}
55
55
  `));const a=S.head||S.documentElement||null;a&&a.appendChild(b)}class k{#e;#t;#n=null;#r={};#o=null;#i=!1;#a=!1;constructor(b,a){this.#e=b,this.#t=a.createGrid}get grid(){return!this.#n&&this.#a&&this.settleCreate(),this.#n}get teardownPending(){return this.#i}config(){return{...this.#r}}configure(b){if(!(!b||typeof b!="object"))for(const[a,l]of Object.entries(b))this.#s(a,l)}attributeChanged(b,a){const l=$[b];if(!l)return;const r=z(l,a);r===void 0&&!W.has(l)||this.#s(l,r)}connect(){this.#i=!1,this.#a=!0,!this.#n&&queueMicrotask(()=>this.settleCreate())}settleCreate(){if(!this.#a||this.#n)return;F(this.#e.ownerDocument||null);const b=this.#t(this.#e,{...this.#r});this.#n=b,this.#l(b)}disconnect(){this.#a=!1,this.#n&&(this.#i=!0,queueMicrotask(()=>this.settleTeardown()))}settleTeardown(){this.#i&&(this.#i=!1,this.destroy())}destroy(){this.#o&&(this.#o(),this.#o=null);const b=this.#n;this.#n=null,b&&typeof b.destroy=="function"&&b.destroy()}#s(b,a){this.#r[b]=a,this.#n&&typeof this.#n.set=="function"&&this.#n.set(b,a)}#l(b){!b||typeof b.on!="function"||(this.#o=b.on("*",a=>{const l=this.#e;if(!l||typeof l.dispatchEvent!="function")return;const r={...a};delete r.grid,l.dispatchEvent(this.#u(U(a.type),r))}))}#u(b,a){const l=globalThis.CustomEvent;return typeof l=="function"?new l(b,{detail:a,bubbles:!0,composed:!0}):{type:b,detail:a,bubbles:!0,composed:!0}}}}),Se("packages/modules/webcomponent/styles.js",function(e,V){"use strict";Object.defineProperty(e,"constructableStyleSheets",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"isLatticeStyleNode",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"sheetText",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"latticeStyleNodes",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"adoptIntoHostRoot",{enumerable:!0,get:function(){return b}});const _=Symbol.for("lattice.webcomponent.styleMirror"),N=/--lattice-|\.lat-/,$=new WeakMap,L=new WeakMap;function W(){const a=globalThis.CSSStyleSheet;if(typeof a!="function")return!1;try{return typeof new a().replaceSync=="function"}catch{return!1}}function Z(a){if(!a||typeof a.getAttribute!="function")return!1;const l=String(a.tagName||"").toLowerCase();if(l!=="style"&&l!=="link"||l==="link"&&!String(a.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet"))return!1;const r=String(a.getAttribute("id")||"");if(r.startsWith("lattice")||r.startsWith("lat-")||a.hasAttribute&&a.hasAttribute("data-lattice"))return!0;if(l==="link"){const t=String(a.getAttribute("href")||"");return/lattice/i.test(t)?!0:N.test(H(a))}return N.test(String(a.textContent||""))}function H(a){if(String(a&&a.tagName||"").toLowerCase()==="style")return String(a.textContent||"");try{const r=a&&a.sheet;if(!r||!r.cssRules)return"";let t="";for(const n of r.cssRules)t+=`${n.cssText}
56
- `;return t}catch{return""}}function U(a,l){const r=$.get(a);if(r)return r.sheet;const t=H(a);if(!t)return null;const n=l.CSSStyleSheet,i=new n;try{i.replaceSync(t)}catch{return null}i[_]=!0;let o=null;const c=l.MutationObserver;return typeof c=="function"&&String(a.tagName).toLowerCase()==="style"&&(o=new c(()=>{try{i.replaceSync(String(a.textContent||""))}catch{}}),o.observe(a,{childList:!0,characterData:!0,subtree:!0})),$.set(a,{sheet:i,stop:()=>o&&o.disconnect()}),i}function z(a){return a?a.nodeType===9?a:a.ownerDocument||globalThis.document||null:globalThis.document||null}function F(a){const l=a||globalThis.document;return!l||typeof l.querySelectorAll!="function"?[]:[...l.querySelectorAll("style,link[rel]")].filter(Z)}function k(a={}){if(!W())return[];const l=a.document||globalThis.document,r=l&&l.defaultView||globalThis,t=[];for(const n of F(l)){const i=U(n,r);i&&!t.includes(i)&&t.push(i)}return t}function S(a,l={}){const r=()=>{};if(!a||typeof a!="object")return r;const t=l.document||z(a);if(!t)return r;const n=t.defaultView||globalThis;let i=L.get(a);i||(i=new Map,L.set(a,i));const o=[],c=W(),d=p=>{if(i.has(p))return;const m=c?U(p,n):null;if(m){i.set(p,m);const v=a.adoptedStyleSheets||[];v.includes(m)||(a.adoptedStyleSheets=[...v,m]);return}if(String(p.tagName).toLowerCase()!=="link"||typeof a.appendChild!="function")return;const w=t.createElement("link");w.setAttribute("rel","stylesheet"),w.setAttribute("href",p.getAttribute("href")||""),w.setAttribute("data-lattice","adopted"),a.appendChild(w),o.push(w),i.set(p,w)};for(const p of F(t))d(p);let f=null;const h=n.MutationObserver,g=t.head||t.documentElement;typeof h=="function"&&g&&(f=new h(p=>{for(const m of p)for(const w of m.addedNodes||[])Z(w)&&d(w)}),f.observe(g,{childList:!0}));let y=!1;return()=>{if(y)return;y=!0,f&&f.disconnect();const p=a.adoptedStyleSheets||[],m=new Set([...i.values()]);a.adoptedStyleSheets=p.filter(w=>!m.has(w));for(const w of o)w.parentNode&&w.parentNode.removeChild(w);i.clear()}}function b(a){if(!a||typeof a.getRootNode!="function"||typeof a.getAttribute=="function"&&String(a.getAttribute("lattice-styles")||"")==="off")return null;const l=a.getRootNode();return!l||l.nodeType!==11||!l.host?null:S(l)}}),Se("packages/modules/webcomponent/elements.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return ae}});const N=V("packages/core/src/internal/util.js").warnOnce,L=V("packages/modules/shared/adapter.js").aliasConfigKey,W=V("packages/modules/react/viewers.js"),Z=W.VIEWER_EVENTS,H=W.viewerHandlerName,U=W.createViewerController,z=V("packages/modules/webcomponent/controller.js"),F=z.GridElementController,k=z.observedAttributeNames,S=z.domEventName,b=z.ATTRIBUTE_CONFIG,l=V("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,r="default",t="lattice-",n=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),i=Object.freeze({chart:ee=>{if("data"in ee){const J=ee.data;delete ee.data,J!=null&&ee.rows===void 0&&(ee.rows=J)}if("stacked"in ee){const J=ee.stacked;delete ee.stacked,J!=null&&ee.stack===void 0&&(ee.stack=J)}if("horizontal"in ee){const J=ee.horizontal;delete ee.horizontal,J&&ee.type==="bar"&&(ee.type="horizontalBar")}},kanban:ee=>{if(!("titleProperty"in ee))return;const J=ee.titleProperty;if(delete ee.titleProperty,typeof J!="string"||!J)return;const se=ee.card&&typeof ee.card=="object"?ee.card:null;se&&se.title!==void 0||(ee.card={title:J,...se||{}})},gantt:ee=>{if(!("scale"in ee))return;const J=ee.scale;if(delete ee.scale,J==null||J==="")return;const se=ee.render&&typeof ee.render=="object"?{...ee.render}:{};se.zoom===void 0&&(se.zoom=J),ee.render=se}}),o=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),c=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),d=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),f=Symbol.for("lattice.webcomponent.routerScope"),h=new WeakMap;function g(ee){if(ee==null)return;if(ee===""||ee==="true")return!0;if(ee==="false")return!1;const J=String(ee).trim();if(J.startsWith("[")||J.startsWith("{"))try{return JSON.parse(J)}catch{return ee}return J!==""&&Number.isFinite(Number(J))?Number(J):ee}function y(ee,J){const se={},le=ee&&typeof ee.getAttributeNames=="function"?ee.getAttributeNames():[];for(const oe of le){if(c.has(oe)||d.has(oe)||J&&J.has(oe)||oe.startsWith("data-")||oe.startsWith("aria-"))continue;const he=g(ee.getAttribute(oe));he!==void 0&&(se[p(oe)]=he)}return se}function p(ee){const J=L(ee);return J!==ee||!ee.includes("-")?J:ee.replace(/-([a-z0-9])/g,(se,le)=>le.toUpperCase())}function m(ee){return ee&&typeof ee.getAttributeNames=="function"?ee.getAttributeNames():[]}function w(ee){const J=[];for(const se of m(ee))c.has(se)||d.has(se)||se.startsWith("data-")||se.startsWith("aria-")||J.push(p(se));return J}function v(){const ee=new Map,J=new Set;return{publish(se,le){const oe=se||r;le?ee.set(oe,le):ee.delete(oe);for(const he of[...J])he()},get(se){return ee.get(se||r)||null},names(){return[...ee.keys()]},subscribe(se){return J.add(se),()=>{J.delete(se)}}}}function u(ee={}){const J=typeof ee.createDataRouter=="function"?ee.createDataRouter:null;let se=null,le=!1;return{grids:v(),get router(){return se},attach(he,fe,ve){le||!J||(se||(se=J(ee.config||{})),se.attach(he,fe,ve||{}))},detach(he){if(!(le||!se))try{se.detach(he)}catch{}},destroy(){le=!0;const he=se;se=null,he&&he.destroy()}}}function s(ee){let J=ee&&ee.parentNode||null;for(;J;){if(J[f])return J[f];J=J.parentNode||J.host||null}const le=(ee&&typeof ee.getRootNode=="function"?ee.getRootNode():ee&&ee.ownerDocument||null)||globalThis.document||globalThis;let oe=h.get(le);return oe||(oe=u(),h.set(le,oe)),oe}function O(ee,J,se){const le=J&&typeof J=="object"?J:{},oe=se&&typeof se=="object"?se:{};for(const[he,fe]of Object.entries(le))Object.is(oe[he],fe)||ee.filters.where(he,typeof fe=="function"?fe:null);for(const he of Object.keys(oe))Object.hasOwn(le,he)||ee.filters.where(he,null)}function E(ee,J){if(!Object.hasOwn(ee,J))return;const se=ee[J];delete ee[J],ee[J]=se}const A=new Set(["instance","config","grid","gridName","router"]);function M(ee,J){let se=Object.getPrototypeOf(ee);for(;se;){const le=Object.getOwnPropertyDescriptor(se,J);if(le)return typeof le.get=="function";se=Object.getPrototypeOf(se)}return!1}function C(ee,J){if(!J||A.has(J)||J.startsWith("__"))return;const se=Object.getOwnPropertyDescriptor(ee,J);if(se&&typeof se.get=="function")return;if(M(ee,J)){se&&E(ee,J);return}const le=se?se.value:void 0;se&&delete ee[J],Object.defineProperty(ee,J,{get(){return this.__props[J]},set(oe){this.__write(J,oe)},configurable:!0,enumerable:!0}),se&&(ee[J]=le)}function P(ee){let J=!1;for(const se of Object.getOwnPropertyNames(ee)){if(se.startsWith("__")||A.has(se))continue;const le=Object.getOwnPropertyDescriptor(ee,se);!le||typeof le.get=="function"||!le.enumerable||(C(ee,se),J=!0)}return J}function D(ee,J,se){if(!ee||typeof ee.dispatchEvent!="function")return;const le=globalThis.CustomEvent,oe={detail:se,bubbles:!0,composed:!0};ee.dispatchEvent(typeof le=="function"?new le(J,oe):{type:J,...oe})}function K(ee){const J=ee.viewer,se=o[J],le=ee.label||se.label,oe=ee.mount,he=Z[J]||[];class fe extends ee.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const be of["config","grid","gridName",...se.properties,...se.scalars])E(this,be);P(this)}get instance(){return this.__controller?this.__controller.instance:null}get grid(){return this.__props.grid}set grid(be){this.__write("grid",be)}get gridName(){const be=this.__props.gridName;if(typeof be=="string")return be;const Re=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Re===null?void 0:Re}set gridName(be){this.__write("gridName",be)}get config(){return{...this.__props}}set config(be){if(!(!be||typeof be!="object")){for(const[Re,He]of Object.entries(be))this.__props[Re]=He;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const be=l(this);be&&this.__release.push(be);const Re=s(this);this.__scope=Re,se.fromContext&&this.__release.push(Re.grids.subscribe(()=>this.__settle()));const He=globalThis.MutationObserver;if(typeof He=="function"){const Oe=new He(()=>this.__settle());Oe.observe(this,{attributes:!0}),this.__release.push(()=>Oe.disconnect())}}P(this);for(const be of w(this))C(this,be);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const be of this.__release.splice(0))try{be()}catch{}this.__tearDown()}}__write(be,Re){this.__props[be]=Re,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!se.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const be=this.__scope;return be?be.grids.get(this.gridName):null}__resolve(){const be={...y(this,this.__ownAttributes),...this.__props};if(delete be.gridName,se.fromContext){const He=this.__boundGrid();He?be[se.fromContext]=He:delete be[se.fromContext]}const Re=i[J];Re&&Re(be);for(const He of he)be[H(He)]=Oe=>D(this,S(He),Oe);return be}__settle(){if(!this.__connected)return;P(this);const be=this.__resolve(),Re=se.fromContext&&be[se.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Re)&&this.__tearDown(),!this.__controller){for(const Oe of se.requires)if(be[Oe]===void 0||be[Oe]===null)return;if(se.fromContext&&!Re&&be.rows===void 0)return;const He=new Set(m(this));this.__controller=U({viewer:J,mount:oe,element:this,props:be,name:le});for(const Oe of m(this))He.has(Oe)||this.__ownAttributes.add(Oe);this.__builtAgainst=Re,D(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(be)}__tearDown(){const be=this.__controller;this.__controller=null,this.__builtAgainst=null,be&&(D(this,"destroyed",{instance:be.instance}),be.destroy())}}for(const ve of[...se.properties,...se.scalars])ve in ee.Base.prototype||Object.defineProperty(fe.prototype,ve,{get(){return this.__props[ve]},set(be){this.__write(ve,be)},configurable:!0,enumerable:!0});return fe}function x(ee,J,se){if(typeof ee!="function")throw new TypeError(`${J} needs ${se}: ${J}({ ${se} }).`)}function I(){const ee=globalThis.HTMLElement;return typeof ee=="function"?ee:null}function j(ee){x(ee&&ee.createKPI,"createLatticeKPIElement","createKPI");const J=I();return J?K({viewer:"kpi",Base:J,mount:(se,le)=>ee.createKPI(se,le)}):null}function T(ee){x(ee&&ee.createChart,"createLatticeChartElement","createChart");const J=I();return J?K({viewer:"chart",Base:J,mount:(se,le)=>ee.createChart({...le,container:se})}):null}function B(ee){x(ee&&ee.createKanban,"createLatticeKanbanElement","createKanban");const J=I();return J?K({viewer:"kanban",Base:J,mount:(se,le)=>ee.createKanban(se,le)}):null}function q(ee){x(ee&&ee.createGantt,"createLatticeGanttElement","createGantt");const J=I();return J?K({viewer:"gantt",Base:J,mount:(se,le)=>ee.createGantt({...le,element:se})}):null}function X(ee){x(ee&&ee.createLayout,"createLatticeLayoutElement","createLayout");const J=I();return J?K({viewer:"layout",Base:J,mount:(se,le)=>ee.createLayout(se,le)}):null}function Q(ee){x(ee&&ee.createTabs,"createLatticeTabsElement","createTabs");const J=I();return J?K({viewer:"tabs",Base:J,mount:(le,oe)=>{const he=new Map,fe=typeof le.querySelectorAll=="function"?[...le.querySelectorAll("template[data-tab]")]:[];for(const Re of fe)Re.parentNode===le&&he.set(Re.getAttribute("data-tab"),Re);const be=(Array.isArray(oe.tabs)&&oe.tabs.length?oe.tabs:[...he.keys()].map(Re=>({id:Re,label:he.get(Re).getAttribute("data-label")||Re}))).map(Re=>{const He=Re,Oe=he.get(He.id);return Oe?{...He,view:Ie=>{const $e=Oe.content.cloneNode(!0),qe=[...$e.childNodes];return Ie.appendChild($e),{destroy(){for(const Ue of qe)Ue.parentNode&&Ue.parentNode.removeChild(Ue)}}}}:He});return ee.createTabs(le,{...oe,tabs:be,createGrid:ee.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function te(ee){x(ee&&ee.createDataRouter,"createLatticeRouterElement","createDataRouter");const J=I();if(!J)return null;class se extends J{__scope=null;__config={};constructor(){super(),E(this,"config")}get config(){return{...this.__config}}set config(oe){!oe||typeof oe!="object"||(this.__config={...this.__config,...oe},this.__scope&&this.__scope.router&&N("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const oe=y(this);this.__scope=u({createDataRouter:ee.createDataRouter,config:{...oe,...this.__config}}),this[f]=this.__scope}disconnectedCallback(){const oe=this.__scope;if(this.__scope=null,this[f]=null,!oe)return;const he=oe.router;oe.destroy(),he&&D(this,"destroyed",{instance:he})}}return se}function re(ee={}){const J={},se=(le,oe,he)=>{if(typeof oe!="function")return;const fe=he();fe&&(J[le]=fe)};return se("LatticeGridElement",ee.createGrid,()=>ae(ee.createGrid)),se("LatticeKPIElement",ee.createKPI,()=>j({createKPI:ee.createKPI})),se("LatticeChartElement",ee.createChart,()=>T({createChart:ee.createChart})),se("LatticeKanbanElement",ee.createKanban,()=>B({createKanban:ee.createKanban})),se("LatticeGanttElement",ee.createGantt,()=>q({createGantt:ee.createGantt})),se("LatticeLayoutElement",ee.createLayout,()=>X({createLayout:ee.createLayout})),se("LatticeTabsElement",ee.createTabs,()=>Q({createTabs:ee.createTabs,createGrid:ee.createGrid})),se("LatticeRouterElement",ee.createDataRouter,()=>te({createDataRouter:ee.createDataRouter})),J}function ie(ee={}){const J=globalThis.customElements,se={};if(!J||typeof J.define!="function")return se;const le=typeof ee.prefix=="string"?ee.prefix:t,oe=re(ee),he={LatticeGridElement:n.grid,LatticeKPIElement:n.kpi,LatticeChartElement:n.chart,LatticeKanbanElement:n.kanban,LatticeGanttElement:n.gantt,LatticeLayoutElement:n.layout,LatticeTabsElement:n.tabs,LatticeRouterElement:n.router};for(const[fe,ve]of Object.entries(oe)){const be=le+he[fe],Re=J.get?J.get(be):void 0;if(Re){se[be]=Re;continue}J.define(be,ve),se[be]=ve}return se}function ae(ee){const J=I();if(!J)return null;class se extends J{static get observedAttributes(){return k()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=r;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new F(this,{createGrid:ee});for(const oe of["rows","columns","config","predicates","rowUpdates",...Object.values(b)])E(this,oe)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(oe){this.__controller.configure({rows:oe})}get columns(){return this.__controller.config().columns}set columns(oe){this.__controller.configure({columns:oe})}get config(){return this.__controller.config()}set config(oe){this.__controller.configure(oe)}get predicates(){return this.__predicates}set predicates(oe){const he=this.__published?this.__controller.grid:null;he&&O(he,oe,this.__predicates),this.__predicates=oe}get rowUpdates(){return this.__rowUpdates}set rowUpdates(oe){if(Object.is(oe,this.__rowUpdates))return;this.__rowUpdates=oe;const he=this.__published?this.__controller.grid:null;he&&oe&&he.rows.apply(oe)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const oe=l(this);oe&&this.__release.push(oe),this.__scope=s(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(oe,he,fe){this.__controller.attributeChanged(oe,fe)}__publish(){if(!this.__connected||this.__published)return;const oe=this.__controller.grid;if(!oe)return;this.__published=!0,this.__predicates&&O(oe,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||r;const fe=this.__scope;fe&&fe.grids.publish(this.__publishedAs,oe);const ve=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(fe&&ve!==null){const be=this.getAttribute("route-options");fe.attach(oe,g(ve),be===null?{}:g(be))}this.__rowUpdates&&oe.rows.apply(this.__rowUpdates),D(this,"grid-ready",{grid:oe})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const oe=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const fe of this.__release.splice(0))try{fe()}catch{}oe&&he&&(D(this,"grid-destroyed",{grid:oe}),he.detach(oe),he.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const le of Object.values(b))Object.getOwnPropertyDescriptor(se.prototype,le)||le in J.prototype||Object.defineProperty(se.prototype,le,{get(){return this.__controller.config()[le]},set(oe){this.__controller.configure({[le]:oe})},configurable:!0,enumerable:!0});return se}}),Se("packages/modules/webcomponent/index.js",function(e,V){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const _=V("packages/dom/src/index.js"),N=_.createGrid,$=V("packages/modules/webcomponent/elements.js"),L=$.gridElementClass,W=V("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return W.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return W.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return W.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return W.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return W.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return $.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return $.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return $.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return $.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return $.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return $.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return $.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return $.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return $.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return $.createLatticeRouterElement}});const Z=V("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return Z.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return Z.latticeStyleSheets}});const H=V("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return H.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return H.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return H.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return H.createViewerController}});const U=V("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return U.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return U.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return _.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return _.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return _.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return _.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return _.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return _.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return _.createPushdownSource}});const z="lattice-grid";function F(b=N){return L(b)}function k(b={}){const a=globalThis.customElements,l=b.tagName||z;if(!a||typeof a.define!="function")return null;const r=a.get?a.get(l):void 0;if(r)return r;const t=F(b.createGrid||N);return t?(a.define(l,t),t):null}k();const S=k});try{En("packages/worker/src/inline.js").setWorkerSource('(function(gt){"use strict";var et=Object.create(null),tt=Object.create(null);function Se(o,fe){et[o]=fe}function nt(o){var fe=tt[o];if(fe)return fe;var le=Object.create(null);tt[o]=le;var ae=et[o];if(!ae)throw new Error("[lattice] missing module: "+o);return ae(le,nt),le}Se("packages/core/src/internal/util.js",function(o,fe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return se}});const le="1.71.1";async function ae(){return le}const Q="1.71.1",q=new Set,te=2e3;function _(T){if(q.add(T),q.size>te){const L=q.values().next().value;L!==void 0&&q.delete(L)}}const F=[],H=500;function ne(T,L,J){F.push({key:T,level:L,message:J.map(he=>typeof he=="string"?he:x(he)).join(" "),at:Date.now()}),F.length>H&&F.shift()}function x(T){if(T instanceof Error)return T.message;try{return JSON.stringify(T)}catch{return String(T)}}function ce(){return F.map(T=>({...T}))}function ie(T,...L){q.has(T)||(_(T),ne(T,"warn",L),console.warn("[lattice]",...L))}function G(T,...L){q.has(T)||(_(T),ne(T,"info",L),console.info("[lattice]",...L))}function D(){q.clear(),F.length=0}function Y(T,L){const J=new Error(`[lattice] ${T}`);throw L!==void 0&&(J.cause=L),J}function ee(T,L){T||Y(L)}const z=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(T){return T!==null&&typeof T=="object"&&!Array.isArray(T)}function i(T){return typeof T=="function"}function s(T){return T==null}function u(T){return T==null||T===""}function f(T){return typeof T!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(T))?!0:!!(T.prototype&&Object.getOwnPropertyNames(T.prototype).length>1)}const c=new Map;function t(T){let L=c.get(T);if(L)return L;if(!T.includes("."))L=J=>J?.[T];else{const J=T.split("."),he=J.length;L=ye=>{let Me=ye;for(let Pe=0;Pe<he;Pe++){if(Me==null)return;Me=Me[J[Pe]]}return Me}}return c.set(T,L),L}const a=new Map;function g(T){let L=a.get(T);if(L)return L;if(!T.includes("."))L=(J,he)=>{J!=null&&(J[T]=he)};else{const J=T.split("."),he=J.length-1;L=(ye,Me)=>{let Pe=ye;for(let Ne=0;Ne<he;Ne++){if(Pe==null)return;const je=J[Ne];Pe[je]==null&&(Pe[je]={}),Pe=Pe[je]}Pe!=null&&(Pe[J[he]]=Me)}}return a.set(T,L),L}function e(T,L){return t(L)(T)}function m(T,L,J){g(L)(T,J)}function d(T){return T?(T.includes(".")?T.slice(T.lastIndexOf(".")+1):T).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,J=>J.toUpperCase()):""}const r={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function n(T){const L=T==null?"":String(T);return/[&<>"\']/.test(L)?L.replace(/[&<>"\']/g,J=>r[J]):L}function l(T){return String(T).replace(/\\w\\S*/g,L=>L[0].toUpperCase()+L.slice(1).toLowerCase())}function b(T,L,J){if(T!==void 0)return T===!0?{enabled:!0,...J}:T===!1?{enabled:!1}:M(T)?T:{[L]:T,enabled:!0}}function E(T){return T==null?[]:Array.isArray(T)?T:[T]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function V(T,L){if(!M(T))return M(L)?{...L}:L;if(!M(L))return L===void 0?T:L;const J={...T};for(const he of Object.keys(L)){if(S.has(he))continue;const ye=L[he];ye!==void 0&&(J[he]=M(ye)&&M(J[he])?V(J[he],ye):ye)}return J}function U(T,L){if(!M(T)||!M(L)||T===L)return L;const J=Object.create(Object.getPrototypeOf(T));return Object.assign(J,T,L),J}class I{#t;#e=new Map;#n;constructor(L=256,J=null){this.#t=L,this.#n=J}get size(){return this.#e.size}get max(){return this.#t}set max(L){this.#t=L,this.#r()}has(L){return this.#e.has(L)}get(L){const J=this.#e;if(!J.has(L))return;const he=J.get(L);return J.delete(L),J.set(L,he),he}peek(L){return this.#e.get(L)}set(L,J){const he=this.#e;return he.has(L)&&he.delete(L),he.set(L,J),this.#r(),J}delete(L){const J=this.#e.get(L);return this.#e.delete(L)&&this.#n&&this.#n(J,L),J}clear(){if(this.#n)for(const[L,J]of this.#e)this.#n(J,L);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const L=this.#e;for(;L.size>this.#t;){const J=L.keys().next().value,he=L.get(J);L.delete(J),this.#n&&this.#n(he,J)}}}const X=new Map;function C(T,L){const J=`${T||""}|${L?JSON.stringify(L):""}`;let he=X.get(J);return he||(he=new Intl.Collator(T||void 0,{numeric:!0,sensitivity:"variant",...L}),X.set(J,he)),he}function R(T,L){if(T===L)return 0;if(T==null)return 1;if(L==null)return-1;if(typeof T=="number"&&typeof L=="number")return Number.isNaN(T)?Number.isNaN(L)?0:1:Number.isNaN(L)||T<L?-1:T>L?1:0;const J=String(T),he=String(L);return J<he?-1:J>he?1:0}function h(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function w(T){return O?requestAnimationFrame(T):setTimeout(()=>T(h()),16)}function P(T){T!=null&&(O?cancelAnimationFrame(T):clearTimeout(T))}function v(T){let L=null,J=null;const he=()=>{L=null;const Me=J;J=null,T(...Me||[])},ye=(...Me)=>{J=Me,L===null&&(L=w(he))};return ye.cancel=()=>{P(L),L=null,J=null},ye.flush=()=>{L!==null&&(P(L),he())},ye}function K(T,L){let J=null,he=null;const ye=()=>{if(J=null,he===null)return;const Ne=he;he=null,T(...Ne),Me()},Me=()=>{J=setTimeout(ye,L),typeof J?.unref=="function"&&J.unref()},Pe=(...Ne)=>{J===null?(T(...Ne),Me()):(he=Ne,clearTimeout(J),Me())};return Pe.flush=()=>{if(J!==null&&clearTimeout(J),J=null,he===null)return;const Ne=he;he=null,T(...Ne)},Pe.cancel=()=>{J!==null&&clearTimeout(J),J=null,he=null},Pe.pending=()=>J!==null||he!==null,Pe}function Z(T,L=50){return typeof requestIdleCallback=="function"?requestIdleCallback(T,{timeout:L}):setTimeout(()=>T({timeRemaining:()=>0,didTimeout:!0}),1)}let oe=0;function se(T="l"){return`${T}${(++oe).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,fe){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.isFunction,q=1,te=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),F=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function H(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ne(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ne(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function x(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=H(s[f]);return u}class ce{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class ie{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const f=this.#e.get(u);if(f!==void 0)return f;const c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const g=ae(u).compare,e=this.#t,m=Array.from(a).sort((r,n)=>{const l=e[r],b=e[n];return l===b?0:l==null?1:b==null?-1:g(String(l),String(b))}),d=new Uint32Array(t);for(let r=0;r<m.length;r++)d[m[r]]=r;return this.#r.set(f,{version:this.#n,ranks:d}),d}}function G(s){if(s==null)return null;const u=s.presence?new ce(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ie(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,g=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(c[e]):c[e];case"bitset":return(c[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const m=t[e],d=t[e+1],r=new Array(d-m);for(let n=m;n<d;n++)r[n-m]=f?f.valueOf(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,presence:u,dict:f,offsets:t,get:g,version:s.version}}function D(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=G(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function z(s,u=[]){const f=c=>{if(!ee(c))return;const t=c.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const c=f.conditions;if(Array.isArray(c))for(const t of c)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,fe){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return ae}});const le=8;class ae{static#t=new Uint8Array(256);static{for(let q=1;q<256;q++)ae.#t[q]=ae.#t[q>>1]+(q&1)}#e;#n;constructor(q=0){const te=Math.max(0,q|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/le))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(q){return q<0||q>=this.#n?0:this.#e[q>>3]>>(q&7)&1}set(q){return q>=0&&q<this.#n&&(this.#e[q>>3]|=1<<(q&7)),this}clear(q){return q>=0&&q<this.#n&&(this.#e[q>>3]&=~(1<<(q&7))),this}assign(q,te){return te?this.set(q):this.clear(q)}fill(q=!1){return this.#e.fill(q?255:0),q&&this.#r(),this}grow(q){const te=Math.max(0,q|0);if(te<=this.#n)return this;const _=Math.ceil(te/le);if(_>this.#e.length){const F=new Uint8Array(_);F.set(this.#e),this.#e=F}return this.#n=te,this}count(){const q=this.#e,te=ae.#t;let _=0;for(let F=0;F<q.length;F++)_+=te[q[F]];return _}and(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]&=te[H];for(let H=F;H<_.length;H++)_[H]=0;return this}or(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]|=te[H];return this}not(){const q=this.#e;for(let te=0;te<q.length;te++)q[te]=~q[te]&255;return this.#r(),this}clone(){const q=new ae(this.#n);return q.words.set(this.#e.subarray(0,q.words.length)),q}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const q=this.#n&7;if(q===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<q)-1)}static from(q){const te=Array.isArray(q)?q:Array.from(q),_=new ae(te.length);for(let F=0;F<te.length;F++)te[F]&&_.set(F);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,fe){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return q}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare;class q{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let F=0;F<_.length;F++){const H=_[F];this.#e.has(H)||(this.#e.set(H,this.#t.length),this.#t.push(H))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let F=0;F<this.#t.length;F++){const H=this.#t[F];typeof H=="string"&&(_+=H.length*2),_+=16}return _}codeOf(_){const F=this.#e.get(_);if(F!==void 0)return F;const H=this.#t.length;return this.#t.push(_),this.#e.set(_,H),this.#n++,H}lookup(_){const F=this.#e.get(_);return F===void 0?-1:F}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const F=_||"";if(this.#r&&this.#i===this.#n&&this.#s===F)return this.#r;const H=this.#t.length,ne=new Array(H);for(let G=0;G<H;G++)ne[G]=G;const x=ae(_).compare,ce=this.#t;ne.sort((G,D)=>this.#h(ce[G],ce[D],x));const ie=new Uint32Array(H);for(let G=0;G<H;G++)ie[ne[G]]=G;return this.#r=ie,this.#i=this.#n,this.#s=F,ie}#h(_,F,H){return typeof _=="string"&&typeof F=="string"?H(_,F):Q(_,F)}}}),Se("packages/core/src/store/multivalue.js",function(o,fe){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return le}});class le{#t;#e;#n=0;#r=0;constructor(Q={}){const q=Math.max(1,Q.rows??16),te=Math.max(1,Q.values??q);this.#t=new Int32Array(te),this.#e=new Uint32Array(q+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,q){if(Q<0||Q>=this.#n)return!1;const te=this.#t,_=this.#e[Q+1];for(let F=this.#e[Q];F<_;F++)if(te[F]===q)return!0;return!1}hasAny(Q,q){for(let te=0;te<q.length;te++)if(this.has(Q,q[te]))return!0;return!1}hasAll(Q,q){for(let te=0;te<q.length;te++)if(!this.has(Q,q[te]))return!1;return!0}hasNone(Q,q){return!this.hasAny(Q,q)}push(Q){const q=this.#n,te=Q.length;this.#i(q+1),this.#s(this.#r+te);const _=this.#r;for(let F=0;F<te;F++)this.#t[_+F]=Q[F]|0;return this.#r+=te,this.#n=q+1,this.#e[q]=_,this.#e[q+1]=this.#r,q}write(Q,q){if(Q===this.#n){this.push(q);return}if(Q<0||Q>this.#n)return;const te=this.#e[Q],_=this.#e[Q+1],F=q.length;if(_-te===F){for(let H=0;H<F;H++)this.#t[te+H]=q[H]|0;return}this.#h(Q,q)}compact(Q,q,te){const _=this.#t,F=this.#e,H=this.#n,ne=new Int32Array(Math.max(1,this.#r)),x=new Uint32Array(q+1);let ce=0;for(let ie=0;ie<H;ie++){if(Q[ie]===te)continue;const G=F[ie],D=F[ie+1];x[Q[ie]]=ce;for(let Y=G;Y<D;Y++)ne[ce++]=_[Y];x[Q[ie]+1]=ce}this.#t=ne,this.#e=x,this.#n=q,this.#r=ce}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let q=this.#e.length-1;for(;q<Q;)q=q*2||16;const te=new Uint32Array(q+1);te.set(this.#e),this.#e=te}#s(Q){if(Q<=this.#t.length)return;let q=this.#t.length;for(;q<Q;)q=q*2||16;const te=new Int32Array(q);te.set(this.#t),this.#t=te}#h(Q,q){const te=this.#t,_=this.#e,F=this.#n,H=q.length-(_[Q+1]-_[Q]),ne=new Int32Array(Math.max(1,this.#r+H)),x=new Uint32Array(_.length);let ce=0;for(let ie=0;ie<F;ie++){if(x[ie]=ce,ie===Q)for(let G=0;G<q.length;G++)ne[ce++]=q[G]|0;else for(let G=_[ie];G<_[ie+1];G++)ne[ce++]=te[G];x[ie+1]=ce}this.#t=ne,this.#e=x,this.#r=ce}}}),Se("packages/core/src/compute/handle.js",function(o,fe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare,q=le.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(q(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const F=new WeakMap;function H(i){const s=i.constructor;if(!s)return"unknown";const u=F.get(s);if(u)return u;let f="unknown";try{let c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return F.set(s,f),f}function ne(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":H(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function x(i){return!i||!i.presence?null:ne(i.presence)}function ce(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ie(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function G(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,g=new Array(t-c);for(let e=c;e<t;e++)g[e-c]=a?ie(a,f[e]):f[e];return g}function D(i){if(!i)return()=>{};const s=i.values,u=x(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?ie(c,s[t]):null:t=>ie(c,s[t])}if(f==="bitset"){const c=ne(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?G(i,c):null:c=>G(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=ae(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Y(u,f);if(c==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),g=f instanceof Date?f.getTime():Number(f);return Y(a,g)}return Q(u,f)}}function z(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,c=ee(s),t=new Array(f);for(let g=0;g<f;g++)t[g]=g;t.sort((g,e)=>c(u[g],u[e])||g-e);const a=new Uint32Array(f);for(let g=0;g<f;g++)a[t[g]]=g;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,fe){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return I}});const le=fe("packages/core/src/compute/handle.js"),ae=le.bitReader,Q=le.dictRanks,q=le.dictSize,te=le.identity,_=le.isMissing,F=le.presenceReader,H=le.rowCount,ne=le.valueComparator,x=le.valueReader,ce=new Uint32Array(0),ie=new ArrayBuffer(8),G=new Float64Array(ie),D=new Uint32Array(ie),Y=(G[0]=-1,(D[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function z(C,R){G[0]=C;let h=D[Y],O=D[ee];(h&2147483648)!==0?(h=~h>>>0,O=~O>>>0):h=(h^2147483648)>>>0,R[0]=O,R[1]=h}function M(C,R,h,O){if(O<2)return C;const w=new Uint32Array(256*8);for(let L=0;L<O;L++){const J=R[L],he=h[L];w[J&255]++,w[256+(J>>>8&255)]++,w[512+(J>>>16&255)]++,w[768+(J>>>24&255)]++,w[1024+(he&255)]++,w[1280+(he>>>8&255)]++,w[1536+(he>>>16&255)]++,w[1792+(he>>>24&255)]++}let P=C,v=R,K=h,Z=new Uint32Array(O),oe=new Uint32Array(O),se=new Uint32Array(O);const T=new Uint32Array(256);for(let L=0;L<8;L++){const J=L<<8,he=(L&3)<<3,ye=L>=4;let Me=!1;for(let je=0;je<256;je++)if(w[J+je]===O){Me=!0;break}if(Me)continue;let Pe=0;for(let je=0;je<256;je++)T[je]=Pe,Pe+=w[J+je];for(let je=0;je<O;je++){const Ve=v[je],We=K[je],Xe=(ye?We:Ve)>>>he&255,qe=T[Xe]++;Z[qe]=P[je],oe[qe]=Ve,se[qe]=We}let Ne=P;P=Z,Z=Ne,Ne=v,v=oe,oe=Ne,Ne=K,K=se,se=Ne}return P}function i(C,R,h){if(h<2)return C;const O=new Uint32Array(256*4);for(let oe=0;oe<h;oe++){const se=R[oe];O[se&255]++,O[256+(se>>>8&255)]++,O[512+(se>>>16&255)]++,O[768+(se>>>24&255)]++}let w=C,P=R,v=new Uint32Array(h),K=new Uint32Array(h);const Z=new Uint32Array(256);for(let oe=0;oe<4;oe++){const se=oe<<8,T=oe<<3;let L=!1;for(let ye=0;ye<256;ye++)if(O[se+ye]===h){L=!0;break}if(L)continue;let J=0;for(let ye=0;ye<256;ye++)Z[ye]=J,J+=O[se+ye];for(let ye=0;ye<h;ye++){const Me=P[ye],Pe=Z[Me>>>T&255]++;v[Pe]=w[ye],K[Pe]=Me}let he=w;w=v,v=he,he=P,P=K,K=he}return w}function s(C,R,h,O){const w=new Uint32Array(O+1);for(let K=0;K<h;K++)w[R[K]]++;let P=0;for(let K=0;K<=O;K++){const Z=w[K];w[K]=P,P+=Z}const v=new Uint32Array(h);for(let K=0;K<h;K++)v[w[R[K]]++]=C[K];return v}function u(C,R,h,O){return h<2?C:O<=65536||O<=h*2?s(C,R,h,O):i(C,R,h)}function f(C,R){return C.length===R&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,R)}function c(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=new Uint32Array(w),v=new Uint32Array(w),K=new Uint32Array(w),Z=new Uint32Array(w),oe=new Uint32Array(2);let se=0,T=0;for(let he=0;he<w;he++){const ye=O[he],Me=C[ye];if(Number.isNaN(Me)){Z[T++]=ye;continue}z(Me,oe),h?(v[se]=~oe[0]>>>0,K[se]=~oe[1]>>>0):(v[se]=oe[0],K[se]=oe[1]),P[se++]=ye}const L=M(P.subarray(0,se),v.subarray(0,se),K.subarray(0,se),se);if(T===0)return f(L,se);const J=new Uint32Array(w);return J.set(L.subarray(0,se),0),J.set(Z.subarray(0,T),se),J}function t(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=Uint32Array.from(O),v=new Uint32Array(w);for(let K=0;K<w;K++){const Z=(C[P[K]]^2147483648)>>>0;v[K]=h?~Z>>>0:Z}return f(i(P,v,w),w)}function a(C,R,h={}){const O=R||te(H(C,h)),w=O.length;if(w<2)return Uint32Array.from(O);const P=Q(C.dict,h.locale),v=C.values,K=F(C),Z=Math.max(q(C.dict),P.length),oe=Z,se=Uint32Array.from(O),T=new Uint32Array(w),L=!!h.descending;for(let J=0;J<w;J++){const he=se[J];let ye=K&&K(he)===0?oe:P[v[he]];ye===void 0&&(ye=oe),T[J]=L?oe-ye:ye}return f(u(se,T,w,Z+1),w)}function g(C,R,h){const O=R.length;let w=Uint32Array.from(R);if(O<2)return w;let P=new Uint32Array(O);for(let v=1;v<O;v<<=1){for(let Z=0;Z<O;Z+=v<<1){const oe=Math.min(Z+v,O),se=Math.min(Z+(v<<1),O);let T=Z,L=oe,J=Z;for(;T<oe&&L<se;)P[J++]=h(C[w[T]],C[w[L]])<=0?w[T++]:w[L++];for(;T<oe;)P[J++]=w[T++];for(;L<se;)P[J++]=w[L++]}const K=w;w=P,P=K}return w}function e(C,R,h){const O=ae(C.values),w=R.length,P=new Uint32Array(w),v=h?1:0;let K=0;for(let Z=0;Z<w;Z++)O(R[Z])===v&&(P[K++]=R[Z]);for(let Z=0;Z<w;Z++)O(R[Z])!==v&&(P[K++]=R[Z]);return P}function m(C,R){const h=C.values,O=C.kind;if((O==="object"||O===void 0)&&(Array.isArray(h)||ArrayBuffer.isView(h))&&!C.presence)return h;const P=x(C),v=new Array(H(C)||0);for(let K=0;K<R.length;K++){const Z=R[K];v[Z]=P(Z)}return v}function d(C,R){for(let h=0;h<R.length;h++)if(typeof C[R[h]]!="string")return!1;return!0}function r(C,R,h,O,w){const P=C.length,v=Uint32Array.from(C);if(P<2||O<1)return v;const K=new Uint32Array(P),Z=O-1;for(let oe=0;oe<P;oe++){const se=h[R[oe]];K[oe]=w?Z-se:se}return f(u(v,K,P,O),P)}function n(C,R,h){const O=ne(h),w=new Array(R);for(let v=0;v<R;v++)w[v]=v;w.sort((v,K)=>O(C[v],C[K])||v-K);const P=new Uint32Array(R);for(let v=0;v<R;v++)P[w[v]]=v;return P}function l(C,R,h){const O=R.length,w=new Map,P=[],v=new Uint32Array(O);for(let oe=0;oe<O;oe++){const se=C[R[oe]];let T=w.get(se);T===void 0&&(T=P.length,w.set(se,T),P.push(se)),v[oe]=T}const K=P.length,Z=n(P,K,h.locale);return r(R,v,Z,K,!!h.descending)}function b(C,R,h){const O=m(C,R);if(R.length>=2&&d(O,R)){const v=C.stringRank;return v&&v.version===C.version&&v.usable(R,O,h.locale)?v.sort(R,h):l(O,R,h)}const w=ne(h.locale),P=h.descending?(v,K)=>w(K,v):w;return g(O,R,P)}function E(C,R,h){const O=m(C,R),w=h.compare,v=!!h.descending?(K,Z)=>-w(K,Z,void 0,void 0,!0):(K,Z)=>w(K,Z,void 0,void 0,!1);return g(O,R,v)}function S(C,R){const h=R.length,O=F(C),w=C.values,P=C.kind==="float64"&&!!w,v=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!O&&!P&&!v)return{present:R,absent:ce};const K=new Uint32Array(h),Z=new Uint32Array(h);let oe=0,se=0;if(O&&P)for(let T=0;T<h;T++){const L=R[T];O(L)===1&&!Number.isNaN(w[L])?K[oe++]=L:Z[se++]=L}else if(P&&!O)for(let T=0;T<h;T++){const L=R[T];Number.isNaN(w[L])?Z[se++]=L:K[oe++]=L}else if(O&&!v)for(let T=0;T<h;T++){const L=R[T];O(L)===1?K[oe++]=L:Z[se++]=L}else{const T=x(C);for(let L=0;L<h;L++){const J=R[L];_(T(J))?Z[se++]=J:K[oe++]=J}}return se===0?{present:R,absent:ce}:{present:K.subarray(0,oe),absent:Z.subarray(0,se)}}function V(C,R,h){if(R.length===0)return C;const O=new Uint32Array(C.length+R.length);return h?(O.set(R,0),O.set(C,R.length)):(O.set(C,0),O.set(R,C.length)),O}function U(C,R,h={}){const O=R||te(H(C,h));if(!C||O.length<2)return Uint32Array.from(O);const{present:w,absent:P}=S(C,O);if(w.length===0)return Uint32Array.from(O);const v=!!h.descending;let K;if(typeof h.compare=="function")K=E(C,w,h);else switch(C.kind){case"float64":K=c(C.values,w,v);break;case"int32":K=t(C.values,w,v);break;case"dictionary":K=a(C,w,h);break;case"bitset":K=e(C,w,v);break;default:K=b(C,w,h);break}return V(K,P,!!h.nullsFirst)}function I(C,R,h,O={}){const w=R||[],P=w.length&&(w[0].handle||X(C,w[0].col))||C&&C[0];let v=h||te(H(P,O));for(let K=w.length-1;K>=0;K--){const Z=w[K],oe=Z.handle||X(C,Z.col)||C&&C[K];oe&&(v=U(oe,v,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:O.locale,compare:Z.compare}))}return v instanceof Uint32Array?v:Uint32Array.from(v)}function X(C,R){if(!(!C||R===void 0)){for(let h=0;h<C.length;h++)if(C[h]&&C[h].id===R)return C[h]}}}),Se("packages/core/src/store/stringrank.js",function(o,fe){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const le=fe("packages/core/src/compute/sort.js"),ae=le.collateStringRanks,Q=le.rankSortStrings,q=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(F=q){this.#h=F>0?F:q,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(F){this.#s=F}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let F=this.#n.byteLength;const H=this.#t;for(let ne=0;ne<H.length;ne++)F+=H[ne].length*2+24;return F}#a(F,H){const ne=this.#e.get(F);if(ne!==void 0)return ne;if(this.#u)return-1;if(H&&this.#t.length>=this.#h)return this.#u=!0,-1;const x=this.#t.length;return this.#t.push(F),this.#e.set(F,x),this.#i++,x}build(F,H){const ne=H|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ne);for(let x=0;x<ne;x++){const ce=F[x],ie=typeof ce=="string"?this.#a(ce,!1):-1;this.#n[x]=ie<0?0:ie}this.#r=ne}append(F,H,ne){const x=(H|0)+(ne|0);if(x>this.#n.length){const ce=new Uint32Array(x);ce.set(this.#n.subarray(0,this.#r)),this.#n=ce}for(let ce=H|0;ce<x;ce++){const ie=F[ce],G=typeof ie=="string"?this.#a(ie,!0):-1;this.#n[ce]=G<0?0:G}this.#r=Math.max(this.#r,x)}ranks(F){const H=F||"";if(this.#o&&this.#c===this.#i&&this.#l===H)return this.#o;const ne=ae(this.#t,this.#t.length,F);return this.#o=ne,this.#c=this.#i,this.#l=H,ne}usable(F,H,ne){if(this.#u||this.#t.length===0)return!1;const x=this.#n,ce=this.#t,ie=this.#r;for(let G=0;G<F.length;G++){const D=F[G];if(D>=ie||ce[x[D]]!==H[D])return!1}return!0}sort(F,H){const ne=this.ranks(H.locale),x=this.#t.length,ce=F.length,ie=new Uint32Array(ce),G=this.#n;for(let D=0;D<ce;D++)ie[D]=G[F[D]];return Q(F,ie,ne,x,!!H.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,fe){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return a}});const le=fe("packages/core/src/internal/util.js"),ae=le.warnOnce,Q=le.isFunction,q=le.pathGetter,_=fe("packages/core/src/store/bitset.js").Bitset,H=fe("packages/core/src/store/dictionary.js").Dictionary,x=fe("packages/core/src/store/multivalue.js").MultiValue,ie=fe("packages/core/src/store/stringrank.js").StringRankIndex,G=4294967295,D=1024,Y=5e3,ee=.2,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(g){return g==null}function i(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(typeof g=="boolean")return g?1:0;const e=Number(g);return Number.isNaN(e)&&typeof g=="string"?Date.parse(g):e}function s(g){const e=i(g);return Number.isFinite(e)?e|0:0}function u(g){return M(g)?[]:Array.isArray(g)?g:[g]}function f(g,e){switch(g.kind){case"float64":case"int32":return g.buf[e];case"bitset":return g.bits.get(e)===1;case"dictionary":return g.dict.valueOf(g.buf[e]);case"multi":{const m=g.mv.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=g.dict.valueOf(m[r]);return d}default:return g.buf[e]}}function c(g,e){switch(g.kind){case"float64":case"int32":return g.values[e];case"bitset":return(g.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(g.table||[])[g.values[e]];case"multi":{const m=g.offsets[e],d=g.offsets[e+1],r=g.table||[],n=new Array(d-m);for(let l=m;l<d;l++)n[l-m]=r[g.values[l]];return n}default:return g.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,m){this.#t=e.id;const d=z.has(e.kind)?e.kind:"object";e.kind&&!z.has(e.kind)&&ae(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=d,this.#e=d,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=m,this.#i=Q(e.read)?e.read:q(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,m=this.#s.physical();if(!e||m===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const d=new ie(this.#S());return d.build(e,m),d.version=this.#f,this.#d=d,this.#k=this.#f,d.capped?null:d}return this.#d.length<m&&this.#d.append(e,this.#d.length,m-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const m=this.#l.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=this.#a.valueOf(m[r]);return d}default:return this.#o[e]}}}set(e,m){this.#g||(this.#u?this.#A(e,m):this.#y.set(e,m===void 0?null:m),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,m,d){if(this.#g||d<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let b=!1;switch(this.#e){case"float64":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]);if(typeof V=="number"){n&&l.set(m+S),E[m+S]=V;continue}const U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?NaN:i(V)}break}case"int32":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?0:s(V)}break}case"bitset":{const E=this.#c;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E.assign(m+S,!U&&!!V)}break}case"dictionary":{const E=this.#o,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0),E[m+V]=I?0:S.codeOf(U)}break}case"multi":{const E=this.#l,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0);const X=u(U),C=new Array(X.length);for(let R=0;R<X.length;R++)C[R]=S.codeOf(X[R]);E.write(m+V,C)}break}default:{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?null:V}break}}b&&ae(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,m,d),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,m,d){if(this.#g||d<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let b=0;b<d;b++)r.assign(m+b,(n[b>>3]&1<<(b&7))!==0);else for(let b=0;b<d;b++)r.set(m+b);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,m),this.#f++;return}if(l&&this.#e==="bitset"){const b=e.values;for(let E=0;E<d;E++)this.#c.assign(m+E,(b[E>>3]&1<<(E&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const b=e.table||[],E=new Uint32Array(b.length);for(let I=0;I<b.length;I++)E[I]=this.#a.codeOf(b[I]);const S=e.values,V=this.#o,U=r;for(let I=0;I<d;I++){if(U&&(n&&(n[I>>3]&1<<(I&7))===0)){V[m+I]=0;continue}V[m+I]=E[S[I]]??0}this.#f++;return}if(l&&this.#e==="multi"){const b=e.table||[],E=new Uint32Array(b.length);for(let U=0;U<b.length;U++)E[U]=this.#a.codeOf(b[U]);const S=e.values,V=e.offsets;for(let U=0;U<d;U++){const I=V[U],X=V[U+1],C=new Array(X-I);for(let R=I;R<X;R++)C[R-I]=E[S[R]]??0;this.#l.write(m+U,C)}this.#f++;return}for(let b=0;b<d;b++){const E=n?(n[b>>3]&1<<(b&7))===0:e.kind==="object"?e.values[b]===null:!1;this.#A(m+b,E?null:c(e,b))}this.#f++}touch(){this.#f++}columnarise(e,m){if(this.#u||this.#g)return;const d=new Array(m);for(let r=0;r<m;r++)d[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<m;r++)this.#A(r,d[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const m=new this.#o.constructor(e);m.set(this.#o),this.#o=m;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!z.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const m={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},d=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<d;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(m,n))}return this.#j(),this.#f++,!0}compact(e,m,d){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,b]of r)e[l]!==G&&n.set(e[l],b);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<m;n++)e[n]!==G&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=d;n<m;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n);break}case"multi":this.#l.compact(e,d,G);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const m=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new _(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#a=this.#a??new H(this.#h??[]);break;case"multi":this.#l=new x({rows:m,values:m}),this.#a=this.#a??new H(this.#h??[]);break;default:this.#o=new Array(m);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(m):this.#m=new _(m)),this.#p=m}#A(e,m){const d=M(m);switch(this.#r?this.#m.assign(e,!d):d&&ae(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=d?NaN:i(m);break;case"int32":this.#o[e]=d?0:s(m);break;case"bitset":this.#c.assign(e,!d&&!!m);break;case"dictionary":this.#o[e]=d?0:this.#a.codeOf(m);break;case"multi":{const r=u(m),n=new Array(r.length);for(let l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);this.#l.write(e,n);break}default:this.#o[e]=d?null:m;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const m=this.#i(this.#s.rowAt(e));return m===void 0?null:m}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),m=new Array(e),d=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);m[r]=n,d&&!M(n)&&d.set(r)}return this.#O={version:this.#f,values:m,presence:d},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,m={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,m.initialCapacity??D),this.#l=m.retainSource!==!1,this.#a=this.#l?m.columnarBelow??Y:0,this.#w=m.compactRatio??ee;const d={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){ae(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,d);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const m of this.#n)e+=m.bytes;return e}append(e){const m=this.#i;if(this.#b||!e)return{from:m,to:m};const d=e.length|0;if(d===0)return{from:m,to:m};if(this.#l)for(let n=0;n<d;n++)this.#r[m+n]=e[n];if(this.#i=m+d,this.#h+=d,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:m,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,m,d);return{from:m,to:this.#i}}appendPacked(e,m){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const r=e.count|0;if(r===0)return{from:d,to:d};if(this.#l&&m)for(let l=0;l<r;l++)this.#r[d+l]=m[l];this.#i=d+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const l of e.columns)n.set(l.id,l);for(const l of this.#n){const b=n.get(l.id);b?l.appendPacked(b,d,r):l.grow(this.#s)}return{from:d,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,m){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=m)}get(e,m){const d=this.#e.get(e);return d?d.get(m):void 0}set(e,m,d){if(this.#b||m<0||m>=this.#i)return;const r=this.#e.get(e);if(!r){ae(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(m,d)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const m=this.#i,d=new Uint32Array(m);let r=0;for(let n=0;n<m;n++)d[n]=this.#o.get(n)===1?G:r++;for(const n of this.#n)n.compact(d,m,r);if(this.#l){const n=this.#r;for(let l=0;l<m;l++)d[l]!==G&&(n[d[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),d}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let d=0;d<this.#i;d++)e[d]=d;return e}let m=0;for(let d=0;d<this.#i;d++)this.#o.get(d)===0&&(e[m++]=d);return e}convert(e,m){const d=this.#e.get(e);return d?d.convert(m):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let m=this.#s||this.#d;for(;m<e;)m*=2;for(const d of this.#n)d.grow(m);this.#o.grow(m),this.#s=m}#m(e){const m={};for(const d of this.#n)m[d.id]=d.get(e);return m}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const m of this.#n)m.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,fe){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.now,Q=le.nextFrame,q=le.infoOnce,te=le.warnOnce,_=le.isFunction,F=le.pathGetter,ne=fe("packages/core/src/store/columnstore.js").ColumnStore,x=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ce(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let g=0;g<M.length;g++){const e=M[g];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function ie(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function G(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const b=_(l.read)?l.read:F(l.field||l.id);f.set(l.id,b),u.set(l.id,b)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},g=i?.wrapDeps??null,e=c.filter(l=>_(t[l])),m=e.some(l=>a[l]==="*");let d=new WeakMap;const r=l=>{const b={};if(m)for(const[E,S]of f)b[E]=S(l);for(const E of e){const S=a[E];let V;if(S==="*")V=b;else{V={};const U=S||[];for(let I=0;I<U.length;I++){const X=U[I];V[X]=X in b?b[X]:f.get(X)?.(l)}}b[E]=t[E](g?g(V,E):V,{data:l,row:null,column:null,grid:null,context:s})}return b},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let b=d.get(l);return b===void 0&&(b=r(l),d.set(l,b)),b};for(const l of e)u.set(l,b=>n(b)[l]);return{readers:u,reset(){d=new WeakMap}}}class D{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...x,...u};const f=s.columns??[];this.#r=G(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ne(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=ae(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,this.#r.reset(),this.#w(!1)}while(this.#i<f&&ae()-i<s);return this.#o+=ae()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),c=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){te(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const g=this.#r.readers.get(a.id)??(_(a.read)?a.read:F(a.field||a.id)),e=new D(a,g);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const m=[];for(let r=0;r<f&&m.length<this.#s.sampleSize;r++){const n=g(u[r]);n!=null&&m.push(n)}e.inferred=!0;const d=ce(m,{multi:a.multi});if(d==="text"){const r=new Set(m).size;e.kind=ie(r,m.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${m.length}`}else e.kind=d,e.reason=`inferred from ${m.length} sampled values`,d==="object"&&m.length&&q(`ingest.mixed.${a.id}`,`column "${a.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(m))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const c=this.#d(f);if(f.kind==="dictionary"&&c>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(M,i={},s={}){const u=new Y(M,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function z(M,i={},s={}){const u=new Y(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,fe){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const ae=fe("packages/core/src/internal/util.js").pathGetter,Q=fe("packages/core/src/store/ingest.js"),q=Q.inferKind,te=Q.decideText,_=Q.INGEST_DEFAULTS,H=fe("packages/core/src/store/columnstore.js").toFloat,ne=new Set(["float64","int32","bitset","dictionary","object","multi"]);function x(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const z of ee)if(!z||typeof z.id!="string"||typeof z.field!="string"||z.field===""||z.kind&&!ne.has(z.kind))return!1;return!0}function ce(ee){const z=H(ee);return Number.isFinite(z)?z|0:0}function ie(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function G(ee,z,M,i){if(ee.kind)return ee.kind;const s=[];for(let c=0;c<z.length&&s.length<_.sampleSize;c++){const t=z[c];t!=null&&s.push(t)}const u=q(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function D(ee,z,M={}){const i=z.length|0,s=M.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const c=ae(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(z[r]);a[r]=n===void 0?null:n}const g=G(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,m=r=>{e&&(e[r>>3]|=1<<(r&7))};let d;switch(g){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?NaN:H(l)}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?0:ce(l)}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),!b&&l&&(r[n>>3]|=1<<(n&7))}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let b=0;b<i;b++){const E=a[b];if(E===null){r[b]=0;continue}m(b);let S=l.get(E);S===void 0&&(S=n.length,n.push(E),l.set(E,S)),r[b]=S}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),b=[];for(let E=0;E<i;E++){const S=a[E];l[E]=b.length,S===null||m(E);const U=ie(S);for(let I=0;I<U.length;I++){const X=U[I];let C=n.get(X);C===void 0&&(C=r.length,r.push(X),n.set(X,C)),b.push(C)}}l[i]=b.length,d={id:f.id,kind:g,nullable:t,values:Int32Array.from(b),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&m(n),r[n]=l}d={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(d)}return{count:i,columns:u}}function Y(ee){const z=[];if(!ee||!Array.isArray(ee.columns))return z;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!z.includes(i.buffer)&&z.push(i.buffer)};for(const i of ee.columns)M(i.values),M(i.presence),M(i.offsets);return z}}),Se("packages/core/src/compute/sortspec.js",function(o,fe){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function le(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function ae(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let F=0;F<_.length;F++)if(!ae(_[F]))return!1;return!0}function q(_,F){const H=_.col!==void 0?_.col:_.handle&&_.handle.id,ne=_.locale!==void 0?_.locale:F;return{col:H,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:le(ne)}}function te(_,F){const H=_||[],ne=new Array(H.length);for(let x=0;x<H.length;x++)ne[x]=q(H[x],F);return ne}}),Se("packages/core/src/format/date.js",function(o,fe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.isNil,Q=le.warnOnce,q=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=q.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&Q(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${q.join(" ")}.`),u+=c,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function F(M){if(ae(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=_.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",g="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+g)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function H(M,i){return String(M).padStart(i,"0")}function ne(M){if(!M)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function x(M,i,s){const u=te(M),f=ne(s),c=new Set(u.filter(m=>m.token).map(m=>m.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,g=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return m=>{const d=f(m);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=H(d.year,4);break;case"yy":r+=H(d.year%100,2);break;case"MMMM":r+=a.format(m);break;case"MMM":r+=t.format(m);break;case"MM":r+=H(d.month,2);break;case"M":r+=String(d.month);break;case"dd":r+=H(d.day,2);break;case"d":r+=String(d.day);break;case"EEEE":r+=e.format(m);break;case"EEE":r+=g.format(m);break;case"HH":r+=H(d.hour,2);break;case"H":r+=String(d.hour);break;case"hh":r+=H(d.hour%12===0?12:d.hour%12,2);break;case"h":r+=String(d.hour%12===0?12:d.hour%12);break;case"mm":r+=H(d.minute,2);break;case"m":r+=String(d.minute);break;case"ss":r+=H(d.second,2);break;case"s":r+=String(d.second);break;case"SSS":r+=H(d.ms,3);break;case"a":r+=d.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ce=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ie(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=x(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const d={timeZone:c};s.dateStyle&&(d.dateStyle=s.dateStyle),s.timeStyle&&(d.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,d);t=n=>r.format(n)}else{const d=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>d.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,m=(d,r)=>{const n=F(d);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),b=n.getTime()-l;if(Math.abs(b)<e){for(const[E,S]of ce)if(Math.abs(b)>=S||E==="second")return a.format(Math.round(b/S),E)}}return t(n)};return m.spec=s,m}function G(M){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=F(M);return f?G(f):null}const i=F(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function D(M,i){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Y.test(u)){const t=F(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,g,e]=f;return`${t}T${a}:${g}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=F(u);return c?D(c):null}const s=F(M);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(M,i){const s=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(M).reduce((e,m)=>(m.type!=="literal"&&(e[m.type]=m.value),e),{}),a=t.hour==="24"?"00":t.hour,g=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(g?`:${t.second}`:"")}catch{}const u=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function z(M,i){const s=ae(M)||M===""?null:String(M),u=ae(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,fe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return R}});const le=fe("packages/core/src/internal/util.js"),ae=le.isBlank,Q=le.toArray,q=le.warnOnce,_=fe("packages/core/src/format/date.js").toIsoDate,F=fe("packages/core/src/compute/handle.js"),H=F.bitReader,ne=F.dictSize,x=F.dictValue,ce=F.presenceReader,ie=F.valueComparator,G=F.valueReader,D=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(h,O){const w=h&&h.pool;if(w){const P=w.mask||w.acquireMask||w.acquire||w.take;if(typeof P=="function"){const v=P.call(w,O);if(v&&v.length>=O)return v}}return new Uint8Array(O)}function z(h,O){const w=h&&h.pool;if(!w||!O)return;const P=w.release||w.releaseMask||w.free||w.recycle;typeof P=="function"&&P.call(w,O)}function M(h,O,w){return h.fill(w,0,O),h}function i(h){return h==null||typeof h=="number"&&Number.isNaN(h)}function s(h,O){if(h==null)return h;if(O==="number")return typeof h=="number"?h:Number(h);if(O==="date"||O==="dateString"){const w=_(h);return w===null?u(h):w}return O==="boolean"?typeof h=="boolean"?h:h==="true"||h===1?!0:h==="false"||h===0?!1:!!h:h}function u(h){return h instanceof Date?h.getTime():typeof h=="number"?h:Date.parse(String(h))}function f(h){return typeof h=="number"?h:h instanceof Date?h.getTime():h==null||h===""?NaN:Number(h)}function c(h,O){const w=typeof h=="string"?h:String(h);return O?w:w.toLowerCase()}function t(h,O){return h==null?Y:typeof h=="string"?O?h:h.toLowerCase():h instanceof Date?h.getTime():h}function a(h,O,w){const P=new Set;for(const v of Q(h)){const K=s(v,w);P.add(t(K,O)),typeof K=="string"&&K!==""&&Number.isFinite(Number(K))?P.add(Number(K)):typeof K=="number"&&Number.isFinite(K)&&P.add(t(String(K),O))}return P}function g(h,O,w){if(h==null||O===null||O===void 0)return h==null&&O==null;const P=typeof h,v=typeof O;return P==="string"&&v==="string"?w?h===O:h.toLowerCase()===O.toLowerCase():h instanceof Date||O instanceof Date?u(h)===u(O):P==="number"&&v==="number"?h===O||Number.isNaN(h)&&Number.isNaN(O):P==="number"&&v==="string"?h===Number(O):P==="string"&&v==="number"?Number(h)===O:P==="boolean"||v==="boolean"?h===O:Array.isArray(h)&&Array.isArray(O)?h.length===O.length&&h.every((K,Z)=>g(K,O[Z],w)):h===O}function e(h,O){try{if(h instanceof RegExp){const w=h.flags.replace(/[gy]/g,"");return new RegExp(h.source,O||w.includes("i")?w:`${w}i`)}return new RegExp(String(h),O?"":"i")}catch(w){return q(`regex:${String(h)}`,`filter operator "matches" received an invalid pattern: ${String(h)}`,w),null}}function m(h,O){const w=d(h,O),P=h&&h.type;return P!=="date"&&P!=="dateString"?w:v=>w(typeof v=="string"&&D.test(v)?v:_(v)??v)}function d(h,O){const w=h&&h.op,P=!!(h&&h.caseSensitive),v=h&&h.type,K=ie(O),Z=oe=>se=>!oe(se);switch(w){case"eq":{const oe=s(h.value,v);return se=>g(se,oe,P)}case"ne":{const oe=s(h.value,v);return se=>!g(se,oe,P)}case"lt":case"lte":case"gt":case"gte":{const oe=s(h.value,v);if(i(oe))return()=>!1;const se=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return T=>{if(i(T))return!1;const L=K(T,oe);return se===-1?L<0:se===0?L<=0:se===1?L>0:L>=0}}case"between":case"notBetween":{const oe=Q(h.value),se=s(oe[0],v),T=s(oe[1],v),L=h.bounds||"[]",J=L.charAt(0)!=="(",he=L.charAt(1)!==")";if(i(se)||i(T))return w==="between"?()=>!1:()=>!0;const ye=Me=>{if(i(Me))return!1;const Pe=K(Me,se),Ne=K(Me,T);return(J?Pe>=0:Pe>0)&&(he?Ne<=0:Ne<0)};return w==="between"?ye:Z(ye)}case"in":case"notIn":{const oe=a(h.value,P,v),se=T=>oe.has(t(T,P));return w==="in"?se:Z(se)}case"contains":case"notContains":{const oe=c(s(h.value,v),P),se=T=>T==null?!1:c(T,P).includes(oe);return w==="contains"?se:Z(se)}case"startsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).startsWith(oe)}case"endsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).endsWith(oe)}case"matches":{const oe=e(h.value,P);return oe?se=>se==null?!1:oe.test(String(se)):()=>!1}case"blank":return oe=>ae(oe)||Array.isArray(oe)&&oe.length===0;case"notBlank":return oe=>!(ae(oe)||Array.isArray(oe)&&oe.length===0);case"containsAny":case"containsNone":{const oe=a(h.value,P,v),se=T=>{const L=T==null?[]:Q(T);for(let J=0;J<L.length;J++)if(oe.has(t(L[J],P)))return!0;return!1};return w==="containsAny"?se:Z(se)}case"containsAll":{const oe=Q(h.value).map(se=>t(s(se,v),P));return se=>{const T=se==null?[]:Q(se);if(oe.length===0)return!0;const L=new Set(T.map(J=>t(J,P)));for(let J=0;J<oe.length;J++)if(!L.has(oe[J]))return!1;return!0}}default:return q(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition passes every row`),()=>!0}}function r(h,O,w){return m(O,w)(h)}function n(h,O,w,P){const v=ce(h);if(v){const oe=O?1:0;for(let se=0;se<P;se++)w[se]=v(se)===oe?1:0;return w}const K=h.kind;if(K==="float64"||K==="int32"||K==="bitset")return M(w,P,O?1:0);const Z=G(h);for(let oe=0;oe<P;oe++){const se=Z(oe),T=ae(se)||Array.isArray(se)&&se.length===0;w[oe]=T===O?0:1}return w}function l(h,O,w,P){const v=h.dict,K=ne(v),Z=new Uint8Array(K);for(let L=0;L<K;L++)Z[L]=O(x(v,L))?1:0;const oe=h.values,se=ce(h);if(!se){for(let L=0;L<P;L++)w[L]=Z[oe[L]];return w}const T=O(null)?1:0;for(let L=0;L<P;L++)w[L]=se(L)===1?Z[oe[L]]:T;return w}function b(h,O,w,P){const v=H(h.values),K=O(!0)?1:0,Z=O(!1)?1:0,oe=ce(h);if(!oe){for(let T=0;T<P;T++)w[T]=v(T)===1?K:Z;return w}const se=O(null)?1:0;for(let T=0;T<P;T++)w[T]=oe(T)===0?se:v(T)===1?K:Z;return w}function E(h,O,w,P,v){const K=h.values,Z=O.type,oe=O.op;let se=!0;switch(oe){case"eq":case"ne":{const L=f(s(O.value,Z)),J=typeof O.value=="number"&&Number.isNaN(O.value),he=oe==="ne"?1:0;if(J)for(let ye=0;ye<v;ye++)P[ye]=(Number.isNaN(K[ye])?1:0)^he;else for(let ye=0;ye<v;ye++)P[ye]=(K[ye]===L?1:0)^he;break}case"lt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<L?1:0;break}case"lte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<=L?1:0;break}case"gt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>L?1:0;break}case"gte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>=L?1:0;break}case"between":case"notBetween":{const L=Q(O.value),J=f(s(L[0],Z)),he=f(s(L[1],Z)),ye=O.bounds||"[]",Me=ye.charAt(0)!=="(",Pe=ye.charAt(1)!==")",Ne=oe==="notBetween"?1:0;if(Me&&Pe)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<=he?1:0)^Ne;else if(Me)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<he?1:0)^Ne;else if(Pe)for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<=he?1:0)^Ne;else for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<he?1:0)^Ne;break}case"in":case"notIn":{const L=new Set;for(const he of Q(O.value)){const ye=f(s(he,Z));Number.isNaN(ye)||L.add(ye)}const J=oe==="notIn"?1:0;for(let he=0;he<v;he++)P[he]=(L.has(K[he])?1:0)^J;break}default:se=!1;break}if(!se)return!1;const T=ce(h);if(T){const L=w(null)?1:0;for(let J=0;J<v;J++)T(J)===0&&(P[J]=L)}return!0}function S(h,O,w,P){const v=G(h);for(let K=0;K<P;K++)w[K]=O(v(K))?1:0;return w}function V(h,O,w){const P=O.count|0,v=w||ee(O,P);if(!h)return M(v,P,1);const K=typeof O.handle=="function"?O.handle(h.col):void 0,Z=typeof O.custom=="function"?O.custom:null;if(!K){if(Z){for(let T=0;T<P;T++)v[T]=Z(h,T)?1:0;return v}return q(`filter:col:${String(h.col)}`,`filter references unknown column "${String(h.col)}"; the condition passes every row`),M(v,P,1)}const oe=h.op;if(oe==="blank"||oe==="notBlank")return n(K,oe==="notBlank",v,P);const se=m(h,O.locale);switch(K.kind){case"dictionary":return l(K,se,v,P);case"bitset":return b(K,se,v,P);case"float64":case"int32":return E(K,h,se,v,P)?v:S(K,se,v,P);default:return S(K,se,v,P)}}function U(h,O,w){if(!h)return M(ee(O,w),w,1);if(Array.isArray(h.conditions)){const P=h.conditions.filter(Z=>Z!=null),v=h.op==="or"?"or":h.op==="not"?"not":"and";if(P.length===0)return M(ee(O,w),w,1);const K=U(P[0],O,w);for(let Z=1;Z<P.length;Z++){const oe=U(P[Z],O,w);if(v==="or")for(let se=0;se<w;se++)K[se]|=oe[se];else for(let se=0;se<w;se++)K[se]&=oe[se];z(O,oe)}if(v==="not")for(let Z=0;Z<w;Z++)K[Z]^=1;return K}return V(h,O,ee(O,w))}function I(h,O){return U(h,O,O.count|0)}function X(h,O){if(!h||!O)return h||null;const w=h;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return C(w,O)?null:h;const v=[];for(const K of w.conditions){const Z=X(K,O);Z&&v.push(Z)}return v.length?{...w,op:"and",conditions:v}:null}return w.col===O?null:h}function C(h,O){if(!h||typeof h!="object")return!1;const w=h;if(w.col===O)return!0;if(Array.isArray(w.conditions)){for(const P of w.conditions)if(C(P,O))return!0}return!1}function R(h,O,w){if(w&&w.length>=O){let Z=0;for(let oe=0;oe<O;oe++)h[oe]&&(w[Z++]=oe);return w.subarray(0,Z)}let P=0;for(let Z=0;Z<O;Z++)P+=h[Z]?1:0;const v=new Uint32Array(P);let K=0;for(let Z=0;Z<O;Z++)h[Z]&&(v[K++]=Z);return v}}),Se("packages/core/src/compute/group.js",function(o,fe){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ie}});const le=fe("packages/core/src/compute/handle.js"),ae=le.dictSize,Q=le.identity,q=le.presenceReader,te=le.rowCount,_=le.valueReader,F="",H="\\0",ne=1<<20;function x(G,D,Y,ee){const z=G.length,M=G.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?M.map((t,a)=>ee[a]?g=>ee[a](t(g)):t):M;if(!i&&z>0&&G.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=G.map(g=>ae(g.dict)+1);let a=1;for(let g=0;g<z;g++)a*=t[g];if(a<=Number.MAX_SAFE_INTEGER){const g=G.map(r=>r.values),e=G.map(r=>q(r)),m=r=>{let n=0;for(let l=0;l<z;l++){const b=e[l],E=b&&b(r)===0?t[l]-1:g[l][r];n=n*t[l]+E}return n},d=new Float64Array(Y);for(let r=0;r<Y;r++)d[r]=m(D[r]);return{packed:d,strings:null,product:a,readers:s,keyOf:m}}}const f=t=>{let a="";for(let g=0;g<z;g++){const e=s[g](t);a+=(g===0?"":F)+(e==null?H:String(e))}return a},c=new Array(Y);for(let t=0;t<Y;t++)c[t]=f(D[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ce(G,D,Y,ee){const z=new Uint32Array(ee+1);for(let u=0;u<Y;u++)z[D[u]+1]++;for(let u=0;u<ee;u++)z[u+1]+=z[u];const M=new Uint32Array(Y),i=z.slice(0,ee);for(let u=0;u<Y;u++)M[i[D[u]]++]=G[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=M.subarray(z[u],z[u+1]);return s}function ie(G,D,Y={}){const ee=G||[],z=D||Q(te(ee[0],Y)),M=z.length;if(ee.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=x(ee,z,M,Y.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ne,M*4))){const d=u,r=new Int32Array(d).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<d;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<d;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const d=new Map;for(let r=0;r<M;r++){const n=i[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of d)a[n]=r}else{const d=new Map;for(let r=0;r<M;r++){const n=s[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}}const g=ce(z,c,M,t),e=new Array(t);for(let d=0;d<t;d++){const r=g[d][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[d]=n}const m={keys:e,buckets:g};return a&&(m.packed=a),m}}),Se("packages/core/src/compute/facet.js",function(o,fe){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=le.dictSize,te=le.dictValue,_=Object.freeze(["equal","quantile","log"]),F=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,ne=50,x=1e4;function ce(n,l){if(!n)return"none";const b=l&&l.base;if(b==="date"||b==="datetime"||b==="time"||b==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return b==="number"?"numeric":b==="boolean"?"boolean":b==="text"?"category":"none"}}function ie(n){const l=n.values,b=n.kind;if((b==="float64"||b==="int32")&&l)return S=>l[S];const E=Q(n);return S=>G(E(S))}function G(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const l=Number(n);if(Number.isFinite(l))return l;const b=Date.parse(n);return Number.isFinite(b)?b:NaN}return NaN}function D(n,l,b,E=ne){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:q(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=Q(n),V=l?l.length:b,U=new Set;for(let I=0;I<V;I++){const X=S(l?l[I]:I);if(X!=null&&(U.add(X),U.size>E))return{cardinality:U.size,exact:!1}}return{cardinality:U.size,exact:!0}}const Y=36e5,ee=864e5;function z(n,l=H){const b=Number.isFinite(n)&&n>0?n:0,E=Math.max(1,l)*2;return b/Y<=E?"hour":b/ee<=E?"day":b/(7*ee)<=E?"week":b/(30*ee)<=E?"month":b/(91*ee)<=E?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const b=new Date(n);switch(l){case"hour":return b.setMinutes(0,0,0),b.getTime();case"day":return b.setHours(0,0,0,0),b.getTime();case"week":{b.setHours(0,0,0,0);const E=(b.getDay()+6)%7;return b.setDate(b.getDate()-E),b.getTime()}case"month":return b.setDate(1),b.setHours(0,0,0,0),b.getTime();case"quarter":return b.setMonth(Math.floor(b.getMonth()/3)*3,1),b.setHours(0,0,0,0),b.getTime();default:return b.setMonth(0,1),b.setHours(0,0,0,0),b.getTime()}}function i(n,l){const b=new Date(n);switch(l){case"hour":b.setHours(b.getHours()+1);break;case"day":b.setDate(b.getDate()+1);break;case"week":b.setDate(b.getDate()+7);break;case"month":b.setMonth(b.getMonth()+1);break;case"quarter":b.setMonth(b.getMonth()+3);break;default:b.setFullYear(b.getFullYear()+1);break}return b.getTime()}function s(n,l,b){const E=ie(n),S=ae(n),V=l?l.length:b;let U=1/0,I=-1/0,X=0,C=0;for(let R=0;R<V;R++){const h=l?l[R]:R;if(S&&!S(h)){X++;continue}const O=E(h);if(!Number.isFinite(O)){X++;continue}O<U&&(U=O),O>I&&(I=O),C++}return{min:U,max:I,nulls:X,finite:C}}function u(n,l,b,E){const S=ie(n),V=ae(n),U=l?l.length:b,I=U>E?U/E:1,X=[];for(let R=0;R<U;R+=I){const h=l?l[Math.floor(R)]:Math.floor(R);if(V&&!V(h))continue;const O=S(h);Number.isFinite(O)&&X.push(O)}const C=Float64Array.from(X);return C.sort(),C}function f(n,l,b,E={}){const S=E.kind||ce(n,E.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,b):S==="category"?t(n,l,b,E):a(n,l,b,S,E)}function c(n,l,b){const E=ae(n);let S=0;if(E){const U=l?l.length:b;for(let I=0;I<U;I++)E(l?l[I]:I)||S++}const V=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&V.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:V}}function t(n,l,b,E){const S=E.cardinalityLimit??ne,{cardinality:V}=D(n,l,b,S);if(V>S&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:V};const U=Q(n),I=l?l.length:b,X=new Map;let C=0;for(let P=0;P<I;P++){const v=U(l?l[P]:P);if(v==null||v===""){C++;continue}if(Array.isArray(v)){if(!v.length){C++;continue}for(const K of v)X.set(K,(X.get(K)||0)+1);continue}X.set(v,(X.get(v)||0)+1)}let R=[...X.entries()];E.order==="alpha"?R.sort((P,v)=>String(P[0]).localeCompare(String(v[0]))):R.sort((P,v)=>v[1]-P[1]);let h=0,O=0;if(R.length>S){O=R.length-S;for(let P=S;P<R.length;P++)h+=R[P][1];R=R.slice(0,S)}const w=R.map(([P])=>({value:P,label:String(P)}));return h>0&&w.push({remainder:!0,label:`Other (${O} values)`}),C>0&&w.push({null:!0,label:"Empty"}),{kind:"category",buckets:w,cardinality:V}}function a(n,l,b,E,S){const{min:V,max:U,nulls:I,finite:X}=s(n,l,b);if(!X)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(S.buckets||H));let R=[];if(E==="date"){const O=F.includes(S.granularity)?S.granularity:z(U-V,C);let w=M(V,O);for(;w<=U&&R.length<4096;){const P=i(w,O);if(!(P>w))break;R.push({from:w,to:P}),w=P}return{kind:E,buckets:g(R,I),granularity:O}}const h=_.includes(S.strategy)?S.strategy:"equal";if(h==="quantile"){const O=u(n,l,b,x);if(O.length){const w=[O[0]];for(let P=1;P<C;P++){const v=O[Math.min(O.length-1,Math.floor(P/C*O.length))];v>w[w.length-1]&&w.push(v)}w.push(U);for(let P=0;P<w.length-1;P++)R.push({from:w[P],to:w[P+1]})}}else if(h==="log"&&V>0){const O=Math.log10(V),P=(Math.log10(U)-O)/C||1;for(let v=0;v<C;v++)R.push({from:10**(O+v*P),to:10**(O+(v+1)*P)})}if(!R.length){const O=(U-V)/C||1;for(let w=0;w<C;w++)R.push({from:V+w*O,to:V+(w+1)*O})}return R[R.length-1].to=U,{kind:E,buckets:g(R,I),strategy:h,min:V,max:U}}function g(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,b,E,S){const V=E&&E.buckets||[],U=S&&S.length>=V.length?S.subarray(0,V.length):new Uint32Array(V.length);if(U.fill(0),!n||!V.length)return U;const I=V.length-1,X=!!V[I]&&V[I].null===!0,C=l?l.length:b;if(E.kind==="boolean"){const P=Q(n);for(let v=0;v<C;v++){const K=P(l?l[v]:v);if(K==null){X&&U[I]++;continue}U[K?1:0]++}return U}if(E.kind==="category"){const P=new Map;for(let Z=0;Z<V.length;Z++)!V[Z].null&&!V[Z].remainder&&P.set(V[Z].value,Z);const v=V.findIndex(Z=>Z.remainder),K=Q(n);for(let Z=0;Z<C;Z++){const oe=K(l?l[Z]:Z);if(oe==null||oe===""){X&&U[I]++;continue}if(Array.isArray(oe)){if(!oe.length){X&&U[I]++;continue}for(const T of oe){const L=P.get(T);L!==void 0?U[L]++:v>=0&&U[v]++}continue}const se=P.get(oe);se!==void 0?U[se]++:v>=0&&U[v]++}return U}const R=X?V.length-1:V.length,h=new Float64Array(R+1);for(let P=0;P<R;P++)h[P]=V[P].from;h[R]=R?V[R-1].to:0;const O=ie(n),w=ae(n);for(let P=0;P<C;P++){const v=l?l[P]:P;if(w&&!w(v)){X&&U[I]++;continue}const K=O(v);if(!Number.isFinite(K)){X&&U[I]++;continue}const Z=m(h,R,K);Z>=0&&U[Z]++}return U}function m(n,l,b){if(!l||b<n[0])return-1;if(b>=n[l])return b===n[l]?l-1:-1;let E=0,S=l-1;for(;E<S;){const V=E+S+1>>>1;b>=n[V]?E=V:S=V-1}return E}function d(n,l,b,E={}){const S=E.bounds||f(n,E.boundsIndices??l,b,E);return{bounds:S,counts:e(n,l,b,S)}}const r=d}),Se("packages/core/src/compute/special.js",function(o,fe){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),ae=3e-12,Q=1e-300;function q(z){if(z<.5)return Math.log(Math.PI/Math.sin(Math.PI*z))-q(1-z);const M=z-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<le.length;u++)i+=le[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(z,M,i){const s=z+M,u=z+1,f=z-1;let c=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let g=1;g<=300;g++){const e=2*g;let m=g*(M-g)*i/((f+e)*(z+e));t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t,a*=t*c,m=-(z+g)*(s+g)*i/((z+e)*(u+e)),t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t;const d=t*c;if(a*=d,Math.abs(d-1)<ae)break}return a}function _(z,M,i){if(!(z>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(q(z+M)-q(z)-q(M)+z*Math.log(i)+M*Math.log(1-i));return i<(z+1)/(z+M+2)?s*te(z,M,i)/z:1-s*te(M,z,1-i)/M}function F(z){if(!(z>0)||!(z<1))return z===0?-1/0:z===1?1/0:Number.NaN;const M=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let c,t,a;z<f?(c=Math.sqrt(-2*Math.log(z)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):z<=1-f?(c=z-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-z)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1));const e=(.5*H(-a/Math.SQRT2)-z)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function H(z){const M=Math.abs(z),i=2/(2+M),s=4*i-2,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let f=0,c=0,t;for(let g=u.length-1;g>0;g--)t=c,c=s*c-f+u[g],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return z>=0?a:2-a}function ne(z){return .5*H(-z/Math.SQRT2)}function x(z,M){if(!(M>0)||!Number.isFinite(z))return Number.NaN;const i=.5*_(M/2,.5,M/(M+z*z));return z>0?1-i:i}function ce(z,M){if(!(z>0)||!(z<1)||!(M>0))return Number.NaN;if(M>1e7)return F(z);let i=-1e4,s=1e4,u=F(z);const f=q(M/2)+q(.5)-q((M+1)/2);for(let c=0;c<60;c++){const t=x(u,M);t<z?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),g=a>0?(t-z)/a:0;if(Math.abs(g)<1e-12)break;const e=u-g;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ie(z,M){let i=z,s=1/z,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*ae));f++);return s*Math.exp(-M+z*Math.log(M)-q(z))}function G(z,M){let i=M+1-z,s=1/Q,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-z);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<ae)break}return Math.exp(-M+z*Math.log(M)-q(z))*f}function D(z,M){return!(z>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<z+1?ie(z,M):1-G(z,M)}function Y(z,M){return M>0?D(M/2,z/2):Number.NaN}function ee(z,M){const i=Y(z,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,fe){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function le(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++)for(let ce=0;ce<=x;ce++){let ie=F[x][ce];for(let G=0;G<ce;G++)ie-=ne[x][G]*ne[ce][G];if(x===ce){if(!(ie>0))return null;ne[x][ce]=Math.sqrt(ie)}else ne[x][ce]=ie/ne[ce][ce]}return ne}function ae(F,H){const ne=F.length,x=new Array(ne).fill(0);for(let ie=0;ie<ne;ie++){let G=H[ie];for(let D=0;D<ie;D++)G-=F[ie][D]*x[D];x[ie]=G/F[ie][ie]}const ce=new Array(ne).fill(0);for(let ie=ne-1;ie>=0;ie--){let G=x[ie];for(let D=ie+1;D<ne;D++)G-=F[D][ie]*ce[D];ce[ie]=G/F[ie][ie]}return ce}function Q(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++){const ce=new Array(H).fill(0);ce[x]=1;const ie=ae(F,ce);for(let G=0;G<H;G++)ne[G][x]=ie[G]}return ne}function q(F,H,ne){const x=F.length,ce=x?F[0].length:0,ie=Array.from({length:ce},()=>new Array(ce).fill(0)),G=new Array(ce).fill(0);for(let D=0;D<x;D++){const Y=ne?ne[D]:1,ee=F[D];for(let z=0;z<ce;z++){const M=Y*ee[z];G[z]+=M*H[D];for(let i=z;i<ce;i++)ie[z][i]+=M*ee[i]}}for(let D=0;D<ce;D++)for(let Y=0;Y<D;Y++)ie[D][Y]=ie[Y][D];return{xtwx:ie,xtwy:G}}function te(F,H){return F.map(ne=>ne.reduce((x,ce,ie)=>x+ce*H[ie],0))}function _(F,H){let ne=0;for(let x=0;x<F.length;x++){let ce=0;for(let ie=0;ie<F.length;ie++)ce+=H[x][ie]*F[ie];ne+=F[x]*ce}return ne}}),Se("packages/core/src/compute/sketch.js",function(o,fe){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ie}});class le{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(D){if(!Number.isFinite(D))return;this.#t++;const Y=D-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(D-this.#e)}merge(D){if(D.#t===0)return;if(this.#t===0){this.#t=D.#t,this.#e=D.#e,this.#n=D.#n;return}const Y=this.#t+D.#t,ee=D.#e-this.#e;this.#e+=ee*(D.#t/Y),this.#n+=D.#n+ee*ee*(this.#t*D.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const D=this.variance();return D===null?null:Math.sqrt(D)}stddevP(){const D=this.varianceP();return D===null?null:Math.sqrt(D)}}class ae{#t=[];#e=0;#n;#r;constructor(D,Y=Math.random){if(!(D>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(D),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(D){if(!Number.isFinite(D))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(D);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=D)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let D=0;for(const Y of this.#t)D+=Y;return D/this.#t.length}quantile(D){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const z=(Y-1)*Math.min(1,Math.max(0,D)),M=Math.floor(z),i=Math.ceil(z);return M===i?ee[M]:ee[M]+(z-M)*(ee[i]-ee[M])}}function Q(G){return G^=G>>>16,G=Math.imul(G,2246822507),G^=G>>>13,G=Math.imul(G,3266489909),G^=G>>>15,G>>>0}function q(G){if(typeof G=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,G===0?0:G),Q(ee.getUint32(0)^ee.getUint32(4))}const D=typeof G=="string"?G:String(G);let Y=2166136261;for(let ee=0;ee<D.length;ee++)Y^=D.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class te{#t;#e;#n;constructor(D=14){const Y=Math.floor(D);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(D=14){const Y=1<<Math.floor(D),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(D){const Y=q(D),ee=Y&this.#e-1,z=Y>>>this.#t|1<<32-this.#t;let M=1,i=z;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[ee]&&(this.#n[ee]=M)}count(){const D=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<D;i++)ee[this.#n[i]]++;let z=D*H(1-ee[Y+1]/D);for(let i=Y;i>=1;i--)z=.5*(z+ee[i]);z+=D*F(ee[0]/D);const M=_*D*D/z;return Math.round(M)}}const _=.5/Math.log(2);function F(G){if(G===1)return 1/0;let D=1,Y=G,ee;do G*=G,ee=Y,Y+=G*D,D+=D;while(Y!==ee);return Y}function H(G){if(G===0||G===1)return 0;let D=1,Y=1-G,ee;do G=Math.sqrt(G),ee=Y,D*=.5,Y-=(1-G)**2*D;while(Y!==ee);return Y/3}class ne{#t=new Map;#e;#n=0;constructor(D){if(!(D>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(D)}errorBoundFor(D){const Y=D/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${D}, m=${this.#e})`})}get seen(){return this.#n}add(D){this.#n++;const Y=this.#t.get(D);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(D,{count:1,error:0});return}let ee,z=1/0;for(const[M,i]of this.#t)i.count<z&&(z=i.count,ee=M);this.#t.delete(ee),this.#t.set(D,{count:z+1,error:z})}top(D=this.#e){return[...this.#t.entries()].map(([ee,z])=>({item:ee,count:z.count,error:z.error})).sort((ee,z)=>z.count-ee.count).slice(0,Math.max(0,Math.floor(D)))}}class x{#t;#e=[[]];#n=0;#r;#i;constructor(D=200,Y=Math.random){this.#t=Math.max(8,Math.floor(D)),this.#r=Y,this.#i=2/3}static errorBoundFor(D=200){const Y=1/Math.max(8,Math.floor(D));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${D})`})}errorBound(){return x.errorBoundFor(this.#t)}get count(){return this.#n}#s(D){const ee=this.#e.length-1-D,z=Math.ceil(this.#t*this.#i**ee);return Math.max(2,z)}add(D){Number.isFinite(D)&&(this.#n++,this.#e[0].push(D),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(D){const Y=this.#e[D];Y.sort((M,i)=>M-i),D+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[D+1],z=this.#r()<.5?0:1;for(let M=z;M<Y.length;M+=2)ee.push(Y[M]);this.#e[D]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const D=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const z of this.#e[Y])D.push({v:z,w:ee})}return D}quantile(D){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const z=Math.min(1,Math.max(0,D))*ee;let M=0;for(const i of Y)if(M+=i.w,M>=z)return i.v;return Y[Y.length-1].v}rank(D){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const z=1<<ee;for(const M of this.#e[ee])M<=D&&(Y+=z)}return Y}}const ce=Object.freeze({distinct:te.errorBoundFor(14),median:x.errorBoundFor(200),p25:x.errorBoundFor(200),p75:x.errorBoundFor(200),p90:x.errorBoundFor(200),p95:x.errorBoundFor(200),p99:x.errorBoundFor(200),iqr:x.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),ie={Welford:le,Reservoir:ae,HyperLogLog:te,SpaceSaving:ne,KLL:x,hash32:q,SKETCH_BOUNDS:ce}}),Se("packages/core/src/compute/statistics.js",function(o,fe){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return it}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=fe("packages/core/src/compute/special.js"),te=q.studentTQuantile,_=q.studentT,F=q.normalQuantile,H=q.normalCdf,ne=q.chiSquareUpperTail,x=fe("packages/core/src/compute/linalg.js"),ce=x.cholesky,ie=x.choleskySolve,G=x.choleskyInverse,D=x.normalEquations,Y=x.quadForm,z=fe("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:z.distinct}),median:Object.freeze({sketch:"KLL",bound:z.median}),p25:Object.freeze({sketch:"KLL",bound:z.p25}),p75:Object.freeze({sketch:"KLL",bound:z.p75}),p90:Object.freeze({sketch:"KLL",bound:z.p90}),p95:Object.freeze({sketch:"KLL",bound:z.p95}),p99:Object.freeze({sketch:"KLL",bound:z.p99}),iqr:Object.freeze({sketch:"KLL",bound:z.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK})});function u(y){const A=y==="sum"||y==="avg"||y==="countValues"||y==="min"||y==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,y)?i[y]:null,p=Object.prototype.hasOwnProperty.call(s,y)?s[y]:null;return{stat:y,exact:A,approximate:p}}function f(y,A){const p=A.length,k=new Float64Array(p);let j=0;if(y&&(y.kind==="float64"||y.kind==="int32")){const B=y.values,$=ae(y);for(let re=0;re<p;re++){const ue=A[re];if($&&$(ue)!==1)continue;const ge=B[ue];Number.isNaN(ge)||(k[j++]=ge)}return k.subarray(0,j)}const W=Q(y);for(let B=0;B<p;B++){const $=W(A[B]);if($==null||$==="")continue;const re=typeof $=="number"?$:Number($);Number.isFinite(re)&&(k[j++]=re)}return k.subarray(0,j)}function c(y,A){const p=new Map,k=Q(y);let j=0;for(let W=0;W<A.length;W++){const B=k(A[W]);if(B==null||B===""||typeof B=="number"&&Number.isNaN(B))continue;const $=typeof B=="object"?String(B):B;p.set($,(p.get($)||0)+1),j++}const N=[...p.values()].sort((W,B)=>B-W);return{counts:N,total:j,distinct:N.length}}function t(y){return y.total>0?y.counts.map(A=>A/y.total):[]}function a(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))k+=j*j;return k}function g(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k}function e(y,A){const p=c(y,A);if(!p.total||p.distinct<2)return p.total?1:null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k/Math.log2(p.distinct)}function m(y,A,p=3){const k=c(y,A);if(!k.total)return null;const j=Math.max(1,Math.floor(p));let N=0;for(let W=0;W<Math.min(j,k.counts.length);W++)N+=k.counts[W];return N/k.total}function d(y,A){const p=f(y,A),k=p.length;if(!k)return null;const j=p.slice().sort();if(j[0]<0)return null;let N=0,W=0;for(let B=0;B<k;B++)N+=j[B],W+=(B+1)*j[B];return N===0?0:2*W/(k*N)-(k+1)/k}function r(y){let A=0,p=0,k=0;for(let j=0;j<y.length;j++){const N=y[j];A++;const W=N-p;p+=W/A,k+=W*(N-p)}return{n:A,mean:p,m2:k}}function n(y,A){const p=y.length;if(!p)return NaN;if(p===1)return y[0];const k=(p-1)*Math.min(1,Math.max(0,A)),j=Math.floor(k),N=Math.ceil(k);return j===N?y[j]:y[j]+(k-j)*(y[N]-y[j])}function l(y,A){if(!y.length)return NaN;const p=y.slice().sort();return n(p,A)}function b(y,A){const p=Q(y);let k=0,j=0,N=0;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=String(B).toUpperCase();$==="PASS"?k++:$==="FAIL"?j++:$==="WARN"&&N++}return{pass:k+N,fail:j,warn:N,judged:k+N+j}}const E=Object.freeze({hhi:(y,A)=>a(y,A),entropy:(y,A)=>g(y,A),evenness:(y,A)=>e(y,A),top3Share:(y,A)=>m(y,A,3),top10Share:(y,A)=>m(y,A,10),gini:(y,A)=>d(y,A),trimmedMean:(y,A)=>X(f(y,A),.1),winsorizedMean:(y,A)=>C(f(y,A),.1),robustOutliers:(y,A)=>R(f(y,A),3.5),jarqueBera:(y,A)=>h(f(y,A)),variance:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?k/(p-1):null},varianceP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?k/p:null},stddev:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?Math.sqrt(k/(p-1)):null},stddevP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?Math.sqrt(k/p):null},median:(y,A)=>{const p=f(y,A);return p.length?l(p,.5):null},p25:(y,A)=>{const p=f(y,A);return p.length?l(p,.25):null},p75:(y,A)=>{const p=f(y,A);return p.length?l(p,.75):null},p90:(y,A)=>{const p=f(y,A);return p.length?l(p,.9):null},p95:(y,A)=>{const p=f(y,A);return p.length?l(p,.95):null},p99:(y,A)=>{const p=f(y,A);return p.length?l(p,.99):null},iqr:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=p.slice().sort();return n(k,.75)-n(k,.25)},mad:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=l(p,.5),j=new Float64Array(p.length);for(let N=0;N<p.length;N++)j[N]=Math.abs(p[N]-k);return l(j,.5)},range:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=1/0,j=-1/0;for(let N=0;N<p.length;N++)p[N]<k&&(k=p[N]),p[N]>j&&(j=p[N]);return j-k},distinct:(y,A)=>{const p=Q(y),k=new Set;for(let j=0;j<A.length;j++){const N=p(A[j]);N==null||N===""||k.add(N instanceof Date?N.getTime():N)}return k.size},mode:(y,A)=>{const p=Q(y),k=new Map;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=B instanceof Date?B.getTime():B;k.set($,(k.get($)||0)+1)}let j=null,N=1;for(const[W,B]of k)B>N&&(N=B,j=W);return j},skewness:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<3||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let $=0;$<p.length;$++)B+=((p[$]-j)/W)**3;return k/((k-1)*(k-2))*B},kurtosis:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<4||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let ue=0;ue<p.length;ue++)B+=((p[ue]-j)/W)**4;const $=k*(k+1)/((k-1)*(k-2)*(k-3)),re=3*(k-1)**2/((k-2)*(k-3));return $*B-re},geomean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]<=0)return null;k+=Math.log(p[j])}return Math.exp(k/p.length)},harmean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]===0)return null;k+=1/p[j]}return p.length/k},sumSquares:(y,A)=>{const p=f(y,A);let k=0;for(let j=0;j<p.length;j++)k+=p[j]*p[j];return k},passRate:(y,A)=>{const{pass:p,judged:k}=b(y,A);return k?p/k:null},failureCount:(y,A)=>b(y,A).fail}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function V(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0;for(let B=0;B<p.length;B++){const $=p[B],re=Number(k($)),ue=Number(j($));!Number.isFinite(re)||!Number.isFinite(ue)||(N+=re*ue,W+=ue)}return W===0?null:N/W}function U(y,A,p){const k=Q(y);let j=null,N=p?-1/0:1/0;for(let W=0;W<A.length;W++){const B=A[W],$=Number(k(B));Number.isFinite($)&&(p?$>N:$<N)&&(N=$,j=B)}return j}function I(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0,B=0,$=0,re=0,ue=0;for(let de=0;de<p.length;de++){const we=p[de],ke=Number(k(we)),me=Number(j(we));!Number.isFinite(ke)||!Number.isFinite(me)||(N++,W+=ke,B+=me,$+=ke*ke,re+=me*me,ue+=ke*me)}if(N<2)return null;const ge=N*ue-W*B,be=Math.sqrt((N*$-W*W)*(N*re-B*B));if(be===0)return null;const pe=ge/be;return Math.max(-1,Math.min(1,pe))}function X(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort((B,$)=>B-$),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k.slice(j,p-j);if(!N.length)return n(k,.5);let W=0;for(const B of N)W+=B;return W/N.length}function C(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort(($,re)=>$-re),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k[j],W=k[p-1-j];let B=0;for(const $ of k)B+=Math.min(W,Math.max(N,$));return B/p}function R(y,A=3.5){if(!y.length)return null;const k=Array.from(y).sort(($,re)=>$-re),j=n(k,.5),N=k.map($=>Math.abs($-j)).sort(($,re)=>$-re),W=n(N,.5);if(W===0)return null;let B=0;for(const $ of k)Math.abs(.6745*($-j)/W)>A&&B++;return B}function h(y){const A=y.length;if(A<8)return null;let p=0;for(const $ of y)p+=$;p/=A;let k=0,j=0,N=0;for(const $ of y){const re=$-p;k+=re*re,j+=re*re*re,N+=re*re*re*re}if(k/=A,j/=A,N/=A,k===0)return null;const W=j/k**1.5,B=N/(k*k)-3;return A/6*(W*W+B*B/4)}function O(y,A,p){const k=[];let j=0;for(let $=0;$<y.length;$++){const re=Number(y[$]),ue=Number(A[$]);!Number.isFinite(re)||!Number.isFinite(ue)||ue<=0||(k.push([re,ue]),j+=ue)}if(!k.length||j<=0)return null;if(k.sort(($,re)=>$[0]-re[0]),k.length===1)return k[0][0];const N=[];let W=0;for(const[,$]of k)N.push((W+$/2)/j),W+=$;const B=Math.max(0,Math.min(1,p));if(B<=N[0])return k[0][0];if(B>=N[N.length-1])return k[k.length-1][0];for(let $=1;$<N.length;$++){if(B>N[$])continue;const re=N[$]-N[$-1],ue=re>0?(B-N[$-1])/re:0;return k[$-1][0]+(k[$][0]-k[$-1][0])*ue}return k[k.length-1][0]}function w(y,A,p){const k=Q(y),j=Q(A),N=new Float64Array(p.length),W=new Float64Array(p.length);let B=0;for(let $=0;$<p.length;$++){const re=p[$],ue=Number(k(re)),ge=Number(j(re));!Number.isFinite(ue)||!Number.isFinite(ge)||(N[B]=ue,W[B]=ge,B++)}return{xs:N.subarray(0,B),ys:W.subarray(0,B),n:B}}function P(y,A,p,k=!1){const{xs:j,ys:N,n:W}=w(y,A,p);if(W<2)return null;let B=0,$=0;for(let ue=0;ue<W;ue++)B+=j[ue],$+=N[ue];B/=W,$/=W;let re=0;for(let ue=0;ue<W;ue++)re+=(j[ue]-B)*(N[ue]-$);return re/(k?W:W-1)}function v(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;let W=0,B=0;for(let ke=0;ke<N;ke++)W+=k[ke],B+=j[ke];W/=N,B/=N;let $=0,re=0,ue=0;for(let ke=0;ke<N;ke++){const me=k[ke]-W,ve=j[ke]-B;$+=me*me,re+=me*ve,ue+=ve*ve}if($===0)return null;const ge=re/$,be=B-ge*W,pe=ue===0?1:Math.max(0,Math.min(1,re*re/($*ue))),de=Math.max(0,ue-ge*re),we=N>2?Math.sqrt(de/(N-2)/$):0;return{slope:ge,intercept:be,r2:pe,stdError:we,n:N}}const K=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),se=1.345;function T(y,A,p){const{xtwx:k,xtwy:j}=D(y,A,p),N=ce(k);if(!N)return null;const W=ie(N,j),B=G(N),$=L(y,W),re=A.map((ue,ge)=>ue-$[ge]);return{beta:W,cov:B,fitted:$,residuals:re}}function L(y,A){return y.map(p=>p.reduce((k,j,N)=>k+j*A[N],0))}function J(y,A){const p=y.length,k=y.map(re=>re[A]),j=y.map(re=>[1,...re.filter((ue,ge)=>ge!==A)]),N=T(j,k,null);if(!N)return 1;const W=k.reduce((re,ue)=>re+ue,0)/p;let B=0,$=0;for(let re=0;re<p;re++)B+=N.residuals[re]**2,$+=(k[re]-W)**2;return $===0?1:Math.max(0,Math.min(1,1-B/$))}function he(y){const A=[...y].sort((j,N)=>j-N),p=ye(A),k=y.map(j=>Math.abs(j-p)).sort((j,N)=>j-N);return ye(k)/.6745}function ye(y){const A=y.length;if(!A)return 0;const p=Math.floor(A/2);return A%2?y[p]:(y[p-1]+y[p])/2}function Me(y,A,p={}){const k=p.method||"ols";if(oe.has(k))throw new Error(`[lattice] regression method "${k}" is out of scope; use ols, wls or robust.`);if(Z.has(k))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(k))throw new Error(`[lattice] unknown regression method "${k}"; use ols, wls or robust.`);const j=Array.isArray(A)?A.length:0,N=j&&Array.isArray(y[0])?y[0].length:0,W=N+1;if(!(j>W))return null;for(let Oe=0;Oe<j;Oe++){if(!Number.isFinite(A[Oe])||!Array.isArray(y[Oe])||y[Oe].length!==N)return null;for(let Ae=0;Ae<N;Ae++)if(!Number.isFinite(y[Oe][Ae]))return null}let B=null;if(k==="wls"){if(B=p.weights,!Array.isArray(B)||B.length!==j)return null;for(let Oe=0;Oe<j;Oe++)if(!(B[Oe]>0)||!Number.isFinite(B[Oe]))return null}const $=y.map(Oe=>[1,...Oe]);let re,ue=null;if(k==="robust"){if(re=T($,A,null),!re)return null;for(let Oe=0;Oe<50;Oe++){const Ae=he(re.residuals);if(!(Ae>0))break;const Te=re.residuals.map(Ie=>{const Be=Math.abs(Ie/Ae);return Be<=se?1:se/Be}),Re=T($,A,Te);if(!Re)return null;const ze=Re.beta.reduce((Ie,Be,Qe)=>Math.max(Ie,Math.abs(Be-re.beta[Qe])),0);if(re=Re,ue=Te,ze<1e-10)break}}else if(re=T($,A,B),!re)return null;const ge=k==="robust"?ue:B,{beta:be,cov:pe,fitted:de,residuals:we}=re;let ke=0,me=0,ve=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;ke+=Ae*we[Oe]**2,me+=Ae,ve+=Ae*A[Oe]}const Ee=ve/me;let Le=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;Le+=Ae*(A[Oe]-Ee)**2}const Fe=j-W,De=ke/Fe,Ce=Le===0?1:Math.max(0,Math.min(1,1-ke/Le)),_e=1-(1-Ce)*(j-1)/Fe,Ge=Array.isArray(p.names)&&p.names.length===N?p.names:y[0].map((Oe,Ae)=>`x${Ae+1}`),Ue=He(p.confidence),Ye=Fe>0?te(1-(1-Ue)/2,Fe):1/0,Lt=be.map((Oe,Ae)=>{const Te=Math.sqrt(Math.max(0,De*pe[Ae][Ae])),Re=Te>0?Oe/Te:Oe===0?0:1/0,ze=Number.isFinite(Re)?2*(1-_(Math.abs(Re),Fe)):0,Ie=Number.isFinite(Ye)?Ye*Te:null;return{name:Ae===0?"(intercept)":Ge[Ae-1],estimate:Oe,stdError:Te,t:Re,p:Math.max(0,Math.min(1,ze)),lower:Ie===null?null:Oe-Ie,upper:Ie===null?null:Oe+Ie}}),ft=new Array(j),ht=new Array(j);for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1,Te=Math.max(0,Math.min(1,Ae*Y($[Oe],pe)));ft[Oe]=Te;const Re=(1-Te)**2;ht[Oe]=Re>0&&De>0?we[Oe]**2/(W*De)*(Te/Re):null}const Ft=y[0].map((Oe,Ae)=>{if(N<2)return 1;const Te=J(y,Ae);return Te>=1?1/0:1/(1-Te)});let dt=null;{const Oe=we.map(Te=>Te*Te),Ae=T($,Oe,null);if(Ae){const Te=Oe.reduce((Ke,Ct)=>Ke+Ct,0)/j;let Re=0,ze=0;for(let Ke=0;Ke<j;Ke++)Re+=Ae.residuals[Ke]**2,ze+=(Oe[Ke]-Te)**2;const Ie=ze===0?0:Math.max(0,Math.min(1,1-Re/ze)),Be=j*Ie,Qe=ne(Be,N);dt={statistic:Be,df:N,p:Qe,heteroscedastic:Qe<.05}}}let mt=null;if(N===1){const Oe=y.map((Ae,Te)=>Te).sort((Ae,Te)=>y[Ae][0]-y[Te][0]);mt={confidence:Ue,points:Oe.map(Ae=>{const Te=$[Ae],Re=Math.sqrt(Math.max(0,De*Y(Te,pe)));return{x:y[Ae][0],yhat:de[Ae],lower:de[Ae]-Ye*Re,upper:de[Ae]+Ye*Re}})}}return{method:k,coefficients:Lt,r2:Ce,adjR2:_e,n:j,df:Fe,sigma2:De,fitted:de,residuals:we,leverage:ft,cooksD:ht,vif:Ft,heteroscedasticity:dt,band:mt,weights:ge?[...ge]:null}}function Pe(y){const A=y.length,p=Array.from({length:A},(N,W)=>W).sort((N,W)=>y[N]-y[W]),k=new Float64Array(A);let j=0;for(;j<A;){let N=j;for(;N+1<A&&y[p[N+1]]===y[p[j]];)N++;const W=(j+N)/2+1;for(let B=j;B<=N;B++)k[p[B]]=W;j=N+1}return k}const Ne=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(y){const A=[.01,.05,.1],p=[Ne["1%"],Ne["5%"],Ne["10%"]];if(y<=p[0]){const N=(Math.log(A[1])-Math.log(A[0]))/(p[1]-p[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(A[0])+N*(y-p[0]))))}if(y>=p[2]){const N=(Math.log(A[2])-Math.log(A[1]))/(p[2]-p[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(A[2])+N*(y-p[2]))))}const k=y<p[1]?0:1,j=(y-p[k])/(p[k+1]-p[k]);return Math.exp(Math.log(A[k])+j*(Math.log(A[k+1])-Math.log(A[k])))}function Ve(y,A,p,k){const j=p-k,N=k+3,W=new Array(j),B=new Array(j);let $=!0,re=k;for(let de=0;de<j;de++){const we=k+de,ke=new Float64Array(N);ke[0]=1,ke[1]=de+1,ke[2]=y[we];for(let me=1;me<=k;me++)ke[2+me]=A[we-me];for(let me=1;me<N;me++)Number.isFinite(ke[me])||(re=Math.min(re,me-3));W[de]=ke,B[de]=A[we],Number.isFinite(B[de])||($=!1)}if(!$)return 0;const{xtwx:ue,xtwy:ge}=D(W,B,null);let be=0,pe=1/0;for(let de=0;de<=re;de++){const we=de+3;if(!(j>we))continue;const ke=new Array(we);for(let Ce=0;Ce<we;Ce++)ke[Ce]=ue[Ce].slice(0,we);const me=ce(ke);if(!me)continue;const ve=ie(me,ge.slice(0,we));let Ee=0;for(let Ce=0;Ce<j;Ce++){const _e=W[Ce];let Ge=0;for(let Ue=0;Ue<we;Ue++)Ge+=_e[Ue]*ve[Ue];Ee+=(B[Ce]-Ge)**2}const Fe=Ee/(j-we)*(j-we);if(!(Fe>0))continue;const De=j*Math.log(Fe/j)+2*we;De<pe&&(pe=De,be=de)}return be}function We(y,A={}){const p=[];for(let pe=0;pe<y.length;pe++){const de=Number(y[pe]);Number.isFinite(de)&&p.push(de)}const k=p.length,j=k-1;if(k<8||j<6)return null;const N=new Array(j);for(let pe=0;pe<j;pe++)N[pe]=p[pe+1]-p[pe];let W=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.ceil(12*(k/100)**.25);W=Math.max(0,Math.min(W,Math.floor((j-5)/2)));const B=(pe,de)=>{const we=[],ke=[];for(let me=de;me<j;me++){const ve=[me-de+1,p[me]];for(let Ee=1;Ee<=pe;Ee++)ve.push(N[me-Ee]);we.push(ve),ke.push(N[me])}return Me(we,ke,{method:"ols"})},$=Ve(p,N,j,W),re=B($,$);if(!re||!re.coefficients[2])return null;const ue=re.coefficients[2].t,ge=je(ue),be=ue<Ne["5%"];return{statistic:ue,usedLag:$,nobs:j-$,criticalValues:{...Ne},pValue:ge,pApproximate:!0,stationary:be,verdict:be?"stationary":"non-stationary",regression:"ct"}}function Xe(y,A={}){const p=[];for(let be=0;be<y.length;be++){const pe=Number(y[be]);Number.isFinite(pe)&&p.push(pe)}const k=p.length;if(k<3)return null;let j=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.min(10,k-1);j=Math.max(1,Math.min(j,k-1));let N=0;for(const be of p)N+=be;N/=k;const W=p.map(be=>be-N);let B=0;for(const be of W)B+=be*be;B/=k;const $=new Array(j+1).fill(0);$[0]=1;for(let be=1;be<=j;be++){let pe=0;for(let de=be;de<k;de++)pe+=W[de]*W[de-be];$[be]=B>0?pe/k/B:0}const re=new Array(j+1).fill(0);re[0]=1;let ue=[];for(let be=1;be<=j;be++){let pe=$[be];for(let me=1;me<be;me++)pe-=ue[me-1]*$[be-me];let de=1;for(let me=1;me<be;me++)de-=ue[me-1]*$[me];const we=de!==0?pe/de:0,ke=new Array(be);for(let me=1;me<be;me++)ke[me-1]=ue[me-1]-we*ue[be-1-me];ke[be-1]=we,re[be]=we,ue=ke}const ge=1.96/Math.sqrt(k);return{acf:$,pacf:re,bounds:{upper:ge,lower:-ge},n:k,nlags:j,approximate:!0}}function qe(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;const W=Pe(k),B=Pe(j);let $=0,re=0;for(let pe=0;pe<N;pe++)$+=W[pe],re+=B[pe];$/=N,re/=N;let ue=0,ge=0,be=0;for(let pe=0;pe<N;pe++){const de=W[pe]-$,we=B[pe]-re;ue+=de*we,ge+=de*de,be+=we*we}return ge===0||be===0?null:Math.max(-1,Math.min(1,ue/Math.sqrt(ge*be)))}function yt(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2||N>M)return null;let W=0,B=0,$=0,re=0;for(let be=0;be<N;be++)for(let pe=be+1;pe<N;pe++){const de=Math.sign(k[be]-k[pe]),we=Math.sign(j[be]-j[pe]),ke=de*we;ke>0?W++:ke<0?B++:de===0&&we===0||(de===0?$++:re++)}const ue=W+B+re,ge=W+B+$;return ue===0||ge===0?null:(W-B)/Math.sqrt(ue*ge)}function pt(y,A={}){const p=y.length;if(p<2)return null;const k=y[0],j=y[p-1],N=[];for(let me=1;me<p;me++){const ve=y[me-1];ve!==0&&N.push((y[me]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let me=0;for(const Ee of N)me+=Ee;me/=N.length;let ve=0;for(const Ee of N)ve+=(Ee-me)**2;W=Math.sqrt(ve/(N.length-1))}const B=Number(A.periodsPerYear)>0?Number(A.periodsPerYear):null;let $=y[0],re=0,ue=0,ge=0,be=0;for(let me=1;me<p;me++){if(y[me]>$){$=y[me],re=me;continue}if($<=0)continue;const ve=($-y[me])/$;ve>ue&&(ue=ve,ge=re,be=me)}let pe=null;if(p>2){let me=0;for(let Le=0;Le<p;Le++)me+=y[Le];me/=p;let ve=0,Ee=0;for(let Le=0;Le<p;Le++){const Fe=y[Le]-me;Ee+=Fe*Fe,Le>0&&(ve+=Fe*(y[Le-1]-me))}pe=Ee>0?ve/Ee:null}let de=0,we=0;for(const me of N)me>0?de++:me<0&&we++;let ke=null;if(k>0&&j>0){const me=(j/k)**(1/(p-1))-1;ke=B?(1+me)**B-1:me}return{n:p,first:k,last:j,change:j-k,changePercent:k===0?null:(j-k)/Math.abs(k)*100,volatility:W,annualisedVolatility:W!==null&&B?W*Math.sqrt(B):null,growth:ke,maxDrawdown:ue,maxDrawdownFrom:ge,maxDrawdownTo:be,autocorrelation:pe,upDays:de,downDays:we}}const rt=1.128,it=3.267;function wt(y){const A=y.length;if(A<2)return null;const p=[];for(let j=1;j<A;j++)p.push(Math.abs(y[j]-y[j-1]));const k=p.reduce((j,N)=>j+N,0)/p.length;return{ranges:p,centre:k,upper:it*k,lower:0}}function Ze(y){const A=y.length;if(A<2)return null;let p=0;for(let j=1;j<A;j++)p+=Math.abs(y[j]-y[j-1]);const k=p/(A-1);return{sigma:k/rt,meanRange:k}}function Ot(y,A){const p=y.length;if(p<2||!A)return null;const k=Number.isFinite(Number(A.lower))?Number(A.lower):null,j=Number.isFinite(Number(A.upper))?Number(A.upper):null;if(k===null&&j===null)return null;let N=0;for(let de=0;de<p;de++)N+=y[de];N/=p;let W=0;for(let de=0;de<p;de++)W+=(y[de]-N)**2;const B=Math.sqrt(W/(p-1)),$=Ze(y),re=$?$.sigma:null,ue=de=>{if(!de||de<=0)return{index:null,k:null};const ke=k!==null&&j!==null?(j-k)/(6*de):null,me=j!==null?(j-N)/(3*de):1/0,ve=k!==null?(N-k)/(3*de):1/0;return{index:ke,k:Math.min(me,ve)}},ge=ue(re),be=ue(B);let pe=0;for(let de=0;de<p;de++){if(k!==null&&y[de]<k){pe++;continue}j!==null&&y[de]>j&&pe++}return{n:p,mean:N,lower:k,upper:j,target:Number.isFinite(Number(A.target))?Number(A.target):null,sigmaWithin:re,sigmaOverall:B,cp:ge.index,cpk:ge.k,pp:be.index,ppk:be.k,outOfSpec:pe,defectRate:p?pe/p:null}}function kt(y){const A=y.length;if(A<2)return null;const p=Ze(y);if(!p||!(p.sigma>0))return null;let k=0;for(let j=0;j<A;j++)k+=y[j];return k/=A,{centre:k,sigma:p.sigma,upper:k+3*p.sigma,lower:k-3*p.sigma}}function ot(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=B=>(y[B]-k)/j,W=[];for(let B=0;B<p;B++){if(Math.abs(N(B))>3&&W.push({index:B,rule:1,description:"beyond three sigma"}),B>=2)for(const $ of[1,-1]){let re=0;for(let ue=B-2;ue<=B;ue++)N(ue)*$>2&&re++;if(re>=2){W.push({index:B,rule:2,description:"two of three past two sigma"});break}}if(B>=4)for(const $ of[1,-1]){let re=0;for(let ue=B-4;ue<=B;ue++)N(ue)*$>1&&re++;if(re>=4){W.push({index:B,rule:3,description:"four of five past one sigma"});break}}if(B>=7)for(const $ of[1,-1]){let re=!0;for(let ue=B-7;ue<=B;ue++)if(N(ue)*$<=0){re=!1;break}if(re){W.push({index:B,rule:4,description:"eight in a row on one side"});break}}}return W}function st(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=$=>(y[$]-k)/j,W=($,re,ue,ge)=>{for(const be of[1,-1]){let pe=0;for(let de=$;de<=re;de++)N(de)*be>ue&&pe++;if(pe>=ge)return!0}return!1},B=[];for(let $=0;$<p;$++){if(Math.abs(N($))>3&&B.push({index:$,rule:1,description:"beyond three sigma"}),$>=8)for(const re of[1,-1]){let ue=!0;for(let ge=$-8;ge<=$;ge++)if(N(ge)*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:2,description:"nine in a row on one side"});break}}if($>=5)for(const re of[1,-1]){let ue=!0;for(let ge=$-4;ge<=$;ge++)if((y[ge]-y[ge-1])*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:3,description:re>0?"six rising":"six falling"});break}}if($>=13){let re=!0;for(let ue=$-12;ue<=$;ue++){const ge=y[ue]-y[ue-1],be=y[ue+1<=$?ue+1:ue]-y[ue];if(ue+1>$)break;if(ge===0||be===0||ge>0==be>0){re=!1;break}}re&&B.push({index:$,rule:4,description:"fourteen alternating"})}if($>=2&&W($-2,$,2,2)&&B.push({index:$,rule:5,description:"two of three past two sigma"}),$>=4&&W($-4,$,1,4)&&B.push({index:$,rule:6,description:"four of five past one sigma"}),$>=14){let re=!0;for(let ue=$-14;ue<=$;ue++)if(Math.abs(N(ue))>=1){re=!1;break}re&&B.push({index:$,rule:7,description:"fifteen within one sigma"})}if($>=7){let re=!0;for(let ue=$-7;ue<=$;ue++)if(Math.abs(N(ue))<=1){re=!1;break}re&&B.push({index:$,rule:8,description:"eight beyond one sigma"})}}return B}const jt=Object.freeze(["westernElectric","nelson"]);function At(y,A,p="westernElectric"){return String(p)==="nelson"?st(y,A):ot(y,A)}function Mt(y,A,p){let k=0;for(let j=0;j<y.length;j++)(y[j]<A||y[j]>p)&&k++;return k}function Pt(y,A,p,k=20){const j=y.length;if(!j)return[];const N=y[0],W=y[j-1];if(W===N)return[{from:N,to:W,count:j}];const B=p-A,$=1.5*B;let re=B>0?Math.max(N,A-$):N,ue=B>0?Math.min(W,p+$):W;ue>re||(re=N,ue=W);const ge=B>0?2*B/Math.cbrt(j):(ue-re)/(Math.ceil(Math.log2(j))+1),be=ge>0?Math.min(k,Math.max(1,Math.ceil((ue-re)/ge))):1,pe=(ue-re)/be,de=[];for(let we=0;we<be;we++)de.push({from:re+we*pe,to:re+(we+1)*pe,count:0});for(let we=0;we<j;we++){const ke=Math.min(be-1,Math.max(0,Math.floor((y[we]-re)/pe)));de[ke].count++}return de[0].from=N,de[be-1].to=W,de}const $e=.95;function He(y){const A=Number(y);return Number.isFinite(A)&&A>0&&A<1?A:$e}function Nt(y,A=$e){const p=y.length;if(p<2)return null;let k=0;for(let ue=0;ue<p;ue++)k+=y[ue];const j=k/p;let N=0;for(let ue=0;ue<p;ue++){const ge=y[ue]-j;N+=ge*ge}const W=Math.sqrt(N/(p-1)),B=He(A),re=te(1-(1-B)/2,p-1)*W/Math.sqrt(p);return{mean:j,lower:j-re,upper:j+re,margin:re,n:p,confidence:B}}function St(y,A,p=$e){const k=Number(y),j=Number(A);if(!(j>0)||!(k>=0)||k>j)return null;const N=He(p),W=F(1-(1-N)/2),B=k/j,$=W*W,re=1+$/j,ue=(B+$/(2*j))/re,ge=W/re*Math.sqrt(B*(1-B)/j+$/(4*j*j));return{proportion:B,lower:Math.max(0,ue-ge),upper:Math.min(1,ue+ge),n:j,confidence:N}}function vt(y,A=$e){if(!y||!(y.n>2)||!Number.isFinite(y.stdError))return null;const p=He(A),j=te(1-(1-p)/2,y.n-2)*y.stdError;return{slope:y.slope,lower:y.slope-j,upper:y.slope+j,margin:j,confidence:p}}function Tt(y,A,p=$e){const k=Number(y),j=Number(A);if(!Number.isFinite(k)||!(j>1))return null;const N=He(p),B=F(1-(1-N)/2)*Math.sqrt(1/(9*j)+k*k/(2*(j-1)));return{index:k,lower:k-B,upper:k+B,margin:B,n:j,confidence:N}}function ut(y,A){return!y||!(y.sd>0)||!Number.isFinite(A)||!Number.isFinite(y.mean)?null:(A-y.mean)/y.sd}function ct(y){return Number.isFinite(y)?Math.min(1,Math.max(0,2*H(Math.abs(y)/2)-1)):0}function Je(y,A){const p=new Map,k=Q(y);let j=0;for(let N=0;N<A.length;N++){const W=k(A[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const B=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;p.set(B,(p.get(B)||0)+1),j++}return{map:p,total:j}}function lt(y,A,p,k){if(!(A>0)||!(k>0))return null;let j=0;const N=new Set(y.keys());for(const W of p.keys())N.add(W);for(const W of N){const B=(y.get(W)||0)/A,$=(p.get(W)||0)/k;j+=Math.abs(B-$)}return j/2}const xe=10;function Et(y,A,p){if(p&&p.numeric){const B=f(y,A),{n:$,mean:re}=r(B),ue=$>0?ut({mean:p.mean,sd:p.sd},re):null;return{measure:"standardizedMeanDifference",magnitude:ue,distance:ue===null?0:ct(ue),direction:ue===null?0:Math.sign(ue),subsetN:$,populationN:p.n||0,reliable:$>=xe}}const{map:j,total:N}=Je(y,A),W=lt(j,N,p.map,p.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:p.total||0,reliable:N>=xe}}function at(y,A){if(y&&(y.kind==="float64"||y.kind==="int32"))return!0;const p=Q(y);let k=0,j=0;for(let N=0;N<A.length&&k<200;N++){const W=p(A[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;k++;const B=typeof W=="number"?W:Number(W);Number.isFinite(B)&&j++}return k===0?!1:j/k>=.9}function Rt(y,A){if(at(y,A)){const j=f(y,A),{n:N,mean:W,m2:B}=r(j);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(B/N):0,n:N}}const{map:p,total:k}=Je(y,A);return{numeric:!1,map:p,total:k}}}),Se("packages/core/src/compute/total.js",function(o,fe){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return d}});const le=fe("packages/core/src/internal/util.js"),ae=le.isFunction,Q=le.warnOnce,q=fe("packages/core/src/compute/handle.js"),te=q.presenceReader,_=q.valueComparator,F=q.valueReader,H=fe("packages/core/src/compute/statistics.js"),ne=H.STAT_FNS,x=H.STAT_LABELS;function ce(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ie(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++){const I=S[n[U]];Number.isNaN(I)||(b+=I)}return b}for(let U=0;U<l;U++){const I=n[U];if(V(I)===1){const X=S[I];Number.isNaN(X)||(b+=X)}}return b}const E=F(r);for(let S=0;S<l;S++){const V=u(E(n[S]));V!==null&&(b+=V)}return b}ie.kernel=!0;function G(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++)Number.isNaN(S[n[U]])||b++;return b}for(let U=0;U<l;U++){const I=n[U];V(I)===1&&!Number.isNaN(S[I])&&b++}return b}const E=F(r);for(let S=0;S<l;S++){const V=E(n[S]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&b++}return b}G.kernel=!0;function D(r,n){return n.length}D.kernel=!0;function Y(r,n){const l=G(r,n);return l===0?null:ie(r,n)/l}Y.kernel=!0;function ee(r,n,l,b){const E=n.length;if(ce(r)){const I=r.values,X=te(r);let C=null;if(!X){for(let R=0;R<E;R++){const h=I[n[R]];Number.isNaN(h)||(C===null||(l<0?h<C:h>C))&&(C=h)}return C}for(let R=0;R<E;R++){const h=n[R];if(X(h)===0)continue;const O=I[h];Number.isNaN(O)||(C===null||(l<0?O<C:O>C))&&(C=O)}return C}const S=F(r),V=_(b);let U=null;for(let I=0;I<E;I++){const X=S(n[I]);X==null||typeof X=="number"&&Number.isNaN(X)||(U===null||(l<0?V(X,U)<0:V(X,U)>0))&&(U=X)}return U}function z(r,n,l){return ee(r,n,-1,l&&l.locale)}z.kernel=!0;function M(r,n,l){return ee(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:F(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:F(r)(n[n.length-1])}s.kernel=!0;function u(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const f={sum:ie,min:z,max:M,avg:Y,count:D,first:i,last:s,countValues:G,...ne},c=Object.freeze({...x,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?c[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function g(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(b=>b in f);for(const b of Object.keys(f))l.includes(b)||l.push(b);return l}function e(r,n){return typeof n!="string"?!0:g(r).includes(n)}function m(r,n){const l=F(r),b=[];for(let E=0;E<n.length;E++){const S=l(n[E]);S!=null&&b.push(S)}return b}function d(r,n,l,b){const E=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,E,b):(Q(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return ae(l)?l.kernel===!0?l(r,E,b):l(m(r,E),b||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,fe){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/internal/util.js").warnOnce,q=fe("packages/core/src/compute/handle.js").valueComparator,_=fe("packages/core/src/compute/group.js").packKeys,H=fe("packages/core/src/compute/total.js").total,ne="|",x="/",ce=2e3;function ie(u,f,c){return`${u}${ne}${f}${ne}${c}`}function G(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function D(u,f,c={}){const t=c.separator||x,a=f.length,{keyOf:g,readers:e}=_(u,f,0),m=new Map,d=[],r=[];for(let U=0;U<a;U++){const I=f[U],X=g(I);if(m.has(X))continue;m.set(X,d.length),r.push(X);const C=new Array(e.length);for(let R=0;R<e.length;R++)C[R]=e[R](I);d.push(C)}const n=q(c.locale),l=d.map((U,I)=>I);l.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=Y(X[R],C[R],n);if(h!==0)return h}return U-I});const b=new Array(l.length),E=new Array(l.length),S=new Map;for(let U=0;U<l.length;U++){const I=l[U];b[U]=d[I],E[U]=G(d[I],t),S.set(r[I],U)}return{keys:b,paths:E,idOf:U=>{const I=S.get(g(U));return I===void 0?-1:I}}}function Y(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(g=>g&&g.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&ae("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const g of f){const e=c(g);e&&a.push({colId:g,handle:e,fn:t?t(g):"sum"})}return a}function z(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=z(u,f,c),a=t.separator||x,g=ee(t),e=t.maxColumns===void 0?ce:t.maxColumns,m=t.groups&&t.groups.buckets?t.groups:null,d=m?m.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(m?m.keys.map(X=>G(X,a)):[""]),n=s(d),{keys:l,paths:b,idOf:E}=D(t.pivotHandles||[],n,t),S=b.length*Math.max(1,g.length),V=i(b,g,a);if(e&&S>e){const X=new Map;return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const U=new Map,I=b.length;for(let X=0;X<d.length;X++){const C=d[X],R=r[X]===void 0?"":r[X],h=C.length;if(h===0)continue;const O=new Int32Array(h),w=new Uint32Array(I+1);for(let K=0;K<h;K++){const Z=E(C[K]);O[K]=Z,Z>=0&&w[Z+1]++}for(let K=0;K<I;K++)w[K+1]+=w[K];const P=new Uint32Array(h),v=w.slice(0,I);for(let K=0;K<h;K++){const Z=O[K];Z>=0&&(P[v[Z]++]=C[K])}for(let K=0;K<I;K++){const Z=w[K],oe=w[K+1];if(oe===Z)continue;const se=P.subarray(Z,oe);for(let T=0;T<g.length;T++){const L=g[T],J=H(L.handle,se,L.fn,t.totalContext||{locale:t.locale});U.set(ie(R,b[K],L.colId),J)}}}return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:U,cells:U,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const g of f)t.push(`${a}${c}${g.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,fe){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/compute/handle.js").valueComparator,q=fe("packages/core/src/compute/total.js").total,_=fe("packages/core/src/compute/group.js").packKeys,F=fe("packages/core/src/compute/pivot.js"),H=F.joinPath,ne=F.DEFAULT_PATH_SEPARATOR,x=F.DEFAULT_MAX_COLUMNS,ce="";function ie(i,s,u={}){const f=u.separator||ne,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ce],buckets:[t]};const{keyOf:g,readers:e}=_(c,t,0),m=new Map,d=[],r=[],n=[];for(let U=0;U<a;U++){const I=t[U],X=g(I);let C=m.get(X);if(C===void 0){C=d.length,m.set(X,C),r.push(X);const R=new Array(e.length);for(let h=0;h<e.length;h++)R[h]=e[h](I);d.push(R),n.push([])}n[C].push(I)}const l=ae(u.locale),b=d.map((U,I)=>I);b.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=G(X[R],C[R],l);if(h!==0)return h}return U-I});const E=new Array(b.length),S=new Array(b.length),V=new Array(b.length);for(let U=0;U<b.length;U++){const I=b[U];E[U]=d[I],S[U]=H(d[I],f),V[U]=Uint32Array.from(n[I])}return{tuples:E,paths:S,buckets:V}}function G(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function D(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?q(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ne,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ie(i.rowHandles||[],t,{...s,separator:u}),g=ie(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?x:s.maxColumns,m=g.paths.length*Math.max(1,c.length),d=new Map;if(e&&m>e)return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:e}};const r=new Map,n=new Map,l=new Map,b=new Map,E=g.buckets.map(S=>new Set(S));for(let S=0;S<g.paths.length;S++){const V=g.buckets[S],U=g.paths[S];for(const I of c)l.set(M(U,I.colId),Y(I.handle,V,I.fn,f))}for(let S=0;S<a.paths.length;S++){const V=a.buckets[S],U=a.paths[S];for(const I of c)n.set(M(U,I.colId),Y(I.handle,V,I.fn,f));for(let I=0;I<g.paths.length;I++){const X=D(V,g.buckets[I],E[I]);if(X.length===0)continue;const C=g.paths[I];for(const R of c)r.set(z(U,C,R.colId),Y(R.handle,X,R.fn,f))}}for(const S of c)b.set(S.colId,Y(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:b,columns:m,error:null}}function z(i,s,u){return`${i}\\0${s}\\0${u}`}function M(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,fe){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const ae=fe("packages/core/src/internal/util.js").getPath,Q=fe("packages/core/src/compute/handle.js"),q=Q.isMissing,te=Q.valueComparator,F=fe("packages/core/src/compute/filter.js").testValue,H="",ne="\\0";function x(i,s){const u=s.includes(".")?ae(i,s):i?.[s];return u===void 0?null:u}function ce(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=ie(i,c,f[t],u);return c}function ie(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),a=u.descending!==void 0?!!u.descending:u.dir==="desc",g=[],e=[];for(const r of s){const n=x(i[r],u.col);q(n)?e.push(r):g.push(r)}const m=new Map;for(let r=0;r<g.length;r++)m.set(g[r],r);const d=(r,n)=>{const l=x(i[r],u.col),b=x(i[n],u.col);let E;return typeof u.compare=="function"?(E=u.compare(l,b,i[r],i[n],a),a&&(E=-E)):E=a?t(b,l):t(l,b),E!==0?E:m.get(r)-m.get(n)};return g.sort(d),u.nullsFirst?e.concat(g):g.concat(e)}function G(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)D(i[c],s,u,c)&&f.push(c);return f}function D(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>D(i,a,u,f));const t=c.every(a=>D(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):F(x(i,s.col),s,u.locale)}function Y(i,s,u,f){const c=u||i.map((e,m)=>m),t=new Map,a=[],g=[];for(const e of c){const m=s.map((n,l)=>{const b=x(i[e],n);return f&&f[l]?f[l](b):b}),d=m.map(n=>n==null?ne:String(n)).join(H);let r=t.get(d);r===void 0&&(r=a.length,t.set(d,r),a.push(m),g.push([])),g[r].push(e)}return{keys:a,buckets:g}}function ee(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!q(a)),t=c.map(z).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,g)=>a+g,0);case"avg":return c.length===0?null:t.reduce((a,g)=>a+g,0)/c.length;case"min":return c.length===0?null:c.reduce((a,g)=>f(g,a)<0?g:a);case"max":return c.length===0?null:c.reduce((a,g)=>f(g,a)>0?g:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(i[i.length-1]);default:return null}}function z(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function M(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,fe){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const ae=fe("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(H,ne=0,x=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(ne>0))throw new RangeError(`a ${H} window needs a positive span`);this.#t=H,this.#e=Math.floor(ne),this.#r=x,this.#i=x()}get size(){return this.#n.length}push(H,ne=this.#r()){Number.isFinite(H)&&(this.#n.push({t:ne,v:H}),this.#s(ne))}#s(H){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ne=H-this.#e;for(;this.#n.length&&this.#n[0].t<ne;)this.#n.shift()}}spec(){const H=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ne=new ae;let x=0,ce=1/0,ie=-1/0;for(const{v:G}of this.#n)x+=G,G<ce&&(ce=G),G>ie&&(ie=G),ne.add(G);return{over:H,count:this.#n.length,sum:x,mean:ne.mean(),min:ce,max:ie,variance:ne.variance(),stddev:ne.stddev()}}reduce(H){const ne=this.aggregate(),x={sum:ne.sum,avg:ne.mean,mean:ne.mean,min:ne.min,max:ne.max,count:ne.count,variance:ne.variance,stddev:ne.stddev};if(!(H in x))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:x[H],over:ne.over}}}const q=Object.freeze(["count","time","session"]);function te(F,H=Date.now){const ne=F.kind==="time"&&F.minutes!=null?F.minutes*6e4:F.span??0;return new Q(F.kind,ne,H)}const _={Window:Q,WINDOW_KINDS:q,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,fe){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const ae=fe("packages/core/src/compute/statistics.js").quantileSorted,q=fe("packages/core/src/compute/special.js").logGamma,te=.6745,_=3.5,F=1.5,H=.975,ne=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function x(c){if(!c.length)return null;const a=Array.from(c,Number).sort((d,r)=>d-r),g=ae(a,.5),e=a.map(d=>Math.abs(d-g)).sort((d,r)=>d-r),m=ae(e,.5);return{median:g,mad:m}}function ce(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,g=c.length,e=new Array(g).fill(null),m=new Array(g).fill(!1),d=[];for(let l=0;l<g;l++){const b=Number(c[l]);Number.isFinite(b)&&d.push(b)}if(!d.length)return{median:null,mad:null,threshold:a,scores:e,flags:m,flagged:0};const r=x(d);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:m,flagged:0};let n=0;for(let l=0;l<g;l++){const b=Number(c[l]);if(!Number.isFinite(b))continue;const E=te*(b-r.median)/r.mad;e[l]=E,Math.abs(E)>a&&(m[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:m,flagged:n}}function ie(c,t={}){const a=Number.isFinite(t.k)?t.k:F,g=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&g.push(l)}if(!g.length)return null;const e=g.sort((n,l)=>n-l),m=ae(e,.25),d=ae(e,.75),r=d-m;return{q1:m,q3:d,iqr:r,lower:m-a*r,upper:d+a*r,k:a}}function G(c,t){if(t<=0)return 0;const a=q(c);if(t<c+1){let l=c,b=1/c,E=b;for(let S=0;S<1e3&&(l+=1,E*=t/l,b+=E,!(Math.abs(E)<Math.abs(b)*1e-15));S++);return b*Math.exp(-t+c*Math.log(t)-a)}const g=1e-300;let e=t+1-c,m=1/g,d=1/e,r=d;for(let l=1;l<1e3;l++){const b=-l*(l-c);e+=2,d=b*d+e,Math.abs(d)<g&&(d=g),m=e+b/m,Math.abs(m)<g&&(m=g),d=1/d;const E=d*m;if(r*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function D(c,t){return c<=0?0:G(t/2,c/2)}function Y(c,t=H){if(!(t>0)||!(t<1))return NaN;let a=0,g=Math.max(1,c);for(;D(g,c)<t;)g*=2;for(let e=0;e<200;e++){const m=(a+g)/2;if(D(m,c)<t?a=m:g=m,g-a<1e-10)break}return(a+g)/2}function ee(c){const t=c.length,a=c.map((g,e)=>{const m=g.slice();for(let d=0;d<t;d++)m.push(e===d?1:0);return m});for(let g=0;g<t;g++){let e=g;for(let d=g+1;d<t;d++)Math.abs(a[d][g])>Math.abs(a[e][g])&&(e=d);if(Math.abs(a[e][g])<1e-12)return null;if(e!==g){const d=a[e];a[e]=a[g],a[g]=d}const m=a[g][g];for(let d=0;d<2*t;d++)a[g][d]/=m;for(let d=0;d<t;d++){if(d===g)continue;const r=a[d][g];if(r!==0)for(let n=0;n<2*t;n++)a[d][n]-=r*a[g][n]}}return a.map(g=>g.slice(t))}function z(c,t){const a=c.length,g=new Array(t).fill(0);for(const d of c)for(let r=0;r<t;r++)g[r]+=d[r];for(let d=0;d<t;d++)g[d]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const d of c)for(let r=0;r<t;r++){const n=d[r]-g[r];for(let l=r;l<t;l++)e[r][l]+=n*(d[l]-g[l])}const m=a>1?a-1:1;for(let d=0;d<t;d++)for(let r=d;r<t;r++)e[d][r]/=m,e[r][d]=e[d][r];return{mean:g,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:H,g=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const m=c[0].length;if(!m)return null;const d=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],b=[];for(let R=0;R<e;R++){const h=c[R];let O=h.length===m;const w=new Array(m);for(let P=0;O&&P<m;P++){const v=Number(h[P]);Number.isFinite(v)?w[P]=v:O=!1}O&&(l.push(R),b.push(w))}const E=m,S=Y(E,a);if(b.length<=m)return{center:[],df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0};const{mean:V,cov:U}=z(b,m);let I=ee(U),X=!1;if(!I){X=!0;let R=0;for(let w=0;w<m;w++)R+=U[w][w];const h=R/m*g||g,O=U.map((w,P)=>w.map((v,K)=>P===K?v+h:v));if(I=ee(O),!I)return{center:V,df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0}}let C=0;for(let R=0;R<b.length;R++){const h=b[R],O=new Array(m);for(let v=0;v<m;v++)O[v]=h[v]-V[v];let w=0;for(let v=0;v<m;v++){let K=0;for(let Z=0;Z<m;Z++)K+=I[v][Z]*O[Z];w+=O[v]*K}w<0&&(w=0);const P=l[R];r[P]=w,d[P]=Math.sqrt(w),w>S&&(n[P]=!0,C++)}return{center:V,df:E,cutoff:S,singular:X,used:b.length,distances:d,squared:r,flags:n,flagged:C}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",g=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,m=Number.isFinite(t.k)?t.k:F,d=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):g,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let b=0;for(let E=0;E<r;E++){const S=Number(c[E]);if(!Number.isFinite(S))continue;const V=Math.max(0,E-g+1),U=[];for(let I=V;I<=E;I++){const X=Number(c[I]);Number.isFinite(X)&&U.push(X)}if(!(U.length<d))if(a==="rollingIqr"){const I=ie(U,{k:m});if(!I)continue;(S<I.lower||S>I.upper)&&(l[E]=!0,b++)}else{const I=x(U);if(!I||I.mad===0)continue;const X=te*(S-I.median)/I.mad;n[E]=X,Math.abs(X)>e&&(l[E]=!0,b++)}}return{method:a,windowLen:g,minPeriods:d,threshold:e,k:m,scores:n,flags:l,flagged:b}}function f(c={}){const t=c||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const g=t.method||"modifiedZScore";if(!(ne.includes(g)||s.includes(g))||g==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${g}\'`);const m=typeof t.orderBy=="string"?t.orderBy:null,d=t.latest===!0,r=s.includes(g),n=l=>Number(l==null?NaN:l[a]);return l=>{const b=Array.isArray(l)?l.slice():[...l];m&&b.sort((I,X)=>{const C=I?.[m],R=X?.[m];return C===R?0:C==null?-1:R==null?1:C<R?-1:1});const E=b.map(n);let S,V;if(r)({flags:S,scores:V}=u(E,{method:g,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(g==="iqr"){const I=ie(E,{k:t.k});S=E.map(X=>I?Number.isFinite(X)&&(X<I.lower||X>I.upper):!1),V=E.map(()=>null)}else({flags:S,scores:V}=ce(E,{threshold:t.threshold}));if(d){const I=S.length-1;return I<0||!S[I]?!1:{method:g,field:a,flagged:[{row:b[I],score:V[I]}]}}const U=[];for(let I=0;I<S.length;I++)S[I]&&U.push({row:b[I],score:V[I]});return U.length?{method:g,field:a,flagged:U}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,fe){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const le=fe("packages/core/src/compute/special.js"),ae=le.normalQuantile,Q=le.studentTQuantile,te=fe("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),F=1e-4,H=1-1e-4;function ne(t){const a=[];for(let g=0;g<t.length;g++){const e=t[g];if(e!==null&&typeof e=="object"){const m=Number.isFinite(e.at)?e.at:g,d=Number.isFinite(e.value)?e.value:null;a.push({at:m,value:d})}else a.push({at:g,value:Number.isFinite(e)?Number(e):null})}return a}function x(t){const a=t.filter(r=>r.value!==null),g=a[0],e=a[a.length-1],m=e.at-g.at,d=a.length>1&&m>0?m/(a.length-1):1;return{lastAt:e.at,step:d}}function ce(t){return Math.min(H,Math.max(F,t))}function ie(t,a=F,g=H,e=80){const m=(Math.sqrt(5)-1)/2;let d=a,r=g,n=r-m*(r-d),l=d+m*(r-d),b=t(n),E=t(l);for(let S=0;S<e;S++)b<E?(r=l,l=n,E=b,n=r-m*(r-d),b=t(n)):(d=n,n=l,b=E,l=d+m*(r-d),E=t(l));return(d+r)/2}function G(t,a){let g=null,e=0,m=0;for(let d=0;d<t.length;d++){const r=t[d];if(r!==null){if(g===null){g=r;continue}e+=(r-g)**2,m+=1,g=a*r+(1-a)*g}}return{level:g,sse:e,m}}function D(t,a,g){let e=null,m=null,d=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&m!==null&&(e+=m);continue}if(e===null){e=l;continue}m===null&&(m=l-e);const b=e+m;d+=(l-b)**2,r+=1;const E=e;e=a*l+(1-a)*(E+m),m=g*(e-E)+(1-g)*m}return{level:e,trend:m,sse:d,m:r}}function Y(t,a,g,e,m){const d=t.length;if(d<2*a)return null;const r=X=>{let C=0,R=0;for(let h=X;h<X+a&&h<d;h++)t[h]!==null&&(C+=t[h],R+=1);return R?C/R:null},n=r(0),l=r(a);if(n===null||l===null)return null;let b=n,E=(l-n)/a;const S=new Array(a).fill(0);for(let X=0;X<a;X++)S[X]=t[X]===null?0:t[X]-b;const V=S.reduce((X,C)=>X+C,0)/a;for(let X=0;X<a;X++)S[X]-=V;let U=0,I=0;for(let X=a;X<d;X++){const C=X%a,R=S[C],h=t[X];if(h===null){b+=E;continue}const O=b+E+R;U+=(h-O)**2,I+=1;const w=b;b=g*(h-R)+(1-g)*(b+E),E=e*(b-w)+(1-e)*E,S[C]=m*(h-b)+(1-m)*R}return{level:b,trend:E,season:S,phase:(d-1)%a,sse:U,count:I}}function ee(t,a,g){let e=1;for(const d of a)e+=d*d;const m=Math.sqrt(t*e);return{se:m,margin:g*m}}function z(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const g=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),m=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,d=1-(1-m)/2,r=ne(t),n=r.map(U=>U.value),l=n.filter(U=>U!==null),b=l.length,{lastAt:E,step:S}=b?x(r):{lastAt:0,step:1},V=U=>E+U*S;return g==="linear"?M(r,b,e,m,d,V):g==="movingAverage"?i(l,b,e,m,d,a,V):g==="ses"?s(n,b,e,m,d,a,V):g==="holt"?u(n,b,e,m,d,a,V):f(n,b,e,m,d,a,V)}function M(t,a,g,e,m,d){if(a<2)return null;let r=0,n=0;for(const h of t)h.value!==null&&(r+=h.at,n+=h.value);r/=a,n/=a;let l=0,b=0,E=0;for(const h of t){if(h.value===null)continue;const O=h.at-r,w=h.value-n;l+=O*O,b+=O*w,E+=w*w}if(l===0)return null;const S=b/l,V=n-S*r,U=E===0?1:Math.max(0,Math.min(1,b*b/(l*E))),I=Math.max(0,E-S*b),X=a>2?Math.sqrt(I/(a-2)):null,C=a>2?Q(m,a-2):null,R=[];for(let h=1;h<=g;h++){const O=d(h),w=V+S*O;let P=null,v=null,K=null,Z=null,oe=null;if(X!==null){const se=1/a+(O-r)**2/l,T=X*Math.sqrt(1+se),L=X*Math.sqrt(se);oe=T,P=w-C*T,v=w+C*T,K=w-C*L,Z=w+C*L}R.push({step:h,at:O,mean:w,lower:P,upper:v,lowerMean:K,upperMean:Z,se:oe})}return{method:"linear",horizon:g,confidence:e,n:a,sigma:X,r2:U,params:{slope:S,intercept:V},points:R}}function i(t,a,g,e,m,d,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(d.windowLen)||a))),l=t.slice(a-n);let b=0;for(const X of l)b+=X;const E=b/n;let S=null,V=null;if(n>1){let X=0;for(const R of l)X+=(R-E)**2;S=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),V=Q(m,n-1)}const U=S===null?null:V*S,I=[];for(let X=1;X<=g;X++)I.push({step:X,at:r(X),mean:E,lower:U===null?null:E-U,upper:U===null?null:E+U,se:S});return{method:"movingAverage",horizon:g,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:I}}function s(t,a,g,e,m,d,r){if(a<1)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null;n===null&&(n=ie(V=>G(t,V).sse));const l=G(t,n),b=ae(m),E=l.m>0?l.sse/l.m:null,S=[];for(let V=1;V<=g;V++){const U=l.level;let I=null,X=null,C=null;if(E!==null){const R=[];for(let O=1;O<V;O++)R.push(n);const h=ee(E,R,b);C=h.se,I=U-h.margin,X=U+h.margin}S.push({step:V,at:r(V),mean:U,lower:I,upper:X,se:C})}return{method:"ses",horizon:g,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:n},points:S}}function u(t,a,g,e,m,d,r){if(a<2)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null,l=Number.isFinite(d.beta)?ce(d.beta):null;if(n===null||l===null){let I=n===null?.5:n,X=l===null?.5:l;for(let C=0;C<6;C++)n===null&&(I=ie(R=>D(t,R,X).sse)),l===null&&(X=ie(R=>D(t,I,R).sse));n=n===null?I:n,l=l===null?X:l}const b=D(t,n,l),E=ae(m),S=b.m>0?b.sse/b.m:null,V=n*l,U=[];for(let I=1;I<=g;I++){const X=b.level+I*b.trend;let C=null,R=null,h=null;if(S!==null){const O=[];for(let P=1;P<I;P++)O.push(n+P*V);const w=ee(S,O,E);h=w.se,C=X-w.margin,R=X+w.margin}U.push({step:I,at:r(I),mean:X,lower:C,upper:R,se:h})}return{method:"holt",horizon:g,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:U}}function f(t,a,g,e,m,d,r){const n=Math.floor(Number(d.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(d.alpha)?ce(d.alpha):null,b=Number.isFinite(d.beta)?ce(d.beta):null,E=Number.isFinite(d.gamma)?ce(d.gamma):null;const S=(h,O,w)=>{const P=Y(t,n,h,O,w);return P?P.sse:1/0};if(l===null||b===null||E===null){let h=l===null?.5:l,O=b===null?.5:b,w=E===null?.5:E;for(let P=0;P<8;P++)l===null&&(h=ie(v=>S(v,O,w))),b===null&&(O=ie(v=>S(h,v,w))),E===null&&(w=ie(v=>S(h,O,v)));l=l===null?h:l,b=b===null?O:b,E=E===null?w:E}const V=Y(t,n,l,b,E);if(!V)return null;const U=ae(m),I=V.count>0?V.sse/V.count:null,X=l*b,C=E*(1-l),R=[];for(let h=1;h<=g;h++){const O=V.season[(V.phase+h)%n],w=V.level+h*V.trend+O;let P=null,v=null,K=null;if(I!==null){const Z=[];for(let se=1;se<h;se++)Z.push(l+se*X+(se%n===0?C:0));const oe=ee(I,Z,U);K=oe.se,P=w-oe.margin,v=w+oe.margin}R.push({step:h,at:r(h),mean:w,lower:P,upper:v,se:K})}return{method:"holtWinters",horizon:g,confidence:e,n:a,sigma:I===null?null:Math.sqrt(I),params:{alpha:l,beta:b,gamma:E,period:n},points:R}}const c={FORECAST_METHODS:_,forecast:z}}),Se("packages/core/src/compute/index.js",function(o,fe){"use strict";const le=fe("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return le.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return le.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return le.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return le.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return le.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return le.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return le.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return le.rankSortStrings}});const ae=fe("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return ae.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return ae.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ae.describeSort}});const Q=fe("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const q=fe("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return q.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return q.packKeys}});const te=fe("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const _=fe("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const F=fe("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return F.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return F.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return F.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return F.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return F.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return F.DEFAULT_MAX_COLUMNS}});const H=fe("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const ne=fe("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ne.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ne.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ne.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ne.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ne.referenceValue}});const x=fe("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return x.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return x.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return x.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return x.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return x.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return x.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return x.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return x.isMissing}});const ce=fe("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ce.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ce.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ce.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ce.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ce.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ce.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce.SKETCH_BOUNDS}});const ie=fe("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ie.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ie.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ie.openWindow}});const G=fe("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return G.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return G.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return G.maintenanceOf}});const D=fe("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return D.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return D.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return D.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return D.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return D.anomalyCondition}});const Y=fe("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,fe){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const le=fe("packages/worker/src/transport.js"),ae=le.PROTOCOL,Q=le.OPS,q=le.CONTROL,te=le.ERRORS,_=le.unpackHandle,F=le.unpackHandles,H=le.createMaskPool,ne=le.collectTransfers,x=fe("packages/core/src/store/columnpack.js"),ce=x.packChunk,ie=x.packedTransfers;let G=null,D=null,Y=null;async function ee(f){if(G)return G;if(!D){const c=f||(()=>Promise.resolve(fe("packages/core/src/compute/index.js")));D=Promise.resolve().then(c).then(t=>(G=t,t)).catch(t=>(Y=t,G=null,null))}return D}function z(f){G=f,D=f?Promise.resolve(f):null,Y=f?null:Y}function M(f,c,t){const a=new Map;for(const g of f)g&&a.set(g.id,g);return{handle(g){return a.get(g)},count:c,pool:H(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return ce(a.schema||[],a.rows||[],a.opts||{});const g=c[t];if(typeof g!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return g(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return g(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=F(a.handles||[]),m=(a.entries||[]).map(d=>({...d,handle:e[d.index]}));return g(e,m,a.order??null)}case Q.EVALUATE_FILTERS:return g(a.filters,M(F(a.handles||[]),a.count,a.locale));case Q.COMPACT:return g(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return g(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return g(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==ae)return null;const{id:t,op:a}=f;if(a===q.CANCEL)return c.cancelled?.add(f.target),null;if(a===q.PING)return{reply:{lattice:ae,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ce(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}const g=await ee(c.loader);if(!g)return{reply:{lattice:ae,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,g);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ne(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async g=>{const e=await s(g.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(c.loader).then(g=>{f.postMessage({lattice:ae,id:0,op:q.READY,compute:!!g})}),()=>f.removeEventListener("message",a)}});var bt=nt("packages/worker/src/kernel.js");gt.__latticeKernel=bt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}var kn=En("packages/modules/webcomponent/index.js");if(typeof module=="object"&&module.exports)module.exports=kn;else if(typeof define=="function"&&define.amd)define(function(){return kn});else{var sr=Hn.LatticeGrid||(Hn.LatticeGrid={});for(var Tn in kn)Tn!=="default"&&(sr[Tn]=kn[Tn])}})(typeof globalThis<"u"?globalThis:this);
56
+ `;return t}catch{return""}}function U(a,l){const r=$.get(a);if(r)return r.sheet;const t=H(a);if(!t)return null;const n=l.CSSStyleSheet,i=new n;try{i.replaceSync(t)}catch{return null}i[_]=!0;let o=null;const c=l.MutationObserver;return typeof c=="function"&&String(a.tagName).toLowerCase()==="style"&&(o=new c(()=>{try{i.replaceSync(String(a.textContent||""))}catch{}}),o.observe(a,{childList:!0,characterData:!0,subtree:!0})),$.set(a,{sheet:i,stop:()=>o&&o.disconnect()}),i}function z(a){return a?a.nodeType===9?a:a.ownerDocument||globalThis.document||null:globalThis.document||null}function F(a){const l=a||globalThis.document;return!l||typeof l.querySelectorAll!="function"?[]:[...l.querySelectorAll("style,link[rel]")].filter(Z)}function k(a={}){if(!W())return[];const l=a.document||globalThis.document,r=l&&l.defaultView||globalThis,t=[];for(const n of F(l)){const i=U(n,r);i&&!t.includes(i)&&t.push(i)}return t}function S(a,l={}){const r=()=>{};if(!a||typeof a!="object")return r;const t=l.document||z(a);if(!t)return r;const n=t.defaultView||globalThis;let i=L.get(a);i||(i=new Map,L.set(a,i));const o=[],c=W(),d=p=>{if(i.has(p))return;const m=c?U(p,n):null;if(m){i.set(p,m);const v=a.adoptedStyleSheets||[];v.includes(m)||(a.adoptedStyleSheets=[...v,m]);return}if(String(p.tagName).toLowerCase()!=="link"||typeof a.appendChild!="function")return;const w=t.createElement("link");w.setAttribute("rel","stylesheet"),w.setAttribute("href",p.getAttribute("href")||""),w.setAttribute("data-lattice","adopted"),a.appendChild(w),o.push(w),i.set(p,w)};for(const p of F(t))d(p);let f=null;const h=n.MutationObserver,g=t.head||t.documentElement;typeof h=="function"&&g&&(f=new h(p=>{for(const m of p)for(const w of m.addedNodes||[])Z(w)&&d(w)}),f.observe(g,{childList:!0}));let y=!1;return()=>{if(y)return;y=!0,f&&f.disconnect();const p=a.adoptedStyleSheets||[],m=new Set([...i.values()]);a.adoptedStyleSheets=p.filter(w=>!m.has(w));for(const w of o)w.parentNode&&w.parentNode.removeChild(w);i.clear()}}function b(a){if(!a||typeof a.getRootNode!="function"||typeof a.getAttribute=="function"&&String(a.getAttribute("lattice-styles")||"")==="off")return null;const l=a.getRootNode();return!l||l.nodeType!==11||!l.host?null:S(l)}}),Se("packages/modules/webcomponent/elements.js",function(e,V){"use strict";Object.defineProperty(e,"DEFAULT_GRID_NAME",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"DEFAULT_TAG_PREFIX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"VIEWER_ALIASES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"VIEWER_BINDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"coerceElementAttribute",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"attributeConfig",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"createElementScope",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"scopeFor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"applyPredicates",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"upgradeProperty",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"installProperty",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"harvestProperties",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"gridElementClass",{enumerable:!0,get:function(){return ae}});const N=V("packages/core/src/internal/util.js").warnOnce,L=V("packages/modules/shared/adapter.js").aliasConfigKey,W=V("packages/modules/react/viewers.js"),Z=W.VIEWER_EVENTS,H=W.viewerHandlerName,U=W.createViewerController,z=V("packages/modules/webcomponent/controller.js"),F=z.GridElementController,k=z.observedAttributeNames,S=z.domEventName,b=z.ATTRIBUTE_CONFIG,l=V("packages/modules/webcomponent/styles.js").adoptIntoHostRoot,r="default",t="lattice-",n=Object.freeze({grid:"grid",kpi:"kpi",chart:"chart",kanban:"kanban",gantt:"gantt",layout:"layout",tabs:"tabs",router:"router"}),i=Object.freeze({chart:ee=>{if("data"in ee){const J=ee.data;delete ee.data,J!=null&&ee.rows===void 0&&(ee.rows=J)}if("stacked"in ee){const J=ee.stacked;delete ee.stacked,J!=null&&ee.stack===void 0&&(ee.stack=J)}if("horizontal"in ee){const J=ee.horizontal;delete ee.horizontal,J&&ee.type==="bar"&&(ee.type="horizontalBar")}},kanban:ee=>{if(!("titleProperty"in ee))return;const J=ee.titleProperty;if(delete ee.titleProperty,typeof J!="string"||!J)return;const se=ee.card&&typeof ee.card=="object"?ee.card:null;se&&se.title!==void 0||(ee.card={title:J,...se||{}})},gantt:ee=>{if(!("scale"in ee))return;const J=ee.scale;if(delete ee.scale,J==null||J==="")return;const se=ee.render&&typeof ee.render=="object"?{...ee.render}:{};se.zoom===void 0&&(se.zoom=J),ee.render=se}}),o=Object.freeze({kpi:Object.freeze({label:"lattice-kpi",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["tiles","rows","columns"]),scalars:Object.freeze(["rowKey","locale"])}),chart:Object.freeze({label:"lattice-chart",requires:Object.freeze(["grid"]),fromContext:"grid",properties:Object.freeze(["shapes","series","data"]),scalars:Object.freeze(["type","x","y","value","label","lon","lat","labels","stacked","horizontal","scheme","subtitle","footnote","tooltip","legend"])}),kanban:Object.freeze({label:"lattice-kanban",requires:Object.freeze([]),fromContext:"grid",properties:Object.freeze(["rows","columns","card"]),scalars:Object.freeze(["rowKey","columnProperty","titleProperty","pointsProperty","orderProperty","swimlaneProperty","sprintProperty","epicProperty","swimlanes","virtualize"])}),gantt:Object.freeze({label:"lattice-gantt",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tasks","dependencies","resources","calendar","columns"]),scalars:Object.freeze(["rowKey","scale","projectStart","autoSchedule"])}),layout:Object.freeze({label:"lattice-layout",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["windows"]),scalars:Object.freeze(["columns","rows","compact","columnWidth","rowHeight","gap","overflowX","overflowY"])}),tabs:Object.freeze({label:"lattice-tabs",requires:Object.freeze([]),fromContext:null,properties:Object.freeze(["tabs"]),scalars:Object.freeze(["lazy"])})}),c=new Set(["grid-name","lattice-styles","name","route","route-options","id","class","style","slot"]),d=new Set(["role","tabindex","hidden","part","exportparts","lang","dir","title-id","is"]),f=Symbol.for("lattice.webcomponent.routerScope"),h=new WeakMap;function g(ee){if(ee==null)return;if(ee===""||ee==="true")return!0;if(ee==="false")return!1;const J=String(ee).trim();if(J.startsWith("[")||J.startsWith("{"))try{return JSON.parse(J)}catch{return ee}return J!==""&&Number.isFinite(Number(J))?Number(J):ee}function y(ee,J){const se={},le=ee&&typeof ee.getAttributeNames=="function"?ee.getAttributeNames():[];for(const oe of le){if(c.has(oe)||d.has(oe)||J&&J.has(oe)||oe.startsWith("data-")||oe.startsWith("aria-"))continue;const he=g(ee.getAttribute(oe));he!==void 0&&(se[p(oe)]=he)}return se}function p(ee){const J=L(ee);return J!==ee||!ee.includes("-")?J:ee.replace(/-([a-z0-9])/g,(se,le)=>le.toUpperCase())}function m(ee){return ee&&typeof ee.getAttributeNames=="function"?ee.getAttributeNames():[]}function w(ee){const J=[];for(const se of m(ee))c.has(se)||d.has(se)||se.startsWith("data-")||se.startsWith("aria-")||J.push(p(se));return J}function v(){const ee=new Map,J=new Set;return{publish(se,le){const oe=se||r;le?ee.set(oe,le):ee.delete(oe);for(const he of[...J])he()},get(se){return ee.get(se||r)||null},names(){return[...ee.keys()]},subscribe(se){return J.add(se),()=>{J.delete(se)}}}}function u(ee={}){const J=typeof ee.createDataRouter=="function"?ee.createDataRouter:null;let se=null,le=!1;return{grids:v(),get router(){return se},attach(he,fe,ve){le||!J||(se||(se=J(ee.config||{})),se.attach(he,fe,ve||{}))},detach(he){if(!(le||!se))try{se.detach(he)}catch{}},destroy(){le=!0;const he=se;se=null,he&&he.destroy()}}}function s(ee){let J=ee&&ee.parentNode||null;for(;J;){if(J[f])return J[f];J=J.parentNode||J.host||null}const le=(ee&&typeof ee.getRootNode=="function"?ee.getRootNode():ee&&ee.ownerDocument||null)||globalThis.document||globalThis;let oe=h.get(le);return oe||(oe=u(),h.set(le,oe)),oe}function O(ee,J,se){const le=J&&typeof J=="object"?J:{},oe=se&&typeof se=="object"?se:{};for(const[he,fe]of Object.entries(le))Object.is(oe[he],fe)||ee.filters.where(he,typeof fe=="function"?fe:null);for(const he of Object.keys(oe))Object.hasOwn(le,he)||ee.filters.where(he,null)}function E(ee,J){if(!Object.hasOwn(ee,J))return;const se=ee[J];delete ee[J],ee[J]=se}const A=new Set(["instance","config","grid","gridName","router"]);function M(ee,J){let se=Object.getPrototypeOf(ee);for(;se;){const le=Object.getOwnPropertyDescriptor(se,J);if(le)return typeof le.get=="function";se=Object.getPrototypeOf(se)}return!1}function C(ee,J){if(!J||A.has(J)||J.startsWith("__"))return;const se=Object.getOwnPropertyDescriptor(ee,J);if(se&&typeof se.get=="function")return;if(M(ee,J)){se&&E(ee,J);return}const le=se?se.value:void 0;se&&delete ee[J],Object.defineProperty(ee,J,{get(){return this.__props[J]},set(oe){this.__write(J,oe)},configurable:!0,enumerable:!0}),se&&(ee[J]=le)}function P(ee){let J=!1;for(const se of Object.getOwnPropertyNames(ee)){if(se.startsWith("__")||A.has(se))continue;const le=Object.getOwnPropertyDescriptor(ee,se);!le||typeof le.get=="function"||!le.enumerable||(C(ee,se),J=!0)}return J}function D(ee,J,se){if(!ee||typeof ee.dispatchEvent!="function")return;const le=globalThis.CustomEvent,oe={detail:se,bubbles:!0,composed:!0};ee.dispatchEvent(typeof le=="function"?new le(J,oe):{type:J,...oe})}function K(ee){const J=ee.viewer,se=o[J],le=ee.label||se.label,oe=ee.mount,he=Z[J]||[];class fe extends ee.Base{__props={};__controller=null;__builtAgainst=null;__connected=!1;__teardownPending=!1;__release=[];__queued=!1;__wired=!1;__scope=null;__ownAttributes=new Set;constructor(){super();for(const be of["config","grid","gridName",...se.properties,...se.scalars])E(this,be);P(this)}get instance(){return this.__controller?this.__controller.instance:null}get grid(){return this.__props.grid}set grid(be){this.__write("grid",be)}get gridName(){const be=this.__props.gridName;if(typeof be=="string")return be;const Re=typeof this.getAttribute=="function"?this.getAttribute("grid-name"):null;return Re===null?void 0:Re}set gridName(be){this.__write("gridName",be)}get config(){return{...this.__props}}set config(be){if(!(!be||typeof be!="object")){for(const[Re,He]of Object.entries(be))this.__props[Re]=He;this.__schedule()}}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__wired){this.__wired=!0;const be=l(this);be&&this.__release.push(be);const Re=s(this);this.__scope=Re,se.fromContext&&this.__release.push(Re.grids.subscribe(()=>this.__settle()));const He=globalThis.MutationObserver;if(typeof He=="function"){const Oe=new He(()=>this.__settle());Oe.observe(this,{attributes:!0}),this.__release.push(()=>Oe.disconnect())}}P(this);for(const be of w(this))C(this,be);this.__schedule()}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()))}__settleTeardown(){if(this.__teardownPending){this.__teardownPending=!1,this.__wired=!1,this.__scope=null;for(const be of this.__release.splice(0))try{be()}catch{}this.__tearDown()}}__write(be,Re){this.__props[be]=Re,this.__schedule()}__schedule(){this.__queued||(this.__queued=!0,queueMicrotask(()=>{this.__queued=!1,this.__settle()}))}__boundGrid(){if(!se.fromContext)return null;if(this.__props.grid!==void 0)return this.__props.grid||null;const be=this.__scope;return be?be.grids.get(this.gridName):null}__resolve(){const be={...y(this,this.__ownAttributes),...this.__props};if(delete be.gridName,se.fromContext){const He=this.__boundGrid();He?be[se.fromContext]=He:delete be[se.fromContext]}const Re=i[J];Re&&Re(be);for(const He of he)be[H(He)]=Oe=>D(this,S(He),Oe);return be}__settle(){if(!this.__connected)return;P(this);const be=this.__resolve(),Re=se.fromContext&&be[se.fromContext]||null;if(this.__controller&&!Object.is(this.__builtAgainst,Re)&&this.__tearDown(),!this.__controller){for(const Oe of se.requires)if(be[Oe]===void 0||be[Oe]===null)return;if(se.fromContext&&!Re&&be.rows===void 0)return;const He=new Set(m(this));this.__controller=U({viewer:J,mount:oe,element:this,props:be,name:le});for(const Oe of m(this))He.has(Oe)||this.__ownAttributes.add(Oe);this.__builtAgainst=Re,D(this,"ready",{instance:this.__controller.instance});return}this.__controller.update(be)}__tearDown(){const be=this.__controller;this.__controller=null,this.__builtAgainst=null,be&&(D(this,"destroyed",{instance:be.instance}),be.destroy())}}for(const ve of[...se.properties,...se.scalars])ve in ee.Base.prototype||Object.defineProperty(fe.prototype,ve,{get(){return this.__props[ve]},set(be){this.__write(ve,be)},configurable:!0,enumerable:!0});return fe}function x(ee,J,se){if(typeof ee!="function")throw new TypeError(`${J} needs ${se}: ${J}({ ${se} }).`)}function I(){const ee=globalThis.HTMLElement;return typeof ee=="function"?ee:null}function j(ee){x(ee&&ee.createKPI,"createLatticeKPIElement","createKPI");const J=I();return J?K({viewer:"kpi",Base:J,mount:(se,le)=>ee.createKPI(se,le)}):null}function T(ee){x(ee&&ee.createChart,"createLatticeChartElement","createChart");const J=I();return J?K({viewer:"chart",Base:J,mount:(se,le)=>ee.createChart({...le,container:se})}):null}function B(ee){x(ee&&ee.createKanban,"createLatticeKanbanElement","createKanban");const J=I();return J?K({viewer:"kanban",Base:J,mount:(se,le)=>ee.createKanban(se,le)}):null}function q(ee){x(ee&&ee.createGantt,"createLatticeGanttElement","createGantt");const J=I();return J?K({viewer:"gantt",Base:J,mount:(se,le)=>ee.createGantt({...le,element:se})}):null}function X(ee){x(ee&&ee.createLayout,"createLatticeLayoutElement","createLayout");const J=I();return J?K({viewer:"layout",Base:J,mount:(se,le)=>ee.createLayout(se,le)}):null}function Q(ee){x(ee&&ee.createTabs,"createLatticeTabsElement","createTabs");const J=I();return J?K({viewer:"tabs",Base:J,mount:(le,oe)=>{const he=new Map,fe=typeof le.querySelectorAll=="function"?[...le.querySelectorAll("template[data-tab]")]:[];for(const Re of fe)Re.parentNode===le&&he.set(Re.getAttribute("data-tab"),Re);const be=(Array.isArray(oe.tabs)&&oe.tabs.length?oe.tabs:[...he.keys()].map(Re=>({id:Re,label:he.get(Re).getAttribute("data-label")||Re}))).map(Re=>{const He=Re,Oe=he.get(He.id);return Oe?{...He,view:Ie=>{const $e=Oe.content.cloneNode(!0),qe=[...$e.childNodes];return Ie.appendChild($e),{destroy(){for(const Ue of qe)Ue.parentNode&&Ue.parentNode.removeChild(Ue)}}}}:He});return ee.createTabs(le,{...oe,tabs:be,createGrid:ee.createGrid||(()=>{throw new Error('[lattice] <lattice-tabs>: a tab has neither a <template data-tab="…"> nor a createGrid to build it with. Give the tab a template, or pass createGrid into createLatticeTabsElement.')})})}}):null}function te(ee){x(ee&&ee.createDataRouter,"createLatticeRouterElement","createDataRouter");const J=I();if(!J)return null;class se extends J{__scope=null;__config={};constructor(){super(),E(this,"config")}get config(){return{...this.__config}}set config(oe){!oe||typeof oe!="object"||(this.__config={...this.__config,...oe},this.__scope&&this.__scope.router&&N("webcomponent.router.mountOnly.config","[lattice] <lattice-router>: `config` changed after the router was built. Nothing was applied and the router was NOT rebuilt — rebuilding it would detach every grid and drop every row it holds. Replace the <lattice-router> element itself when a genuinely different router is wanted."))}get router(){return this.__scope?this.__scope.router:null}get instance(){return this.router}connectedCallback(){if(this.__scope)return;const oe=y(this);this.__scope=u({createDataRouter:ee.createDataRouter,config:{...oe,...this.__config}}),this[f]=this.__scope}disconnectedCallback(){const oe=this.__scope;if(this.__scope=null,this[f]=null,!oe)return;const he=oe.router;oe.destroy(),he&&D(this,"destroyed",{instance:he})}}return se}function re(ee={}){const J={},se=(le,oe,he)=>{if(typeof oe!="function")return;const fe=he();fe&&(J[le]=fe)};return se("LatticeGridElement",ee.createGrid,()=>ae(ee.createGrid)),se("LatticeKPIElement",ee.createKPI,()=>j({createKPI:ee.createKPI})),se("LatticeChartElement",ee.createChart,()=>T({createChart:ee.createChart})),se("LatticeKanbanElement",ee.createKanban,()=>B({createKanban:ee.createKanban})),se("LatticeGanttElement",ee.createGantt,()=>q({createGantt:ee.createGantt})),se("LatticeLayoutElement",ee.createLayout,()=>X({createLayout:ee.createLayout})),se("LatticeTabsElement",ee.createTabs,()=>Q({createTabs:ee.createTabs,createGrid:ee.createGrid})),se("LatticeRouterElement",ee.createDataRouter,()=>te({createDataRouter:ee.createDataRouter})),J}function ie(ee={}){const J=globalThis.customElements,se={};if(!J||typeof J.define!="function")return se;const le=typeof ee.prefix=="string"?ee.prefix:t,oe=re(ee),he={LatticeGridElement:n.grid,LatticeKPIElement:n.kpi,LatticeChartElement:n.chart,LatticeKanbanElement:n.kanban,LatticeGanttElement:n.gantt,LatticeLayoutElement:n.layout,LatticeTabsElement:n.tabs,LatticeRouterElement:n.router};for(const[fe,ve]of Object.entries(oe)){const be=le+he[fe],Re=J.get?J.get(be):void 0;if(Re){se[be]=Re;continue}J.define(be,ve),se[be]=ve}return se}function ae(ee){const J=I();if(!J)return null;class se extends J{static get observedAttributes(){return k()}__connected=!1;__teardownPending=!1;__published=!1;__publishedAs=r;__scope=null;__predicates=void 0;__rowUpdates=void 0;__release=[];constructor(){super(),this.__controller=new F(this,{createGrid:ee});for(const oe of["rows","columns","config","predicates","rowUpdates",...Object.values(b)])E(this,oe)}get grid(){return this.__controller.grid}get instance(){return this.__controller.grid}get rows(){return this.__controller.config().rows}set rows(oe){this.__controller.configure({rows:oe})}get columns(){return this.__controller.config().columns}set columns(oe){this.__controller.configure({columns:oe})}get config(){return this.__controller.config()}set config(oe){this.__controller.configure(oe)}get predicates(){return this.__predicates}set predicates(oe){const he=this.__published?this.__controller.grid:null;he&&O(he,oe,this.__predicates),this.__predicates=oe}get rowUpdates(){return this.__rowUpdates}set rowUpdates(oe){if(Object.is(oe,this.__rowUpdates))return;this.__rowUpdates=oe;const he=this.__published?this.__controller.grid:null;he&&oe&&he.rows.apply(oe)}connectedCallback(){if(this.__teardownPending=!1,!this.__connected){if(this.__connected=!0,!this.__scope){const oe=l(this);oe&&this.__release.push(oe),this.__scope=s(this)}this.__controller.connect(),queueMicrotask(()=>this.__publish())}}disconnectedCallback(){this.__connected&&(this.__connected=!1,this.__teardownPending=!0,queueMicrotask(()=>this.__settleTeardown()),this.__controller.disconnect())}attributeChangedCallback(oe,he,fe){this.__controller.attributeChanged(oe,fe)}__publish(){if(!this.__connected||this.__published)return;const oe=this.__controller.grid;if(!oe)return;this.__published=!0,this.__predicates&&O(oe,this.__predicates,{});const he=typeof this.getAttribute=="function"?this.getAttribute("name"):null;this.__publishedAs=he||r;const fe=this.__scope;fe&&fe.grids.publish(this.__publishedAs,oe);const ve=typeof this.getAttribute=="function"?this.getAttribute("route"):null;if(fe&&ve!==null){const be=this.getAttribute("route-options");fe.attach(oe,g(ve),be===null?{}:g(be))}this.__rowUpdates&&oe.rows.apply(this.__rowUpdates),D(this,"grid-ready",{grid:oe})}__settleTeardown(){if(!this.__teardownPending)return;this.__teardownPending=!1;const oe=this.__controller.grid,he=this.__scope;this.__scope=null,this.__published=!1;for(const fe of this.__release.splice(0))try{fe()}catch{}oe&&he&&(D(this,"grid-destroyed",{grid:oe}),he.detach(oe),he.grids.publish(this.__publishedAs,null)),this.__controller.settleTeardown()}}for(const le of Object.values(b))Object.getOwnPropertyDescriptor(se.prototype,le)||le in J.prototype||Object.defineProperty(se.prototype,le,{get(){return this.__controller.config()[le]},set(oe){this.__controller.configure({[le]:oe})},configurable:!0,enumerable:!0});return se}}),Se("packages/modules/webcomponent/index.js",function(e,V){"use strict";Object.defineProperty(e,"TAG_NAME",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createLatticeGridElement",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"defineLatticeGrid",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const _=V("packages/dom/src/index.js"),N=_.createGrid,$=V("packages/modules/webcomponent/elements.js"),L=$.gridElementClass,W=V("packages/modules/webcomponent/controller.js");Object.defineProperty(e,"GridElementController",{enumerable:!0,get:function(){return W.GridElementController}}),Object.defineProperty(e,"observedAttributeNames",{enumerable:!0,get:function(){return W.observedAttributeNames}}),Object.defineProperty(e,"domEventName",{enumerable:!0,get:function(){return W.domEventName}}),Object.defineProperty(e,"ATTRIBUTE_CONFIG",{enumerable:!0,get:function(){return W.ATTRIBUTE_CONFIG}}),Object.defineProperty(e,"EVENT_PREFIX",{enumerable:!0,get:function(){return W.EVENT_PREFIX}}),Object.defineProperty(e,"createLatticeElements",{enumerable:!0,get:function(){return $.createLatticeElements}}),Object.defineProperty(e,"defineLatticeElements",{enumerable:!0,get:function(){return $.defineLatticeElements}}),Object.defineProperty(e,"ELEMENT_TAGS",{enumerable:!0,get:function(){return $.ELEMENT_TAGS}}),Object.defineProperty(e,"createLatticeKPIElement",{enumerable:!0,get:function(){return $.createLatticeKPIElement}}),Object.defineProperty(e,"createLatticeChartElement",{enumerable:!0,get:function(){return $.createLatticeChartElement}}),Object.defineProperty(e,"createLatticeKanbanElement",{enumerable:!0,get:function(){return $.createLatticeKanbanElement}}),Object.defineProperty(e,"createLatticeGanttElement",{enumerable:!0,get:function(){return $.createLatticeGanttElement}}),Object.defineProperty(e,"createLatticeLayoutElement",{enumerable:!0,get:function(){return $.createLatticeLayoutElement}}),Object.defineProperty(e,"createLatticeTabsElement",{enumerable:!0,get:function(){return $.createLatticeTabsElement}}),Object.defineProperty(e,"createLatticeRouterElement",{enumerable:!0,get:function(){return $.createLatticeRouterElement}});const Z=V("packages/modules/webcomponent/styles.js");Object.defineProperty(e,"adoptLatticeStyles",{enumerable:!0,get:function(){return Z.adoptLatticeStyles}}),Object.defineProperty(e,"latticeStyleSheets",{enumerable:!0,get:function(){return Z.latticeStyleSheets}});const H=V("packages/modules/react/viewers.js");Object.defineProperty(e,"VIEWER_EVENTS",{enumerable:!0,get:function(){return H.VIEWER_EVENTS}}),Object.defineProperty(e,"VIEWER_APPLY",{enumerable:!0,get:function(){return H.VIEWER_APPLY}}),Object.defineProperty(e,"viewerHandlerName",{enumerable:!0,get:function(){return H.viewerHandlerName}}),Object.defineProperty(e,"createViewerController",{enumerable:!0,get:function(){return H.createViewerController}});const U=V("packages/modules/shared/adapter.js");Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return U.EVENT_NAMES}}),Object.defineProperty(e,"dashedName",{enumerable:!0,get:function(){return U.dashedName}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return _.createCurrencyType}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return _.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return _.registerUnitSystem}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return _.createStat}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return _.createHeadlessGrid}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return _.duckdbAdapter}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return _.createPushdownSource}});const z="lattice-grid";function F(b=N){return L(b)}function k(b={}){const a=globalThis.customElements,l=b.tagName||z;if(!a||typeof a.define!="function")return null;const r=a.get?a.get(l):void 0;if(r)return r;const t=F(b.createGrid||N);return t?(a.define(l,t),t):null}k();const S=k});try{En("packages/worker/src/inline.js").setWorkerSource('(function(gt){"use strict";var et=Object.create(null),tt=Object.create(null);function Se(o,fe){et[o]=fe}function nt(o){var fe=tt[o];if(fe)return fe;var le=Object.create(null);tt[o]=le;var ae=et[o];if(!ae)throw new Error("[lattice] missing module: "+o);return ae(le,nt),le}Se("packages/core/src/internal/util.js",function(o,fe){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return se}});const le="1.71.3";async function ae(){return le}const Q="1.71.3",q=new Set,te=2e3;function _(T){if(q.add(T),q.size>te){const L=q.values().next().value;L!==void 0&&q.delete(L)}}const F=[],H=500;function ne(T,L,J){F.push({key:T,level:L,message:J.map(he=>typeof he=="string"?he:x(he)).join(" "),at:Date.now()}),F.length>H&&F.shift()}function x(T){if(T instanceof Error)return T.message;try{return JSON.stringify(T)}catch{return String(T)}}function ce(){return F.map(T=>({...T}))}function ie(T,...L){q.has(T)||(_(T),ne(T,"warn",L),console.warn("[lattice]",...L))}function G(T,...L){q.has(T)||(_(T),ne(T,"info",L),console.info("[lattice]",...L))}function D(){q.clear(),F.length=0}function Y(T,L){const J=new Error(`[lattice] ${T}`);throw L!==void 0&&(J.cause=L),J}function ee(T,L){T||Y(L)}const z=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(T){return T!==null&&typeof T=="object"&&!Array.isArray(T)}function i(T){return typeof T=="function"}function s(T){return T==null}function u(T){return T==null||T===""}function f(T){return typeof T!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(T))?!0:!!(T.prototype&&Object.getOwnPropertyNames(T.prototype).length>1)}const c=new Map;function t(T){let L=c.get(T);if(L)return L;if(!T.includes("."))L=J=>J?.[T];else{const J=T.split("."),he=J.length;L=ye=>{let Me=ye;for(let Pe=0;Pe<he;Pe++){if(Me==null)return;Me=Me[J[Pe]]}return Me}}return c.set(T,L),L}const a=new Map;function g(T){let L=a.get(T);if(L)return L;if(!T.includes("."))L=(J,he)=>{J!=null&&(J[T]=he)};else{const J=T.split("."),he=J.length-1;L=(ye,Me)=>{let Pe=ye;for(let Ne=0;Ne<he;Ne++){if(Pe==null)return;const je=J[Ne];Pe[je]==null&&(Pe[je]={}),Pe=Pe[je]}Pe!=null&&(Pe[J[he]]=Me)}}return a.set(T,L),L}function e(T,L){return t(L)(T)}function m(T,L,J){g(L)(T,J)}function d(T){return T?(T.includes(".")?T.slice(T.lastIndexOf(".")+1):T).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,J=>J.toUpperCase()):""}const r={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function n(T){const L=T==null?"":String(T);return/[&<>"\']/.test(L)?L.replace(/[&<>"\']/g,J=>r[J]):L}function l(T){return String(T).replace(/\\w\\S*/g,L=>L[0].toUpperCase()+L.slice(1).toLowerCase())}function b(T,L,J){if(T!==void 0)return T===!0?{enabled:!0,...J}:T===!1?{enabled:!1}:M(T)?T:{[L]:T,enabled:!0}}function E(T){return T==null?[]:Array.isArray(T)?T:[T]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function V(T,L){if(!M(T))return M(L)?{...L}:L;if(!M(L))return L===void 0?T:L;const J={...T};for(const he of Object.keys(L)){if(S.has(he))continue;const ye=L[he];ye!==void 0&&(J[he]=M(ye)&&M(J[he])?V(J[he],ye):ye)}return J}function U(T,L){if(!M(T)||!M(L)||T===L)return L;const J=Object.create(Object.getPrototypeOf(T));return Object.assign(J,T,L),J}class I{#t;#e=new Map;#n;constructor(L=256,J=null){this.#t=L,this.#n=J}get size(){return this.#e.size}get max(){return this.#t}set max(L){this.#t=L,this.#r()}has(L){return this.#e.has(L)}get(L){const J=this.#e;if(!J.has(L))return;const he=J.get(L);return J.delete(L),J.set(L,he),he}peek(L){return this.#e.get(L)}set(L,J){const he=this.#e;return he.has(L)&&he.delete(L),he.set(L,J),this.#r(),J}delete(L){const J=this.#e.get(L);return this.#e.delete(L)&&this.#n&&this.#n(J,L),J}clear(){if(this.#n)for(const[L,J]of this.#e)this.#n(J,L);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const L=this.#e;for(;L.size>this.#t;){const J=L.keys().next().value,he=L.get(J);L.delete(J),this.#n&&this.#n(he,J)}}}const X=new Map;function C(T,L){const J=`${T||""}|${L?JSON.stringify(L):""}`;let he=X.get(J);return he||(he=new Intl.Collator(T||void 0,{numeric:!0,sensitivity:"variant",...L}),X.set(J,he)),he}function R(T,L){if(T===L)return 0;if(T==null)return 1;if(L==null)return-1;if(typeof T=="number"&&typeof L=="number")return Number.isNaN(T)?Number.isNaN(L)?0:1:Number.isNaN(L)||T<L?-1:T>L?1:0;const J=String(T),he=String(L);return J<he?-1:J>he?1:0}function h(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const O=typeof requestAnimationFrame=="function";function w(T){return O?requestAnimationFrame(T):setTimeout(()=>T(h()),16)}function P(T){T!=null&&(O?cancelAnimationFrame(T):clearTimeout(T))}function v(T){let L=null,J=null;const he=()=>{L=null;const Me=J;J=null,T(...Me||[])},ye=(...Me)=>{J=Me,L===null&&(L=w(he))};return ye.cancel=()=>{P(L),L=null,J=null},ye.flush=()=>{L!==null&&(P(L),he())},ye}function K(T,L){let J=null,he=null;const ye=()=>{if(J=null,he===null)return;const Ne=he;he=null,T(...Ne),Me()},Me=()=>{J=setTimeout(ye,L),typeof J?.unref=="function"&&J.unref()},Pe=(...Ne)=>{J===null?(T(...Ne),Me()):(he=Ne,clearTimeout(J),Me())};return Pe.flush=()=>{if(J!==null&&clearTimeout(J),J=null,he===null)return;const Ne=he;he=null,T(...Ne)},Pe.cancel=()=>{J!==null&&clearTimeout(J),J=null,he=null},Pe.pending=()=>J!==null||he!==null,Pe}function Z(T,L=50){return typeof requestIdleCallback=="function"?requestIdleCallback(T,{timeout:L}):setTimeout(()=>T({timeRemaining:()=>0,didTimeout:!0}),1)}let oe=0;function se(T="l"){return`${T}${(++oe).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,fe){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.isFunction,q=1,te=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),_=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),F=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function H(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?ne(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function ne(s){return Array.isArray(s)?s:Q(s.values)?s.values():[]}function x(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=H(s[f]);return u}class ce{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class ie{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const f=this.#e.get(u);if(f!==void 0)return f;const c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const g=ae(u).compare,e=this.#t,m=Array.from(a).sort((r,n)=>{const l=e[r],b=e[n];return l===b?0:l==null?1:b==null?-1:g(String(l),String(b))}),d=new Uint32Array(t);for(let r=0;r<m.length;r++)d[m[r]]=r;return this.#r.set(f,{version:this.#n,ranks:d}),d}}function G(s){if(s==null)return null;const u=s.presence?new ce(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new ie(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,g=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(c[e]):c[e];case"bitset":return(c[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const m=t[e],d=t[e+1],r=new Array(d-m);for(let n=m;n<d;n++)r[n-m]=f?f.valueOf(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,presence:u,dict:f,offsets:t,get:g,version:s.version}}function D(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=G(s[f]);return u}function Y(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function ee(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function z(s,u=[]){const f=c=>{if(!ee(c))return;const t=c.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const c=f.conditions;if(Array.isArray(c))for(const t of c)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,fe){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return ae}});const le=8;class ae{static#t=new Uint8Array(256);static{for(let q=1;q<256;q++)ae.#t[q]=ae.#t[q>>1]+(q&1)}#e;#n;constructor(q=0){const te=Math.max(0,q|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/le))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(q){return q<0||q>=this.#n?0:this.#e[q>>3]>>(q&7)&1}set(q){return q>=0&&q<this.#n&&(this.#e[q>>3]|=1<<(q&7)),this}clear(q){return q>=0&&q<this.#n&&(this.#e[q>>3]&=~(1<<(q&7))),this}assign(q,te){return te?this.set(q):this.clear(q)}fill(q=!1){return this.#e.fill(q?255:0),q&&this.#r(),this}grow(q){const te=Math.max(0,q|0);if(te<=this.#n)return this;const _=Math.ceil(te/le);if(_>this.#e.length){const F=new Uint8Array(_);F.set(this.#e),this.#e=F}return this.#n=te,this}count(){const q=this.#e,te=ae.#t;let _=0;for(let F=0;F<q.length;F++)_+=te[q[F]];return _}and(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]&=te[H];for(let H=F;H<_.length;H++)_[H]=0;return this}or(q){const te=q instanceof ae?q.words:q,_=this.#e,F=Math.min(_.length,te.length);for(let H=0;H<F;H++)_[H]|=te[H];return this}not(){const q=this.#e;for(let te=0;te<q.length;te++)q[te]=~q[te]&255;return this.#r(),this}clone(){const q=new ae(this.#n);return q.words.set(this.#e.subarray(0,q.words.length)),q}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const q=this.#n&7;if(q===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<q)-1)}static from(q){const te=Array.isArray(q)?q:Array.from(q),_=new ae(te.length);for(let F=0;F<te.length;F++)te[F]&&_.set(F);return _}}}),Se("packages/core/src/store/dictionary.js",function(o,fe){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return q}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare;class q{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(_=[]){this.#t=[];for(let F=0;F<_.length;F++){const H=_[F];this.#e.has(H)||(this.#e.set(H,this.#t.length),this.#t.push(H))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let _=this.#t.length*8;for(let F=0;F<this.#t.length;F++){const H=this.#t[F];typeof H=="string"&&(_+=H.length*2),_+=16}return _}codeOf(_){const F=this.#e.get(_);if(F!==void 0)return F;const H=this.#t.length;return this.#t.push(_),this.#e.set(_,H),this.#n++,H}lookup(_){const F=this.#e.get(_);return F===void 0?-1:F}has(_){return this.#e.has(_)}valueOf(_){return this.#t[_]}values(){return this.#t}ranks(_){const F=_||"";if(this.#r&&this.#i===this.#n&&this.#s===F)return this.#r;const H=this.#t.length,ne=new Array(H);for(let G=0;G<H;G++)ne[G]=G;const x=ae(_).compare,ce=this.#t;ne.sort((G,D)=>this.#h(ce[G],ce[D],x));const ie=new Uint32Array(H);for(let G=0;G<H;G++)ie[ne[G]]=G;return this.#r=ie,this.#i=this.#n,this.#s=F,ie}#h(_,F,H){return typeof _=="string"&&typeof F=="string"?H(_,F):Q(_,F)}}}),Se("packages/core/src/store/multivalue.js",function(o,fe){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return le}});class le{#t;#e;#n=0;#r=0;constructor(Q={}){const q=Math.max(1,Q.rows??16),te=Math.max(1,Q.values??q);this.#t=new Int32Array(te),this.#e=new Uint32Array(q+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(Q){return Q<0||Q>=this.#n?0:this.#e[Q+1]-this.#e[Q]}at(Q){return Q<0||Q>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[Q],this.#e[Q+1])}has(Q,q){if(Q<0||Q>=this.#n)return!1;const te=this.#t,_=this.#e[Q+1];for(let F=this.#e[Q];F<_;F++)if(te[F]===q)return!0;return!1}hasAny(Q,q){for(let te=0;te<q.length;te++)if(this.has(Q,q[te]))return!0;return!1}hasAll(Q,q){for(let te=0;te<q.length;te++)if(!this.has(Q,q[te]))return!1;return!0}hasNone(Q,q){return!this.hasAny(Q,q)}push(Q){const q=this.#n,te=Q.length;this.#i(q+1),this.#s(this.#r+te);const _=this.#r;for(let F=0;F<te;F++)this.#t[_+F]=Q[F]|0;return this.#r+=te,this.#n=q+1,this.#e[q]=_,this.#e[q+1]=this.#r,q}write(Q,q){if(Q===this.#n){this.push(q);return}if(Q<0||Q>this.#n)return;const te=this.#e[Q],_=this.#e[Q+1],F=q.length;if(_-te===F){for(let H=0;H<F;H++)this.#t[te+H]=q[H]|0;return}this.#h(Q,q)}compact(Q,q,te){const _=this.#t,F=this.#e,H=this.#n,ne=new Int32Array(Math.max(1,this.#r)),x=new Uint32Array(q+1);let ce=0;for(let ie=0;ie<H;ie++){if(Q[ie]===te)continue;const G=F[ie],D=F[ie+1];x[Q[ie]]=ce;for(let Y=G;Y<D;Y++)ne[ce++]=_[Y];x[Q[ie]+1]=ce}this.#t=ne,this.#e=x,this.#n=q,this.#r=ce}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(Q){if(Q+1<=this.#e.length)return;let q=this.#e.length-1;for(;q<Q;)q=q*2||16;const te=new Uint32Array(q+1);te.set(this.#e),this.#e=te}#s(Q){if(Q<=this.#t.length)return;let q=this.#t.length;for(;q<Q;)q=q*2||16;const te=new Int32Array(q);te.set(this.#t),this.#t=te}#h(Q,q){const te=this.#t,_=this.#e,F=this.#n,H=q.length-(_[Q+1]-_[Q]),ne=new Int32Array(Math.max(1,this.#r+H)),x=new Uint32Array(_.length);let ce=0;for(let ie=0;ie<F;ie++){if(x[ie]=ce,ie===Q)for(let G=0;G<q.length;G++)ne[ce++]=q[G]|0;else for(let G=_[ie];G<_[ie+1];G++)ne[ce++]=te[G];x[ie+1]=ce}this.#t=ne,this.#e=x,this.#r=ce}}}),Se("packages/core/src/compute/handle.js",function(o,fe){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const le=fe("packages/core/src/internal/util.js"),ae=le.collator,Q=le.defaultCompare,q=le.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function _(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(q(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const F=new WeakMap;function H(i){const s=i.constructor;if(!s)return"unknown";const u=F.get(s);if(u)return u;let f="unknown";try{let c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return F.set(s,f),f}function ne(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":H(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function x(i){return!i||!i.presence?null:ne(i.presence)}function ce(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function ie(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function G(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,g=new Array(t-c);for(let e=c;e<t;e++)g[e-c]=a?ie(a,f[e]):f[e];return g}function D(i){if(!i)return()=>{};const s=i.values,u=x(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?ie(c,s[t]):null:t=>ie(c,s[t])}if(f==="bitset"){const c=ne(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?G(i,c):null:c=>G(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Y(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function ee(i){const s=ae(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Y(u,f);if(c==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),g=f instanceof Date?f.getTime():Number(f);return Y(a,g)}return Q(u,f)}}function z(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,c=ee(s),t=new Array(f);for(let g=0;g<f;g++)t[g]=g;t.sort((g,e)=>c(u[g],u[e])||g-e);const a=new Uint32Array(f);for(let g=0;g<f;g++)a[t[g]]=g;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,fe){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return I}});const le=fe("packages/core/src/compute/handle.js"),ae=le.bitReader,Q=le.dictRanks,q=le.dictSize,te=le.identity,_=le.isMissing,F=le.presenceReader,H=le.rowCount,ne=le.valueComparator,x=le.valueReader,ce=new Uint32Array(0),ie=new ArrayBuffer(8),G=new Float64Array(ie),D=new Uint32Array(ie),Y=(G[0]=-1,(D[1]&2147483648)!==0?1:0),ee=Y===1?0:1;function z(C,R){G[0]=C;let h=D[Y],O=D[ee];(h&2147483648)!==0?(h=~h>>>0,O=~O>>>0):h=(h^2147483648)>>>0,R[0]=O,R[1]=h}function M(C,R,h,O){if(O<2)return C;const w=new Uint32Array(256*8);for(let L=0;L<O;L++){const J=R[L],he=h[L];w[J&255]++,w[256+(J>>>8&255)]++,w[512+(J>>>16&255)]++,w[768+(J>>>24&255)]++,w[1024+(he&255)]++,w[1280+(he>>>8&255)]++,w[1536+(he>>>16&255)]++,w[1792+(he>>>24&255)]++}let P=C,v=R,K=h,Z=new Uint32Array(O),oe=new Uint32Array(O),se=new Uint32Array(O);const T=new Uint32Array(256);for(let L=0;L<8;L++){const J=L<<8,he=(L&3)<<3,ye=L>=4;let Me=!1;for(let je=0;je<256;je++)if(w[J+je]===O){Me=!0;break}if(Me)continue;let Pe=0;for(let je=0;je<256;je++)T[je]=Pe,Pe+=w[J+je];for(let je=0;je<O;je++){const Ve=v[je],We=K[je],Xe=(ye?We:Ve)>>>he&255,qe=T[Xe]++;Z[qe]=P[je],oe[qe]=Ve,se[qe]=We}let Ne=P;P=Z,Z=Ne,Ne=v,v=oe,oe=Ne,Ne=K,K=se,se=Ne}return P}function i(C,R,h){if(h<2)return C;const O=new Uint32Array(256*4);for(let oe=0;oe<h;oe++){const se=R[oe];O[se&255]++,O[256+(se>>>8&255)]++,O[512+(se>>>16&255)]++,O[768+(se>>>24&255)]++}let w=C,P=R,v=new Uint32Array(h),K=new Uint32Array(h);const Z=new Uint32Array(256);for(let oe=0;oe<4;oe++){const se=oe<<8,T=oe<<3;let L=!1;for(let ye=0;ye<256;ye++)if(O[se+ye]===h){L=!0;break}if(L)continue;let J=0;for(let ye=0;ye<256;ye++)Z[ye]=J,J+=O[se+ye];for(let ye=0;ye<h;ye++){const Me=P[ye],Pe=Z[Me>>>T&255]++;v[Pe]=w[ye],K[Pe]=Me}let he=w;w=v,v=he,he=P,P=K,K=he}return w}function s(C,R,h,O){const w=new Uint32Array(O+1);for(let K=0;K<h;K++)w[R[K]]++;let P=0;for(let K=0;K<=O;K++){const Z=w[K];w[K]=P,P+=Z}const v=new Uint32Array(h);for(let K=0;K<h;K++)v[w[R[K]]++]=C[K];return v}function u(C,R,h,O){return h<2?C:O<=65536||O<=h*2?s(C,R,h,O):i(C,R,h)}function f(C,R){return C.length===R&&C.byteOffset===0?C:Uint32Array.prototype.slice.call(C,0,R)}function c(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=new Uint32Array(w),v=new Uint32Array(w),K=new Uint32Array(w),Z=new Uint32Array(w),oe=new Uint32Array(2);let se=0,T=0;for(let he=0;he<w;he++){const ye=O[he],Me=C[ye];if(Number.isNaN(Me)){Z[T++]=ye;continue}z(Me,oe),h?(v[se]=~oe[0]>>>0,K[se]=~oe[1]>>>0):(v[se]=oe[0],K[se]=oe[1]),P[se++]=ye}const L=M(P.subarray(0,se),v.subarray(0,se),K.subarray(0,se),se);if(T===0)return f(L,se);const J=new Uint32Array(w);return J.set(L.subarray(0,se),0),J.set(Z.subarray(0,T),se),J}function t(C,R,h=!1){const O=R||te(C.length),w=O.length;if(w<2)return Uint32Array.from(O);const P=Uint32Array.from(O),v=new Uint32Array(w);for(let K=0;K<w;K++){const Z=(C[P[K]]^2147483648)>>>0;v[K]=h?~Z>>>0:Z}return f(i(P,v,w),w)}function a(C,R,h={}){const O=R||te(H(C,h)),w=O.length;if(w<2)return Uint32Array.from(O);const P=Q(C.dict,h.locale),v=C.values,K=F(C),Z=Math.max(q(C.dict),P.length),oe=Z,se=Uint32Array.from(O),T=new Uint32Array(w),L=!!h.descending;for(let J=0;J<w;J++){const he=se[J];let ye=K&&K(he)===0?oe:P[v[he]];ye===void 0&&(ye=oe),T[J]=L?oe-ye:ye}return f(u(se,T,w,Z+1),w)}function g(C,R,h){const O=R.length;let w=Uint32Array.from(R);if(O<2)return w;let P=new Uint32Array(O);for(let v=1;v<O;v<<=1){for(let Z=0;Z<O;Z+=v<<1){const oe=Math.min(Z+v,O),se=Math.min(Z+(v<<1),O);let T=Z,L=oe,J=Z;for(;T<oe&&L<se;)P[J++]=h(C[w[T]],C[w[L]])<=0?w[T++]:w[L++];for(;T<oe;)P[J++]=w[T++];for(;L<se;)P[J++]=w[L++]}const K=w;w=P,P=K}return w}function e(C,R,h){const O=ae(C.values),w=R.length,P=new Uint32Array(w),v=h?1:0;let K=0;for(let Z=0;Z<w;Z++)O(R[Z])===v&&(P[K++]=R[Z]);for(let Z=0;Z<w;Z++)O(R[Z])!==v&&(P[K++]=R[Z]);return P}function m(C,R){const h=C.values,O=C.kind;if((O==="object"||O===void 0)&&(Array.isArray(h)||ArrayBuffer.isView(h))&&!C.presence)return h;const P=x(C),v=new Array(H(C)||0);for(let K=0;K<R.length;K++){const Z=R[K];v[Z]=P(Z)}return v}function d(C,R){for(let h=0;h<R.length;h++)if(typeof C[R[h]]!="string")return!1;return!0}function r(C,R,h,O,w){const P=C.length,v=Uint32Array.from(C);if(P<2||O<1)return v;const K=new Uint32Array(P),Z=O-1;for(let oe=0;oe<P;oe++){const se=h[R[oe]];K[oe]=w?Z-se:se}return f(u(v,K,P,O),P)}function n(C,R,h){const O=ne(h),w=new Array(R);for(let v=0;v<R;v++)w[v]=v;w.sort((v,K)=>O(C[v],C[K])||v-K);const P=new Uint32Array(R);for(let v=0;v<R;v++)P[w[v]]=v;return P}function l(C,R,h){const O=R.length,w=new Map,P=[],v=new Uint32Array(O);for(let oe=0;oe<O;oe++){const se=C[R[oe]];let T=w.get(se);T===void 0&&(T=P.length,w.set(se,T),P.push(se)),v[oe]=T}const K=P.length,Z=n(P,K,h.locale);return r(R,v,Z,K,!!h.descending)}function b(C,R,h){const O=m(C,R);if(R.length>=2&&d(O,R)){const v=C.stringRank;return v&&v.version===C.version&&v.usable(R,O,h.locale)?v.sort(R,h):l(O,R,h)}const w=ne(h.locale),P=h.descending?(v,K)=>w(K,v):w;return g(O,R,P)}function E(C,R,h){const O=m(C,R),w=h.compare,v=!!h.descending?(K,Z)=>-w(K,Z,void 0,void 0,!0):(K,Z)=>w(K,Z,void 0,void 0,!1);return g(O,R,v)}function S(C,R){const h=R.length,O=F(C),w=C.values,P=C.kind==="float64"&&!!w,v=C.kind==="object"||C.kind==="multi"||C.kind===void 0;if(!O&&!P&&!v)return{present:R,absent:ce};const K=new Uint32Array(h),Z=new Uint32Array(h);let oe=0,se=0;if(O&&P)for(let T=0;T<h;T++){const L=R[T];O(L)===1&&!Number.isNaN(w[L])?K[oe++]=L:Z[se++]=L}else if(P&&!O)for(let T=0;T<h;T++){const L=R[T];Number.isNaN(w[L])?Z[se++]=L:K[oe++]=L}else if(O&&!v)for(let T=0;T<h;T++){const L=R[T];O(L)===1?K[oe++]=L:Z[se++]=L}else{const T=x(C);for(let L=0;L<h;L++){const J=R[L];_(T(J))?Z[se++]=J:K[oe++]=J}}return se===0?{present:R,absent:ce}:{present:K.subarray(0,oe),absent:Z.subarray(0,se)}}function V(C,R,h){if(R.length===0)return C;const O=new Uint32Array(C.length+R.length);return h?(O.set(R,0),O.set(C,R.length)):(O.set(C,0),O.set(R,C.length)),O}function U(C,R,h={}){const O=R||te(H(C,h));if(!C||O.length<2)return Uint32Array.from(O);const{present:w,absent:P}=S(C,O);if(w.length===0)return Uint32Array.from(O);const v=!!h.descending;let K;if(typeof h.compare=="function")K=E(C,w,h);else switch(C.kind){case"float64":K=c(C.values,w,v);break;case"int32":K=t(C.values,w,v);break;case"dictionary":K=a(C,w,h);break;case"bitset":K=e(C,w,v);break;default:K=b(C,w,h);break}return V(K,P,!!h.nullsFirst)}function I(C,R,h,O={}){const w=R||[],P=w.length&&(w[0].handle||X(C,w[0].col))||C&&C[0];let v=h||te(H(P,O));for(let K=w.length-1;K>=0;K--){const Z=w[K],oe=Z.handle||X(C,Z.col)||C&&C[K];oe&&(v=U(oe,v,{descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,locale:Z.locale!==void 0?Z.locale:O.locale,compare:Z.compare}))}return v instanceof Uint32Array?v:Uint32Array.from(v)}function X(C,R){if(!(!C||R===void 0)){for(let h=0;h<C.length;h++)if(C[h]&&C[h].id===R)return C[h]}}}),Se("packages/core/src/store/stringrank.js",function(o,fe){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const le=fe("packages/core/src/compute/sort.js"),ae=le.collateStringRanks,Q=le.rankSortStrings,q=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(F=q){this.#h=F>0?F:q,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(F){this.#s=F}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let F=this.#n.byteLength;const H=this.#t;for(let ne=0;ne<H.length;ne++)F+=H[ne].length*2+24;return F}#a(F,H){const ne=this.#e.get(F);if(ne!==void 0)return ne;if(this.#u)return-1;if(H&&this.#t.length>=this.#h)return this.#u=!0,-1;const x=this.#t.length;return this.#t.push(F),this.#e.set(F,x),this.#i++,x}build(F,H){const ne=H|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(ne);for(let x=0;x<ne;x++){const ce=F[x],ie=typeof ce=="string"?this.#a(ce,!1):-1;this.#n[x]=ie<0?0:ie}this.#r=ne}append(F,H,ne){const x=(H|0)+(ne|0);if(x>this.#n.length){const ce=new Uint32Array(x);ce.set(this.#n.subarray(0,this.#r)),this.#n=ce}for(let ce=H|0;ce<x;ce++){const ie=F[ce],G=typeof ie=="string"?this.#a(ie,!0):-1;this.#n[ce]=G<0?0:G}this.#r=Math.max(this.#r,x)}ranks(F){const H=F||"";if(this.#o&&this.#c===this.#i&&this.#l===H)return this.#o;const ne=ae(this.#t,this.#t.length,F);return this.#o=ne,this.#c=this.#i,this.#l=H,ne}usable(F,H,ne){if(this.#u||this.#t.length===0)return!1;const x=this.#n,ce=this.#t,ie=this.#r;for(let G=0;G<F.length;G++){const D=F[G];if(D>=ie||ce[x[D]]!==H[D])return!1}return!0}sort(F,H){const ne=this.ranks(H.locale),x=this.#t.length,ce=F.length,ie=new Uint32Array(ce),G=this.#n;for(let D=0;D<ce;D++)ie[D]=G[F[D]];return Q(F,ie,ne,x,!!H.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,fe){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return a}});const le=fe("packages/core/src/internal/util.js"),ae=le.warnOnce,Q=le.isFunction,q=le.pathGetter,_=fe("packages/core/src/store/bitset.js").Bitset,H=fe("packages/core/src/store/dictionary.js").Dictionary,x=fe("packages/core/src/store/multivalue.js").MultiValue,ie=fe("packages/core/src/store/stringrank.js").StringRankIndex,G=4294967295,D=1024,Y=5e3,ee=.2,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(g){return g==null}function i(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(typeof g=="boolean")return g?1:0;const e=Number(g);return Number.isNaN(e)&&typeof g=="string"?Date.parse(g):e}function s(g){const e=i(g);return Number.isFinite(e)?e|0:0}function u(g){return M(g)?[]:Array.isArray(g)?g:[g]}function f(g,e){switch(g.kind){case"float64":case"int32":return g.buf[e];case"bitset":return g.bits.get(e)===1;case"dictionary":return g.dict.valueOf(g.buf[e]);case"multi":{const m=g.mv.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=g.dict.valueOf(m[r]);return d}default:return g.buf[e]}}function c(g,e){switch(g.kind){case"float64":case"int32":return g.values[e];case"bitset":return(g.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(g.table||[])[g.values[e]];case"multi":{const m=g.offsets[e],d=g.offsets[e+1],r=g.table||[],n=new Array(d-m);for(let l=m;l<d;l++)n[l-m]=r[g.values[l]];return n}default:return g.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,m){this.#t=e.id;const d=z.has(e.kind)?e.kind:"object";e.kind&&!z.has(e.kind)&&ae(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=d,this.#e=d,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=m,this.#i=Q(e.read)?e.read:q(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,m=this.#s.physical();if(!e||m===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const d=new ie(this.#S());return d.build(e,m),d.version=this.#f,this.#d=d,this.#k=this.#f,d.capped?null:d}return this.#d.length<m&&this.#d.append(e,this.#d.length,m-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const m=this.#l.at(e),d=new Array(m.length);for(let r=0;r<m.length;r++)d[r]=this.#a.valueOf(m[r]);return d}default:return this.#o[e]}}}set(e,m){this.#g||(this.#u?this.#A(e,m):this.#y.set(e,m===void 0?null:m),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,m,d){if(this.#g||d<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let b=!1;switch(this.#e){case"float64":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]);if(typeof V=="number"){n&&l.set(m+S),E[m+S]=V;continue}const U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?NaN:i(V)}break}case"int32":{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?0:s(V)}break}case"bitset":{const E=this.#c;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E.assign(m+S,!U&&!!V)}break}case"dictionary":{const E=this.#o,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0),E[m+V]=I?0:S.codeOf(U)}break}case"multi":{const E=this.#l,S=this.#a;for(let V=0;V<d;V++){const U=r(e[V]),I=U==null;n?l.assign(m+V,!I):I&&(b=!0);const X=u(U),C=new Array(X.length);for(let R=0;R<X.length;R++)C[R]=S.codeOf(X[R]);E.write(m+V,C)}break}default:{const E=this.#o;for(let S=0;S<d;S++){const V=r(e[S]),U=V==null;n?l.assign(m+S,!U):U&&(b=!0),E[m+S]=U?null:V}break}}b&&ae(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,m,d),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,m,d){if(this.#g||d<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let b=0;b<d;b++)r.assign(m+b,(n[b>>3]&1<<(b&7))!==0);else for(let b=0;b<d;b++)r.set(m+b);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,m),this.#f++;return}if(l&&this.#e==="bitset"){const b=e.values;for(let E=0;E<d;E++)this.#c.assign(m+E,(b[E>>3]&1<<(E&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const b=e.table||[],E=new Uint32Array(b.length);for(let I=0;I<b.length;I++)E[I]=this.#a.codeOf(b[I]);const S=e.values,V=this.#o,U=r;for(let I=0;I<d;I++){if(U&&(n&&(n[I>>3]&1<<(I&7))===0)){V[m+I]=0;continue}V[m+I]=E[S[I]]??0}this.#f++;return}if(l&&this.#e==="multi"){const b=e.table||[],E=new Uint32Array(b.length);for(let U=0;U<b.length;U++)E[U]=this.#a.codeOf(b[U]);const S=e.values,V=e.offsets;for(let U=0;U<d;U++){const I=V[U],X=V[U+1],C=new Array(X-I);for(let R=I;R<X;R++)C[R-I]=E[S[R]]??0;this.#l.write(m+U,C)}this.#f++;return}for(let b=0;b<d;b++){const E=n?(n[b>>3]&1<<(b&7))===0:e.kind==="object"?e.values[b]===null:!1;this.#A(m+b,E?null:c(e,b))}this.#f++}touch(){this.#f++}columnarise(e,m){if(this.#u||this.#g)return;const d=new Array(m);for(let r=0;r<m;r++)d[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<m;r++)this.#A(r,d[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const m=new this.#o.constructor(e);m.set(this.#o),this.#o=m;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!z.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const m={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},d=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<d;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(m,n))}return this.#j(),this.#f++,!0}compact(e,m,d){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,b]of r)e[l]!==G&&n.set(e[l],b);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<m;n++)e[n]!==G&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=d;n<m;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n);break}case"multi":this.#l.compact(e,d,G);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<m;n++)e[n]!==G&&r.assign(e[n],r.get(n)===1);for(let n=d;n<m;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const m=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(m);break;case"int32":this.#o=new Int32Array(m);break;case"bitset":this.#c=new _(m);break;case"dictionary":this.#o=new Uint32Array(m),this.#a=this.#a??new H(this.#h??[]);break;case"multi":this.#l=new x({rows:m,values:m}),this.#a=this.#a??new H(this.#h??[]);break;default:this.#o=new Array(m);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(m):this.#m=new _(m)),this.#p=m}#A(e,m){const d=M(m);switch(this.#r?this.#m.assign(e,!d):d&&ae(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=d?NaN:i(m);break;case"int32":this.#o[e]=d?0:s(m);break;case"bitset":this.#c.assign(e,!d&&!!m);break;case"dictionary":this.#o[e]=d?0:this.#a.codeOf(m);break;case"multi":{const r=u(m),n=new Array(r.length);for(let l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);this.#l.write(e,n);break}default:this.#o[e]=d?null:m;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const m=this.#i(this.#s.rowAt(e));return m===void 0?null:m}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),m=new Array(e),d=this.#r?new _(e):null;for(let r=0;r<e;r++){const n=this.#M(r);m[r]=n,d&&!M(n)&&d.set(r)}return this.#O={version:this.#f,values:m,presence:d},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new _(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,m={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,m.initialCapacity??D),this.#l=m.retainSource!==!1,this.#a=this.#l?m.columnarBelow??Y:0,this.#w=m.compactRatio??ee;const d={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){ae(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,d);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const m of this.#n)e+=m.bytes;return e}append(e){const m=this.#i;if(this.#b||!e)return{from:m,to:m};const d=e.length|0;if(d===0)return{from:m,to:m};if(this.#l)for(let n=0;n<d;n++)this.#r[m+n]=e[n];if(this.#i=m+d,this.#h+=d,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:m,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,m,d);return{from:m,to:this.#i}}appendPacked(e,m){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const r=e.count|0;if(r===0)return{from:d,to:d};if(this.#l&&m)for(let l=0;l<r;l++)this.#r[d+l]=m[l];this.#i=d+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const l of e.columns)n.set(l.id,l);for(const l of this.#n){const b=n.get(l.id);b?l.appendPacked(b,d,r):l.grow(this.#s)}return{from:d,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,m){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=m)}get(e,m){const d=this.#e.get(e);return d?d.get(m):void 0}set(e,m,d){if(this.#b||m<0||m>=this.#i)return;const r=this.#e.get(e);if(!r){ae(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(m,d)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const m=this.#i,d=new Uint32Array(m);let r=0;for(let n=0;n<m;n++)d[n]=this.#o.get(n)===1?G:r++;for(const n of this.#n)n.compact(d,m,r);if(this.#l){const n=this.#r;for(let l=0;l<m;l++)d[l]!==G&&(n[d[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new _(Math.max(this.#s,r)),d}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let d=0;d<this.#i;d++)e[d]=d;return e}let m=0;for(let d=0;d<this.#i;d++)this.#o.get(d)===0&&(e[m++]=d);return e}convert(e,m){const d=this.#e.get(e);return d?d.convert(m):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let m=this.#s||this.#d;for(;m<e;)m*=2;for(const d of this.#n)d.grow(m);this.#o.grow(m),this.#s=m}#m(e){const m={};for(const d of this.#n)m[d.id]=d.get(e);return m}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const m of this.#n)m.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,fe){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.now,Q=le.nextFrame,q=le.infoOnce,te=le.warnOnce,_=le.isFunction,F=le.pathGetter,ne=fe("packages/core/src/store/columnstore.js").ColumnStore,x=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ce(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let g=0;g<M.length;g++){const e=M[g];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function ie(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function G(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const b=_(l.read)?l.read:F(l.field||l.id);f.set(l.id,b),u.set(l.id,b)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},g=i?.wrapDeps??null,e=c.filter(l=>_(t[l])),m=e.some(l=>a[l]==="*");let d=new WeakMap;const r=l=>{const b={};if(m)for(const[E,S]of f)b[E]=S(l);for(const E of e){const S=a[E];let V;if(S==="*")V=b;else{V={};const U=S||[];for(let I=0;I<U.length;I++){const X=U[I];V[X]=X in b?b[X]:f.get(X)?.(l)}}b[E]=t[E](g?g(V,E):V,{data:l,row:null,column:null,grid:null,context:s})}return b},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let b=d.get(l);return b===void 0&&(b=r(l),d.set(l,b)),b};for(const l of e)u.set(l,b=>n(b)[l]);return{readers:u,reset(){d=new WeakMap}}}class D{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Y{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...x,...u};const f=s.columns??[];this.#r=G(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new ne(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=ae(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,this.#r.reset(),this.#w(!1)}while(this.#i<f&&ae()-i<s);return this.#o+=ae()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),c=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){te(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const g=this.#r.readers.get(a.id)??(_(a.read)?a.read:F(a.field||a.id)),e=new D(a,g);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const m=[];for(let r=0;r<f&&m.length<this.#s.sampleSize;r++){const n=g(u[r]);n!=null&&m.push(n)}e.inferred=!0;const d=ce(m,{multi:a.multi});if(d==="text"){const r=new Set(m).size;e.kind=ie(r,m.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${m.length}`}else e.kind=d,e.reason=`inferred from ${m.length} sampled values`,d==="object"&&m.length&&q(`ingest.mixed.${a.id}`,`column "${a.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(m))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const c=this.#d(f);if(f.kind==="dictionary"&&c>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function ee(M,i={},s={}){const u=new Y(M,i,s),f=s.scheduler?.frame??Q;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function z(M,i={},s={}){const u=new Y(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,fe){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Y}});const ae=fe("packages/core/src/internal/util.js").pathGetter,Q=fe("packages/core/src/store/ingest.js"),q=Q.inferKind,te=Q.decideText,_=Q.INGEST_DEFAULTS,H=fe("packages/core/src/store/columnstore.js").toFloat,ne=new Set(["float64","int32","bitset","dictionary","object","multi"]);function x(ee){if(!Array.isArray(ee)||ee.length===0)return!1;for(const z of ee)if(!z||typeof z.id!="string"||typeof z.field!="string"||z.field===""||z.kind&&!ne.has(z.kind))return!1;return!0}function ce(ee){const z=H(ee);return Number.isFinite(z)?z|0:0}function ie(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}function G(ee,z,M,i){if(ee.kind)return ee.kind;const s=[];for(let c=0;c<z.length&&s.length<_.sampleSize;c++){const t=z[c];t!=null&&s.push(t)}const u=q(s,{multi:ee.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function D(ee,z,M={}){const i=z.length|0,s=M.dictionaryRatio??_.dictionaryRatio,u=[];for(const f of ee){const c=ae(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(z[r]);a[r]=n===void 0?null:n}const g=G(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,m=r=>{e&&(e[r>>3]|=1<<(r&7))};let d;switch(g){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?NaN:H(l)}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),r[n]=b?0:ce(l)}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const l=a[n],b=l===null;b||m(n),!b&&l&&(r[n>>3]|=1<<(n&7))}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let b=0;b<i;b++){const E=a[b];if(E===null){r[b]=0;continue}m(b);let S=l.get(E);S===void 0&&(S=n.length,n.push(E),l.set(E,S)),r[b]=S}d={id:f.id,kind:g,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),b=[];for(let E=0;E<i;E++){const S=a[E];l[E]=b.length,S===null||m(E);const U=ie(S);for(let I=0;I<U.length;I++){const X=U[I];let C=n.get(X);C===void 0&&(C=r.length,r.push(X),n.set(X,C)),b.push(C)}}l[i]=b.length,d={id:f.id,kind:g,nullable:t,values:Int32Array.from(b),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&m(n),r[n]=l}d={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(d)}return{count:i,columns:u}}function Y(ee){const z=[];if(!ee||!Array.isArray(ee.columns))return z;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!z.includes(i.buffer)&&z.push(i.buffer)};for(const i of ee.columns)M(i.values),M(i.presence),M(i.offsets);return z}}),Se("packages/core/src/compute/sortspec.js",function(o,fe){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function le(_){return{locale:_===void 0?void 0:String(_),numeric:!0,sensitivity:"variant"}}function ae(_){return!!_&&typeof _.compare!="function"}function Q(_){if(!_)return!0;for(let F=0;F<_.length;F++)if(!ae(_[F]))return!1;return!0}function q(_,F){const H=_.col!==void 0?_.col:_.handle&&_.handle.id,ne=_.locale!==void 0?_.locale:F;return{col:H,descending:_.descending!==void 0?!!_.descending:_.dir==="desc",nullsFirst:!!_.nullsFirst,collation:le(ne)}}function te(_,F){const H=_||[],ne=new Array(H.length);for(let x=0;x<H.length;x++)ne[x]=q(H[x],F);return ne}}),Se("packages/core/src/format/date.js",function(o,fe){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return z}});const le=fe("packages/core/src/internal/util.js"),ae=le.isNil,Q=le.warnOnce,q=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=q.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&Q(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${q.join(" ")}.`),u+=c,s+=1}return f(),i}const _=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function F(M){if(ae(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=_.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",g="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+g)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function H(M,i){return String(M).padStart(i,"0")}function ne(M){if(!M)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function x(M,i,s){const u=te(M),f=ne(s),c=new Set(u.filter(m=>m.token).map(m=>m.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,g=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return m=>{const d=f(m);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=H(d.year,4);break;case"yy":r+=H(d.year%100,2);break;case"MMMM":r+=a.format(m);break;case"MMM":r+=t.format(m);break;case"MM":r+=H(d.month,2);break;case"M":r+=String(d.month);break;case"dd":r+=H(d.day,2);break;case"d":r+=String(d.day);break;case"EEEE":r+=e.format(m);break;case"EEE":r+=g.format(m);break;case"HH":r+=H(d.hour,2);break;case"H":r+=String(d.hour);break;case"hh":r+=H(d.hour%12===0?12:d.hour%12,2);break;case"h":r+=String(d.hour%12===0?12:d.hour%12);break;case"mm":r+=H(d.minute,2);break;case"m":r+=String(d.minute);break;case"ss":r+=H(d.second,2);break;case"s":r+=String(d.second);break;case"SSS":r+=H(d.ms,3);break;case"a":r+=d.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ce=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function ie(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=x(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const d={timeZone:c};s.dateStyle&&(d.dateStyle=s.dateStyle),s.timeStyle&&(d.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,d);t=n=>r.format(n)}else{const d=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>d.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,m=(d,r)=>{const n=F(d);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),b=n.getTime()-l;if(Math.abs(b)<e){for(const[E,S]of ce)if(Math.abs(b)>=S||E==="second")return a.format(Math.round(b/S),E)}}return t(n)};return m.spec=s,m}function G(M){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=F(M);return f?G(f):null}const i=F(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function D(M,i){if(ae(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Y.test(u)){const t=F(u);return t?ee(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,g,e]=f;return`${t}T${a}:${g}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=F(u);return c?D(c):null}const s=F(M);return s?ee(s,i):null}const Y=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ee(M,i){const s=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(M).reduce((e,m)=>(m.type!=="literal"&&(e[m.type]=m.value),e),{}),a=t.hour==="24"?"00":t.hour,g=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(g?`:${t.second}`:"")}catch{}const u=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function z(M,i){const s=ae(M)||M===""?null:String(M),u=ae(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,fe){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return R}});const le=fe("packages/core/src/internal/util.js"),ae=le.isBlank,Q=le.toArray,q=le.warnOnce,_=fe("packages/core/src/format/date.js").toIsoDate,F=fe("packages/core/src/compute/handle.js"),H=F.bitReader,ne=F.dictSize,x=F.dictValue,ce=F.presenceReader,ie=F.valueComparator,G=F.valueReader,D=/^\\d{4}-\\d{2}-\\d{2}$/,Y="\\0null\\0";function ee(h,O){const w=h&&h.pool;if(w){const P=w.mask||w.acquireMask||w.acquire||w.take;if(typeof P=="function"){const v=P.call(w,O);if(v&&v.length>=O)return v}}return new Uint8Array(O)}function z(h,O){const w=h&&h.pool;if(!w||!O)return;const P=w.release||w.releaseMask||w.free||w.recycle;typeof P=="function"&&P.call(w,O)}function M(h,O,w){return h.fill(w,0,O),h}function i(h){return h==null||typeof h=="number"&&Number.isNaN(h)}function s(h,O){if(h==null)return h;if(O==="number")return typeof h=="number"?h:Number(h);if(O==="date"||O==="dateString"){const w=_(h);return w===null?u(h):w}return O==="boolean"?typeof h=="boolean"?h:h==="true"||h===1?!0:h==="false"||h===0?!1:!!h:h}function u(h){return h instanceof Date?h.getTime():typeof h=="number"?h:Date.parse(String(h))}function f(h){return typeof h=="number"?h:h instanceof Date?h.getTime():h==null||h===""?NaN:Number(h)}function c(h,O){const w=typeof h=="string"?h:String(h);return O?w:w.toLowerCase()}function t(h,O){return h==null?Y:typeof h=="string"?O?h:h.toLowerCase():h instanceof Date?h.getTime():h}function a(h,O,w){const P=new Set;for(const v of Q(h)){const K=s(v,w);P.add(t(K,O)),typeof K=="string"&&K!==""&&Number.isFinite(Number(K))?P.add(Number(K)):typeof K=="number"&&Number.isFinite(K)&&P.add(t(String(K),O))}return P}function g(h,O,w){if(h==null||O===null||O===void 0)return h==null&&O==null;const P=typeof h,v=typeof O;return P==="string"&&v==="string"?w?h===O:h.toLowerCase()===O.toLowerCase():h instanceof Date||O instanceof Date?u(h)===u(O):P==="number"&&v==="number"?h===O||Number.isNaN(h)&&Number.isNaN(O):P==="number"&&v==="string"?h===Number(O):P==="string"&&v==="number"?Number(h)===O:P==="boolean"||v==="boolean"?h===O:Array.isArray(h)&&Array.isArray(O)?h.length===O.length&&h.every((K,Z)=>g(K,O[Z],w)):h===O}function e(h,O){try{if(h instanceof RegExp){const w=h.flags.replace(/[gy]/g,"");return new RegExp(h.source,O||w.includes("i")?w:`${w}i`)}return new RegExp(String(h),O?"":"i")}catch(w){return q(`regex:${String(h)}`,`filter operator "matches" received an invalid pattern: ${String(h)}`,w),null}}function m(h,O){const w=d(h,O),P=h&&h.type;return P!=="date"&&P!=="dateString"?w:v=>w(typeof v=="string"&&D.test(v)?v:_(v)??v)}function d(h,O){const w=h&&h.op,P=!!(h&&h.caseSensitive),v=h&&h.type,K=ie(O),Z=oe=>se=>!oe(se);switch(w){case"eq":{const oe=s(h.value,v);return se=>g(se,oe,P)}case"ne":{const oe=s(h.value,v);return se=>!g(se,oe,P)}case"lt":case"lte":case"gt":case"gte":{const oe=s(h.value,v);if(i(oe))return()=>!1;const se=w==="lt"?-1:w==="lte"?0:w==="gt"?1:2;return T=>{if(i(T))return!1;const L=K(T,oe);return se===-1?L<0:se===0?L<=0:se===1?L>0:L>=0}}case"between":case"notBetween":{const oe=Q(h.value),se=s(oe[0],v),T=s(oe[1],v),L=h.bounds||"[]",J=L.charAt(0)!=="(",he=L.charAt(1)!==")";if(i(se)||i(T))return w==="between"?()=>!1:()=>!0;const ye=Me=>{if(i(Me))return!1;const Pe=K(Me,se),Ne=K(Me,T);return(J?Pe>=0:Pe>0)&&(he?Ne<=0:Ne<0)};return w==="between"?ye:Z(ye)}case"in":case"notIn":{const oe=a(h.value,P,v),se=T=>oe.has(t(T,P));return w==="in"?se:Z(se)}case"contains":case"notContains":{const oe=c(s(h.value,v),P),se=T=>T==null?!1:c(T,P).includes(oe);return w==="contains"?se:Z(se)}case"startsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).startsWith(oe)}case"endsWith":{const oe=c(s(h.value,v),P);return se=>se==null?!1:c(se,P).endsWith(oe)}case"matches":{const oe=e(h.value,P);return oe?se=>se==null?!1:oe.test(String(se)):()=>!1}case"blank":return oe=>ae(oe)||Array.isArray(oe)&&oe.length===0;case"notBlank":return oe=>!(ae(oe)||Array.isArray(oe)&&oe.length===0);case"containsAny":case"containsNone":{const oe=a(h.value,P,v),se=T=>{const L=T==null?[]:Q(T);for(let J=0;J<L.length;J++)if(oe.has(t(L[J],P)))return!0;return!1};return w==="containsAny"?se:Z(se)}case"containsAll":{const oe=Q(h.value).map(se=>t(s(se,v),P));return se=>{const T=se==null?[]:Q(se);if(oe.length===0)return!0;const L=new Set(T.map(J=>t(J,P)));for(let J=0;J<oe.length;J++)if(!L.has(oe[J]))return!1;return!0}}default:return q(`op:${String(w)}`,`unknown filter operator "${String(w)}"; the condition passes every row`),()=>!0}}function r(h,O,w){return m(O,w)(h)}function n(h,O,w,P){const v=ce(h);if(v){const oe=O?1:0;for(let se=0;se<P;se++)w[se]=v(se)===oe?1:0;return w}const K=h.kind;if(K==="float64"||K==="int32"||K==="bitset")return M(w,P,O?1:0);const Z=G(h);for(let oe=0;oe<P;oe++){const se=Z(oe),T=ae(se)||Array.isArray(se)&&se.length===0;w[oe]=T===O?0:1}return w}function l(h,O,w,P){const v=h.dict,K=ne(v),Z=new Uint8Array(K);for(let L=0;L<K;L++)Z[L]=O(x(v,L))?1:0;const oe=h.values,se=ce(h);if(!se){for(let L=0;L<P;L++)w[L]=Z[oe[L]];return w}const T=O(null)?1:0;for(let L=0;L<P;L++)w[L]=se(L)===1?Z[oe[L]]:T;return w}function b(h,O,w,P){const v=H(h.values),K=O(!0)?1:0,Z=O(!1)?1:0,oe=ce(h);if(!oe){for(let T=0;T<P;T++)w[T]=v(T)===1?K:Z;return w}const se=O(null)?1:0;for(let T=0;T<P;T++)w[T]=oe(T)===0?se:v(T)===1?K:Z;return w}function E(h,O,w,P,v){const K=h.values,Z=O.type,oe=O.op;let se=!0;switch(oe){case"eq":case"ne":{const L=f(s(O.value,Z)),J=typeof O.value=="number"&&Number.isNaN(O.value),he=oe==="ne"?1:0;if(J)for(let ye=0;ye<v;ye++)P[ye]=(Number.isNaN(K[ye])?1:0)^he;else for(let ye=0;ye<v;ye++)P[ye]=(K[ye]===L?1:0)^he;break}case"lt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<L?1:0;break}case"lte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]<=L?1:0;break}case"gt":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>L?1:0;break}case"gte":{const L=f(s(O.value,Z));for(let J=0;J<v;J++)P[J]=K[J]>=L?1:0;break}case"between":case"notBetween":{const L=Q(O.value),J=f(s(L[0],Z)),he=f(s(L[1],Z)),ye=O.bounds||"[]",Me=ye.charAt(0)!=="(",Pe=ye.charAt(1)!==")",Ne=oe==="notBetween"?1:0;if(Me&&Pe)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<=he?1:0)^Ne;else if(Me)for(let je=0;je<v;je++)P[je]=(K[je]>=J&K[je]<he?1:0)^Ne;else if(Pe)for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<=he?1:0)^Ne;else for(let je=0;je<v;je++)P[je]=(K[je]>J&K[je]<he?1:0)^Ne;break}case"in":case"notIn":{const L=new Set;for(const he of Q(O.value)){const ye=f(s(he,Z));Number.isNaN(ye)||L.add(ye)}const J=oe==="notIn"?1:0;for(let he=0;he<v;he++)P[he]=(L.has(K[he])?1:0)^J;break}default:se=!1;break}if(!se)return!1;const T=ce(h);if(T){const L=w(null)?1:0;for(let J=0;J<v;J++)T(J)===0&&(P[J]=L)}return!0}function S(h,O,w,P){const v=G(h);for(let K=0;K<P;K++)w[K]=O(v(K))?1:0;return w}function V(h,O,w){const P=O.count|0,v=w||ee(O,P);if(!h)return M(v,P,1);const K=typeof O.handle=="function"?O.handle(h.col):void 0,Z=typeof O.custom=="function"?O.custom:null;if(!K){if(Z){for(let T=0;T<P;T++)v[T]=Z(h,T)?1:0;return v}return q(`filter:col:${String(h.col)}`,`filter references unknown column "${String(h.col)}"; the condition passes every row`),M(v,P,1)}const oe=h.op;if(oe==="blank"||oe==="notBlank")return n(K,oe==="notBlank",v,P);const se=m(h,O.locale);switch(K.kind){case"dictionary":return l(K,se,v,P);case"bitset":return b(K,se,v,P);case"float64":case"int32":return E(K,h,se,v,P)?v:S(K,se,v,P);default:return S(K,se,v,P)}}function U(h,O,w){if(!h)return M(ee(O,w),w,1);if(Array.isArray(h.conditions)){const P=h.conditions.filter(Z=>Z!=null),v=h.op==="or"?"or":h.op==="not"?"not":"and";if(P.length===0)return M(ee(O,w),w,1);const K=U(P[0],O,w);for(let Z=1;Z<P.length;Z++){const oe=U(P[Z],O,w);if(v==="or")for(let se=0;se<w;se++)K[se]|=oe[se];else for(let se=0;se<w;se++)K[se]&=oe[se];z(O,oe)}if(v==="not")for(let Z=0;Z<w;Z++)K[Z]^=1;return K}return V(h,O,ee(O,w))}function I(h,O){return U(h,O,O.count|0)}function X(h,O){if(!h||!O)return h||null;const w=h;if(Array.isArray(w.conditions)){if((w.op==="or"?"or":w.op==="not"?"not":"and")!=="and")return C(w,O)?null:h;const v=[];for(const K of w.conditions){const Z=X(K,O);Z&&v.push(Z)}return v.length?{...w,op:"and",conditions:v}:null}return w.col===O?null:h}function C(h,O){if(!h||typeof h!="object")return!1;const w=h;if(w.col===O)return!0;if(Array.isArray(w.conditions)){for(const P of w.conditions)if(C(P,O))return!0}return!1}function R(h,O,w){if(w&&w.length>=O){let Z=0;for(let oe=0;oe<O;oe++)h[oe]&&(w[Z++]=oe);return w.subarray(0,Z)}let P=0;for(let Z=0;Z<O;Z++)P+=h[Z]?1:0;const v=new Uint32Array(P);let K=0;for(let Z=0;Z<O;Z++)h[Z]&&(v[K++]=Z);return v}}),Se("packages/core/src/compute/group.js",function(o,fe){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return ie}});const le=fe("packages/core/src/compute/handle.js"),ae=le.dictSize,Q=le.identity,q=le.presenceReader,te=le.rowCount,_=le.valueReader,F="",H="\\0",ne=1<<20;function x(G,D,Y,ee){const z=G.length,M=G.map(t=>_(t)),i=Array.isArray(ee)&&ee.some(Boolean),s=i?M.map((t,a)=>ee[a]?g=>ee[a](t(g)):t):M;if(!i&&z>0&&G.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=G.map(g=>ae(g.dict)+1);let a=1;for(let g=0;g<z;g++)a*=t[g];if(a<=Number.MAX_SAFE_INTEGER){const g=G.map(r=>r.values),e=G.map(r=>q(r)),m=r=>{let n=0;for(let l=0;l<z;l++){const b=e[l],E=b&&b(r)===0?t[l]-1:g[l][r];n=n*t[l]+E}return n},d=new Float64Array(Y);for(let r=0;r<Y;r++)d[r]=m(D[r]);return{packed:d,strings:null,product:a,readers:s,keyOf:m}}}const f=t=>{let a="";for(let g=0;g<z;g++){const e=s[g](t);a+=(g===0?"":F)+(e==null?H:String(e))}return a},c=new Array(Y);for(let t=0;t<Y;t++)c[t]=f(D[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ce(G,D,Y,ee){const z=new Uint32Array(ee+1);for(let u=0;u<Y;u++)z[D[u]+1]++;for(let u=0;u<ee;u++)z[u+1]+=z[u];const M=new Uint32Array(Y),i=z.slice(0,ee);for(let u=0;u<Y;u++)M[i[D[u]]++]=G[u];const s=new Array(ee);for(let u=0;u<ee;u++)s[u]=M.subarray(z[u],z[u+1]);return s}function ie(G,D,Y={}){const ee=G||[],z=D||Q(te(ee[0],Y)),M=z.length;if(ee.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=x(ee,z,M,Y.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(ne,M*4))){const d=u,r=new Int32Array(d).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<d;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<d;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const d=new Map;for(let r=0;r<M;r++){const n=i[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of d)a[n]=r}else{const d=new Map;for(let r=0;r<M;r++){const n=s[r];let l=d.get(n);l===void 0&&(l=t++,d.set(n,l)),c[r]=l}}const g=ce(z,c,M,t),e=new Array(t);for(let d=0;d<t;d++){const r=g[d][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[d]=n}const m={keys:e,buckets:g};return a&&(m.packed=a),m}}),Se("packages/core/src/compute/facet.js",function(o,fe){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=le.dictSize,te=le.dictValue,_=Object.freeze(["equal","quantile","log"]),F=Object.freeze(["hour","day","week","month","quarter","year"]),H=20,ne=50,x=1e4;function ce(n,l){if(!n)return"none";const b=l&&l.base;if(b==="date"||b==="datetime"||b==="time"||b==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return b==="number"?"numeric":b==="boolean"?"boolean":b==="text"?"category":"none"}}function ie(n){const l=n.values,b=n.kind;if((b==="float64"||b==="int32")&&l)return S=>l[S];const E=Q(n);return S=>G(E(S))}function G(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const l=Number(n);if(Number.isFinite(l))return l;const b=Date.parse(n);return Number.isFinite(b)?b:NaN}return NaN}function D(n,l,b,E=ne){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:q(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=Q(n),V=l?l.length:b,U=new Set;for(let I=0;I<V;I++){const X=S(l?l[I]:I);if(X!=null&&(U.add(X),U.size>E))return{cardinality:U.size,exact:!1}}return{cardinality:U.size,exact:!0}}const Y=36e5,ee=864e5;function z(n,l=H){const b=Number.isFinite(n)&&n>0?n:0,E=Math.max(1,l)*2;return b/Y<=E?"hour":b/ee<=E?"day":b/(7*ee)<=E?"week":b/(30*ee)<=E?"month":b/(91*ee)<=E?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const b=new Date(n);switch(l){case"hour":return b.setMinutes(0,0,0),b.getTime();case"day":return b.setHours(0,0,0,0),b.getTime();case"week":{b.setHours(0,0,0,0);const E=(b.getDay()+6)%7;return b.setDate(b.getDate()-E),b.getTime()}case"month":return b.setDate(1),b.setHours(0,0,0,0),b.getTime();case"quarter":return b.setMonth(Math.floor(b.getMonth()/3)*3,1),b.setHours(0,0,0,0),b.getTime();default:return b.setMonth(0,1),b.setHours(0,0,0,0),b.getTime()}}function i(n,l){const b=new Date(n);switch(l){case"hour":b.setHours(b.getHours()+1);break;case"day":b.setDate(b.getDate()+1);break;case"week":b.setDate(b.getDate()+7);break;case"month":b.setMonth(b.getMonth()+1);break;case"quarter":b.setMonth(b.getMonth()+3);break;default:b.setFullYear(b.getFullYear()+1);break}return b.getTime()}function s(n,l,b){const E=ie(n),S=ae(n),V=l?l.length:b;let U=1/0,I=-1/0,X=0,C=0;for(let R=0;R<V;R++){const h=l?l[R]:R;if(S&&!S(h)){X++;continue}const O=E(h);if(!Number.isFinite(O)){X++;continue}O<U&&(U=O),O>I&&(I=O),C++}return{min:U,max:I,nulls:X,finite:C}}function u(n,l,b,E){const S=ie(n),V=ae(n),U=l?l.length:b,I=U>E?U/E:1,X=[];for(let R=0;R<U;R+=I){const h=l?l[Math.floor(R)]:Math.floor(R);if(V&&!V(h))continue;const O=S(h);Number.isFinite(O)&&X.push(O)}const C=Float64Array.from(X);return C.sort(),C}function f(n,l,b,E={}){const S=E.kind||ce(n,E.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,b):S==="category"?t(n,l,b,E):a(n,l,b,S,E)}function c(n,l,b){const E=ae(n);let S=0;if(E){const U=l?l.length:b;for(let I=0;I<U;I++)E(l?l[I]:I)||S++}const V=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&V.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:V}}function t(n,l,b,E){const S=E.cardinalityLimit??ne,{cardinality:V}=D(n,l,b,S);if(V>S&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:V};const U=Q(n),I=l?l.length:b,X=new Map;let C=0;for(let P=0;P<I;P++){const v=U(l?l[P]:P);if(v==null||v===""){C++;continue}if(Array.isArray(v)){if(!v.length){C++;continue}for(const K of v)X.set(K,(X.get(K)||0)+1);continue}X.set(v,(X.get(v)||0)+1)}let R=[...X.entries()];E.order==="alpha"?R.sort((P,v)=>String(P[0]).localeCompare(String(v[0]))):R.sort((P,v)=>v[1]-P[1]);let h=0,O=0;if(R.length>S){O=R.length-S;for(let P=S;P<R.length;P++)h+=R[P][1];R=R.slice(0,S)}const w=R.map(([P])=>({value:P,label:String(P)}));return h>0&&w.push({remainder:!0,label:`Other (${O} values)`}),C>0&&w.push({null:!0,label:"Empty"}),{kind:"category",buckets:w,cardinality:V}}function a(n,l,b,E,S){const{min:V,max:U,nulls:I,finite:X}=s(n,l,b);if(!X)return{kind:E,buckets:I?[{null:!0,label:"Empty"}]:[],empty:!0};const C=Math.max(1,Math.floor(S.buckets||H));let R=[];if(E==="date"){const O=F.includes(S.granularity)?S.granularity:z(U-V,C);let w=M(V,O);for(;w<=U&&R.length<4096;){const P=i(w,O);if(!(P>w))break;R.push({from:w,to:P}),w=P}return{kind:E,buckets:g(R,I),granularity:O}}const h=_.includes(S.strategy)?S.strategy:"equal";if(h==="quantile"){const O=u(n,l,b,x);if(O.length){const w=[O[0]];for(let P=1;P<C;P++){const v=O[Math.min(O.length-1,Math.floor(P/C*O.length))];v>w[w.length-1]&&w.push(v)}w.push(U);for(let P=0;P<w.length-1;P++)R.push({from:w[P],to:w[P+1]})}}else if(h==="log"&&V>0){const O=Math.log10(V),P=(Math.log10(U)-O)/C||1;for(let v=0;v<C;v++)R.push({from:10**(O+v*P),to:10**(O+(v+1)*P)})}if(!R.length){const O=(U-V)/C||1;for(let w=0;w<C;w++)R.push({from:V+w*O,to:V+(w+1)*O})}return R[R.length-1].to=U,{kind:E,buckets:g(R,I),strategy:h,min:V,max:U}}function g(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,b,E,S){const V=E&&E.buckets||[],U=S&&S.length>=V.length?S.subarray(0,V.length):new Uint32Array(V.length);if(U.fill(0),!n||!V.length)return U;const I=V.length-1,X=!!V[I]&&V[I].null===!0,C=l?l.length:b;if(E.kind==="boolean"){const P=Q(n);for(let v=0;v<C;v++){const K=P(l?l[v]:v);if(K==null){X&&U[I]++;continue}U[K?1:0]++}return U}if(E.kind==="category"){const P=new Map;for(let Z=0;Z<V.length;Z++)!V[Z].null&&!V[Z].remainder&&P.set(V[Z].value,Z);const v=V.findIndex(Z=>Z.remainder),K=Q(n);for(let Z=0;Z<C;Z++){const oe=K(l?l[Z]:Z);if(oe==null||oe===""){X&&U[I]++;continue}if(Array.isArray(oe)){if(!oe.length){X&&U[I]++;continue}for(const T of oe){const L=P.get(T);L!==void 0?U[L]++:v>=0&&U[v]++}continue}const se=P.get(oe);se!==void 0?U[se]++:v>=0&&U[v]++}return U}const R=X?V.length-1:V.length,h=new Float64Array(R+1);for(let P=0;P<R;P++)h[P]=V[P].from;h[R]=R?V[R-1].to:0;const O=ie(n),w=ae(n);for(let P=0;P<C;P++){const v=l?l[P]:P;if(w&&!w(v)){X&&U[I]++;continue}const K=O(v);if(!Number.isFinite(K)){X&&U[I]++;continue}const Z=m(h,R,K);Z>=0&&U[Z]++}return U}function m(n,l,b){if(!l||b<n[0])return-1;if(b>=n[l])return b===n[l]?l-1:-1;let E=0,S=l-1;for(;E<S;){const V=E+S+1>>>1;b>=n[V]?E=V:S=V-1}return E}function d(n,l,b,E={}){const S=E.bounds||f(n,E.boundsIndices??l,b,E);return{bounds:S,counts:e(n,l,b,S)}}const r=d}),Se("packages/core/src/compute/special.js",function(o,fe){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ee}});const le=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),ae=3e-12,Q=1e-300;function q(z){if(z<.5)return Math.log(Math.PI/Math.sin(Math.PI*z))-q(1-z);const M=z-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<le.length;u++)i+=le[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(z,M,i){const s=z+M,u=z+1,f=z-1;let c=1,t=1-s*i/u;Math.abs(t)<Q&&(t=Q),t=1/t;let a=t;for(let g=1;g<=300;g++){const e=2*g;let m=g*(M-g)*i/((f+e)*(z+e));t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t,a*=t*c,m=-(z+g)*(s+g)*i/((z+e)*(u+e)),t=1+m*t,Math.abs(t)<Q&&(t=Q),c=1+m/c,Math.abs(c)<Q&&(c=Q),t=1/t;const d=t*c;if(a*=d,Math.abs(d-1)<ae)break}return a}function _(z,M,i){if(!(z>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(q(z+M)-q(z)-q(M)+z*Math.log(i)+M*Math.log(1-i));return i<(z+1)/(z+M+2)?s*te(z,M,i)/z:1-s*te(M,z,1-i)/M}function F(z){if(!(z>0)||!(z<1))return z===0?-1/0:z===1?1/0:Number.NaN;const M=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let c,t,a;z<f?(c=Math.sqrt(-2*Math.log(z)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):z<=1-f?(c=z-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-z)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1));const e=(.5*H(-a/Math.SQRT2)-z)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function H(z){const M=Math.abs(z),i=2/(2+M),s=4*i-2,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let f=0,c=0,t;for(let g=u.length-1;g>0;g--)t=c,c=s*c-f+u[g],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return z>=0?a:2-a}function ne(z){return .5*H(-z/Math.SQRT2)}function x(z,M){if(!(M>0)||!Number.isFinite(z))return Number.NaN;const i=.5*_(M/2,.5,M/(M+z*z));return z>0?1-i:i}function ce(z,M){if(!(z>0)||!(z<1)||!(M>0))return Number.NaN;if(M>1e7)return F(z);let i=-1e4,s=1e4,u=F(z);const f=q(M/2)+q(.5)-q((M+1)/2);for(let c=0;c<60;c++){const t=x(u,M);t<z?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),g=a>0?(t-z)/a:0;if(Math.abs(g)<1e-12)break;const e=u-g;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function ie(z,M){let i=z,s=1/z,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*ae));f++);return s*Math.exp(-M+z*Math.log(M)-q(z))}function G(z,M){let i=M+1-z,s=1/Q,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-z);i+=2,u=t*u+i,Math.abs(u)<Q&&(u=Q),s=i+t/s,Math.abs(s)<Q&&(s=Q),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<ae)break}return Math.exp(-M+z*Math.log(M)-q(z))*f}function D(z,M){return!(z>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<z+1?ie(z,M):1-G(z,M)}function Y(z,M){return M>0?D(M/2,z/2):Number.NaN}function ee(z,M){const i=Y(z,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,fe){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return _}});function le(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++)for(let ce=0;ce<=x;ce++){let ie=F[x][ce];for(let G=0;G<ce;G++)ie-=ne[x][G]*ne[ce][G];if(x===ce){if(!(ie>0))return null;ne[x][ce]=Math.sqrt(ie)}else ne[x][ce]=ie/ne[ce][ce]}return ne}function ae(F,H){const ne=F.length,x=new Array(ne).fill(0);for(let ie=0;ie<ne;ie++){let G=H[ie];for(let D=0;D<ie;D++)G-=F[ie][D]*x[D];x[ie]=G/F[ie][ie]}const ce=new Array(ne).fill(0);for(let ie=ne-1;ie>=0;ie--){let G=x[ie];for(let D=ie+1;D<ne;D++)G-=F[D][ie]*ce[D];ce[ie]=G/F[ie][ie]}return ce}function Q(F){const H=F.length,ne=Array.from({length:H},()=>new Array(H).fill(0));for(let x=0;x<H;x++){const ce=new Array(H).fill(0);ce[x]=1;const ie=ae(F,ce);for(let G=0;G<H;G++)ne[G][x]=ie[G]}return ne}function q(F,H,ne){const x=F.length,ce=x?F[0].length:0,ie=Array.from({length:ce},()=>new Array(ce).fill(0)),G=new Array(ce).fill(0);for(let D=0;D<x;D++){const Y=ne?ne[D]:1,ee=F[D];for(let z=0;z<ce;z++){const M=Y*ee[z];G[z]+=M*H[D];for(let i=z;i<ce;i++)ie[z][i]+=M*ee[i]}}for(let D=0;D<ce;D++)for(let Y=0;Y<D;Y++)ie[D][Y]=ie[Y][D];return{xtwx:ie,xtwy:G}}function te(F,H){return F.map(ne=>ne.reduce((x,ce,ie)=>x+ce*H[ie],0))}function _(F,H){let ne=0;for(let x=0;x<F.length;x++){let ce=0;for(let ie=0;ie<F.length;ie++)ce+=H[x][ie]*F[ie];ne+=F[x]*ce}return ne}}),Se("packages/core/src/compute/sketch.js",function(o,fe){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return ie}});class le{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(D){if(!Number.isFinite(D))return;this.#t++;const Y=D-this.#e;this.#e+=Y/this.#t,this.#n+=Y*(D-this.#e)}merge(D){if(D.#t===0)return;if(this.#t===0){this.#t=D.#t,this.#e=D.#e,this.#n=D.#n;return}const Y=this.#t+D.#t,ee=D.#e-this.#e;this.#e+=ee*(D.#t/Y),this.#n+=D.#n+ee*ee*(this.#t*D.#t/Y),this.#t=Y}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const D=this.variance();return D===null?null:Math.sqrt(D)}stddevP(){const D=this.varianceP();return D===null?null:Math.sqrt(D)}}class ae{#t=[];#e=0;#n;#r;constructor(D,Y=Math.random){if(!(D>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(D),this.#r=Y}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(D){if(!Number.isFinite(D))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(D);return}const Y=Math.floor(this.#r()*this.#e);Y<this.#n&&(this.#t[Y]=D)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let D=0;for(const Y of this.#t)D+=Y;return D/this.#t.length}quantile(D){const Y=this.#t.length;if(!Y)return null;const ee=this.#t.slice().sort((s,u)=>s-u);if(Y===1)return ee[0];const z=(Y-1)*Math.min(1,Math.max(0,D)),M=Math.floor(z),i=Math.ceil(z);return M===i?ee[M]:ee[M]+(z-M)*(ee[i]-ee[M])}}function Q(G){return G^=G>>>16,G=Math.imul(G,2246822507),G^=G>>>13,G=Math.imul(G,3266489909),G^=G>>>15,G>>>0}function q(G){if(typeof G=="number"){const ee=new DataView(new ArrayBuffer(8));return ee.setFloat64(0,G===0?0:G),Q(ee.getUint32(0)^ee.getUint32(4))}const D=typeof G=="string"?G:String(G);let Y=2166136261;for(let ee=0;ee<D.length;ee++)Y^=D.charCodeAt(ee),Y=Math.imul(Y,16777619);return Q(Y)}class te{#t;#e;#n;constructor(D=14){const Y=Math.floor(D);if(Y<4||Y>16)throw new RangeError("HLL precision must be 4..16");this.#t=Y,this.#e=1<<Y,this.#n=new Uint8Array(this.#e)}static errorBoundFor(D=14){const Y=1<<Math.floor(D),ee=1.04/Math.sqrt(Y);return Object.freeze({kind:"probabilistic",metric:"relative",value:ee,statement:`distinct count within ~${(ee*100).toFixed(2)}% relative standard error (m=${Y} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(D){const Y=q(D),ee=Y&this.#e-1,z=Y>>>this.#t|1<<32-this.#t;let M=1,i=z;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[ee]&&(this.#n[ee]=M)}count(){const D=this.#e,Y=32-this.#t,ee=new Float64Array(Y+2);for(let i=0;i<D;i++)ee[this.#n[i]]++;let z=D*H(1-ee[Y+1]/D);for(let i=Y;i>=1;i--)z=.5*(z+ee[i]);z+=D*F(ee[0]/D);const M=_*D*D/z;return Math.round(M)}}const _=.5/Math.log(2);function F(G){if(G===1)return 1/0;let D=1,Y=G,ee;do G*=G,ee=Y,Y+=G*D,D+=D;while(Y!==ee);return Y}function H(G){if(G===0||G===1)return 0;let D=1,Y=1-G,ee;do G=Math.sqrt(G),ee=Y,D*=.5,Y-=(1-G)**2*D;while(Y!==ee);return Y/3}class ne{#t=new Map;#e;#n=0;constructor(D){if(!(D>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(D)}errorBoundFor(D){const Y=D/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Y,statement:`each count overestimates the truth by at most N/m = ${Y.toFixed(2)} (N=${D}, m=${this.#e})`})}get seen(){return this.#n}add(D){this.#n++;const Y=this.#t.get(D);if(Y){Y.count++;return}if(this.#t.size<this.#e){this.#t.set(D,{count:1,error:0});return}let ee,z=1/0;for(const[M,i]of this.#t)i.count<z&&(z=i.count,ee=M);this.#t.delete(ee),this.#t.set(D,{count:z+1,error:z})}top(D=this.#e){return[...this.#t.entries()].map(([ee,z])=>({item:ee,count:z.count,error:z.error})).sort((ee,z)=>z.count-ee.count).slice(0,Math.max(0,Math.floor(D)))}}class x{#t;#e=[[]];#n=0;#r;#i;constructor(D=200,Y=Math.random){this.#t=Math.max(8,Math.floor(D)),this.#r=Y,this.#i=2/3}static errorBoundFor(D=200){const Y=1/Math.max(8,Math.floor(D));return Object.freeze({kind:"probabilistic",metric:"rank",value:Y,statement:`queried quantile\'s true rank within ~${(Y*100).toFixed(2)}% of N of the requested rank (k=${D})`})}errorBound(){return x.errorBoundFor(this.#t)}get count(){return this.#n}#s(D){const ee=this.#e.length-1-D,z=Math.ceil(this.#t*this.#i**ee);return Math.max(2,z)}add(D){Number.isFinite(D)&&(this.#n++,this.#e[0].push(D),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(D){const Y=this.#e[D];Y.sort((M,i)=>M-i),D+1>=this.#e.length&&this.#e.push([]);const ee=this.#e[D+1],z=this.#r()<.5?0:1;for(let M=z;M<Y.length;M+=2)ee.push(Y[M]);this.#e[D]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const D=[];for(let Y=0;Y<this.#e.length;Y++){const ee=1<<Y;for(const z of this.#e[Y])D.push({v:z,w:ee})}return D}quantile(D){const Y=this.#u();if(!Y.length)return null;Y.sort((i,s)=>i.v-s.v);let ee=0;for(const i of Y)ee+=i.w;const z=Math.min(1,Math.max(0,D))*ee;let M=0;for(const i of Y)if(M+=i.w,M>=z)return i.v;return Y[Y.length-1].v}rank(D){let Y=0;for(let ee=0;ee<this.#e.length;ee++){const z=1<<ee;for(const M of this.#e[ee])M<=D&&(Y+=z)}return Y}}const ce=Object.freeze({distinct:te.errorBoundFor(14),median:x.errorBoundFor(200),p25:x.errorBoundFor(200),p75:x.errorBoundFor(200),p90:x.errorBoundFor(200),p95:x.errorBoundFor(200),p99:x.errorBoundFor(200),iqr:x.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),ie={Welford:le,Reservoir:ae,HyperLogLog:te,SpaceSaving:ne,KLL:x,hash32:q,SKETCH_BOUNDS:ce}}),Se("packages/core/src/compute/statistics.js",function(o,fe){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return it}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const le=fe("packages/core/src/compute/handle.js"),ae=le.presenceReader,Q=le.valueReader,q=fe("packages/core/src/compute/special.js"),te=q.studentTQuantile,_=q.studentT,F=q.normalQuantile,H=q.normalCdf,ne=q.chiSquareUpperTail,x=fe("packages/core/src/compute/linalg.js"),ce=x.cholesky,ie=x.choleskySolve,G=x.choleskyInverse,D=x.normalEquations,Y=x.quadForm,z=fe("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:z.distinct}),median:Object.freeze({sketch:"KLL",bound:z.median}),p25:Object.freeze({sketch:"KLL",bound:z.p25}),p75:Object.freeze({sketch:"KLL",bound:z.p75}),p90:Object.freeze({sketch:"KLL",bound:z.p90}),p95:Object.freeze({sketch:"KLL",bound:z.p95}),p99:Object.freeze({sketch:"KLL",bound:z.p99}),iqr:Object.freeze({sketch:"KLL",bound:z.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:z.topK})});function u(y){const A=y==="sum"||y==="avg"||y==="countValues"||y==="min"||y==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,y)?i[y]:null,p=Object.prototype.hasOwnProperty.call(s,y)?s[y]:null;return{stat:y,exact:A,approximate:p}}function f(y,A){const p=A.length,k=new Float64Array(p);let j=0;if(y&&(y.kind==="float64"||y.kind==="int32")){const B=y.values,$=ae(y);for(let re=0;re<p;re++){const ue=A[re];if($&&$(ue)!==1)continue;const ge=B[ue];Number.isNaN(ge)||(k[j++]=ge)}return k.subarray(0,j)}const W=Q(y);for(let B=0;B<p;B++){const $=W(A[B]);if($==null||$==="")continue;const re=typeof $=="number"?$:Number($);Number.isFinite(re)&&(k[j++]=re)}return k.subarray(0,j)}function c(y,A){const p=new Map,k=Q(y);let j=0;for(let W=0;W<A.length;W++){const B=k(A[W]);if(B==null||B===""||typeof B=="number"&&Number.isNaN(B))continue;const $=typeof B=="object"?String(B):B;p.set($,(p.get($)||0)+1),j++}const N=[...p.values()].sort((W,B)=>B-W);return{counts:N,total:j,distinct:N.length}}function t(y){return y.total>0?y.counts.map(A=>A/y.total):[]}function a(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))k+=j*j;return k}function g(y,A){const p=c(y,A);if(!p.total)return null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k}function e(y,A){const p=c(y,A);if(!p.total||p.distinct<2)return p.total?1:null;let k=0;for(const j of t(p))j>0&&(k-=j*Math.log2(j));return k/Math.log2(p.distinct)}function m(y,A,p=3){const k=c(y,A);if(!k.total)return null;const j=Math.max(1,Math.floor(p));let N=0;for(let W=0;W<Math.min(j,k.counts.length);W++)N+=k.counts[W];return N/k.total}function d(y,A){const p=f(y,A),k=p.length;if(!k)return null;const j=p.slice().sort();if(j[0]<0)return null;let N=0,W=0;for(let B=0;B<k;B++)N+=j[B],W+=(B+1)*j[B];return N===0?0:2*W/(k*N)-(k+1)/k}function r(y){let A=0,p=0,k=0;for(let j=0;j<y.length;j++){const N=y[j];A++;const W=N-p;p+=W/A,k+=W*(N-p)}return{n:A,mean:p,m2:k}}function n(y,A){const p=y.length;if(!p)return NaN;if(p===1)return y[0];const k=(p-1)*Math.min(1,Math.max(0,A)),j=Math.floor(k),N=Math.ceil(k);return j===N?y[j]:y[j]+(k-j)*(y[N]-y[j])}function l(y,A){if(!y.length)return NaN;const p=y.slice().sort();return n(p,A)}function b(y,A){const p=Q(y);let k=0,j=0,N=0;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=String(B).toUpperCase();$==="PASS"?k++:$==="FAIL"?j++:$==="WARN"&&N++}return{pass:k+N,fail:j,warn:N,judged:k+N+j}}const E=Object.freeze({hhi:(y,A)=>a(y,A),entropy:(y,A)=>g(y,A),evenness:(y,A)=>e(y,A),top3Share:(y,A)=>m(y,A,3),top10Share:(y,A)=>m(y,A,10),gini:(y,A)=>d(y,A),trimmedMean:(y,A)=>X(f(y,A),.1),winsorizedMean:(y,A)=>C(f(y,A),.1),robustOutliers:(y,A)=>R(f(y,A),3.5),jarqueBera:(y,A)=>h(f(y,A)),variance:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?k/(p-1):null},varianceP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?k/p:null},stddev:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>1?Math.sqrt(k/(p-1)):null},stddevP:(y,A)=>{const{n:p,m2:k}=r(f(y,A));return p>0?Math.sqrt(k/p):null},median:(y,A)=>{const p=f(y,A);return p.length?l(p,.5):null},p25:(y,A)=>{const p=f(y,A);return p.length?l(p,.25):null},p75:(y,A)=>{const p=f(y,A);return p.length?l(p,.75):null},p90:(y,A)=>{const p=f(y,A);return p.length?l(p,.9):null},p95:(y,A)=>{const p=f(y,A);return p.length?l(p,.95):null},p99:(y,A)=>{const p=f(y,A);return p.length?l(p,.99):null},iqr:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=p.slice().sort();return n(k,.75)-n(k,.25)},mad:(y,A)=>{const p=f(y,A);if(!p.length)return null;const k=l(p,.5),j=new Float64Array(p.length);for(let N=0;N<p.length;N++)j[N]=Math.abs(p[N]-k);return l(j,.5)},range:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=1/0,j=-1/0;for(let N=0;N<p.length;N++)p[N]<k&&(k=p[N]),p[N]>j&&(j=p[N]);return j-k},distinct:(y,A)=>{const p=Q(y),k=new Set;for(let j=0;j<A.length;j++){const N=p(A[j]);N==null||N===""||k.add(N instanceof Date?N.getTime():N)}return k.size},mode:(y,A)=>{const p=Q(y),k=new Map;for(let W=0;W<A.length;W++){const B=p(A[W]);if(B==null||B==="")continue;const $=B instanceof Date?B.getTime():B;k.set($,(k.get($)||0)+1)}let j=null,N=1;for(const[W,B]of k)B>N&&(N=B,j=W);return j},skewness:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<3||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let $=0;$<p.length;$++)B+=((p[$]-j)/W)**3;return k/((k-1)*(k-2))*B},kurtosis:(y,A)=>{const p=f(y,A),{n:k,mean:j,m2:N}=r(p);if(k<4||N<=0)return null;const W=Math.sqrt(N/(k-1));let B=0;for(let ue=0;ue<p.length;ue++)B+=((p[ue]-j)/W)**4;const $=k*(k+1)/((k-1)*(k-2)*(k-3)),re=3*(k-1)**2/((k-2)*(k-3));return $*B-re},geomean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]<=0)return null;k+=Math.log(p[j])}return Math.exp(k/p.length)},harmean:(y,A)=>{const p=f(y,A);if(!p.length)return null;let k=0;for(let j=0;j<p.length;j++){if(p[j]===0)return null;k+=1/p[j]}return p.length/k},sumSquares:(y,A)=>{const p=f(y,A);let k=0;for(let j=0;j<p.length;j++)k+=p[j]*p[j];return k},passRate:(y,A)=>{const{pass:p,judged:k}=b(y,A);return k?p/k:null},failureCount:(y,A)=>b(y,A).fail}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function V(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0;for(let B=0;B<p.length;B++){const $=p[B],re=Number(k($)),ue=Number(j($));!Number.isFinite(re)||!Number.isFinite(ue)||(N+=re*ue,W+=ue)}return W===0?null:N/W}function U(y,A,p){const k=Q(y);let j=null,N=p?-1/0:1/0;for(let W=0;W<A.length;W++){const B=A[W],$=Number(k(B));Number.isFinite($)&&(p?$>N:$<N)&&(N=$,j=B)}return j}function I(y,A,p){const k=Q(y),j=Q(A);let N=0,W=0,B=0,$=0,re=0,ue=0;for(let de=0;de<p.length;de++){const we=p[de],ke=Number(k(we)),me=Number(j(we));!Number.isFinite(ke)||!Number.isFinite(me)||(N++,W+=ke,B+=me,$+=ke*ke,re+=me*me,ue+=ke*me)}if(N<2)return null;const ge=N*ue-W*B,be=Math.sqrt((N*$-W*W)*(N*re-B*B));if(be===0)return null;const pe=ge/be;return Math.max(-1,Math.min(1,pe))}function X(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort((B,$)=>B-$),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k.slice(j,p-j);if(!N.length)return n(k,.5);let W=0;for(const B of N)W+=B;return W/N.length}function C(y,A=.1){const p=y.length;if(!p)return null;const k=Array.from(y).sort(($,re)=>$-re),j=Math.floor(p*Math.min(.49,Math.max(0,A))),N=k[j],W=k[p-1-j];let B=0;for(const $ of k)B+=Math.min(W,Math.max(N,$));return B/p}function R(y,A=3.5){if(!y.length)return null;const k=Array.from(y).sort(($,re)=>$-re),j=n(k,.5),N=k.map($=>Math.abs($-j)).sort(($,re)=>$-re),W=n(N,.5);if(W===0)return null;let B=0;for(const $ of k)Math.abs(.6745*($-j)/W)>A&&B++;return B}function h(y){const A=y.length;if(A<8)return null;let p=0;for(const $ of y)p+=$;p/=A;let k=0,j=0,N=0;for(const $ of y){const re=$-p;k+=re*re,j+=re*re*re,N+=re*re*re*re}if(k/=A,j/=A,N/=A,k===0)return null;const W=j/k**1.5,B=N/(k*k)-3;return A/6*(W*W+B*B/4)}function O(y,A,p){const k=[];let j=0;for(let $=0;$<y.length;$++){const re=Number(y[$]),ue=Number(A[$]);!Number.isFinite(re)||!Number.isFinite(ue)||ue<=0||(k.push([re,ue]),j+=ue)}if(!k.length||j<=0)return null;if(k.sort(($,re)=>$[0]-re[0]),k.length===1)return k[0][0];const N=[];let W=0;for(const[,$]of k)N.push((W+$/2)/j),W+=$;const B=Math.max(0,Math.min(1,p));if(B<=N[0])return k[0][0];if(B>=N[N.length-1])return k[k.length-1][0];for(let $=1;$<N.length;$++){if(B>N[$])continue;const re=N[$]-N[$-1],ue=re>0?(B-N[$-1])/re:0;return k[$-1][0]+(k[$][0]-k[$-1][0])*ue}return k[k.length-1][0]}function w(y,A,p){const k=Q(y),j=Q(A),N=new Float64Array(p.length),W=new Float64Array(p.length);let B=0;for(let $=0;$<p.length;$++){const re=p[$],ue=Number(k(re)),ge=Number(j(re));!Number.isFinite(ue)||!Number.isFinite(ge)||(N[B]=ue,W[B]=ge,B++)}return{xs:N.subarray(0,B),ys:W.subarray(0,B),n:B}}function P(y,A,p,k=!1){const{xs:j,ys:N,n:W}=w(y,A,p);if(W<2)return null;let B=0,$=0;for(let ue=0;ue<W;ue++)B+=j[ue],$+=N[ue];B/=W,$/=W;let re=0;for(let ue=0;ue<W;ue++)re+=(j[ue]-B)*(N[ue]-$);return re/(k?W:W-1)}function v(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;let W=0,B=0;for(let ke=0;ke<N;ke++)W+=k[ke],B+=j[ke];W/=N,B/=N;let $=0,re=0,ue=0;for(let ke=0;ke<N;ke++){const me=k[ke]-W,ve=j[ke]-B;$+=me*me,re+=me*ve,ue+=ve*ve}if($===0)return null;const ge=re/$,be=B-ge*W,pe=ue===0?1:Math.max(0,Math.min(1,re*re/($*ue))),de=Math.max(0,ue-ge*re),we=N>2?Math.sqrt(de/(N-2)/$):0;return{slope:ge,intercept:be,r2:pe,stdError:we,n:N}}const K=new Set(["ols","wls","robust"]),Z=new Set(["quantile"]),oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),se=1.345;function T(y,A,p){const{xtwx:k,xtwy:j}=D(y,A,p),N=ce(k);if(!N)return null;const W=ie(N,j),B=G(N),$=L(y,W),re=A.map((ue,ge)=>ue-$[ge]);return{beta:W,cov:B,fitted:$,residuals:re}}function L(y,A){return y.map(p=>p.reduce((k,j,N)=>k+j*A[N],0))}function J(y,A){const p=y.length,k=y.map(re=>re[A]),j=y.map(re=>[1,...re.filter((ue,ge)=>ge!==A)]),N=T(j,k,null);if(!N)return 1;const W=k.reduce((re,ue)=>re+ue,0)/p;let B=0,$=0;for(let re=0;re<p;re++)B+=N.residuals[re]**2,$+=(k[re]-W)**2;return $===0?1:Math.max(0,Math.min(1,1-B/$))}function he(y){const A=[...y].sort((j,N)=>j-N),p=ye(A),k=y.map(j=>Math.abs(j-p)).sort((j,N)=>j-N);return ye(k)/.6745}function ye(y){const A=y.length;if(!A)return 0;const p=Math.floor(A/2);return A%2?y[p]:(y[p-1]+y[p])/2}function Me(y,A,p={}){const k=p.method||"ols";if(oe.has(k))throw new Error(`[lattice] regression method "${k}" is out of scope; use ols, wls or robust.`);if(Z.has(k))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(k))throw new Error(`[lattice] unknown regression method "${k}"; use ols, wls or robust.`);const j=Array.isArray(A)?A.length:0,N=j&&Array.isArray(y[0])?y[0].length:0,W=N+1;if(!(j>W))return null;for(let Oe=0;Oe<j;Oe++){if(!Number.isFinite(A[Oe])||!Array.isArray(y[Oe])||y[Oe].length!==N)return null;for(let Ae=0;Ae<N;Ae++)if(!Number.isFinite(y[Oe][Ae]))return null}let B=null;if(k==="wls"){if(B=p.weights,!Array.isArray(B)||B.length!==j)return null;for(let Oe=0;Oe<j;Oe++)if(!(B[Oe]>0)||!Number.isFinite(B[Oe]))return null}const $=y.map(Oe=>[1,...Oe]);let re,ue=null;if(k==="robust"){if(re=T($,A,null),!re)return null;for(let Oe=0;Oe<50;Oe++){const Ae=he(re.residuals);if(!(Ae>0))break;const Te=re.residuals.map(Ie=>{const Be=Math.abs(Ie/Ae);return Be<=se?1:se/Be}),Re=T($,A,Te);if(!Re)return null;const ze=Re.beta.reduce((Ie,Be,Qe)=>Math.max(Ie,Math.abs(Be-re.beta[Qe])),0);if(re=Re,ue=Te,ze<1e-10)break}}else if(re=T($,A,B),!re)return null;const ge=k==="robust"?ue:B,{beta:be,cov:pe,fitted:de,residuals:we}=re;let ke=0,me=0,ve=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;ke+=Ae*we[Oe]**2,me+=Ae,ve+=Ae*A[Oe]}const Ee=ve/me;let Le=0;for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1;Le+=Ae*(A[Oe]-Ee)**2}const Fe=j-W,De=ke/Fe,Ce=Le===0?1:Math.max(0,Math.min(1,1-ke/Le)),_e=1-(1-Ce)*(j-1)/Fe,Ge=Array.isArray(p.names)&&p.names.length===N?p.names:y[0].map((Oe,Ae)=>`x${Ae+1}`),Ue=He(p.confidence),Ye=Fe>0?te(1-(1-Ue)/2,Fe):1/0,Lt=be.map((Oe,Ae)=>{const Te=Math.sqrt(Math.max(0,De*pe[Ae][Ae])),Re=Te>0?Oe/Te:Oe===0?0:1/0,ze=Number.isFinite(Re)?2*(1-_(Math.abs(Re),Fe)):0,Ie=Number.isFinite(Ye)?Ye*Te:null;return{name:Ae===0?"(intercept)":Ge[Ae-1],estimate:Oe,stdError:Te,t:Re,p:Math.max(0,Math.min(1,ze)),lower:Ie===null?null:Oe-Ie,upper:Ie===null?null:Oe+Ie}}),ft=new Array(j),ht=new Array(j);for(let Oe=0;Oe<j;Oe++){const Ae=ge?ge[Oe]:1,Te=Math.max(0,Math.min(1,Ae*Y($[Oe],pe)));ft[Oe]=Te;const Re=(1-Te)**2;ht[Oe]=Re>0&&De>0?we[Oe]**2/(W*De)*(Te/Re):null}const Ft=y[0].map((Oe,Ae)=>{if(N<2)return 1;const Te=J(y,Ae);return Te>=1?1/0:1/(1-Te)});let dt=null;{const Oe=we.map(Te=>Te*Te),Ae=T($,Oe,null);if(Ae){const Te=Oe.reduce((Ke,Ct)=>Ke+Ct,0)/j;let Re=0,ze=0;for(let Ke=0;Ke<j;Ke++)Re+=Ae.residuals[Ke]**2,ze+=(Oe[Ke]-Te)**2;const Ie=ze===0?0:Math.max(0,Math.min(1,1-Re/ze)),Be=j*Ie,Qe=ne(Be,N);dt={statistic:Be,df:N,p:Qe,heteroscedastic:Qe<.05}}}let mt=null;if(N===1){const Oe=y.map((Ae,Te)=>Te).sort((Ae,Te)=>y[Ae][0]-y[Te][0]);mt={confidence:Ue,points:Oe.map(Ae=>{const Te=$[Ae],Re=Math.sqrt(Math.max(0,De*Y(Te,pe)));return{x:y[Ae][0],yhat:de[Ae],lower:de[Ae]-Ye*Re,upper:de[Ae]+Ye*Re}})}}return{method:k,coefficients:Lt,r2:Ce,adjR2:_e,n:j,df:Fe,sigma2:De,fitted:de,residuals:we,leverage:ft,cooksD:ht,vif:Ft,heteroscedasticity:dt,band:mt,weights:ge?[...ge]:null}}function Pe(y){const A=y.length,p=Array.from({length:A},(N,W)=>W).sort((N,W)=>y[N]-y[W]),k=new Float64Array(A);let j=0;for(;j<A;){let N=j;for(;N+1<A&&y[p[N+1]]===y[p[j]];)N++;const W=(j+N)/2+1;for(let B=j;B<=N;B++)k[p[B]]=W;j=N+1}return k}const Ne=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(y){const A=[.01,.05,.1],p=[Ne["1%"],Ne["5%"],Ne["10%"]];if(y<=p[0]){const N=(Math.log(A[1])-Math.log(A[0]))/(p[1]-p[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(A[0])+N*(y-p[0]))))}if(y>=p[2]){const N=(Math.log(A[2])-Math.log(A[1]))/(p[2]-p[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(A[2])+N*(y-p[2]))))}const k=y<p[1]?0:1,j=(y-p[k])/(p[k+1]-p[k]);return Math.exp(Math.log(A[k])+j*(Math.log(A[k+1])-Math.log(A[k])))}function Ve(y,A,p,k){const j=p-k,N=k+3,W=new Array(j),B=new Array(j);let $=!0,re=k;for(let de=0;de<j;de++){const we=k+de,ke=new Float64Array(N);ke[0]=1,ke[1]=de+1,ke[2]=y[we];for(let me=1;me<=k;me++)ke[2+me]=A[we-me];for(let me=1;me<N;me++)Number.isFinite(ke[me])||(re=Math.min(re,me-3));W[de]=ke,B[de]=A[we],Number.isFinite(B[de])||($=!1)}if(!$)return 0;const{xtwx:ue,xtwy:ge}=D(W,B,null);let be=0,pe=1/0;for(let de=0;de<=re;de++){const we=de+3;if(!(j>we))continue;const ke=new Array(we);for(let Ce=0;Ce<we;Ce++)ke[Ce]=ue[Ce].slice(0,we);const me=ce(ke);if(!me)continue;const ve=ie(me,ge.slice(0,we));let Ee=0;for(let Ce=0;Ce<j;Ce++){const _e=W[Ce];let Ge=0;for(let Ue=0;Ue<we;Ue++)Ge+=_e[Ue]*ve[Ue];Ee+=(B[Ce]-Ge)**2}const Fe=Ee/(j-we)*(j-we);if(!(Fe>0))continue;const De=j*Math.log(Fe/j)+2*we;De<pe&&(pe=De,be=de)}return be}function We(y,A={}){const p=[];for(let pe=0;pe<y.length;pe++){const de=Number(y[pe]);Number.isFinite(de)&&p.push(de)}const k=p.length,j=k-1;if(k<8||j<6)return null;const N=new Array(j);for(let pe=0;pe<j;pe++)N[pe]=p[pe+1]-p[pe];let W=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.ceil(12*(k/100)**.25);W=Math.max(0,Math.min(W,Math.floor((j-5)/2)));const B=(pe,de)=>{const we=[],ke=[];for(let me=de;me<j;me++){const ve=[me-de+1,p[me]];for(let Ee=1;Ee<=pe;Ee++)ve.push(N[me-Ee]);we.push(ve),ke.push(N[me])}return Me(we,ke,{method:"ols"})},$=Ve(p,N,j,W),re=B($,$);if(!re||!re.coefficients[2])return null;const ue=re.coefficients[2].t,ge=je(ue),be=ue<Ne["5%"];return{statistic:ue,usedLag:$,nobs:j-$,criticalValues:{...Ne},pValue:ge,pApproximate:!0,stationary:be,verdict:be?"stationary":"non-stationary",regression:"ct"}}function Xe(y,A={}){const p=[];for(let be=0;be<y.length;be++){const pe=Number(y[be]);Number.isFinite(pe)&&p.push(pe)}const k=p.length;if(k<3)return null;let j=Number.isFinite(A.maxlag)?Math.floor(A.maxlag):Math.min(10,k-1);j=Math.max(1,Math.min(j,k-1));let N=0;for(const be of p)N+=be;N/=k;const W=p.map(be=>be-N);let B=0;for(const be of W)B+=be*be;B/=k;const $=new Array(j+1).fill(0);$[0]=1;for(let be=1;be<=j;be++){let pe=0;for(let de=be;de<k;de++)pe+=W[de]*W[de-be];$[be]=B>0?pe/k/B:0}const re=new Array(j+1).fill(0);re[0]=1;let ue=[];for(let be=1;be<=j;be++){let pe=$[be];for(let me=1;me<be;me++)pe-=ue[me-1]*$[be-me];let de=1;for(let me=1;me<be;me++)de-=ue[me-1]*$[me];const we=de!==0?pe/de:0,ke=new Array(be);for(let me=1;me<be;me++)ke[me-1]=ue[me-1]-we*ue[be-1-me];ke[be-1]=we,re[be]=we,ue=ke}const ge=1.96/Math.sqrt(k);return{acf:$,pacf:re,bounds:{upper:ge,lower:-ge},n:k,nlags:j,approximate:!0}}function qe(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2)return null;const W=Pe(k),B=Pe(j);let $=0,re=0;for(let pe=0;pe<N;pe++)$+=W[pe],re+=B[pe];$/=N,re/=N;let ue=0,ge=0,be=0;for(let pe=0;pe<N;pe++){const de=W[pe]-$,we=B[pe]-re;ue+=de*we,ge+=de*de,be+=we*we}return ge===0||be===0?null:Math.max(-1,Math.min(1,ue/Math.sqrt(ge*be)))}function yt(y,A,p){const{xs:k,ys:j,n:N}=w(y,A,p);if(N<2||N>M)return null;let W=0,B=0,$=0,re=0;for(let be=0;be<N;be++)for(let pe=be+1;pe<N;pe++){const de=Math.sign(k[be]-k[pe]),we=Math.sign(j[be]-j[pe]),ke=de*we;ke>0?W++:ke<0?B++:de===0&&we===0||(de===0?$++:re++)}const ue=W+B+re,ge=W+B+$;return ue===0||ge===0?null:(W-B)/Math.sqrt(ue*ge)}function pt(y,A={}){const p=y.length;if(p<2)return null;const k=y[0],j=y[p-1],N=[];for(let me=1;me<p;me++){const ve=y[me-1];ve!==0&&N.push((y[me]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let me=0;for(const Ee of N)me+=Ee;me/=N.length;let ve=0;for(const Ee of N)ve+=(Ee-me)**2;W=Math.sqrt(ve/(N.length-1))}const B=Number(A.periodsPerYear)>0?Number(A.periodsPerYear):null;let $=y[0],re=0,ue=0,ge=0,be=0;for(let me=1;me<p;me++){if(y[me]>$){$=y[me],re=me;continue}if($<=0)continue;const ve=($-y[me])/$;ve>ue&&(ue=ve,ge=re,be=me)}let pe=null;if(p>2){let me=0;for(let Le=0;Le<p;Le++)me+=y[Le];me/=p;let ve=0,Ee=0;for(let Le=0;Le<p;Le++){const Fe=y[Le]-me;Ee+=Fe*Fe,Le>0&&(ve+=Fe*(y[Le-1]-me))}pe=Ee>0?ve/Ee:null}let de=0,we=0;for(const me of N)me>0?de++:me<0&&we++;let ke=null;if(k>0&&j>0){const me=(j/k)**(1/(p-1))-1;ke=B?(1+me)**B-1:me}return{n:p,first:k,last:j,change:j-k,changePercent:k===0?null:(j-k)/Math.abs(k)*100,volatility:W,annualisedVolatility:W!==null&&B?W*Math.sqrt(B):null,growth:ke,maxDrawdown:ue,maxDrawdownFrom:ge,maxDrawdownTo:be,autocorrelation:pe,upDays:de,downDays:we}}const rt=1.128,it=3.267;function wt(y){const A=y.length;if(A<2)return null;const p=[];for(let j=1;j<A;j++)p.push(Math.abs(y[j]-y[j-1]));const k=p.reduce((j,N)=>j+N,0)/p.length;return{ranges:p,centre:k,upper:it*k,lower:0}}function Ze(y){const A=y.length;if(A<2)return null;let p=0;for(let j=1;j<A;j++)p+=Math.abs(y[j]-y[j-1]);const k=p/(A-1);return{sigma:k/rt,meanRange:k}}function Ot(y,A){const p=y.length;if(p<2||!A)return null;const k=Number.isFinite(Number(A.lower))?Number(A.lower):null,j=Number.isFinite(Number(A.upper))?Number(A.upper):null;if(k===null&&j===null)return null;let N=0;for(let de=0;de<p;de++)N+=y[de];N/=p;let W=0;for(let de=0;de<p;de++)W+=(y[de]-N)**2;const B=Math.sqrt(W/(p-1)),$=Ze(y),re=$?$.sigma:null,ue=de=>{if(!de||de<=0)return{index:null,k:null};const ke=k!==null&&j!==null?(j-k)/(6*de):null,me=j!==null?(j-N)/(3*de):1/0,ve=k!==null?(N-k)/(3*de):1/0;return{index:ke,k:Math.min(me,ve)}},ge=ue(re),be=ue(B);let pe=0;for(let de=0;de<p;de++){if(k!==null&&y[de]<k){pe++;continue}j!==null&&y[de]>j&&pe++}return{n:p,mean:N,lower:k,upper:j,target:Number.isFinite(Number(A.target))?Number(A.target):null,sigmaWithin:re,sigmaOverall:B,cp:ge.index,cpk:ge.k,pp:be.index,ppk:be.k,outOfSpec:pe,defectRate:p?pe/p:null}}function kt(y){const A=y.length;if(A<2)return null;const p=Ze(y);if(!p||!(p.sigma>0))return null;let k=0;for(let j=0;j<A;j++)k+=y[j];return k/=A,{centre:k,sigma:p.sigma,upper:k+3*p.sigma,lower:k-3*p.sigma}}function ot(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=B=>(y[B]-k)/j,W=[];for(let B=0;B<p;B++){if(Math.abs(N(B))>3&&W.push({index:B,rule:1,description:"beyond three sigma"}),B>=2)for(const $ of[1,-1]){let re=0;for(let ue=B-2;ue<=B;ue++)N(ue)*$>2&&re++;if(re>=2){W.push({index:B,rule:2,description:"two of three past two sigma"});break}}if(B>=4)for(const $ of[1,-1]){let re=0;for(let ue=B-4;ue<=B;ue++)N(ue)*$>1&&re++;if(re>=4){W.push({index:B,rule:3,description:"four of five past one sigma"});break}}if(B>=7)for(const $ of[1,-1]){let re=!0;for(let ue=B-7;ue<=B;ue++)if(N(ue)*$<=0){re=!1;break}if(re){W.push({index:B,rule:4,description:"eight in a row on one side"});break}}}return W}function st(y,A){if(!A||!(A.sigma>0))return[];const p=y.length,{centre:k,sigma:j}=A,N=$=>(y[$]-k)/j,W=($,re,ue,ge)=>{for(const be of[1,-1]){let pe=0;for(let de=$;de<=re;de++)N(de)*be>ue&&pe++;if(pe>=ge)return!0}return!1},B=[];for(let $=0;$<p;$++){if(Math.abs(N($))>3&&B.push({index:$,rule:1,description:"beyond three sigma"}),$>=8)for(const re of[1,-1]){let ue=!0;for(let ge=$-8;ge<=$;ge++)if(N(ge)*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:2,description:"nine in a row on one side"});break}}if($>=5)for(const re of[1,-1]){let ue=!0;for(let ge=$-4;ge<=$;ge++)if((y[ge]-y[ge-1])*re<=0){ue=!1;break}if(ue){B.push({index:$,rule:3,description:re>0?"six rising":"six falling"});break}}if($>=13){let re=!0;for(let ue=$-12;ue<=$;ue++){const ge=y[ue]-y[ue-1],be=y[ue+1<=$?ue+1:ue]-y[ue];if(ue+1>$)break;if(ge===0||be===0||ge>0==be>0){re=!1;break}}re&&B.push({index:$,rule:4,description:"fourteen alternating"})}if($>=2&&W($-2,$,2,2)&&B.push({index:$,rule:5,description:"two of three past two sigma"}),$>=4&&W($-4,$,1,4)&&B.push({index:$,rule:6,description:"four of five past one sigma"}),$>=14){let re=!0;for(let ue=$-14;ue<=$;ue++)if(Math.abs(N(ue))>=1){re=!1;break}re&&B.push({index:$,rule:7,description:"fifteen within one sigma"})}if($>=7){let re=!0;for(let ue=$-7;ue<=$;ue++)if(Math.abs(N(ue))<=1){re=!1;break}re&&B.push({index:$,rule:8,description:"eight beyond one sigma"})}}return B}const jt=Object.freeze(["westernElectric","nelson"]);function At(y,A,p="westernElectric"){return String(p)==="nelson"?st(y,A):ot(y,A)}function Mt(y,A,p){let k=0;for(let j=0;j<y.length;j++)(y[j]<A||y[j]>p)&&k++;return k}function Pt(y,A,p,k=20){const j=y.length;if(!j)return[];const N=y[0],W=y[j-1];if(W===N)return[{from:N,to:W,count:j}];const B=p-A,$=1.5*B;let re=B>0?Math.max(N,A-$):N,ue=B>0?Math.min(W,p+$):W;ue>re||(re=N,ue=W);const ge=B>0?2*B/Math.cbrt(j):(ue-re)/(Math.ceil(Math.log2(j))+1),be=ge>0?Math.min(k,Math.max(1,Math.ceil((ue-re)/ge))):1,pe=(ue-re)/be,de=[];for(let we=0;we<be;we++)de.push({from:re+we*pe,to:re+(we+1)*pe,count:0});for(let we=0;we<j;we++){const ke=Math.min(be-1,Math.max(0,Math.floor((y[we]-re)/pe)));de[ke].count++}return de[0].from=N,de[be-1].to=W,de}const $e=.95;function He(y){const A=Number(y);return Number.isFinite(A)&&A>0&&A<1?A:$e}function Nt(y,A=$e){const p=y.length;if(p<2)return null;let k=0;for(let ue=0;ue<p;ue++)k+=y[ue];const j=k/p;let N=0;for(let ue=0;ue<p;ue++){const ge=y[ue]-j;N+=ge*ge}const W=Math.sqrt(N/(p-1)),B=He(A),re=te(1-(1-B)/2,p-1)*W/Math.sqrt(p);return{mean:j,lower:j-re,upper:j+re,margin:re,n:p,confidence:B}}function St(y,A,p=$e){const k=Number(y),j=Number(A);if(!(j>0)||!(k>=0)||k>j)return null;const N=He(p),W=F(1-(1-N)/2),B=k/j,$=W*W,re=1+$/j,ue=(B+$/(2*j))/re,ge=W/re*Math.sqrt(B*(1-B)/j+$/(4*j*j));return{proportion:B,lower:Math.max(0,ue-ge),upper:Math.min(1,ue+ge),n:j,confidence:N}}function vt(y,A=$e){if(!y||!(y.n>2)||!Number.isFinite(y.stdError))return null;const p=He(A),j=te(1-(1-p)/2,y.n-2)*y.stdError;return{slope:y.slope,lower:y.slope-j,upper:y.slope+j,margin:j,confidence:p}}function Tt(y,A,p=$e){const k=Number(y),j=Number(A);if(!Number.isFinite(k)||!(j>1))return null;const N=He(p),B=F(1-(1-N)/2)*Math.sqrt(1/(9*j)+k*k/(2*(j-1)));return{index:k,lower:k-B,upper:k+B,margin:B,n:j,confidence:N}}function ut(y,A){return!y||!(y.sd>0)||!Number.isFinite(A)||!Number.isFinite(y.mean)?null:(A-y.mean)/y.sd}function ct(y){return Number.isFinite(y)?Math.min(1,Math.max(0,2*H(Math.abs(y)/2)-1)):0}function Je(y,A){const p=new Map,k=Q(y);let j=0;for(let N=0;N<A.length;N++){const W=k(A[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const B=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;p.set(B,(p.get(B)||0)+1),j++}return{map:p,total:j}}function lt(y,A,p,k){if(!(A>0)||!(k>0))return null;let j=0;const N=new Set(y.keys());for(const W of p.keys())N.add(W);for(const W of N){const B=(y.get(W)||0)/A,$=(p.get(W)||0)/k;j+=Math.abs(B-$)}return j/2}const xe=10;function Et(y,A,p){if(p&&p.numeric){const B=f(y,A),{n:$,mean:re}=r(B),ue=$>0?ut({mean:p.mean,sd:p.sd},re):null;return{measure:"standardizedMeanDifference",magnitude:ue,distance:ue===null?0:ct(ue),direction:ue===null?0:Math.sign(ue),subsetN:$,populationN:p.n||0,reliable:$>=xe}}const{map:j,total:N}=Je(y,A),W=lt(j,N,p.map,p.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:p.total||0,reliable:N>=xe}}function at(y,A){if(y&&(y.kind==="float64"||y.kind==="int32"))return!0;const p=Q(y);let k=0,j=0;for(let N=0;N<A.length&&k<200;N++){const W=p(A[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;k++;const B=typeof W=="number"?W:Number(W);Number.isFinite(B)&&j++}return k===0?!1:j/k>=.9}function Rt(y,A){if(at(y,A)){const j=f(y,A),{n:N,mean:W,m2:B}=r(j);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(B/N):0,n:N}}const{map:p,total:k}=Je(y,A);return{numeric:!1,map:p,total:k}}}),Se("packages/core/src/compute/total.js",function(o,fe){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return d}});const le=fe("packages/core/src/internal/util.js"),ae=le.isFunction,Q=le.warnOnce,q=fe("packages/core/src/compute/handle.js"),te=q.presenceReader,_=q.valueComparator,F=q.valueReader,H=fe("packages/core/src/compute/statistics.js"),ne=H.STAT_FNS,x=H.STAT_LABELS;function ce(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function ie(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++){const I=S[n[U]];Number.isNaN(I)||(b+=I)}return b}for(let U=0;U<l;U++){const I=n[U];if(V(I)===1){const X=S[I];Number.isNaN(X)||(b+=X)}}return b}const E=F(r);for(let S=0;S<l;S++){const V=u(E(n[S]));V!==null&&(b+=V)}return b}ie.kernel=!0;function G(r,n){const l=n.length;let b=0;if(ce(r)){const S=r.values,V=te(r);if(!V){for(let U=0;U<l;U++)Number.isNaN(S[n[U]])||b++;return b}for(let U=0;U<l;U++){const I=n[U];V(I)===1&&!Number.isNaN(S[I])&&b++}return b}const E=F(r);for(let S=0;S<l;S++){const V=E(n[S]);V!=null&&!(typeof V=="number"&&Number.isNaN(V))&&b++}return b}G.kernel=!0;function D(r,n){return n.length}D.kernel=!0;function Y(r,n){const l=G(r,n);return l===0?null:ie(r,n)/l}Y.kernel=!0;function ee(r,n,l,b){const E=n.length;if(ce(r)){const I=r.values,X=te(r);let C=null;if(!X){for(let R=0;R<E;R++){const h=I[n[R]];Number.isNaN(h)||(C===null||(l<0?h<C:h>C))&&(C=h)}return C}for(let R=0;R<E;R++){const h=n[R];if(X(h)===0)continue;const O=I[h];Number.isNaN(O)||(C===null||(l<0?O<C:O>C))&&(C=O)}return C}const S=F(r),V=_(b);let U=null;for(let I=0;I<E;I++){const X=S(n[I]);X==null||typeof X=="number"&&Number.isNaN(X)||(U===null||(l<0?V(X,U)<0:V(X,U)>0))&&(U=X)}return U}function z(r,n,l){return ee(r,n,-1,l&&l.locale)}z.kernel=!0;function M(r,n,l){return ee(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:F(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:F(r)(n[n.length-1])}s.kernel=!0;function u(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const f={sum:ie,min:z,max:M,avg:Y,count:D,first:i,last:s,countValues:G,...ne},c=Object.freeze({...x,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?c[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function g(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(b=>b in f);for(const b of Object.keys(f))l.includes(b)||l.push(b);return l}function e(r,n){return typeof n!="string"?!0:g(r).includes(n)}function m(r,n){const l=F(r),b=[];for(let E=0;E<n.length;E++){const S=l(n[E]);S!=null&&b.push(S)}return b}function d(r,n,l,b){const E=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,E,b):(Q(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return ae(l)?l.kernel===!0?l(r,E,b):l(m(r,E),b||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,fe){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/internal/util.js").warnOnce,q=fe("packages/core/src/compute/handle.js").valueComparator,_=fe("packages/core/src/compute/group.js").packKeys,H=fe("packages/core/src/compute/total.js").total,ne="|",x="/",ce=2e3;function ie(u,f,c){return`${u}${ne}${f}${ne}${c}`}function G(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function D(u,f,c={}){const t=c.separator||x,a=f.length,{keyOf:g,readers:e}=_(u,f,0),m=new Map,d=[],r=[];for(let U=0;U<a;U++){const I=f[U],X=g(I);if(m.has(X))continue;m.set(X,d.length),r.push(X);const C=new Array(e.length);for(let R=0;R<e.length;R++)C[R]=e[R](I);d.push(C)}const n=q(c.locale),l=d.map((U,I)=>I);l.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=Y(X[R],C[R],n);if(h!==0)return h}return U-I});const b=new Array(l.length),E=new Array(l.length),S=new Map;for(let U=0;U<l.length;U++){const I=l[U];b[U]=d[I],E[U]=G(d[I],t),S.set(r[I],U)}return{keys:b,paths:E,idOf:U=>{const I=S.get(g(U));return I===void 0?-1:I}}}function Y(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function ee(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(g=>g&&g.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&ae("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const g of f){const e=c(g);e&&a.push({colId:g,handle:e,fn:t?t(g):"sum"})}return a}function z(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=z(u,f,c),a=t.separator||x,g=ee(t),e=t.maxColumns===void 0?ce:t.maxColumns,m=t.groups&&t.groups.buckets?t.groups:null,d=m?m.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(m?m.keys.map(X=>G(X,a)):[""]),n=s(d),{keys:l,paths:b,idOf:E}=D(t.pivotHandles||[],n,t),S=b.length*Math.max(1,g.length),V=i(b,g,a);if(e&&S>e){const X=new Map;return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:X,cells:X,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const U=new Map,I=b.length;for(let X=0;X<d.length;X++){const C=d[X],R=r[X]===void 0?"":r[X],h=C.length;if(h===0)continue;const O=new Int32Array(h),w=new Uint32Array(I+1);for(let K=0;K<h;K++){const Z=E(C[K]);O[K]=Z,Z>=0&&w[Z+1]++}for(let K=0;K<I;K++)w[K+1]+=w[K];const P=new Uint32Array(h),v=w.slice(0,I);for(let K=0;K<h;K++){const Z=O[K];Z>=0&&(P[v[Z]++]=C[K])}for(let K=0;K<I;K++){const Z=w[K],oe=w[K+1];if(oe===Z)continue;const se=P.subarray(Z,oe);for(let T=0;T<g.length;T++){const L=g[T],J=H(L.handle,se,L.fn,t.totalContext||{locale:t.locale});U.set(ie(R,b[K],L.colId),J)}}}return{keys:l,paths:b,fields:V,groupPaths:r,columns:S,values:U,cells:U,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const g of f)t.push(`${a}${c}${g.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,fe){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const ae=fe("packages/core/src/compute/handle.js").valueComparator,q=fe("packages/core/src/compute/total.js").total,_=fe("packages/core/src/compute/group.js").packKeys,F=fe("packages/core/src/compute/pivot.js"),H=F.joinPath,ne=F.DEFAULT_PATH_SEPARATOR,x=F.DEFAULT_MAX_COLUMNS,ce="";function ie(i,s,u={}){const f=u.separator||ne,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ce],buckets:[t]};const{keyOf:g,readers:e}=_(c,t,0),m=new Map,d=[],r=[],n=[];for(let U=0;U<a;U++){const I=t[U],X=g(I);let C=m.get(X);if(C===void 0){C=d.length,m.set(X,C),r.push(X);const R=new Array(e.length);for(let h=0;h<e.length;h++)R[h]=e[h](I);d.push(R),n.push([])}n[C].push(I)}const l=ae(u.locale),b=d.map((U,I)=>I);b.sort((U,I)=>{const X=d[U],C=d[I];for(let R=0;R<X.length;R++){const h=G(X[R],C[R],l);if(h!==0)return h}return U-I});const E=new Array(b.length),S=new Array(b.length),V=new Array(b.length);for(let U=0;U<b.length;U++){const I=b[U];E[U]=d[I],S[U]=H(d[I],f),V[U]=Uint32Array.from(n[I])}return{tuples:E,paths:S,buckets:V}}function G(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function D(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Y(i,s,u,f){return{value:s.length?q(i,s,u,f):null,leaves:s,count:s.length}}function ee(i){const s=i&&i.opts||{},u=s.separator||ne,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=ie(i.rowHandles||[],t,{...s,separator:u}),g=ie(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?x:s.maxColumns,m=g.paths.length*Math.max(1,c.length),d=new Map;if(e&&m>e)return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:d,rowMargin:d,columnMargin:d,grand:d,columns:m,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${m} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:m,maxColumns:e}};const r=new Map,n=new Map,l=new Map,b=new Map,E=g.buckets.map(S=>new Set(S));for(let S=0;S<g.paths.length;S++){const V=g.buckets[S],U=g.paths[S];for(const I of c)l.set(M(U,I.colId),Y(I.handle,V,I.fn,f))}for(let S=0;S<a.paths.length;S++){const V=a.buckets[S],U=a.paths[S];for(const I of c)n.set(M(U,I.colId),Y(I.handle,V,I.fn,f));for(let I=0;I<g.paths.length;I++){const X=D(V,g.buckets[I],E[I]);if(X.length===0)continue;const C=g.paths[I];for(const R of c)r.set(z(U,C,R.colId),Y(R.handle,X,R.fn,f))}}for(const S of c)b.set(S.colId,Y(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:g,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:b,columns:m,error:null}}function z(i,s,u){return`${i}\\0${s}\\0${u}`}function M(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,fe){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ee}});const ae=fe("packages/core/src/internal/util.js").getPath,Q=fe("packages/core/src/compute/handle.js"),q=Q.isMissing,te=Q.valueComparator,F=fe("packages/core/src/compute/filter.js").testValue,H="",ne="\\0";function x(i,s){const u=s.includes(".")?ae(i,s):i?.[s];return u===void 0?null:u}function ce(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=ie(i,c,f[t],u);return c}function ie(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),a=u.descending!==void 0?!!u.descending:u.dir==="desc",g=[],e=[];for(const r of s){const n=x(i[r],u.col);q(n)?e.push(r):g.push(r)}const m=new Map;for(let r=0;r<g.length;r++)m.set(g[r],r);const d=(r,n)=>{const l=x(i[r],u.col),b=x(i[n],u.col);let E;return typeof u.compare=="function"?(E=u.compare(l,b,i[r],i[n],a),a&&(E=-E)):E=a?t(b,l):t(l,b),E!==0?E:m.get(r)-m.get(n)};return g.sort(d),u.nullsFirst?e.concat(g):g.concat(e)}function G(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)D(i[c],s,u,c)&&f.push(c);return f}function D(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>D(i,a,u,f));const t=c.every(a=>D(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):F(x(i,s.col),s,u.locale)}function Y(i,s,u,f){const c=u||i.map((e,m)=>m),t=new Map,a=[],g=[];for(const e of c){const m=s.map((n,l)=>{const b=x(i[e],n);return f&&f[l]?f[l](b):b}),d=m.map(n=>n==null?ne:String(n)).join(H);let r=t.get(d);r===void 0&&(r=a.length,t.set(d,r),a.push(m),g.push([])),g[r].push(e)}return{keys:a,buckets:g}}function ee(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!q(a)),t=c.map(z).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,g)=>a+g,0);case"avg":return c.length===0?null:t.reduce((a,g)=>a+g,0)/c.length;case"min":return c.length===0?null:c.reduce((a,g)=>f(g,a)<0?g:a);case"max":return c.length===0?null:c.reduce((a,g)=>f(g,a)>0?g:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(i[i.length-1]);default:return null}}function z(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function M(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,fe){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return _}});const ae=fe("packages/core/src/compute/sketch.js").Welford;class Q{#t;#e;#n=[];#r;#i;constructor(H,ne=0,x=Date.now){if(H!=="count"&&H!=="time"&&H!=="session")throw new RangeError(`unknown window kind: ${H}`);if((H==="count"||H==="time")&&!(ne>0))throw new RangeError(`a ${H} window needs a positive span`);this.#t=H,this.#e=Math.floor(ne),this.#r=x,this.#i=x()}get size(){return this.#n.length}push(H,ne=this.#r()){Number.isFinite(H)&&(this.#n.push({t:ne,v:H}),this.#s(ne))}#s(H){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const ne=H-this.#e;for(;this.#n.length&&this.#n[0].t<ne;)this.#n.shift()}}spec(){const H=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:H,size:this.#n.length}}values(){return this.#n.map(H=>H.v)}aggregate(){const H=this.spec();if(!this.#n.length)return{over:H,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const ne=new ae;let x=0,ce=1/0,ie=-1/0;for(const{v:G}of this.#n)x+=G,G<ce&&(ce=G),G>ie&&(ie=G),ne.add(G);return{over:H,count:this.#n.length,sum:x,mean:ne.mean(),min:ce,max:ie,variance:ne.variance(),stddev:ne.stddev()}}reduce(H){const ne=this.aggregate(),x={sum:ne.sum,avg:ne.mean,mean:ne.mean,min:ne.min,max:ne.max,count:ne.count,variance:ne.variance,stddev:ne.stddev};if(!(H in x))throw new RangeError(`unknown windowed aggregate: ${H}`);return{value:x[H],over:ne.over}}}const q=Object.freeze(["count","time","session"]);function te(F,H=Date.now){const ne=F.kind==="time"&&F.minutes!=null?F.minutes*6e4:F.span??0;return new Q(F.kind,ne,H)}const _={Window:Q,WINDOW_KINDS:q,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,fe){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const ae=fe("packages/core/src/compute/statistics.js").quantileSorted,q=fe("packages/core/src/compute/special.js").logGamma,te=.6745,_=3.5,F=1.5,H=.975,ne=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function x(c){if(!c.length)return null;const a=Array.from(c,Number).sort((d,r)=>d-r),g=ae(a,.5),e=a.map(d=>Math.abs(d-g)).sort((d,r)=>d-r),m=ae(e,.5);return{median:g,mad:m}}function ce(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:_,g=c.length,e=new Array(g).fill(null),m=new Array(g).fill(!1),d=[];for(let l=0;l<g;l++){const b=Number(c[l]);Number.isFinite(b)&&d.push(b)}if(!d.length)return{median:null,mad:null,threshold:a,scores:e,flags:m,flagged:0};const r=x(d);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:m,flagged:0};let n=0;for(let l=0;l<g;l++){const b=Number(c[l]);if(!Number.isFinite(b))continue;const E=te*(b-r.median)/r.mad;e[l]=E,Math.abs(E)>a&&(m[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:m,flagged:n}}function ie(c,t={}){const a=Number.isFinite(t.k)?t.k:F,g=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&g.push(l)}if(!g.length)return null;const e=g.sort((n,l)=>n-l),m=ae(e,.25),d=ae(e,.75),r=d-m;return{q1:m,q3:d,iqr:r,lower:m-a*r,upper:d+a*r,k:a}}function G(c,t){if(t<=0)return 0;const a=q(c);if(t<c+1){let l=c,b=1/c,E=b;for(let S=0;S<1e3&&(l+=1,E*=t/l,b+=E,!(Math.abs(E)<Math.abs(b)*1e-15));S++);return b*Math.exp(-t+c*Math.log(t)-a)}const g=1e-300;let e=t+1-c,m=1/g,d=1/e,r=d;for(let l=1;l<1e3;l++){const b=-l*(l-c);e+=2,d=b*d+e,Math.abs(d)<g&&(d=g),m=e+b/m,Math.abs(m)<g&&(m=g),d=1/d;const E=d*m;if(r*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function D(c,t){return c<=0?0:G(t/2,c/2)}function Y(c,t=H){if(!(t>0)||!(t<1))return NaN;let a=0,g=Math.max(1,c);for(;D(g,c)<t;)g*=2;for(let e=0;e<200;e++){const m=(a+g)/2;if(D(m,c)<t?a=m:g=m,g-a<1e-10)break}return(a+g)/2}function ee(c){const t=c.length,a=c.map((g,e)=>{const m=g.slice();for(let d=0;d<t;d++)m.push(e===d?1:0);return m});for(let g=0;g<t;g++){let e=g;for(let d=g+1;d<t;d++)Math.abs(a[d][g])>Math.abs(a[e][g])&&(e=d);if(Math.abs(a[e][g])<1e-12)return null;if(e!==g){const d=a[e];a[e]=a[g],a[g]=d}const m=a[g][g];for(let d=0;d<2*t;d++)a[g][d]/=m;for(let d=0;d<t;d++){if(d===g)continue;const r=a[d][g];if(r!==0)for(let n=0;n<2*t;n++)a[d][n]-=r*a[g][n]}}return a.map(g=>g.slice(t))}function z(c,t){const a=c.length,g=new Array(t).fill(0);for(const d of c)for(let r=0;r<t;r++)g[r]+=d[r];for(let d=0;d<t;d++)g[d]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const d of c)for(let r=0;r<t;r++){const n=d[r]-g[r];for(let l=r;l<t;l++)e[r][l]+=n*(d[l]-g[l])}const m=a>1?a-1:1;for(let d=0;d<t;d++)for(let r=d;r<t;r++)e[d][r]/=m,e[r][d]=e[d][r];return{mean:g,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:H,g=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const m=c[0].length;if(!m)return null;const d=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],b=[];for(let R=0;R<e;R++){const h=c[R];let O=h.length===m;const w=new Array(m);for(let P=0;O&&P<m;P++){const v=Number(h[P]);Number.isFinite(v)?w[P]=v:O=!1}O&&(l.push(R),b.push(w))}const E=m,S=Y(E,a);if(b.length<=m)return{center:[],df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0};const{mean:V,cov:U}=z(b,m);let I=ee(U),X=!1;if(!I){X=!0;let R=0;for(let w=0;w<m;w++)R+=U[w][w];const h=R/m*g||g,O=U.map((w,P)=>w.map((v,K)=>P===K?v+h:v));if(I=ee(O),!I)return{center:V,df:E,cutoff:S,singular:!0,used:b.length,distances:d,squared:r,flags:n,flagged:0}}let C=0;for(let R=0;R<b.length;R++){const h=b[R],O=new Array(m);for(let v=0;v<m;v++)O[v]=h[v]-V[v];let w=0;for(let v=0;v<m;v++){let K=0;for(let Z=0;Z<m;Z++)K+=I[v][Z]*O[Z];w+=O[v]*K}w<0&&(w=0);const P=l[R];r[P]=w,d[P]=Math.sqrt(w),w>S&&(n[P]=!0,C++)}return{center:V,df:E,cutoff:S,singular:X,used:b.length,distances:d,squared:r,flags:n,flagged:C}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",g=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:_,m=Number.isFinite(t.k)?t.k:F,d=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):g,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let b=0;for(let E=0;E<r;E++){const S=Number(c[E]);if(!Number.isFinite(S))continue;const V=Math.max(0,E-g+1),U=[];for(let I=V;I<=E;I++){const X=Number(c[I]);Number.isFinite(X)&&U.push(X)}if(!(U.length<d))if(a==="rollingIqr"){const I=ie(U,{k:m});if(!I)continue;(S<I.lower||S>I.upper)&&(l[E]=!0,b++)}else{const I=x(U);if(!I||I.mad===0)continue;const X=te*(S-I.median)/I.mad;n[E]=X,Math.abs(X)>e&&(l[E]=!0,b++)}}return{method:a,windowLen:g,minPeriods:d,threshold:e,k:m,scores:n,flags:l,flagged:b}}function f(c={}){const t=c||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const g=t.method||"modifiedZScore";if(!(ne.includes(g)||s.includes(g))||g==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${g}\'`);const m=typeof t.orderBy=="string"?t.orderBy:null,d=t.latest===!0,r=s.includes(g),n=l=>Number(l==null?NaN:l[a]);return l=>{const b=Array.isArray(l)?l.slice():[...l];m&&b.sort((I,X)=>{const C=I?.[m],R=X?.[m];return C===R?0:C==null?-1:R==null?1:C<R?-1:1});const E=b.map(n);let S,V;if(r)({flags:S,scores:V}=u(E,{method:g,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(g==="iqr"){const I=ie(E,{k:t.k});S=E.map(X=>I?Number.isFinite(X)&&(X<I.lower||X>I.upper):!1),V=E.map(()=>null)}else({flags:S,scores:V}=ce(E,{threshold:t.threshold}));if(d){const I=S.length-1;return I<0||!S[I]?!1:{method:g,field:a,flagged:[{row:b[I],score:V[I]}]}}const U=[];for(let I=0;I<S.length;I++)S[I]&&U.push({row:b[I],score:V[I]});return U.length?{method:g,field:a,flagged:U}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,fe){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const le=fe("packages/core/src/compute/special.js"),ae=le.normalQuantile,Q=le.studentTQuantile,te=fe("packages/core/src/internal/util.js").warnOnce,_=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),F=1e-4,H=1-1e-4;function ne(t){const a=[];for(let g=0;g<t.length;g++){const e=t[g];if(e!==null&&typeof e=="object"){const m=Number.isFinite(e.at)?e.at:g,d=Number.isFinite(e.value)?e.value:null;a.push({at:m,value:d})}else a.push({at:g,value:Number.isFinite(e)?Number(e):null})}return a}function x(t){const a=t.filter(r=>r.value!==null),g=a[0],e=a[a.length-1],m=e.at-g.at,d=a.length>1&&m>0?m/(a.length-1):1;return{lastAt:e.at,step:d}}function ce(t){return Math.min(H,Math.max(F,t))}function ie(t,a=F,g=H,e=80){const m=(Math.sqrt(5)-1)/2;let d=a,r=g,n=r-m*(r-d),l=d+m*(r-d),b=t(n),E=t(l);for(let S=0;S<e;S++)b<E?(r=l,l=n,E=b,n=r-m*(r-d),b=t(n)):(d=n,n=l,b=E,l=d+m*(r-d),E=t(l));return(d+r)/2}function G(t,a){let g=null,e=0,m=0;for(let d=0;d<t.length;d++){const r=t[d];if(r!==null){if(g===null){g=r;continue}e+=(r-g)**2,m+=1,g=a*r+(1-a)*g}}return{level:g,sse:e,m}}function D(t,a,g){let e=null,m=null,d=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&m!==null&&(e+=m);continue}if(e===null){e=l;continue}m===null&&(m=l-e);const b=e+m;d+=(l-b)**2,r+=1;const E=e;e=a*l+(1-a)*(E+m),m=g*(e-E)+(1-g)*m}return{level:e,trend:m,sse:d,m:r}}function Y(t,a,g,e,m){const d=t.length;if(d<2*a)return null;const r=X=>{let C=0,R=0;for(let h=X;h<X+a&&h<d;h++)t[h]!==null&&(C+=t[h],R+=1);return R?C/R:null},n=r(0),l=r(a);if(n===null||l===null)return null;let b=n,E=(l-n)/a;const S=new Array(a).fill(0);for(let X=0;X<a;X++)S[X]=t[X]===null?0:t[X]-b;const V=S.reduce((X,C)=>X+C,0)/a;for(let X=0;X<a;X++)S[X]-=V;let U=0,I=0;for(let X=a;X<d;X++){const C=X%a,R=S[C],h=t[X];if(h===null){b+=E;continue}const O=b+E+R;U+=(h-O)**2,I+=1;const w=b;b=g*(h-R)+(1-g)*(b+E),E=e*(b-w)+(1-e)*E,S[C]=m*(h-b)+(1-m)*R}return{level:b,trend:E,season:S,phase:(d-1)%a,sse:U,count:I}}function ee(t,a,g){let e=1;for(const d of a)e+=d*d;const m=Math.sqrt(t*e);return{se:m,margin:g*m}}function z(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const g=_.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),m=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,d=1-(1-m)/2,r=ne(t),n=r.map(U=>U.value),l=n.filter(U=>U!==null),b=l.length,{lastAt:E,step:S}=b?x(r):{lastAt:0,step:1},V=U=>E+U*S;return g==="linear"?M(r,b,e,m,d,V):g==="movingAverage"?i(l,b,e,m,d,a,V):g==="ses"?s(n,b,e,m,d,a,V):g==="holt"?u(n,b,e,m,d,a,V):f(n,b,e,m,d,a,V)}function M(t,a,g,e,m,d){if(a<2)return null;let r=0,n=0;for(const h of t)h.value!==null&&(r+=h.at,n+=h.value);r/=a,n/=a;let l=0,b=0,E=0;for(const h of t){if(h.value===null)continue;const O=h.at-r,w=h.value-n;l+=O*O,b+=O*w,E+=w*w}if(l===0)return null;const S=b/l,V=n-S*r,U=E===0?1:Math.max(0,Math.min(1,b*b/(l*E))),I=Math.max(0,E-S*b),X=a>2?Math.sqrt(I/(a-2)):null,C=a>2?Q(m,a-2):null,R=[];for(let h=1;h<=g;h++){const O=d(h),w=V+S*O;let P=null,v=null,K=null,Z=null,oe=null;if(X!==null){const se=1/a+(O-r)**2/l,T=X*Math.sqrt(1+se),L=X*Math.sqrt(se);oe=T,P=w-C*T,v=w+C*T,K=w-C*L,Z=w+C*L}R.push({step:h,at:O,mean:w,lower:P,upper:v,lowerMean:K,upperMean:Z,se:oe})}return{method:"linear",horizon:g,confidence:e,n:a,sigma:X,r2:U,params:{slope:S,intercept:V},points:R}}function i(t,a,g,e,m,d,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(d.windowLen)||a))),l=t.slice(a-n);let b=0;for(const X of l)b+=X;const E=b/n;let S=null,V=null;if(n>1){let X=0;for(const R of l)X+=(R-E)**2;S=Math.sqrt(X/(n-1))*Math.sqrt(1+1/n),V=Q(m,n-1)}const U=S===null?null:V*S,I=[];for(let X=1;X<=g;X++)I.push({step:X,at:r(X),mean:E,lower:U===null?null:E-U,upper:U===null?null:E+U,se:S});return{method:"movingAverage",horizon:g,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:I}}function s(t,a,g,e,m,d,r){if(a<1)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null;n===null&&(n=ie(V=>G(t,V).sse));const l=G(t,n),b=ae(m),E=l.m>0?l.sse/l.m:null,S=[];for(let V=1;V<=g;V++){const U=l.level;let I=null,X=null,C=null;if(E!==null){const R=[];for(let O=1;O<V;O++)R.push(n);const h=ee(E,R,b);C=h.se,I=U-h.margin,X=U+h.margin}S.push({step:V,at:r(V),mean:U,lower:I,upper:X,se:C})}return{method:"ses",horizon:g,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:n},points:S}}function u(t,a,g,e,m,d,r){if(a<2)return null;let n=Number.isFinite(d.alpha)?ce(d.alpha):null,l=Number.isFinite(d.beta)?ce(d.beta):null;if(n===null||l===null){let I=n===null?.5:n,X=l===null?.5:l;for(let C=0;C<6;C++)n===null&&(I=ie(R=>D(t,R,X).sse)),l===null&&(X=ie(R=>D(t,I,R).sse));n=n===null?I:n,l=l===null?X:l}const b=D(t,n,l),E=ae(m),S=b.m>0?b.sse/b.m:null,V=n*l,U=[];for(let I=1;I<=g;I++){const X=b.level+I*b.trend;let C=null,R=null,h=null;if(S!==null){const O=[];for(let P=1;P<I;P++)O.push(n+P*V);const w=ee(S,O,E);h=w.se,C=X-w.margin,R=X+w.margin}U.push({step:I,at:r(I),mean:X,lower:C,upper:R,se:h})}return{method:"holt",horizon:g,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:U}}function f(t,a,g,e,m,d,r){const n=Math.floor(Number(d.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(d.alpha)?ce(d.alpha):null,b=Number.isFinite(d.beta)?ce(d.beta):null,E=Number.isFinite(d.gamma)?ce(d.gamma):null;const S=(h,O,w)=>{const P=Y(t,n,h,O,w);return P?P.sse:1/0};if(l===null||b===null||E===null){let h=l===null?.5:l,O=b===null?.5:b,w=E===null?.5:E;for(let P=0;P<8;P++)l===null&&(h=ie(v=>S(v,O,w))),b===null&&(O=ie(v=>S(h,v,w))),E===null&&(w=ie(v=>S(h,O,v)));l=l===null?h:l,b=b===null?O:b,E=E===null?w:E}const V=Y(t,n,l,b,E);if(!V)return null;const U=ae(m),I=V.count>0?V.sse/V.count:null,X=l*b,C=E*(1-l),R=[];for(let h=1;h<=g;h++){const O=V.season[(V.phase+h)%n],w=V.level+h*V.trend+O;let P=null,v=null,K=null;if(I!==null){const Z=[];for(let se=1;se<h;se++)Z.push(l+se*X+(se%n===0?C:0));const oe=ee(I,Z,U);K=oe.se,P=w-oe.margin,v=w+oe.margin}R.push({step:h,at:r(h),mean:w,lower:P,upper:v,se:K})}return{method:"holtWinters",horizon:g,confidence:e,n:a,sigma:I===null?null:Math.sqrt(I),params:{alpha:l,beta:b,gamma:E,period:n},points:R}}const c={FORECAST_METHODS:_,forecast:z}}),Se("packages/core/src/compute/index.js",function(o,fe){"use strict";const le=fe("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return le.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return le.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return le.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return le.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return le.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return le.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return le.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return le.rankSortStrings}});const ae=fe("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return ae.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return ae.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return ae.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return ae.describeSort}});const Q=fe("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return Q.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Q.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Q.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return Q.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return Q.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return Q.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Q.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Q.mentionsColumn}});const q=fe("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return q.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return q.packKeys}});const te=fe("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const _=fe("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return _.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return _.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return _.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return _.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return _.collectValues}});const F=fe("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return F.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return F.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return F.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return F.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return F.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return F.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return F.DEFAULT_MAX_COLUMNS}});const H=fe("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return H.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return H.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return H.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return H.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return H.GRAND_PATH}});const ne=fe("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ne.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return ne.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return ne.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return ne.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return ne.referenceValue}});const x=fe("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return x.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return x.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return x.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return x.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return x.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return x.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return x.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return x.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return x.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return x.isMissing}});const ce=fe("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ce.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ce.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ce.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ce.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ce.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ce.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ce.SKETCH_BOUNDS}});const ie=fe("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return ie.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return ie.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return ie.openWindow}});const G=fe("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return G.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return G.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return G.maintenanceOf}});const D=fe("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return D.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return D.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return D.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return D.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return D.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return D.anomalyCondition}});const Y=fe("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Y.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Y.forecast}})}),Se("packages/worker/src/kernel.js",function(o,fe){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const le=fe("packages/worker/src/transport.js"),ae=le.PROTOCOL,Q=le.OPS,q=le.CONTROL,te=le.ERRORS,_=le.unpackHandle,F=le.unpackHandles,H=le.createMaskPool,ne=le.collectTransfers,x=fe("packages/core/src/store/columnpack.js"),ce=x.packChunk,ie=x.packedTransfers;let G=null,D=null,Y=null;async function ee(f){if(G)return G;if(!D){const c=f||(()=>Promise.resolve(fe("packages/core/src/compute/index.js")));D=Promise.resolve().then(c).then(t=>(G=t,t)).catch(t=>(Y=t,G=null,null))}return D}function z(f){G=f,D=f?Promise.resolve(f):null,Y=f?null:Y}function M(f,c,t){const a=new Map;for(const g of f)g&&a.set(g.id,g);return{handle(g){return a.get(g)},count:c,pool:H(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===Q.COLUMNIZE)return ce(a.schema||[],a.rows||[],a.opts||{});const g=c[t];if(typeof g!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case Q.COLLATE_STRING_RANKS:return g(a.table||[],(a.table||[]).length,a.locale);case Q.SORT_COLUMN:return g(_(a.handle),a.order??null,a.opts||{});case Q.SORT_MULTI:{const e=F(a.handles||[]),m=(a.entries||[]).map(d=>({...d,handle:e[d.index]}));return g(e,m,a.order??null)}case Q.EVALUATE_FILTERS:return g(a.filters,M(F(a.handles||[]),a.count,a.locale));case Q.COMPACT:return g(a.mask,a.count,void 0);case Q.GROUP_BY_COLUMNS:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.TOTAL:return g(_(a.handle),a.indices??null,a.fn);case Q.PIVOT:return g(F(a.handles||[]),a.order??null,a.opts||{});case Q.FACET:return g(_(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==ae)return null;const{id:t,op:a}=f;if(a===q.CANCEL)return c.cancelled?.add(f.target),null;if(a===q.PING)return{reply:{lattice:ae,id:t,ok:!0,result:"pong"},transfer:[]};if(a===Q.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ce(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ie(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}const g=await ee(c.loader);if(!g)return{reply:{lattice:ae,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Y?Y.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,g);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:ae,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:ae,id:t,ok:!0,result:e},transfer:ne(e)}}catch(e){const m=e;return{reply:{lattice:ae,id:t,ok:!1,error:{code:m.code||te.KERNEL,message:m.message||String(e),stack:m.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async g=>{const e=await s(g.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),ee(c.loader).then(g=>{f.postMessage({lattice:ae,id:0,op:q.READY,compute:!!g})}),()=>f.removeEventListener("message",a)}});var bt=nt("packages/worker/src/kernel.js");gt.__latticeKernel=bt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}var kn=En("packages/modules/webcomponent/index.js");if(typeof module=="object"&&module.exports)module.exports=kn;else if(typeof define=="function"&&define.amd)define(function(){return kn});else{var sr=Hn.LatticeGrid||(Hn.LatticeGrid={});for(var Tn in kn)Tn!=="default"&&(sr[Tn]=kn[Tn])}})(typeof globalThis<"u"?globalThis:this);
57
57
 
58
58
  //# sourceMappingURL=webcomponent.min.js.map