@toclocoinc/lattice-grid 1.89.0 → 1.89.1

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 (310) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +5 -5
  5. package/docs/THEMING.md +27 -0
  6. package/docs/api/adapters.html +1 -1
  7. package/docs/api/ai.html +1 -1
  8. package/docs/api/alarms.html +1 -1
  9. package/docs/api/calendar.html +1 -1
  10. package/docs/api/charts.html +1 -1
  11. package/docs/api/dashboard.html +1 -1
  12. package/docs/api/data-router.html +1 -1
  13. package/docs/api/deckgl.html +1 -1
  14. package/docs/api/designer.html +2 -2
  15. package/docs/api/gantt.html +1 -1
  16. package/docs/api/geometry.html +1 -1
  17. package/docs/api/grid.html +2 -2
  18. package/docs/api/index.html +1 -1
  19. package/docs/api/kanban.html +1 -1
  20. package/docs/api/kpi.html +1 -1
  21. package/docs/api/layout.html +1 -1
  22. package/docs/api/leaflet.html +1 -1
  23. package/docs/api/list.html +1 -1
  24. package/docs/api/mapview.html +1 -1
  25. package/docs/api/mock-socket.html +1 -1
  26. package/docs/api/presets.html +1 -1
  27. package/docs/api/tabs.html +1 -1
  28. package/docs/api/types.html +1 -1
  29. package/docs/api-detail.html +4 -4
  30. package/docs/warnings.json +1 -1
  31. package/lattice-grid.d.ts +1 -1
  32. package/lattice-grid.esm.min.js +3 -3
  33. package/lattice-grid.min.cjs +3 -3
  34. package/lattice-grid.min.css +1 -1
  35. package/lattice-grid.min.js +3 -3
  36. package/modules/ai.d.ts +1 -1
  37. package/modules/ai.esm.min.js +2 -2
  38. package/modules/ai.min.cjs +2 -2
  39. package/modules/ai.min.js +2 -2
  40. package/modules/alarms.d.ts +1 -1
  41. package/modules/alarms.esm.min.js +2 -2
  42. package/modules/alarms.min.cjs +2 -2
  43. package/modules/alarms.min.js +2 -2
  44. package/modules/angular.d.ts +1 -1
  45. package/modules/angular.esm.min.js +2 -2
  46. package/modules/angular.min.cjs +2 -2
  47. package/modules/angular.min.js +2 -2
  48. package/modules/calendar.d.ts +1 -1
  49. package/modules/calendar.esm.min.js +2 -2
  50. package/modules/calendar.min.cjs +2 -2
  51. package/modules/calendar.min.js +2 -2
  52. package/modules/chart-alluvial.d.ts +1 -1
  53. package/modules/chart-alluvial.esm.min.js +1 -1
  54. package/modules/chart-alluvial.min.cjs +1 -1
  55. package/modules/chart-alluvial.min.js +1 -1
  56. package/modules/chart-arc.d.ts +1 -1
  57. package/modules/chart-arc.esm.min.js +1 -1
  58. package/modules/chart-arc.min.cjs +1 -1
  59. package/modules/chart-arc.min.js +1 -1
  60. package/modules/chart-barrace.d.ts +1 -1
  61. package/modules/chart-barrace.esm.min.js +1 -1
  62. package/modules/chart-barrace.min.cjs +1 -1
  63. package/modules/chart-barrace.min.js +1 -1
  64. package/modules/chart-bubblemap.d.ts +1 -1
  65. package/modules/chart-bubblemap.esm.min.js +1 -1
  66. package/modules/chart-bubblemap.min.cjs +1 -1
  67. package/modules/chart-bubblemap.min.js +1 -1
  68. package/modules/chart-bump.d.ts +1 -1
  69. package/modules/chart-bump.esm.min.js +1 -1
  70. package/modules/chart-bump.min.cjs +1 -1
  71. package/modules/chart-bump.min.js +1 -1
  72. package/modules/chart-calendar.d.ts +1 -1
  73. package/modules/chart-calendar.esm.min.js +1 -1
  74. package/modules/chart-calendar.min.cjs +1 -1
  75. package/modules/chart-calendar.min.js +1 -1
  76. package/modules/chart-choropleth.d.ts +1 -1
  77. package/modules/chart-choropleth.esm.min.js +1 -1
  78. package/modules/chart-choropleth.min.cjs +1 -1
  79. package/modules/chart-choropleth.min.js +1 -1
  80. package/modules/chart-decomposition.d.ts +1 -1
  81. package/modules/chart-decomposition.esm.min.js +1 -1
  82. package/modules/chart-decomposition.min.cjs +1 -1
  83. package/modules/chart-decomposition.min.js +1 -1
  84. package/modules/chart-diverging.d.ts +1 -1
  85. package/modules/chart-diverging.esm.min.js +1 -1
  86. package/modules/chart-diverging.min.cjs +1 -1
  87. package/modules/chart-diverging.min.js +1 -1
  88. package/modules/chart-dumbbell.d.ts +1 -1
  89. package/modules/chart-dumbbell.esm.min.js +1 -1
  90. package/modules/chart-dumbbell.min.cjs +1 -1
  91. package/modules/chart-dumbbell.min.js +1 -1
  92. package/modules/chart-fan.d.ts +1 -1
  93. package/modules/chart-fan.esm.min.js +1 -1
  94. package/modules/chart-fan.min.cjs +1 -1
  95. package/modules/chart-fan.min.js +1 -1
  96. package/modules/chart-forcetree.d.ts +1 -1
  97. package/modules/chart-forcetree.esm.min.js +1 -1
  98. package/modules/chart-forcetree.min.cjs +1 -1
  99. package/modules/chart-forcetree.min.js +1 -1
  100. package/modules/chart-hexbin.d.ts +1 -1
  101. package/modules/chart-hexbin.esm.min.js +1 -1
  102. package/modules/chart-hexbin.min.cjs +1 -1
  103. package/modules/chart-hexbin.min.js +1 -1
  104. package/modules/chart-hexmap.d.ts +1 -1
  105. package/modules/chart-hexmap.esm.min.js +1 -1
  106. package/modules/chart-hexmap.min.cjs +1 -1
  107. package/modules/chart-hexmap.min.js +1 -1
  108. package/modules/chart-icicle.d.ts +1 -1
  109. package/modules/chart-icicle.esm.min.js +1 -1
  110. package/modules/chart-icicle.min.cjs +1 -1
  111. package/modules/chart-icicle.min.js +1 -1
  112. package/modules/chart-markermap.d.ts +1 -1
  113. package/modules/chart-markermap.esm.min.js +1 -1
  114. package/modules/chart-markermap.min.cjs +1 -1
  115. package/modules/chart-markermap.min.js +1 -1
  116. package/modules/chart-motion.d.ts +1 -1
  117. package/modules/chart-motion.esm.min.js +1 -1
  118. package/modules/chart-motion.min.cjs +1 -1
  119. package/modules/chart-motion.min.js +1 -1
  120. package/modules/chart-pack.d.ts +1 -1
  121. package/modules/chart-pack.esm.min.js +1 -1
  122. package/modules/chart-pack.min.cjs +1 -1
  123. package/modules/chart-pack.min.js +1 -1
  124. package/modules/chart-parallel.d.ts +1 -1
  125. package/modules/chart-parallel.esm.min.js +1 -1
  126. package/modules/chart-parallel.min.cjs +1 -1
  127. package/modules/chart-parallel.min.js +1 -1
  128. package/modules/chart-pictorial.d.ts +1 -1
  129. package/modules/chart-pictorial.esm.min.js +1 -1
  130. package/modules/chart-pictorial.min.cjs +1 -1
  131. package/modules/chart-pictorial.min.js +1 -1
  132. package/modules/chart-polararea.d.ts +1 -1
  133. package/modules/chart-polararea.esm.min.js +1 -1
  134. package/modules/chart-polararea.min.cjs +1 -1
  135. package/modules/chart-polararea.min.js +1 -1
  136. package/modules/chart-polarscatter.d.ts +1 -1
  137. package/modules/chart-polarscatter.esm.min.js +1 -1
  138. package/modules/chart-polarscatter.min.cjs +1 -1
  139. package/modules/chart-polarscatter.min.js +1 -1
  140. package/modules/chart-pyramid.d.ts +1 -1
  141. package/modules/chart-pyramid.esm.min.js +1 -1
  142. package/modules/chart-pyramid.min.cjs +1 -1
  143. package/modules/chart-pyramid.min.js +1 -1
  144. package/modules/chart-radialbar.d.ts +1 -1
  145. package/modules/chart-radialbar.esm.min.js +1 -1
  146. package/modules/chart-radialbar.min.cjs +1 -1
  147. package/modules/chart-radialbar.min.js +1 -1
  148. package/modules/chart-ridgeline.d.ts +1 -1
  149. package/modules/chart-ridgeline.esm.min.js +1 -1
  150. package/modules/chart-ridgeline.min.cjs +1 -1
  151. package/modules/chart-ridgeline.min.js +1 -1
  152. package/modules/chart-roc.d.ts +1 -1
  153. package/modules/chart-roc.esm.min.js +1 -1
  154. package/modules/chart-roc.min.cjs +1 -1
  155. package/modules/chart-roc.min.js +1 -1
  156. package/modules/chart-serpentine.d.ts +1 -1
  157. package/modules/chart-serpentine.esm.min.js +1 -1
  158. package/modules/chart-serpentine.min.cjs +1 -1
  159. package/modules/chart-serpentine.min.js +1 -1
  160. package/modules/chart-slope.d.ts +1 -1
  161. package/modules/chart-slope.esm.min.js +1 -1
  162. package/modules/chart-slope.min.cjs +1 -1
  163. package/modules/chart-slope.min.js +1 -1
  164. package/modules/chart-spiral.d.ts +1 -1
  165. package/modules/chart-spiral.esm.min.js +1 -1
  166. package/modules/chart-spiral.min.cjs +1 -1
  167. package/modules/chart-spiral.min.js +1 -1
  168. package/modules/chart-splom.d.ts +1 -1
  169. package/modules/chart-splom.esm.min.js +1 -1
  170. package/modules/chart-splom.min.cjs +1 -1
  171. package/modules/chart-splom.min.js +1 -1
  172. package/modules/chart-tree.d.ts +1 -1
  173. package/modules/chart-tree.esm.min.js +1 -1
  174. package/modules/chart-tree.min.cjs +1 -1
  175. package/modules/chart-tree.min.js +1 -1
  176. package/modules/chart-venn.d.ts +1 -1
  177. package/modules/chart-venn.esm.min.js +1 -1
  178. package/modules/chart-venn.min.cjs +1 -1
  179. package/modules/chart-venn.min.js +1 -1
  180. package/modules/chart-voronoi.d.ts +1 -1
  181. package/modules/chart-voronoi.esm.min.js +1 -1
  182. package/modules/chart-voronoi.min.cjs +1 -1
  183. package/modules/chart-voronoi.min.js +1 -1
  184. package/modules/chart-waffle.d.ts +1 -1
  185. package/modules/chart-waffle.esm.min.js +1 -1
  186. package/modules/chart-waffle.min.cjs +1 -1
  187. package/modules/chart-waffle.min.js +1 -1
  188. package/modules/chart-wordcloud.d.ts +1 -1
  189. package/modules/chart-wordcloud.esm.min.js +1 -1
  190. package/modules/chart-wordcloud.min.cjs +1 -1
  191. package/modules/chart-wordcloud.min.js +1 -1
  192. package/modules/charts.d.ts +1 -1
  193. package/modules/charts.esm.min.js +2 -2
  194. package/modules/charts.min.cjs +2 -2
  195. package/modules/charts.min.js +2 -2
  196. package/modules/dashboard.d.ts +1 -1
  197. package/modules/dashboard.esm.min.js +2 -2
  198. package/modules/dashboard.min.cjs +2 -2
  199. package/modules/dashboard.min.js +2 -2
  200. package/modules/data-router.d.ts +1 -1
  201. package/modules/data-router.esm.min.js +2 -2
  202. package/modules/data-router.min.cjs +2 -2
  203. package/modules/data-router.min.js +2 -2
  204. package/modules/deckgl.d.ts +1 -1
  205. package/modules/deckgl.esm.min.js +2 -2
  206. package/modules/deckgl.min.cjs +2 -2
  207. package/modules/deckgl.min.js +2 -2
  208. package/modules/designer.d.ts +1 -1
  209. package/modules/designer.esm.min.js +187 -73
  210. package/modules/designer.esm.min.js.map +2 -2
  211. package/modules/designer.min.cjs +187 -73
  212. package/modules/designer.min.js +187 -73
  213. package/modules/designer.min.js.map +2 -2
  214. package/modules/devtools.d.ts +1 -1
  215. package/modules/devtools.esm.min.js +1 -1
  216. package/modules/devtools.min.cjs +1 -1
  217. package/modules/devtools.min.js +1 -1
  218. package/modules/dhtmlx-compat.d.ts +1 -1
  219. package/modules/dhtmlx-compat.esm.min.js +2 -2
  220. package/modules/dhtmlx-compat.min.cjs +2 -2
  221. package/modules/dhtmlx-compat.min.js +2 -2
  222. package/modules/gantt.d.ts +1 -1
  223. package/modules/gantt.esm.min.js +2 -2
  224. package/modules/gantt.min.cjs +2 -2
  225. package/modules/gantt.min.js +2 -2
  226. package/modules/geo-europe-nuts.d.ts +1 -1
  227. package/modules/geo-europe-nuts.esm.min.js +1 -1
  228. package/modules/geo-europe-nuts.min.cjs +1 -1
  229. package/modules/geo-europe-nuts.min.js +1 -1
  230. package/modules/geo-uk.d.ts +1 -1
  231. package/modules/geo-uk.esm.min.js +1 -1
  232. package/modules/geo-uk.min.cjs +1 -1
  233. package/modules/geo-uk.min.js +1 -1
  234. package/modules/geo-us-states.d.ts +1 -1
  235. package/modules/geo-us-states.esm.min.js +1 -1
  236. package/modules/geo-us-states.min.cjs +1 -1
  237. package/modules/geo-us-states.min.js +1 -1
  238. package/modules/geo-world-110m.d.ts +1 -1
  239. package/modules/geo-world-110m.esm.min.js +1 -1
  240. package/modules/geo-world-110m.min.cjs +1 -1
  241. package/modules/geo-world-110m.min.js +1 -1
  242. package/modules/geo-world-50m.d.ts +1 -1
  243. package/modules/geo-world-50m.esm.min.js +1 -1
  244. package/modules/geo-world-50m.min.cjs +1 -1
  245. package/modules/geo-world-50m.min.js +1 -1
  246. package/modules/geometry.d.ts +1 -1
  247. package/modules/geometry.esm.min.js +2 -2
  248. package/modules/geometry.min.cjs +2 -2
  249. package/modules/geometry.min.js +2 -2
  250. package/modules/htmx.d.ts +1 -1
  251. package/modules/htmx.esm.min.js +3 -3
  252. package/modules/htmx.min.cjs +3 -3
  253. package/modules/htmx.min.js +3 -3
  254. package/modules/kanban.d.ts +1 -1
  255. package/modules/kanban.esm.min.js +2 -2
  256. package/modules/kanban.min.cjs +2 -2
  257. package/modules/kanban.min.js +2 -2
  258. package/modules/kpi.d.ts +1 -1
  259. package/modules/kpi.esm.min.js +2 -2
  260. package/modules/kpi.min.cjs +2 -2
  261. package/modules/kpi.min.js +2 -2
  262. package/modules/layout.d.ts +1 -1
  263. package/modules/layout.esm.min.js +2 -2
  264. package/modules/layout.min.cjs +2 -2
  265. package/modules/layout.min.js +2 -2
  266. package/modules/leaflet.d.ts +1 -1
  267. package/modules/leaflet.esm.min.js +2 -2
  268. package/modules/leaflet.min.cjs +2 -2
  269. package/modules/leaflet.min.js +2 -2
  270. package/modules/list.d.ts +1 -1
  271. package/modules/list.esm.min.js +2 -2
  272. package/modules/list.min.cjs +2 -2
  273. package/modules/list.min.js +2 -2
  274. package/modules/mapview.d.ts +1 -1
  275. package/modules/mapview.esm.min.js +2 -2
  276. package/modules/mapview.min.cjs +2 -2
  277. package/modules/mapview.min.js +2 -2
  278. package/modules/mock-socket.d.ts +1 -1
  279. package/modules/mock-socket.esm.min.js +1 -1
  280. package/modules/mock-socket.min.cjs +1 -1
  281. package/modules/mock-socket.min.js +1 -1
  282. package/modules/presets/antd5.css +9 -0
  283. package/modules/presets/bootstrap5.css +9 -0
  284. package/modules/presets/fluent2.css +9 -0
  285. package/modules/presets/material3.css +9 -0
  286. package/modules/presets.d.ts +1 -1
  287. package/modules/presets.esm.min.js +2 -2
  288. package/modules/presets.min.cjs +2 -2
  289. package/modules/presets.min.js +2 -2
  290. package/modules/react.d.ts +1 -1
  291. package/modules/react.esm.min.js +2 -2
  292. package/modules/react.min.cjs +2 -2
  293. package/modules/react.min.js +2 -2
  294. package/modules/svelte.d.ts +1 -1
  295. package/modules/svelte.esm.min.js +2 -2
  296. package/modules/svelte.min.cjs +2 -2
  297. package/modules/svelte.min.js +2 -2
  298. package/modules/tabs.d.ts +1 -1
  299. package/modules/tabs.esm.min.js +2 -2
  300. package/modules/tabs.min.cjs +2 -2
  301. package/modules/tabs.min.js +2 -2
  302. package/modules/vue.d.ts +1 -1
  303. package/modules/vue.esm.min.js +2 -2
  304. package/modules/vue.min.cjs +2 -2
  305. package/modules/vue.min.js +2 -2
  306. package/modules/webcomponent.d.ts +1 -1
  307. package/modules/webcomponent.esm.min.js +3 -3
  308. package/modules/webcomponent.min.cjs +3 -3
  309. package/modules/webcomponent.min.js +3 -3
  310. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.89.0, core + DOM renderer
2
+ * Lattice Grid 1.89.1, core + DOM renderer
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var fr=Object.create(null),pr=Object.create(null);function Fe(e,K){fr[e]=K}function Wn(e){var K=pr[e];if(K)return K;var Q=Object.create(null);pr[e]=Q;var x=fr[e];if(!x)throw new Error("[lattice] missing module: "+e);return x(Q,Wn),Q}Fe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),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 o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return re}});const Q="1.89.0";async function x(){return Q}const z="1.89.0",$=new Set,_=2e3;function X(ie){if($.add(ie),$.size>_){const ae=$.values().next().value;ae!==void 0&&$.delete(ae)}}const W=[],V=500;function H(ie,ae,fe){W.push({key:ie,level:ae,message:fe.map(ce=>typeof ce=="string"?ce:B(ce)).join(" "),at:Date.now()}),W.length>V&&W.shift()}function B(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function w(){return W.map(ie=>({...ie}))}function A(ie){if(ie.length===0||typeof ie[0]!="string")return ie;const ae=ie[0].replace(/^\[lattice\]\s*/,"");return ae===ie[0]?ie:[ae,...ie.slice(1)]}function g(ie,...ae){if($.has(ie))return;X(ie);const fe=A(ae);H(ie,"warn",fe),console.warn("[lattice]",...fe)}function u(ie,...ae){if($.has(ie))return;X(ie);const fe=A(ae);H(ie,"info",fe),console.info("[lattice]",...fe)}function h(){$.clear(),W.length=0}function a(ie,ae){const fe=new Error(`[lattice] ${ie}`);throw ae!==void 0&&(fe.cause=ae),fe}function r(ie,ae){ie||a(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 o(ie){return typeof ie=="function"}function d(ie){return ie==null}function l(ie){return ie==null||ie===""}function i(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const m=new Map;function c(ie){let ae=m.get(ie);if(ae)return ae;if(!ie.includes("."))ae=fe=>fe?.[ie];else{const fe=ie.split("."),ce=fe.length;ae=te=>{let oe=te;for(let he=0;he<ce;he++){if(oe==null)return;oe=oe[fe[he]]}return oe}}return m.set(ie,ae),ae}const f=new Map;function s(ie){let ae=f.get(ie);if(ae)return ae;if(!ie.includes("."))ae=(fe,ce)=>{fe!=null&&(fe[ie]=ce)};else{const fe=ie.split("."),ce=fe.length-1;ae=(te,oe)=>{let he=te;for(let de=0;de<ce;de++){if(he==null)return;const be=fe[de];he[be]==null&&(he[be]={}),he=he[be]}he!=null&&(he[fe[ce]]=oe)}}return f.set(ie,ae),ae}function p(ie,ae){return c(ae)(ie)}function b(ie,ae,fe){s(ae)(ie,fe)}function S(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(/^./,fe=>fe.toUpperCase()):""}const j={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function y(ie){const ae=ie==null?"":String(ie);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,fe=>j[fe]):ae}function v(ie){return String(ie).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function R(ie,ae,fe){if(ie!==void 0)return ie===!0?{enabled:!0,...fe}:ie===!1?{enabled:!1}:n(ie)?ie:{[ae]:ie,enabled:!0}}function O(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(ie,ae){if(!n(ie))return n(ae)?{...ae}:ae;if(!n(ae))return ae===void 0?ie:ae;const fe={...ie};for(const ce of Object.keys(ae)){if(F.has(ce))continue;const te=ae[ce];te!==void 0&&(fe[ce]=n(te)&&n(fe[ce])?C(fe[ce],te):te)}return fe}function T(ie,ae){if(!n(ie)||!n(ae)||ie===ae)return ae;const fe=Object.create(Object.getPrototypeOf(ie));return Object.assign(fe,ie,ae),fe}class L{#e;#t=new Map;#n;constructor(ae=256,fe=null){this.#e=ae,this.#n=fe}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 fe=this.#t;if(!fe.has(ae))return;const ce=fe.get(ae);return fe.delete(ae),fe.set(ae,ce),ce}peek(ae){return this.#t.get(ae)}set(ae,fe){const ce=this.#t;return ce.has(ae)&&ce.delete(ae),ce.set(ae,fe),this.#r(),fe}delete(ae){const fe=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(fe,ae),fe}clear(){if(this.#n)for(const[ae,fe]of this.#t)this.#n(fe,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 fe=ae.keys().next().value,ce=ae.get(fe);ae.delete(fe),this.#n&&this.#n(ce,fe)}}}const E=new Map;function D(ie,ae){const fe=`${ie||""}|${ae?JSON.stringify(ae):""}`;let ce=E.get(fe);return ce||(ce=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...ae}),E.set(fe,ce)),ce}function I(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 fe=String(ie),ce=String(ae);return fe<ce?-1:fe>ce?1:0}function P(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function N(ie){return k?requestAnimationFrame(ie):setTimeout(()=>ie(P()),16)}function G(ie){ie!=null&&(k?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let ae=null,fe=null;const ce=()=>{ae=null;const oe=fe;fe=null,ie(...oe||[])},te=(...oe)=>{fe=oe,ae===null&&(ae=N(ce))};return te.cancel=()=>{G(ae),ae=null,fe=null},te.flush=()=>{ae!==null&&(G(ae),ce())},te}function Y(ie,ae){let fe=null,ce=null;const te=()=>{if(fe=null,ce===null)return;const de=ce;ce=null,ie(...de),oe()},oe=()=>{fe=setTimeout(te,ae),typeof fe?.unref=="function"&&fe.unref()},he=(...de)=>{fe===null?(ie(...de),oe()):(ce=de,clearTimeout(fe),oe())};return he.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,ce===null)return;const de=ce;ce=null,ie(...de)},he.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,ce=null},he.pending=()=>fe!==null||ce!==null,he}function J(ie,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:ae}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function re(ie="l"){return`${ie}${(++ee).toString(36)}`}}),Fe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function W(R,O){const F=Number(R),C=Number(O);if(R!==null&&R!==""&&O!==null&&O!==""&&Number.isFinite(F)&&Number.isFinite(C))return F<C?-1:F>C?1:0;const L=String(R??"").toLowerCase(),E=String(O??"").toLowerCase();return L<E?-1:L>E?1:0}function V(R){return R==null||R===""}function H(R,O){if(!O||typeof O!="object")return!1;const{op:F}=O,C=O.value,T=O.value2;switch(F){case"blank":return V(R);case"notBlank":return!V(R);case"true":return R===!0;case"false":return R===!1;default:break}if(V(R))return!1;switch(F){case"eq":return W(R,C)===0;case"ne":return W(R,C)!==0;case"gt":return W(R,C)>0;case"gte":return W(R,C)>=0;case"lt":return W(R,C)<0;case"lte":return W(R,C)<=0;case"between":return W(R,C)>=0&&W(R,T)<=0;case"outside":return W(R,C)<0||W(R,T)>0;case"contains":return String(R).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function B(R,O,F){const C=G=>{const q=String(G).replace("#",""),Y=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[T,L,E]=C(R),[D,I,P]=C(O),k=Math.max(0,Math.min(1,F)),N=(G,q)=>Math.round(G+(q-G)*k);return`#${[N(T,D),N(L,I),N(E,P)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const O=[];for(const D of R||[]){if(D==null||D==="")continue;const I=D instanceof Date?D.getTime():Number(D);Number.isFinite(I)&&O.push(I)}if(!O.length)return null;O.sort((D,I)=>D-I);let F=0,C=0,T=0;for(const D of O){F++;const I=D-C;C+=I/F,T+=I*(D-C)}const L=A(O,.25),E=A(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:C,stddev:O.length>1?Math.sqrt(T/(O.length-1)):0,median:A(O,.5),q1:L,q3:E,iqr:E-L,sorted:O}}function A(R,O){if(!R.length)return 0;const F=(R.length-1)*Math.max(0,Math.min(1,O)),C=Math.floor(F),T=Math.ceil(F);return C===T?R[C]:R[C]+(F-C)*(R[T]-R[C])}function g(R){for(const O of Array.isArray(R)?R:[])if(!(!O||typeof O!="object")&&(O.when&&_.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function u(R,O){const F=Number(R.value),C=T=>A(O.sorted,T);switch(R.op){case"topPercent":{const T=h(F,10);return{op:"gte",value:C(1-T)}}case"bottomPercent":{const T=h(F,10);return{op:"lte",value:C(T)}}case"topN":{const T=Math.max(1,Math.floor(F)||1),L=Math.max(0,O.sorted.length-T);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(F)||1),L=Math.min(O.sorted.length-1,T-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(F)?F:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(F)?F:2)*O.stddev}:null;case"outlier":{const T=(Number.isFinite(F)&&F>0?F:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-T,value2:O.q3+T}:null}default:return null}}function h(R,O){const F=Number.isFinite(R)?R:O,C=F>1?F/100:F;return Math.max(0,Math.min(1,C))}function a(R,O){if(R.from==="minmax")return{...R,min:O.min,max:O.max};if(R.from==="quantile")return{...R,min:A(O.sorted,h(Number(R.low),5)),max:A(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const F=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:O.mean-F*O.stddev,max:O.mean+F*O.stddev}}return R}function r(R,O){const F=Array.isArray(R)?R:[];return!O||!O.n?F.map(C=>C&&g([C])?{...C,enabled:!1}:C):F.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:a(C.scale,O)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,O)};if(C.iconSet)return{...C,iconSet:n(C.iconSet,O)};if(!C.when||!_.includes(C.when.op))return C;const T=u(C.when,O);return T?{...C,when:T}:{...C,enabled:!1}})}function t(R,O){const F=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(F!==void 0&&C!==void 0)return{...R,min:F,max:C};if(R.from==="quantile")return{...R,min:F??A(O.sorted,h(Number(R.low),5)),max:C??A(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:F??O.mean-T*O.stddev,max:C??O.mean+T*O.stddev}}return{...R,min:F??O.min,max:C??O.max}}function n(R,O){if(Array.isArray(R.thresholds))return R;const F=o(R),C=[];for(let T=1;T<F;T++)C.push(A(O.sorted,T/F));return{...R,thresholds:C}}function o(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const O=s[R.set];return O?O.length:3}function d(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function l(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,O){const F="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 ${O*16} 16">`;for(let T=0;T<O;T++){const L=T<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${T*16},0)" d="${F}" fill="${L}"/>`}return`${C}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),f=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),s=Object.freeze({arrows:c,trafficLights:f,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?d(String(C)):String(C));const O=R.set||"arrows";if(O==="ratings"){const C=o(R),T=[];for(let L=1;L<=C;L++)T.push(d(m(L,C)));return T}const F=s[O];return F?F.map(d):(z(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),c.map(d))}function S(R){const O=Number(R.min),C=Number(R.max)-O,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=P=>Math.max(0,Math.min(1,(P-O)/C))*100,I=C?Math.max(0,Math.min(100,(0-O)/C*100)):0;return P=>{if(V(P))return null;const k=Number(P);if(!Number.isFinite(k)||!C)return null;const N=D(k),G=Math.min(N,I),q=Math.max(N,I),Y=k>=0?T:L;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function j(R){const O=b(R),F=R.reverse?[...O].reverse():O,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(R.size))?Number(R.size):16,L=R.set==="ratings"?T*o(R):T;return E=>{if(V(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let I=0;for(const k of C)D>=k&&I++;const P=F[Math.min(I,F.length-1)];return P?{backgroundImage:P,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function y(R){const O=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],F=Number(R.min),C=Number(R.max),T=C-F,L=O.length-1,E=[];for(let I=0;I<=L;I++)E.push(L?I/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(O.length%2===0)z("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(F,C)&&D<Math.max(F,C)){const I=L/2,P=Math.max(0,Math.min(1,(D-F)/T));for(let k=0;k<=L;k++)E[k]=k<=I?I?k/I*P:P:P+(k-I)/(L-I)*(1-P)}else Number.isFinite(D)&&z("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return I=>{const P=Number(I);if(!Number.isFinite(P)||!T)return null;const k=Math.max(0,Math.min(1,(P-F)/T));let N=0;for(;N<L-1&&k>E[N+1];)N++;const G=E[N+1]-E[N],q=G>0?(k-E[N])/G:0;return{background:B(O[N],O[N+1],Math.max(0,Math.min(1,q)))}}}function v(R,O=null){const F=g(R)?r(R,O):R,C=(Array.isArray(F)?F:[]).filter(L=>L&&typeof L=="object");if(!C.length)return()=>null;const T=C.map(L=>L.scale?{scale:y(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:S(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:j(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const E=L?L.value:void 0;let D=null;for(const I of T){if(!I.enabled)continue;if(I.scale){const k=I.scale(E);k&&(D={...D||{},...k});continue}if(!H(E,I.when))continue;const P=x(I.style)?I.style(L):I.style;if(P&&(D={...D||{},...P}),I.stop)break}return D}}}),Fe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",x="str",z="ref",$="name",_="op",X="end",W=["<=",">=","<>","!="],V="+-*/^%(),<>=";class H extends Error{constructor(o,d){super(o),this.name="FormulaError",this.at=d}}function B(n){const o=[];let d=0;for(;d<n.length;){const l=n[d];if(l===" "||l===" "||l===`
6
+ var fr=Object.create(null),pr=Object.create(null);function Fe(e,K){fr[e]=K}function Wn(e){var K=pr[e];if(K)return K;var Q=Object.create(null);pr[e]=Q;var x=fr[e];if(!x)throw new Error("[lattice] missing module: "+e);return x(Q,Wn),Q}Fe("packages/core/src/internal/util.js",function(e,K){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return a}}),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 o}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return re}});const Q="1.89.1";async function x(){return Q}const z="1.89.1",$=new Set,_=2e3;function X(ie){if($.add(ie),$.size>_){const ae=$.values().next().value;ae!==void 0&&$.delete(ae)}}const W=[],V=500;function H(ie,ae,fe){W.push({key:ie,level:ae,message:fe.map(ce=>typeof ce=="string"?ce:B(ce)).join(" "),at:Date.now()}),W.length>V&&W.shift()}function B(ie){if(ie instanceof Error)return ie.message;try{return JSON.stringify(ie)}catch{return String(ie)}}function w(){return W.map(ie=>({...ie}))}function A(ie){if(ie.length===0||typeof ie[0]!="string")return ie;const ae=ie[0].replace(/^\[lattice\]\s*/,"");return ae===ie[0]?ie:[ae,...ie.slice(1)]}function g(ie,...ae){if($.has(ie))return;X(ie);const fe=A(ae);H(ie,"warn",fe),console.warn("[lattice]",...fe)}function u(ie,...ae){if($.has(ie))return;X(ie);const fe=A(ae);H(ie,"info",fe),console.info("[lattice]",...fe)}function h(){$.clear(),W.length=0}function a(ie,ae){const fe=new Error(`[lattice] ${ie}`);throw ae!==void 0&&(fe.cause=ae),fe}function r(ie,ae){ie||a(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 o(ie){return typeof ie=="function"}function d(ie){return ie==null}function l(ie){return ie==null||ie===""}function i(ie){return typeof ie!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ie))?!0:!!(ie.prototype&&Object.getOwnPropertyNames(ie.prototype).length>1)}const m=new Map;function c(ie){let ae=m.get(ie);if(ae)return ae;if(!ie.includes("."))ae=fe=>fe?.[ie];else{const fe=ie.split("."),ce=fe.length;ae=te=>{let oe=te;for(let he=0;he<ce;he++){if(oe==null)return;oe=oe[fe[he]]}return oe}}return m.set(ie,ae),ae}const f=new Map;function s(ie){let ae=f.get(ie);if(ae)return ae;if(!ie.includes("."))ae=(fe,ce)=>{fe!=null&&(fe[ie]=ce)};else{const fe=ie.split("."),ce=fe.length-1;ae=(te,oe)=>{let he=te;for(let de=0;de<ce;de++){if(he==null)return;const be=fe[de];he[be]==null&&(he[be]={}),he=he[be]}he!=null&&(he[fe[ce]]=oe)}}return f.set(ie,ae),ae}function p(ie,ae){return c(ae)(ie)}function b(ie,ae,fe){s(ae)(ie,fe)}function S(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(/^./,fe=>fe.toUpperCase()):""}const j={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function y(ie){const ae=ie==null?"":String(ie);return/[&<>"']/.test(ae)?ae.replace(/[&<>"']/g,fe=>j[fe]):ae}function v(ie){return String(ie).replace(/\w\S*/g,ae=>ae[0].toUpperCase()+ae.slice(1).toLowerCase())}function R(ie,ae,fe){if(ie!==void 0)return ie===!0?{enabled:!0,...fe}:ie===!1?{enabled:!1}:n(ie)?ie:{[ae]:ie,enabled:!0}}function O(ie){return ie==null?[]:Array.isArray(ie)?ie:[ie]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function C(ie,ae){if(!n(ie))return n(ae)?{...ae}:ae;if(!n(ae))return ae===void 0?ie:ae;const fe={...ie};for(const ce of Object.keys(ae)){if(F.has(ce))continue;const te=ae[ce];te!==void 0&&(fe[ce]=n(te)&&n(fe[ce])?C(fe[ce],te):te)}return fe}function T(ie,ae){if(!n(ie)||!n(ae)||ie===ae)return ae;const fe=Object.create(Object.getPrototypeOf(ie));return Object.assign(fe,ie,ae),fe}class L{#e;#t=new Map;#n;constructor(ae=256,fe=null){this.#e=ae,this.#n=fe}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 fe=this.#t;if(!fe.has(ae))return;const ce=fe.get(ae);return fe.delete(ae),fe.set(ae,ce),ce}peek(ae){return this.#t.get(ae)}set(ae,fe){const ce=this.#t;return ce.has(ae)&&ce.delete(ae),ce.set(ae,fe),this.#r(),fe}delete(ae){const fe=this.#t.get(ae);return this.#t.delete(ae)&&this.#n&&this.#n(fe,ae),fe}clear(){if(this.#n)for(const[ae,fe]of this.#t)this.#n(fe,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 fe=ae.keys().next().value,ce=ae.get(fe);ae.delete(fe),this.#n&&this.#n(ce,fe)}}}const E=new Map;function D(ie,ae){const fe=`${ie||""}|${ae?JSON.stringify(ae):""}`;let ce=E.get(fe);return ce||(ce=new Intl.Collator(ie||void 0,{numeric:!0,sensitivity:"variant",...ae}),E.set(fe,ce)),ce}function I(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 fe=String(ie),ce=String(ae);return fe<ce?-1:fe>ce?1:0}function P(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function N(ie){return k?requestAnimationFrame(ie):setTimeout(()=>ie(P()),16)}function G(ie){ie!=null&&(k?cancelAnimationFrame(ie):clearTimeout(ie))}function q(ie){let ae=null,fe=null;const ce=()=>{ae=null;const oe=fe;fe=null,ie(...oe||[])},te=(...oe)=>{fe=oe,ae===null&&(ae=N(ce))};return te.cancel=()=>{G(ae),ae=null,fe=null},te.flush=()=>{ae!==null&&(G(ae),ce())},te}function Y(ie,ae){let fe=null,ce=null;const te=()=>{if(fe=null,ce===null)return;const de=ce;ce=null,ie(...de),oe()},oe=()=>{fe=setTimeout(te,ae),typeof fe?.unref=="function"&&fe.unref()},he=(...de)=>{fe===null?(ie(...de),oe()):(ce=de,clearTimeout(fe),oe())};return he.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,ce===null)return;const de=ce;ce=null,ie(...de)},he.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,ce=null},he.pending=()=>fe!==null||ce!==null,he}function J(ie,ae=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ie,{timeout:ae}):setTimeout(()=>ie({timeRemaining:()=>0,didTimeout:!0}),1)}let ee=0;function re(ie="l"){return`${ie}${(++ee).toString(36)}`}}),Fe("packages/core/src/formatting/rules.js",function(e,K){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return v}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),_=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function W(R,O){const F=Number(R),C=Number(O);if(R!==null&&R!==""&&O!==null&&O!==""&&Number.isFinite(F)&&Number.isFinite(C))return F<C?-1:F>C?1:0;const L=String(R??"").toLowerCase(),E=String(O??"").toLowerCase();return L<E?-1:L>E?1:0}function V(R){return R==null||R===""}function H(R,O){if(!O||typeof O!="object")return!1;const{op:F}=O,C=O.value,T=O.value2;switch(F){case"blank":return V(R);case"notBlank":return!V(R);case"true":return R===!0;case"false":return R===!1;default:break}if(V(R))return!1;switch(F){case"eq":return W(R,C)===0;case"ne":return W(R,C)!==0;case"gt":return W(R,C)>0;case"gte":return W(R,C)>=0;case"lt":return W(R,C)<0;case"lte":return W(R,C)<=0;case"between":return W(R,C)>=0&&W(R,T)<=0;case"outside":return W(R,C)<0||W(R,T)>0;case"contains":return String(R).toLowerCase().includes(String(C??"").toLowerCase());case"notContains":return!String(R).toLowerCase().includes(String(C??"").toLowerCase());case"startsWith":return String(R).toLowerCase().startsWith(String(C??"").toLowerCase());case"endsWith":return String(R).toLowerCase().endsWith(String(C??"").toLowerCase());default:return!1}}function B(R,O,F){const C=G=>{const q=String(G).replace("#",""),Y=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[T,L,E]=C(R),[D,I,P]=C(O),k=Math.max(0,Math.min(1,F)),N=(G,q)=>Math.round(G+(q-G)*k);return`#${[N(T,D),N(L,I),N(E,P)].map(G=>G.toString(16).padStart(2,"0")).join("")}`}function w(R){const O=[];for(const D of R||[]){if(D==null||D==="")continue;const I=D instanceof Date?D.getTime():Number(D);Number.isFinite(I)&&O.push(I)}if(!O.length)return null;O.sort((D,I)=>D-I);let F=0,C=0,T=0;for(const D of O){F++;const I=D-C;C+=I/F,T+=I*(D-C)}const L=A(O,.25),E=A(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:C,stddev:O.length>1?Math.sqrt(T/(O.length-1)):0,median:A(O,.5),q1:L,q3:E,iqr:E-L,sorted:O}}function A(R,O){if(!R.length)return 0;const F=(R.length-1)*Math.max(0,Math.min(1,O)),C=Math.floor(F),T=Math.ceil(F);return C===T?R[C]:R[C]+(F-C)*(R[T]-R[C])}function g(R){for(const O of Array.isArray(R)?R:[])if(!(!O||typeof O!="object")&&(O.when&&_.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function u(R,O){const F=Number(R.value),C=T=>A(O.sorted,T);switch(R.op){case"topPercent":{const T=h(F,10);return{op:"gte",value:C(1-T)}}case"bottomPercent":{const T=h(F,10);return{op:"lte",value:C(T)}}case"topN":{const T=Math.max(1,Math.floor(F)||1),L=Math.max(0,O.sorted.length-T);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const T=Math.max(1,Math.floor(F)||1),L=Math.min(O.sorted.length-1,T-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(F)?F:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(F)?F:2)*O.stddev}:null;case"outlier":{const T=(Number.isFinite(F)&&F>0?F:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-T,value2:O.q3+T}:null}default:return null}}function h(R,O){const F=Number.isFinite(R)?R:O,C=F>1?F/100:F;return Math.max(0,Math.min(1,C))}function a(R,O){if(R.from==="minmax")return{...R,min:O.min,max:O.max};if(R.from==="quantile")return{...R,min:A(O.sorted,h(Number(R.low),5)),max:A(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const F=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:O.mean-F*O.stddev,max:O.mean+F*O.stddev}}return R}function r(R,O){const F=Array.isArray(R)?R:[];return!O||!O.n?F.map(C=>C&&g([C])?{...C,enabled:!1}:C):F.map(C=>{if(!C||typeof C!="object")return C;if(C.scale&&C.scale.from)return{...C,scale:a(C.scale,O)};if(C.dataBar)return{...C,dataBar:t(C.dataBar,O)};if(C.iconSet)return{...C,iconSet:n(C.iconSet,O)};if(!C.when||!_.includes(C.when.op))return C;const T=u(C.when,O);return T?{...C,when:T}:{...C,enabled:!1}})}function t(R,O){const F=Number.isFinite(Number(R.min))?Number(R.min):void 0,C=Number.isFinite(Number(R.max))?Number(R.max):void 0;if(F!==void 0&&C!==void 0)return{...R,min:F,max:C};if(R.from==="quantile")return{...R,min:F??A(O.sorted,h(Number(R.low),5)),max:C??A(O.sorted,h(Number(R.high),95))};if(R.from==="stddev"){const T=Number.isFinite(Number(R.deviations))?Number(R.deviations):2;return{...R,min:F??O.mean-T*O.stddev,max:C??O.mean+T*O.stddev}}return{...R,min:F??O.min,max:C??O.max}}function n(R,O){if(Array.isArray(R.thresholds))return R;const F=o(R),C=[];for(let T=1;T<F;T++)C.push(A(O.sorted,T/F));return{...R,thresholds:C}}function o(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.length;if(Number.isFinite(Number(R.count))&&Number(R.count)>=2)return Math.floor(Number(R.count));const O=s[R.set];return O?O.length:3}function d(R){return`url("data:image/svg+xml,${encodeURIComponent(R)}")`}function l(R){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${R}"/></svg>`}function i(R,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${R}"/></svg>`}function m(R,O){const F="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 ${O*16} 16">`;for(let T=0;T<O;T++){const L=T<R?"#f5a623":"#d0d0d0";C+=`<path transform="translate(${T*16},0)" d="${F}" fill="${L}"/>`}return`${C}</svg>`}const c=Object.freeze([i("#c0392b","down"),i("#e0a800","right"),i("#2e7d32","up")]),f=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),s=Object.freeze({arrows:c,trafficLights:f,ratings:Object.freeze([1,2,3,4,5].map(R=>m(R,5)))}),p=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function b(R){if(Array.isArray(R.icons)&&R.icons.length>=2)return R.icons.map(C=>/^\s*(url\(|data:|<)/.test(String(C))&&String(C).trim().startsWith("<")?d(String(C)):String(C));const O=R.set||"arrows";if(O==="ratings"){const C=o(R),T=[];for(let L=1;L<=C;L++)T.push(d(m(L,C)));return T}const F=s[O];return F?F.map(d):(z(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),c.map(d))}function S(R){const O=Number(R.min),C=Number(R.max)-O,T=R.colour||R.color||"#5b9bd5",L=R.negativeColour||R.negativeColor||"#d13438",E=R.direction==="rtl"?"left":"right",D=P=>Math.max(0,Math.min(1,(P-O)/C))*100,I=C?Math.max(0,Math.min(100,(0-O)/C*100)):0;return P=>{if(V(P))return null;const k=Number(P);if(!Number.isFinite(k)||!C)return null;const N=D(k),G=Math.min(N,I),q=Math.max(N,I),Y=k>=0?T:L;return{backgroundImage:`linear-gradient(to ${E}, transparent ${G}%, ${Y} ${G}%, ${Y} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function j(R){const O=b(R),F=R.reverse?[...O].reverse():O,C=(Array.isArray(R.thresholds)?R.thresholds:[]).map(Number).filter(Number.isFinite),T=Number.isFinite(Number(R.size))?Number(R.size):16,L=R.set==="ratings"?T*o(R):T;return E=>{if(V(E))return null;const D=Number(E);if(!Number.isFinite(D))return null;let I=0;for(const k of C)D>=k&&I++;const P=F[Math.min(I,F.length-1)];return P?{backgroundImage:P,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${T}px`,paddingLeft:`${L+4}px`}:null}}function y(R){const O=Array.isArray(R.colours)&&R.colours.length>=2?R.colours:["#f8f9fa","#1a6bc7"],F=Number(R.min),C=Number(R.max),T=C-F,L=O.length-1,E=[];for(let I=0;I<=L;I++)E.push(L?I/L:0);const D=Number(R.mid);if(R.mid!==void 0&&R.mid!==null)if(O.length%2===0)z("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(D)&&T&&D>Math.min(F,C)&&D<Math.max(F,C)){const I=L/2,P=Math.max(0,Math.min(1,(D-F)/T));for(let k=0;k<=L;k++)E[k]=k<=I?I?k/I*P:P:P+(k-I)/(L-I)*(1-P)}else Number.isFinite(D)&&z("formatting.scale.mid.range",`a scale's "mid" (${D}) is outside its min..max range, so it was ignored.`);return I=>{const P=Number(I);if(!Number.isFinite(P)||!T)return null;const k=Math.max(0,Math.min(1,(P-F)/T));let N=0;for(;N<L-1&&k>E[N+1];)N++;const G=E[N+1]-E[N],q=G>0?(k-E[N])/G:0;return{background:B(O[N],O[N+1],Math.max(0,Math.min(1,q)))}}}function v(R,O=null){const F=g(R)?r(R,O):R,C=(Array.isArray(F)?F:[]).filter(L=>L&&typeof L=="object");if(!C.length)return()=>null;const T=C.map(L=>L.scale?{scale:y(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:S(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:j(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const E=L?L.value:void 0;let D=null;for(const I of T){if(!I.enabled)continue;if(I.scale){const k=I.scale(E);k&&(D={...D||{},...k});continue}if(!H(E,I.when))continue;const P=x(I.style)?I.style(L):I.style;if(P&&(D={...D||{},...P}),I.stop)break}return D}}}),Fe("packages/core/src/formula/parse.js",function(e,K){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const Q="num",x="str",z="ref",$="name",_="op",X="end",W=["<=",">=","<>","!="],V="+-*/^%(),<>=";class H extends Error{constructor(o,d){super(o),this.name="FormulaError",this.at=d}}function B(n){const o=[];let d=0;for(;d<n.length;){const l=n[d];if(l===" "||l===" "||l===`
7
7
  `||l==="\r"){d++;continue}if(l>="0"&&l<="9"){d=A(n,d,o);continue}if(l==="."&&n[d+1]>="0"&&n[d+1]<="9"){d=A(n,d,o);continue}if(l==='"'||l==="'"){d=g(n,d,o);continue}if(l==="["){const m=n.indexOf("]",d+1);if(m<0)throw new H("a [column reference] was opened and never closed",d);o.push({kind:z,value:n.slice(d+1,m).trim(),at:d}),d=m+1;continue}if(w(l)){d=u(n,d,o);continue}const i=n.slice(d,d+2);if(W.includes(i)){o.push({kind:_,value:i==="!="?"<>":i,at:d}),d+=2;continue}if(V.includes(l)){o.push({kind:_,value:l,at:d}),d++;continue}throw new H(`unexpected character ${JSON.stringify(l)}`,d)}return o.push({kind:X,value:null,at:n.length}),o}function w(n){return/[A-Za-z_À-￿]/.test(n)}function A(n,o,d){let l=o,i=!1;for(;l<n.length;){const m=n[l];if(m>="0"&&m<="9"){l++;continue}if(m==="."&&!i){i=!0,l++;continue}if((m==="e"||m==="E")&&/[0-9+-]/.test(n[l+1]||"")){for(l+=2;l<n.length&&n[l]>="0"&&n[l]<="9";)l++;break}break}return d.push({kind:Q,value:Number(n.slice(o,l)),at:o}),l}function g(n,o,d){const l=n[o];let i=o+1,m="";for(;i<n.length;){if(n[i]===l){if(n[i+1]===l){m+=l,i+=2;continue}return d.push({kind:x,value:m,at:o}),i+1}m+=n[i],i++}throw new H("a string was opened and never closed",o)}function u(n,o,d){let l=o;for(;l<n.length&&/[A-Za-z0-9_.À-￿]/.test(n[l]);)l++;const i=n.slice(o,l);let m=l;for(;m<n.length&&n[m]===" ";)m++;return d.push({kind:n[m]==="("?$:z,value:i,at:o}),l}const h={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function a(n){const o=String(n??"").replace(/^\s*=/,"");if(!o.trim())throw new H("the formula is empty");const d=B(o);let l=0;const i=()=>d[l],m=()=>d[l++],c=y=>{const v=i();if(v.kind!==_||v.value!==y)throw new H(`expected ${JSON.stringify(y)}`,v.at);l++},f=y=>{let v=s();for(;;){const R=i();if(R.kind!==_)break;const O=h[R.value];if(!O||O<y)break;l++;const F=f(R.value==="^"?O:O+1);v={kind:"bin",op:R.value,left:v,right:F}}return v},s=()=>{const y=i();return y.kind===_&&(y.value==="-"||y.value==="+")?(l++,{kind:"unary",op:y.value,arg:s()}):p()},p=()=>{let y=b();for(;i().kind===_&&i().value==="%";)l++,y={kind:"unary",op:"%",arg:y};return y},b=()=>{const y=m();if(y.kind===Q)return{kind:"num",value:y.value};if(y.kind===x)return{kind:"str",value:y.value};if(y.kind===z)return{kind:"ref",name:y.value};if(y.kind===$){c("(");const v=[];if(!(i().kind===_&&i().value===")"))for(;;){if(v.push(f(1)),i().kind===_&&i().value===","){l++;continue}break}return c(")"),{kind:"call",name:String(y.value).toUpperCase(),args:v}}if(y.kind===_&&y.value==="("){const v=f(1);return c(")"),v}throw y.kind===X?new H("the formula ends unexpectedly",y.at):new H(`unexpected ${JSON.stringify(y.value)}`,y.at)},S=f(1),j=i();if(j.kind!==X)throw new H(`unexpected ${JSON.stringify(j.value)}: is an operator missing?`,j.at);return S}function r(n){const o=new Set,d=l=>{if(!(!l||typeof l!="object")){if(l.kind==="ref"){o.add(String(l.name));return}if(l.kind==="bin"){d(l.left),d(l.right);return}if(l.kind==="unary"){d(l.arg);return}if(l.kind==="call")for(const i of l.args)d(i)}};return d(n),[...o]}function t(n){return typeof n=="string"&&/^\s*=/.test(n)&&n.trim()!=="="}}),Fe("packages/core/src/formula/evaluate.js",function(e,K){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return A}});const x=K("packages/core/src/formula/parse.js").FormulaError;function z(g){if(g==null||g==="")return 0;if(typeof g=="boolean")return g?1:0;if(g instanceof Date)return g.getTime();const u=typeof g=="number"?g:Number(String(g).replace(/[,\s]/g,""));if(!Number.isFinite(u))throw new x(`${JSON.stringify(g)} is not a number`);return u}function $(g){return g==null?"":String(g)}function _(g){if(typeof g=="boolean")return g;if(g==null||g==="")return!1;if(typeof g=="number")return g!==0;const u=String(g).trim().toLowerCase();return u==="false"||u==="no"||u==="0"?!1:u!==""}function X(g){const u=[];for(const h of g){if(Array.isArray(h)){for(const a of h)a!=null&&a!==""&&u.push(z(a));continue}h==null||h===""||u.push(z(h))}return u}function W(g,u){const h=10**u,a=g*h;return Math.sign(a)*Math.round(Math.abs(a)+Number.EPSILON*Math.abs(a))/h}function V(g,u){if(!g.length)return 0;const h=g.slice().sort((n,o)=>n-o),a=(h.length-1)*Math.min(1,Math.max(0,u)),r=Math.floor(a),t=Math.ceil(a);return r===t?h[r]:h[r]+(a-r)*(h[t]-h[r])}function H(g,u){let h=0,a=0,r=0;for(const n of g){h++;const o=n-a;a+=o/h,r+=o*(n-a)}const t=u?h-1:h;return t>0?Math.sqrt(r/t):0}const B={SUM:g=>X(g).reduce((u,h)=>u+h,0),AVERAGE:g=>{const u=X(g);return u.length?u.reduce((h,a)=>h+a,0)/u.length:0},MIN:g=>{const u=X(g);return u.length?Math.min(...u):0},MAX:g=>{const u=X(g);return u.length?Math.max(...u):0},COUNT:g=>X(g).length,PRODUCT:g=>X(g).reduce((u,h)=>u*h,1),ROUND:g=>W(z(g[0]),g.length>1?z(g[1]):0),ROUNDDOWN:g=>{const u=10**(g.length>1?z(g[1]):0),h=z(g[0])*u;return(h<0?Math.ceil(h):Math.floor(h))/u},ROUNDUP:g=>{const u=10**(g.length>1?z(g[1]):0),h=z(g[0])*u;return(h<0?Math.floor(h):Math.ceil(h))/u},ABS:g=>Math.abs(z(g[0])),FLOOR:g=>Math.floor(z(g[0])),CEILING:g=>Math.ceil(z(g[0])),SQRT:g=>Math.sqrt(z(g[0])),POWER:g=>z(g[0])**z(g[1]),MOD:g=>{const u=z(g[1]);if(u===0)throw new x("MOD by zero");return(z(g[0])%u+u)%u},IF:g=>_(g[0])?g[1]:g.length>2?g[2]:!1,AND:g=>g.every(_),OR:g=>g.some(_),NOT:g=>!_(g[0]),COALESCE:g=>g.find(u=>u!=null&&u!=="")??null,CONCAT:g=>g.map($).join(""),LEN:g=>$(g[0]).length,UPPER:g=>$(g[0]).toUpperCase(),LOWER:g=>$(g[0]).toLowerCase(),TRIM:g=>$(g[0]).trim(),LEFT:g=>$(g[0]).slice(0,g.length>1?z(g[1]):1),RIGHT:g=>{const u=g.length>1?z(g[1]):1;return u<=0?"":$(g[0]).slice(-u)},MEDIAN:g=>V(X(g),.5),PERCENTILE:g=>{const u=z(g[g.length-1]);return V(X(g.slice(0,-1)),u>1?u/100:u)},QUARTILE1:g=>V(X(g),.25),QUARTILE3:g=>V(X(g),.75),STDEV:g=>H(X(g),!0),STDEVP:g=>H(X(g),!1),VAR:g=>{const u=H(X(g),!0);return u*u},VARP:g=>{const u=H(X(g),!1);return u*u},COUNTDISTINCT:g=>{const u=new Set;for(const h of g){const a=Array.isArray(h)?h:[h];for(const r of a)r!=null&&r!==""&&u.add(r)}return u.size},IQR:g=>{const u=X(g);return V(u,.75)-V(u,.25)}};B.AVG=B.AVERAGE,B.CEIL=B.CEILING,B.POW=B.POWER,B.STDEVS=B.STDEV,B.PERCENTILEINC=B.PERCENTILE;function w(g,u){const h=Number(g),a=Number(u);if(g!==null&&g!==""&&u!==null&&u!==""&&Number.isFinite(h)&&Number.isFinite(a))return h<a?-1:h>a?1:0;const t=$(g).toLowerCase(),n=$(u).toLowerCase();return t<n?-1:t>n?1:0}function A(g,u={}){const h=typeof u.lookup=="function"?u.lookup:null,a=u.functions?{...B,...u.functions}:B,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!h)throw new x(`there is no column called ${JSON.stringify(t.name)} here`);const n=h(String(t.name));if(n===void 0)throw new x(`there is no column called ${JSON.stringify(t.name)}`);return n}case"unary":{if(t.op==="%")return z(r(t.arg))/100;const n=z(r(t.arg));return t.op==="-"?-n:n}case"bin":{const n=t.op;if(n==="=")return w(r(t.left),r(t.right))===0;if(n==="<>")return w(r(t.left),r(t.right))!==0;if(n==="<")return w(r(t.left),r(t.right))<0;if(n==="<=")return w(r(t.left),r(t.right))<=0;if(n===">")return w(r(t.left),r(t.right))>0;if(n===">=")return w(r(t.left),r(t.right))>=0;const o=z(r(t.left)),d=z(r(t.right));if(n==="+")return o+d;if(n==="-")return o-d;if(n==="*")return o*d;if(n==="^")return o**d;if(n==="/"){if(d===0)throw new x("division by zero");return o/d}throw new x(`unknown operator ${JSON.stringify(n)}`)}case"call":{const n=u.lazy&&u.lazy[t.name];if(typeof n=="function")return n(t.args,r,u);const o=a[t.name];if(typeof o!="function")throw new x(`there is no function called ${t.name}`);return o(t.args.map(r),u)}default:throw new x("the formula could not be read")}};return r(g)}}),Fe("packages/core/src/formula/index.js",function(e,K){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/formula/parse.js"),x=Q.parseFormula,z=Q.referencesOf,$=Q.looksLikeFormula,_=Q.FormulaError,X=Q.tokenise,W=K("packages/core/src/formula/evaluate.js"),V=W.evaluateAst,H=W.FUNCTIONS;function B(A){const{grid:g,row:u,data:h}=A||{},a=d=>String(d).toLowerCase().replace(/[\s_-]/g,""),r=g&&g.columns&&typeof g.columns.all=="function"?g.columns.all():[],t=g&&g.permissions,n=t&&typeof t.isReadable=="function"?d=>t.isReadable(d):()=>!0,o=new Set;for(const d of r)n(d)||(o.add(a(d.id)),d.field&&o.add(a(d.field)),d.title&&o.add(a(d.title)));return d=>{const l=a(d);if(o.has(l))throw new _(`"${d}" cannot be read`);for(const i of r)if(a(i.id)===l||i.field&&a(i.field)===l||i.title&&a(i.title)===l)return u&&g.rows&&typeof g.rows.value=="function"?g.rows.value(u.key,i.id):h?h[i.field||i.id]:void 0;if(h&&typeof h=="object"){for(const i of Object.keys(h))if(a(i)===l){if(!n(i))throw new _(`"${d}" cannot be read`);return h[i]}}}}function w(A,g={}){try{const u=x(A);return{ok:!0,value:V(u,{lookup:B(g),functions:g.formulaFunctions}),references:z(u)}}catch(u){return{ok:!1,error:u instanceof _?u.message:"the formula could not be read",at:u instanceof _?u.at:void 0}}}}),Fe("packages/core/src/defaults.js",function(e,K){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return H}});const Q=K("packages/core/src/internal/util.js"),x=Q.isObject,z=Q.merge,$=Q.warnOnce;let _=null;class X extends Error{}function W(B,w=new Set){if(Array.isArray(B)){if(w.has(B))throw new X;w.add(B);const g=B.map(u=>W(u,w));return w.delete(B),g}if(!x(B)||Object.getPrototypeOf(B)!==Object.prototype&&Object.getPrototypeOf(B)!==null)return B;if(w.has(B))throw new X;w.add(B);const A={};for(const[g,u]of Object.entries(B))A[g]=W(u,w);return w.delete(B),A}function V(B){if(B===void 0)return W(_??{});if(B===null)return _=null,{};if(!x(B))return $("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(B)?"an array":typeof B}. The call was ignored and the defaults are unchanged.`),W(_??{});try{_=W(B)}catch(w){if(!(w instanceof X))throw w;return $("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),W(_??{})}return W(_)}function H(B){return _===null?B:z(W(_),B)}}),Fe("packages/core/src/events/names.js",function(e,K){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return z}});const Q=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),x=new Set(Q);function z($){return $==="*"||x.has($)}}),Fe("packages/core/src/events/bus.js",function(e,K){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.uid,$=Q.DEV,X=K("packages/core/src/events/names.js").isKnownEvent,W="*";function V(h,a){!$||X(a)||x(`bus.unknown:${a}`,`${h}('${a}') 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 H=new Set(["api","user","init","ai"]),B=new WeakMap;function w(h){let a=B.get(h);return a||(a=z("h"),B.set(h,a)),a}function A(){return typeof performance=="object"&&performance?performance.now():Date.now()}function g(h){if(!h||typeof h!="object")return{};const a={};for(const[r,t]of Object.entries(h))r!=="grid"&&(t==null?a[r]=String(t):Array.isArray(t)?a[r]=`[${t.length}]`:typeof t=="object"?a[r]=t.key?`row ${t.key}`:"{…}":typeof t=="function"?a[r]="[function]":a[r]=String(t).slice(0,60));return a}class u{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(a=null){this.#i=a}attach(a){this.#i=a}get grid(){return this.#i}get destroyed(){return this.#s}on(a,r){if(typeof r!="function")return x(`bus.handler:${a}`,`on('${a}') needs a function; ignored.`),()=>{};V("on",a);let t=this.#e.get(a);return t||(t=[],this.#e.set(a,t)),t.push(r),()=>this.off(a,r)}once(a,r){if(typeof r!="function")return x(`bus.handler:${a}`,`once('${a}') needs a function; ignored.`),()=>{};V("once",a);const t=n=>{this.off(a,r),r(n)};return this.#o.set(r,t),this.on(a,t)}off(a,r){if(r===void 0){this.#e.delete(a);return}const t=this.#e.get(a);if(!t)return;const n=this.#o.get(r),o=n&&t.includes(n)?n:r,d=t.indexOf(o);d>=0&&t.splice(d,1),n&&o===n&&this.#o.delete(r),t.length===0&&this.#e.delete(a)}count(a){const r=this.#e.get(a),t=a===W?null:this.#e.get(W);return(r?r.length:0)+(t?t.length:0)}#a(a,r,t,n,o){this.#n.push({type:a,origin:r,listeners:(n?n.length:0)+(o?o.length:0),payload:g(t),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(a,r){this.#t=!!a,Number.isFinite(r)&&r>0&&(this.#r=Math.floor(r)),a||(this.#n=[])}eventLog(){return this.#n.map(a=>({...a}))}clearEventLog(){this.#n=[]}counts(){const a={};for(const[r,t]of this.#e)a[r]=t.length;return a}emit(a,r,t){const n=t??(r&&r.origin),o=H.has(n)?n:"api",d={...r||null,type:a,origin:o,grid:this.#i};if(this.#s)return d;const l=this.#e.get(a),i=a===W?void 0:this.#e.get(W);if(this.#t&&this.#a(a,o,r,l,i),!l&&!i)return d;const m=this.#t?A():0;this.#l++;try{l&&this.#u(l.slice(),d,a),i&&this.#u(i.slice(),d,W)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=A()-m)}return d}emitBefore(a,r,t){const n=t??(r&&r.origin),o=H.has(n)?n:"user";let d=!1,l=null;const i=b=>{d=!0,b!=null&&l===null&&(l=String(b))},m={...r||null,type:a,origin:o,grid:this.#i,get defaultPrevented(){return d},get reason(){return l},preventDefault(b){i(b)}};if(this.#s)return!0;const c=this.#e.get(a);this.#t&&this.#a(a,o,r,c,void 0);const f=c?c.slice():[];if(f.length===0)return!0;const s=()=>(d&&l===null&&(l="prevented"),d&&r&&typeof r=="object"&&(r.reason=l),!d),p=[];for(const b of f)try{const S=b(m);S&&typeof S.then=="function"?p.push(S):S===!1&&i("prevented")}catch(S){i("error"),x(`bus.beforeThrow:${a}:${w(b)}`,`a '${a}' before-handler threw; the action was cancelled.`,S)}return p.length===0?s():Promise.allSettled(p).then(b=>{for(const S of b)S.status==="rejected"?(i("error"),x(`bus.beforeReject:${a}`,`a '${a}' before-handler rejected; the action was cancelled.`,S.reason)):S.value===!1&&i("prevented");return s()})}#u(a,r,t){for(let n=0;n<a.length;n++)try{a[n](r)}catch(o){x(`bus.throw:${t}:${w(a[n])}`,`a '${t}' handler threw; other handlers were unaffected.`,o)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Fe("packages/core/src/registry/free-tier-notice.js",function(e,K){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return Q}});const Q="Free for non-commercial use: latticegrid.dev/free"}),Fe("packages/core/src/registry/licence.js",function(e,K){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return F}});const x=K("packages/core/src/internal/util.js").warnOnce,z=K("packages/core/src/registry/free-tier-notice.js"),$=z.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return z.FREE_TIER_NOTICE}});const _="lattice-grid",X=1,W="LG1",V=64,H="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",w=(()=>{const C=new Int16Array(128).fill(-1);for(let T=0;T<B.length;T++)C[B.charCodeAt(T)]=T;return C[43]=62,C[47]=63,C})();function A(C){if(typeof C!="string")return null;let T="";for(let k=0;k<C.length;k++){const N=C.charCodeAt(k);if(N!==61){if(N>127||w[N]<0)return null;T+=C[k]}}const L=T.length;if(L%4===1)return null;const E=new Uint8Array(Math.floor(L*3/4));let D=0,I=0,P=0;for(let k=0;k<L;k++)D=D<<6|w[T.charCodeAt(k)],I+=6,I>=8&&(I-=8,E[P++]=D>>I&255);return P===E.length?E:E.subarray(0,P)}function g(C){let T="",L=0;for(;L+2<C.length;L+=3){const D=C[L]<<16|C[L+1]<<8|C[L+2];T+=B[D>>18&63]+B[D>>12&63]+B[D>>6&63]+B[D&63]}const E=C.length-L;if(E===1){const D=C[L]<<16;T+=B[D>>18&63]+B[D>>12&63]}else if(E===2){const D=C[L]<<16|C[L+1]<<8;T+=B[D>>18&63]+B[D>>12&63]+B[D>>6&63]}return T}function u(C){const T=new Uint8Array(C.length);for(let L=0;L<C.length;L++)T[L]=C.charCodeAt(L)&127;return T}function h(C){if(typeof TextDecoder=="function")return new TextDecoder().decode(C);let T="";for(let L=0;L<C.length;L++)T+=String.fromCharCode(C[L]);return T}function a(C){const T={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof C=="string"?C:""};if(typeof C!="string"||C.length===0)return{...T,reason:"missing"};const L=C.trim(),E=L.split(".");if(E.length!==3)return T;const[D,I,P]=E;if(D!==W)return{...T,reason:"prefix"};const k=A(I),N=A(P);if(!k||!N)return T;let G;try{G=JSON.parse(h(k))}catch{return T}return G===null||typeof G!="object"?T:{ok:!0,reason:null,product:typeof G.p=="string"?G.p:null,issuedTo:typeof G.t=="string"?G.t:null,expires:typeof G.e=="string"?G.e:null,terms:typeof G.terms=="string"?G.terms:null,features:Array.isArray(G.f)?G.f.slice():[],deployments:Array.isArray(G.d)?G.d.slice():[],version:typeof G.v=="number"?G.v:0,message:u(I),signature:N,raw:L}}function r(C,T){if(!C)return!1;const L=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(C)?`${C}T23:59:59.999Z`:C);return Number.isNaN(L)?!0:T>L}function t(C){return C==="non-commercial"?"non-commercial":"commercial"}let n=null,o=null,d=null;function l(){const C=globalThis.crypto;return C&&C.subtle?C.subtle:null}async function i(C){if(n&&o===C)return n;const T=l();if(!T)return null;const L=A(C);if(!L)return null;try{const E=await T.importKey("raw",L,{name:"Ed25519"},!1,["verify"]);return n=E,o=C,E}catch{return null}}async function m(){return d!==null||(d=await i(H)!==null),d}async function c(C,T={}){const L=T.warn!==!1,E=T.product||_,D=T.publicKey||H,I=T.now??Date.now(),P=T.host??s(),k=f(P)?"":` ${$}`,N=a(C);if(!N.ok){const ee=N.reason==="missing"?"missing":"malformed";return L&&x(`licence.${ee}`,ee==="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.${k}`:`licence key could not be read. The grid will render with a watermark.${k}`),{valid:!1,reason:ee,terms:"commercial"}}const G={product:N.product||void 0,issuedTo:N.issuedTo||void 0,expires:N.expires||void 0,terms:t(N.terms)};if(N.product!==E)return L&&x("licence.product",`licence key is for '${N.product}', not '${E}'. The grid will render with a watermark.`),{valid:!1,...G,reason:"product"};if(r(N.expires,I))return L&&x("licence.expired",`licence expired on ${N.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...G,reason:"expired"};const q=N.deployments||[];if(q.length&&P&&!f(P)&&!p(P,q))return L&&x("licence.domain",`licence key is not valid for ${P}; it covers ${q.join(", ")}. The grid will render with a watermark.`),{valid:!1,...G,reason:"domain"};const Y=await i(D);if(!Y){const ee=!!N.signature&&N.signature.length===V;return L&&x("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ee?{valid:!0,...G,reason:"unverified"}:{valid:!1,...G,reason:"signature"}}let J=!1;try{J=await l().verify({name:"Ed25519"},Y,N.signature,N.message)}catch{J=!1}return J?{valid:!0,...G}:(L&&x("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...G,reason:"signature"})}function f(C){const T=String(C??s()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!T||T==="localhost"||T.endsWith(".localhost")||T==="::1"||T==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(T)}function s(){const C=globalThis.location;return C&&typeof C.hostname=="string"?C.hostname:null}function p(C,T){const L=b(C);return!L||!Array.isArray(T)?!1:T.some(E=>{const D=b(E);if(!D)return!1;if(D==="*")return!0;if(D.startsWith("*.")){const I=D.slice(2);return L===I||L.endsWith(`.${I}`)}return L===D})}function b(C){return String(C??"").trim().toLowerCase().replace(/\.$/,"")}class S{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#o;#i=new Set;constructor(T={}){this.#o=T}set(T){this.#e=typeof T=="string"?T.trim():"";const L=a(this.#e);return this.#t=L.ok?{valid:!r(L.expires,Date.now())&&L.product===(this.#o.product||_),product:L.product||void 0,issuedTo:L.issuedTo||void 0,expires:L.expires||void 0,terms:t(L.terms),reason:"pending"}:{valid:!1,reason:L.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const T=this.#e;return this.#n=c(T,this.#o).then(L=>{if(this.#e===T){this.#t=L;for(const E of this.#i)E(L)}return L}),this.#n}onSettled(T){return this.#i.add(T),()=>this.#i.delete(T)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!f(this.#r)}setHost(T){this.#r=T}state(){return this.#t.valid?"licensed":f(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const j=new S;function y(C){return j.set(C)}function v(){return j.info()}function R(){return j.watermark()}function O(){return j.state()}function F(){return j}}),Fe("packages/core/src/registry/registry.js",function(e,K){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.isFunction,$=Q.DEV,_=K("packages/core/src/registry/licence.js"),X=_.LicenceHolder,W=_.sharedLicence,V=["renderer","editor","filter","dataType","totalFn","pipe","component"],H=["all","header","body","totals","panels"];class B{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(o={}){for(const d of V)this.#t.set(d,new Map);this.#o=o.holder||W(),this.#s=o.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),o.licence&&this.setLicence(o.licence)}registerModules(o,d={}){d.licence&&this.setLicence(d.licence),d.grid!==void 0&&(this.#s=d.grid);const l=Array.isArray(o)?o:[o],i=[];for(const m of l){if(!m||typeof m!="object"||typeof m.name!="string"||!m.name){x("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(m.name)){$&&this.#c(this.#e.get(m.name),m);continue}if(!z(m.install)){x(`registry.module.install:${m.name}`,`module '${m.name}' has no install() and was ignored.`);continue}const c={registry:this,grid:this.#s};try{m.install(c)}catch(f){x(`registry.module.throw:${m.name}`,`module '${m.name}' threw during install; it was not registered.`,f);continue}this.#e.set(m.name,m);for(const f of w(m))this.#n.add(f);i.push(m.name),this.#d({reason:"module",name:m.name,capabilities:this.capabilities(),regions:u(m)})}return i}unregisterModule(o){const d=this.#e.get(o);if(!d)return!1;if(z(d.uninstall))try{d.uninstall({registry:this,grid:this.#s})}catch(l){x(`registry.module.uninstall:${o}`,`module '${o}' threw during uninstall.`,l)}return this.#e.delete(o),this.#u(),this.#d({reason:"unmodule",name:o,capabilities:this.capabilities(),regions:u(d)}),!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 d of w(o))this.#n.add(d)}#c(o,d){!o||o===d||A(o,d)||x(`registry.module.reconfigure:${d.name}`,`module '${d.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 z(o)?(this.#r.add(o),this.#a.set(o,this.#s),()=>{this.#r.delete(o),this.#a.delete(o)}):()=>{}}#d(o){for(const d of[...this.#r])try{d(o)}catch(l){x("registry.onChange.throw","a registry change handler threw.",l)}}register(o,d,l){const i=this.#t.get(o);if(!i){x(`registry.kind:${o}`,`unknown registry kind '${o}'; expected one of ${V.join(", ")}.`);return}if(!d||typeof d!="string"){x(`registry.name:${o}`,`register('${o}', ...) needs a name.`);return}i.has(d)&&i.get(d)!==l&&x(`registry.replace:${o}:${d}`,`'${d}' was already registered as a ${o} and has been replaced.`),i.set(d,l),this.#d({reason:"register",name:d,kind:o,capabilities:this.capabilities(),regions:h(o)})}registerAll(o,d){if(d)for(const l of Object.keys(d))this.register(o,l,d[l])}get(o,d){const l=this.#t.get(o);return l?l.get(d):void 0}names(o){const d=this.#t.get(o);return d?[...d.keys()]:[]}#h(o,d){const l=this.#t.get(o).get(d);return l!==void 0?l:this.#t.get("component").get(d)}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.#l.add(o),this.#s=o)}detach(o){if(o!=null){this.#l.delete(o);for(const[d,l]of[...this.#a])l===o&&(this.#r.delete(d),this.#a.delete(d));if(this.#s===o){const d=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=d}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(o){if(o!=null){this.detach(o);return}for(const d of[...this.#e.keys()])this.unregisterModule(d);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function w(n){const o=n.capabilities,d=Array.isArray(o)?o.filter(l=>typeof l=="string"):[];return[n.name,...d]}function A(n,o){return n.install!==o.install||n.uninstall!==o.uninstall||(n.version||"")!==(o.version||"")?!1:g(w(n),w(o))&&g(u(n),u(o))}function g(n,o){const d=new Set(n),l=new Set(o);if(d.size!==l.size)return!1;for(const i of d)if(!l.has(i))return!1;return!0}function u(n){const o=n.regions;return!Array.isArray(o)||o.length===0?["all"]:o.filter(d=>H.includes(d))}function h(n){switch(n){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const a=new B;function r(){return a}function t(n,o={}){return a.registerModules(n,o)}}),Fe("packages/core/src/format/number.js",function(e,K){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return z}});const x=K("packages/core/src/internal/util.js").isNil;function z($,_){const X=$||{},W=X.locale||_||void 0,V=X.style||"decimal",H=typeof X.scale=="number"?X.scale:1,B=X.nullDisplay??"",w=X.zeroDisplay,A=X.prefix||"",g=X.suffix||"",u=X.negative||"minus",h=X.signed===!0,a={style:V,notation:X.notation||"standard"};V==="currency"&&(a.currency=X.currency||"USD",X.currencyDisplay&&(a.currencyDisplay=X.currencyDisplay)),typeof X.decimals=="number"?(a.minimumFractionDigits=X.decimals,a.maximumFractionDigits=X.decimals):(typeof X.minDecimals=="number"&&(a.minimumFractionDigits=X.minDecimals),typeof X.maxDecimals=="number"&&(a.maximumFractionDigits=X.maxDecimals),a.minimumFractionDigits>(a.maximumFractionDigits??20)&&(a.maximumFractionDigits=a.minimumFractionDigits)),X.thousandsSeparator===!1&&(a.useGrouping=!1),a.notation==="compact"&&(a.compactDisplay=X.compactDisplay||"short");const r=new Intl.NumberFormat(W,a),t=typeof X.thousandsSeparator=="string"?X.thousandsSeparator:null,n=typeof X.decimalSeparator=="string"?X.decimalSeparator:null;let o=",",d=".";if(t||n)for(const s of r.formatToParts(12345.6))s.type==="group"?o=s.value:s.type==="decimal"&&(d=s.value);const l=s=>{let p=s;return t&&(p=p.split(o).join("")),n&&(p=p.split(d).join("")),t&&(p=p.split("").join(t)),n&&(p=p.split("").join(n)),p},i=!!(t||n),m=A!==""&&V==="currency",c=s=>{let p;if(m){const b=r.formatToParts(s);let S=!1;p="";for(const j of b)p+=j.value,!S&&j.type==="currency"&&(p+=A,S=!0);S||(p=A+p)}else p=A+r.format(s);return i&&(p=l(p)),p+g},f=s=>{if(x(s)||s==="")return B;const p=typeof s=="number"?s:Number(s);if(Number.isNaN(p))return B;const b=H===1?p:p*H;return b===0&&w!==void 0?w:b<0?u==="parentheses"?`(${c(-b)})`:u==="suffix"?`${c(-b)}-`:c(b):h&&b>0?`+${c(b)}`:c(b)};return f.negativeClass=X.negativeClass||null,f.spec=X,f}}),Fe("packages/core/src/format/date.js",function(e,K){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return r}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.warnOnce,$=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(t){const n=[];let o=0,d="";const l=()=>{d&&(n.push({token:null,text:d}),d="")};for(;o<t.length;){const i=t[o];if(i==="'"){if(t[o+1]==="'"){d+="'",o+=2;continue}const c=t.indexOf("'",o+1);if(c===-1){d+=t.slice(o+1),o=t.length;continue}d+=t.slice(o+1,c),o=c+1;continue}const m=$.find(c=>t.startsWith(c,o));if(m){l(),n.push({token:m,text:m}),o+=m.length;continue}/[A-Za-z]/.test(i)&&z(`date.pattern.token:${i}`,`the date pattern "${t}" contains '${i}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${$.join(" ")}.`),d+=i,o+=1}return l(),n}const X=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function W(t){if(x(t)||t==="")return null;if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t=="number")return Number.isNaN(t)?null:new Date(t);if(typeof t=="string"){const n=X.exec(t.trim());if(n){const[,d,l,i,m="0",c="0",f="0"]=n;return new Date(+d,+l-1,+i,+m,+c,+f)}const o=new Date(t);return Number.isNaN(o.getTime())?null:o}return null}function V(t,n){return String(t).padStart(n,"0")}function H(t){if(!t)return d=>({year:d.getFullYear(),month:d.getMonth()+1,day:d.getDate(),hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),ms:d.getMilliseconds(),weekday:d.getDay()});const n=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),o={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return d=>{const l={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:d.getMilliseconds(),weekday:0};for(const i of n.formatToParts(d))switch(i.type){case"year":l.year=Number(i.value);break;case"month":l.month=Number(i.value);break;case"day":l.day=Number(i.value);break;case"hour":l.hour=Number(i.value)%24;break;case"minute":l.minute=Number(i.value);break;case"second":l.second=Number(i.value);break;case"weekday":l.weekday=o[i.value]??0;break;default:break}return l}}function B(t,n,o){const d=_(t),l=H(o),i=new Set(d.filter(p=>p.token).map(p=>p.token)),m=i.has("MMM")?new Intl.DateTimeFormat(n,{month:"short",timeZone:o}):null,c=i.has("MMMM")?new Intl.DateTimeFormat(n,{month:"long",timeZone:o}):null,f=i.has("EEE")?new Intl.DateTimeFormat(n,{weekday:"short",timeZone:o}):null,s=i.has("EEEE")?new Intl.DateTimeFormat(n,{weekday:"long",timeZone:o}):null;return p=>{const b=l(p);let S="";for(const j of d){if(!j.token){S+=j.text;continue}switch(j.token){case"yyyy":S+=V(b.year,4);break;case"yy":S+=V(b.year%100,2);break;case"MMMM":S+=c.format(p);break;case"MMM":S+=m.format(p);break;case"MM":S+=V(b.month,2);break;case"M":S+=String(b.month);break;case"dd":S+=V(b.day,2);break;case"d":S+=String(b.day);break;case"EEEE":S+=s.format(p);break;case"EEE":S+=f.format(p);break;case"HH":S+=V(b.hour,2);break;case"H":S+=String(b.hour);break;case"hh":S+=V(b.hour%12===0?12:b.hour%12,2);break;case"h":S+=String(b.hour%12===0?12:b.hour%12);break;case"mm":S+=V(b.minute,2);break;case"m":S+=String(b.minute);break;case"ss":S+=V(b.second,2);break;case"s":S+=String(b.second);break;case"SSS":S+=V(b.ms,3);break;case"a":S+=b.hour<12?"AM":"PM";break;default:S+=j.text;break}}return S}}const w=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function A(t,n){const o=t||{},d=o.locale||n||void 0,l=o.nullDisplay??"",i=o.timeZone;let m;if(o.pattern)m=B(o.pattern,d,i);else if(o.dateStyle||o.timeStyle){const b={timeZone:i};o.dateStyle&&(b.dateStyle=o.dateStyle),o.timeStyle&&(b.timeStyle=o.timeStyle);const S=new Intl.DateTimeFormat(d,b);m=j=>S.format(j)}else{const b=new Intl.DateTimeFormat(d,{dateStyle:"medium",timeZone:i});m=S=>b.format(S)}const c=o.relative?new Intl.RelativeTimeFormat(d,{numeric:"auto"}):null,s=(typeof o.relative=="object"&&o.relative?o.relative.threshold??7:7)*24*36e5,p=(b,S)=>{const j=W(b);if(!j)return l;if(c){const y=S&&typeof S.now=="number"?S.now:Date.now(),v=j.getTime()-y;if(Math.abs(v)<s){for(const[R,O]of w)if(Math.abs(v)>=O||R==="second")return c.format(Math.round(v/O),R)}}return m(j)};return p.spec=o,p}function g(t){if(x(t)||t==="")return null;if(typeof t=="string"){const d=/^(\d{4}-\d{2}-\d{2})/.exec(t.trim());if(d)return d[1];const l=W(t);return l?g(l):null}const n=W(t);if(!n)return null;const o=d=>String(d).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())}`}function u(t,n){if(x(t)||t==="")return null;if(typeof t=="string"){const d=t.trim();if(h.test(d)){const m=W(d);return m?a(m,n):null}const l=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(d);if(l){const[,m,c,f,s]=l;return`${m}T${c}:${f}${s&&s!=="00"?`:${s}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(d))return`${d}T00:00`;const i=W(d);return i?u(i):null}const o=W(t);return o?a(o,n):null}const h=/(?:Z|[+-]\d{2}:?\d{2})$/i;function a(t,n){const o=m=>String(m).padStart(2,"0");if(n)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(t).reduce((s,p)=>(p.type!=="literal"&&(s[p.type]=p.value),s),{}),c=m.hour==="24"?"00":m.hour,f=Number(m.second);return`${m.year}-${m.month}-${m.day}T${c}:${m.minute}`+(f?`:${m.second}`:"")}catch{}const d=`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`,l=t.getSeconds(),i=`${o(t.getHours())}:${o(t.getMinutes())}${l?`:${o(l)}`:""}`;return`${d}T${i}`}function r(t,n){const o=x(t)||t===""?null:String(t),d=x(n)||n===""?null:String(n);return o===null?d===null?0:1:d===null||o<d?-1:o>d?1:0}}),Fe("packages/core/src/format/boolean.js",function(e,K){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isNil,z={true:"☑",false:"☐",null:""},$={true:"◉",false:"◯",null:""};function _(W){if(x(W)||W==="")return null;if(typeof W=="boolean")return W;if(typeof W=="number")return W!==0;const V=String(W).trim().toLowerCase();return V==="true"||V==="yes"||V==="y"||V==="1"?!0:V==="false"||V==="no"||V==="n"||V==="0"?!1:null}function X(W,V){const H=W||{},B=H.display||"text",w=H.trueLabel??"Yes",A=H.falseLabel??"No",g=H.nullLabel??"";let u=w,h=A;const a=g;B==="checkbox"?(u=z.true,h=z.false):B==="switch"?(u=$.true,h=$.false):B==="icon"&&(u=H.trueIcon??w,h=H.falseIcon??A);const r=t=>{const n=_(t);return n===null?a:n?u:h};return r.display=B,r.labels={true:w,false:A,null:g},r.locale=V,r.spec=H,r}}),Fe("packages/core/src/format/text.js",function(e,K){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return $}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.titleCase;function $(_,X){const W=_||{},V=W.locale||X||void 0,H=W.nullDisplay??"",B=W.emptyDisplay??"",w=W.transform||"none",A=typeof W.truncate=="number"?{chars:W.truncate}:W.truncate||null,g=A?A.chars:0,u=A?A.ellipsis??"…":"",h=r=>{switch(w){case"upper":return V?r.toLocaleUpperCase(V):r.toUpperCase();case"lower":return V?r.toLocaleLowerCase(V):r.toLowerCase();case"title":return z(r);default:return r}},a=r=>{if(x(r))return H;let t=typeof r=="string"?r:String(r);return t===""?B:(w!=="none"&&(t=h(t)),g>0&&t.length>g&&(t=t.slice(0,g)+u),t)};return a.spec=W,a}}),Fe("packages/core/src/format/mask.js",function(e,K){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return X}});const Q=new Set(["0","#","?",",","."]),x="\0";function z(V){const H=[];let B="",w=!1;for(let A=0;A<V.length;A++){const g=V[A];if(g==="\\"){B+=g+(V[A+1]??""),A+=1;continue}if(g==='"'){w=!w,B+=g;continue}if(g===";"&&!w){H.push(B),B="";continue}B+=g}return H.push(B),H}function $(V){let H="",B="",w="",A=1,g=!1,u=!1;const h=m=>{u?B+=m:H+=m};for(let m=0;m<V.length;m++){const c=V[m];if(c==="\\"){h(V[m+1]??""),m+=1;continue}if(c==='"'){const f=V.indexOf('"',m+1);h(f===-1?V.slice(m+1):V.slice(m+1,f)),m=f===-1?V.length:f;continue}if(c==="%"){A*=100,h("%");continue}if(c==="@"){g=!0,h("\0");continue}if(Q.has(c)){w+=c,u=!0;continue}h(c)}let a=-1;for(let m=w.length-1;m>=0;m--){const c=w[m];if(c==="0"||c==="#"||c==="?"){a=m;break}}let r=!1,t="";for(let m=0;m<w.length;m++){const c=w[m];if(c===","){m>a?A/=1e3:r=!0;continue}t+=c}const n=t.indexOf("."),o=n===-1?t:t.slice(0,n),d=n===-1?"":t.slice(n+1);let l=0;for(const m of o)m==="0"&&(l+=1);let i=0;for(const m of d)m==="0"&&(i+=1);return{prefix:H,suffix:B,minInt:l,minDec:i,maxDec:d.length,grouping:r,scale:A,hasNumber:a!==-1,isText:g}}function _(V,H){const B=new Intl.NumberFormat(H,{minimumIntegerDigits:Math.max(V.minInt,1),minimumFractionDigits:V.minDec,maximumFractionDigits:Math.max(V.maxDec,V.minDec),useGrouping:V.grouping}),{prefix:w,suffix:A,scale:g,hasNumber:u}=V;return h=>{if(!u)return w+A;const a=g===1?h:h*g;return w+B.format(a)+A}}function X(V,H){const w=z(String(V)).map($),A=w.map(t=>_(t,H)),g=0,u=w.length>1?1:-1,h=w.length>2?2:-1,a=w.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const n=Number(t);if(Number.isNaN(n))return a===-1?String(t):(w[a].prefix+w[a].suffix).split("\0").join(String(t));t=n}return t===0&&h!==-1?A[h](0):t<0&&u!==-1?A[u](-t):A[g](t)};return r.spec={mask:V},{format:r,ooxml:W(String(V))}}function W(V){return V.trim()}}),Fe("packages/core/src/format/shorthand.js",function(e,K){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return W}});const Q=["currency","number","percent","date","boolean","text","relative"],x=/[#0?@;"\\]/,z=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function $(V){return typeof V!="string"||V===""||X(V)?!1:x.test(V)}function _(V){return typeof V!="string"||V===""||X(V)?!1:z.test(V)}function X(V){const H=V.indexOf(":"),B=H===-1?V:V.slice(0,H);return Q.includes(B)?B:null}function W(V){const H=X(V);if(!H)return null;const B=V.indexOf(":"),w=B===-1?"":V.slice(B+1),A=w===""?[]:w.split(":");switch(H){case"currency":{const g={type:"number",style:"currency",currency:A[0]||"USD"};return A[1]!==void 0&&A[1]!==""&&(g.decimals=Number(A[1])),g}case"number":{const g={type:"number",style:"decimal"};return A[0]!==void 0&&A[0]!==""&&(g.decimals=Number(A[0])),g}case"percent":{const g={type:"number",style:"percent"};return A[0]!==void 0&&A[0]!==""&&(g.decimals=Number(A[0])),g}case"date":return{type:"date",pattern:w||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const g=w.split("/"),u={type:"boolean",display:"text"};return g[0]!==void 0&&g[0]!==""&&(u.trueLabel=g[0]),g[1]!==void 0&&g[1]!==""&&(u.falseLabel=g[1]),g[2]!==void 0&&(u.nullLabel=g[2]),u}case"text":{const g={type:"text"};return A[0]&&(g.transform=A[0]),A[1]!==void 0&&A[1]!==""&&(g.truncate=Number(A[1])),g}default:return null}}}),Fe("packages/core/src/format/index.js",function(e,K){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return S}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.isObject,$=Q.warnOnce,_=K("packages/core/src/format/number.js"),X=_.compileNumber,W=K("packages/core/src/format/date.js"),V=W.compileDate,H=W.scanPattern,B=K("packages/core/src/format/boolean.js"),w=B.compileBoolean,A=K("packages/core/src/format/text.js"),g=A.compileText,u=K("packages/core/src/format/mask.js"),h=u.compileMask,a=K("packages/core/src/format/shorthand.js"),r=a.parseShorthand,t=a.looksLikeMask,n=a.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return _.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return W.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return W.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return W.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return B.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return B.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return A.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return u.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return u.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return u.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return a.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return a.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return a.looksLikeDatePattern}});const o=new Set(["decimal","currency","percent","unit"]),d=new Set(["type","locale"]),l={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},i=new Set(["number","date","boolean","text"]);function m(R,O){const F=R.type;if(F===void 0||i.has(F)||!o.has(String(F)))return;const C=O?`"${O}"`:"with no id";$(`format:unknown-style-key:${O||""}:${F}`,`column ${C} has format: { type: "${F}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${F}" instead?`)}function c(R,O,F){const C=l[O],T=F?`"${F}"`:"with no id";for(const L of R){if(d.has(L)||C.has(L))continue;const E=Object.keys(l).find(D=>D!==O&&l[D].has(L));E?$(`format:inapplicable:${F||""}:${L}`,`column ${T} has format key "${L}", which applies to a ${E} column, not the ${O} column it was applied to; it is ignored.`):$(`format:unknown:${F||""}:${L}`,`column ${T} has an unrecognised format key "${L}" for its ${O} format; it is ignored.`)}}function f(R){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return!0;const O=o.has(String(R.style));return!!(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone||R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon||R.transform||R.truncate||R.emptyDisplay||O||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)}function s(R,O){if(R.type==="number"||R.type==="date"||R.type==="boolean"||R.type==="text")return R.type;if(R.pattern||R.dateStyle||R.timeStyle||R.relative||R.timeZone)return"date";if(R.trueLabel||R.falseLabel||R.display||R.trueIcon||R.falseIcon)return"boolean";if(R.transform||R.truncate||R.emptyDisplay)return"text";if(R.style||R.currency||R.decimals!==void 0||R.minDecimals!==void 0||R.maxDecimals!==void 0||R.notation||R.negative||R.scale!==void 0||R.prefix||R.suffix||R.zeroDisplay!==void 0)return"number";const F=O&&O.base;return F==="number"?"number":F==="date"||F==="dateString"?"date":F==="boolean"?"boolean":"text"}function p(R,O=null,F=void 0,C=void 0,T=void 0){if(R==null||R==="")return null;const L=z(R)?Object.keys(R):null;if(typeof R=="function"){const I=(P,k)=>String(R({...k||{},value:P,locale:F})??"");return I.ooxml=O&&O.excel||"General",I}if(typeof R=="string"){if(t(R)){const{format:P,ooxml:k}=h(R,F);return P.ooxml=k,P}const I=r(R)||(n(R)?{type:"date",pattern:R}:null);return I?p(I,O,F,C,T):($(`format:${R}`,`unrecognised format string "${R}"; the value will be stringified`),null)}if(!z(R))return $("format:shape","format must be a spec object or a string; ignoring",R),null;if(O&&x(O.format)&&!f(R)||O&&x(O.format)&&Array.isArray(O.formatPatterns)&&R.type===void 0)return null;const E=s(R,O);E==="date"&&C&&R.timeZone===void 0&&(R={...R,timeZone:C}),m(R,T),c(L||Object.keys(R),E,T);let D;switch(E){case"number":D=X(R,F);break;case"date":D=V(R,F);break;case"boolean":D=w(R,F);break;default:D=g(R,F);break}return D.ooxml=S(R,E,F,O),D.kind=E,D}const b={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 S(R,O,F=void 0,C=null){if(O==="date"){if(R.pattern){let I="";for(const P of H(R.pattern))I+=P.token?b[P.token]??P.text:P.text;return I}return C&&C.excel||"yyyy-mm-dd"}if(O==="boolean")return"General";if(O==="text")return"@";if(R.notation==="compact"||R.notation==="scientific")return"General";const T=typeof R.decimals=="number"?R.decimals:typeof R.minDecimals=="number"?R.minDecimals:R.style==="currency"?2:0;let E=`${R.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,D="";return R.style==="currency"&&(D+=j(v(R.currency||"USD",F))),R.prefix&&(D+=j(R.prefix)),E=D+E,R.style==="percent"&&(E=`${E}%`),R.suffix&&(E+=j(R.suffix)),R.negative==="parentheses"?`${E};(${E})`:R.negative==="suffix"?`${E};${E}-`:E}function j(R){return`"${String(R).split('"').join("")}"`}const y=new Map;function v(R,O){const F=`${R}|${O||""}`;let C=y.get(F);if(C!==void 0)return C;C=R;try{const L=new Intl.NumberFormat(O,{style:"currency",currency:R}).formatToParts(0).find(E=>E.type==="currency");L&&(C=L.value)}catch{}return y.set(F,C),C}}),Fe("packages/core/src/columns/types/temporal.js",function(e,K){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ye}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.isFunction,$=K("packages/core/src/format/date.js"),_=$.toDate,X=$.compilePattern,W=$.compileDate,V=$.toIsoDateTime,H=$.compareIso,B=864e5,w=Object.freeze({}),A=1e3,g=60*A,u=60*g,h=24*u,a=7*h,r=new WeakMap;function t(Oe,Ve){const Ze=Oe&&Oe.locale||"",it=Oe&&Oe.column;if(!it)return Ze?{locale:Ze}:w;const at=r.get(it);if(at&&at.locale===Ze)return at.bag;const pt=it.typeOptions||it[Ve]||(n(it.format)?it.format:null),bt={...pt||w,locale:pt&&pt.locale||Ze||void 0};return r.set(it,{locale:Ze,bag:bt}),bt}function n(Oe){return Oe!==null&&typeof Oe=="object"&&!Array.isArray(Oe)&&!(Oe instanceof Date)}function o(Oe,Ve){const Ze=Oe===null||Number.isNaN(Oe)?null:Oe,it=Ve===null||Number.isNaN(Ve)?null:Ve;return Ze===null?it===null?0:1:it===null||Ze<it?-1:Ze>it?1:0}const d=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,l=/^(\d{3,6})$/;function i(Oe,Ve,Ze,it){return!(Oe>=0&&Oe<=23)||!(Ve>=0&&Ve<=59)||!(Ze>=0&&Ze<=59)||!(it>=0&&it<=999)?null:Oe*u+Ve*g+Ze*A+it}function m(Oe){if(x(Oe))return null;const Ve=String(Oe).trim();if(Ve==="")return null;const Ze=l.exec(Ve);if(Ze){const Mt=Ze[1];if(Mt.length===5)return null;const Tt=Mt.length===3?1:2;return i(Number(Mt.slice(0,Tt)),Number(Mt.slice(Tt,Tt+2)),Number(Mt.slice(Tt+2,Tt+4)||0),0)}const it=d.exec(Ve);if(!it)return null;let at=Number(it[1]);const pt=Number(it[2]||0),bt=Number(it[3]||0),Ot=it[4]?Number(it[4].padEnd(3,"0")):0,Et=it[5]?it[5][0].toLowerCase():null;if(Et){if(at<1||at>12)return null;at=at%12,Et==="p"&&(at+=12)}return i(at,pt,bt,Ot)}function c(Oe){return x(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?(Oe%h+h)%h:null:Oe instanceof Date?Number.isNaN(Oe.getTime())?null:Oe.getHours()*u+Oe.getMinutes()*g+Oe.getSeconds()*A+Oe.getMilliseconds():m(Oe)}const f=new Map;function s(Oe){const Ve=Oe.pattern||"",Ze=Oe.timeStyle||(Oe.seconds?"medium":"short"),it=`${Oe.locale||""}|${Ve}|${Ze}`;let at=f.get(it);if(at)return at;if(Ve)at=X(Ve,Oe.locale||void 0,"UTC");else{const pt=new Intl.DateTimeFormat(Oe.locale||void 0,{timeStyle:Ze,timeZone:"UTC"});at=bt=>pt.format(bt)}return f.set(it,at),at}function p(Oe,Ve){const Ze=Ve||w;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return Ze.nullDisplay??"";const it=(Oe%h+h)%h;return s(Ze)(new Date(it))}function b(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe=="number"?Number.isFinite(Oe)&&Oe>=0&&Oe<h:typeof Oe!="string"||!Oe.includes(":")?!1:m(Oe)!==null}function S(Oe){const Ve=c(Oe);return Ve==null?"":p(Ve,{pattern:Ve%A===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const j=new Map;function y(Oe){const Ve=Oe||"";let Ze=j.get(Ve);return Ze||(Ze=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),j.set(Ve,Ze)),Ze}function v(Oe,Ve){const Ze={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const it of y(Ve).formatToParts(new Date(Oe)))it.type==="year"?Ze.year=Number(it.value):it.type==="month"?Ze.month=Number(it.value):it.type==="day"?Ze.day=Number(it.value):it.type==="hour"?Ze.hour=Number(it.value)%24:it.type==="minute"?Ze.minute=Number(it.value):it.type==="second"&&(Ze.second=Number(it.value));return Ze}function R(Oe,Ve){const Ze=v(Oe,Ve);return Date.UTC(Ze.year,Ze.month-1,Ze.day,Ze.hour,Ze.minute,Ze.second,0)-Math.floor(Oe/1e3)*1e3}function O(Oe,Ve){const Ze=Oe.hour||0,it=Oe.minute||0,at=Oe.second||0,pt=Oe.ms||0;if(!Ve)return new Date(Oe.year,Oe.month-1,Oe.day,Ze,it,at,pt).getTime();const bt=Date.UTC(Oe.year,Oe.month-1,Oe.day,Ze,it,at,pt);let Ot=bt-R(bt,Ve);return Ot=bt-R(Ot,Ve),Ot}const F=/(?:Z|[+-]\d{2}:?\d{2})$/i,C=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function T(Oe,Ve){if(x(Oe))return null;const Ze=String(Oe).trim();if(Ze==="")return null;const it=Ve&&Ve.timeZone||void 0;if(!F.test(Ze)){const at=C.exec(Ze);if(at){const pt=(at[4]||"").trim(),bt=pt===""?0:m(pt);if(bt===null)return null;const Ot=O({year:Number(at[1]),month:Number(at[2]),day:Number(at[3]),hour:Math.floor(bt/u),minute:Math.floor(bt/g)%60,second:Math.floor(bt/A)%60,ms:bt%A},it);return Number.isNaN(Ot)?null:new Date(Ot)}}return _(Ze)}function L(Oe){if(typeof Oe=="number")return Number.isFinite(Oe)?Oe:null;const Ve=_(Oe);return Ve?Ve.getTime():null}const E=new Map;function D(Oe){const Ve=[Oe.locale||"",Oe.pattern||"",Oe.dateStyle||"",Oe.timeStyle||"",Oe.timeZone||"",Oe.seconds?"1":""].join("|");let Ze=E.get(Ve);if(Ze)return Ze;const it=Oe.pattern?{type:"date",pattern:Oe.pattern,timeZone:Oe.timeZone}:{type:"date",dateStyle:Oe.dateStyle||"medium",timeStyle:Oe.timeStyle||(Oe.seconds?"medium":"short"),timeZone:Oe.timeZone};return Ze=W(it,Oe.locale||void 0),E.set(Ve,Ze),Ze}function I(Oe,Ve){const Ze=Ve||w,it=L(Oe);return it==null?Ze.nullDisplay??"":D(Ze)(it)}function P(Oe){return Oe instanceof Date?!Number.isNaN(Oe.getTime()):typeof Oe!="string"||!C.test(Oe.trim())?!1:T(Oe)!==null}const k=Object.freeze([{key:"w",ms:a,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:h,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:u,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:g,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:A,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"]}]),N=new Map;for(const Oe of k)for(const Ve of Oe.names)N.set(Ve,Oe);const G=Object.freeze(k.filter(Oe=>Oe.key!=="w")),q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Y=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function ee(Oe){const Ve=Oe&&Oe.defaultUnit?N.get(String(Oe.defaultUnit).toLowerCase()):null;return Ve?Ve.ms:g}function re(Oe){return(Oe&&Oe.defaultUnit?N.get(String(Oe.defaultUnit).toLowerCase()):null)||N.get("m")}function ie(Oe,Ve){if(x(Oe))return null;let Ze=String(Oe).trim().toLowerCase();if(Ze==="")return null;let it=1;if(Ze[0]==="-"?(it=-1,Ze=Ze.slice(1).trim()):Ze[0]==="+"&&(Ze=Ze.slice(1).trim()),Ze==="")return null;const at=J.exec(Ze);if(at){const Et=at[3]!==void 0,Mt=Number(at[1])*u+Number(at[2])*g+(Et?Number(at[3])*A:0)+(at[4]?Number(at[4].padEnd(3,"0")):0);return it*Mt}if(Y.test(Ze))return Math.round(it*Number(Ze)*ee(Ve||w));let pt=Ze,bt=0,Ot=0;for(;pt!=="";){const Et=q.exec(pt);if(!Et)return null;const Mt=N.get(Et[2]);if(!Mt)return null;bt+=Number(Et[1])*Mt.ms,pt=pt.slice(Et[0].length),Ot++}return Ot===0?null:Math.round(it*bt)}function ae(Oe){return x(Oe)||Oe===""?null:typeof Oe=="number"?Number.isFinite(Oe)?Oe:null:ie(Oe)}const fe=new Map;function ce(Oe,Ve,Ze){const it=`${Ze||""}|${Ve.intl}`;let at=fe.get(it);if(at===void 0){try{at=new Intl.NumberFormat(Ze||void 0,{style:"unit",unit:Ve.intl,unitDisplay:"long"})}catch{at=null}fe.set(it,at)}return at?at.format(Oe):`${Oe} ${Oe===1?Ve.long[0]:Ve.long[1]}`}function te(Oe,Ve){return String(Oe).padStart(Ve,"0")}function oe(Oe,Ve){const Ze=Ve||w;if(Oe==null||typeof Oe!="number"||!Number.isFinite(Oe))return Ze.nullDisplay??"";const it=Ze.style||"short",at=Oe<0;let pt=Math.round(Math.abs(Oe));const bt=at?"-":"";if(pt===0&&Ze.zeroDisplay!=null)return Ze.zeroDisplay;if(it==="clock"){const Tt=Math.floor(pt/u),Bt=Math.floor(pt/g)%60,zt=Math.floor(pt/A)%60;return`${bt}${te(Tt,2)}:${te(Bt,2)}:${te(zt,2)}`}if(pt===0){const Tt=re(Ze);return it==="long"?ce(0,Tt,Ze.locale):`0${Tt.key}`}const Ot=Ze.weeks===!0?k:G,Et=typeof Ze.maxUnits=="number"&&Ze.maxUnits>0?Ze.maxUnits:Ze.maxUnits===void 0?2:1/0,Mt=[];for(const Tt of Ot){if(Mt.length>=Et)break;const Bt=Math.floor(pt/Tt.ms);Bt!==0&&(pt-=Bt*Tt.ms,Mt.push(it==="long"?ce(Bt,Tt,Ze.locale):`${Bt}${Tt.key}`))}return bt+Mt.join(" ")}function he(Oe){if(typeof Oe!="string")return!1;const Ve=Oe.trim();return Ve===""||J.test(Ve)||!/[a-z]/i.test(Ve)?!1:ie(Ve)!==null}const de=Date.UTC(1899,11,30),be=new Map;function Te(Oe,Ve){const Ze=Oe||"";let it=be.get(Ze);it||(it=new Intl.DateTimeFormat("en-GB",{timeZone:Oe||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),be.set(Ze,it));const at=typeof Ve=="number"?Ve:Date.now();for(const pt of it.formatToParts(new Date(at)))if(pt.type==="timeZoneName")return pt.value;return""}function Ae(Oe){if(Oe)return Oe;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Ce(Oe,Ve){const Ze=Ae(Oe),it=Te(Oe,Ve);return it?`${Ze} (${it})`:Ze}function me(Oe,Ve){if(Oe&&Oe.timeZone)return Oe.timeZone;const Ze=Ve&&Ve.grid;return(Ze&&z(Ze.get)?Ze.get("timeZone"):void 0)||void 0}function we(Oe,Ve){const Ze=Ve||w,it=L(Oe);if(it==null)return Ze.nullDisplay??"";const at=D(Ze)(it);if(!Ze.showOrigin)return at;const pt=Ze.originZone;return pt?pt===(Ze.timeZone||Ae(Ze.timeZone))?at:`${at} (${Ce(pt,it)})`:`${at} (no origin recorded)`}function ge(Oe,Ve,Ze,it){if(Ve==="instant"||!Ve)return Oe;const at=v(Oe,Ze);if(Ve==="month")return O({year:at.year,month:at.month,day:1},Ze);if(Ve==="week"){const pt=it>=1&&it<=7?it:1,Ot=((new Date(Date.UTC(at.year,at.month-1,at.day)).getUTCDay()+6)%7+1-pt+7)%7,Et=new Date(Date.UTC(at.year,at.month-1,at.day-Ot));return O({year:Et.getUTCFullYear(),month:Et.getUTCMonth()+1,day:Et.getUTCDate()},Ze)}return O({year:at.year,month:at.month,day:at.day},Ze)}function Ne(Oe,Ve){const Ze=Oe&&Oe.group,it=Ze&&Ze.granularity||"day";if(it==="instant")return null;const at=Ze&&Ze.weekStart;return pt=>typeof pt=="number"?ge(pt,it,Ve,at):pt}const Ie={time:{base:"number",storage:"float64",matches:b,format:Oe=>p(c(Oe.value),t(Oe,"time")),parse:Oe=>m(Oe.text),compare:(Oe,Ve)=>o(c(Oe),c(Ve)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Oe=>{const Ve=c(Oe);return Ve===null?null:Ve/B},toStorage:Oe=>c(Oe),toClipboard:S,fromClipboard:m},datetime:{base:"dateString",storage:"dictionary",matches:P,format:Oe=>I(Oe.value,t(Oe,"datetime")),parse:Oe=>V(T(Oe.text,t(Oe,"datetime"))??Oe.text),compare:H,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Oe,Ve)=>V(Oe,Ve&&Ve.timeZone),toClipboard:Oe=>x(Oe)?"":String(Oe),fromClipboard:Oe=>V(Oe)},duration:{base:"number",storage:"float64",matches:he,format:Oe=>oe(ae(Oe.value),t(Oe,"duration")),parse:Oe=>ie(Oe.text,t(Oe,"duration")),compare:(Oe,Ve)=>o(ae(Oe),ae(Ve)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Oe=>{const Ve=ae(Oe);return Ve===null?null:Ve/B},toStorage:Oe=>ae(Oe),toClipboard:Oe=>oe(ae(Oe),{style:"short",maxUnits:-1}),fromClipboard:Oe=>ie(Oe)},timestamp:{base:"number",storage:"float64",format:Oe=>{const Ve=t(Oe,"timestamp");return we(Oe.value,{...Ve,timeZone:me(Ve,Oe)})},parse:Oe=>{const Ve=t(Oe,"timestamp"),Ze=T(Oe.text,{timeZone:me(Ve,Oe)});return Ze?Ze.getTime():null},compare:(Oe,Ve)=>o(L(Oe),L(Ve)),groupProjector:(Oe,Ve)=>Ne(Oe,Ve),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Oe,Ve)=>{const Ze=L(Oe);if(Ze==null)return null;const it=v(Ze,Ve&&Ve.timeZone||void 0);return(Date.UTC(it.year,it.month-1,it.day,it.hour,it.minute,it.second)-de)/B},toStorage:Oe=>L(Oe),toClipboard:Oe=>{const Ve=L(Oe);return Ve==null?"":new Date(Ve).toISOString()},fromClipboard:Oe=>L(Oe)}},He=["datetime","time","duration"],Ye=Ie}),Fe("packages/core/src/columns/types/network.js",function(e,K){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.Lru,$=4294967295,_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function X(L){if(x(L))return null;if(typeof L=="string")return W(L);const E=Number(L);return Number.isFinite(E)?E<0?E<-2147483648?null:E>>>0:E>$?null:Math.trunc(E)>>>0:null}function W(L){if(x(L))return null;const E=String(L).trim();if(E==="")return null;const D=_.exec(E);if(!D)return null;let I=0;for(let P=1;P<=4;P++){const k=D[P];if(k.length>1&&k.charCodeAt(0)===48)return null;const N=Number(k);if(N>255)return null;I=I*256+N}return I}function V(L){const E=X(L);return E===null?"":`${E>>>24&255}.${E>>>16&255}.${E>>>8&255}.${E&255}`}function H(L){return typeof L=="string"&&W(L)!==null}function B(L,E){const D=X(L),I=X(E);return D===null?I===null?0:1:I===null||D<I?-1:D>I?1:0}const w=64,A=$*w+32,g=/^(?:0|[1-9]\d?)$/;function u(L,E){return L*w+E}function h(L){if(x(L))return null;if(typeof L=="string"){const I=a(L);return I===null?null:h(I)}if(typeof L=="object"){const I=X(L.address),P=Number(L.prefix);return I===null||!Number.isInteger(P)||P<0||P>32?null:{address:I,prefix:P}}const E=Number(L);if(!Number.isInteger(E)||E<0||E>A)return null;const D=E%w;return D>32?null:{address:(E-D)/w,prefix:D}}function a(L){if(x(L))return null;const E=String(L).trim();if(E==="")return null;const D=E.indexOf("/");if(D<0)return null;const I=W(E.slice(0,D));if(I===null)return null;const P=E.slice(D+1).trim();if(!g.test(P))return null;const k=Number(P);return k>32?null:u(I,k)}function r(L){const E=h(L);return E?`${V(E.address)}/${E.prefix}`:""}function t(L){return typeof L=="string"&&a(L)!==null}function n(L,E){const D=h(L),I=h(E);return D?I?D.address!==I.address?D.address<I.address?-1:1:D.prefix-I.prefix:-1:I?1:0}function o(L){return L===0?0:4294967295<<32-L>>>0}function d(L){const E=h(L);return E?(E.address&o(E.prefix))>>>0:null}function l(L){const E=h(L);return E?(E.address&o(E.prefix)|~o(E.prefix)>>>0)>>>0:null}function i(L){const E=h(L);return E?2**(32-E.prefix):null}function m(L){const E=h(L);return E?E.prefix===32?1:E.prefix===31?2:2**(32-E.prefix)-2:null}function c(L,E){const D=h(L);if(!D)return!1;const I=X(E);if(I===null)return!1;const P=o(D.prefix);return(I&P)>>>0===(D.address&P)>>>0}function f(L,E){const D=d(L),I=d(E);return D===null||I===null?!1:D<=l(E)&&I<=l(L)}const s=/^[0-9a-fA-F]{1,4}$/,p=new z(512);function b(L){if(x(L))return null;let E=String(L).trim();if(E==="")return null;const D=E.indexOf("%");if(D>=0&&(E=E.slice(0,D)),E==="")return null;if(E.indexOf(".")>=0){const q=E.lastIndexOf(":");if(q<0)return null;const Y=W(E.slice(q+1));if(Y===null)return null;E=`${E.slice(0,q+1)}${(Y>>>16&65535).toString(16)}:${(Y&65535).toString(16)}`}const I=E.split("::");if(I.length>2)return null;const P=S(I[0]);if(P===null)return null;if(I.length===1)return P.length===8?P:null;const k=S(I[1]);if(k===null)return null;const N=8-P.length-k.length;if(N<1)return null;const G=P.slice();for(let q=0;q<N;q++)G.push(0);for(const q of k)G.push(q);return G}function S(L){if(L==="")return[];const E=[];for(const D of L.split(":")){if(!s.test(D))return null;E.push(parseInt(D,16))}return E}function j(L){if(typeof L!="string")return b(L);if(p.has(L))return p.get(L);const E=b(L);return p.set(L,E),E}function y(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${V((L[6]<<16|L[7])>>>0)}`;let E=-1,D=0,I=-1,P=0;for(let G=0;G<8;G++)L[G]===0?(I<0?(I=G,P=1):P++,P>D&&(D=P,E=I)):(I=-1,P=0);if(D<2)return L.map(G=>G.toString(16)).join(":");const k=L.slice(0,E).map(G=>G.toString(16)).join(":"),N=L.slice(E+D).map(G=>G.toString(16)).join(":");return`${k}::${N}`}function v(L){const E=b(L);return E===null?null:y(E)}function R(L){return v(L)??""}function O(L){return typeof L=="string"&&L.indexOf(":")>=0&&b(L)!==null}function F(L,E){const D=j(L),I=j(E);if(!D)return I?1:0;if(!I)return-1;for(let P=0;P<8;P++)if(D[P]!==I[P])return D[P]<I[P]?-1:1;return 0}const C=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:H,parse:L=>W(L.text),compare:B,format:L=>V(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>X(L),toClipboard:L=>V(L),fromClipboard:L=>W(L)},cidr:{base:"number",storage:"float64",matches:t,parse:L=>a(L.text),compare:n,format:L=>r(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const E=h(L);return E===null?null:u(E.address,E.prefix)},toClipboard:L=>r(L),fromClipboard:L=>a(L)},ipv6:{base:"text",storage:"dictionary",matches:O,parse:L=>v(L.text),compare:F,format:L=>R(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:L=>v(L),toClipboard:L=>R(L),fromClipboard:L=>v(L)}}),T=C}),Fe("packages/core/src/i18n/catalogue.js",function(e,K){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return $}});const x=K("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,z=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","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","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","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","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","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.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","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.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","licence.watermark.free":x,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","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.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","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"}),$=Object.freeze(Object.keys(z))}),Fe("packages/core/src/i18n/format.js",function(e,K){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return A}});const x=K("packages/core/src/internal/util.js").isFunction,z=/\{(\w+)\}/g,$=new Map,_=new Map;function X(g){const u=g||"";if($.has(u))return $.get(u);let h=null;try{h=new Intl.PluralRules(g||void 0)}catch{h=null}return $.set(u,h),h}function W(g,u,h="conjunction"){const a=Array.isArray(g)?g.filter(n=>n!=null&&n!==""):[];if(a.length===0)return"";if(a.length===1)return String(a[0]);const r=`${u||""}|${h}`;let t=_.get(r);if(t===void 0){try{t=new Intl.ListFormat(u||void 0,{style:"long",type:h})}catch{t=null}_.set(r,t)}return t?t.format(a.map(String)):a.map(String).join(", ")}function V(g,u){return g==null?"":typeof g=="number"?Number.isFinite(g)?g.toLocaleString(u||void 0,{maximumFractionDigits:20}):"":String(g)}function H(g,u,h){if(typeof g=="string")return g;if(!g||typeof g!="object")return"";const a=u&&typeof u.count=="number"?u.count:null;if(a===null)return g.other??"";const r=X(h),t=r?r.select(a):a===1?"one":"other";return g[t]??g.other??""}function B(g,u={},h){const a=H(g,u,h);return a?a.replace(z,(r,t)=>Object.prototype.hasOwnProperty.call(u,t)?V(u[t],h):r):""}function w(g,u,h="en-GB"){return typeof g=="string"&&g?g:typeof u=="string"&&u?u:h}function A(g,u){const h=g?g[u]:void 0;return h==null||x(h)?u:h}}),Fe("packages/core/src/i18n/index.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/i18n/catalogue.js"),x=Q.EN_GB,z=Q.MESSAGE_KEYS,$=K("packages/core/src/i18n/format.js"),_=$.formatMessage,X=$.formatList,W=$.lookup,V=$.resolveLocale,H=K("packages/core/src/internal/util.js"),B=H.isFunction,w=H.warnOnce;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return Q.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return Q.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return $.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return $.resolveLocale}});const A="en-GB";class g{#e=A;#t=x;constructor(t={}){this.configure(t)}configure(t={}){this.#e=V(t.locale,t.declared,A);const n=t.messages;if(!n||typeof n!="object"){this.#t=x;return}const o=Object.keys(n).filter(d=>!(d in x));o.length&&w(`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={...x,...n}}get locale(){return this.#e}t(t,n){return _(W(this.#t,t),n||{},this.#e)}list(t,n){return X(t,this.#e,n)}number(t,n){const o=Number(t);return Number.isFinite(o)?o.toLocaleString(this.#e,n||{maximumFractionDigits:20}):""}}const u=new g;function h(r){return r instanceof g?r:new g(r||{})}function a(r){const t=r&&typeof r=="object"?r:{},n=z.filter(d=>{const l=t[d];return l==null||l===""||B(l)}),o=Object.keys(t).filter(d=>!(d in x));return{missing:n,unknown:o}}}),Fe("packages/core/src/columns/types/structured.js",function(e,K){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.isObject,_=K("packages/core/src/i18n/index.js").defaultMessages,X=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function W(r,t){const n=t||{},o=n.emptyDisplay??X.emptyDisplay;if(x(r)||r==="")return o;const l=[...typeof n.char=="string"&&n.char!==""?n.char:X.char][0]||X.char,i=n.fixedLength??X.fixedLength,m=Number.isFinite(n.length)&&Number(n.length)>0?Math.floor(Number(n.length)):X.length,c=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let f=0;if(c!==null){const s=Number.isFinite(n.lastVisible)?Math.floor(Number(n.lastVisible)):X.lastVisible,p=[...c];if(f=s>0&&s<p.length?s:0,f>0){const b=p.slice(p.length-f).join(""),S=Math.max(1,(i?m:p.length)-f);return l.repeat(S)+b}return l.repeat(i?m:Math.max(1,p.length))}return l.repeat(m)}const V=48;function H(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function B(r,t){if(x(r))return"";const n=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):V;if(typeof r=="string")return r.length>n?`${r.slice(0,n-1)}…`:r;if(typeof r!="object")return String(r);const o=H(r);if(o!==null&&o.length<=n)return o;if(Array.isArray(r)){const l=r.length;return`[${_.t("count.items",{count:l})}]`}const d=Object.keys(r).length;return`{${_.t("count.keys",{count:d})}}`}function w(r,t){if(r==null)return"null";const n=typeof r;if(n==="number"||n==="boolean"||n==="bigint")return String(r);if(n==="string")return JSON.stringify(r);if(n!=="object")return JSON.stringify(String(r));const o=t||new WeakSet;return o.has(r)?'"[circular]"':(o.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(i=>w(i,o)).join(",")}]`:`{${Object.keys(r).sort().map(i=>`${JSON.stringify(i)}:${w(r[i],o)}`).join(",")}}`)}function A(r,t){if(x(r))return x(t)?0:1;if(x(t))return-1;const n=w(r),o=w(t);return n<o?-1:n>o?1:0}function g(r){if(x(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function u(r){const t=r&&r.cell&&r.cell.props;return z(t)?t:{}}const h=Object.freeze({json:{base:"object",storage:"object",format:r=>B(r&&r.value,u(r&&r.column)),parse:r=>g(r&&r.text),compare:A,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(x(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>g(r)},secret:{base:"text",storage:"object",format:r=>W(r&&r.value,u(r&&r.column)),parse:r=>{const t=r&&r.text;return x(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const n=x(r)||r==="",o=x(t)||t==="";return n===o?0:n?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>W(r),fromClipboard:r=>x(r)||String(r)===""?null:String(r)}}),a=h}),Fe("packages/core/src/columns/types/unit.js",function(e,K){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.warnOnce;function $(P,k,N,G){return Object.freeze({symbol:P,factor:k,aliases:Object.freeze(N||[]),binary:!!(G&&G.binary),prefix:G&&G.prefix||null,auto:!(G&&G.auto===!1)})}function _(P,k,N,G){return $(P,k,N,G)}const X=Object.freeze({data:Object.freeze([$("B",1,["byte","bytes"]),$("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),$("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),$("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),$("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),$("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),$("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),$("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),$("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),$("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([$("bps",1,["bit","bits","bit/s","b/s"]),$("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),$("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),$("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),$("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([$("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),$("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),$("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),$("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),$("in",.0254,["inch","inches"],{auto:!1}),$("ft",.3048,["foot","feet"],{auto:!1}),$("yd",.9144,["yard","yards"],{auto:!1}),$("m",1,["metre","metres","meter","meters"]),$("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),$("mi",1609.344,["mile","miles"],{auto:!1}),$("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([$("mg",.001,["milligram","milligrams"]),$("g",1,["gram","grams"]),$("oz",28.349523125,["ounce","ounces"],{auto:!1}),$("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),$("kg",1e3,["kilogram","kilograms"]),$("st",6350.29318,["stone"],{auto:!1}),$("t",1e6,["tonne","tonnes","ton"],{auto:!1}),$("ton (US)",907184.74,["ton","shortton"],{auto:!1}),$("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([$("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),$("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),$("ms",.001,["msec","msecs","millisecond","milliseconds"]),$("s",1,["sec","secs","second","seconds"]),$("m",60,["min","mins","minute","minutes"]),$("h",3600,["hr","hrs","hour","hours"]),$("d",86400,["day","days"])]),speed:Object.freeze([$("mm/s",.001,["millimetre/s","millimeter/s"]),$("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),$("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),$("mph",.44704,["mile/h","miles/h"],{auto:!1}),$("kn",1852/3600,["knot","knots"],{auto:!1}),$("m/s",1,["metre/s","meter/s","mps"]),$("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([$("mm/s²",.001,["mm/s2"]),$("ft/s²",.3048,["ft/s2"],{auto:!1}),$("m/s²",1,["m/s2","metre/s2","meter/s2"]),$("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([$("mm²",1e-6,["mm2"]),$("cm²",1e-4,["cm2"]),$("in²",64516e-8,["in2","sqin"],{auto:!1}),$("ft²",.09290304,["ft2","sqft"],{auto:!1}),$("yd²",.83612736,["yd2","sqyd"],{auto:!1}),$("m²",1,["m2","sqm"]),$("ha",1e4,["hectare","hectares"],{auto:!1}),$("ac",4046.8564224,["acre","acres"],{auto:!1}),$("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([$("µL",1e-6,["ul","microlitre","microliter"]),$("mL",.001,["millilitre","milliliter"]),$("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),$("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),$("L",1,["litre","litres","liter","liters"]),$("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),$("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),$("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),$("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([$("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),$("J",1,["joule","joules"]),$("cal",4.184,["calorie","calories"],{auto:!1}),$("kJ",1e3,["kilojoule","kilojoules"]),$("BTU",1055.05585262,["btu"],{auto:!1}),$("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),$("MJ",1e6,["megajoule","megajoules"]),$("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),$("GJ",1e9,["gigajoule","gigajoules"]),$("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([$("mW",.001,["milliwatt","milliwatts"]),$("W",1,["watt","watts"]),$("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),$("kW",1e3,["kilowatt","kilowatts"]),$("hp",745.6998715822702,["horsepower"],{auto:!1}),$("MW",1e6,["megawatt","megawatts"]),$("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([$("mN",.001,["millinewton","millinewtons"]),$("N",1,["newton","newtons"]),$("lbf",4.4482216152605,["poundforce"],{auto:!1}),$("kgf",9.80665,["kilogramforce"],{auto:!1}),$("kN",1e3,["kilonewton","kilonewtons"]),$("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([$("Pa",1,["pascal","pascals"]),$("mbar",100,["millibar"],{auto:!1}),$("inH₂O",249.0889,["inh2o"],{auto:!1}),$("mmHg",133.322387415,["torr"],{auto:!1}),$("kPa",1e3,["kilopascal","kilopascals"]),$("inHg",3386.388640341,["inhg"],{auto:!1}),$("psi",6894.757293168361,["lbf/in2"],{auto:!1}),$("bar",1e5,[],{auto:!1}),$("atm",101325,["atmosphere","atmospheres"],{auto:!1}),$("MPa",1e6,["megapascal","megapascals"]),$("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([$("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),$("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),$("kN·m",1e3,["knm","kn.m"],{auto:!1}),$("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([$("kg/m³",1,["kg/m3"]),$("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),$("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),$("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([$("L/min",1/6e4,["lpm","l/min"],{auto:!1}),$("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),$("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),$("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),$("cfm",.0004719474432,["ft3/min"],{auto:!1}),$("L/s",.001,["lps","l/s"],{auto:!1}),$("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([$("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),$("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),$("mrad",.001,["milliradian","milliradians"],{auto:!1}),$("mil",Math.PI/3200,["nato-mil"],{auto:!1}),$("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),$("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),$("rad",1,["radian","radians"]),$("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([$("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),$("rad/s",1,["radps","radians/s"]),$("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),$("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([$("ppt",1e-12,["partspertrillion"],{auto:!1}),$("ppb",1e-9,["partsperbillion"]),$("ppm",1e-6,["partspermillion"]),$("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),$("‰",.001,["permille","permil"],{auto:!1}),$("%",.01,["pct","percent"]),$("×",1,["x","ratio","times"])]),molarity:Object.freeze([$("pM",1e-12,["picomolar","picomolarity"]),$("nM",1e-9,["nanomolar","nanomolarity"]),$("µM",1e-6,["um-molar","micromolar","micromolarity"]),$("mM",.001,["millimolar","millimolarity"]),$("M",1,["molar","mol/l","mol/L","molarity"]),$("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([$("mg/s",1e-6,["milligrams/s"]),$("g/s",.001,["grams/s"]),$("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),$("kg/s",1,["kilograms/s","kgps"]),$("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),$("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),$("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([$("µPa·s",1e-6,["upas","micropascalsecond"]),$("cP",.001,["centipoise"],{auto:!1}),$("mPa·s",.001,["mpas","millipascalsecond"]),$("P",.1,["poise"],{auto:!1}),$("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([$("cSt",1e-6,["centistokes","centistoke"]),$("mm²/s",1e-6,["mm2/s"],{auto:!1}),$("St",1e-4,["stokes","stoke"],{auto:!1}),$("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([$("mW/(m·K)",.001,["mw/mk"]),$("W/(m·K)",1,["w/mk","wmk"]),$("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),$("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([$("J/(kg·K)",1,["j/kgk","jkgk"]),$("kJ/(kg·K)",1e3,["kj/kgk"]),$("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([$("nSv/h",1e-9,["nsvh"]),$("µSv/h",1e-6,["usv/h","usvh"]),$("mSv/h",.001,["msvh"]),$("Sv/h",1,["svh"]),$("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),W=Symbol("ambiguous"),V=new Map,H=new Map;function B(P,k){const N=String(P||"").trim();if(!N)throw new Error("[lattice] a unit system needs a name");if(X[N]||H.has(N))throw new Error(`[lattice] unit system "${N}" already exists`);const G=[...k||[]];if(!G.length)throw new Error(`[lattice] unit system "${N}" has no units`);if(!G.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${N}" has no base unit (none with factor 1)`);const q=new Set;for(const Y of G){if(q.has(Y.symbol))throw new Error(`[lattice] unit system "${N}" declares "${Y.symbol}" twice`);q.add(Y.symbol)}return H.set(N,Object.freeze(G)),V.delete(N),N}function w(){return[...Object.keys(X),...H.keys()]}function A(P){const k=g(P);return k?k.units:[]}function g(P){const k=String(P||""),N=V.get(k);if(N!==void 0)return N;const G=X[k]||H.get(k);if(!G)return V.set(k,null),null;const q=Object.freeze([...G].sort((ie,ae)=>ie.factor-ae.factor)),Y=new Map,J=new Map,ee=(ie,ae)=>{const fe=Y.get(ie);fe===void 0?Y.set(ie,ae):fe!==ae&&Y.set(ie,W)};for(const ie of q){ee(ie.symbol.toLowerCase(),ie);for(const ae of ie.aliases)ee(ae.toLowerCase(),ie);if(ie.prefix){const ae=J.get(ie.prefix)||[];ae.push(ie),J.set(ie.prefix,ae)}}const re={units:q,byToken:Y,byPrefix:J,decimal:q.filter(ie=>!ie.binary&&ie.auto),binary:q.some(ie=>ie.binary)?q.filter(ie=>(ie.binary||ie.factor===1)&&ie.auto):null};return V.set(k,re),re}function u(P,k){return k&&P.binary||P.decimal}function h(P,k){const N=g(P);if(!N||x(k))return null;const G=N.units.find(Y=>Y.symbol===String(k));if(G)return G;const q=N.byToken.get(String(k).trim().toLowerCase());return q&&q!==W?q:null}const a=new WeakMap;function r(P){const k=P||{};if(typeof k=="object"&&k!==null){const Y=a.get(k);if(Y!==void 0)return Y}const N=k.system||"data",G=g(N);let q=null;if(!G)z(`unit:system:${N}`,`unknown unit system "${N}"; known systems are ${w().join(", ")}`);else{let Y=k.unit?h(N,k.unit):null;Y||(k.unit&&z(`unit:unit:${N}:${k.unit}`,`unknown unit "${k.unit}" in system "${N}"; falling back to ${G.units[0].symbol}`),Y=G.units.find(J=>J.factor===1)||G.units[0]),q={index:G,base:Y,binary:k.binary===!0}}return typeof k=="object"&&k!==null&&a.set(k,q),q}const t=new WeakMap;function n(P,k){if(!P||!k||!Array.isArray(P.compound)||P.compound.length===0)return null;const N=t.get(P);if(N!==void 0)return N;const G=new Set,q=[];for(const J of P.compound){const ee=h(P.system||"data",J);if(!ee){z(`unit:compound:${P.system}:${J}`,`unknown compound unit "${J}" in system "${P.system||"data"}"; ignoring it`);continue}G.has(ee.symbol)||(G.add(ee.symbol),q.push(ee))}q.sort((J,ee)=>ee.factor-J.factor);const Y=q.length>=2?q:null;return t.set(P,Y),Y}function o(P,k,N){return k===N||k.factor===N.factor?P:P*k.factor/N.factor}const d=new Map;function l(P){const k=P||"",N=d.get(k);if(N)return N;const G={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(P||void 0).formatToParts(12345.6))q.type==="group"?G.group=q.value:q.type==="decimal"&&(G.decimal=q.value)}catch{}return d.set(k,G),G}const i=/[\s   ]/g,m=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,c=/^[^\d+\-(.,\s]+\s*/,f=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function s(P,k){const{group:N,decimal:G}=l(k);let q=String(P).replace(i,"");if(q==="")return null;const Y=G?q.indexOf(G):-1;if(N&&N!==G){if(Y>=0&&q.indexOf(N,Y+G.length)>=0)return null;q=q.split(N).join("")}if(G&&G!=="."&&(q=q.split(G).join(".")),!f.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function p(P,k,N){const G=String(P).trim().replace(/\.$/,"");if(G==="")return null;const q=k.units.find(ae=>ae.symbol===G);if(q)return q;const Y=G.toLowerCase(),J=k.byToken.get(Y);if(J===W)return null;if(J)return J;const ee=k.byPrefix.get(Y);if(!ee||!ee.length)return null;const re=u(k,N),ie=ee.filter(ae=>re.includes(ae));return ie.length===1?ie[0]:null}function b(P,k,N,G){let q=P,Y=0,J=!1,ee=!1;for(;q!=="";){const re=m.exec(q)[0];if(re==="")return null;const ie=s(re,G&&G.locale);if(ie===null)return null;q=q.slice(re.length).trim();const ae=q.search(/[+-]?[\d]/),fe=(ae>=0?q.slice(0,ae):q).trim();if(q=ae>=0?q.slice(ae).trim():"",fe===""){if(J)return null;ee=!0,Y+=o(ie,N[0],k.base)}else{const ce=p(fe,k.index,k.binary);if(!ce)return null;Y+=o(ie,ce,k.base)}if(J=!0,ee&&q!=="")return null}return J?Y:null}function S(P,k){if(x(P))return null;if(typeof P=="number")return Number.isFinite(P)?P:null;const N=r(k);if(!N)return null;let G=String(P).trim();if(G==="")return null;let q=!1;G.startsWith("(")&&G.endsWith(")")&&(q=!0,G=G.slice(1,-1).trim());const Y=n(k,N);if(Y){G.startsWith("-")&&(q=!0,G=G.slice(1).trim());const te=b(G,N,Y,k);return te===null?null:q?-te:te}let J=null;const ee=c.exec(G);if(ee&&ee[0]){const te=p(ee[0].trim(),N.index,N.binary);te&&(J=te,G=G.slice(ee[0].length).trim())}const re=m.exec(G)[0],ie=s(re,k&&k.locale);if(ie===null)return null;const ae=G.slice(re.length).trim();if(J&&ae!=="")return null;const fe=J||(ae===""?N.base:p(ae,N.index,N.binary));if(!fe)return null;const ce=o(ie,fe,N.base);return q?-ce:ce}const j=new Map;function y(P,k,N,G){const q=`${P||""}|${k}|${N}|${G?1:0}`;let Y=j.get(q);return Y||(Y=new Intl.NumberFormat(P||void 0,{minimumFractionDigits:k,maximumFractionDigits:N,useGrouping:G}),j.set(q,Y)),Y}function v(P,k){if(!Number.isFinite(P)||P===0)return Math.max(0,k-1);const N=Math.floor(Math.log10(Math.abs(P)));return Math.min(20,Math.max(0,k-1-N))}function R(P,k){if(!Number.isFinite(P)||P===0)return P;const N=Math.ceil(Math.log10(Math.abs(P))),G=10**(k-N);return Math.round(P*G)/G}function O(P,k,N){if(!N||N===k.base.symbol)return k.base;if(N!=="auto")return F(k,N);if(P===0||!Number.isFinite(P))return k.base;const G=Math.abs(P)*k.base.factor,q=u(k.index,k.binary);let Y=q[0];for(const re of q)G>=re.factor&&(Y=re);if(G>=Y.factor)return Y;let J=Y;for(const re of k.index.units)re.binary!==k.binary&&re.factor!==1||re.factor<=G&&re.factor>(J===Y?0:J.factor)&&(J=re);if(J!==Y)return J;let ee=Y;for(const re of k.index.units)re.binary!==k.binary&&re.factor!==1||re.factor<ee.factor&&(ee=re);return ee.factor<k.base.factor?ee:k.base}function F(P,k){const N=P.index.units.find(q=>q.symbol===k);if(N)return N;const G=P.index.byToken.get(String(k).toLowerCase());return G&&G!==W?G:(z(`unit:display:${k}`,`unknown display unit "${k}"; rendering in ${P.base.symbol}`),P.base)}function C(P,k,N,G){const q=P<0;let Y=Math.abs(P)*k.base.factor;const J=typeof G.decimals=="number"?G.decimals:G.minDecimals??0,ee=typeof G.decimals=="number"?G.decimals:G.maxDecimals??Math.max(J,2),re=G.space??" ",ie=[];for(let fe=0;fe<N.length;fe++){const ce=N[fe],te=fe===N.length-1;let oe=te?Y/ce.factor:Math.floor(Y/ce.factor);if(Y-=oe*ce.factor,te){const de=10**ee;oe=Math.round(oe*de)/de+0}const he=te?y(G.locale,J,ee,G.group!==!1):y(G.locale,0,0,G.group!==!1);ie.push(`${he.format(oe)}${re}${ce.symbol}`)}const ae=ie.join(" ");return q?`-${ae}`:ae}function T(P,k){const N=k||{},G=N.nullDisplay??"";if(x(P)||P==="")return G;const q=typeof P=="number"?P:Number(P);if(!Number.isFinite(q))return G;const Y=r(N);if(!Y)return String(q);const J=n(N,Y);if(J)return C(q,Y,J,N);const ee=typeof N.significantFigures=="number"&&N.significantFigures>0?N.significantFigures:0,re=ee?R(q,ee):q,ie=O(re,Y,N.display),ae=o(re,Y.base,ie);let fe=typeof N.decimals=="number"?N.decimals:N.minDecimals??0,ce=typeof N.decimals=="number"?N.decimals:N.maxDecimals??Math.max(fe,2);ee&&(fe=v(ae,ee),ce=fe);const te=y(N.locale,fe,ce,N.group!==!1).format(ae),oe=N.space??" ";return N.placement==="prefix"?`${ie.symbol}${N.space??""}${te}`:`${te}${oe}${ie.symbol}`}function L(P,k){const N=x(P)||Number.isNaN(P)?null:Number(P),G=x(k)||Number.isNaN(k)?null:Number(k);return N===null||Number.isNaN(N)?G===null||Number.isNaN(G)?0:1:G===null||Number.isNaN(G)||N<G?-1:N>G?1:0}function E(P){const k=typeof P.decimals=="number"&&P.decimals>0?`.${"0".repeat(P.decimals)}`:"";return`${typeof P.decimals=="number"?`#,##0${k}`:"#,##0.##"}" ${P.symbol}"`}function D(P){const k={system:"data",...P||{}},N=r(k),G=N?N.base.symbol:String(k.unit||""),q=Object.freeze({...k,unit:G}),Y=Object.freeze({...q,display:G,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),ee=re=>{const ie=re||"";let ae=J.get(ie);return ae||(ae=Object.freeze({...q,locale:re||void 0}),J.set(ie,ae)),ae};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:re=>T(re.value,re.locale?ee(re.locale):q),parse:re=>S(re.text,re.locale?ee(re.locale):q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:k.total||"sum"},...k.totals?{totals:k.totals}:{},excel:k.excel||E({decimals:k.decimals,symbol:G}),toStorage:re=>typeof re=="number"?Number.isFinite(re)?re:null:typeof re=="string"?S(re,q):x(re)?null:S(String(re),q),toClipboard:re=>T(re,Y),fromClipboard:re=>S(re,q)}}const I=D}),Fe("packages/core/src/columns/types/engineering.js",function(e,K){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return _}});const x=K("packages/core/src/internal/util.js").isNil,$=K("packages/core/src/columns/types/unit.js").createUnitType;function _(V){const H=2*Math.PI/V;return B=>{let w=0,A=0,g=0;for(const h of B||[]){if(x(h))continue;const a=Number(h);Number.isFinite(a)&&(w+=Math.cos(a*H),A+=Math.sin(a*H),g+=1)}return!g||Math.hypot(w,A)/g<1e-12?null:(Math.atan2(A,w)/H%V+V)%V}}function X(V){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:_(V)}}}const W=Object.freeze({metres:$({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:$({system:"length",unit:"mm",maxDecimals:2}),kilometres:$({system:"length",unit:"km",maxDecimals:3}),grams:$({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:$({system:"mass",unit:"kg",maxDecimals:3}),tonnes:$({system:"mass",unit:"t",maxDecimals:3}),seconds:$({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:$({system:"duration",unit:"ms",maxDecimals:3}),hours:$({system:"duration",unit:"h",maxDecimals:2}),speed:$({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:$({system:"speed",unit:"km/h",maxDecimals:1}),mph:$({system:"speed",unit:"mph",maxDecimals:1}),knots:$({system:"speed",unit:"kn",maxDecimals:1}),acceleration:$({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:$({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:$({system:"area",unit:"ha",maxDecimals:4}),volume:$({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:$({system:"volume",unit:"m³",maxDecimals:3}),energy:$({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:$({system:"energy",unit:"kWh",maxDecimals:2}),power:$({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:$({system:"power",unit:"kW",maxDecimals:2}),force:$({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:$({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:$({system:"pressure",unit:"bar",maxDecimals:3}),psi:$({system:"pressure",unit:"psi",maxDecimals:1}),torque:$({system:"torque",unit:"N·m",maxDecimals:2}),density:$({system:"density",unit:"kg/m³",maxDecimals:2}),flow:$({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:$({system:"flow",unit:"L/min",maxDecimals:1}),radians:$({system:"angle",unit:"rad",maxDecimals:4,totals:X(2*Math.PI)}),degrees:$({system:"angle",unit:"°",maxDecimals:2,totals:X(360)}),rpm:$({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:$({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:$({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:$({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:$({system:"fraction",unit:"bp",maxDecimals:1}),molarity:$({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:$({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:$({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:$({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:$({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:$({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:$({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:$({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Fe("packages/core/src/columns/types/si.js",function(e,K){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/columns/types/unit.js"),x=Q.defineUnit,z=Q.registerUnitSystem,$=Q.createUnitType,_=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),X=Object.freeze(["p","n","µ","m","","k","M","G"]);function W(A){const g=String(A.base),u=new Set([...A.prefixes||X,""]),h=[];for(const a of _){if(!u.has(a.symbol))continue;const r=`${a.symbol}${g}`,t=[];if(A.name){t.push(`${a.name}${A.name}`,`${a.name}${A.name}s`);const n=a.name.slice(-1);if(n&&A.name.startsWith(n)){const o=`${a.name.slice(0,-1)}${A.name}`;t.push(o,`${o}s`)}}a.symbol==="µ"&&t.push(`u${g}`),a.factor===1&&A.aliases&&t.push(...A.aliases),h.push(x(r,a.factor,t))}for(const a of A.extra||[])h.push(a);return h}function V(A,g){const u=W(g);return z(A,u)}function H(A,g,u){return V(A,g),$({system:A,unit:g.base,display:"auto",maxDecimals:3,...u||{}})}const B=Object.freeze({voltage:H("voltage",{base:"V",name:"volt"}),current:H("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:H("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:H("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:H("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:H("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[x("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),x("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:H("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:H("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[x("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:H("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:H("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:H("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:H("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:H("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:H("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:H("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[x("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:H("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),w=H}),Fe("packages/core/src/columns/types/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const x=K("packages/core/src/internal/util.js").isNil,z=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:h=>h+273.15,fromKelvin:h=>h-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:h=>(h+459.67)*(5/9),fromKelvin:h=>h*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:h=>h,fromKelvin:h=>h}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:h=>h*(5/9),fromKelvin:h=>h*(9/5)})});function $(h){if(x(h))return null;const a=String(h).trim();if(a==="")return null;for(const[t,n]of Object.entries(z))if(a===t||a===n.symbol)return{key:t,scale:n};const r=a.toLowerCase();for(const[t,n]of Object.entries(z))if(n.aliases.includes(r))return{key:t,scale:n};return null}function _(h,a,r){const t=$(a),n=$(r);return!t||!n||!Number.isFinite(Number(h))?null:t.key===n.key?Number(h):n.scale.fromKelvin(t.scale.toKelvin(Number(h)))}const X=new Map;function W(h,a,r){const t=`${h||""}|${a}|${r}`;let n=X.get(t);return n||(n=new Intl.NumberFormat(h||void 0,{minimumFractionDigits:a,maximumFractionDigits:r}),X.set(t,n)),n}function V(h,a){const r=a||{},t=r.nullDisplay??"";if(x(h)||h==="")return t;const n=Number(h);if(!Number.isFinite(n))return t;const o=$(r.scale||"C");if(!o)return String(n);const d=$(r.display||r.scale||"C")||o,l=d.key===o.key?n:d.scale.fromKelvin(o.scale.toKelvin(n)),i=typeof r.decimals=="number"?r.decimals:null,m=i??r.minDecimals??0,c=i??r.maxDecimals??1;return`${W(r.locale,m,c).format(l)}${r.space??" "}${d.scale.symbol}`}const H=/^[+-]?[\d\s.,  ]*\d/;function B(h,a){const r=String(h).trim();if(r==="")return null;const t=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(l=>l.type==="decimal")?.value||".",n=t===","?".":",",o=r.split(n).join("").split(/[\s  ]/).join("").replace(t,"."),d=Number(o);return Number.isFinite(d)?d:null}function w(h,a){if(x(h))return null;const r=a||{},t=$(r.scale||"C");if(!t)return null;if(typeof h=="number")return Number.isFinite(h)?h:null;let n=String(h).trim();if(n==="")return null;let o=!1;n.startsWith("(")&&n.endsWith(")")&&(o=!0,n=n.slice(1,-1).trim());const d=H.exec(n);if(!d)return null;const l=B(d[0],r.locale);if(l===null)return null;const i=n.slice(d[0].length).trim();if(i==="")return o?-l:l;const m=$(i);if(!m)return null;const c=m.key===t.key?l:t.scale.fromKelvin(m.scale.toKelvin(l));return o?-c:c}function A(h){const a=Object.freeze({scale:"C",...h||{}}),t=($(a.scale)||$("C")).scale.symbol,n=Object.freeze({...a,display:a.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),o=new Map([[a.locale||"",a]]),d=l=>{const i=l||"";let m=o.get(i);return m||(m=Object.freeze({...a,locale:l||void 0}),o.set(i,m)),m};return{base:"number",extends:"number",storage:"float64",temperatureConfig:a,format:l=>V(l.value,l.locale?d(l.locale):a),parse:l=>w(l.text,l.locale?d(l.locale):a),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:a.excel||`#,##0${typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".#"}" ${t}"`,toStorage:l=>typeof l=="number"?Number.isFinite(l)?l:null:typeof l=="string"?w(l,a):x(l)?null:w(String(l),a),toClipboard:l=>V(l,n),fromClipboard:l=>w(l,a)}}const g=Object.freeze({celsius:A({scale:"C"}),fahrenheit:A({scale:"F"}),kelvin:A({scale:"K"})}),u=A}),Fe("packages/core/src/columns/types/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return C}});const Q=K("packages/core/src/internal/util.js"),x=Q.isNil,z=Q.warnOnce,$=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),_=Object.freeze({2:1,8:3,16:4}),X=Object.freeze({2:"0b",8:"0o",16:"0x"}),W=Object.freeze({2:4,8:3,16:2}),V=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),H=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),B=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),w=/[\s\u00a0\u202f_,']/g,A=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,g=Object.freeze([8,16,32,53]),u=new WeakSet,h=new WeakMap,a=new Map,r=new WeakMap,t=new WeakMap,n=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(T){if(T==null)return 16;const L=typeof T=="string"?T.toLowerCase():T,E=$[L];return E||(z(`radix:base:${String(T)}`,`unsupported radix ${String(T)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function d(T,L){return Math.ceil(T/_[L])}function l(T,L){if(!T)return L?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!L)return{min:0,max:2**T-1};const E=2**(T-1);return{min:-E,max:E-1}}function i(T){return H[T]||"hexadecimal"}function m(T){if(typeof T=="string"){const L=n[T];return L||z(`radix:preset:${T}`,`unknown radix preset "${T}"; known presets are ${Object.keys(n).join(", ")}`),{...L||{}}}if(T&&typeof T.preset=="string"){const L=n[T.preset];return L||z(`radix:preset:${T.preset}`,`unknown radix preset "${T.preset}"; known presets are ${Object.keys(n).join(", ")}`),{...L||{},...T}}return T||{}}function c(T){const L=m(T),E=o(L.radix),D=_[E];let I=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const re=Number(L.bitWidth);g.includes(re)?I=re:z(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let P=L.signed!==!1;!P&&I===null&&(z("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),I=32);const k=L.prefix===void 0||L.prefix===!0?X[E]:L.prefix===!1?"":String(L.prefix);let N=0;L.pad===!0?N=I?d(I,E):0:typeof L.pad=="number"&&L.pad>0&&(N=Math.floor(L.pad));let G=0;L.group===!0?G=W[E]:typeof L.group=="number"&&L.group>0&&(G=Math.floor(L.group));const q=l(I,P),Y=typeof L.min=="number"?Math.max(q.min,L.min):q.min,J=typeof L.max=="number"?Math.min(q.max,L.max):q.max,ee=Object.freeze({radix:E,bits:D,prefix:k,uppercase:L.uppercase!==!1,pad:N,group:G,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:I,signed:P,min:Y,max:J<Y?Y:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:i(E)});return u.add(ee),ee}function f(T){if(T&&u.has(T))return T;if(typeof T=="string"){let L=a.get(T);return L||(L=c(T),a.set(T,L)),L}if(T&&typeof T=="object"){let L=h.get(T);return L||(L=c(T),h.set(T,L)),L}return f("hex")}function s(T){return T<0?-Math.round(-T):Math.round(T)}function p(T,L,E){if(L<=0||T.length<=L)return T;const D=T.length%L||L,I=[T.slice(0,D)];for(let P=D;P<T.length;P+=L)I.push(T.slice(P,P+L));return I.join(E)}function b(T){const L=f(T),{radix:E,prefix:D,uppercase:I,pad:P,group:k,groupSeparator:N,signed:G,bitWidth:q,nullDisplay:Y}=L,J=q?2**q:0,ee=re=>{if(x(re)||re==="")return Y;const ie=typeof re=="number"?re:Number(re);if(!Number.isFinite(ie))return Y;const ae=s(ie);let fe="",ce=ae;ae<0&&(G?(fe="-",ce=-ae):ce=(ae%J+J)%J);let te=ce.toString(E);return te=I?te.toUpperCase():te.toLowerCase(),P>0&&te.length<P&&(te=te.padStart(P,"0")),k>0&&(te=p(te,k,N)),fe+D+te};return ee.options=L,ee}function S(T,L){const E=f(L);let D=r.get(E);return D||(D=b(E),r.set(E,D)),D(T)}function j(T){const L=f(T),{radix:E,groupSeparator:D,signed:I,min:P,max:k}=L,N=V[E],G=q=>{if(x(q))return{ok:!0,value:null,reason:"blank"};let Y=String(q);if(D&&D!==""&&(Y=Y.split(D).join("")),Y=Y.replace(w,""),Y==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Y[0]==="-"||Y[0]==="+")&&(J=Y[0]==="-",Y=Y.slice(1)),Y==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[ie,ae]of B){const fe=ie.exec(Y);if(!fe)continue;const ce=Y.slice(fe[0].length);if(ce==="")break;if(!V[ae].test(ce))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ce,ae);break}if(ee===null)if(N.test(Y))ee=parseInt(Y,E);else if(A.test(Y))ee=Number(Y);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const re=s(J?-ee:ee);return!I&&re<0?{ok:!1,value:re,reason:"negative"}:re<P||re>k?{ok:!1,value:re,reason:"range"}:{ok:!0,value:re,reason:"ok"}};return G.options=L,G}function y(T,L){const E=f(L);let D=t.get(E);return D||(D=j(E),t.set(E,D)),D(T)}function v(T,L){const E=y(T,L);return E.ok?E.value:null}function R(T,L){const E=x(T)||Number.isNaN(T)?null:Number(T),D=x(L)||Number.isNaN(L)?null:Number(L);return E===null?D===null?0:1:D===null||E<D?-1:E>D?1:0}function O(T){const L=T.min>=-2147483648&&T.max<=2147483647;return T.bitWidth&&L?"int32":"float64"}function F(T){const L=c(T),E=b(L),D=j(L);return{base:"number",extends:"number",storage:O(L),matches:null,format:I=>E(I.value),parse:I=>{const P=D(I.text);return P.ok?P.value:null},compare:R,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:I=>E(I),fromClipboard:I=>{const P=D(I);return P.ok?P.value:null},radix:L,formatValue:E,parseText:D}}const C=F}),Fe("packages/core/src/columns/types/aggregable.js",function(e,K){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return _}});const x=K("packages/core/src/internal/util.js").isNil;function z(B){const w=[];for(const A of B||[]){if(x(A))continue;const g=Number(A);Number.isFinite(g)&&w.push(g)}return w}function $(B){return w=>{const A=z(w);if(!A.length)return null;let g=0;for(const u of A)g+=10**(u/B);return B*Math.log10(g)}}function _(B){return w=>{const A=z(w);if(!A.length)return null;let g=0;for(const u of A)g+=10**(u/B);return B*Math.log10(g/A.length)}}function X(B,w){const A=w&&w.column,u=(A&&A.typeOptions||{}).weight,h=w&&w.valueAt;if(!u||typeof h!="function")return null;let a=0,r=0;for(let t=0;t<B.length;t++){if(x(B[t]))continue;const n=Number(B[t]);if(!Number.isFinite(n))continue;const o=h(u,t);if(x(o))continue;const d=Number(o);!Number.isFinite(d)||d<=0||(a+=n*d,r+=d)}return r===0?null:a/r}function W(B={}){const w=B.factor===20?20:10,A=typeof B.suffix=="string"?B.suffix:"",g=Number.isInteger(B.decimals)?B.decimals:1;return{base:"number",storage:"float64",name:B.name||"logarithmic",format:u=>{const h=u&&u.value;return x(h)||!Number.isFinite(Number(h))?"":`${Number(h).toFixed(g)}${A}`},parse:u=>{const h=String((u&&u.text)??"").replace(A,"").trim();if(!h)return null;const a=Number(h);return Number.isFinite(a)?a:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:$(w),avg:_(w)}}}}function V(B={}){const w=Number.isInteger(B.decimals)?B.decimals:1,A=B.percent===!0;return{base:"number",storage:"float64",name:B.name||"ratio",format:g=>{const u=g&&g.value;return x(u)||!Number.isFinite(Number(u))?"":A?`${Number(u).toFixed(w)}%`:Number(u).toFixed(w)},parse:g=>{const u=String((g&&g.text)??"").replace("%","").trim();if(!u)return null;const h=Number(u);return Number.isFinite(h)?h:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:X}}}}const H=Object.freeze({decibel:W({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:W({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:V({name:"ratio"}),percentRate:V({name:"percentRate",percent:!0})})}),Fe("packages/core/src/columns/types/currency.js",function(e,K){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const x=K("packages/core/src/internal/util.js").isNil,z="⚠ no rate";function $(l){if(x(l))return null;const i=String(l).trim().toUpperCase();return i===""?null:i}function _(l){if(x(l))return null;if(typeof l=="object"&&!Array.isArray(l)){const i=Number(l.amount),m=$(l.code);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}if(Array.isArray(l)&&l.length===2){const i=Number(l[0]),m=$(l[1]);return!m||!Number.isFinite(i)?null:{amount:i,code:m}}return null}const X=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),W=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),V=/[+-]?[\d\s., ]*\d/;function H(l,i){const m=String(l).trim();if(m==="")return null;const c=new Intl.NumberFormat(i||void 0).formatToParts(1.1).find(b=>b.type==="decimal")?.value||".",f=c===","?".":",",s=m.split(f).join("").split(/[\s ]/).join("").replace(c,"."),p=Number(s);return Number.isFinite(p)?p:null}function B(l,i){const m=i||{},c=$(m.code);if(x(l))return null;const f=_(l);if(f)return f;if(typeof l=="number")return Number.isFinite(l)&&c?{amount:l,code:c}:null;let s=String(l).trim();if(s==="")return null;let p=!1;s.startsWith("(")&&s.endsWith(")")&&(p=!0,s=s.slice(1,-1).trim());let b=null;for(const[O,F]of Object.entries(X)){if(s.startsWith(O)){b=F,s=s.slice(O.length).trim();break}if(s.endsWith(O)){b=F,s=s.slice(0,-O.length).trim();break}}const S=V.exec(s);if(!S)return null;const j=H(S[0],m.locale);if(j===null)return null;const y=(s.slice(0,S.index)+" "+s.slice(S.index+S[0].length)).trim();!b&&y!==""&&(b=$(y));const v=b||c;return v?{amount:p?-j:j,code:v}:null}function w(l,i){if(typeof l=="function")return(m,c)=>{if(m===c)return 1;const f=l(m,c);return typeof f=="number"&&Number.isFinite(f)&&f>0?f:null};if(l&&typeof l=="object"){const m=l;return(c,f)=>{if(c===f)return 1;const s=Number(m[c]),p=Number(m[f]);return!Number.isFinite(s)||!Number.isFinite(p)||s<=0||p<=0?null:p/s}}return(m,c)=>m===c?1:null}function A(l,i,m){if(!l)return null;if(l.code===i)return l.amount;const c=m(l.code,i);return c===null?null:l.amount*c}const g=new Map;function u(l,i,m){const c=`${l||""}|${i}|${m??""}`;let f=g.get(c);if(!f){const s={style:"currency",currency:i};typeof m=="number"&&(s.minimumFractionDigits=m,s.maximumFractionDigits=m);try{f={fmt:new Intl.NumberFormat(l||void 0,s),currency:!0}}catch{f={fmt:new Intl.NumberFormat(l||void 0,typeof m=="number"?{minimumFractionDigits:m,maximumFractionDigits:m}:{}),currency:!1}}g.set(c,f)}return f}function h(l,i){const m=i||{},c=m.nullDisplay??"",f=_(l);if(!f)return c;const s=$(m.display)||f.code;let p=f.amount,b=f.code;if(s!==f.code){const y=m.rateFn||w(m.rates,m.rateBase),v=A(f,s,y);if(v===null)return`${m.missingRate??z} ${f.code}→${s}`;p=v,b=s}const{fmt:S,currency:j}=u(m.locale,b,m.decimals);return j?S.format(p):`${S.format(p)} ${b}`}function a(l){const i=_(l);return i?`${i.amount} ${i.code}`:""}function r(l){const i=l||{},m=$(i.display),c=i.rateFn||w(i.rates,i.rateBase);return(f,s)=>{const p=_(f),b=_(s);if(!p&&!b)return 0;if(!p)return 1;if(!b)return-1;if(m){const S=A(p,m,c),j=A(b,m,c);if(S!==null&&j!==null)return S===j?0:S<j?-1:1}return p.code===b.code?p.amount===b.amount?0:p.amount<b.amount?-1:1:p.code<b.code?-1:1}}function t(l){const i=l||{},m=(f,s)=>{const p=[];for(const v of f||[]){const R=_(v);R&&p.push(R)}if(!p.length)return null;if(new Set(p.map(v=>v.code)).size===1){const v=p[0].code;return{amount:s(p.map(R=>R.amount)),code:v}}const S=$(i.display);if(!S)return`${i.missingRate??z}: mixed currencies, no display currency set`;const j=i.rateFn||w(i.rates,i.rateBase),y=[];for(const v of p){const R=A(v,S,j);if(R===null)return`${i.missingRate??z}: ${v.code}→${S}`;y.push(R)}return{amount:s(y),code:S}},c=f=>f.reduce((s,p)=>s+p,0);return{sum:f=>m(f,c),avg:f=>m(f,s=>c(s)/s.length),min:f=>m(f,s=>Math.min(...s)),max:f=>m(f,s=>Math.max(...s))}}function n(l){const i=Object.freeze({code:"USD",...l||{}}),m=w(i.rates,i.rateBase),c=Object.freeze({...i,rateFn:m}),f=t(c),s=r(c),p=new Map([[i.locale||"",c]]),b=y=>{const v=y||"";let R=p.get(v);return R||(R=Object.freeze({...c,locale:y||void 0}),p.set(v,R)),R},S=W[$(i.display||i.code)]||"",j=typeof i.decimals=="number"&&i.decimals>0?`.${"0".repeat(i.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:c,format:y=>h(y.value,y.locale?b(y.locale):c),parse:y=>B(y.text,y.locale?b(y.locale):c),compare:s,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:f},excel:i.excel||(S?`"${S}"#,##0${j}`:`#,##0${j}`),toStorage:y=>{const v=_(y);return v||(typeof y=="string"||typeof y=="number"?B(y,c):null)},toClipboard:y=>a(y),fromClipboard:y=>B(y,c)}}const o=Object.freeze({currency:n({code:"USD"}),usd:n({code:"USD"}),eur:n({code:"EUR"}),gbp:n({code:"GBP"}),jpy:n({code:"JPY",decimals:0})}),d=n}),Fe("packages/core/src/columns/types/index.js",function(e,K){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/columns/types/temporal.js"),x=Q.TEMPORAL_TYPES,z=K("packages/core/src/columns/types/network.js"),$=z.NETWORK_TYPES,_=K("packages/core/src/columns/types/structured.js"),X=_.STRUCTURED_TYPES,W=K("packages/core/src/columns/types/unit.js"),V=W.createUnitType,H=W.UNIT_SYSTEMS,B=W.parseUnit,w=W.formatUnit,A=W.registerUnitSystem,g=W.unitSystemNames,u=W.unitsOf,h=W.defineUnit,a=K("packages/core/src/columns/types/engineering.js"),r=a.ENGINEERING_TYPES,t=K("packages/core/src/columns/types/si.js"),n=t.SI_TYPES,o=t.createSiType,d=t.createSiSystem,l=t.siUnits,i=t.SI_PREFIXES,m=K("packages/core/src/columns/types/temperature.js"),c=m.TEMPERATURE_TYPES,f=m.createTemperatureType,s=m.convertTemperature,p=m.formatTemperature,b=m.parseTemperature,S=m.TEMPERATURE_SCALES,j=K("packages/core/src/columns/types/radix.js"),y=j.createRadixType,v=j.RADIX_PRESETS,R=j.parseRadix,O=j.formatRadix,F=K("packages/core/src/columns/types/aggregable.js"),C=F.AGGREGABLE_TYPES,T=K("packages/core/src/columns/types/currency.js"),L=T.CURRENCY_TYPES,E=T.createCurrencyType,D=T.parseMoney,I=T.formatMoney,P=T.convertMoney,k=T.toMoney,N=T.rateFunction,G=T.moneyComparator,q=T.normaliseCode,Y=T.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return W.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return a.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return a.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return m.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return m.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return m.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return m.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return m.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return m.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return m.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return T.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return T.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return T.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return T.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return T.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return T.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return T.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return T.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return T.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return T.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return Q.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return z.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return _.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return F.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return F.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return F.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return Q.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return Q.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return Q.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return Q.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return Q.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return Q.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return z.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return z.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return z.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return z.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return z.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return z.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return z.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return z.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return z.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return z.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return z.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return _.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return _.summariseJson}});const J=Object.freeze({...x,...$,...X,...C,hex:y(v.hex),hex8:y(v.hex8),hex16:y(v.hex16),hex32:y(v.hex32),binary:y(v.binary),binary8:y(v.binary8),octal:y(v.octal),bytes:V({system:"data",unit:"B",display:"auto"}),megabytes:V({system:"data",unit:"MB"}),gigabytes:V({system:"data",unit:"GB"}),bitrate:V({system:"bitrate",unit:"Mbps"}),gigabits:V({system:"bitrate",unit:"Gbps"}),...r,...n,...c,...L});{const ee=new Set;for(const re of[x,$,X,C,r,n,c,L])for(const ie of Object.keys(re)){if(ee.has(ie))throw new Error(`[lattice] data type "${ie}" is declared twice`);ee.add(ie)}}}),Fe("packages/core/src/compute/handle.js",function(e,K){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return t}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,z=Q.defaultCompare,$=Q.warnOnce;function _(n){const o=new Uint32Array(n);for(let d=0;d<n;d++)o[d]=d;return o}function X(n,o){if(o&&typeof o.count=="number")return o.count;if(!n)return 0;if(typeof n.count=="number")return n.count;if(typeof n.length=="number")return n.length;const d=n.values;return n.kind==="multi"&&n.offsets?Math.max(0,n.offsets.length-1):d?n.kind==="bitset"?typeof d.size=="number"?d.size:n.presence&&typeof n.presence.size=="number"?n.presence.size:($(`count:${n.id}`,`column "${n.id}" is bitset-backed with no declared row count; assuming ${d.length*8}`),d.length*8):d.length:n.presence&&typeof n.presence.size=="number"?n.presence.size:0}const W=new WeakMap;function V(n){const o=n.constructor;if(!o)return"unknown";const d=W.get(o);if(d)return d;let l="unknown";try{let i=null;typeof o.from=="function"?i=o.from([!1,!0]):(i=new o(8),i.set(1));const m=i&&i.words;m&&m.length&&(m[0]===2?l="lsb":m[0]===64&&(l="msb"))}catch{l="unknown"}return W.set(o,l),l}function H(n){if(!n)return()=>0;const o=n instanceof Uint8Array?n:n.words;if(o instanceof Uint8Array){const d=n instanceof Uint8Array?"lsb":V(n);if(d==="lsb")return l=>o[l>>>3]>>>(l&7)&1;if(d==="msb")return l=>o[l>>>3]>>>7-(l&7)&1}return typeof n.get=="function"?d=>n.get(d)?1:0:()=>0}function B(n){return!n||!n.presence?null:H(n.presence)}function w(n){return n?typeof n.size=="number"?n.size:typeof n.values=="function"?n.values().length:0:0}function A(n,o){return n?typeof n.valueOf=="function"?n.valueOf(o):typeof n.values=="function"?n.values()[o]:null:null}function g(n,o){const d=n.offsets,l=n.values;if(!d||!l)return[];const i=d[o],m=d[o+1];if(!(m>i))return[];const c=n.dict,f=new Array(m-i);for(let s=i;s<m;s++)f[s-i]=c?A(c,l[s]):l[s];return f}function u(n){if(!n)return()=>{};const o=n.values,d=B(n),l=n.kind;if(l==="dictionary"){const i=n.dict;return d?m=>d(m)?A(i,o[m]):null:m=>A(i,o[m])}if(l==="bitset"){const i=H(o);return d?m=>d(m)?i(m)===1:null:m=>i(m)===1}if(l==="multi")return d?i=>d(i)?g(n,i):null:i=>g(n,i);if(!o&&typeof n.get=="function"){const i=n.get.bind(n);return m=>{const c=i(m);return c===void 0?null:c}}return d?i=>{if(!d(i))return null;const m=o[i];return m===void 0?null:m}:i=>{const m=o[i];return m===void 0?null:m}}function h(n,o){if(n<o)return-1;if(n>o)return 1;if(n===o){const i=Object.is(n,-0),m=Object.is(o,-0);return i===m?0:i?-1:1}const d=Number.isNaN(n),l=Number.isNaN(o);return d&&l?0:d?1:-1}function a(n){const o=x(n);return(d,l)=>{if(d===l)return 0;const i=typeof d,m=typeof l;if(i==="string"&&m==="string")return o.compare(d,l);if(i==="number"&&m==="number")return h(d,l);if(i==="boolean"&&m==="boolean")return d===l?0:d?1:-1;if(d instanceof Date||l instanceof Date){const c=d instanceof Date?d.getTime():Number(d),f=l instanceof Date?l.getTime():Number(l);return h(c,f)}return z(d,l)}}function r(n,o){if(n&&typeof n.ranks=="function")return n.ranks(o);const d=n&&typeof n.values=="function"?n.values():[],l=d.length,i=a(o),m=new Array(l);for(let f=0;f<l;f++)m[f]=f;m.sort((f,s)=>i(d[f],d[s])||f-s);const c=new Uint32Array(l);for(let f=0;f<l;f++)c[m[f]]=f;return c}function t(n){return n==null||typeof n=="number"&&Number.isNaN(n)}}),Fe("packages/core/src/compute/filter.js",function(e,K){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return fe}});const Q=K("packages/core/src/internal/util.js"),x=Q.isBlank,z=Q.toArray,$=Q.warnOnce,_=K("packages/core/src/format/date.js"),X=_.toDate,W=_.toIsoDate,V=K("packages/core/src/compute/handle.js"),H=V.bitReader,B=V.dictSize,w=V.dictValue,A=V.presenceReader,g=V.valueComparator,u=V.valueReader,h=/^\d{4}-\d{2}-\d{2}$/,a="\0null\0";function r(ce,te){const oe=ce&&ce.pool;if(oe){const he=oe.mask||oe.acquireMask||oe.acquire||oe.take;if(typeof he=="function"){const de=he.call(oe,te);if(de&&de.length>=te)return de}}return new Uint8Array(te)}function t(ce,te){const oe=ce&&ce.pool;if(!oe||!te)return;const he=oe.release||oe.releaseMask||oe.free||oe.recycle;typeof he=="function"&&he.call(oe,te)}function n(ce,te,oe){return ce.fill(oe,0,te),ce}function o(ce){return ce==null||typeof ce=="number"&&Number.isNaN(ce)}function d(ce,te){if(ce==null)return ce;if(te==="number")return typeof ce=="number"?ce:Number(ce);if(te==="date"||te==="dateString"){const oe=W(ce);return oe===null?l(ce):oe}return te==="boolean"?typeof ce=="boolean"?ce:ce==="true"||ce===1?!0:ce==="false"||ce===0?!1:!!ce:ce}function l(ce){return ce instanceof Date?ce.getTime():typeof ce=="number"?ce:Date.parse(String(ce))}function i(ce){return typeof ce=="number"?ce:ce instanceof Date?ce.getTime():ce==null||ce===""?NaN:Number(ce)}function m(ce,te){const oe=typeof ce=="string"?ce:String(ce);return te?oe:oe.toLowerCase()}function c(ce,te){return ce==null?a:typeof ce=="string"?te?ce:ce.toLowerCase():ce instanceof Date?ce.getTime():ce}function f(ce,te,oe){const he=new Set;for(const de of z(ce)){const be=d(de,oe);he.add(c(be,te)),typeof be=="string"&&be!==""&&Number.isFinite(Number(be))?he.add(Number(be)):typeof be=="number"&&Number.isFinite(be)&&he.add(c(String(be),te))}return he}function s(ce,te,oe){if(ce==null||te===null||te===void 0)return ce==null&&te==null;const he=typeof ce,de=typeof te;return he==="string"&&de==="string"?oe?ce===te:ce.toLowerCase()===te.toLowerCase():ce instanceof Date||te instanceof Date?l(ce)===l(te):he==="number"&&de==="number"?ce===te||Number.isNaN(ce)&&Number.isNaN(te):he==="number"&&de==="string"?ce===Number(te):he==="string"&&de==="number"?Number(ce)===te:he==="boolean"||de==="boolean"?ce===te:Array.isArray(ce)&&Array.isArray(te)?ce.length===te.length&&ce.every((be,Te)=>s(be,te[Te],oe)):ce===te}function p(ce,te){try{if(ce instanceof RegExp){const oe=ce.flags.replace(/[gy]/g,"");return new RegExp(ce.source,te||oe.includes("i")?oe:`${oe}i`)}return new RegExp(String(ce),te?"":"i")}catch(oe){return $(`regex:${String(ce)}`,`filter operator "matches" received an invalid pattern: ${String(ce)}`,oe),null}}function b(ce,te){if(ce&&ce.type==="datetime"&&S.has(ce.op))return O(ce,te);const oe=F(ce,te),he=ce&&ce.type;return he!=="date"&&he!=="dateString"?oe:de=>oe(typeof de=="string"&&h.test(de)?de:W(de)??de)}const S=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),j=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,y=new Map;function v(ce,te){let oe=y.get(te);if(oe===void 0){try{oe=new Intl.DateTimeFormat("en-CA",{timeZone:te,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{oe=null}y.set(te,oe)}if(!oe)return null;const he={};for(const de of oe.formatToParts(ce))de.type!=="literal"&&(he[de.type]=de.value);return he}function R(ce,te){if(ce==null||ce==="")return null;if(typeof ce=="string"){const be=j.exec(ce.trim());if(be)return Date.UTC(+be[1],+be[2]-1,+be[3],+(be[4]||0),+(be[5]||0),+(be[6]||0),+(be[7]||"0").padEnd(3,"0"))}const oe=X(ce);if(!oe)return null;const he=oe.getUTCMilliseconds(),de=te?v(oe,te):null;return de?Date.UTC(+de.year,+de.month-1,+de.day,de.hour==="24"?0:+de.hour,+de.minute,+de.second,he):Date.UTC(oe.getFullYear(),oe.getMonth(),oe.getDate(),oe.getHours(),oe.getMinutes(),oe.getSeconds(),he)}function O(ce,te){const oe=typeof ce.timeZone=="string"&&ce.timeZone?ce.timeZone:void 0,he=Te=>R(Te,oe),de=Array.isArray(ce.value)?ce.value.map(he):he(ce.value),be=F({...ce,type:"number",value:de},te);return Te=>be(R(Te))}function F(ce,te){const oe=ce&&ce.op,he=!!(ce&&ce.caseSensitive),de=ce&&ce.type,be=g(te),Te=Ae=>Ce=>!Ae(Ce);switch(oe){case"eq":{const Ae=d(ce.value,de);return Ce=>s(Ce,Ae,he)}case"ne":{const Ae=d(ce.value,de);return Ce=>!s(Ce,Ae,he)}case"lt":case"lte":case"gt":case"gte":{const Ae=d(ce.value,de);if(o(Ae))return()=>!1;const Ce=oe==="lt"?-1:oe==="lte"?0:oe==="gt"?1:2;return me=>{if(o(me))return!1;const we=be(me,Ae);return Ce===-1?we<0:Ce===0?we<=0:Ce===1?we>0:we>=0}}case"between":case"notBetween":{const Ae=z(ce.value),Ce=d(Ae[0],de),me=d(Ae[1],de),we=ce.bounds||"[]",ge=we.charAt(0)!=="(",Ne=we.charAt(1)!==")";if(o(Ce)||o(me))return oe==="between"?()=>!1:()=>!0;const Ie=He=>{if(o(He))return!1;const Ye=be(He,Ce),Oe=be(He,me);return(ge?Ye>=0:Ye>0)&&(Ne?Oe<=0:Oe<0)};return oe==="between"?Ie:Te(Ie)}case"in":case"notIn":{const Ae=f(ce.value,he,de),Ce=me=>Ae.has(c(me,he));return oe==="in"?Ce:Te(Ce)}case"contains":case"notContains":{const Ae=m(d(ce.value,de),he),Ce=me=>me==null?!1:m(me,he).includes(Ae);return oe==="contains"?Ce:Te(Ce)}case"startsWith":{const Ae=m(d(ce.value,de),he);return Ce=>Ce==null?!1:m(Ce,he).startsWith(Ae)}case"endsWith":{const Ae=m(d(ce.value,de),he);return Ce=>Ce==null?!1:m(Ce,he).endsWith(Ae)}case"matches":{const Ae=p(ce.value,he);return Ae?Ce=>Ce==null?!1:Ae.test(String(Ce)):()=>!1}case"blank":return Ae=>x(Ae)||Array.isArray(Ae)&&Ae.length===0;case"notBlank":return Ae=>!(x(Ae)||Array.isArray(Ae)&&Ae.length===0);case"containsAny":case"containsNone":{const Ae=f(ce.value,he,de),Ce=me=>{const we=me==null?[]:z(me);for(let ge=0;ge<we.length;ge++)if(Ae.has(c(we[ge],he)))return!0;return!1};return oe==="containsAny"?Ce:Te(Ce)}case"containsAll":{const Ae=z(ce.value).map(Ce=>c(d(Ce,de),he));return Ce=>{const me=Ce==null?[]:z(Ce);if(Ae.length===0)return!0;const we=new Set(me.map(ge=>c(ge,he)));for(let ge=0;ge<Ae.length;ge++)if(!we.has(Ae[ge]))return!1;return!0}}default:{const Ae=fe(oe);return Ae?Ae.compile(ce.value):($(`op:${String(oe)}`,`unknown filter operator "${String(oe)}"; the condition is refused rather than matching every row`),()=>!1)}}}function C(ce,te,oe){return b(te,oe)(ce)}const T=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),L=new Set(["containsAny","containsAll","containsNone"]);function E(ce,te,oe){const he=ce&&ce.op,de=T[he]||he,be=b({...ce,op:de,type:te.type},oe),Te=te.items,Ae=Ce=>{const me=Te(Ce);if(!me)return!1;for(let we=0;we<me.length;we++)if(be(me[we]))return!0;return!1};return T[he]?Ce=>!Ae(Ce):Ae}function D(ce,te,oe,he){const de=A(ce);if(de){const Ae=te?1:0;for(let Ce=0;Ce<he;Ce++)oe[Ce]=de(Ce)===Ae?1:0;return oe}const be=ce.kind;if(be==="float64"||be==="int32"||be==="bitset")return n(oe,he,te?1:0);const Te=u(ce);for(let Ae=0;Ae<he;Ae++){const Ce=Te(Ae),me=x(Ce)||Array.isArray(Ce)&&Ce.length===0;oe[Ae]=me===te?0:1}return oe}function I(ce,te,oe,he){const de=ce.dict,be=B(de),Te=new Uint8Array(be);for(let we=0;we<be;we++)Te[we]=te(w(de,we))?1:0;const Ae=ce.values,Ce=A(ce);if(!Ce){for(let we=0;we<he;we++)oe[we]=Te[Ae[we]];return oe}const me=te(null)?1:0;for(let we=0;we<he;we++)oe[we]=Ce(we)===1?Te[Ae[we]]:me;return oe}function P(ce,te,oe,he){const de=H(ce.values),be=te(!0)?1:0,Te=te(!1)?1:0,Ae=A(ce);if(!Ae){for(let me=0;me<he;me++)oe[me]=de(me)===1?be:Te;return oe}const Ce=te(null)?1:0;for(let me=0;me<he;me++)oe[me]=Ae(me)===0?Ce:de(me)===1?be:Te;return oe}function k(ce,te,oe,he,de){const be=ce.values,Te=te.type,Ae=te.op;let Ce=!0;switch(Ae){case"eq":case"ne":{const we=i(d(te.value,Te)),ge=typeof te.value=="number"&&Number.isNaN(te.value),Ne=Ae==="ne"?1:0;if(ge)for(let Ie=0;Ie<de;Ie++)he[Ie]=(Number.isNaN(be[Ie])?1:0)^Ne;else for(let Ie=0;Ie<de;Ie++)he[Ie]=(be[Ie]===we?1:0)^Ne;break}case"lt":{const we=i(d(te.value,Te));for(let ge=0;ge<de;ge++)he[ge]=be[ge]<we?1:0;break}case"lte":{const we=i(d(te.value,Te));for(let ge=0;ge<de;ge++)he[ge]=be[ge]<=we?1:0;break}case"gt":{const we=i(d(te.value,Te));for(let ge=0;ge<de;ge++)he[ge]=be[ge]>we?1:0;break}case"gte":{const we=i(d(te.value,Te));for(let ge=0;ge<de;ge++)he[ge]=be[ge]>=we?1:0;break}case"between":case"notBetween":{const we=z(te.value),ge=i(d(we[0],Te)),Ne=i(d(we[1],Te)),Ie=te.bounds||"[]",He=Ie.charAt(0)!=="(",Ye=Ie.charAt(1)!==")",Oe=Ae==="notBetween"?1:0;if(He&&Ye)for(let Ve=0;Ve<de;Ve++)he[Ve]=(be[Ve]>=ge&be[Ve]<=Ne?1:0)^Oe;else if(He)for(let Ve=0;Ve<de;Ve++)he[Ve]=(be[Ve]>=ge&be[Ve]<Ne?1:0)^Oe;else if(Ye)for(let Ve=0;Ve<de;Ve++)he[Ve]=(be[Ve]>ge&be[Ve]<=Ne?1:0)^Oe;else for(let Ve=0;Ve<de;Ve++)he[Ve]=(be[Ve]>ge&be[Ve]<Ne?1:0)^Oe;break}case"in":case"notIn":{const we=new Set;for(const Ne of z(te.value)){const Ie=i(d(Ne,Te));Number.isNaN(Ie)||we.add(Ie)}const ge=Ae==="notIn"?1:0;for(let Ne=0;Ne<de;Ne++)he[Ne]=(we.has(be[Ne])?1:0)^ge;break}default:Ce=!1;break}if(!Ce)return!1;const me=A(ce);if(me){const we=oe(null)?1:0;for(let ge=0;ge<de;ge++)me(ge)===0&&(he[ge]=we)}return!0}function N(ce,te,oe,he){const de=u(ce);for(let be=0;be<he;be++)oe[be]=te(de(be))?1:0;return oe}function G(ce,te,oe){const he=te.count|0,de=oe||r(te,he);if(!ce)return n(de,he,1);const be=typeof te.handle=="function"?te.handle(ce.col):void 0,Te=typeof te.custom=="function"?te.custom:null;if(!be){if(Te){for(let we=0;we<he;we++)de[we]=Te(ce,we)?1:0;return de}return $(`filter:col:${String(ce.col)}`,`filter references unknown column "${String(ce.col)}"; the condition is refused rather than matching every row`),n(de,he,0)}const Ae=ce.op;if(Ae==="blank"||Ae==="notBlank")return D(be,Ae==="notBlank",de,he);const Ce=typeof te.itemwise=="function"?te.itemwise(ce.col):null;if(Ce&&!fe(Ae)&&!L.has(Ae))return N(be,E(ce,Ce,te.locale),de,he);const me=b(ce,te.locale);switch(be.kind){case"dictionary":return I(be,me,de,he);case"bitset":return P(be,me,de,he);case"float64":case"int32":return k(be,ce,me,de,he)?de:N(be,me,de,he);default:return N(be,me,de,he)}}function q(ce,te,oe){if(!ce)return n(r(te,oe),oe,1);if(Array.isArray(ce.conditions)){const he=ce.conditions.filter(Te=>Te!=null),de=ce.op==="or"?"or":ce.op==="not"?"not":"and";if(he.length===0)return n(r(te,oe),oe,1);const be=q(he[0],te,oe);for(let Te=1;Te<he.length;Te++){const Ae=q(he[Te],te,oe);if(de==="or")for(let Ce=0;Ce<oe;Ce++)be[Ce]|=Ae[Ce];else for(let Ce=0;Ce<oe;Ce++)be[Ce]&=Ae[Ce];t(te,Ae)}if(de==="not")for(let Te=0;Te<oe;Te++)be[Te]^=1;return be}return G(ce,te,r(te,oe))}function Y(ce,te){return q(ce,te,te.count|0)}function J(ce,te){if(!ce||!te)return ce||null;const oe=ce;if(Array.isArray(oe.conditions)){if((oe.op==="or"?"or":oe.op==="not"?"not":"and")!=="and")return ee(oe,te)?null:ce;const de=[];for(const be of oe.conditions){const Te=J(be,te);Te&&de.push(Te)}return de.length?{...oe,op:"and",conditions:de}:null}return oe.col===te?null:ce}function ee(ce,te){if(!ce||typeof ce!="object")return!1;const oe=ce;if(oe.col===te)return!0;if(Array.isArray(oe.conditions)){for(const he of oe.conditions)if(ee(he,te))return!0}return!1}function re(ce,te,oe){if(oe&&oe.length>=te){let Te=0;for(let Ae=0;Ae<te;Ae++)ce[Ae]&&(oe[Te++]=Ae);return oe.subarray(0,Te)}let he=0;for(let Te=0;Te<te;Te++)he+=ce[Te]?1:0;const de=new Uint32Array(he);let be=0;for(let Te=0;Te<te;Te++)ce[Te]&&(de[be++]=Te);return de}const ie=new Map;function ae(ce){if(!(!ce||typeof ce!="object"))for(const[te,oe]of Object.entries(ce))oe&&typeof oe.compile=="function"&&ie.set(te,oe)}function fe(ce){return typeof ce=="string"?ie.get(ce):void 0}}),Fe("packages/core/src/columns/datatypes.js",function(e,K){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,z=Q.defaultCompare,$=Q.isNil,_=Q.isObject,X=Q.isFunction,W=Q.fail,V=Q.titleCase,H=K("packages/core/src/format/date.js"),B=H.toDate,w=H.toIsoDate,A=H.compareIso,u=K("packages/core/src/format/boolean.js").toTriState,a=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,r=K("packages/core/src/formula/index.js"),t=r.evaluateFormula,n=r.looksLikeFormula,d=K("packages/core/src/compute/filter.js").declareOperators,l=/^\d{4}-\d{2}-\d{2}$/;function i(E){return E.getHours()===0&&E.getMinutes()===0&&E.getSeconds()===0&&E.getMilliseconds()===0}const m=new Map;function c(E){const D=E||"",I=m.get(D);if(I)return I;const P={group:",",decimal:"."};try{for(const k of new Intl.NumberFormat(E||void 0).formatToParts(12345.6))k.type==="group"?P.group=k.value:k.type==="decimal"&&(P.decimal=k.value)}catch{}return m.set(D,P),P}const f=/\d\s*[*/^]\s*[\d.(]/;function s(E,D){if($(E))return null;let I=String(E).trim();if(I===""||I.startsWith("=")||f.test(I))return null;let P=1;I.startsWith("(")&&I.endsWith(")")&&(P=-1,I=I.slice(1,-1));const k=I.endsWith("%"),{group:N,decimal:G}=c(D);if(I=I.replace(/[\s\u00a0\u202f\u2009']/g,""),N&&N!=="."&&N!==","&&(I=I.split(N).join("")),I=I.replace(/[^0-9eE+\-.,]/g,""),G===","?I=I.split(".").join("").replace(",","."):I=I.split(",").join(""),I===""||I==="-"||I==="+")return null;const q=Number(I);return Number.isNaN(q)?null:P*(k?q/100:q)}function p(E,D){const I=$(E)||Number.isNaN(E)?null:Number(E),P=$(D)||Number.isNaN(D)?null:Number(D);return I===null?P===null?0:1:P===null||I<P?-1:I>P?1:0}function b(E,D){const I=u(E),P=u(D);return I===null?P===null?0:1:P===null?-1:I===P?0:I?1:-1}function S(E,D){const I=B(E),P=B(D);if(!I)return P?1:0;if(!P)return-1;const k=I.getTime(),N=P.getTime();return k<N?-1:k>N?1:0}const j=new Map;function y(E){const D=B(E.value);if(!D)return"";const I=E.locale||"";let P=j.get(I);return P||(P=new Intl.DateTimeFormat(E.locale||void 0,{dateStyle:"medium"}),j.set(I,P)),P.format(D)}const v={boolean:{base:"boolean",storage:"bitset",matches:E=>typeof E=="boolean",parse:E=>u(E.text),compare:b,format:E=>u(E.value)===null?"":u(E.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:E=>u(E)===null?"":String(u(E)),fromClipboard:E=>u(E)},number:{base:"number",storage:"float64",matches:E=>typeof E=="number"&&!Number.isNaN(E),parse:E=>{if(n(E.text)){const D=t(E.text,E);if(!D.ok)return null;const I=Number(D.value);return Number.isFinite(I)?I:null}return s(E.text,E.locale)},compare:p,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:E=>$(E)?"":String(E),fromClipboard:(E,D)=>s(E,D&&D.locale)},date:{base:"dateString",storage:"dictionary",matches:E=>typeof E=="string"&&l.test(E)&&!Number.isNaN(Date.parse(E))||E instanceof Date&&!Number.isNaN(E.getTime())&&i(E),parse:E=>w(E.text),compare:A,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:E=>w(E),toClipboard:E=>$(E)?"":String(E),fromClipboard:E=>w(E)},dateString:{base:"dateString",storage:"dictionary",matches:E=>typeof E=="string"&&l.test(E)&&!Number.isNaN(Date.parse(E)),parse:E=>w(E.text),compare:A,format:y,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:E=>w(E),toClipboard:E=>$(E)?"":String(E),fromClipboard:E=>w(E)},text:{base:"text",storage:"dictionary",matches:E=>typeof E=="string",parse:E=>E.text===""?null:String(E.text),compare:(E,D)=>$(E)?$(D)?0:1:$(D)?-1:x().compare(String(E),String(D)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:E=>$(E)?"":String(E),fromClipboard:E=>E},image:{base:"text",storage:"dictionary",parse:E=>E.text===""||E.text==null?null:String(E.text).trim(),compare:(E,D)=>$(E)?$(D)?0:1:$(D)?-1:x().compare(String(E),String(D)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:E=>$(E)?"":String(E),fromClipboard:E=>E},lookup:{base:"text",storage:"dictionary",parse:E=>{if(E.text===""||E.text==null)return null;const D=E.column&&E.column.lookup,I=D&&X(D.options)?D.options():null;if(!I)return E.text;const P=String(E.text),k=I.find(q=>String(q.id)===P);if(k)return k.id;const N=P.trim().toLowerCase(),G=I.find(q=>String(q.label).toLowerCase()===N);return G?G.id:E.text},compare:z,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:E=>$(E)?"":String(E),fromClipboard:E=>E},object:{base:"object",storage:"object",matches:E=>E!==null&&typeof E=="object"&&!(E instanceof Date),parse:E=>{try{return E.text===""?null:JSON.parse(E.text)}catch{return E.text}},compare:(E,D)=>z(E,D),format:E=>{const D=E.value;if($(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:E=>$(E)?"":typeof E=="string"?E:JSON.stringify(E),fromClipboard:E=>E}},R=["boolean","number","date","dateString","datetime","text","object"];function O(E,D,I,P){const k=I.get(E);if(k)return k;P.includes(E)&&W(`circular data type extends chain: ${[...P,E].join(" → ")}`);const N=D[E];N||W(`unknown data type "${E}"`);let G=null;N.extends&&(G=O(N.extends,D,I,[...P,E]));const q={...G||{},...N,name:E,defaults:{...G&&G.defaults||{},...N.defaults||{}}};return q.base||(q.base=G&&G.base||"text"),q.storage||(q.storage=G&&G.storage||"object"),I.set(E,q),q}function F(E,D){const I={...v,...a};if(D&&typeof D.dataType=="function"&&typeof D.names=="function")for(const k of D.names("dataType")){const N=D.dataType(k);N&&(I[k]=N)}if(_(E))for(const[k,N]of Object.entries(E))I[k]=N;const P=new Map;for(const k of R)O(k,I,P,[]);O("lookup",I,P,[]);for(const k of Object.keys(I))O(k,I,P,[]);for(const k of P.values())d(k.operators);return P}function C(E,D){if(E.base==="text"&&(!E.compare||E.compare===v.text.compare)){const I=x(D);return(P,k)=>$(P)?$(k)?0:1:$(k)?-1:I.compare(String(P),String(k))}return E.compare||z}function T(E,D){return D?E.multiStorage||"multi":E.storage||"object"}function L(E){return V(String(E).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Fe("packages/core/src/columns/infer.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return X}});const Q=K("packages/core/src/internal/util.js"),x=Q.infoOnce,z=Q.isNil,$=100;function _(W,V,H={}){const B=H.sampleSize??$,w=[];for(let A=0;A<W.length&&w.length<B;A++){const g=W[A];z(g)||typeof g=="number"&&Number.isNaN(g)||w.push(g)}if(w.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[A,g]of V){if(typeof g.matches!="function")continue;let u=!0;for(let h=0;h<w.length;h++)if(!g.matches(w[h])){u=!1;break}if(u)return{type:A,unanimous:!0,sampled:w.length}}return H.quiet||x(`infer:${H.colId||"?"}`,`column "${H.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:w.length}}function X(W,V,H,B,w={}){const A=w.sampleSize??$,g=[];for(let u=0;u<V.length&&g.length<A;u++){const h=H(V[u]);z(h)||typeof h=="number"&&Number.isNaN(h)||g.push(h)}return _(g,B,{...w,colId:W}).type}}),Fe("packages/core/src/columns/graph.js",function(e,K){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return B}});const Q=K("packages/core/src/internal/util.js"),x=Q.DEV,z=Q.fail,$=Q.isFunction,_=Q.warnOnce,X="*";function W(w){const A=w.value||{};if(!$(A.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const u=A.pure!==!1;return A.deps===X?{computed:!0,wholeRow:!0,deps:[],pure:u}:Array.isArray(A.deps)?{computed:!0,wholeRow:!1,deps:A.deps.slice(),pure:u}:(_(`deps:missing:${w.id}`,`computed column "${w.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:u})}function V(w){const A=new Map;for(const m of w)A.set(m.id,m);const g=new Map,u=new Map,h=new Set,a=new Set,r=new Set,t=new Set;for(const m of w){const c=W(m);if(!c.computed){g.set(m.id,[]);continue}a.add(m.id),(c.pure?r:t).add(m.id),c.wholeRow&&h.add(m.id);const f=[],s=[];for(const p of c.deps)(A.has(p)?f:s).push(p);g.set(m.id,f),s.length&&u.set(m.id,s)}for(const m of r)for(const c of g.get(m))t.has(c)&&z(`pure computed column "${m}" depends on impure column "${c}". Mark it \`value.pure: false\` or make the dependency pure.`);const n=[],o=new Map,d=[],l=m=>{const c=o.get(m);if(c!=="done"){if(c==="open"){const f=d.indexOf(m);z(`circular column dependency: ${[...d.slice(f),m].join(" → ")}`)}o.set(m,"open"),d.push(m);for(const f of g.get(m)||[])A.has(f)&&l(f);d.pop(),o.set(m,"done"),n.push(m)}};for(const m of w)l(m.id);const i=new Map;for(const m of w)i.set(m.id,[]);for(const m of w)for(const c of g.get(m.id)||[]){const f=i.get(c);f&&!f.includes(m.id)&&f.push(m.id)}if(h.size)for(const m of w){if(a.has(m.id))continue;const c=i.get(m.id);for(const f of h)c.includes(f)||c.push(f)}return{order:n,dependents:i,pure:r,impure:t,computed:a,deps:g,wholeRow:h,external:u,index:A}}function H(w,A){const g=Array.isArray(A)?A:[A],u=new Set,h=[...g];for(;h.length;){const a=h.shift();for(const r of w.dependents.get(a)||[])u.has(r)||(u.add(r),h.push(r))}for(const a of g)u.delete(a);return w.order.filter(a=>u.has(a))}function B(w,A,g){if(!x)return w;const u=A instanceof Set?A:new Set(A);return new Proxy(w,{get(h,a){return typeof a=="string"&&!u.has(a)&&!Object.hasOwn(h,a)&&_(`undeclared:${g}:${a}`,`computed column "${g}" read undeclared dependency "${a}". Add it to \`value.deps\` or the value will go stale.`),h[a]}})}}),Fe("packages/core/src/model/rowkey.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return h}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.pathGetter,$=Q.isFunction,_=Q.isBlank,X=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],W="";function V(a){if(a===null)return"\0n";if(a===void 0)return"\0u";const r=typeof a;if(r==="string")return a;if(r==="number"||r==="bigint"||r==="boolean")return String(a);if(a instanceof Date)return`\0d${a.getTime()}`;try{return`\0o${JSON.stringify(a)}`}catch{return"\0o?"}}function H(a){if(a.length===1)return V(a[0]);let r="";for(let t=0;t<a.length;t++)t&&(r+=W),r+=V(a[t]);return r}function B(a,r={}){const t=r.warn!==!1;if($(a)){const n=a;return{stable:!0,fields:[],disabled:[],key(o,d){try{const l=n(o);return Array.isArray(l)?H(l):V(l)}catch(l){return x("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",l),`#${d??-1}`}},keyEmpty(o){try{const d=n(o);return Array.isArray(d)?d.length===0||d.some(_):_(d)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(a)&&a.length>0){const n=a.filter(l=>typeof l=="string"),o=n.map(l=>z(l)),d=o.length;return{stable:!0,fields:n,disabled:[],key(l){const i=new Array(d);for(let m=0;m<d;m++)i[m]=o[m](l);return H(i)},keyEmpty(l){for(let i=0;i<d;i++)if(_(o[i](l)))return!0;return!1},missingFields(l){const i=[];for(let m=0;m<d;m++)_(o[m](l))&&i.push(n[m]);return i}}}if(typeof a=="string"&&a.length>0){const n=z(a);return{stable:!0,fields:[a],disabled:[],key(o){return V(n(o))},keyEmpty(o){return _(n(o))},missingFields(o){return _(n(o))?[a]:[]}}}return t&&x("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${X.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:X.slice(),key(n,o){if(n===null||typeof n!="object")return`#${o??0}:${String(n)}`;let d=w.get(n);return d===void 0&&(d=`#${A++}`,w.set(n,d)),d}}}const w=new WeakMap;let A=0;function g(a,r){if(!a||a.stable===!1||!$(a.keyEmpty)||!Array.isArray(r)||r.length===0)return;let t=0,n=null,o;for(let m=0;m<r.length;m++){const c=r[m];a.keyEmpty(c)&&(t++,n===null&&(n=$(a.missingFields)?a.missingFields(c):[],o=c))}if(t===0)return;const d=a.fields.length?a.fields.join(","):"(function)",l=n&&n.length?n.join(", "):a.fields.length?a.fields.join(", "):"the rowKey function",i=o!==null&&typeof o=="object"?Object.keys(o).join(", ")||"(no fields)":String(o);x(`rowKey.emptyValue:${d}`,`rowKey ${l} is missing on ${t} of ${r.length} rows; the first such row has: ${i}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function u(a){return H(a)}function h(a){return a.split(W)}}),Fe("packages/core/src/columns/lookup.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,z=Q.defaultCompare,$=Q.isFunction,_=Q.isNil,X=Q.warnOnce,V=K("packages/core/src/model/rowkey.js").compositeKey,H=", ",B="";function w(r,t,n,o){if(r===null||typeof r!="object")return{id:r,label:r==null?"":String(r)};const d=r[t],l=r[n],i={id:d,label:l==null?String(d??""):String(l)};r.disabled&&(i.disabled=!0),r.variant&&(i.variant=r.variant),r.icon&&(i.icon=r.icon);const m=o?r[o]:r.group;return m!==void 0&&(i.group=m),i}function A(r,t,n=0,o=[],d=[]){for(const l of r||[]){const i=l&&typeof l=="object"?l[t]:null;if(d.push({raw:l,depth:n,path:o}),Array.isArray(i)&&i.length){const m=String(l&&typeof l=="object"?l.label??l.name??l.id??"":l);A(i,t,n+1,[...o,m],d)}}return d}function g(r){return!!r&&typeof r=="object"&&!Array.isArray(r)&&$(r.router&&r.router.subscribe)}class u{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;#d=null;#h=new Map;constructor(t,n={}){this.#e=t||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#c=x(this.#n),Array.isArray(this.#e.options)?this.#f(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??H}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(t){this.#n=t,this.#c=x(t)}#f(t){const n=this.#e,o=n.valueKey||"id",d=n.labelKey||"label",l=n.childrenKey||"children";this.#o=A(t,l).map(i=>{const m=w(i.raw,o,d,n.groupKey);return i.depth&&(m.depth=i.depth,m.path=i.path),m}),this.#i=new Map,this.#s=new Map,this.#o.forEach((i,m)=>{this.#i.set(i.id,i),this.#s.set(i.id,m)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const t=this.#e.options;if(Array.isArray(t)||t===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(g(t))return this.#u=this.#p(t),this.#u;if(!$(t))return X(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let n;try{n=t()}catch(o){return this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),this.#u=Promise.resolve([]),this.#u}return!n||!$(n.then)?(this.#f(n),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=n.then(o=>(this.#f(o),this.#r&&this.#r(this),this.#o),o=>(this.#a="error",X(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,o),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#f(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}#p(t){if(this.#d)return Promise.resolve(this.#o);const n=this.#e,o=n.valueKey||"id",d=n.labelKey||"label",l=n.groupKey,i=$(t.map)?t.map:null,m=f=>w(i?i(f):f,o,d,l).id,c=f=>this.#m(f,i,o,d,l);return t.router.subscribe(t.predicate,c,{rowKey:m}),this.#d=()=>{$(t.router.detach)&&t.router.detach(c)},this.#a="ready",Promise.resolve(this.#o)}#m(t,n,o,d,l){const i=t&&t.add||[],m=t&&t.update||[],c=t&&t.remove||[];if(!(!i.length&&!m.length&&!c.length)){for(const f of i)this.#g(f,n,o,d,l);for(const f of m)this.#g(f,n,o,d,l);for(const f of c){if(!this.#h.has(f))continue;const s=this.#h.get(f);this.#h.delete(f),this.#i.delete(s);const p=this.#o.findIndex(b=>b.id===s);p>=0&&this.#o.splice(p,1)}this.#s=new Map(this.#o.map((f,s)=>[f.id,s])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(t,n,o,d,l){const i=w(n?n(t):t,o,d,l);this.#h.set(V([i.id]),i.id);const m=this.#o.findIndex(c=>c.id===i.id);m>=0?this.#o[m]=i:this.#o.push(i),this.#i.set(i.id,i)}destroy(){this.#d&&(this.#d(),this.#d=null)}search(t,n){const o=this.#e;if(!$(o.search)){const i=String(t||"").toLowerCase();return Promise.resolve(i===""?this.#o:this.#o.filter(m=>m.label.toLowerCase().includes(i)))}const d=o.valueKey||"id",l=o.labelKey||"label";return Promise.resolve(o.search(t,n)).then(i=>(i||[]).map(m=>w(m,d,l,o.groupKey)))}option(t){return this.#i.get(t)}has(t){return this.#i.has(t)}label(t){if(_(t)||t==="")return"";const n=this.#i.get(t);if(n)return n.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||X(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(t)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const o=this.#e.unknownLabel;return $(o)?String(o(t)??""):typeof o=="string"?o:String(t)}text(t){if(this.multiple){const n=h(t);return n.length===0?"":n.map(o=>this.label(o)).join(this.separator)}return this.label(t)}dictionary(){return this.#o.map(t=>t.id)}sorted(){const t=this.sortBy;if(t==="optionOrder"||t==="count")return this.#o.slice();if(t==="value")return this.#o.slice().sort((o,d)=>z(o.id,d.id));const n=this.#c;return this.#o.slice().sort((o,d)=>n.compare(o.label,d.label))}comparator(){const t=this.sortBy,n=this.multiple,o=this.#c,d=this.#s;if(n&&t==="count")return(i,m)=>h(i).length-h(m).length;const l=n?i=>h(i)[0]:i=>i;return t==="value"?(i,m)=>z(l(i),l(m)):t==="optionOrder"?(i,m)=>{const c=d.has(l(i))?d.get(l(i)):Number.MAX_SAFE_INTEGER,f=d.has(l(m))?d.get(l(m)):Number.MAX_SAFE_INTEGER;return c-f}:(i,m)=>{const c=l(i),f=l(m);return _(c)?_(f)?0:1:_(f)?-1:o.compare(this.label(c),this.label(f))}}groupKey(t){return this.multiple?h(t).map(o=>String(o)).sort().join(B):_(t)?"":String(t)}countValues(t){return this.multiple?h(t).length:_(t)?0:1}contains(t,n,o){const d=this.multiple?h(t):_(t)?[]:[t],l=Array.isArray(n)?n:[n];switch(o){case"containsAll":return l.every(i=>d.includes(i));case"containsNone":return!l.some(i=>d.includes(i));default:return l.some(i=>d.includes(i))}}exportText(t,n="label"){return n==="value"?this.multiple?h(t).join(this.separator):_(t)?"":String(t):this.text(t)}exportColumns(){const t=this.multiple;return this.#o.map(n=>({id:n.id,label:n.label,has:o=>t?h(o).includes(n.id):o===n.id}))}}function h(r){return Array.isArray(r)?r:_(r)||r===""?[]:[r]}function a(r,t={}){const n=r.lookup;if(!n)return null;const o=new u(n,{colId:r.id,locale:t.locale,onChange:t.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&o.load(),o}}),Fe("packages/core/src/columns/value.js",function(e,K){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.getPath,z=Q.isFunction,$=Q.isNil,_=Q.Lru,X=Q.warnOnce,V=K("packages/core/src/columns/graph.js").depsProxy,H="\0";function B(r,t={}){const n=t.locale,o=t.grid??null,d=t.context,l=r.value&&r.value.format,i=r.formatter||null,m=r.dataType&&r.dataType.format,c=r.lookup||null,f=(s,p,b)=>({value:s,data:b,row:p,column:r,colId:r.id,grid:o,context:d,locale:n});if(z(l))return(s,p,b)=>{const S=l(f(s,p,b));return S==null?"":String(S)};if(i){if(c){const s=i.kind==="text";return(p,b,S)=>i(s?c.text(p):p,f(p,b,S))}return(s,p,b)=>i(s,f(s,p,b))}return z(m)?(s,p,b)=>{const S=m(f(s,p,b));return S==null?"":String(S)}:c?s=>c.text(s):s=>$(s)?"":typeof s=="string"?s:String(s)}function w(r,t){!r||!r.value||r.value.pure!==!1||X(`impure:${t}:${r.id}`,`column "${r.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${t}. The result is not stable across passes.`)}class A{#e;#t;#n;#r;#o;#i;#s=new _(4096);constructor(t){this.#e=t.columns instanceof Map?t.columns:new Map((t.columns||[]).map(n=>[n.id,n])),this.#t=t.graph,this.#n=t.grid??null,this.#r=t.context,this.#i=t.stored||null,this.#o=t.rowKey||g}get graph(){return this.#t}setGraph(t){this.#t=t,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(t){if(this.#s.size===0)return;const n=t&&t.rows?new Set([...t.rows].map(String)):null,o=t&&t.columns?[...t.columns]:null;if(!n&&!o){this.#s.clear();return}const d=o?this.#l(o):null;for(const l of[...this.#s.keys()]){const i=String(l).split(H);i.length===3&&(n&&!n.has(i[0])||d&&!d.has(i[2])||this.#s.delete(l))}}#l(t){const n=new Set,o=this.#t,d=[...t];for(;d.length;){const l=d.pop();if(!n.has(l)){n.add(l);for(const i of o?o.dependents.get(l)||[]:[])d.push(i)}}return n}value(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;if(!d)return;if(!d.computed)return this.#u(d,n,o);if(d.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(d.id))return this.#i.get(d.id,o.physical);if(d.volatile)return this.compute(d,n,o);if(d.value.pure===!1)return this.compute(d,n,o);const l=`${this.#a(n,o)}${H}${d.id}`;if(this.#s.has(l))return this.#s.get(l);const i=this.compute(d,n,o);return this.#s.set(l,i),i}#a(t,n){return`${this.#o(t,n)}${H}${u(t)}`}#u(t,n,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(t.id))return this.#i.get(t.id,o.physical);if(t.field)return t.read?t.read(n):x(n,t.field)}compute(t,n,o){const d=this.#t,l=d&&d.wholeRow.has(t.id);let i;if(l)i=n??{};else{i={};const c=d&&d.deps.get(t.id)||[];for(const s of c)i[s]=this.value(s,n,o);const f=d&&d.external.get(t.id)||[];for(const s of f)i[s]=x(n,s);i=V(i,[...c,...f],t.id)}const m={data:n,row:o,column:t,grid:this.#n,context:this.#r};return t.value.compute(i,m)}values(t,n){const o={},d=this.#t?this.#t.order:[...this.#e.keys()];for(const l of d)o[l]=this.value(l,t,n);return o}text(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;return d?d.formatValue(this.value(d,n,o),o,n):""}key(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;if(!d)return"";const l=this.value(d,n,o);return z(d.value.key)?String(d.value.key(this.#c(d,l,n,o))):d.lookup?d.lookup.groupKey(l):$(l)?"":String(l)}quickFilterText(t,n,o){const d=typeof t=="string"?this.#e.get(t):t;if(!d)return"";if(z(d.value.quickFilterText)){const l=this.value(d,n,o);return String(d.value.quickFilterText(this.#c(d,l,n,o))??"")}return this.text(d,n,o)}#c(t,n,o,d){return{value:n,data:o,row:d,column:t,colId:t.id,grid:this.#n,context:this.#r}}parse(t,n,o,d){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return n;const i={text:n,value:this.value(l,o,d),data:o,row:d,column:l,grid:this.#n,context:this.#r,locale:this.#n&&z(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&z(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return z(l.value.parse)?l.value.parse(i):l.dataType&&z(l.dataType.parse)?l.dataType.parse(i):n}validate(t,n,o,d,l){const i=typeof t=="string"?this.#e.get(t):t;if(!i||!z(i.edit.validate))return!0;const m=i.edit.validate({value:n,oldValue:o,data:d,row:l,column:i,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(t,n,o,d){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return!1;const i=this.value(l,o,d);if(z(l.value.apply)){const m=l.value.apply({value:n,oldValue:i,data:o,row:d,column:l,grid:this.#n,context:this.#r});return this.#d(l,o,d),m!==!1}return l.field?i===n?!1:(l.write(o,n),this.#d(l,o,d),!0):(X(`apply:${l.id}`,`column "${l.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(t,n,o,d){const l=typeof t=="string"?this.#e.get(t):t;if(!l)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const i=this.value(l,o,d),m=this.parse(l,n,o,d),c=this.validate(l,m,i,o,d);if(c!==!0)return{ok:!1,value:m,oldValue:i,changed:!1,error:c};const f=this.apply(l,m,o,d);return{ok:!0,value:m,oldValue:i,changed:f}}#d(t,n,o){if(this.#s.size===0)return;const d=this.#a(n,o);this.#s.delete(`${d}${H}${t.id}`);for(const l of this.#t?this.#t.dependents.get(t.id)||[]:[])this.#s.delete(`${d}${H}${l}`)}}function g(r,t){return t&&t.key!=null?String(t.key):u(r)}function u(r){if(r&&typeof r=="object"){let t=h.get(r);return t===void 0&&(t=`#${a++}`,h.set(r,t)),t}return String(r)}const h=new WeakMap;let a=0}),Fe("packages/core/src/model/shadow.js",function(e,K){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return i}});const x=K("packages/core/src/internal/util.js").warnOnce,z=2e5,$=20,_=1e3,X=50;function W(m){return Math.min(_,Math.max(X,Math.floor(m)))}const V=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),H=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),B=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),w=.6745,A=3.5,g=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),u=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),h=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 a(m,c){if(!c)return null;const f=Number.isFinite(Number(c.lower))?Number(c.lower):null,s=Number.isFinite(Number(c.upper))?Number(c.upper):null;if(f===null&&s===null||!Number.isFinite(m))return null;if(f!==null&&m<f||s!==null&&m>s)return g.FAIL;const p=Number.isFinite(Number(c.warnLower))?Number(c.warnLower):null,b=Number.isFinite(Number(c.warnUpper))?Number(c.warnUpper):null;return p!==null&&m<p||b!==null&&m>b?g.WARN:g.PASS}function r(m,c,f){if(!c||typeof c!="object")return null;if(c.kind!=="time")return c.kind!==void 0&&x(`shadow.history.window.kind:${m}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${c.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const s=c.minutes!=null?Number(c.minutes)*6e4:Number(c.span);if(!(s>0))return x(`shadow.history.window.span:${m}`,"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 p=Math.max(2,Math.floor(f)||$);return{span:s,bucketMs:Math.max(1,Math.floor(s/p))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#h=new Map;#f=null;#p=null;#m=null;constructor(c){this.#e=c.colId,this.#a=Math.max(2,c.depth||$),this.#u=Math.max(1,c.max||z),this.#c=c.now||(()=>Date.now()),this.#d=r(this.#e,c.historyWindow,this.#a),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(c,f){const s=l(f);if(s===null)return;if(!this.#n.has(c)){this.#p=null,this.#m=null,this.#g(),this.#t.set(c,s),this.#n.set(c,s),this.#r.set(c,0),this.#o.set(c,this.#c()),this.#i.set(c,[s]),this.#d&&this.#h.set(c,[s]),this.#s.set(c,0);return}const p=this.#n.get(c);if(p===s)return;this.#p=null,this.#m=null,this.#n.set(c,s),this.#r.set(c,(this.#r.get(c)||0)+1),this.#o.set(c,this.#c());const b=this.#i.get(c)||[];b.push(s),b.length>this.#a&&b.splice(0,b.length-this.#a),this.#i.set(c,b);const S=Math.sign(s-p),j=this.#s.get(c)||0;this.#s.set(c,Math.sign(j)===S?j+S:S)}#g(){if(this.#n.size<this.#u)return;const c=this.#n.keys().next().value;c!==void 0&&(this.#t.delete(c),this.#n.delete(c),this.#r.delete(c),this.#o.delete(c),this.#i.delete(c),this.#h.delete(c),this.#s.delete(c),this.#l++)}rebase(){for(const[c,f]of this.#n)this.#t.set(c,f);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#s.clear(),this.#l=0,this.#p=null,this.#m=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(c){const f=c instanceof Set?c:new Set(c);let s=0;for(const p of[...this.#n.keys()])f.has(p)||(this.#t.delete(p),this.#n.delete(p),this.#r.delete(p),this.#o.delete(p),this.#i.delete(p),this.#h.delete(p),this.#s.delete(p),s++);return s&&(this.#p=null,this.#m=null),s}advanceHistoryWindow(c=this.#c()){const f=this.#d;if(!f)return 0;const s=Math.floor(c/f.bucketMs),p=s-this.#f;if(!(p>0))return 0;const b=Math.min(p,this.#a);for(const[S,j]of this.#h){const y=this.#n.get(S);for(let v=0;v<b;v++)j.push(y);j.length>this.#a&&j.splice(0,j.length-this.#a)}return this.#f=s,p}read(c,f,s,p){switch(c){case"updates":return this.#r.has(f)?this.#r.get(f):0;case"updatedAt":{const b=this.#o.get(f);return b===void 0?null:new Date(b)}case"sinceUpdate":{const b=this.#o.get(f);return b===void 0?null:this.#c()-b}case"firstValue":return this.#t.has(f)?this.#t.get(f):null;case"delta":return this.#n.has(f)?this.#n.get(f)-this.#t.get(f):null;case"deltaPercent":{if(!this.#n.has(f))return null;const b=this.#t.get(f);return b?(this.#n.get(f)-b)/Math.abs(b)*100:null}case"rate":{const b=this.#i.get(f),S=this.#o.get(f);if(!b||b.length<2||S===void 0)return null;const j=this.#c()-S,y=b[b.length-1]-b[b.length-2];return j>0?y/j*1e3:y}case"history":return this.#d?this.#h.has(f)?[...this.#h.get(f)]:null:this.#i.has(f)?[...this.#i.get(f)]:null;case"streak":return this.#s.has(f)?this.#s.get(f):0;case"specStatus":return this.#n.has(f)?a(this.#n.get(f),p):null;default:return u.includes(c)?this.#A(c,f,s,p):null}}#y(c){if(c){if(this.#m&&this.#m.only===c)return this.#m.view;const f=this.#b(c);return this.#m={only:c,view:f},f}return this.#p?this.#p:(this.#p=this.#b(null),this.#p)}#b(c){const f=[];for(const[F,C]of this.#n)c&&!c.has(F)||f.push(C);const s=f.sort((F,C)=>F-C);let p=0,b=0,S=0,j=0;for(const F of s){j+=F,p++;const C=F-b;b+=C/p,S+=C*(F-b)}const y=[];for(const[F,C]of this.#t)c&&!c.has(F)||y.push(C);const v=p?n(s):0,R=s.map(F=>Math.abs(F-v)).sort((F,C)=>F-C),O=p?n(R):0;return{sorted:s,baseline:y.sort((F,C)=>F-C),sum:j,mean:p?b:0,sd:p>1?Math.sqrt(S/(p-1)):0,median:v,mad:O}}#A(c,f,s,p){if(!this.#n.has(f)||s&&!s.has(f))return null;const b=this.#n.get(f),S=this.#y(s),j=S.sorted.length;if(!j)return null;switch(c){case"rank":return j-d(S.sorted,b)+1;case"rankAsc":return o(S.sorted,b)+1;case"rankChange":{if(!this.#t.has(f)||!S.baseline.length)return null;const y=S.baseline.length-d(S.baseline,this.#t.get(f))+1,v=j-d(S.sorted,b)+1;return y-v}case"percentile":return d(S.sorted,b)/j*100;case"quartile":{const y=d(S.sorted,b)/j;return Math.min(4,Math.max(1,Math.ceil(y*4)))}case"zScore":return S.sd?(b-S.mean)/S.sd:null;case"anomalyScore":return S.mad?w*(b-S.median)/S.mad:null;case"anomalyFlag":{if(!S.mad)return null;const y=p&&Number.isFinite(Number(p.threshold))?Number(p.threshold):A;return Math.abs(w*(b-S.median)/S.mad)>y}case"shareOfTotal":return S.sum?b/S.sum*100:null;default:return null}}}function n(m){const c=m.length;if(!c)return 0;const f=(c-1)*.5,s=Math.floor(f),p=Math.ceil(f);return s===p?m[s]:m[s]+(f-s)*(m[p]-m[s])}function o(m,c){let f=0,s=m.length;for(;f<s;){const p=f+s>>1;m[p]<c?f=p+1:s=p}return f}function d(m,c){let f=0,s=m.length;for(;f<s;){const p=f+s>>1;m[p]<=c?f=p+1:s=p}return f}function l(m){if(m==null||m==="")return null;if(m instanceof Date){const f=m.getTime();return Number.isFinite(f)?f:null}const c=typeof m=="number"?m:Number(m);return Number.isFinite(c)?c:null}function i(m){const c=[];for(const f of m||[]){const s=f.shadow;if(!s)continue;const p=typeof s=="string"?{kind:s}:s,b=p.kind;V.includes(b)&&(H.includes(b)||B.includes(b)||c.push({colId:f.id||f.field,of:p.of||f.field||f.id,kind:b,depth:p.depth,historyWindow:b==="history"?p.window:void 0}))}return c}}),Fe("packages/core/src/columns/model.js",function(e,K){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return ae}});const Q=K("packages/core/src/internal/util.js"),x=Q.expand,z=Q.fail,$=Q.getPath,_=Q.humanise,X=Q.isFunction,W=Q.isObject,V=Q.merge,H=Q.pathGetter,B=Q.pathSetter,w=Q.toArray,A=Q.uid,g=Q.warnOnce,h=K("packages/core/src/format/index.js").compileFormat,a=K("packages/core/src/columns/datatypes.js"),r=a.comparatorFor,t=a.createTypeRegistry,n=a.storageKind,o=K("packages/core/src/columns/infer.js"),d=o.inferColumnType,l=o.DEFAULT_SAMPLE,i=K("packages/core/src/columns/graph.js"),m=i.buildGraph,c=i.affectedBy,s=K("packages/core/src/columns/lookup.js").createLookup,p=K("packages/core/src/columns/value.js"),b=p.compileDisplay,S=p.ValuePipeline,j=p.warnImpureUse,v=K("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,R=Object.freeze({geometry:"geometry",list:"list"}),O={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},F={centre:"center"},C=new Set(["start","center","end","left","right"]);function T(ce){if(typeof ce!="string")return;const te=ce.toLowerCase();return F[te]?F[te]:C.has(te)?te:void 0}function L(ce){if(typeof ce!="string")return;const te=ce.toLowerCase();return te==="center"||te==="centre"?"middle":te==="top"||te==="middle"||te==="bottom"?te:void 0}const E=["cell","layout","header"];function D(ce){if(!W(ce))return{};const te={...ce},oe=(he,de)=>{if(ce[he]===void 0)return;const be=x(ce[he],de);be&&E.includes(he)&&!W(ce[he])&&delete be.enabled,te[he]=be};return oe("sort","direction"),oe("filter","type"),oe("cell","render"),oe("edit","editor"),oe("layout","width"),oe("group","index"),oe("pivot","index"),oe("header","render"),oe("facet","strategy"),te}function I(ce,te){const oe={...ce||{}},he=W(te)&&W(te.layout)&&te.layout.width!==void 0;return oe.fit==="content"&&!he&&delete oe.width,oe}const P=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),k=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function N(ce,te,oe,he){const de=oe==="columnGroup"?"column group":"column";for(const be of Object.keys(ce))if(!te.has(be)){if(be==="timeZone"&&oe==="column"){g("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${he}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}g(`${oe}.unknown:${be}`,`'${be}' is not a configuration key this grid recognises, so it had no effect on ${de} "${he}". Check the spelling against the reference.`)}}function G(ce){W(ce.cell)&&ce.cell.autoHeight!==void 0&&g("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${ce.id||ce.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function q(ce,te){const oe=te&&X(ce.defaultsFor)?ce.defaultsFor(te):null,he={...ce.defaults||{},...W(oe)?oe:{}},de={};return he.align&&(de.align=he.align,de.cell={align:he.align},de.header={align:he.align}),he.filter&&(de.filter=he.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:he.filter}),he.editor&&(de.edit=he.editor==="none"?{editor:null}:{editor:he.editor}),he.total&&(de.total=he.total),he.render&&(de.cell={...de.cell||{},render:he.render}),ce.export&&(de.export={...ce.export}),de}function Y(ce){if(typeof ce=="string")return ce.trim()?[ce.trim()]:[];if(!Array.isArray(ce))return[];const te=[];for(const oe of ce){if(typeof oe!="string")continue;const he=oe.trim();he&&!te.includes(he)&&te.push(he)}return te}class J{#e=new Map;#t=[];#n=[];#r=new WeakMap;#o;#i;#s;#l;#a;#u;#c(te,oe,he){const de=this.#d(te,oe,he);if(typeof de!="string"||!this.#h)return de??null;const be=oe&&oe.totals&&oe.totals.implement;if(be&&X(be[de])){const Ae=be[de];return Ae.totalName=de,Ae}const Te=this.#h.totalFn?.(de);return X(Te)?Te:de}#d(te,oe,he){if(typeof te!="string")return te;const de=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(de)||de.includes(te))return te;const be=de.length?de.join(", "):"none";return z(`column "${he}" is typed ${oe.name||"a type"}, for which the total "${te}" is not meaningful. Supported: ${be}. Aggregating it anyway would produce a confident wrong number.`),te}#h;#f;#p;#m;#g;#y;#b=!1;#A;#w;constructor(te={}){this.#i=D(te.columnDefaults||{}),this.#s=te.columnPresets||{},this.#a=te.locale,this.#l=te.timeZone,this.#u=L(te.verticalAlign),this.#h=te.registry||null,this.#f=te.grid||null,this.#p=te.context,this.#A=te.sampleSize??l,this.#w=te.onChange||null,this.#y=X(te.rowKey)?te.rowKey:void 0,this.#o=t(te.dataTypes,this.#h);const{leaves:oe,groups:he}=ae(te.columns||[]);this.#n=he;for(const de of oe){de.facet!==void 0&&this.#r.set(de.def,de.facet);const be=this.#S(de.def,null);if(be.groupPath=de.path,this.#e.has(be.id)){g(`columns.duplicate:${be.id}`,`two columns resolve to the id '${be.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}de.column=be,this.#e.set(be.id,be),this.#t.push(be.id)}this.#P(te.stored||null)}#S(te,oe){N(te,P,"column",te.id||te.field||"(unnamed)"),G(te);const he=D(te),de=w(te.preset),be=de.map(Oe=>{const Ve=this.#s[Oe];return Ve?D(Ve):(g(`preset:${Oe}`,`unknown column preset "${Oe}"; ignoring`),{})}),Te=this.#O(he,be,oe),Ae=this.#o.get(Te)||this.#o.get("text");if(!this.#o.has(Te)&&te.type){const Oe=R[Te];g(`type:${Te}`,`unknown data type "${Te}"; falling back to "text"`+(Oe?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${Oe}'.`:""))}const Ce=X(Ae.items)?this.#C(he,be,te.id||te.field||"(unnamed)"):null;let me=O;me=V(me,this.#i),te.type!==!1&&(me=V(me,q(Ae,Ce)));for(const Oe of be)me=V(me,Oe);this.#r.has(te)&&(me=V(me,D({facet:this.#r.get(te)}))),me=V(me,he);const we=me.edit;we&&we.editor&&we.enabled!==!0&&!X(we.enabled)&&(te.edit||{}).editor&&g(`column.editor-not-enabled:${te.id||te.field}`,`column '${te.id||te.field}' names the editor '${we.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const ge=te.id||te.field||A("col");if(te.shadow&&!X(me.value&&me.value.compute)){const Oe=typeof te.shadow=="string"?{kind:te.shadow}:te.shadow,Ve=Oe.of||te.field||ge,Ze=v.includes(Oe.kind),it=Ze?Oe.model||Oe:null,at=Ze&&it?[...Array.isArray(it.predictors)?it.predictors:[],it.response].filter(Boolean):null;me.value={...me.value||{},deps:at&&at.length?at:Oe.orderBy&&Oe.orderBy!==Ve?[Ve,Oe.orderBy]:[Ve],pure:!1,compute:(pt,bt)=>{const Ot=bt.grid&&bt.grid.statistics;if(!Ot)return null;const Et=bt.row&&bt.row.key||Ot.keyOf(bt.data);if(!Et)return null;if(Ze){if(!X(Ot.fitShadow))return null;const Mt=Oe.model?{...Oe.model,threshold:Oe.threshold}:Oe;return Ot.fitShadow(Oe.kind,Et,Mt)}return Ot.shadow(Ve,Oe.kind,Et,Oe.scope,Oe)}}}if(te.running&&!X(me.value&&me.value.compute)){const Oe=typeof te.running=="string"?{kind:te.running}:te.running,Ve=Oe.of||te.field||ge;me.value={...me.value||{},deps:[Ve],pure:!1,compute:(Ze,it)=>{const at=it.grid&&it.grid.statistics;if(!at||!X(at.running))return null;const pt=it.row&&it.row.key||at.keyOf(it.data);return pt?at.running(Ve,Oe.kind||"total",pt):null}},te.sort===void 0&&(me.sort={...me.sort||{},enabled:!1})}const Ne=te.field??(X(me.value&&me.value.compute)?null:te.id??null),Ie=X(me.value&&me.value.compute),He={id:ge,field:Ne,shadow:te.shadow||null,running:te.running||null,spec:te.spec||null,validation:te.validation||null,volatile:!!(te.shadow||te.running),title:me.title??_(Ne||ge),type:Ae.name,dataType:Ae,itemType:Ce,nullable:me.nullable!==!1,align:T(he.cell&&he.cell.align||he.align||me.cell&&me.cell.align||me.align||Ae.defaults&&Ae.defaults.align)||"start",verticalAlign:L(he.cell&&he.cell.verticalAlign||he.verticalAlign||me.cell&&me.cell.verticalAlign||me.verticalAlign)||this.#u,rowSpan:X(me.rowSpan)?me.rowSpan:null,colSpan:X(me.colSpan)?me.colSpan:null,value:{pure:!0,...me.value||{}},cell:{...me.cell||{}},edit:{...me.edit||{}},sort:{...me.sort||{}},filter:{...me.filter||{}},group:{enabled:!1,index:-1,explode:!1,...me.group||{}},pivot:{enabled:!1,index:-1,...me.pivot||{}},total:this.#c(me.total,Ae,te.id||te.field||"(unnamed)"),groupTotal:me.groupTotal===void 0?null:this.#c(me.groupTotal,Ae,te.id||te.field||"(unnamed)"),grandTotal:me.grandTotal===void 0?null:this.#c(me.grandTotal,Ae,te.id||te.field||"(unnamed)"),tags:Y(me.tags),typeOptions:me.typeOptions??null,...W(me[Te])?{[Te]:me[Te]}:{},layout:I(me.layout,he),header:{...me.header||{}},contextMenu:me.contextMenu===void 0?null:me.contextMenu,facet:{...me.facet||{}},export:{...me.export||{}},allowGroup:me.allowGroup!==!1,allowPivot:me.allowPivot!==!1,allowTotal:me.allowTotal!==!1,quickFilter:me.quickFilter!==!1,def:te,format:me.format,presets:de,inferred:oe!=null&&!te.type,computed:Ie,diff:te.diff===void 0?void 0:!!te.diff,read:Ne?H(Ne):null,write:Ne?B(Ne):null};He.cell.align=T(he.cell&&he.cell.align)||He.align,He.header.align=T(he.header&&he.header.align)||He.align;const Ye=me.lookup||null;return He.lookup=Ye?s({id:ge,lookup:Ye},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:ge})}}):null,He.group.explode&&He.lookup&&He.lookup.multiple&&g(`explode:${ge}`,`column "${ge}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(He),He}#v(te){te.formatter=h(te.format,te.dataType,this.#a,this.#l,te.id),te.formatValue=b(te,{locale:this.#a,grid:this.#f,context:this.#p}),te.itemCompare=te.itemType?r(te.itemType,this.#a):null,te.compare=X(te.value.compare)?te.value.compare:te.lookup?te.lookup.comparator():X(te.dataType.compareFor)?te.dataType.compareFor(te):r(te.dataType,this.#a),te.excel=te.formatter&&te.formatter.ooxml||te.dataType&&te.dataType.excel||"General",te.storeKind=n(te.dataType,!!(te.lookup&&te.lookup.multiple))}#C(te,oe,he){let de=W(te.typeOptions)?te.typeOptions:null;for(let Ce=oe.length-1;!de&&Ce>=0;Ce--)W(oe[Ce].typeOptions)&&(de=oe[Ce].typeOptions);!de&&W(this.#i.typeOptions)&&(de=this.#i.typeOptions);const be=de&&de.of!==void 0?de.of:"text",Te=typeof be=="string"?this.#o.get(be):void 0;return Te&&!X(Te.items)&&Te.storage!=="object"?Te:(g(`type:of:${String(be)}`,`column "${he}" names "${String(be)}" as its item type (typeOptions.of), which is not ${Te?"a scalar data type":"a known data type"}; its items are read as text.`),this.#o.get("text"))}#O(te,oe,he){if(te.type===!1)return"text";if(te.type)return te.type;for(let de=oe.length-1;de>=0;de--)if(oe[de].type)return oe[de].type;if(this.#i.type)return this.#i.type;if(te.shadow){const de=typeof te.shadow=="string"?te.shadow:te.shadow.kind;if(de==="fitInfluence")return"boolean";if(de==="fitPredicted"||de==="fitResidual"||de==="fitStdResidual"||de==="fitLeverage"||de==="fitCooksD"||de==="tsTrend"||de==="tsSeasonal"||de==="tsResidual"||de==="tsCoverage"||de==="tsSmoothed"||de==="tsSmoothingAlpha"||de==="tsSmoothingBeta")return"number"}return he||(te.lookup?"lookup":"text")}#P(te){const oe=this.all();this.#m=m(oe),this.#g?this.#g.setGraph(this.#m):this.#g=new S({columns:this.#e,graph:this.#m,grid:this.#f,context:this.#p,stored:te||null,rowKey:this.#y});const he=this.#g;for(const de of oe)de.getValue=(be,Te)=>he.value(de,be,Te)}all(){return this.#t.map(te=>this.#e.get(te))}visible(){return this.all().filter(te=>!te.layout.hidden)}get(te){return this.#e.get(te)}groups(){const te=oe=>{const he=[];for(const de of oe)Array.isArray(de.columns)?he.push({...de,columns:te(de.columns)}):de.column&&he.push(de.column);return he};return te(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#o}affectedBy(te){return c(this.#m,te)}value(te,oe,he){return this.#g.value(te,oe,he)}text(te,oe,he){return this.#g.text(te,oe,he)}checkImpure(te,oe){j(this.#e.get(te),oe)}setLocale(te){this.#a=te;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(te),this.#v(oe);this.#w&&this.#w("locale",{locale:te})}infer(te){const oe={};if(this.#b||!Array.isArray(te)||te.length===0)return oe;this.#b=!0;let he=!1;for(const de of this.all()){const be=de.def;if(be.type!==void 0||!de.field||de.computed||de.lookup||this.#M(de))continue;const Te=de.read||(me=>$(me,de.field)),Ae=d(de.id,te,Te,this.#o,{sampleSize:this.#A});if(Ae===de.type)continue;oe[de.id]=Ae;const Ce=this.#S(be,Ae);Ce.groupPath=de.groupPath,Ce.layout={...Ce.layout,...ee(de.layout)},this.#e.set(de.id,Ce),fe(this.#n,de.id,Ce),he=!0}return he&&this.#P(null),oe}redecorate(te,oe,he={}){const de=this.#e.get(te);if(!de){g(`redecorate:${te}`,`columns.decorate('${te}', …): no column with id '${te}'.`);return}const be=de.def||{},Te={...W(be.cell)?be.cell:{}};Te.decoration=oe??void 0,he&&"variant"in he&&(Te.variant=he.variant);const Ae={...be,cell:Te};this.#r.has(be)&&this.#r.set(Ae,this.#r.get(be));const Ce=this.#S(Ae,de.type);return Ce.groupPath=de.groupPath,Ce.layout={...Ce.layout,...ee(de.layout)},de.lookup&&de.lookup!==Ce.lookup&&X(de.lookup.destroy)&&de.lookup.destroy(),this.#e.set(te,Ce),fe(this.#n,te,Ce),this.#P(null),this.#w&&this.#w("decorate",{colId:te}),Ce}destroy(){for(const te of this.#e.values())te.lookup&&X(te.lookup.destroy)&&te.lookup.destroy()}#M(te){for(const oe of te.presets){const he=this.#s[oe];if(he&&he.type)return!0}return!!this.#i.type}#E(te){return!te.computed&&X(te.dataType&&te.dataType.toStorage)}storeReader(te){if(te.computed)return oe=>this.#g.value(te,oe,null);if(this.#E(te)){const oe=te.dataType.toStorage,he={timeZone:this.#l,colId:te.id,itemType:te.itemType||null};return de=>oe(te.read(de),he)}return te.read}storeValue(te,oe){if(!(!te||te.computed)&&X(te.read))return this.storeReader(te)(oe)}storeSchema(){const te=[];for(const oe of this.all()){if(oe.computed&&oe.value.pure===!1||!oe.computed&&!oe.field)continue;const he=this.storeReader(oe);let de=null;!oe.computed&&!this.#E(oe)&&typeof oe.field=="string"&&!oe.lookup&&(de=oe.field);const be={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:he};de!==null&&(be.field=de),oe.lookup&&(be.dictionary=oe.lookup.dictionary()),te.push(be)}return te}state(){return this.all().map(te=>({id:te.id,width:te.layout.width,flex:te.layout.flex||void 0,hidden:!!te.layout.hidden,pin:te.layout.pin??null,sort:te.sort.direction??null,sortIndex:te.sort.direction?te.sort.order??0:null,groupIndex:te.group.enabled?te.group.index??0:null,pivotIndex:te.pivot.enabled?te.pivot.index??0:null,total:typeof te.total=="string"?te.total:null,groupTotal:typeof te.groupTotal=="string"?te.groupTotal:void 0,grandTotal:typeof te.grandTotal=="string"?te.grandTotal:void 0,decoration:te.cell&&te.cell.decoration!=null?re(te.cell.decoration):void 0,variant:te.cell&&te.cell.variant!=null?re(te.cell.variant):void 0}))}applyState(te,oe={}){const he={applied:[],skipped:[]},de=Array.isArray(te)?te:te&&te.columns||[],be=!Array.isArray(te)&&te&&te.columnOrder||null;for(const Ae of de){if(!Ae||!Ae.id){he.skipped.push({key:"?",reason:"no id"});continue}let Ce=this.#e.get(Ae.id);if(!Ce){he.skipped.push({key:Ae.id,reason:"unknown column"});continue}if(Object.hasOwn(Ae,"decoration")||Object.hasOwn(Ae,"variant")){const me=Ce.cell?Ce.cell.decoration:void 0,we=Ae.decoration??null,ge=Object.hasOwn(Ae,"variant"),Ne=ge&&!ie(Ce.cell?Ce.cell.variant:void 0,Ae.variant);(!ie(me,we)||Ne)&&(this.redecorate(Ae.id,we,ge?{variant:Ae.variant??void 0}:{}),Ce=this.#e.get(Ae.id)||Ce)}Ae.width!=null&&(Ce.layout.width=Ae.width),Ae.flex!=null&&(Ce.layout.flex=Ae.flex),Ae.hidden!=null&&(Ce.layout.hidden=!!Ae.hidden),Ae.pin!==void 0&&(Ce.layout.pin=Ae.pin),Ae.sort!==void 0&&(Ce.sort.direction=Ae.sort),Ae.sortIndex!=null&&(Ce.sort.order=Ae.sortIndex),Ae.groupIndex!=null&&(Ce.group.enabled=!0,Ce.group.index=Ae.groupIndex),Ae.pivotIndex!=null&&(Ce.pivot.enabled=!0,Ce.pivot.index=Ae.pivotIndex),Ae.total!==void 0&&(Ce.total=Ae.total),Ae.groupTotal!==void 0&&(Ce.groupTotal=Ae.groupTotal),Ae.grandTotal!==void 0&&(Ce.grandTotal=Ae.grandTotal),he.applied.push(Ae.id)}const Te=be||(oe&&oe.keepOrder?[]:de.map(Ae=>Ae&&Ae.id).filter(Boolean));if(Te.length){const Ae=Te.filter(me=>this.#e.has(me)),Ce=this.#t.filter(me=>!Ae.includes(me));this.#t=[...Ae,...Ce]}return this.#w&&this.#w("state",he),he}move(te,oe){this.#T(te,oe)&&(this.#L(),this.#w&&this.#w("move",{id:te,to:oe}))}reorder(te){const oe={applied:[],skipped:[]},he=[];let de=0;for(const be of Array.isArray(te)?te:[]){const Te=de++;this.#T(be,Te)&&(oe.applied.push(be),he.push({id:be,to:Te}))}if(!he.length)return oe;if(this.#L(),this.#w)for(const be of he)this.#w("move",be);return oe}#T(te,oe){const he=this.#t.indexOf(te);if(he===-1||Math.max(0,Math.min(Number(oe)||0,this.#t.length-1))===he)return!1;const be=this.#e.get(te);if(be.layout.movable===!1||be.layout.lockPosition)return g(`move:${te}`,`column "${te}" is not movable; the move was ignored`),!1;const Te=this.#N(te,oe);return Te?(g(`move.married:${Te}`,`band "${Te}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(he,1),this.#t.splice(Math.max(0,Math.min(oe,this.#t.length)),0,te),!0)}#N(te,oe){if(!this.#n||!this.#n.length)return null;const he=this.#t.filter(Ae=>Ae!==te),de=Math.max(0,Math.min(oe,he.length)),be=(Ae,Ce)=>{if(Array.isArray(Ae.columns)){for(const we of Ae.columns)be(we,Ce);return Ce}const me=Ae.column?Ae.column.id:Ae.id;return me&&Ce.push(me),Ce},Te=Ae=>{for(const Ce of Ae){if(!Array.isArray(Ce.columns))continue;if(Ce.marryChildren===!0){const we=be(Ce,[]),ge=we.includes(te),Ne=we.map(Ie=>he.indexOf(Ie)).filter(Ie=>Ie>=0);if(Ne.length){const Ie=Math.min(...Ne),He=Math.max(...Ne);if(ge?de<Ie||de>He+1:de>Ie&&de<=He)return Ce.id}}const me=Te(Ce.columns);if(me)return me}return null};return Te(this.#n)}#L(){const te=new Map(this.#t.map((de,be)=>[de,be])),oe=de=>{if(!Array.isArray(de.columns)){const Te=de.column?de.column.id:de.id;return te.has(Te)?te.get(Te):1/0}let be=1/0;for(const Te of de.columns)be=Math.min(be,oe(Te));return be},he=de=>{de.sort((be,Te)=>oe(be)-oe(Te));for(const be of de)Array.isArray(be.columns)&&he(be.columns)};he(this.#n)}#B(te){const oe=he=>{for(let de=0;de<he.length;de++){const be=he[de];if(Array.isArray(be.columns)){const Te=oe(be.columns);if(Te)return Te}else if(be.column&&be.column.id===te)return he.splice(de,1)[0]}return null};return oe(this.#n)}#_(te){const oe=[];for(let he=te.length-1;he>=0;he--){const de=te[he];Array.isArray(de.columns)&&(oe.push(...this.#_(de.columns)),de.columns.length===0&&(oe.push(de.id),te.splice(he,1)))}return oe}#z(){const te=(oe,he,de)=>{for(const be of oe)Array.isArray(be.columns)?te(be.columns,[...he,be.id]):be.column&&(be.column.groupPath=he)};te(this.#n,[])}#$(te){const oe=new Set(te),he=this.#t.filter(Ae=>oe.has(Ae));if(!he.length)return;const de=Math.min(...he.map(Ae=>this.#t.indexOf(Ae))),be=this.#t.slice(0,de).filter(Ae=>!oe.has(Ae)),Te=this.#t.slice(de).filter(Ae=>!oe.has(Ae));this.#t=[...be,...he,...Te]}#q(te){const oe=[],he=de=>{if(Array.isArray(de.columns))for(const be of de.columns)he(be);else de.column&&oe.push(de.column.id)};return he(te),oe}#I(te){const oe=he=>{for(const de of he){if(!Array.isArray(de.columns))continue;if(de.id===te)return{node:de,parent:he};const be=oe(de.columns);if(be)return be}return null};return oe(this.#n)}groupColumns(te,oe={}){const he=w(te).filter(Ce=>this.#e.has(Ce));if(!he.length)return g("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const Ce of he)if(this.#e.get(Ce).layout.lockPosition)return g(`columns.group.locked:${Ce}`,`column "${Ce}" is position-locked and cannot be grouped.`),null;const de=oe.groupId?this.#I(oe.groupId):null;if(oe.groupId&&!de)return g(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let be=null;if(!de&&oe.id!=null&&(be=String(oe.id),this.#I(be)||this.#e.has(be)))return g(`columns.group.idtaken:${be}`,`band id "${be}" is already in use; nothing was grouped.`),null;const Te=he.map(Ce=>this.#B(Ce)).filter(Boolean);if(!Te.length)return null;let Ae;if(de)de.node.columns.push(...Te),Ae=de.node.id;else{const Ce={id:be||A("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Te},me=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(me,0,Ce),Ae=Ce.id}return this.#_(this.#n),this.#$(he),this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"formed",groupId:Ae,ids:he}),Ae}ungroupColumn(te){const oe=this.#e.get(te);if(!oe){g(`columns.ungroup.unknown:${te}`,`no column "${te}" to ungroup.`);return}const he=oe.groupPath||[];if(!he.length)return;const de=he[he.length-1],be=this.#I(de);if(!be)return;const Te=this.#B(te);if(!Te)return;const Ae=be.parent.indexOf(be.node);be.parent.splice(Ae+1,0,Te);const Ce=this.#_(this.#n),me=this.#q(be.node);if(me.length){this.#$(me);const we=Math.max(...me.map(Ne=>this.#t.indexOf(Ne))),ge=this.#t.filter(Ne=>Ne!==te);ge.splice(we+1,0,te),this.#t=ge}this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"removed",id:te,dissolved:Ce})}renameGroup(te,oe){const he=this.#I(te);if(!he){g(`columns.group.rename:${te}`,`no band "${te}" to rename.`);return}he.node.title=String(oe??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:te,title:he.node.title})}dissolveGroup(te){const oe=this.#I(te);if(!oe){g(`columns.group.dissolve:${te}`,`no band "${te}" to dissolve.`);return}const he=oe.parent.indexOf(oe.node);oe.parent.splice(he,1,...oe.node.columns),this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:te})}moveGroup(te,oe){const he=this.#I(te);if(!he){g(`columns.group.move:${te}`,`no band "${te}" to move.`);return}const de=he.parent,be=de.indexOf(he.node);be!==-1&&(de.splice(be,1),de.splice(Math.max(0,Math.min(oe,de.length)),0,he.node),this.#W(),this.#z(),this.#w&&this.#w("columngroup",{action:"moved",groupId:te,to:oe}))}#W(){const te=[],oe=de=>{for(const be of de)Array.isArray(be.columns)?oe(be.columns):be.column&&te.push(be.column.id)};oe(this.#n);const he=new Set(te);this.#t=[...te,...this.#t.filter(de=>!he.has(de))]}groupTree(){const te=he=>he.map(de=>Array.isArray(de.columns)?{id:de.id,title:de.title||"",collapsible:!!de.collapsible,openByDefault:de.openByDefault!==!1,columns:te(de.columns)}:de.column?de.column.id:null).filter(de=>de!==null),oe=te(this.#n);return oe.some(he=>he&&typeof he=="object")?oe:[]}applyGroupTree(te){if(!Array.isArray(te))return;const oe=new Set,he=be=>{const Te=[];for(const Ae of be)if(Ae&&typeof Ae=="object"&&Array.isArray(Ae.columns)){const Ce=he(Ae.columns);if(!Ce.length)continue;Te.push({id:Ae.id||A("grp"),title:Ae.title||"",collapsible:Ae.collapsible===!0,openByDefault:Ae.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Ce})}else if(typeof Ae=="string"){const Ce=this.#e.get(Ae);Ce&&!oe.has(Ae)&&(oe.add(Ae),Te.push({column:Ce,path:[]}))}return Te},de=he(te);for(const be of this.#t){if(oe.has(be))continue;const Te=this.#e.get(be);Te&&de.push({column:Te,path:[]})}this.#n=de,this.#z(),this.#L(),this.#w&&this.#w("columngroup",{action:"applied"})}show(te){this.#V(te,!1)}hide(te){this.#V(te,!0)}#V(te,oe){const he=[];for(const de of w(te)){const be=this.#e.get(de);if(be){if(oe&&be.layout.lockVisible){g(`lockVisible:${de}`,`column "${de}" is \`layout.lockVisible\` and cannot be hidden`);continue}be.layout.hidden!==oe&&(be.layout.hidden=oe,he.push(de))}}he.length&&this.#w&&this.#w("visible",{ids:he,hidden:oe})}pin(te,oe){const he=this.#e.get(te);he&&(he.layout.pin=oe??null,this.#w&&this.#w("pin",{id:te,side:he.layout.pin}))}pinMany(te){const oe={};for(const[de,be]of te){const Te=this.#e.get(de);Te&&(Te.layout.pin=be??null,oe[de]=Te.layout.pin)}const he=Object.keys(oe);he.length&&this.#w&&this.#w("pin",{ids:he,pins:oe})}#U(te,oe){const he=te.layout.min??0,de=te.layout.max;let be=Math.max(he,oe);return de!=null&&(be=Math.min(de,be)),te.layout.width=be,te.layout.flex=0,be}resize(te,oe){const he=this.#e.get(te);if(!he)return;if(he.layout.resizable===!1){g(`resize:${te}`,`column "${te}" is not resizable; the resize was ignored`);return}const de=this.#U(he,oe);this.#w&&this.#w("resize",{id:te,width:de})}resizeMany(te){const oe={};for(const[de,be]of te){const Te=this.#e.get(de);if(Te){if(Te.layout.resizable===!1){g(`resize:${de}`,`column "${de}" is not resizable; the resize was ignored`);continue}oe[de]=this.#U(Te,be)}}const he=Object.keys(oe);he.length&&this.#w&&this.#w("resize",{ids:he,widths:oe})}}function ee(ce){const te={};return ce.width!=null&&(te.width=ce.width),ce.hidden!=null&&(te.hidden=ce.hidden),ce.pin!==void 0&&(te.pin=ce.pin),te}function re(ce){if(ce===null||typeof ce!="object")return ce;try{return structuredClone(ce)}catch{}try{return JSON.parse(JSON.stringify(ce))}catch{return ce}}function ie(ce,te){const oe=ce??null,he=te??null;if(oe===he)return!0;if(oe===null||he===null)return!1;if(typeof oe!="object"||typeof he!="object")return oe===he;try{return JSON.stringify(oe)===JSON.stringify(he)}catch{return!1}}function ae(ce){const te=[],oe=(de,be,Te)=>{const Ae=[];for(const Ce of de){if(!W(Ce)){z("a column definition must be an object");continue}if(Array.isArray(Ce.columns)){N(Ce,k,"columnGroup",Ce.title||Ce.id||"(unnamed)");const me={id:Ce.id||A("grp"),title:Ce.title||"",collapsible:Ce.collapsible===!0,openByDefault:Ce.openByDefault!==!1,showWhen:Ce.showWhen||"always",marryChildren:Ce.marryChildren===!0,header:Ce.header||{},def:Ce,columns:[]};me.columns=oe(Ce.columns,[...be,me.id],Ce.facet!==void 0?Ce.facet:Te),Ae.push(me)}else{const me={def:Ce,path:be,facet:Te};te.push(me),Ae.push(me)}}return Ae},he=oe(ce,[],void 0);return{leaves:te,groups:he}}function fe(ce,te,oe){for(const he of ce){if(he.columns){if(fe(he.columns,te,oe))return!0;continue}if(he.column&&he.column.id===te)return he.column=oe,!0}return!1}}),Fe("packages/core/src/columns/autogroup.js",function(e,K){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return W}});const x=K("packages/core/src/internal/util.js").warnOnce,z="__lattice_group",$=240,_=.5;function X(V){const{columns:H,groupBy:B}=V,w=B.map(u=>H.get(u)).filter(Boolean),A=w.length?w.map(u=>u.title||u.id).join(" > "):"Group",g=V.config&&V.config.autoGroupColumnWidth||$;return{id:z,field:null,title:A,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:B.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:g,min:120,pin:V.config&&V.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(u,h){return h&&h.group?h.groupValue:null},formatValue(u,h){if(!h||!h.group)return"";if(h.grandTotal)return V.config&&V.config.grandTotalLabel||"Total";const a=w[Math.min(h.level||0,w.length-1)];return a&&typeof a.formatValue=="function"?a.formatValue(u,h):u==null?"":String(u)}}}function W(V,H,B){!V.length||B<100||H<B*_||x(`grouping.cardinality:${V.join(",")}`,`grouping by ${V.join(", ")} produced ${H} groups for ${B} 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.`)}}),Fe("packages/core/src/columns/selectcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q="__lattice_select",x=44;function z(_){const X=_.selection||{},W=_.config&&_.config.selectionColumnWidth||x;return{id:Q,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:W,min:W,max:W,pin:_.config&&_.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:X.headerCheckbox===!0,def:{},getValue(V,H){return H?H.selected:!1},formatValue(){return""}}}const $=z}),Fe("packages/core/src/columns/rownumbercolumn.js",function(e,K){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,z="__lattice_rownumber",$=40,_=9,X=22;function W(B){const w=String(Math.max(1,Math.trunc(Math.abs(B))||1)).length;return Math.max($,w*_+X)}function V(B){const w=B.rowNumbers,A=w&&typeof w=="object"?w:{},g=Number.isFinite(A.start)?A.start:1,u=Number.isFinite(A.width)?A.width:W((B.maxNumber||0)+g),h=x(B.rank)?B.rank:()=>null;return{id:z,field:null,title:typeof A.title=="string"?A.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:u,min:u,max:u,pin:"start",hidden:!1,resizable:A.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(a,r){const t=h(r);return t==null?null:t-1+g},formatValue(a){return a==null?"":String(a)}}}const H=V}),Fe("packages/core/src/model/detail.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=240,_=10;function X(H){if(!H)return null;const B=H===!0?{}:H;return B.enabled===!1?null:!x(B.rows)&&!B.render?(z("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:B.render||null,config:B.config||null,rows:x(B.rows)?B.rows:null,height:B.height??$,cacheLimit:Number.isFinite(B.cacheLimit)?Math.max(0,B.cacheLimit):_,isMaster:x(B.isMaster)?B.isMaster:null,target:B.target||null,onCreate:x(B.onCreate)?B.onCreate:null,path:typeof B.path=="string"?B.path:null}}class W{#e;#t=new Set;#n;#r=0;constructor(B){this.#e=B.config,this.#n=x(B.onChange)?B.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(B){if(!B||B.group||B.detail)return!1;const w=this.#e.isMaster;return w?!!w(B.data,B):!0}isOpen(B){return this.#t.has(B)}keys(){return[...this.#t]}activeKey(){for(const B of this.#t)return B;return null}heightOf(B){const w=this.#e.height;return x(w)?Number(w(B))||$:w==="auto"?$:Number(w)||$}open(B){return this.#t.has(B)?!1:(this.inline||this.#t.clear(),this.#t.add(B),this.#o(),!0)}close(B){return this.#t.delete(B)?(this.#o(),!0):!1}toggle(B){return this.#t.has(B)?(this.close(B),!1):(this.open(B),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(B){if(!this.#t.size||!x(B))return;let w=!1;for(const A of[...this.#t])B(A)||(this.#t.delete(A),w=!0);w&&this.#o()}signature(){return`${this.#r}`}set(B){this.#t.clear();const w=Array.isArray(B)?B:[];for(const A of this.inline?w:w.slice(0,1))this.#t.add(A);this.#o()}#o(){this.#r++,this.#n()}}const V=W}),Fe("packages/core/src/compute/special.js",function(e,K){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return a}});const Q=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),x=3e-12,z=1e-300;function $(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-$(1-r);const t=r-1;let n=.9999999999998099;const o=t+7.5;for(let d=0;d<Q.length;d++)n+=Q[d]/(t+d+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(o)-o+Math.log(n)}function _(r,t,n){const o=r+t,d=r+1,l=r-1;let i=1,m=1-o*n/d;Math.abs(m)<z&&(m=z),m=1/m;let c=m;for(let f=1;f<=300;f++){const s=2*f;let p=f*(t-f)*n/((l+s)*(r+s));m=1+p*m,Math.abs(m)<z&&(m=z),i=1+p/i,Math.abs(i)<z&&(i=z),m=1/m,c*=m*i,p=-(r+f)*(o+f)*n/((r+s)*(d+s)),m=1+p*m,Math.abs(m)<z&&(m=z),i=1+p/i,Math.abs(i)<z&&(i=z),m=1/m;const b=m*i;if(c*=b,Math.abs(b-1)<x)break}return c}function X(r,t,n){if(!(r>0)||!(t>0)||!Number.isFinite(n))return Number.NaN;if(n<=0)return 0;if(n>=1)return 1;const o=Math.exp($(r+t)-$(r)-$(t)+r*Math.log(n)+t*Math.log(1-n));return n<(r+1)/(r+t+2)?o*_(r,t,n)/r:1-o*_(t,r,1-n)/t}function W(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],n=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],o=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],d=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],l=.02425;let i,m,c;r<l?(i=Math.sqrt(-2*Math.log(r)),c=(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+1)):r<=1-l?(i=r-.5,m=i*i,c=(((((t[0]*m+t[1])*m+t[2])*m+t[3])*m+t[4])*m+t[5])*i/(((((n[0]*m+n[1])*m+n[2])*m+n[3])*m+n[4])*m+1)):(i=Math.sqrt(-2*Math.log(1-r)),c=-(((((o[0]*i+o[1])*i+o[2])*i+o[3])*i+o[4])*i+o[5])/((((d[0]*i+d[1])*i+d[2])*i+d[3])*i+1));const s=(.5*V(-c/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(c*c/2);return c-s/(1+c*s/2)}function V(r){const t=Math.abs(r),n=2/(2+t),o=4*n-2,d=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let l=0,i=0,m;for(let f=d.length-1;f>0;f--)m=i,i=o*i-l+d[f],l=m;const c=n*Math.exp(-t*t+.5*(d[0]+o*i)-l);return r>=0?c:2-c}function H(r){return .5*V(-r/Math.SQRT2)}function B(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const n=.5*X(t/2,.5,t/(t+r*r));return r>0?1-n:n}function w(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return W(r);let n=-1e4,o=1e4,d=W(r);const l=$(t/2)+$(.5)-$((t+1)/2);for(let i=0;i<60;i++){const m=B(d,t);m<r?n=d:o=d;const c=Math.exp(-((t+1)/2)*Math.log(1+d*d/t)-l)/Math.sqrt(t),f=c>0?(m-r)/c:0;if(Math.abs(f)<1e-12)break;const s=d-f;if(d=s>n&&s<o&&Number.isFinite(s)?s:(n+o)/2,o-n<1e-12)break}return d}function A(r,t){let n=r,o=1/r,d=o;for(let l=0;l<300&&(n+=1,d*=t/n,o+=d,!(Math.abs(d)<Math.abs(o)*x));l++);return o*Math.exp(-t+r*Math.log(t)-$(r))}function g(r,t){let n=t+1-r,o=1/z,d=1/n,l=d;for(let i=1;i<=300;i++){const m=-i*(i-r);n+=2,d=m*d+n,Math.abs(d)<z&&(d=z),o=n+m/o,Math.abs(o)<z&&(o=z),d=1/d;const c=d*o;if(l*=c,Math.abs(c-1)<x)break}return Math.exp(-t+r*Math.log(t)-$(r))*l}function u(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?A(r,t):1-g(r,t)}function h(r,t){return t>0?u(t/2,r/2):Number.NaN}function a(r,t){const n=h(r,t);return Number.isNaN(n)?Number.NaN:Math.min(1,Math.max(0,1-n))}}),Fe("packages/core/src/compute/linalg.js",function(e,K){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return X}});function Q(W){const V=W.length,H=Array.from({length:V},()=>new Array(V).fill(0));for(let B=0;B<V;B++)for(let w=0;w<=B;w++){let A=W[B][w];for(let g=0;g<w;g++)A-=H[B][g]*H[w][g];if(B===w){if(!(A>0))return null;H[B][w]=Math.sqrt(A)}else H[B][w]=A/H[w][w]}return H}function x(W,V){const H=W.length,B=new Array(H).fill(0);for(let A=0;A<H;A++){let g=V[A];for(let u=0;u<A;u++)g-=W[A][u]*B[u];B[A]=g/W[A][A]}const w=new Array(H).fill(0);for(let A=H-1;A>=0;A--){let g=B[A];for(let u=A+1;u<H;u++)g-=W[u][A]*w[u];w[A]=g/W[A][A]}return w}function z(W){const V=W.length,H=Array.from({length:V},()=>new Array(V).fill(0));for(let B=0;B<V;B++){const w=new Array(V).fill(0);w[B]=1;const A=x(W,w);for(let g=0;g<V;g++)H[g][B]=A[g]}return H}function $(W,V,H){const B=W.length,w=B?W[0].length:0,A=Array.from({length:w},()=>new Array(w).fill(0)),g=new Array(w).fill(0);for(let u=0;u<B;u++){const h=H?H[u]:1,a=W[u];for(let r=0;r<w;r++){const t=h*a[r];g[r]+=t*V[u];for(let n=r;n<w;n++)A[r][n]+=t*a[n]}}for(let u=0;u<w;u++)for(let h=0;h<u;h++)A[u][h]=A[h][u];return{xtwx:A,xtwy:g}}function _(W,V){return W.map(H=>H.reduce((B,w,A)=>B+w*V[A],0))}function X(W,V){let H=0;for(let B=0;B<W.length;B++){let w=0;for(let A=0;A<W.length;A++)w+=V[B][A]*W[A];H+=W[B]*w}return H}}),Fe("packages/core/src/compute/sketch.js",function(e,K){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});class Q{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(u){if(!Number.isFinite(u))return;this.#e++;const h=u-this.#t;this.#t+=h/this.#e,this.#n+=h*(u-this.#t)}merge(u){if(u.#e===0)return;if(this.#e===0){this.#e=u.#e,this.#t=u.#t,this.#n=u.#n;return}const h=this.#e+u.#e,a=u.#t-this.#t;this.#t+=a*(u.#e/h),this.#n+=u.#n+a*a*(this.#e*u.#e/h),this.#e=h}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const u=this.variance();return u===null?null:Math.sqrt(u)}stddevP(){const u=this.varianceP();return u===null?null:Math.sqrt(u)}}class x{#e=[];#t=0;#n;#r;constructor(u,h=Math.random){if(!(u>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(u),this.#r=h}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(u){if(!Number.isFinite(u))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(u);return}const h=Math.floor(this.#r()*this.#t);h<this.#n&&(this.#e[h]=u)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let u=0;for(const h of this.#e)u+=h;return u/this.#e.length}quantile(u){const h=this.#e.length;if(!h)return null;const a=this.#e.slice().sort((o,d)=>o-d);if(h===1)return a[0];const r=(h-1)*Math.min(1,Math.max(0,u)),t=Math.floor(r),n=Math.ceil(r);return t===n?a[t]:a[t]+(r-t)*(a[n]-a[t])}}function z(g){return g^=g>>>16,g=Math.imul(g,2246822507),g^=g>>>13,g=Math.imul(g,3266489909),g^=g>>>15,g>>>0}function $(g){if(typeof g=="number"){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,g===0?0:g),z(a.getUint32(0)^a.getUint32(4))}const u=typeof g=="string"?g:String(g);let h=2166136261;for(let a=0;a<u.length;a++)h^=u.charCodeAt(a),h=Math.imul(h,16777619);return z(h)}class _{#e;#t;#n;constructor(u=14){const h=Math.floor(u);if(h<4||h>16)throw new RangeError("HLL precision must be 4..16");this.#e=h,this.#t=1<<h,this.#n=new Uint8Array(this.#t)}static errorBoundFor(u=14){const h=1<<Math.floor(u),a=1.04/Math.sqrt(h);return Object.freeze({kind:"probabilistic",metric:"relative",value:a,statement:`distinct count within ~${(a*100).toFixed(2)}% relative standard error (m=${h} buckets)`})}errorBound(){return _.errorBoundFor(this.#e)}add(u){const h=$(u),a=h&this.#t-1,r=h>>>this.#e|1<<32-this.#e;let t=1,n=r;for(;(n&1)===0;)t++,n>>>=1;t>this.#n[a]&&(this.#n[a]=t)}count(){const u=this.#t,h=32-this.#e,a=new Float64Array(h+2);for(let n=0;n<u;n++)a[this.#n[n]]++;let r=u*V(1-a[h+1]/u);for(let n=h;n>=1;n--)r=.5*(r+a[n]);r+=u*W(a[0]/u);const t=X*u*u/r;return Math.round(t)}}const X=.5/Math.log(2);function W(g){if(g===1)return 1/0;let u=1,h=g,a;do g*=g,a=h,h+=g*u,u+=u;while(h!==a);return h}function V(g){if(g===0||g===1)return 0;let u=1,h=1-g,a;do g=Math.sqrt(g),a=h,u*=.5,h-=(1-g)**2*u;while(h!==a);return h/3}class H{#e=new Map;#t;#n=0;constructor(u){if(!(u>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(u)}errorBoundFor(u){const h=u/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:h,statement:`each count overestimates the truth by at most N/m = ${h.toFixed(2)} (N=${u}, m=${this.#t})`})}get seen(){return this.#n}add(u){this.#n++;const h=this.#e.get(u);if(h){h.count++;return}if(this.#e.size<this.#t){this.#e.set(u,{count:1,error:0});return}let a,r=1/0;for(const[t,n]of this.#e)n.count<r&&(r=n.count,a=t);this.#e.delete(a),this.#e.set(u,{count:r+1,error:r})}top(u=this.#t){return[...this.#e.entries()].map(([a,r])=>({item:a,count:r.count,error:r.error})).sort((a,r)=>r.count-a.count).slice(0,Math.max(0,Math.floor(u)))}}class B{#e;#t=[[]];#n=0;#r;#o;constructor(u=200,h=Math.random){this.#e=Math.max(8,Math.floor(u)),this.#r=h,this.#o=2/3}static errorBoundFor(u=200){const h=1/Math.max(8,Math.floor(u));return Object.freeze({kind:"probabilistic",metric:"rank",value:h,statement:`queried quantile's true rank within ~${(h*100).toFixed(2)}% of N of the requested rank (k=${u})`})}errorBound(){return B.errorBoundFor(this.#e)}get count(){return this.#n}#i(u){const a=this.#t.length-1-u,r=Math.ceil(this.#e*this.#o**a);return Math.max(2,r)}add(u){Number.isFinite(u)&&(this.#n++,this.#t[0].push(u),this.#t[0].length>=this.#i(0)&&this.#s(0))}#s(u){const h=this.#t[u];h.sort((t,n)=>t-n),u+1>=this.#t.length&&this.#t.push([]);const a=this.#t[u+1],r=this.#r()<.5?0:1;for(let t=r;t<h.length;t+=2)a.push(h[t]);this.#t[u]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#s(t);return}}#l(){const u=[];for(let h=0;h<this.#t.length;h++){const a=1<<h;for(const r of this.#t[h])u.push({v:r,w:a})}return u}quantile(u){const h=this.#l();if(!h.length)return null;h.sort((n,o)=>n.v-o.v);let a=0;for(const n of h)a+=n.w;const r=Math.min(1,Math.max(0,u))*a;let t=0;for(const n of h)if(t+=n.w,t>=r)return n.v;return h[h.length-1].v}rank(u){let h=0;for(let a=0;a<this.#t.length;a++){const r=1<<a;for(const t of this.#t[a])t<=u&&(h+=r)}return h}}const w=Object.freeze({distinct:_.errorBoundFor(14),median:B.errorBoundFor(200),p25:B.errorBoundFor(200),p75:B.errorBoundFor(200),p90:B.errorBoundFor(200),p95:B.errorBoundFor(200),p99:B.errorBoundFor(200),iqr:B.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"})}),A={Welford:Q,Reservoir:x,HyperLogLog:_,SpaceSaving:H,KLL:B,hash32:$,SKETCH_BOUNDS:w}}),Fe("packages/core/src/compute/statistics.js",function(e,K){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return at}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return qe}});const Q=K("packages/core/src/compute/handle.js"),x=Q.presenceReader,z=Q.valueReader,$=K("packages/core/src/compute/special.js"),_=$.studentTQuantile,X=$.studentT,W=$.normalQuantile,V=$.normalCdf,H=$.chiSquareUpperTail,B=K("packages/core/src/compute/linalg.js"),w=B.cholesky,A=B.choleskySolve,g=B.choleskyInverse,u=B.normalEquations,h=B.quadForm,r=K("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,n=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:r.distinct}),median:Object.freeze({sketch:"KLL",bound:r.median}),p25:Object.freeze({sketch:"KLL",bound:r.p25}),p75:Object.freeze({sketch:"KLL",bound:r.p75}),p90:Object.freeze({sketch:"KLL",bound:r.p90}),p95:Object.freeze({sketch:"KLL",bound:r.p95}),p99:Object.freeze({sketch:"KLL",bound:r.p99}),iqr:Object.freeze({sketch:"KLL",bound:r.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK})});function d(ye){const ke=ye==="sum"||ye==="avg"||ye==="countValues"||ye==="min"||ye==="max"?"maintained":Object.prototype.hasOwnProperty.call(n,ye)?n[ye]:null,pe=Object.prototype.hasOwnProperty.call(o,ye)?o[ye]:null;return{stat:ye,exact:ke,approximate:pe}}function l(ye,ke){const pe=ke.length,Pe=new Float64Array(pe);let Me=0;if(ye&&(ye.kind==="float64"||ye.kind==="int32")){const De=ye.values,Se=x(ye);for(let xe=0;xe<pe;xe++){const Ue=ke[xe];if(Se&&Se(Ue)!==1)continue;const et=De[Ue];Number.isNaN(et)||(Pe[Me++]=et)}return Pe.subarray(0,Me)}const _e=z(ye);for(let De=0;De<pe;De++){const Se=_e(ke[De]);if(Se==null||Se==="")continue;const xe=typeof Se=="number"?Se:Number(Se);Number.isFinite(xe)&&(Pe[Me++]=xe)}return Pe.subarray(0,Me)}function i(ye,ke){const pe=new Map,Pe=z(ye);let Me=0;for(let _e=0;_e<ke.length;_e++){const De=Pe(ke[_e]);if(De==null||De===""||typeof De=="number"&&Number.isNaN(De))continue;const Se=typeof De=="object"?String(De):De;pe.set(Se,(pe.get(Se)||0)+1),Me++}const ze=[...pe.values()].sort((_e,De)=>De-_e);return{counts:ze,total:Me,distinct:ze.length}}function m(ye){return ye.total>0?ye.counts.map(ke=>ke/ye.total):[]}function c(ye,ke){const pe=i(ye,ke);if(!pe.total)return null;let Pe=0;for(const Me of m(pe))Pe+=Me*Me;return Pe}function f(ye,ke){const pe=i(ye,ke);if(!pe.total)return null;let Pe=0;for(const Me of m(pe))Me>0&&(Pe-=Me*Math.log2(Me));return Pe}function s(ye,ke){const pe=i(ye,ke);if(!pe.total||pe.distinct<2)return pe.total?1:null;let Pe=0;for(const Me of m(pe))Me>0&&(Pe-=Me*Math.log2(Me));return Pe/Math.log2(pe.distinct)}function p(ye,ke,pe=3){const Pe=i(ye,ke);if(!Pe.total)return null;const Me=Math.max(1,Math.floor(pe));let ze=0;for(let _e=0;_e<Math.min(Me,Pe.counts.length);_e++)ze+=Pe.counts[_e];return ze/Pe.total}function b(ye,ke){const pe=l(ye,ke),Pe=pe.length;if(!Pe)return null;const Me=pe.slice().sort();if(Me[0]<0)return null;let ze=0,_e=0;for(let De=0;De<Pe;De++)ze+=Me[De],_e+=(De+1)*Me[De];return ze===0?0:2*_e/(Pe*ze)-(Pe+1)/Pe}function S(ye){let ke=0,pe=0,Pe=0;for(let Me=0;Me<ye.length;Me++){const ze=ye[Me];ke++;const _e=ze-pe;pe+=_e/ke,Pe+=_e*(ze-pe)}return{n:ke,mean:pe,m2:Pe}}function j(ye,ke){const pe=ye.length;if(!pe)return NaN;if(pe===1)return ye[0];const Pe=(pe-1)*Math.min(1,Math.max(0,ke)),Me=Math.floor(Pe),ze=Math.ceil(Pe);return Me===ze?ye[Me]:ye[Me]+(Pe-Me)*(ye[ze]-ye[Me])}function y(ye,ke){if(!ye.length)return NaN;const pe=ye.slice().sort();return j(pe,ke)}function v(ye,ke){const pe=z(ye);let Pe=0,Me=0,ze=0;for(let _e=0;_e<ke.length;_e++){const De=pe(ke[_e]);if(De==null||De==="")continue;const Se=String(De).toUpperCase();Se==="PASS"?Pe++:Se==="FAIL"?Me++:Se==="WARN"&&ze++}return{pass:Pe+ze,fail:Me,warn:ze,judged:Pe+ze+Me}}const R=Object.freeze({hhi:(ye,ke)=>c(ye,ke),entropy:(ye,ke)=>f(ye,ke),evenness:(ye,ke)=>s(ye,ke),top3Share:(ye,ke)=>p(ye,ke,3),top10Share:(ye,ke)=>p(ye,ke,10),gini:(ye,ke)=>b(ye,ke),trimmedMean:(ye,ke)=>L(l(ye,ke),.1),winsorizedMean:(ye,ke)=>E(l(ye,ke),.1),robustOutliers:(ye,ke)=>D(l(ye,ke),3.5),jarqueBera:(ye,ke)=>I(l(ye,ke)),variance:(ye,ke)=>{const{n:pe,m2:Pe}=S(l(ye,ke));return pe>1?Pe/(pe-1):null},varianceP:(ye,ke)=>{const{n:pe,m2:Pe}=S(l(ye,ke));return pe>0?Pe/pe:null},stddev:(ye,ke)=>{const{n:pe,m2:Pe}=S(l(ye,ke));return pe>1?Math.sqrt(Pe/(pe-1)):null},stddevP:(ye,ke)=>{const{n:pe,m2:Pe}=S(l(ye,ke));return pe>0?Math.sqrt(Pe/pe):null},median:(ye,ke)=>{const pe=l(ye,ke);return pe.length?y(pe,.5):null},p25:(ye,ke)=>{const pe=l(ye,ke);return pe.length?y(pe,.25):null},p75:(ye,ke)=>{const pe=l(ye,ke);return pe.length?y(pe,.75):null},p90:(ye,ke)=>{const pe=l(ye,ke);return pe.length?y(pe,.9):null},p95:(ye,ke)=>{const pe=l(ye,ke);return pe.length?y(pe,.95):null},p99:(ye,ke)=>{const pe=l(ye,ke);return pe.length?y(pe,.99):null},iqr:(ye,ke)=>{const pe=l(ye,ke);if(!pe.length)return null;const Pe=pe.slice().sort();return j(Pe,.75)-j(Pe,.25)},mad:(ye,ke)=>{const pe=l(ye,ke);if(!pe.length)return null;const Pe=y(pe,.5),Me=new Float64Array(pe.length);for(let ze=0;ze<pe.length;ze++)Me[ze]=Math.abs(pe[ze]-Pe);return y(Me,.5)},range:(ye,ke)=>{const pe=l(ye,ke);if(!pe.length)return null;let Pe=1/0,Me=-1/0;for(let ze=0;ze<pe.length;ze++)pe[ze]<Pe&&(Pe=pe[ze]),pe[ze]>Me&&(Me=pe[ze]);return Me-Pe},distinct:(ye,ke)=>{const pe=z(ye),Pe=new Set;for(let Me=0;Me<ke.length;Me++){const ze=pe(ke[Me]);ze==null||ze===""||Pe.add(ze instanceof Date?ze.getTime():ze)}return Pe.size},mode:(ye,ke)=>{const pe=z(ye),Pe=new Map;for(let _e=0;_e<ke.length;_e++){const De=pe(ke[_e]);if(De==null||De==="")continue;const Se=De instanceof Date?De.getTime():De;Pe.set(Se,(Pe.get(Se)||0)+1)}let Me=null,ze=1;for(const[_e,De]of Pe)De>ze&&(ze=De,Me=_e);return Me},skewness:(ye,ke)=>{const pe=l(ye,ke),{n:Pe,mean:Me,m2:ze}=S(pe);if(Pe<3||ze<=0)return null;const _e=Math.sqrt(ze/(Pe-1));let De=0;for(let Se=0;Se<pe.length;Se++)De+=((pe[Se]-Me)/_e)**3;return Pe/((Pe-1)*(Pe-2))*De},kurtosis:(ye,ke)=>{const pe=l(ye,ke),{n:Pe,mean:Me,m2:ze}=S(pe);if(Pe<4||ze<=0)return null;const _e=Math.sqrt(ze/(Pe-1));let De=0;for(let Ue=0;Ue<pe.length;Ue++)De+=((pe[Ue]-Me)/_e)**4;const Se=Pe*(Pe+1)/((Pe-1)*(Pe-2)*(Pe-3)),xe=3*(Pe-1)**2/((Pe-2)*(Pe-3));return Se*De-xe},geomean:(ye,ke)=>{const pe=l(ye,ke);if(!pe.length)return null;let Pe=0;for(let Me=0;Me<pe.length;Me++){if(pe[Me]<=0)return null;Pe+=Math.log(pe[Me])}return Math.exp(Pe/pe.length)},harmean:(ye,ke)=>{const pe=l(ye,ke);if(!pe.length)return null;let Pe=0;for(let Me=0;Me<pe.length;Me++){if(pe[Me]===0)return null;Pe+=1/pe[Me]}return pe.length/Pe},sumSquares:(ye,ke)=>{const pe=l(ye,ke);let Pe=0;for(let Me=0;Me<pe.length;Me++)Pe+=pe[Me]*pe[Me];return Pe},passRate:(ye,ke)=>{const{pass:pe,judged:Pe}=v(ye,ke);return Pe?pe/Pe:null},failureCount:(ye,ke)=>v(ye,ke).fail}),O=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function F(ye,ke,pe){const Pe=z(ye),Me=z(ke);let ze=0,_e=0;for(let De=0;De<pe.length;De++){const Se=pe[De],xe=Number(Pe(Se)),Ue=Number(Me(Se));!Number.isFinite(xe)||!Number.isFinite(Ue)||(ze+=xe*Ue,_e+=Ue)}return _e===0?null:ze/_e}function C(ye,ke,pe){const Pe=z(ye);let Me=null,ze=pe?-1/0:1/0;for(let _e=0;_e<ke.length;_e++){const De=ke[_e],Se=Number(Pe(De));Number.isFinite(Se)&&(pe?Se>ze:Se<ze)&&(ze=Se,Me=De)}return Me}function T(ye,ke,pe){const Pe=z(ye),Me=z(ke);let ze=0,_e=0,De=0,Se=0,xe=0,Ue=0;for(let ot=0;ot<pe.length;ot++){const gt=pe[ot],vt=Number(Pe(gt)),ht=Number(Me(gt));!Number.isFinite(vt)||!Number.isFinite(ht)||(ze++,_e+=vt,De+=ht,Se+=vt*vt,xe+=ht*ht,Ue+=vt*ht)}if(ze<2)return null;const et=ze*Ue-_e*De,Je=Math.sqrt((ze*Se-_e*_e)*(ze*xe-De*De));if(Je===0)return null;const lt=et/Je;return Math.max(-1,Math.min(1,lt))}function L(ye,ke=.1){const pe=ye.length;if(!pe)return null;const Pe=Array.from(ye).sort((De,Se)=>De-Se),Me=Math.floor(pe*Math.min(.49,Math.max(0,ke))),ze=Pe.slice(Me,pe-Me);if(!ze.length)return j(Pe,.5);let _e=0;for(const De of ze)_e+=De;return _e/ze.length}function E(ye,ke=.1){const pe=ye.length;if(!pe)return null;const Pe=Array.from(ye).sort((Se,xe)=>Se-xe),Me=Math.floor(pe*Math.min(.49,Math.max(0,ke))),ze=Pe[Me],_e=Pe[pe-1-Me];let De=0;for(const Se of Pe)De+=Math.min(_e,Math.max(ze,Se));return De/pe}function D(ye,ke=3.5){if(!ye.length)return null;const Pe=Array.from(ye).sort((Se,xe)=>Se-xe),Me=j(Pe,.5),ze=Pe.map(Se=>Math.abs(Se-Me)).sort((Se,xe)=>Se-xe),_e=j(ze,.5);if(_e===0)return null;let De=0;for(const Se of Pe)Math.abs(.6745*(Se-Me)/_e)>ke&&De++;return De}function I(ye){const ke=ye.length;if(ke<8)return null;let pe=0;for(const Se of ye)pe+=Se;pe/=ke;let Pe=0,Me=0,ze=0;for(const Se of ye){const xe=Se-pe;Pe+=xe*xe,Me+=xe*xe*xe,ze+=xe*xe*xe*xe}if(Pe/=ke,Me/=ke,ze/=ke,Pe===0)return null;const _e=Me/Pe**1.5,De=ze/(Pe*Pe)-3;return ke/6*(_e*_e+De*De/4)}function P(ye,ke,pe){const Pe=[];let Me=0;for(let Se=0;Se<ye.length;Se++){const xe=Number(ye[Se]),Ue=Number(ke[Se]);!Number.isFinite(xe)||!Number.isFinite(Ue)||Ue<=0||(Pe.push([xe,Ue]),Me+=Ue)}if(!Pe.length||Me<=0)return null;if(Pe.sort((Se,xe)=>Se[0]-xe[0]),Pe.length===1)return Pe[0][0];const ze=[];let _e=0;for(const[,Se]of Pe)ze.push((_e+Se/2)/Me),_e+=Se;const De=Math.max(0,Math.min(1,pe));if(De<=ze[0])return Pe[0][0];if(De>=ze[ze.length-1])return Pe[Pe.length-1][0];for(let Se=1;Se<ze.length;Se++){if(De>ze[Se])continue;const xe=ze[Se]-ze[Se-1],Ue=xe>0?(De-ze[Se-1])/xe:0;return Pe[Se-1][0]+(Pe[Se][0]-Pe[Se-1][0])*Ue}return Pe[Pe.length-1][0]}function k(ye,ke,pe){const Pe=z(ye),Me=z(ke),ze=new Float64Array(pe.length),_e=new Float64Array(pe.length);let De=0;for(let Se=0;Se<pe.length;Se++){const xe=pe[Se],Ue=Number(Pe(xe)),et=Number(Me(xe));!Number.isFinite(Ue)||!Number.isFinite(et)||(ze[De]=Ue,_e[De]=et,De++)}return{xs:ze.subarray(0,De),ys:_e.subarray(0,De),n:De}}function N(ye,ke,pe,Pe=!1){const{xs:Me,ys:ze,n:_e}=k(ye,ke,pe);if(_e<2)return null;let De=0,Se=0;for(let Ue=0;Ue<_e;Ue++)De+=Me[Ue],Se+=ze[Ue];De/=_e,Se/=_e;let xe=0;for(let Ue=0;Ue<_e;Ue++)xe+=(Me[Ue]-De)*(ze[Ue]-Se);return xe/(Pe?_e:_e-1)}function G(ye,ke,pe){const{xs:Pe,ys:Me,n:ze}=k(ye,ke,pe);if(ze<2)return null;let _e=0,De=0;for(let vt=0;vt<ze;vt++)_e+=Pe[vt],De+=Me[vt];_e/=ze,De/=ze;let Se=0,xe=0,Ue=0;for(let vt=0;vt<ze;vt++){const ht=Pe[vt]-_e,Ct=Me[vt]-De;Se+=ht*ht,xe+=ht*Ct,Ue+=Ct*Ct}if(Se===0)return null;const et=xe/Se,Je=De-et*_e,lt=Ue===0?1:Math.max(0,Math.min(1,xe*xe/(Se*Ue))),ot=Math.max(0,Ue-et*xe),gt=ze>2?Math.sqrt(ot/(ze-2)/Se):0;return{slope:et,intercept:Je,r2:lt,stdError:gt,n:ze}}const q=new Set(["ols","wls","robust"]),Y=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),ee=1.345;function re(ye,ke,pe){const{xtwx:Pe,xtwy:Me}=u(ye,ke,pe),ze=w(Pe);if(!ze)return null;const _e=A(ze,Me),De=g(ze),Se=ie(ye,_e),xe=ke.map((Ue,et)=>Ue-Se[et]);return{beta:_e,cov:De,fitted:Se,residuals:xe}}function ie(ye,ke){return ye.map(pe=>pe.reduce((Pe,Me,ze)=>Pe+Me*ke[ze],0))}function ae(ye,ke){const pe=ye.length,Pe=ye.map(xe=>xe[ke]),Me=ye.map(xe=>[1,...xe.filter((Ue,et)=>et!==ke)]),ze=re(Me,Pe,null);if(!ze)return 1;const _e=Pe.reduce((xe,Ue)=>xe+Ue,0)/pe;let De=0,Se=0;for(let xe=0;xe<pe;xe++)De+=ze.residuals[xe]**2,Se+=(Pe[xe]-_e)**2;return Se===0?1:Math.max(0,Math.min(1,1-De/Se))}function fe(ye){const ke=[...ye].sort((Me,ze)=>Me-ze),pe=ce(ke),Pe=ye.map(Me=>Math.abs(Me-pe)).sort((Me,ze)=>Me-ze);return ce(Pe)/.6745}function ce(ye){const ke=ye.length;if(!ke)return 0;const pe=Math.floor(ke/2);return ke%2?ye[pe]:(ye[pe-1]+ye[pe])/2}function te(ye,ke,pe={}){const Pe=pe.method||"ols";if(J.has(Pe))throw new Error(`[lattice] regression method "${Pe}" is out of scope; use ols, wls or robust.`);if(Y.has(Pe))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!q.has(Pe))throw new Error(`[lattice] unknown regression method "${Pe}"; use ols, wls or robust.`);const Me=Array.isArray(ke)?ke.length:0,ze=Me&&Array.isArray(ye[0])?ye[0].length:0,_e=ze+1;if(!(Me>_e))return null;for(let jt=0;jt<Me;jt++){if(!Number.isFinite(ke[jt])||!Array.isArray(ye[jt])||ye[jt].length!==ze)return null;for(let $t=0;$t<ze;$t++)if(!Number.isFinite(ye[jt][$t]))return null}let De=null;if(Pe==="wls"){if(De=pe.weights,!Array.isArray(De)||De.length!==Me)return null;for(let jt=0;jt<Me;jt++)if(!(De[jt]>0)||!Number.isFinite(De[jt]))return null}const Se=ye.map(jt=>[1,...jt]);let xe,Ue=null;if(Pe==="robust"){if(xe=re(Se,ke,null),!xe)return null;for(let jt=0;jt<50;jt++){const $t=fe(xe.residuals);if(!($t>0))break;const Vt=xe.residuals.map(Yt=>{const Jt=Math.abs(Yt/$t);return Jt<=ee?1:ee/Jt}),Wt=re(Se,ke,Vt);if(!Wt)return null;const Qt=Wt.beta.reduce((Yt,Jt,on)=>Math.max(Yt,Math.abs(Jt-xe.beta[on])),0);if(xe=Wt,Ue=Vt,Qt<1e-10)break}}else if(xe=re(Se,ke,De),!xe)return null;const et=Pe==="robust"?Ue:De,{beta:Je,cov:lt,fitted:ot,residuals:gt}=xe;let vt=0,ht=0,Ct=0;for(let jt=0;jt<Me;jt++){const $t=et?et[jt]:1;vt+=$t*gt[jt]**2,ht+=$t,Ct+=$t*ke[jt]}const xt=Ct/ht;let Ge=0;for(let jt=0;jt<Me;jt++){const $t=et?et[jt]:1;Ge+=$t*(ke[jt]-xt)**2}const ft=Me-_e,st=vt/ft,ut=Ge===0?1:Math.max(0,Math.min(1,1-vt/Ge)),At=1-(1-ut)*(Me-1)/ft,Rt=Array.isArray(pe.names)&&pe.names.length===ze?pe.names:ye[0].map((jt,$t)=>`x${$t+1}`),yt=Et(pe.confidence),Lt=ft>0?_(1-(1-yt)/2,ft):1/0,Ut=Je.map((jt,$t)=>{const Vt=Math.sqrt(Math.max(0,st*lt[$t][$t])),Wt=Vt>0?jt/Vt:jt===0?0:1/0,Qt=Number.isFinite(Wt)?2*(1-X(Math.abs(Wt),ft)):0,Yt=Number.isFinite(Lt)?Lt*Vt:null;return{name:$t===0?"(intercept)":Rt[$t-1],estimate:jt,stdError:Vt,t:Wt,p:Math.max(0,Math.min(1,Qt)),lower:Yt===null?null:jt-Yt,upper:Yt===null?null:jt+Yt}}),tn=new Array(Me),an=new Array(Me);for(let jt=0;jt<Me;jt++){const $t=et?et[jt]:1,Vt=Math.max(0,Math.min(1,$t*h(Se[jt],lt)));tn[jt]=Vt;const Wt=(1-Vt)**2;an[jt]=Wt>0&&st>0?gt[jt]**2/(_e*st)*(Vt/Wt):null}const bn=ye[0].map((jt,$t)=>{if(ze<2)return 1;const Vt=ae(ye,$t);return Vt>=1?1/0:1/(1-Vt)});let ln=null;{const jt=gt.map(Vt=>Vt*Vt),$t=re(Se,jt,null);if($t){const Vt=jt.reduce((en,hn)=>en+hn,0)/Me;let Wt=0,Qt=0;for(let en=0;en<Me;en++)Wt+=$t.residuals[en]**2,Qt+=(jt[en]-Vt)**2;const Yt=Qt===0?0:Math.max(0,Math.min(1,1-Wt/Qt)),Jt=Me*Yt,on=H(Jt,ze);ln={statistic:Jt,df:ze,p:on,heteroscedastic:on<.05}}}let Zt=null;if(ze===1){const jt=ye.map(($t,Vt)=>Vt).sort(($t,Vt)=>ye[$t][0]-ye[Vt][0]);Zt={confidence:yt,points:jt.map($t=>{const Vt=Se[$t],Wt=Math.sqrt(Math.max(0,st*h(Vt,lt)));return{x:ye[$t][0],yhat:ot[$t],lower:ot[$t]-Lt*Wt,upper:ot[$t]+Lt*Wt}})}}return{method:Pe,coefficients:Ut,r2:ut,adjR2:At,n:Me,df:ft,sigma2:st,fitted:ot,residuals:gt,leverage:tn,cooksD:an,vif:bn,heteroscedasticity:ln,band:Zt,weights:et?[...et]:null}}function oe(ye){const ke=ye.length,pe=Array.from({length:ke},(ze,_e)=>_e).sort((ze,_e)=>ye[ze]-ye[_e]),Pe=new Float64Array(ke);let Me=0;for(;Me<ke;){let ze=Me;for(;ze+1<ke&&ye[pe[ze+1]]===ye[pe[Me]];)ze++;const _e=(Me+ze)/2+1;for(let De=Me;De<=ze;De++)Pe[pe[De]]=_e;Me=ze+1}return Pe}const he=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function de(ye){const ke=[.01,.05,.1],pe=[he["1%"],he["5%"],he["10%"]];if(ye<=pe[0]){const ze=(Math.log(ke[1])-Math.log(ke[0]))/(pe[1]-pe[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(ke[0])+ze*(ye-pe[0]))))}if(ye>=pe[2]){const ze=(Math.log(ke[2])-Math.log(ke[1]))/(pe[2]-pe[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(ke[2])+ze*(ye-pe[2]))))}const Pe=ye<pe[1]?0:1,Me=(ye-pe[Pe])/(pe[Pe+1]-pe[Pe]);return Math.exp(Math.log(ke[Pe])+Me*(Math.log(ke[Pe+1])-Math.log(ke[Pe])))}function be(ye,ke,pe,Pe){const Me=pe-Pe,ze=Pe+3,_e=new Array(Me),De=new Array(Me);let Se=!0,xe=Pe;for(let ot=0;ot<Me;ot++){const gt=Pe+ot,vt=new Float64Array(ze);vt[0]=1,vt[1]=ot+1,vt[2]=ye[gt];for(let ht=1;ht<=Pe;ht++)vt[2+ht]=ke[gt-ht];for(let ht=1;ht<ze;ht++)Number.isFinite(vt[ht])||(xe=Math.min(xe,ht-3));_e[ot]=vt,De[ot]=ke[gt],Number.isFinite(De[ot])||(Se=!1)}if(!Se)return 0;const{xtwx:Ue,xtwy:et}=u(_e,De,null);let Je=0,lt=1/0;for(let ot=0;ot<=xe;ot++){const gt=ot+3;if(!(Me>gt))continue;const vt=new Array(gt);for(let ut=0;ut<gt;ut++)vt[ut]=Ue[ut].slice(0,gt);const ht=w(vt);if(!ht)continue;const Ct=A(ht,et.slice(0,gt));let xt=0;for(let ut=0;ut<Me;ut++){const At=_e[ut];let Rt=0;for(let yt=0;yt<gt;yt++)Rt+=At[yt]*Ct[yt];xt+=(De[ut]-Rt)**2}const ft=xt/(Me-gt)*(Me-gt);if(!(ft>0))continue;const st=Me*Math.log(ft/Me)+2*gt;st<lt&&(lt=st,Je=ot)}return Je}function Te(ye,ke={}){const pe=[];for(let lt=0;lt<ye.length;lt++){const ot=Number(ye[lt]);Number.isFinite(ot)&&pe.push(ot)}const Pe=pe.length,Me=Pe-1;if(Pe<8||Me<6)return null;const ze=new Array(Me);for(let lt=0;lt<Me;lt++)ze[lt]=pe[lt+1]-pe[lt];let _e=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.ceil(12*(Pe/100)**.25);_e=Math.max(0,Math.min(_e,Math.floor((Me-5)/2)));const De=(lt,ot)=>{const gt=[],vt=[];for(let ht=ot;ht<Me;ht++){const Ct=[ht-ot+1,pe[ht]];for(let xt=1;xt<=lt;xt++)Ct.push(ze[ht-xt]);gt.push(Ct),vt.push(ze[ht])}return te(gt,vt,{method:"ols"})},Se=be(pe,ze,Me,_e),xe=De(Se,Se);if(!xe||!xe.coefficients[2])return null;const Ue=xe.coefficients[2].t,et=de(Ue),Je=Ue<he["5%"];return{statistic:Ue,usedLag:Se,nobs:Me-Se,criticalValues:{...he},pValue:et,pApproximate:!0,stationary:Je,verdict:Je?"stationary":"non-stationary",regression:"ct"}}function Ae(ye,ke={}){const pe=[];for(let Je=0;Je<ye.length;Je++){const lt=Number(ye[Je]);Number.isFinite(lt)&&pe.push(lt)}const Pe=pe.length;if(Pe<3)return null;let Me=Number.isFinite(ke.maxlag)?Math.floor(ke.maxlag):Math.min(10,Pe-1);Me=Math.max(1,Math.min(Me,Pe-1));let ze=0;for(const Je of pe)ze+=Je;ze/=Pe;const _e=pe.map(Je=>Je-ze);let De=0;for(const Je of _e)De+=Je*Je;De/=Pe;const Se=new Array(Me+1).fill(0);Se[0]=1;for(let Je=1;Je<=Me;Je++){let lt=0;for(let ot=Je;ot<Pe;ot++)lt+=_e[ot]*_e[ot-Je];Se[Je]=De>0?lt/Pe/De:0}const xe=new Array(Me+1).fill(0);xe[0]=1;let Ue=[];for(let Je=1;Je<=Me;Je++){let lt=Se[Je];for(let ht=1;ht<Je;ht++)lt-=Ue[ht-1]*Se[Je-ht];let ot=1;for(let ht=1;ht<Je;ht++)ot-=Ue[ht-1]*Se[ht];const gt=ot!==0?lt/ot:0,vt=new Array(Je);for(let ht=1;ht<Je;ht++)vt[ht-1]=Ue[ht-1]-gt*Ue[Je-1-ht];vt[Je-1]=gt,xe[Je]=gt,Ue=vt}const et=1.96/Math.sqrt(Pe);return{acf:Se,pacf:xe,bounds:{upper:et,lower:-et},n:Pe,nlags:Me,approximate:!0}}function Ce(ye,ke,pe){const{xs:Pe,ys:Me,n:ze}=k(ye,ke,pe);if(ze<2)return null;const _e=oe(Pe),De=oe(Me);let Se=0,xe=0;for(let lt=0;lt<ze;lt++)Se+=_e[lt],xe+=De[lt];Se/=ze,xe/=ze;let Ue=0,et=0,Je=0;for(let lt=0;lt<ze;lt++){const ot=_e[lt]-Se,gt=De[lt]-xe;Ue+=ot*gt,et+=ot*ot,Je+=gt*gt}return et===0||Je===0?null:Math.max(-1,Math.min(1,Ue/Math.sqrt(et*Je)))}function me(ye,ke,pe){const{xs:Pe,ys:Me,n:ze}=k(ye,ke,pe);if(ze<2||ze>t)return null;let _e=0,De=0,Se=0,xe=0;for(let Je=0;Je<ze;Je++)for(let lt=Je+1;lt<ze;lt++){const ot=Math.sign(Pe[Je]-Pe[lt]),gt=Math.sign(Me[Je]-Me[lt]),vt=ot*gt;vt>0?_e++:vt<0?De++:ot===0&&gt===0||(ot===0?Se++:xe++)}const Ue=_e+De+xe,et=_e+De+Se;return Ue===0||et===0?null:(_e-De)/Math.sqrt(Ue*et)}function we(ye,ke={}){const pe=ye.length;if(pe<2)return null;const Pe=ye[0],Me=ye[pe-1],ze=[];for(let ht=1;ht<pe;ht++){const Ct=ye[ht-1];Ct!==0&&ze.push((ye[ht]-Ct)/Math.abs(Ct))}let _e=null;if(ze.length>1){let ht=0;for(const xt of ze)ht+=xt;ht/=ze.length;let Ct=0;for(const xt of ze)Ct+=(xt-ht)**2;_e=Math.sqrt(Ct/(ze.length-1))}const De=Number(ke.periodsPerYear)>0?Number(ke.periodsPerYear):null;let Se=ye[0],xe=0,Ue=0,et=0,Je=0;for(let ht=1;ht<pe;ht++){if(ye[ht]>Se){Se=ye[ht],xe=ht;continue}if(Se<=0)continue;const Ct=(Se-ye[ht])/Se;Ct>Ue&&(Ue=Ct,et=xe,Je=ht)}let lt=null;if(pe>2){let ht=0;for(let Ge=0;Ge<pe;Ge++)ht+=ye[Ge];ht/=pe;let Ct=0,xt=0;for(let Ge=0;Ge<pe;Ge++){const ft=ye[Ge]-ht;xt+=ft*ft,Ge>0&&(Ct+=ft*(ye[Ge-1]-ht))}lt=xt>0?Ct/xt:null}let ot=0,gt=0;for(const ht of ze)ht>0?ot++:ht<0&&gt++;let vt=null;if(Pe>0&&Me>0){const ht=(Me/Pe)**(1/(pe-1))-1;vt=De?(1+ht)**De-1:ht}return{n:pe,first:Pe,last:Me,change:Me-Pe,changePercent:Pe===0?null:(Me-Pe)/Math.abs(Pe)*100,volatility:_e,annualisedVolatility:_e!==null&&De?_e*Math.sqrt(De):null,growth:vt,maxDrawdown:Ue,maxDrawdownFrom:et,maxDrawdownTo:Je,autocorrelation:lt,upDays:ot,downDays:gt}}const ge=1.128,Ne=3.267;function Ie(ye){const ke=ye.length;if(ke<2)return null;const pe=[];for(let Me=1;Me<ke;Me++)pe.push(Math.abs(ye[Me]-ye[Me-1]));const Pe=pe.reduce((Me,ze)=>Me+ze,0)/pe.length;return{ranges:pe,centre:Pe,upper:Ne*Pe,lower:0}}function He(ye){const ke=ye.length;if(ke<2)return null;let pe=0;for(let Me=1;Me<ke;Me++)pe+=Math.abs(ye[Me]-ye[Me-1]);const Pe=pe/(ke-1);return{sigma:Pe/ge,meanRange:Pe}}function Ye(ye,ke){const pe=ye.length;if(pe<2||!ke)return null;const Pe=Number.isFinite(Number(ke.lower))?Number(ke.lower):null,Me=Number.isFinite(Number(ke.upper))?Number(ke.upper):null;if(Pe===null&&Me===null)return null;let ze=0;for(let ot=0;ot<pe;ot++)ze+=ye[ot];ze/=pe;let _e=0;for(let ot=0;ot<pe;ot++)_e+=(ye[ot]-ze)**2;const De=Math.sqrt(_e/(pe-1)),Se=He(ye),xe=Se?Se.sigma:null,Ue=ot=>{if(!ot||ot<=0)return{index:null,k:null};const vt=Pe!==null&&Me!==null?(Me-Pe)/(6*ot):null,ht=Me!==null?(Me-ze)/(3*ot):1/0,Ct=Pe!==null?(ze-Pe)/(3*ot):1/0;return{index:vt,k:Math.min(ht,Ct)}},et=Ue(xe),Je=Ue(De);let lt=0;for(let ot=0;ot<pe;ot++){if(Pe!==null&&ye[ot]<Pe){lt++;continue}Me!==null&&ye[ot]>Me&&lt++}return{n:pe,mean:ze,lower:Pe,upper:Me,target:Number.isFinite(Number(ke.target))?Number(ke.target):null,sigmaWithin:xe,sigmaOverall:De,cp:et.index,cpk:et.k,pp:Je.index,ppk:Je.k,outOfSpec:lt,defectRate:pe?lt/pe:null}}function Oe(ye){const ke=ye.length;if(ke<2)return null;const pe=He(ye);if(!pe||!(pe.sigma>0))return null;let Pe=0;for(let Me=0;Me<ke;Me++)Pe+=ye[Me];return Pe/=ke,{centre:Pe,sigma:pe.sigma,upper:Pe+3*pe.sigma,lower:Pe-3*pe.sigma}}function Ve(ye,ke){if(!ke||!(ke.sigma>0))return[];const pe=ye.length,{centre:Pe,sigma:Me}=ke,ze=De=>(ye[De]-Pe)/Me,_e=[];for(let De=0;De<pe;De++){if(Math.abs(ze(De))>3&&_e.push({index:De,rule:1,description:"beyond three sigma"}),De>=2)for(const Se of[1,-1]){let xe=0;for(let Ue=De-2;Ue<=De;Ue++)ze(Ue)*Se>2&&xe++;if(xe>=2){_e.push({index:De,rule:2,description:"two of three past two sigma"});break}}if(De>=4)for(const Se of[1,-1]){let xe=0;for(let Ue=De-4;Ue<=De;Ue++)ze(Ue)*Se>1&&xe++;if(xe>=4){_e.push({index:De,rule:3,description:"four of five past one sigma"});break}}if(De>=7)for(const Se of[1,-1]){let xe=!0;for(let Ue=De-7;Ue<=De;Ue++)if(ze(Ue)*Se<=0){xe=!1;break}if(xe){_e.push({index:De,rule:4,description:"eight in a row on one side"});break}}}return _e}function Ze(ye,ke){if(!ke||!(ke.sigma>0))return[];const pe=ye.length,{centre:Pe,sigma:Me}=ke,ze=Se=>(ye[Se]-Pe)/Me,_e=(Se,xe,Ue,et)=>{for(const Je of[1,-1]){let lt=0;for(let ot=Se;ot<=xe;ot++)ze(ot)*Je>Ue&&lt++;if(lt>=et)return!0}return!1},De=[];for(let Se=0;Se<pe;Se++){if(Math.abs(ze(Se))>3&&De.push({index:Se,rule:1,description:"beyond three sigma"}),Se>=8)for(const xe of[1,-1]){let Ue=!0;for(let et=Se-8;et<=Se;et++)if(ze(et)*xe<=0){Ue=!1;break}if(Ue){De.push({index:Se,rule:2,description:"nine in a row on one side"});break}}if(Se>=5)for(const xe of[1,-1]){let Ue=!0;for(let et=Se-4;et<=Se;et++)if((ye[et]-ye[et-1])*xe<=0){Ue=!1;break}if(Ue){De.push({index:Se,rule:3,description:xe>0?"six rising":"six falling"});break}}if(Se>=13){let xe=!0;for(let Ue=Se-12;Ue<=Se;Ue++){const et=ye[Ue]-ye[Ue-1],Je=ye[Ue+1<=Se?Ue+1:Ue]-ye[Ue];if(Ue+1>Se)break;if(et===0||Je===0||et>0==Je>0){xe=!1;break}}xe&&De.push({index:Se,rule:4,description:"fourteen alternating"})}if(Se>=2&&_e(Se-2,Se,2,2)&&De.push({index:Se,rule:5,description:"two of three past two sigma"}),Se>=4&&_e(Se-4,Se,1,4)&&De.push({index:Se,rule:6,description:"four of five past one sigma"}),Se>=14){let xe=!0;for(let Ue=Se-14;Ue<=Se;Ue++)if(Math.abs(ze(Ue))>=1){xe=!1;break}xe&&De.push({index:Se,rule:7,description:"fifteen within one sigma"})}if(Se>=7){let xe=!0;for(let Ue=Se-7;Ue<=Se;Ue++)if(Math.abs(ze(Ue))<=1){xe=!1;break}xe&&De.push({index:Se,rule:8,description:"eight beyond one sigma"})}}return De}const it=Object.freeze(["westernElectric","nelson"]);function at(ye,ke,pe="westernElectric"){return String(pe)==="nelson"?Ze(ye,ke):Ve(ye,ke)}function pt(ye,ke,pe){let Pe=0;for(let Me=0;Me<ye.length;Me++)(ye[Me]<ke||ye[Me]>pe)&&Pe++;return Pe}function bt(ye,ke,pe,Pe=20){const Me=ye.length;if(!Me)return[];const ze=ye[0],_e=ye[Me-1];if(_e===ze)return[{from:ze,to:_e,count:Me}];const De=pe-ke,Se=1.5*De;let xe=De>0?Math.max(ze,ke-Se):ze,Ue=De>0?Math.min(_e,pe+Se):_e;Ue>xe||(xe=ze,Ue=_e);const et=De>0?2*De/Math.cbrt(Me):(Ue-xe)/(Math.ceil(Math.log2(Me))+1),Je=et>0?Math.min(Pe,Math.max(1,Math.ceil((Ue-xe)/et))):1,lt=(Ue-xe)/Je,ot=[];for(let gt=0;gt<Je;gt++)ot.push({from:xe+gt*lt,to:xe+(gt+1)*lt,count:0});for(let gt=0;gt<Me;gt++){const vt=Math.min(Je-1,Math.max(0,Math.floor((ye[gt]-xe)/lt)));ot[vt].count++}return ot[0].from=ze,ot[Je-1].to=_e,ot}const Ot=.95;function Et(ye){const ke=Number(ye);return Number.isFinite(ke)&&ke>0&&ke<1?ke:Ot}function Mt(ye,ke=Ot){const pe=ye.length;if(pe<2)return null;let Pe=0;for(let Ue=0;Ue<pe;Ue++)Pe+=ye[Ue];const Me=Pe/pe;let ze=0;for(let Ue=0;Ue<pe;Ue++){const et=ye[Ue]-Me;ze+=et*et}const _e=Math.sqrt(ze/(pe-1)),De=Et(ke),xe=_(1-(1-De)/2,pe-1)*_e/Math.sqrt(pe);return{mean:Me,lower:Me-xe,upper:Me+xe,margin:xe,n:pe,confidence:De}}function Tt(ye,ke,pe=Ot){const Pe=Number(ye),Me=Number(ke);if(!(Me>0)||!(Pe>=0)||Pe>Me)return null;const ze=Et(pe),_e=W(1-(1-ze)/2),De=Pe/Me,Se=_e*_e,xe=1+Se/Me,Ue=(De+Se/(2*Me))/xe,et=_e/xe*Math.sqrt(De*(1-De)/Me+Se/(4*Me*Me));return{proportion:De,lower:Math.max(0,Ue-et),upper:Math.min(1,Ue+et),n:Me,confidence:ze}}function Bt(ye,ke=Ot){if(!ye||!(ye.n>2)||!Number.isFinite(ye.stdError))return null;const pe=Et(ke),Me=_(1-(1-pe)/2,ye.n-2)*ye.stdError;return{slope:ye.slope,lower:ye.slope-Me,upper:ye.slope+Me,margin:Me,confidence:pe}}function zt(ye,ke,pe=Ot){const Pe=Number(ye),Me=Number(ke);if(!Number.isFinite(Pe)||!(Me>1))return null;const ze=Et(pe),De=W(1-(1-ze)/2)*Math.sqrt(1/(9*Me)+Pe*Pe/(2*(Me-1)));return{index:Pe,lower:Pe-De,upper:Pe+De,margin:De,n:Me,confidence:ze}}function dt(ye,ke){return!ye||!(ye.sd>0)||!Number.isFinite(ke)||!Number.isFinite(ye.mean)?null:(ke-ye.mean)/ye.sd}function rt(ye){return Number.isFinite(ye)?Math.min(1,Math.max(0,2*V(Math.abs(ye)/2)-1)):0}function ue(ye,ke){const pe=new Map,Pe=z(ye);let Me=0;for(let ze=0;ze<ke.length;ze++){const _e=Pe(ke[ze]);if(_e==null||_e===""||typeof _e=="number"&&Number.isNaN(_e))continue;const De=_e instanceof Date?_e.getTime():typeof _e=="object"?String(_e):_e;pe.set(De,(pe.get(De)||0)+1),Me++}return{map:pe,total:Me}}function ve(ye,ke,pe,Pe){if(!(ke>0)||!(Pe>0))return null;let Me=0;const ze=new Set(ye.keys());for(const _e of pe.keys())ze.add(_e);for(const _e of ze){const De=(ye.get(_e)||0)/ke,Se=(pe.get(_e)||0)/Pe;Me+=Math.abs(De-Se)}return Me/2}const Re=10;function We(ye,ke,pe){if(pe&&pe.numeric){const De=l(ye,ke),{n:Se,mean:xe}=S(De),Ue=Se>0?dt({mean:pe.mean,sd:pe.sd},xe):null;return{measure:"standardizedMeanDifference",magnitude:Ue,distance:Ue===null?0:rt(Ue),direction:Ue===null?0:Math.sign(Ue),subsetN:Se,populationN:pe.n||0,reliable:Se>=Re}}const{map:Me,total:ze}=ue(ye,ke),_e=ve(Me,ze,pe.map,pe.total);return{measure:"categoricalTotalVariation",magnitude:_e,distance:_e===null?0:_e,direction:0,subsetN:ze,populationN:pe.total||0,reliable:ze>=Re}}function $e(ye,ke){if(ye&&(ye.kind==="float64"||ye.kind==="int32"))return!0;const pe=z(ye);let Pe=0,Me=0;for(let ze=0;ze<ke.length&&Pe<200;ze++){const _e=pe(ke[ze]);if(_e==null||_e==="")continue;if(_e instanceof Date)return!1;Pe++;const De=typeof _e=="number"?_e:Number(_e);Number.isFinite(De)&&Me++}return Pe===0?!1:Me/Pe>=.9}function qe(ye,ke){if($e(ye,ke)){const Me=l(ye,ke),{n:ze,mean:_e,m2:De}=S(Me);return{numeric:!0,mean:_e,sd:ze>0?Math.sqrt(De/ze):0,n:ze}}const{map:pe,total:Pe}=ue(ye,ke);return{numeric:!1,map:pe,total:Pe}}}),Fe("packages/core/src/compute/total.js",function(e,K){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=K("packages/core/src/compute/handle.js"),_=$.presenceReader,X=$.valueComparator,W=$.valueReader,V=K("packages/core/src/compute/statistics.js"),H=V.STAT_FNS,B=V.STAT_LABELS;function w(S){return!!S&&(S.kind==="float64"||S.kind==="int32")}function A(S,j){const y=j.length;let v=0;if(w(S)){const O=S.values,F=_(S);if(!F){for(let C=0;C<y;C++){const T=O[j[C]];Number.isNaN(T)||(v+=T)}return v}for(let C=0;C<y;C++){const T=j[C];if(F(T)===1){const L=O[T];Number.isNaN(L)||(v+=L)}}return v}const R=W(S);for(let O=0;O<y;O++){const F=d(R(j[O]));F!==null&&(v+=F)}return v}A.kernel=!0;function g(S,j){const y=j.length;let v=0;if(w(S)){const O=S.values,F=_(S);if(!F){for(let C=0;C<y;C++)Number.isNaN(O[j[C]])||v++;return v}for(let C=0;C<y;C++){const T=j[C];F(T)===1&&!Number.isNaN(O[T])&&v++}return v}const R=W(S);for(let O=0;O<y;O++){const F=R(j[O]);F!=null&&!(typeof F=="number"&&Number.isNaN(F))&&v++}return v}g.kernel=!0;function u(S,j){return j.length}u.kernel=!0;function h(S,j){const y=g(S,j);return y===0?null:A(S,j)/y}h.kernel=!0;function a(S,j,y,v){const R=j.length;if(w(S)){const T=S.values,L=_(S);let E=null;if(!L){for(let D=0;D<R;D++){const I=T[j[D]];Number.isNaN(I)||(E===null||(y<0?I<E:I>E))&&(E=I)}return E}for(let D=0;D<R;D++){const I=j[D];if(L(I)===0)continue;const P=T[I];Number.isNaN(P)||(E===null||(y<0?P<E:P>E))&&(E=P)}return E}const O=W(S),F=X(v);let C=null;for(let T=0;T<R;T++){const L=O(j[T]);L==null||typeof L=="number"&&Number.isNaN(L)||(C===null||(y<0?F(L,C)<0:F(L,C)>0))&&(C=L)}return C}function r(S,j,y){return a(S,j,-1,y&&y.locale)}r.kernel=!0;function t(S,j,y){return a(S,j,1,y&&y.locale)}t.kernel=!0;function n(S,j){return j.length===0?null:W(S)(j[0])}n.kernel=!0;function o(S,j){return j.length===0?null:W(S)(j[j.length-1])}o.kernel=!0;function d(S){if(typeof S=="number")return Number.isNaN(S)?null:S;if(S==null||S===""||typeof S=="boolean")return null;if(S instanceof Date)return S.getTime();const j=Number(S);return Number.isNaN(j)?null:j}const l={sum:A,min:r,max:t,avg:h,count:u,first:n,last:o,countValues:g,...H},i=Object.freeze({...B,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function m(S){return S?typeof S=="string"?i[S]||S:"Total":""}const c=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function f(S){const j=S&&S.dataType&&S.dataType.totals&&S.dataType.totals.supported;if(Array.isArray(j))return j.slice();const y=c.filter(v=>v in l);for(const v of Object.keys(l))y.includes(v)||y.push(v);return y}function s(S,j){return typeof j!="string"?!0:f(S).includes(j)}function p(S,j){const y=W(S),v=[];for(let R=0;R<j.length;R++){const O=y(j[R]);O!=null&&v.push(O)}return v}function b(S,j,y,v){const R=j||[];if(typeof y=="string"){const O=l[y];return O?O(S,R,v):(z(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return x(y)?y.kernel===!0?y(S,R,v):y(p(S,R),v||{}):null}}),Fe("packages/core/src/compute/windowed.js",function(e,K){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/compute/sketch.js").Welford;class z{#e;#t;#n=[];#r;#o;constructor(V,H=0,B=Date.now){if(V!=="count"&&V!=="time"&&V!=="session")throw new RangeError(`unknown window kind: ${V}`);if((V==="count"||V==="time")&&!(H>0))throw new RangeError(`a ${V} window needs a positive span`);this.#e=V,this.#t=Math.floor(H),this.#r=B,this.#o=B()}get size(){return this.#n.length}push(V,H=this.#r()){Number.isFinite(V)&&(this.#n.push({t:H,v:V}),this.#i(H))}#i(V){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const H=V-this.#t;for(;this.#n.length&&this.#n[0].t<H;)this.#n.shift()}}spec(){const V=this.#e==="session"?this.#r()-this.#o:this.#t;return{kind:this.#e,span:V,size:this.#n.length}}values(){return this.#n.map(V=>V.v)}aggregate(){const V=this.spec();if(!this.#n.length)return{over:V,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const H=new x;let B=0,w=1/0,A=-1/0;for(const{v:g}of this.#n)B+=g,g<w&&(w=g),g>A&&(A=g),H.add(g);return{over:V,count:this.#n.length,sum:B,mean:H.mean(),min:w,max:A,variance:H.variance(),stddev:H.stddev()}}reduce(V){const H=this.aggregate(),B={sum:H.sum,avg:H.mean,mean:H.mean,min:H.min,max:H.max,count:H.count,variance:H.variance,stddev:H.stddev};if(!(V in B))throw new RangeError(`unknown windowed aggregate: ${V}`);return{value:B[V],over:H.over}}}const $=Object.freeze(["count","time","session"]);function _(W,V=Date.now){const H=W.kind==="time"&&W.minutes!=null?W.minutes*6e4:W.span??0;return new z(W.kind,H,V)}const X={Window:z,WINDOW_KINDS:$,openWindow:_}}),Fe("packages/core/src/compute/rolling.js",function(e,K){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const x=K("packages/core/src/compute/windowed.js").openWindow,$=K("packages/core/src/compute/sketch.js").KLL,_=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function X(i,m,c,f){if(i.kind==="count"){const s=Math.max(1,Math.floor(i.span||0));return{coverage:Math.min(1,m/s),partial:m<s}}if(i.kind==="time"){const s=i.minutes!=null?i.minutes*6e4:i.span||0;if(!(s>0))return{coverage:1,partial:!1};const p=c-f;return{coverage:Math.min(1,p/s),partial:p<s}}return{coverage:null,partial:!1}}function W(i,m){const c=x(m),f=new Map,s=i.length?i[0].at:0;for(let p=0;p<i.length;p++){const{key:b,at:S,value:j}=i[p];Number.isFinite(j)&&c.push(j,S);const y=c.aggregate(),v=X(m,y.count,S,s);b!=null&&f.set(String(b),{sum:y.sum,avg:y.mean,min:y.min,max:y.max,count:y.count,coverage:v.coverage,partial:v.partial})}return f}function V(i){const m=new Map;let c=0;for(const{key:f,value:s}of i)Number.isFinite(s)&&(c+=s),f!=null&&m.set(String(f),c);return m}function H(i,m=1){const c=new Map,f=Math.max(1,Math.floor(m));for(let s=0;s<i.length;s++){const{key:p,value:b}=i[s];if(p==null)continue;const S=s>=f?i[s-f].value:null,j=Number.isFinite(b)?b:null,y=Number.isFinite(S)?S:null;c.set(String(p),j!==null&&y!==null?j-y:null)}return c}const B=4096;function w(i){let m=i>>>0;return()=>{m+=1831565813;let c=m;return c=Math.imul(c^c>>>15,c|1),c^=c+Math.imul(c^c>>>7,c|61),((c^c>>>14)>>>0)/4294967296}}function A(i,m){const c=i.length;if(c===1)return i[0];const f=(c-1)*m,s=Math.floor(f),p=Math.ceil(f);return s===p?i[s]:i[s]+(f-s)*(i[p]-i[s])}function g(i,m,c={}){const f=Math.min(1,Math.max(0,c.q==null?.5:c.q)),s=Math.max(1,Math.floor(c.cap==null?B:c.cap)),p=w(c.seed==null?2654435769:c.seed),b=new Map,S=i.length?i[0].at:0;if(m.kind==="session"){const y=new $(200,p);let v=0;for(const{key:R,value:O}of i)Number.isFinite(O)&&(y.add(O),v++),R!=null&&b.set(String(R),{value:v?y.quantile(f):null,approx:v>0,count:v,coverage:null,partial:!1});return b}const j=x(m);for(const{key:y,at:v,value:R}of i){Number.isFinite(R)&&j.push(R,v);const O=j.values(),F=O.length;let C=null,T=!1;if(F)if(F<=s)C=A([...O].sort((E,D)=>E-D),f);else{const E=new $(200,p);for(const D of O)E.add(D);C=E.quantile(f),T=!0}const L=X(m,F,v,S);y!=null&&b.set(String(y),{value:C,approx:T,count:F,coverage:L.coverage,partial:L.partial})}return b}function u(i,m){const c=i.length,f=new Array(c).fill(null),s=Math.floor(m/2),p=m%2===0;for(let b=0;b<c;b++){if(b-s<0||b+s>=c)continue;let S=0,j=!0;if(p)for(let y=-s;y<=s;y++){const v=i[b+y];if(!Number.isFinite(v)){j=!1;break}S+=y===-s||y===s?v*.5:v}else for(let y=-s;y<=s;y++){const v=i[b+y];if(!Number.isFinite(v)){j=!1;break}S+=v}j&&(f[b]=S/m)}return f}function h(i,m){const c=new Map,f=Math.floor(Number(m&&m.period));if(!(f>=2))return c;const s=m&&m.model==="multiplicative",p=i.length,b=i.map(T=>Number.isFinite(T.value)?T.value:null),S=u(b,f),j=new Array(p).fill(null);for(let T=0;T<p;T++){const L=S[T],E=b[T];L===null||E===null||(s?L!==0&&(j[T]=E/L):j[T]=E-L)}const y=new Array(f).fill(0),v=new Array(f).fill(0);for(let T=0;T<p;T++){if(j[T]===null)continue;const L=T%f;y[L]+=j[T],v[L]+=1}const R=s?1:0,O=y.map((T,L)=>v[L]?T/v[L]:R),F=O.reduce((T,L)=>T+L,0)/f,C=s?O.map(T=>F!==0?T/F:1):O.map(T=>T-F);for(let T=0;T<p;T++){const{key:L}=i[T];if(L==null)continue;const E=S[T],D=C[T%f],I=b[T];let P=null;E!==null&&I!==null&&(P=s?E*D!==0?I/(E*D):null:I-E-D),c.set(String(L),{trend:E,seasonal:I===null?null:D,residual:P,coverage:E===null?0:1,partial:E===null})}return c}function a(i,m,c,f=80){const s=(Math.sqrt(5)-1)/2;let p=m,b=c,S=b-s*(b-p),j=p+s*(b-p),y=i(S),v=i(j);for(let R=0;R<f;R++)y<v?(b=j,j=S,v=y,S=b-s*(b-p),y=i(S)):(p=S,S=j,y=v,j=p+s*(b-p),v=i(j));return(p+b)/2}const r=1e-4,t=1-1e-4;function n(i,m){const c=i.length,f=new Array(c).fill(null),s=new Array(c).fill(null);let p=null,b=0;for(let S=0;S<c;S++){const j=i[S];if(!Number.isFinite(j)){p!==null&&(s[S]=p,f[S]=p);continue}if(p===null){p=j,s[S]=j,f[S]=j;continue}s[S]=p,b+=(j-p)**2,p=m*j+(1-m)*p,f[S]=p}return{smoothed:f,fitted:s,sse:b}}function o(i,m,c){const f=i.length,s=new Array(f).fill(null),p=new Array(f).fill(null);let b=null,S=null,j=0;for(let y=0;y<f;y++){const v=i[y];if(!Number.isFinite(v)){b!==null&&(b+=S,s[y]=b);continue}if(b===null){b=v,s[y]=v;continue}if(S===null){S=v-b;const F=b+S;p[y]=F,j+=(v-F)**2;const C=b;b=m*v+(1-m)*(C+S),S=c*(b-C)+(1-c)*S,s[y]=b;continue}const R=b+S;p[y]=R,j+=(v-R)**2;const O=b;b=m*v+(1-m)*(O+S),S=c*(b-O)+(1-c)*S,s[y]=b}return{smoothed:s,fitted:p,sse:j}}function d(i,m={}){const c=new Map,f=m.method==="holt",s=i.map(R=>Number.isFinite(R.value)?R.value:null),p=s.filter(R=>R!==null).length,b=R=>Math.min(t,Math.max(r,R)),S=()=>{for(const{key:R}of i)R!=null&&c.set(String(R),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return c};if(p<(f?2:1))return S();let j=Number.isFinite(m.alpha)?b(m.alpha):null,y=f&&Number.isFinite(m.beta)?b(m.beta):null;if(f){if(j===null||y===null){let R=j===null?.5:j,O=y===null?.5:y;for(let F=0;F<6;F++)j===null&&(R=a(C=>o(s,C,O).sse,r,t)),y===null&&(O=a(C=>o(s,R,C).sse,r,t));j=j===null?R:j,y=y===null?O:y}}else j===null&&(j=a(R=>n(s,R).sse,r,t));const v=f?o(s,j,y):n(s,j);for(let R=0;R<i.length;R++){const{key:O}=i[R];O!=null&&c.set(String(O),{smoothed:v.smoothed[R],fitted:v.fitted[R],alpha:j,beta:f?y:null,sse:v.sse})}return c}const l={ROLLING_WINDOW_FIELDS:_,QUANTILE_SPAN_CAP:B,rollingWindow:W,rollingQuantile:g,cumulativeToDate:V,periodOverPeriod:H,seasonalDecompose:h,exponentialSmoothing:d}}),Fe("packages/core/src/compute/compare.js",function(e,K){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/compute/statistics.js"),x=Q.numbers,z=Q.moments,$=Q.frequencyMap,_=Q.categoricalDistance,X=Q.normalTotalVariation,W=Q.isNumericColumn,V=Q.SUBSET_RELIABILITY_FLOOR,H=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function B(h,a){if(!h||!a||!(h.n>0)||!(a.n>0)||!Number.isFinite(h.mean)||!Number.isFinite(a.mean))return null;const r=(h.n*h.sd*h.sd+a.n*a.sd*a.sd)/(h.n+a.n);return r>0?(h.mean-a.mean)/Math.sqrt(r):null}function w(h,a){const r=x(h,a),{n:t,mean:n,m2:o}=z(r),d=t>0?Math.sqrt(o/t):0;return{mean:n,sd:d,n:t}}function A(h,a,r,t){return W(h,a)&&W(r,t)}function g(h,a,r,t){if(A(h,a,r,t)){const l=w(h,a),i=w(r,t),m=B(l,i);return{measure:H.numeric,magnitude:m,distance:m===null?0:X(m),direction:m===null?0:Math.sign(m),nA:l.n,nB:i.n,reliable:l.n>=V&&i.n>=V}}const n=$(h,a),o=$(r,t),d=_(n.map,n.total,o.map,o.total);return{measure:H.categorical,magnitude:d,distance:d===null?0:d,direction:0,nA:n.total,nB:o.total,reliable:n.total>=V&&o.total>=V}}function u(h,a,r={}){const t=new Set(h.columns),n=new Set(a.columns),o=h.columns.filter(c=>n.has(c)),d=Array.isArray(r.columns)&&r.columns.length?o.filter(c=>r.columns.includes(c)):o,l=h.indices(),i=a.indices(),m=[];for(const c of d){const f=h.handle(c),s=a.handle(c);if(!f||!s)continue;const p=g(f,l,s,i);m.push({column:c,name:h.name&&h.name(c)||a.name&&a.name(c)||c,measure:p.measure,magnitude:p.magnitude,distance:p.distance,direction:p.direction,nA:p.nA,nB:p.nB,reliable:p.reliable})}return m.sort((c,f)=>f.distance-c.distance||Math.abs(f.magnitude||0)-Math.abs(c.magnitude||0)),{ranked:m,nA:l.length,nB:i.length,unmatched:{onlyA:h.columns.filter(c=>!n.has(c)),onlyB:a.columns.filter(c=>!t.has(c))},measures:H}}}),Fe("packages/core/src/compute/anomaly.js",function(e,K){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l}});const x=K("packages/core/src/compute/statistics.js").quantileSorted,$=K("packages/core/src/compute/special.js").logGamma,_=.6745,X=3.5,W=1.5,V=.975,H=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function B(i){if(!i.length)return null;const c=Array.from(i,Number).sort((b,S)=>b-S),f=x(c,.5),s=c.map(b=>Math.abs(b-f)).sort((b,S)=>b-S),p=x(s,.5);return{median:f,mad:p}}function w(i,m={}){const c=Number.isFinite(m.threshold)?m.threshold:X,f=i.length,s=new Array(f).fill(null),p=new Array(f).fill(!1),b=[];for(let y=0;y<f;y++){const v=Number(i[y]);Number.isFinite(v)&&b.push(v)}if(!b.length)return{median:null,mad:null,threshold:c,scores:s,flags:p,flagged:0};const S=B(b);if(S.mad===0)return{median:S.median,mad:0,threshold:c,scores:s,flags:p,flagged:0};let j=0;for(let y=0;y<f;y++){const v=Number(i[y]);if(!Number.isFinite(v))continue;const R=_*(v-S.median)/S.mad;s[y]=R,Math.abs(R)>c&&(p[y]=!0,j++)}return{median:S.median,mad:S.mad,threshold:c,scores:s,flags:p,flagged:j}}function A(i,m={}){const c=Number.isFinite(m.k)?m.k:W,f=[];for(let j=0;j<i.length;j++){const y=Number(i[j]);Number.isFinite(y)&&f.push(y)}if(!f.length)return null;const s=f.sort((j,y)=>j-y),p=x(s,.25),b=x(s,.75),S=b-p;return{q1:p,q3:b,iqr:S,lower:p-c*S,upper:b+c*S,k:c}}function g(i,m){if(m<=0)return 0;const c=$(i);if(m<i+1){let y=i,v=1/i,R=v;for(let O=0;O<1e3&&(y+=1,R*=m/y,v+=R,!(Math.abs(R)<Math.abs(v)*1e-15));O++);return v*Math.exp(-m+i*Math.log(m)-c)}const f=1e-300;let s=m+1-i,p=1/f,b=1/s,S=b;for(let y=1;y<1e3;y++){const v=-y*(y-i);s+=2,b=v*b+s,Math.abs(b)<f&&(b=f),p=s+v/p,Math.abs(p)<f&&(p=f),b=1/b;const R=b*p;if(S*=R,Math.abs(R-1)<1e-15)break}return 1-Math.exp(-m+i*Math.log(m)-c)*S}function u(i,m){return i<=0?0:g(m/2,i/2)}function h(i,m=V){if(!(m>0)||!(m<1))return NaN;let c=0,f=Math.max(1,i);for(;u(f,i)<m;)f*=2;for(let s=0;s<200;s++){const p=(c+f)/2;if(u(p,i)<m?c=p:f=p,f-c<1e-10)break}return(c+f)/2}function a(i){const m=i.length,c=i.map((f,s)=>{const p=f.slice();for(let b=0;b<m;b++)p.push(s===b?1:0);return p});for(let f=0;f<m;f++){let s=f;for(let b=f+1;b<m;b++)Math.abs(c[b][f])>Math.abs(c[s][f])&&(s=b);if(Math.abs(c[s][f])<1e-12)return null;if(s!==f){const b=c[s];c[s]=c[f],c[f]=b}const p=c[f][f];for(let b=0;b<2*m;b++)c[f][b]/=p;for(let b=0;b<m;b++){if(b===f)continue;const S=c[b][f];if(S!==0)for(let j=0;j<2*m;j++)c[b][j]-=S*c[f][j]}}return c.map(f=>f.slice(m))}function r(i,m){const c=i.length,f=new Array(m).fill(0);for(const b of i)for(let S=0;S<m;S++)f[S]+=b[S];for(let b=0;b<m;b++)f[b]/=c;const s=Array.from({length:m},()=>new Array(m).fill(0));for(const b of i)for(let S=0;S<m;S++){const j=b[S]-f[S];for(let y=S;y<m;y++)s[S][y]+=j*(b[y]-f[y])}const p=c>1?c-1:1;for(let b=0;b<m;b++)for(let S=b;S<m;S++)s[b][S]/=p,s[S][b]=s[b][S];return{mean:f,cov:s}}function t(i,m={}){const c=Number.isFinite(m.p)?m.p:V,f=Number.isFinite(m.ridge)?m.ridge:1e-6,s=i.length;if(!s)return null;const p=i[0].length;if(!p)return null;const b=new Array(s).fill(null),S=new Array(s).fill(null),j=new Array(s).fill(!1),y=[],v=[];for(let D=0;D<s;D++){const I=i[D];let P=I.length===p;const k=new Array(p);for(let N=0;P&&N<p;N++){const G=Number(I[N]);Number.isFinite(G)?k[N]=G:P=!1}P&&(y.push(D),v.push(k))}const R=p,O=h(R,c);if(v.length<=p)return{center:[],df:R,cutoff:O,singular:!0,used:v.length,distances:b,squared:S,flags:j,flagged:0};const{mean:F,cov:C}=r(v,p);let T=a(C),L=!1;if(!T){L=!0;let D=0;for(let k=0;k<p;k++)D+=C[k][k];const I=D/p*f||f,P=C.map((k,N)=>k.map((G,q)=>N===q?G+I:G));if(T=a(P),!T)return{center:F,df:R,cutoff:O,singular:!0,used:v.length,distances:b,squared:S,flags:j,flagged:0}}let E=0;for(let D=0;D<v.length;D++){const I=v[D],P=new Array(p);for(let G=0;G<p;G++)P[G]=I[G]-F[G];let k=0;for(let G=0;G<p;G++){let q=0;for(let Y=0;Y<p;Y++)q+=T[G][Y]*P[Y];k+=P[G]*q}k<0&&(k=0);const N=y[D];S[N]=k,b[N]=Math.sqrt(k),k>O&&(j[N]=!0,E++)}return{center:F,df:R,cutoff:O,singular:L,used:v.length,distances:b,squared:S,flags:j,flagged:E}}const n=20,o=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function d(i,m={}){const c=m.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",f=Number.isFinite(m.windowLen)&&m.windowLen>=1?Math.floor(m.windowLen):n,s=Number.isFinite(m.threshold)?m.threshold:X,p=Number.isFinite(m.k)?m.k:W,b=Number.isFinite(m.minPeriods)&&m.minPeriods>=1?Math.floor(m.minPeriods):f,S=i.length,j=new Array(S).fill(null),y=new Array(S).fill(!1);let v=0;for(let R=0;R<S;R++){const O=Number(i[R]);if(!Number.isFinite(O))continue;const F=Math.max(0,R-f+1),C=[];for(let T=F;T<=R;T++){const L=Number(i[T]);Number.isFinite(L)&&C.push(L)}if(!(C.length<b))if(c==="rollingIqr"){const T=A(C,{k:p});if(!T)continue;(O<T.lower||O>T.upper)&&(y[R]=!0,v++)}else{const T=B(C);if(!T||T.mad===0)continue;const L=_*(O-T.median)/T.mad;j[R]=L,Math.abs(L)>s&&(y[R]=!0,v++)}}return{method:c,windowLen:f,minPeriods:b,threshold:s,k:p,scores:j,flags:y,flagged:v}}function l(i={}){const m=i||{},c=m.field;if(typeof c!="string"||!c)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const f=m.method||"modifiedZScore";if(!(H.includes(f)||o.includes(f))||f==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${f}'`);const p=typeof m.orderBy=="string"?m.orderBy:null,b=m.latest===!0,S=o.includes(f),j=y=>Number(y==null?NaN:y[c]);return y=>{const v=Array.isArray(y)?y.slice():[...y];p&&v.sort((T,L)=>{const E=T?.[p],D=L?.[p];return E===D?0:E==null?-1:D==null?1:E<D?-1:1});const R=v.map(j);let O,F;if(S)({flags:O,scores:F}=d(R,{method:f,windowLen:m.windowLen,threshold:m.threshold,k:m.k,minPeriods:m.minPeriods}));else if(f==="iqr"){const T=A(R,{k:m.k});O=R.map(L=>T?Number.isFinite(L)&&(L<T.lower||L>T.upper):!1),F=R.map(()=>null)}else({flags:O,scores:F}=w(R,{threshold:m.threshold}));if(b){const T=O.length-1;return T<0||!O[T]?!1:{method:f,field:c,flagged:[{row:v[T],score:F[T]}]}}const C=[];for(let T=0;T<O.length;T++)O[T]&&C.push({row:v[T],score:F[T]});return C.length?{method:f,field:c,flagged:C}:!1}}}),Fe("packages/core/src/compute/forecast.js",function(e,K){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/compute/special.js"),x=Q.normalQuantile,z=Q.studentTQuantile,_=K("packages/core/src/internal/util.js").warnOnce,X=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),W=1e-4,V=1-1e-4;function H(m){const c=[];for(let f=0;f<m.length;f++){const s=m[f];if(s!==null&&typeof s=="object"){const p=Number.isFinite(s.at)?s.at:f,b=Number.isFinite(s.value)?s.value:null;c.push({at:p,value:b})}else c.push({at:f,value:Number.isFinite(s)?Number(s):null})}return c}function B(m){const c=m.filter(S=>S.value!==null),f=c[0],s=c[c.length-1],p=s.at-f.at,b=c.length>1&&p>0?p/(c.length-1):1;return{lastAt:s.at,step:b}}function w(m){return Math.min(V,Math.max(W,m))}function A(m,c=W,f=V,s=80){const p=(Math.sqrt(5)-1)/2;let b=c,S=f,j=S-p*(S-b),y=b+p*(S-b),v=m(j),R=m(y);for(let O=0;O<s;O++)v<R?(S=y,y=j,R=v,j=S-p*(S-b),v=m(j)):(b=j,j=y,v=R,y=b+p*(S-b),R=m(y));return(b+S)/2}function g(m,c){let f=null,s=0,p=0;for(let b=0;b<m.length;b++){const S=m[b];if(S!==null){if(f===null){f=S;continue}s+=(S-f)**2,p+=1,f=c*S+(1-c)*f}}return{level:f,sse:s,m:p}}function u(m,c,f){let s=null,p=null,b=0,S=0;for(let j=0;j<m.length;j++){const y=m[j];if(y===null){s!==null&&p!==null&&(s+=p);continue}if(s===null){s=y;continue}p===null&&(p=y-s);const v=s+p;b+=(y-v)**2,S+=1;const R=s;s=c*y+(1-c)*(R+p),p=f*(s-R)+(1-f)*p}return{level:s,trend:p,sse:b,m:S}}function h(m,c,f,s,p){const b=m.length;if(b<2*c)return null;const S=L=>{let E=0,D=0;for(let I=L;I<L+c&&I<b;I++)m[I]!==null&&(E+=m[I],D+=1);return D?E/D:null},j=S(0),y=S(c);if(j===null||y===null)return null;let v=j,R=(y-j)/c;const O=new Array(c).fill(0);for(let L=0;L<c;L++)O[L]=m[L]===null?0:m[L]-v;const F=O.reduce((L,E)=>L+E,0)/c;for(let L=0;L<c;L++)O[L]-=F;let C=0,T=0;for(let L=c;L<b;L++){const E=L%c,D=O[E],I=m[L];if(I===null){v+=R;continue}const P=v+R+D;C+=(I-P)**2,T+=1;const k=v;v=f*(I-D)+(1-f)*(v+R),R=s*(v-k)+(1-s)*R,O[E]=p*(I-v)+(1-p)*D}return{level:v,trend:R,season:O,phase:(b-1)%c,sse:C,count:T}}function a(m,c,f){let s=1;for(const b of c)s+=b*b;const p=Math.sqrt(m*s);return{se:p,margin:f*p}}function r(m,c={}){if(!m||typeof m.length!="number"||m.length===0)return null;const f=X.includes(c.method)?c.method:"linear",s=Math.max(1,Math.floor(Number(c.horizon)||1)),p=Number.isFinite(c.confidence)&&c.confidence>0&&c.confidence<1?c.confidence:.95,b=1-(1-p)/2,S=H(m),j=S.map(C=>C.value),y=j.filter(C=>C!==null),v=y.length,{lastAt:R,step:O}=v?B(S):{lastAt:0,step:1},F=C=>R+C*O;return f==="linear"?t(S,v,s,p,b,F):f==="movingAverage"?n(y,v,s,p,b,c,F):f==="ses"?o(j,v,s,p,b,c,F):f==="holt"?d(j,v,s,p,b,c,F):l(j,v,s,p,b,c,F)}function t(m,c,f,s,p,b){if(c<2)return null;let S=0,j=0;for(const I of m)I.value!==null&&(S+=I.at,j+=I.value);S/=c,j/=c;let y=0,v=0,R=0;for(const I of m){if(I.value===null)continue;const P=I.at-S,k=I.value-j;y+=P*P,v+=P*k,R+=k*k}if(y===0)return null;const O=v/y,F=j-O*S,C=R===0?1:Math.max(0,Math.min(1,v*v/(y*R))),T=Math.max(0,R-O*v),L=c>2?Math.sqrt(T/(c-2)):null,E=c>2?z(p,c-2):null,D=[];for(let I=1;I<=f;I++){const P=b(I),k=F+O*P;let N=null,G=null,q=null,Y=null,J=null;if(L!==null){const ee=1/c+(P-S)**2/y,re=L*Math.sqrt(1+ee),ie=L*Math.sqrt(ee);J=re,N=k-E*re,G=k+E*re,q=k-E*ie,Y=k+E*ie}D.push({step:I,at:P,mean:k,lower:N,upper:G,lowerMean:q,upperMean:Y,se:J})}return{method:"linear",horizon:f,confidence:s,n:c,sigma:L,r2:C,params:{slope:O,intercept:F},points:D}}function n(m,c,f,s,p,b,S){if(c<1)return null;const j=Math.max(1,Math.min(c,Math.floor(Number(b.windowLen)||c))),y=m.slice(c-j);let v=0;for(const L of y)v+=L;const R=v/j;let O=null,F=null;if(j>1){let L=0;for(const D of y)L+=(D-R)**2;O=Math.sqrt(L/(j-1))*Math.sqrt(1+1/j),F=z(p,j-1)}const C=O===null?null:F*O,T=[];for(let L=1;L<=f;L++)T.push({step:L,at:S(L),mean:R,lower:C===null?null:R-C,upper:C===null?null:R+C,se:O});return{method:"movingAverage",horizon:f,confidence:s,n:c,sigma:O===null?null:O,params:{windowLen:j},points:T}}function o(m,c,f,s,p,b,S){if(c<1)return null;let j=Number.isFinite(b.alpha)?w(b.alpha):null;j===null&&(j=A(F=>g(m,F).sse));const y=g(m,j),v=x(p),R=y.m>0?y.sse/y.m:null,O=[];for(let F=1;F<=f;F++){const C=y.level;let T=null,L=null,E=null;if(R!==null){const D=[];for(let P=1;P<F;P++)D.push(j);const I=a(R,D,v);E=I.se,T=C-I.margin,L=C+I.margin}O.push({step:F,at:S(F),mean:C,lower:T,upper:L,se:E})}return{method:"ses",horizon:f,confidence:s,n:c,sigma:R===null?null:Math.sqrt(R),params:{alpha:j},points:O}}function d(m,c,f,s,p,b,S){if(c<2)return null;let j=Number.isFinite(b.alpha)?w(b.alpha):null,y=Number.isFinite(b.beta)?w(b.beta):null;if(j===null||y===null){let T=j===null?.5:j,L=y===null?.5:y;for(let E=0;E<6;E++)j===null&&(T=A(D=>u(m,D,L).sse)),y===null&&(L=A(D=>u(m,T,D).sse));j=j===null?T:j,y=y===null?L:y}const v=u(m,j,y),R=x(p),O=v.m>0?v.sse/v.m:null,F=j*y,C=[];for(let T=1;T<=f;T++){const L=v.level+T*v.trend;let E=null,D=null,I=null;if(O!==null){const P=[];for(let N=1;N<T;N++)P.push(j+N*F);const k=a(O,P,R);I=k.se,E=L-k.margin,D=L+k.margin}C.push({step:T,at:S(T),mean:L,lower:E,upper:D,se:I})}return{method:"holt",horizon:f,confidence:s,n:c,sigma:O===null?null:Math.sqrt(O),params:{alpha:j,beta:y},points:C}}function l(m,c,f,s,p,b,S){const j=Math.floor(Number(b.period));if(!(j>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(c<2*j)return null;let y=Number.isFinite(b.alpha)?w(b.alpha):null,v=Number.isFinite(b.beta)?w(b.beta):null,R=Number.isFinite(b.gamma)?w(b.gamma):null;const O=(I,P,k)=>{const N=h(m,j,I,P,k);return N?N.sse:1/0};if(y===null||v===null||R===null){let I=y===null?.5:y,P=v===null?.5:v,k=R===null?.5:R;for(let N=0;N<8;N++)y===null&&(I=A(G=>O(G,P,k))),v===null&&(P=A(G=>O(I,G,k))),R===null&&(k=A(G=>O(I,P,G)));y=y===null?I:y,v=v===null?P:v,R=R===null?k:R}const F=h(m,j,y,v,R);if(!F)return null;const C=x(p),T=F.count>0?F.sse/F.count:null,L=y*v,E=R*(1-y),D=[];for(let I=1;I<=f;I++){const P=F.season[(F.phase+I)%j],k=F.level+I*F.trend+P;let N=null,G=null,q=null;if(T!==null){const Y=[];for(let ee=1;ee<I;ee++)Y.push(y+ee*L+(ee%j===0?E:0));const J=a(T,Y,C);q=J.se,N=k-J.margin,G=k+J.margin}D.push({step:I,at:S(I),mean:k,lower:N,upper:G,se:q})}return{method:"holtWinters",horizon:f,confidence:s,n:c,sigma:T===null?null:Math.sqrt(T),params:{alpha:y,beta:v,gamma:R,period:j},points:D}}const i={FORECAST_METHODS:X,forecast:r}}),Fe("packages/core/src/compute/hypothesis.js",function(e,K){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return C}});const x=K("packages/core/src/internal/util.js").warnOnce,$=K("packages/core/src/compute/handle.js").valueReader,_=K("packages/core/src/compute/statistics.js"),X=_.numbers,W=_.moments,V=_.frequencyMap,H=_.categoricalDistance,B=_.isNumericColumn,w=_.jarqueBera,A=_.proportionInterval,g=_.SUBSET_RELIABILITY_FLOOR,h=K("packages/core/src/compute/compare.js").pooledStandardMeanDifference,a=K("packages/core/src/compute/special.js"),r=a.studentT,t=a.studentTQuantile,n=a.normalCdf,o=a.normalQuantile,d=a.chiSquareUpperTail,l=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),i=.05,m=2e6;function c(T){const L=Number(T);return Number.isFinite(L)&&L>0&&L<1?L:.95}function f(T){const{n:L,mean:E,m2:D}=W(T);return{mean:E,sd:L>0?Math.sqrt(D/L):0,n:L}}function s(T,L){const E=T.length;if(E<2)return 0;let D=0;for(let I=0;I<E;I++){const P=T[I]-L;D+=P*P}return D/(E-1)}function p(T,L){return{name:"pooledStandardMeanDifference",value:h(f(T),f(L))}}function b(T,L,E){const D=T.length,I=L.length;if(D<2||I<2)return null;const P=c(E),{mean:k}=W(T),{mean:N}=W(L),G=s(T,k),q=s(L,N),Y=G/D+q/I;if(!(Y>0))return null;const J=Math.sqrt(Y),ee=(k-N)/J,re=G/D*(G/D)/(D-1),ie=q/I*(q/I)/(I-1),ae=Y*Y/(re+ie),fe=Math.min(1,Math.max(0,2*(1-r(Math.abs(ee),ae)))),ce=k-N,te=t(1-(1-P)/2,ae)*J;return{test:l.WELCH,statistic:ee,statisticName:"t",df:ae,pValue:fe,interval:{estimate:ce,lower:ce-te,upper:ce+te,confidence:P,method:"welch-t (difference of means)"},effectSize:p(T,L),nA:D,nB:I,reliable:D>=g&&I>=g,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function S(T){const L=T.length;if(L===0)return Number.NaN;const E=L>>1;return L%2?T[E]:(T[E-1]+T[E])/2}function j(T,L,E){const D=T.length,I=L.length,P=D*I;if(P===0||P>m)return null;const k=new Float64Array(P);let N=0;for(let re=0;re<D;re++)for(let ie=0;ie<I;ie++)k[N++]=T[re]-L[ie];k.sort();const G=S(k),q=Math.sqrt(D*I*(D+I+1)/12),Y=o(1-(1-E)/2);let J=Math.round(P/2-Y*q);J>=0||(J=0);const ee=Math.floor((P-1)/2);return J>ee&&(J=ee),{estimate:G,lower:k[J],upper:k[P-1-J],confidence:E,method:"hodges-lehmann (normal approximation)"}}function y(T,L,E){const D=T.length,I=L.length;if(D<1||I<1)return null;const P=c(E),k=D+I,N=new Array(k);for(let fe=0;fe<D;fe++)N[fe]={v:T[fe],g:0};for(let fe=0;fe<I;fe++)N[D+fe]={v:L[fe],g:1};N.sort((fe,ce)=>fe.v-ce.v);let G=0,q=0,Y=0;for(;Y<k;){let fe=Y;for(;fe<k&&N[fe].v===N[Y].v;)fe++;const ce=fe-Y,te=(Y+1+fe)/2;for(let oe=Y;oe<fe;oe++)N[oe].g===0&&(G+=te);q+=ce*ce*ce-ce,Y=fe}const J=G-D*(D+1)/2,ee=D*I/2,re=D*I/12*(k+1-q/(k*(k-1)));let ie=1;if(re>0){const fe=Math.max(0,Math.abs(J-ee)-.5);ie=Math.min(1,2*n(-fe/Math.sqrt(re)))}const ae=j(T,L,P);return{test:l.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:ie,interval:ae,effectSize:p(T,L),nA:D,nB:I,reliable:D>=g&&I>=g,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function v(T,L,E,D,I){const P=A(T,L,I),k=A(E,D,I);if(!P||!k)return null;const N=P.proportion-k.proportion,G=N-Math.sqrt((P.proportion-P.lower)**2+(k.upper-k.proportion)**2),q=N+Math.sqrt((P.upper-P.proportion)**2+(k.proportion-k.lower)**2);return{lower:G,upper:q}}function R(T,L,E,D,I,P={}){if(!(L>0)||!(D>0))return null;const k=new Set([...T.keys(),...E.keys()]),N=k.size;if(N<2)return null;const G=L+D;let q=0;for(const ie of k){const ae=T.get(ie)||0,fe=E.get(ie)||0,ce=ae+fe,te=L*ce/G,oe=D*ce/G;te>0&&(q+=(ae-te)*(ae-te)/te),oe>0&&(q+=(fe-oe)*(fe-oe)/oe)}const Y=N-1,J=d(q,Y);let ee=null;P.category!==void 0&&k.has(P.category)?ee=P.category:N===2&&([ee]=[...k]);let re=null;if(ee!==null){const ie=v(T.get(ee)||0,L,E.get(ee)||0,D,c(I));ie&&(re={estimate:(T.get(ee)||0)/L-(E.get(ee)||0)/D,lower:ie.lower,upper:ie.upper,confidence:c(I),method:"newcombe (difference in this category's share)",category:ee})}return{test:l.CHI_SQUARE,statistic:q,statisticName:"chiSquare",df:Y,pValue:J,interval:re,effectSize:{name:"categoricalTotalVariation",value:H(T,L,E,D)},nA:L,nB:D,reliable:L>=g&&D>=g,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function O(T){return T==null||T===""||typeof T=="number"&&Number.isNaN(T)?null:T instanceof Date?T.getTime():typeof T=="object"?String(T):T}function F(T,L,E){if(E===l.WELCH||E===l.MANN_WHITNEY)return{test:E,chosenBy:"override",reason:`caller override: ${E}`};const D=w(T),I=w(L),P=D===null?null:Math.exp(-D/2),k=I===null?null:Math.exp(-I/2);return P!==null&&P<i||k!==null&&k<i?{test:l.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${i})`}:{test:l.WELCH,chosenBy:"auto",reason:P!==null||k!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function C(T,L,E,D={}){if(!T||!L)return null;const I=c(D.confidence),P=$(L);let k;if(Array.isArray(D.groups)&&D.groups.length===2)k=[O(D.groups[0]),O(D.groups[1])];else{const{map:fe}=V(L,E),ce=[...fe.entries()].sort((te,oe)=>oe[1]-te[1]).slice(0,2).map(te=>te[0]);if(ce.length<2)return x("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;k=ce}const[N,G]=k;if(N===null||G===null||N===G)return x("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const q=[],Y=[];for(let fe=0;fe<E.length;fe++){const ce=O(P(E[fe]));ce===N?q.push(E[fe]):ce===G&&Y.push(E[fe])}if(q.length===0||Y.length===0)return x("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=D.test&&D.test!=="auto"?String(D.test):null,ee=B(T,q.concat(Y));let re,ie,ae;if(J===l.CHI_SQUARE||!J&&!ee){ie=J?"override":"auto",ae=J?"caller override: chiSquare":"column family: categorical";const fe=V(T,q),ce=V(T,Y);re=R(fe.map,fe.total,ce.map,ce.total,I,{category:D.category})}else{if((J===l.WELCH||J===l.MANN_WHITNEY)&&!ee)return x("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const fe=X(T,q),ce=X(T,Y),te=F(fe,ce,J);ie=te.chosenBy,ae=te.reason,re=te.test===l.MANN_WHITNEY?y(fe,ce,I):b(fe,ce,I)}return re?{...re,chosenBy:ie,reason:ae,groups:[N,G]}:(x("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Fe("packages/core/src/columns/detailcolumn.js",function(e,K){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q="__lattice_detail",x=36;function z(_){const X=_.config&&_.config.detailColumnWidth||x;return{id:Q,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:X,min:X,max:X,pin:_.config&&_.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(W,V){return!!(V&&V.expanded)},formatValue(){return""}}}const $=z}),Fe("packages/core/src/columns/treecolumn.js",function(e,K){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,z="__lattice_tree",$=260;function _(W){const V=W.tree||{},H=W.config&&W.config.treeColumnWidth||$,B=()=>(W.columns&&x(W.columns.visible)?W.columns.visible():[]).find(u=>!u.generated)||null,w=(g,u)=>{if(u&&u.group)return u.groupValue;if(x(V.label))return V.label(g,u);if(typeof V.label=="string")return g==null?null:g[V.label];const h=B();return h&&x(h.getValue)?h.getValue(g,u):null},A=()=>{if(V.title)return V.title;const g=typeof V.label=="string"?W.columns&&x(W.columns.get)?W.columns.get(V.label):null:B();return g&&(g.title||g.id)||"Hierarchy"};return{id:z,get title(){return A()},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:H,min:140,pin:W.config&&W.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(g,u){return w(g,u)},formatValue(g,u){if(u&&u.grandTotal)return W.config&&W.config.grandTotalLabel||"Total";if(g==null)return"";if(!V.label){const h=B();if(h&&x(h.formatValue))return h.formatValue(g,u)}return String(g)}}}const X=_}),Fe("packages/core/src/columns/pivotcolumns.js",function(e,K){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return _}});const x=K("packages/core/src/internal/util.js").warnOnce,z="__lattice_pivot",$=500;function _(H){const{pivot:B,valueColumns:w,config:A}=H,g=B&&B.paths||[],u=H.separator||A&&A.pivot&&A.pivot.separator||" | ",h=A&&A.pivot&&A.pivot.maxColumns||$;if(!g.length||!w.length)return{tree:[],leaves:[],error:null};const a=X(A),r=g.length*w.length+(a?w.length:0);if(r>h){const o=`pivot would generate ${r} columns, above the limit of ${h}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return x(`pivot.maxColumns:${r}`,o),{tree:[],leaves:[],error:o}}const t=[],n=[];for(const o of g){const d=[];for(const l of w){const i=V(o,l,u);d.push(i),n.push(i)}d.length===1?(d[0].title=String(o),t.push(d[0])):t.push({id:`${z}:group:${o}`,title:String(o),columns:d,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(a){const o=w.map(l=>W(l,A));n.push(...o);const d=A&&A.pivot&&A.pivot.totalsLabel||"Total";if(o.length===1)o[0].title=d,a==="before"?t.unshift(o[0]):t.push(o[0]);else{const l={id:`${z}:group:__totals`,title:d,columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};a==="before"?t.unshift(l):t.push(l)}}return{tree:t,leaves:n,error:null}}function X(H){const B=H&&H.pivot&&H.pivot.groupTotals;return B==="before"||B==="after"?B:null}function W(H,B){return{id:`${z}:__total${B&&B.pivot&&B.pivot.separator||" | "}${H.id}`,field:null,title:H.title||H.id,type:H.type,dataType:H.dataType,nullable:!0,align:H.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:H.id,total:!0},value:{pure:!0},cell:{align:H.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:H.total,lookup:null,layout:{width:H.layout&&H.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(w,A){const g=A&&A.totals;return g&&Object.hasOwn(g,H.id)?g[H.id]:null},formatValue(w,A){return w==null?"":H.formatValue?H.formatValue(w,A):String(w)}}}function V(H,B,w){return{id:`${z}:${H}${w}${B.id}`,field:null,title:B.title||B.id,type:B.type,dataType:B.dataType,nullable:!0,align:B.align,generated:!0,pivot:{enabled:!1,index:0,path:H,sourceId:B.id},value:{pure:!0},cell:{align:B.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:B.total,lookup:null,layout:{width:B.layout&&B.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(A,g){return A==null?"":B.formatValue?B.formatValue(A,g):String(A)}}}}),Fe("packages/core/src/compute/group.js",function(e,K){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return A}});const Q=K("packages/core/src/compute/handle.js"),x=Q.dictSize,z=Q.identity,$=Q.presenceReader,_=Q.rowCount,X=Q.valueReader,W="",V="\0",H=1<<20;function B(g,u,h,a){const r=g.length,t=g.map(m=>X(m)),n=Array.isArray(a)&&a.some(Boolean),o=n?t.map((m,c)=>a[c]?f=>a[c](m(f)):m):t;if(!n&&r>0&&g.every(m=>m&&m.kind==="dictionary"&&m.dict)){const m=g.map(f=>x(f.dict)+1);let c=1;for(let f=0;f<r;f++)c*=m[f];if(c<=Number.MAX_SAFE_INTEGER){const f=g.map(S=>S.values),s=g.map(S=>$(S)),p=S=>{let j=0;for(let y=0;y<r;y++){const v=s[y],R=v&&v(S)===0?m[y]-1:f[y][S];j=j*m[y]+R}return j},b=new Float64Array(h);for(let S=0;S<h;S++)b[S]=p(u[S]);return{packed:b,strings:null,product:c,readers:o,keyOf:p}}}const l=m=>{let c="";for(let f=0;f<r;f++){const s=o[f](m);c+=(f===0?"":W)+(s==null?V:String(s))}return c},i=new Array(h);for(let m=0;m<h;m++)i[m]=l(u[m]);return{packed:null,strings:i,product:1/0,readers:o,keyOf:l}}function w(g,u,h,a){const r=new Uint32Array(a+1);for(let d=0;d<h;d++)r[u[d]+1]++;for(let d=0;d<a;d++)r[d+1]+=r[d];const t=new Uint32Array(h),n=r.slice(0,a);for(let d=0;d<h;d++)t[n[u[d]]++]=g[d];const o=new Array(a);for(let d=0;d<a;d++)o[d]=t.subarray(r[d],r[d+1]);return o}function A(g,u,h={}){const a=g||[],r=u||z(_(a[0],h)),t=r.length;if(a.length===0||t===0)return{keys:[],buckets:[]};const{packed:n,strings:o,product:d,readers:l}=B(a,r,t,h.project),i=new Uint32Array(t);let m=0,c=null;if(n&&d<=Math.max(1024,Math.min(H,t*4))){const b=d,S=new Int32Array(b).fill(-1);for(let j=0;j<t;j++)S[n[j]]=0;for(let j=0;j<b;j++)S[j]===0&&(S[j]=m++);for(let j=0;j<t;j++)i[j]=S[n[j]];c=new Float64Array(m);for(let j=0;j<b;j++)S[j]>=0&&(c[S[j]]=j)}else if(n){const b=new Map;for(let S=0;S<t;S++){const j=n[S];let y=b.get(j);y===void 0&&(y=m++,b.set(j,y)),i[S]=y}c=new Float64Array(m);for(const[S,j]of b)c[j]=S}else{const b=new Map;for(let S=0;S<t;S++){const j=o[S];let y=b.get(j);y===void 0&&(y=m++,b.set(j,y)),i[S]=y}}const f=w(r,i,t,m),s=new Array(m);for(let b=0;b<m;b++){const S=f[b][0],j=new Array(l.length);for(let y=0;y<l.length;y++)j[y]=l[y](S);s[b]=j}const p={keys:s,buckets:f};return c&&(p.packed=c),p}}),Fe("packages/core/src/compute/pivot.js",function(e,K){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const x=K("packages/core/src/internal/util.js").warnOnce,$=K("packages/core/src/compute/handle.js").valueComparator,X=K("packages/core/src/compute/group.js").packKeys,V=K("packages/core/src/compute/total.js").total,H="|",B="/",w=2e3;function A(d,l,i){return`${d}${H}${l}${H}${i}`}function g(d,l){let i="";for(let m=0;m<d.length;m++){const c=d[m];i+=(m===0?"":l)+(c==null?"":String(c))}return i}function u(d,l,i={}){const m=i.separator||B,c=l.length,{keyOf:f,readers:s}=X(d,l,0),p=new Map,b=[],S=[];for(let C=0;C<c;C++){const T=l[C],L=f(T);if(p.has(L))continue;p.set(L,b.length),S.push(L);const E=new Array(s.length);for(let D=0;D<s.length;D++)E[D]=s[D](T);b.push(E)}const j=$(i.locale),y=b.map((C,T)=>T);y.sort((C,T)=>{const L=b[C],E=b[T];for(let D=0;D<L.length;D++){const I=h(L[D],E[D],j);if(I!==0)return I}return C-T});const v=new Array(y.length),R=new Array(y.length),O=new Map;for(let C=0;C<y.length;C++){const T=y[C];v[C]=b[T],R[C]=g(b[T],m),O.set(S[T],C)}return{keys:v,paths:R,idOf:C=>{const T=O.get(f(C));return T===void 0?-1:T}}}function h(d,l,i){const m=d==null,c=l==null;return m||c?m&&c?0:m?1:-1:i(d,l)}function a(d){const l=d.values||d.totals||[];if(l.length&&typeof l[0]=="object"&&l[0]!==null)return l.filter(f=>f&&f.handle);const i=typeof d.handle=="function"?d.handle:null;if(!i)return l.length&&x("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 m=typeof d.totalOf=="function"?d.totalOf:null,c=[];for(const f of l){const s=i(f);s&&c.push({colId:f,handle:s,fn:m?m(f):"sum"})}return c}function r(d,l,i){if(Array.isArray(d)){const m=i||{};return{...m,pivotHandles:d,order:l||null,groups:m.groups||null}}return d||{}}function t(d,l,i){const m=r(d,l,i),c=m.separator||B,f=a(m),s=m.maxColumns===void 0?w:m.maxColumns,p=m.groups&&m.groups.buckets?m.groups:null,b=p?p.buckets:[m.order||new Uint32Array(0)],S=m.groupPaths||(p?p.keys.map(L=>g(L,c)):[""]),j=o(b),{keys:y,paths:v,idOf:R}=u(m.pivotHandles||[],j,m),O=v.length*Math.max(1,f.length),F=n(v,f,c);if(s&&O>s){const L=new Map;return{keys:y,paths:v,fields:F,groupPaths:S,columns:O,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${O} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:O,maxColumns:s}}}const C=new Map,T=v.length;for(let L=0;L<b.length;L++){const E=b[L],D=S[L]===void 0?"":S[L],I=E.length;if(I===0)continue;const P=new Int32Array(I),k=new Uint32Array(T+1);for(let q=0;q<I;q++){const Y=R(E[q]);P[q]=Y,Y>=0&&k[Y+1]++}for(let q=0;q<T;q++)k[q+1]+=k[q];const N=new Uint32Array(I),G=k.slice(0,T);for(let q=0;q<I;q++){const Y=P[q];Y>=0&&(N[G[Y]++]=E[q])}for(let q=0;q<T;q++){const Y=k[q],J=k[q+1];if(J===Y)continue;const ee=N.subarray(Y,J);for(let re=0;re<f.length;re++){const ie=f[re],ae=V(ie.handle,ee,ie.fn,m.totalContext||{locale:m.locale});C.set(A(D,v[q],ie.colId),ae)}}}return{keys:y,paths:v,fields:F,groupPaths:S,columns:O,values:C,cells:C,error:null}}function n(d,l,i){if(l.length===0)return d.slice();const m=[];for(const c of d)for(const f of l)m.push(`${c}${i}${f.colId}`);return m}function o(d){if(d.length===1)return d[0]||new Uint32Array(0);let l=0;for(const c of d)l+=c?c.length:0;const i=new Uint32Array(l);let m=0;for(const c of d)!c||c.length===0||(i.set(c,m),m+=c.length);return i}}),Fe("packages/core/src/store/bitset.js",function(e,K){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return x}});const Q=8;class x{static#e=new Uint8Array(256);static{for(let $=1;$<256;$++)x.#e[$]=x.#e[$>>1]+($&1)}#t;#n;constructor($=0){const _=Math.max(0,$|0);this.#n=_,this.#t=new Uint8Array(Math.ceil(_/Q))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get($){return $<0||$>=this.#n?0:this.#t[$>>3]>>($&7)&1}set($){return $>=0&&$<this.#n&&(this.#t[$>>3]|=1<<($&7)),this}clear($){return $>=0&&$<this.#n&&(this.#t[$>>3]&=~(1<<($&7))),this}assign($,_){return _?this.set($):this.clear($)}fill($=!1){return this.#t.fill($?255:0),$&&this.#r(),this}grow($){const _=Math.max(0,$|0);if(_<=this.#n)return this;const X=Math.ceil(_/Q);if(X>this.#t.length){const W=new Uint8Array(X);W.set(this.#t),this.#t=W}return this.#n=_,this}count(){const $=this.#t,_=x.#e;let X=0;for(let W=0;W<$.length;W++)X+=_[$[W]];return X}and($){const _=$ instanceof x?$.words:$,X=this.#t,W=Math.min(X.length,_.length);for(let V=0;V<W;V++)X[V]&=_[V];for(let V=W;V<X.length;V++)X[V]=0;return this}or($){const _=$ instanceof x?$.words:$,X=this.#t,W=Math.min(X.length,_.length);for(let V=0;V<W;V++)X[V]|=_[V];return this}not(){const $=this.#t;for(let _=0;_<$.length;_++)$[_]=~$[_]&255;return this.#r(),this}clone(){const $=new x(this.#n);return $.words.set(this.#t.subarray(0,$.words.length)),$}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const $=this.#n&7;if($===0)return;const _=this.#n>>3;_<this.#t.length&&(this.#t[_]&=(1<<$)-1)}static from($){const _=Array.isArray($)?$:Array.from($),X=new x(_.length);for(let W=0;W<_.length;W++)_[W]&&X.set(W);return X}}}),Fe("packages/core/src/store/dictionary.js",function(e,K){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return $}});const Q=K("packages/core/src/internal/util.js"),x=Q.collator,z=Q.defaultCompare;class ${#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(X=[]){this.#e=[];for(let W=0;W<X.length;W++){const V=X[W];this.#t.has(V)||(this.#t.set(V,this.#e.length),this.#e.push(V))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let X=this.#e.length*8;for(let W=0;W<this.#e.length;W++){const V=this.#e[W];typeof V=="string"&&(X+=V.length*2),X+=16}return X}codeOf(X){const W=this.#t.get(X);if(W!==void 0)return W;const V=this.#e.length;return this.#e.push(X),this.#t.set(X,V),this.#n++,V}lookup(X){const W=this.#t.get(X);return W===void 0?-1:W}has(X){return this.#t.has(X)}valueOf(X){return this.#e[X]}values(){return this.#e}ranks(X){const W=X||"";if(this.#r&&this.#o===this.#n&&this.#i===W)return this.#r;const V=this.#e.length,H=new Array(V);for(let g=0;g<V;g++)H[g]=g;const B=x(X).compare,w=this.#e;H.sort((g,u)=>this.#s(w[g],w[u],B));const A=new Uint32Array(V);for(let g=0;g<V;g++)A[H[g]]=g;return this.#r=A,this.#o=this.#n,this.#i=W,A}#s(X,W,V){return typeof X=="string"&&typeof W=="string"?V(X,W):z(X,W)}}}),Fe("packages/core/src/store/multivalue.js",function(e,K){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return Q}});class Q{#e;#t;#n=0;#r=0;constructor(z={}){const $=Math.max(1,z.rows??16),_=Math.max(1,z.values??$);this.#e=new Int32Array(_),this.#t=new Uint32Array($+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(z){return z<0||z>=this.#n?0:this.#t[z+1]-this.#t[z]}at(z){return z<0||z>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[z],this.#t[z+1])}has(z,$){if(z<0||z>=this.#n)return!1;const _=this.#e,X=this.#t[z+1];for(let W=this.#t[z];W<X;W++)if(_[W]===$)return!0;return!1}hasAny(z,$){for(let _=0;_<$.length;_++)if(this.has(z,$[_]))return!0;return!1}hasAll(z,$){for(let _=0;_<$.length;_++)if(!this.has(z,$[_]))return!1;return!0}hasNone(z,$){return!this.hasAny(z,$)}push(z){const $=this.#n,_=z.length;this.#o($+1),this.#i(this.#r+_);const X=this.#r;for(let W=0;W<_;W++)this.#e[X+W]=z[W]|0;return this.#r+=_,this.#n=$+1,this.#t[$]=X,this.#t[$+1]=this.#r,$}write(z,$){if(z===this.#n){this.push($);return}if(z<0||z>this.#n)return;const _=this.#t[z],X=this.#t[z+1],W=$.length;if(X-_===W){for(let V=0;V<W;V++)this.#e[_+V]=$[V]|0;return}this.#s(z,$)}compact(z,$,_){const X=this.#e,W=this.#t,V=this.#n,H=new Int32Array(Math.max(1,this.#r)),B=new Uint32Array($+1);let w=0;for(let A=0;A<V;A++){if(z[A]===_)continue;const g=W[A],u=W[A+1];B[z[A]]=w;for(let h=g;h<u;h++)H[w++]=X[h];B[z[A]+1]=w}this.#e=H,this.#t=B,this.#n=$,this.#r=w}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#o(z){if(z+1<=this.#t.length)return;let $=this.#t.length-1;for(;$<z;)$=$*2||16;const _=new Uint32Array($+1);_.set(this.#t),this.#t=_}#i(z){if(z<=this.#e.length)return;let $=this.#e.length;for(;$<z;)$=$*2||16;const _=new Int32Array($);_.set(this.#e),this.#e=_}#s(z,$){const _=this.#e,X=this.#t,W=this.#n,V=$.length-(X[z+1]-X[z]),H=new Int32Array(Math.max(1,this.#r+V)),B=new Uint32Array(X.length);let w=0;for(let A=0;A<W;A++){if(B[A]=w,A===z)for(let g=0;g<$.length;g++)H[w++]=$[g]|0;else for(let g=X[A];g<X[A+1];g++)H[w++]=_[g];B[A+1]=w}this.#e=H,this.#t=B,this.#r=w}}}),Fe("packages/core/src/compute/sort.js",function(e,K){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/compute/handle.js"),x=Q.bitReader,z=Q.dictRanks,$=Q.dictSize,_=Q.identity,X=Q.isMissing,W=Q.presenceReader,V=Q.rowCount,H=Q.valueComparator,B=Q.valueReader,w=new Uint32Array(0),A=new ArrayBuffer(8),g=new Float64Array(A),u=new Uint32Array(A),h=(g[0]=-1,(u[1]&2147483648)!==0?1:0),a=h===1?0:1;function r(E,D){g[0]=E;let I=u[h],P=u[a];(I&2147483648)!==0?(I=~I>>>0,P=~P>>>0):I=(I^2147483648)>>>0,D[0]=P,D[1]=I}function t(E,D,I,P){if(P<2)return E;const k=new Uint32Array(256*8);for(let ie=0;ie<P;ie++){const ae=D[ie],fe=I[ie];k[ae&255]++,k[256+(ae>>>8&255)]++,k[512+(ae>>>16&255)]++,k[768+(ae>>>24&255)]++,k[1024+(fe&255)]++,k[1280+(fe>>>8&255)]++,k[1536+(fe>>>16&255)]++,k[1792+(fe>>>24&255)]++}let N=E,G=D,q=I,Y=new Uint32Array(P),J=new Uint32Array(P),ee=new Uint32Array(P);const re=new Uint32Array(256);for(let ie=0;ie<8;ie++){const ae=ie<<8,fe=(ie&3)<<3,ce=ie>=4;let te=!1;for(let de=0;de<256;de++)if(k[ae+de]===P){te=!0;break}if(te)continue;let oe=0;for(let de=0;de<256;de++)re[de]=oe,oe+=k[ae+de];for(let de=0;de<P;de++){const be=G[de],Te=q[de],Ae=(ce?Te:be)>>>fe&255,Ce=re[Ae]++;Y[Ce]=N[de],J[Ce]=be,ee[Ce]=Te}let he=N;N=Y,Y=he,he=G,G=J,J=he,he=q,q=ee,ee=he}return N}function n(E,D,I){if(I<2)return E;const P=new Uint32Array(256*4);for(let J=0;J<I;J++){const ee=D[J];P[ee&255]++,P[256+(ee>>>8&255)]++,P[512+(ee>>>16&255)]++,P[768+(ee>>>24&255)]++}let k=E,N=D,G=new Uint32Array(I),q=new Uint32Array(I);const Y=new Uint32Array(256);for(let J=0;J<4;J++){const ee=J<<8,re=J<<3;let ie=!1;for(let ce=0;ce<256;ce++)if(P[ee+ce]===I){ie=!0;break}if(ie)continue;let ae=0;for(let ce=0;ce<256;ce++)Y[ce]=ae,ae+=P[ee+ce];for(let ce=0;ce<I;ce++){const te=N[ce],oe=Y[te>>>re&255]++;G[oe]=k[ce],q[oe]=te}let fe=k;k=G,G=fe,fe=N,N=q,q=fe}return k}function o(E,D,I,P){const k=new Uint32Array(P+1);for(let q=0;q<I;q++)k[D[q]]++;let N=0;for(let q=0;q<=P;q++){const Y=k[q];k[q]=N,N+=Y}const G=new Uint32Array(I);for(let q=0;q<I;q++)G[k[D[q]]++]=E[q];return G}function d(E,D,I,P){return I<2?E:P<=65536||P<=I*2?o(E,D,I,P):n(E,D,I)}function l(E,D){return E.length===D&&E.byteOffset===0?E:Uint32Array.prototype.slice.call(E,0,D)}function i(E,D,I=!1){const P=D||_(E.length),k=P.length;if(k<2)return Uint32Array.from(P);const N=new Uint32Array(k),G=new Uint32Array(k),q=new Uint32Array(k),Y=new Uint32Array(k),J=new Uint32Array(2);let ee=0,re=0;for(let fe=0;fe<k;fe++){const ce=P[fe],te=E[ce];if(Number.isNaN(te)){Y[re++]=ce;continue}r(te,J),I?(G[ee]=~J[0]>>>0,q[ee]=~J[1]>>>0):(G[ee]=J[0],q[ee]=J[1]),N[ee++]=ce}const ie=t(N.subarray(0,ee),G.subarray(0,ee),q.subarray(0,ee),ee);if(re===0)return l(ie,ee);const ae=new Uint32Array(k);return ae.set(ie.subarray(0,ee),0),ae.set(Y.subarray(0,re),ee),ae}function m(E,D,I=!1){const P=D||_(E.length),k=P.length;if(k<2)return Uint32Array.from(P);const N=Uint32Array.from(P),G=new Uint32Array(k);for(let q=0;q<k;q++){const Y=(E[N[q]]^2147483648)>>>0;G[q]=I?~Y>>>0:Y}return l(n(N,G,k),k)}function c(E,D,I={}){const P=D||_(V(E,I)),k=P.length;if(k<2)return Uint32Array.from(P);const N=z(E.dict,I.locale),G=E.values,q=W(E),Y=Math.max($(E.dict),N.length),J=Y,ee=Uint32Array.from(P),re=new Uint32Array(k),ie=!!I.descending;for(let ae=0;ae<k;ae++){const fe=ee[ae];let ce=q&&q(fe)===0?J:N[G[fe]];ce===void 0&&(ce=J),re[ae]=ie?J-ce:ce}return l(d(ee,re,k,Y+1),k)}function f(E,D,I){const P=D.length;let k=Uint32Array.from(D);if(P<2)return k;let N=new Uint32Array(P);for(let G=1;G<P;G<<=1){for(let Y=0;Y<P;Y+=G<<1){const J=Math.min(Y+G,P),ee=Math.min(Y+(G<<1),P);let re=Y,ie=J,ae=Y;for(;re<J&&ie<ee;)N[ae++]=I(E[k[re]],E[k[ie]])<=0?k[re++]:k[ie++];for(;re<J;)N[ae++]=k[re++];for(;ie<ee;)N[ae++]=k[ie++]}const q=k;k=N,N=q}return k}function s(E,D,I){const P=x(E.values),k=D.length,N=new Uint32Array(k),G=I?1:0;let q=0;for(let Y=0;Y<k;Y++)P(D[Y])===G&&(N[q++]=D[Y]);for(let Y=0;Y<k;Y++)P(D[Y])!==G&&(N[q++]=D[Y]);return N}function p(E,D){const I=E.values,P=E.kind;if((P==="object"||P===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!E.presence)return I;const N=B(E),G=new Array(V(E)||0);for(let q=0;q<D.length;q++){const Y=D[q];G[Y]=N(Y)}return G}function b(E,D){for(let I=0;I<D.length;I++)if(typeof E[D[I]]!="string")return!1;return!0}function S(E,D,I,P,k){const N=E.length,G=Uint32Array.from(E);if(N<2||P<1)return G;const q=new Uint32Array(N),Y=P-1;for(let J=0;J<N;J++){const ee=I[D[J]];q[J]=k?Y-ee:ee}return l(d(G,q,N,P),N)}function j(E,D,I){const P=H(I),k=new Array(D);for(let G=0;G<D;G++)k[G]=G;k.sort((G,q)=>P(E[G],E[q])||G-q);const N=new Uint32Array(D);for(let G=0;G<D;G++)N[k[G]]=G;return N}function y(E,D,I){const P=D.length,k=new Map,N=[],G=new Uint32Array(P);for(let J=0;J<P;J++){const ee=E[D[J]];let re=k.get(ee);re===void 0&&(re=N.length,k.set(ee,re),N.push(ee)),G[J]=re}const q=N.length,Y=j(N,q,I.locale);return S(D,G,Y,q,!!I.descending)}function v(E,D,I){const P=p(E,D);if(D.length>=2&&b(P,D)){const G=E.stringRank;return G&&G.version===E.version&&G.usable(D,P,I.locale)?G.sort(D,I):y(P,D,I)}const k=H(I.locale),N=I.descending?(G,q)=>k(q,G):k;return f(P,D,N)}function R(E,D,I){const P=p(E,D),k=I.compare,G=!!I.descending?(q,Y)=>-k(q,Y,void 0,void 0,!0):(q,Y)=>k(q,Y,void 0,void 0,!1);return f(P,D,G)}function O(E,D){const I=D.length,P=W(E),k=E.values,N=E.kind==="float64"&&!!k,G=E.kind==="object"||E.kind==="multi"||E.kind===void 0;if(!P&&!N&&!G)return{present:D,absent:w};const q=new Uint32Array(I),Y=new Uint32Array(I);let J=0,ee=0;if(P&&N)for(let re=0;re<I;re++){const ie=D[re];P(ie)===1&&!Number.isNaN(k[ie])?q[J++]=ie:Y[ee++]=ie}else if(N&&!P)for(let re=0;re<I;re++){const ie=D[re];Number.isNaN(k[ie])?Y[ee++]=ie:q[J++]=ie}else if(P&&!G)for(let re=0;re<I;re++){const ie=D[re];P(ie)===1?q[J++]=ie:Y[ee++]=ie}else{const re=B(E);for(let ie=0;ie<I;ie++){const ae=D[ie];X(re(ae))?Y[ee++]=ae:q[J++]=ae}}return ee===0?{present:D,absent:w}:{present:q.subarray(0,J),absent:Y.subarray(0,ee)}}function F(E,D,I){if(D.length===0)return E;const P=new Uint32Array(E.length+D.length);return I?(P.set(D,0),P.set(E,D.length)):(P.set(E,0),P.set(D,E.length)),P}function C(E,D,I={}){const P=D||_(V(E,I));if(!E||P.length<2)return Uint32Array.from(P);const{present:k,absent:N}=O(E,P);if(k.length===0)return Uint32Array.from(P);const G=!!I.descending;let q;if(typeof I.compare=="function")q=R(E,k,I);else switch(E.kind){case"float64":q=i(E.values,k,G);break;case"int32":q=m(E.values,k,G);break;case"dictionary":q=c(E,k,I);break;case"bitset":q=s(E,k,G);break;default:q=v(E,k,I);break}return F(q,N,!!I.nullsFirst)}function T(E,D,I,P={}){const k=D||[],N=k.length&&(k[0].handle||L(E,k[0].col))||E&&E[0];let G=I||_(V(N,P));for(let q=k.length-1;q>=0;q--){const Y=k[q],J=Y.handle||L(E,Y.col)||E&&E[q];J&&(G=C(J,G,{descending:Y.descending!==void 0?!!Y.descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:Y.locale!==void 0?Y.locale:P.locale,compare:Y.compare}))}return G instanceof Uint32Array?G:Uint32Array.from(G)}function L(E,D){if(!(!E||D===void 0)){for(let I=0;I<E.length;I++)if(E[I]&&E[I].id===D)return E[I]}}}),Fe("packages/core/src/store/stringrank.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/compute/sort.js"),x=Q.collateStringRanks,z=Q.rankSortStrings,$=1e5;class _{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(W=$){this.#s=W>0?W:$,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(W){this.#i=W}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let W=this.#n.byteLength;const V=this.#e;for(let H=0;H<V.length;H++)W+=V[H].length*2+24;return W}#d(W,V){const H=this.#t.get(W);if(H!==void 0)return H;if(this.#l)return-1;if(V&&this.#e.length>=this.#s)return this.#l=!0,-1;const B=this.#e.length;return this.#e.push(W),this.#t.set(W,B),this.#o++,B}build(W,V){const H=V|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(H);for(let B=0;B<H;B++){const w=W[B],A=typeof w=="string"?this.#d(w,!1):-1;this.#n[B]=A<0?0:A}this.#r=H}append(W,V,H){const B=(V|0)+(H|0);if(B>this.#n.length){const w=new Uint32Array(B);w.set(this.#n.subarray(0,this.#r)),this.#n=w}for(let w=V|0;w<B;w++){const A=W[w],g=typeof A=="string"?this.#d(A,!0):-1;this.#n[w]=g<0?0:g}this.#r=Math.max(this.#r,B)}ranks(W){const V=W||"";if(this.#a&&this.#u===this.#o&&this.#c===V)return this.#a;const H=x(this.#e,this.#e.length,W);return this.#a=H,this.#u=this.#o,this.#c=V,H}usable(W,V,H){if(this.#l||this.#e.length===0)return!1;const B=this.#n,w=this.#e,A=this.#r;for(let g=0;g<W.length;g++){const u=W[g];if(u>=A||w[B[u]]!==V[u])return!1}return!0}sort(W,V){const H=this.ranks(V.locale),B=this.#e.length,w=W.length,A=new Uint32Array(w),g=this.#n;for(let u=0;u<w;u++)A[u]=g[W[u]];return z(W,A,H,B,!!V.descending)}}}),Fe("packages/core/src/store/columnstore.js",function(e,K){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.isFunction,$=Q.pathGetter,X=K("packages/core/src/store/bitset.js").Bitset,V=K("packages/core/src/store/dictionary.js").Dictionary,B=K("packages/core/src/store/multivalue.js").MultiValue,A=K("packages/core/src/store/stringrank.js").StringRankIndex,g=4294967295,u=1024,h=5e3,a=.2,r=new Set(["float64","int32","bitset","dictionary","object","multi"]);function t(f){return f==null}function n(f){if(typeof f=="number")return f;if(f instanceof Date)return f.getTime();if(typeof f=="boolean")return f?1:0;const s=Number(f);return Number.isNaN(s)&&typeof f=="string"?Date.parse(f):s}function o(f){const s=n(f);return Number.isFinite(s)?s|0:0}function d(f){return t(f)?[]:Array.isArray(f)?f:[f]}function l(f,s){switch(f.kind){case"float64":case"int32":return f.buf[s];case"bitset":return f.bits.get(s)===1;case"dictionary":return f.dict.valueOf(f.buf[s]);case"multi":{const p=f.mv.at(s),b=new Array(p.length);for(let S=0;S<p.length;S++)b[S]=f.dict.valueOf(p[S]);return b}default:return f.buf[s]}}function i(f,s){switch(f.kind){case"float64":case"int32":return f.values[s];case"bitset":return(f.values[s>>3]&1<<(s&7))!==0;case"dictionary":return(f.table||[])[f.values[s]];case"multi":{const p=f.offsets[s],b=f.offsets[s+1],S=f.table||[],j=new Array(b-p);for(let y=p;y<b;y++)j[y-p]=S[f.values[y]];return j}default:return f.values[s]}}class m{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f;#p;#m=-1;#g=null;#y=0;#b=0;#A=null;#w=null;#S=!1;constructor(s,p){this.#e=s.id;const b=r.has(s.kind)?s.kind:"object";s.kind&&!r.has(s.kind)&&x(`store.kind.${s.id}`,`column "${s.id}" declares unknown storage kind "${s.kind}"; falling back to object`),this.#n=b,this.#t=b,this.#r=s.nullable!==!1,this.#s=s.dictionary??null,this.#i=p,this.#o=z(s.read)?s.read:$(s.field||s.id),this.#f=s.stringRankIndex!=="off",this.#p=typeof s.stringRankMaxDistinct=="number"?s.stringRankMaxDistinct:0,this.#A=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#E().values}get presence(){return this.#S||!this.#r?null:this.#l?this.#g:this.#E().presence}get dict(){return this.#S||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#f||this.kind!=="object")return null;const s=this.values,p=this.#i.physical();if(!s||p===0)return null;if(this.#h===null){if(typeof s[0]!="string")return null;const b=new A(this.#v());return b.build(s,p),b.version=this.#b,this.#h=b,this.#m=this.#b,b.capped?null:b}return this.#h.length<p&&this.#h.append(s,this.#h.length,p-this.#h.length),this.#h.version=this.#b,this.#m=this.#b,this.#h.capped?null:this.#h}#v(){return this.#p}#C(){this.#h=null,this.#m=-1}get offsets(){return this.#S||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let s=0;return this.#a&&(s+=this.#a.byteLength??this.#a.length*8),this.#u&&(s+=this.#u.bytes),this.#c&&(s+=this.#c.bytes),this.#g&&(s+=this.#g.bytes),this.#d&&(s+=this.#d.bytes),this.#A&&(s+=this.#A.size*24),s}get(s){if(!this.#S&&!(s<0||s>=this.#i.physical())){if(!this.#l)return this.#M(s);if(this.#r&&this.#g.get(s)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[s];case"bitset":return this.#u.get(s)===1;case"dictionary":return this.#d.valueOf(this.#a[s]);case"multi":{const p=this.#c.at(s),b=new Array(p.length);for(let S=0;S<p.length;S++)b[S]=this.#d.valueOf(p[S]);return b}default:return this.#a[s]}}}set(s,p){this.#S||(this.#l?this.#P(s,p):this.#A.set(s,p===void 0?null:p),this.#h&&this.#C(),this.#b++)}read(s){return this.#o(s)}appendColumn(s,p,b){if(this.#S||b<=0)return;if(!this.#l){this.#b++;return}const S=this.#o,j=this.#r,y=this.#g;let v=!1;switch(this.#t){case"float64":{const R=this.#a;for(let O=0;O<b;O++){const F=S(s[O]);if(typeof F=="number"){j&&y.set(p+O),R[p+O]=F;continue}const C=F==null;j?y.assign(p+O,!C):C&&(v=!0),R[p+O]=C?NaN:n(F)}break}case"int32":{const R=this.#a;for(let O=0;O<b;O++){const F=S(s[O]),C=F==null;j?y.assign(p+O,!C):C&&(v=!0),R[p+O]=C?0:o(F)}break}case"bitset":{const R=this.#u;for(let O=0;O<b;O++){const F=S(s[O]),C=F==null;j?y.assign(p+O,!C):C&&(v=!0),R.assign(p+O,!C&&!!F)}break}case"dictionary":{const R=this.#a,O=this.#d;for(let F=0;F<b;F++){const C=S(s[F]),T=C==null;j?y.assign(p+F,!T):T&&(v=!0),R[p+F]=T?0:O.codeOf(C)}break}case"multi":{const R=this.#c,O=this.#d;for(let F=0;F<b;F++){const C=S(s[F]),T=C==null;j?y.assign(p+F,!T):T&&(v=!0);const L=d(C),E=new Array(L.length);for(let D=0;D<L.length;D++)E[D]=O.codeOf(L[D]);R.write(p+F,E)}break}default:{const R=this.#a;for(let O=0;O<b;O++){const F=S(s[O]),C=F==null;j?y.assign(p+O,!C):C&&(v=!0),R[p+O]=C?null:F}break}}v&&x(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#a,p,b),this.#h.version=this.#b+1,this.#m=this.#b+1),this.#b++}appendPacked(s,p,b){if(this.#S||b<=0||!s)return;if(!this.#l){this.#b++;return}const S=this.#g,j=s.presence;if(S)if(j)for(let v=0;v<b;v++)S.assign(p+v,(j[v>>3]&1<<(v&7))!==0);else for(let v=0;v<b;v++)S.set(p+v);const y=s.kind===this.#t;if(y&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(s.values,p),this.#b++;return}if(y&&this.#t==="bitset"){const v=s.values;for(let R=0;R<b;R++)this.#u.assign(p+R,(v[R>>3]&1<<(R&7))!==0);this.#b++;return}if(y&&this.#t==="dictionary"){const v=s.table||[],R=new Uint32Array(v.length);for(let T=0;T<v.length;T++)R[T]=this.#d.codeOf(v[T]);const O=s.values,F=this.#a,C=S;for(let T=0;T<b;T++){if(C&&(j&&(j[T>>3]&1<<(T&7))===0)){F[p+T]=0;continue}F[p+T]=R[O[T]]??0}this.#b++;return}if(y&&this.#t==="multi"){const v=s.table||[],R=new Uint32Array(v.length);for(let C=0;C<v.length;C++)R[C]=this.#d.codeOf(v[C]);const O=s.values,F=s.offsets;for(let C=0;C<b;C++){const T=F[C],L=F[C+1],E=new Array(L-T);for(let D=T;D<L;D++)E[D-T]=R[O[D]]??0;this.#c.write(p+C,E)}this.#b++;return}for(let v=0;v<b;v++){const R=j?(j[v>>3]&1<<(v&7))===0:s.kind==="object"?s.values[v]===null:!1;this.#P(p+v,R?null:i(s,v))}this.#b++}touch(){this.#b++}columnarise(s,p){if(this.#l||this.#S)return;const b=new Array(p);for(let S=0;S<p;S++)b[S]=this.#M(S);this.#t=this.#n,this.#l=!0,this.#O(s);for(let S=0;S<p;S++)this.#P(S,b[S]);this.#A.clear(),this.#w=null,this.#C(),this.#b++}grow(s){if(!(!this.#l||this.#S||s<=this.#y)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(s);p.set(this.#a),this.#a=p;break}case"bitset":this.#u.grow(s);break;case"multi":break;default:this.#a.length=s;break}this.#g&&this.#g.grow(s),this.#y=s,this.#b++}}convert(s){if(this.#S||!r.has(s)||(this.#n=s,!this.#l||s===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},b=this.#i.physical(),S=this.#g;this.#t=s,this.#O(this.#y);for(let j=0;j<b;j++){const y=S!==null&&S.get(j)===0;y&&s!=="multi"||this.#P(j,y?null:l(p,j))}return this.#C(),this.#b++,!0}compact(s,p,b){if(!this.#S){if(this.#C(),!this.#l){const S=this.#A;if(S.size){const j=new Map;for(const[y,v]of S)s[y]!==g&&j.set(s[y],v);this.#A=j}this.#w=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const S=this.#a;for(let j=0;j<p;j++)s[j]!==g&&(S[s[j]]=S[j]);if(this.#t==="object")for(let j=b;j<p;j++)S[j]=void 0;break}case"bitset":{const S=this.#u;for(let j=0;j<p;j++)s[j]!==g&&S.assign(s[j],S.get(j)===1);for(let j=b;j<p;j++)S.clear(j);break}case"multi":this.#c.compact(s,b,g);break;default:break}if(this.#g){const S=this.#g;for(let j=0;j<p;j++)s[j]!==g&&S.assign(s[j],S.get(j)===1);for(let j=b;j<p;j++)S.clear(j)}this.#b++}}release(){this.#S||(this.#S=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#A=new Map,this.#w=null,this.#y=0,this.#b++)}#O(s){const p=Math.max(1,s);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#u=new X(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#d=this.#d??new V(this.#s??[]);break;case"multi":this.#c=new B({rows:p,values:p}),this.#d=this.#d??new V(this.#s??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new X(p)),this.#y=p}#P(s,p){const b=t(p);switch(this.#r?this.#g.assign(s,!b):b&&x(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[s]=b?NaN:n(p);break;case"int32":this.#a[s]=b?0:o(p);break;case"bitset":this.#u.assign(s,!b&&!!p);break;case"dictionary":this.#a[s]=b?0:this.#d.codeOf(p);break;case"multi":{const S=d(p),j=new Array(S.length);for(let y=0;y<S.length;y++)j[y]=this.#d.codeOf(S[y]);this.#c.write(s,j);break}default:this.#a[s]=b?null:p;break}}#M(s){if(this.#A.has(s))return this.#A.get(s);const p=this.#o(this.#i.rowAt(s));return p===void 0?null:p}#E(){if(this.#w&&this.#w.version===this.#b)return this.#w;const s=this.#i.physical(),p=new Array(s),b=this.#r?new X(s):null;for(let S=0;S<s;S++){const j=this.#M(S);p[S]=j,b&&!t(j)&&b.set(S)}return this.#w={version:this.#b,values:p,presence:b},this.#w}}class c{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new X(0);#u=!1;#c=!0;#d;#h;#f;#p=!1;constructor(s,p={}){this.#e=Array.isArray(s)?s:[],this.#h=Math.max(1,p.initialCapacity??u),this.#c=p.retainSource!==!1,this.#d=this.#c?p.columnarBelow??h:0,this.#f=p.compactRatio??a;const b={rowAt:S=>this.#r[S],physical:()=>this.#o};for(const S of this.#e){if(!S||!S.id)continue;if(this.#t.has(S.id)){x(`store.dup.${S.id}`,`duplicate column id "${S.id}" in the store schema; ignoring the second`);continue}const j=new m(S,b);this.#t.set(S.id,j),this.#n.push(j)}this.#d<=0&&this.#y()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#p}get bytes(){let s=this.#a.bytes+this.#r.length*8;for(const p of this.#n)s+=p.bytes;return s}append(s){const p=this.#o;if(this.#p||!s)return{from:p,to:p};const b=s.length|0;if(b===0)return{from:p,to:p};if(this.#c)for(let j=0;j<b;j++)this.#r[p+j]=s[j];if(this.#o=p+b,this.#s+=b,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#y();else for(const j of this.#n)j.touch();return{from:p,to:this.#o}}this.#m(this.#o);const S=this.#n;for(let j=0;j<S.length;j++)S[j].appendColumn(s,p,b);return{from:p,to:this.#o}}appendPacked(s,p){const b=this.#o;if(this.#p||!s)return{from:b,to:b};const S=s.count|0;if(S===0)return{from:b,to:b};if(this.#c&&p)for(let y=0;y<S;y++)this.#r[b+y]=p[y];this.#o=b+S,this.#s+=S,this.#a.grow(this.#o),this.#u||this.#y(),this.#m(this.#o);const j=new Map;for(const y of s.columns)j.set(y.id,y);for(const y of this.#n){const v=j.get(y.id);v?y.appendPacked(v,b,S):y.grow(this.#i)}return{from:b,to:this.#o}}source(s){if(this.#c)return this.#r[s];if(!(s<0||s>=this.#o))return this.#g(s)}setSource(s,p){this.#p||s<0||s>=this.#o||this.#c&&(this.#r[s]=p)}get(s,p){const b=this.#t.get(s);return b?b.get(p):void 0}set(s,p,b){if(this.#p||p<0||p>=this.#o)return;const S=this.#t.get(s);if(!S){x(`store.set.${s}`,`set() on unknown column "${s}"`);return}S.set(p,b)}remove(s){return this.#p||s<0||s>=this.#o||this.#a.get(s)===1?!1:(this.#a.set(s),this.#l++,this.#s--,!0)}live(s){return s<0||s>=this.#o?!1:this.#a.get(s)===0}compact(s={}){if(this.#p||this.#l===0||!s.force&&this.#l/this.#o<this.#f)return null;const p=this.#o,b=new Uint32Array(p);let S=0;for(let j=0;j<p;j++)b[j]=this.#a.get(j)===1?g:S++;for(const j of this.#n)j.compact(b,p,S);if(this.#c){const j=this.#r;for(let y=0;y<p;y++)b[y]!==g&&(j[b[y]]=j[y]);j.length=S}return this.#o=S,this.#s=S,this.#l=0,this.#a=new X(Math.max(this.#i,S)),b}column(s){return this.#t.get(s)}columns(){return this.#n.slice()}liveIndices(){const s=new Uint32Array(this.#s);if(this.#l===0){for(let b=0;b<this.#o;b++)s[b]=b;return s}let p=0;for(let b=0;b<this.#o;b++)this.#a.get(b)===0&&(s[p++]=b);return s}convert(s,p){const b=this.#t.get(s);return b?b.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const s of this.#n)s.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#m(s){if(s<=this.#i)return;let p=this.#i||this.#h;for(;p<s;)p*=2;for(const b of this.#n)b.grow(p);this.#a.grow(p),this.#i=p}#g(s){const p={};for(const b of this.#n)p[b.id]=b.get(s);return p}#y(){if(this.#u)return;let s=this.#h;for(;s<this.#o;)s*=2;this.#u=!0,this.#i=s,this.#a.grow(s);for(const p of this.#n)p.columnarise(s,this.#o)}}}),Fe("packages/core/src/store/pool.js",function(e,K){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return _}});const Q=64,x=8;function z(W){let V=Q;for(;V<W;)V*=2;return V}class ${#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(V={}){this.#n=V.limit??x}get bytes(){return this.#r}mask(V){const H=new Uint8Array(this.#i(V),0,V);return H.fill(0),H}indices(V){return new Uint32Array(this.#i(V*4),0,V)}release(V){if(!V||!V.buffer)return!1;const H=V.buffer;if(!this.#t.has(H))return!1;this.#t.delete(H),this.#o.released++;const B=H.byteLength;let w=this.#e.get(B);return w||this.#e.set(B,w=[]),w.length>=this.#n||(w.push(H),this.#r+=B),!0}releaseAll(V){for(const H of V)this.release(H)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(V){const H=z(V),B=this.#e.get(H);this.#o.acquired++;let w;return B&&B.length?(w=B.pop(),this.#r-=H,this.#o.reused++):w=new ArrayBuffer(H),this.#t.add(w),w}}function _(){return X??=new $,X}let X=null}),Fe("packages/core/src/compute/sortspec.js",function(e,K){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return _}});function Q(X){return{locale:X===void 0?void 0:String(X),numeric:!0,sensitivity:"variant"}}function x(X){return!!X&&typeof X.compare!="function"}function z(X){if(!X)return!0;for(let W=0;W<X.length;W++)if(!x(X[W]))return!1;return!0}function $(X,W){const V=X.col!==void 0?X.col:X.handle&&X.handle.id,H=X.locale!==void 0?X.locale:W;return{col:V,descending:X.descending!==void 0?!!X.descending:X.dir==="desc",nullsFirst:!!X.nullsFirst,collation:Q(H)}}function _(X,W){const V=X||[],H=new Array(V.length);for(let B=0;B<V.length;B++)H[B]=$(V[B],W);return H}}),Fe("packages/core/src/compute/facet.js",function(e,K){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const Q=K("packages/core/src/compute/handle.js"),x=Q.presenceReader,z=Q.valueReader,$=Q.dictSize,_=Q.dictValue,X=Object.freeze(["equal","quantile","log"]),W=Object.freeze(["hour","day","week","month","quarter","year"]),V=20,H=50,B=1e4;function w(j,y){if(!j)return"none";const v=y;if(v&&(v.multi===!0||typeof v.items=="function"))return"category";const R=y&&y.base;if(R==="date"||R==="datetime"||R==="time"||R==="dateString")return"date";switch(j.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return R==="number"?"numeric":R==="boolean"?"boolean":R==="text"?"category":"none"}}function A(j){const y=j.values,v=j.kind;if((v==="float64"||v==="int32")&&y)return O=>y[O];const R=z(j);return O=>g(R(O))}function g(j){if(typeof j=="number")return j;if(j instanceof Date)return j.getTime();if(j==null||j==="")return NaN;if(typeof j=="boolean")return j?1:0;if(typeof j=="string"){const y=Number(j);if(Number.isFinite(y))return y;const v=Date.parse(j);return Number.isFinite(v)?v:NaN}return NaN}function u(j,y,v,R=H){if(!j)return{cardinality:0,exact:!0};if(j.dict)return{cardinality:$(j.dict),exact:!0};if(j.kind==="bitset")return{cardinality:2,exact:!0};const O=z(j),F=y?y.length:v,C=new Set;for(let T=0;T<F;T++){const L=O(y?y[T]:T);if(L!=null&&(C.add(L),C.size>R))return{cardinality:C.size,exact:!1}}return{cardinality:C.size,exact:!0}}const h=36e5,a=864e5;function r(j,y=V){const v=Number.isFinite(j)&&j>0?j:0,R=Math.max(1,y)*2;return v/h<=R?"hour":v/a<=R?"day":v/(7*a)<=R?"week":v/(30*a)<=R?"month":v/(91*a)<=R?"quarter":"year"}function t(j,y){if(!Number.isFinite(j))return NaN;const v=new Date(j);switch(y){case"hour":return v.setMinutes(0,0,0),v.getTime();case"day":return v.setHours(0,0,0,0),v.getTime();case"week":{v.setHours(0,0,0,0);const R=(v.getDay()+6)%7;return v.setDate(v.getDate()-R),v.getTime()}case"month":return v.setDate(1),v.setHours(0,0,0,0),v.getTime();case"quarter":return v.setMonth(Math.floor(v.getMonth()/3)*3,1),v.setHours(0,0,0,0),v.getTime();default:return v.setMonth(0,1),v.setHours(0,0,0,0),v.getTime()}}function n(j,y){const v=new Date(j);switch(y){case"hour":v.setHours(v.getHours()+1);break;case"day":v.setDate(v.getDate()+1);break;case"week":v.setDate(v.getDate()+7);break;case"month":v.setMonth(v.getMonth()+1);break;case"quarter":v.setMonth(v.getMonth()+3);break;default:v.setFullYear(v.getFullYear()+1);break}return v.getTime()}function o(j,y,v){const R=A(j),O=x(j),F=y?y.length:v;let C=1/0,T=-1/0,L=0,E=0;for(let D=0;D<F;D++){const I=y?y[D]:D;if(O&&!O(I)){L++;continue}const P=R(I);if(!Number.isFinite(P)){L++;continue}P<C&&(C=P),P>T&&(T=P),E++}return{min:C,max:T,nulls:L,finite:E}}function d(j,y,v,R){const O=A(j),F=x(j),C=y?y.length:v,T=C>R?C/R:1,L=[];for(let D=0;D<C;D+=T){const I=y?y[Math.floor(D)]:Math.floor(D);if(F&&!F(I))continue;const P=O(I);Number.isFinite(P)&&L.push(P)}const E=Float64Array.from(L);return E.sort(),E}function l(j,y,v,R={}){const O=R.kind||w(j,R.type);return O==="none"||!j?{kind:"none",buckets:[],suppressed:"type"}:O==="boolean"?i(j,y,v):O==="category"?m(j,y,v,R):c(j,y,v,O,R)}function i(j,y,v){const R=x(j);let O=0;if(R){const C=y?y.length:v;for(let T=0;T<C;T++)R(y?y[T]:T)||O++}const F=[{value:!1,label:"false"},{value:!0,label:"true"}];return O>0&&F.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:F}}function m(j,y,v,R){const O=R.cardinalityLimit??H,{cardinality:F}=u(j,y,v,O);if(F>O&&(R.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:F};const C=z(j),T=y?y.length:v,L=new Map;let E=0;for(let N=0;N<T;N++){const G=C(y?y[N]:N);if(G==null||G===""){E++;continue}if(Array.isArray(G)){if(!G.length){E++;continue}for(const q of G)L.set(q,(L.get(q)||0)+1);continue}L.set(G,(L.get(G)||0)+1)}let D=[...L.entries()];R.order==="alpha"?D.sort((N,G)=>String(N[0]).localeCompare(String(G[0]))):D.sort((N,G)=>G[1]-N[1]);let I=0,P=0;if(D.length>O){P=D.length-O;for(let N=O;N<D.length;N++)I+=D[N][1];D=D.slice(0,O)}const k=D.map(([N])=>({value:N,label:String(N)}));return I>0&&k.push({remainder:!0,label:`Other (${P} values)`}),E>0&&k.push({null:!0,label:"Empty"}),{kind:"category",buckets:k,cardinality:F}}function c(j,y,v,R,O){const{min:F,max:C,nulls:T,finite:L}=o(j,y,v);if(!L)return{kind:R,buckets:T?[{null:!0,label:"Empty"}]:[],empty:!0};const E=Math.max(1,Math.floor(O.buckets||V));let D=[];if(R==="date"){const P=W.includes(O.granularity)?O.granularity:r(C-F,E);let k=t(F,P);for(;k<=C&&D.length<4096;){const N=n(k,P);if(!(N>k))break;D.push({from:k,to:N}),k=N}return{kind:R,buckets:f(D,T),granularity:P}}const I=X.includes(O.strategy)?O.strategy:"equal";if(I==="quantile"){const P=d(j,y,v,B);if(P.length){const k=[P[0]];for(let N=1;N<E;N++){const G=P[Math.min(P.length-1,Math.floor(N/E*P.length))];G>k[k.length-1]&&k.push(G)}k.push(C);for(let N=0;N<k.length-1;N++)D.push({from:k[N],to:k[N+1]})}}else if(I==="log"&&F>0){const P=Math.log10(F),N=(Math.log10(C)-P)/E||1;for(let G=0;G<E;G++)D.push({from:10**(P+G*N),to:10**(P+(G+1)*N)})}if(!D.length){const P=(C-F)/E||1;for(let k=0;k<E;k++)D.push({from:F+k*P,to:F+(k+1)*P})}return D[D.length-1].to=C,{kind:R,buckets:f(D,T),strategy:I,min:F,max:C}}function f(j,y){return y>0?[...j,{null:!0,label:"Empty"}]:j}function s(j,y,v,R,O){const F=R&&R.buckets||[],C=O&&O.length>=F.length?O.subarray(0,F.length):new Uint32Array(F.length);if(C.fill(0),!j||!F.length)return C;const T=F.length-1,L=!!F[T]&&F[T].null===!0,E=y?y.length:v;if(R.kind==="boolean"){const N=z(j);for(let G=0;G<E;G++){const q=N(y?y[G]:G);if(q==null){L&&C[T]++;continue}C[q?1:0]++}return C}if(R.kind==="category"){const N=new Map;for(let Y=0;Y<F.length;Y++)!F[Y].null&&!F[Y].remainder&&N.set(F[Y].value,Y);const G=F.findIndex(Y=>Y.remainder),q=z(j);for(let Y=0;Y<E;Y++){const J=q(y?y[Y]:Y);if(J==null||J===""){L&&C[T]++;continue}if(Array.isArray(J)){if(!J.length){L&&C[T]++;continue}for(const re of J){const ie=N.get(re);ie!==void 0?C[ie]++:G>=0&&C[G]++}continue}const ee=N.get(J);ee!==void 0?C[ee]++:G>=0&&C[G]++}return C}const D=L?F.length-1:F.length,I=new Float64Array(D+1);for(let N=0;N<D;N++)I[N]=F[N].from;I[D]=D?F[D-1].to:0;const P=A(j),k=x(j);for(let N=0;N<E;N++){const G=y?y[N]:N;if(k&&!k(G)){L&&C[T]++;continue}const q=P(G);if(!Number.isFinite(q)){L&&C[T]++;continue}const Y=p(I,D,q);Y>=0&&C[Y]++}return C}function p(j,y,v){if(!y||v<j[0])return-1;if(v>=j[y])return v===j[y]?y-1:-1;let R=0,O=y-1;for(;R<O;){const F=R+O+1>>>1;v>=j[F]?R=F:O=F-1}return R}function b(j,y,v,R={}){const O=R.bounds||l(j,R.boundsIndices??y,v,R);return{bounds:O,counts:s(j,y,v,O)}}const S=b}),Fe("packages/core/src/compute/pivotmatrix.js",function(e,K){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const x=K("packages/core/src/compute/handle.js").valueComparator,$=K("packages/core/src/compute/total.js").total,X=K("packages/core/src/compute/group.js").packKeys,W=K("packages/core/src/compute/pivot.js"),V=W.joinPath,H=W.DEFAULT_PATH_SEPARATOR,B=W.DEFAULT_MAX_COLUMNS,w="";function A(n,o,d={}){const l=d.separator||H,i=n||[],m=o instanceof Uint32Array?o:Uint32Array.from(o||[]),c=m.length;if(i.length===0)return{tuples:[[]],paths:[w],buckets:[m]};const{keyOf:f,readers:s}=X(i,m,0),p=new Map,b=[],S=[],j=[];for(let C=0;C<c;C++){const T=m[C],L=f(T);let E=p.get(L);if(E===void 0){E=b.length,p.set(L,E),S.push(L);const D=new Array(s.length);for(let I=0;I<s.length;I++)D[I]=s[I](T);b.push(D),j.push([])}j[E].push(T)}const y=x(d.locale),v=b.map((C,T)=>T);v.sort((C,T)=>{const L=b[C],E=b[T];for(let D=0;D<L.length;D++){const I=g(L[D],E[D],y);if(I!==0)return I}return C-T});const R=new Array(v.length),O=new Array(v.length),F=new Array(v.length);for(let C=0;C<v.length;C++){const T=v[C];R[C]=b[T],O[C]=V(b[T],l),F[C]=Uint32Array.from(j[T])}return{tuples:R,paths:O,buckets:F}}function g(n,o,d){const l=n==null,i=o==null;return l||i?l&&i?0:l?1:-1:d(n,o)}function u(n,o,d){const l=[];for(let i=0;i<n.length;i++)d.has(n[i])&&l.push(n[i]);return Uint32Array.from(l)}function h(n,o,d,l){return{value:o.length?$(n,o,d,l):null,leaves:o,count:o.length}}function a(n){const o=n&&n.opts||{},d=o.separator||H,l=o.totalContext||{locale:o.locale},i=(n.measures||[]).filter(O=>O&&O.handle),m=n.leaves instanceof Uint32Array?n.leaves:Uint32Array.from(n.leaves||[]),c=A(n.rowHandles||[],m,{...o,separator:d}),f=A(n.columnHandles||[],m,{...o,separator:d}),s=o.maxColumns===void 0?B:o.maxColumns,p=f.paths.length*Math.max(1,i.length),b=new Map;if(s&&p>s)return{rowAxis:c,columnAxis:f,measures:i.map(O=>({colId:O.colId,fn:O.fn})),body:b,rowMargin:b,columnMargin:b,grand:b,columns:p,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${p} columns, above pivot.maxColumns of ${s}. Narrow the pivot columns or raise the limit.`,columns:p,maxColumns:s}};const S=new Map,j=new Map,y=new Map,v=new Map,R=f.buckets.map(O=>new Set(O));for(let O=0;O<f.paths.length;O++){const F=f.buckets[O],C=f.paths[O];for(const T of i)y.set(t(C,T.colId),h(T.handle,F,T.fn,l))}for(let O=0;O<c.paths.length;O++){const F=c.buckets[O],C=c.paths[O];for(const T of i)j.set(t(C,T.colId),h(T.handle,F,T.fn,l));for(let T=0;T<f.paths.length;T++){const L=u(F,f.buckets[T],R[T]);if(L.length===0)continue;const E=f.paths[T];for(const D of i)S.set(r(C,E,D.colId),h(D.handle,L,D.fn,l))}}for(const O of i)v.set(O.colId,h(O.handle,m,O.fn,l));return{rowAxis:c,columnAxis:f,measures:i.map(O=>({colId:O.colId,fn:O.fn})),body:S,rowMargin:j,columnMargin:y,grand:v,columns:p,error:null}}function r(n,o,d){return`${n}\0${o}\0${d}`}function t(n,o){return`${n}\0${o}`}}),Fe("packages/core/src/compute/reference.js",function(e,K){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return a}});const x=K("packages/core/src/internal/util.js").getPath,z=K("packages/core/src/compute/handle.js"),$=z.isMissing,_=z.valueComparator,W=K("packages/core/src/compute/filter.js").testValue,V="",H="\0";function B(n,o){const d=o.includes(".")?x(n,o):n?.[o];return d===void 0?null:d}function w(n,o,d={}){const l=o||[];let i=n.map((m,c)=>c);if(l.length===0)return i;for(let m=l.length-1;m>=0;m--)i=A(n,i,l[m],d);return i}function A(n,o,d,l){const i=d.locale!==void 0?d.locale:l.locale,m=_(i),c=d.descending!==void 0?!!d.descending:d.dir==="desc",f=[],s=[];for(const S of o){const j=B(n[S],d.col);$(j)?s.push(S):f.push(S)}const p=new Map;for(let S=0;S<f.length;S++)p.set(f[S],S);const b=(S,j)=>{const y=B(n[S],d.col),v=B(n[j],d.col);let R;return typeof d.compare=="function"?(R=d.compare(y,v,n[S],n[j],c),c&&(R=-R)):R=c?m(v,y):m(y,v),R!==0?R:p.get(S)-p.get(j)};return f.sort(b),d.nullsFirst?s.concat(f):f.concat(s)}function g(n,o,d={}){const l=[];for(let i=0;i<n.length;i++)u(n[i],o,d,i)&&l.push(i);return l}function u(n,o,d,l){if(!o)return!0;if(Array.isArray(o.conditions)){const i=o.conditions.filter(c=>c!=null);if(i.length===0)return!0;if(o.op==="or")return i.some(c=>u(n,c,d,l));const m=i.every(c=>u(n,c,d,l));return o.op==="not"?!m:m}return o.col===void 0&&typeof d.custom=="function"?!!d.custom(o,n,l):W(B(n,o.col),o,d.locale)}function h(n,o,d,l){const i=d||n.map((s,p)=>p),m=new Map,c=[],f=[];for(const s of i){const p=o.map((j,y)=>{const v=B(n[s],j);return l&&l[y]?l[y](v):v}),b=p.map(j=>j==null?H:String(j)).join(V);let S=m.get(b);S===void 0&&(S=c.length,m.set(b,S),c.push(p),f.push([])),f[S].push(s)}return{keys:c,buckets:f}}function a(n,o,d={}){const l=_(d.locale),i=n.filter(c=>!$(c)),m=i.map(r).filter(c=>c!==null);switch(o){case"count":return n.length;case"countValues":return i.length;case"sum":return m.reduce((c,f)=>c+f,0);case"avg":return i.length===0?null:m.reduce((c,f)=>c+f,0)/i.length;case"min":return i.length===0?null:i.reduce((c,f)=>l(f,c)<0?f:c);case"max":return i.length===0?null:i.reduce((c,f)=>l(f,c)>0?f:c);case"first":return n.length===0?null:t(n[0]);case"last":return n.length===0?null:t(n[n.length-1]);default:return null}}function r(n){if(typeof n=="number")return Number.isNaN(n)?null:n;if(n==null||n===""||typeof n=="boolean")return null;if(n instanceof Date)return n.getTime();const o=Number(n);return Number.isNaN(o)?null:o}function t(n){return n===void 0?null:n}}),Fe("packages/core/src/compute/index.js",function(e,K){"use strict";const Q=K("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return Q.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return Q.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return Q.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return Q.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return Q.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return Q.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return Q.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return Q.rankSortStrings}});const x=K("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return x.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return x.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return x.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return x.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return x.describeSort}});const z=K("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return z.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return z.evaluateCondition}}),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,"compilePredicate",{enumerable:!0,get:function(){return z.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return z.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return z.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return z.mentionsColumn}});const $=K("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return $.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return $.packKeys}});const _=K("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const X=K("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return X.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return X.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return X.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return X.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return X.collectValues}});const W=K("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return W.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return W.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return W.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return W.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return W.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return W.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return W.DEFAULT_MAX_COLUMNS}});const V=K("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return V.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return V.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return V.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return V.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return V.GRAND_PATH}});const H=K("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return H.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return H.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return H.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return H.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return H.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return H.referenceValue}});const B=K("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return B.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return B.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return B.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return B.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return B.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return B.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return B.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return B.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return B.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return B.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return B.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return B.isMissing}});const w=K("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return w.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return w.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return w.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return w.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return w.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return w.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return w.SKETCH_BOUNDS}});const A=K("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return A.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return A.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return A.openWindow}});const g=K("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return g.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return g.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return g.maintenanceOf}});const u=K("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return u.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return u.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return u.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return u.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return u.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u.anomalyCondition}});const h=K("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return h.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return h.forecast}})}),Fe("packages/core/src/source/rows.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return u}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.isFunction,$=32,_="\0";function X(h){return new W(h)}class W{#e;#t;constructor(a){this.#e=z(a&&a.rowKey)?a.rowKey:null;const r=a&&a.config?a.config.rowHeight:void 0;this.#t=typeof r=="number"||z(r)?r:$}get keyed(){return this.#e!==null}keyOf(a,r){if(this.#e){const t=this.#e(a);if(t!=null)return String(t)}else x("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${r}`}heightOf(a){return z(this.#t)?Number(this.#t(a))||$:this.#t}leaf(a,r,t=0,n=null){const o={key:this.keyOf(a,r),data:a,level:t,parent:n,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:r};return o.height=this.heightOf(o),o}group(a){const r={key:g(a.keyPath||a.path),data:null,level:a.level,parent:a.parent||null,children:[],group:!0,expanded:a.expanded!==!1,leafCount:a.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:a.column,groupValue:a.value,groupPath:a.path,hasChildren:a.hasChildren!==!1};return a.totals&&(r.totals=a.totals),r.height=this.heightOf(r),r}footer(a){const r={key:`${a.key}${_}footer`,data:null,level:a.level,parent:a,group:!0,footer:!0,expanded:!1,leafCount:a.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:a.groupColumn,groupValue:a.groupValue,groupPath:a.groupPath,hasChildren:!1,totals:a.totals};return r.height=this.heightOf(r),r}detail(a,r){return{key:`${a.key}${_}detail`,data:a.data,level:a.level+1,parent:a,group:!1,detail:!0,expanded:!1,leafCount:0,height:r,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:a.key}}grandTotal(a,r){const t={key:`${_}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:r,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:a};return t.height=this.heightOf(t),t}skeleton(a,r=0,t=!1){const n={key:`${_}pending${_}${a}`,data:null,level:r,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:a,selected:!1,physical:null,pending:!0};return t&&(n.loadError=!0),n.height=this.heightOf(n),n}}function V(h,a,r,t){return{key:`${_}pinned${_}${r}${_}${a}`,data:h,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,pinned:r}}function H(h,a){return new Proxy([],{get(r,t,n){if(t==="length")return h();if(typeof t=="string"){const o=Number(t);if(Number.isInteger(o)&&o>=0)return a(o)}return Reflect.get(r,t,n)},has(r,t){if(typeof t=="string"){const n=Number(t);if(Number.isInteger(n)&&n>=0)return n<h()}return Reflect.has(r,t)}})}function B(h){return h==null?"":String(h)}const w="";function A(h){if(h==null)return w;const a=String(h);return a.startsWith(w)?w+a:a}function g(h){const a=h||[];let r="g";for(let t=0;t<a.length;t++)r+=_+A(a[t]);return r}function u(h){const a=new Array(h.length),r=[];for(let t=0;t<h.length;t++)r.push(h[t]),a[t]=g(r);return a}}),Fe("packages/core/src/source/handles.js",function(e,K){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return _}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce;class ${#e;#t;#n;#r=new Map;#o=0;constructor(W,V,H){this.#e=W,this.#t=V,this.#n=x(H)?H:()=>!1}get store(){const W=this.#e.store;return W&&x(W.column)?W:null}invalidate(){this.#o++}handle(W){const V=this.store;if(V){const A=V.column(W);if(A)return A}const H=this.#r.get(W);if(H&&H.builtAt===this.#o)return H.handle;const B=this.#i(W);if(!B)return;if(V&&this.#n()){z(`source.dropped.${W}`,`column "${W}" 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 w=this.#s(B);return this.#r.set(W,{handle:w,builtAt:this.#o}),w}#i(W){const V=this.#e.columns;return V&&x(V.get)?V.get(W):void 0}#s(W){const V=this.#t()||[],H=V.length,B=new Array(H),w=x(W.getValue)?g=>W.getValue(g):g=>g?.[W.field||W.id];for(let g=0;g<H;g++)B[g]=V[g]===void 0?void 0:w(V[g]);const A=this.#o;return{id:W.id,kind:"object",nullable:!1,values:B,presence:null,dict:null,offsets:null,get(g){return B[g]},version:A}}}function _(X,W,V){return new $(X,W,V)}}),Fe("packages/core/src/compute/incremental.js",function(e,K){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/store/columnstore.js").toFloat,z=Object.freeze(["sum","avg","countValues","min","max"]),$=Object.freeze(["float64"]),_=1e15;function X(B,w){return typeof B!="string"||!z.includes(B)?!1:!!w&&$.includes(w.kind)}function W(B){if(B==null)return null;const w=x(B);return Number.isNaN(w)?null:w}class V{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(w){this.#e=w}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(w){this.#a();for(let A=0;A<w.length;A++){const g=W(w[A]);g!==null&&this.#u(g)}this.#s=!0}seedColumn(w,A,g){this.#a();for(let u=0;u<g.length;u++){const h=g[u];if(A&&A(h)===0)continue;const a=w[h];Number.isNaN(a)||this.#u(a)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(w){if(!Number.isFinite(w)){this.#l=!0;return}const A=this.#t+w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-A+w:w-A+this.#t,this.#t=A,this.#r++,w<this.#o&&(this.#o=w),w>this.#i&&(this.#i=w)}#c(w){const A=this.#t-w;this.#n+=Math.abs(this.#t)>=Math.abs(w)?this.#t-A-w:-w-A+this.#t,this.#t=A,this.#r--}update(w,A){if(!this.#s)return!1;const g=W(w),u=W(A);return g===null&&u===null?!0:g!==null&&!Number.isFinite(g)||u!==null&&!Number.isFinite(u)?!1:this.#e==="min"||this.#e==="max"?g===null||u===null?!1:this.#e==="min"?u<this.#o?(this.#o=u,!0):g>this.#o:u>this.#i?(this.#i=u,!0):g<this.#i:Math.abs(this.#t)>_?!1:(g!==null&&this.#c(g),u!==null&&this.#u(u),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#o:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#s=!1}}const H=V}),Fe("packages/core/src/source/filterwire.js",function(e,K){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return y}});const x=K("packages/core/src/internal/util.js").warnOnce,z="source.remote.hostFilter",$="source.where.pageRelative";function _(O,F){!Array.isArray(O)||!O.length||x($,`filters.where (${O.join(", ")}) runs over the rows the ${F} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function X(O){const F=(O||{}).config;!F||!F.hostFilter||x(z,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const W="source.where.notApplied";function V(O,F){x(`${W}:${O}`,`filters.where("${O}") is registered but the ${F} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const H="source.where.overThreshold";function B(O,F,C,T){!Array.isArray(O)||!O.length||x(`${H}:${F}`,`filters.where (${O.join(", ")}) is not applied to the ${F} pushdown source:`,C===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${C.toLocaleString()} rows, at or past the whereRowLimit of ${T.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 w=new Map;function A(O){let F=w.get(O);return F||(F=new Intl.DateTimeFormat("en-US",{timeZone:O,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),w.set(O,F)),F}function g(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function u(O,F){const C=A(F).formatToParts(new Date(O)),T={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const L of C)L.type==="year"?T.y=+L.value:L.type==="month"?T.m=+L.value:L.type==="day"?T.d=+L.value:L.type==="hour"?T.h=+L.value%24:L.type==="minute"?T.mi=+L.value:L.type==="second"&&(T.s=+L.value);return T}function h(O,F){const C=u(O,F);return Date.UTC(C.y,C.m-1,C.d,C.h,C.mi,C.s)-Math.floor(O/1e3)*1e3}function a(O,F,C,T){const L=Date.UTC(O,F-1,C),E=L-h(L,T);return L-h(E,T)}function r(O,F,C){const T=new Date(Date.UTC(O.y,O.m-1,O.d+F));return a(T.getUTCFullYear(),T.getUTCMonth()+1,T.getUTCDate(),C)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function n(O,F){if(typeof O!="string")return null;const C=O.trim().toLowerCase().replace(/[\s_-]+/g,""),T=/^last(\d*|n)days?$/.exec(C);if(T){const L=T[1]==="n"?"":T[1],E=Number(L||F);return!Number.isFinite(E)||E<=0?null:{kind:"lastNDays",n:Math.floor(E)}}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(O,F={}){const C=n(O,F.n);if(!C)return null;const T=F.tz||g(),L=F.now instanceof Date?F.now.getTime():typeof F.now=="number"?F.now:Date.now(),E=u(L,T),D=a(E.y,E.m,E.d,T),I=r(E,1,T);let P=D,k=I;switch(C.kind){case"today":break;case"yesterday":P=r(E,-1,T),k=D;break;case"lastNDays":k=F.includeToday?I:D,P=r(E,F.includeToday?-(C.n-1):-C.n,T);break;case"thisWeek":{const N=Number.isFinite(F.weekStartsOn)?Number(F.weekStartsOn):1,q=(new Date(Date.UTC(E.y,E.m-1,E.d)).getUTCDay()-N+7)%7;P=r(E,-q,T),k=r(E,-q+7,T);break}case"thisMonth":P=a(E.y,E.m,1,T),k=a(E.m===12?E.y+1:E.y,E.m===12?1:E.m+1,1,T);break;case"thisQuarter":case"quarterToDate":{const N=Math.floor((E.m-1)/3)*3+1;P=a(E.y,N,1,T),k=C.kind==="quarterToDate"?I:N===10?a(E.y+1,1,1,T):a(E.y,N+3,1,T);break}case"thisYear":case"yearToDate":P=a(E.y,1,1,T),k=C.kind==="yearToDate"?I:a(E.y+1,1,1,T);break;default:return null}return{from:new Date(P).toISOString(),to:new Date(k).toISOString(),bounds:"[)",tz:T,relative:C.kind==="lastNDays"?`last${C.n}Days`:C.kind,n:C.n}}function d(O){if(!O||typeof O!="object")return null;const F=O.value;if(F&&typeof F=="object"&&!Array.isArray(F)&&"relative"in F)return{token:String(F.relative),n:typeof F.n=="number"?F.n:void 0};if(O.op==="relative"&&typeof O.value=="string")return{token:O.value,n:void 0};const C=O.meta;return C&&typeof C.relative=="string"&&O.value===void 0?{token:C.relative,n:typeof C.n=="number"?C.n:void 0}:null}function l(){return`Known tokens: ${t.filter(F=>F!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function i(O){const F=d(O);return F?n(F.token,F.n)!==null:!1}function m(O,F={}){const C=d(O);if(!C)return O;const T=o(C.token,{...F,n:C.n});return T?{...O,type:O.type||"date",op:"between",value:[T.from,T.to],bounds:O.bounds||T.bounds,meta:{...O.meta||{},relative:T.relative,tz:T.tz}}:(x(`source.relative.${C.token}`,`unknown relative date token "${C.token}"; sending the condition unresolved.`,l()),O)}function c(O){return!!O&&typeof O=="object"&&Array.isArray(O.conditions)}function f(O,F){if(O){if(c(O)){for(const C of O.conditions)f(C,F);return}F(O)}}function s(O,F){if(!O)return null;if(!c(O))return F(O);const C=O;let T=!1;const L=[];for(const E of C.conditions){const D=s(E,F);D!==E&&(T=!0),D&&L.push(D)}return!T&&L.length===C.conditions.length?O:L.length?{...C,conditions:L}:null}function p(O){if(!O)return null;if(!c(O))return O;const F=O,C=[];for(const T of F.conditions){const L=p(T);L&&C.push(L)}return C.length?{op:F.op,conditions:C}:null}function b(O){const F=p(O);return F?c(F)&&F.op==="and"?F:{op:"and",conditions:[F]}:null}function S(O){const F=(O||[]).filter(Boolean);return F.length?{op:"and",conditions:F}:null}function j(O,F={}){const C=s(O,T=>m(T,F));return b(C)}function y(O){const F=v(O.filters??null);return JSON.stringify([F,O.sort??null,O.quick??"",O.groupBy??null,O.pivotBy??null,R(O.context)])}function v(O){if(!O)return null;if(c(O)){const T=O;return{op:T.op,conditions:T.conditions.map(v)}}const F=O,C=F.meta&&typeof F.meta.relative=="string"?F.meta.relative:d(F)?.token;return{col:F.col,op:F.op,bounds:F.bounds??null,caseSensitive:F.caseSensitive??!1,value:C?`rel:${C}`:F.value??null}}function R(O){if(O==null)return null;try{return JSON.parse(JSON.stringify(O))}catch{return x("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Fe("packages/core/src/source/tree.js",function(e,K){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$="",_="\0tree:";function X(u,h){return{physical:u,key:h,level:0,children:[],value:void 0}}function W(u,h){const a=[],r=new Map;for(let t=0;t<u.length;t++){const n=u[t],o=h.pathOf(n),d=Array.isArray(o)?o.map(i=>String(i)):[];if(!d.length){const i=X(n,h.keyOf(n));a.push(i);continue}let l=null;for(let i=0;i<d.length;i++){const m=d.slice(0,i+1).join($),c=i===d.length-1;let f=r.get(m);f&&c&&f.physical===-1&&(f.physical=n,f.key=h.keyOf(n)),f||(f=X(c?n:-1,c?h.keyOf(n):_+m),f.level=i,f.value=d[i],r.set(m,f),l?l.children.push(f):a.push(f)),l=f}}return{roots:a,nodes:r}}function V(u,h){const a=new Map,r=[];for(let d=0;d<u.length;d++){const l=u[d],i=h.keyOf(l),m=X(l,i);a.set(i,m);const c=h.parentOf(l);c!=null&&c!==""&&r.push({node:m,parent:String(c)})}let t=null;const n=new Map;for(const{node:d,parent:l}of r){const i=a.get(l);if(i){n.set(d.key,i);continue}h.orphans&&h.orphans!=="root"&&(t||(t=X(-1,`${_}orphans`),t.value=h.orphans),n.set(d.key,t))}const o=[];for(const d of a.values()){const l=n.get(d.key);l?l.children.push(d):o.push(d)}return t&&t.children.length&&o.push(t),{roots:H(o,a,h.orphans,t),nodes:a}}function H(u,h,a,r){const t=new Set,n=[...u];for(;n.length;){const m=n.pop();if(!t.has(m.key)){t.add(m.key);for(const c of m.children)n.push(c)}}const o=[];for(const m of h.values())t.has(m.key)||o.push(m);if(!o.length)return u;const d=!!a&&a!=="root";z("tree.cycle",`tree.parentKey produced ${o.length} row(s) inside a parent cycle; `+(d?`they are shown under "${a}".`:"they are shown at the root."));for(const m of o)m.children=m.children.filter(c=>t.has(c.key));if(!d)return[...u,...o];let l=r;const i=[...u];return l||(l=X(-1,`${_}orphans`),l.value=a,i.push(l)),l.children.push(...o),i}function B(u){let h=0;const a=(r,t)=>{for(const n of r)n.level=t,t>h&&(h=t),n.children.length&&a(n.children,t+1)};return a(u,0),h}function w(u,h){if(!u||typeof u!="object")return null;const a=u.path,r=u.parentKey,t=x(u.hasChildren)?n=>!!u.hasChildren(h.dataAt(n)):null;if(x(a))return{mode:"path",pathOf:n=>a(h.dataAt(n)),keyOf:h.keyOf,declaresChildren:t};if(r!=null){const n=x(r)?r:o=>o?.[r];return{mode:"parentKey",parentOf:o=>n(h.dataAt(o)),keyOf:h.keyOf,orphans:u.orphans||"root",declaresChildren:t}}return z("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function A(u,h){const a=h.mode==="path"?W(u,h):V(u,h),r=B(a.roots);return{...a,depth:r}}function g(u,h){const a=new Map,r=t=>{for(let n=0;n<t.length;n++){const o=t[n];if(o.physical>=0){const d=h?h(o.physical):!1,l=d&&o.children.length===0;a.set(o.physical,{level:o.level,posinset:n+1,setsize:t.length,hasChildren:o.children.length>0||d,lazy:l})}o.children.length&&r(o.children)}};return r(u),a}}),Fe("packages/core/src/source/memory.js",function(e,K){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return I}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,z=Q.warnOnce,$=Q.fail,_=Q.isFunction,X=Q.defaultCompare,W=Q.mergeRow,V=K("packages/core/src/source/rows.js"),H=V.createRowFactory,B=V.groupKey,w=V.groupPathElement,A=V.groupPrefixKeys,g=V.lazyRowView,h=K("packages/core/src/source/handles.js").createHandleProvider,a=K("packages/core/src/compute/incremental.js"),r=a.RunningTotal,t=a.isIncremental,o=K("packages/core/src/compute/handle.js").presenceReader,d=K("packages/core/src/source/filterwire.js"),l=d.querySignature,i=d.mapConditions,m=d.resolveRelativeCondition,c=K("packages/core/src/source/tree.js"),f=c.buildTree,s=c.resolveTree,p=c.indexTree,b=Object.freeze(["filter","sort","group","total","pivot","flatten"]),S=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function j(P){const k=P&&typeof P=="object"?P.reason:null;return typeof k=="string"&&S.includes(k)}const y=Object.freeze([]);function v(P,k){if(!P)return null;const N=k==="grand"?P.grandTotal:P.groupTotal;return N??P.total}function R(P){return!!P&&!P.running}function O(P){if(P)return P.value&&_(P.value.compare)?P.value.compare:_(P.compare)?P.compare:void 0}function F(P){const k=P&&P.dataType;return!k||!_(k.items)?null:{items:k.items,type:P.itemType&&P.itemType.name||"text"}}function C(P){return!!P&&(typeof P=="object"||typeof P=="function")&&_(P.then)}const T=new Uint32Array(0),L=4096;function E(P,k){return new I(P,k)}function D(P,k){if(k==="regex")try{const N=new RegExp(P,"iu");return G=>N.test(G)}catch{return N=>N.includes(P)}if(k==="fuzzy"){const N=[...P].filter(G=>G!==" ");return N.length?G=>{let q=0;for(let Y=0;Y<G.length&&q<N.length;Y++)G[Y]===N[q]&&q++;return q===N.length}:()=>!0}if(k==="words"){const N=P.split(/\s+/).filter(Boolean);return N.length?G=>N.every(q=>G.includes(q)):()=>!0}return N=>N.includes(P)}class I{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#p=null;#m=I.#g();static#g(){return{slots:[],groupHeadings:y,unnumbered:y,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#y=new Map;#b=null;#A=new Map;#w=-1;#S=[];#v=new Map;#C=-1;#O=[];#P=null;#M=null;#E=null;#T=null;#N=null;#L=null;#B=null;#_=null;#z=Symbol("unset");#$=new Map;#q=null;get#I(){return this.#m.slots}set#I(k){this.#m.slots=k}get#W(){return this.#m.inlineLeaves}set#W(k){this.#m.inlineLeaves=k}get#V(){return this.#m.groupHeadings}set#V(k){this.#m.groupHeadings=k}get#U(){return this.#m.unnumbered}set#U(k){this.#m.unnumbered=k}get#fe(){return this.#m.pivot}set#fe(k){this.#m.pivot=k}constructor(k,N){this.#t=k||{mode:"memory"},this.#e=N||{};const G=this.#e.config||{};this.#n=this.#t.rows||G.rows||[],this.#i=H(this.#e),this.#s=h(this.#e,()=>this.#n,()=>this.#r),this.#f=new x(Number(G.rowCacheSize)||L);for(const q of b)this.#l.set(q,{key:null,result:null,id:0,computed:!1})}count(){this.#D();const k=this.#ie();return k?k.length:this.#I.length}#ie(){const k=Number(this.#H("pageSize",0))||0;if(k<=0)return null;const N=this.#I.length,G=Math.max(1,Math.ceil(N/k)),Y=Math.min(Math.max(0,Number(this.#H("page",0))||0),G-1)*k;return{offset:Y,length:Math.max(0,Math.min(k,N-Y))}}pageInfo(){this.#D();const k=Number(this.#H("pageSize",0))||0,N=this.#I.length;if(k<=0)return{page:0,pageSize:0,total:N,pageCount:1};const G=Math.max(1,Math.ceil(N/k));return{page:Math.min(Math.max(0,Number(this.#H("page",0))||0),G-1),pageSize:k,total:N,pageCount:G}}totalCount(){return this.#de().length}matchCount(){return this.#D(),this.#m.matchCount}at(k){this.#D();const N=this.#ie();if(N)return k<0||k>=N.length?void 0:this.#Fe(N.offset+k,k);if(!(k<0||k>=this.#I.length))return this.#Fe(k,k)}byKey(k){this.#D(),this.#p||this.#Te();const N=this.#p.get(k);if(N!==void 0)return this.#Ae(N);for(let G=0;G<this.#I.length;G++){const q=this.#I[G];if(typeof q!="number"&&q&&q.key===k)return this.#Fe(G)}}loaded(k){return k>=0&&k<this.count()}hint(k,N){}display(){return this.#D(),this.#q||(this.#q=this.#Mt()),this.#q}invalidateQuickText(){this.#$.clear(),this.invalidate("filter")}invalidate(k){const N=b.indexOf(k);N<0&&$(`unknown pipeline stage "${k}"; expected one of ${b.join(", ")}`);for(let G=N;G<b.length;G++){const q=this.#l.get(b[G]);q.key=null,q.computed=!1}this.#q=null}apply(k){const N=[],G={added:[],updated:[],removed:[],rejected:N};if(!k)return G;let q=!1;const Y=new Set;if(k.remove&&k.remove.length)for(const J of k.remove){const ee=this.#me(J);if(ee===void 0){N.push({operation:"remove",id:this.#we(J),reason:"unknown-id"});continue}G.removed.push(this.#i.keyOf(this.#r?this.#ue(ee):this.#n[ee],ee)),this.#r||(this.#n[ee]=void 0),this.#f.delete(ee),this.#$.delete(ee),q=!0}if(k.update&&k.update.length){const J=this.#A.size||this.#Ke()?this.#Xe():null,ee=this.#v.size?this.#kt():null,re=ee&&ee.length?this.#Xe():null;for(const ie of k.update){const ae=this.#me(ie);if(ae===void 0){N.push({operation:"update",id:this.#Ee(ie),reason:"unknown-id"});continue}const fe=this.#r?this.#o&&this.#o.has(ae)?this.#o.get(ae):this.#ue(ae):this.#n[ae],ce=W(fe,ie);for(const te of this.#te(fe,ce))Y.add(te);if(this.#r||(this.#n[ae]=ce),J&&this.#Tt(J,ae,fe,ce),re&&this.#lt(ee,re,ae,fe,ce),this.#p){const te=this.#i.keyOf(fe,ae),oe=this.#i.keyOf(ce,ae);te!==oe&&(this.#p.delete(te),this.#p.set(oe,ae))}this.#f.delete(ae),this.#$.delete(ae),G.updated.push(this.#Ae(ae))}}if(k.add&&k.add.length&&this.#r){typeof k.at=="number"&&k.at<this.#Me()&&(this.#f.clear(),this.#$.clear()),this.#p=null;for(const J of k.add){const ee=this.#se(this.#Ee(J));ee!==void 0&&G.added.push(this.#Ae(ee))}q=!0}else if(k.add&&k.add.length){const J=typeof k.at=="number"?k.at:this.#n.length,ee=this.#n.length;let re=k.add===this.#n?k.add.slice():k.add;if(this.#i.keyed){const ie=[];for(const ae of re){const fe=this.#Ee(ae);if(this.#me(fe)!==void 0){N.push({operation:"add",id:fe,reason:"duplicate-id"});continue}ie.push(ae)}ie.length!==re.length&&(re=ie)}if(!re.length)return G;if(J>=ee)for(let ie=0;ie<re.length;ie++)this.#n.push(re[ie]);else this.#n.splice(J,0,...re),this.#f.clear(),this.#$.clear();for(let ie=0;ie<re.length;ie++)G.added.push(this.#Ae(J>=ee?ee+ie:J+ie));q=!0}return this.#u++,q&&(this.#p=null,this.#nt()),this.#s.invalidate(),this.#q=null,q||this.#Z(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:G.added.length,updated:G.updated.length,removed:G.removed.length}),this.#o=null,G}groupHeadingsAt(k){this.#D();const N=this.#V;if(!N.length||!Number.isInteger(k)||k<0)return y;let G=0,q=N.length-1,Y=-1;for(;G<=q;){const ee=G+q>>1;N[ee].at<=k?(Y=ee,G=ee+1):q=ee-1}if(Y<0)return y;const J=[];for(let ee=N[Y].row;ee;ee=ee.parent)J.push(ee);return J.reverse(),J}unnumberedRowCount(k){this.#D();const N=this.#U;if(!N.length||!Number.isInteger(k)||k<0)return 0;let G=0,q=N.length-1,Y=-1;for(;G<=q;){const J=G+q>>1;N[J].at<=k?(Y=J,G=J+1):q=J-1}return Y+1}moveRow(k,N){if(this.#r)return z("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 G=this.#n;if(!Number.isInteger(k)||!Number.isInteger(N)||k<0||k>=G.length)return!1;const q=Math.max(0,Math.min(G.length-1,N));if(q===k)return!1;const[Y]=G.splice(k,1);return G.splice(q,0,Y),this.#u++,this.#c++,this.#p=null,this.#f.clear(),this.#$.clear(),this.#nt(),this.#s.invalidate(),this.#q=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(k){this.#ye(),this.#u++,this.#c++,this.#p=null,this.#$.clear(),this.#f.clear(),this.#nt(),this.#s.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#ye(),this.#f.clear(),this.#$.clear(),this.#p=null,this.#I=[],this.#W=null,this.#q=null,this.#nt();for(const k of b)this.#l.set(k,{key:null,result:null,id:0,computed:!1})}#ye(){for(const{controller:k}of this.#y.values())try{k.abort()}catch{}this.#y.clear()}setRows(k){this.#n=k||[],this.#r=!1,this.#u++,this.#c++,this.#p=null,this.#$.clear(),this.#f.clear(),this.#nt(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(k){this.#o=k||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#f.clear(),this.#$.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const k=this.#e.store;if(!k||!_(k.source))return this.#n;const N=k.physical||0,G=new Array(N);for(let q=0;q<N;q++)G[q]=k.live&&!k.live(q)?void 0:k.source(q);return G}#Ie(){const k=this.#H("detail",null);return!k||!_(k.isOpen)||k.inline===!1?null:k}#be(){const k=(this.#e.config||{}).tree;return this.#z!==k&&(this.#z=k,this.#_=s(k,{dataAt:N=>this.#ue(N),keyOf:N=>this.#i.keyOf(this.#ue(N),N)})),this.#_}#pe(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#pe())return null;this.#D();const k=this.#m.grand;return k?this.#i.grandTotal(k,this.#et(this.#m.grandLeaves)):null}pivot(){return this.#D(),this.#fe}pivotMatrix(){this.#D();const k=this.#m.groupLeaves,N=(this.#e.compute||{}).pivotMatrix;if(!_(N))return null;const G=this.#H("groupBy",[]),q=this.#H("pivotBy",[]);if(!G.length&&!q.length)return z("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const Y=this.#Xe().map(ee=>({colId:ee.id,handle:this.#s.handle(ee.id),fn:v(ee,"group")})).filter(ee=>ee.handle&&ee.fn),J=this.#e.config||{};return N({rowHandles:G.map(ee=>this.#s.handle(ee)).filter(Boolean),columnHandles:q.map(ee=>this.#s.handle(ee)).filter(Boolean),measures:Y,leaves:k||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(k){const N=[];if(!k)return N;for(let G=0;G<k.length;G++){const q=this.#Ae(k[G]);q&&q.key!=null&&N.push(String(q.key))}return N}leavesOf(k){this.#D();const N=this.#l.get("group"),G=N&&N.result;if(!G||!G.nodes)return[];const q=G.nodes.get(k);if(!q)return[];const Y=[],J=ee=>{const re=ee.row&&ee.row.children;if(re&&re.length){for(const ie of re){const ae=G.nodes.get(ie.key);ae&&J(ae)}return}if(ee.leaves)for(let ie=0;ie<ee.leaves.length;ie++)Y.push(this.#Ae(ee.leaves[ie]))};return J(q),Y}#we(k){return typeof k=="string"?k:this.#Ee(k)}#Ee(k){try{return this.#i.keyOf(k,-1)}catch{return"(unkeyed)"}}#me(k){if(typeof k=="string")return this.#se(k);if(this.#i.keyed){const G=this.#i.keyOf(k,-1),q=this.#se(G);if(q!==void 0)return q}if(this.#r)return;const N=this.#n.indexOf(k);return N>=0?N:void 0}#se(k){return this.#p||this.#Te(),this.#p.get(k)}#Te(){this.#p=new Map;const k=this.#Me(),N=this.#e.store,G=N&&_(N.live)?q=>N.live(q):null;for(let q=0;q<k;q++){if(G&&!G(q))continue;const Y=this.#ue(q);Y!==void 0&&this.#p.set(this.#i.keyOf(Y,q),q)}}#te(k,N){const G=[];for(const q of this.#K())this.#ze(q)&&this.#ne(q,k,N,new Set)&&G.push(q);return G}#ne(k,N,G,q){if(q.has(k))return!1;q.add(k);const Y=this.#ze(k);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(ee=>this.#ne(String(ee),N,G,q)):_(Y.getValue)?!Object.is(Y.getValue(N),Y.getValue(G)):!1}#K(){const k=new Set;for(const G of this.#H("sort",[]))k.add(G.col);for(const G of this.#H("groupBy",[]))k.add(G);const N=G=>{if(G){if(Array.isArray(G.conditions)){G.conditions.forEach(N);return}G.col&&k.add(G.col)}};return N(this.#H("filters",null)),[...k]}#Z(k){if(!k.size)return!1;if(this.#H("quick",""))return!0;for(const N of this.#K())if(k.has(N))return!0;return!1}#D(){if(!this.#a){this.#a=!0;try{this.#Ne()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Ne(){const k=this.#J("filter",()=>this.#G(),()=>this.#Oe()),N=this.#ee(k),G=this.#J("group",()=>this.#ge(),()=>this.#Ge(N)),q=this.#J("total",()=>this.#ve(),()=>this.#He(G));this.#J("pivot",()=>this.#k(),()=>this.#At(G)),this.#J("flatten",()=>this.#Se(),()=>this.#Ve(G)),this.#Ue(G,q)}#ee(k){const N=this.#l.get("sort"),G=this.#le();if(N.computed&&N.key===G&&!this.#y.has("sort"))return N.result;const q=this.#y.get("sort");return q&&q.key===G?N.result:N.result&&this.#Pe(k)?(this.#Ce(k,G),N.result):this.#J("sort",()=>G,()=>this.#Re(k))}#ae(){if(this.#b===null){const k=this.#e.pipelineWorker,N=_(k)?k():null;this.#b=N||!1}return this.#b||null}#ce(){const k=this.#H("sort",[]);if(!Array.isArray(k)||!k.length)return null;const N=(this.#e.config||{}).locale,G=[],q=[];for(const Y of k){const J=this.#ze(Y.col);if(J&&J.running)continue;if(J&&J.value&&_(J.value.compare))return null;const ee=this.#s.handle(Y.col);if(!ee)return null;G.push({col:Y.col,descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:N}),q.push(ee)}return G.length?{entries:G,handles:q,locale:N}:null}#Pe(k){if(this.#he())return!1;const N=this.#ae();if(!N)return!1;const G=Number(N.threshold);return Number.isFinite(G)&&k.length<G?!1:!!this.#ce()}#Ce(k,N){const G=this.#ae(),q=G&&this.#ce();if(!q){this.#J("sort",()=>N,()=>this.#Re(k));return}const Y=new AbortController;this.#y.set("sort",{key:N,controller:Y});const J=q.entries.length===1?G.sortColumn(q.handles[0],k,{descending:q.entries[0].descending,nullsFirst:q.entries[0].nullsFirst,locale:q.locale,signal:Y.signal,key:"sort"}):G.sortMulti(q.handles,q.entries.map((ee,re)=>({...ee,handle:q.handles[re]})),k,{signal:Y.signal,key:"sort"});if(!C(J)){this.#y.delete("sort"),this.#J("sort",()=>N,()=>J);return}J.then(ee=>this.#Y(N,ee),ee=>this.#x("sort",N,ee))}#Y(k,N){const G=this.#y.get("sort");if(!(!G||G.key!==k)){if(this.#le()!==k){this.#y.delete("sort");return}this.#y.delete("sort"),this.#J("sort",()=>k,()=>N),this.#q=null,this.#D(),this.#Qe("model:changed",{reason:S[0]})}}#x(k,N,G){const q=this.#y.get(k);if(!(!q||q.key!==N)&&(this.#y.delete(k),!(G&&G.name==="AbortError")&&k==="sort"&&this.#le()===N)){const Y=this.#J("filter",()=>this.#G(),()=>this.#Oe());this.#J("sort",()=>N,()=>this.#Re(Y)),this.#q=null,this.#D(),z("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",G),this.#Qe("model:changed",{reason:S[1]})}}#Ue(k,N){const G=k&&k.leaves?k.leaves.length:this.#m.slots.length;this.#m.matchCount=G,this.#m.grand=N&&N.grand||null,this.#m.grandLeaves=k&&k.leaves?k.leaves.length:0,this.#m.groupLeaves=k&&k.leaves?k.leaves:null}#J(k,N,G){const q=this.#l.get(k),Y=N();return q.computed&&q.key===Y||(q.result=G(),q.key=Y,q.computed=!0,q.id++,k==="flatten"&&(this.#q=null)),q.result}#R(k){return this.#l.get(k).id}#G(){const k=(this.#e.config||{}).hostFilter,N=k&&_(k.active)&&k.active()?1:0,G=this.#H("where",null),q=G?G.version:0,Y=this.#gt("filter.sig",`${this.#ct()}`,()=>l({filters:this.#H("filters",null),quick:this.#H("quick",""),quickMode:this.#H("quickMode","contains")}));return`${this.#c}|${Y}|${N}|${q}`}#le(){const k=this.#he();return`${this.#R("filter")}|${JSON.stringify(this.#H("sort",[]))}`+(k?`|manual:${k.version}`:"")}#he(){const k=this.#H("rowOrder",null);return k&&Array.isArray(k.keys)?k:null}#oe(k,N){this.#p||this.#Te();const G=this.#p,q=this.#Me(),Y=N.keys.length,J=new Float64Array(q);for(let ee=0;ee<q;ee++)J[ee]=Y+ee;for(let ee=0;ee<Y;ee++){const re=G.get(N.keys[ee]);re!==void 0&&(J[re]=ee)}return Uint32Array.from(k).sort((ee,re)=>J[ee]-J[re])}orderedKeys(){this.#p||this.#Te();const k=this.#p,N=new Map;for(const[ee,re]of k)N.set(re,ee);const G=Uint32Array.from([...N.keys()]).sort(),q=this.#he(),Y=q?this.#oe(G,q):this.#Re(G),J=new Array(Y.length);for(let ee=0;ee<Y.length;ee++)J[ee]=N.get(Y[ee]);return J}#ge(){const k=this.#H("pivotBy",[]).length>0?"p":"u";return`${this.#R("sort")}|${JSON.stringify(this.#H("groupBy",[]))}|${k}`}#ve(){const k=this.#qe()?"f":"a",N=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#R("group")}|${JSON.stringify(this.#H("totals",[]))}|${k}${N}|${this.#u}`}#k(){return`${this.#R("group")}|${JSON.stringify(this.#H("pivotBy",[]))}`}#Se(){const N=this.#We()||!this.#pe()?this.#R("total"):"x",G=`${this.#ct()}`,q=this.#gt("flatten.keys",G,()=>{const J=this.#H("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#gt("flatten.detail",G,()=>{const J=this.#H("detail",null);return J&&_(J.signature)?J.signature():""});return`${N}|${this.#R("pivot")}|${q}|${Y}`}#We(){const k=this.#H("groupBy",[]);return Array.isArray(k)&&k.length>0}stageState(){const k=[];for(const[N,G]of this.#l){const q=G.result;k.push({stage:N,materialised:!!G.computed,bytes:q&&typeof q.byteLength=="number"?q.byteLength:null,rows:q&&typeof q.length=="number"?q.length:null,rebuilds:G.id})}return k}facetIndices(k){return this.#Oe(k||null)}facetRows(k){const N=this.facetIndices(k),G=[];for(let q=0;q<N.length;q++){const Y=this.#Ae(N[q]);Y&&G.push(Y)}return G}invalidateRows(){this.#f.clear(),this.#$.clear(),this.#q=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#de()}filteredIndices(){const k=this.#l.get("filter");if(k&&k.computed&&k.key===this.#G())return k.result||this.#de();this.#D();const N=this.#l.get("filter");return(N&&N.computed?N.result:null)||this.#de()}unfilteredRows(){const k=this.#de(),N=[];for(let G=0;G<k.length;G++){const q=this.#Ae(k[G]);q&&N.push(q)}return N}#Oe(k=null){const N=this.#de(),G=this.#H("filters",null),q=k?this.#ot("pruneColumn")(G,k):G,Y=this.#it(q),J=String(this.#H("quick","")||"").trim().toLowerCase(),ee=J?D(J,String(this.#H("quickMode","contains")||"contains")):null,re=(this.#e.config||{}).hostFilter,ie=!!(re&&_(re.active)&&re.active()),ae=this.#H("where",null),fe=!!(ae&&ae.active);if(!Y&&!J&&!ie&&!fe)return N;let ce=null;Y&&(ce=this.#ot("evaluateFilters")(Y,{handle:de=>this.#s.handle(de),count:this.#Me(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:de=>F(this.#ze(de))}));const te=new Uint32Array(N.length);let oe=0;for(let he=0;he<N.length;he++){const de=N[he];if(!(ce&&!ce[de])&&!(ee&&!this.#ut(de,ee))){if(ie||fe){const be=this.#Ae(de);if(ie&&!re.passes(be)||fe&&!ae.passes(be.data,be.key))continue}te[oe++]=de}}if(ce){const he=(this.#e.compute||{}).releaseMask;_(he)&&he({pool:this.#e.pool},ce)}return te.subarray(0,oe)}handleFor(k){return this.#s.handle(k)}#Re(k){const N=this.#he();if(N)return this.#oe(k,N);const G=this.#H("sort",[]).filter(J=>{const ee=this.#ze(J.col);return!ee||!ee.running?!0:(z(`source.sort.running.${J.col}`,`sort ignores "${J.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!G.length)return k;const q=(this.#e.config||{}).locale;if(G.length===1){const J=G[0],ee=this.#s.handle(J.col);if(!ee)return z(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`),k;const re=this.#ze(J.col);return this.#ot("sortColumn")(ee,k,{descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:O(re)})}const Y=[];for(const J of G){const ee=this.#s.handle(J.col);if(!ee){z(`source.sort.${J.col}`,`sort ignores unknown column "${J.col}".`);continue}Y.push({handle:ee,descending:J.dir==="desc",nullsFirst:J.nullsFirst,locale:q,compare:O(this.#ze(J.col))})}return Y.length?this.#ot("sortMulti")(Y.map(J=>J.handle),Y,k):k}#Ge(k){const N=this.#H("groupBy",[]),G=this.#be();if(G&&!N.length){const he=f(k,G);return this.#L=p(he.roots,G.declaresChildren),{roots:null,leaves:k,nodes:new Map,tree:he}}if(this.#L=null,G&&N.length&&z("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!N.length)return{roots:null,leaves:k,nodes:new Map};const q=(this.#e.config||{}).timeZone,Y=[],J=[];let ee=!1;for(const he of N){const de=this.#s.handle(he);if(!de){z(`source.group.${he}`,`grouping ignores unknown column "${he}".`);continue}Y.push(de);const be=this.#ze(he),Te=be&&be.dataType;if(Te&&_(Te.groupProjector)){const Ae=be.typeOptions&&be.typeOptions.timeZone||q||void 0,Ce=Te.groupProjector(be,Ae);J.push(Ce||null),Ce&&(ee=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:k,nodes:new Map};const{keys:re,buckets:ie}=this.#ot("groupByColumns")(Y,k,{locale:(this.#e.config||{}).locale,project:ee?J:void 0}),ae=this.#H("pivotBy",[]).length>0,fe=[],ce=new Map;for(let he=0;he<ie.length;he++){const de=re[he];let be=null;const Te=[];for(let Ae=0;Ae<de.length;Ae++){Te.push(w(de[Ae]));const Ce=B(Te),me=Ae===de.length-1;let we=ce.get(Ce);if(!we){const ge=this.#i.group({path:[...Te],column:N[Ae],value:de[Ae],level:Ae,parent:be,expanded:ae&&me?!1:this.#pt(Ce,{key:Ce,column:N[Ae],value:de[Ae],level:Ae,path:[...Te]}),hasChildren:!(ae&&me)});we={row:ge,leaves:null},ce.set(Ce,we),be?be.children.push(ge):fe.push(ge)}we.row.leafCount+=ie[he].length,Ae===de.length-1&&(we.leaves=ie[he]),be=we.row}}const te=this.#H("sort",[])||[],oe=(he,de)=>{if(!he||he.length<2){if(he)for(const Ce of he)oe(Ce.children,de+1);return}const be=N[de],Te=te.find(Ce=>Ce.col===be),Ae=Te&&Te.dir==="desc"?-1:1;he.sort((Ce,me)=>Ae*X(Ce.groupValue,me.groupValue));for(const Ce of he)oe(Ce.children,de+1)};return oe(fe,0),{roots:fe,leaves:k,nodes:ce,keys:re,buckets:ie}}#Ze(k,N){const G=new Map,q=new Map,Y=J=>{const ee=J.physical>=0?[J.physical]:[];for(const re of J.children)ee.push(...Y(re));if(J.children.length){const re=this.#rt(N,Uint32Array.from(ee),null);J.physical>=0?G.set(J.physical,re):q.set(J.key,re)}return ee};for(const J of k.roots)Y(J);return{byPhysical:G,byKey:q}}#He(k){const N=this.#Xe();if(!N.length)return this.#M=null,this.#E=null,{grand:null};const G={id:this.#R("group"),columns:N.map(te=>te.id).join("")},q=this.#M&&this.#M.id===G.id&&this.#M.columns===G.columns,Y=this.#Ke()&&q?this.#P:null,J=Y?N.filter(te=>Y.has(te.id)):N,ee=q?this.#E:null,re=this.#qe()?null:this.#tt(),ie=this.#ke(N),ae=te=>{const oe=k.nodes.get(te.key);let he=oe&&oe.leaves?oe.leaves:null;if(te.children&&te.children.length){const Te=te.children.map(ae);let Ae=0;for(const we of Te)Ae+=we.length;const Ce=new Uint32Array(Ae);let me=0;for(const we of Te)Ce.set(we,me),me+=we.length;he=Ce}he=he||new Uint32Array(0);const de=re?re.get(te.key)||T:he,be=this.#at(te,Y?J:N,de,ie);return te.totals=Y?{...te.totals,...be}:be,he};if(k.roots&&J.length)for(const te of k.roots)ae(te);if(this.#B=k.tree?this.#Ze(k.tree,N):null,this.#M=G,this.#P=this.#Ke()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#E=null,{grand:null};const ce=re?this.#Ye():k.leaves;return this.#E=this.#_e(N,ce,Y,ee),{grand:this.#E}}#_e(k,N,G,q){const Y={},J=this.#R("group");J!==this.#w&&(this.#Ot(),this.#w=J);const ee=this.#S;this.#S=[];for(const re of k){if(!R(re))continue;const ie=this.#s.handle(re.id);if(!ie)continue;const ae=v(re,"grand");if(!t(ae,ie)){if(G&&!G.has(re.id)&&q&&re.id in q){Y[re.id]=q[re.id];continue}Y[re.id]=this.#rt([re],N,null,"grand")[re.id];continue}let fe=this.#A.get(re.id);if((!fe||fe.fn!==ae)&&(fe=new r(ae),this.#A.set(re.id,fe)),fe.valid){let ce=!0;for(const te of ee)if(te.colId===re.id&&!fe.update(te.before,te.after)){ce=!1;break}if(ce){Y[re.id]=fe.value();continue}fe.invalidate()}fe.seedColumn(ie.values,o(ie),N),Y[re.id]=fe.valid?fe.value():this.#rt([re],N,null,"grand")[re.id]}return Y}#ke(k){const N=this.#R("group");N!==this.#C&&(this.#v.clear(),this.#C=N);const G=new Map;for(const Y of k){if(!R(Y))continue;const J=this.#s.handle(Y.id),ee=v(Y,"group");t(ee,J)&&G.set(Y.id,{fn:ee})}if(!G.size)return this.#O.length=0,G;const q=this.#O;this.#O=[];for(const Y of q){const{beforeKeys:J,afterKeys:ee,colDeltas:re}=Y,ie=J.length?new Set(J):null,ae=ee.length?new Set(ee):null;for(const{colId:fe,before:ce,after:te}of re)if(G.has(fe)){for(const oe of J)ae&&ae.has(oe)||this.#Le(oe,fe,ce,null);for(const oe of ee)ie&&ie.has(oe)||this.#Le(oe,fe,null,te);for(const oe of J)ae&&!ae.has(oe)||this.#Le(oe,fe,ce,te)}}return G}#Le(k,N,G,q){const Y=this.#v.get(k),J=Y&&Y.get(N);!J||!J.valid||J.update(G,q)||J.invalidate()}#at(k,N,G,q){if(!q||!q.size)return this.#rt(N,G,k);const Y={};let J=null,ee=this.#v.get(k.key);for(const re of N){const ie=q.get(re.id);if(!ie){(J||(J=[])).push(re);continue}const ae=this.#s.handle(re.id);if(!ae)continue;ee||(ee=new Map,this.#v.set(k.key,ee));let fe=ee.get(re.id);if((!fe||fe.fn!==ie.fn)&&(fe=new r(ie.fn),ee.set(re.id,fe)),fe.valid||fe.seedColumn(ae.values,o(ae),G),fe.valid){Y[re.id]=fe.value();continue}(J||(J=[])).push(re)}return J&&Object.assign(Y,this.#rt(J,G,k)),Y}#Tt(k,N,G,q){const Y=!this.#qe()||this.#St(N);for(const J of k){const ee=J.getValue;if(!_(ee))continue;const re=ee(G),ie=ee(q);Object.is(re,ie)||(this.#P&&this.#P.add(J.id),Y&&this.#A.has(J.id)&&this.#S.push({colId:J.id,before:re,after:ie}))}}#kt(){const k=this.#H("groupBy",[]),N=[];for(const G of k){const q=this.#ze(G);q&&N.push(q)}return N}#re(k,N){const G=new Array(k.length);for(let q=0;q<k.length;q++){const Y=k[q].getValue;G[q]=w(_(Y)?Y(N):void 0)}return G}#lt(k,N,G,q,Y){if(this.#qe()&&!this.#St(G))return;const J=A(this.#re(k,q)),ee=A(this.#re(k,Y)),re=J.length!==ee.length||J.some((ae,fe)=>ae!==ee[fe]),ie=[];for(const ae of N){const fe=ae.getValue;if(!_(fe))continue;const ce=fe(q),te=fe(Y);!re&&Object.is(ce,te)||ie.push({colId:ae.id,before:ce,after:te})}!ie.length&&!re||this.#O.push({beforeKeys:J,afterKeys:ee,colDeltas:ie})}#St(k){const N=this.#l.get("filter"),G=N&&N.computed?N.result:null;if(!G)return!0;let q=0,Y=G.length-1;for(;q<=Y;){const J=q+Y>>1,ee=G[J];if(ee===k)return!0;ee<k?q=J+1:Y=J-1}return!1}#qe(){return(this.#e.config||{}).totalFilteredOnly!==!1}#et(k){return this.#qe()?k:this.#Ye().length}#Ye(){return(!this.#T||this.#T.version!==this.#c)&&(this.#T={version:this.#c,indices:this.#de()}),this.#T.indices}#tt(){const k=this.#H("groupBy",[]),N=`${this.#c}|${JSON.stringify(k)}`;if(this.#N&&this.#N.key===N)return this.#N.map;const G=new Map,q=[];for(const Y of k){const J=this.#s.handle(Y);J&&q.push(J)}if(q.length){const Y=this.#Ye(),{keys:J,buckets:ee}=this.#ot("groupByColumns")(q,Y,{locale:(this.#e.config||{}).locale}),re=new Map;for(let ie=0;ie<ee.length;ie++){const ae=J[ie],fe=[];for(let ce=0;ce<ae.length;ce++){fe.push(w(ae[ce]));const te=B(fe);let oe=re.get(te);oe||(oe=[],re.set(te,oe));for(let he=0;he<ee[ie].length;he++)oe.push(ee[ie][he])}}for(const[ie,ae]of re)G.set(ie,Uint32Array.from(ae))}return this.#N={key:N,map:G},G}#Ke(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#nt(){this.#Ot(),this.#j(),this.#P=null,this.#M=null,this.#E=null}#Ot(){this.#A.clear(),this.#S.length=0,this.#w=-1}#j(){this.#v.clear(),this.#O.length=0,this.#C=-1}#At(k){const N=this.#H("pivotBy",[]);if(!N.length)return this.#fe=null,null;const G=(this.#e.compute||{}).pivot;if(!_(G))return z("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#fe=null,null;const q=N.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#Xe();return this.#fe=G(q,k.leaves,{groups:k.keys&&k.buckets?{keys:k.keys,buckets:k.buckets}:null,totals:Y.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>v(Y.find(ee=>ee.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#fe}#Ve(k){const N=this.#l.get("total").result,G=!!(this.#e.config||{}).groupFooter,q=this.#Ie();if(k.tree)return this.#jt(k,N,q);if(!k.roots&&!q){if(N&&N.grand&&!this.#pe()){const ae=this.#i.grandTotal(N.grand,this.#et(k.leaves.length));if(this.#W===k.leaves&&Array.isArray(this.#I))this.#I[this.#I.length-1]=ae;else{const fe=Array.from(k.leaves);fe.push(ae),this.#I=fe,this.#W=k.leaves}this.#U=[{at:this.#I.length-1}]}else this.#W=null,this.#I=k.leaves,this.#U=y;return this.#V=y,this.#I}const Y=[],J=[],ee=[],re=ae=>{if(Y.push(ae),!q)return;const fe=this.#Ae(ae);!fe||!q.isOpen(fe.key)||(fe.master=!0,fe.expanded=!0,ee.push({at:Y.length}),Y.push(this.#i.detail(fe,q.heightOf(fe))))};if(!k.roots){for(let ae=0;ae<k.leaves.length;ae++)re(k.leaves[ae]);return N&&N.grand&&!this.#pe()&&(ee.push({at:Y.length}),Y.push(this.#i.grandTotal(N.grand,this.#et(k.leaves.length)))),this.#W=null,this.#V=y,this.#U=ee.length?ee:y,this.#I=Y,Y}const ie=(ae,fe,ce)=>{if(ae.expanded=ae.hasChildren===!1?!1:this.#pt(ae.key,{key:ae.key,column:ae.groupColumn,value:ae.groupValue,level:ae.level,path:ae.groupPath}),ae.posinset=fe+1,ae.setsize=ce,J.push({at:Y.length,row:ae}),ee.push({at:Y.length}),Y.push(ae),!!ae.expanded){if(ae.children&&ae.children.length)for(let te=0;te<ae.children.length;te++)ie(ae.children[te],te,ae.children.length);else{const te=k.nodes.get(ae.key),oe=te&&te.leaves?te.leaves:null;if(oe)for(let he=0;he<oe.length;he++)re(oe[he])}G&&ae.totals&&(ee.push({at:Y.length}),Y.push(this.#i.footer(ae)))}};for(let ae=0;ae<k.roots.length;ae++)ie(k.roots[ae],ae,k.roots.length);return N&&N.grand&&!this.#pe()&&(ee.push({at:Y.length}),Y.push(this.#i.grandTotal(N.grand,this.#et(k.leaves.length)))),this.#V=J,this.#U=ee,this.#I=Y,Y}#de(){const k=this.#e.store;if(k&&_(k.liveIndices))return k.liveIndices();const N=new Uint32Array(this.#n.length);let G=0;for(let q=0;q<this.#n.length;q++)this.#n[q]!==void 0&&(N[G++]=q);return N.subarray(0,G)}#Me(){const k=this.#e.store;return k&&typeof k.physical=="number"?k.physical:this.#n.length}#ue(k){const N=this.#e.store;return N&&_(N.source)?N.source(k):this.#n[k]}#Fe(k,N=k){const G=this.#I[k];if(typeof G!="number")return G.index=N,G;const q=this.#Ae(G);return q.index=N,q}#Ae(k){let N=this.#f.get(k);N||(N=this.#i.leaf(this.#ue(k),k),this.#f.set(k,N));const G=this.#L?this.#L.get(k):null;if(G){N.level=G.level,N.posinset=G.posinset,N.setsize=G.setsize,N.hasChildren=G.hasChildren,N.expanded=G.hasChildren&&!G.lazy&&this.#pt(N.key);const q=this.#B?this.#B.byPhysical.get(k):void 0;q?N.totals=q:N.totals&&(N.totals=null)}else N.hasChildren&&(N.level=0,N.hasChildren=!1,N.expanded=!1,N.posinset=void 0,N.setsize=void 0);return N}#jt(k,N,G){const q=[],Y=[],J=re=>{if(re.leafCount!==void 0)return re.leafCount;let ie=re.physical>=0?1:0;for(const ae of re.children)ie+=J(ae);return re.leafCount=ie,ie},ee=re=>{const ie=this.#pt(re.key);if(re.physical>=0){if(q.push(re.physical),G&&G.isOpen(this.#Ae(re.physical).key)){const ae=this.#Ae(re.physical);Y.push({at:q.length}),q.push(this.#i.detail(ae,G.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:J(re),totals:this.#B?this.#B.byKey.get(re.key):void 0}));if(ie)for(const ae of re.children)ee(ae)};for(const re of k.tree.roots)ee(re);return N&&N.grand&&!this.#pe()&&(Y.push({at:q.length}),q.push(this.#i.grandTotal(N.grand,this.#et(k.leaves.length)))),this.#W=null,this.#V=y,this.#U=Y.length?Y:y,this.#I=q,q}#Mt(){return g(()=>this.count(),k=>this.at(k))}#ut(k,N){let G=this.#$.get(k);if(G===void 0){const q=this.#ue(k),Y=this.#st(),J=[],ee=this.#e.columnHidden;for(const re of Y){if(re.quickFilter===!1||_(ee)&&ee(re.id))continue;const ie=re.value&&_(re.value.quickFilterText)?re.value.quickFilterText({value:void 0,data:q,row:null,column:re,colId:re.id,grid:null,context:this.#H("context",null)}):null,ae=ie??(_(re.formatValue)?re.formatValue(_(re.getValue)?re.getValue(q):void 0):"");ae!=null&&ae!==""&&J.push(String(ae))}G=J.join(" ").toLowerCase(),this.#$.set(k,G)}return N(G)}#Xe(){const k=this.#H("totals",[]),N=k&&k.length?new Set(k):null;return this.#st().filter(G=>N?N.has(G.id):!!(G.total||G.groupTotal||G.grandTotal))}#rt(k,N,G,q="group"){const Y={},J=(this.#e.compute||{}).total;for(const ee of k){if(!R(ee))continue;const re=this.#s.handle(ee.id);if(!re)continue;const ie=v(ee,q);if(ie)if(_(ie)){const ae=new Array(N.length);for(let fe=0;fe<N.length;fe++)ae[fe]=re.get(N[fe]);Y[ee.id]=ie(ae,{row:G,column:ee,grid:this.#e.grid||null,context:this.#H("context",null),valueAt:(fe,ce)=>{const te=this.#s.handle(fe);return te&&ce>=0&&ce<N.length?te.get(N[ce]):null}})}else _(J)&&(Y[ee.id]=J(re,N,ie))}return Y}#it(k){if(!k)return k;const N=this.#e.config||{},G={tz:N.timeZone,weekStartsOn:N.weekStartsOn};return i(k,q=>{const Y=m(q,G),J=this.#ze(Y&&Y.col),ee=J&&J.type==="datetime";if(Y&&Y.type)return Y.type==="datetime"&&!Y.timeZone&&J?{...Y,timeZone:N.timeZone||void 0}:Y;if(ee)return{...Y,type:"datetime",timeZone:N.timeZone||void 0};const re=J&&(J.dataType?.base||J.type);return re?{...Y,type:re}:Y})}#pt(k,N){const G=this.#H("expanded",null);return G?_(G.has)?G.has(k,N):Array.prototype.includes.call(G,k):!0}#H(k,N){if(k==="context"||!_(this.#e.stateVersion))return this.#Nt(k,N);const G=this.#mt(k),q=this.#d.get(k);if(q&&q.version===G)return q.value;const Y=this.#Nt(k,N);return this.#d.set(k,{version:G,value:Y}),Y}#Nt(k,N){const G=this.#e.state;if(G&&_(G[k])){const q=G[k]();return q??N}return N}#ct(){const k=this.#e.stateVersion;return _(k)?k():0}#$t(){const k=this.#e.columnsVersion,N=this.#e.permissionsVersion;return`${_(k)?k():0}|${_(N)?N():0}`}#mt(k){return k==="totals"?this.#$t():`${this.#ct()}`}#gt(k,N,G){if(!_(this.#e.stateVersion))return G();const q=this.#h.get(k);if(q&&q.version===N)return q.key;const Y=G();return this.#h.set(k,{version:N,key:Y}),Y}#ot(k){const N=(this.#e.compute||{})[k];return _(N)||$(`ctx.compute.${k} is required by the memory source pipeline`),N}#st(){const k=this.#e.columns;return k&&_(k.all)?k.all():[]}#ze(k){const N=this.#e.columns;return N&&_(N.get)?N.get(k):void 0}#Qe(k,N){const G=this.#e.emit;_(G)&&G(k,N)}}}),Fe("packages/core/src/source/abort.js",function(e,K){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return _}});class Q extends Error{constructor(W,V="superseded"){super(`[lattice] request ${W?`"${W}" `:""}${V}`),this.name="SupersededError",this.superseded=!0,this.key=W}}class x{#e;constructor(W,V,H,B){this.#e=W,this.key=V,this.controller=H,this.signal=H.signal,this.seq=B}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(W){this.signal.aborted||this.controller.abort(new Q(this.key,W)),this.#e.settle(this)}}class z{#e=new Map;#t=0;begin(W="",V="superseded"){const H=this.#e.get(W);H&&!H.signal.aborted&&H.controller.abort(new Q(W,V));const B=new x(this,W,new AbortController,++this.#t);return this.#e.set(W,B),B}tokenFor(W){return this.#e.get(W)}pending(W=""){const V=this.#e.get(W);return!!V&&!V.signal.aborted}get size(){return this.#e.size}settle(W){this.#e.get(W.key)===W&&this.#e.delete(W.key)}abort(W="",V="superseded"){const H=this.#e.get(W);H&&H.abort(V)}abortAll(W="superseded"){for(const V of[...this.#e.values()])V.abort(W);this.#e.clear()}}function $(){return new z}function _(X){if(!X||typeof X!="object")return!1;const W=X;return W.superseded===!0||W.name==="AbortError"||W.name==="SupersededError"}}),Fe("packages/core/src/source/blockcache.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return $}});const Q=100,x=32;class z{constructor(X){this.id=X,this.rows=null,this.state="pending",this.token=null,this.error=null}}class ${#e=new Map;#t;#n;#r=0;#o=-1;constructor(X={}){this.#t=Math.max(1,Math.floor(Number(X.pageSize)||Q)),this.#n=Math.max(1,Math.floor(Number(X.maxCachedPages)||x))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(X){return Math.floor(X/this.#t)}rangeOf(X){return{start:X*this.#t,end:(X+1)*this.#t}}has(X){return this.#e.has(X)}pending(X){const W=this.#e.get(X);return!!W&&W.state==="pending"}loaded(X){const W=this.#e.get(X);return!!W&&W.state==="loaded"}begin(X,W){let V=this.#e.get(X);return V||(V=new z(X)),V.state="pending",V.token=W,V.error=null,this.#i(X,V),V}fill(X,W){const V=this.#e.get(X)||new z(X);V.rows=W,V.state="loaded",V.token=null,this.#i(X,V)}failed(X,W){const V=this.#e.get(X)||new z(X);V.state="error",V.error=W,V.token=null,this.#i(X,V)}delete(X){return this.#e.delete(X)}rowAt(X){const W=this.blockOf(X),V=this.#e.get(W);if(!(!V||V.state!=="loaded"||!V.rows))return this.#i(W,V),V.rows[X-W*this.#t]}rowLoaded(X){const W=this.blockOf(X),V=this.#e.get(W);return!!V&&V.state==="loaded"&&!!V.rows&&X-W*this.#t<V.rows.length}erroredAt(X){const W=this.#e.get(this.blockOf(X));return!!W&&W.state==="error"}loadedExtent(){let X=0;for(const W of this.#e.values()){if(W.state!=="loaded"||!W.rows)continue;const V=W.id*this.#t+W.rows.length;V>X&&(X=V)}return X}fillOf(X){const W=this.#e.get(X);return W&&W.state==="loaded"&&W.rows?W.rows.length:null}protect(X,W){this.#r=this.blockOf(Math.max(0,X)),this.#o=this.blockOf(Math.max(0,W))}evict(){const X=[];if(this.#e.size<=this.#n)return X;for(const[W,V]of this.#e){if(this.#e.size-X.length<=this.#n)break;W>=this.#r&&W<=this.#o||V.state!=="pending"&&X.push(W)}for(const W of X)this.#e.delete(W);return X}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(X,W){this.#e.delete(X),this.#e.set(X,W)}}}),Fe("packages/core/src/source/pagewindow.js",function(e,K){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return Q}});function Q(x,z,$,_){const X=Math.floor(Number(x)||0);if(X<=0)return null;const W=Math.max(0,Math.floor(Number(z)||0)),V=Math.max(0,Math.floor(Number($)||0));if(_){const H=Math.max(1,Math.ceil(V/X)),B=Math.min(W,H-1),w=B*X;return{page:B,pageSize:X,offset:w,length:Math.max(0,Math.min(X,V-w)),pageCount:H,total:V}}return{page:W,pageSize:X,offset:W*X,length:X,pageCount:Math.max(W+2,Math.ceil(V/X)),total:null}}}),Fe("packages/core/src/source/paged.js",function(e,K){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return i}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,z=Q.isFunction,$=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,V=X.isAbortError,H=K("packages/core/src/source/blockcache.js"),B=H.BlockCache,w=H.DEFAULT_PAGE_SIZE,A=H.DEFAULT_MAX_CACHED_PAGES,u=K("packages/core/src/source/rows.js").createRowFactory,h=K("packages/core/src/source/filterwire.js"),a=h.wireFilters,r=h.querySignature,t=h.warnHostFilterNotApplied,o=K("packages/core/src/source/pagewindow.js").pageWindow,d=120;function l(m,c){return new i(m,c)}class i{mode="paged";#e;#t;#n;#r=W();#o;#i;#s=new Map;#l=null;#a=null;#u=!1;#c=0;#d="";#h={start:0,end:0};#f;#p=!1;#m=0;#g="";constructor(c,f){this.#e=c||{mode:"paged"},this.#t=f||{},this.#n=new B({pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||A}),this.#o=u(this.#t),this.#i=new x(this.#n.pageSize*4),this.#f=_((s,p)=>this.#w(s,p),d),this.#d=this.#P(),z(this.#e.fetch)||$("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),t(this.#t)}count(){const c=this.#b();return c?c.length:this.#y()}#y(){if(this.#C(),this.#l!==null)return this.#l;const c=Math.max(this.#c,this.#n.loadedExtent());return this.#u?c:c+this.#n.pageSize}matchCount(){return this.#y()}totalCount(){return this.#y()}pageInfo(){const c=this.#b();if(!c){const f=this.#y();return{page:0,pageSize:0,total:this.exact()?f:null,pageCount:1,counting:!1}}return{page:c.page,pageSize:c.pageSize,total:c.total,pageCount:c.pageCount,counting:c.total===null&&this.#r.size>0&&this.#c===0&&this.#n.loadedExtent()===0}}#b(){const c=this.#y(),f=o(this.#E("pageSize",0),this.#E("page",0),c,this.exact());if(!f)return this.#g="",null;const s=`${this.#m}:${f.offset}:${f.length}`;if(s!==this.#g&&!this.#p&&(this.#g=s,f.length>0)){const p=f.offset+f.length-1;this.#h={start:f.offset,end:p},this.#w(f.offset,p)}return f}at(c){const f=this.#b();if(f){if(c<0||c>=f.length)return;const s=this.#A(f.offset+c);return s&&(s.index=c),s}return this.#A(c)}#A(c){if(c<0||c>=this.#y())return;const f=this.#i.get(c);if(f&&(f.data!==null||!this.#n.rowLoaded(c)))return f;const s=this.#n.rowAt(c);if(s===void 0){const b=this.#o.skeleton(c,0,this.#n.erroredAt(c));return this.#i.set(c,b),b}const p=this.#o.leaf(s,c);return p.index=c,this.#i.set(c,p),this.#s.set(p.key,c),p}byKey(c){const f=this.#s.get(c);return f===void 0?void 0:this.#A(f)}loaded(c){const f=this.#b();return f?c>=0&&c<f.length&&this.#n.rowLoaded(f.offset+c):this.#n.rowLoaded(c)}loadedCount(){this.#C();let c=0;for(const f of this.#n.ids()){if(!this.#n.loaded(f))continue;const s=this.#n.fillOf(f);typeof s=="number"&&(c+=s)}return c}residentRows(){this.#C();const c=this.#b(),f=c?c.offset:0,s=c?c.offset+c.length:1/0,p=[],b=this.#n.ids().sort((S,j)=>S-j);for(const S of b){if(!this.#n.loaded(S))continue;const{start:j}=this.#n.rangeOf(S),y=this.#n.fillOf(S)||0;for(let v=j;v<j+y;v++){if(v<f||v>=s)continue;const R=this.#i.peek(v);if(R&&R.data!==null&&R.data!==void 0){p.push(R);continue}const O=this.#n.rowAt(v);if(O===void 0)continue;const F=this.#o.leaf(O,v);F.index=v,this.#i.set(v,F),this.#s.set(F.key,v),p.push(F)}}return p}hint(c,f){if(this.#p)return;const s=this.#C();let p=Math.max(0,Math.floor(c)),b=Math.max(p,Math.floor(f));const S=this.#b();if(S){if(S.length===0)return;p=S.offset,b=S.offset+S.length-1}this.#h={start:p,end:b},this.#n.protect(p,b);for(const j of this.#n.evict())this.#v(j);this.#f(p,b),s&&this.#f.flush()}#w(c,f){if(this.#p)return;this.#n.protect(c,f);const s=this.#n.blockOf(c),p=this.#n.blockOf(f);for(let b=s;b<=p&&!(this.#l!==null&&b*this.#n.pageSize>=this.#l);b++)this.#n.has(b)||this.#S(b)}apply(c){const f={added:[],updated:[],removed:[]};if(!c)return f;if(c.update)for(const s of c.update){const p=this.#o.keyOf(s,-1),b=this.#s.get(p);if(b===void 0)continue;const S=this.#o.leaf(s,b);S.index=b,this.#i.set(b,S),f.updated.push(S)}return(c.add&&c.add.length||c.remove&&c.remove.length)&&this.reload(),f}reload(c){this.#O("reload"),this.#f.cancel(),this.hint(this.#h.start,this.#h.end)}destroy(){this.#p=!0,this.#f.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#u}pending(){return this.#r.size}async#S(c){if(!z(this.#e.fetch))return;const f=this.#r.begin(`block:${c}`);this.#n.begin(c,f);const{start:s,end:p}=this.#n.rangeOf(c),b=this.#d;try{const S=await this.#e.fetch({range:{start:s,end:p},sort:this.#E("sort",[]),filters:a(this.#E("filters",null),this.#M()),quick:this.#E("quick","")||void 0,context:this.#E("context",null),signal:f.signal});if(!f.current||b!==this.#d||this.#p)return;f.settle();const j=S&&S.rows||[];this.#n.fill(c,j);for(let v=0;v<j.length;v++)this.#i.delete(s+v);const y=S&&typeof S.total=="number"?S.total:S&&typeof S.count=="number"?S.count:null;y!==null?(this.#l=y,this.#u=!0):j.length<this.#n.pageSize?(this.#u=!0,this.#l=s+j.length):this.#c=Math.max(this.#c,s+j.length),this.#T("model:changed",{reason:"page",block:c,from:s,to:s+j.length}),this.#T("rows:changed",{companion:!0,reason:"page",block:c,from:s,to:s+j.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#T("source:total",{total:this.#l,groupPath:[]}))}catch(S){if(f.settle(),V(S))return;this.#n.failed(c,S);for(let j=s;j<p;j++)this.#i.delete(j);this.#T("model:changed",{reason:"page-error",block:c,range:{start:s,end:p}}),this.#T("source:error",{error:S,block:c,range:{start:s,end:p}})}}#v(c){const{start:f,end:s}=this.#n.rangeOf(c);for(let p=f;p<s;p++){const b=this.#i.peek(p);b&&this.#s.delete(b.key),this.#i.delete(p)}}#C(){const c=this.#P();return c===this.#d?!1:(this.#d=c,this.#O("query"),!0)}#O(c){this.#r.abortAll(c),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=null,this.#u=!1,this.#c=0,this.#m++,this.#T("model:changed",{reason:c})}#P(){return r({filters:this.#E("filters",null),sort:this.#E("sort",[]),quick:this.#E("quick",""),context:this.#E("context",null)})}#M(){const c=this.#t.config||{};return{tz:c.timeZone,weekStartsOn:c.weekStartsOn}}#E(c,f){const s=this.#t.state;if(s&&z(s[c])){const p=s[c]();return p??f}return f}#T(c,f){const s=this.#t.emit;z(s)&&s(c,f)}}}),Fe("packages/core/src/source/aggregates.js",function(e,K){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return H}});const Q=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function x(){const B=new Set;for(const[w,A]of Object.entries(Q))A.pushable&&B.add(w);return B}function z(B,w,A){let g=B.split("%c").join(w);return A!==void 0&&(g=g.split("%w").join(A)),g}function $(B){const w=B||{},A=w.default==="engine"||w.default==="engine-if-identical"?w.default:"client",g={};if(w.overrides&&typeof w.overrides=="object")for(const[u,h]of Object.entries(w.overrides))(h==="engine"||h==="client")&&(g[u]=h);return{default:A,overrides:g}}function _(B,w){const A=Q[B];if(!A||!A.pushable)return"client";const g=w.overrides[B];return g==="engine"||g==="client"?g:w.default==="client"?"client":w.default==="engine-if-identical"?A.class==="identical"?"engine":"client":"engine"}function X(B,w){const A=$(w),g=[],u=[];for(const h of B||[]){const a=Q[h.fn],r=_(h.fn,A),t={id:h.id,col:h.col,fn:h.fn,class:a?a.class:"fallback"};h.weight!==void 0&&(t.weight=h.weight),h.params!==void 0&&(t.params=h.params),r==="engine"?g.push(t):(t.reason=a&&!a.pushable?a.note||"the engine cannot express this stat":"client by config",u.push(t))}return{engine:g,client:u,config:A}}const W=/^[A-Za-z_][A-Za-z0-9_$]*$/;function V(B,w=[]){return(B||[]).every(g=>{if(typeof g=="string")return W.test(g);if(!g||typeof g!="object")return!1;const u=g;return Array.isArray(w)&&w.includes(u.bucket)&&typeof u.col=="string"&&W.test(u.col)&&typeof u.size=="number"&&Number.isFinite(u.size)&&u.size>0})}function H(){return Object.entries(Q).map(([B,w])=>({stat:B,class:w.class,sql:w.sql?z(w.sql,"col",w.twoColumn?"weight":void 0):"",note:w.note||(w.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Fe("packages/core/src/source/pushdown.js",function(e,K){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return k}});const Q=K("packages/core/src/internal/util.js"),x=Q.defaultCompare,z=Q.isFunction,$=Q.toArray,_=Q.warnOnce,X=K("packages/core/src/source/filterwire.js"),W=X.isGroup,V=X.warnWherePageRelative,H=X.warnWhereOverThreshold,B=K("packages/core/src/source/aggregates.js"),w=B.resolveAggregatePlan,A=B.groupKeysPushable,g=B.STAT_PUSHDOWN,h=K("packages/core/src/source/abort.js").SupersededError,a=1e3;function r(N){const G=N&&N.signal;if(!G||!G.aborted)return;const q=G.reason;throw q instanceof Error?q:new h("","superseded before it was sent")}const t=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function n(N){if(!N||typeof N!="object")return!1;const G=N.returning==="row"||N.returning==="key"?N.returning:"none";return{append:N.append===!0,update:N.update===!0,delete:N.delete===!0,returning:G}}function o(N,G){if(!N||typeof G!="string")return;if(!G.includes("."))return N[G];let q=N;for(const Y of G.split(".")){if(q===null||typeof q!="object")return;q=q[Y]}return q}function d(N){if(N===!0)return!0;if(!N||typeof N!="object")return!1;const G=N;return G.enabled===!1?!1:G.enabled===!0||z(G.commit)}function l(N){const G={...t,...N||{}};return G.operators=new Set(G.operators||[]),G.mutate=n(G.mutate),G}function i(N,G){return!N||!N.op||!G.operators.size?!1:G.operators.has(N.op)}function m(N,G){if(!N)return{pushed:null,residual:null};if(!G.filter)return{pushed:null,residual:N};if(G.filter==="term"){if(W(N)){const ee=N.conditions||[];if(String(N.op)!=="and")return{pushed:null,residual:N};const re=ee.findIndex(ae=>!W(ae)&&i(ae,G));if(re<0)return{pushed:null,residual:N};const ie=ee.filter((ae,fe)=>fe!==re);return{pushed:ee[re],residual:ie.length?{op:"and",conditions:ie}:null}}return i(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N}}if(!W(N))return i(N,G)?{pushed:N,residual:null}:{pushed:null,residual:N};if(String(N.op)!=="and")return(N.conditions||[]).every(re=>W(re)?m(re,G).residual===null:i(re,G))?{pushed:N,residual:null}:{pushed:null,residual:N};const q=[],Y=[];for(const ee of N.conditions||[]){if(W(ee)){if(G.filter==="flat"){Y.push(ee);continue}const re=m(ee,G);re.pushed&&q.push(re.pushed),re.residual&&Y.push(re.residual);continue}(i(ee,G)?q:Y).push(ee)}const J=ee=>ee.length===0?null:ee.length===1?ee[0]:{op:"and",conditions:ee};return{pushed:J(q),residual:J(Y)}}const c="__lattice_leaves";function f(N){return N.aggregates?N.aggregates instanceof Set?N.aggregates:new Set($(N.aggregates)):new Set}function s(N){const G=f(N);return G.size?G.has("count")?N.filter!=="tree"||!N.operators||!N.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function p(N,G,q,Y,J,ee,re){const ie=Array.isArray(N.groupBy)?N.groupBy:[],ae=Array.isArray(N.groupPath)?N.groupPath:[],fe=Array.isArray(N.groupValues)?N.groupValues:null;if(!G.group){const ce=s(G);if(ce)return ce}return A(ie)?q.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":Y?J?ee?"a host `where` predicate can only run in the browser, over rows the engine grouped":re?"fullDataset holds the whole matching set, so the grid groups it itself":!fe||fe.length!==ae.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const b="pushdown:pivot-unsupported",S="pushdown:group-unsupported",j=Symbol("lattice.remote.ungroupedLevel");function y(N,G,q,Y,J,ee){const re=Array.isArray(N.pivotBy)?N.pivotBy:[],ie=Array.isArray(N.groupBy)?N.groupBy:[],ae=Array.isArray(N.groupPath)?N.groupPath:[],fe=Array.isArray(N.groupValues)?N.groupValues:null;return G.pivot?A(re)?ie.length&&!A(ie)?"a grouping key is not a plain column the engine can name in a GROUP BY":q.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":Y?J?ee?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!fe||fe.length!==ae.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function v(N,G,q=!1){const Y=m(N.filters||null,G),J=[];Y.residual&&J.push("filter");const ee=N.sort||[],re=ee.length===0||G.sort==="multi"&&ee.length>=1||G.sort==="single"&&ee.length===1;!re&&ee.length&&J.push("sort");const ie=N.quick?String(N.quick):"",ae=!ie||!!G.quick;ae||J.push("quick");const fe=N.where&&N.where.active?N.where:null;fe&&J.push("where");const ce={filters:Y.residual,sort:re?null:ee,quick:ae?"":ie,where:fe},te=!!q,oe=Array.isArray(N.groupBy)&&N.groupBy.length>0,he=oe?p(N,G,Y,re,ae,fe,te):"",de=N.pivotMode!==!1&&Array.isArray(N.pivotBy)&&N.pivotBy.length>0,be=de?y(N,G,Y,re,ae,fe):"",Te=de&&be==="";de&&!Te&&J.push("pivot");const Ae=de?Te&&oe:oe&&he==="";oe&&!de&&!Ae&&J.push("group");const Ce=(Ae||Te)&&Array.isArray(N.groupValues)?N.groupValues.length:0,me=Ae||de?!1:te||!!(ce.filters||ce.sort||ce.quick||ce.where)||!G.range;return{pushed:{...N,filters:Y.pushed,sort:re?ee:[],quick:ae?ie:"",range:me?null:N.range},residual:ce,needsAll:me,unpushed:J,full:te,grouped:Ae,groupLevel:Ce,groupReason:de?"":he,pivoted:Te,pivotReason:be}}function R(N){const G=Array.isArray(N.totals)?N.totals:[],q=N.totalFns&&typeof N.totalFns=="object"?N.totalFns:{},Y=[],J=[];for(const ee of G){const re=String(ee),ie=typeof q[re]=="string"?q[re]:null,ae=ie?g[ie]:null;ie?!ae||!ae.pushable||!ae.sql?J.push({id:re,fn:ie,class:ae?ae.class:"fallback",reason:ae&&ae.note?ae.note:`the pushdown map cannot express "${ie}"`}):ae.twoColumn?J.push({id:re,fn:ie,class:ae.class,reason:`"${ie}" reduces two columns, and a grouped request carries no weight column`}):Y.push({id:re,col:re,fn:ie,class:ae.class}):J.push({id:re,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:Y,client:J}}const O=Object.freeze({items:N=>N==null?[]:Array.isArray(N)?N:[N]});function F(N,G,q){if(!G)return N;let Y=N;if(G.filters&&z(q.evaluateFilters)){const J=Y,ee={count:Y.length,handle:ae=>({id:ae,get:fe=>o(J[fe],ae)}),itemwise:ae=>J.some(fe=>Array.isArray(o(fe,ae)))?O:null},re=q.evaluateFilters(G.filters,ee),ie=[];for(let ae=0;ae<Y.length;ae++)re[ae]&&ie.push(Y[ae]);Y=ie}if(G.where&&G.where.active&&(G.whole||V(G.where.names,"pushdown"),Y=Y.filter(J=>G.where.passes(J))),G.quick){const J=G.quick.toLowerCase();Y=Y.filter(ee=>{if(!ee||typeof ee!="object")return!1;for(const re of Object.values(ee))if(re!=null&&String(re).toLowerCase().includes(J))return!0;return!1})}if(G.sort&&G.sort.length&&z(q.sortMulti)){const J=[...new Set(G.sort.map(ae=>ae.col))],ee=Y,re=J.map(ae=>({id:ae,get:fe=>o(ee[fe],ae)})),ie=q.sortMulti(re,G.sort.map(ae=>({col:ae.col,dir:ae.dir})),Uint32Array.from({length:Y.length},(ae,fe)=>fe),{});Y=Array.from(ie,ae=>ee[ae])}return Y}function C(N){return JSON.stringify({filters:N.filters||null,sort:N.sort||[],quick:N.quick||"",groupBy:N.groupBy||[],groupPath:N.groupPath||[],context:N.context??null})}function T(N){if(!N||typeof N!="object")return 16;let G="";try{G=JSON.stringify(N)}catch{return 200}return G.length*2+64}function L(N){const G=N||{};return{enabled:!!G.enabled,maxRows:Number.isFinite(G.maxRows)?G.maxRows:1e6,maxBytesEstimate:Number.isFinite(G.maxBytesEstimate)?G.maxBytesEstimate:512*1024*1024}}const E=5e4;function D(N){return Number.isFinite(N)&&N>=0?N:E}function I(N){return!!N&&z(N.then)}async function P(N){if(!N||N.total!==void 0||!I(N.pendingTotal))return N;const G=await N.pendingTotal,{pendingTotal:q,...Y}=N;return typeof G=="number"?{...Y,total:G}:Y}function k(N={}){const G=N.adapter;if(!G||!z(G.execute))return _("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...N,mode:"remote",fetch:async()=>({rows:[],total:0})};const q=l(G.capabilities),Y=G.capabilities&&Object.getOwnPropertyDescriptor(G.capabilities,"operators");Y&&z(Y.get)&&Object.defineProperty(q,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(G.capabilities.operators||[]),set:()=>{}});const J=G.name||"adapter";let ee=null;const re=()=>z(G.ready)?(ee||(ee=Promise.resolve(G.ready()).then(()=>{Object.assign(q,l(G.capabilities))},$e=>{throw ee=null,$e})),ee):null,ie=L(N.fullDataset),ae=!!N.allowPartialResults,fe=D(N.whereRowLimit);let ce=null;const te=N.aggregates;let oe=null,he=null,de=null,be=null,Te=null,Ae,Ce=null,me=0,we=null;const ge=()=>!ie.enabled||!oe?null:(we!==oe.key&&(me++,we=oe.key),{rows:oe.rows,version:me}),Ne=async $e=>{const qe=$e.where&&$e.where.active?$e.where:null;if(!qe)return{request:$e,probe:null};const{where:ye,...ke}=$e,pe=v(ke,q,ie.enabled);if(pe.needsAll)return{request:$e,probe:null};const Pe=C(pe.pushed);let Me=null;return(!ce||ce.key!==Pe)&&(q.total?(r($e),Me=await P(await G.execute(pe.pushed,$e)),ce={key:Pe,size:Me&&typeof Me.total=="number"?Me.total:null}):ce={key:Pe,size:null}),ce.size!==null&&ce.size<fe?{request:$e,probe:null}:(H(qe.names,J,ce.size,fe),{request:ke,probe:Me})},Ie=async($e,qe)=>{Ce=null;const ye=R($e.pushed);de={engine:ye.engine,client:ye.client,groupBy:$e.pushed.groupBy},ye.client.length&&_(`source.pushdown.group.totals.${J}.${ye.client.map(Pe=>Pe.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${ye.client.map(Pe=>`"${Pe.id}" (${Pe.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const ke=await G.executeGroupLevel($e.pushed,ye.engine,qe)||{};let pe=ke.rows||[];return!q.range&&qe.range&&(pe=pe.slice(qe.range.start,qe.range.end)),Ve(ke),ke.total===void 0?{rows:pe}:{rows:pe,total:ke.total}},He=new Map,Ye=64,Oe=async($e,qe)=>{Ce=null;const ye=$e.pushed,ke=ye.groupBy,pe=Array.isArray(ye.groupValues)?ye.groupValues:[],Pe=pe.length,Me=[...ye.filters?[ye.filters]:[],...ke.slice(0,Pe).map((st,ut)=>({col:st,op:"eq",value:pe[ut]===void 0?null:pe[ut],caseSensitive:!0}))],ze=Me.length===0?null:Me.length===1?Me[0]:{op:"and",conditions:Me},_e=qe.range?qe.range.start:0;if(Pe>=ke.length){const st={...ye,filters:ze,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ut=await P(await G.execute(st,qe))||{};let At=ut.rows||[];return!q.range&&qe.range&&(At=At.slice(qe.range.start,qe.range.end)),typeof ut.total=="number"?{rows:At,total:ut.total}:{rows:At}}const De=ke[Pe],Se=R(ye),xe=f(q),Ue=Se.engine.filter(st=>xe.has(st.fn)),et=[...Se.engine.filter(st=>!xe.has(st.fn)).map(st=>({id:st.id,fn:st.fn,class:st.class,reason:`the ${J} adapter does not compute "${st.fn}"`})),...Se.client];de={engine:Ue,client:et,groupBy:ke},et.length&&_(`source.pushdown.group.totals.${J}.${et.map(st=>st.id).join(".")}`,`the ${J} adapter cannot compute the group subtotal for ${et.map(st=>`"${st.id}" (${st.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Je=[...Ue.map(st=>({id:st.id,col:st.col,fn:st.fn})),{id:c,col:De,fn:"count"}],lt={...ye,filters:ze,range:null},ot=JSON.stringify([C(lt),pe,De,Je]);let gt=_e>0?He.get(ot):void 0;if(!gt){for(gt=Promise.resolve(G.executeGroupedAggregates(lt,[De],Je)),He.delete(ot),He.set(ot,gt);He.size>Ye;)He.delete(He.keys().next().value);gt.catch(()=>{He.get(ot)===gt&&He.delete(ot)})}const vt=await gt||[];r(qe);const ht=st=>{const ut={};for(const At of Ue)ut[At.id]=st?st[At.id]:void 0;return ut},Ct=(ye.sort||[]).find(st=>st&&st.col===De),xt=Ct&&Ct.dir==="desc"?-1:1,Ge=vt.filter(st=>st&&st.level===1).map(st=>({[De]:st.keys[0]===void 0?null:st.keys[0],leafCount:Number(st.values&&st.values[c])||0,totals:ht(st.values)})).sort((st,ut)=>xt*x(st[De],ut[De]));if(Pe===0){const st=vt.find(At=>At&&At.level===0),ut=st?Number(st.values&&st.values[c]):NaN;Ve({matchCount:Number.isFinite(ut)?ut:Ge.reduce((At,Rt)=>At+Rt.leafCount,0),...st?{grand:ht(st.values)}:{}})}const ft=qe.range?qe.range.end:Ge.length;return{rows:Ge.slice(_e,ft),total:Ge.length}},Ve=$e=>{typeof $e.matchCount=="number"&&(be=$e.matchCount,Te=$e.grand?{totals:$e.grand,leafCount:$e.matchCount}:null,Ae===void 0&&z(G.unfilteredCount)&&(Ae=null,Promise.resolve(G.unfilteredCount()).then(qe=>{Ae=typeof qe=="number"?qe:null}).catch(qe=>{_(`source.pushdown.group.unfiltered.${J}`,`the ${J} adapter could not count the unfiltered set (${qe&&qe.message?qe.message:qe}), so "N of M" falls back to the display count for its denominator.`)})))},Ze=async($e,qe)=>{Ce=null;const ye=R($e.pushed);de={engine:ye.engine,client:ye.client,groupBy:$e.pushed.groupBy,pivotBy:$e.pushed.pivotBy},ye.client.length&&_(`source.pushdown.pivot.totals.${J}.${ye.client.map(ze=>ze.id).join(".")}`,`the ${J} adapter cannot compute the pivot cells for ${ye.client.map(ze=>`"${ze.id}" (${ze.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const ke=await G.executePivotLevel($e.pushed,ye.engine,qe)||{};let pe=ke.rows||[];!q.range&&qe.range&&(pe=pe.slice(qe.range.start,qe.range.end)),Ve(ke);const Pe=ke.pivot&&typeof ke.pivot=="object"?ke.pivot:{},Me={cells:Array.isArray(Pe.cells)?Pe.cells:[],...Array.isArray(Pe.axis)?{axis:Pe.axis}:{}};return ke.total===void 0?{rows:pe,pivot:Me}:{rows:pe,total:ke.total,pivot:Me}},it=$e=>{_(`source.pushdown.pivot.${J}.${$e}`,`pushdown:pivot-unsupported: the ${J} adapter cannot pivot this query because ${$e}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const qe=new Error(`[lattice] ${b}: the ${J} adapter cannot pivot this query because ${$e}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw qe.code=b,qe.reason=$e,qe},at=($e,qe)=>{const ye={key:qe,state:"pending",value:null};return Ce=ye,$e.then(ke=>(Ce===ye&&(Ce={key:qe,state:"settled",value:typeof ke=="number"?ke:null}),ke),ke=>{throw Ce===ye&&(Ce={key:qe,state:"failed",value:null}),ke})};let pt=0,bt=[];const Ot=()=>pt===0?null:new Promise($e=>{const qe=setTimeout($e,a);bt.push(()=>{clearTimeout(qe),$e()})});let Et;const Mt=async $e=>{const qe=re();qe&&await qe;const ke=$e&&$e.pivotMode!==!1&&Array.isArray($e.pivotBy)&&$e.pivotBy.length>0?{request:$e,probe:null}:await Ne($e);r($e);let pe=v(ke.request,q,ie.enabled);if(q.group&&pe.grouped&&!pe.pivoted&&!z(G.executeGroupLevel)&&(_(`source.pushdown.group.method.${J}`,`the ${J} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),pe=v(ke.request,{...q,group:!1,aggregates:null},ie.enabled)),pe.pivoted&&!z(G.executePivotLevel)&&(pe=v(ke.request,{...q,pivot:!1},ie.enabled),pe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),pe.grouped&&!pe.pivoted&&!q.group&&!z(G.executeGroupedAggregates)&&(_(`source.pushdown.group.aggregates.method.${J}`,`the ${J} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),pe=v(ke.request,{...q,aggregates:null},ie.enabled)),he=pe,pe.pivoted)return Ze(pe,$e);if(pe.pivotReason&&it(pe.pivotReason),pe.grouped)return q.group?Ie(pe,$e):Oe(pe,$e);const Me=!!pe.groupReason&&!pe.full;Me?_(`source.pushdown.group-unsupported.${J}.${pe.groupReason}`,`pushdown:group-unsupported: the ${J} adapter was not asked to group this query because ${pe.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):pe.groupReason&&_(`source.pushdown.group.${J}.${pe.groupReason}`,`the ${J} adapter was not asked to group this query because ${pe.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const ze=Je=>Me?{...Je,[j]:!0}:Je;if(!pe.needsAll){const Je=ke.probe||await G.execute(pe.pushed,$e),lt=Je.rows||[];return I(Je.pendingTotal)&&Je.total===void 0?ze({rows:lt,pendingTotal:at(Je.pendingTotal,C(pe.pushed))}):(Ce=null,!q.total&&Je.total===void 0?ze({rows:lt}):ze({rows:lt,total:Je.total??lt.length}))}pe.unpushed.length&&_(`source.pushdown.residual.${J}.${pe.unpushed.join(".")}`,`the ${J} adapter cannot push ${pe.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const _e=C(pe.pushed);if(!oe||oe.key!==_e){const Je=await P(await G.execute(pe.pushed,$e));Ce=null;const lt=Je.rows||[];if(pe.full){const ot=typeof Je.total=="number"?Math.max(Je.total,lt.length):lt.length;if(ot>ie.maxRows)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is ${ot.toLocaleString()} rows, past the configured maxRows of ${ie.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const gt=lt.length*T(lt[0]);if(gt>ie.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${J} adapter's matching set is an estimated ${Math.round(gt/(1024*1024)).toLocaleString()} MB across ${lt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ie.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Je.total=="number"&&lt.length<Je.total){const ot=!!(pe.residual.filters||pe.residual.quick||pe.residual.sort&&pe.residual.sort.length);if(ot&&!ae)throw new Error(`[lattice] the ${J} adapter returned ${lt.length} of ${Je.total} matching rows when asked for the whole result, and the query has residual ${pe.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);ot?_(`source.pushdown.partial.residual.${J}`,`the ${J} adapter returned ${lt.length} of ${Je.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):_(`source.pushdown.partial.${J}`,`the ${J} adapter returned ${lt.length} of ${Je.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}oe={key:_e,rows:lt,total:typeof Je.total=="number"?Je.total:null}}let De=pe;if(pe.residual.where){const Je=oe.total??oe.rows.length;if(Je>=fe){H(pe.residual.where.names,J,Je,fe);const{where:lt,...ot}=ke.request;De=v(ot,q,ie.enabled),he=De}}const Se=oe.total!==null&&oe.rows.length>=oe.total,xe=F(oe.rows,{...De.residual,whole:Se},N.compute||{}),Ue=$e.range?$e.range.start:0,et=$e.range?$e.range.end:xe.length;return ze({rows:xe.slice(Ue,et),total:xe.length})},Tt=async($e,qe,ye)=>{const pe=ye&&ye.waitForPage&&Et&&z(Et.pageForegroundIdle)?Et.pageForegroundIdle():Ot();pe&&await pe;const Pe=re();Pe&&await Pe;const Me=v($e,q,ie.enabled);he=Me;const ze=w(qe,te),_e=Array.isArray($e.groupBy)?$e.groupBy:[],De=_e.length>0,Se=!Me.residual.filters&&!Me.residual.quick,xe=!De||A(_e,q.buckets);let Ue=ze.engine,et=ze.client;if(q.aggregates&&Ue.length){const gt=q.aggregates instanceof Set?q.aggregates:new Set($(q.aggregates)),vt=Ue.filter(ht=>!gt.has(ht.fn));vt.length&&(Ue=Ue.filter(ht=>gt.has(ht.fn)),et=[...vt.map(ht=>({...ht,reason:`the ${J} adapter does not compute "${ht.fn}"`})),...et])}const Je=gt=>{et=[...Ue.map(vt=>({...vt,reason:gt})),...et],Ue=[]};Ue.length&&!Se?Je(Me.residual.quick&&!Me.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Ue.length&&!xe&&Je("a grouping key the engine cannot form forces all-client (no mixed provenance)");let lt={},ot;return Ue.length&&(z(De?G.executeGroupedAggregates:G.executeAggregates)?De?ot=await G.executeGroupedAggregates(Me.pushed,_e,Ue)||[]:lt=await G.executeAggregates(Me.pushed,Ue)||{}:(_(`source.pushdown.aggregates.${J}${De?".grouped":""}`,`the ${J} adapter cannot compute ${De?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Je(`adapter cannot compute ${De?"grouped ":""}aggregates`))),de={engine:Ue,client:et,...De?{groupBy:_e}:{}},{values:lt,engine:Ue,client:et,...ot!==void 0?{groups:ot}:{}}},Bt=async $e=>{pt++;try{return await Mt($e)}finally{if(pt--,pt===0&&bt.length){const qe=bt;bt=[];for(const ye of qe)ye()}}},zt=d(N.edit),dt=N.edit&&typeof N.edit=="object"&&z(N.edit.commit);let rt=N.edit;if(zt&&!dt)if(q.mutate&&q.mutate.update){const $e=qe=>{if(!q.mutate||!q.mutate.update)throw new Error(`[lattice] the ${J} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const ye={kind:"update",key:String(qe.key),patch:{[qe.colId]:qe.value}};return G.mutate(ye,qe.request||{})};rt={...N.edit===!0?{}:N.edit,commit:$e}}else _(`source.pushdown.readonly.${J}`,`edit is enabled but the ${J} adapter declares mutate: ${q.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const ue=zt&&q.mutate&&(q.mutate.append||q.mutate.delete)?{append:q.mutate.append===!0,remove:q.mutate.delete===!0,returning:q.mutate.returning,mutate:($e,qe)=>G.mutate($e,qe||{})}:null,ve=async $e=>{const qe=re();qe&&await qe;const{range:ye,signal:ke,export:pe,...Pe}=$e||{},Me={...Pe,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:v(Me,q,ie.enabled),signal:ke}};async function*Re($e,qe={}){const{plan:ye,signal:ke}=await ve($e),pe=Math.max(1,Math.floor(Number(qe.pageSize))||5e3),Pe={signal:ke,stream:!0};if(!ye.needsAll)for(let _e=0;;_e+=pe){r(Pe);const De=await G.execute({...ye.pushed,range:{start:_e,end:_e+pe}},Pe);De&&I(De.pendingTotal)&&De.pendingTotal.then(null,()=>{});const Se=De&&De.rows||[];if(Se.length&&(yield Se),Se.length<pe)return}r(Pe);const Me=await P(await G.execute({...ye.pushed,range:void 0},Pe)),ze=F(Me&&Me.rows||[],{...ye.residual,whole:!0},N.compute||{});for(let _e=0;_e<ze.length;_e+=pe)yield ze.slice(_e,_e+pe)}return Et={...N,edit:rt,rowMutate:ue,mode:"remote",fetch:Bt,foregroundIdle:Ot,aggregate:Tt,countMatching:async $e=>{const{plan:qe,signal:ye}=await ve($e);if(!qe.needsAll&&q.total){r({signal:ye});const pe=await P(await G.execute({...qe.pushed,range:{start:0,end:0}},{signal:ye}));if(pe&&typeof pe.total=="number")return pe.total}let ke=0;for await(const pe of Re($e))ke+=pe.length;return ke},streamMatching:Re,lastPlan:()=>he?{...he,...de?{aggregates:de}:{},...Ce?{total:{deferred:!0,state:Ce.state,value:Ce.value}}:{}}:null,fullFrame:ge,counts:()=>({match:be,total:Ae??null,pending:!!Ce&&Ce.state==="pending"}),grandTotals:()=>Te},Et}}),Fe("packages/core/src/source/remote.js",function(e,K){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,z=Q.isFunction,$=Q.warnOnce,_=Q.settleDebounce,X=K("packages/core/src/source/abort.js"),W=X.createAbortScope,V=X.isAbortError,H=K("packages/core/src/source/blockcache.js"),B=H.BlockCache,w=H.DEFAULT_PAGE_SIZE,A=H.DEFAULT_MAX_CACHED_PAGES,g=K("packages/core/src/source/rows.js"),u=g.createRowFactory,h=g.groupKey,a=K("packages/core/src/source/filterwire.js"),r=a.wireFilters,t=a.querySignature,n=a.warnHostFilterNotApplied,d=K("packages/core/src/source/pagewindow.js").pageWindow,i=K("packages/core/src/source/memory.js").MemorySource,c=K("packages/core/src/compute/handle.js").valueComparator,f=K("packages/core/src/compute/pivot.js"),s=f.pivotKey,p=f.joinPath,b=f.DEFAULT_PATH_SEPARATOR,j=K("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,y=1,v=120,R=1e3;function O(L,E,D){for(let I=0;I<Math.max(L.length,E.length);I++){const P=L[I],k=E[I],N=P==null,G=k==null;if(N||G){if(N&&G)continue;return N?1:-1}const q=D(P,k);if(q!==0)return q}return 0}function F(L,E){return new T(L,E)}class C{constructor(E,D,I,P){this.path=E,this.keyPath=P||E,this.values=[],this.level=D,this.key=h(this.keyPath),this.cache=new B(I),this.count=null,this.complete=!1,this.announced=null,this.counting=!1,this.failed=!1,this.children=new Map,this.row=null,this.flat=!1}}class T{mode="remote";#e;#t;#n;#r;#o=new Map;#i=new Set;#s=W();#l;#a;#u=new Map;#c=[];#d=null;#h="";#f;#p=!1;#m=!1;#g=[];#y=!1;#b=0;#A="";#w=null;#S=-1;constructor(E,D){this.#e=E||{mode:"remote"},this.#t=D||{},z(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#B(),this.unfilteredIndices=()=>this.#_(),this.handleFor=G=>this.#z(G),this.display=()=>this.#$(),this.grandTotalRow=()=>this.#I(),this.unfilteredRows=()=>this.#U(),this.facetIndices=G=>this.#q(G));const I=this.#e.counts;z(I)&&(this.matchCount=()=>this.#W("match"),this.totalCount=()=>this.#W("total"));const P=this.#e.grandTotals;z(P)&&(this.grandTotalRow=()=>this.#V());const k=this.#e.foregroundIdle;z(k)&&(this.foregroundIdle=()=>this.#we(k),this.#e.pageForegroundIdle=()=>this.#y?this.#we(k):null);const N=this.#e;z(N.countMatching)&&z(N.streamMatching)&&(this.selectionQuery=()=>this.#fe(),this.countMatching=G=>N.countMatching(G),this.streamMatching=(G,q)=>N.streamMatching(G,q),this.loadedRows=()=>this.#ie(),this.resident=()=>this.#N()!==null),this.#n={pageSize:this.#e.pageSize||w,maxCachedPages:this.#e.maxCachedPages||A},this.#l=u(this.#t),this.#a=new x(this.#n.pageSize*4),this.#f=_((G,q)=>this.#E(G,q),v),this.#r=new C([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#h=this.#ce(),z(this.#e.fetch)||$("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Ue()}count(){const E=this.#O();return E?E.length:this.#v()}#v(){const E=this.#N();return E?E.count():(this.#ee(),this.#te(this.#r))}#C(){if(this.#N())return!0;const E=D=>{if(D.count===null&&!D.complete)return!1;for(const I of D.children.values())if(this.#Pe(I.key)&&!E(I))return!1;return!0};return E(this.#r)}pageInfo(){const E=this.#O(),D=this.totalPending();if(!E){const I=this.#v();return{page:0,pageSize:0,total:this.#C()?I:null,pageCount:1,counting:D}}return{page:E.page,pageSize:E.pageSize,total:E.total,pageCount:E.pageCount,counting:D||E.total===null&&this.#s.size>0&&this.#r.cache.loadedExtent()===0}}#O(){const E=this.#v(),D=d(this.#R("pageSize",0),this.#R("page",0),E,this.#C());if(!D)return this.#A="",null;const I=`${this.#b}:${D.offset}:${D.length}`;return I!==this.#A&&!this.#p&&(this.#A=I,D.length>0&&!this.#N()&&this.#E(D.offset,D.offset+D.length-1)),D}at(E){const D=this.#O();if(D){if(E<0||E>=D.length)return;const I=this.#P(D.offset+E);return I&&(I.index=E),I}return this.#P(E)}#P(E){const D=this.#N();if(D)return D.at(E);if(this.#ee(),E<0||E>=this.#v())return;const I=this.#K(this.#r,E);if(!I)return;const P=this.#Z(I.node,I.local);return P&&(P.index=E),P||this.#l.skeleton(E,I.node.level,I.node.cache.erroredAt(I.local))}byKey(E){const D=this.#N();if(D)return D.byKey(E);const I=this.#u.get(E);if(!I)return;const P=I.lastIndexOf(":"),k=this.#o.get(I.slice(0,P));return k&&this.#Z(k,Number(I.slice(P+1)))||void 0}loaded(E){const D=this.#O();if(D){if(E<0||E>=D.length)return!1;E+=D.offset}const I=this.#N();if(I)return I.loaded(E);if(E<0||E>=this.#v())return!1;const P=this.#K(this.#r,E);return!!P&&P.node.cache.rowLoaded(P.local)}hint(E,D){if(this.#p)return;this.#y=!0;const I=this.#ee();let P=Math.max(0,Math.floor(E)),k=Math.max(P,Math.floor(D));const N=this.#O();if(N){if(N.length===0)return;P=N.offset,k=N.offset+N.length-1}for(const[G,q]of this.#M(P,k)){G.cache.protect(q.min,q.max);for(const Y of G.cache.evict())this.#Ne(G,Y)}this.#f(P,k),I&&this.#f.flush()}#M(E,D){const I=this.#v(),P=new Map;for(let k=E;k<=D&&k<I;k++){const N=this.#K(this.#r,k);if(!N)continue;const G=P.get(N.node);G?(G.min=Math.min(G.min,N.local),G.max=Math.max(G.max,N.local)):P.set(N.node,{min:N.local,max:N.local})}return P.size||P.set(this.#r,{min:E,max:E}),P}#E(E,D){if(!this.#p)for(const[I,P]of this.#M(E,D)){I.cache.protect(P.min,P.max);const k=I.cache.blockOf(P.min),N=I.cache.blockOf(P.max);for(let G=k;G<=N&&!(I.count!==null&&G*I.cache.pageSize>=I.count);G++)I.cache.has(G)||this.#Ie(I,G)}}apply(E){const D={added:[],updated:[],removed:[]};if(!E)return D;if(E.update)for(const I of E.update){const P=this.#u.get(this.#l.keyOf(I,-1));if(!P)continue;this.#a.delete(P);const k=P.lastIndexOf(":"),N=this.#o.get(P.slice(0,k));if(!N)continue;const G=Number(P.slice(k+1)),q=N.cache.blockOf(G);if(!N.cache.loaded(q))continue;const{start:Y}=N.cache.rangeOf(q),J=[];for(let re=Y;re<Y+N.cache.pageSize;re++){const ie=N.cache.rowAt(re);if(ie===void 0)break;J.push(re===G?I:ie)}N.cache.fill(q,J);const ee=this.#Z(N,G);ee&&D.updated.push(ee)}return(E.add&&E.add.length||E.remove&&E.remove.length)&&this.reload({keepExpanded:!0}),D}reload(E){this.#s.abortAll("reload"),this.#f.cancel(),E&&E.keepExpanded===!1&&this.#i.clear(),this.#ae(),this.#G("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#f.cancel(),this.#s.abortAll("destroyed"),this.#ae(),this.#o.clear(),this.#i.clear(),this.#w&&z(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(E){this.#i.has(E)||(this.#i.add(E),this.#G("group:toggled",{key:E,expanded:!0}),this.#G("model:changed",{reason:"expand",key:E}))}collapse(E){this.#i.delete(E)&&(this.#G("group:toggled",{key:E,expanded:!1}),this.#G("model:changed",{reason:"collapse",key:E}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}pivot(){this.#ee();const E=this.#d;if(!E||!E.keys.size||!this.#R("pivotBy",[]).length)return null;if(!E.result){const D=c((this.#t.config||{}).locale),I=[...E.keys.entries()].sort((k,N)=>O(k[1],N[1],D)),P=I.map(([k])=>k);E.result={keys:I.map(([,k])=>k),paths:P,fields:this.#se(P),groupPaths:[],columns:P.length*Math.max(1,this.#Ce().length),values:E.cells,cells:E.cells,error:null}}return E.result}invalidateHandles(){this.#w&&(z(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),z(this.#w.invalidate)&&this.#w.invalidate("filter"))}#T(){const E=this.#e.fullFrame;return z(E)?E():null}#N(){const E=this.#T();return E?(this.#w||(this.#w=new i({mode:"memory"},this.#L())),E.version!==this.#S&&(this.#w.setRows(E.rows),this.#S=E.version),this.#w):null}#L(){const E=this.#t,D=E.state||{};return{...E,state:{...D,page:()=>0,pageSize:()=>0}}}#B(){const E=this.#N();return E?E.filteredIndices():new Uint32Array(0)}#_(){const E=this.#N();return E?E.unfilteredIndices():new Uint32Array(0)}#z(E){const D=this.#N();return D?D.handleFor(E):void 0}#$(){const E=this.#N();return E?E.display():[]}#q(E){const D=this.#N();return D&&z(D.facetIndices)?D.facetIndices(E):new Uint32Array(0)}#I(){const E=this.#N();return E&&z(E.grandTotalRow)?E.grandTotalRow():null}#W(E){const D=this.#N();if(D){const N=E==="match"?D.matchCount:D.totalCount;if(z(N))return N.call(D)}const I=this.#e.counts,P=z(I)?I():null,k=P?P[E]:null;return typeof k=="number"?k:this.#v()}#V(){const E=this.#N();if(E&&z(E.grandTotalRow))return E.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const I=this.#e.grandTotals,P=z(I)?I():null;return!P||!P.totals?null:this.#l.grandTotal(P.totals,P.leafCount||0)}#U(){const E=this.#N();if(E&&z(E.unfilteredRows))return E.unfilteredRows();const D=[],I=this.count();for(let P=0;P<I;P++){const k=this.at(P);k&&D.push(k)}return D}#fe(){const E=this.#R("quick",""),D={protocol:y,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:r(this.#R("filters",null),this.#J()),sort:this.#R("sort",[]),context:this.#R("context",null)};E&&(D.quick=E);const I=this.#R("where",null);return I&&I.active&&(D.where=I),D}#ie(){const E=this.#R("groupBy",[]).length,D=[];for(const I of this.#o.values())if(!(I.level!==E&&!I.flat))for(const P of I.cache.ids()){if(!I.cache.loaded(P))continue;const{start:k,end:N}=I.cache.rangeOf(P);for(let G=k;G<N&&I.cache.rowLoaded(G);G++){const q=this.#Z(I,G);q&&!q.group&&D.push(q)}}return D}loadedCount(){const E=this.#N();if(E){const P=E.matchCount();return typeof P=="number"?P:E.count()}this.#ee();const D=this.#R("groupBy",[]).length;let I=0;for(const P of this.#o.values())if(!(P.level!==D&&!P.flat))for(const k of P.cache.ids()){if(!P.cache.loaded(k))continue;const N=P.cache.fillOf(k);typeof N=="number"&&(I+=N)}return I}residentRows(){const E=this.#N();return E?E.display():this.#R("groupBy",[]).length>0?null:(this.#ee(),this.#ie())}#ye(E,D,I){const{start:P,end:k}=E.cache.rangeOf(D),N=this.#R("groupBy",[]),G=this.#R("pivotBy",[]),q=this.#R("quick",""),Y=this.#Ce(),J={protocol:y,range:{start:P,end:k},groupPath:E.path,groupValues:E.values,groupBy:N,totals:Y,totalFns:this.#Y(Y),pivotBy:G,pivotMode:G.length>0,filters:r(this.#R("filters",null),this.#J()),sort:this.#R("sort",[]),context:this.#R("context",null),signal:I};q&&(J.quick=q);const ee=this.#R("where",null);return ee&&ee.active&&(J.where=ee),J}async#Ie(E,D){if(!z(this.#e.fetch))return;if(!this.#m){this.#m=!0;const N=this.#g;this.#g=[],queueMicrotask(()=>{for(const G of N)G()})}const I=this.#s.begin(`${E.key}:${D}`);E.cache.begin(D,I);const P=this.#h,{start:k}=E.cache.rangeOf(D);try{const N=await this.#e.fetch(this.#ye(E,D,I.signal));if(!I.current||P!==this.#h||this.#p)return;I.settle();const G=N&&N.rows||[];if(!!(N&&N[j])&&!E.flat){E.flat=!0,E.children.clear();for(const[ee,re]of[...this.#u])re.startsWith(`${E.key}:`)&&(this.#a.delete(re),this.#u.delete(ee))}E.cache.fill(D,G),E.failed=!1;for(let ee=0;ee<G.length;ee++)this.#a.delete(`${E.key}:${k+ee}`);const Y=N&&typeof N.count=="number"?N.count:N&&typeof N.total=="number"?N.total:null,J=N&&z(N.pendingTotal?.then)?N.pendingTotal:null;Y!==null?(E.count=Y,E.complete=!0):G.length<E.cache.pageSize?(E.count=k+G.length,E.complete=!0):J&&(E.counting=!0,E.announced=null),N&&Array.isArray(N.pivotFields)&&this.#Ee(N.pivotFields),N&&N.pivot&&typeof N.pivot=="object"&&this.#Te(N.pivot),this.#G("model:changed",{reason:"page",groupPath:E.path,block:D}),this.#G("rows:changed",{companion:!0,reason:"page",groupPath:E.path,block:D}),this.#pe(E),J&&this.#be(E,J,P)}catch(N){if(I.settle(),V(N))return;E.cache.failed(D,N),E.failed=!0;const{end:G}=E.cache.rangeOf(D);for(let q=k;q<G;q++)this.#a.delete(`${E.key}:${q}`);this.#G("model:changed",{reason:"page-error",groupPath:E.path,block:D}),this.#G("source:error",{error:N,groupPath:E.path,block:D})}}async#be(E,D,I){let P;try{P=await D}catch(k){if(I!==this.#h||this.#p)return;E.counting=!1,V(k)||(E.failed=!0),V(k)||this.#G("source:error",{error:k,groupPath:E.path});return}I!==this.#h||this.#p||(E.counting=!1,typeof P=="number"&&(E.count=P,E.complete=!0,this.#pe(E),this.#G("model:changed",{reason:"total",count:P,groupPath:E.path})))}#pe(E){typeof E.count!="number"||!E.complete||E.announced!==E.count&&(E.announced=E.count,this.#G("source:total",{total:E.count,groupPath:E.path}))}#we(E){if(this.#p)return null;this.#ee();const D=this.#m?null:new Promise(G=>{this.#g.push(G),setTimeout(G,R)}),I=E();if(!D&&!I)return null;const P=(async()=>{D&&await D;for(let G=E();G;G=E())await G})();let k;const N=new Promise(G=>{k=setTimeout(G,R)});return Promise.race([P,N]).then(()=>clearTimeout(k))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#N())return!1;this.#ee();const E=this.#r;return E.count===null&&!E.complete&&E.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Ee(E){E.length===this.#c.length&&E.every((D,I)=>D===this.#c[I])||(this.#c=E,this.#G("column:pivoted",{pivotFields:E,remote:!0}))}#me(){const E=this.#t.config||{};return E.pivot&&E.pivot.separator||b}#se(E){const D=this.#me(),I=this.#Ce();if(!I.length)return E.slice();const P=[];for(const k of E)for(const N of I)P.push(`${k}${D}${N}`);return P}#Te(E){const D=this.#me();this.#d||(this.#d={keys:new Map,cells:new Map,result:null});const I=this.#d;let P=!1;const k=G=>{const q=Array.isArray(G)?G:[G],Y=p(q,D);return I.keys.has(Y)||(I.keys.set(Y,q),P=!0),Y},N=this.#R("groupBy",[]).length>0;for(const G of Array.isArray(E.axis)?E.axis:[])k(G);for(const G of Array.isArray(E.cells)?E.cells:[]){if(!G||typeof G!="object")continue;const q=k(G.pivot);if(N&&!(Array.isArray(G.group)&&G.group.length))continue;const Y=p(Array.isArray(G.group)?G.group:[],D);for(const[J,ee]of Object.entries(G.values||{}))I.cells.set(s(Y,q,J),ee)}I.result=null,P&&this.#Ee((this.pivot()||{fields:[]}).fields)}#te(E){let D=this.#ne(E);for(const I of E.children.values())this.#Pe(I.key)&&(D+=this.#te(I));return D}#ne(E){if(E.count!==null)return E.count;const D=E.cache.loadedExtent();return E.complete?D:E.row&&E.row.leafCount>0?E.level>=this.#R("groupBy",[]).length?Math.max(D,E.row.leafCount):D===0?1:Math.min(D+E.cache.pageSize,Math.max(D,E.row.leafCount)):D+E.cache.pageSize}#K(E,D){let I=D,P=0;const k=[...E.children.entries()].filter(([,G])=>this.#Pe(G.key)).sort((G,q)=>G[0]-q[0]);for(const[G,q]of k){const Y=G-P+1;if(I<Y)return{node:E,local:P+I};I-=Y,P=G+1;const J=this.#te(q);if(I<J)return this.#K(q,I);I-=J}const N=this.#ne(E);return P+I<N?{node:E,local:P+I}:null}#Z(E,D){const I=`${E.key}:${D}`,P=this.#a.get(I);if(P)return P;const k=E.cache.rowAt(D);if(k===void 0)return null;const N=this.#R("groupBy",[]);let G;if(E.level<N.length&&!E.flat){const q=N[E.level],Y=this.#d!==null&&E.level===N.length-1&&this.#R("pivotBy",[]).length>0,J=this.#x(k,q),ee=J==null,re=[...E.path,ee?"":String(J)],ie=[...E.keyPath,ee?null:String(J)];if(G=this.#l.group({path:re,keyPath:ie,column:q,value:J,level:E.level,parent:E.row,leafCount:Number(k.leafCount)||0,expanded:Y?!1:this.#Pe(h(ie)),...Y?{hasChildren:!1}:{}}),G.totals=this.#D(k),G.data=k,!Y){let ae=this.#o.get(G.key);ae?ae.row=G:(ae=new C(re,E.level+1,this.#n,ie),ae.row=G,this.#o.set(ae.key,ae)),ae.values=[...E.values,J],E.children.set(D,ae)}}else G=this.#l.leaf(k,D,E.level,E.row);return this.#a.set(I,G),this.#u.set(G.key,I),G}#D(E){const D=E||{};if(D.totals&&typeof D.totals=="object")return D.totals;const I={};for(const P of this.#Ce())Object.hasOwn(D,P)&&(I[P]=D[P]);return I}#Ne(E,D){const{start:I,end:P}=E.cache.rangeOf(D);for(let k=I;k<P;k++){const N=`${E.key}:${k}`,G=this.#a.peek(N);G&&this.#u.delete(G.key),this.#a.delete(N)}}#ee(){const E=this.#ce();return E===this.#h?!1:(this.#h=E,this.#s.abortAll("query"),this.#ae(),this.#m=!1,this.#G("model:changed",{reason:"query"}),!0)}#ae(){for(const E of this.#o.values())E.cache.clear(),E.count=null,E.complete=!1,E.announced=null,E.counting=!1,E.failed=!1,E.children.clear(),E.flat=!1;this.#a.clear(),this.#u.clear(),this.#b++,this.#d=null}#ce(){const E=this.#R("where",null);return`${t({filters:this.#R("filters",null),sort:this.#R("sort",[]),quick:this.#R("quick",""),groupBy:this.#R("groupBy",[]),pivotBy:this.#R("pivotBy",[]),context:this.#R("context",null)})}|${E?E.version:0}`}#Pe(E){const D=this.#R("expanded",null);return D?z(D.has)?D.has(E):Array.prototype.includes.call(D,E):this.#i.has(E)}#Ce(){const E=this.#R("totals",[]);if(E&&E.length)return[...E];const D=this.#t.columns;return!D||!z(D.all)?[]:D.all().filter(I=>!!I.total).map(I=>I.id)}#Y(E){const D=this.#t.columns,I={};if(!D||!z(D.get))return I;for(const P of E){const k=D.get(P);if(!k)continue;const N=k.groupTotal!=null?k.groupTotal:k.total;typeof N=="string"&&(I[P]=N)}return I}#x(E,D){const I=this.#t.columns,P=I&&z(I.get)?I.get(D):void 0;return P&&z(P.getValue)?P.getValue(E):E?.[D]}#Ue(){n(this.#t)}#J(){const E=this.#t.config||{};return{tz:E.timeZone,weekStartsOn:E.weekStartsOn}}#R(E,D){const I=this.#t.state;if(I&&z(I[E])){const P=I[E]();return P??D}return D}#G(E,D){const I=this.#t.emit;z(I)&&I(E,D)}}}),Fe("packages/core/src/source/gapbuffer.js",function(e,K){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return x}});const Q=64;class x{#e;#t=0;#n=0;constructor($=Q){this.#e=new Uint32Array(Math.max(1,$)),this.#n=this.#e.length}static from($,_=Q){const X=new x($.length+Math.max(1,_));return X.#e.set($,0),X.#t=$.length,X.#n=X.#e.length,X}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at($){return $<0||$>=this.length?0:$<this.#t?this.#e[$]:this.#e[$+(this.#n-this.#t)]}insert($,_){const X=$<0?0:$>this.length?this.length:$;this.#r(X),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=_}push($){this.insert(this.length,$)}removeAt($){return!Number.isInteger($)||$<0||$>=this.length?!1:(this.#r($),this.#n++,!0)}toArray(){const $=new Uint32Array(this.length);return $.set(this.#e.subarray(0,this.#t),0),$.set(this.#e.subarray(this.#n),this.#t),$}clear(){this.#t=0,this.#n=this.#e.length}#r($){if($!==this.#t)if($<this.#t){const _=this.#t-$;this.#e.copyWithin(this.#n-_,$,this.#t),this.#t=$,this.#n-=_}else{const _=$-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+_),this.#t=$,this.#n+=_}}#o(){const $=this.#e.length-this.#n,_=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+Q));_.set(this.#e.subarray(0,this.#t),0),_.set(this.#e.subarray(this.#n),_.length-$),this.#e=_,this.#n=_.length-$}}}),Fe("packages/core/src/store/ingest.js",function(e,K){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return r}});const Q=K("packages/core/src/internal/util.js"),x=Q.now,z=Q.nextFrame,$=Q.infoOnce,_=Q.warnOnce,X=Q.isFunction,W=Q.pathGetter,H=K("packages/core/src/store/columnstore.js").ColumnStore,B=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function w(t,n={}){if(n.multi)return"multi";if(t.length===0)return"object";let o=0,d=0,l=0,i=0,m=0;for(let f=0;f<t.length;f++){const s=t[f];typeof s=="number"?o++:typeof s=="boolean"?d++:typeof s=="string"?l++:s instanceof Date?i++:Array.isArray(s)&&m++}const c=t.length;return o===c?"float64":d===c?"bitset":i===c?"float64":l===c?"text":m===c?"multi":"object"}function A(t,n,o){return n<=0||t<o*n?"dictionary":"object"}function g(t,n,o){const d=new Map,l=new Map;for(const y of t){if(y.computed)continue;const v=X(y.read)?y.read:W(y.field||y.id);l.set(y.id,v),d.set(y.id,v)}const i=n?.order??[],m=n?.fns??{},c=n?.deps??{},f=n?.wrapDeps??null,s=i.filter(y=>X(m[y])),p=s.some(y=>c[y]==="*");let b=new WeakMap;const S=y=>{const v={};if(p)for(const[R,O]of l)v[R]=O(y);for(const R of s){const O=c[R];let F;if(O==="*")F=v;else{F={};const C=O||[];for(let T=0;T<C.length;T++){const L=C[T];F[L]=L in v?v[L]:l.get(L)?.(y)}}v[R]=m[R](f?f(F,R):F,{data:y,row:null,column:null,grid:null,context:o})}return v},j=y=>{if(y===null||typeof y!="object"&&typeof y!="function")return S(y);let v=b.get(y);return v===void 0&&(v=S(y),b.set(y,v)),v};for(const y of s)d.set(y,v=>j(v)[y]);return{readers:d,reset(){b=new WeakMap}}}class u{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(n,o){this.spec=n,this.read=o,this.kind="object",this.inferred=!1,this.nullable=n.nullable!==!1}}class h{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(n,o={},d={}){this.#e=Array.isArray(n)?n:Array.from(n||[]),this.#i={...B,...d};const l=o.columns??[];this.#r=g(l,o.computed??null,o.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(l,o.computed??null),this.#n=new H(this.#t.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const n=x(),{chunkMs:o,chunkRows:d}=this.#i,l=this.#e.length;do{const i=Math.min(this.#o+d,l);this.#n.append(this.#e.slice(this.#o,i)),this.#d(this.#o,i),this.#o=i,this.#r.reset(),this.#f(!1)}while(this.#o<l&&x()-n<o);return this.#a+=x()-n,this.#i.onProgress?.({loaded:this.#o,total:l}),this.#o>=l?(this.#f(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(n=>({id:n.spec.id,kind:n.kind,nullable:n.nullable,read:n.read,dictionary:n.spec.dictionary})),decisions:this.#t.map(n=>({id:n.spec.id,kind:n.kind,nullable:n.nullable,inferred:n.inferred,distinct:n.candidate||n.change?this.#h(n):null,change:n.change,reason:n.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(n,o){const d=this.#e,l=Math.min(this.#i.sampleSize,d.length),i=this.#i.dictionaryRatio,m=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const c of n){if(!c||!c.id)continue;if(c.computed&&(c.pure===!1||o&&!m.has(c.id))){_(`ingest.impure.${c.id}`,`column "${c.id}" is an impure computed column and is not materialised into the store`);continue}const f=this.#r.readers.get(c.id)??(X(c.read)?c.read:W(c.field||c.id)),s=new u(c,f);if(c.kind)s.kind=c.kind,s.reason="declared by the caller";else if(c.dictionary)s.kind=c.multi?"multi":"dictionary",s.reason="value table supplied (lookup column)";else{const p=[];for(let S=0;S<l&&p.length<this.#i.sampleSize;S++){const j=f(d[S]);j!=null&&p.push(j)}s.inferred=!0;const b=w(p,{multi:c.multi});if(b==="text"){const S=new Set(p).size;s.kind=A(S,p.length,i),s.candidate=this.#u,s.reason=`sampled ${S} distinct in ${p.length}`}else s.kind=b,s.reason=`inferred from ${p.length} sampled values`,b==="object"&&p.length&&$(`ingest.mixed.${c.id}`,`column "${c.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);s.kind==="object"&&s.candidate&&(s.distinct=new Set(p))}this.#t.push(s)}}#d(n,o){const d=this.#e;for(const l of this.#t){if(!l.candidate||!l.distinct)continue;const i=l.distinct;for(let m=n;m<o;m++){const c=l.read(d[m]);c!=null&&i.add(c)}}}#h(n){if(n.distinct)return n.distinct.size;const o=this.#n.column(n.spec.id);return o?.dict?o.dict.size:0}#f(n){const o=this.#i.dictionaryRatio,d=this.#e.length;for(const l of this.#t){if(!l.candidate)continue;const i=this.#h(l);if(l.kind==="dictionary"&&i>=o*d){const m=this.#n.column(l.spec.id);l.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(l.spec.id,"object"),l.kind="object",l.change="demoted",l.reason=`${i} distinct values is at or above ${o*100}% of ${d} rows`;continue}if(l.kind==="object"&&i>=o*d){l.candidate=!1,l.distinct=null,l.reason=`${i} distinct values is at or above ${o*100}% of ${d} rows`;continue}n&&l.kind==="object"&&i<o*d&&(this.#n.convert(l.spec.id,"dictionary"),l.kind="dictionary",l.change=l.change==="demoted"?null:"promoted",l.reason=`${i} distinct values is below ${o*100}% of ${d} rows`,l.distinct=null),n&&(l.candidate=!1)}}}async function a(t,n={},o={}){const d=new h(t,n,o),l=o.scheduler?.frame??z;for(;d.slice();)await new Promise(i=>{l(i)});return d.result()}function r(t,n={},o={}){const d=new h(t,n,{...o,chunkMs:1/0});for(;d.slice(););return d.result()}}),Fe("packages/core/src/store/columnpack.js",function(e,K){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return h}});const x=K("packages/core/src/internal/util.js").pathGetter,z=K("packages/core/src/store/ingest.js"),$=z.inferKind,_=z.decideText,X=z.INGEST_DEFAULTS,V=K("packages/core/src/store/columnstore.js").toFloat,H=new Set(["float64","int32","bitset","dictionary","object","multi"]);function B(a){if(!Array.isArray(a)||a.length===0)return!1;for(const r of a)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!H.has(r.kind))return!1;return!0}function w(a){const r=V(a);return Number.isFinite(r)?r|0:0}function A(a){return a==null?[]:Array.isArray(a)?a:[a]}function g(a,r,t,n){if(a.kind)return a.kind;const o=[];for(let i=0;i<r.length&&o.length<X.sampleSize;i++){const m=r[i];m!=null&&o.push(m)}const d=$(o,{multi:a.multi});if(d!=="text")return d;const l=new Set(o).size;return _(l,o.length,n)}function u(a,r,t={}){const n=r.length|0,o=t.dictionaryRatio??X.dictionaryRatio,d=[];for(const l of a){const i=x(l.field||l.id),m=l.nullable!==!1,c=new Array(n);for(let S=0;S<n;S++){const j=i(r[S]);c[S]=j===void 0?null:j}const f=g(l,c,n,o),s=m?new Uint8Array(n+7>>3):null,p=S=>{s&&(s[S>>3]|=1<<(S&7))};let b;switch(f){case"float64":{const S=new Float64Array(n);for(let j=0;j<n;j++){const y=c[j],v=y===null;v||p(j),S[j]=v?NaN:V(y)}b={id:l.id,kind:f,nullable:m,values:S,presence:s,offsets:null,table:null};break}case"int32":{const S=new Int32Array(n);for(let j=0;j<n;j++){const y=c[j],v=y===null;v||p(j),S[j]=v?0:w(y)}b={id:l.id,kind:f,nullable:m,values:S,presence:s,offsets:null,table:null};break}case"bitset":{const S=new Uint8Array(n+7>>3);for(let j=0;j<n;j++){const y=c[j],v=y===null;v||p(j),!v&&y&&(S[j>>3]|=1<<(j&7))}b={id:l.id,kind:f,nullable:m,values:S,presence:s,offsets:null,table:null};break}case"dictionary":{const S=new Uint32Array(n),j=[],y=new Map;for(let v=0;v<n;v++){const R=c[v];if(R===null){S[v]=0;continue}p(v);let O=y.get(R);O===void 0&&(O=j.length,j.push(R),y.set(R,O)),S[v]=O}b={id:l.id,kind:f,nullable:m,values:S,presence:s,offsets:null,table:j};break}case"multi":{const S=[],j=new Map,y=new Uint32Array(n+1),v=[];for(let R=0;R<n;R++){const O=c[R];y[R]=v.length,O===null||p(R);const C=A(O);for(let T=0;T<C.length;T++){const L=C[T];let E=j.get(L);E===void 0&&(E=S.length,S.push(L),j.set(L,E)),v.push(E)}}y[n]=v.length,b={id:l.id,kind:f,nullable:m,values:Int32Array.from(v),presence:s,offsets:y,table:S};break}default:{const S=new Array(n);for(let j=0;j<n;j++){const y=c[j];y!==null&&p(j),S[j]=y}b={id:l.id,kind:"object",nullable:m,values:S,presence:s,offsets:null,table:null};break}}d.push(b)}return{count:n,columns:d}}function h(a){const r=[];if(!a||!Array.isArray(a.columns))return r;const t=n=>{ArrayBuffer.isView(n)&&n.buffer&&!r.includes(n.buffer)&&r.push(n.buffer)};for(const n of a.columns)t(n.values),t(n.presence),t(n.offsets);return r}}),Fe("packages/core/src/source/stream.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return O}});const Q=K("packages/core/src/internal/util.js"),x=Q.Lru,z=Q.isFunction,$=Q.now,_=Q.nextFrame,X=Q.cancelFrame,W=Q.whenIdle,V=Q.defaultCompare,H=Q.warnOnce,B=Q.infoOnce,w=Q.getPath,A=K("packages/core/src/source/abort.js"),g=A.createAbortScope,u=A.isAbortError,h=K("packages/core/src/source/rows.js"),a=h.createRowFactory,r=h.lazyRowView,n=K("packages/core/src/source/gapbuffer.js").GapBuffer,d=K("packages/core/src/source/memory.js").createMemorySource,i=K("packages/core/src/source/filterwire.js").querySignature,c=K("packages/core/src/store/columnpack.js").isPortableSchema,f=25e4,s=Symbol("lattice.stream.storeBacked"),p=8,b=.1,S=1e3,j=50;function y(F){return Math.min(S,Math.max(j,Math.floor(F/4)))}function v(F){if(F instanceof Date)return F.getTime();if(typeof F=="number")return Number.isFinite(F)?F:NaN;if(typeof F=="string"){const C=F.trim();if(!C)return NaN;const T=Date.parse(C);return Number.isNaN(T)?Number(C):T}return NaN}function R(F,C){return new O(F,C)}class O{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=g();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#p=0;#m=0;#g=null;#y=null;#b=null;#A=!1;#w=!1;#S=!1;#v=!1;#C="";#O=0;#P=0;#M=0;#E=null;#T=1/0;#N=!1;#L=null;#B=null;#_=null;#z=null;#$=!1;#q=0;#I=0;#W=!1;constructor(C,T){this.#e=C||{mode:"stream"},this.#t=T||{},this.#s=a(this.#t),this.#l=new x(4096),this.#C=this.#_e();const L=(this.#t.config||{}).ingest;this.#$=!!L&&L.retainSource===!1,z(this.#e.open)||H("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const E=Number(this.#e.poll);Number.isFinite(E)&&E>0&&(this.#z=setInterval(()=>{this.#v||this.reload()},E),this.#z&&z(this.#z.unref)&&this.#z.unref()),this.#U()}#V(){const C=Number(this.#e.maxAge);return Number.isFinite(C)&&C>0?C:0}#U(){const C=this.#V();if(!C)return;const T=this.#e.ageBy;z(T)?this.#B=T:typeof T=="string"&&T?this.#B=L=>w(L,T):this.#B=null,this.#E=[],this.#L=setInterval(()=>{this.#v||this.#fe()&&(this.#ee(),this.#he())},y(C)),this.#L&&z(this.#L.unref)&&this.#L.unref()}#fe(){const C=this.#V();return!C||!this.#E?!1:this.#N?!0:this.#T<Date.now()-C*(1+b)}#ie(C,T){if(!this.#E)return;const L=this.#B?v(this.#B(T)):Date.now();this.#E[C]=L,Number.isNaN(L)||(L<this.#T&&(this.#T=L),L<Date.now()-this.#V()&&(this.#N=!0))}#ye(){return this.#ke("groupBy",[]).length>0?!0:!!this.#ke("pivotMode",!1)&&this.#ke("pivotBy",[]).length>0}#Ie(){if(this.#g||this.#v)return;const C=this.#ye();if(C&&!this.#y){this.#y=d({mode:"memory",rows:this.#n},this.#be()),this.#A=!1;return}!C&&this.#y&&(this.#y.destroy(),this.#y=null)}#be(){if(this.#b)return this.#b;const C=this,T={liveIndices:()=>C.#pe(),live:L=>C.#n[L]!==void 0,source:L=>C.#Se(L),get physical(){return C.#n.length}};return this.#$&&(T.column=L=>{const E=C.#t.store;return E&&z(E.column)?E.column(L):void 0}),this.#b=Object.create(this.#t,{store:{value:T,enumerable:!0,configurable:!0}}),this.#b}#pe(){const C=new Uint32Array(this.#n.length);let T=0;for(let L=0;L<this.#n.length;L++)this.#n[L]!==void 0&&(C[T++]=L);return C.subarray(0,T)}#we(){return this.#g?this.#g:this.#y?(this.#A&&(this.#A=!1,this.#y.setRows(this.#n)),this.#y):null}invalidate(C="filter"){if(this.#g){this.#g.invalidate(C);return}this.#Ie(),this.#y&&this.#y.invalidate(C),(C==="filter"||C==="sort")&&this.#Ce()}count(){const C=this.#we();return C?C.count():this.#r?this.#r.length:this.#O}matchCount(){const C=this.#we();return C&&z(C.matchCount)?C.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const C=this.#we();return C&&z(C.totalCount)?C.totalCount():this.#O}unfilteredRows(){const C=this.#we();if(C&&z(C.unfilteredRows))return C.unfilteredRows();const T=[];for(let L=0;L<this.#n.length;L++){if(!this.#n[L])continue;const E=this.#Oe(L);E&&T.push(E)}return T}at(C){const T=this.#we();if(T)return T.at(C);if(C<0||C>=this.count())return;const L=this.#r?this.#r.at(C):C,E=this.#Oe(L);return E.index=C,E}byKey(C){const T=this.#we();if(T)return T.byKey(C);const L=this.#a.get(C);return L===void 0?void 0:this.#Oe(L)}leavesOf(C){const T=this.#we();return T&&z(T.leavesOf)?T.leavesOf(C):[]}loaded(C){return C>=0&&C<this.count()}hint(C,T){if(this.#g){this.#g.hint(C,T);return}this.#Ee(),this.#p=Math.max(0,Math.floor(C))}#Ee(){this.#v||this.#_e()===this.#C||this.reload()}display(){const C=this.#we();return C?C.display():r(()=>this.count(),T=>this.at(T))}apply(C){if(this.#g)return this.#g.apply(C);const T={added:[],updated:[],removed:[]};if(!C)return T;if(C.update){let L=!1;for(const E of C.update){const D=this.#a.get(this.#s.keyOf(E,-1));if(D===void 0)continue;const I=this.#Ue(D);this.#$?this.#We(D,E):this.#n[D]=E,this.#l.delete(D),this.#J(D,I),this.#E&&(this.#ie(D,E),L=!0),this.#A=!0,T.updated.push(this.#Oe(D))}L&&this.#ee()}if(C.add&&C.add.length){const L=this.#D(C.add);for(const E of L)T.added.push(this.#Oe(E))}return C.remove&&C.remove.length&&H("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#he(),T}reload(C){this.#u.abortAll("reload"),this.#He(),this.#y&&(this.#y.destroy(),this.#y=null),this.#A=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#P=0,this.#M=0,this.#E&&(this.#E=[]),this.#T=1/0,this.#N=!1,this.#w=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#C=this.#_e(),this.#Le("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#z!==null&&(clearInterval(this.#z),this.#z=null),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#E=null,this.#u.abortAll("destroyed"),this.#He(),this.#d!==null&&(this.#k(this.#d),this.#d=null),this.#y&&(this.#y.destroy(),this.#y=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#S||this.#v||!z(this.#e.open))return;this.#S=!0;const C=this.#u.begin("stream");this.#Ce(),this.#Ie();let T;try{T=this.#e.open({sort:this.#ke("sort",[]),filters:this.#ke("filters",null),quick:this.#ke("quick","")||void 0,context:this.#ke("context",null),signal:C.signal})}catch(E){this.#Le("source:error",{error:E});return}const L=z(T[Symbol.asyncIterator])?T[Symbol.asyncIterator]():T[Symbol.iterator]();this.#_=L;try{for(;;){const E=await L.next();if(!C.current||this.#v)return;if(E.done){this.#le();return}if(await this.#me(E.value,C),!C.current||this.#v)return;if(E.value&&E.value.done){this.#le();return}if(await this.#oe(),!C.current||this.#v)return}}catch(E){if(u(E))return;this.#Le("source:error",{error:E})}finally{C.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#w,live:this.#O,evicted:this.#P}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const C=this.#we();C&&(z(C.invalidateHandles)&&C.invalidateHandles(),z(C.invalidate)&&C.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#q,inline:this.#I,storeBacked:this.#$}}#me(C,T){if(!C)return;const L=C.rows;if(L&&L.length&&this.#Te(L))return this.#ne(C,T);const E=$();L&&L.length&&(this.#D(L),this.#I++),this.#se(C),this.#f+=$()-E,this.#he()}#se(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)}#Te(C){if(this.#W||this.#g)return!1;const T=this.#K();if(!T)return!1;const L=this.#t.store;if(!L||!z(L.appendPacked))return!1;const E=this.#Z();return!E||!c(E)?(this.#W=!0,B("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<T.threshold?!1:!this.#te(C)}#te(C){if(!this.#s.keyed)return!1;const T=new Set;for(let L=0;L<C.length;L++){const E=this.#s.keyOf(C[L],this.#n.length+L);if(E!=null){if(T.has(E)||this.#a.has(E))return!0;T.add(E)}}return!1}async#ne(C,T){const L=C.rows,E=this.#K(),D=this.#Z();let I;try{I=await E.columnize(D,L,{key:"ingest:stream",signal:T&&T.signal})}catch(q){if(u(q)||(H("source.stream.columnize","worker columnization failed; columnizing on the main thread",q),this.#W=!0,T&&(!T.current||this.#v)))return;this.#D(L),this.#I++,this.#se(C),this.#he();return}if(T&&(!T.current||this.#v))return;const P=this.#t.store,k=this.#$?void 0:L,{from:N}=P.appendPacked(I,k),G=I.count|0;for(let q=0;q<G;q++){const Y=N+q,J=L[q],ee=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#$?s:J,this.#O++,this.#ie(Y,J),ee!==null&&this.#a.set(ee,Y),!this.#r||!this.#Y(Y))continue;const re=this.#R(Y);this.#r.insert(re,Y),re<=this.#p&&this.#m++}this.#A=!0,this.#ee(),this.#q++,this.#se(C),this.#he()}#K(){const C=this.#t.ingestWorker;return z(C)?C():null}#Z(){const C=this.#t.storeSchema;return z(C)?C():null}#D(C){const T=[],L=this.#t.store,E=new Array(C.length),D=[],I=new Set;for(let k=0;k<C.length;k++){const N=this.#s.keyed?this.#s.keyOf(C[k],this.#n.length+D.length):null;E[k]=N,!(N!==null&&(this.#a.has(N)||I.has(N)))&&(N!==null&&I.add(N),D.push(C[k]))}let P=D.length&&L&&z(L.append)?L.append(D).from:this.#n.length;for(let k=0;k<C.length;k++){const N=C[k],G=E[k];if(G!==null&&this.#a.has(G)){const J=this.#a.get(G),ee=this.#Ue(J);this.#$||(this.#n[J]=N,L&&z(L.setSource)&&L.setSource(J,N)),this.#We(J,N),this.#l.delete(J),this.#ie(J,N),this.#J(J,ee);continue}const q=P++;if(this.#n[q]=this.#$?s:N,this.#O++,this.#ie(q,N),G!==null&&this.#a.set(G,q),T.push(q),!this.#r||!this.#Y(q))continue;const Y=this.#R(q);this.#r.insert(Y,q),Y<=this.#p&&this.#m++}return this.#A=!0,this.#ee(),T}#Ne(C){const T=this.#n[C];let L=!1;if(this.#r){const P=this.#Pe(C);P>=0&&P<=this.#p&&(L=!0)}else C<=this.#p&&(L=!0);const E=T===s?this.#Se(C):T,D=this.#s.keyed?this.#s.keyOf(E,C):null;D!==null&&this.#a.get(D)===C&&this.#a.delete(D),this.#n[C]=void 0,this.#E&&(this.#E[C]=NaN),this.#l.delete(C);const I=this.#t.store;return I&&z(I.remove)&&I.remove(C),this.#O--,L}#ee(){let C=0,T=0;const L=this.#ce();C+=L.dropped,T+=L.aboveAnchor;const E=this.#ae();C+=E.dropped,T+=E.aboveAnchor,C&&(this.#A=!0,this.#P+=C,this.#Ce(),this.#m-=T,this.#Le("stream:evicted",{evicted:C,total:this.#P,live:this.#O}))}#ae(){const C=this.#e.maxRows;if(!Number.isFinite(C)||C<=0||this.#O<=C)return{dropped:0,aboveAnchor:0};const T=Math.max(1,Math.floor(C*(1-b)));let L=0,E=0;for(;this.#O>T&&this.#M<this.#n.length;){const D=this.#M++;this.#n[D]!==void 0&&(this.#Ne(D)&&E++,L++)}return{dropped:L,aboveAnchor:E}}#ce(){const C=this.#V();if(!C||!this.#E||!this.#fe())return{dropped:0,aboveAnchor:0};const T=Date.now()-C;let L=0,E=0,D=1/0;for(let I=this.#M;I<this.#n.length;I++){if(this.#n[I]===void 0)continue;const P=this.#E[I];if(!(Number.isNaN(P)||P===void 0)){if(P>=T){P<D&&(D=P);continue}this.#Ne(I)&&E++,L++}}for(this.#T=D,this.#N=!1;this.#M<this.#n.length&&this.#n[this.#M]===void 0;)this.#M++;return{dropped:L,aboveAnchor:E}}#Pe(C){if(!this.#r)return C;for(let T=0;T<this.#r.length;T++)if(this.#r.at(T)===C)return T;return-1}#Ce(){this.#o=this.#ke("sort",[]),this.#i=this.#ke("filters",null);const C=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#V()>0,T=this.#ke("where",null),L=(this.#t.config||{}).hostFilter,E=!!(T&&T.active)||!!(L&&z(L.active)&&L.active());if(!(C||this.#o.length>0||!!this.#i||!!this.#ke("quick","")||E)){this.#r=null;return}this.#r=new n(Math.max(64,this.#n.length+64));for(let I=0;I<this.#n.length;I++)this.#n[I]!==void 0&&this.#Y(I)&&this.#r.insert(this.#R(I),I)}#Y(C){const T=this.#Se(C);if(this.#i&&!this.#x(this.#i,T))return!1;const L=String(this.#ke("quick","")||"").toLowerCase();if(L&&!this.#Ge(T).includes(L))return!1;const E=(this.#t.config||{}).hostFilter;if(E&&z(E.active)&&E.active()&&!E.passes(this.#Oe(C)))return!1;const D=this.#ke("where",null);if(D&&D.active){const I=this.#Oe(C);if(!D.passes(I.data,I.key))return!1}return!0}#x(C,T){if(!C)return!0;const L=C;if(Array.isArray(L.conditions))return L.op==="or"?L.conditions.some(I=>this.#x(I,T)):L.op==="not"?!L.conditions.some(I=>this.#x(I,T)):L.conditions.every(I=>this.#x(I,T));const E=C,D=(this.#t.compute||{}).testValue;return z(D)?!!D(this.#Re(T,E.col),E,(this.#t.config||{}).locale):(H("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Ue(C){if(!this.#r)return-1;if(!this.#o.length)return this.#Pe(C);let T=0,L=this.#r.length;for(;T<L;){const E=T+L>>>1;this.#G(this.#r.at(E),C)<0?T=E+1:L=E}for(let E=T;E<this.#r.length;E++){const D=this.#r.at(E);if(D===C)return E;if(this.#G(D,C)>0)break}return this.#Pe(C)}#J(C,T){if(!this.#r||!this.#o.length)return;const L=this.#Y(C);if(T>=0&&this.#r.at(T)===C)this.#r.removeAt(T),T<=this.#p&&this.#m--;else if(T>=0)return;if(!L)return;const E=this.#R(C);this.#r.insert(E,C),E<=this.#p&&this.#m++}#R(C){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let T=0,L=this.#r.length;for(;T<L;){const E=T+L>>>1;this.#G(C,this.#r.at(E))<0?L=E:T=E+1}return T}#G(C,T){const L=this.#Se(C),E=this.#Se(T);for(const D of this.#o){const I=this.#Ze(D.col),P=this.#Re(L,D.col),k=this.#Re(E,D.col),G=(I&&I.value&&z(I.value.compare)?I.value.compare:V)(P,k);if(G!==0)return D.dir==="desc"?-G:G}return 0}#le(){this.#w=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const C=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:f;!this.#$&&this.#n.length<C&&(this.#g=d({mode:"memory",rows:this.#n},this.#t),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#y&&(this.#y.destroy(),this.#y=null)),this.#he(),this.#Le("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:C})}#he(){this.#d!==null||this.#v||(this.#d=this.#ve(()=>{this.#d=null,this.#h++;const C=this.#m;this.#m=0,this.#f=0,this.#Le("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#Le("model:changed",{reason:"stream",shiftAboveViewport:C,anchor:this.#p}),this.#Le("rows:changed",{companion:!0,reason:"stream"})}))}#oe(){return this.#h===0||this.#f<this.#ge()?Promise.resolve():(this.#f=0,new Promise(C=>{const T=(this.#t.scheduler||{}).idle;z(T)?T(()=>C()):W(()=>C())}))}#ge(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:p}#ve(C){const T=this.#t.scheduler||{};return z(T.frame)?T.frame(C):_(C)}#k(C){const T=this.#t.scheduler||{};z(T.cancel)?T.cancel(C):X(C)}#Se(C){const T=this.#n[C];if(T!==void 0&&T!==s)return T;if(T===void 0)return;const L=this.#t.store;return L&&z(L.source)?L.source(C):void 0}#We(C,T){const L=this.#t.store;if(!L||!z(L.set))return;const E=this.#Z();if(Array.isArray(E))for(const D of E){if(!D||!D.id)continue;const I=z(D.read)?D.read:P=>w(P,D.field||D.id);L.set(D.id,C,I(T))}}#Oe(C){let T=this.#l.get(C);return T||(T=this.#s.leaf(this.#Se(C),C),this.#l.set(C,T)),T}#Re(C,T){const L=this.#Ze(T);return L&&z(L.getValue)?L.getValue(C):C?.[T]}#Ge(C){const T=this.#t.columns,L=T&&z(T.all)?T.all():[],E=[];for(const D of L){const I=z(D.getValue)?D.getValue(C):void 0;I!=null&&I!==""&&E.push(String(I))}return E.join(" ").toLowerCase()}#Ze(C){const T=this.#t.columns;return T&&z(T.get)?T.get(C):void 0}#He(){const C=this.#_;if(this.#_=null,C&&z(C.return))try{C.return()}catch{}}#_e(){return i({context:this.#ke("context",null)})}#ke(C,T){const L=this.#t.state;if(L&&z(L[C])){const E=L[C]();return E??T}return T}#Le(C,T){const L=this.#t.emit;z(L)&&L(C,T)}}}),Fe("packages/core/src/source/url.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.isObject,$=Q.isFunction,_=Q.getPath,W=K("packages/core/src/source/abort.js").isAbortError,V=500,H=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),B=Symbol("lattice.url.skip");function w(c,f={}){const s=z(f)?f:{},p=$(s.fetch)?s.fetch:typeof globalThis<"u"&&$(globalThis.fetch)?globalThis.fetch:null,b=s.format==="json"||s.format==="ndjson"?s.format:void 0,S=typeof s.rowsPath=="string"&&s.rowsPath?s.rowsPath:void 0,j=$(s.map)?s.map:void 0,y=z(s.headers)?s.headers:void 0,v=Number.isFinite(s.batchSize)&&s.batchSize>0?Math.floor(s.batchSize):V,R=s.lenient===!0,O=Number.isFinite(s.poll)&&s.poll>0?Math.floor(s.poll):void 0,F=typeof c=="string"&&c.length>0;F||x("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*C(L={}){if(!F)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const E=L&&L.signal;let D;try{D=await p(c,y?{signal:E,headers:y}:{signal:E})}catch(k){throw W(k)?k:new Error(`[lattice] createUrlSource: request to ${c} failed — ${k&&k.message||k}`)}if(!D||!D.ok){const k=D?D.status:"no response";throw new Error(`[lattice] createUrlSource: ${k} for ${c}`)}const I=A(c,b,D),P=D.body&&$(D.body.getReader)?D.body.getReader():null;try{if(!P){const G=await D.text();(I||h(G,c))==="ndjson"?yield*d(null,null,G,0,D,c,v,R):yield*o(G,c,S,j);return}const k=new TextDecoder("utf-8");if(I==="json"){yield*o(await n(P,k,""),c,S,j);return}if(I==="ndjson"){yield*d(P,k,"",0,D,c,v,R);return}const N=await a(P,k,c);N.format==="json"?yield*o(await n(P,k,N.seed),c,S,j):yield*d(P,k,N.seed,N.bytes,D,c,v,R)}finally{if(P&&$(P.cancel))try{await P.cancel()}catch{}}}const T={mode:"stream",open:C,autoStart:s.autoStart!==!1};return O!==void 0&&(T.poll=O),Number.isFinite(s.maxRows)&&(T.maxRows=s.maxRows),Number.isFinite(s.maxAge)&&(T.maxAge=s.maxAge),(typeof s.ageBy=="string"||$(s.ageBy))&&(T.ageBy=s.ageBy),Number.isFinite(s.coalesceMs)&&(T.coalesceMs=s.coalesceMs),Number.isFinite(s.promoteToMemoryBelow)&&(T.promoteToMemoryBelow=s.promoteToMemoryBelow),T}function A(c,f,s){if(f)return f;const p=g(c);if(p)return p;const b=s&&s.headers&&$(s.headers.get)?s.headers.get("content-type"):null;return u(b)}function g(c){const f=String(c).split(/[?#]/)[0].toLowerCase();if(f.endsWith(".ndjson")||f.endsWith(".jsonl"))return"ndjson";if(f.endsWith(".json"))return"json"}function u(c){if(!c)return;const f=c.split(";")[0].trim().toLowerCase();if(H.has(f))return"ndjson";if(f==="application/json"||f==="text/json"||f.endsWith("+json"))return"json"}function h(c,f){const s=c.replace(/^\s+/,""),p=r(s);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${f} — pass opts.format: 'json' | 'ndjson'.`);return p}async function a(c,f,s){let p="",b=0;for(;;){const{value:j,done:y}=await c.read();if(j&&(b+=j.byteLength,p+=f.decode(j,{stream:!0})),y){p+=f.decode();break}const v=p.replace(/^\s+/,"");if(v){if(v[0]==="[")return{format:"json",seed:p,bytes:b};if(v[0]!=="{"||p.indexOf(`
8
8
  `)!==-1)break}}const S=r(p.replace(/^\s+/,""));if(S==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${s} — pass opts.format: 'json' | 'ndjson'.`);return{format:S,seed:p,bytes:b}}function r(c){if(!c||c[0]==="[")return"json";if(c[0]!=="{")return"error";const f=c.indexOf(`
9
9
  `);if(f===-1)return"json";let s=c.slice(0,f);return s.endsWith("\r")&&(s=s.slice(0,-1)),t(s)?"ndjson":"json"}function t(c){try{return JSON.parse(c),!0}catch{return!1}}async function n(c,f,s){let p=s;for(;;){const{value:b,done:S}=await c.read();if(b&&(p+=f.decode(b,{stream:!0})),S)break}return p+=f.decode(),p}function*o(c,f,s,p){let b;try{b=JSON.parse(c)}catch(j){throw new Error(`[lattice] createUrlSource: ${f} is not valid JSON — ${j.message}`)}let S=s!==void 0?_(b,s):b;if(p&&(S=p(S)),!Array.isArray(S)){const j=s!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${f} did not resolve to an array${j}.`)}yield{rows:S,progress:{loaded:S.length,estimated:S.length}}}async function*d(c,f,s,p,b,S,j,y){const v=m(b);let R=s||"",O=p||0,F=0,C=0,T=[];function*L(){let D;for(;(D=R.indexOf(`
@@ -54,6 +54,6 @@ ${ee}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
54
54
  `,b),R=s.slice(y,v),O=R.split(`
55
55
  `);let F=0;const C=O.map(T=>{if(!c)return F+=S.length,S+T;if(T.startsWith(S))return F-=S.length,T.slice(S.length);const L=T.replace(/^[ \t]/,"");return F-=T.length-L.length,L}).join(`
56
56
  `);return C===R?!1:(f.value=s.slice(0,y)+C+s.slice(v),this.#r(Math.max(y,p+(c?-S.length:S.length)),Math.max(y,b+F)),this.revalidate(),!0)}#r(c,f){const s=this.input;s&&(s.selectionStart=c,s.selectionEnd=f===void 0?c:f,W(s.setSelectionRange)&&s.setSelectionRange(s.selectionStart,s.selectionEnd))}format(c){const f=this.input;if(!f||this.language!=="json")return!1;const s=a(f.value);if(!s.ok)return this.revalidate(),!1;if(s.value===null&&f.value.trim()==="")return!1;try{const p=JSON.stringify(s.value,null,c===void 0?this.indent:c);return p===void 0?!1:(f.value=p,this.#r(p.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const c=this.input?this.input.value:"",f=o(c,this.language);this.lastResult=f;const s=this.errorNode;return s&&(s.textContent=f.ok?"":d(f),s.classList.toggle(w.errorOn,!f.ok)),this.input&&(f.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),f.ok||!s?this.input.removeAttribute("aria-errormessage"):(s.id||(s.id=V("lat-err")),this.input.setAttribute("aria-errormessage",s.id))),f}text(){return this.input?this.input.value:""}readValue(){const c=this.text();if(c.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return c;const s=a(c);return s.ok?s.value:c}checkValue(c){if(this.props.allowInvalid===!0)return!0;const f=this.revalidate();return f.ok?!0:d(f)}toClipboard(){return this.text()}fromClipboard(c){const f=c==null?"":String(c);return this.input&&(this.input.value=f),this.revalidate(),f.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:f}:{ok:!0,value:B(f)}}destroy(){for(const c of this.#e)c();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const i=l}),Fe("packages/dom/src/editors/unit.js",function(e,K){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/columns/types/unit.js"),H=V.parseUnit,B=V.formatUnit,w=V.findUnit;function A(h,a){return B(h,a)}class g extends x{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.props,r=this.params.column&&this.params.column.dataType||null,t=r&&r.unitConfig||{};return{system:a.system||t.system||"data",unit:a.unit??t.unit,binary:a.binary===!0||a.binary===void 0&&t.binary===!0,display:a.display??t.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const a=this.props;this.opts=this.buildOptions();const r=this.symbol(),t=`${this.id}-unit`,n=$(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:a.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":r?t:null}});n.value=A(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(n.value=this.params.key),this.input=n;const o=typeof a.step=="number"?a.step:0;return o>0&&this.#e.push(_(n,"keydown",d=>{d.key==="ArrowUp"?(W(d.preventDefault)&&d.preventDefault(),this.nudge(o)):d.key==="ArrowDown"&&(W(d.preventDefault)&&d.preventDefault(),this.nudge(-o))})),this.hint=$(this.doc,"span",{class:`${z.editor}__suffix`,text:r,attrs:{id:t,"aria-hidden":"true"}}),$(this.doc,"div",{class:`${z.editor}__unit`,children:[n,this.hint]})}symbol(){const a=w(this.opts.system,this.opts.unit);return a?a.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const a=this.input;a&&!this.params.key&&this.props.selectOnFocus!==!1&&W(a.select)&&a.select()}nudge(a){const r=H(this.input?this.input.value:"",this.opts);let t=(r??0)+a;const{min:n,max:o}=this.props;typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=A(t,this.opts))}readValue(){const a=this.input?this.input.value:"";if(String(a).trim()==="")return null;const r=H(a,this.opts);if(r===null)return NaN;if(this.mode()!=="clamp")return r;const{min:t,max:n}=this.props;let o=r;return typeof t=="number"&&o<t&&(o=t),typeof n=="number"&&o>n&&(o=n),o}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a)){const r=this.symbol();return r?`Enter a value such as 10 ${r}`:"Enter a value"}if(this.mode()==="reject"){const{min:r,max:t}=this.props;if(typeof r=="number"&&a<r)return`Must be ${this.describe(r)} or more`;if(typeof t=="number"&&a>t)return`Must be ${this.describe(t)} or less`}return!0}describe(a){return B(a,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return B(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(a){const r=a==null?"":String(a);if(r.trim()==="")return{ok:!0,value:null};const t=H(r,this.opts),n=t===null?NaN:t,o=this.checkValue(n);return o!==!0?{ok:!1,message:o}:{ok:!0,value:n}}destroy(){for(const a of this.#e)a();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const u=g}),Fe("packages/dom/src/editors/radix.js",function(e,K){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,X=K("packages/core/src/internal/util.js"),W=X.isFunction,V=X.uid,H=K("packages/core/src/columns/types/radix.js"),B=H.compileRadixFormat,w=H.compileRadixParse,A=H.normaliseRadixOptions,g=H.radixRange,u=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),h=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),a=new Map;function r(d){const l=d||"";let i=a.get(l);if(i)return i;try{i=new Intl.NumberFormat(d||void 0,{maximumFractionDigits:0})}catch{i={format:m=>String(m)}}return a.set(l,i),i}function t(d,l){const i=l||{},m={};if(d){for(const f of h)d[f]!==void 0&&(m[f]=d[f]);const c=g(d.bitWidth??null,d.signed!==!1);typeof d.min=="number"&&d.min>c.min&&(m.min=d.min),typeof d.max=="number"&&d.max<c.max&&(m.max=d.max)}for(const c of h)i[c]!==void 0&&(m[c]=i[c]);return typeof i.min=="number"&&(m.min=i.min),typeof i.max=="number"&&(m.max=i.max),A(m)}class n extends x{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const l=this.params.column&&this.params.column.dataType;this.options=t(l&&l.radix||null,this.props),this.format=B(this.options),this.parse=w(this.options);const i=$(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});i.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(i.value=this.params.key),this.input=i;const m=$(this.doc,"span",{class:u.hint,attrs:{"aria-live":"polite"}});this.hint=m,this.#e.push(_(i,"input",()=>this.refresh())),this.#e.push(_(i,"keydown",f=>this.#n(f)));const c=$(this.doc,"div",{class:u.root,children:[i,m]});return this.refresh(),c}focusTarget(){return this.input}attached(){super.attached();const l=this.input;l&&!this.params.key&&this.props.selectOnFocus!==!1&&W(l.select)&&l.select()}#t(l){return l.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(l)}#n(l){const i=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;l.key==="ArrowUp"?(W(l.preventDefault)&&l.preventDefault(),this.nudge(i)):l.key==="ArrowDown"&&(W(l.preventDefault)&&l.preventDefault(),this.nudge(-i))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(l){const{min:i,max:m}=this.options;return l<i?i:l>m?m:l}evaluate(){const l=this.input?String(this.input.value):"";if(l.trim()==="")return{value:null,message:null};const i=this.parse(l);return i.ok?{value:this.mode()==="clamp"?this.clamp(i.value):i.value,message:null}:this.mode()==="clamp"&&typeof i.value=="number"&&(i.reason==="range"||i.reason==="negative")?{value:this.clamp(i.value),message:null}:{value:NaN,message:this.messageFor(i.reason)}}messageFor(l){const i=this.options;return l==="negative"?`This column holds an unsigned ${i.bitWidth}-bit pattern; enter ${this.format(0)} or more`:l==="range"?`Must be between ${this.format(i.min)} and ${this.format(i.max)}`:`Enter a ${i.name} value, e.g. ${this.format(i.radix===2?5:26)}`}refresh(){const{value:l,message:i}=this.evaluate();if(this.input&&this.input.classList&&(i?this.input.classList.add(z.invalid):this.input.classList.remove(z.invalid),this.input.setAttribute("aria-invalid",i?"true":"false"),i&&this.hint?(this.hint.id||(this.hint.id=V("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(i){this.hint.textContent=i,this.hint.classList&&this.hint.classList.add(u.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(u.hintInvalid),this.hint.textContent=l===null?"":`= ${r(this.params.locale).format(l)}`}}nudge(l){if(!this.input)return;const i=this.parse(this.input.value);let m;typeof i.value=="number"?m=i.value:typeof this.params.value=="number"?m=this.params.value:m=0,this.input.value=this.format(this.clamp(m+l)),this.refresh()}readValue(){return this.evaluate().value}checkValue(l){return l===null?!0:typeof l!="number"||Number.isNaN(l)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&l<0?this.messageFor("negative"):this.mode()==="reject"&&(l<this.options.min||l>this.options.max)?this.messageFor("range"):!0}toClipboard(){const l=this.readValue();return l===null||Number.isNaN(l)?this.input?String(this.input.value):"":this.format(l)}fromClipboard(l){const i=l==null?"":String(l);if(i.trim()==="")return{ok:!0,value:null};const m=this.parse(i);let c;if(m.ok)c=m.value;else if(this.mode()==="clamp"&&typeof m.value=="number"&&(m.reason==="range"||m.reason==="negative"))c=this.clamp(m.value);else return{ok:!1,message:this.messageFor(m.reason)};const f=this.checkValue(c);return f!==!0?{ok:!1,message:f}:{ok:!0,value:c}}destroy(){for(const l of this.#e)l();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const o=n}),Fe("packages/dom/src/editors/segmented.js",function(e,K){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,X=Q.keyOf,W=Q.normaliseLookup,V=Q.documentFor,H=Q.lookupFor,w=K("packages/dom/src/editors/select.js").SelectEditor,g=K("packages/core/src/internal/util.js").isFunction,h=K("packages/dom/src/cell/icons.js").createIcon,a=6;class r extends x{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(d){const l=d||{},i=t(l),m=H(l,i,{colId:l.column&&(l.column.id||l.column.field)}),c=Number(i.max??a),f=m.options().length;if(Number.isFinite(c)&&f>c){const s=new w;s.init(l),this.#e=s,this.params=l,this.doc=V(l),this.props=i,this.lookup=m,this.popup=s.popup;return}super.init(l),(!this.lookup||!this.lookup.options().length)&&(this.lookup=m)}usesFallback(){return this.#e!==null}build(){const d=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const l=$(d,"div",{class:`${z.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let i=0;i<this.options.length;i++)l.appendChild(this.buildSegment(this.options[i],i));return this.props.allowClear===!0&&l.appendChild(this.buildClear()),this.#t.push(_(l,"keydown",i=>this.onKeyDown(i))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),l}buildSegment(d,l){const i=this.doc,m=$(i,"button",{class:`${z.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":l,"data-variant":d.variant??null,"aria-disabled":d.disabled===!0?"true":null}});return d.icon&&m.appendChild(h(i,d.icon,{className:z.icon})),m.appendChild($(i,"span",{class:`${z.editor}__segment-label`,text:d.label})),this.#t.push(_(m,"mousedown",c=>{c&&g(c.preventDefault)&&c.preventDefault(),d.disabled!==!0&&(this.focused=l,this.select(l,{commit:!0}))})),this.segments.push(m),m}buildClear(){const d=$(this.doc,"button",{class:`${z.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(_(d,"mousedown",l=>{l&&g(l.preventDefault)&&l.preventDefault(),this.clearSelection()})),d}indexOf(d){if(d==null)return-1;const l=X(d);for(let i=0;i<this.options.length;i++)if(X(this.options[i].id)===l)return i;return-1}paint(){for(let d=0;d<this.segments.length;d++){const l=d===this.indexOf(this.selected),i=this.segments[d];i.setAttribute("aria-checked",l?"true":"false"),i.setAttribute("tabindex",d===this.focused?"0":"-1"),i.classList.toggle(`${z.editor}__segment--active`,l),i.classList.toggle(`${z.editor}__segment--disabled`,this.options[d].disabled===!0)}}select(d,l){const i=this.options[d];!i||i.disabled===!0||(this.selected=i.id,this.paint(),l&&l.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(d){const l=this.segments.length;if(!l)return;let i=this.focused;for(let m=0;m<l;m++)if(i=(i+d+l)%l,this.options[i].disabled!==!0){this.focusAt(i);return}}focusAt(d){if(d<0||d>=this.segments.length)return;this.focused=d,this.paint();const l=this.segments[d];l&&g(l.focus)&&l.focus()}edgeIndex(d){const l=this.options.length;for(let i=0;i<l;i++){const m=d===1?i:l-1-i;if(this.options[m].disabled!==!0)return m}return-1}onKeyDown(d){const l=()=>{g(d.preventDefault)&&d.preventDefault()};switch(d.key){case"ArrowRight":case"ArrowDown":l(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":l(),this.moveFocus(-1);break;case"Home":l(),this.focusAt(this.edgeIndex(1));break;case"End":l(),this.focusAt(this.edgeIndex(-1));break;case"Enter":l(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":l(),this.select(this.focused);break;case"Escape":l(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(d){return d==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(d)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(d)}" 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 d=this.indexOf(this.selected);return this.segments[d>=0?d:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const d=this.lookup.ready();!d||!g(d.then)||d.then(()=>{if(!super.element()||this.options.length)return;const l=super.element();this.options=this.lookup.options();for(let i=0;i<this.options.length;i++)l.appendChild(this.buildSegment(this.options[i],i));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(d){return this.#e?this.#e.validate(d):super.validate(d)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(d){return this.#e?this.#e.fromClipboard(d):super.fromClipboard(d)}destroy(){for(const d of this.#t)d();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function t(o){return{...o.column&&o.column.edit&&o.column.edit.props||{},...o.props||{}}}const n=r}),Fe("packages/dom/src/editors/rating.js",function(e,K){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,W=K("packages/dom/src/cell/icons.js").createIcon,V=K("packages/dom/src/cell/renderers/rating.js"),H=V.ratingFills,B=V.fillState,w=V.ratingText,A=V.clampRating,g=V.DEFAULT_RATING_ICON,u=V.DEFAULT_RATING_MAX,a=K("packages/core/src/internal/util.js").isFunction;class r extends x{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const d=Math.floor(Number(this.props.max??u));return Number.isFinite(d)&&d>0?d:u}step(){return this.props.allowHalf===!0?.5:1}build(){const d=this.doc,l=this.max();this.rating=t(this.params.value,l,this.props.allowHalf===!0);const i=$(d,"div",{class:`${z.editor}__rating`}),m=$(d,"div",{class:`${z.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(l),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let f=0;f<l;f++)m.appendChild(this.buildItem(f));i.appendChild(m),this.slider=m;const c=$(d,"span",{class:`${z.editor}__rating-value`});return i.appendChild(c),this.readout=c,this.props.allowClear===!0&&i.appendChild(this.buildClear()),this.#e.push(_(m,"keydown",f=>this.onKeyDown(f))),this.props.hoverPreview!==!1&&this.#e.push(_(m,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),l)),this.paint(),i}buildItem(d){const l=this.doc,i=String(this.props.icon??g),m=$(l,"span",{class:`${z.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[W(l,i,{className:z.icon})]}),c=$(l,"span",{class:`${z.editor}__rating-item`,attrs:{"data-index":d,"data-icon":i,"aria-hidden":"true"},children:[W(l,i,{className:z.icon}),m]});return this.fills.push(m),this.#e.push(_(c,"mousedown",f=>{f&&a(f.preventDefault)&&f.preventDefault(),this.setRating(this.ratingAt(d,f),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(_(c,"mousemove",f=>{const s=this.ratingAt(d,f);s!==this.preview&&(this.preview=s,this.paint())})),this.items.push(c),c}buildClear(){const d=$(this.doc,"button",{class:`${z.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(_(d,"mousedown",l=>{l&&a(l.preventDefault)&&l.preventDefault(),this.setRating(null)})),d}ratingAt(d,l){if(this.props.allowHalf!==!0)return d+1;const i=this.items[d],m=i&&Number(i.offsetWidth),c=l&&Number(l.offsetX);return!Number.isFinite(m)||m<=0||!Number.isFinite(c)?d+1:c*2<m?d+.5:d+1}focusTarget(){return this.slider}setRating(d,l){this.rating=d===null?null:A(d,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),l&&l.commit&&this.commit()}nudge(d){const l=this.rating===null?0:this.rating;this.setRating(l+d)}paint(){const d=this.max(),l=this.props.allowHalf===!0,i=this.preview===null?this.rating:this.preview,m=H(i===null?0:i,d,{allowHalf:l});for(let s=0;s<this.items.length;s++){const p=B(m[s]);this.items[s].setAttribute("data-fill",p),this.items[s].classList.toggle(`${z.editor}__rating-item--filled`,p!=="empty"),this.fills[s]&&this.fills[s].style.setProperty("--lat-rating-fill",`${(m[s]*100).toFixed(2)}%`)}const c=i===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:w(i),max:d}),f=this.slider;f&&(f.setAttribute("aria-valuenow",i===null?"0":String(i)),f.setAttribute("aria-valuetext",c),f.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=c)}onKeyDown(d){const l=()=>{a(d.preventDefault)&&d.preventDefault()},i=this.step();if(/^[0-9]$/.test(d.key)){l(),this.setRating(Math.min(Number(d.key),this.max()));return}switch(d.key){case"ArrowRight":case"ArrowUp":l(),this.nudge(i);break;case"ArrowLeft":case"ArrowDown":l(),this.nudge(-i);break;case"Home":l(),this.setRating(0);break;case"End":l(),this.setRating(this.max());break;case"Enter":l(),this.commit();break;case"Escape":l(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(d){if(d==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof d!="number"||!Number.isFinite(d))return"Enter a rating";const l=this.max();return d<0?"Must be 0 or more":d>l?`Must be ${l} or less`:this.props.allowHalf!==!0&&!Number.isInteger(d)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":w(this.rating)}fromClipboard(d){const l=String(d??"").trim();if(l==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const i=Number(l);if(!Number.isFinite(i))return{ok:!1,message:`"${l}" is not a rating`};const m=this.checkValue(i);return m!==!0?{ok:!1,message:m}:{ok:!0,value:i}}destroy(){for(const d of this.#e)d();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function t(o,d,l){if(o==null||o==="")return null;const i=Number(o);return Number.isFinite(i)?A(i,d,l,!1):null}const n=r}),Fe("packages/dom/src/editors/slider.js",function(e,K){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,X=K("packages/dom/src/editors/number.js"),W=X.parseNumberText,V=X.presentNumber,B=K("packages/core/src/internal/util.js").isFunction,w=0,A=100;class g extends x{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const n=Number(this.props.min??w);return Number.isFinite(n)?n:w}max(){const n=Number(this.props.max??A);return Number.isFinite(n)?n:A}step(){const n=Number(this.props.step??1);return Number.isFinite(n)&&n>0?n:1}build(){const n=this.doc,o=this.min(),d=this.max(),l=this.step(),i=a(this.props.marks);this.marks=i,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const m=$(n,"div",{class:`${z.editor}__slider`});this.root=m;const c=$(n,"input",{class:`${z.editor}__slider-input`,attrs:{type:"range",min:String(o),max:String(d),step:String(l),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:i.length?`${this.id}-marks`:null}});if(this.range=c,m.appendChild(c),i.length){const s=$(n,"datalist",{attrs:{id:`${this.id}-marks`}}),p=$(n,"div",{class:`${z.editor}__slider-marks`});for(const b of i){s.appendChild($(n,"option",{attrs:{value:String(b.value),label:b.label}}));const S=$(n,"span",{class:`${z.editor}__slider-mark`,text:b.label,attrs:{"data-value":String(b.value)}});S.style&&B(S.style.setProperty)&&S.style.setProperty("--lat-slider-mark",`${(u(b.value,o,d)*100).toFixed(2)}%`),p.appendChild(S)}m.appendChild(s),m.appendChild(p)}const f=$(n,"input",{class:`${z.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=f,m.appendChild(f),this.props.showValue!==!1){const s=$(n,"span",{class:`${z.editor}__slider-value`});m.appendChild(s),this.readout=s}return this.#e.push(_(c,"input",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"change",()=>this.setAmount(Number(c.value),"range"))),this.#e.push(_(c,"keydown",s=>this.onKeyDown(s))),this.#e.push(_(f,"input",()=>this.onFieldInput())),this.#e.push(_(f,"change",()=>this.paint())),this.#e.push(_(f,"keydown",s=>this.onKeyDown(s))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(f.value=this.params.key,this.onFieldInput()),this.paint(),m}focusTarget(){return this.field}attached(){super.attached();const n=this.field;n&&!this.params.key&&this.props.selectOnFocus!==!1&&B(n.select)&&n.select()}snap(n){if(!Number.isFinite(n))return this.min();const o=this.min(),d=this.max(),l=this.step(),i=Math.min(Math.max(n,o),d),m=o+Math.round((i-o)/l)*l,c=h(l),f=c>0?Number(m.toFixed(c)):Math.round(m);return Math.min(Math.max(f,o),d)}setAmount(n,o){this.amount=n===null?null:this.snap(n),this.paint(o)}onFieldInput(){const n=this.field?String(this.field.value):"";if(n.trim()===""){this.amount=null,this.paint("field");return}const o=W(n,this.params.locale);if(o===null||Number.isNaN(o)){this.paint("field");return}this.setAmount(o,"field")}paint(n){const o=this.min(),d=this.max(),l=this.amount,i=l===null?o:l;this.range&&n!=="range"&&(this.range.value=String(i)),this.field&&n!=="field"&&(this.field.value=l===null?"":V(l,this.props));const m=this.root;m&&m.style&&B(m.style.setProperty)&&m.style.setProperty("--lat-slider-pos",`${(u(i,o,d)*100).toFixed(2)}%`),m&&m.setAttribute&&m.setAttribute("data-empty",l===null?"true":"false");const c=this.labelFor(l);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",c),this.readout&&(this.readout.textContent=c)}labelFor(n){if(n===null)return String(this.props.emptyLabel??"");const o=this.marks.find(l=>l.value===n),d=V(n,this.props);return o&&o.label!==d?`${d} (${o.label})`:d}onKeyDown(n){if(n.key==="Escape"){B(n.preventDefault)&&n.preventDefault(),this.cancel();return}if(n.key==="Enter"){B(n.preventDefault)&&n.preventDefault(),this.commit();return}n.key==="Tab"&&this.commit()}readValue(){const n=this.field?String(this.field.value):"";if(n.trim()==="")return null;const o=W(n,this.params.locale);return o===null||Number.isNaN(o)?NaN:this.snap(o)}checkValue(n){return n==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof n!="number"||Number.isNaN(n)?"Enter a number":n<this.min()?`Must be ${this.min()} or more`:n>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(n){const o=String(n??"").trim();if(o==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const d=W(o,this.params.locale);if(d===null||Number.isNaN(d))return{ok:!1,message:"Enter a number"};const l=this.snap(d),i=this.checkValue(l);return i!==!0?{ok:!1,message:i}:{ok:!0,value:l}}destroy(){for(const n of this.#e)n();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function u(t,n,o){const d=o-n;return!Number.isFinite(d)||d===0?0:Math.min(1,Math.max(0,(Number(t)-n)/d))}function h(t){if(!Number.isFinite(t))return 0;const n=String(t),o=n.indexOf("e");if(o>=0){const l=n.slice(0,o),i=l.indexOf("."),m=i<0?0:l.length-i-1;return Math.min(15,Math.max(0,m-Number(n.slice(o+1))))}const d=n.indexOf(".");return d<0?0:Math.min(15,n.length-d-1)}function a(t){if(!t)return[];const n=[];if(Array.isArray(t)){for(const o of t){if(o&&typeof o=="object"){const l=Number(o.value);Number.isFinite(l)&&n.push({value:l,label:String(o.label??l)});continue}const d=Number(o);Number.isFinite(d)&&n.push({value:d,label:String(d)})}return n}if(typeof t=="object")for(const[o,d]of Object.entries(t)){const l=Number(o);Number.isFinite(l)&&n.push({value:l,label:String(d)})}return n}const r=g}),Fe("packages/dom/src/editors/colour.js",function(e,K){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,X=K("packages/dom/src/cell/renderers/colour.js"),W=X.normaliseColour,V=X.parseColour,B=K("packages/core/src/internal/util.js").isFunction,w=Object.freeze(["neutral","info","success","warning","danger","accent"]),A=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function g(n){if(n==null)return null;if(typeof n=="object"){const l=n,i=g(l.token??l.value??l.colour??l.color);return i?{...i,label:l.label==null?i.label:String(l.label)}:null}const o=String(n).trim();if(o==="")return null;const d=W(o);return d?{token:null,hex:d,label:d}:Object.hasOwn(A,o)?{token:o,hex:A[o],label:o}:null}function u(n,o){const d=n&&n.ownerDocument,l=d&&d.defaultView;if(!l||!B(l.getComputedStyle))return null;try{const i=l.getComputedStyle(n);return!i||!B(i.getPropertyValue)?null:W(String(i.getPropertyValue(`--lattice-variant-${o}-solid`)).trim())}catch{return null}}class h extends x{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=a(this.props.swatches);const d=$(o,"div",{class:`${z.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=$(o,"span",{class:`${z.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),d.appendChild(this.preview),this.swatches.length){const i=$(o,"div",{class:`${z.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let m=0;m<this.swatches.length;m++)i.appendChild(this.buildSwatch(this.swatches[m],m));d.appendChild(i)}this.native=$(o,"input",{class:`${z.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),d.appendChild(this.native),this.hex=$(o,"input",{class:`${z.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),d.appendChild(this.hex),this.props.allowClear===!0&&d.appendChild(this.buildClear()),this.#e.push(_(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(_(this.hex,"input",()=>this.paint())),this.#e.push(_(this.hex,"change",()=>this.paint())),this.#e.push(_(this.hex,"keydown",i=>this.onKeyDown(i))),this.#e.push(_(d,"keydown",i=>this.onKeyDown(i)));const l=W(this.params.value,{alpha:this.alpha()});return this.hex.value=l===null?this.params.value==null?"":String(this.params.value):l,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),d}buildSwatch(o,d){const l=$(this.doc,"button",{class:`${z.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":o.label,"data-index":d,"data-variant":o.token}});return o.token||r(l,o.hex),this.#e.push(_(l,"mousedown",i=>{i&&B(i.preventDefault)&&i.preventDefault(),this.setColour(this.swatches[d].hex)})),this.buttons.push(l),l}buildClear(){const o=$(this.doc,"button",{class:`${z.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(_(o,"mousedown",d=>{d&&B(d.preventDefault)&&d.preventDefault(),this.setColour(null)})),o}focusTarget(){return this.hex}attached(){super.attached();for(let o=0;o<this.swatches.length;o++){const d=this.swatches[o];if(!d.token)continue;const l=u(this.buttons[o]||this.element(),d.token);l&&(d.hex=l)}this.paint()}setColour(o){const d=o===null?null:W(o,{alpha:this.alpha()});this.hex&&(this.hex.value=d===null?"":d),this.paint()}current(){const o=this.hex?String(this.hex.value).trim():"";return o===""?null:W(o,{alpha:this.alpha()})}paint(){const o=this.current(),d=o===null?null:o.slice(0,7);r(this.preview,d),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",o===null?"true":"false"),this.native&&(this.native.value=d===null?"#000000":d);for(let l=0;l<this.buttons.length;l++){const i=o!==null&&this.swatches[l].hex.toLowerCase()===o.toLowerCase();this.buttons[l].setAttribute("aria-checked",i?"true":"false"),this.buttons[l].classList.toggle(`${z.editor}__colour-swatch--selected`,i),this.swatches[l].token||r(this.buttons[l],this.swatches[l].hex)}}onKeyDown(o){if(o.key==="Escape"){B(o.preventDefault)&&o.preventDefault(),this.cancel();return}if(o.key==="Enter"){B(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 d=W(o,{alpha:this.alpha()});return d===null?o:d}checkValue(o){if(o==null||o==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const d=V(o);return d?!this.alpha()&&d.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 d=String(o??"").trim();if(d==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const l=W(d,{alpha:this.alpha()});if(l===null)return{ok:!1,message:`"${d}" is not a colour`};const i=this.checkValue(l);return i!==!0?{ok:!1,message:i}:{ok:!0,value:l}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function a(n){const o=Array.isArray(n)&&n.length?n:n===!1?[]:w,d=[];for(const l of o){const i=g(l);i&&d.push(i)}return d}function r(n,o){const d=n&&n.style;if(d){if(o===null){B(d.removeProperty)&&d.removeProperty("--lat-swatch");return}B(d.setProperty)&&d.setProperty("--lat-swatch",o)}}const t=h}),Fe("packages/dom/src/editors/treeselect.js",function(e,K){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const x=K("packages/dom/src/editors/select.js").SelectEditorBase,$=K("packages/dom/src/cell/icons.js").createIcon,_=K("packages/dom/src/editors/common.js"),X=_.CLS,W=_.el,V=_.on,H=_.clear,B=_.keyOf,w=_.rawOptions,A=_.lookupKey,g=K("packages/core/src/internal/util.js"),u=g.isFunction,h=g.isObject,a="\0";class r extends x{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 d=o.parent;d;d=d.parent)this.expanded.add(d.key)}rebuild(){const o=w(this.params,this.props),d=this.props.keys||{},l=d.value||A(this.params,"valueKey")||"id",i=d.label||A(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const m of o){if(!h(m)){this.addNode(null,String(m??""),m,null);continue}Array.isArray(m.path)&&m.path.length?this.addByPath(m,l,i):this.addByChildren(m,null,l,i)}if(this.props.defaultExpanded===!0)for(const m of this.nodes.keys())this.expanded.add(m)}addNode(o,d,l,i){const m=o?`${o.key}${a}${d}`:d;let c=this.nodes.get(m);return c?c.id===void 0&&l!==void 0&&(c.id=l):(c={id:l,label:d,key:m,parent:o,children:[],depth:o?o.depth+1:0,disabled:!1},this.nodes.set(m,c),(o?o.children:this.roots).push(c)),i&&(i.disabled===!0&&(c.disabled=!0),i.icon!==void 0&&(c.icon=i.icon),i.variant!==void 0&&(c.variant=i.variant)),c}addByPath(o,d,l){const i=o.path;let m=null;for(let c=0;c<i.length;c++){const f=c===i.length-1,s=String(i[c]),p=f&&o[l]!=null?String(o[l]):s,b=this.addNode(m,s,f?o[d]:void 0,f?o:null);f&&(b.label=p),m=b}}addByChildren(o,d,l,i){const m=o[l],c=o[i]!=null?String(o[i]):String(m??""),f=this.addNode(d,c,m,o),s=Array.isArray(o.children)?o.children:[];for(const p of s)h(p)?this.addByChildren(p,f,l,i):this.addNode(f,String(p??""),p,null)}nodeById(o){if(o==null)return;const d=B(o);for(const l of this.nodes.values())if(l.id!==void 0&&B(l.id)===d)return l}filterOptions(o){const d=String(o||"").trim().toLowerCase(),l=d!=="";this.matched=l?this.computeMatches(d):new Set;const i=[],m=c=>{for(const f of c)l&&!this.matched.has(f.key)||(i.push(f),f.children.length&&(l||this.expanded.has(f.key))&&m(f.children))};return m(this.roots),i}computeMatches(o){const d=new Set,l=i=>{let m=i.label.toLowerCase().includes(o);for(const c of i.children)l(c)&&(m=!0);return m&&d.add(i.key),m};for(const i of this.roots)l(i);return d}repaint(o){if(this.refreshOptions(),!o||!this.list)return;const d=this.visible.findIndex(l=>l.key===o);d>=0&&this.list.setActive(d)}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,d){this.isBranch(o)&&(d?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&&B(o.id)===B(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 d=this.nodeById(o);return d&&this.isSelectable(d)?!0:d?`"${d.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,d,l){H(d),d.setAttribute("role","treeitem"),d.setAttribute("aria-level",String(o.depth+1)),d.setAttribute("data-depth",String(o.depth));const i=W(this.doc,"span",{class:"lat-tree__indent"});for(let b=0;b<o.depth;b++)i.appendChild(W(this.doc,"span",{class:"lat-tree__guide"}));d.appendChild(i);const m=this.isBranch(o),c=m&&(this.expanded.has(o.key)||this.query.trim()!==""),f=m?c?"chevronDown":"chevronRight":"blank",s=W(this.doc,"span",{class:m?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[$(this.doc,f,{className:X.icon})],attrs:{"data-icon":m?f:null,"aria-hidden":"true"}});m&&V(s,"mousedown",b=>{u(b.preventDefault)&&b.preventDefault(),u(b.stopPropagation)&&b.stopPropagation(),this.setExpanded(o,!this.expanded.has(o.key))}),d.appendChild(s),o.icon&&d.appendChild($(this.doc,o.icon,{className:X.icon})),d.appendChild(W(this.doc,"span",{class:`${X.option}__label`,text:o.label})),o.variant?d.setAttribute("data-variant",o.variant):d.removeAttribute("data-variant"),m?d.setAttribute("aria-expanded",c?"true":"false"):d.removeAttribute("aria-expanded");const p=this.isSelected(o);d.classList.toggle(X.optionSelected,p),d.classList.toggle(X.optionDisabled,!this.isSelectable(o)),d.classList.toggle("lat-tree__row--branch",m),d.setAttribute("aria-selected",p?"true":"false"),this.isSelectable(o)?d.removeAttribute("aria-disabled"):d.setAttribute("aria-disabled","true")}paintDisplay(){const o=this.display;if(!o)return;if(H(o),this.selected==null){o.removeAttribute("data-variant");return}const d=this.nodeById(this.selected);if(!d){o.appendChild(W(this.doc,"span",{text:String(this.selected)}));return}d.icon&&o.appendChild($(this.doc,d.icon,{className:X.icon})),o.appendChild(W(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(d)})),d.variant?o.setAttribute("data-variant",d.variant):o.removeAttribute("data-variant")}pathLabel(o){const d=[];for(let l=o;l;l=l.parent)d.unshift(l.label);return d.join(String(this.props.pathSeparator??" / "))}onKeyDown(o){const d=this.list,l=d&&d.active>=0?this.visible[d.active]:null;switch(o.key){case"ArrowRight":{if(u(o.preventDefault)&&o.preventDefault(),!l)return;this.isBranch(l)&&!this.expanded.has(l.key)?this.setExpanded(l,!0):this.isBranch(l)&&d&&d.setActive(Math.min(this.visible.length-1,d.active+1));return}case"ArrowLeft":{if(u(o.preventDefault)&&o.preventDefault(),!l)return;this.isBranch(l)&&this.expanded.has(l.key)?this.setExpanded(l,!1):l.parent&&this.focusNode(l.parent.key);return}case"Home":u(o.preventDefault)&&o.preventDefault(),d&&this.visible.length&&d.setActive(0);return;case"End":u(o.preventDefault)&&o.preventDefault(),d&&this.visible.length&&d.setActive(this.visible.length-1);return;default:super.onKeyDown(o)}}focusNode(o){if(!this.list)return;const d=this.visible.findIndex(l=>l.key===o);d>=0&&this.list.setActive(d)}acceptHighlight(o){const d=this.list,l=d&&d.active>=0?this.visible[d.active]:null;if(!l){o&&o.commit&&this.commit();return}if(this.isSelectable(l)){this.choose(l);return}this.isBranch(l)?this.setExpanded(l,!this.expanded.has(l.key)):o&&o.commit&&this.commit()}moveHighlight(o){const d=this.list;if(!d)return;let l=d.active;for(let i=0;i<this.visible.length;i++){if(l+=o,l<0||l>=this.visible.length)return;if(!this.visible[l].disabled){d.setActive(l);return}}}}const t=r}),Fe("packages/dom/src/editors/objectpicker.js",function(e,K){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const x=K("packages/dom/src/editors/select.js").SelectEditorBase,z=K("packages/dom/src/editors/common.js"),$=z.CLS,_=z.el,X=z.on,W=z.clear,V=z.keyOf,H=z.debounce,B=z.rawOptions,w=z.optionSource,A=z.lookupSearch,g=z.lookupKey,u=K("packages/core/src/internal/util.js"),h=u.isFunction,a=u.isObject,r=u.getPath,n=K("packages/dom/src/cell/icons.js").createIcon;class o extends x{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const f=super.build();if(f.classList.add("lat-objectpicker"),h(this.props.search)&&!(this.lookup&&this.lookup.search)){const s=Number(this.props.searchDebounce)||200;this.#n=H(p=>this.runRemoteSearch(String(p)),s)}return f}onQuery(f){super.onQuery(f),this.#n&&this.#n(f)}initSelection(){const f=B(this.params,this.props).map(s=>this.toOption(s));(f.length||!this.all.length)&&(this.all=f),this.selected=this.params.value??null}toOption(f){if(!a(f)){const y=f==null?"":String(f);return{id:f,label:y,secondary:"",avatar:"",initials:l(y),disabled:!1,raw:{}}}const s=this.props.valueKey||g(this.params,"valueKey")||"id",p=this.props.labelKey||g(this.params,"labelKey")||"label",b=d(f,this.props.template??p,""),S=d(f,this.props.secondary,""),j=d(f,this.props.avatar,"");return{id:f[s],label:b||String(f[s]??""),secondary:S,avatar:j,initials:l(b||String(f[s]??"")),disabled:f.disabled===!0,icon:f.icon,variant:f.variant,raw:f}}attached(){if(super.attached(),this.#t||this.all.length)return;const f=w(this.params,this.props);h(f)&&(this.#t=!0,Promise.resolve(f()).then(s=>{!this.element()||!Array.isArray(s)||(this.all=s.map(p=>this.toOption(p)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(f){const s=String(f||"").trim().toLowerCase();if(s==="")return this.all;const p=i(this.props.searchFields);return this.all.filter(b=>{if(!p)return b.label.toLowerCase().includes(s)||b.secondary.toLowerCase().includes(s);for(const S of p){const j=h(S)?S(b.raw):r(b.raw,S);if(j!=null&&String(j).toLowerCase().includes(s))return!0}return!1})}async runRemoteSearch(f){const s=A(this.params,this.props);if(!s)return;this.#e&&this.#e.abort();const p=new AbortController;this.#e=p;try{const b=await s(f,p.signal);if(p.signal.aborted||this.#e!==p)return;this.refreshOptions(Array.isArray(b)?b.map(S=>this.toOption(S)):[])}catch(b){if(!p.signal.aborted)throw b}finally{this.#e===p&&(this.#e=null)}}choose(f){!f||f.disabled||(this.selected=f.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(f){return this.selected!=null&&f!=null&&V(f.id)===V(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(f){if(f==null)return;const s=V(f);return this.all.find(p=>V(p.id)===s)}checkValue(f){return f==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.all.length||this.optionById(f)||this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(f)}" is not a valid option`}renderOption(f,s,p){W(s),s.appendChild(this.buildAvatar(f));const b=_(this.doc,"span",{class:"lat-object__text"});b.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:f.label})),f.secondary&&b.appendChild(_(this.doc,"span",{class:"lat-object__secondary",text:f.secondary})),s.appendChild(b),f.icon&&s.appendChild(n(this.doc,f.icon,{className:$.icon})),f.variant?s.setAttribute("data-variant",f.variant):s.removeAttribute("data-variant");const S=this.isSelected(f);s.classList.add("lat-object__row"),s.classList.toggle($.optionSelected,S),s.classList.toggle($.optionDisabled,f.disabled===!0),s.setAttribute("aria-selected",S?"true":"false"),f.disabled?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled")}buildAvatar(f){const s=_(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!f.avatar)return s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:f.initials})),s.setAttribute("data-fallback","initials"),s;const p=_(this.doc,"img",{class:"lat-avatar__image",attrs:{src:f.avatar,alt:"",loading:"lazy",decoding:"async"}});return X(p,"error",()=>{p.parentNode===s&&(s.removeChild(p),s.appendChild(_(this.doc,"span",{class:"lat-avatar__initials",text:f.initials})),s.setAttribute("data-fallback","initials"))}),s.appendChild(p),s}paintDisplay(){const f=this.display;if(!f)return;if(W(f),this.selected==null){f.removeAttribute("data-variant");return}const s=this.optionById(this.selected);if(!s){f.appendChild(_(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}f.appendChild(this.buildAvatar(s)),f.appendChild(_(this.doc,"span",{class:"lat-object__primary",text:s.label})),s.variant?f.setAttribute("data-variant",s.variant):f.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 d(c,f,s){if(f==null)return s;const p=h(f)?f(c):r(c,String(f));return p==null?s:String(p)}function l(c){const f=String(c||"").trim().split(/\s+/).filter(b=>b!=="");if(!f.length)return"";const s=[...f[0]][0]||"";if(f.length===1)return s.toUpperCase();const p=[...f[f.length-1]][0]||"";return(s+p).toUpperCase()}function i(c){if(c==null)return null;const s=(Array.isArray(c)?c:[c]).filter(p=>typeof p=="string"||h(p));return s.length?s:null}const m=o}),Fe("packages/dom/src/editors/iconpicker.js",function(e,K){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.VirtualList,_=Q.el,X=Q.on,W=Q.clear,V=K("packages/dom/src/cell/icons.js"),H=V.createIcon,B=V.iconNames,A=K("packages/core/src/internal/util.js").isFunction;class g extends x{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const r=this.props;this.columns=Math.max(1,Math.floor(Number(r.columns)||8)),this.names=u(r.icons),this.selected=this.params.value==null?null:String(this.params.value);const t=_(this.doc,"div",{class:["lat-iconpicker",`${z.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=_(this.doc,"div",{class:`${z.editor}__display`}),this.input=_(this.doc,"input",{class:z.input,attrs:{type:"text",autocomplete:"off",placeholder:r.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new $({document:this.doc,itemHeight:Number(r.rowHeight)||34,height:Number(r.listHeight)||204,renderItem:(n,o,d)=>this.renderRow(n,o,d)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),t.appendChild(this.display),t.appendChild(this.input),r.allowClear===!0&&t.appendChild(this.buildClearButton()),t.appendChild(this.list.element()),this.off.push(X(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(X(this.input,"keydown",n=>this.onKeyDown(n))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),t}buildClearButton(){const r=_(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(X(r,"mousedown",t=>{A(t.preventDefault)&&t.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),r}focusTarget(){return this.input}onQuery(r){this.query=r,this.refreshIcons()}refreshIcons(){const r=this.query.trim().toLowerCase();this.matches=r===""?this.names.slice():this.names.filter(n=>n.toLowerCase().includes(r)),this.rows=[];for(let n=0;n<this.matches.length;n+=this.columns)this.rows.push(this.matches.slice(n,n+this.columns));const t=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=t>=0?t:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(r){return r<0?-1:Math.floor(r/this.columns)}moveCursor(r){if(!this.matches.length)return-1;const t=Math.max(0,Math.min(this.matches.length-1,this.cursor+r));return this.setCursor(t)}setCursor(r){return this.cursor=r,this.list&&this.list.setActive(this.rowOf(r)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(r,t,n){t.setAttribute("role","row"),t.classList.add("lat-iconpicker__row");let o=t.__latIconCells;if(!o){o=[],W(t);for(let d=0;d<this.columns;d++){const l=_(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});X(l,"mousedown",i=>{A(i.preventDefault)&&i.preventDefault();const m=l.getAttribute("data-icon");m&&this.choose(m)}),t.appendChild(l),o.push(l)}t.__latIconCells=o}for(let d=0;d<o.length;d++){const l=o[d],i=r[d];if(i===void 0){l.setAttribute("aria-hidden","true"),l.removeAttribute("data-icon"),l.removeAttribute("title"),l.removeAttribute("aria-label"),l.classList.add("lat-iconpicker__cell--empty"),l.classList.remove("lat-iconpicker__cell--active"),l.classList.remove("lat-iconpicker__cell--selected"),l.__latIconName!==void 0&&(W(l),l.__latIconName=void 0);continue}const m=n*this.columns+d;l.removeAttribute("aria-hidden"),l.classList.remove("lat-iconpicker__cell--empty"),l.setAttribute("data-icon",i),l.setAttribute("title",i),l.setAttribute("aria-label",i),l.__latIconName!==i&&(W(l),l.appendChild(H(this.doc,i,{className:z.icon})),l.__latIconName=i);const c=this.selected===i;l.classList.toggle("lat-iconpicker__cell--active",m===this.cursor),l.classList.toggle("lat-iconpicker__cell--selected",c),l.setAttribute("aria-selected",c?"true":"false")}}paintDisplay(){const r=this.display;if(r){if(W(r),this.selected==null){r.appendChild(_(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}r.appendChild(H(this.doc,this.selected,{className:z.icon})),r.appendChild(_(this.doc,"span",{text:this.selected}))}}choose(r){this.selected=r;const t=this.matches.indexOf(r);t>=0&&(this.cursor=t),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(r){return r==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(r))?!0:`"${String(r)}" is not a known icon name`}onKeyDown(r){const t=()=>{A(r.preventDefault)&&r.preventDefault()};switch(r.key){case"ArrowRight":t(),this.moveCursor(1);return;case"ArrowLeft":t(),this.moveCursor(-1);return;case"ArrowDown":t(),this.moveCursor(this.columns);return;case"ArrowUp":t(),this.moveCursor(-this.columns);return;case"PageDown":t(),this.moveCursor(this.columns*5);return;case"PageUp":t(),this.moveCursor(-this.columns*5);return;case"Home":t(),this.setCursor(this.matches.length?0:-1);return;case"End":t(),this.setCursor(this.matches.length-1);return;case"Enter":{t();const n=this.cursorName();n&&this.choose(n);return}case"Escape":t(),this.cancel();return;case"Tab":{const n=this.cursorName();n&&(this.selected=n),this.commit();return}default:break}}destroy(){for(const r of this.off)r();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function u(a){const r=B();if(Array.isArray(a)&&a.length){const t=new Set(r);return a.map(n=>String(n)).filter(n=>t.has(n))}return r.filter(t=>t!=="blank")}const h=g}),Fe("packages/dom/src/editors/temperature.js",function(e,K){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/columns/types/temperature.js"),H=V.formatTemperature,B=V.parseTemperature,w=V.findScale;function A(h,a){return H(h,{...a,decimals:void 0,minDecimals:0,maxDecimals:20})}class g extends x{input=null;hint=null;opts=null;#e=[];buildOptions(){const a=this.params.column&&this.params.column.dataType||null,r=a&&a.temperatureConfig||{};return{scale:this.props.scale||r.scale||"C",locale:this.params.locale}}build(){const a=this.props;this.opts=this.buildOptions();const r=w(this.opts.scale),t=r?r.scale.symbol:"",n=`${this.id}-scale`,o=$(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:a.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?n:null}});o.value=A(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(o.value=this.params.key),this.input=o;const d=typeof a.step=="number"?a.step:0;return d>0&&this.#e.push(_(o,"keydown",l=>{l.key==="ArrowUp"?(W(l.preventDefault)&&l.preventDefault(),this.nudge(d)):l.key==="ArrowDown"&&(W(l.preventDefault)&&l.preventDefault(),this.nudge(-d))})),this.hint=$(this.doc,"span",{class:`${z.editor}__suffix`,text:t,attrs:{id:n,"aria-hidden":"true"}}),$(this.doc,"div",{class:`${z.editor}__unit`,children:[o,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const a=this.input;a&&!this.params.key&&this.props.selectOnFocus!==!1&&W(a.select)&&a.select()}nudge(a){const r=B(this.input?this.input.value:"",this.opts);let t=(r??0)+a;const{min:n,max:o}=this.props;typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),this.input&&(this.input.value=A(t,this.opts))}readValue(){const a=this.input?String(this.input.value).trim():"";if(a==="")return null;const r=B(a,this.opts);return r===null?Number.NaN:r}checkValue(a){if(a===null)return!0;if(typeof a!="number"||Number.isNaN(a))return"Enter a temperature";const{min:r,max:t}=this.props;return typeof r=="number"&&a<r?`Must be ${r} or more`:typeof t=="number"&&a>t?`Must be ${t} or less`:!0}destroy(){for(const a of this.#e)a();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const u=g}),Fe("packages/dom/src/editors/currency.js",function(e,K){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.BaseEditor,z=Q.CLS,$=Q.el,_=Q.on,W=K("packages/core/src/internal/util.js").isFunction,V=K("packages/core/src/columns/types/currency.js"),H=V.parseMoney,B=V.toMoney,w=V.normaliseCode,A=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function g(a){const r=B(a);return r?String(r.amount):""}class u extends x{input=null;picker=null;opts=null;#e=[];buildOptions(){const r=this.params.column&&this.params.column.dataType||null,t=r&&r.currencyConfig||{},n=B(this.params.value),o=w(this.props.code)||n&&n.code||w(t.code)||"USD";let d=this.props.codes||t.codes||A;return d=d.map(l=>w(l)).filter(Boolean),d.includes(o)||(d=[o,...d]),{code:o,codes:d,locale:this.params.locale}}build(){const r=this.props;this.opts=this.buildOptions();const t=$(this.doc,"input",{class:z.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:r.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});t.value=g(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(t.value=this.params.key),this.input=t;const n=$(this.doc,"select",{class:`${z.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const o of this.opts.codes){const d=$(this.doc,"option",{text:o,attrs:{value:o}});o===this.opts.code&&(d.selected=!0),n.appendChild(d)}return this.picker=n,$(this.doc,"div",{class:`${z.editor}__unit`,children:[t,n]})}focusTarget(){return this.input}attached(){super.attached();const r=this.input;r&&!this.params.key&&this.props.selectOnFocus!==!1&&W(r.select)&&r.select()}readValue(){const r=this.input?String(this.input.value).trim():"";if(r==="")return null;const t=this.picker?this.picker.value:this.opts.code,n=H(r,{...this.opts,code:t});return n===null?Number.NaN:n}checkValue(r){if(r===null)return!0;if(!r||typeof r!="object"||!Number.isFinite(r.amount))return"Enter an amount";const t=r.amount,{min:n,max:o}=this.props;return typeof n=="number"&&t<n?`Must be ${n} or more`:typeof o=="number"&&t>o?`Must be ${o} or less`:!0}destroy(){for(const r of this.#e)r();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const h=u}),Fe("packages/dom/src/editors/index.js",function(e,K){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return he}});const x=K("packages/dom/src/editors/text.js").TextEditor,$=K("packages/dom/src/editors/textarea.js").TextareaEditor,X=K("packages/dom/src/editors/number.js").NumberEditor,V=K("packages/dom/src/editors/date.js").DateEditor,B=K("packages/dom/src/editors/checkbox.js").CheckboxEditor,A=K("packages/dom/src/editors/select.js").SelectEditor,u=K("packages/dom/src/editors/multiselect.js").MultiSelectEditor,a=K("packages/dom/src/editors/time.js").TimeEditor,t=K("packages/dom/src/editors/datetime.js").DateTimeEditor,o=K("packages/dom/src/editors/duration.js").DurationEditor,l=K("packages/dom/src/editors/ipaddress.js").IpAddressEditor,m=K("packages/dom/src/editors/password.js").PasswordEditor,f=K("packages/dom/src/editors/code.js").CodeEditor,p=K("packages/dom/src/editors/unit.js").UnitEditor,S=K("packages/dom/src/editors/radix.js").RadixEditor,y=K("packages/dom/src/editors/segmented.js").SegmentedEditor,R=K("packages/dom/src/editors/rating.js").RatingEditor,F=K("packages/dom/src/editors/slider.js").SliderEditor,T=K("packages/dom/src/editors/colour.js").ColourEditor,E=K("packages/dom/src/editors/treeselect.js").TreeSelectEditor,I=K("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,k=K("packages/dom/src/editors/iconpicker.js").IconPickerEditor,G=K("packages/dom/src/editors/temperature.js").TemperatureEditor,Y=K("packages/dom/src/editors/currency.js").CurrencyEditor,J=K("packages/core/src/internal/util.js"),ee=J.isCtor,re=J.isFunction,ie=J.warnOnce,ae=K("packages/dom/src/editors/common.js");for(const de of Object.keys(ae))de!=="default"&&Object.defineProperty(e,de,{enumerable:!0,get:function(){return ae[de]}});const fe=Object.freeze({text:x,textarea:$,number:X,date:V,checkbox:B,select:A,multiSelect:u,temperature:G,currency:Y,time:a,datetime:t,duration:o,ipaddress:l,password:m,code:f,unit:p,radix:S,slider:F,rating:R,segmented:y,treeSelect:E,objectPicker:I,iconPicker:k,colour:T}),ce=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function te(de,be){const Te=de&&de.edit&&de.edit.editor,Ae=be&&be.editors||{},Ce=!!(de&&de.lookup&&de.lookup.multiple);if(ee(Te)||re(Te))return Te;if(typeof Te=="string"){if(Ce&&Te==="select")return u;const ge=Ae[Te]||fe[Te];if(ge)return ge;ie(`editor:missing:${Te}`,`unknown editor "${Te}"; falling back to the data type default`)}const me=de&&de.type||"text";if(me==="lookup"||de&&de.lookup)return Ce?u:A;const we=ce[me];return we&&(Ae[we]||fe[we])||null}function oe(de,be){const Te=te(de.column||{},be);if(!Te)return null;const Ae=new Te;return Ae.init(de),re(Ae.cancelBeforeStart)&&Ae.cancelBeforeStart()===!0?(re(Ae.destroy)&&Ae.destroy(),null):Ae}const he=fe}),Fe("packages/dom/src/ui/statusbar.js",function(e,K){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return m}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.documentFor,$=Q.el,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction;function B(c){let f=0,s=0,p=0,b=null,S=null;for(const j of c||[]){if(j==null||j==="")continue;f++;const y=typeof j=="number"?j:Number(j);Number.isFinite(y)&&(s++,p+=y,(b===null||y<b)&&(b=y),(S===null||y>S)&&(S=y))}return{count:f,numericCount:s,sum:s?p:null,min:b,max:S,avg:s?p/s:null}}class w{root=null;valueNode=null;init(f){this.ctx=f,this.doc=f.document,this.root=$(this.doc,"div",{class:`${x.statusBar}__panel`,attrs:{"data-align":f.align||"end"}}),f.label&&this.root.appendChild($(this.doc,"span",{class:`${x.statusBar}__label`,text:f.label})),this.valueNode=$(this.doc,"span",{class:`${x.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(f,s){const p=this.ctx&&this.ctx.messages;return(p&&H(p.t)?p:W).t(f,s)}element(){return this.root}refresh(){const f=this.read();this.valueNode&&this.valueNode.textContent!==f&&(this.valueNode.textContent=f)}read(){return""}destroy(){this.root=null,this.valueNode=null}}class A extends w{read(){const f=this.ctx.host||{},s=H(f.totalRowCount)?f.totalRowCount():0,p=H(f.loadError)?f.loadError():null;if(p)return p;if(s==null)return this.t("status.counting");const b=H(f.rowCount)?f.rowCount():s;if(b==null)return p||this.t("status.counting");const S=this.ctx.noun,j=y=>S===void 0?this.t("count.rows",{count:y}):`${d(y,this.ctx.locale)}${S?` ${S}`:""}`;return b===s?this.t("status.total",{rows:j(s)}):this.t("status.shownOfTotal",{shown:d(b,this.ctx.locale),total:j(s)})}}class g extends w{read(){const f=this.ctx.host||{},s=H(f.selectedAcrossSource)?f.selectedAcrossSource():null;if(s)return typeof s.count=="number"?this.t("status.selectedAcrossSource",{count:s.count}):this.t("status.selectedAcrossSourceCounting");const p=H(f.selectedCount)?f.selectedCount():0;return p?this.t("status.selected",{count:p}):""}}class u extends w{read(){const f=this.ctx.host||{},s=H(f.rangeValues)?f.rangeValues():[],p=B(s);if(!p.count)return"";const b=this.ctx.stats||["count","sum","min","max","avg"],S=[];for(const j of b){if(j==="count"){S.push(this.t("status.count",{count:p.count}));continue}const y=p[j];y!==null&&S.push(`${this.t(`status.stat.${j}`)} ${i(y,this.ctx.locale)}`)}return S.join(" ")}}class h extends w{read(){const f=this.ctx.host||{},s=H(f.progress)?f.progress():null;if(!s)return"";const{loaded:p,estimated:b,done:S}=s;if(S)return"";if(!b)return this.t("status.loading",{count:p||0});const j=Math.min(100,Math.round((p||0)/b*100));return this.t("status.loadingOf",{loaded:p||0,total:b,percent:j})}}class a extends w{read(){const f=this.ctx.host||{},s=H(f.updateStats)?f.updateStats():null;return s?s.paused?s.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:s.pending})}):this.t("status.paused"):s.coalescedTotal?this.t("status.coalesced",{count:s.coalescedTotal}):"":""}}class r extends w{read(){const f=this.ctx.host||{},s=H(f.hiddenUnresolved)?f.hiddenUnresolved():0;return s?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:s})}):""}}const t=Object.freeze({rowCount:A,selectedCount:g,aggregation:u,progress:h,updates:a,comments:r});class n{panels=[];root=null;init(f){const s=f||{};this.doc=z(s),this.host=s.host||{},this.messages=s.messages||null,this.root=$(this.doc,"div",{class:x.statusBar,attrs:{role:"status","aria-live":"polite"}});const p=s.registry||{},b=Array.isArray(s.panels)&&s.panels.length?s.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const S of b){const j=typeof S=="string"?S:S.name,y=typeof S=="function"?S:p[j]||t[j];if(!y)continue;const v=new y;v.init({document:this.doc,host:this.host,locale:s.locale,messages:this.messages,...typeof S=="object"?S.props||{}:{}}),this.panels.push({name:String(j||"panel"),panel:v}),this.root.appendChild(v.element())}this.refresh()}element(){return this.root}addPanel(f,s,p){const b=new s;return b.init({document:this.doc,host:this.host,messages:this.messages,...p||{}}),this.panels.push({name:f,panel:b}),this.root&&this.root.appendChild(b.element()),b.refresh(),b}removePanel(f){const s=this.panels.findIndex(S=>S.name===f);if(s<0)return!1;const[p]=this.panels.splice(s,1),b=p.panel.element();return b&&b.parentNode&&b.parentNode.removeChild(b),H(p.panel.destroy)&&p.panel.destroy(),!0}refresh(){for(const f of this.panels)f.panel.refresh()}destroy(){for(const f of this.panels)H(f.panel.destroy)&&f.panel.destroy();this.panels=[],this.root&&_(this.root),this.root=null}}const o=new Map;function d(c,f){const s=f||"";let p=o.get(s);return p||(p=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:0}),o.set(s,p)),p.format(Number(c)||0)}const l=new Map;function i(c,f){const s=f||"";let p=l.get(s);return p||(p=new Intl.NumberFormat(f||void 0,{maximumFractionDigits:3}),l.set(s,p)),p.format(Number(c)||0)}const m=n}),Fe("packages/dom/src/ui/contextmenu.js",function(e,K){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/internal/util.js").isFunction,B=K("packages/dom/src/renderer/direction.js").isRtlElement,A=K("packages/dom/src/cell/icons.js").renderIconInto;function g(t,n){const o=[];for(const d of t||[]){const l=V(d)?d(n):d;if(l==null||l===!1)continue;if(l==="separator"){o.push({separator:!0});continue}if(typeof l=="string"){o.push({name:l});continue}const i=l,m=i.subMenu||i.children;m?o.push({...i,subMenu:g(m,n)}):o.push(i)}return o.filter((d,l,i)=>d.separator?l===0||l===i.length-1?!1:!i[l-1].separator:!0)}class u{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(n){const o=n||{};this.doc=z(o),this.host=o.host||this.doc.body,this.ctx=o.ctx||{},this.onClose=o.onClose||null,this.parent=o.parent||null}place(n){const o=this.host,d=V(o.getBoundingClientRect)?o.getBoundingClientRect():{left:0,top:0},l=V(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},i=this.doc.defaultView||{innerWidth:0,innerHeight:0},m=i.innerWidth||0,c=i.innerHeight||0;let f=n.x||0,s=n.y||0;const p=B(o);if(n.anchor&&V(n.anchor.getBoundingClientRect)){const j=n.anchor.getBoundingClientRect();n.placement==="below"?(f=p?j.right-l.width:j.left,s=j.bottom):(f=p?j.left-l.width:j.right,s=j.top)}else p&&(f-=l.width);const b={left:Math.max(0,d.left||0),top:Math.max(0,d.top||0),right:Math.min(m||1/0,(d.left||0)+(d.width||1/0)),bottom:Math.min(c||1/0,(d.top||0)+(d.height||1/0))};f+l.width>b.right&&(f-=l.width),f<b.left&&(f=b.left),s+l.height>b.bottom&&(s-=l.height),s<b.top&&(s=b.top);const S=b.bottom-s;l.height>S&&(this.root.style.maxHeight=`${Math.max(0,Math.floor(S))}px`,this.root.style.overflowY="auto"),this.root.style.left=`${Math.round(f-d.left+(o.scrollLeft||0))}px`,this.root.style.top=`${Math.round(s-d.top+(o.scrollTop||0))}px`}show(n){return this.hide(),n.ctx&&(this.ctx={...this.ctx||{},...n.ctx}),this.items=g(n.items,this.ctx),this.returnFocus=n.returnFocus||null,this.anchor=n.anchor&&V(n.anchor.setAttribute)&&n.anchor.getAttribute&&n.anchor.getAttribute("aria-haspopup")?n.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=$(this.doc,"div",{class:x.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((o,d)=>{if(o.separator){this.root.appendChild($(this.doc,"div",{class:x.menuSeparator,attrs:{role:"separator"}}));return}const l=$(this.doc,"div",{class:[x.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":d}});if(o.icon!=null&&o.icon!==""){const m=$(this.doc,"span",{class:x.icon});A(m,o.icon,`menu:${o.name||d}`),l.appendChild(m)}l.appendChild($(this.doc,"span",{class:`${x.menuItem}__label`,text:o.name||""})),o.shortcut&&l.appendChild($(this.doc,"span",{class:`${x.menuItem}__shortcut`,text:o.shortcut})),o.subMenu&&l.appendChild($(this.doc,"span",{class:`${x.menuItem}__arrow`,text:"›"}));const i=this.itemNodes.length;this.off.push(_(l,"click",()=>this.invoke(i))),this.off.push(_(l,"mouseenter",()=>{this.focus(i),o.subMenu?this.openSubMenu(i):this.closeChild()})),this.itemNodes.push(l),this.root.appendChild(l)}),this.host.appendChild(this.root),this.place(n),this.open=!0,this.off.push(_(this.root,"keydown",o=>this.onKeyDown(o))),V(this.doc.addEventListener)&&this.off.push(_(this.doc,"mousedown",this.outside=o=>{this.root&&!a(this.root,o.target)&&!(this.child&&this.child.root&&a(this.child.root,o.target))&&this.hide()},!0)),V(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let n=0;n<this.itemNodes.length;n++)if(!this.itemAt(n).disabled)return n;return-1}itemAt(n){const o=this.itemNodes[n];return o?this.items[Number(o.getAttribute("data-index"))]||{}:{}}focus(n){if(n<0||n>=this.itemNodes.length)return;const o=this.itemNodes[this.focused];o&&o.classList.remove(`${x.menuItem}--focused`),this.focused=n;const d=this.itemNodes[n];d.classList.add(`${x.menuItem}--focused`),V(d.focus)&&d.focus(),V(d.scrollIntoView)&&d.scrollIntoView({block:"nearest",inline:"nearest"})}move(n){const o=this.itemNodes.length;if(!o)return;let d=this.focused;for(let l=0;l<o;l++)if(d=(d+n+o)%o,!this.itemAt(d).disabled){this.focus(d);return}}invoke(n){const o=this.itemAt(n);if(!(!o||o.disabled)){if(o.subMenu){this.openSubMenu(n);return}V(o.action)&&o.action({...this.ctx,item:o}),this.hideRoot()}}openSubMenu(n){const o=this.itemAt(n);o.subMenu&&(this.closeChild(),this.child=new u({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:o.subMenu,anchor:this.itemNodes[n]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(n){switch(n.key){case"ArrowDown":h(n),this.move(1);break;case"ArrowUp":h(n),this.move(-1);break;case"Home":h(n),this.focus(this.firstEnabled());break;case"End":h(n),this.focus(this.itemNodes.length-1);break;case"ArrowRight":h(n),this.openSubMenu(this.focused);break;case"ArrowLeft":h(n),this.parent&&(this.hide(),V(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":h(n),this.invoke(this.focused);break;case"Escape":h(n),this.hideRoot();break;default:n.key&&n.key.length===1&&this.jumpTo(n.key);break}}jumpTo(n){const o=n.toLowerCase(),d=this.itemNodes.length;for(let l=1;l<=d;l++){const i=(this.focused+l+d)%d,m=this.itemAt(i);if(!m.disabled&&(m.name||"").toLowerCase().startsWith(o)){this.focus(i);return}}}hideRoot(){let n=this;for(;n.parent;)n=n.parent;n.hide()}hide(){this.closeChild();for(const n of this.off)n();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&V(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&V(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,V(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function h(t){V(t.preventDefault)&&t.preventDefault(),V(t.stopPropagation)&&t.stopPropagation()}function a(t,n){let o=n;for(;o;){if(o===t)return!0;o=o.parentNode}return!1}const r=u}),Fe("packages/dom/src/viewpicker.js",function(e,K){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,z=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,w=K("packages/dom/src/cell/icons.js").createIcon,A=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 g{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(r,t){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(r,t)}init(r){this.messages=r&&r.messages||r&&r.grid&&r.grid.messages||W;const t=r||{};this.doc=x(t),this.host=t.host||{},this.props=t.props||{},this.root=z(this.doc,"div",{class:A.root,attrs:{role:"group","aria-label":String(this.props.title||"Saved views")}}),this.refresh()}element(){return this.root}refresh(){const r=this.root;if(!r)return;for(const l of this.off)l();this.off.length=0,_(r),this.diffs=new Map;const t=this.views(),n=t.filter(l=>l.builtin),o=t.filter(l=>!l.builtin);n.length&&(r.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),n.length)),r.appendChild(this.buildList(n))),r.appendChild(this.buildHead(String(this.props.title||"Saved views"),o.length)),o.length?r.appendChild(this.buildList(o)):r.appendChild(z(this.doc,"p",{class:A.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const d=this.buildFoot();d&&r.appendChild(d)}buildList(r){const t=z(this.doc,"div",{class:A.list,attrs:{role:"list"}});for(const n of r)t.appendChild(this.buildItem(n));return t}views(){const r=H(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?r:r.slice().sort((t,n)=>String(t.name||"").localeCompare(String(n.name||"")))}activeId(){return H(this.host.activeId)?this.host.activeId():null}buildHead(r,t){return z(this.doc,"div",{class:A.head,children:[z(this.doc,"span",{class:A.title,text:String(r)}),z(this.doc,"span",{class:A.count,text:String(t)})]})}buildItem(r){const t=String(r.id),n=this.activeId()===t,o=H(this.host.canEdit)?this.host.canEdit(r)!==!1:!0,d=z(this.doc,"div",{class:[A.item,n?A.itemActive:"",this.editing===t?A.itemEditing:""],attrs:{role:"listitem","data-view":t,"data-shared":r.shared?"true":"false"}});if(this.editing===t)return d.appendChild(this.buildRenameRow(r)),d;const l=z(this.doc,"button",{class:A.apply,attrs:{type:"button","aria-current":n?"true":null,title:[n?`${r.name} is applied`:`Apply ${r.name}`,r.shared?"Shared with everyone":"Private to you"].join(": ")},children:[z(this.doc,"span",{class:A.name,text:String(r.name||"")}),r.isDefault?this.buildBadges(r):null].filter(Boolean)});H(this.host.apply)?this.off.push($(l,"click",()=>this.applyView(t))):l.setAttribute("disabled",""),r.description&&l.appendChild(z(this.doc,"span",{class:A.description,text:String(r.description)}));const i=this.buildDiff(t,n);return i&&l.appendChild(i),d.appendChild(l),r.builtin||d.appendChild(this.confirming===t?this.buildConfirm(r):this.buildActions(r,o)),d}buildBadges(r){const t=z(this.doc,"span",{class:A.badges});return r.isDefault&&t.appendChild(z(this.doc,"span",{class:[A.badge,A.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),t}buildDiff(r,t){if(this.props.showDiff!==!0||!H(this.host.diff))return null;const n=this.diffOf(r);if(!n)return null;if(!n.changed)return z(this.doc,"span",{class:[A.diff,A.diffClean],text:this.t(t?"views.applied":"views.matchesGrid")});const o=u(n);return o.length?z(this.doc,"span",{class:A.diff,text:o.join(" · ")}):null}diffOf(r){if(!H(this.host.diff))return null;if(this.diffs.has(r))return this.diffs.get(r);let t=null;try{t=this.host.diff(r)}catch{t=null}return this.diffs.set(r,t),t}buildActions(r,t){const n=String(r.id),o=z(this.doc,"span",{class:A.actions});if(t&&H(this.host.rename)&&o.appendChild(this.buildAction("Rename",`Rename ${r.name}`,()=>{this.editing=n,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),r.isDefault&&H(this.host.clearDefault)?o.appendChild(this.buildAction("Unset default",`Stop applying ${r.name} at load`,()=>{this.host.clearDefault(n),this.refresh()},"pin")):!r.isDefault&&H(this.host.setDefault)&&o.appendChild(this.buildAction("Make default",`Apply ${r.name} when the grid loads`,()=>{this.host.setDefault(n),this.refresh()},"pin")),H(this.host.export)&&o.appendChild(this.buildAction("Share",`Export ${r.name}`,()=>this.host.export(n),"share")),t&&H(this.host.remove)){const d=this.buildAction("Delete",`Delete ${r.name}`,()=>{this.confirming=n,this.refresh()},"trash");d.classList.add(A.actionDanger),o.appendChild(d)}return o}buildConfirm(r){const t=String(r.id),n=z(this.doc,"span",{class:A.confirm});n.appendChild(z(this.doc,"span",{text:this.t("views.confirmDelete",{name:r.name})}));const o=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:r.name}),()=>{this.confirming=null,this.host.remove(t),this.refresh()});return o.classList.add(A.actionDanger),n.appendChild(o),n.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),n}buildRenameRow(r){const t=String(r.id),n=z(this.doc,"span",{class:A.confirm}),o=z(this.doc,"input",{class:A.input,attrs:{type:"text","aria-label":`New name for ${r.name}`}});o.value=String(r.name||""),this.input=o;const d=()=>{const i=String(o.value||"").trim();this.editing=null,i&&i!==r.name&&this.host.rename(t,i),this.refresh()},l=()=>{this.editing=null,this.refresh()};return this.off.push($(o,"keydown",i=>{i.key==="Enter"?d():i.key==="Escape"&&l()})),n.appendChild(o),n.appendChild(this.buildAction("Save","Save the new name",d)),n.appendChild(this.buildAction("Cancel","Leave the name alone",l)),n}buildFoot(){if(this.props.allowSave===!1||!H(this.host.saveAs))return null;const r=z(this.doc,"div",{class:A.foot}),t=z(this.doc,"input",{class:A.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});t.value=this.draft,this.editing===null&&(this.input=t);const n=()=>{const d=String(t.value||"").trim();if(!d){H(t.focus)&&t.focus();return}this.draft="",this.host.saveAs(d),this.refresh()};this.off.push($(t,"input",()=>{this.draft=String(t.value||"")})),this.off.push($(t,"keydown",d=>{d.key==="Enter"&&n()}));const o=z(this.doc,"button",{class:A.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push($(o,"click",n)),r.appendChild(t),r.appendChild(o),r}buildAction(r,t,n,o){const d=z(this.doc,"button",{class:A.action,text:o?null:r,attrs:{type:"button",title:t,"aria-label":t,"data-action":r}});return o&&d.appendChild(w(this.doc,o,{className:A.actionIcon})),this.off.push($(d,"click",n)),d}applyView(r){this.confirming=null,this.host.apply(r),this.refresh()}focusInput(){const r=this.input;r&&H(r.focus)&&r.focus(),r&&H(r.select)&&r.select()}destroy(){for(const r of this.off)r();this.off.length=0,this.root=null,this.input=null,this.diffs=new Map}}function u(a,r=3){if(!a||!a.changed)return[];const t=a.counts||{},n=[],o=(d,l,i)=>{d&&n.push((d===1?l:i).replace("%",String(d)))};if(o(t.columnsHidden,"hides % column","hides % columns"),o(t.columnsShown,"shows % column","shows % columns"),o(t.columnsMoved,"moves % column","moves % columns"),o(t.columnsPinned,"repins % column","repins % columns"),o(t.columnsResized,"resizes % column","resizes % columns"),a.filters&&a.filters.changed){const d=t.filterColumns||0;n.push(d?`changes ${d} filter${d===1?"":"s"}`:"changes the filter")}return a.quick&&a.quick.changed&&n.push("changes the search"),a.sort&&a.sort.changed&&n.push("changes the sort"),a.group&&a.group.changed&&n.push("changes the grouping"),a.pivot&&a.pivot.changed&&n.push("changes the pivot"),o(t.columnsTotalled,"changes % total","changes % totals"),a.pagination&&a.pagination.changed&&n.push("changes the page size"),n.length<=r?n:[...n.slice(0,r),`and ${n.length-r} more`]}const h=g}),Fe("packages/dom/src/ui/panelbase.js",function(e,K){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return X}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.el,_=K("packages/core/src/i18n/index.js").defaultMessages;class X{root=null;off=[];init(V){this.ctx=V,this.doc=V.document,this.host=V.host||{},this.props=V.props||{},this.root=z(this.doc,"div",{class:`${x.panel}__body`}),this.refresh()}t(V,H){const B=this.host||{};if(typeof B.t=="function")return B.t(V,H);const w=this.ctx||{};if(w.messages&&typeof w.messages.t=="function")return w.messages.t(V,H);const A=w.grid;return(A&&A.messages?A.messages:_).t(V,H)}element(){return this.root}refresh(){}destroy(){for(const V of this.off)V();this.off.length=0,this.root=null}}}),Fe("packages/dom/src/formattingpanel.js",function(e,K){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/internal/util.js").isFunction,B=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,w=K("packages/core/src/formatting/rules.js"),A=w.compileRules,g=w.summariseColumn,u=w.needsDistribution,h=w.DISTRIBUTION_LABELS,a="*",r=8,t=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),n=Object.freeze([{op:"topPercent",label:h.topPercent,values:1},{op:"bottomPercent",label:h.bottomPercent,values:1},{op:"topN",label:h.topN,values:1},{op:"bottomN",label:h.bottomN,values:1},{op:"aboveMean",label:h.aboveMean,values:0},{op:"belowMean",label:h.belowMean,values:0},{op:"aboveMedian",label:h.aboveMedian,values:0},{op:"belowMedian",label:h.belowMedian,values:0},{op:"zAbove",label:h.zAbove,values:1},{op:"zBelow",label:h.zBelow,values:1},{op:"outlier",label:h.outlier,values:0}]),o=Object.freeze([...t,...n]),d=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),l=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),i=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function m(b){const S=o.find(j=>j.op===b);return S?S.values:1}function c(b){if(!b)return"";if(b.scale){const{min:v,max:R,from:O}=b.scale;if(Number.isFinite(v)&&Number.isFinite(R))return`Colour scale, ${v} to ${R}`;const F=i.find(C=>C.from===O);return F?`Colour scale ${F.label}`:"Colour scale"}const S=b.when||{},j=o.find(v=>v.op===S.op),y=j?j.label:S.op;return!j||j.values===0?`Value ${y}`:j.values===2?`Value ${y} ${S.value} and ${S.value2}`:`Value ${y} ${S.value}`}class f extends B{scope=a;mode="condition";refresh(){const S=this.root;if(S){for(const j of this.off)j();this.off.length=0,X(S),S.appendChild(this.#o()),S.appendChild(this.#i()),S.appendChild(this.#l())}}#e(){const S=V(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:a,title:"All columns"},...S]}#t(){return V(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(S){if(!V(this.host.columnSamples))return[];const j=this.host.columnSamples(S);return Array.isArray(j)?j:[...j||[]]}#r(S,j,y){const v=u(S)?g(j):null;return A(S,v)({value:y})}#o(){const S=$(this.doc,"div",{class:`${x.panel}__row`});S.appendChild($(this.doc,"label",{class:`${x.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const j=$(this.doc,"select",{class:`${x.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const y of this.#e()){const v=$(this.doc,"option",{text:y.title,attrs:{value:y.id}});y.id===this.scope&&v.setAttribute("selected","selected"),j.appendChild(v)}return j.value=this.scope,this.off.push(_(j,"change",()=>{this.scope=j.value||a,this.refresh()})),S.appendChild(j),S}#i(){const S=$(this.doc,"ul",{class:`${x.panel}__list`}),j=this.#t();if(!j.length)return S.appendChild($(this.doc,"li",{class:`${x.panel}__empty`,text:this.t("formatting.noRules")})),S;j.forEach((R,O)=>{const F=$(this.doc,"li",{class:`${x.panel}__item`,attrs:{"data-rule":R.id}}),C=$(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${c(R)}`}});C.checked=R.enabled!==!1,this.off.push(_(C,"change",()=>{this.#c("updateRule",this.scope,R.id,{enabled:C.checked})})),F.appendChild(C);const T=$(this.doc,"span",{class:`${x.panel}__swatch`}),L=R.style||{};if(L.background&&T.style&&T.style.setProperty)T.style.setProperty("background",String(L.background));else if(R.scale&&R.scale.colours&&T.style&&T.style.setProperty){const P=R.scale.colours;T.style.setProperty("background",`linear-gradient(90deg, ${P[0]}, ${P[P.length-1]})`)}F.appendChild(T),F.appendChild($(this.doc,"span",{class:`${x.panel}__text`,text:c(R)}));const E=$(this.doc,"button",{class:`${x.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...O===0?{disabled:"disabled"}:{}}});this.off.push(_(E,"click",()=>this.#c("moveRule",this.scope,R.id,O-1))),F.appendChild(E);const D=$(this.doc,"button",{class:`${x.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...O===j.length-1?{disabled:"disabled"}:{}}});this.off.push(_(D,"click",()=>this.#c("moveRule",this.scope,R.id,O+1))),F.appendChild(D);const I=$(this.doc,"button",{class:`${x.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${c(R)}`}});this.off.push(_(I,"click",()=>this.#c("removeRule",this.scope,R.id))),F.appendChild(I),S.appendChild(F)});const y=this.#s(j);y&&S.appendChild(y);const v=$(this.doc,"button",{class:`${x.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(_(v,"click",()=>this.#c("clearRules",this.scope))),S.appendChild(v),S}#s(S){const j=this.#n(this.scope);if(!j.length)return null;const y=S.filter(R=>R.enabled!==!1);if(!y.length)return null;const v=$(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const R of j.slice(0,r)){const O=this.#r(y,j,R),F=$(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(R)});O&&F.style&&F.style.setProperty&&(O.background&&F.style.setProperty("background",String(O.background)),O.color&&F.style.setProperty("color",String(O.color))),v.appendChild(F)}return v}#l(){const S=$(this.doc,"div",{class:`${x.panel}__form`}),j=$(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return j.appendChild($(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),j.appendChild($(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),j.value=this.mode,this.off.push(_(j,"change",()=>{this.mode=j.value==="scale"?"scale":"condition",this.refresh()})),S.appendChild(j),this.mode==="scale"?S.appendChild(this.#u()):S.appendChild(this.#a()),S}#a(){const S=$(this.doc,"div",{class:`${x.panel}__form`}),j=$(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),y=$(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const I of t)y.appendChild($(this.doc,"option",{text:I.label,attrs:{value:I.op}}));j.appendChild(y);const v=$(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const I of n)v.appendChild($(this.doc,"option",{text:I.label,attrs:{value:I.op}}));j.appendChild(v),j.value="gt",S.appendChild(j);const R=$(this.doc,"input",{class:`${x.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),O=$(this.doc,"input",{class:`${x.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});S.appendChild(R),S.appendChild(O);const F=()=>{const I=m(j.value);R.style.setProperty("display",I>=1?"":"none"),O.style.setProperty("display",I>=2?"":"none"),E()};this.off.push(_(j,"change",F));const C=$(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const I of d)C.appendChild($(this.doc,"option",{text:I.name,attrs:{value:I.name}}));C.value=d[0].name,S.appendChild(C);const T=$(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});S.appendChild(T);const L=()=>{const I=d.find(N=>N.name===C.value)||d[0],P=m(j.value),k={op:j.value};return P>=1&&(k.value=R.value),P>=2&&(k.value2=O.value),{when:k,style:{background:I.background,color:I.color}}},E=()=>{X(T);const I=this.#n(this.scope);if(I.length)for(const P of I.slice(0,r)){const k=this.#r([L()],I,P),N=$(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(P)});k&&N.style&&N.style.setProperty&&(k.background&&N.style.setProperty("background",String(k.background)),k.color&&N.style.setProperty("color",String(k.color))),T.appendChild(N)}};this.off.push(_(R,"input",E)),this.off.push(_(O,"input",E)),this.off.push(_(C,"change",E)),F();const D=$(this.doc,"button",{class:`${x.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(D,"click",()=>{this.#c("addRule",this.scope,L()),R.value="",O.value=""})),S.appendChild(D),S}#u(){const S=$(this.doc,"div",{class:`${x.panel}__form`}),j=$(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const C of l)j.appendChild($(this.doc,"option",{text:C.name,attrs:{value:C.name}}));j.value=l[0].name,S.appendChild(j);const y=$(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const C of i)y.appendChild($(this.doc,"option",{text:C.label,attrs:{value:C.from}}));y.value=i[0].from,S.appendChild(y);const v=$(this.doc,"div",{class:`${x.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});S.appendChild(v);const R=()=>{const C=l.find(T=>T.name===j.value)||l[0];return{scale:{from:y.value,colours:[...C.colours]}}},O=()=>{X(v);const C=this.#n(this.scope);if(C.length)for(const T of C.slice(0,r)){const L=this.#r([R()],C,T),E=$(this.doc,"span",{class:`${x.panel}__previewcell`,text:String(T)});L&&L.background&&E.style&&E.style.setProperty&&E.style.setProperty("background",String(L.background)),v.appendChild(E)}};this.off.push(_(j,"change",O)),this.off.push(_(y,"change",O)),O();const F=$(this.doc,"button",{class:`${x.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(_(F,"click",()=>{this.#c("addRule",this.scope,R())})),S.appendChild(F),S}#c(S,...j){V(this.host[S])&&this.host[S](...j),this.refresh()}}function s(b={}){const S=new f;return S.init({document:z(b),host:b.host||{}}),S}const p=f}),Fe("packages/dom/src/statisticspanel.js",function(e,K){"use strict";Object.defineProperty(e,"shouldThinLabels",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return r}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=70,w=40;function A(t,n){return!t||!n?!1:t<n*2+w}const g=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"}]),u=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),h=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 a(t){if(t==null||!Number.isFinite(t))return"—";if(Number.isInteger(t))return String(t);const n=Math.abs(t);return n!==0&&(n<.001||n>=1e7)?t.toExponential(2):String(Number(t.toPrecision(4)))}class r extends H{column=null;#e=0;#t(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const n=this.root;if(!n)return;for(const l of this.off)l();this.off.length=0,_(n);const o=this.#t();if(!o.length){n.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("stats.noColumns")}));return}o.some(l=>l.id===this.column)||(this.column=o[0].id),n.appendChild(this.#o(o));const d=W(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!d&&W(this.host.columnProfileAsync)){const l=z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("facets.computing")});n.appendChild(l);const i=++this.#e,m=this.column;Promise.resolve(this.host.columnProfileAsync(m)).then(c=>{if(i!==this.#e||this.root!==n||this.column!==m)return;const f=z(this.doc,"div",{});this.#n(f,c);for(const s of[...f.children])n.insertBefore(s,l);n.removeChild(l)},()=>{i!==this.#e||this.root!==n||(l.textContent=this.t("stats.noValues"))});return}this.#e++,this.#n(n,d)}#n(n,o){if(!o||!o.present){n.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("stats.noValues")}));const l=this.#r(o);l&&n.appendChild(l);return}if(n.appendChild(z(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.filtered",{count:o.rows})})),Array.isArray(o.topValues)){n.appendChild(this.#l(o,u)),n.appendChild(this.#a(o.topValues));const l=this.#r(o);l&&n.appendChild(l);return}if(n.appendChild(this.#l(o)),o.computed!=="source"){for(const i of h){const m=this.#i(i);m&&n.appendChild(m)}const l=this.#s();l&&n.appendChild(l)}o.histogram&&o.histogram.length>1&&n.appendChild(this.#u(o.histogram));const d=this.#r(o);d&&n.appendChild(d)}#r(n){const o=n&&Array.isArray(n.unavailable)?n.unavailable:[];if(!o.length)return null;const d=this.doc.createElement("div");d.setAttribute("data-unavailable",""),d.appendChild(z(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.unavailable",{stats:o.map(i=>i.stat).join(", ")})}));const l=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const i of o)l.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:i.stat})),l.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,text:i.reasonKey?this.t(i.reasonKey,i.reasonParams):i.reason}));return d.appendChild(l),d}#o(n){const o=z(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const d of n){const l=z(this.doc,"option",{text:d.title,attrs:{value:d.id,selected:d.id===this.column?!0:null}});o.appendChild(l)}return o.value=this.column,this.off.push($(o,"change",()=>{this.column=o.value,this.refresh()})),z(this.doc,"label",{class:`${x.panel}__field`,children:[z(this.doc,"span",{class:`${x.panel}__label`,text:this.t("stats.column")}),o]})}#i(n){const o=this.host.reduceColumn;if(!W(o)||!this.column)return null;const d=[];for(const m of n.kernels){const c=o(this.column,m);c==null||Number.isNaN(c)||d.push([m,c])}if(!d.length)return null;const l=this.doc.createElement("div");l.appendChild(z(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t(n.label)}));const i=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const[m,c]of d)i.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(`total.${m}`)})),i.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,text:typeof c=="number"?a(c):String(c)}));return l.appendChild(i),l}#s(){const n=this.host.columnCapability;if(!W(n)||!this.column)return null;const o=n(this.column);if(!o)return null;const d=this.doc.createElement("div");d.appendChild(z(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.section.capability")}));const l=z(this.doc,"dl",{class:`${x.panel}__stats`}),i=[["stats.cp",o.cp,null],["stats.cpk",o.cpk,o.interval],["stats.pp",o.pp,null],["stats.ppk",o.ppk,o.intervalPp],["stats.outOfSpec",o.outOfSpec,null]];for(const[m,c,f]of i){if(c==null)continue;l.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(m)}));const s=[z(this.doc,"span",{text:a(c)})];f&&Number.isFinite(f.lower)&&s.push(z(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${a(f.lower)} – ${a(f.upper)}`,attrs:{title:`${Math.round(f.confidence*100)}%`}})),l.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,children:s}))}return d.appendChild(l),d}#l(n,o=g){const d=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const l of o){const i=n[l.key];d.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(l.label)})),d.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,text:l.kind==="count"?String(i??0):a(i)}))}return d}#a(n){const o=this.doc.createElement("div");o.appendChild(z(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.topValues")}));const d=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const l of n)d.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:String(l.value)})),d.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,children:[z(this.doc,"span",{text:String(l.count)}),z(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${Math.round(l.share*100)}%`})]}));return o.appendChild(d),o}#u(n){const o=n.reduce((m,c)=>Math.max(m,c.count),0)||1,d=z(this.doc,"div",{class:`${x.panel}__histogram`});d.appendChild(z(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t("stats.distribution.detail")}));const l=z(this.doc,"ul",{class:`${x.panel}__histogram-list`,attrs:{role:"list","aria-label":this.t("stats.distribution.detail")}}),i=[];for(const m of n){const c=m.count||0,f=c?Math.max(2,c/o*100):0,s=String(c),p=f>=B,b=z(this.doc,"div",{class:`${x.panel}__bar`,style:{width:`${f}%`},children:p?[z(this.doc,"span",{class:`${x.panel}__bin-count ${x.panel}__bin-count--inside`,text:s})]:[]}),S=z(this.doc,"div",{class:`${x.panel}__bin-track`,children:p?[b]:[b,z(this.doc,"span",{class:`${x.panel}__bin-count ${x.panel}__bin-count--outside`,text:s})]}),j=z(this.doc,"span",{class:`${x.panel}__bin-range`,text:`${a(m.from)}–${a(m.to)}`});i.push(j);const y=this.t("stats.bin",{count:c,from:a(m.from),to:a(m.to)});l.appendChild(z(this.doc,"li",{class:`${x.panel}__bin`,attrs:{title:y,"aria-label":y},children:[j,S]}))}return d.appendChild(l),this.#c(d,l,i),d}#c(n,o,d){const l=globalThis.ResizeObserver;if(!W(l))return;const i=()=>{const c=n.clientWidth||(W(n.getBoundingClientRect)?n.getBoundingClientRect().width:0);if(!c)return;let f=0;for(const s of d){const p=s.scrollWidth||(W(s.getBoundingClientRect)?s.getBoundingClientRect().width:0);p>f&&(f=p)}o.classList.toggle(`${x.panel}__histogram-list--thin`,A(c,f))},m=new l(i);m.observe(n),this.off.push(()=>m.disconnect()),i()}}}),Fe("packages/dom/src/regressionpanel.js",function(e,K){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.el,$=Q.clear,X=K("packages/core/src/internal/util.js").isFunction,V=K("packages/dom/src/ui/panelbase.js").ToolPanelBase;function H(A,g=4){const u=Number(A);return Number.isFinite(u)?u.toFixed(g):u===1/0?"∞":"—"}class B extends V{#e(){const g=this.props||{};if(Array.isArray(g.predictors)&&g.predictors.length&&g.response)return g;const u=this.ctx&&this.ctx.grid,h=u&&X(u.get)?u.get("regression"):null;return h&&Array.isArray(h.predictors)&&h.response?h:null}refresh(){const g=this.root;if(!g)return;$(g);const u=this.#e();if(!u){g.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.noModel")}));return}const h=X(this.host.regressionModel)?this.host.regressionModel(u):null;if(!h){g.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.cannotFit")}));return}g.appendChild(z(this.doc,"p",{class:`${x.panel}__count`,text:this.t("regression.observations",{count:h.n})})),g.appendChild(this.#t(h)),g.appendChild(this.#n(h));const a=this.#r(h,u);a&&g.appendChild(a),g.appendChild(this.#o(h))}#t(g){const u=z(this.doc,"dl",{class:`${x.panel}__stats`}),h=(a,r)=>{u.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-label`,text:a})),u.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,text:r}))};return h(this.t("regression.r2"),H(g.r2,4)),h(this.t("regression.adjR2"),H(g.adjR2,4)),u}#n(g){const u=z(this.doc,"div",{class:`${x.panel}__section`});u.appendChild(z(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.coefficients")}));const h=z(this.doc,"table",{class:`${x.panel}__coef-table`}),a=z(this.doc,"tr");for(const r of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])a.appendChild(z(this.doc,"th",{text:this.t(r)}));h.appendChild(a);for(const r of g.coefficients){const t=z(this.doc,"tr");t.appendChild(z(this.doc,"td",{text:r.name})),t.appendChild(z(this.doc,"td",{text:`${H(r.estimate)} ± ${H(r.stdError)}`})),t.appendChild(z(this.doc,"td",{text:H(r.stdError)})),t.appendChild(z(this.doc,"td",{text:H(r.t,3)})),t.appendChild(z(this.doc,"td",{text:H(r.p,4)})),h.appendChild(t)}return u.appendChild(h),u}#r(g,u){if(!Array.isArray(g.vif)||g.vif.length<2)return null;const h=z(this.doc,"div",{class:`${x.panel}__section`});h.appendChild(z(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.vif")}));const a=z(this.doc,"dl",{class:`${x.panel}__stats`});return g.vif.forEach((r,t)=>{a.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-label`,text:u.predictors[t]})),a.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,text:H(r,3)}))}),h.appendChild(a),h}#o(g){const u=g.heteroscedasticity,h=z(this.doc,"div",{class:`${x.panel}__section`});return h.appendChild(z(this.doc,"h4",{class:`${x.panel}__heading`,text:this.t("regression.heteroscedasticity")})),u?(h.appendChild(z(this.doc,"p",{class:`${x.panel}__flag`,attrs:{"data-heteroscedastic":u.heteroscedastic?"true":"false"},text:this.t(u.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:H(u.statistic,3),p:H(u.p,4)})})),h):(h.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("regression.cannotFit")})),h)}}const w=B}),Fe("packages/dom/src/comparepanel.js",function(e,K){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return A}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=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 w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const u=Math.abs(g);return u!==0&&(u<.001||u>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class A extends H{first=null;second=null;#e(){return W(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const u=this.root;if(!u)return;for(const t of this.off)t();this.off.length=0,_(u);const h=this.#e();if(h.length<2){u.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("compare.needTwo")}));return}h.some(t=>t.id===this.first)||(this.first=h[0].id),(!h.some(t=>t.id===this.second)||this.second===this.first)&&(this.second=(h.find(t=>t.id!==this.first)||h[0]).id),u.appendChild(this.#t("compare.first",h,this.first,t=>{this.first=t,this.second===t&&(this.second=(h.find(n=>n.id!==t)||h[0]).id),this.refresh()})),u.appendChild(this.#t("compare.second",h,this.second,t=>{this.second=t,this.first===t&&(this.first=(h.find(n=>n.id!==t)||h[0]).id),this.refresh()}));const a=W(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!a||!a.n){u.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("compare.noPairs")}));return}u.appendChild(z(this.doc,"p",{class:`${x.panel}__count`,text:this.t("compare.pairs",{count:a.n})}));const r=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const t of B){const n=a[t.key];n!=null&&(r.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(t.label)})),r.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,text:w(n)})))}u.appendChild(r)}#t(u,h,a,r){const t=z(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const n of h)t.appendChild(z(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===a?!0:null}}));return t.value=a,this.off.push($(t,"change",()=>r(t.value))),z(this.doc,"label",{class:`${x.panel}__field`,children:[z(this.doc,"span",{class:`${x.panel}__label`,text:this.t(u)}),t]})}}}),Fe("packages/dom/src/insightspanel.js",function(e,K){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return A}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,B=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 w(g){if(g==null||!Number.isFinite(g))return"—";if(Number.isInteger(g))return String(g);const u=Math.abs(g);return u!==0&&(u<.001||u>=1e7)?g.toExponential(2):String(Number(g.toPrecision(4)))}class A extends H{column=null;by=null;#e(){return W(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const u=this.root;if(!u)return;for(const o of this.off)o();this.off.length=0,_(u);const h=this.#e();if(!h.length){u.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.empty")}));return}const a=this.#t();a&&u.appendChild(a);const r=this.#n();r&&u.appendChild(r),u.appendChild(this.#o(h));const t=this.#s();t&&u.appendChild(t);const n=this.#u();n&&u.appendChild(n)}#t(){if(!W(this.host.subsetVsPopulation))return null;const u=this.host.subsetVsPopulation();if(!u)return null;const h=this.#c("insights.subset");return u.filtered?(h.appendChild(z(this.doc,"p",{class:`${x.panel}__count`,text:this.t("stats.filtered",{count:u.subsetN})})),h.appendChild(this.#r(u.ranked)),h):(h.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.noFilter")})),h)}#n(){const u=this.props&&this.props.other;if(!u||!W(this.host.datasetVsDataset))return null;let h;try{h=this.host.datasetVsDataset(u)}catch{return null}if(!h||!h.ranked)return null;const a=this.#c("insights.dataset");return a.appendChild(this.#r(h.ranked)),a}#r(u){const h=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const a of u||[]){const r=z(this.doc,"dt",{class:`${x.panel}__stat-name`});r.appendChild(z(this.doc,"span",{text:String(a.name??a.column)})),r.appendChild(z(this.doc,"span",{class:`${x.panel}__stat-interval`,text:String(a.measure||"")}));const t=z(this.doc,"dd",{class:`${x.panel}__stat-value`});t.appendChild(z(this.doc,"span",{text:w(a.magnitude)})),a.reliable===!1&&t.appendChild(z(this.doc,"span",{class:`${x.panel}__stat-interval`,text:this.t("insights.smallSample")})),h.appendChild(r),h.appendChild(t)}return h}#o(u){const h=this.#c("insights.groups");u.some(r=>r.id===this.column)||(this.column=u[0].id),(!u.some(r=>r.id===this.by)||this.by===this.column)&&(this.by=(u.find(r=>r.id!==this.column)||u[0]).id),h.appendChild(this.#d("stats.column",u,this.column,r=>{this.column=r,this.by===r&&(this.by=(u.find(t=>t.id!==r)||u[0]).id),this.refresh()})),h.appendChild(this.#d("insights.by",u,this.by,r=>{this.by=r,this.column===r&&(this.column=(u.find(t=>t.id!==r)||u[0]).id),this.refresh()}));const a=W(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return a?(h.appendChild(this.#i(a)),h):(h.appendChild(z(this.doc,"p",{class:`${x.panel}__empty`,text:this.t("insights.needGroups")})),h)}#i(u){const h=z(this.doc,"dl",{class:`${x.panel}__stats`});Array.isArray(u.groups)&&u.groups.length===2&&this.#a(h,"insights.groups",`${u.groups[0]} · ${u.groups[1]}`),this.#a(h,"insights.test",String(u.method||u.test||""));const a=u.effectSize||{};this.#a(h,"insights.effect",`${a.name||""} ${w(a.value)}`.trim());const r=u.interval;let t="—";if(r&&Number.isFinite(r.lower)&&Number.isFinite(r.upper)){const o=Number.isFinite(r.confidence)?` (${Math.round(r.confidence*100)}%)`:"";t=`${w(r.lower)} – ${w(r.upper)}${o}`}const n=this.#a(h,"insights.interval",t);return r&&r.method&&n.appendChild(z(this.doc,"span",{class:`${x.panel}__stat-interval`,text:String(r.method)})),Number.isFinite(u.pValue)&&this.#a(h,"insights.pValue",w(u.pValue)),h}#s(){if(!W(this.host.anomalies))return null;let u;try{u=this.host.anomalies()}catch{return null}if(!u)return null;const h=this.#c("insights.anomalies");h.appendChild(z(this.doc,"p",{class:`${x.panel}__count`,text:this.t("insights.anomalyCount",{count:u.flagged||0,n:u.n||0})}));const a=z(this.doc,"dl",{class:`${x.panel}__stats`});this.#a(a,"insights.anomalyMethod",String(u.method||""));const r=this.#l(u);r!==null&&this.#a(a,"insights.anomalyThreshold",w(r)),h.appendChild(a);const t=(u.rows||[]).map(n=>({name:n.rowKey!=null?String(n.rowKey):`#${n.index}`,measure:(n.why||[]).map(o=>o.name||o.column).join(", "),magnitude:n.score}));return h.appendChild(this.#r(t)),h}#l(u){if(u.method==="mahalanobis")return Number.isFinite(u.cutoff)?u.cutoff:null;if(u.method==="iqr")return Number.isFinite(u.k)?u.k:null;const h=Array.isArray(u.columns)?u.columns[0]:null;return h&&Number.isFinite(h.threshold)?h.threshold:null}#a(u,h,a){u.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(h)}));const r=z(this.doc,"dd",{class:`${x.panel}__stat-value`});return r.appendChild(z(this.doc,"span",{text:a})),u.appendChild(r),r}#u(){if(!W(this.host.columnCapability)||!this.column)return null;const u=this.host.columnCapability(this.column);if(!u)return null;const h=this.#c("stats.section.capability"),a=z(this.doc,"dl",{class:`${x.panel}__stats`});for(const r of B){const t=u[r.field];if(t==null)continue;a.appendChild(z(this.doc,"dt",{class:`${x.panel}__stat-name`,text:this.t(r.key)}));const n=[z(this.doc,"span",{text:w(t)})],o=r.interval?u[r.interval]:null;o&&Number.isFinite(o.lower)&&n.push(z(this.doc,"span",{class:`${x.panel}__stat-interval`,text:`${w(o.lower)} – ${w(o.upper)}`,attrs:{title:`${Math.round(o.confidence*100)}%`}})),a.appendChild(z(this.doc,"dd",{class:`${x.panel}__stat-value`,children:n}))}return h.appendChild(a),h}#c(u){const h=this.doc.createElement("div");return h.appendChild(z(this.doc,"h4",{class:`${x.panel}__subtitle`,text:this.t(u)})),h}#d(u,h,a,r){const t=z(this.doc,"select",{class:`${x.panel}__select`,attrs:{"aria-label":this.t(u)}});for(const n of h)t.appendChild(z(this.doc,"option",{text:n.title,attrs:{value:n.id,selected:n.id===a?!0:null}}));return t.value=a,this.off.push($(t,"change",()=>r(t.value))),z(this.doc,"label",{class:`${x.panel}__field`,children:[z(this.doc,"span",{class:`${x.panel}__label`,text:this.t(u)}),t]})}}}),Fe("packages/dom/src/ui/toolpanel.js",function(e,K){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return E}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.cssEscape,$=Q.documentFor,_=Q.el,X=Q.on,W=Q.clear,H=K("packages/core/src/i18n/index.js").defaultMessages,B=K("packages/core/src/internal/util.js"),w=B.isFunction,A=B.nextFrame,g=K("packages/dom/src/cell/icons.js"),u=g.createIcon,h=g.updateIcon,a=g.icon,t=K("packages/dom/src/viewpicker.js").ViewPicker,o=K("packages/dom/src/formattingpanel.js").FormattingPanel,l=K("packages/dom/src/statisticspanel.js").StatisticsPanel,m=K("packages/dom/src/regressionpanel.js").RegressionPanel,f=K("packages/dom/src/comparepanel.js").ComparePanel,p=K("packages/dom/src/insightspanel.js").InsightsPanel,S=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,y=K("packages/core/src/compute/total.js").TOTAL_LABELS;class v extends S{dragging=null;collapsed=new Set;refresh(){const P=this.root;if(!P)return;for(const Y of this.off)Y();this.off.length=0,W(P);const k=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.query&&(k.value=this.query),this.off.push(X(k,"input",()=>{this.query=k.value,this.paintList()})),P.appendChild(k),P.appendChild(this.buildZone("group","Row groups")),P.appendChild(this.buildZone("values","Grouped row calculation")),P.appendChild(this.buildZone("pivot","Pivot"));const N=_(this.doc,"div",{class:`${x.panel}__heading`});N.appendChild(_(this.doc,"span",{text:this.t("panel.columns")}));const G=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),q=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.showColumns)&&this.host.showColumns(Y),this.refresh()})),this.off.push(X(q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);w(this.host.hideColumns)&&this.host.hideColumns(Y),this.refresh()})),N.appendChild(G),N.appendChild(q),P.appendChild(N),this.list=_(this.doc,"div",{class:`${x.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),P.appendChild(this.list),this.paintList()}columns(){const P=this.host;return w(P.columns)?P.columns()||[]:P.columns&&w(P.columns.all)?P.columns.all():[]}paintList(){const P=this.list;if(!P)return;W(P);const k=String(this.query||"").trim().toLowerCase();this.paintNodes(P,this.bandTree(),k)}paintNodes(P,k,N,G=!1){let q=0;for(const Y of k){if(Y.column){const fe=String(Y.column.title||Y.column.id||"");if(N&&!G&&!fe.toLowerCase().includes(N))continue;P.appendChild(this.buildColumnRow(Y.column)),q++;continue}const J=!!N&&this.bandTitle(Y.band).toLowerCase().includes(N),ee=_(this.doc,"div",{class:`${x.panel}__bandBody`}),re=this.paintNodes(ee,Y.children,N,G||J);if(N&&!re&&!J)continue;const ie=_(this.doc,"div",{class:`${x.panel}__band`,attrs:{role:"group","aria-label":this.bandTitle(Y.band),"data-band":Y.band.id}}),ae=!this.collapsed.has(Y.band.id);ie.appendChild(this.buildBandRow(Y,ae)),(ae||N)&&ie.appendChild(ee),P.appendChild(ie),q++}return q}bandTree(){const P=this.columns(),k=new Map,N=this.host;if(w(N.columnGroups)){const Y=J=>{for(const ee of J||[])Array.isArray(ee.columns)&&(k.set(ee.id,ee.title),Y(ee.columns))};Y(N.columnGroups())}const G=[],q=new Map;for(const Y of P){let J=G,ee="";for(const re of Y.groupPath||[]){ee+=`/${re}`;let ie=q.get(ee);ie||(ie={band:{id:re,title:k.has(re)?k.get(re):""},children:[],ids:[]},q.set(ee,ie),J.push(ie)),ie.ids.push(Y.id),J=ie.children}J.push({column:Y})}return G}bandTitle(P){return String(P.title||"")||this.t("columngroup.untitled")}buildColumnRow(P){const k=String(P.title||P.id||""),N=_(this.doc,"div",{class:`${x.panel}__column`,attrs:{"data-col":P.id,draggable:"true",title:this.t("panel.columnDragHint",{column:k})}});N.appendChild(_(this.doc,"span",{class:`${x.panel}__grip`,attrs:{"aria-hidden":"true"}}));const G=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":k}});return G.checked=!(P.layout&&P.layout.hidden),P.layout&&P.layout.lockVisible&&G.setAttribute("disabled",""),this.off.push(X(G,"change",()=>this.setVisible(P.id,G.checked))),N.appendChild(G),N.appendChild(_(this.doc,"span",{text:k})),N.setAttribute("tabindex","0"),N.setAttribute("role","listitem"),this.off.push(X(N,"keydown",q=>this.onRowKey(q,P))),this.off.push(X(N,"dragstart",()=>{this.dragging=P.id})),this.off.push(X(N,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(X(N,"dragover",q=>{if(!this.dragging||this.dragging===P.id)return;if(w(q.preventDefault)&&q.preventDefault(),this.bandDrop(this.dragging,P)){N.setAttribute("data-drop","into");return}const J=D(q,N);N.setAttribute("data-drop",J?"before":"after")})),this.off.push(X(N,"dragleave",()=>N.removeAttribute("data-drop"))),this.off.push(X(N,"drop",q=>{w(q.preventDefault)&&q.preventDefault();const Y=this.dragging;if(this.dragging=null,this.clearDropMark(),!Y||Y===P.id)return;const J=this.bandDrop(Y,P);if(J==="leave"){this.leaveBand(Y);return}if(J){this.joinBand(Y,J);return}this.moveColumn(Y,P.id,D(q,N))})),N}bandOf(P){const k=typeof P=="string"?this.columns().find(G=>G.id===P):P,N=k&&k.groupPath||[];return N.length?N[N.length-1]:null}bandDrop(P,k){const N=this.host;if(!w(N.groupColumns))return null;const G=this.bandOf(P),q=this.bandOf(k);return q&&q!==G?q:G&&!q?"leave":null}joinBand(P,k){const N=this.columns().find(q=>q.id===P),G=this.titleOf(P);if(N&&N.layout&&N.layout.lockPosition){this.announce(this.t("a11y.column.cannotGroup",{column:G}),{repeat:!0});return}this.host.groupColumns([P],{groupId:k}),this.announce(this.t("a11y.column.addedToGroup",{column:G,group:this.bandName(k)}),{repeat:!0}),this.refresh()}leaveBand(P){w(this.host.ungroupColumn)&&(this.host.ungroupColumn(P),this.announce(this.t("a11y.column.removedFromGroup",{column:this.titleOf(P)}),{repeat:!0}),this.refresh())}bandName(P){const k=G=>{for(const q of G){if(!q.band)continue;if(q.band.id===P)return q.band;const Y=k(q.children);if(Y)return Y}return null},N=k(this.bandTree());return N?this.bandTitle(N):P}buildBandRow(P,k){const{band:N,ids:G}=P,q=this.bandTitle(N),Y=_(this.doc,"div",{class:`${x.panel}__bandRow`,attrs:{"data-band-row":N.id,tabindex:"0",role:"listitem","aria-label":q}}),J=_(this.doc,"button",{class:`${x.panel}__bandToggle`,attrs:{type:"button","aria-expanded":k?"true":"false","aria-label":this.t(k?"panel.bandCollapse":"panel.bandExpand",{band:q})},text:k?"▾":"▸"});this.off.push(X(J,"click",()=>this.toggleBand(N.id))),Y.appendChild(J);const ee=new Map(this.columns().map(ce=>[ce.id,ce])),re=G.filter(ce=>!(ee.get(ce).layout&&ee.get(ce).layout.hidden)).length,ie=_(this.doc,"input",{attrs:{type:"checkbox","aria-label":this.t("panel.bandVisible",{band:q})}});ie.checked=re===G.length,ie.indeterminate=re>0&&re<G.length,re>0&&re<G.length&&ie.setAttribute("aria-checked","mixed");const ae=G.filter(ce=>!(ee.get(ce).layout&&ee.get(ce).layout.lockVisible));ae.length||ie.setAttribute("disabled",""),this.off.push(X(ie,"change",()=>{const ce=this.host;ie.checked?w(ce.showColumns)&&ce.showColumns(ae):w(ce.hideColumns)&&ce.hideColumns(ae),this.refresh()})),Y.appendChild(ie);const fe=_(this.doc,"span",{class:`${x.panel}__bandTitle`,text:q});if(Y.appendChild(fe),w(this.host.renameGroup)){const ce=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("columngroup.rename"),attrs:{type:"button","aria-label":this.t("panel.bandRenameFor",{band:q})}});this.off.push(X(ce,"click",()=>this.startBandRename(Y,fe,N))),Y.appendChild(ce)}if(w(this.host.dissolveGroup)){const ce=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("columngroup.dissolve"),attrs:{type:"button","aria-label":this.t("panel.bandDissolveFor",{band:q})}});this.off.push(X(ce,"click",()=>this.dissolveBand(N.id))),Y.appendChild(ce)}return this.off.push(X(Y,"keydown",ce=>this.onBandKey(ce,N,Y))),this.off.push(X(Y,"dragover",ce=>{!this.dragging||!w(this.host.groupColumns)||this.bandOf(this.dragging)===N.id||(w(ce.preventDefault)&&ce.preventDefault(),Y.setAttribute("data-drop","into"))})),this.off.push(X(Y,"dragleave",()=>Y.removeAttribute("data-drop"))),this.off.push(X(Y,"drop",ce=>{w(ce.preventDefault)&&ce.preventDefault();const te=this.dragging;this.dragging=null,this.clearDropMark(),!(!te||!w(this.host.groupColumns)||this.bandOf(te)===N.id)&&this.joinBand(te,N.id)})),Y}toggleBand(P){this.collapsed.has(P)?this.collapsed.delete(P):this.collapsed.add(P),this.paintList(),this.focusBand(P)}focusBand(P){const k=this.list&&this.list.querySelector?this.list.querySelector(`[data-band-row="${z(P)}"]`):null;k&&w(k.focus)&&k.focus()}dissolveBand(P){if(!w(this.host.dissolveGroup))return;const k=this.bandName(P);this.collapsed.delete(P),this.host.dissolveGroup(P),this.announce(this.t("a11y.group.dissolved",{group:k}),{repeat:!0}),this.refresh()}startBandRename(P,k,N){const G=_(this.doc,"input",{class:`${x.panel}__bandRename`,attrs:{type:"text","aria-label":this.t("columngroup.rename")}});G.value=N.title||"";let q=!1;const Y=J=>{q||(q=!0,J?(this.host.renameGroup(N.id,G.value),this.announce(this.t("a11y.group.renamed",{group:G.value}),{repeat:!0}),this.refresh()):this.paintList(),this.focusBand(N.id))};this.off.push(X(G,"keydown",J=>{J.key==="Enter"?(w(J.preventDefault)&&J.preventDefault(),Y(!0)):J.key==="Escape"&&(w(J.preventDefault)&&J.preventDefault(),Y(!1))})),this.off.push(X(G,"blur",()=>Y(!0))),k.parentNode&&k.parentNode.replaceChild(G,k),w(G.focus)&&G.focus(),w(G.select)&&G.select()}onBandKey(P,k,N){if(P.target&&P.target!==N)return;const G=P.key;G==="Enter"?(w(P.preventDefault)&&P.preventDefault(),this.toggleBand(k.id)):G==="Delete"?(w(P.preventDefault)&&P.preventDefault(),this.dissolveBand(k.id)):(G==="ArrowUp"||G==="ArrowDown")&&(w(P.preventDefault)&&P.preventDefault(),this.walk(N,G==="ArrowUp"))}walk(P,k){const N=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],G=N.indexOf(P),q=N[G+(k?-1:1)];q&&w(q.focus)&&q.focus()}onRowKey(P,k){const N=P&&P.key,G=v.zoneKeys[String(N).toLowerCase()];if(G&&!P.ctrlKey&&!P.metaKey&&!P.altKey){w(P.preventDefault)&&P.preventDefault(),this.toggleZone(G,k);return}if(N!=="ArrowUp"&&N!=="ArrowDown")return;const q=N==="ArrowUp",Y=this.columns().map(fe=>fe.id),J=Y.indexOf(k.id);if(J<0)return;if(w(P.preventDefault)&&P.preventDefault(),!P.shiftKey){const fe=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col], [data-band-row]")]:[],ce=fe.findIndex(oe=>oe.getAttribute("data-col")===k.id),te=fe[ce+(q?-1:1)];te&&w(te.focus)&&te.focus();return}const ee=k.layout&&(k.layout.movable===!1||k.layout.lockPosition),re=String(k.title||k.id||"");if(ee){this.announce(this.t("a11y.panel.cannotMove",{column:re}),{repeat:!0});return}const ie=Y[J+(q?-1:1)];if(!ie){this.announce(this.t(q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:re}),{repeat:!0});return}this.moveColumn(k.id,ie,q),this.announce(this.t("a11y.panel.moved",{column:re,at:q?J:J+2,of:Y.length}),{repeat:!0});const ae=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${z(k.id)}"]`):null;ae&&w(ae.focus)&&ae.focus()}toggleZone(P,k){const N=this.titleOf(k.id),G=this.t(v.zoneLabel[P]||"panel.zone.group");if(this.zoneColumns(P).includes(k.id)){this.dropFromZone(P,k.id),this.announce(this.t("a11y.panel.removedFrom",{column:N,list:G}),{repeat:!0}),this.restoreFocus(k.id);return}if(this.addToZone(P,k.id)){this.announce(this.t("a11y.panel.addedTo",{column:N,list:G}),{repeat:!0}),this.restoreFocus(k.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:N,list:G}),{repeat:!0})}restoreFocus(P){const k=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${z(P)}"]`):null;k&&w(k.focus)&&k.focus()}announce(P,k){const N=this.host||{};w(N.announce)&&N.announce(P,k)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const P of this.list.querySelectorAll("[data-drop]"))P.removeAttribute("data-drop")}moveColumn(P,k,N){const G=this.host||{};w(G.moveColumn)&&(G.moveColumn(P,k,N),this.refresh())}buildZone(P,k){const N=_(this.doc,"div",{class:`${x.panel}__zone`,attrs:{"data-zone":P,role:"group","aria-label":k}});N.appendChild(_(this.doc,"div",{class:`${x.panel}__zoneTitle`,text:k}));const G=this.zoneColumns(P);let q=v.zoneAbout[P]||"";P==="values"&&G.length&&!this.zoneColumns("group").length&&(q+=" Add a row group to see them."),q&&N.appendChild(_(this.doc,"div",{class:`${x.panel}__zoneAbout`,text:q}));const Y=_(this.doc,"div",{class:`${x.panel}__zoneBody`});G.length||Y.appendChild(_(this.doc,"span",{class:`${x.panel}__zoneHint`,text:this.t(v.zoneHint[P]||"panel.zoneHint.any")})),P==="values"&&Y.classList.add(`${x.panel}__zoneBody--rows`);for(const J of G){const ee=_(this.doc,"span",{class:[x.chip,P==="values"?`${x.chip}--row`:""]});if(ee.appendChild(_(this.doc,"span",{class:`${x.chip}__label`,text:this.titleOf(J)})),P==="values"&&w(this.host.setValueAggregation)){const ie=w(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",ae=_(this.doc,"select",{class:`${x.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const fe of v.aggregations)ae.appendChild(_(this.doc,"option",{text:this.t(`total.${fe.name}`),attrs:{value:fe.name,selected:fe.name===ie?"":null}}));ae.value=ie,this.off.push(X(ae,"change",()=>{this.host.setValueAggregation(J,ae.value),this.refresh()})),ee.appendChild(ae)}const re=_(this.doc,"button",{class:x.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(X(re,"click",()=>this.dropFromZone(P,J))),ee.appendChild(re),Y.appendChild(ee)}return this.off.push(X(N,"dragover",J=>{w(J.preventDefault)&&J.preventDefault(),N.setAttribute("data-over","true")})),this.off.push(X(N,"dragleave",()=>N.removeAttribute("data-over"))),this.off.push(X(N,"drop",J=>{w(J.preventDefault)&&J.preventDefault(),N.removeAttribute("data-over"),this.dragging&&this.addToZone(P,this.dragging)})),N.appendChild(Y),N}static aggregations=Object.freeze(Object.keys(y).map(P=>({name:P})));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(P){const k=v.zoneApi[P],N=this.host;return k&&w(N[k.read])?N[k.read]()||[]:[]}titleOf(P){const k=this.columns().find(N=>N.id===P);return String(k&&(k.title||k.id)||P)}addToZone(P,k){const N=v.zoneApi[P],G=this.columns().find(Y=>Y.id===k);if(!N||!G||G[N.permission]===!1||!w(this.host[N.write]))return!1;const q=this.zoneColumns(P);return q.includes(k)?!1:(this.host[N.write]([...q,k]),this.refresh(),!0)}dropFromZone(P,k){const N=v.zoneApi[P];return!N||!w(this.host[N.write])?!1:(this.host[N.write](this.zoneColumns(P).filter(G=>G!==k)),this.refresh(),!0)}setVisible(P,k){const N=this.host;k&&w(N.showColumns)?N.showColumns([P]):!k&&w(N.hideColumns)&&N.hideColumns([P])}}class R extends S{open=new Set;query="";#e=!1;#t=!1;refresh(){if(this.#e){this.#t=!0;return}this.#e=!0;try{do this.#t=!1,this.#n();while(this.#t)}finally{this.#e=!1}}#n(){const P=this.root;if(!P)return;for(const ee of this.off)ee();this.off.length=0,W(P);const k=this.host,N=(w(k.columns)?k.columns():[]).filter(ee=>!(ee.filter&&ee.filter.enabled===!1));if(!w(k.filterFor))return;const G=N.filter(ee=>this.isFiltered(ee.id));P.appendChild(this.buildSearch()),P.appendChild(this.buildSummary(G.length,N.length));const q=this.query.trim().toLowerCase(),Y=q?N.filter(ee=>String(ee.title||ee.id).toLowerCase().includes(q)):N;if(!Y.length){P.appendChild(_(this.doc,"p",{class:`${x.panel}__empty`,text:q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=_(this.doc,"div",{class:`${x.panel}__filters`});for(const ee of Y)J.appendChild(this.buildSection(ee));P.appendChild(J)}isFiltered(P){const k=this.host;return w(k.isFiltered)?k.isFiltered(P)===!0:!1}buildSearch(){const P=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return P.value=this.query,this.off.push(X(P,"input",()=>{this.query=P.value||"",this.refresh();const k=this.root&&this.root.querySelector?this.root.querySelector(`.${x.panel}__search`):null;k&&w(k.focus)&&k.focus()})),P}buildSummary(P,k){const N=_(this.doc,"div",{class:`${x.panel}__filterSummary`});if(N.appendChild(_(this.doc,"span",{class:`${x.panel}__filterCount`,text:P?this.t("panel.filterSummaryActive",{active:P,total:k}):this.t("panel.filterSummaryNone",{total:k}),attrs:{"data-active":P?"true":"false"}})),!P)return N;const G=_(this.doc,"button",{class:`${x.panel}__clearAll`,text:this.t("panel.clearAll"),attrs:{type:"button"}});return this.off.push(X(G,"click",()=>{w(this.host.clearAllFilters)&&this.host.clearAllFilters(),this.refresh()})),N.appendChild(G),N}buildSection(P){const k=P.id,N=String(P.title||k),G=this.isFiltered(k),q=this.open.has(k),Y=_(this.doc,"section",{class:`${x.panel}__filter`,attrs:{"data-col":k,"data-filtered":G?"true":null}}),J=_(this.doc,"button",{class:`${x.panel}__filterTitle`,attrs:{type:"button","aria-expanded":q?"true":"false",title:this.t(G?"panel.filteredBy":"panel.filterBy",{column:N})},children:[u(this.doc,q?"chevronDown":"chevronRight",{className:`${x.panel}__twisty`}),_(this.doc,"span",{class:`${x.panel}__filterName`,text:N})]});G&&J.appendChild(_(this.doc,"span",{class:`${x.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const ee=_(this.doc,"div",{class:`${x.panel}__filterBody`,style:{display:q?"":"none"}}),re=()=>{if(ee.firstChild)return;const ie=this.host.filterFor(k);ie&&w(ie.element)&&ee.appendChild(ie.element())};if(this.off.push(X(J,"click",()=>{const ie=this.open.has(k);ie?this.open.delete(k):this.open.add(k),J.setAttribute("aria-expanded",ie?"false":"true"),ee.style.display=ie?"none":"";const ae=J.firstElementChild;ae&&h(ae,ie?"chevronRight":"chevronDown"),ie||re()})),Y.appendChild(J),G){const ie=_(this.doc,"button",{class:`${x.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:N}),title:this.t("panel.clearFilter")},children:[u(this.doc,"close",{className:x.icon})]});this.off.push(X(ie,"click",ae=>{w(ae.stopPropagation)&&ae.stopPropagation(),w(this.host.clearFilter)&&this.host.clearFilter(k),this.refresh()})),Y.appendChild(ie)}return Y.appendChild(ee),q&&re(),Y}}class O extends S{refresh(){const P=this.root;if(!P)return;if(this.box){const q=w(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==q&&(this.box.value=q),this.paintCount();return}for(const q of this.off)q();this.off.length=0,W(P);const k=w(this.host.quickFilter)?this.host.quickFilter():"",N=_(this.doc,"input",{class:`${x.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});N.value=k||"",this.off.push(X(N,"input",()=>{w(this.host.setQuickFilter)&&this.host.setQuickFilter(N.value),this.paintCount()})),P.appendChild(N),this.box=N;const G=_(this.doc,"button",{class:`${x.panel}__link`,text:this.t("panel.clear"),attrs:{type:"button"}});this.off.push(X(G,"click",()=>{N.value="",w(this.host.setQuickFilter)&&this.host.setQuickFilter(""),this.paintCount(),w(N.focus)&&N.focus()})),P.appendChild(G),this.count=_(this.doc,"p",{class:`${x.panel}__count`}),P.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){A(()=>{this.box&&w(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const P=w(this.host.rowCount)?this.host.rowCount():null,k=w(this.host.totalRowCount)?this.host.totalRowCount():null;if(P===null||k===null||P===void 0){this.count.textContent="";return}this.count.textContent=P===k?this.t("count.rows",{count:k}):this.t("panel.rowsOf",{shown:P,total:k})}}const F=Object.freeze({columns:v,filters:R,views:t,quick:O,formatting:o,statistics:l,regression:m,compare:f,insights:p}),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"}),T=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class L{panels=[];actions=[];root=null;openPanel=null;off=[];t(P,k){return(this.messages&&typeof this.messages.t=="function"?this.messages:H).t(P,k)}init(P){const k=P||{};this.doc=$(k),this.host=k.host||{},this.grid=k.grid||null,this.messages=k.messages||k.grid&&k.grid.messages||H,this.icons=k.icons===void 0?k.side==="left":!!k.icons,this.side=k.side==="left"?"left":"right",this.root=_(this.doc,"div",{class:[x.panel,`${x.panel}--${this.side}`,this.icons?`${x.panel}--icons`:null]}),this.tabs=_(this.doc,"div",{class:`${x.panel}__tabs`,attrs:{role:"tablist"}}),this.body=_(this.doc,"div",{class:`${x.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=_(this.doc,"div",{class:`${x.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const q of Array.isArray(k.actions)?k.actions:[])this.registerAction(q);const N=k.registry||{},G=Array.isArray(k.panels)&&k.panels.length?k.panels:["columns","filters"];for(const q of G){const Y=q!==null&&typeof q=="object",J=Y?q.name:q,ee=w(J),re=ee?J.name||"panel":String(J),ie=Y&&w(q.Ctor)?q.Ctor:ee?J:N[re]||F[re];ie&&this.registerPanel(re,ie,Y?q:{})}k.openPanel&&this.show(k.openPanel)}registerPanel(P,k,N){const G=new k;G.init({document:this.doc,host:this.host,grid:this.grid,props:N&&N.props||{}});const q=N&&N.title||P,Y=N&&N.icon||P,J=_(this.doc,"button",{class:`${x.panel}__tab`,text:this.icons?null:q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":P,title:this.icons?q:null,"aria-label":this.icons?q:null}});return this.icons&&J.appendChild(u(this.doc,Y,{className:`${x.panel}__icon`})),this.off.push(X(J,"click",()=>this.toggle(P))),this.tabs.appendChild(J),this.panels.push({name:P,title:q,panel:G}),G}registerAction(P){if(!P||!P.name)return null;if(P.separator)return this.actionGroup.appendChild(_(this.doc,"div",{class:`${x.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const k=_(this.doc,"button",{class:`${x.panel}__action`,text:this.icons?null:w(P.title)?String(P.title()):P.title,attrs:{type:"button","data-action":P.name,title:w(P.title)?null:P.title,"aria-label":w(P.title)?null:P.title}});if(this.icons){const q=(w(P.icon)?P.icon():P.icon)||(a(P.name)?P.name:"blank");k.appendChild(u(this.doc,q,{className:`${x.panel}__icon`})),k.setAttribute("data-icon",q)}const N=X(k,"click",()=>{w(P.enabled)&&!P.enabled()||(w(P.run)&&P.run(),this.paintActions())});return this.off.push(N),this.actionGroup.appendChild(k),this.actions.push({...P,button:k,offClick:N}),this.paintActions(),k}removeAction(P){const k=this.actions.findIndex(G=>G.name===P);if(k<0)return!1;const N=this.actions[k];return w(N.offClick)&&N.offClick(),N.button&&N.button.parentNode&&N.button.parentNode.removeChild(N.button),this.actions.splice(k,1),!0}paintActions(){for(const P of this.actions){if(!P.button)continue;const k=w(P.enabled)?!!P.enabled():!0;if(P.button.disabled=!k,P.button.setAttribute("aria-disabled",k?"false":"true"),w(P.active)&&P.button.setAttribute("aria-pressed",P.active()?"true":"false"),w(P.title)){const N=String(P.title());P.button.setAttribute("title",N),P.button.setAttribute("aria-label",N),!this.icons&&P.button.textContent!==N&&(P.button.textContent=N)}if(this.icons&&w(P.icon)){const N=String(P.icon());P.button.getAttribute("data-icon")!==N&&(W(P.button),P.button.appendChild(u(this.doc,N,{className:`${x.panel}__icon`})),P.button.setAttribute("data-icon",N))}}}show(P){const k=this.panels.find(N=>N.name===P);return k?(W(this.body),w(k.panel.refresh)&&k.panel.refresh(),this.body.appendChild(k.panel.element()),this.openPanel=P,this.paintTabs(),w(k.panel.focus)&&k.panel.focus(),!0):!1}hide(){W(this.body),this.openPanel=null,this.paintTabs()}toggle(P){this.openPanel===P?this.hide():this.show(P)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let P=0;P<this.tabs.childNodes.length;P++){const k=this.tabs.childNodes[P];k&&k.setAttribute&&k.setAttribute("aria-selected",k.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const P=this.panels.find(k=>k.name===this.openPanel);P&&w(P.panel.refresh)&&!this.#e(P.panel)&&P.panel.refresh(),this.paintActions()}#e(P){const k=this.doc&&this.doc.activeElement;if(!k||k===this.doc.body)return!1;const N=w(P.element)?P.element():null;return!!(N&&w(N.contains)&&N.contains(k))}destroy(){for(const P of this.off)P();this.off.length=0;for(const P of this.panels)w(P.panel.destroy)&&P.panel.destroy();this.panels=[],this.root=null}}const E=L;function D(I,P){if(!P.getBoundingClientRect||typeof I.clientY!="number")return!0;const k=P.getBoundingClientRect();return I.clientY<k.top+k.height/2}}),Fe("packages/dom/src/ui/groupbyzone.js",function(e,K){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return A}});const x=K("packages/dom/src/ui/panelbase.js").ToolPanelBase,z=K("packages/dom/src/editors/common.js"),$=z.CLS,_=z.el,X=z.on,W=z.clear,V=z.cssEscape,B=K("packages/core/src/internal/util.js").isFunction,w="text/x-lattice-col";class A extends x{dragging=null;#e=[];init(u){this.ctx=u,this.doc=u.document,this.host=u.host||{},this.props=u.props||{},this.root=_(this.doc,"div",{class:$.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const u=this.host;return B(u.columns)?u.columns()||[]:u.columns&&B(u.columns.all)?u.columns.all():[]}groups(){return B(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(u){B(this.host.setGroupBy)&&this.host.setGroupBy(u)}titleOf(u){const h=this.columns().find(a=>a.id===u);return String(h&&(h.title||h.id)||u)}canGroup(u){const h=this.columns().find(a=>a.id===u);return!!h&&h.allowGroup!==!1&&!h.generated}announce(u,h){B(this.host.announce)&&this.host.announce(u,h)}refresh(){const u=this.root;if(!u)return;for(const r of this.off)r();this.off.length=0,W(u),u.appendChild(_(this.doc,"span",{class:$.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const h=this.groups(),a=_(this.doc,"div",{class:$.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});h.length||a.appendChild(_(this.doc,"span",{class:$.groupZoneHint,text:this.t("groupZone.hint")})),h.forEach((r,t)=>a.appendChild(this.#t(r,t,h.length))),u.appendChild(a),this.chips=a,u.appendChild(this.#i(h)),this.off.push(X(u,"dragover",r=>{this.dragging==null&&!this.#l(r)||(B(r.preventDefault)&&r.preventDefault(),u.setAttribute("data-over","true"))})),this.off.push(X(u,"dragleave",()=>u.removeAttribute("data-over"))),this.off.push(X(u,"drop",r=>{B(r.preventDefault)&&r.preventDefault(),u.removeAttribute("data-over");const t=this.#l(r)||this.dragging;t!=null&&this.#o(t,this.groups().length)})),this.#s()}#t(u,h,a){const r=this.titleOf(u),t=_(this.doc,"div",{class:[$.chip,$.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":u,"aria-label":this.t("groupZone.chip",{column:r,at:h+1,of:a})}});t.appendChild(_(this.doc,"span",{class:$.groupZoneChipText,text:r}));const n=_(this.doc,"button",{class:$.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:r})}});return this.off.push(X(n,"click",()=>this.#r(u))),t.appendChild(n),this.off.push(X(t,"dragstart",o=>{this.dragging=u,o.dataTransfer&&B(o.dataTransfer.setData)&&o.dataTransfer.setData(w,u)})),this.off.push(X(t,"dragend",()=>{this.dragging=null})),this.off.push(X(t,"dragover",o=>{const d=this.#l(o)||this.dragging;d==null||d===u||B(o.preventDefault)&&o.preventDefault()})),this.off.push(X(t,"drop",o=>{const d=this.#l(o)||this.dragging;d!=null&&(B(o.preventDefault)&&o.preventDefault(),B(o.stopPropagation)&&o.stopPropagation(),this.#o(d,h))})),this.off.push(X(t,"keydown",o=>this.#n(o,u,h))),t}#n(u,h,a){const r=u&&u.key,t=this.groups();if(r==="Delete"||r==="Backspace"){B(u.preventDefault)&&u.preventDefault(),this.#r(h,t,a);return}const n=r==="ArrowLeft"||r==="ArrowUp",o=r==="ArrowRight"||r==="ArrowDown",d=r==="Home",l=r==="End";if(!n&&!o&&!d&&!l)return;if(B(u.preventDefault)&&u.preventDefault(),u.shiftKey&&(n||o)){const c=a+(n?-1:1);if(c<0||c>=t.length){this.announce(this.t(n?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(h)}),{repeat:!0});return}const f=t.slice();f.splice(a,1),f.splice(c,0,h),this.setGroups(f),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(h),at:c+1,of:f.length}),{repeat:!0}),this.#a(h);return}let i=a+(n?-1:o?1:0);d&&(i=0),l&&(i=t.length-1);const m=t[i];m&&this.#a(m)}#r(u,h=this.groups(),a=h.indexOf(u)){const r=this.titleOf(u);this.setGroups(h.filter(n=>n!==u)),this.announce(this.t("a11y.panel.removedFrom",{column:r,list:this.t("panel.zone.group")}),{repeat:!0});const t=this.groups();t.length?this.#a(t[Math.min(a,t.length-1)]):this.#u()}#o(u,h){if(!this.canGroup(u)){this.announce(this.t("a11y.panel.cannotAddTo",{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0});return}const a=this.groups(),r=a.indexOf(u),t=a.slice();r>=0&&(t.splice(r,1),r<h&&(h-=1)),t.splice(Math.max(0,Math.min(h,t.length)),0,u),this.setGroups(t);const n=t.indexOf(u);this.announce(this.t(r>=0?"a11y.panel.moved":"a11y.panel.addedTo",r>=0?{column:this.titleOf(u),at:n+1,of:t.length}:{column:this.titleOf(u),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(u)}#i(u){const h=new Set(u),a=_(this.doc,"label",{class:$.groupZoneAdd}),r=_(this.doc,"select",{class:$.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});r.appendChild(_(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const t of this.columns())h.has(t.id)||!this.canGroup(t.id)||r.appendChild(_(this.doc,"option",{text:this.titleOf(t.id),attrs:{value:t.id}}));return this.off.push(X(r,"change",()=>{const t=r.value;t&&this.#o(t,this.groups().length)})),this.adderSelect=r,a.appendChild(r),a}#s(){for(const h of this.#e)h();this.#e.length=0;const u=this.props&&this.props.header;if(!(!u||!B(u.querySelectorAll)))for(const h of u.querySelectorAll("[data-col]")){const a=B(h.getAttribute)?h.getAttribute("data-col"):null;!a||!this.canGroup(a)||(B(h.setAttribute)&&h.setAttribute("draggable","true"),this.#e.push(X(h,"dragstart",r=>{this.dragging=a,r.dataTransfer&&B(r.dataTransfer.setData)&&r.dataTransfer.setData(w,a)})),this.#e.push(X(h,"dragend",()=>{this.dragging=null})))}}#l(u){const h=u&&u.dataTransfer;if(h&&B(h.getData)){const a=h.getData(w);if(a)return a}return null}#a(u){const h=this.chips&&B(this.chips.querySelector)?this.chips.querySelector(`[data-col="${V(u)}"]`):null;h&&B(h.focus)&&h.focus()}#u(){this.adderSelect&&B(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const u of this.#e)u();this.#e.length=0,super.destroy()}}}),Fe("packages/dom/src/ui/tooltip.js",function(e,K){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/internal/util.js").isFunction;class H{root=null;init(g){this.doc=g.document,this.root=$(this.doc,"div",{class:`${x.tooltip}__text`}),this.update(g.content)}update(g){if(!this.root)return;const u=g==null?"":String(g);this.root.textContent!==u&&(this.root.textContent=u)}element(){return this.root}destroy(){this.root=null}}class B{root=null;component=null;timer=null;target=null;off=[];constructor(g){const u=g||{};this.doc=z(u),this.host=u.host||this.doc.body,this.delay=u.delay??400,this.hideDelay=u.hideDelay??0,this.components={text:H,...u.components||{}}}show(g){this.cancelTimer();const u=g.delay??this.delay;if(!u){this.showNow(g);return}this.timer=setTimeout(()=>{this.timer=null,this.showNow(g)},u)}showNow(g){const u=g.component||"text",h=typeof u=="function"?u:this.components[u]||H;return this.root||(this.root=$(this.doc,"div",{class:x.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==h?(this.component&&V(this.component.destroy)&&this.component.destroy(),X(this.root),this.component=new h,this.componentCtor=h,this.component.init({document:this.doc,content:g.content,...g.props||{}}),this.root.appendChild(this.component.element())):V(this.component.update)&&this.component.update(g.content),this.target=g.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!V(this.target.getBoundingClientRect))return;const g=this.target.getBoundingClientRect(),u=this.doc.defaultView||{};this.root.style.left=`${g.left+(u.scrollX||0)}px`,this.root.style.top=`${g.bottom+(u.scrollY||0)}px`}hide(){this.cancelTimer(),this.root&&(this.root.setAttribute("data-open","false"),this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.target=null)}cancelTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}attach(g,u,h){const a=()=>this.show({target:g,content:u(),...h||{}}),r=()=>this.hide(),t=[_(g,"mouseenter",a),_(g,"mouseleave",r),_(g,"focus",a),_(g,"blur",r)],n=()=>{for(const o of t)o()};return this.off.push(n),n}destroy(){this.hide();for(const g of this.off)g();this.off.length=0,this.component&&V(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const w=B}),Fe("packages/dom/src/ui/pagination.js",function(e,K){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.documentFor,$=Q.el,_=Q.on,X=Q.clear,V=K("packages/core/src/i18n/index.js").defaultMessages,B=K("packages/core/src/internal/util.js").isFunction;function w(u){const h=Math.max(1,Number(u.pageSize)||100),a=u.total==null?null:Math.max(0,Number(u.total)),r=a==null?null:Math.max(1,Math.ceil(a/h)),t=Math.max(0,r==null?Number(u.page)||0:Math.min(Number(u.page)||0,r-1)),n=a===0?0:t*h+1,o=a==null?(t+1)*h:Math.min(a,(t+1)*h);return{page:t,pageSize:h,pageCount:r,from:n,to:o,first:t===0,last:r==null?u.hasMore!==!0:t>=r-1,total:a}}class A{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(h){const a=h||{};this.doc=z(a),this.host=a.host||{},this.pageSize=Number(a.pageSize)||100;const r=Array.isArray(a.pageSizes)&&a.pageSizes.length?[...a.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!r.includes(this.pageSize)&&r.push(this.pageSize),this.pageSizes=r.sort((t,n)=>t-n),this.page=Number(a.page)||0,this.total=a.total===void 0?null:a.total,this.locale=a.locale,this.messages=a.messages||null,this.onChange=a.onChange||null,this.root=$(this.doc,"nav",{class:x.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(h,a){const r=this.messages;return(r&&typeof r.t=="function"?r:V).t(h,a)}element(){return this.root}model(){return w({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(h){h.total!==void 0&&(this.total=h.total),h.counting!==void 0&&(this.counting=h.counting===!0),h.hasMore!==void 0&&(this.hasMore=h.hasMore===!0),h.page!==void 0&&(this.page=Number(h.page)||0),this.paint()}goTo(h){const a=this.page;this.page=h;const r=this.model();return this.page=r.page,this.paint(),this.page!==a&&B(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 h=this.model();return h.pageCount==null?this.page:this.goTo(h.pageCount-1)}setPageSize(h){const a=this.page*this.pageSize;this.pageSize=Math.max(1,Number(h)||1),this.page=Math.floor(a/this.pageSize),this.paint(),B(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const h=this.root;if(!h)return;for(const i of this.off)i();this.off.length=0,X(h);const a=this.model(),r=$(this.doc,"select",{class:`${x.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const i of this.pageSizes)r.appendChild($(this.doc,"option",{text:String(i),attrs:{value:i}}));r.value=String(this.pageSize),this.off.push(_(r,"change",()=>this.setPageSize(Number(r.value)))),h.appendChild(r);const t=a.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:a.from,to:a.to}):this.t("pagination.summary",{from:a.from,to:a.to,total:a.total});h.appendChild($(this.doc,"span",{class:`${x.pagination}__summary`,text:t}));const n=(i,m,c,f)=>{const s=$(this.doc,"button",{class:`${x.pagination}__button`,text:i,attrs:{type:"button","aria-label":f,disabled:c?"":null}});return c||this.off.push(_(s,"click",m)),s};h.appendChild(n("«",()=>this.goTo(0),a.first,this.t("pagination.first"))),h.appendChild(n("‹",()=>this.previous(),a.first,this.t("pagination.previous")));const o=$(this.doc,"span",{class:`${x.pagination}__page`});o.appendChild($(this.doc,"span",{text:`${this.t("pagination.page")} `}));const d=$(this.doc,"input",{class:`${x.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":a.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:a.pageCount}),size:String(Math.max(2,String(a.pageCount??a.page+1).length))}});d.value=String(a.page+1);const l=()=>{const i=parseInt(String(d.value).trim(),10);if(!Number.isFinite(i)){d.value=String(this.model().page+1);return}this.goTo(i-1)};this.off.push(_(d,"keydown",i=>{i.key==="Enter"?(l(),i.preventDefault?.()):i.key==="Escape"?(d.value=String(this.model().page+1),d.blur?.()):i.stopPropagation?.()})),this.off.push(_(d,"blur",()=>l())),this.off.push(_(d,"focus",()=>d.select?.())),o.appendChild(d),a.pageCount!=null&&o.appendChild($(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:a.pageCount})}`})),h.appendChild(o),h.appendChild(n("›",()=>this.next(),a.last,this.t("pagination.next"))),h.appendChild(n("»",()=>this.last(),a.last||a.pageCount==null,this.t("pagination.last")))}destroy(){for(const h of this.off)h();this.off.length=0,this.root=null}}const g=A}),Fe("packages/dom/src/ui/overlay.js",function(e,K){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const Q=K("packages/dom/src/editors/common.js"),x=Q.CLS,z=Q.documentFor,$=Q.el,_=Q.clear,W=K("packages/core/src/internal/util.js").isFunction,H=K("packages/core/src/i18n/index.js").defaultMessages;function B(a,r){const t=a&&a.grid&&a.grid.messages;return(t&&W(t.t)?t:H).t(r)}class w{root=null;init(r){this.doc=r.document,this.root=$(this.doc,"div",{class:`${x.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[$(this.doc,"span",{class:`${x.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),$(this.doc,"span",{class:`${x.overlay}__message`,text:r.message||B(r,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class A{root=null;init(r){this.doc=r.document,this.root=$(this.doc,"div",{class:`${x.overlay}__empty`,attrs:{role:"status"},children:[$(this.doc,"span",{class:`${x.overlay}__message`,text:r.message||B(r,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const g=Object.freeze({loading:w,empty:A});class u{root=null;slot=null;component=null;current=null;init(r){const t=r||{};this.doc=z(t),this.components={...g,...t.components||{}},this.root=$(this.doc,"div",{class:x.overlay,attrs:{"data-open":"false"}}),this.slot=$(this.doc,"div",{class:`${x.overlay}__slot`}),this.root.appendChild(this.slot),t.host&&t.host.appendChild(this.root)}element(){return this.root}show(r,t){const n=typeof r=="function"?r:this.components[r];return n?(this.hide(),this.component=new n,this.component.init({document:this.doc,message:t&&t.message,...t&&t.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof r=="string"?r:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&W(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&_(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(r,t){this.components[r]=t}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const h=u}),Fe("packages/dom/src/ui/index.js",function(e,K){"use strict";const Q=K("packages/dom/src/ui/statusbar.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return Q.StatusBar}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return Q.StatusPanel}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return Q.RowCountPanel}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return Q.SelectedCountPanel}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return Q.AggregationPanel}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return Q.ProgressPanel}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return Q.UpdatesPanel}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return Q.CommentsPanel}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return Q.statusPanels}}),Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return Q.aggregate}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return Q.formatCount}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return Q.formatNumber}});const x=K("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return x.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return x.resolveMenuItems}});const z=K("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return z.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return z.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return z.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return z.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return z.toolPanels}});const $=K("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return $.GroupByZone}});const _=K("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return _.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return _.TextTooltip}});const X=K("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return X.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return X.pageModel}});const W=K("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return W.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return W.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return W.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return W.overlays}})}),Fe("packages/dom/src/ui/celltooltip.js",function(e,K){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,z=Q.el,$=Q.on,_=Q.clear,X=K("packages/core/src/internal/util.js"),W=X.isFunction,V=X.warnOnce,B=K("packages/dom/src/cell/sanitise.js").sanitiseHtml,A=K("packages/dom/src/detailhost.js").insideDetail,u=K("packages/dom/src/renderer/renderer.js").displayIndexOf,h=K("packages/dom/src/renderer/viewport.js"),a=h.CLASS,r=h.NAMESPACE,n=K("packages/dom/src/themeof.js").carryTheme,o={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},d=400,l=140,i=6;let m=0;class c{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f=[];#p=!1;constructor(p){const b=p||{};this.#e=b.grid,this.#t=b.host,this.#n=b.viewport,this.#r=x(b),m+=1,this.#s=`lat-cell-tooltip-${m}`}mount(){const p=this.#n&&this.#n.root;if(!p||!W(p.addEventListener))return;const b=this.#e.on("cell:mouseover",y=>this.#b(y));W(b)&&this.#f.push(b);const S=this.#e.on("cell:mouseout",()=>this.#v());W(S)&&this.#f.push(S),this.#f.push($(p,"focusin",y=>this.#A(y))),this.#f.push($(p,"focusout",()=>this.#v())),this.#f.push($(this.#r,"keydown",y=>this.#w(y),!0));const j=this.#r.defaultView;j&&W(j.addEventListener)&&this.#f.push($(j,"scroll",()=>this.hide(),!0))}#m(){const p=W(this.#e.get)?this.#e.get("tooltip"):null,b=p&&typeof p=="object"?p:{},S=Number.isFinite(b.delay)&&b.delay>=0?Number(b.delay):d,j=b.maxWidth;return{delay:S,hideDelay:l,maxWidth:typeof j=="number"&&Number.isFinite(j)?`${j}px`:typeof j=="string"&&j?j:null}}#g(p){const b=p&&p.cell?p.cell.tooltip:null;return!b||typeof b!="object"||Array.isArray(b)||!W(b.render)&&!W(b.mount)?null:b}#y(p){if(!p||!W(p.closest))return null;const b=p.closest(`.${a.row}`);if(!b)return null;const S=u(b);if(S<0)return null;const j=this.#t.rowAt(S);if(!j)return null;const y=p.getAttribute("data-col");if(!y)return null;const v=this.#t.columns.get(y);return v?{row:j,key:j.key,index:S,colId:y,column:v,value:this.#t.cellValue?this.#t.cellValue(j,v):void 0,data:j.data,text:this.#t.cellText?this.#t.cellText(j,v):"",cell:p,grid:this.#e}:null}#b(p){const b=p&&p.target;if(!this.#g(p&&p.column)){this.#v();return}this.#S(b)}#A(p){const b=p&&p.target;if(!b||!W(b.closest)||A(b,this.#n.root))return;const S=b.closest(`.${a.cell}`);if(!S||S!==b){this.#v();return}const j=S.getAttribute("data-col"),y=j?this.#t.columns.get(j):null;if(!this.#g(y)){this.#v();return}this.#S(S)}#w(p){!p||p.key!=="Escape"||p.defaultPrevented||this.#l&&(W(p.preventDefault)&&p.preventDefault(),this.hide())}#S(p){if(this.#p||!p||(this.#L(),this.#l&&this.#a===p))return;this.#N();const{delay:b}=this.#m();if(!b){this.#M(p);return}this.#d=setTimeout(()=>{this.#d=null,this.#M(p)},b)}#v(){if(this.#N(),!this.#l||this.#h!==null)return;const{hideDelay:p}=this.#m();this.#h=setTimeout(()=>{this.#h=null,this.hide()},p)}#C(){if(this.#o)return this.#o;const p=this.#r,b=z(p,"div",{class:[r,o.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=z(p,"div",{class:o.body}),b.appendChild(this.#i),this.#f.push($(b,"mouseenter",()=>this.#L())),this.#f.push($(b,"mouseleave",()=>this.#v()));const S=p.body;return S&&W(S.appendChild)&&S.appendChild(b),this.#o=b,b}#O(p,b){const S=this.#i;if(_(S),p==null||p==="")return!1;if(typeof p=="string")return S.textContent=p,!0;if(typeof p=="object"){if(typeof p.nodeType=="number")return S.appendChild(p),!0;const j=p;if(typeof j.html=="string")return S.innerHTML=B(j.html),!0;if(j.title!==void 0||j.rows!==void 0||j.note!==void 0)return this.#P(j),!0}return V(`tooltip-content:${b}`,`Column '${b}' 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}#P(p){const b=this.#r,S=this.#i,j=v=>v==null?"":String(v);p.title!==void 0&&p.title!==null&&p.title!==""&&S.appendChild(z(b,"div",{class:o.title,text:j(p.title)}));const y=Array.isArray(p.rows)?p.rows:[];if(y.length){const v=z(b,"div",{class:o.rows});for(const R of y){if(!R||typeof R!="object")continue;const O=z(b,"div",{class:o.row});O.appendChild(z(b,"span",{class:o.label,text:j(R.label)})),O.appendChild(z(b,"span",{class:o.value,text:j(R.value)})),v.appendChild(O)}S.appendChild(v)}p.note!==void 0&&p.note!==null&&p.note!==""&&S.appendChild(z(b,"div",{class:o.note,text:j(p.note)}))}#M(p){if(this.#p)return;const b=this.#y(p);if(!b){this.hide();return}const S=this.#g(b.column);if(!S){this.hide();return}this.hide();const j=this.#C();n(j,this.#n&&this.#n.root);let y;if(W(S.render))try{y=S.render(b)}catch(O){V(`tooltip-render:${b.colId}`,`Column '${b.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const v=this.#O(y,b.colId);if(W(S.mount))try{S.mount(this.#i,b),this.#u=S}catch(O){V(`tooltip-mount:${b.colId}`,`Column '${b.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!v)return;const{maxWidth:R}=this.#m();R&&(j.style.maxWidth=R),this.#a=p,this.#l=!0,j.setAttribute("data-open","true"),this.#E(p),this.#T(p)}#E(p){if(!W(p.setAttribute))return;const b=W(p.getAttribute)?p.getAttribute("aria-describedby"):null;this.#c={cell:p,previous:b},p.setAttribute("aria-describedby",b?`${b} ${this.#s}`:this.#s)}#T(p){const b=this.#o;if(!b||!W(p.getBoundingClientRect))return;const S=this.#r.defaultView;if(!S)return;const j=p.getBoundingClientRect(),y=W(b.getBoundingClientRect)?b.getBoundingClientRect():{width:0,height:0},v=S.innerWidth||0,R=S.innerHeight||0,O=y.width||0,F=y.height||0;let C=j.bottom+i;const T=j.top-i-F;C+F>R-i&&T>=i&&(C=T),R&&(C=Math.max(i,Math.min(C,Math.max(i,R-F-i))));let L=j.left;v&&(L=Math.min(L,Math.max(i,v-O-i))),L=Math.max(i,L),b.style.left=`${Math.round(L)}px`,b.style.top=`${Math.round(C)}px`}hide(){if(this.#N(),this.#L(),!this.#l)return;if(this.#l=!1,this.#u&&W(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(b){V("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",b)}this.#u=null,this.#i&&_(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const p=this.#c;p&&W(p.cell.setAttribute)&&(p.previous?p.cell.setAttribute("aria-describedby",p.previous):W(p.cell.removeAttribute)&&p.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#N(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#L(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#p=!0;for(const p of this.#f)p();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const f=c}),Fe("packages/dom/src/platform.js",function(e,K){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return Q}});function Q(){const x=globalThis.navigator,z=String(x&&(x.userAgentData?.platform||x.platform)||"");return/mac|iphone|ipad/i.test(z)}}),Fe("packages/dom/src/columnmenu.js",function(e,K){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return b}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,_=K("packages/dom/src/platform.js").macLike,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/dom/src/ui/contextmenu.js").ContextMenu,B=K("packages/core/src/compute/total.js"),w=B.aggregatesFor,A=B.totalLabel,g=10,u=150;function h(S,j){const y=(ee,re)=>(S&&S.messages?S.messages:W).t(ee,re),v=S.columns.get(j);if(!v)return[];const R=S.sort.get(),O=R.find(ee=>ee.col===j),F=v.layout&&v.layout.pin,C=S.state.get().group||[],T=C.includes(j);if(v.generated&&Array.isArray(v.groupedIds))return n(S,v,C);const L=!v.sort||v.sort.enabled!==!1,E=!v.filter||v.filter.enabled!==!1,D=[];L&&D.push({name:y("menu.sortAscending"),icon:"↑",disabled:O&&O.dir==="asc",action:()=>S.sort.set([{col:j,dir:"asc"}])},{name:y("menu.sortDescending"),icon:"↓",disabled:O&&O.dir==="desc",action:()=>S.sort.set([{col:j,dir:"desc"}])},{name:y("menu.clearSort"),disabled:!O,action:()=>S.sort.set(R.filter(ee=>ee.col!==j))},{separator:!0}),E&&D.push({name:y("menu.filterEllipsis"),action:()=>S.emit("column:filter:open",{colId:j})},{separator:!0}),D.push({name:y("menu.columnStatistics"),action:()=>S.emit("column:profile:open",{colId:j})},{separator:!0}),D.push({name:y("menu.pinColumn"),children:[{name:y("menu.pinStart"),disabled:F==="start",action:()=>S.columns.pin(j,"start")},{name:y("menu.pinEnd"),disabled:F==="end",action:()=>S.columns.pin(j,"end")},{name:y("menu.unpin"),disabled:!F,action:()=>S.columns.pin(j,null)}]});const I=!(v.layout&&(v.layout.movable===!1||v.layout.lockPosition)),P=!(v.layout&&v.layout.resizable===!1),k=ee=>{const re=S.columns.get(ee);return Number(re&&re.layout&&re.layout.width)||u},N=S.columns.visible().filter(ee=>!ee.generated).map(ee=>ee.id),G=N.indexOf(j);if(D.push({name:y("menu.sizeToFit"),action:()=>S.columns.autoSize(j)},{name:y("menu.sizeAllToFit"),action:()=>S.columns.fit()},{name:y("menu.width"),disabled:!P,children:[{name:y("menu.narrower"),disabled:!P,action:()=>S.columns.resize(j,Math.max(1,k(j)-g))},{name:y("menu.wider"),disabled:!P,action:()=>S.columns.resize(j,k(j)+g)},{name:y("menu.autosize"),disabled:!P,action:()=>S.columns.autoSize(j)}]},{separator:!0},{name:y("menu.moveColumn"),disabled:!I,children:[{name:y("menu.moveLeft"),disabled:!I||G<=0,action:()=>S.columns.move(j,Math.max(0,G-1))},{name:y("menu.moveRight"),disabled:!I||G<0||G>=N.length-1,action:()=>S.columns.move(j,Math.min(N.length-1,G+1))},{name:y("menu.moveToStart"),disabled:!I||G<=0,action:()=>S.columns.move(j,0)},{name:y("menu.moveToEnd"),disabled:!I||G<0||G>=N.length-1,action:()=>S.columns.move(j,N.length-1)}]},{separator:!0}),v.allowGroup!==!1&&D.push({name:y(T?"menu.ungroup":"menu.groupBy"),action:()=>S.columns.group(T?C.filter(ee=>ee!==j):[...C,j])}),C.length&&D.push({name:y("menu.expandAll"),action:()=>S.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>S.rows.collapseAll()}),x(S.columns.groupColumns)){const ee=v.groupPath||[],re=ee.length?ee[ee.length-1]:null,ie=[{name:y("columngroup.group"),disabled:N.length<2||G<0,action:()=>{const ae=N[G+1]??N[G-1];if(!ae)return;const fe=(S.columns.get(ae)||{}).groupPath||[],ce=fe.length?fe[fe.length-1]:null;ce?S.columns.groupColumns([j],{groupId:ce}):S.columns.groupColumns([j,ae],{title:y("columngroup.newGroup")})}}];re&&ie.push({name:y("columngroup.dissolve"),action:()=>S.columns.dissolveGroup(re)}),D.push({separator:!0},...ie)}const q=S.state&&x(S.state.get)?S.state.get().pivot:null,Y=q&&q.columns||[],J=Y.includes(j);if(v.allowPivot!==!1&&D.push({name:y(J?"menu.unpivot":"menu.pivotBy"),action:()=>S.columns.pivot(J?Y.filter(ee=>ee!==j):[...Y,j])}),v.allowTotal!==!1)if(x(S.get)&&S.get("aggregateChooser")===!0)D.push(a(S,v,y));else{const re=!!v.total;D.push({name:y(re?"menu.stopTotalling":"menu.totalColumn"),action:()=>S.columns.setTotal(j,re?null:"sum")})}return D.push({name:y("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>S.columns.hide(j)}),D}function a(S,j,y){const v=j.id,R=typeof j.total=="string"?j.total:null,O=[{name:y("menu.aggregateNone"),checked:!j.total,action:()=>S.columns.setTotal(v,null)},{separator:!0},...w(j).map(F=>({name:A(F),checked:R===F,action:()=>S.columns.setTotal(v,F)})),{separator:!0},r(S,j,y,"group",y("menu.aggregateGroup")),r(S,j,y,"grand",y("menu.aggregateGrand"))];return{name:y("menu.aggregate"),children:O}}function r(S,j,y,v,R){const O=j.id,F=v==="grand"?j.grandTotal:j.groupTotal,C=typeof F=="string"?F:null,T=[{name:y("menu.aggregateSame"),checked:F==null,action:()=>S.columns.setTotal(O,null,{scope:v})},{separator:!0},...w(j).map(L=>({name:A(L),checked:C===L,action:()=>S.columns.setTotal(O,L,{scope:v})}))];return{name:R,children:T}}function t(S,j){const y=(C,T)=>(S&&S.messages?S.messages:W).t(C,T),v=S.columns.get(j);if(!v)return[];const R=S.redaction,O=!!(R&&R.has(j)),F=[];return R&&(F.push({name:y(O?"menu.stopRedacting":"menu.redactColumn"),action:()=>R.toggle(j)}),(R.list().length>1||R.active&&!O)&&F.push({name:y("menu.stopRedactingAll"),action:()=>R.clear()}),F.push({separator:!0})),F.push({name:y("menu.hideColumn"),disabled:v.layout&&v.layout.lockVisible===!0,action:()=>S.columns.hide(j)}),F}function n(S,j,y){const v=(T,L)=>(S&&S.messages?S.messages:W).t(T,L),R=y[0],O=S.sort.get(),F=R?O.find(T=>T.col===R):null,C=[];R&&C.push({name:v("menu.sortGroupsAscending"),icon:"↑",disabled:F&&F.dir==="asc",action:()=>S.sort.set([{col:R,dir:"asc"}])},{name:v("menu.sortGroupsDescending"),icon:"↓",disabled:F&&F.dir==="desc",action:()=>S.sort.set([{col:R,dir:"desc"}])},{separator:!0},{name:v("menu.filterGroups"),action:()=>S.emit("column:filter:open",{colId:j.id})},{separator:!0}),C.push({name:v("menu.expandAll"),action:()=>S.rows.expandAll()},{name:v("menu.collapseAll"),action:()=>S.rows.collapseAll()},{separator:!0});for(const T of y){const L=S.columns.get(T);C.push({name:`Remove "${L&&L.title||T}" from grouping`,action:()=>S.columns.group(y.filter(E=>E!==T))})}return C.push({name:v("menu.clearGrouping"),disabled:!y.length,action:()=>S.columns.group([])}),C}function o(){const S=globalThis.navigator&&globalThis.navigator.clipboard;return!!(S&&typeof S.readText=="function")}function d(S){return x(S.get)&&S.get("edit")===!1?!1:(S.columns&&x(S.columns.visible)?S.columns.visible():[]).some(y=>{const v=y&&y.edit;return v?v.enabled===void 0||x(v.enabled)?!0:v.enabled!==!1:!1})}function l(S,j){if(x(S.get)&&S.get("edit")===!1)return!1;const y=j&&j.edit;return y?y.enabled===void 0||x(y.enabled)?!0:y.enabled!==!1:!1}const i=new Set(["number","currency","percent","integer"]);function m(S){const j=x(S.get)?S.get("rangeChart"):void 0;return j?x(j)?{enabled:!0,handler:j}:j&&typeof j=="object"&&x(j.onChart)?{enabled:!0,handler:j.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function c(S){const j=S.selection&&x(S.selection.ranges)?S.selection.ranges():[];if(!Array.isArray(j)||!j.length)return null;const y=j[j.length-1],v=x(S.columns.visible)?S.columns.visible():[],R=new Set(v.filter(O=>O&&i.has(O.type)).map(O=>O.id));return(y.columns||[]).some(O=>R.has(O))?y:null}function f(S,j){const y=(Y,J)=>(S&&S.messages?S.messages:W).t(Y,J),{colId:v,row:R}=j,O=S.selection.keys().length,F=S.selection.cells().length,C=(S.state&&x(S.state.get)?S.state.get().group:null)||[],T=S.ranges||null,L=_()?"Cmd":"Ctrl",E=()=>F||O||0,D=Y=>S.columns&&x(S.columns.get)?S.columns.get(Y):null,I=x(S.selection.cells)?S.selection.cells():[],P=[...new Set(I.map(Y=>Y&&Y.colId).filter(Boolean))];!P.length&&v&&P.push(v);const k=P.length?P.some(Y=>l(S,D(Y))):d(S),N=v?l(S,D(v)):!1,G=m(S),q=G.enabled?c(S):null;return[{name:F>1?`Copy ${F} cells`:y("menu.copy"),shortcut:`${L}+C`,disabled:!E(),action:()=>T&&F?T.copy():S.export.clipboard({rows:O?"selected":"range"})},{name:y("menu.copyWithHeaders"),disabled:!E(),action:()=>S.export.clipboard({headers:!0,rows:O?"selected":"range"})},...v==null?[]:[{name:y("menu.paste"),shortcut:`${L}+V`,disabled:!T||!k||!o(),action:()=>T&&T.paste()},{separator:!0},{name:y("menu.clearCells",{count:F||1}),shortcut:"Delete",disabled:!T||!k||!F,action:()=>T&&T.clear()},{name:y("menu.fillDown"),shortcut:`${L}+D`,disabled:!T||!k||F<2,action:()=>T&&T.fillDown()}],...q&&G.handler?[{name:"Chart selection",action:()=>G.handler(S,q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>S.export.csv({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to CSV`,disabled:!O,action:()=>S.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>S.export.excel({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to Excel`,disabled:!O,action:()=>S.export.excel({rows:"selected",download:!0})},{name:"Copy visible rows",action:()=>S.export.clipboard({rows:"visible",headers:!0})},{name:"Print",action:()=>S.export.print()},...S.importer&&x(S.importer.openFile)?[{name:y("menu.importCsv"),action:()=>S.importer.openFile()}]:[],{separator:!0},...C.length?[{name:y("menu.expandAll"),action:()=>S.rows.expandAll()},{name:y("menu.collapseAll"),action:()=>S.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!O,action:()=>S.selection.clear()},...x(S.get)&&S.get("rowDelete")===!0?[{name:y("menu.deleteRow",{count:O||1}),disabled:!O&&!R,action:()=>S.edit.deleteRows(O?void 0:R?R.key:void 0)}]:[],...v==null?[]:[{name:"Edit cell",disabled:!R||!v||!N,action:()=>R&&v&&S.edit.start(R.key,v)}]]}function s(S,j,y,v){if(S==null)return{items:j,spoke:!1,suppress:!1};if(S===!1)return{items:j,spoke:!0,suppress:!0};if(S===!0)return{items:j,spoke:!0,suppress:!1};if(Array.isArray(S))return{items:[...j,...S],spoke:!0,suppress:!1};if(x(S)){const R=S(y,j);return{items:Array.isArray(R)?R:j,spoke:!0,suppress:!1}}return z(`menu-layer:${v}`,`${v} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof S}. Ignoring it.`),{items:j,spoke:!1,suppress:!1}}function p(S,j,y){let v=Array.isArray(S)?S:[],R=!1;for(const O of j){if(!O)continue;const F=s(O.layer,v,y,O.where);v=F.items,F.spoke&&(R=F.suppress)}return R?null:v}class b{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(j){this.#n=j.grid,this.#e=j.cellMenu!==!1,this.#t=j.headerMenu!==!1,this.#i=x(j.items)?j.items:null,this.#s=x(j.headerItems)?j.headerItems:null,this.#r=new H({document:j.document,host:j.host,ctx:{grid:j.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",j=>{const y=String(j.colId),v=this.#c(y,h(this.#n,y));v.length&&this.#r.show({items:v,ctx:this.#u(y),anchor:j.element,placement:"below",returnFocus:j.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",j=>{const y=String(j.colId),v=this.#c(y,t(this.#n,y));v.length&&this.#r.show({items:v,ctx:this.#u(y),x:j.x,y:j.y,returnFocus:j.element})})),this.#o.push(this.#n.on("cell:contextmenu",j=>{const y=j.event;this.#e&&y&&x(y.preventDefault)&&y.preventDefault();const v=this.#l(j),R=f(this.#n,v),O=p(R,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(v.column),where:`column '${v.colId}' contextMenu`}],v);!O||!O.length||(!this.#e&&y&&x(y.preventDefault)&&y.preventDefault(),this.#r.show({items:O,ctx:v,x:y?y.clientX:void 0,y:y?y.clientY:void 0}))}))}#l(j){const y=this.#n.columns,v=j.column||(j.colId!=null&&y&&x(y.get)?y.get(j.colId):void 0),R=j.row,O=this.#n.rows,F=j.key!==void 0?j.key:R?R.key:void 0;return{key:F,colId:j.colId,value:j.value!==void 0||F===void 0||j.colId==null?j.value:O&&x(O.value)?O.value(F,j.colId):void 0,row:R,data:R?R.data:void 0,column:v,index:j.index!==void 0?j.index:j.rowIndex,grid:this.#n}}#a(j){if(!(!j||j.contextMenu===void 0||j.contextMenu===null))return j.contextMenu}#u(j){return{colId:j,column:this.#n.columns.get(j),grid:this.#n}}#c(j,y){return this.#s?p(y,[{layer:this.#s,where:"columnMenu"}],this.#u(j))||[]:y}destroy(){for(const j of this.#o)j();this.#o=[],this.#r.destroy()}}}),Fe("packages/dom/src/shortcutshelp.js",function(e,K){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return A}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/renderer/keyboard.js"),X=_.groupedShortcuts,W=_.SHORTCUT_IDS,H=K("packages/dom/src/platform.js").macLike,B="lat-shortcuts",w='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class A{#e;#t;#n=null;#r=null;#o=[];constructor(u){this.#e=u.grid,this.#t=u.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#i(u,h){const a=this.#e;return(a&&a.messages?a.messages:$).t(u,h)}#s(u){const h=W[u.combo];if(!h)return u.meaning;const a=`shortcut.${h}`,r=this.#i(a);return r===a?u.meaning:r}mount(){const u=this.#t.viewport?.root;if(!u||!x(u.addEventListener))return;const h=a=>{if(this.open||a.key!=="?")return;const r=a.target,t=r&&r.tagName;t==="INPUT"||t==="TEXTAREA"||r&&r.isContentEditable||(a.preventDefault(),a.stopPropagation(),this.show())};u.addEventListener("keydown",h,!0),this.#o.push(()=>u.removeEventListener("keydown",h,!0))}show(){const u=this.#l();if(!u)return;const h=u.ownerDocument;this.#r=h&&h.activeElement,u.style.display="",x(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:opened",{})}hide(){if(!this.#n)return;this.#n.style.display="none";const u=this.#r;this.#r=null,u&&x(u.focus)&&u.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const u=this.#t.viewport?.overlays,h=u?.ownerDocument;if(!u||!h?.createElement)return null;const a=h.createElement("div");a.className=B,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("tabindex","-1");const r=`${B}-title`;a.setAttribute("aria-labelledby",r);const t=h.createElement("div");t.className=`${B}__head`;const n=h.createElement("h2");n.className=`${B}__title`,n.id=r,n.textContent=this.#i("shortcuts.title");const o=h.createElement("button");o.className=`${B}__close`,o.type="button",o.setAttribute("aria-label",this.#i("shortcuts.close")),o.textContent="×",t.appendChild(n),t.appendChild(o),a.appendChild(t);const d=h.createElement("div");d.className=`${B}__body`;for(const i of X())i.items.length&&d.appendChild(this.#a(h,i));a.appendChild(d);const l=h.createElement("p");return l.className=`${B}__hint`,l.textContent=this.#i("shortcuts.hint"),a.appendChild(l),u.appendChild(a),this.#n=a,this.#u(a,o),a}#a(u,h){const a=u.createElement("section");a.className=`${B}__group`;const r=u.createElement("h3");r.className=`${B}__group-title`,r.textContent=this.#i(h.messageKey),a.appendChild(r);const t=u.createElement("dl");t.className=`${B}__list`;const n=H();for(const o of h.items){const d=u.createElement("dt");d.className=`${B}__keys`,o.alternatives.forEach((i,m)=>{if(m>0){const c=u.createElement("span");c.className=`${B}__or`,c.textContent=this.#i("shortcuts.or"),d.appendChild(c)}i.forEach((c,f)=>{f>0&&d.appendChild(u.createTextNode("+"));const s=u.createElement("kbd");s.textContent=n&&c==="Ctrl"?this.#i("shortcuts.key.cmd"):c,d.appendChild(s)})});const l=u.createElement("dd");l.className=`${B}__meaning`,l.textContent=this.#s(o),t.appendChild(d),t.appendChild(l)}return a.appendChild(t),a}#u(u,h){const a=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.hide();return}if(t.key!=="Tab")return;const n=[...u.querySelectorAll(w)];if(!n.length){t.preventDefault();return}const o=n[0],d=n[n.length-1],l=u.ownerDocument.activeElement;t.shiftKey&&(l===o||l===u)?(t.preventDefault(),d.focus()):!t.shiftKey&&l===d&&(t.preventDefault(),o.focus())},r=t=>{t.preventDefault?.(),this.hide()};u.addEventListener("keydown",a),h.addEventListener("click",r),this.#o.push(()=>{u.removeEventListener("keydown",a),h.removeEventListener("click",r)})}destroy(){for(const u of this.#o)u();this.#o=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null}}}),Fe("packages/dom/src/rowreorder.js",function(e,K){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MANUAL_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return a}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/renderer.js").displayIndexOf,W="lat-rowdrag",V="lat-rowdrag-marker",H="lat-rowdrag-lifted",B="lat-manual-order",w=Object.freeze({sorted:"a11y.reorder.sorted",filtered:"a11y.reorder.filtered",grouped:"a11y.reorder.grouped","group-derived":"a11y.reorder.groupDerived","group-not-editable":"a11y.reorder.groupReadOnly",invalid:"a11y.reorder.invalid",vetoed:"a11y.reorder.vetoed"}),A=4,g=new Set;function u(r){if(!r)return null;const t=r===!0?{}:typeof r=="object"?r:null;return t?{send:t.send!==!1,receive:t.receive!==!1,mode:t.mode==="copy"?"copy":"move",group:typeof t.group=="string"?t.group:null}:null}function h(r){return r===!0?{column:null,manualOrder:!1,betweenGroups:!1}:!r||typeof r!="object"?null:{column:typeof r.column=="string"?r.column:null,manualOrder:r.manualOrder===!0,betweenGroups:r.betweenGroups===!0}}class a{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(t){this.#e=t.grid,this.#t=t.renderer,this.#n=t.document,this.#r=h(t.grid.get("rowReorder")),this.#o=u(t.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(t){if(!this.#o||!this.#o.receive)return!1;const n=t&&t.transfer;return!n||!n.send?!1:n.group===this.#o.group}get transfer(){return this.#o}#u(t,n){const o=this.#e;return(o&&o.messages?o.messages:$).t(t,n)}#c(t,n){const o=this.#t&&this.#t.announce;x(o)&&o.call(this.#t,t,n)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const t=this.#e.columns.visible().filter(n=>!n.generated);return t.length?t[0].id:null}paint(){if(!this.draggable)return;const t=this.#d(),n=this.#t.viewport?.root;if(!t||!n)return;const o=n.querySelectorAll(`.lat-cell[data-col="${t}"]`);for(const d of o){if(d.querySelector(`.${W}`))continue;const l=d.parentNode;if(l&&x(l.getAttribute)&&l.getAttribute("data-pinned"))continue;const i=this.#n.createElement("span");i.className=W,i.setAttribute("data-role","row-drag"),i.setAttribute("aria-hidden","true"),i.setAttribute("title",this.#u("a11y.reorder.grab")),i.textContent="⠿",d.insertBefore(i,d.firstChild||null)}this.#f(n,t)}#h(){const t=this.#e.rowOrder;return!!(t&&x(t.manual)&&t.manual())}#f(t,n){const o=this.#h();if(x(t.setAttribute)&&(o?t.setAttribute("data-row-order","manual"):t.removeAttribute("data-row-order")),!this.#r||!this.#r.manualOrder)return;const d=t.querySelector(`.lat-header-cell[data-col="${n}"]`);if(!d)return;let l=d.querySelector(`.${B}`);l||(l=this.#n.createElement("button"),l.className=B,l.setAttribute("type","button"),l.setAttribute("data-role","manual-order"),l.setAttribute("tabindex","-1"),l.textContent=this.#u("rowOrder.button"),l.addEventListener("click",m=>{m.stopPropagation?.(),this.toggleManual()}),l.addEventListener("pointerdown",m=>m.stopPropagation?.()),d.insertBefore(l,d.firstChild||null)),l.setAttribute("aria-pressed",o?"true":"false");const i=this.#u(o?"rowOrder.exit":"rowOrder.enter");l.setAttribute("title",i),l.setAttribute("aria-label",i)}toggleManual(){const t=this.#e.rowOrder;if(!t)return;const n=this.#h()?t.exit():t.enter({origin:"user"}),o=d=>{d&&d.reason&&this.#c(this.#u(w[d.reason]||"a11y.reorder.refused"),{repeat:!0}),this.paint()};n&&x(n.then)?n.then(o):o(n)}mount(){if(!this.active)return;g.add(this);const t=this.#t.viewport?.root;if(!t||!x(t.addEventListener))return;const n=m=>this.#p(m),o=m=>this.#m(m),d=()=>this.#g(),l=m=>this.#P(m);if(t.addEventListener("pointerdown",n),t.addEventListener("keydown",l),x(this.#e.on)){let m=this.#h();this.#a.push(this.#e.on("state:changed",c=>{!c||!Array.isArray(c.sections)||!c.sections.includes("rowOrder")||this.#h()!==m&&(m=this.#h(),this.#c(this.#u(m?"a11y.rowOrder.entered":"a11y.rowOrder.exited"),{repeat:!0}))}))}const i=this.#n.defaultView||this.#n;i.addEventListener?.("pointermove",o),i.addEventListener?.("pointerup",d),this.#a.push(()=>{t.removeEventListener("pointerdown",n),t.removeEventListener("keydown",l),i.removeEventListener?.("pointermove",o),i.removeEventListener?.("pointerup",d)})}#p(t){const n=t.target;if(!n||!x(n.closest)||!n.closest('[data-role="row-drag"]'))return;const o=n.closest(".lat-row"),d=o?X(o):-1;if(d<0)return;const l=this.#e.rows.get(d);if(!l||l.group)return;const i=this.#N();if(i&&!(this.#o&&this.#o.send)){this.#c(this.#u(i),{repeat:!0});return}t.preventDefault?.(),this.#i={key:l.key,from:d,at:d,x:t.clientX,y:t.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#m(t){const n=this.#i;if(!n)return;if(!n.armed){if(Math.abs(t.clientX-n.x)+Math.abs(t.clientY-n.y)<A)return;n.armed=!0,this.#B(n),n.over=this,this.#e.emit("rowDrag:started",this.#y(n,this,n.from,n.key),"user")}this.#l&&this.#_(t.clientX,t.clientY);const o=this.#O(t.clientX,t.clientY);if(n.target=o,o!==this){this.#q(),o&&o.accepts(this)?(o.showDropTarget(t.clientX,t.clientY),n.hit=o.hitAt(t.clientX,t.clientY)):n.hit=null,this.#A(n,o),this.#w(n,o,n.hit?n.hit.at:null,n.hit?n.hit.overKey:null);return}const d=this.#L(t.clientX,t.clientY);if(this.#A(n,o),d<0){this.#w(n,this,null,null);return}n.at=d,this.#$(d);const l=this.#e.rows.get(d);this.#w(n,this,d,l?l.key:null)}#g(){const t=this.#i;this.#i=null,this.#q(),this.#z();for(const d of g)d.hideDropTarget();if(!t||(this.#S(t),!t.armed))return;const n=t.target;if(this.#e.emit("rowDrag:ended",this.#b(t),"user"),n&&n!==this){this.#C(t,n);return}if(t.at===t.from)return;const o=this.#N();if(o){this.#c(this.#u(o),{repeat:!0});return}this.#E(t.key,t.at)}#y(t,n,o,d){const l=this.#e.rows.byKey(t.key);return{key:t.key,data:l?l.data:null,over:n?n.grid:null,at:o,overKey:d}}#b(t){const n=t.target||null;if(n&&n!==this){if(!n.accepts(this))return{...this.#y(t,n,null,null),dropped:!1};const o=t.hit||{at:n.grid.rows.count(),overKey:null};return{...this.#y(t,n,o.at,o.overKey),dropped:!0}}if(n===this){const o=this.#e.rows.get(t.at);return{...this.#y(t,this,t.at,o?o.key:null),dropped:t.at!==t.from&&this.#N()===null}}return{...this.#y(t,null,null,null),dropped:!1}}#A(t,n){if(t.over===n)return;const o=t.over;t.over=n,o&&(this.#S(t),this.#e.emit("rowDrag:left",this.#y(t,o,null,null),"user"))}#w(t,n,o,d){t.pending={over:n,at:o,overKey:d},t.frame===null&&(t.frame=this.#v(()=>{t.frame=null;const l=t.pending;t.pending=null,!(!l||this.#i!==t)&&this.#e.emit("rowDrag:moved",this.#y(t,l.over,l.at,l.overKey),"user")}))}#S(t){t.pending=null,t.frame!==null&&(t.frame(),t.frame=null)}#v(t){const n=this.#n.defaultView||globalThis;if(x(n.requestAnimationFrame)){const d=n.requestAnimationFrame(t);return()=>{x(n.cancelAnimationFrame)&&n.cancelAnimationFrame(d)}}const o=setTimeout(t,16);return()=>clearTimeout(o)}#C(t,n){if(!n.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const o=this.#e.rows.byKey(t.key);if(!o)return;const d=this.#o.mode,l=t.key,i=t.hit||{at:n.grid.rows.count(),overKey:null};let m=null;const c=n.receive(o.data,i.at,{overKey:i.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(l),onCancel:s=>{m=s}}),f=s=>{if(s!==!0){const p=s===!1?"a11y.transfer.refused":m==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(p),{repeat:!0});return}d==="move"?(this.#e.rows.apply({remove:[l]}),this.#e.emit("row:sent",{key:l,data:o.data,mode:d})):this.#e.emit("row:copied",{key:l,data:o.data,mode:d}),this.#c(this.#u(d==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};c&&x(c.then)?c.then(f):f(c)}receive(t,n,o={}){const d=this.#e,l=t&&typeof t=="object"?{...t}:t,i=o.overKey??null,m=o.source||null,c=x(o.onCancel)?o.onCancel:null,f=()=>{const j=d.rows.totalCount(),y=d.rows.apply({add:[l],at:Math.max(0,n||0)}),v=d.rows.totalCount()>j;return v&&d.emit("row:received",{data:l,at:n,overKey:i,rejected:y?.rejected||[]}),v},s=()=>{if(i!==null){const j=d.rows.get(n);if(!j||j.key!==i)return!1}else n=d.rows.count();return!x(o.revalidate)||o.revalidate()},p=x(d.rendererHost)?d.rendererHost():null;if(!p||!x(p.gateBefore))return f();const b=c?d.on("rowReceive:cancelled",j=>c(j.reason)):null,S=p.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:l,at:n,overKey:i,source:m,origin:"user"},f,s);return b&&(S&&x(S.then)?S.then(b,b):b()),S}hitAt(t,n){const o=this.#L(t,n);if(o<0)return{at:this.#e.rows.count(),overKey:null};const d=this.#e.rows.get(o);return{at:o,overKey:d?d.key:null}}showDropTarget(t,n){const o=this.root;o&&x(o.setAttribute)&&o.setAttribute("data-drop-target","")}hideDropTarget(){const t=this.root;t&&x(t.removeAttribute)&&t.removeAttribute("data-drop-target")}#O(t,n){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,n):null,d=o&&x(o.closest)?o.closest(".lattice"):null;if(!d)return null;for(const l of g)if(l.root===d)return l;return null}#P(t){if(!t.altKey||!t.shiftKey)return;if(this.#r&&this.#r.manualOrder&&(t.code==="KeyM"||t.key==="M"||t.key==="m")){t.preventDefault?.(),t.stopPropagation?.(),this.toggleManual();return}const n=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0;if(!n)return;const o=this.#n.activeElement,d=o&&x(o.closest)?o.closest(".lat-row"):null,l=d?X(d):-1;if(l<0)return;t.preventDefault?.(),t.stopPropagation?.();const i=this.#N();if(i){this.#c(this.#u(i),{repeat:!0});return}const m=this.#e.rows.get(l);!m||m.group||this.#E(m.key,this.#M(l,n))}#M(t,n){const o=this.#e;if(n>0||!x(o.rows.groupHeadings))return t+n;const d=new Set(o.rows.groupHeadings(t).map(i=>i.key));let l=t+n;for(;l>=0;){const i=o.rows.get(l);if(!i||!d.has(i.key))break;l+=n}return l<0?t:l}#E(t,n){const o=this.#e.rows.count(),d=Math.max(0,Math.min(o-1,n)),l=this.#e.rows.move(t,d,{origin:"user"});l&&x(l.then)?l.then(i=>this.#T(i,o)):this.#T(l,o)}#T(t,n){if(!t){this.#c(this.#u("a11y.reorder.vetoed"),{repeat:!0});return}if(!t.moved){if(!t.reason||t.reason==="unchanged")return;const o=t.reason==="vetoed"&&t.detail&&t.detail!=="prevented"?t.detail:null,d=o?this.#u("a11y.reorder.vetoedBecause",{reason:o}):this.#u(w[t.reason]||"a11y.reorder.refused");this.#c(d,{repeat:!0});return}if(Array.isArray(t.regrouped)&&t.regrouped.length){const o=t.regrouped.map(d=>String(d.to??"")).join(" / ");this.#c(this.#u("a11y.reorder.regrouped",{group:o}),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:t.to+1,total:n}),{repeat:!0})}#N(){const t=this.#e,n=this.#r||{manualOrder:!1,betweenGroups:!1};if(t.sort.get().length)return n.manualOrder?"a11y.reorder.sortedManual":"a11y.reorder.sorted";if((t.state.get().group||[]).length&&!this.#h()&&!n.betweenGroups)return"a11y.reorder.grouped";const o=t.filters.get();return o&&Object.keys(o).length?"a11y.reorder.filtered":null}#L(t,n){const o=this.#n.elementFromPoint?this.#n.elementFromPoint(t,n):null,d=o&&x(o.closest)?o.closest(".lat-row"):null;return!d||x(d.getAttribute)&&d.getAttribute("data-pinned")?-1:X(d)}#B(t){const n=this.root,o=n&&x(n.querySelector)?n.querySelector(`.lat-row[data-index="${t.from}"]`):null;o&&x(o.classList?.add)&&o.classList.add(H);const d=this.#n.body;if(!d||!x(d.appendChild))return;const l=this.#d(),i=l&&x(this.#e.rows?.text)&&this.#e.rows.text(t.key,l)||this.#u("a11y.reorder.grab"),m=n&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(n):null,c=(s,p)=>m&&m.getPropertyValue(s).trim()||p,f=this.#n.createElement("div");f.textContent=String(i),f.setAttribute("aria-hidden","true"),f.setAttribute("data-role","row-drag-ghost"),f.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${c("--lattice-space","4px")} calc(${c("--lattice-space","4px")} * 2)`,`border-radius:${c("--lattice-radius-sm",c("--lattice-radius","4px"))}`,`border:${c("--lattice-border-width","1px")} solid ${c("--lattice-border-strong","#0003")}`,`background:${c("--lattice-background","#fff")}`,`color:${c("--lattice-foreground","#000")}`,`box-shadow:${c("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${c("--lattice-font-size","13px")} ${c("--lattice-font-family","system-ui, sans-serif")}`].join(";"),d.appendChild(f),this.#l=f}#_(t,n){this.#l&&(this.#l.style.transform=`translate(${Math.round(t)+14}px, ${Math.round(n)+16}px)`)}#z(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const t=this.root,n=t&&x(t.querySelectorAll)?t.querySelectorAll(`.${H}`):[];for(const o of n)o.classList.remove(H)}#$(t){const n=this.#t.viewport?.overlays;if(!n)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=V,n.appendChild(this.#s));const o=this.#t.viewport.root,d=o.querySelector(`.lat-row[data-index="${t}"]`)||o.querySelectorAll(".lat-row")[0];if(!d||!x(d.getBoundingClientRect))return;const l=d.getBoundingClientRect(),i=o.getBoundingClientRect(),m=this.#i&&t>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((m?l.bottom:l.top)-i.top)}px`}#q(){this.#s&&(this.#s.style.display="none")}destroy(){g.delete(this);for(const t of this.#a)t();this.#a=[],this.#i&&this.#S(this.#i),this.#i=null,this.#z(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Fe("packages/dom/src/alignedgrids.js",function(e,K){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,z=["column:resized","column:moved","column:visible","column:pinned"];function $(W){return(W||[]).map(V=>({id:V.id,width:V.width,flex:V.flex,hidden:V.hidden,pin:V.pin===void 0?null:V.pin}))}class _{#e=new Set;#t=new Map;#n=!1;add(V){if(!V||this.#e.has(V))return;this.#e.add(V);const H=[];for(const w of z)H.push(V.on(w,()=>this.#r(V)));H.push(V.on("scroll",w=>this.#i(V,w))),H.push(V.on("destroy",()=>this.remove(V))),this.#t.set(V,H);const[B]=this.#e;B!==V&&this.#o(V,$(B.columns.state()))}remove(V){const H=this.#t.get(V);if(H)for(const B of H)B();this.#t.delete(V),this.#e.delete(V)}get size(){return this.#e.size}destroy(){for(const V of[...this.#e])this.remove(V)}#r(V){if(this.#n)return;const H=$(V.columns.state());this.#n=!0;try{for(const B of this.#e)B!==V&&this.#o(B,H)}finally{this.#n=!1}}#o(V,H){if(!V.columns||!x(V.columns.apply))return;const B=new Map((V.columns.state()||[]).map(A=>[A.id,A])),w=[];for(const A of H){const g=B.get(A.id);g&&(w.push({...g,...A}),B.delete(A.id))}for(const A of B.values())w.push(A);V.columns.apply(w)}#i(V,H){if(this.#n)return;const B=H&&typeof H.left=="number"?H.left:null;if(B!==null){this.#n=!0;try{for(const w of this.#e)w!==V&&w.scroll?.to?.({left:B})}finally{this.#n=!1}}}}function X(W){const V=new _;for(const H of W||[])V.add(H);return V}}),Fe("packages/dom/src/columntagbar.js",function(e,K){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return W}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-tagbar";function X(H){if(!H)return null;const B=H===!0?{}:typeof H=="object"?H:null;return B?{multiple:B.multiple===!0,label:typeof B.label=="string"?B.label:null}:null}class W{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(B){this.#e=B.grid,this.#t=B.renderer,this.#n=B.document,this.#r=X(B.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(B,w){const A=this.#e;return(A&&A.messages?A.messages:$).t(B,w)}mount(){if(!this.active)return;const B=this.#t.viewport,w=B?.root;if(!w||!x(w.insertBefore))return;const A=this.#n.createElement("div");A.className=_,A.setAttribute("role","toolbar"),A.setAttribute("aria-label",this.#a("tags.label"));const g=this.#n.createElement("label");g.className=`${_}__label`,g.textContent=this.#r.label||this.#a("tags.label");const u=this.#n.createElement("select");u.className=`${_}__select`,this.#r.multiple&&u.setAttribute("multiple","");const h=`${_}-select-${Math.abs(V(String(w.className)))}`;u.id=h,g.setAttribute("for",h),A.appendChild(g),A.appendChild(u),w.insertBefore(A,B.header||w.firstChild),this.#o=A,this.#i=u;const a=()=>{const t=this.#r.multiple?[...u.selectedOptions||[]].map(n=>n.value).filter(Boolean):u.value?[u.value]:[];this.#e.columns.showTagged(t),this.#u(t)};u.addEventListener("change",a),this.#l.push(()=>u.removeEventListener("change",a));const r=this.#e.on("model:changed",()=>this.refresh());this.#l.push(r),this.refresh()}#u(B){const w=this.#t&&this.#t.announce;if(!x(w))return;const A=B.length?B.join(", "):this.#a("tags.all");w.call(this.#t,this.#a("tags.showing",{tag:A}))}refresh(){if(!this.#i||!this.#o)return;const B=this.#e.columns.tags();if(this.#o.style.display=B.length?"":"none",!B.length)return;const w=B.join("\0");if(w===this.#s)return;this.#s=w;const A=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const g=this.#n.createElement("option");g.value="",g.textContent=this.#a("tags.all"),this.#i.appendChild(g)}for(const g of B){const u=this.#n.createElement("option");u.value=g,u.textContent=g,A.includes(g)&&(u.selected=!0),this.#i.appendChild(u)}this.#r.multiple||(this.#i.value=A.length?A[0]:"")}destroy(){for(const B of this.#l)B();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function V(H){let B=0;for(let w=0;w<H.length;w++)B=B*31+H.charCodeAt(w)|0;return B}}),Fe("packages/dom/src/anomalychip.js",function(e,K){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-anomaly-chip";function X(B){if(!B)return null;const w=B===!0?{}:typeof B=="object"?B:null;return w?{column:typeof w.column=="string"?w.column:null,label:typeof w.label=="string"?w.label:null}:null}function W(B){return B?typeof B=="string"?{kind:B}:typeof B=="object"?B:null:null}function V(B,w){return B?Array.isArray(B.conditions)?B.conditions.some(A=>V(A,w)):B.col===w&&B.op==="eq"&&B.value===!0:!1}class H{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!1;#u=null;#c=0;#d=null;constructor(w){this.#e=w.grid,this.#t=w.renderer,this.#n=w.document,this.#r=X(w.grid.get("anomalySummary"))}get active(){return this.#r!==null}#h(w,A){const g=this.#e;return(g&&g.messages?g.messages:$).t(w,A)}#f(){const w=this.#r&&this.#r.column;let A=null;for(const g of this.#e.columns.all()){const u=W(g.shadow);if(!u||u.kind!=="anomalyFlag")continue;const h=u.of||g.field||g.id;if(w){if(g.id===w||h===w)return this.#d=g.id,g}else A||(A=g,this.#d=g.id)}return w?null:A}#p(){if(!this.#d||!x(this.#e.rows&&this.#e.rows.forEach))return 0;let w=0;try{this.#e.rows.forEach(A=>{!A||A.group||A.key==null||this.#e.rows.value(A.key,this.#d)===!0&&w++})}catch{return 0}return w}mount(){if(!this.active)return;const w=this.#t.viewport,A=w&&w.root;if(!A||!x(A.insertBefore))return;const g=this.#n.createElement("div");g.className=_,g.setAttribute("role","status");const u=this.#n.createElement("button");u.className=`${_}__button`,u.setAttribute("type","button"),u.setAttribute("aria-pressed","false"),g.appendChild(u),A.insertBefore(g,w.header||A.firstChild),this.#o=g,this.#i=u;const h=()=>this.toggle();u.addEventListener("click",h),this.#s.push(()=>u.removeEventListener("click",h));for(const a of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(a,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#m()}#m(){if(!this.#d)return;this.#u=this.#e.filters.get();const w={col:this.#d,op:"eq",value:!0},A=this.#u?{op:"and",conditions:[this.#u,w]}:w;this.#l=!0,this.#a=!0;try{this.#e.filters.set(A)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#l&&!V(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#y(this.#c,!0);return}const A=this.#p();if(this.#c=A,!A){this.#o.style.display="none";return}this.#y(A,!1)}#y(w,A){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",A?"true":"false"),this.#i.setAttribute("aria-pressed",A?"true":"false");const g=this.#r&&this.#r.label,u=A?this.#h("anomaly.chipActive",{count:w}):g||this.#h("anomaly.chip",{count:w});this.#i.textContent=u}destroy(){for(const w of this.#s)w();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),Fe("packages/dom/src/rowform.js",function(e,K){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return o}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,W=K("packages/core/src/model/rowkey.js").createRowKey,H=K("packages/dom/src/editors/index.js").createEditor,w=K("packages/dom/src/renderer/renderer.js").displayIndexOf,g=K("packages/dom/src/themeof.js").themeOf,u="lat-rowform",h='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function a(d){if(!d)return null;const l=d===!0?{}:typeof d=="object"?d:null;if(!l)return null;const i=x(l.load)?l.load:null,m=Array.isArray(l.fields)&&l.fields.length?l.fields:null;return{timeout:n(l.timeout),container:l.container??null,mode:l.container?"inline":l.mode==="dialog"?"dialog":"drawer",load:i,create:x(l.create)?l.create:null,fields:m,title:l.title??null,width:typeof l.width=="string"?l.width:null,trigger:l.trigger===!1?"none":"dblclick"}}function r(d,l){const i=x(d)?d():d;return i?typeof i=="string"?l&&x(l.querySelector)?l.querySelector(i):null:i&&x(i.appendChild)?i:null:null}const t=2e3;function n(d){return d===!1||d===0?0:typeof d!="number"||!Number.isFinite(d)||d<=0?t:d}class o{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];#h=null;#f=0;#p=null;#m=!1;#g=[];constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document,this.#r=l.registry||null,this.#o=a(l.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#y(l,i){const m=this.#e;return(m&&m.messages?m.messages:_).t(l,i)}mount(){if(!this.active)return;const l=this.#t.viewport?.root;if(!l||!x(l.addEventListener)||this.#o.trigger==="none")return;const i=m=>{const c=m.target;if(!c||!x(c.closest)||c.closest(".lat-editor-host, .lat-editor--popup"))return;const f=c.closest(".lat-row"),s=f?w(f):-1;if(s<0)return;const p=this.#e.rows.get(s);!p||p.group||p.detail||(m.preventDefault?.(),m.stopPropagation?.(),this.openRow(p.key))};l.addEventListener("dblclick",i,!0),this.#g.push(()=>l.removeEventListener("dblclick",i,!0))}openRow(l){const i=this.#e.rows.byKey(l);if(!i)return!1;const m=this.#C();if(!m)return!1;this.#a=i,this.#u=!1,this.#v(),this.#h=this.#n.activeElement,m.style.display="",this.#$(m),this.#P(i);const c=this.#o.load;if(!c)this.#_(i.data);else{this.#N();const f=++this.#f;this.#M(f,s=>{this.#L(new Error(`Loading the record timed out after ${s}ms`),l,"form.loadTimeout")}),Promise.resolve().then(()=>c({row:i,data:i.data,key:l,grid:this.#e})).then(s=>{f!==this.#f||!this.open||(this.#T(),this.#_(s||i.data))}).catch(s=>{f!==this.#f||!this.open||(this.#T(),this.#L(s,l))})}return x(m.focus)&&m.focus(),this.#e.emit("form:opened",{key:l,row:i}),!0}openNew(l){const i=this.#C();if(!i)return!1;this.#f+=1,this.#T(),this.#a=null,this.#u=!0,this.#v(),this.open||(this.#h=this.#n.activeElement),i.style.display="",this.#$(i);const m=i.querySelector(`.${u}__title`);return m&&(m.textContent=this.#y("form.newTitle")),this.#_(l&&typeof l=="object"?{...l}:{}),x(i.focus)&&i.focus(),this.#e.emit("form:opened",{key:null,row:null,created:!0}),!0}close(){if(!this.#i)return;this.#f+=1,this.#T(),this.#ye(),this.#i.style.display="none";const l=this.#a?this.#a.key:null;this.#a=null,this.#u=!1,this.#v();const i=this.#h;this.#h=null,i&&x(i.focus)&&i.focus(),this.#e.emit("form:closed",{key:l})}save(){if(!this.#a&&!this.#u||!this.#d.length||this.#u&&this.#l&&this.#l.disabled)return!1;const l=this.#a?this.#a.key:null,i={},m={},c=[],f=[];for(const s of this.#d){const p=x(s.editor.commit)?s.editor.commit():{ok:!0,value:void 0};if(!p.ok)return this.#W(s,p.message),!1;if(i[s.field]=p.value,s.readOnly){f.push(s.field);continue}const b=s.initial;Object.is(b,p.value)||(m[s.field]=p.value,s.colId?c.push({key:l,colId:s.colId,value:p.value}):f.push(s.field))}return this.#u?this.#b(i):(c.length&&this.#e.edit.setCells(c,"cell",{origin:"form"}),this.#e.emit("form:saved",{key:l,values:i,changed:m,unmapped:f}),this.close(),!0)}#b(l){const i=this.#d.filter(f=>!f.colId).map(f=>f.field),m=this.#o.create;if(!m)return this.#A(l)?(this.#w(l,l,i),!0):(z("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),!1);this.#v(),this.#E(!1);const c=++this.#f;return this.#M(c,f=>{this.#S(new Error(`Adding the record timed out after ${f}ms`),l,!0)}),Promise.resolve().then(()=>m(l)).then(f=>{if(!(c!==this.#f||!this.open)){if(this.#T(),!this.#A(f)){z("rowform:create:missing-key","rowForm could not add the new row: it carries no row key. Return the stored row, key included, from rowForm.create, or give the key a field or a default."),this.#S(new Error("rowForm.create answered with a row that carries no row key"),l,!1);return}this.#w(f,l,i)}}).catch(f=>{c!==this.#f||!this.open||(this.#T(),this.#S(f,l,!1))}),!0}#A(l){if(!l||typeof l!="object")return!1;const i=W(this.#e.get("rowKey"),{warn:!1});return!i||i.stable===!1?!1:x(i.keyEmpty)?!i.keyEmpty(l):!0}#w(l,i,m){const c=this.#e,f=c.rows.apply({add:[l]}),s=f&&Array.isArray(f.added)?f.added[0]:null;if(!s){this.#S(new Error("The new row could not be added"),i,!1);return}const p=s.key;c.emit("form:saved",{key:p,values:i,changed:i,unmapped:m,created:!0}),this.close();const b=c.get("selection");(typeof b=="string"?b!=="none":b&&typeof b=="object"&&b.mode!=="none")&&c.selection&&x(c.selection.set)&&c.selection.set([p]),c.scroll&&x(c.scroll.toRow)&&c.scroll.toRow(p)}#S(l,i,m){this.#E(!0),this.#v();const c=this.#n.createElement("div");c.className=`${u}__failure`;const f=this.#n.createElement("p");f.className=`${u}__note ${u}__note--error`,f.setAttribute("role","alert"),f.textContent=this.#y("form.createFailed");const s=this.#n.createElement("button");s.className=`${u}__retry`,s.type="button",s.textContent=this.#y("form.retry"),s.addEventListener("click",()=>this.save()),c.appendChild(f),c.appendChild(s),x(this.#s.insertBefore)?this.#s.insertBefore(c,this.#s.firstChild):this.#s.appendChild(c),this.#c=c,this.#e.emit("form:error",{key:null,error:l,timedOut:m,created:!0})}#v(){const l=this.#c;this.#c=null,l&&l.parentNode&&l.parentNode.removeChild(l)}#C(){if(this.#i)return this.#i;const l=this.#t.viewport?.overlays,i=this.#n||l?.ownerDocument;if(!i?.createElement)return null;const m=r(this.#o.container,i),c=m||l;if(!c)return null;this.#o.container&&!m&&z("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#m=!!m;const f=i.createElement("div"),s=this.#m?"lattice ":"";f.className=`${s}${u} ${u}--${this.#m?"inline":this.#o.mode}`,f.setAttribute("role",this.#m?"region":"dialog"),this.#m||f.setAttribute("aria-modal","true"),f.setAttribute("tabindex","-1"),this.#o.width&&f.style.setProperty("--lattice-rowform-width",this.#o.width);const p=`${u}-title`;f.setAttribute("aria-labelledby",p);const b=i.createElement("div");b.className=`${u}__head`;const S=i.createElement("h2");S.className=`${u}__title`,S.id=p,b.appendChild(S);const j=i.createElement("div");j.className=`${u}__body`;const y=i.createElement("div");y.className=`${u}__foot`;const v=i.createElement("button");v.className=`${u}__cancel`,v.type="button",v.textContent=this.#y("form.cancel");const R=i.createElement("button");return R.className=`${u}__save`,R.type="button",R.textContent=this.#y("form.save"),y.appendChild(v),y.appendChild(R),f.appendChild(b),f.appendChild(j),f.appendChild(y),c.appendChild(f),this.#i=f,this.#s=j,this.#l=R,this.#O(f,R,v),f}#O(l,i,m){const c=p=>{if(p.stopPropagation(),p.key==="Escape"){p.preventDefault(),this.close();return}if(p.key!=="Tab"||this.#m)return;const b=[...l.querySelectorAll(h)];if(!b.length){p.preventDefault();return}const S=b[0],j=b[b.length-1],y=l.ownerDocument.activeElement;p.shiftKey&&(y===S||y===l)?(p.preventDefault(),j.focus()):!p.shiftKey&&y===j&&(p.preventDefault(),S.focus())},f=p=>{p.preventDefault?.(),this.save()},s=p=>{p.preventDefault?.(),this.close()};l.addEventListener("keydown",c),i.addEventListener("click",f),m.addEventListener("click",s),this.#g.push(()=>{l.removeEventListener("keydown",c),i.removeEventListener("click",f),m.removeEventListener("click",s)})}#P(l){const i=this.#i.querySelector(`.${u}__title`);if(!i)return;const m=this.#o.title;x(m)?i.textContent=String(m({row:l,data:l.data})??""):typeof m=="string"?i.textContent=m:i.textContent=this.#y("form.title")}#M(l,i){this.#T();const m=this.#o.timeout;if(!m)return;const c=this.#n.defaultView||globalThis;x(c.setTimeout)&&(this.#p=c.setTimeout(()=>{this.#p=null,!(l!==this.#f||!this.open)&&(this.#f+=1,i(m))},m))}#E(l){this.#l&&(this.#l.disabled=!l,l?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#T(){if(this.#p===null)return;const l=this.#n.defaultView||globalThis;x(l.clearTimeout)&&l.clearTimeout(this.#p),this.#p=null}#N(){this.#ye(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const l=this.#n.createElement("p");l.className=`${u}__note`,l.setAttribute("role","status"),l.textContent=this.#y("form.loading"),this.#s.appendChild(l)}#L(l,i,m="form.loadFailed"){this.#ye(),this.#E(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const c=this.#n.createElement("p");c.className=`${u}__note ${u}__note--error`,c.setAttribute("role","alert"),c.textContent=this.#y(m);const f=this.#n.createElement("button");f.className=`${u}__retry`,f.type="button",f.textContent=this.#y("form.retry"),f.addEventListener("click",()=>this.openRow(i)),this.#s.appendChild(c),this.#s.appendChild(f),this.#e.emit("form:error",{key:i,error:l,timedOut:m==="form.loadTimeout"})}#B(){return this.#o.fields?this.#o.fields.map(l=>typeof l=="string"?{field:l}:l):this.#e.columns.all().filter(l=>!l.generated&&l.field).map(l=>({field:l.field,label:l.title,colId:l.id}))}#_(l){this.#ye(),this.#E(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const i=l&&typeof l=="object"?l:{};for(const m of this.#B()){const c=m.field;if(!c)continue;const f=m.colId?this.#e.columns.get(m.colId):this.#ie(c),s=Object.hasOwn(i,c)?i[c]:null,p=this.#n.createElement("div");p.className=`${u}__field`;const b=this.#n.createElement("label");b.className=`${u}__label`,b.textContent=String(m.label??(f&&f.title)??c);const S=this.#n.createElement("div");S.className=`${u}__control`,p.appendChild(b),p.appendChild(S),this.#s.appendChild(p);const j={field:c,colId:f?f.id:null,editor:null,initial:s,opener:null,wrap:p,readOnly:!1},v=!!(f&&(f.computed||f.generated))?null:H({grid:this.#e,column:this.#fe(m,f,c),colId:f?f.id:c,row:this.#a,data:i,value:s,text:s==null?"":String(s),locale:this.#e.get("locale"),props:m.props||f&&f.edit&&f.edit.props,lookup:m.lookup||f&&f.lookup,document:this.#n,cell:S,overlay:this.#q(),stop:()=>this.#V(j)},this.#r);if(!v){j.readOnly=!0,j.colId=null,j.editor={commit:()=>({ok:!0,value:j.initial})},this.#z(S,f,s),this.#d.push(j);continue}j.editor=v;try{x(v.value)&&(j.initial=v.value())}catch{}if(this.#d.push(j),v.popup===!0)this.#I(S,j);else{const R=x(v.element)?v.element():null;R&&S.appendChild(R)}}this.#d.length||z("rowform:no-fields","rowForm has no fields to show; the form opened with no controls. Check rowForm.fields, or the grid's columns when fields is absent.")}#z(l,i,m){const c=this.#n.createElement("div");c.className=`${u}__static`,c.setAttribute("aria-readonly","true");let f="";try{const s=i&&i.dataType&&i.dataType.format;x(s)&&(f=s({value:m,column:i,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")}))}catch{f=""}(f===""||f==null)&&(f=m==null?"":String(m)),c.textContent=f,l.appendChild(c)}#$(l){if(!this.#m)return;const i=this.#t.viewport?.root;if(!(!i||!x(i.getAttribute)))for(const m of["data-theme","data-density","dir"]){const c=m==="data-theme"?g(i):i.getAttribute(m);c?l.setAttribute(m,c):x(l.removeAttribute)&&l.removeAttribute(m)}}#q(){return this.#m?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#I(l,i){const m=this.#n.createElement("button");m.className=`${u}__opener`,m.type="button",i.opener=m,this.#U(i);const c=()=>{x(i.editor.attached)&&i.editor.attached()};m.addEventListener("click",c),this.#g.push(()=>m.removeEventListener("click",c)),l.appendChild(m)}#W(l,i){const m=l.wrap;m&&x(m.scrollIntoView)&&m.scrollIntoView({block:"nearest"});const c=l.opener||(x(l.editor.focusTarget)?l.editor.focusTarget():null);c&&x(c.focus)&&c.focus();const f=this.#t&&this.#t.announce;x(f)&&i&&f.call(this.#t,String(i))}#V(l){if(!l.opener||!l.editor)return;const i=x(l.editor.popupHandle)?l.editor.popupHandle():null;i&&x(i.hide)&&i.hide(),this.#U(l),x(l.opener.focus)&&l.opener.focus()}#U(l){if(!l.opener)return;let i="";try{const c=l.colId?this.#e.columns.get(l.colId):null,f=c&&c.dataType&&c.dataType.format;x(f)&&(i=f({value:x(l.editor.value)?l.editor.value():null,column:c,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(i===""||i==null)&&x(l.editor.toClipboard)&&(i=l.editor.toClipboard())}catch{i=""}const m=i===""||i==null;l.opener.textContent=m?this.#y("form.choose"):String(i),l.opener.classList.toggle(`${u}__opener--empty`,m)}#fe(l,i,m){const c=l.editor||l.type||l.lookup||l.props,f={...i&&i.edit?i.edit:{},enabled:!0};return l.editor&&(f.editor=l.editor),l.props&&(f.props=l.props),i&&!c?{...i,edit:f}:{...i||{id:m,field:m},type:l.type||i&&i.type||"text",lookup:l.lookup||i&&i.lookup||void 0,edit:f}}#ie(l){for(const i of this.#e.columns.all())if(!i.generated&&i.field===l)return i;return null}#ye(){for(const l of this.#d)x(l.editor.destroy)&&l.editor.destroy();this.#d=[]}destroy(){this.#f+=1,this.#T(),this.#ye();for(const l of this.#g)l();this.#g=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Fe("packages/dom/src/toolpanelmount.js",function(e,K){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return T}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=K("packages/dom/src/ui/toolpanel.js"),_=$.ToolPanel,X=$.toolPanels,W=$.toolPanelTitles,V=$.toolPanelIcons,H=K("packages/dom/src/filters/index.js"),B=H.createFilter,w=H.filterFor,g=K("packages/dom/src/filters/text.js").TextFilter,u=K("packages/dom/src/filters/engineset.js"),h=u.EngineSetFilter,a=u.VALUE_LIMIT,r=K("packages/dom/src/editors/common.js"),t=r.CLS,n=r.documentFor,o=r.scannableRows,d=r.el,l=K("packages/dom/src/filtermenu.js"),i=l.mergeColumnFilter,m=l.branchFor,c=l.valueSource,f=l.isSetFilter,s=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 p(L,E,D){const I=d(L,"div",{class:`${t.panel}__filterRefusal`});return I.appendChild(d(L,"div",{class:`${t.filter}__note`,text:D,attrs:{role:"note","data-warning":"filter:values-unsupported"}})),I.appendChild(E.element()),{get:()=>E.get(),set:P=>E.set(P),active:()=>E.active(),...x(E.clear)?{clear:()=>E.clear()}:{},destroy:()=>E.destroy(),element:()=>I}}function b(L){const{grid:E,container:D}=L||{};if(!E)throw new Error("[lattice] mountPanel needs a grid");if(!D||!D.appendChild)throw new Error("[lattice] mountPanel needs a container element");const I=x(L.panel)?L.panel:X[String(L.panel)];if(!I)throw new Error(`[lattice] unknown panel "${L.panel}"; known panels are ${Object.keys(X).join(", ")}`);const P=D.ownerDocument||n(D),k=C(E,P,L.announce),N=new I;N.init({document:P,host:k,grid:E,props:L.props||{}});const G=N.element();D.appendChild(G);const q=[];for(const Y of s)x(E.on)&&q.push(E.on(Y,()=>N.refresh()));return x(E.on)&&q.push(E.on("config:changed",Y=>{Y&&(Y.key==="regression"||Array.isArray(Y.keys)&&Y.keys.includes("regression"))&&N.refresh()})),{element:G,refresh(){N.refresh()},destroy(){for(const Y of q)Y();q.length=0,x(N.destroy)&&N.destroy(),G&&G.parentNode&&G.parentNode.removeChild(G)}}}const S=260,j=30,y=`${t.panel}-dock`;function v(L,E,D){if(!L||!x(L.set))return;const I=m(D.filters.get(),E)||null,P=x(L.get)&&(!x(L.active)||L.active())&&L.get()||null;JSON.stringify(P)!==JSON.stringify(I)&&(I?L.set(I):x(L.clear)?L.clear():L.set(null))}function R(L,E){if(L==="insights"){const P=E&&x(E.get)?E.get("insights"):null;return{other:(P&&typeof P=="object"?P:{}).compareWith||null}}if(L!=="views")return{};const D=E&&x(E.get)?E.get("views"):null,I=D&&typeof D=="object"?D:{};return{allowSave:I.allowSave!==!1,showDiff:I.showDiff===!0,builtinTitle:I.builtinTitle,savedTitle:I.savedTitle}}function O(L,E){const D=L!==null&&typeof L=="object",I=D?L.name:L,P=x(I),k=P?I.name||"panel":String(I),N=P?I:X[k];if(!N)return z(`toolpanel:${k}`,`unknown tool panel "${k}"`),null;const G=D&&L.props||{};return{name:k,title:D&&L.title||(W[k]?E.messages.t(W[k]):k),icon:D&&L.icon||V[k]||k,Ctor:N,props:{...P?{}:R(k,E),...G}}}function F(L){const E=L.pagination&&x(L.pagination.get)?L.pagination.get():null;return E&&Number.isFinite(E.total)?E.total:L.rows.count()}function C(L,E,D){const I=new Map;return{announce(P,k){x(D)&&D(P,k)},t(P,k){return L.messages.t(P,k)},grid:L,document:E,columns:()=>L.columns.all(),columnGroups:()=>L.state.get().columnGroups||[],groupColumns:(P,k)=>L.columns.groupColumns(P,k),ungroupColumn:P=>L.columns.ungroupColumn(P),renameGroup:(P,k)=>L.columns.renameGroup(P,k),dissolveGroup:P=>L.columns.dissolveGroup(P),showColumns:P=>L.columns.show(P),hideColumns:P=>L.columns.hide(P),groupBy:()=>L.state.get().group||[],setGroupBy:P=>L.columns.group(P),pivotBy:()=>(L.state.get().pivot||{}).columns||[],setPivotBy:P=>L.columns.pivot(P),valueColumns:()=>L.columns.all().filter(P=>P.total).map(P=>P.id),setValueColumns:P=>L.columns.totals(P),valueAggregation(P){const k=L.columns.get(P);return!k||!k.total?"sum":typeof k.total=="string"?k.total:"custom"},setValueAggregation(P,k){L.columns.setTotal(P,k)},quickFilter:()=>L.state.get().quick||"",setQuickFilter:P=>L.filters.quick(P),rowCount:()=>F(L),totalRowCount:()=>x(L.rows.totalCount)?L.rows.totalCount():L.rows.count(),formattableColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id)})),formattingRules:P=>L.formatting.list(P),columnSamples:P=>{let k=P;if(!k||k==="*"){const q=L.columns.visible().find(Y=>!Y.generated);k=q?q.id:null}if(!k)return[];const N=[],G=new Set;for(const q of o(L)){const Y=L.rows.value(q.key,k);if(Y==null||Y==="")continue;const J=typeof Y=="object"?N.length:Y;if(!G.has(J)&&(G.add(J),N.push(Y),N.length>=24))break}return N},profilableColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id)})),columnProfile:P=>{const k=L.config().source;return((L.state.get().pivot||{}).columns||[]).length&&k&&typeof k=="object"&&x(k.aggregate)?null:L.statistics.profile(P)},columnProfileAsync:P=>L.statistics.profileAsync(P),reduceColumn:(P,k)=>L.statistics.reduce(P,k),columnCapability:P=>L.statistics.capability(P),regressionModel:P=>x(L.statistics.regressionModel)?L.statistics.regressionModel(P):null,insightsColumns:()=>L.columns.visible().filter(P=>!P.generated).map(P=>({id:P.id,title:String(P.title??P.id),type:P.type})),subsetVsPopulation:()=>L.statistics.subsetVsPopulation(),datasetVsDataset:P=>L.statistics.datasetVsDataset(P),compareGroups:(P,k)=>L.statistics.compareGroups(P,k),anomalies:P=>L.statistics.anomalies(P||{}),compareColumns:(P,k)=>{if(!P||!k||P===k)return null;const N=L.statistics.regression(P,k);return{n:N?N.n:0,pearson:L.statistics.correlation(P,k),spearman:L.statistics.spearman(P,k),kendall:L.statistics.kendall(P,k),covariance:L.statistics.covariance(P,k),slope:N?N.slope:null,intercept:N?N.intercept:null,r2:N?N.r2:null,stdError:N?N.stdError:null,weighted:L.statistics.weightedAverage(P,k)}},addRule:(P,k)=>L.formatting.add(P,k),removeRule:(P,k)=>L.formatting.remove(P,k),updateRule:(P,k,N)=>L.formatting.update(P,k,N),moveRule:(P,k,N)=>L.formatting.move(P,k,N),clearRules:P=>L.formatting.clear(P),views:()=>L.views.list(),activeId:()=>L.views.activeId,apply:P=>{L.views.apply(P)},saveAs:P=>L.views.save(P),rename:(P,k)=>L.views.rename(P,k),setDefault:P=>L.views.setDefault(P),clearDefault:()=>L.views.setDefault(null),remove:P=>L.views.remove(P),export:P=>L.views.export(P),diff:P=>L.views.diff(P),moveColumn(P,k,N){const G=L.columns.all().map(ee=>ee.id),q=G.indexOf(P),Y=G.indexOf(k);if(q<0||Y<0)return;let J=N?Y:Y+1;q<J&&(J-=1),J!==q&&L.columns.move(P,J)},isFiltered(P){return m(L.filters.get(),P)!==null},clearFilter(P){L.filters.set(i(L.filters.get(),P,null));const k=I.get(P);k&&x(k.clear)?k.clear():k&&x(k.set)&&k.set(null)},clearAllFilters(){L.filters.set(null);for(const P of I.values())x(P.clear)?P.clear():x(P.set)&&P.set(null)},filterFor(P){if(I.has(P))return v(I.get(P),P,L),I.get(P);const k=L.columns.get(P);if(!k)return null;const N=k.filter&&k.filter.props&&k.filter.props.values,G=c(L),q=G?L.config().context??null:null,Y=G?ie=>G.columnValues(P,{...ie||{},context:q}):null,J={grid:L,column:k,colId:P,type:k.type,locale:L.get("locale"),props:{...k.filter&&k.filter.props,values:N||(k.lookup?void 0:G?()=>Y({limit:a}).then(ie=>ie&&ie.supported?ie.values.map(ae=>ae.value):[]):()=>L.columns.distinct(P)),...G?{valueList:!1}:{}},lookup:k.lookup,document:E,value:ie=>L.rows.value(ie.row&&ie.row.key,P),rows:G?()=>[]:k.lookup?void 0:()=>o(L),changed:()=>{const ae=(x(ee.active)?ee.active():!0)&&x(ee.get)?ee.get():null;L.filters.set(i(L.filters.get(),P,ae||null))},fetchValues:Y};let ee=null;const re=G&&!N&&!k.lookup?w(k):null;if(re&&f(re)){const ie=G.columnValuesRefusal(P);if(ie){const ae=new g;ae.init({...J,props:{...J.props,valueList:!1}}),ee=p(E,ae,L.messages.t("filter.valuesUnsupported",{column:k.title||P})),z(`filter:values-unsupported:${P}`,`the filter on column "${P}" cannot list its values: ${ie}. It offers the text condition editor instead.`)}else ee=new h,ee.init(J)}else ee=B(J);return ee&&(v(ee,P,L),I.set(P,ee)),ee},destroyFilters(){for(const P of I.values())x(P.destroy)&&P.destroy();I.clear()}}}class T{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(E){this.#e=E.grid,this.#t=E.document,this.#n=E.root,this.#o=C(E.grid,E.document,E.announce);const I=(E.panels||["columns","filters"]).map(P=>O(P,E.grid)).filter(Boolean);this.#l=E.side==="left"?"left":"right",this.#r=new _,this.#r.init({document:E.document,host:this.#o,grid:E.grid,panels:I,actions:E.actions,icons:E.icons,side:this.#l,openPanel:E.openPanel})}mount(){const E=this.#t.createElement("div");E.className=`${y} ${y}--${this.#l}`,E.appendChild(this.#r.element()),this.#n.appendChild(E),this.#i=E;const D=this.#r.show.bind(this.#r),I=this.#r.hide.bind(this.#r);this.#r.show=P=>{const k=D(P);return this.#f(),k},this.#r.hide=()=>{I(),this.#f()};for(const P of[...s,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(P,()=>this.#r.refresh()));this.#s.push(this.#e.on("config:changed",P=>{P&&(P.key==="regression"||Array.isArray(P.keys)&&P.keys.includes("regression"))&&this.#r.refresh()})),this.#s.push(this.#e.on("presentation:started",P=>{this.#u=!0;const k=P&&P.options&&Array.isArray(P.options.chrome)?P.options.chrome:[];this.#c=k.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",P=>{const k=P&&P.colId,N=this.#r.panels.find(G=>G.name==="statistics");N&&k!=null&&(N.panel.column=String(k)),this.open("statistics")})),this.#f()}open(E){this.#r.show(E),this.#f()}close(){this.#r.hide(),this.#f()}toggle(E){this.#r.toggle(E),this.#f()}addAction(E){if(!(!E||!E.name)&&!this.#r.actions.some(D=>D.name===E.name)){if(this.#r.registerAction(E),this.#a&&!E.annotation){const D=this.#r.actions.find(I=>I.name===E.name);D&&this.#h(D.button)}else!this.#a&&E.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(E){this.#r.removeAction(E)&&this.#f()}presentOnly(){return this.#a?!0:this.#r.actions.some(E=>E.annotation&&E.button)?(this.#d(),!0):!1}#d(){const E=this.#r;this.#a={hidden:[],reopen:E.openPanel||null},this.#a.reopen&&E.hide(),this.#h(E.body);for(const D of[...E.tabs?.children||[]])D!==E.actionGroup&&this.#h(D);for(const D of[...E.actionGroup?.children||[]]){const I=E.actions.find(P=>P.button===D);(!I||!I.annotation)&&this.#h(D)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const E=this.#a;if(!E)return!1;this.#a=null;for(const D of E.hidden)D.el&&D.el.style&&(D.el.style.display=D.display);return E.reopen&&this.#r.show(E.reopen),this.#f(),!0}#h(E){if(!E||!E.style||!this.#a)return;const D=E.style.display||"";D!=="none"&&(E.style.display="none",this.#a.hidden.push({el:E,display:D}))}#f(){if(!this.#i)return;const E=!!this.#r.openPanel;this.#i.setAttribute("data-open",E?"true":"false"),this.#i.style.width=E?`${S}px`:"";const D=`${E?S:this.#p()}px`;this.#n.style.paddingLeft=this.#l==="left"?D:"",this.#n.style.paddingRight=this.#l==="left"?"":D,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?D:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":D)}#p(){const E=this.#r&&x(this.#r.element)?this.#r.element().querySelector?.(`.${t.panel}__tabs`):null,D=E&&(E.offsetWidth||E.getBoundingClientRect?.().width)||0;return D>0?Math.ceil(D):j}destroy(){for(const E of this.#s)E();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),Fe("packages/dom/src/celledit.js",function(e,K){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return g}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,X=K("packages/dom/src/editors/common.js"),W=X.CLS,V=X.markInvalid,H=X.isEditable,w=K("packages/dom/src/detailhost.js").insideDetail,A=`${W.editor}-host`;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;#h=null;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",m=>{const c=m.key||m.row&&m.row.key;this.#h=c&&m.colId?{key:c,colId:m.colId}:null,this.open(m)})),this.#u.push(this.#e.on("cell:edit:end",()=>{this.#h=null,this.close(!0)}));const t=this.#n.viewport.root,n=this.#e.get("edit"),o=n&&typeof n=="object"&&n.start||"double",d=m=>{if(w(m.target,t))return;const c=u(m.target,S=>S.getAttribute&&S.getAttribute("data-col"));if(!c)return;const f=u(c,S=>S.getAttribute&&S.getAttribute("data-key"));if(!f)return;const s=this.#e.rows.byKey(f.getAttribute("data-key"));if(!s||s.group)return;const p=c.getAttribute("data-col"),b=this.#e.columns.get(p);!b||!b.edit||!b.edit.enabled||this.#e.edit.start(s.key,p)},l=o==="key"?null:o==="single"?"click":"dblclick";l&&(t.addEventListener(l,d),this.#u.push(()=>t.removeEventListener(l,d)));const i=m=>{!this.#i||!this.#l||this.#g(m.target)||this.commit()};this.#t.addEventListener("mousedown",i,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",i,!0))}get target(){return this.#l}open(t){const n=t.key||t.row&&t.row.key,o=t.colId;if(!n||!o)return;if(this.#i&&this.#l&&this.#l.key===n&&this.#l.colId===o){this.#m();return}this.close();const d=this.#e.columns.get(o),l=this.#e.rows.byKey(n);if(!d||!l||!H({column:d,edit:d.edit,row:l,value:this.#e.rows.value(n,o),grid:this.#e}))return;const i=this.#w(n,o);if(this.#c=i,!i){z("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const m=this.#e.permissions,c=!!(m&&x(m.isSecret)&&m.isSecret(o)),f=_({grid:this.#e,column:d,colId:o,row:l,data:l.data,value:c?null:this.#e.rows.value(n,o),text:c?"":this.#e.rows.text(n,o),locale:this.#e.get("locale"),props:d.edit&&d.edit.props,lookup:d.lookup,document:this.#t,cell:i,overlay:this.#n.viewport.overlays,onCommit:b=>this.#p({value:b,key:n,colId:o}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:b=>{this.#d||this.#e.edit.stop(b)}},this.#r);if(!f){z(`celledit.noeditor:${o}`,`column "${o}" has no editor.`);return}this.#i=f,this.#s=i,this.#l={key:n,colId:o},this.#d=!1,this.#a=this.#A(i);const s=f.element();f.popup?(this.#n.viewport.overlays.appendChild(s),h(s,i,this.#n.viewport.root)):i.replaceChildren(s),i.classList.add(A),x(f.attached)&&f.attached(),a(s);const p=b=>this.#f(b);s.addEventListener("keydown",p),this.#u.push(()=>s.removeEventListener("keydown",p))}#f(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 o=n==="Enter"?this.#y(t.shiftKey?-1:1):this.#b(t.shiftKey?-1:1);this.commit()&&o&&this.#e.edit.start(o.key,o.colId)}#p(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if(x(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:n}=this.#l;if(x(this.#i.value)){const o=this.#i.value();if(x(this.#i.validate)){const d=this.#i.validate(o);if(d!==!0){if(V(this.#c,d),x(this.#i.focusTarget)){const l=this.#i.focusTarget();l&&x(l.focus)&&l.focus()}return!1}V(this.#c,null)}this.#p({value:o,key:t,colId:n})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(){const t=x(this.#i.element)?this.#i.element():null;if(!t)return;const n=t.querySelector&&t.querySelector("input, select, textarea, [tabindex]")||t;x(n.focus)&&n.focus()}#g(t){if(!t)return!1;const n=x(this.#i.element)?this.#i.element():null;if(n&&x(n.contains)&&n.contains(t))return!0;const o=this.#c;return!!(o&&x(o.contains)&&o.contains(t))}#y(t){if(!this.#l||this.#a<0)return null;for(let n=this.#a+t;n>=0&&n<this.#e.rows.count();n+=t){const o=this.#e.rows.get(n);if(o&&!o.group)return{key:o.key,colId:this.#l.colId}}return null}#b(t){if(!this.#l)return null;const n=this.#e.columns.visible(),o=n.findIndex(d=>d.id===this.#l.colId);for(let d=o+t;d>=0&&d<n.length;d+=t){const l=n[d];if(l.edit&&l.edit.enabled)return{key:this.#l.key,colId:l.id}}return null}#A(t){const n=u(t,d=>d.getAttribute&&d.getAttribute("data-index"));if(!n)return-1;const o=Number(n.getAttribute("data-index"));return Number.isFinite(o)?o:-1}#w(t,n){const o=this.#n.viewport.root;if(!o||!o.querySelectorAll)return null;for(const d of o.querySelectorAll(`[data-col="${n}"]`)){const l=u(d,i=>i.getAttribute&&i.getAttribute("data-key"));if(l&&l.getAttribute("data-key")===t)return d}return null}close(t=!1){const n=this.#l,o=this.#d;this.#c&&V(this.#c,null);const d=this.#S();if(this.#i&&x(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(A),this.#o&&x(this.#o.releaseCell)){const l=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,l)}this.#s.replaceChildren&&this.#s.replaceChildren(),d&&this.#v(this.#s),this.#n.refresh({force:!0})}if(this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1,!t&&n&&!o){const l=this.#h;l&&l.key===n.key&&l.colId===n.colId&&this.#e.edit.stop(!1)}}#S(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const n=this.#i&&x(this.#i.element)?this.#i.element():null,o=d=>!!d&&x(d.contains)&&d.contains(t);return o(n)||o(this.#s)}#v(t){const o=x(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;o&&x(o.focus)&&o.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function u(r,t){let n=r;for(;n;){if(t(n))return n;n=n.parentNode}return null}function h(r,t,n){if(!x(t.getBoundingClientRect))return;const o=t.getBoundingClientRect(),d=n.getBoundingClientRect();r.style.position="absolute",r.style.top=`${Math.round(o.top-d.top)}px`,r.style.minWidth=`${Math.round(o.width)}px`,r.style.left=`${Math.round(o.left-d.left)}px`;const l=r.offsetWidth||Math.round(o.width),i=Math.round(o.left-d.left)+l-Math.round(d.width);i>0&&(r.style.left=`${Math.max(0,Math.round(o.left-d.left)-i)}px`)}function a(r){const t=r.querySelector&&r.querySelector("input, select, textarea, [tabindex]")||r;x(t.focus)&&t.focus(),x(t.select)&&t.select()}}),Fe("packages/dom/src/editbar.js",function(e,K){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return H}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,_=K("packages/dom/src/editors/index.js").createEditor,V=`${K("packages/dom/src/editors/common.js").CLS.editor}-bar`;class H{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=!1;#c=null;#d=[];constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root}mount(){const w=this.#t,A=w.createElement("div");A.className=V;const g=w.createElement("span");g.className=`${V}__ref`,g.textContent="";const u=w.createElement("div");u.className=`${V}__slot`;const h=w.createElement("span");h.className=`${V}__readonly`,A.appendChild(g),A.appendChild(u),this.#n.insertBefore(A,this.#n.firstChild),this.#r=A,this.#o=g,this.#i=u,this.#l=h;for(const a of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(a,r=>this.#f(r)))}bind(w,A){const g=this.#e.columns.get(A),u=w?this.#e.rows.byKey(w):null;this.#a=u&&g&&!u.group?{key:w,colId:A}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#a){this.#o.textContent="";return}const{key:w,colId:A}=this.#a,g=this.#e.columns.get(A);if(!g)return;if(this.#o.textContent=g.title||A,!!!(g.edit&&g.edit.enabled)){this.#l.textContent=this.#e.rows.text(w,A),this.#i.appendChild(this.#l);return}const h=this.#e.rows.byKey(w);if(!h)return;const a=_({grid:this.#e,column:g,colId:A,row:h,data:h.data,value:this.#e.rows.value(w,A),text:this.#e.rows.text(w,A),locale:this.#e.get("locale"),props:g.edit&&g.edit.props,lookup:g.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:d=>d?this.cancel():this.commit(!0)});if(!a){z(`editbar.noeditor:${A}`,`column "${A}" has no editor.`),this.#l.textContent=this.#e.rows.text(w,A),this.#i.appendChild(this.#l);return}this.#s=a;const r=a.element();a.popup?(this.#l.textContent=this.#e.rows.text(w,A),this.#i.appendChild(this.#l)):this.#i.appendChild(r),x(a.attached)&&a.attached();const t=d=>this.#p(d),n=()=>{this.#u=!0},o=[r,this.#i];for(const d of o)d.addEventListener("keydown",t),d.addEventListener("input",n),d.addEventListener("change",n);this.#c=()=>{for(const d of o)d.removeEventListener("keydown",t),d.removeEventListener("input",n),d.removeEventListener("change",n)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#s&&x(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(w){if(w&&w.colId&&(w.key||w.row&&w.row.key)){this.bind(w.key||w.row.key,w.colId);return}this.refresh()}#p(w){if(w.key==="Enter"){w.preventDefault(),this.commit();return}w.key==="Escape"&&(w.preventDefault(),this.cancel())}commit(w){if(!this.#a||!this.#u&&!w)return!1;const{key:A,colId:g}=this.#a;if(!this.#s||!x(this.#s.value))return!1;const u=this.#s.value();return this.#u=!1,this.#e.edit.start(A,g),this.#e.edit.stop(!1,{value:u,key:A,colId:g}),this.refresh(),!0}destroy(){this.#h();for(const w of this.#d)w();this.#d=[],this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Fe("packages/dom/src/pastepreview.js",function(e,K){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return B}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.clear,V="lat-pastepreview",H='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class B{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(A){this.#e=A.grid,this.#t=A.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(A,g){const u=this.#e;return(u&&u.messages?u.messages:$).t(A,g)}#d(A){const g=`paste.preview.reason.${A}`,u=this.#c(g);return u===g?A:u}#h(A){return A==null||A===""?"":String(A)}#f(A,g){const u=this.#e.columns&&x(this.#e.columns.get)?this.#e.columns.get(g):null;return`${u&&(u.title||u.headerName)||g} · ${A}`}show(A,g){const u=this.#b();if(!u)return!1;this.#l=g&&g.onConfirm,this.#a=g&&g.onCancel||null;const h=A&&A.changes||[],a=A&&A.rejected||[],r=h.filter(n=>n.changed);this.#p(r,a);const t=u.ownerDocument;return this.#s=t&&t.activeElement,u.style.display="",x(u.focus)&&u.focus(),this.#w(this.#c("a11y.paste.previewOpened",{count:r.length,changes:r.length,rejected:a.length}),{repeat:!0}),!0}#p(A,g){const u=this.#r.ownerDocument;W(this.#r);const h=X(u,"p",{class:`${V}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:A.length,changes:A.length,rejected:g.length})});if(this.#r.appendChild(h),!A.length&&!g.length){this.#r.appendChild(X(u,"p",{class:`${V}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!A.length;return}this.#o.disabled=!A.length,A.length&&(this.#r.appendChild(X(u,"h3",{class:`${V}__heading`,text:this.#c("paste.preview.changesHeading",{count:A.length})})),this.#r.appendChild(this.#m(u,A))),g.length&&(this.#r.appendChild(X(u,"h3",{class:`${V}__heading ${V}__heading--rejected`,text:this.#c("paste.preview.rejectedHeading",{count:g.length})})),this.#r.appendChild(this.#g(u,g)))}#m(A,g){const u=X(A,"tr",{children:[X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),h=g.map(a=>X(A,"tr",{children:[X(A,"th",{attrs:{scope:"row"},text:this.#f(a.key,a.colId)}),X(A,"td",{class:`${V}__old`,text:this.#h(a.oldValue)}),X(A,"td",{class:`${V}__new`,text:this.#h(a.newValue)})]}));return X(A,"table",{class:`${V}__table`,children:[X(A,"thead",{children:[u]}),X(A,"tbody",{children:h})]})}#g(A,g){const u=X(A,"tr",{children:[X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),X(A,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),h=g.map(a=>X(A,"tr",{children:[X(A,"th",{attrs:{scope:"row"},text:this.#f(a.key,a.colId)}),X(A,"td",{class:`${V}__reason`,text:this.#d(a.reason)})]}));return X(A,"table",{class:`${V}__table ${V}__table--rejected`,children:[X(A,"thead",{children:[u]}),X(A,"tbody",{children:h})]})}confirm(){const A=this.#l;this.#y(),x(A)&&A()}cancel(){const A=this.#a;this.#y(),this.#w(this.#c("a11y.paste.cancelled"),{repeat:!0}),x(A)&&A()}#y(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const A=this.#s;this.#s=null,A&&x(A.focus)&&A.focus()}#b(){if(this.#n)return this.#n;const A=this.#t.viewport&&this.#t.viewport.overlays,g=A&&A.ownerDocument;if(!A||!g||!x(g.createElement))return null;const u=`${V}-title`,h=X(g,"h2",{class:`${V}__title`,attrs:{id:u},text:this.#c("paste.preview.title")}),a=X(g,"div",{class:`${V}__body`}),r=X(g,"button",{class:`${V}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),t=X(g,"button",{class:`${V}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),n=X(g,"div",{class:`${V}__foot`,children:[t,r]}),o=X(g,"div",{class:V,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":u},children:[X(g,"div",{class:`${V}__head`,children:[h]}),a,n]});return A.appendChild(o),this.#n=o,this.#r=a,this.#o=r,this.#i=t,this.#A(o,r,t),o}#A(A,g,u){const h=t=>{if(t.stopPropagation(),t.key==="Escape"){t.preventDefault(),this.cancel();return}if(t.key!=="Tab")return;const n=[...A.querySelectorAll(H)].filter(i=>!i.disabled);if(!n.length){t.preventDefault();return}const o=n[0],d=n[n.length-1],l=A.ownerDocument.activeElement;t.shiftKey&&(l===o||l===A)?(t.preventDefault(),d.focus()):!t.shiftKey&&l===d&&(t.preventDefault(),o.focus())},a=t=>{t&&x(t.preventDefault)&&t.preventDefault(),this.confirm()},r=t=>{t&&x(t.preventDefault)&&t.preventDefault(),this.cancel()};A.addEventListener("keydown",h),g.addEventListener("click",a),u.addEventListener("click",r),this.#u.push(()=>{A.removeEventListener("keydown",h),g.removeEventListener("click",a),u.removeEventListener("click",r)})}#w(A,g){const u=this.#t&&this.#t.announce;x(u)&&u.call(this.#t,A,g)}destroy(){for(const A of this.#u)A();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Fe("packages/dom/src/rangeselect.js",function(e,K){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/model/selection.js"),X=_.extendSeries,W=_.resolveSelectionConfig,V=K("packages/dom/src/renderer/textentry.js"),H=V.isTextEntry,B=V.isFindBarControl,A=K("packages/dom/src/pastepreview.js").PastePreview,g=K("packages/dom/src/columnmenu.js"),u=g.chartableRange,h=g.rangeChartConfig,a="lat-cell--range",r="lat-cell--range-edge",t=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),n=3;class o{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(i){this.#e=i.grid,this.#t=i.renderer,this.#n=i.document,this.#a=i.preview||null}mount(){const i=this.#t.viewport.root,m=p=>this.#c(p),c=p=>this.#d(p),f=()=>this.#h(),s=p=>this.#f(p);i.addEventListener("pointerdown",m),this.#n.addEventListener("pointermove",c),this.#n.addEventListener("pointerup",f),i.addEventListener("keydown",s),this.#o.push(()=>{i.removeEventListener("pointerdown",m),this.#n.removeEventListener("pointermove",c),this.#n.removeEventListener("pointerup",f),i.removeEventListener("keydown",s)});for(const p of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(p,()=>this.paint()));this.paint()}#c(i){if(i.button!==0)return;const m=i.target;if(!m||!x(m.closest))return;if(this.#r=!1,m.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:i.clientX,fromY:i.clientY,armed:!0};return}if(m.closest('[data-role="row-drag"]'))return;const c=this.#q(m);if(!c)return;if(i.shiftKey&&this.#e.selection.corner()){const s=this.#E(c);this.#e.selection.extendRange(s.rowIndex,s.colId),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!0};return}const f=this.#M(c);this.#u=f,this.#e.selection.startRange(f.rowIndex,f.colId,{additive:i.ctrlKey||i.metaKey}),this.#i={mode:"select",fromX:i.clientX,fromY:i.clientY,armed:!1}}#d(i){const m=this.#i;if(!m)return;if(!m.armed){if(Math.abs(i.clientX-m.fromX)+Math.abs(i.clientY-m.fromY)<n)return;m.armed=!0}const c=this.#I(i.clientX,i.clientY);if(!c)return;if(m.mode==="fill"){this.#l=c,this.paint();return}const f=this.#E(c);this.#e.selection.extendRange(f.rowIndex,f.colId)}#h(){const i=this.#i;if(this.#i=null,!!i){if(i.mode==="fill"&&this.#l){const m=this.#l;this.#l=null,this.fillTo(m.rowIndex)}this.#l=null,this.paint()}}#f(i){if(this.#B()||B(i.target)||H(i.target))return;const m=i.ctrlKey||i.metaKey,c=i.key;if(m&&(c==="c"||c==="C")){this.copy(),i.preventDefault();return}if(m&&(c==="v"||c==="V")){this.paste(),i.preventDefault();return}if(m&&(c==="d"||c==="D")){this.fillDown(),i.preventDefault();return}if(m&&!i.altKey&&(c==="z"||c==="Z"||c==="y"||c==="Y")){const O=this.#e.edit;if(!O||O.undoShortcuts===!1)return;const F=c==="y"||c==="Y"||i.shiftKey;this.#w(F)&&i.preventDefault();return}if(c==="Delete"||c==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),i.preventDefault();return}if(this.#e.edit&&this.#e.edit.clearOnDelete===!1)return;this.clear(),i.preventDefault();return}if(i.altKey&&c==="F1"){this.chartSelection()&&i.preventDefault();return}if(!i.shiftKey)return;const f={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[c];if(!f)return;if(m){const O=this.#$();if(!O)return;if(!this.#r){const E=this.#M(O);this.#u=E,this.#e.selection.startRange(E.rowIndex,E.colId,{additive:!0}),this.#r=!0}const F=this.#e.columns.visible().map(E=>E.id),C=F.indexOf(O.colId),T=this.#e.selection.corner()||{row:O.rowIndex,colId:O.colId},L=this.#E({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,T.row+f[0])),colId:F[Math.min(F.length-1,Math.max(0,(C<0?0:C)+f[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),i.preventDefault();return}this.#r=!1;const s=this.#e.selection.corner(),p=this.#$(),b=s||p;if(!b)return;if(!s&&p){const O=this.#M(p);this.#u=O,this.#e.selection.startRange(O.rowIndex,O.colId)}const S=this.#e.columns.visible().map(O=>O.id),j=S.indexOf(b.colId??b.colId),y=S[Math.min(S.length-1,Math.max(0,j+f[1]))],v=Math.min(this.#e.rows.count()-1,Math.max(0,(s?s.row:p.rowIndex)+f[0])),R=this.#E({rowIndex:v,colId:y});this.#e.selection.extendRange(R.rowIndex,R.colId),i.preventDefault()}async copy(){const i=this.#e.export.rangeText();if(!i)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const m=globalThis.navigator&&globalThis.navigator.clipboard;if(!m||!x(m.writeText))return!1;try{return await m.writeText(i),this.#e.emit("clipboard:copy",{text:i,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:i,ok:!1,rows:"range"},"user"),!1}}async paste(){const i=globalThis.navigator&&globalThis.navigator.clipboard;if(!i||!x(i.readText))return 0;let m="";try{m=await i.readText()}catch{return 0}return this.pasteText(m)}pasteText(i){if(!i)return 0;const m=this.#e.selection.cells(),c=m.length?m[0]:this.#A();if(!c)return 0;const f=m.length>1?{rows:new Set(m.map(s=>s.key)).size,columns:new Set(m.map(s=>s.colId)).size}:void 0;if(this.#p()){const s=this.#e.edit.previewPaste(c,i,f);if(s.changes.length+s.rejected.length>1)return this.#m().show(s,{onConfirm:()=>this.#g(c,i,f)}),0}return this.#g(c,i,f)}#p(){const i=this.#e.edit;return!!(i&&i.pastePreview&&x(i.previewPaste))}#m(){return this.#a||(this.#a=new A({grid:this.#e,renderer:this.#t})),this.#a}#g(i,m,c){const f=this.#e.edit.pasteInto(i,m,c,{origin:"user"}),s=p=>this.#b(p?this.#y("a11y.range.written",{count:p}):this.#y("a11y.range.refused"),{repeat:!0});return f&&x(f.then)?f.then(s):s(f),f}#y(i,m){const c=this.#e;return(c&&c.messages?c.messages:$).t(i,m)}#b(i,m){const c=this.#t&&this.#t.announce;x(c)&&c.call(this.#t,i,m)}#A(){const i=this.#$();if(!i)return null;const m=this.#e.rows.get(i.rowIndex);return m?{key:m.key,colId:i.colId}:null}#w(i){const m=this.#e.history;return!(!m||!(i?m.canRedo():m.canUndo())||!(i?m.redo():m.undo()))}clear(){let i=this.#e.selection.cells();const m=this.#A(),c=this.#n&&this.#n.activeElement;if(!!(m&&c&&x(c.matches)&&c.matches('[data-col][tabindex="0"]'))&&!i.some(b=>b.key===m.key&&b.colId===m.colId)?i=[m]:i.length||(i=m?[m]:[]),!i.length)return 0;const s=this.#e.edit.setCells(i.map(b=>({key:b.key,colId:b.colId,value:null})),"cell",{origin:"user"}),p=b=>{b&&this.#b(this.#y("a11y.range.cleared",{count:b}),{repeat:!0})};return s&&x(s.then)?s.then(p):p(s),s}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const i=this.#e.selection.cells();if(i.length<2)return 0;const m=[...new Set(i.map(s=>s.key))];if(m.length<2)return 0;const c=m[0],f=[];for(const{key:s,colId:p}of i)s!==c&&f.push({key:s,colId:p,value:this.#e.rows.value(c,p)});return this.#e.edit.setCells(f,"cell",{origin:"user"})}chartSelection(){const i=h(this.#e);if(!i.handler)return!1;const m=u(this.#e);return m?(i.handler(this.#e,m),!0):!1}fillTo(i){if(this.#e.selection.ranges().length>1)return 0;const m=this.#e.selection.cells();if(!m.length)return 0;const c=[...new Set(m.map(y=>y.key))],f=[...new Set(m.map(y=>y.colId))],s=this.#z(c[c.length-1]);if(s<0||i<=s)return 0;const p=[];for(let y=s+1;y<=i;y++){const v=this.#e.rows.get(y);if(!v)break;p.push(v)}if(!p.length)return 0;const b=[];for(const y of f){const v=c.map(O=>this.#e.rows.value(O,y)),R=this.#S(v,p,y);for(let O=0;O<p.length;O++)b.push({key:p[O].key,colId:y,value:R[O]})}const S=this.#e.edit.setCells(b,"cell",{origin:"user"}),j=this.#e.selection.corner();return j&&this.#e.selection.extendRange(i,j.colId),S}#S(i,m,c){const f=this.#e.get("selection"),s=f&&typeof f=="object"?f.fill:void 0;if(x(s)){const p=this.#e.columns.get(c),b=m.map(j=>({row:j,column:p})),S=s({source:i,target:b,direction:"down"});if(Array.isArray(S)&&S.length===m.length)return S}return X(i,m.length)}paint(){const i=this.#t.viewport.root;if(!i||!i.querySelectorAll)return;const m=this.#e.selection,c=m.ranges().length>0,f=this.#l;for(const s of i.querySelectorAll("[data-col]")){const p=s.getAttribute("data-col"),b=s.parentNode,S=s.getAttribute?s.getAttribute("data-index"):null,j=S!==null&&S!==""?S:b&&b.getAttribute?b.getAttribute("data-index"):null;if(j===null||j==="")continue;const y=Number(j);if(!Number.isFinite(y)||y<0)continue;const v=c&&m.inRange(y,p),R=!!f&&this.#v(y,p,f);s.classList.toggle(a,v||R);const O=v||R?this.#C(y,p,m):null;s.classList.toggle(r,!!O&&O.any);for(const[F,C]of Object.entries(t))s.classList.toggle(C,!!O&&O[F])}this.#O()}#v(i,m,c){const f=this.#e.selection.cells();if(!f.length||!new Set(f.map(b=>b.colId)).has(m))return!1;const p=this.#z([...new Set(f.map(b=>b.key))].pop());return i>p&&i<=c.rowIndex}#C(i,m,c){const f=this.#e.columns.visible().map(j=>j.id),s=f.indexOf(m),p=s>0?f[s-1]:null,b=s>=0&&s<f.length-1?f[s+1]:null,S={top:!c.inRange(i-1,m),bottom:!c.inRange(i+1,m),left:!p||!c.inRange(i,p),right:!b||!c.inRange(i,b)};return S.any=S.top||S.bottom||S.left||S.right,S}#O(){const i=this.#e.selection.corner(),m=this.#t.viewport.overlays;if(!m)return;if(!i||this.#L()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#s&&(this.#s.style.display="none");return}const c=this.#W(i.row,i.colId);if(!c||!x(c.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#y("a11y.fillHandle")),m.appendChild(this.#s));const f=c.getBoundingClientRect(),s=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const b=this.#t.viewport.rtl===!0?f.left:f.right;this.#s.style.left=`${Math.round(b-s.left)-4}px`,this.#s.style.top=`${Math.round(f.bottom-s.top)-4}px`}#P(i){const m=this.#t;return!i||typeof m.spanAt!="function"?null:m.spanAt(i.rowIndex,i.colId)}#M(i){const m=this.#P(i);return m?{rowIndex:m.row,colId:m.columnId}:i}#E(i){const m=this.#P(i);if(!m)return i;const c=this.#u,f=!!c&&c.rowIndex>=m.row+m.rows,s=this.#N(),p=c?s.indexOf(c.colId):-1,b=p>=0&&p>=m.col+m.cols;return{rowIndex:f?m.row:m.row+m.rows-1,colId:b?m.columnId:m.endColumnId}}#T(){const i=this.#e.selection.corner();if(!i)return!1;const m=this.#P({rowIndex:i.row,colId:i.colId});return!!m&&(m.rows>1||m.cols>1)}#N(){const i=this.#e.columns;return i&&x(i.visible)?i.visible().map(m=>m.id):[]}#L(){return W(this.#e.get("selection")).fillHandle}#B(){const i=this.#t.viewport.root;return!!(i&&i.querySelector&&i.querySelector(".lat-editor-host, .lat-editor--popup"))}#_(){const i=this.#e.selection.cells();return i.length?i[0]:null}#z(i){for(let m=0;m<this.#e.rows.count();m++){const c=this.#e.rows.get(m);if(c&&c.key===i)return m}return-1}#$(){const i=this.#t.viewport.root,m=i&&i.querySelector?i.querySelector('[data-col][tabindex="0"]'):null;return m?this.#q(m):null}#q(i){if(!i||!x(i.closest))return null;const m=i.closest("[data-col]");if(!m||!m.classList.contains("lat-cell"))return null;const c=m.closest("[data-index]");if(!c)return null;const f=Number(c.getAttribute("data-index"));return!Number.isFinite(f)||f<0?null:{rowIndex:f,colId:m.getAttribute("data-col")}}#I(i,m){const c=this.#n.elementFromPoint?this.#n.elementFromPoint(i,m):null;return c?this.#q(c):null}#W(i,m){const c=this.#t.viewport.root;if(!c||!c.querySelectorAll)return null;for(const f of c.querySelectorAll(`[data-col="${m}"]`)){const s=f.closest?f.closest("[data-index]"):null;if(s&&Number(s.getAttribute("data-index"))===i)return f}return null}destroy(){for(const i of this.#o)i();this.#o=[],this.#s&&x(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&x(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const d=o}),Fe("packages/dom/src/importer.js",function(e,K){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return o}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/core/src/import/index.js"),X=_.parseDelimited,W=_.inferColumns,V=_.mapRecords,H=_.readXlsx,B=_.looksLikeXlsx,w=K("packages/dom/src/editors/common.js"),A=w.el,g=w.clear,u=w.on,a=K("packages/dom/src/renderer/textentry.js").isTextEntry,r="lat-import",t='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',n=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class o{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document;const i=l.settings&&typeof l.settings=="object"?l.settings:{};this.#r={file:i.file!==!1,drop:i.drop!==!1,paste:i.paste!==!1,mode:i.mode==="replace"?"replace":"append"},this.#u()}#u(){const l=this.#t&&this.#t.viewport?this.#t.viewport.root:null;l&&(this.#r.drop&&(this.#o.push(u(l,"dragover",i=>{i.dataTransfer&&[...i.dataTransfer.types||[]].includes("Files")&&(i.preventDefault(),l.classList.add("lat-import--dropzone"))})),this.#o.push(u(l,"dragleave",()=>l.classList.remove("lat-import--dropzone"))),this.#o.push(u(l,"drop",i=>{l.classList.remove("lat-import--dropzone");const m=i.dataTransfer&&i.dataTransfer.files&&i.dataTransfer.files[0];m&&(i.preventDefault(),this.#c(m))}))),this.#r.paste&&this.#o.push(u(l,"paste",i=>{if(a(i.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const m=i.clipboardData&&i.clipboardData.getData("text/plain");!m||!m.includes(`
57
- `)||(i.preventDefault(),this.fromText(m))})))}openFile(){const l=A(this.#n,"input",{attrs:{type:"file",accept:n}});l.style.display="none",this.#o.push(u(l,"change",()=>{const i=l.files&&l.files[0];i&&this.#c(i),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(x(l.arrayBuffer)){l.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(B(c)){this.fromXlsx(c,l.name);return}this.fromText(new TextDecoder().decode(c),l.name)});return}if(x(l.text)){l.text().then(m=>this.fromText(m,l.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),l.name),i.readAsText(l)}async fromXlsx(l,i){const{header:m,rows:c}=await H(l);if(!m.length)return;const f=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:f,delimiter:null,name:i,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(l,i){const{header:m,rows:c,delimiter:f}=X(l);if(!m.length)return;const s=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(b=>b.length!==m.length).length;this.#l={rows:c,columns:s,delimiter:f,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(t);l&&x(l.focus)&&l.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(l,i){const m=this.#t&&this.#t.announce;x(m)&&m.call(this.#t,l,i)}#f(l,i){return(this.#e&&this.#e.messages?this.#e.messages:$).t(l,i)}#p(){const l=this.#n,i=A(l,"div",{class:r,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),m=A(l,"div",{class:`${r}__panel`});m.appendChild(A(l,"h2",{class:`${r}__title`,text:this.#f("import.title")})),this.#s=A(l,"div",{class:`${r}__body`}),m.appendChild(this.#s);const c=A(l,"div",{class:`${r}__footer`}),f=A(l,"button",{class:`${r}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),s=A(l,"button",{class:`${r}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(u(f,"click",()=>this.close())),this.#o.push(u(s,"click",()=>this.#g())),c.appendChild(f),c.appendChild(s),m.appendChild(c),i.appendChild(m),this.#o.push(u(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const S=[...i.querySelectorAll(t)].filter(v=>!v.hidden);if(!S.length)return;const j=S[0],y=S[S.length-1];b.shiftKey&&this.#n.activeElement===j?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),j.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const l=this.#n,i=g(this.#s),{rows:m,columns:c,name:f,warnings:s}=this.#l;i.appendChild(A(l,"p",{class:`${r}__summary`,text:this.#f("import.summary",{count:m.length,name:f||this.#f("import.clipboard")})}));for(const v of s)i.appendChild(A(l,"p",{class:`${r}__warning`,text:v}));const p=this.#e.columns.all().map(v=>v.field||v.id).filter(Boolean),b=A(l,"table",{class:`${r}__map`}),S=A(l,"tr",{});for(const v of["import.colSource","import.colField","import.colType"])S.appendChild(A(l,"th",{text:this.#f(v)}));b.appendChild(S),c.forEach((v,R)=>{const O=A(l,"tr",{});O.appendChild(A(l,"td",{text:v.source}));const F=A(l,"select",{attrs:{"data-col":String(R),"aria-label":this.#f("import.mapLabel",{source:v.source})}});F.appendChild(A(l,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const T of p)F.appendChild(A(l,"option",{text:T,attrs:{value:T,selected:T===v.field?!0:null}}));v.field&&!p.includes(v.field)&&F.appendChild(A(l,"option",{text:v.field,attrs:{value:v.field,selected:!0}}));const C=A(l,"td",{});C.appendChild(F),O.appendChild(C),O.appendChild(A(l,"td",{class:`${r}__type`,text:v.type})),b.appendChild(O)}),i.appendChild(b);const j=A(l,"div",{class:`${r}__mode`}),y=A(l,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});y.appendChild(A(l,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(A(l,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),j.appendChild(A(l,"label",{text:this.#f("import.modeLabel")})),j.appendChild(y),i.appendChild(j)}#g(){const{rows:l,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,f=c==="replace"||c==="append"?c:this.#r.mode,s=V(l,i);this.#e.import.apply(s,{mode:f}),this.close(),this.#h(this.#f("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&x(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Fe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V=_.clear,H=_.documentFor,B="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,h){return(this.messages&&typeof this.messages.t=="function"?this.messages:$).t(u,h)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||$;const h=u||{};if(this.doc=H(h),this.host=h.host||{},this.props=h.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",B],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 a=X(this.doc,"button",{class:`${B}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(a,"click",()=>this.toggle())),this.root.appendChild(a),this.toggleButton=a,this.menu=X(this.doc,"div",{class:`${B}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,h,a){const r=X(this.doc,"button",{class:`${B}__${u}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${B}__glyph`,text:a,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${B}__label`,text:h})]});return this.off.push(W(r,"click",()=>{const t=this.host[u];x(t)&&t(),this.refresh()})),r}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,h=x(u.canUndo)?u.canUndo():!1,a=x(u.canRedo)?u.canRedo():!1,r=x(u.peek)?u.peek("undo"):null,t=x(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",h,r),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(u,h,a,r){if(!u)return;u.disabled=!a;const t=h==="undo",n=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${B}__label`);o&&(o.textContent=n);const d=r&&r.label?this.t("history.described",{action:n,label:r.label}):n;u.setAttribute("title",a?d:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",a?d:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;V(u);const h=x(this.host.list)?this.host.list():[];if(!h.length){u.appendChild(X(this.doc,"p",{class:`${B}__empty`,text:this.t("history.empty")}));return}h.forEach((a,r)=>{const t=X(this.doc,"button",{class:`${B}__item`,attrs:{type:"button",role:"menuitem","data-type":a.type,"data-undone":a.undone?"true":null},children:[X(this.doc,"span",{class:`${B}__kind`,text:a.type}),X(this.doc,"span",{class:`${B}__text`,text:a.label||a.type})]});this.off.push(W(t,"click",()=>{const n=r+1;for(let o=0;o<n;o++)x(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&x(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const A=w}),Fe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",V="lat-cell--added-column";class H{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const u=this.#e.diff,h=u&&u.enabled;for(const a of g.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key"),t=h?u.statusOf(r):"unchanged";for(const o of Object.values(X))a.classList.remove(o);h&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",h?t:"");const n=h&&t==="changed";for(const o of a.querySelectorAll("[data-col]")){const d=o.getAttribute("data-col");if(o.classList.remove(W,V),o.removeAttribute("data-before"),!n)continue;const l=u.cellStatus(r,d);if(l==="changed"){o.classList.add(W);const i=this.#r(u,r,d);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else l==="added-column"&&o.classList.add(V)}}}#r(g,u,h){const a=this.#e,r=a&&a.columns,t=r&&x(r.get)?r.get(h):null,n=a&&a.permissions;if(t&&n&&x(n.isSecret)&&n.isSecret(t))return null;const o=g.before(u,h);if(o==null)return this.#o("diff.empty");if(!t||!x(t.formatValue))return String(o);const d=x(g.beforeRow)?g.beforeRow(u):void 0,i={...(a.rows&&x(a.rows.byKey)?a.rows.byKey(u):null)||{},data:d===void 0?{}:d};try{const m=t.formatValue(o,i,i.data);return m==null?"":String(m)}catch(m){return z(`diff-before-format:${h}`,`the formatter for column "${h}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(o)}}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:_).t(g,u)}destroy(){for(const u of this.#n)u();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const u of g.querySelectorAll("[data-key]")){for(const h of Object.values(X))u.classList.remove(h);u.removeAttribute("data-diff")}for(const u of g.querySelectorAll("[data-col]"))u.classList.remove(W,V),u.removeAttribute("data-before")}}}function B(A){return!!(A&&A.diff&&(x(A.diff)||typeof A.diff=="object"))}const w=H}),Fe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,z="lat-cell--highlight",$="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const V=()=>{this.#o=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#l();if(H){H.sweep();for(const B of V.querySelectorAll("[data-key]")){const w=B.getAttribute("data-key");for(const A of B.querySelectorAll("[data-col]")){const g=H.active?H.colourFor(w,A.getAttribute("data-col")):null;g?(A.classList.add(z),A.style.setProperty($,g)):A.classList.contains(z)&&(A.classList.remove(z),A.style.removeProperty($))}}this.#s(H)}}#s(V){this.#r!==null&&x(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const H=V.nextExpiry;if(!Number.isFinite(H)||!x(this.#i.setTimeout))return;const B=Math.max(0,H-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},B)}#l(){const V=this.#e.highlight;return V&&x(V.model)?V.model():null}destroy(){this.#r!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const H of V.querySelectorAll(`.${z}`))H.classList.remove(z),H.style.removeProperty($)}}const X=_}),Fe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,z="lat-cell--find",$="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const V=()=>{this.#r=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#e.find;if(!H||!x(H.stateFor))return;const B=x(H.model)?H.model():null,w=!!B&&B.active;if(!w&&!this.#o)return;let A=!1;for(const g of V.querySelectorAll("[data-key]")){const u=g.getAttribute("data-key");for(const h of g.querySelectorAll("[data-col]")){const a=w?H.stateFor(u,h.getAttribute("data-col")):null;a?(A=!0,h.classList.add(z),h.classList.toggle($,a==="current")):h.classList.contains(z)&&h.classList.remove(z,$)}}this.#o=A}destroy(){for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll)){for(const H of V.querySelectorAll(`.${z}`))H.classList.remove(z,$);this.#o=!1}}}const X=_}),Fe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.el,z=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,B="lat-find",w=12,A=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#p=!1;#m=null;#g=[];#y=null;#b=null;#A=!1;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document||a.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=a.settings&&typeof a.settings=="object"?a.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(a,r){const t=this.#e;return(t&&t.messages&&H(t.messages.t)?t.messages:W).t(a,r)}mount(){const a=this.#S();if(!a)return;a.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),a.attachDriver({run:()=>this.#E()});const r=this.#t.viewport?.root;if(r&&H(r.addEventListener)&&this.#o.shortcut!==!1){const t=n=>{if(!(n.ctrlKey||n.metaKey)||n.altKey||n.shiftKey||n.key!=="f"&&n.key!=="F")return;const o=n.target;if(this.#s&&o===this.#s){n.preventDefault(),n.stopPropagation(),H(this.#s.select)&&this.#s.select();return}_(o)||(n.preventDefault(),n.stopPropagation(),this.show())};r.addEventListener("keydown",t,!0),this.#g.push(()=>r.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#C())),this.#g.push(this.#e.on("column:visible",()=>this.#C()))}show(a){const r=this.#v();if(!r)return;const t=r.style.display!=="none";r.style.display="",t||this.#w(),this.#S().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#P()),this.#s.focus(),H(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#_();const a=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),a&&(a.clear(),a.setOpen(!1));const r=this.#t.viewport?.root;if(!r||!(this.#i&&this.#n&&this.#n.activeElement&&H(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(H(r.querySelector)?r.querySelector('[tabindex="0"]'):null)||r;H(o.focus)&&o.focus()}search(){this.#P()}destroy(){this.#A=!0,this.#_();for(const r of this.#g)r();this.#g=[];const a=this.#S();a&&(a.attachUi(null),a.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const a=this.#t;a&&H(a.invalidate)&&a.invalidate("size")}#S(){const a=this.#e&&this.#e.find;return a&&H(a.model)?a.model():null}#v(){if(this.#i)return this.#i;const a=this.#t.viewport,r=a?.root,t=this.#n;if(!r||!t||!H(r.insertBefore))return null;const n=x(t,"div",{class:B,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=x(t,"input",{class:`${B}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=x(t,"span",{class:`${B}__count`,attrs:{"aria-hidden":"true"}}),this.#a=x(t,"span",{class:`${B}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=x(t,"span",{class:`${B}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=x(t,"button",{class:`${B}__nav ${B}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),d=x(t,"button",{class:`${B}__nav ${B}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=x(t,"button",{class:`${B}__toggle ${B}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=x(t,"button",{class:`${B}__toggle ${B}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=x(t,"select",{class:`${B}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=x(t,"button",{class:`${B}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=x(t,"div",{class:`${B}__options`,children:[this.#c,this.#d,this.#h]});for(const c of[this.#s,this.#l,this.#a,this.#u,o,d,l,i])n.appendChild(c);this.#g.push(z(this.#s,"input",()=>this.#O())),this.#g.push(z(o,"click",()=>this.#e.find.prev())),this.#g.push(z(d,"click",()=>this.#e.find.next())),this.#g.push(z(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#P()})),this.#g.push(z(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#P()})),this.#g.push(z(this.#h,"change",()=>{const c=this.#h.value;this.#m=c?String(c):null,this.#P()})),this.#g.push(z(l,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#y!==null&&(this.#L(),this.#P()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return n.addEventListener("keydown",m),this.#g.push(()=>n.removeEventListener("keydown",m)),n.style.display="none",r.insertBefore(n,a.header||r.firstChild),this.#i=n,this.#C(),n}#C(){const a=this.#h;if(!a)return;const r=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(x(r,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,n=t&&H(t.visible)?t.visible():[];let o=!1;for(const d of n){if(!d||d.id===void 0)continue;const l=String(d.id);a.appendChild(x(r,"option",{text:d.title||l,attrs:{value:l}})),l===this.#m&&(o=!0)}o||(this.#m=null),a.value=this.#m||""}#O(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):A;if(this.#L(),a===0||!H(this.#r.setTimeout)){this.#P();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#P()},a)}#P(){const a=this.#S();if(!a||this.#A)return;const r=this.#s?this.#s.value:"";if(!r){this.#B(),a.clear();return}a.begin(r,{caseSensitive:this.#f,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#M()}),this.#E()}#M(){const a=this.#t&&this.#t.window,r=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,r)}#E(){if(this.#b!==null||this.#A)return;const a=()=>{this.#b=null,this.#T()};H(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(a):H(this.#r.setTimeout)?this.#b=this.#r.setTimeout(a,0):a()}#T(){const a=this.#S();!a||this.#A||!a.active||(a.stale&&a.rescan({from:this.#M()}),!a.complete&&(a.step(w)||this.#E()))}#N(){if(!this.#i||this.#A)return;const a=this.#e.find.count(),r=this.#S().active;let t="",n="idle";r&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),n=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),n=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",n);const o=r&&a.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",r?a.complete&&(this.#u.textContent=a.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#L(){this.#y!==null&&H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#B(){this.#b!==null&&(H(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#L(),this.#B()}}const u=g}),Fe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q="lat-cell--redacted",x="lat-cell";class z{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const V=W.active;for(const H of X.querySelectorAll(`.${x}[data-col]`))V&&W.has(H.getAttribute("data-col"))?H.classList.add(Q):H.classList.contains(Q)&&H.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const $=z}),Fe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/dom/src/editors/common.js").markInvalid,z="lat-cell";function $(W,V){let H=W;for(;H;){if(V(H))return H;H=H.parentNode}return null}class _{#e;#t;#n=[];constructor(V){this.#e=V.grid,this.#t=V.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const V of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(V,()=>this.paint()));this.paint()}#r(V){const H=$(V,B=>B.getAttribute&&B.getAttribute("data-key")!==null);return H?H.getAttribute("data-key"):null}paint(){const V=this.#e.validation;if(!V||!V.active)return;const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const B of H.querySelectorAll(`.${z}[data-col]`)){const w=B.getAttribute("data-col"),A=this.#r(B),g=A?V.errorFor(A,w):null;x(B,g?g.message:null)}}destroy(){for(const V of this.#n)V();this.#n=[]}}const X=_}),Fe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",V="lat-presenting--changing",H="lat-presenting__progress",B="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class A{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(h){this.#e=h.grid,this.#t=h.renderer,this.#n=h.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",a=>this.#a(a))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&x(this.#n.watch)&&this.#r.push(this.#n.watch(a=>{a||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const h=this.#t.viewport?.root;if(h&&x(h.addEventListener)){const a=r=>this.#l(r);h.addEventListener("keydown",a),this.#r.push(()=>h.removeEventListener("keydown",a))}}#l(h){const a=this.#e.presentation;if(!a?.active)return;const r=h.ctrlKey||h.metaKey,t=h.key;if(t==="Escape"&&!this.#n){h.defaultPrevented||(a.stop(),h.preventDefault?.());return}if(r){t==="="||t==="+"?(a.nudge(1),h.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),h.preventDefault?.()):t==="0"&&(a.setScale(1.5),h.preventDefault?.());return}if(!a.views.length||$(h.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),h.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),h.preventDefault?.()):t==="Home"?(a.goTo(0),h.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),h.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),h.preventDefault?.())}#a(h){!h||!h.viewId||(this.#u(),this.#e.views?.apply?.(h.viewId),this.#c(h))}#u(){const h=this.#t.viewport?.root;h?.classList&&(h.classList.remove(V),h.offsetWidth,h.classList.add(V))}#c(h){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const r=a.ownerDocument;if(!r?.createElement)return;if(!this.#i){const o=r.createElement("div");o.className=H,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),a.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(h.viewId),n=t&&t.name?t.name:"";this.#i.textContent=n?`${n} · ${(h.index||0)+1} / ${h.count||0}`:`${(h.index||0)+1} / ${h.count||0}`}#d(){if(this.#o){this.#f();return}const h=!!(this.#n&&this.#n.active());this.#n&&!h&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),r=[];for(const n of w){if(a.has(n)||n==="toolPanel"&&this.#A())continue;const o=this.#w(n);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",r.push(o))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#b(t)&&(t.style.display="none",r.push(t)),this.#o={maximised:h,hidden:r},this.#t.viewport?.root?.classList?.add(W),this.#f(),this.#m()}#h(){const h=this.#o;this.#o=null;const a=this.#t.viewport?.root;if(a?.classList?.remove(W),a?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),a?.classList?.remove(V),this.#p(),h){const r=this.#e.toolPanel;r&&x(r.presentRestore)&&r.presentRestore();for(const t of h.hidden)t.style.display="";this.#n&&!h.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const h=this.#t.viewport?.root;!h||!h.style||(h.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const h=this.#t.viewport?.root;if(!h?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,r=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const n of h.querySelectorAll("[data-key]")){const o=!r||r.has(n.getAttribute("data-key"));for(const d of n.querySelectorAll("[data-col]"))!a||o&&(!t||t.has(d.getAttribute("data-col")))?d.classList.remove(B):d.classList.add(B)}}#m(){this.#g();const h=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(h)||h<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const r=this.#e.presentation;r.active&&r.goTo(r.index>=r.views.length-1?0:r.index+1)},Math.max(1e3,h)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const h=this.#e.element;return!h||!x(h.querySelector)?null:h.querySelector(`.${X.statusBar}`)}#b(h){const a=h.children||[];for(const r of a)if(!r.style||r.style.display!=="none")return!1;return!0}#A(){const h=this.#e.toolPanel;return!!(h&&x(h.presentOnly)&&h.presentOnly())}#w(h){const a=this.#e.element;if(!a||!x(a.querySelector))return null;const r={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[h];return r?a.querySelector(r):null}destroy(){this.#o&&this.#h();for(const h of this.#r)h();this.#r=[]}}const g=A}),Fe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const x=K("packages/core/src/internal/util.js").isFunction,z=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function $(H,B,w){const A=w.getComputedStyle(H),g=B.style;if(g)for(let u=0;u<A.length;u++){const h=A[u];z.has(h)||g.setProperty(h,A.getPropertyValue(h),A.getPropertyPriority(h))}}function _(H,B,w){if($(H,B,w),H.tagName==="CANVAS"&&x(H.toDataURL))try{const u=H.toDataURL("image/png"),h=B.style;h&&(h.setProperty("background-image",`url(${u})`),h.setProperty("background-size","100% 100%"),h.setProperty("background-repeat","no-repeat"))}catch{}const A=H.children||[],g=B.children||[];for(let u=0;u<A.length&&u<g.length;u++)_(A[u],g[u],w)}function X(H,B){if(!H||H.startsWith("data:")||H.startsWith("blob:"))return!0;try{return new URL(H,B).origin===B}catch{return!0}}async function W(H,B={}){const w=H.ownerDocument,A=w?.defaultView;if(!A||typeof A.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=H.getBoundingClientRect(),u=Math.max(1,Math.ceil(g.width)),h=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(B.scale)||2),r=A.location?.origin||"";for(const m of H.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,r))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=H.cloneNode(!0);_(H,t,A),t.style.width=`${u}px`,t.style.height=`${h}px`,t.style.margin="0";const n=new A.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${h}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${n}</div></foreignObject></svg>`,d=new A.Image;await new Promise((m,c)=>{d.onload=()=>m(void 0),d.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const l=w.createElement("canvas");l.width=Math.round(u*a),l.height=Math.round(h*a);const i=l.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=B.background||A.getComputedStyle(H).backgroundColor||"#ffffff",i.fillRect(0,0,l.width,l.height),i.drawImage(d,0,0,l.width,l.height),new Promise((m,c)=>{l.toBlob(f=>f?m({blob:f,width:l.width,height:l.height}):c(new Error("capture produced no image")),B.type||"image/png",B.quality)})}const V=W}),Fe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.uid,$=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),H=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),B=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,A="system-ui, -apple-system, sans-serif";function g(f,s){if(!f||typeof f!="object")return null;const p=H[f.type];if(!p)return null;const b=typeof f.id=="string"&&f.id?f.id:z("mark"),S=Array.isArray(f.points)?f.points:[],j=[];for(const v of S){const R=Number(v&&v.x),O=Number(v&&v.y);Number.isFinite(R)&&Number.isFinite(O)&&j.push({x:R,y:O})}const y=typeof f.colour=="string"&&f.colour?f.colour:s;if(p==="text"){const v=typeof f.text=="string"?f.text:"";if(!j.length||!v)return null;const R={id:b,tool:p,colour:y,points:[j[0]],text:v,region:u(f.region)},O=Number(f.fontSize);return Number.isFinite(O)&&O>0&&(R.fontSize=O),typeof f.background=="string"&&f.background&&(R.background=f.background),R}return j.length<2?null:{id:b,tool:p,colour:y,points:j,region:u(f.region)}}function u(f){return f==="start"||f==="end"?f:"centre"}function h(f){const s={id:f.id,type:B[f.tool]||f.tool,colour:f.colour,points:f.points.map(p=>({x:p.x,y:p.y}))};return(f.region==="start"||f.region==="end")&&(s.region=f.region),f.tool==="text"&&(s.text=f.text,f.fontSize!==void 0&&(s.fontSize=f.fontSize),f.background!==void 0&&(s.background=f.background)),s}const a="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(f){return f==="arrow"||f==="rect"}function n(f,s){return{id:f,count:s,valueOf(){return this.count}}}const o=10;function d(f,s,p){const b=p.x-s.x,S=p.y-s.y,j=b*b+S*S;let y=j?((f.x-s.x)*b+(f.y-s.y)*S)/j:0;y=Math.max(0,Math.min(1,y));const v=s.x+y*b,R=s.y+y*S;return Math.hypot(f.x-v,f.y-R)}function l(f){const s=f.points;if(!s.length)return null;if(f.tool==="text"){const y=f.fontSize||w,v=(f.text||"").length*y*.6;return{x1:s[0].x,y1:s[0].y,x2:s[0].x+v,y2:s[0].y+y*1.2}}let p=1/0,b=1/0,S=-1/0,j=-1/0;for(const y of s)p=Math.min(p,y.x),b=Math.min(b,y.y),S=Math.max(S,y.x),j=Math.max(j,y.y);return{x1:p,y1:b,x2:S,y2:j}}function i(f,s){const p=l(f);if(!p)return 1/0;if(f.tool==="text"||f.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(f.tool==="text")return 1/0}const b=f.points;if(f.tool==="rect"){const j=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let v=0;v<4;v++)y=Math.min(y,d(s,j[v],j[(v+1)%4]));return y}if(b.length===1)return Math.hypot(s.x-b[0].x,s.y-b[0].y);let S=1/0;for(let j=0;j<b.length-1;j++)S=Math.min(S,d(s,b[j],b[j+1]));return S}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(s){const p=g(s,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#P(),this.redraw(),this.#T(),n(p.id,this.#s.length)):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),n(null,this.#s.length))}list(){return this.#s.map(h)}remove(s){const p=this.#s.findIndex(b=>b.id===s);return p<0?($("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${s}".`),!1):(this.#s.splice(p,1),this.#c===s&&(this.#c=null),this.redraw(),this.#T(),!0)}replaceAll(s){const p=Array.isArray(s)?s:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#P(),this.redraw(),this.#T()}#d(){const s=this.#t.viewport?.root;if(!s||!x(s.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#h(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#f(b)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#h(s){if(!this.#s.length){this.#L("a11y.annotate.noMarks");return}s.preventDefault?.();const p=this.#c?this.#s.findIndex(j=>j.id===this.#c):-1,b=s.shiftKey?-1:1,S=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[S].id,this.redraw(),this.#L("a11y.annotate.focusedMark",{at:S+1,of:this.#s.length})}#f(s){if(!this.#c)return;s.preventDefault?.();const p=this.#c;this.remove(p),this.#L("a11y.annotate.erased")}#p(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!x(s.matchMedia))return;let p=null;const b=()=>{const S=s.devicePixelRatio||1;let j;try{j=s.matchMedia(`(resolution: ${S}dppx)`)}catch{return}p=j;const y=()=>{this.redraw(),b()};x(j.addEventListener)?j.addEventListener("change",y,{once:!0}):x(j.addListener)&&j.addListener(y)};b(),this.#a.push(()=>{p=null})}use(s,p={}){const b=!!p.colour&&s===this.#o;p.colour&&(this.#i=String(p.colour));const S=s&&W.includes(s)?s:null;this.#o=S&&S===this.#o&&!b?null:S,this.#o!=="erase"&&(this.#c=null);const j=this.#o?this.#P():this.#n;return j&&(j.style.pointerEvents=this.#o?"auto":"none",j.style.cursor=this.#o?"crosshair":""),this.#T(),this.#o}undo(){const s=this.#s.pop();return s&&this.#c===s.id&&(this.#c=null),this.redraw(),this.#T(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#T())}#m(){const s=this.#s.filter(p=>p.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#T())}redraw(){!this.#n&&this.#s.length&&this.#P();const s=this.#n,p=this.#r;if(!s||!p)return;this.#M();const{left:b,top:S}=this.#O();p.clearRect(0,0,s.width,s.height);const j=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const v=j.filter(R=>u(R.region)===y);if(v.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-S||0);for(const R of v)this.#w(p,R),R.id===this.#c&&this.#v(p,R);p.restore()}}}#g(s,p="centre"){const b=this.#n,S=this.#t.viewport?.bodyViewport;if(!x(b?.getBoundingClientRect)||!x(S?.getBoundingClientRect))return;const j=b.getBoundingClientRect(),y=S.getBoundingClientRect();if(!y.width||!y.height)return;const v=this.#y(p,y);v&&(s.beginPath(),s.rect(v.left-j.left,y.top-j.top,v.width,y.height),s.clip())}#y(s,p){const b=O=>{if(!x(O?.getBoundingClientRect))return null;const F=O.getBoundingClientRect();return F&&F.width>0?{left:F.left,width:F.width}:null},S=b(this.#t.viewport?.bodyStart),j=b(this.#t.viewport?.bodyEnd);if(s==="start")return S;if(s==="end")return j;let y=p.left,v=p.left+p.width;const R=p.left+p.width/2;for(const O of[S,j]){if(!O)continue;const F=O.left+O.width;O.left+O.width/2<R?y=Math.max(y,F):v=Math.min(v,O.left)}return v>y?{left:y,width:v-y}:null}#b(s){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!x(b?.getBoundingClientRect))continue;const S=b.getBoundingClientRect();if(S&&S.width>0&&s>=S.left&&s<S.left+S.width)return p}return"centre"}#A(s){const p=this.#t.viewport?.bodyViewport;if(!x(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:s.clientX>=b.left&&s.clientX<=b.right&&s.clientY>=b.top&&s.clientY<=b.bottom}#w(s,p){const b=p.points;if(!b.length)return;const S=this.#e.presentation?.scale||1;s.lineWidth=(r[p.tool]||3)*S,s.strokeStyle=p.colour,s.fillStyle=p.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=p.tool==="highlight"?.32:1;const j=b[0],y=b[b.length-1];if(p.tool==="text"){const v=(p.fontSize||w)*S;s.font=`${v}px ${A}`,s.textBaseline="top";const R=p.text||"";if(p.background){let O=R.length*v*.6;if(typeof s.measureText=="function"){const F=s.measureText(R);F&&Number.isFinite(F.width)&&(O=F.width)}s.fillStyle=p.background,s.fillRect(j.x-v*.15,j.y-v*.1,O+v*.3,v*1.2)}s.fillStyle=p.colour,s.fillText(R,j.x,j.y),s.globalAlpha=1;return}if(p.tool==="rect")s.strokeRect(j.x,j.y,y.x-j.x,y.y-j.y);else if(p.tool==="arrow")s.beginPath(),s.moveTo(j.x,j.y),s.lineTo(y.x,y.y),s.stroke(),this.#S(s,j,y,s.lineWidth);else{s.beginPath(),s.moveTo(j.x,j.y);for(let v=1;v<b.length;v++)s.lineTo(b[v].x,b[v].y);s.stroke()}s.globalAlpha=1}#S(s,p,b,S){const j=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,S*3);s.beginPath(),s.moveTo(b.x,b.y),s.lineTo(b.x-y*Math.cos(j-Math.PI/7),b.y-y*Math.sin(j-Math.PI/7)),s.lineTo(b.x-y*Math.cos(j+Math.PI/7),b.y-y*Math.sin(j+Math.PI/7)),s.closePath(),s.fill()}#v(s,p){const b=l(p);if(!b||!x(s.strokeRect))return;const S=6;s.save(),s.setLineDash?.([4,3]),s.strokeStyle="#1a73e8",s.lineWidth=2,s.globalAlpha=1,s.strokeRect(b.x1-S,b.y1-S,b.x2-b.x1+S*2,b.y2-b.y1+S*2),s.restore()}#C(s,p){const b=this.#e.presentation?.scale||1,S=o*b;for(let j=this.#s.length-1;j>=0;j--){const y=this.#s[j];if(u(y.region)===p&&i(y,s)<=S)return y}return null}#O(){const s=x(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(s?.left||0,p),top:s?.top||0}}#P(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,p=s?.ownerDocument;if(!s||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=a,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",s.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#M(),this.#E(b),b}#M(){const s=this.#n,p=this.#t.viewport?.root;if(!s||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),j=s.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*j)),v=Math.max(1,Math.round(b.height*j));s.width===y&&s.height===v||(s.width=y,s.height=v,s.style&&(s.style.width=`${Math.max(1,b.width)}px`,s.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(j,0,0,j,0,0))}#E(s){const p=(v,R="centre")=>{const O=s.getBoundingClientRect(),{left:F,top:C}=this.#O();return{x:v.clientX-O.left+(R==="centre"?F:0),y:v.clientY-O.top+C}},b=v=>{if(!this.#o||!this.#A(v))return;const R=this.#b(v.clientX);if(this.#o==="erase"){const O=this.#C(p(v,R),R);O&&(this.remove(O.id),this.#L("a11y.annotate.erased")),v.preventDefault?.();return}this.#l={id:z("mark"),tool:this.#o,colour:this.#i,points:[p(v,R)],region:R},s.setPointerCapture?.(v.pointerId),v.preventDefault?.()},S=v=>{if(!this.#l)return;const R=p(v,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},j=v=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(v.pointerId),this.redraw(),this.#T())},y=v=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let O=!1;v.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=v.deltaY,O=!0),v.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=v.deltaX,O=!0),O&&v.preventDefault?.()};s.addEventListener("pointerdown",b),s.addEventListener("pointermove",S),s.addEventListener("pointerup",j),s.addEventListener("pointercancel",j),s.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",b),s.removeEventListener("pointermove",S),s.removeEventListener("pointerup",j),s.removeEventListener("pointercancel",j),s.removeEventListener("wheel",y)})}#T(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#N(s,p){const b=this.#e.messages;return b&&x(b.t)?b.t(s,p):s}#L(s,p){this.#t.announce?.(this.#N(s,p),{repeat:!0})}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Fe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(B){if(!Number.isFinite(B)||B<1e3)return"now";const w=Math.round(B/1e3);if(w<60)return`${w}s ago`;const A=Math.round(w/60);return A<60?`${A}m ago`:`${Math.round(A/60)}h ago`}function W(B,w){return Number.isFinite(B)?new Date(B).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class V{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,A=w.depth,g=w.position;this.#r.max=String(Math.max(1,A)),this.#r.value=String(Math.max(0,A-g)),this.#r.disabled=A===0;const u=w.at(),h=w.live;this.#o&&(this.#o.textContent=h?this.#l("timeline.live"):X(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",h?"true":"false")),this.#i&&(this.#i.textContent=A===0?this.#l("timeline.recording"):W(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",h?"true":"false")}#l(w,A){const g=this.#e;return(g&&g.messages?g.messages:$).t(w,A)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,A=w?.ownerDocument;if(!w||!A?.createElement)return;const g=A.createElement("div");g.className=_;const u=A.createElement("span");u.className=`${_}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const h=A.createElement("input");h.className=`${_}__range`,h.type="range",h.min="0",h.step="1",h.setAttribute("aria-label",this.#l("timeline.scrub"));const a=A.createElement("span");a.className=`${_}__clock`;const r=A.createElement("button");r.className=`${_}__live`,r.type="button",r.textContent=this.#l("timeline.goLive"),r.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(u),g.appendChild(h),g.appendChild(a),g.appendChild(r),w.appendChild(g),this.#n=g,this.#r=h,this.#o=u,this.#i=a;const t=()=>{const d=this.#e.timeline.depth;this.#e.timeline.seek(d-Number(h.value))};h.addEventListener("input",t);const n=()=>this.#e.timeline.toLive();r.addEventListener("click",n);const o=d=>d.stopPropagation();h.addEventListener("keydown",o),this.#s.push(()=>{h.removeEventListener("input",t),r.removeEventListener("click",n),h.removeEventListener("keydown",o)})}#u(){this.#n&&(x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const H=V}),Fe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",V="lat-cell--commented",H="lat-cell--commented-open";class B{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const h=[];for(const a of u.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key");if(r){h.push(r);for(const t of a.querySelectorAll("[data-col]")){const n=t.getAttribute("data-col"),o=g.at(r,n),d=!!(o&&o.count);t.classList.toggle(V,d),t.classList.toggle(H,d&&o.unresolved>0),this.#i(t,o,n)}}}(h.length!==this.#r.length||h.some((a,r)=>a!==this.#r[r]))&&(this.#r=h,g.request(h))}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:$).t(g,u)}#i(g,u,h){if(!u||!u.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=u.count,r=u.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",r>0?this.#o("comments.someUnresolved",{comments:t,unresolved:r}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!x(g.addEventListener))return;const u=a=>{const r=this.#e.comments;if(!r||!r.enabled)return;const t=a.target&&x(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(V)||!this.#l(t,a))return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.stopPropagation(),a.preventDefault(),r.open(o,t.getAttribute("data-col")))},h=a=>{const r=this.#e.comments;if(!r||!r.enabled||!a.altKey||a.key!=="m"&&a.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&x(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.preventDefault(),a.stopPropagation(),r.open(o,t.getAttribute("data-col")))};g.addEventListener("click",u,!0),g.addEventListener("keydown",h,!0),this.#n.push(()=>{g.removeEventListener("click",u,!0),g.removeEventListener("keydown",h,!0)})}#l(g,u){if(!x(g.getBoundingClientRect))return!1;const h=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,h.height*.6));return(X(g)?u.clientX<=h.left+a:u.clientX>=h.right-a)&&u.clientY<=h.top+a}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=B}),Fe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,H="lat-presence";class B{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,h=>this.#l(u,h)));this.#a(),this.paint()}}#l(g,u){if(this.#h(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=u&&u.peer;a&&(this.#r.textContent=this.#f(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,u=g?.ownerDocument;if(!g||!u?.createElement)return;const h=this.#e.get("presence")||{},a=u.createElement("span");if(a.className=`${H}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,h.roster===!1)return;const r=u.createElement("div");r.className=H,h.roster&&h.roster.side==="start"&&r.setAttribute("data-side","start"),r.style.pointerEvents="auto",g.appendChild(r),this.#n=r}paint(){const g=this.#e.presence,u=this.#t.viewport?.root;if(!g||!g.enabled||!u?.querySelectorAll)return;this.#d(u);const h=g.peers(),a=[...h].sort((r,t)=>r.at-t.at);for(const r of a)for(const t of r.ranges||[])for(const n of t.rowIds||[])for(const o of t.columns||[])this.#c(u,n,o,r,"range");for(const r of a)r.cursor&&this.#c(u,r.cursor.rowId,r.cursor.colId,r,"cursor");for(const r of a)r.editing&&this.#c(u,r.editing.rowId,r.editing.colId,r,"edit");this.#h(),this.#u(h)}#u(g){if(this.#s!==null)return;const u=g.filter(r=>r.cursorFresh);if(!u.length)return;const a=Math.max(...u.map(r=>r.cursorAt||0))+V-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,u,h,a,r){const t=g.querySelector(`[data-key="${X(u)}"]`),n=t&&t.querySelector(`[data-col="${X(h)}"]`);n&&(n.setAttribute("data-presence",r),n.style.setProperty("--lat-peer",a.colour),n.setAttribute("data-peer-name",a.name),n.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?n.setAttribute("data-peer-idle","true"):n.removeAttribute("data-peer-idle"),r==="cursor"&&a.cursorFresh&&n.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${h}`))}#d(g){if(this.#o.size){for(const u of g.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const g=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const a of u){const r=g.createElement("button");r.className=`${H}__peer`,r.type="button",r.style.setProperty("--lat-peer",a.colour),r.toggleAttribute("data-idle",!!a.idle),r.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),r.setAttribute("aria-label",this.#f(t,{name:a.name}));const n=g.createElement("span");n.className=`${H}__dot`,n.setAttribute("aria-hidden","true"),n.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),r.appendChild(n);const o=g.createElement("span");o.className=`${H}__name`,o.textContent=a.name,r.appendChild(o),r.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(r)}const h=u.filter(a=>a.hidden).length;if(h){const a=g.createElement("span");a.className=`${H}__hidden`,a.textContent=this.#f("presence.hidden",{count:h}),this.#n.appendChild(a)}}announceRefusal(g){if(!this.#r)return;const u=g&&g.name?g.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:u})}#f(g,u){const h=this.#e;return(h&&h.messages?h.messages:$).t(g,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=B}),Fe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/comments.js").parseCellKey,H="lat-comments",B=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function A(a,r){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((r-a)/1e3));if(t<60)return"just now";const n=Math.round(t/60);if(n<60)return`${n}m ago`;const o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function g(a,r,t,n){r.textContent="";const o=String(t??"");if(!n){r.textContent=o;return}const d=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,i=d.exec(o);for(;i;){i.index>l&&r.appendChild(a.createTextNode(o.slice(l,i.index)));const m=i[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),r.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),r.appendChild(c)}else{const c=m.indexOf("]("),f=m.slice(1,c),s=m.slice(c+2,-1);if(B.test(s)){const p=a.createElement("a");p.href=s,p.textContent=f,p.rel="noopener noreferrer",p.target="_blank",r.appendChild(p)}else r.appendChild(a.createTextNode(f))}l=i.index+m.length,i=d.exec(o)}l<o.length&&r.appendChild(a.createTextNode(o.slice(l)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",r=>this.#a(r))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(r){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#h(r.rowId,r.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&x(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const r=this.#s;this.#s=null,r&&x(r.focus)&&r.focus()}#c(){const r=this.#e.comments.openKey;if(!r)return;const{rowId:t}=V(r);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(r){if(!this.#r)return;const n=this.#r.ownerDocument.createElement("p");n.className=`${H}__note`,n.setAttribute("role","status"),n.textContent=r,this.#r.appendChild(n)}#h(r,t){const n=this.#t.viewport?.root;if(!n||!n.querySelector)return null;const o=n.querySelector(`[data-key="${X(r)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#f(r,t){const n=this.#e;return(n&&n.messages?n.messages:$).t(r,t)}#p(r){const t=r.createElement("div");t.className=H,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#f("comments.panel"));const n=r.createElement("header");n.className=`${H}__head`;const o=r.createElement("div");o.className=`${H}__title`,n.appendChild(o);const d=r.createElement("button");d.className=`${H}__resolve`,d.type="button",n.appendChild(d);const l=r.createElement("button");l.className=`${H}__close`,l.type="button",l.setAttribute("aria-label",this.#f("comments.close")),l.textContent="×",n.appendChild(l);const i=r.createElement("div");i.className=`${H}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=r.createElement("form");m.className=`${H}__composer`;const c=r.createElement("textarea");c.className=`${H}__input`,c.rows=2,c.setAttribute("aria-label",this.#f("comments.write"));const f=r.createElement("button");f.className=`${H}__send`,f.type="submit",f.textContent=this.#f("comments.post"),m.appendChild(c),m.appendChild(f),t.appendChild(n),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=o,this.#g=d;const s=j=>{j.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},S=j=>{if(j.stopPropagation(),j.key==="Escape"){j.preventDefault(),this.#e.comments.close();return}if(j.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(F=>F.offsetParent!==null||F===c);if(!y.length)return;const v=y[0],R=y[y.length-1],O=t.ownerDocument.activeElement;j.shiftKey&&O===v?(j.preventDefault(),R.focus()):!j.shiftKey&&O===R&&(j.preventDefault(),v.focus())};m.addEventListener("submit",s),l.addEventListener("click",p),d.addEventListener("click",b),t.addEventListener("keydown",S),this.#l.push(()=>{m.removeEventListener("submit",s),l.removeEventListener("click",p),d.removeEventListener("click",b),t.removeEventListener("keydown",S)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#b(){const r=this.#e.comments;if(!this.#n||!r.openKey)return;const t=this.#n.ownerDocument,n=this.#e.get("comments")||{},o=Date.now(),d=r.openKey,{rowId:l,field:i}=V(d),m=this.#e.columns.get(i),c=this.#e.rows.byKey(l),f=x(n.rowLabel)&&c?n.rowLabel(c):l;if(this.#m.textContent=this.#f("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:f}),this.#g.textContent=this.#y()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",r.loading){this.#d(this.#f("comments.loading"));return}const s=r.thread||[];if(!s.length){this.#d(this.#f("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const b of s)this.#r.appendChild(this.#A(t,b,o,p,n))}#A(r,t,n,o,d){const l=r.createElement("article");l.className=`${H}__item`,t.pending&&l.setAttribute("data-pending","true"),t.resolved&&l.setAttribute("data-resolved","true");const i=r.createElement("div");i.className=`${H}__meta`;const m=r.createElement("span");m.className=`${H}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#f("comments.unknownAuthor"),i.appendChild(m);const c=r.createElement("time");c.className=`${H}__time`;const f=A(t.at,n);c.textContent=t.edited?this.#f("comments.edited",{time:f}):f,i.appendChild(c),l.appendChild(i);const s=r.createElement("div");if(s.className=`${H}__body`,g(r,s,t.body,!!d.markdown),l.appendChild(s),t.value!==void 0&&!Object.is(t.value,o)){const S=r.createElement("p");S.className=`${H}__moved`,S.textContent=this.#f("comments.valueMoved",{was:String(t.value),now:String(o)}),l.appendChild(S)}const p=t.can||{},b=S=>p[S]!==!1;if(b("edit")||b("delete")){const S=r.createElement("div");if(S.className=`${H}__actions`,b("delete")){const j=r.createElement("button");j.type="button",j.className=`${H}__action`,j.textContent=this.#f("comments.delete"),j.addEventListener("click",()=>this.#e.comments.remove(t.id)),S.appendChild(j)}l.appendChild(S)}return l}#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 t=this.#e.comments.openKey,{rowId:n,field:o}=V(t),d=this.#h(n,o)||this.#i,l=this.#t.viewport?.root;if(!d||!l||!x(d.getBoundingClientRect))return;const i=d.getBoundingClientRect(),m=l.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let f=i.bottom-m.top+4;f+c.height>m.height&&i.top-m.top>c.height&&(f=i.top-m.top-c.height-4);let s=i.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,f)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const r of this.#l)r();this.#l=[],this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const h=u}),Fe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V="lat-watermark",H="https://www.latticegrid.dev",B=["br","bl","tl","tr"],w=4e3;class A{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(h){this.#e=h.grid,this.#t=h.document,this.#n=h.element,this.#i=h.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),x(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const h=this.#e.licence&&this.#e.licence.ready;h&&x(h.then)&&h.then(()=>this.refresh(),()=>this.refresh())}refresh(){const h=this.#d();h&&!this.#r?(this.#h(),this.#u()):!h&&this.#r&&(this.#f(),this.#c())}#a(){const h=this.#i;if(!h||!x(h.matchMedia))return!1;try{return!!h.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),x(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%B.length,this.#f(),this.#h(),this.#u()},w)))}#c(){this.#l!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const h=this.#e.licence;return!!(h&&x(h.watermark)&&h.watermark())}#h(){const h=this.grid&&this.grid.messages?this.grid.messages:$,a=X(this.#t,"a",{class:`${V}__link`,text:h.t("licence.watermark"),attrs:{href:H,target:"_blank",rel:"noopener noreferrer"}}),r=X(this.#t,"span",{class:`${V}__free`,text:h.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${V} ${V}--${B[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a,r]}),this.#o.push(W(this.#r,"pointerdown",t=>{x(t.stopPropagation)&&t.stopPropagation()})),this.#n&&x(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const h of this.#o)h();this.#o=[],this.#f()}}const g=A}),Fe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_MAXIMISE_Z",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"MAXIMISE_Z_PROP",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.isFunction,$=K("packages/dom/src/editors/common.js"),_=$.el,X=$.on,V=K("packages/dom/src/themeof.js").themeOf,H="lat-maximised",B={top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px"},w="1000",A="--lattice-maximise-z",g="lat-maximised-host",u="lat-maximise-placeholder";class h{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=w;#c=null;#d=!1;#h=null;constructor(t){this.#e=t.element,this.#t=t.document,this.#n=z(t.onChange)?t.onChange:null,this.#r=z(t.captureScroll)?t.captureScroll:null,this.#o=z(t.restoreScroll)?t.restoreScroll:null,t.zIndex!==void 0&&t.zIndex!==null&&(this.#u=String(t.zIndex)),t.container&&z(t.container.appendChild)&&(this.#c=t.container)}active(){return this.#i!==null}enter(){if(this.active())return!0;const t=this.#e.parentNode,n=this.#c||this.#t.body;if(!t||!n||!this.#t.body)return x("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:u}),this.#i.style.visibility="hidden";const o=this.#e.offsetWidth,d=this.#e.offsetHeight;o&&(this.#i.style.width=`${o}px`),d&&(this.#i.style.height=`${d}px`);const l=this.#r?this.#r():null,i=z(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?V(this.#c||t):null;i&&(this.#e.setAttribute("data-theme",i),this.#d=!0),t.insertBefore(this.#i,this.#e),this.#p(()=>n.appendChild(this.#e)),this.#a={};for(const[m,c]of Object.entries(this.#f()))this.#a[m]=this.#e.style[m]||"",this.#e.style[m]=c;return this.#h=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#t.body.style&&z(this.#t.body.style.setProperty)&&this.#t.body.style.setProperty(A,this.#u),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(g),l&&this.#o&&this.#o(l),this.#s=X(this.#t,"keydown",m=>this.#m(m)),this.#g(),!0}#f(){return{...B,position:this.#c?"absolute":"fixed",zIndex:this.#u}}exit(){if(!this.active())return!1;const t=this.#r?this.#r():null,n=this.#i,o=n.parentNode;if(o&&z(o.insertBefore)&&this.#p(()=>o.insertBefore(this.#e,n)),z(n.remove)&&n.remove(),this.#i=null,this.#d&&(this.#e.removeAttribute("data-theme"),this.#d=!1),this.#a){for(const[d,l]of Object.entries(this.#a))this.#e.style[d]=l;this.#a=null}return this.#h!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#h),this.#h=null,this.#t.body&&this.#t.body.style&&z(this.#t.body.style.removeProperty)&&this.#t.body.style.removeProperty(A),this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(g),t&&this.#o&&this.#o(t),this.#s&&this.#s(),this.#s=null,this.#g(),!0}toggle(){return this.active()?!this.exit():this.enter()}#p(t){const n=this.#t.activeElement,o=n&&n!==this.#t.body&&z(this.#e.contains)&&this.#e.contains(n)?n:null;t(),o&&z(o.focus)&&o.focus()}#m(t){!t||t.key!=="Escape"||t.defaultPrevented||this.exit()}#g(){this.#n&&this.#n();for(const t of this.#l)t(this.active())}watch(t){return z(t)?(this.#l.add(t),()=>this.#l.delete(t)):()=>{}}destroy(){this.exit()}}const a=h}),Fe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,z=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,B=K("packages/core/src/ai/schema.js"),w=B.describeGrid,A=B.promptText,g=K("packages/core/src/ai/intent.js"),u=g.applyPlan,h=g.buildPrompt,a=g.planIntent,r="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#p=null;#m=null;#g=null;#y="idle";#b=0;#A=!1;#w=[];t(l,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(l,i)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||W,this.#e=x(l),this.#t=l.grid||null,this.#n=H(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:H(l.onPlan)?l.onPlan:null,onApply:H(l.onApply)?l.onApply:null,onError:H(l.onError)?l.onError:null},this.#s=z(this.#e,"div",{class:r,attrs:{"data-state":"idle",role:"search"}}),this.#S(l)}element(){return this.#s}refresh(){this.#A||!this.#s||this.#y!=="busy"&&this.#P()}destroy(){this.#A=!0,this.#b++;for(const l of this.#w)l();this.#w.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(l){if(this.#A||this.#y==="busy")return null;const i=String(l??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#b;this.#v("busy"),this.#M("Thinking…");let c;try{const f=w(this.#t,this.#r),s=A(f);if(c=await this.#n({prompt:i,schema:f,schemaText:s,message:h(i,s),context:this.#o}),this.#A||m!==this.#b)return null;const p=a(c,f);return this.#C(p),p}catch(f){return this.#A||m!==this.#b||(this.#i.onError&&this.#i.onError(f),this.#E(f instanceof Error?f.message:String(f))),null}}apply(){const l=this.#g;if(this.#A||!l||!l.ok)return null;const i=this.#t?.ai,m=H(i?.apply)?i.apply(l):u(l,this.#t);return this.#i.onApply&&this.#i.onApply(m,l),this.#P(),this.#l&&(this.#l.value=""),m.failed.length?this.#E(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#M(`Applied: ${l.describe()}`),m}discard(){this.#A||(this.#P(),this.#M("Discarded."))}#S(l){const i=this.#e,m=z(i,"div",{class:`${r}__row`});this.#l=z(i,"input",{class:`${r}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push($(this.#l,"keydown",f=>{const s=f&&f.key;s==="Enter"?(H(f.preventDefault)&&f.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(H(f.preventDefault)&&f.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=z(i,"button",{class:`${r}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push($(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=z(i,"div",{class:`${r}__preview`,attrs:{hidden:!0}}),this.#c=z(i,"p",{class:`${r}__summary`}),this.#d=z(i,"ul",{class:`${r}__notes`});const c=z(i,"div",{class:`${r}__buttons`});this.#h=z(i,"button",{class:`${r}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=z(i,"button",{class:`${r}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push($(this.#h,"click",()=>{this.apply()})),this.#w.push($(this.#f,"click",()=>{this.discard()})),c.appendChild(this.#h),c.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=z(i,"p",{class:`${r}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=z(i,"p",{class:`${r}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#v(l){if(this.#y=l,!this.#s)return;this.#s.setAttribute("data-state",l);const i=l==="busy";n(this.#l,i),n(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,l!=="preview"),o(this.#m,l!=="error")}#C(l){const i=l;if(this.#i.onPlan&&this.#i.onPlan(l),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${m}`);return}this.#g=l,this.#M(""),this.#c&&(this.#c.textContent=i.describe()),this.#O(i.rejected),this.#v("preview")}#O(l){const i=this.#d;if(i){_(i),o(i,!l.length);for(const m of l.slice(0,6))i.appendChild(z(this.#e,"li",{class:`${r}__note`,text:m.reason}));l.length>6&&i.appendChild(z(this.#e,"li",{class:`${r}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#P(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#v("idle")}#M(l){this.#p&&(this.#p.textContent=l)}#E(l){this.#g=null,this.#M(""),this.#m&&(this.#m.textContent=l),this.#v("error")}}function n(d,l){d&&(d.disabled=l,l?d.setAttribute("disabled",""):d.removeAttribute("disabled"))}function o(d,l){d&&(d.hidden=l,l?d.setAttribute("hidden",""):d.removeAttribute("hidden"))}}),Fe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.isObject,$=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,V=K("packages/core/src/source/memory.js").isPipelineSettle,B=K("packages/core/src/i18n/index.js").defaultMessages,A=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",h=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),a=Object.freeze({direction:"flat",change:null,percent:null});function r(s,p){if(!Number.isFinite(s)||!Number.isFinite(p))return a;const b=s-p,S=b>0?"up":b<0?"down":"flat",j=p===0?null:b/Math.abs(p)*100;return{direction:S,change:b,percent:j}}function t(s,p){return s==="flat"||p==="neither"?"flat":s===p?"good":"bad"}function n(s,p,b=null){if(x(p)){const O=p(s,b);return O==="good"||O==="warn"||O==="bad"?O:null}if(!z(p))return null;const S=typeof s=="number"&&Number.isFinite(s)?s:null;if(S===null)return null;const j=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,v=String(p.direction||"up")==="down",R=O=>v?S<=O:S>=O;return j!==null&&R(j)?"good":y!==null&&R(y)?"warn":j===null&&y===null?null:"bad"}function o(s){return!(x(s.value)||s.value!==void 0&&!z(s.value))}function d(s){return!s||!s.rows||!x(s.rows.totalCount)?!0:s.rows.totalCount()>0}function l(s){const p=z(s)?s:{},b=p.grid||null,S=c(p.container,b);if(!S)return $("stat.container","createStat needs a `container`: an element or a selector."),f();const j=S.ownerDocument||(typeof document>"u"?null:document);if(!j)return $("stat.document","createStat needs a document; it draws DOM."),f();const y=j.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const v=j.createElement("div");v.className=g.title;const R=j.createElement("div");R.className=g.value;const O=j.createElement("div");O.className=g.interval;const F=j.createElement("div");F.className=g.delta;const C=j.createElement("div");C.className=g.footer;const T=j.createElement("div");if(T.className=g.note,T.hidden=!0,p.icon!=null&&p.icon!==""){const ee=j.createElement("span");ee.className=g.icon,ee.setAttribute("aria-hidden","true"),A(ee,p.icon,`stat:${p.title||"stat"}`),y.appendChild(ee);const re=j.createElement("div");re.className=g.body,re.appendChild(v),re.appendChild(R),re.appendChild(T),re.appendChild(O),re.appendChild(F),re.appendChild(C),y.appendChild(re)}else y.appendChild(v),y.appendChild(R),y.appendChild(T),y.appendChild(O),y.appendChild(F),y.appendChild(C);S.appendChild(y);let E=null;const D=[];let I=!1;function P(){if(x(p.value))return p.value(b);if(p.value!==void 0&&!z(p.value))return p.value;const ee=z(p.value)?p.value:p,re=ee.of,ie=ee.fn||"sum",ae=ee.show;return b?ie==="count"?N().length:re?ae?G(String(re),String(ie),String(ae)):k()==="filtered"&&b.statistics&&x(b.statistics.reduce)?b.statistics.reduce(String(re),String(ie)):X(N().map(fe=>m(fe,String(re))),String(ie)):null:null}function k(){return String(p.scope||"filtered")}function N(){if(!b||!b.rows)return[];const ee=k();if(ee==="all"){const ie=[];return x(b.rows.forEachAll)&&b.rows.forEachAll(ae=>{ae.group||ie.push(i(ae))}),ie}if(ee==="selected")return(b.selection&&x(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const re=[];return x(b.rows.forEach)&&b.rows.forEach(ie=>{ie.group||re.push(i(ie))}),re}function G(ee,re,ie){if(re!=="min"&&re!=="max")return $(`stat.show.${re}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${re}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ae=null,fe=null;for(const ce of N()){const te=Number(m(ce,ee));Number.isFinite(te)&&(ae===null||(re==="max"?te>ae:te<ae))&&(ae=te,fe=ce)}return fe===null?null:m(fe,ie)}function q(ee){if(x(p.format))return String(p.format(ee,b));if(ee==null)return p.empty??"—";const re=z(p.value)?p.value:p,ie=re.show||re.of;if((re.show?!0:h.has(String(re.fn||"sum")))&&b&&ie&&x(b.columns?.get)){const fe=b.columns.get(String(ie));if(fe&&x(fe.formatValue))return fe.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function Y(ee){return ee?(b&&b.messages||B).t(`stat.tone.${ee}`):""}function J(){if(I)return;const ee=P(),re=o(p)&&!!b&&!d(b),ie=re?null:ee,ae=x(p.baseline)?p.baseline(b):p.baseline;E=ie,v.textContent=p.title??"",v.hidden=!p.title,R.textContent=q(ie),T.hidden=!re,re&&(T.textContent=b.messages.t("stat.noData"));const fe=re||ae===void 0||ae===null?a:r(typeof ie=="number"?ie:null,Number(ae)),ce=t(fe.direction,p.goodWhen||"up");if(F.hidden=fe.change===null,fe.change!==null){const de=fe.direction==="up"?"↑":fe.direction==="down"?"↓":"→",be=fe.percent===null?q(Math.abs(fe.change)):`${Math.abs(fe.percent).toFixed(1)}%`;F.textContent=`${de} ${be}`,F.setAttribute("data-tone",ce),F.setAttribute("data-direction",fe.direction)}const te=x(p.interval)?p.interval(ie,b):null,oe=!!te&&Number.isFinite(te.lower)&&Number.isFinite(te.upper);O.hidden=!oe,oe&&(O.textContent=`${q(te.lower)} – ${q(te.upper)}`,Number.isFinite(te.confidence)&&O.setAttribute("title",`${Math.round(te.confidence*100)}%`));const he=re?u:p.bands?n(ie,p.bands,b):null;he?y.setAttribute("data-tone",he):y.removeAttribute("data-tone"),C.textContent=x(p.footer)?String(p.footer(ie,b)):p.footer??"",C.hidden=!C.textContent,y.setAttribute("aria-label",[p.title,R.textContent,re?T.textContent:"",oe?O.textContent:"",fe.change===null?"":F.textContent,fe.change===null?"":Y(ce),C.textContent].filter(Boolean).join(", "))}if(b&&x(b.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const re=ie=>{ee==="model:changed"&&!V(ie)||J()};b.on(ee,re),D.push(()=>x(b.off)&&b.off(ee,re))}return J(),{element:()=>y,value:()=>E,refresh:J,destroy(){I=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(s){return z(s)&&"data"in s?s.data:s}function m(s,p){if(!z(s))return;if(!p.includes("."))return s[p];let b=s;for(const S of p.split(".")){if(!z(b))return;b=b[S]}return b}function c(s,p){if(s&&typeof s=="object")return s;if(typeof s!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(s):null}function f(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Fe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isObject,$=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:V,document:H,kpis:B}){this.#e=V,this.#t=H,this.#n=Array.isArray(B)?B.filter(x):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const H=this.#t.createElement("div");H.className=`lattice ${_.band}`,H.setAttribute("role","group"),H.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=H;for(const B of this.#n){const w=$({...B,grid:this.#e,container:H});this.#o.push(w)}}destroy(){for(const V of this.#o)try{V.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Fe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return xt}});const x=K("packages/core/src/index.js").createHeadlessGrid,$=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),V=W.fail,H=W.isFunction,B=W.warnOnce,A=K("packages/dom/src/localviews.js").createLocalViewStorage,u=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,r=K("packages/dom/src/cell/icons.js"),t=r.icon,n=r.iconNames,d=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,f=m.TooltipManager,s=m.Pagination,p=m.GroupByZone,S=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,F=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,E=K("packages/dom/src/alignedgrids.js").AlignedGrids,I=K("packages/dom/src/columntagbar.js").ColumnTagBar,k=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Y=q.ToolPanelDock,J=q.panelHost,re=K("packages/dom/src/celledit.js").CellEditController,ae=K("packages/dom/src/editbar.js").EditBar,ce=K("packages/dom/src/rangeselect.js").RangeController,oe=K("packages/core/src/model/selection.js").resolveSelectionConfig,de=K("packages/dom/src/importer.js").ImportController,Te=K("packages/dom/src/historybar.js").HistoryBar,Ce=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,He=K("packages/dom/src/findpaint.js").FindPainter,Oe=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,at=K("packages/dom/src/validationpaint.js").ValidationPainter,bt=K("packages/dom/src/presentation.js").PresentationController,Et=K("packages/dom/src/capture.js").captureElement,Tt=K("packages/dom/src/annotate.js").AnnotationLayer,zt=K("packages/dom/src/timelinebar.js").TimelineBar,rt=K("packages/dom/src/commentpaint.js").CommentPainter,ve=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,ye=K("packages/dom/src/maximise.js"),ke=ye.Maximiser,pe=ye.DEFAULT_MAXIMISE_Z,Me=K("packages/dom/src/promptbar.js").PromptBar,_e=K("packages/dom/src/kpistrip.js").KpiStrip;function De(Ge,ft,st){const ut=ft==="redo"?"toolbar.redo":"toolbar.undo";return!st||!st.label?Ge(ut):Ge(ft==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:st.label})}const Se=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],xe=2e3;function Ue(Ge,ft,st,ut){const At=ft.annotate===!0?et(Ge,ut):[];if(ft.actions===!1)return[];if(ft.actions===void 0&&ft.side!=="left")return At;const Rt=Array.isArray(ft.actions)?ft.actions:Se,yt=(Ut,tn)=>Ge.messages.t(Ut,tn),Lt={undo:{name:"undo",title:()=>De(yt,"undo",Ge.history.peek("undo")),icon:"undo",run:()=>Ge.history.undo(),enabled:()=>Ge.history.canUndo()},redo:{name:"redo",title:()=>De(yt,"redo",Ge.history.peek("redo")),icon:"redo",run:()=>Ge.history.redo(),enabled:()=>Ge.history.canRedo()},export:{name:"export",title:()=>yt("toolbar.exportCsv"),icon:"download",run:()=>Ge.export.csv({download:!0,fileName:ft.exportName})},excel:{name:"excel",title:()=>yt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ge.export.excel({download:!0,fileName:ft.exportName})},clipboard:{name:"clipboard",title:()=>yt("toolbar.clipboard"),icon:"copy",run:()=>Ge.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>yt("toolbar.print"),icon:"print",run:()=>Ge.export.print()},pause:{name:"pause",title:()=>{if(!Ge.updates.paused)return yt("toolbar.pause");const Ut=Ge.updates.stats().pending;return Ut?yt("toolbar.applyHeld",{count:Ut}):yt("toolbar.resume")},icon:()=>Ge.updates.paused?"play":"pause",run:()=>Ge.updates.paused?Ge.updates.resume():Ge.updates.pause()},restore:{name:"restore",title:()=>yt("toolbar.restoreView"),icon:"restore",run:()=>Ge.state.reset(),enabled:()=>Ge.state.modified()},maximise:{name:"maximise",title:()=>yt(st&&st.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>st&&st.active()?"minimise":"maximise",run:()=>st.toggle()}};return st||delete Lt.maximise,Rt.map(Ut=>Ut==="-"?{name:"-",separator:!0}:typeof Ut=="string"?Lt[Ut]:!Ut||typeof Ut!="object"||!Ut.name?null:{...Ut,run:H(Ut.run)?()=>Ut.run({grid:Ge,keys:Ge.selection&&H(Ge.selection.keys)?Ge.selection.keys():[],cells:Ge.selection&&H(Ge.selection.cells)?Ge.selection.cells():[]}):void 0}).filter(Boolean).concat(At)}function et(Ge,ft){const st={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ut=(Rt,yt)=>Ge.messages.t(Rt,yt),At=["pen","arrow","rect","highlight","erase"].map(Rt=>({name:Rt,title:()=>ut(`toolbar.annotate.${Rt}`),icon:st[Rt],run:()=>Ge.annotate?.use(Rt),active:()=>Ge.annotate?.tool===Rt,annotation:!0}));return At.push(Je(Ge,ut,ft)),At}function Je(Ge,ft,st){return{name:"clearAll",title:()=>ft("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ge.annotate?.count||0)>0,annotation:!0,run:()=>lt(Ge,ft,st)}}function lt(Ge,ft,st){const ut=Ge.toolPanel;if(!ut)return;const At=yt=>st?.announce?.(ft(yt),{repeat:!0});ut.removeAction("clearAll");const Rt=()=>{ut.removeAction("clearAllConfirm"),ut.removeAction("clearAllKeep"),ut.addAction(Je(Ge,ft,st))};ut.addAction({name:"clearAllConfirm",title:()=>ft("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ge.annotate?.clear(),Rt(),At("a11y.annotate.cleared")}}),ut.addAction({name:"clearAllKeep",title:()=>ft("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>Rt()}),At("a11y.annotate.confirmClear")}const ot=["pen","arrow","rect","highlight","erase","clearAll"];function gt(Ge){let ft=null,st=null;return Ge.on("source:error",ut=>{const At=ut&&ut.error;st=String(At&&At.message||"").replace(/^\[lattice\]\s*/,"")||(Ge.messages?Ge.messages.t("overlay.error"):"Something went wrong")}),Ge.on("rows:changed",()=>{st=null}),{loadError:()=>st,rowCount:()=>{if(H(Ge.rows.matchCount))return Ge.rows.matchCount();const ut=Ge.pagination&&H(Ge.pagination.get)?Ge.pagination.get():null;return ut&&Number.isFinite(ut.total)?ut.total:Ge.rows.count()},totalRowCount:()=>H(Ge.rows.totalCount)?Ge.rows.totalCount():Ge.rows.count(),selectedAcrossSource:()=>{ft||(ft=H(Ge.rendererHost)?Ge.rendererHost():{});const ut=H(ft.selectionSummary)?ft.selectionSummary():null;return ut&&ut.predicate?{count:ut.count}:null},selectedCount:()=>{const ut=Ge.selection&&Ge.selection.keys?Ge.selection.keys():null;return ut?ut.length:0},rangeValues:()=>{const ut=Ge.selection;return!ut||!H(ut.cells)?[]:ut.cells().map(({key:At,colId:Rt})=>Ge.rows.value(At,Rt))},hiddenUnresolved:()=>H(Ge.comments&&Ge.comments.hiddenUnresolved)?Ge.comments.hiddenUnresolved():0,progress:()=>H(Ge.source&&Ge.source.progress)?Ge.source.progress():null,updateStats:()=>Ge.updates?Ge.updates.stats():null}}function vt(Ge,ft){for(const[st,ut]of Object.entries(d||{}))Ge.register("editor",st,ut);for(const[st,ut]of Object.entries(i||{}))Ge.register("filter",st,ut);for(const[st,ut]of Object.entries(ft.components||{}))Ge.register("component",st,ut);for(const[st,ut]of Object.entries(ft.pipes||{}))Ge.register("pipe",st,ut);for(const[st,ut]of Object.entries(ft.totalFns||{}))Ge.register("totalFn",st,ut)}function ht(Ge,ft,st,ut,At,Rt){const yt=[],Lt=ft.viewport;let Ut=null;if(st.maximise!==!1){const ct=st.maximise&&typeof st.maximise=="object"?st.maximise:{};let kt=ct.zIndex;if(kt==null){const Nt=Lt.root,Ht=ut.defaultView;kt=Ht&&typeof Ht.getComputedStyle=="function"?Ht.getComputedStyle(Nt).getPropertyValue("--lattice-maximise-z").trim():"",kt||(kt=pe)}Ut=new ke({element:Rt,document:ut,onChange:()=>ft.invalidate("all"),captureScroll:()=>ft.scrollState(),restoreScroll:Nt=>ft.restoreScroll(Nt),zIndex:kt,container:ct.container}),Ge.maximise=Ut,yt.push(()=>Ut.destroy())}if(st.statusBar){const ct=typeof st.statusBar=="object"?st.statusBar:{},kt=new c;kt.init({document:ut,host:gt(Ge),panels:ct.panels,registry:ct.registry,locale:Ge.get("locale"),messages:Ge.messages}),Lt.statusBar.appendChild(kt.element());const Nt=()=>{const nn=Lt.statusBar.offsetHeight||Lt.statusBar.getBoundingClientRect?.().height||0;Lt.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},Ht=()=>{kt.refresh(),Nt()},_t=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Ge.on(nn,Ht));Ht(),Nt(),yt.push(()=>{for(const nn of _t)nn();Lt.root.style.removeProperty("--lattice-status-height"),kt.destroy?.()})}const tn=oe(st.selection);if(tn.ranges){const ct=new ce({grid:Ge,renderer:ft,document:ut});ct.mount(),Ge.ranges=ct,yt.push(()=>ct.destroy())}if(st.import){const ct=new de({grid:Ge,renderer:ft,document:ut,settings:typeof st.import=="object"?st.import:{}});Ge.importer=ct,yt.push(()=>ct.destroy())}if(st.historyBar){const ct=typeof st.historyBar=="object"?st.historyBar.element:null,kt=new Te;kt.init({document:ut,host:{undo:()=>Ge.history.undo(),redo:()=>Ge.history.redo(),canUndo:()=>Ge.history.canUndo(),canRedo:()=>Ge.history.canRedo(),peek:Ht=>Ge.history.peek(Ht),list:()=>Ge.history.list()},props:typeof st.historyBar=="object"?st.historyBar:{}}),(ct||Lt.root).appendChild(kt.element());const Nt=[Ge.on("history:changed",()=>kt.refresh())];Ge.historyBar=kt,yt.push(()=>{for(const Ht of Nt)Ht();kt.destroy()})}if(st.diff){const ct=new Ce({grid:Ge,renderer:ft});ct.mount(),Ge.diffPainter=ct,yt.push(()=>ct.destroy())}if(st.ai&&H(st.ai.ask)){const ct=new Me;ct.init({document:ut,grid:Ge,ask:st.ai.ask,schemaOptions:st.ai.schemaOptions,context:st.ai.context,placeholder:st.ai.placeholder});const kt=st.ai.element||Lt.root;kt===Lt.root?kt.insertBefore(ct.element(),kt.firstChild):kt.appendChild(ct.element()),Ge.promptBar=ct,yt.push(()=>ct.destroy())}if(st.groupPanel){const ct=typeof st.groupPanel=="object"?st.groupPanel:{},kt=new p;kt.init({document:ut,grid:Ge,host:J(Ge,ut,(Nt,Ht)=>ft.announce?.(Nt,Ht)),props:{header:Lt.header,hint:ct.hint}}),Lt.root.insertBefore(kt.element(),Lt.header),Ge.groupPanel=kt;for(const Nt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])H(Ge.on)&&yt.push(Ge.on(Nt,()=>kt.refresh()));yt.push(()=>kt.destroy())}if(st.kpis){const ct=new _e({grid:Ge,document:ut,kpis:st.kpis});ct.active&&(ct.mount(),Lt.root.insertBefore(ct.element(),Lt.header),Ge.kpiStrip=ct,yt.push(()=>ct.destroy()))}if(st.toolPanel){const ct=typeof st.toolPanel=="object"?st.toolPanel:{},kt=new Y({grid:Ge,document:ut,root:Lt.root,panels:ct.panels,openPanel:ct.openPanel,side:ct.side,icons:ct.icons,actions:Ue(Ge,ct,Ut,ft),announce:(Nt,Ht)=>ft.announce?.(Nt,Ht)});kt.mount(),Ge.toolPanel=kt,yt.push(()=>kt.destroy()),ct.annotate===void 0&&(yt.push(Ge.on("presentation:started",()=>{for(const Nt of et(Ge,ft))kt.addAction(Nt)})),yt.push(Ge.on("presentation:ended",()=>{for(const Nt of ot)kt.removeAction(Nt)})))}if(!!st.pagination&&(()=>{const ct=typeof st.pagination=="object"?st.pagination:{};return Ge.pagination.set({pageSize:Number(ct.pageSize)||100}),Ge.pagination.get().pageSize>0})()){const ct=typeof st.pagination=="object"?st.pagination:{},kt=new s;kt.init({document:ut,pageSize:ct.pageSize,pageSizes:ct.pageSizes,page:ct.page,total:ct.total,locale:Ge.get("locale"),messages:Ge.messages,onChange:({page:_t,pageSize:nn})=>Ge.pagination.set({page:_t,pageSize:nn})});const Nt=()=>{const _t=Ge.pagination.get();kt.total=_t.total,kt.counting=_t.counting===!0,kt.hasMore=_t.total==null&&_t.pageCount>_t.page+1,kt.page=_t.page,kt.paint()};Ge.pagination.set({pageSize:kt.pageSize}),Nt();const Ht=["rows:changed","filter:changed","model:changed"].map(_t=>Ge.on(_t,Nt));Lt.statusBar.appendChild(kt.element()),yt.push(()=>{for(const _t of Ht)_t();kt.destroy?.()})}if(st.edit!==!1)if(st.editBar){const ct=new ae({grid:Ge,document:ut,root:Lt.root});ct.mount(),Ge.editBar=ct,yt.push(()=>ct.destroy())}else{const ct=new re({grid:Ge,document:ut,renderer:ft,registry:At,cellLayer:ft.cellLayer});ct.mount(),yt.push(()=>ct.destroy())}const ln=new y({grid:Ge,document:ut,layer:Lt.overlays,registry:At});ln.mount(),yt.push(()=>ln.destroy());const Zt=new R({grid:Ge,document:ut,host:Lt.root,cellMenu:st.contextMenu!==!1,headerMenu:st.columnMenu!==!1,items:H(st.contextMenu)?st.contextMenu:void 0,headerItems:H(st.columnMenu)?st.columnMenu:void 0});if(Zt.mount(),yt.push(()=>Zt.destroy()),Array.isArray(st.alignedGrids)&&st.alignedGrids.length){const ct=new E;ct.add(Ge);for(const kt of st.alignedGrids)kt&&kt!==Ge&&ct.add(kt);yt.push(()=>ct.destroy())}const jt=new G({grid:Ge,renderer:ft,document:ut,registry:At});jt.active&&(jt.mount(),yt.push(()=>jt.destroy())),Object.defineProperty(Ge,"form",{configurable:!0,value:Object.freeze({open(ct){return jt.active?jt.openRow(ct):!1},openNew(ct){return jt.active?jt.openNew(ct):(B("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){jt.active&&jt.close()},save(){return jt.active?jt.save():!1},isOpen(){return jt.active?jt.open:!1}})}),yt.push(()=>{delete Ge.form}),Object.defineProperty(Ge,"icons",{configurable:!0,value:Object.freeze({get(ct){const kt=t(ct);return kt?{viewBox:kt.viewBox,paths:kt.paths.slice(),paint:kt.paint==="stroke"?"stroke":"fill"}:null},names(){return n()}})}),yt.push(()=>{delete Ge.icons});const $t=new I({grid:Ge,renderer:ft,document:ut});$t.active&&($t.mount(),yt.push(()=>$t.destroy()));const Vt=new k({grid:Ge,renderer:ft,document:ut});Vt.active&&(Vt.mount(),yt.push(()=>Vt.destroy()));const Wt=new T({grid:Ge,renderer:ft,document:ut});if(Wt.active){Wt.mount(),Wt.paint();const ct=Ge.on("render:done",()=>Wt.paint());yt.push(()=>{ct(),Wt.destroy()})}if(st.shortcuts!==!1){const ct=new F({grid:Ge,renderer:ft});ct.mount(),yt.push(()=>ct.destroy())}const Qt=new Ne({grid:Ge,renderer:ft,window:ut.defaultView||void 0});Qt.mount(),yt.push(()=>Qt.destroy());const Yt=new He({grid:Ge,renderer:ft,window:ut.defaultView||void 0});if(Yt.mount(),yt.push(()=>Yt.destroy()),st.find!==!1){const ct=new Oe({grid:Ge,renderer:ft,document:ut,settings:st.find});ct.mount(),yt.push(()=>ct.destroy())}const Jt=new Ze({grid:Ge,renderer:ft});Jt.mount(),yt.push(()=>Jt.destroy());const on=new at({grid:Ge,renderer:ft});on.mount(),yt.push(()=>on.destroy());const en=new bt({grid:Ge,renderer:ft,maximiser:Ut});en.mount(),yt.push(()=>en.destroy());const hn=new zt({grid:Ge,renderer:ft});hn.mount(),yt.push(()=>hn.destroy()),st.environment||Ge.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 mn=null;for(const[ct,kt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])yt.push(Ge.on(ct,()=>{mn=kt}));yt.push(Ge.on("render:done",ct=>{Ge.diagnostics.render(mn||ct.cause,ct.phases),mn=null}));const cn=ut.defaultView;if(cn&&H(cn.requestAnimationFrame)){let ct=cn.requestAnimationFrame(function kt(Nt){Ge.diagnostics.frame(Nt),ct=cn.requestAnimationFrame(kt)});yt.push(()=>{H(cn.cancelAnimationFrame)&&cn.cancelAnimationFrame(ct)})}const gn=new ve({grid:Ge,renderer:ft});if(gn.mount(),yt.push(()=>gn.destroy()),yt.push(Ge.on("presence:lockRefused",ct=>gn.announceRefusal(ct.peer))),Ge.presence&&Ge.presence.enabled){for(const Nt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])yt.push(Ge.on(Nt,()=>Ge.presence.publish()));let ct="";yt.push(Ge.on("render:done",()=>{const Nt=ft.focusState&&ft.focusState(),Ht=Nt?`${Nt.rowKey}${Nt.colId}`:"";Ht!==ct&&(ct=Ht,Ge.presence.publish())}));const kt=Rt.ownerDocument;if(kt&&H(kt.addEventListener)){const Nt=()=>Ge.presence.setPaused(kt.visibilityState==="hidden");kt.addEventListener("visibilitychange",Nt),Nt(),yt.push(()=>kt.removeEventListener("visibilitychange",Nt))}}const wn=new rt({grid:Ge,renderer:ft});wn.mount(),yt.push(()=>wn.destroy());const En=new We({grid:Ge,renderer:ft});En.mount(),yt.push(()=>En.destroy()),yt.push(Ge.on("facet:computed",()=>ft.refreshHeader?.())),tn&&tn.headerCheckbox===!0&&yt.push(Ge.on("selection:changed",()=>ft.refreshHeader?.())),yt.push(Ge.on("facet:expanded",()=>ft.invalidate("columns"))),yt.push(Ge.on("model:changed",()=>ft.invalidate("rows")));const qt=(ct,kt)=>ft.announce?.(ct,kt),fn=Ge.messages,Kt=(ct,kt)=>fn.t(ct,kt),yn=ct=>Kt("count.rows",{count:ct});yt.push(Ge.on("sort:changed",()=>{const ct=Ge.sort.get();if(!ct.length){qt(Kt("a11y.sort.cleared"));return}const kt=ct.map(Nt=>{const Ht=Ge.columns.get(Nt.col);return Kt("a11y.sort.column",{column:Ht&&Ht.title||Nt.col,direction:Kt(Nt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});qt(Kt("a11y.sort.by",{columns:fn.list(kt)}))})),yt.push(Ge.on("filter:changed",()=>{const ct=Ge.rows.matchCount?Ge.rows.matchCount():Ge.rows.count();if(ct===null)return;const kt=Ge.rows.totalCount?Ge.rows.totalCount():ct;qt(ct===kt?Kt("a11y.filter.cleared",{rows:yn(kt)}):Kt("a11y.filter.applied",{shown:yn(ct),total:yn(kt)}))})),yt.push(Ge.on("selection:changed",()=>{const ct=Ge.selection.keys().length;qt(ct===0?Kt("a11y.selection.cleared"):Kt("a11y.selection.count",{count:ct}))})),yt.push(Ge.on("group:toggled",ct=>{const kt=Ge.rows.byKey?Ge.rows.byKey(ct.key):null,Nt=(kt&&(kt.groupLabel??kt.groupValue))??ct.key;qt(Kt(ct.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Nt,rows:yn(Ge.rows.count())}))})),yt.push(Ge.on("column:grouped",ct=>{const kt=Array.isArray(ct.columns)?ct.columns:[];if(!kt.length){qt(Kt("a11y.group.cleared"));return}const Nt=kt.map(Ht=>{const _t=Ge.columns.get(Ht);return _t&&_t.title||Ht});qt(Kt("a11y.group.by",{columns:fn.list(Nt)}))})),yt.push(Ge.on("page:changed",ct=>{const kt=Number(ct.size)||0,Nt=Number(ct.total)||0,Ht=kt>0?Math.max(1,Math.ceil(Nt/kt)):1;qt(Kt("a11y.page.position",{page:(Number(ct.page)||0)+1,pages:Ht}))}));let Xt={added:0,removed:0},sn=null;const Ln=()=>{sn=null;const ct=[];Xt.added&&ct.push(Kt("count.rowsAdded",{count:Xt.added})),Xt.removed&&ct.push(Kt("count.rowsRemoved",{count:Xt.removed})),Xt={added:0,removed:0},ct.length&&qt(fn.list(ct))};yt.push(Ge.on("rows:changed",ct=>{if(!ct||typeof ct.added!="number")return;const kt=Number(ct.added)||0,Nt=Number(ct.removed)||0;!kt&&!Nt||(Xt.added+=kt,Xt.removed+=Nt,sn||(sn=setTimeout(Ln,xe)))})),yt.push(()=>{sn&&clearTimeout(sn)}),yt.push(Ge.on("rows:paused",()=>{sn&&(clearTimeout(sn),sn=null),Xt={added:0,removed:0},qt(Kt("a11y.updates.paused"),{repeat:!0})})),yt.push(Ge.on("rows:resumed",()=>qt(Kt("a11y.updates.resumed"),{repeat:!0})));let pn={count:0,first:null},dn=null;const Fn=()=>{dn=null;const{count:ct,first:kt}=pn;if(pn={count:0,first:null},!ct||!kt)return;const Nt=Ge.columns.get(kt.colId),Ht=Nt&&Nt.title||kt.colId,_t=kt.reason?Kt("a11y.edit.reason",{reason:kt.reason}):"";if(ct===1){const nn=kt.restored===void 0||kt.restored===null||kt.restored===""?Kt("value.empty"):String(kt.restored);qt(Kt("a11y.edit.refusedOne",{column:Ht,value:nn,reason:_t}),{repeat:!0});return}qt(Kt("a11y.edit.refusedMany",{count:ct,reason:_t}),{repeat:!0})};yt.push(Ge.on("cell:reverted",ct=>{!ct||!ct.applied||(pn.count+=1,pn.first||(pn.first=ct),dn||(dn=setTimeout(Fn,150)))})),yt.push(()=>{dn&&clearTimeout(dn)}),yt.push(Ge.on("history:applied",ct=>{const kt=!!(ct&&ct.direction==="redo"),Nt=ct&&ct.step&&ct.step.label;qt(Nt?Kt(kt?"a11y.history.redo":"a11y.history.undo",{label:Nt}):Kt(kt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Tt({grid:Ge,renderer:ft,seed:st.state&&Array.isArray(st.state.annotations)?st.state.annotations:null});vn.mount(),yt.push(()=>vn.destroy()),Ge.annotate=vn,Ge.capture=async(ct={})=>{const{blob:kt,width:Nt,height:Ht}=await Et(ft.viewport.root,ct);return(ct.download===!0||ct.download!==!1&&ct.fileName)&&X(kt,ct.fileName||`${Ge.get("exportName")||"grid"}.png`),Ge.emit("presentation:captured",{width:Nt,height:Ht,bytes:kt.size,mimeType:kt.type,fileName:ct.fileName||null},"api"),kt};const xn=new qe({grid:Ge,document:ut,element:Lt.overlays,window:ut.defaultView||void 0});xn.mount(),yt.push(()=>xn.destroy());const Tn=new f({grid:Ge,document:ut,element:Lt.overlays});Tn.mount?.(),yt.push(()=>Tn.destroy?.());const kn=new S({grid:Ge,host:Ge.rendererHost(),viewport:Lt,document:ut});return kn.mount(),yt.push(()=>kn.destroy()),yt}function Ct(Ge){const ft=[],st=ut=>{if(ut&&(ut.__lattice&&ft.push(ut),ut.children))for(const At of ut.children)st(At)};return st(Ge),ft}function xt(Ge,ft={}){(!Ge||typeof Ge!="object"||!("appendChild"in Ge))&&V("createGrid needs a host element as its first argument."),ft=$(ft);const st=Ge.ownerDocument||(typeof document<"u"?document:null);st||V("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ut=st.documentElement&&st.documentElement.lang,At=!ft.licence&&H(st.querySelector)?st.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Rt={...ft};if(!ft.locale&&ut&&(Rt.locale=ut),At&&(Rt.licence=At),ft.views&&ft.views.local)if(ft.views.storage)B("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const Zt=ft.views.local===!0?{}:ft.views.local;Rt.views={...ft.views,storage:A(Zt)}}const yt=x(Rt),Lt=yt.rendererHost();Lt.document=st,vt(Lt.registry,ft),Lt.cellLayer=a(Lt),Lt.detailHost=new we({grid:yt,document:Ge.ownerDocument||globalThis.document,createGrid:(Zt,jt)=>xt(Zt,jt)});const Ut=new u(Ge,Lt),tn=yt.on("detail:toggled",()=>{Lt.detailHost.syncTarget(),Lt.detailHost.prune()}),an=yt.on("config:changed",Zt=>{Zt&&Zt.key==="detail"&&Lt.detailHost.reconfigure()});yt.on("destroy",()=>{tn(),an(),Lt.detailHost.destroy()}),Lt.detailHost.syncTarget(),yt.attachRenderer(Ut),Ut.mount();const bn=ht(yt,Ut,ft,st,Lt.registry,Ge),ln=yt.destroy.bind(yt);return yt.destroy=()=>{for(const Zt of bn)try{Zt()}catch{}Ge.__lattice===yt&&(Ge.__lattice=null),ln()},Ge.__lattice=yt,yt}}),Fe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return f}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=K("packages/core/src/columns/datatypes.js"),_=$.BUILTIN_TYPES,X=$.parseNumberText,V=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,B=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),A=w.toIsoDate,g=w.toIsoDateTime,h=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(V)]);function r(s,p){for(const b of s.children)if(b.tagName===p.toUpperCase())return b;return null}function t(s,p){const b=[];for(const S of s.children)S.tagName===p.toUpperCase()&&b.push(S);return b}function n(s,p){const b=x(s.getAttribute)?s.getAttribute("data-field"):null;return b||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function o(s){const p=s.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function d(s,p){return p==="text"?s===""?null:s:p==="boolean"?B(s):p==="number"?X(s):p==="date"||p==="dateString"?A(s):p==="datetime"?g(s):o(s)}function l(s){const p=r(s,"thead"),b=r(p||s,"tr"),j=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((O,F)=>{const C=n(O,F),T={id:C,field:C,title:String(O.textContent||"").trim()||C},L=x(O.getAttribute)?O.getAttribute("data-type"):null;L&&(a.has(L)?T.type=L:z(`hydrate.unknownType:${L}`,`data-type "${L}" on column "${C}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const E=x(O.getAttribute)?O.getAttribute("data-format"):null;return E&&(T.format=E),T}),y=r(s,"tbody"),R=(y?t(y,"tr"):t(s,"tr").filter(O=>O!==b)).map((O,F)=>{const C=t(O,"td"),L={__row:(x(O.getAttribute)?O.getAttribute("data-id"):null)||`row${F}`};return j.forEach((E,D)=>{L[E.field]=C[D]?E.type?d(String(C[D].textContent||""),E.type):o(String(C[D].textContent||"")):null}),L});return{columns:j,rows:R}}function i(s,p){if(p===void 0)return s;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const j of p)if(j&&typeof j=="object"){const y=j.id??j.field;y!=null&&b.set(y,j)}const S=s.map(j=>{const y=b.get(j.id)??b.get(j.field);return y===void 0?j:{...j,...y}});for(const[j,y]of b)s.some(v=>v.id===j||v.field===j)||S.push({...y});return S}const m="data-lattice-hydrate-config";function c(s,p,b={}){const{columns:S,rows:j}=l(p);return h(s,{rowKey:"__row",...b,columns:i(S,b.columns),rows:b.rows!==void 0?b.rows:j})}function f(s,p={}){const b=s.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),s.removeAttribute("data-lattice-grid"),b.__latticeTable=s;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return s.parentNode.insertBefore(b,s),s.parentNode.removeChild(s),c(b,s,p)}}),Fe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return B}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,A){const g=[];return x(w.hasAttribute)&&w.hasAttribute(A)&&g.push(w),x(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${A}]`)),g}function V(w){const A=w.parentNode;if(!A||!A.children)return null;const g=[...A.children],u=g.indexOf(w),h=[g[u+1],g[u-1]];for(const a of h)if(a&&a.tagName==="SCRIPT"&&x(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function H(w){const A=V(w);if(!A)return{};try{return JSON.parse(A.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function B(w){const A=w||(typeof document<"u"?document:null);if(!A)return[];const g=[];for(const u of W(A,"data-lattice-grid")){if(u.__lattice)continue;const h=H(u);g.push(u.tagName==="TABLE"?X(u,h):$(u,h))}return g}}),Fe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q=K("packages/dom/src/createGrid.js"),x=Q.createGrid,z=K("packages/dom/src/hydrate.js"),$=z.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),V=W.createLocalViewStorage,H=K("packages/core/src/index.js"),B=H.createHeadlessGrid,w=H.registerModules,A=H.setLicence,g=H.version,u=H.getVersion,h=H.serialiseState,a=H.restoreState,r=H.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return z.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return z.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return H.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return H.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return H.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return H.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return H.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return H.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return H.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return H.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return H.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return H.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return H.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return H.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return H.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return H.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return H.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return H.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return H.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return H.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return H.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return H.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return H.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return H.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return H.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return H.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return H.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return H.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return H.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return H.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return H.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return H.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return H.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return H.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return H.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return H.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return H.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return H.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return H.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return H.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return H.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return H.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return H.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return H.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return H.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return H.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return H.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return H.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return H.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return H.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return H.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return H.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return H.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return H.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return H.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return H.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return H.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return H.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return H.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return H.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return H.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return H.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return H.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return H.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return H.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return H.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return H.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return H.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return H.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return H.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return H.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return H.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return H.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return H.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return H.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return H.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return H.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return H.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return H.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return H.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return H.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return H.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return H.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return H.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return H.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return H.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return H.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return H.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return H.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return H.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return H.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return H.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return H.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return H.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return H.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return H.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return H.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return H.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return H.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return H.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return H.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return H.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return H.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return H.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return H.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return H.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return H.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return H.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return H.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return H.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return H.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return H.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return H.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return H.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return H.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return H.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return H.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return H.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return H.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return H.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return H.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return H.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return H.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return H.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return H.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return H.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return H.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return H.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return H.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return H.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return H.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return H.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return H.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return H.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return H.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return H.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return H.VERSION}});const n=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return n.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const d=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return d.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return d.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return d.autoGroupMenuItems}});const l=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const f=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return f.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return f.HISTORY_CLS}});const s=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return s.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const S=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return S.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return S.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return S.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return S.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return S.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return S.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return S.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return S.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return S.sanitiseHtml}});const j=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return j.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return j.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return j.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return j.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const v=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return v.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return v.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return v.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return v.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return v.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return v.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const O=Object.freeze({createGrid:x,createHeadlessGrid:B,defaults:r,registerModules:w,setLicence:A,version:g,autoInit:X,hydrateTable:$,serialiseState:h,restoreState:a,createLocalViewStorage:V}),F=O});try{Wn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.89.0";async function he(){return ae}const W="1.89.0",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).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(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=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"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){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 h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+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(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),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 l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}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 f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(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,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=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(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="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 A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#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(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}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 T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}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(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.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"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),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 ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=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"}),a=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:R.distinct}),median:Object.freeze({sketch:"KLL",bound:R.median}),p25:Object.freeze({sketch:"KLL",bound:R.p25}),p75:Object.freeze({sketch:"KLL",bound:R.p75}),p90:Object.freeze({sketch:"KLL",bound:R.p90}),p95:Object.freeze({sketch:"KLL",bound:R.p95}),p99:Object.freeze({sketch:"KLL",bound:R.p99}),iqr:Object.freeze({sketch:"KLL",bound:R.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK})});function s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(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 h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,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"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(i[i.length-1]);default:return null}}function R(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 a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Qe=Wn("packages/dom/src/index.js"),ro=Qe.createGrid,io=Qe.gridElementsWithin,oo=Qe.createStat,so=Qe.deltaOf,ao=Qe.toneOf,lo=Qe.readTable,uo=Qe.hydrateTable,co=Qe.autoInit,ho=Qe.createLocalViewStorage,fo=Qe.DEFAULT_VIEWS_KEY,po=Qe.createHeadlessGrid,mo=Qe.defaults,go=Qe.version,yo=Qe.getVersion,bo=Qe.Grid,wo=Qe.EventBus,vo=Qe.Registry,ko=Qe.sharedRegistry,So=Qe.registerModules,Oo=Qe.parseLicence,Ao=Qe.verifyLicence,jo=Qe.licenceInfo,Po=Qe.watermark,Co=Qe.setLicence,Eo=Qe.licenceState,To=Qe.isLocalHost,Mo=Qe.matchesDomain,No=Qe.LicenceHolder,Ro=Qe.ColumnModel,Lo=Qe.buildGraph,Fo=Qe.Lookup,xo=Qe.ValuePipeline,Io=Qe.compileFormat,$o=Qe.compileMask,Do=Qe.specToOoxml,zo=Qe.EXTENDED_TYPES,Bo=Qe.createRadixType,Uo=Qe.RADIX_PRESETS,Ho=Qe.parseRadix,Vo=Qe.formatRadix,Go=Qe.createUnitType,Ko=Qe.registerUnitSystem,Wo=Qe.defineUnit,_o=Qe.UNIT_SYSTEMS,qo=Qe.parseUnit,Zo=Qe.formatUnit,Yo=Qe.createCurrencyType,Xo=Qe.parseMoney,Qo=Qe.formatMoney,Jo=Qe.convertMoney,es=Qe.rateFunction,ts=Qe.MISSING_RATE,ns=Qe.Messages,rs=Qe.createMessages,is=Qe.auditCatalogue,os=Qe.EN_GB,ss=Qe.MESSAGE_KEYS,as=Qe.DEFAULT_LOCALE,ls=Qe.formatList,us=Qe.resolveLocale,cs=Qe.LOCALES,ds=Qe.resolveCatalogue,hs=Qe.EN_US,fs=Qe.FR_FR,ps=Qe.FR_CA,ms=Qe.IT_IT,gs=Qe.ES_ES,ys=Qe.PT_BR,bs=Qe.DE_DE,ws=Qe.NL_NL,vs=Qe.SV_SE,ks=Qe.DA_DK,Ss=Qe.NB_NO,Os=Qe.FI_FI,As=Qe.PL_PL,js=Qe.CS_CZ,Ps=Qe.HU_HU,Cs=Qe.RO_RO,Es=Qe.UK_UA,Ts=Qe.EL_GR,Ms=Qe.JA_JP,Ns=Qe.AR,Rs=Qe.AR_SA,Ls=Qe.ColumnStore,Fs=Qe.Bitset,xs=Qe.Dictionary,Is=Qe.MultiValue,$s=Qe.MaskPool,Ds=Qe.sortColumn,zs=Qe.sortMulti,Bs=Qe.evaluateFilters,Us=Qe.compact,Hs=Qe.testValue,Vs=Qe.groupByColumns,Gs=Qe.total,Ks=Qe.TOTAL_FNS,Ws=Qe.pivot,_s=Qe.Window,qs=Qe.openWindow,Zs=Qe.WINDOW_KINDS,Ys=Qe.ANOMALY_METHODS,Xs=Qe.modifiedZScores,Qs=Qe.iqrFences,Js=Qe.mahalanobis,ea=Qe.ROLLING_ANOMALY_METHODS,ta=Qe.rollingAnomalies,na=Qe.anomalyCondition,ra=Qe.FORECAST_METHODS,ia=Qe.forecast,oa=Qe.evaluateFormula,sa=Qe.parseFormula,aa=Qe.referencesOf,la=Qe.looksLikeFormula,ua=Qe.FormulaError,ca=Qe.FUNCTIONS,da=Qe.compileRules,ha=Qe.ingest,fa=Qe.ingestSync,pa=Qe.createSource,ma=Qe.createMemorySource,ga=Qe.createPagedSource,ya=Qe.createRemoteSource,ba=Qe.createStreamSource,wa=Qe.createUrlSource,va=Qe.PROTOCOL,ka=Qe.createPushdownSource,Sa=Qe.planQuery,Oa=Qe.splitFilters,Aa=Qe.applyResidual,ja=Qe.capabilitiesOf,Pa=Qe.resolveMutate,Ca=Qe.NO_CAPABILITIES,Ea=Qe.odataAdapter,Ta=Qe.filtersToOData,Ma=Qe.conditionToOData,Na=Qe.restAdapter,Ra=Qe.DEFAULT_PARAMS,La=Qe.dfqlAdapter,Fa=Qe.duckdbAdapter,xa=Qe.filtersToSql,Ia=Qe.graphqlAdapter,$a=Qe.splunkAdapter,Da=Qe.clickhouseAdapter,za=Qe.elasticsearchAdapter,Ba=Qe.RowModel,Ua=Qe.createRowKey,Ha=Qe.SelectionModel,Va=Qe.RangeModel,Ga=Qe.EditModel,Ka=Qe.ChangeModel,Wa=Qe.StateModel,_a=Qe.STATE_VERSION,qa=Qe.serialiseState,Za=Qe.restoreState,Ya=Qe.VERSION,Xa=Qe.DomRenderer,Qa=Qe.FilterMenu,Ja=Qe.mergeColumnFilter,el=Qe.branchFor,tl=Qe.ColumnMenu,nl=Qe.columnMenuItems,rl=Qe.cellMenuItems,il=Qe.autoGroupMenuItems,ol=Qe.AlignedGrids,sl=Qe.alignGrids,al=Qe.layoutState,ll=Qe.ToolPanelDock,ul=Qe.panelHost,cl=Qe.mountPanel,dl=Qe.CellEditController,hl=Qe.EditBar,fl=Qe.HistoryBar,pl=Qe.HISTORY_CLS,ml=Qe.DiffPainter,gl=Qe.ViewPicker,yl=Qe.VIEW_CLS,bl=Qe.summariseDiff,wl=Qe.PromptBar,vl=Qe.PROMPT_CLASS,kl=Qe.createCellLayer,Sl=Qe.compileTemplate,Ol=Qe.compileVariant,Al=Qe.checkVariant,jl=Qe.VariantRegistry,Pl=Qe.BUILTIN_RENDERERS,Cl=Qe.BUILTIN_VARIANTS,El=Qe.BUILTIN_PIPES,Tl=Qe.sanitiseHtml,Ml=Qe.editors,Nl=Qe.createEditor,Rl=Qe.editorFor,Ll=Qe.BaseEditor,Fl=Qe.filters,xl=Qe.createFilter,Il=Qe.filterFor,$l=Qe.parseExpression,Dl=Qe.ConditionFilter,zl=Qe.StatusBar,Bl=Qe.ContextMenu,Ul=Qe.ToolPanel,Hl=Qe.TooltipManager,Vl=Qe.Pagination,Gl=Qe.OverlayLayer,Kl=Qe.LatticeGrid,Wl=Qe.setLicense,_l=Qe.licenseInfo,ql=Qe.licenseState;var Zl=Qe.default;export{Ys as ANOMALY_METHODS,Ns as AR,Rs as AR_SA,ol as AlignedGrids,El as BUILTIN_PIPES,Pl as BUILTIN_RENDERERS,Cl as BUILTIN_VARIANTS,Ll as BaseEditor,Fs as Bitset,js as CS_CZ,dl as CellEditController,Ka as ChangeModel,tl as ColumnMenu,Ro as ColumnModel,Ls as ColumnStore,Dl as ConditionFilter,Bl as ContextMenu,ks as DA_DK,as as DEFAULT_LOCALE,Ra as DEFAULT_PARAMS,fo as DEFAULT_VIEWS_KEY,bs as DE_DE,xs as Dictionary,ml as DiffPainter,Xa as DomRenderer,Ts as EL_GR,os as EN_GB,hs as EN_US,gs as ES_ES,zo as EXTENDED_TYPES,hl as EditBar,Ga as EditModel,wo as EventBus,Os as FI_FI,ra as FORECAST_METHODS,ps as FR_CA,fs as FR_FR,ca as FUNCTIONS,Qa as FilterMenu,ua as FormulaError,bo as Grid,pl as HISTORY_CLS,Ps as HU_HU,fl as HistoryBar,ms as IT_IT,Ms as JA_JP,cs as LOCALES,Kl as LatticeGrid,No as LicenceHolder,Fo as Lookup,ss as MESSAGE_KEYS,ts as MISSING_RATE,$s as MaskPool,ns as Messages,Is as MultiValue,Ss as NB_NO,ws as NL_NL,Ca as NO_CAPABILITIES,Gl as OverlayLayer,As as PL_PL,vl as PROMPT_CLASS,va as PROTOCOL,ys as PT_BR,Vl as Pagination,wl as PromptBar,Uo as RADIX_PRESETS,ea as ROLLING_ANOMALY_METHODS,Cs as RO_RO,Va as RangeModel,vo as Registry,Ba as RowModel,_a as STATE_VERSION,vs as SV_SE,Ha as SelectionModel,Wa as StateModel,zl as StatusBar,Ks as TOTAL_FNS,Ul as ToolPanel,ll as ToolPanelDock,Hl as TooltipManager,Es as UK_UA,_o as UNIT_SYSTEMS,Ya as VERSION,yl as VIEW_CLS,xo as ValuePipeline,jl as VariantRegistry,gl as ViewPicker,Zs as WINDOW_KINDS,_s as Window,sl as alignGrids,na as anomalyCondition,Aa as applyResidual,is as auditCatalogue,il as autoGroupMenuItems,co as autoInit,el as branchFor,Lo as buildGraph,ja as capabilitiesOf,rl as cellMenuItems,Al as checkVariant,Da as clickhouseAdapter,nl as columnMenuItems,Us as compact,Io as compileFormat,$o as compileMask,da as compileRules,Sl as compileTemplate,Ol as compileVariant,Ma as conditionToOData,Jo as convertMoney,kl as createCellLayer,Yo as createCurrencyType,Nl as createEditor,xl as createFilter,ro as createGrid,po as createHeadlessGrid,ho as createLocalViewStorage,ma as createMemorySource,rs as createMessages,ga as createPagedSource,ka as createPushdownSource,Bo as createRadixType,ya as createRemoteSource,Ua as createRowKey,pa as createSource,oo as createStat,ba as createStreamSource,Go as createUnitType,wa as createUrlSource,Zl as default,mo as defaults,Wo as defineUnit,so as deltaOf,La as dfqlAdapter,Fa as duckdbAdapter,Rl as editorFor,Ml as editors,za as elasticsearchAdapter,Bs as evaluateFilters,oa as evaluateFormula,Il as filterFor,Fl as filters,Ta as filtersToOData,xa as filtersToSql,ia as forecast,ls as formatList,Qo as formatMoney,Vo as formatRadix,Zo as formatUnit,yo as getVersion,Ia as graphqlAdapter,io as gridElementsWithin,Vs as groupByColumns,uo as hydrateTable,ha as ingest,fa as ingestSync,Qs as iqrFences,To as isLocalHost,al as layoutState,jo as licenceInfo,Eo as licenceState,_l as licenseInfo,ql as licenseState,la as looksLikeFormula,Js as mahalanobis,Mo as matchesDomain,Ja as mergeColumnFilter,Xs as modifiedZScores,cl as mountPanel,Ea as odataAdapter,qs as openWindow,ul as panelHost,$l as parseExpression,sa as parseFormula,Oo as parseLicence,Xo as parseMoney,Ho as parseRadix,qo as parseUnit,Ws as pivot,Sa as planQuery,es as rateFunction,lo as readTable,aa as referencesOf,So as registerModules,Ko as registerUnitSystem,ds as resolveCatalogue,us as resolveLocale,Pa as resolveMutate,Na as restAdapter,Za as restoreState,ta as rollingAnomalies,Tl as sanitiseHtml,qa as serialiseState,Co as setLicence,Wl as setLicense,ko as sharedRegistry,Ds as sortColumn,zs as sortMulti,Do as specToOoxml,Oa as splitFilters,$a as splunkAdapter,bl as summariseDiff,Hs as testValue,ao as toneOf,Gs as total,Ao as verifyLicence,go as version,Po as watermark};
57
+ `)||(i.preventDefault(),this.fromText(m))})))}openFile(){const l=A(this.#n,"input",{attrs:{type:"file",accept:n}});l.style.display="none",this.#o.push(u(l,"change",()=>{const i=l.files&&l.files[0];i&&this.#c(i),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(x(l.arrayBuffer)){l.arrayBuffer().then(m=>{const c=new Uint8Array(m);if(B(c)){this.fromXlsx(c,l.name);return}this.fromText(new TextDecoder().decode(c),l.name)});return}if(x(l.text)){l.text().then(m=>this.fromText(m,l.name));return}const i=new this.#n.defaultView.FileReader;i.onload=()=>this.fromText(String(i.result||""),l.name),i.readAsText(l)}async fromXlsx(l,i){const{header:m,rows:c}=await H(l);if(!m.length)return;const f=W(m,c,{columns:this.#e.columns.all()}),s=c.filter(p=>p.length!==m.length).length;this.#l={rows:c,columns:f,delimiter:null,name:i,warnings:s?[`${s} row(s) do not have ${m.length} columns`]:[]},this.#d()}fromText(l,i){const{header:m,rows:c,delimiter:f}=X(l);if(!m.length)return;const s=W(m,c,{columns:this.#e.columns.all()}),p=c.filter(b=>b.length!==m.length).length;this.#l={rows:c,columns:s,delimiter:f,name:i,warnings:p?[`${p} row(s) do not have ${m.length} columns`]:[]},this.#d()}#d(){this.#i||this.#p(),this.#m(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(t);l&&x(l.focus)&&l.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(l,i){const m=this.#t&&this.#t.announce;x(m)&&m.call(this.#t,l,i)}#f(l,i){return(this.#e&&this.#e.messages?this.#e.messages:$).t(l,i)}#p(){const l=this.#n,i=A(l,"div",{class:r,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),m=A(l,"div",{class:`${r}__panel`});m.appendChild(A(l,"h2",{class:`${r}__title`,text:this.#f("import.title")})),this.#s=A(l,"div",{class:`${r}__body`}),m.appendChild(this.#s);const c=A(l,"div",{class:`${r}__footer`}),f=A(l,"button",{class:`${r}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),s=A(l,"button",{class:`${r}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(u(f,"click",()=>this.close())),this.#o.push(u(s,"click",()=>this.#g())),c.appendChild(f),c.appendChild(s),m.appendChild(c),i.appendChild(m),this.#o.push(u(i,"keydown",b=>{if(b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab")return;const S=[...i.querySelectorAll(t)].filter(v=>!v.hidden);if(!S.length)return;const j=S[0],y=S[S.length-1];b.shiftKey&&this.#n.activeElement===j?(b.preventDefault(),y.focus()):!b.shiftKey&&this.#n.activeElement===y&&(b.preventDefault(),j.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(i),this.#i=i}#m(){const l=this.#n,i=g(this.#s),{rows:m,columns:c,name:f,warnings:s}=this.#l;i.appendChild(A(l,"p",{class:`${r}__summary`,text:this.#f("import.summary",{count:m.length,name:f||this.#f("import.clipboard")})}));for(const v of s)i.appendChild(A(l,"p",{class:`${r}__warning`,text:v}));const p=this.#e.columns.all().map(v=>v.field||v.id).filter(Boolean),b=A(l,"table",{class:`${r}__map`}),S=A(l,"tr",{});for(const v of["import.colSource","import.colField","import.colType"])S.appendChild(A(l,"th",{text:this.#f(v)}));b.appendChild(S),c.forEach((v,R)=>{const O=A(l,"tr",{});O.appendChild(A(l,"td",{text:v.source}));const F=A(l,"select",{attrs:{"data-col":String(R),"aria-label":this.#f("import.mapLabel",{source:v.source})}});F.appendChild(A(l,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const T of p)F.appendChild(A(l,"option",{text:T,attrs:{value:T,selected:T===v.field?!0:null}}));v.field&&!p.includes(v.field)&&F.appendChild(A(l,"option",{text:v.field,attrs:{value:v.field,selected:!0}}));const C=A(l,"td",{});C.appendChild(F),O.appendChild(C),O.appendChild(A(l,"td",{class:`${r}__type`,text:v.type})),b.appendChild(O)}),i.appendChild(b);const j=A(l,"div",{class:`${r}__mode`}),y=A(l,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});y.appendChild(A(l,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),y.appendChild(A(l,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),j.appendChild(A(l,"label",{text:this.#f("import.modeLabel")})),j.appendChild(y),i.appendChild(j)}#g(){const{rows:l,columns:i}=this.#l;for(const p of this.#i.querySelectorAll("select[data-col]")){const b=Number(p.getAttribute("data-col"));i[b]&&p.value!==void 0&&p.value!==null&&(i[b].field=p.value)}const m=this.#i.querySelector("select[data-mode]"),c=m?m.value:void 0,f=c==="replace"||c==="append"?c:this.#r.mode,s=V(l,i);this.#e.import.apply(s,{mode:f}),this.close(),this.#h(this.#f("import.done",{count:s.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&x(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Fe("packages/dom/src/historybar.js",function(e,K){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V=_.clear,H=_.documentFor,B="lat-history";class w{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(u,h){return(this.messages&&typeof this.messages.t=="function"?this.messages:$).t(u,h)}init(u){this.messages=u&&u.messages||u&&u.grid&&u.grid.messages||$;const h=u||{};if(this.doc=H(h),this.host=h.host||{},this.props=h.props||{},this.root=X(this.doc,"div",{class:["lattice-tokens",B],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 a=X(this.doc,"button",{class:`${B}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(W(a,"click",()=>this.toggle())),this.root.appendChild(a),this.toggleButton=a,this.menu=X(this.doc,"div",{class:`${B}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(u,h,a){const r=X(this.doc,"button",{class:`${B}__${u}`,attrs:{type:"button"},children:[X(this.doc,"span",{class:`${B}__glyph`,text:a,attrs:{"aria-hidden":"true"}}),X(this.doc,"span",{class:`${B}__label`,text:h})]});return this.off.push(W(r,"click",()=>{const t=this.host[u];x(t)&&t(),this.refresh()})),r}element(){return this.root}refresh(){if(!this.root)return;const u=this.host,h=x(u.canUndo)?u.canUndo():!1,a=x(u.canRedo)?u.canRedo():!1,r=x(u.peek)?u.peek("undo"):null,t=x(u.peek)?u.peek("redo"):null;this.#t(this.undoButton,"undo",h,r),this.#t(this.redoButton,"redo",a,t),this.open&&this.#n()}#t(u,h,a,r){if(!u)return;u.disabled=!a;const t=h==="undo",n=this.t(t?"history.undo":"history.redo"),o=u.querySelector(`.${B}__label`);o&&(o.textContent=n);const d=r&&r.label?this.t("history.described",{action:n,label:r.label}):n;u.setAttribute("title",a?d:this.t(t?"history.nothingToUndo":"history.nothingToRedo")),u.setAttribute("aria-label",a?d:this.t(t?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const u=this.menu;if(!u)return;V(u);const h=x(this.host.list)?this.host.list():[];if(!h.length){u.appendChild(X(this.doc,"p",{class:`${B}__empty`,text:this.t("history.empty")}));return}h.forEach((a,r)=>{const t=X(this.doc,"button",{class:`${B}__item`,attrs:{type:"button",role:"menuitem","data-type":a.type,"data-undone":a.undone?"true":null},children:[X(this.doc,"span",{class:`${B}__kind`,text:a.type}),X(this.doc,"span",{class:`${B}__text`,text:a.label||a.type})]});this.off.push(W(t,"click",()=>{const n=r+1;for(let o=0;o<n;o++)x(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),u.appendChild(t)})}destroy(){for(const u of this.off)u();this.off=[],this.root&&x(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const A=w}),Fe("packages/dom/src/diffpaint.js",function(e,K){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,_=K("packages/core/src/i18n/index.js").defaultMessages,X={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},W="lat-cell--changed",V="lat-cell--added-column";class H{#e;#t;#n=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){for(const g of["render:done","diff:changed","rows:changed","model:changed","cell:changed","scroll"])this.#n.push(this.#e.on(g,()=>this.paint()));this.paint()}paint(){const g=this.#t.viewport.root;if(!g||!g.querySelectorAll)return;const u=this.#e.diff,h=u&&u.enabled;for(const a of g.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key"),t=h?u.statusOf(r):"unchanged";for(const o of Object.values(X))a.classList.remove(o);h&&X[t]&&a.classList.add(X[t]),a.setAttribute("data-diff",h?t:"");const n=h&&t==="changed";for(const o of a.querySelectorAll("[data-col]")){const d=o.getAttribute("data-col");if(o.classList.remove(W,V),o.removeAttribute("data-before"),!n)continue;const l=u.cellStatus(r,d);if(l==="changed"){o.classList.add(W);const i=this.#r(u,r,d);i===null?o.removeAttribute("title"):(o.setAttribute("data-before",i),o.setAttribute("title",this.#o("diff.before",{value:i})))}else l==="added-column"&&o.classList.add(V)}}}#r(g,u,h){const a=this.#e,r=a&&a.columns,t=r&&x(r.get)?r.get(h):null,n=a&&a.permissions;if(t&&n&&x(n.isSecret)&&n.isSecret(t))return null;const o=g.before(u,h);if(o==null)return this.#o("diff.empty");if(!t||!x(t.formatValue))return String(o);const d=x(g.beforeRow)?g.beforeRow(u):void 0,i={...(a.rows&&x(a.rows.byKey)?a.rows.byKey(u):null)||{},data:d===void 0?{}:d};try{const m=t.formatValue(o,i,i.data);return m==null?"":String(m)}catch(m){return z(`diff-before-format:${h}`,`the formatter for column "${h}" threw while formatting a previous value, so the diff hover shows the raw one.`,m),String(o)}}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:_).t(g,u)}destroy(){for(const u of this.#n)u();this.#n=[];const g=this.#t.viewport.root;if(!(!g||!g.querySelectorAll)){for(const u of g.querySelectorAll("[data-key]")){for(const h of Object.values(X))u.classList.remove(h);u.removeAttribute("data-diff")}for(const u of g.querySelectorAll("[data-col]"))u.classList.remove(W,V),u.removeAttribute("data-before")}}}function B(A){return!!(A&&A.diff&&(x(A.diff)||typeof A.diff=="object"))}const w=H}),Fe("packages/dom/src/highlightpaint.js",function(e,K){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,z="lat-cell--highlight",$="--lattice-cell-highlight";class _{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const V=()=>{this.#o=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#l();if(H){H.sweep();for(const B of V.querySelectorAll("[data-key]")){const w=B.getAttribute("data-key");for(const A of B.querySelectorAll("[data-col]")){const g=H.active?H.colourFor(w,A.getAttribute("data-col")):null;g?(A.classList.add(z),A.style.setProperty($,g)):A.classList.contains(z)&&(A.classList.remove(z),A.style.removeProperty($))}}this.#s(H)}}#s(V){this.#r!==null&&x(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const H=V.nextExpiry;if(!Number.isFinite(H)||!x(this.#i.setTimeout))return;const B=Math.max(0,H-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},B)}#l(){const V=this.#e.highlight;return V&&x(V.model)?V.model():null}destroy(){this.#r!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll))for(const H of V.querySelectorAll(`.${z}`))H.classList.remove(z),H.style.removeProperty($)}}const X=_}),Fe("packages/dom/src/findpaint.js",function(e,K){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isFunction,z="lat-cell--find",$="lat-cell--find-current";class _{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(V){this.#e=V.grid,this.#t=V.renderer,this.#i=V.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const V=()=>{this.#r=!1,this.paint()};x(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(V):x(this.#i.setTimeout)?this.#i.setTimeout(V,0):V()}paint(){const V=this.#t.viewport?.root;if(!V||!V.querySelectorAll)return;const H=this.#e.find;if(!H||!x(H.stateFor))return;const B=x(H.model)?H.model():null,w=!!B&&B.active;if(!w&&!this.#o)return;let A=!1;for(const g of V.querySelectorAll("[data-key]")){const u=g.getAttribute("data-key");for(const h of g.querySelectorAll("[data-col]")){const a=w?H.stateFor(u,h.getAttribute("data-col")):null;a?(A=!0,h.classList.add(z),h.classList.toggle($,a==="current")):h.classList.contains(z)&&h.classList.remove(z,$)}}this.#o=A}destroy(){for(const H of this.#n)H();this.#n=[];const V=this.#t.viewport?.root;if(!(!V||!V.querySelectorAll)){for(const H of V.querySelectorAll(`.${z}`))H.classList.remove(z,$);this.#o=!1}}}const X=_}),Fe("packages/dom/src/findbar.js",function(e,K){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const Q=K("packages/dom/src/editors/common.js"),x=Q.el,z=Q.on,_=K("packages/dom/src/renderer/textentry.js").isTextEntry,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,B="lat-find",w=12,A=120;class g{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#p=!1;#m=null;#g=[];#y=null;#b=null;#A=!1;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document||a.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=a.settings&&typeof a.settings=="object"?a.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(a,r){const t=this.#e;return(t&&t.messages&&H(t.messages.t)?t.messages:W).t(a,r)}mount(){const a=this.#S();if(!a)return;a.attachUi({open:t=>this.show(t),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),a.attachDriver({run:()=>this.#E()});const r=this.#t.viewport?.root;if(r&&H(r.addEventListener)&&this.#o.shortcut!==!1){const t=n=>{if(!(n.ctrlKey||n.metaKey)||n.altKey||n.shiftKey||n.key!=="f"&&n.key!=="F")return;const o=n.target;if(this.#s&&o===this.#s){n.preventDefault(),n.stopPropagation(),H(this.#s.select)&&this.#s.select();return}_(o)||(n.preventDefault(),n.stopPropagation(),this.show())};r.addEventListener("keydown",t,!0),this.#g.push(()=>r.removeEventListener("keydown",t,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#C())),this.#g.push(this.#e.on("column:visible",()=>this.#C()))}show(a){const r=this.#v();if(!r)return;const t=r.style.display!=="none";r.style.display="",t||this.#w(),this.#S().setOpen(!0),a!=null&&(this.#s.value=String(a),this.#P()),this.#s.focus(),H(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#_();const a=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#w()),a&&(a.clear(),a.setOpen(!1));const r=this.#t.viewport?.root;if(!r||!(this.#i&&this.#n&&this.#n.activeElement&&H(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const o=(H(r.querySelector)?r.querySelector('[tabindex="0"]'):null)||r;H(o.focus)&&o.focus()}search(){this.#P()}destroy(){this.#A=!0,this.#_();for(const r of this.#g)r();this.#g=[];const a=this.#S();a&&(a.attachUi(null),a.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#w(){const a=this.#t;a&&H(a.invalidate)&&a.invalidate("size")}#S(){const a=this.#e&&this.#e.find;return a&&H(a.model)?a.model():null}#v(){if(this.#i)return this.#i;const a=this.#t.viewport,r=a?.root,t=this.#n;if(!r||!t||!H(r.insertBefore))return null;const n=x(t,"div",{class:B,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=x(t,"input",{class:`${B}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=x(t,"span",{class:`${B}__count`,attrs:{"aria-hidden":"true"}}),this.#a=x(t,"span",{class:`${B}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=x(t,"span",{class:`${B}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const o=x(t,"button",{class:`${B}__nav ${B}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),d=x(t,"button",{class:`${B}__nav ${B}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=x(t,"button",{class:`${B}__toggle ${B}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=x(t,"button",{class:`${B}__toggle ${B}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=x(t,"select",{class:`${B}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=x(t,"button",{class:`${B}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),i=x(t,"div",{class:`${B}__options`,children:[this.#c,this.#d,this.#h]});for(const c of[this.#s,this.#l,this.#a,this.#u,o,d,l,i])n.appendChild(c);this.#g.push(z(this.#s,"input",()=>this.#O())),this.#g.push(z(o,"click",()=>this.#e.find.prev())),this.#g.push(z(d,"click",()=>this.#e.find.next())),this.#g.push(z(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#P()})),this.#g.push(z(this.#d,"click",()=>{this.#p=!this.#p,this.#d.setAttribute("aria-pressed",String(this.#p)),this.#P()})),this.#g.push(z(this.#h,"change",()=>{const c=this.#h.value;this.#m=c?String(c):null,this.#P()})),this.#g.push(z(l,"click",()=>this.hide()));const m=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),this.hide();return}c.key==="Enter"&&c.target===this.#s&&(c.preventDefault(),c.stopPropagation(),this.#y!==null&&(this.#L(),this.#P()),c.shiftKey?this.#e.find.prev():this.#e.find.next())};return n.addEventListener("keydown",m),this.#g.push(()=>n.removeEventListener("keydown",m)),n.style.display="none",r.insertBefore(n,a.header||r.firstChild),this.#i=n,this.#C(),n}#C(){const a=this.#h;if(!a)return;const r=this.#n;for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(x(r,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const t=this.#e.columns,n=t&&H(t.visible)?t.visible():[];let o=!1;for(const d of n){if(!d||d.id===void 0)continue;const l=String(d.id);a.appendChild(x(r,"option",{text:d.title||l,attrs:{value:l}})),l===this.#m&&(o=!0)}o||(this.#m=null),a.value=this.#m||""}#O(){const a=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):A;if(this.#L(),a===0||!H(this.#r.setTimeout)){this.#P();return}this.#y=this.#r.setTimeout(()=>{this.#y=null,this.#P()},a)}#P(){const a=this.#S();if(!a||this.#A)return;const r=this.#s?this.#s.value:"";if(!r){this.#B(),a.clear();return}a.begin(r,{caseSensitive:this.#f,wholeCell:this.#p,columns:this.#m?[this.#m]:null,from:this.#M()}),this.#E()}#M(){const a=this.#t&&this.#t.window,r=a&&Number.isFinite(a.first)?a.first:0;return Math.max(0,r)}#E(){if(this.#b!==null||this.#A)return;const a=()=>{this.#b=null,this.#T()};H(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(a):H(this.#r.setTimeout)?this.#b=this.#r.setTimeout(a,0):a()}#T(){const a=this.#S();!a||this.#A||!a.active||(a.stale&&a.rescan({from:this.#M()}),!a.complete&&(a.step(w)||this.#E()))}#N(){if(!this.#i||this.#A)return;const a=this.#e.find.count(),r=this.#S().active;let t="",n="idle";r&&(a.total===0?(t=a.complete?this.t("find.none"):this.t("find.searching"),n=a.complete?"none":"searching"):(t=this.t(a.complete?"find.count":"find.countPartial",{current:a.current,total:a.total}),n=a.complete?"matches":"searching")),this.#l.textContent=t,this.#i.setAttribute("data-state",n);const o=r&&a.windowed;this.#a.textContent=o?this.t("find.loadedRows"):"",this.#a.style.display=o?"":"none",r?a.complete&&(this.#u.textContent=a.total===0?this.t(o?"a11y.find.noneLoaded":"a11y.find.none"):this.t(o?"a11y.find.countLoaded":"a11y.find.count",{current:a.current,count:a.total})):this.#u.textContent=""}#L(){this.#y!==null&&H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#y),this.#y=null}#B(){this.#b!==null&&(H(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):H(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#_(){this.#L(),this.#B()}}const u=g}),Fe("packages/dom/src/redactpaint.js",function(e,K){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return $}});const Q="lat-cell--redacted",x="lat-cell";class z{#e;#t;#n=[];constructor(X){this.#e=X.grid,this.#t=X.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const X=this.#t.viewport?.root;if(!X||!X.querySelectorAll)return;const W=this.#e.redaction;if(!W)return;const V=W.active;for(const H of X.querySelectorAll(`.${x}[data-col]`))V&&W.has(H.getAttribute("data-col"))?H.classList.add(Q):H.classList.contains(Q)&&H.classList.remove(Q)}destroy(){for(const X of this.#n)X();this.#n=[]}}const $=z}),Fe("packages/dom/src/validationpaint.js",function(e,K){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return X}});const x=K("packages/dom/src/editors/common.js").markInvalid,z="lat-cell";function $(W,V){let H=W;for(;H;){if(V(H))return H;H=H.parentNode}return null}class _{#e;#t;#n=[];constructor(V){this.#e=V.grid,this.#t=V.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint()));for(const V of["validation:failed","validation:cleared","cell:changed"])this.#n.push(this.#e.on(V,()=>this.paint()));this.paint()}#r(V){const H=$(V,B=>B.getAttribute&&B.getAttribute("data-key")!==null);return H?H.getAttribute("data-key"):null}paint(){const V=this.#e.validation;if(!V||!V.active)return;const H=this.#t.viewport?.root;if(!(!H||!H.querySelectorAll))for(const B of H.querySelectorAll(`.${z}[data-col]`)){const w=B.getAttribute("data-col"),A=this.#r(B),g=A?V.errorFor(A,w):null;x(B,g?g.message:null)}}destroy(){for(const V of this.#n)V();this.#n=[]}}const X=_}),Fe("packages/dom/src/presentation.js",function(e,K){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/renderer/textentry.js").isTextEntry,X=K("packages/dom/src/renderer/viewport.js").CLASS,W="lat-presenting",V="lat-presenting--changing",H="lat-presenting__progress",B="lat-cell--dimmed",w=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class A{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(h){this.#e=h.grid,this.#t=h.renderer,this.#n=h.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",a=>this.#a(a))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#p())),this.#r.push(this.#e.on("render:done",()=>this.#p())),this.#n&&x(this.#n.watch)&&this.#r.push(this.#n.watch(a=>{a||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const h=this.#t.viewport?.root;if(h&&x(h.addEventListener)){const a=r=>this.#l(r);h.addEventListener("keydown",a),this.#r.push(()=>h.removeEventListener("keydown",a))}}#l(h){const a=this.#e.presentation;if(!a?.active)return;const r=h.ctrlKey||h.metaKey,t=h.key;if(t==="Escape"&&!this.#n){h.defaultPrevented||(a.stop(),h.preventDefault?.());return}if(r){t==="="||t==="+"?(a.nudge(1),h.preventDefault?.()):t==="-"||t==="_"?(a.nudge(-1),h.preventDefault?.()):t==="0"&&(a.setScale(1.5),h.preventDefault?.());return}if(!a.views.length||$(h.target))return;t==="ArrowRight"||t==="ArrowDown"||t==="PageDown"||t===" "?(a.step(1),h.preventDefault?.()):t==="ArrowLeft"||t==="ArrowUp"||t==="PageUp"?(a.step(-1),h.preventDefault?.()):t==="Home"?(a.goTo(0),h.preventDefault?.()):t==="End"?(a.goTo(a.views.length-1),h.preventDefault?.()):(t==="r"||t==="R")&&(a.reset(),h.preventDefault?.())}#a(h){!h||!h.viewId||(this.#u(),this.#e.views?.apply?.(h.viewId),this.#c(h))}#u(){const h=this.#t.viewport?.root;h?.classList&&(h.classList.remove(V),h.offsetWidth,h.classList.add(V))}#c(h){const a=this.#t.viewport?.overlays;if(!a||!this.#e.presentation.views.length)return;const r=a.ownerDocument;if(!r?.createElement)return;if(!this.#i){const o=r.createElement("div");o.className=H,o.setAttribute("role","status"),o.setAttribute("aria-live","polite"),a.appendChild(o),this.#i=o}const t=this.#e.views?.get?.(h.viewId),n=t&&t.name?t.name:"";this.#i.textContent=n?`${n} · ${(h.index||0)+1} / ${h.count||0}`:`${(h.index||0)+1} / ${h.count||0}`}#d(){if(this.#o){this.#f();return}const h=!!(this.#n&&this.#n.active());this.#n&&!h&&this.#n.enter();const a=new Set(this.#e.presentation?.options?.chrome||[]),r=[];for(const n of w){if(a.has(n)||n==="toolPanel"&&this.#A())continue;const o=this.#w(n);o&&o.style&&o.style.display!=="none"&&(o.style.display="none",r.push(o))}const t=this.#y();t&&t.style&&t.style.display!=="none"&&this.#b(t)&&(t.style.display="none",r.push(t)),this.#o={maximised:h,hidden:r},this.#t.viewport?.root?.classList?.add(W),this.#f(),this.#m()}#h(){const h=this.#o;this.#o=null;const a=this.#t.viewport?.root;if(a?.classList?.remove(W),a?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),a?.classList?.remove(V),this.#p(),h){const r=this.#e.toolPanel;r&&x(r.presentRestore)&&r.presentRestore();for(const t of h.hidden)t.style.display="";this.#n&&!h.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const h=this.#t.viewport?.root;!h||!h.style||(h.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#p(){const h=this.#t.viewport?.root;if(!h?.querySelectorAll)return;const a=this.#e.presentation?.active?this.#e.presentation.spotlight:null,r=a&&a.keys.length?new Set(a.keys):null,t=a&&a.colIds.length?new Set(a.colIds):null;for(const n of h.querySelectorAll("[data-key]")){const o=!r||r.has(n.getAttribute("data-key"));for(const d of n.querySelectorAll("[data-col]"))!a||o&&(!t||t.has(d.getAttribute("data-col")))?d.classList.remove(B):d.classList.add(B)}}#m(){this.#g();const h=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(h)||h<=0||!this.#e.presentation.views.length)return;const a=this.#t.viewport?.root?.ownerDocument?.defaultView;a?.setInterval&&(this.#s=a.setInterval(()=>{const r=this.#e.presentation;r.active&&r.goTo(r.index>=r.views.length-1?0:r.index+1)},Math.max(1e3,h)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#y(){const h=this.#e.element;return!h||!x(h.querySelector)?null:h.querySelector(`.${X.statusBar}`)}#b(h){const a=h.children||[];for(const r of a)if(!r.style||r.style.display!=="none")return!1;return!0}#A(){const h=this.#e.toolPanel;return!!(h&&x(h.presentOnly)&&h.presentOnly())}#w(h){const a=this.#e.element;if(!a||!x(a.querySelector))return null;const r={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[h];return r?a.querySelector(r):null}destroy(){this.#o&&this.#h();for(const h of this.#r)h();this.#r=[]}}const g=A}),Fe("packages/dom/src/capture.js",function(e,K){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return V}});const x=K("packages/core/src/internal/util.js").isFunction,z=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function $(H,B,w){const A=w.getComputedStyle(H),g=B.style;if(g)for(let u=0;u<A.length;u++){const h=A[u];z.has(h)||g.setProperty(h,A.getPropertyValue(h),A.getPropertyPriority(h))}}function _(H,B,w){if($(H,B,w),H.tagName==="CANVAS"&&x(H.toDataURL))try{const u=H.toDataURL("image/png"),h=B.style;h&&(h.setProperty("background-image",`url(${u})`),h.setProperty("background-size","100% 100%"),h.setProperty("background-repeat","no-repeat"))}catch{}const A=H.children||[],g=B.children||[];for(let u=0;u<A.length&&u<g.length;u++)_(A[u],g[u],w)}function X(H,B){if(!H||H.startsWith("data:")||H.startsWith("blob:"))return!0;try{return new URL(H,B).origin===B}catch{return!0}}async function W(H,B={}){const w=H.ownerDocument,A=w?.defaultView;if(!A||typeof A.getComputedStyle!="function")throw new Error("capture needs a browser document");const g=H.getBoundingClientRect(),u=Math.max(1,Math.ceil(g.width)),h=Math.max(1,Math.ceil(g.height)),a=Math.max(.1,Number(B.scale)||2),r=A.location?.origin||"";for(const m of H.querySelectorAll("img")){const c=m.getAttribute("src")||"";if(!X(c,r))throw new Error(`capture refused: the image at ${c} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const t=H.cloneNode(!0);_(H,t,A),t.style.width=`${u}px`,t.style.height=`${h}px`,t.style.margin="0";const n=new A.XMLSerializer().serializeToString(t),o=`<svg xmlns="http://www.w3.org/2000/svg" width="${u}" height="${h}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${n}</div></foreignObject></svg>`,d=new A.Image;await new Promise((m,c)=>{d.onload=()=>m(void 0),d.onerror=()=>c(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`});const l=w.createElement("canvas");l.width=Math.round(u*a),l.height=Math.round(h*a);const i=l.getContext("2d");if(!i)throw new Error("capture could not get a 2d context");return i.fillStyle=B.background||A.getComputedStyle(H).backgroundColor||"#ffffff",i.fillRect(0,0,l.width,l.height),i.drawImage(d,0,0,l.width,l.height),new Promise((m,c)=>{l.toBlob(f=>f?m({blob:f,width:l.width,height:l.height}):c(new Error("capture produced no image")),B.type||"image/png",B.quality)})}const V=W}),Fe("packages/dom/src/annotate.js",function(e,K){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.uid,$=Q.warnOnce,X=K("packages/dom/src/renderer/direction.js").signedX,W=Object.freeze(["pen","arrow","rect","highlight","erase"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),H=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),B=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),w=14,A="system-ui, -apple-system, sans-serif";function g(f,s){if(!f||typeof f!="object")return null;const p=H[f.type];if(!p)return null;const b=typeof f.id=="string"&&f.id?f.id:z("mark"),S=Array.isArray(f.points)?f.points:[],j=[];for(const v of S){const R=Number(v&&v.x),O=Number(v&&v.y);Number.isFinite(R)&&Number.isFinite(O)&&j.push({x:R,y:O})}const y=typeof f.colour=="string"&&f.colour?f.colour:s;if(p==="text"){const v=typeof f.text=="string"?f.text:"";if(!j.length||!v)return null;const R={id:b,tool:p,colour:y,points:[j[0]],text:v,region:u(f.region)},O=Number(f.fontSize);return Number.isFinite(O)&&O>0&&(R.fontSize=O),typeof f.background=="string"&&f.background&&(R.background=f.background),R}return j.length<2?null:{id:b,tool:p,colour:y,points:j,region:u(f.region)}}function u(f){return f==="start"||f==="end"?f:"centre"}function h(f){const s={id:f.id,type:B[f.tool]||f.tool,colour:f.colour,points:f.points.map(p=>({x:p.x,y:p.y}))};return(f.region==="start"||f.region==="end")&&(s.region=f.region),f.tool==="text"&&(s.text=f.text,f.fontSize!==void 0&&(s.fontSize=f.fontSize),f.background!==void 0&&(s.background=f.background)),s}const a="lat-annotate",r=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(f){return f==="arrow"||f==="rect"}function n(f,s){return{id:f,count:s,valueOf(){return this.count}}}const o=10;function d(f,s,p){const b=p.x-s.x,S=p.y-s.y,j=b*b+S*S;let y=j?((f.x-s.x)*b+(f.y-s.y)*S)/j:0;y=Math.max(0,Math.min(1,y));const v=s.x+y*b,R=s.y+y*S;return Math.hypot(f.x-v,f.y-R)}function l(f){const s=f.points;if(!s.length)return null;if(f.tool==="text"){const y=f.fontSize||w,v=(f.text||"").length*y*.6;return{x1:s[0].x,y1:s[0].y,x2:s[0].x+v,y2:s[0].y+y*1.2}}let p=1/0,b=1/0,S=-1/0,j=-1/0;for(const y of s)p=Math.min(p,y.x),b=Math.min(b,y.y),S=Math.max(S,y.x),j=Math.max(j,y.y);return{x1:p,y1:b,x2:S,y2:j}}function i(f,s){const p=l(f);if(!p)return 1/0;if(f.tool==="text"||f.tool==="rect"){if(s.x>=p.x1&&s.x<=p.x2&&s.y>=p.y1&&s.y<=p.y2)return 0;if(f.tool==="text")return 1/0}const b=f.points;if(f.tool==="rect"){const j=[{x:p.x1,y:p.y1},{x:p.x2,y:p.y1},{x:p.x2,y:p.y2},{x:p.x1,y:p.y2}];let y=1/0;for(let v=0;v<4;v++)y=Math.min(y,d(s,j[v],j[(v+1)%4]));return y}if(b.length===1)return Math.hypot(s.x-b[0].x,s.y-b[0].y);let S=1/0;for(let j=0;j<b.length-1;j++)S=Math.min(S,d(s,b[j],b[j+1]));return S}class m{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;#c=null;constructor(s){this.#e=s.grid,this.#t=s.renderer,this.#u=Array.isArray(s.seed)?s.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#m()})),this.#d(),this.#p(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(s){const p=g(s,this.#i);return p?(p.durable=!0,this.#s.push(p),this.#P(),this.redraw(),this.#T(),n(p.id,this.#s.length)):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),n(null,this.#s.length))}list(){return this.#s.map(h)}remove(s){const p=this.#s.findIndex(b=>b.id===s);return p<0?($("annotate.remove.unknown",`annotate.remove ignored an unknown id: "${s}".`),!1):(this.#s.splice(p,1),this.#c===s&&(this.#c=null),this.redraw(),this.#T(),!0)}replaceAll(s){const p=Array.isArray(s)?s:[];this.#s=p.map(b=>g(b,this.#i)).filter(Boolean);for(const b of this.#s)b.durable=!0;this.#s.length&&this.#P(),this.redraw(),this.#T()}#d(){const s=this.#t.viewport?.root;if(!s||!x(s.addEventListener))return;const p=b=>{if(!(!this.#o||!b)){if(b.key==="Escape"){this.use(null),b.preventDefault?.();return}if(this.#o==="erase"){if(b.key==="Tab"){this.#h(b);return}(b.key==="Delete"||b.key==="Backspace")&&this.#f(b)}}};s.addEventListener("keydown",p,!0),this.#a.push(()=>s.removeEventListener("keydown",p,!0))}#h(s){if(!this.#s.length){this.#L("a11y.annotate.noMarks");return}s.preventDefault?.();const p=this.#c?this.#s.findIndex(j=>j.id===this.#c):-1,b=s.shiftKey?-1:1,S=p<0?b>0?0:this.#s.length-1:(p+b+this.#s.length)%this.#s.length;this.#c=this.#s[S].id,this.redraw(),this.#L("a11y.annotate.focusedMark",{at:S+1,of:this.#s.length})}#f(s){if(!this.#c)return;s.preventDefault?.();const p=this.#c;this.remove(p),this.#L("a11y.annotate.erased")}#p(){const s=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!s||!x(s.matchMedia))return;let p=null;const b=()=>{const S=s.devicePixelRatio||1;let j;try{j=s.matchMedia(`(resolution: ${S}dppx)`)}catch{return}p=j;const y=()=>{this.redraw(),b()};x(j.addEventListener)?j.addEventListener("change",y,{once:!0}):x(j.addListener)&&j.addListener(y)};b(),this.#a.push(()=>{p=null})}use(s,p={}){const b=!!p.colour&&s===this.#o;p.colour&&(this.#i=String(p.colour));const S=s&&W.includes(s)?s:null;this.#o=S&&S===this.#o&&!b?null:S,this.#o!=="erase"&&(this.#c=null);const j=this.#o?this.#P():this.#n;return j&&(j.style.pointerEvents=this.#o?"auto":"none",j.style.cursor=this.#o?"crosshair":""),this.#T(),this.#o}undo(){const s=this.#s.pop();return s&&this.#c===s.id&&(this.#c=null),this.redraw(),this.#T(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.#c=null,this.redraw(),this.#T())}#m(){const s=this.#s.filter(p=>p.durable);s.length!==this.#s.length&&(this.#s=s,this.redraw(),this.#T())}redraw(){!this.#n&&this.#s.length&&this.#P();const s=this.#n,p=this.#r;if(!s||!p)return;this.#M();const{left:b,top:S}=this.#O();p.clearRect(0,0,s.width,s.height);const j=this.#l?[...this.#s,this.#l]:this.#s;for(const y of["centre","start","end"]){const v=j.filter(R=>u(R.region)===y);if(v.length){p.save(),this.#g(p,y),p.translate((y==="centre"?-b:0)||0,-S||0);for(const R of v)this.#w(p,R),R.id===this.#c&&this.#v(p,R);p.restore()}}}#g(s,p="centre"){const b=this.#n,S=this.#t.viewport?.bodyViewport;if(!x(b?.getBoundingClientRect)||!x(S?.getBoundingClientRect))return;const j=b.getBoundingClientRect(),y=S.getBoundingClientRect();if(!y.width||!y.height)return;const v=this.#y(p,y);v&&(s.beginPath(),s.rect(v.left-j.left,y.top-j.top,v.width,y.height),s.clip())}#y(s,p){const b=O=>{if(!x(O?.getBoundingClientRect))return null;const F=O.getBoundingClientRect();return F&&F.width>0?{left:F.left,width:F.width}:null},S=b(this.#t.viewport?.bodyStart),j=b(this.#t.viewport?.bodyEnd);if(s==="start")return S;if(s==="end")return j;let y=p.left,v=p.left+p.width;const R=p.left+p.width/2;for(const O of[S,j]){if(!O)continue;const F=O.left+O.width;O.left+O.width/2<R?y=Math.max(y,F):v=Math.min(v,O.left)}return v>y?{left:y,width:v-y}:null}#b(s){for(const[p,b]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!x(b?.getBoundingClientRect))continue;const S=b.getBoundingClientRect();if(S&&S.width>0&&s>=S.left&&s<S.left+S.width)return p}return"centre"}#A(s){const p=this.#t.viewport?.bodyViewport;if(!x(p?.getBoundingClientRect))return!0;const b=p.getBoundingClientRect();return!b.width||!b.height?!0:s.clientX>=b.left&&s.clientX<=b.right&&s.clientY>=b.top&&s.clientY<=b.bottom}#w(s,p){const b=p.points;if(!b.length)return;const S=this.#e.presentation?.scale||1;s.lineWidth=(r[p.tool]||3)*S,s.strokeStyle=p.colour,s.fillStyle=p.colour,s.lineCap="round",s.lineJoin="round",s.globalAlpha=p.tool==="highlight"?.32:1;const j=b[0],y=b[b.length-1];if(p.tool==="text"){const v=(p.fontSize||w)*S;s.font=`${v}px ${A}`,s.textBaseline="top";const R=p.text||"";if(p.background){let O=R.length*v*.6;if(typeof s.measureText=="function"){const F=s.measureText(R);F&&Number.isFinite(F.width)&&(O=F.width)}s.fillStyle=p.background,s.fillRect(j.x-v*.15,j.y-v*.1,O+v*.3,v*1.2)}s.fillStyle=p.colour,s.fillText(R,j.x,j.y),s.globalAlpha=1;return}if(p.tool==="rect")s.strokeRect(j.x,j.y,y.x-j.x,y.y-j.y);else if(p.tool==="arrow")s.beginPath(),s.moveTo(j.x,j.y),s.lineTo(y.x,y.y),s.stroke(),this.#S(s,j,y,s.lineWidth);else{s.beginPath(),s.moveTo(j.x,j.y);for(let v=1;v<b.length;v++)s.lineTo(b[v].x,b[v].y);s.stroke()}s.globalAlpha=1}#S(s,p,b,S){const j=Math.atan2(b.y-p.y,b.x-p.x),y=Math.max(8,S*3);s.beginPath(),s.moveTo(b.x,b.y),s.lineTo(b.x-y*Math.cos(j-Math.PI/7),b.y-y*Math.sin(j-Math.PI/7)),s.lineTo(b.x-y*Math.cos(j+Math.PI/7),b.y-y*Math.sin(j+Math.PI/7)),s.closePath(),s.fill()}#v(s,p){const b=l(p);if(!b||!x(s.strokeRect))return;const S=6;s.save(),s.setLineDash?.([4,3]),s.strokeStyle="#1a73e8",s.lineWidth=2,s.globalAlpha=1,s.strokeRect(b.x1-S,b.y1-S,b.x2-b.x1+S*2,b.y2-b.y1+S*2),s.restore()}#C(s,p){const b=this.#e.presentation?.scale||1,S=o*b;for(let j=this.#s.length-1;j>=0;j--){const y=this.#s[j];if(u(y.region)===p&&i(y,s)<=S)return y}return null}#O(){const s=x(this.#t.scrollPosition)?this.#t.scrollPosition():null,p=this.#t.viewport?.rtl===!0;return{left:X(s?.left||0,p),top:s?.top||0}}#P(){if(this.#n)return this.#n;const s=this.#t.viewport?.overlays,p=s?.ownerDocument;if(!s||!p?.createElement)return null;const b=p.createElement("canvas");return b.className=a,b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",s.appendChild(b),this.#n=b,this.#r=b.getContext?b.getContext("2d"):null,this.#M(),this.#E(b),b}#M(){const s=this.#n,p=this.#t.viewport?.root;if(!s||!p?.getBoundingClientRect)return;const b=p.getBoundingClientRect(),j=s.ownerDocument?.defaultView?.devicePixelRatio||1,y=Math.max(1,Math.round(b.width*j)),v=Math.max(1,Math.round(b.height*j));s.width===y&&s.height===v||(s.width=y,s.height=v,s.style&&(s.style.width=`${Math.max(1,b.width)}px`,s.style.height=`${Math.max(1,b.height)}px`),this.#r?.setTransform(j,0,0,j,0,0))}#E(s){const p=(v,R="centre")=>{const O=s.getBoundingClientRect(),{left:F,top:C}=this.#O();return{x:v.clientX-O.left+(R==="centre"?F:0),y:v.clientY-O.top+C}},b=v=>{if(!this.#o||!this.#A(v))return;const R=this.#b(v.clientX);if(this.#o==="erase"){const O=this.#C(p(v,R),R);O&&(this.remove(O.id),this.#L("a11y.annotate.erased")),v.preventDefault?.();return}this.#l={id:z("mark"),tool:this.#o,colour:this.#i,points:[p(v,R)],region:R},s.setPointerCapture?.(v.pointerId),v.preventDefault?.()},S=v=>{if(!this.#l)return;const R=p(v,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(R),this.redraw()},j=v=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,s.releasePointerCapture?.(v.pointerId),this.redraw(),this.#T())},y=v=>{if(!this.#o)return;const R=this.#t.viewport?.bodyViewport;if(!R)return;let O=!1;v.deltaY&&typeof R.scrollTop=="number"&&(R.scrollTop+=v.deltaY,O=!0),v.deltaX&&typeof R.scrollLeft=="number"&&(R.scrollLeft+=v.deltaX,O=!0),O&&v.preventDefault?.()};s.addEventListener("pointerdown",b),s.addEventListener("pointermove",S),s.addEventListener("pointerup",j),s.addEventListener("pointercancel",j),s.addEventListener("wheel",y,{passive:!1}),this.#a.push(()=>{s.removeEventListener("pointerdown",b),s.removeEventListener("pointermove",S),s.removeEventListener("pointerup",j),s.removeEventListener("pointercancel",j),s.removeEventListener("wheel",y)})}#T(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}#N(s,p){const b=this.#e.messages;return b&&x(b.t)?b.t(s,p):s}#L(s,p){this.#t.announce?.(this.#N(s,p),{repeat:!0})}destroy(){for(const s of this.#a)s();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const c=m}),Fe("packages/dom/src/timelinebar.js",function(e,K){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return H}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_="lat-timeline";function X(B){if(!Number.isFinite(B)||B<1e3)return"now";const w=Math.round(B/1e3);if(w<60)return`${w}s ago`;const A=Math.round(w/60);return A<60?`${A}m ago`:`${Math.round(A/60)}h ago`}function W(B,w){return Number.isFinite(B)?new Date(B).toLocaleTimeString(w||void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}class V{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=[];constructor(w){this.#e=w.grid,this.#t=w.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const w=this.#e.timeline,A=w.depth,g=w.position;this.#r.max=String(Math.max(1,A)),this.#r.value=String(Math.max(0,A-g)),this.#r.disabled=A===0;const u=w.at(),h=w.live;this.#o&&(this.#o.textContent=h?this.#l("timeline.live"):X(Date.now()-(u||Date.now())),this.#o.setAttribute("data-live",h?"true":"false")),this.#i&&(this.#i.textContent=A===0?this.#l("timeline.recording"):W(u,this.#e.get("locale"))),this.#n.setAttribute("data-live",h?"true":"false")}#l(w,A){const g=this.#e;return(g&&g.messages?g.messages:$).t(w,A)}#a(){if(this.#n)return;const w=this.#t.viewport?.overlays,A=w?.ownerDocument;if(!w||!A?.createElement)return;const g=A.createElement("div");g.className=_;const u=A.createElement("span");u.className=`${_}__ago`,u.setAttribute("role","status"),u.setAttribute("aria-live","polite");const h=A.createElement("input");h.className=`${_}__range`,h.type="range",h.min="0",h.step="1",h.setAttribute("aria-label",this.#l("timeline.scrub"));const a=A.createElement("span");a.className=`${_}__clock`;const r=A.createElement("button");r.className=`${_}__live`,r.type="button",r.textContent=this.#l("timeline.goLive"),r.setAttribute("aria-label",this.#l("timeline.returnToPresent")),g.appendChild(u),g.appendChild(h),g.appendChild(a),g.appendChild(r),w.appendChild(g),this.#n=g,this.#r=h,this.#o=u,this.#i=a;const t=()=>{const d=this.#e.timeline.depth;this.#e.timeline.seek(d-Number(h.value))};h.addEventListener("input",t);const n=()=>this.#e.timeline.toLive();r.addEventListener("click",n);const o=d=>d.stopPropagation();h.addEventListener("keydown",o),this.#s.push(()=>{h.removeEventListener("input",t),r.removeEventListener("click",n),h.removeEventListener("keydown",o)})}#u(){this.#n&&(x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const w of this.#s)w();this.#s=[],this.#u()}}const H=V}),Fe("packages/dom/src/commentpaint.js",function(e,K){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/renderer/direction.js").isRtlElement,W="lat-comment-mark",V="lat-cell--commented",H="lat-cell--commented-open";class B{#e;#t;#n=[];#r=[];constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const g=this.#e.comments;if(!g||!g.enabled)return;const u=this.#t.viewport?.root;if(!u||!u.querySelectorAll)return;const h=[];for(const a of u.querySelectorAll("[data-key]")){const r=a.getAttribute("data-key");if(r){h.push(r);for(const t of a.querySelectorAll("[data-col]")){const n=t.getAttribute("data-col"),o=g.at(r,n),d=!!(o&&o.count);t.classList.toggle(V,d),t.classList.toggle(H,d&&o.unresolved>0),this.#i(t,o,n)}}}(h.length!==this.#r.length||h.some((a,r)=>a!==this.#r[r]))&&(this.#r=h,g.request(h))}#o(g,u){const h=this.#e;return(h&&h.messages?h.messages:$).t(g,u)}#i(g,u,h){if(!u||!u.count){g.hasAttribute("aria-description")&&g.removeAttribute("aria-description");return}const a=u.count,r=u.unresolved,t=this.#o("count.comments",{count:a});g.setAttribute("aria-description",r>0?this.#o("comments.someUnresolved",{comments:t,unresolved:r}):this.#o("comments.allResolved",{comments:t}))}#s(){const g=this.#t.viewport?.root;if(!g||!x(g.addEventListener))return;const u=a=>{const r=this.#e.comments;if(!r||!r.enabled)return;const t=a.target&&x(a.target.closest)?a.target.closest("[data-col]"):null;if(!t||!t.classList.contains(V)||!this.#l(t,a))return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.stopPropagation(),a.preventDefault(),r.open(o,t.getAttribute("data-col")))},h=a=>{const r=this.#e.comments;if(!r||!r.enabled||!a.altKey||a.key!=="m"&&a.key!=="M")return;const t=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&x(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!t)return;const n=t.closest("[data-key]"),o=n&&n.getAttribute("data-key");o&&(a.preventDefault(),a.stopPropagation(),r.open(o,t.getAttribute("data-col")))};g.addEventListener("click",u,!0),g.addEventListener("keydown",h,!0),this.#n.push(()=>{g.removeEventListener("click",u,!0),g.removeEventListener("keydown",h,!0)})}#l(g,u){if(!x(g.getBoundingClientRect))return!1;const h=g.getBoundingClientRect(),a=Math.max(14,Math.min(24,h.height*.6));return(X(g)?u.clientX<=h.left+a:u.clientX>=h.right-a)&&u.clientY<=h.top+a}destroy(){for(const g of this.#n)g();this.#n=[]}}const w=B}),Fe("packages/dom/src/presencepaint.js",function(e,K){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return w}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/presence.js").CURSOR_LABEL_MS,H="lat-presence";class B{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(g){this.#e=g.grid,this.#t=g.renderer}mount(){const g=this.#e.presence;if(!(!g||!g.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const u of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(u,h=>this.#l(u,h)));this.#a(),this.paint()}}#l(g,u){if(this.#h(),g==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const a=u&&u.peer;a&&(this.#r.textContent=this.#f(g==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:a.name}))}#a(){const g=this.#t.viewport?.overlays,u=g?.ownerDocument;if(!g||!u?.createElement)return;const h=this.#e.get("presence")||{},a=u.createElement("span");if(a.className=`${H}__live`,a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),g.appendChild(a),this.#r=a,h.roster===!1)return;const r=u.createElement("div");r.className=H,h.roster&&h.roster.side==="start"&&r.setAttribute("data-side","start"),r.style.pointerEvents="auto",g.appendChild(r),this.#n=r}paint(){const g=this.#e.presence,u=this.#t.viewport?.root;if(!g||!g.enabled||!u?.querySelectorAll)return;this.#d(u);const h=g.peers(),a=[...h].sort((r,t)=>r.at-t.at);for(const r of a)for(const t of r.ranges||[])for(const n of t.rowIds||[])for(const o of t.columns||[])this.#c(u,n,o,r,"range");for(const r of a)r.cursor&&this.#c(u,r.cursor.rowId,r.cursor.colId,r,"cursor");for(const r of a)r.editing&&this.#c(u,r.editing.rowId,r.editing.colId,r,"edit");this.#h(),this.#u(h)}#u(g){if(this.#s!==null)return;const u=g.filter(r=>r.cursorFresh);if(!u.length)return;const a=Math.max(...u.map(r=>r.cursorAt||0))+V-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,a))}#c(g,u,h,a,r){const t=g.querySelector(`[data-key="${X(u)}"]`),n=t&&t.querySelector(`[data-col="${X(h)}"]`);n&&(n.setAttribute("data-presence",r),n.style.setProperty("--lat-peer",a.colour),n.setAttribute("data-peer-name",a.name),n.setAttribute("data-peer-initial",a.initials||(a.name||"?").slice(0,1).toUpperCase()),a.idle?n.setAttribute("data-peer-idle","true"):n.removeAttribute("data-peer-idle"),r==="cursor"&&a.cursorFresh&&n.setAttribute("data-peer-fresh","true"),this.#o.add(`${u}${h}`))}#d(g){if(this.#o.size){for(const u of g.querySelectorAll("[data-presence]"))u.removeAttribute("data-presence"),u.removeAttribute("data-peer-name"),u.removeAttribute("data-peer-initial"),u.removeAttribute("data-peer-fresh"),u.removeAttribute("data-peer-idle"),u.style.removeProperty("--lat-peer");this.#o.clear()}}#h(){if(!this.#n)return;const g=this.#n.ownerDocument,u=this.#e.presence.peers();if(this.#n.textContent="",!u.length){this.#n.toggleAttribute("data-empty",!0);return}this.#n.removeAttribute("data-empty");for(const a of u){const r=g.createElement("button");r.className=`${H}__peer`,r.type="button",r.style.setProperty("--lat-peer",a.colour),r.toggleAttribute("data-idle",!!a.idle),r.toggleAttribute("data-hidden",!!a.hidden);let t="presence.peer";a.hidden?t="presence.peerHidden":a.idle&&(t="presence.peerIdle"),r.setAttribute("aria-label",this.#f(t,{name:a.name}));const n=g.createElement("span");n.className=`${H}__dot`,n.setAttribute("aria-hidden","true"),n.textContent=a.initials||(a.name||"?").slice(0,1).toUpperCase(),r.appendChild(n);const o=g.createElement("span");o.className=`${H}__name`,o.textContent=a.name,r.appendChild(o),r.addEventListener("click",()=>this.#e.presence.jumpTo(a.id)),this.#n.appendChild(r)}const h=u.filter(a=>a.hidden).length;if(h){const a=g.createElement("span");a.className=`${H}__hidden`,a.textContent=this.#f("presence.hidden",{count:h}),this.#n.appendChild(a)}}announceRefusal(g){if(!this.#r)return;const u=g&&g.name?g.name:this.#f("presence.someoneElse");this.#r.textContent=this.#f("a11y.presence.refused",{name:u})}#f(g,u){const h=this.#e;return(h&&h.messages?h.messages:$).t(g,u)}destroy(){for(const u of this.#i)u();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const g=this.#t.viewport?.root;g?.querySelectorAll&&this.#d(g),this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const w=B}),Fe("packages/dom/src/commentpanel.js",function(e,K){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return h}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,X=K("packages/dom/src/editors/common.js").cssEscape,V=K("packages/core/src/model/comments.js").parseCellKey,H="lat-comments",B=/^(https?:|mailto:)/i,w='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function A(a,r){if(!Number.isFinite(a))return"";const t=Math.max(0,Math.round((r-a)/1e3));if(t<60)return"just now";const n=Math.round(t/60);if(n<60)return`${n}m ago`;const o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function g(a,r,t,n){r.textContent="";const o=String(t??"");if(!n){r.textContent=o;return}const d=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,i=d.exec(o);for(;i;){i.index>l&&r.appendChild(a.createTextNode(o.slice(l,i.index)));const m=i[0];if(m.startsWith("*")){const c=a.createElement("em");c.textContent=m.slice(1,-1),r.appendChild(c)}else if(m.startsWith("`")){const c=a.createElement("code");c.textContent=m.slice(1,-1),r.appendChild(c)}else{const c=m.indexOf("]("),f=m.slice(1,c),s=m.slice(c+2,-1);if(B.test(s)){const p=a.createElement("a");p.href=s,p.textContent=f,p.rel="noopener noreferrer",p.target="_blank",r.appendChild(p)}else r.appendChild(a.createTextNode(f))}l=i.index+m.length,i=d.exec(o)}l<o.length&&r.appendChild(a.createTextNode(o.slice(l)))}class u{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(r){this.#e=r.grid,this.#t=r.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",r=>this.#a(r))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#w()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(r){const t=this.#t.viewport?.root?.ownerDocument;t&&(this.#s=t.activeElement||null,this.#i=this.#h(r.rowId,r.field),this.#n||this.#p(t),this.#n.setAttribute("data-open","true"),this.#b(),this.#w(),this.#o&&x(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const r=this.#s;this.#s=null,r&&x(r.focus)&&r.focus()}#c(){const r=this.#e.comments.openKey;if(!r)return;const{rowId:t}=V(r);this.#e.rows.byKey(t)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(r){if(!this.#r)return;const n=this.#r.ownerDocument.createElement("p");n.className=`${H}__note`,n.setAttribute("role","status"),n.textContent=r,this.#r.appendChild(n)}#h(r,t){const n=this.#t.viewport?.root;if(!n||!n.querySelector)return null;const o=n.querySelector(`[data-key="${X(r)}"]`);return o?o.querySelector(`[data-col="${t}"]`):null}#f(r,t){const n=this.#e;return(n&&n.messages?n.messages:$).t(r,t)}#p(r){const t=r.createElement("div");t.className=H,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",this.#f("comments.panel"));const n=r.createElement("header");n.className=`${H}__head`;const o=r.createElement("div");o.className=`${H}__title`,n.appendChild(o);const d=r.createElement("button");d.className=`${H}__resolve`,d.type="button",n.appendChild(d);const l=r.createElement("button");l.className=`${H}__close`,l.type="button",l.setAttribute("aria-label",this.#f("comments.close")),l.textContent="×",n.appendChild(l);const i=r.createElement("div");i.className=`${H}__list`,i.setAttribute("role","log"),i.setAttribute("aria-live","polite");const m=r.createElement("form");m.className=`${H}__composer`;const c=r.createElement("textarea");c.className=`${H}__input`,c.rows=2,c.setAttribute("aria-label",this.#f("comments.write"));const f=r.createElement("button");f.className=`${H}__send`,f.type="submit",f.textContent=this.#f("comments.post"),m.appendChild(c),m.appendChild(f),t.appendChild(n),t.appendChild(i),t.appendChild(m),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(t),this.#n=t,this.#r=i,this.#o=c,this.#m=o,this.#g=d;const s=j=>{j.preventDefault();const y=String(c.value||"").trim();y&&(c.value="",this.#e.comments.add(y))},p=()=>this.#e.comments.close(),b=()=>{this.#y()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},S=j=>{if(j.stopPropagation(),j.key==="Escape"){j.preventDefault(),this.#e.comments.close();return}if(j.key!=="Tab")return;const y=[...t.querySelectorAll(w)].filter(F=>F.offsetParent!==null||F===c);if(!y.length)return;const v=y[0],R=y[y.length-1],O=t.ownerDocument.activeElement;j.shiftKey&&O===v?(j.preventDefault(),R.focus()):!j.shiftKey&&O===R&&(j.preventDefault(),v.focus())};m.addEventListener("submit",s),l.addEventListener("click",p),d.addEventListener("click",b),t.addEventListener("keydown",S),this.#l.push(()=>{m.removeEventListener("submit",s),l.removeEventListener("click",p),d.removeEventListener("click",b),t.removeEventListener("keydown",S)})}#m=null;#g=null;#y(){return(this.#e.comments.thread||[]).filter(t=>!t.resolved).length}#b(){const r=this.#e.comments;if(!this.#n||!r.openKey)return;const t=this.#n.ownerDocument,n=this.#e.get("comments")||{},o=Date.now(),d=r.openKey,{rowId:l,field:i}=V(d),m=this.#e.columns.get(i),c=this.#e.rows.byKey(l),f=x(n.rowLabel)&&c?n.rowLabel(c):l;if(this.#m.textContent=this.#f("comments.cellTitle",{column:m&&(m.title??m.id)||i,row:f}),this.#g.textContent=this.#y()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",r.loading){this.#d(this.#f("comments.loading"));return}const s=r.thread||[];if(!s.length){this.#d(this.#f("comments.empty"));return}const p=c&&m?m.getValue(c.data,c):void 0;for(const b of s)this.#r.appendChild(this.#A(t,b,o,p,n))}#A(r,t,n,o,d){const l=r.createElement("article");l.className=`${H}__item`,t.pending&&l.setAttribute("data-pending","true"),t.resolved&&l.setAttribute("data-resolved","true");const i=r.createElement("div");i.className=`${H}__meta`;const m=r.createElement("span");m.className=`${H}__author`,m.textContent=t.author&&(t.author.name||t.author.initials)||this.#f("comments.unknownAuthor"),i.appendChild(m);const c=r.createElement("time");c.className=`${H}__time`;const f=A(t.at,n);c.textContent=t.edited?this.#f("comments.edited",{time:f}):f,i.appendChild(c),l.appendChild(i);const s=r.createElement("div");if(s.className=`${H}__body`,g(r,s,t.body,!!d.markdown),l.appendChild(s),t.value!==void 0&&!Object.is(t.value,o)){const S=r.createElement("p");S.className=`${H}__moved`,S.textContent=this.#f("comments.valueMoved",{was:String(t.value),now:String(o)}),l.appendChild(S)}const p=t.can||{},b=S=>p[S]!==!1;if(b("edit")||b("delete")){const S=r.createElement("div");if(S.className=`${H}__actions`,b("delete")){const j=r.createElement("button");j.type="button",j.className=`${H}__action`,j.textContent=this.#f("comments.delete"),j.addEventListener("click",()=>this.#e.comments.remove(t.id)),S.appendChild(j)}l.appendChild(S)}return l}#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 t=this.#e.comments.openKey,{rowId:n,field:o}=V(t),d=this.#h(n,o)||this.#i,l=this.#t.viewport?.root;if(!d||!l||!x(d.getBoundingClientRect))return;const i=d.getBoundingClientRect(),m=l.getBoundingClientRect(),c=this.#n.getBoundingClientRect();let f=i.bottom-m.top+4;f+c.height>m.height&&i.top-m.top>c.height&&(f=i.top-m.top-c.height-4);let s=i.left-m.left;s+c.width>m.width&&(s=Math.max(0,m.width-c.width-4)),this.#n.style.top=`${Math.max(0,f)}px`,this.#n.style.left=`${Math.max(0,s)}px`;const p=i.bottom<m.top||i.top>m.bottom;this.#n.toggleAttribute("data-offscreen",p)}destroy(){for(const r of this.#l)r();this.#l=[],this.#n&&x(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const h=u}),Fe("packages/dom/src/watermark.js",function(e,K){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return g}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/core/src/i18n/index.js").defaultMessages,_=K("packages/dom/src/editors/common.js"),X=_.el,W=_.on,V="lat-watermark",H="https://www.latticegrid.dev",B=["br","bl","tl","tr"],w=4e3;class A{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(h){this.#e=h.grid,this.#t=h.document,this.#n=h.element,this.#i=h.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),x(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const h=this.#e.licence&&this.#e.licence.ready;h&&x(h.then)&&h.then(()=>this.refresh(),()=>this.refresh())}refresh(){const h=this.#d();h&&!this.#r?(this.#h(),this.#u()):!h&&this.#r&&(this.#f(),this.#c())}#a(){const h=this.#i;if(!h||!x(h.matchMedia))return!1;try{return!!h.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),x(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%B.length,this.#f(),this.#h(),this.#u()},w)))}#c(){this.#l!==null&&x(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const h=this.#e.licence;return!!(h&&x(h.watermark)&&h.watermark())}#h(){const h=this.grid&&this.grid.messages?this.grid.messages:$,a=X(this.#t,"a",{class:`${V}__link`,text:h.t("licence.watermark"),attrs:{href:H,target:"_blank",rel:"noopener noreferrer"}}),r=X(this.#t,"span",{class:`${V}__free`,text:h.t("licence.watermark.free")});this.#r=X(this.#t,"div",{class:`${V} ${V}--${B[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[a,r]}),this.#o.push(W(this.#r,"pointerdown",t=>{x(t.stopPropagation)&&t.stopPropagation()})),this.#n&&x(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&x(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const h of this.#o)h();this.#o=[],this.#f()}}const g=A}),Fe("packages/dom/src/maximise.js",function(e,K){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"DEFAULT_MAXIMISE_Z",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"MAXIMISE_Z_PROP",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const Q=K("packages/core/src/internal/util.js"),x=Q.warnOnce,z=Q.isFunction,$=K("packages/dom/src/editors/common.js"),_=$.el,X=$.on,V=K("packages/dom/src/themeof.js").themeOf,H="lat-maximised",B={top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px"},w="1000",A="--lattice-maximise-z",g="lat-maximised-host",u="lat-maximise-placeholder";class h{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=w;#c=null;#d=!1;#h=null;constructor(t){this.#e=t.element,this.#t=t.document,this.#n=z(t.onChange)?t.onChange:null,this.#r=z(t.captureScroll)?t.captureScroll:null,this.#o=z(t.restoreScroll)?t.restoreScroll:null,t.zIndex!==void 0&&t.zIndex!==null&&(this.#u=String(t.zIndex)),t.container&&z(t.container.appendChild)&&(this.#c=t.container)}active(){return this.#i!==null}enter(){if(this.active())return!0;const t=this.#e.parentNode,n=this.#c||this.#t.body;if(!t||!n||!this.#t.body)return x("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=_(this.#t,"div",{class:u}),this.#i.style.visibility="hidden";const o=this.#e.offsetWidth,d=this.#e.offsetHeight;o&&(this.#i.style.width=`${o}px`),d&&(this.#i.style.height=`${d}px`);const l=this.#r?this.#r():null,i=z(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?V(this.#c||t):null;i&&(this.#e.setAttribute("data-theme",i),this.#d=!0),t.insertBefore(this.#i,this.#e),this.#p(()=>n.appendChild(this.#e)),this.#a={};for(const[m,c]of Object.entries(this.#f()))this.#a[m]=this.#e.style[m]||"",this.#e.style[m]=c;return this.#h=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#t.body.style&&z(this.#t.body.style.setProperty)&&this.#t.body.style.setProperty(A,this.#u),this.#e.classList.add(H),this.#t.body.classList&&this.#t.body.classList.add(g),l&&this.#o&&this.#o(l),this.#s=X(this.#t,"keydown",m=>this.#m(m)),this.#g(),!0}#f(){return{...B,position:this.#c?"absolute":"fixed",zIndex:this.#u}}exit(){if(!this.active())return!1;const t=this.#r?this.#r():null,n=this.#i,o=n.parentNode;if(o&&z(o.insertBefore)&&this.#p(()=>o.insertBefore(this.#e,n)),z(n.remove)&&n.remove(),this.#i=null,this.#d&&(this.#e.removeAttribute("data-theme"),this.#d=!1),this.#a){for(const[d,l]of Object.entries(this.#a))this.#e.style[d]=l;this.#a=null}return this.#h!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#h),this.#h=null,this.#t.body&&this.#t.body.style&&z(this.#t.body.style.removeProperty)&&this.#t.body.style.removeProperty(A),this.#e.classList.remove(H),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(g),t&&this.#o&&this.#o(t),this.#s&&this.#s(),this.#s=null,this.#g(),!0}toggle(){return this.active()?!this.exit():this.enter()}#p(t){const n=this.#t.activeElement,o=n&&n!==this.#t.body&&z(this.#e.contains)&&this.#e.contains(n)?n:null;t(),o&&z(o.focus)&&o.focus()}#m(t){!t||t.key!=="Escape"||t.defaultPrevented||this.exit()}#g(){this.#n&&this.#n();for(const t of this.#l)t(this.active())}watch(t){return z(t)?(this.#l.add(t),()=>this.#l.delete(t)):()=>{}}destroy(){this.exit()}}const a=h}),Fe("packages/dom/src/promptbar.js",function(e,K){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return t}});const Q=K("packages/dom/src/editors/common.js"),x=Q.documentFor,z=Q.el,$=Q.on,_=Q.clear,W=K("packages/core/src/i18n/index.js").defaultMessages,H=K("packages/core/src/internal/util.js").isFunction,B=K("packages/core/src/ai/schema.js"),w=B.describeGrid,A=B.promptText,g=K("packages/core/src/ai/intent.js"),u=g.applyPlan,h=g.buildPrompt,a=g.planIntent,r="lat-prompt";class t{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#p=null;#m=null;#g=null;#y="idle";#b=0;#A=!1;#w=[];t(l,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:W).t(l,i)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||W,this.#e=x(l),this.#t=l.grid||null,this.#n=H(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:H(l.onPlan)?l.onPlan:null,onApply:H(l.onApply)?l.onApply:null,onError:H(l.onError)?l.onError:null},this.#s=z(this.#e,"div",{class:r,attrs:{"data-state":"idle",role:"search"}}),this.#S(l)}element(){return this.#s}refresh(){this.#A||!this.#s||this.#y!=="busy"&&this.#P()}destroy(){this.#A=!0,this.#b++;for(const l of this.#w)l();this.#w.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#p=null,this.#m=null}plan(){return this.#g}async ask(l){if(this.#A||this.#y==="busy")return null;const i=String(l??(this.#l&&this.#l.value)??"").trim();if(!i)return null;if(!this.#n)return this.#E("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const m=++this.#b;this.#v("busy"),this.#M("Thinking…");let c;try{const f=w(this.#t,this.#r),s=A(f);if(c=await this.#n({prompt:i,schema:f,schemaText:s,message:h(i,s),context:this.#o}),this.#A||m!==this.#b)return null;const p=a(c,f);return this.#C(p),p}catch(f){return this.#A||m!==this.#b||(this.#i.onError&&this.#i.onError(f),this.#E(f instanceof Error?f.message:String(f))),null}}apply(){const l=this.#g;if(this.#A||!l||!l.ok)return null;const i=this.#t?.ai,m=H(i?.apply)?i.apply(l):u(l,this.#t);return this.#i.onApply&&this.#i.onApply(m,l),this.#P(),this.#l&&(this.#l.value=""),m.failed.length?this.#E(`Applied ${m.applied.length}; ${m.failed.map(c=>`${c.type} failed: ${c.reason}`).join("; ")}`):this.#M(`Applied: ${l.describe()}`),m}discard(){this.#A||(this.#P(),this.#M("Discarded."))}#S(l){const i=this.#e,m=z(i,"div",{class:`${r}__row`});this.#l=z(i,"input",{class:`${r}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#w.push($(this.#l,"keydown",f=>{const s=f&&f.key;s==="Enter"?(H(f.preventDefault)&&f.preventDefault(),this.ask()):s==="Escape"&&this.#g&&(H(f.preventDefault)&&f.preventDefault(),this.discard())})),m.appendChild(this.#l),this.#a=z(i,"button",{class:`${r}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#w.push($(this.#a,"click",()=>{this.ask()})),m.appendChild(this.#a),this.#s.appendChild(m),this.#u=z(i,"div",{class:`${r}__preview`,attrs:{hidden:!0}}),this.#c=z(i,"p",{class:`${r}__summary`}),this.#d=z(i,"ul",{class:`${r}__notes`});const c=z(i,"div",{class:`${r}__buttons`});this.#h=z(i,"button",{class:`${r}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=z(i,"button",{class:`${r}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#w.push($(this.#h,"click",()=>{this.apply()})),this.#w.push($(this.#f,"click",()=>{this.discard()})),c.appendChild(this.#h),c.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(c),this.#s.appendChild(this.#u),this.#p=z(i,"p",{class:`${r}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#m=z(i,"p",{class:`${r}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#p),this.#s.appendChild(this.#m)}#v(l){if(this.#y=l,!this.#s)return;this.#s.setAttribute("data-state",l);const i=l==="busy";n(this.#l,i),n(this.#a,i),this.#a&&(this.#a.textContent=this.t(i?"prompt.asking":"prompt.ask")),o(this.#u,l!=="preview"),o(this.#m,l!=="error")}#C(l){const i=l;if(this.#i.onPlan&&this.#i.onPlan(l),!i.ok){this.#g=null;const m=i.rejected.length?i.rejected.map(c=>c.reason).join("; "):"nothing to do";this.#E(`I could not turn that into a change: ${m}`);return}this.#g=l,this.#M(""),this.#c&&(this.#c.textContent=i.describe()),this.#O(i.rejected),this.#v("preview")}#O(l){const i=this.#d;if(i){_(i),o(i,!l.length);for(const m of l.slice(0,6))i.appendChild(z(this.#e,"li",{class:`${r}__note`,text:m.reason}));l.length>6&&i.appendChild(z(this.#e,"li",{class:`${r}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#P(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&_(this.#d),this.#v("idle")}#M(l){this.#p&&(this.#p.textContent=l)}#E(l){this.#g=null,this.#M(""),this.#m&&(this.#m.textContent=l),this.#v("error")}}function n(d,l){d&&(d.disabled=l,l?d.setAttribute("disabled",""):d.removeAttribute("disabled"))}function o(d,l){d&&(d.hidden=l,l?d.setAttribute("hidden",""):d.removeAttribute("hidden"))}}),Fe("packages/dom/src/stat.js",function(e,K){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.isObject,$=Q.warnOnce,X=K("packages/core/src/source/derive.js").reduceValues,V=K("packages/core/src/source/memory.js").isPipelineSettle,B=K("packages/core/src/i18n/index.js").defaultMessages,A=K("packages/dom/src/cell/icons.js").renderIconInto,g={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},u="unknown",h=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),a=Object.freeze({direction:"flat",change:null,percent:null});function r(s,p){if(!Number.isFinite(s)||!Number.isFinite(p))return a;const b=s-p,S=b>0?"up":b<0?"down":"flat",j=p===0?null:b/Math.abs(p)*100;return{direction:S,change:b,percent:j}}function t(s,p){return s==="flat"||p==="neither"?"flat":s===p?"good":"bad"}function n(s,p,b=null){if(x(p)){const O=p(s,b);return O==="good"||O==="warn"||O==="bad"?O:null}if(!z(p))return null;const S=typeof s=="number"&&Number.isFinite(s)?s:null;if(S===null)return null;const j=Number.isFinite(Number(p.good))?Number(p.good):null,y=Number.isFinite(Number(p.warn))?Number(p.warn):null,v=String(p.direction||"up")==="down",R=O=>v?S<=O:S>=O;return j!==null&&R(j)?"good":y!==null&&R(y)?"warn":j===null&&y===null?null:"bad"}function o(s){return!(x(s.value)||s.value!==void 0&&!z(s.value))}function d(s){return!s||!s.rows||!x(s.rows.totalCount)?!0:s.rows.totalCount()>0}function l(s){const p=z(s)?s:{},b=p.grid||null,S=c(p.container,b);if(!S)return $("stat.container","createStat needs a `container`: an element or a selector."),f();const j=S.ownerDocument||(typeof document>"u"?null:document);if(!j)return $("stat.document","createStat needs a document; it draws DOM."),f();const y=j.createElement("div");y.className=["lattice",g.root,p.class].filter(Boolean).join(" "),y.setAttribute("role","group");const v=j.createElement("div");v.className=g.title;const R=j.createElement("div");R.className=g.value;const O=j.createElement("div");O.className=g.interval;const F=j.createElement("div");F.className=g.delta;const C=j.createElement("div");C.className=g.footer;const T=j.createElement("div");if(T.className=g.note,T.hidden=!0,p.icon!=null&&p.icon!==""){const ee=j.createElement("span");ee.className=g.icon,ee.setAttribute("aria-hidden","true"),A(ee,p.icon,`stat:${p.title||"stat"}`),y.appendChild(ee);const re=j.createElement("div");re.className=g.body,re.appendChild(v),re.appendChild(R),re.appendChild(T),re.appendChild(O),re.appendChild(F),re.appendChild(C),y.appendChild(re)}else y.appendChild(v),y.appendChild(R),y.appendChild(T),y.appendChild(O),y.appendChild(F),y.appendChild(C);S.appendChild(y);let E=null;const D=[];let I=!1;function P(){if(x(p.value))return p.value(b);if(p.value!==void 0&&!z(p.value))return p.value;const ee=z(p.value)?p.value:p,re=ee.of,ie=ee.fn||"sum",ae=ee.show;return b?ie==="count"?N().length:re?ae?G(String(re),String(ie),String(ae)):k()==="filtered"&&b.statistics&&x(b.statistics.reduce)?b.statistics.reduce(String(re),String(ie)):X(N().map(fe=>m(fe,String(re))),String(ie)):null:null}function k(){return String(p.scope||"filtered")}function N(){if(!b||!b.rows)return[];const ee=k();if(ee==="all"){const ie=[];return x(b.rows.forEachAll)&&b.rows.forEachAll(ae=>{ae.group||ie.push(i(ae))}),ie}if(ee==="selected")return(b.selection&&x(b.selection.rows)?b.selection.rows():[]).filter(Boolean).map(i);const re=[];return x(b.rows.forEach)&&b.rows.forEach(ie=>{ie.group||re.push(i(ie))}),re}function G(ee,re,ie){if(re!=="min"&&re!=="max")return $(`stat.show.${re}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${re}" reduces to a value that no single row holds, so there is no row to report from.`),null;let ae=null,fe=null;for(const ce of N()){const te=Number(m(ce,ee));Number.isFinite(te)&&(ae===null||(re==="max"?te>ae:te<ae))&&(ae=te,fe=ce)}return fe===null?null:m(fe,ie)}function q(ee){if(x(p.format))return String(p.format(ee,b));if(ee==null)return p.empty??"—";const re=z(p.value)?p.value:p,ie=re.show||re.of;if((re.show?!0:h.has(String(re.fn||"sum")))&&b&&ie&&x(b.columns?.get)){const fe=b.columns.get(String(ie));if(fe&&x(fe.formatValue))return fe.formatValue(ee)}return typeof ee=="number"?Number.isInteger(ee)?String(ee):ee.toFixed(p.decimals??2):String(ee)}function Y(ee){return ee?(b&&b.messages||B).t(`stat.tone.${ee}`):""}function J(){if(I)return;const ee=P(),re=o(p)&&!!b&&!d(b),ie=re?null:ee,ae=x(p.baseline)?p.baseline(b):p.baseline;E=ie,v.textContent=p.title??"",v.hidden=!p.title,R.textContent=q(ie),T.hidden=!re,re&&(T.textContent=b.messages.t("stat.noData"));const fe=re||ae===void 0||ae===null?a:r(typeof ie=="number"?ie:null,Number(ae)),ce=t(fe.direction,p.goodWhen||"up");if(F.hidden=fe.change===null,fe.change!==null){const de=fe.direction==="up"?"↑":fe.direction==="down"?"↓":"→",be=fe.percent===null?q(Math.abs(fe.change)):`${Math.abs(fe.percent).toFixed(1)}%`;F.textContent=`${de} ${be}`,F.setAttribute("data-tone",ce),F.setAttribute("data-direction",fe.direction)}const te=x(p.interval)?p.interval(ie,b):null,oe=!!te&&Number.isFinite(te.lower)&&Number.isFinite(te.upper);O.hidden=!oe,oe&&(O.textContent=`${q(te.lower)} – ${q(te.upper)}`,Number.isFinite(te.confidence)&&O.setAttribute("title",`${Math.round(te.confidence*100)}%`));const he=re?u:p.bands?n(ie,p.bands,b):null;he?y.setAttribute("data-tone",he):y.removeAttribute("data-tone"),C.textContent=x(p.footer)?String(p.footer(ie,b)):p.footer??"",C.hidden=!C.textContent,y.setAttribute("aria-label",[p.title,R.textContent,re?T.textContent:"",oe?O.textContent:"",fe.change===null?"":F.textContent,fe.change===null?"":Y(ce),C.textContent].filter(Boolean).join(", "))}if(b&&x(b.on)&&p.live!==!1)for(const ee of["rows:changed","filter:changed","selection:changed","model:changed"]){const re=ie=>{ee==="model:changed"&&!V(ie)||J()};b.on(ee,re),D.push(()=>x(b.off)&&b.off(ee,re))}return J(),{element:()=>y,value:()=>E,refresh:J,destroy(){I=!0;for(const ee of D)try{ee()}catch{}D.length=0,y.remove()}}}function i(s){return z(s)&&"data"in s?s.data:s}function m(s,p){if(!z(s))return;if(!p.includes("."))return s[p];let b=s;for(const S of p.split(".")){if(!z(b))return;b=b[S]}return b}function c(s,p){if(s&&typeof s=="object")return s;if(typeof s!="string")return null;const b=p&&p.element&&p.element.ownerDocument||(typeof document>"u"?null:document);return b?b.querySelector(s):null}function f(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Fe("packages/dom/src/kpistrip.js",function(e,K){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return X}});const x=K("packages/core/src/internal/util.js").isObject,$=K("packages/dom/src/stat.js").createStat,_={band:"lat-kpi-strip"};class X{#e;#t;#n;#r=null;#o=[];constructor({grid:V,document:H,kpis:B}){this.#e=V,this.#t=H,this.#n=Array.isArray(B)?B.filter(x):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const H=this.#t.createElement("div");H.className=`lattice ${_.band}`,H.setAttribute("role","group"),H.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=H;for(const B of this.#n){const w=$({...B,grid:this.#e,container:H});this.#o.push(w)}}destroy(){for(const V of this.#o)try{V.destroy()}catch{}this.#o.length=0,this.#r&&(this.#r.remove(),this.#r=null)}}}),Fe("packages/dom/src/createGrid.js",function(e,K){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return xt}});const x=K("packages/core/src/index.js").createHeadlessGrid,$=K("packages/core/src/defaults.js").applyDefaults,X=K("packages/core/src/export/download.js").downloadBlob,W=K("packages/core/src/internal/util.js"),V=W.fail,H=W.isFunction,B=W.warnOnce,A=K("packages/dom/src/localviews.js").createLocalViewStorage,u=K("packages/dom/src/renderer/index.js").DomRenderer,a=K("packages/dom/src/cell/index.js").createCellLayer,r=K("packages/dom/src/cell/icons.js"),t=r.icon,n=r.iconNames,d=K("packages/dom/src/editors/index.js").editors,i=K("packages/dom/src/filters/index.js").filters,m=K("packages/dom/src/ui/index.js"),c=m.StatusBar,f=m.TooltipManager,s=m.Pagination,p=m.GroupByZone,S=K("packages/dom/src/ui/celltooltip.js").CellTooltips,y=K("packages/dom/src/filtermenu.js").FilterMenu,R=K("packages/dom/src/columnmenu.js").ColumnMenu,F=K("packages/dom/src/shortcutshelp.js").ShortcutsHelp,T=K("packages/dom/src/rowreorder.js").RowReorder,E=K("packages/dom/src/alignedgrids.js").AlignedGrids,I=K("packages/dom/src/columntagbar.js").ColumnTagBar,k=K("packages/dom/src/anomalychip.js").AnomalyChip,G=K("packages/dom/src/rowform.js").RowForm,q=K("packages/dom/src/toolpanelmount.js"),Y=q.ToolPanelDock,J=q.panelHost,re=K("packages/dom/src/celledit.js").CellEditController,ae=K("packages/dom/src/editbar.js").EditBar,ce=K("packages/dom/src/rangeselect.js").RangeController,oe=K("packages/core/src/model/selection.js").resolveSelectionConfig,de=K("packages/dom/src/importer.js").ImportController,Te=K("packages/dom/src/historybar.js").HistoryBar,Ce=K("packages/dom/src/diffpaint.js").DiffPainter,we=K("packages/dom/src/detailhost.js").DetailHost,Ne=K("packages/dom/src/highlightpaint.js").HighlightPainter,He=K("packages/dom/src/findpaint.js").FindPainter,Oe=K("packages/dom/src/findbar.js").FindBar,Ze=K("packages/dom/src/redactpaint.js").RedactionPainter,at=K("packages/dom/src/validationpaint.js").ValidationPainter,bt=K("packages/dom/src/presentation.js").PresentationController,Et=K("packages/dom/src/capture.js").captureElement,Tt=K("packages/dom/src/annotate.js").AnnotationLayer,zt=K("packages/dom/src/timelinebar.js").TimelineBar,rt=K("packages/dom/src/commentpaint.js").CommentPainter,ve=K("packages/dom/src/presencepaint.js").PresencePainter,We=K("packages/dom/src/commentpanel.js").CommentPanel,qe=K("packages/dom/src/watermark.js").Watermark,ye=K("packages/dom/src/maximise.js"),ke=ye.Maximiser,pe=ye.DEFAULT_MAXIMISE_Z,Me=K("packages/dom/src/promptbar.js").PromptBar,_e=K("packages/dom/src/kpistrip.js").KpiStrip;function De(Ge,ft,st){const ut=ft==="redo"?"toolbar.redo":"toolbar.undo";return!st||!st.label?Ge(ut):Ge(ft==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:st.label})}const Se=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],xe=2e3;function Ue(Ge,ft,st,ut){const At=ft.annotate===!0?et(Ge,ut):[];if(ft.actions===!1)return[];if(ft.actions===void 0&&ft.side!=="left")return At;const Rt=Array.isArray(ft.actions)?ft.actions:Se,yt=(Ut,tn)=>Ge.messages.t(Ut,tn),Lt={undo:{name:"undo",title:()=>De(yt,"undo",Ge.history.peek("undo")),icon:"undo",run:()=>Ge.history.undo(),enabled:()=>Ge.history.canUndo()},redo:{name:"redo",title:()=>De(yt,"redo",Ge.history.peek("redo")),icon:"redo",run:()=>Ge.history.redo(),enabled:()=>Ge.history.canRedo()},export:{name:"export",title:()=>yt("toolbar.exportCsv"),icon:"download",run:()=>Ge.export.csv({download:!0,fileName:ft.exportName})},excel:{name:"excel",title:()=>yt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Ge.export.excel({download:!0,fileName:ft.exportName})},clipboard:{name:"clipboard",title:()=>yt("toolbar.clipboard"),icon:"copy",run:()=>Ge.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>yt("toolbar.print"),icon:"print",run:()=>Ge.export.print()},pause:{name:"pause",title:()=>{if(!Ge.updates.paused)return yt("toolbar.pause");const Ut=Ge.updates.stats().pending;return Ut?yt("toolbar.applyHeld",{count:Ut}):yt("toolbar.resume")},icon:()=>Ge.updates.paused?"play":"pause",run:()=>Ge.updates.paused?Ge.updates.resume():Ge.updates.pause()},restore:{name:"restore",title:()=>yt("toolbar.restoreView"),icon:"restore",run:()=>Ge.state.reset(),enabled:()=>Ge.state.modified()},maximise:{name:"maximise",title:()=>yt(st&&st.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>st&&st.active()?"minimise":"maximise",run:()=>st.toggle()}};return st||delete Lt.maximise,Rt.map(Ut=>Ut==="-"?{name:"-",separator:!0}:typeof Ut=="string"?Lt[Ut]:!Ut||typeof Ut!="object"||!Ut.name?null:{...Ut,run:H(Ut.run)?()=>Ut.run({grid:Ge,keys:Ge.selection&&H(Ge.selection.keys)?Ge.selection.keys():[],cells:Ge.selection&&H(Ge.selection.cells)?Ge.selection.cells():[]}):void 0}).filter(Boolean).concat(At)}function et(Ge,ft){const st={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight",erase:"eraser"},ut=(Rt,yt)=>Ge.messages.t(Rt,yt),At=["pen","arrow","rect","highlight","erase"].map(Rt=>({name:Rt,title:()=>ut(`toolbar.annotate.${Rt}`),icon:st[Rt],run:()=>Ge.annotate?.use(Rt),active:()=>Ge.annotate?.tool===Rt,annotation:!0}));return At.push(Je(Ge,ut,ft)),At}function Je(Ge,ft,st){return{name:"clearAll",title:()=>ft("toolbar.annotate.clearAll"),icon:"trash",enabled:()=>(Ge.annotate?.count||0)>0,annotation:!0,run:()=>lt(Ge,ft,st)}}function lt(Ge,ft,st){const ut=Ge.toolPanel;if(!ut)return;const At=yt=>st?.announce?.(ft(yt),{repeat:!0});ut.removeAction("clearAll");const Rt=()=>{ut.removeAction("clearAllConfirm"),ut.removeAction("clearAllKeep"),ut.addAction(Je(Ge,ft,st))};ut.addAction({name:"clearAllConfirm",title:()=>ft("toolbar.annotate.clearAllConfirm"),icon:"trash",annotation:!0,run:()=>{Ge.annotate?.clear(),Rt(),At("a11y.annotate.cleared")}}),ut.addAction({name:"clearAllKeep",title:()=>ft("toolbar.annotate.clearAllKeep"),icon:"close",annotation:!0,run:()=>Rt()}),At("a11y.annotate.confirmClear")}const ot=["pen","arrow","rect","highlight","erase","clearAll"];function gt(Ge){let ft=null,st=null;return Ge.on("source:error",ut=>{const At=ut&&ut.error;st=String(At&&At.message||"").replace(/^\[lattice\]\s*/,"")||(Ge.messages?Ge.messages.t("overlay.error"):"Something went wrong")}),Ge.on("rows:changed",()=>{st=null}),{loadError:()=>st,rowCount:()=>{if(H(Ge.rows.matchCount))return Ge.rows.matchCount();const ut=Ge.pagination&&H(Ge.pagination.get)?Ge.pagination.get():null;return ut&&Number.isFinite(ut.total)?ut.total:Ge.rows.count()},totalRowCount:()=>H(Ge.rows.totalCount)?Ge.rows.totalCount():Ge.rows.count(),selectedAcrossSource:()=>{ft||(ft=H(Ge.rendererHost)?Ge.rendererHost():{});const ut=H(ft.selectionSummary)?ft.selectionSummary():null;return ut&&ut.predicate?{count:ut.count}:null},selectedCount:()=>{const ut=Ge.selection&&Ge.selection.keys?Ge.selection.keys():null;return ut?ut.length:0},rangeValues:()=>{const ut=Ge.selection;return!ut||!H(ut.cells)?[]:ut.cells().map(({key:At,colId:Rt})=>Ge.rows.value(At,Rt))},hiddenUnresolved:()=>H(Ge.comments&&Ge.comments.hiddenUnresolved)?Ge.comments.hiddenUnresolved():0,progress:()=>H(Ge.source&&Ge.source.progress)?Ge.source.progress():null,updateStats:()=>Ge.updates?Ge.updates.stats():null}}function vt(Ge,ft){for(const[st,ut]of Object.entries(d||{}))Ge.register("editor",st,ut);for(const[st,ut]of Object.entries(i||{}))Ge.register("filter",st,ut);for(const[st,ut]of Object.entries(ft.components||{}))Ge.register("component",st,ut);for(const[st,ut]of Object.entries(ft.pipes||{}))Ge.register("pipe",st,ut);for(const[st,ut]of Object.entries(ft.totalFns||{}))Ge.register("totalFn",st,ut)}function ht(Ge,ft,st,ut,At,Rt){const yt=[],Lt=ft.viewport;let Ut=null;if(st.maximise!==!1){const ct=st.maximise&&typeof st.maximise=="object"?st.maximise:{};let kt=ct.zIndex;if(kt==null){const Nt=Lt.root,Ht=ut.defaultView;kt=Ht&&typeof Ht.getComputedStyle=="function"?Ht.getComputedStyle(Nt).getPropertyValue("--lattice-maximise-z").trim():"",kt||(kt=pe)}Ut=new ke({element:Rt,document:ut,onChange:()=>ft.invalidate("all"),captureScroll:()=>ft.scrollState(),restoreScroll:Nt=>ft.restoreScroll(Nt),zIndex:kt,container:ct.container}),Ge.maximise=Ut,yt.push(()=>Ut.destroy())}if(st.statusBar){const ct=typeof st.statusBar=="object"?st.statusBar:{},kt=new c;kt.init({document:ut,host:gt(Ge),panels:ct.panels,registry:ct.registry,locale:Ge.get("locale"),messages:Ge.messages}),Lt.statusBar.appendChild(kt.element());const Nt=()=>{const nn=Lt.statusBar.offsetHeight||Lt.statusBar.getBoundingClientRect?.().height||0;Lt.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},Ht=()=>{kt.refresh(),Nt()},_t=["rows:changed","model:changed","source:error","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Ge.on(nn,Ht));Ht(),Nt(),yt.push(()=>{for(const nn of _t)nn();Lt.root.style.removeProperty("--lattice-status-height"),kt.destroy?.()})}const tn=oe(st.selection);if(tn.ranges){const ct=new ce({grid:Ge,renderer:ft,document:ut});ct.mount(),Ge.ranges=ct,yt.push(()=>ct.destroy())}if(st.import){const ct=new de({grid:Ge,renderer:ft,document:ut,settings:typeof st.import=="object"?st.import:{}});Ge.importer=ct,yt.push(()=>ct.destroy())}if(st.historyBar){const ct=typeof st.historyBar=="object"?st.historyBar.element:null,kt=new Te;kt.init({document:ut,host:{undo:()=>Ge.history.undo(),redo:()=>Ge.history.redo(),canUndo:()=>Ge.history.canUndo(),canRedo:()=>Ge.history.canRedo(),peek:Ht=>Ge.history.peek(Ht),list:()=>Ge.history.list()},props:typeof st.historyBar=="object"?st.historyBar:{}}),(ct||Lt.root).appendChild(kt.element());const Nt=[Ge.on("history:changed",()=>kt.refresh())];Ge.historyBar=kt,yt.push(()=>{for(const Ht of Nt)Ht();kt.destroy()})}if(st.diff){const ct=new Ce({grid:Ge,renderer:ft});ct.mount(),Ge.diffPainter=ct,yt.push(()=>ct.destroy())}if(st.ai&&H(st.ai.ask)){const ct=new Me;ct.init({document:ut,grid:Ge,ask:st.ai.ask,schemaOptions:st.ai.schemaOptions,context:st.ai.context,placeholder:st.ai.placeholder});const kt=st.ai.element||Lt.root;kt===Lt.root?kt.insertBefore(ct.element(),kt.firstChild):kt.appendChild(ct.element()),Ge.promptBar=ct,yt.push(()=>ct.destroy())}if(st.groupPanel){const ct=typeof st.groupPanel=="object"?st.groupPanel:{},kt=new p;kt.init({document:ut,grid:Ge,host:J(Ge,ut,(Nt,Ht)=>ft.announce?.(Nt,Ht)),props:{header:Lt.header,hint:ct.hint}}),Lt.root.insertBefore(kt.element(),Lt.header),Ge.groupPanel=kt;for(const Nt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])H(Ge.on)&&yt.push(Ge.on(Nt,()=>kt.refresh()));yt.push(()=>kt.destroy())}if(st.kpis){const ct=new _e({grid:Ge,document:ut,kpis:st.kpis});ct.active&&(ct.mount(),Lt.root.insertBefore(ct.element(),Lt.header),Ge.kpiStrip=ct,yt.push(()=>ct.destroy()))}if(st.toolPanel){const ct=typeof st.toolPanel=="object"?st.toolPanel:{},kt=new Y({grid:Ge,document:ut,root:Lt.root,panels:ct.panels,openPanel:ct.openPanel,side:ct.side,icons:ct.icons,actions:Ue(Ge,ct,Ut,ft),announce:(Nt,Ht)=>ft.announce?.(Nt,Ht)});kt.mount(),Ge.toolPanel=kt,yt.push(()=>kt.destroy()),ct.annotate===void 0&&(yt.push(Ge.on("presentation:started",()=>{for(const Nt of et(Ge,ft))kt.addAction(Nt)})),yt.push(Ge.on("presentation:ended",()=>{for(const Nt of ot)kt.removeAction(Nt)})))}if(!!st.pagination&&(()=>{const ct=typeof st.pagination=="object"?st.pagination:{};return Ge.pagination.set({pageSize:Number(ct.pageSize)||100}),Ge.pagination.get().pageSize>0})()){const ct=typeof st.pagination=="object"?st.pagination:{},kt=new s;kt.init({document:ut,pageSize:ct.pageSize,pageSizes:ct.pageSizes,page:ct.page,total:ct.total,locale:Ge.get("locale"),messages:Ge.messages,onChange:({page:_t,pageSize:nn})=>Ge.pagination.set({page:_t,pageSize:nn})});const Nt=()=>{const _t=Ge.pagination.get();kt.total=_t.total,kt.counting=_t.counting===!0,kt.hasMore=_t.total==null&&_t.pageCount>_t.page+1,kt.page=_t.page,kt.paint()};Ge.pagination.set({pageSize:kt.pageSize}),Nt();const Ht=["rows:changed","filter:changed","model:changed"].map(_t=>Ge.on(_t,Nt));Lt.statusBar.appendChild(kt.element()),yt.push(()=>{for(const _t of Ht)_t();kt.destroy?.()})}if(st.edit!==!1)if(st.editBar){const ct=new ae({grid:Ge,document:ut,root:Lt.root});ct.mount(),Ge.editBar=ct,yt.push(()=>ct.destroy())}else{const ct=new re({grid:Ge,document:ut,renderer:ft,registry:At,cellLayer:ft.cellLayer});ct.mount(),yt.push(()=>ct.destroy())}const ln=new y({grid:Ge,document:ut,layer:Lt.overlays,registry:At});ln.mount(),yt.push(()=>ln.destroy());const Zt=new R({grid:Ge,document:ut,host:Lt.root,cellMenu:st.contextMenu!==!1,headerMenu:st.columnMenu!==!1,items:H(st.contextMenu)?st.contextMenu:void 0,headerItems:H(st.columnMenu)?st.columnMenu:void 0});if(Zt.mount(),yt.push(()=>Zt.destroy()),Array.isArray(st.alignedGrids)&&st.alignedGrids.length){const ct=new E;ct.add(Ge);for(const kt of st.alignedGrids)kt&&kt!==Ge&&ct.add(kt);yt.push(()=>ct.destroy())}const jt=new G({grid:Ge,renderer:ft,document:ut,registry:At});jt.active&&(jt.mount(),yt.push(()=>jt.destroy())),Object.defineProperty(Ge,"form",{configurable:!0,value:Object.freeze({open(ct){return jt.active?jt.openRow(ct):!1},openNew(ct){return jt.active?jt.openNew(ct):(B("rowform:off","grid.form.openNew() was called on a grid with no row form (rowForm is off, or no renderer is attached); nothing opened."),!1)},close(){jt.active&&jt.close()},save(){return jt.active?jt.save():!1},isOpen(){return jt.active?jt.open:!1}})}),yt.push(()=>{delete Ge.form}),Object.defineProperty(Ge,"icons",{configurable:!0,value:Object.freeze({get(ct){const kt=t(ct);return kt?{viewBox:kt.viewBox,paths:kt.paths.slice(),paint:kt.paint==="stroke"?"stroke":"fill"}:null},names(){return n()}})}),yt.push(()=>{delete Ge.icons});const $t=new I({grid:Ge,renderer:ft,document:ut});$t.active&&($t.mount(),yt.push(()=>$t.destroy()));const Vt=new k({grid:Ge,renderer:ft,document:ut});Vt.active&&(Vt.mount(),yt.push(()=>Vt.destroy()));const Wt=new T({grid:Ge,renderer:ft,document:ut});if(Wt.active){Wt.mount(),Wt.paint();const ct=Ge.on("render:done",()=>Wt.paint());yt.push(()=>{ct(),Wt.destroy()})}if(st.shortcuts!==!1){const ct=new F({grid:Ge,renderer:ft});ct.mount(),yt.push(()=>ct.destroy())}const Qt=new Ne({grid:Ge,renderer:ft,window:ut.defaultView||void 0});Qt.mount(),yt.push(()=>Qt.destroy());const Yt=new He({grid:Ge,renderer:ft,window:ut.defaultView||void 0});if(Yt.mount(),yt.push(()=>Yt.destroy()),st.find!==!1){const ct=new Oe({grid:Ge,renderer:ft,document:ut,settings:st.find});ct.mount(),yt.push(()=>ct.destroy())}const Jt=new Ze({grid:Ge,renderer:ft});Jt.mount(),yt.push(()=>Jt.destroy());const on=new at({grid:Ge,renderer:ft});on.mount(),yt.push(()=>on.destroy());const en=new bt({grid:Ge,renderer:ft,maximiser:Ut});en.mount(),yt.push(()=>en.destroy());const hn=new zt({grid:Ge,renderer:ft});hn.mount(),yt.push(()=>hn.destroy()),st.environment||Ge.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 mn=null;for(const[ct,kt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])yt.push(Ge.on(ct,()=>{mn=kt}));yt.push(Ge.on("render:done",ct=>{Ge.diagnostics.render(mn||ct.cause,ct.phases),mn=null}));const cn=ut.defaultView;if(cn&&H(cn.requestAnimationFrame)){let ct=cn.requestAnimationFrame(function kt(Nt){Ge.diagnostics.frame(Nt),ct=cn.requestAnimationFrame(kt)});yt.push(()=>{H(cn.cancelAnimationFrame)&&cn.cancelAnimationFrame(ct)})}const gn=new ve({grid:Ge,renderer:ft});if(gn.mount(),yt.push(()=>gn.destroy()),yt.push(Ge.on("presence:lockRefused",ct=>gn.announceRefusal(ct.peer))),Ge.presence&&Ge.presence.enabled){for(const Nt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])yt.push(Ge.on(Nt,()=>Ge.presence.publish()));let ct="";yt.push(Ge.on("render:done",()=>{const Nt=ft.focusState&&ft.focusState(),Ht=Nt?`${Nt.rowKey}${Nt.colId}`:"";Ht!==ct&&(ct=Ht,Ge.presence.publish())}));const kt=Rt.ownerDocument;if(kt&&H(kt.addEventListener)){const Nt=()=>Ge.presence.setPaused(kt.visibilityState==="hidden");kt.addEventListener("visibilitychange",Nt),Nt(),yt.push(()=>kt.removeEventListener("visibilitychange",Nt))}}const wn=new rt({grid:Ge,renderer:ft});wn.mount(),yt.push(()=>wn.destroy());const En=new We({grid:Ge,renderer:ft});En.mount(),yt.push(()=>En.destroy()),yt.push(Ge.on("facet:computed",()=>ft.refreshHeader?.())),tn&&tn.headerCheckbox===!0&&yt.push(Ge.on("selection:changed",()=>ft.refreshHeader?.())),yt.push(Ge.on("facet:expanded",()=>ft.invalidate("columns"))),yt.push(Ge.on("model:changed",()=>ft.invalidate("rows")));const qt=(ct,kt)=>ft.announce?.(ct,kt),fn=Ge.messages,Kt=(ct,kt)=>fn.t(ct,kt),yn=ct=>Kt("count.rows",{count:ct});yt.push(Ge.on("sort:changed",()=>{const ct=Ge.sort.get();if(!ct.length){qt(Kt("a11y.sort.cleared"));return}const kt=ct.map(Nt=>{const Ht=Ge.columns.get(Nt.col);return Kt("a11y.sort.column",{column:Ht&&Ht.title||Nt.col,direction:Kt(Nt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});qt(Kt("a11y.sort.by",{columns:fn.list(kt)}))})),yt.push(Ge.on("filter:changed",()=>{const ct=Ge.rows.matchCount?Ge.rows.matchCount():Ge.rows.count();if(ct===null)return;const kt=Ge.rows.totalCount?Ge.rows.totalCount():ct;qt(ct===kt?Kt("a11y.filter.cleared",{rows:yn(kt)}):Kt("a11y.filter.applied",{shown:yn(ct),total:yn(kt)}))})),yt.push(Ge.on("selection:changed",()=>{const ct=Ge.selection.keys().length;qt(ct===0?Kt("a11y.selection.cleared"):Kt("a11y.selection.count",{count:ct}))})),yt.push(Ge.on("group:toggled",ct=>{const kt=Ge.rows.byKey?Ge.rows.byKey(ct.key):null,Nt=(kt&&(kt.groupLabel??kt.groupValue))??ct.key;qt(Kt(ct.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Nt,rows:yn(Ge.rows.count())}))})),yt.push(Ge.on("column:grouped",ct=>{const kt=Array.isArray(ct.columns)?ct.columns:[];if(!kt.length){qt(Kt("a11y.group.cleared"));return}const Nt=kt.map(Ht=>{const _t=Ge.columns.get(Ht);return _t&&_t.title||Ht});qt(Kt("a11y.group.by",{columns:fn.list(Nt)}))})),yt.push(Ge.on("page:changed",ct=>{const kt=Number(ct.size)||0,Nt=Number(ct.total)||0,Ht=kt>0?Math.max(1,Math.ceil(Nt/kt)):1;qt(Kt("a11y.page.position",{page:(Number(ct.page)||0)+1,pages:Ht}))}));let Xt={added:0,removed:0},sn=null;const Ln=()=>{sn=null;const ct=[];Xt.added&&ct.push(Kt("count.rowsAdded",{count:Xt.added})),Xt.removed&&ct.push(Kt("count.rowsRemoved",{count:Xt.removed})),Xt={added:0,removed:0},ct.length&&qt(fn.list(ct))};yt.push(Ge.on("rows:changed",ct=>{if(!ct||typeof ct.added!="number")return;const kt=Number(ct.added)||0,Nt=Number(ct.removed)||0;!kt&&!Nt||(Xt.added+=kt,Xt.removed+=Nt,sn||(sn=setTimeout(Ln,xe)))})),yt.push(()=>{sn&&clearTimeout(sn)}),yt.push(Ge.on("rows:paused",()=>{sn&&(clearTimeout(sn),sn=null),Xt={added:0,removed:0},qt(Kt("a11y.updates.paused"),{repeat:!0})})),yt.push(Ge.on("rows:resumed",()=>qt(Kt("a11y.updates.resumed"),{repeat:!0})));let pn={count:0,first:null},dn=null;const Fn=()=>{dn=null;const{count:ct,first:kt}=pn;if(pn={count:0,first:null},!ct||!kt)return;const Nt=Ge.columns.get(kt.colId),Ht=Nt&&Nt.title||kt.colId,_t=kt.reason?Kt("a11y.edit.reason",{reason:kt.reason}):"";if(ct===1){const nn=kt.restored===void 0||kt.restored===null||kt.restored===""?Kt("value.empty"):String(kt.restored);qt(Kt("a11y.edit.refusedOne",{column:Ht,value:nn,reason:_t}),{repeat:!0});return}qt(Kt("a11y.edit.refusedMany",{count:ct,reason:_t}),{repeat:!0})};yt.push(Ge.on("cell:reverted",ct=>{!ct||!ct.applied||(pn.count+=1,pn.first||(pn.first=ct),dn||(dn=setTimeout(Fn,150)))})),yt.push(()=>{dn&&clearTimeout(dn)}),yt.push(Ge.on("history:applied",ct=>{const kt=!!(ct&&ct.direction==="redo"),Nt=ct&&ct.step&&ct.step.label;qt(Nt?Kt(kt?"a11y.history.redo":"a11y.history.undo",{label:Nt}):Kt(kt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const vn=new Tt({grid:Ge,renderer:ft,seed:st.state&&Array.isArray(st.state.annotations)?st.state.annotations:null});vn.mount(),yt.push(()=>vn.destroy()),Ge.annotate=vn,Ge.capture=async(ct={})=>{const{blob:kt,width:Nt,height:Ht}=await Et(ft.viewport.root,ct);return(ct.download===!0||ct.download!==!1&&ct.fileName)&&X(kt,ct.fileName||`${Ge.get("exportName")||"grid"}.png`),Ge.emit("presentation:captured",{width:Nt,height:Ht,bytes:kt.size,mimeType:kt.type,fileName:ct.fileName||null},"api"),kt};const xn=new qe({grid:Ge,document:ut,element:Lt.overlays,window:ut.defaultView||void 0});xn.mount(),yt.push(()=>xn.destroy());const Tn=new f({grid:Ge,document:ut,element:Lt.overlays});Tn.mount?.(),yt.push(()=>Tn.destroy?.());const kn=new S({grid:Ge,host:Ge.rendererHost(),viewport:Lt,document:ut});return kn.mount(),yt.push(()=>kn.destroy()),yt}function Ct(Ge){const ft=[],st=ut=>{if(ut&&(ut.__lattice&&ft.push(ut),ut.children))for(const At of ut.children)st(At)};return st(Ge),ft}function xt(Ge,ft={}){(!Ge||typeof Ge!="object"||!("appendChild"in Ge))&&V("createGrid needs a host element as its first argument."),ft=$(ft);const st=Ge.ownerDocument||(typeof document<"u"?document:null);st||V("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const ut=st.documentElement&&st.documentElement.lang,At=!ft.licence&&H(st.querySelector)?st.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Rt={...ft};if(!ft.locale&&ut&&(Rt.locale=ut),At&&(Rt.licence=At),ft.views&&ft.views.local)if(ft.views.storage)B("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const Zt=ft.views.local===!0?{}:ft.views.local;Rt.views={...ft.views,storage:A(Zt)}}const yt=x(Rt),Lt=yt.rendererHost();Lt.document=st,vt(Lt.registry,ft),Lt.cellLayer=a(Lt),Lt.detailHost=new we({grid:yt,document:Ge.ownerDocument||globalThis.document,createGrid:(Zt,jt)=>xt(Zt,jt)});const Ut=new u(Ge,Lt),tn=yt.on("detail:toggled",()=>{Lt.detailHost.syncTarget(),Lt.detailHost.prune()}),an=yt.on("config:changed",Zt=>{Zt&&Zt.key==="detail"&&Lt.detailHost.reconfigure()});yt.on("destroy",()=>{tn(),an(),Lt.detailHost.destroy()}),Lt.detailHost.syncTarget(),yt.attachRenderer(Ut),Ut.mount();const bn=ht(yt,Ut,ft,st,Lt.registry,Ge),ln=yt.destroy.bind(yt);return yt.destroy=()=>{for(const Zt of bn)try{Zt()}catch{}Ge.__lattice===yt&&(Ge.__lattice=null),ln()},Ge.__lattice=yt,yt}}),Fe("packages/dom/src/hydrate.js",function(e,K){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"HYDRATE_CONFIG_ATTR",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"hydrateInto",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return f}});const Q=K("packages/core/src/internal/util.js"),x=Q.isFunction,z=Q.warnOnce,$=K("packages/core/src/columns/datatypes.js"),_=$.BUILTIN_TYPES,X=$.parseNumberText,V=K("packages/core/src/columns/types/index.js").EXTENDED_TYPES,B=K("packages/core/src/format/boolean.js").toTriState,w=K("packages/core/src/format/date.js"),A=w.toIsoDate,g=w.toIsoDateTime,h=K("packages/dom/src/createGrid.js").createGrid,a=new Set([...Object.keys(_),...Object.keys(V)]);function r(s,p){for(const b of s.children)if(b.tagName===p.toUpperCase())return b;return null}function t(s,p){const b=[];for(const S of s.children)S.tagName===p.toUpperCase()&&b.push(S);return b}function n(s,p){const b=x(s.getAttribute)?s.getAttribute("data-field"):null;return b||String(s.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${p}`}function o(s){const p=s.trim();if(p==="")return null;if(p==="true"||p==="false")return p==="true";const b=Number(p);return Number.isFinite(b)&&p!==""?b:p}function d(s,p){return p==="text"?s===""?null:s:p==="boolean"?B(s):p==="number"?X(s):p==="date"||p==="dateString"?A(s):p==="datetime"?g(s):o(s)}function l(s){const p=r(s,"thead"),b=r(p||s,"tr"),j=(b?t(b,"th").length?t(b,"th"):t(b,"td"):[]).map((O,F)=>{const C=n(O,F),T={id:C,field:C,title:String(O.textContent||"").trim()||C},L=x(O.getAttribute)?O.getAttribute("data-type"):null;L&&(a.has(L)?T.type=L:z(`hydrate.unknownType:${L}`,`data-type "${L}" on column "${C}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const E=x(O.getAttribute)?O.getAttribute("data-format"):null;return E&&(T.format=E),T}),y=r(s,"tbody"),R=(y?t(y,"tr"):t(s,"tr").filter(O=>O!==b)).map((O,F)=>{const C=t(O,"td"),L={__row:(x(O.getAttribute)?O.getAttribute("data-id"):null)||`row${F}`};return j.forEach((E,D)=>{L[E.field]=C[D]?E.type?d(String(C[D].textContent||""),E.type):o(String(C[D].textContent||"")):null}),L});return{columns:j,rows:R}}function i(s,p){if(p===void 0)return s;if(p!==null&&typeof p=="object"&&!Array.isArray(p)&&Array.isArray(p.only))return p.only;if(!Array.isArray(p))return p;const b=new Map;for(const j of p)if(j&&typeof j=="object"){const y=j.id??j.field;y!=null&&b.set(y,j)}const S=s.map(j=>{const y=b.get(j.id)??b.get(j.field);return y===void 0?j:{...j,...y}});for(const[j,y]of b)s.some(v=>v.id===j||v.field===j)||S.push({...y});return S}const m="data-lattice-hydrate-config";function c(s,p,b={}){const{columns:S,rows:j}=l(p);return h(s,{rowKey:"__row",...b,columns:i(S,b.columns),rows:b.rows!==void 0?b.rows:j})}function f(s,p={}){const b=s.ownerDocument.createElement("div");b.setAttribute("data-lattice-hydrated",""),s.removeAttribute("data-lattice-grid"),b.__latticeTable=s;try{b.setAttribute(m,JSON.stringify(p))}catch{b.setAttribute(m,"{}")}return s.parentNode.insertBefore(b,s),s.parentNode.removeChild(s),c(b,s,p)}}),Fe("packages/dom/src/autoinit.js",function(e,K){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return B}});const x=K("packages/core/src/internal/util.js").isFunction,$=K("packages/dom/src/createGrid.js").createGrid,X=K("packages/dom/src/hydrate.js").hydrateTable;function W(w,A){const g=[];return x(w.hasAttribute)&&w.hasAttribute(A)&&g.push(w),x(w.querySelectorAll)&&g.push(...w.querySelectorAll(`[${A}]`)),g}function V(w){const A=w.parentNode;if(!A||!A.children)return null;const g=[...A.children],u=g.indexOf(w),h=[g[u+1],g[u-1]];for(const a of h)if(a&&a.tagName==="SCRIPT"&&x(a.getAttribute)&&a.hasAttribute("data-lattice-config"))return a;return null}function H(w){const A=V(w);if(!A)return{};try{return JSON.parse(A.textContent||"{}")}catch(g){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",g),{}}}function B(w){const A=w||(typeof document<"u"?document:null);if(!A)return[];const g=[];for(const u of W(A,"data-lattice-grid")){if(u.__lattice)continue;const h=H(u);g.push(u.tagName==="TABLE"?X(u,h):$(u,h))}return g}}),Fe("packages/dom/src/index.js",function(e,K){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});const Q=K("packages/dom/src/createGrid.js"),x=Q.createGrid,z=K("packages/dom/src/hydrate.js"),$=z.hydrateTable,_=K("packages/dom/src/autoinit.js"),X=_.autoInit,W=K("packages/dom/src/localviews.js"),V=W.createLocalViewStorage,H=K("packages/core/src/index.js"),B=H.createHeadlessGrid,w=H.registerModules,A=H.setLicence,g=H.version,u=H.getVersion,h=H.serialiseState,a=H.restoreState,r=H.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return Q.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return Q.gridElementsWithin}});const t=K("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return t.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return t.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return z.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return z.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return _.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return W.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return W.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return H.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return H.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return H.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return H.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return H.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return H.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return H.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return H.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return H.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return H.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return H.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return H.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return H.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return H.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return H.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return H.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return H.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return H.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return H.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return H.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return H.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return H.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return H.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return H.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return H.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return H.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return H.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return H.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return H.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return H.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return H.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return H.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return H.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return H.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return H.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return H.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return H.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return H.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return H.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return H.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return H.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return H.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return H.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return H.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return H.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return H.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return H.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return H.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return H.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return H.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return H.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return H.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return H.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return H.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return H.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return H.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return H.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return H.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return H.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return H.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return H.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return H.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return H.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return H.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return H.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return H.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return H.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return H.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return H.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return H.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return H.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return H.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return H.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return H.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return H.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return H.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return H.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return H.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return H.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return H.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return H.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return H.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return H.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return H.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return H.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return H.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return H.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return H.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return H.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return H.WINDOW_KINDS}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return H.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return H.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return H.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return H.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return H.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return H.anomalyCondition}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return H.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return H.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return H.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return H.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return H.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return H.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return H.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return H.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return H.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return H.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return H.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return H.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return H.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return H.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return H.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return H.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return H.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return H.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return H.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return H.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return H.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return H.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return H.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return H.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return H.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return H.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return H.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return H.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return H.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return H.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return H.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return H.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return H.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return H.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return H.splunkAdapter}}),Object.defineProperty(e,"clickhouseAdapter",{enumerable:!0,get:function(){return H.clickhouseAdapter}}),Object.defineProperty(e,"elasticsearchAdapter",{enumerable:!0,get:function(){return H.elasticsearchAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return H.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return H.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return H.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return H.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return H.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return H.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return H.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return H.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return H.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return H.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return H.VERSION}});const n=K("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return n.DomRenderer}});const o=K("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return o.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return o.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return o.branchFor}});const d=K("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return d.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return d.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return d.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return d.autoGroupMenuItems}});const l=K("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const i=K("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return i.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return i.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return i.mountPanel}});const m=K("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return m.CellEditController}});const c=K("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return c.EditBar}});const f=K("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return f.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return f.HISTORY_CLS}});const s=K("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return s.DiffPainter}});const p=K("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return p.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return p.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return p.summariseDiff}});const b=K("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return b.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return b.PROMPT_CLASS}});const S=K("packages/dom/src/cell/index.js");Object.defineProperty(e,"createCellLayer",{enumerable:!0,get:function(){return S.createCellLayer}}),Object.defineProperty(e,"compileTemplate",{enumerable:!0,get:function(){return S.compileTemplate}}),Object.defineProperty(e,"compileVariant",{enumerable:!0,get:function(){return S.compileVariant}}),Object.defineProperty(e,"checkVariant",{enumerable:!0,get:function(){return S.checkVariant}}),Object.defineProperty(e,"VariantRegistry",{enumerable:!0,get:function(){return S.VariantRegistry}}),Object.defineProperty(e,"BUILTIN_RENDERERS",{enumerable:!0,get:function(){return S.BUILTIN_RENDERERS}}),Object.defineProperty(e,"BUILTIN_VARIANTS",{enumerable:!0,get:function(){return S.BUILTIN_VARIANTS}}),Object.defineProperty(e,"BUILTIN_PIPES",{enumerable:!0,get:function(){return S.BUILTIN_PIPES}}),Object.defineProperty(e,"sanitiseHtml",{enumerable:!0,get:function(){return S.sanitiseHtml}});const j=K("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return j.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return j.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return j.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return j.BaseEditor}});const y=K("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return y.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return y.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return y.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return y.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return y.ConditionFilter}});const v=K("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return v.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return v.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return v.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return v.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return v.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return v.OverlayLayer}});const R=K("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return R.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return R.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return R.licenceState}});const O=Object.freeze({createGrid:x,createHeadlessGrid:B,defaults:r,registerModules:w,setLicence:A,version:g,autoInit:X,hydrateTable:$,serialiseState:h,restoreState:a,createLocalViewStorage:V}),F=O});try{Wn("packages/worker/src/inline.js").setWorkerSource('(function(Ot){"use strict";var ct=Object.create(null),lt=Object.create(null);function Ce(o,me){ct[o]=me}function at(o){var me=lt[o];if(me)return me;var ae=Object.create(null);lt[o]=ae;var he=ct[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(ae,at),ae}Ce("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return Se}});const ae="1.89.1";async function he(){return ae}const W="1.89.1",U=new Set,_=2e3;function Z(D){if(U.add(D),U.size>_){const x=U.values().next().value;x!==void 0&&U.delete(x)}}const E=[],z=500;function re(D,x,fe){E.push({key:D,level:x,message:fe.map(p=>typeof p=="string"?p:Y(p)).join(" "),at:Date.now()}),E.length>z&&E.shift()}function Y(D){if(D instanceof Error)return D.message;try{return JSON.stringify(D)}catch{return String(D)}}function se(){return E.map(D=>({...D}))}function te(D){if(D.length===0||typeof D[0]!="string")return D;const x=D[0].replace(/^\\[lattice\\]\\s*/,"");return x===D[0]?D:[x,...D.slice(1)]}function H(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"warn",fe),console.warn("[lattice]",...fe)}function T(D,...x){if(U.has(D))return;Z(D);const fe=te(x);re(D,"info",fe),console.info("[lattice]",...fe)}function V(){U.clear(),E.length=0}function ne(D,x){const fe=new Error(`[lattice] ${D}`);throw x!==void 0&&(fe.cause=x),fe}function R(D,x){D||ne(x)}const j=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(D){return D!==null&&typeof D=="object"&&!Array.isArray(D)}function a(D){return typeof D=="function"}function s(D){return D==null}function h(D){return D==null||D===""}function u(D){return typeof D!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(D))?!0:!!(D.prototype&&Object.getOwnPropertyNames(D.prototype).length>1)}const t=new Map;function l(D){let x=t.get(D);if(x)return x;if(!D.includes("."))x=fe=>fe?.[D];else{const fe=D.split("."),p=fe.length;x=Q=>{let X=Q;for(let ce=0;ce<p;ce++){if(X==null)return;X=X[fe[ce]]}return X}}return t.set(D,x),x}const m=new Map;function e(D){let x=m.get(D);if(x)return x;if(!D.includes("."))x=(fe,p)=>{fe!=null&&(fe[D]=p)};else{const fe=D.split("."),p=fe.length-1;x=(Q,X)=>{let ce=Q;for(let le=0;le<p;le++){if(ce==null)return;const ge=fe[le];ce[ge]==null&&(ce[ge]={}),ce=ce[ge]}ce!=null&&(ce[fe[p]]=X)}}return m.set(D,x),x}function d(D,x){return l(x)(D)}function f(D,x,fe){e(x)(D,fe)}function r(D){return D?(D.includes(".")?D.slice(D.lastIndexOf(".")+1):D).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(/^./,fe=>fe.toUpperCase()):""}const n={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function c(D){const x=D==null?"":String(D);return/[&<>"\']/.test(x)?x.replace(/[&<>"\']/g,fe=>n[fe]):x}function g(D){return String(D).replace(/\\w\\S*/g,x=>x[0].toUpperCase()+x.slice(1).toLowerCase())}function A(D,x,fe){if(D!==void 0)return D===!0?{enabled:!0,...fe}:D===!1?{enabled:!1}:i(D)?D:{[x]:D,enabled:!0}}function P(D){return D==null?[]:Array.isArray(D)?D:[D]}const q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function L(D,x){if(!i(D))return i(x)?{...x}:x;if(!i(x))return x===void 0?D:x;const fe={...D};for(const p of Object.keys(x)){if(q.has(p))continue;const Q=x[p];Q!==void 0&&(fe[p]=i(Q)&&i(fe[p])?L(fe[p],Q):Q)}return fe}function v(D,x){if(!i(D)||!i(x)||D===x)return x;const fe=Object.create(Object.getPrototypeOf(D));return Object.assign(fe,D,x),fe}class G{#t;#e=new Map;#n;constructor(x=256,fe=null){this.#t=x,this.#n=fe}get size(){return this.#e.size}get max(){return this.#t}set max(x){this.#t=x,this.#r()}has(x){return this.#e.has(x)}get(x){const fe=this.#e;if(!fe.has(x))return;const p=fe.get(x);return fe.delete(x),fe.set(x,p),p}peek(x){return this.#e.get(x)}set(x,fe){const p=this.#e;return p.has(x)&&p.delete(x),p.set(x,fe),this.#r(),fe}delete(x){const fe=this.#e.get(x);return this.#e.delete(x)&&this.#n&&this.#n(fe,x),fe}clear(){if(this.#n)for(const[x,fe]of this.#e)this.#n(fe,x);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const x=this.#e;for(;x.size>this.#t;){const fe=x.keys().next().value,p=x.get(fe);x.delete(fe),this.#n&&this.#n(p,fe)}}}const S=new Map;function N(D,x){const fe=`${D||""}|${x?JSON.stringify(x):""}`;let p=S.get(fe);return p||(p=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...x}),S.set(fe,p)),p}function I(D,x){if(D===x)return 0;if(D==null)return 1;if(x==null)return-1;if(typeof D=="number"&&typeof x=="number")return Number.isNaN(D)?Number.isNaN(x)?0:1:Number.isNaN(x)||D<x?-1:D>x?1:0;const fe=String(D),p=String(x);return fe<p?-1:fe>p?1:0}function K(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const B=typeof requestAnimationFrame=="function";function ee(D){return B?requestAnimationFrame(D):setTimeout(()=>D(K()),16)}function J(D){D!=null&&(B?cancelAnimationFrame(D):clearTimeout(D))}function ue(D){let x=null,fe=null;const p=()=>{x=null;const X=fe;fe=null,D(...X||[])},Q=(...X)=>{fe=X,x===null&&(x=ee(p))};return Q.cancel=()=>{J(x),x=null,fe=null},Q.flush=()=>{x!==null&&(J(x),p())},Q}function de(D,x){let fe=null,p=null;const Q=()=>{if(fe=null,p===null)return;const le=p;p=null,D(...le),X()},X=()=>{fe=setTimeout(Q,x),typeof fe?.unref=="function"&&fe.unref()},ce=(...le)=>{fe===null?(D(...le),X()):(p=le,clearTimeout(fe),X())};return ce.flush=()=>{if(fe!==null&&clearTimeout(fe),fe=null,p===null)return;const le=p;p=null,D(...le)},ce.cancel=()=>{fe!==null&&clearTimeout(fe),fe=null,p=null},ce.pending=()=>fe!==null||p!==null,ce}function Oe(D,x=50){return typeof requestIdleCallback=="function"?requestIdleCallback(D,{timeout:x}):setTimeout(()=>D({timeRemaining:()=>0,didTimeout:!0}),1)}let Ae=0;function Se(D="l"){return`${D}${(++Ae).toString(36)}`}}),Ce("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.isFunction,U=1,_=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"}),Z=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),E=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function z(a){if(a==null)return null;const s=a.presence;return{id:a.id,kind:a.kind,nullable:!!a.nullable,values:a.values??null,presence:s?s.words??s:null,presenceBits:s?s.size??(s.words??s).length*8:0,dict:a.dict?re(a.dict):null,offsets:a.offsets??null,version:a.version??0}}function re(a){return Array.isArray(a)?a:W(a.values)?a.values():[]}function Y(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=z(a[h]);return s}class se{#t;#e;constructor(s,h){this.#t=s,this.#e=h}get words(){return this.#t}get size(){return this.#e}get(s){return(this.#t[s>>>3]&1<<(s&7))!==0}count(){const s=this.#t;let h=0;for(let u=0;u<s.length;u++){let t=s[u];for(;t;)t&=t-1,h++}return h}}class te{#t;#e=null;#n=0;#r=new Map;constructor(s){this.#t=s||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(s){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 h=this.#e.get(s);if(h!==void 0)return h;const u=this.#t.length;return this.#t.push(s),this.#e.set(s,u),this.#n++,u}valueOf(s){return this.#t[s]}values(){return this.#t}ranks(s){const h=s||"",u=this.#r.get(h);if(u&&u.version===this.#n)return u.ranks;const t=this.#t.length,l=new Uint32Array(t);for(let r=0;r<t;r++)l[r]=r;const m=he(s).compare,e=this.#t,d=Array.from(l).sort((r,n)=>{const c=e[r],g=e[n];return c===g?0:c==null?1:g==null?-1:m(String(c),String(g))}),f=new Uint32Array(t);for(let r=0;r<d.length;r++)f[d[r]]=r;return this.#r.set(h,{version:this.#n,ranks:f}),f}}function H(a){if(a==null)return null;const s=a.presence?new se(a.presence,a.presenceBits||a.presence.length*8):null,h=a.dict?new te(a.dict):null,u=a.values,t=a.offsets??null,l=a.kind,m=e=>{if(s&&!s.get(e))return null;switch(l){case"dictionary":return h?h.valueOf(u[e]):u[e];case"bitset":return(u[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],f=t[e+1],r=new Array(f-d);for(let n=d;n<f;n++)r[n-d]=h?h.valueOf(u[n]):u[n];return r}default:return u[e]}};return{id:a.id,kind:l,nullable:a.nullable,values:u,presence:s,dict:h,offsets:t,get:m,version:a.version}}function T(a){const s=new Array(a.length);for(let h=0;h<a.length;h++)s[h]=H(a[h]);return s}function V(){const a=[],s=[];return{mask(h){for(let u=0;u<a.length;u++)if(a[u].length>=h){const t=a.splice(u,1)[0].subarray(0,h);return t.fill(0),t}return new Uint8Array(h)},indices(h){for(let u=0;u<s.length;u++)if(s[u].length>=h)return s.splice(u,1)[0].subarray(0,h);return new Uint32Array(h)},release(h){h&&(h instanceof Uint8Array?a.push(h):h instanceof Uint32Array&&s.push(h))},clear(){a.length=0,s.length=0}}}function ne(a){if(!ArrayBuffer.isView(a))return!1;const s=a.buffer;return s?typeof SharedArrayBuffer>"u"||!(s instanceof SharedArrayBuffer):!1}function R(a,s=[]){const h=u=>{if(!ne(u))return;const t=u.buffer;s.includes(t)||s.push(t)};if(a==null)return s;if(ArrayBuffer.isView(a))return h(a),s;if(Array.isArray(a)){for(const u of a)h(u);return s}if(typeof a=="object")for(const u of Object.keys(a)){const t=a[u];if(Array.isArray(t))for(const l of t)h(l);else h(t)}return s}function j(a,s=0){if(a==null)return!0;const h=typeof a;if(h==="function"||h==="symbol")return!1;if(h!=="object"||s>4||ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof Date)return!0;if(Array.isArray(a)){for(const u of a)if(!j(u,s+1))return!1;return!0}for(const u of Object.keys(a))if(!j(a[u],s+1))return!1;return!0}function i(a,s=new Set){if(!a||typeof a!="object")return s;const h=a;typeof h.col=="string"&&s.add(h.col);const u=h.conditions;if(Array.isArray(u))for(const t of u)i(t,s);return s}}),Ce("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const ae=8;class he{static#t=new Uint8Array(256);static{for(let U=1;U<256;U++)he.#t[U]=he.#t[U>>1]+(U&1)}#e;#n;constructor(U=0){const _=Math.max(0,U|0);this.#n=_,this.#e=new Uint8Array(Math.ceil(_/ae))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(U){return U<0||U>=this.#n?0:this.#e[U>>3]>>(U&7)&1}set(U){return U>=0&&U<this.#n&&(this.#e[U>>3]|=1<<(U&7)),this}clear(U){return U>=0&&U<this.#n&&(this.#e[U>>3]&=~(1<<(U&7))),this}assign(U,_){return _?this.set(U):this.clear(U)}fill(U=!1){return this.#e.fill(U?255:0),U&&this.#r(),this}grow(U){const _=Math.max(0,U|0);if(_<=this.#n)return this;const Z=Math.ceil(_/ae);if(Z>this.#e.length){const E=new Uint8Array(Z);E.set(this.#e),this.#e=E}return this.#n=_,this}count(){const U=this.#e,_=he.#t;let Z=0;for(let E=0;E<U.length;E++)Z+=_[U[E]];return Z}and(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]&=_[z];for(let z=E;z<Z.length;z++)Z[z]=0;return this}or(U){const _=U instanceof he?U.words:U,Z=this.#e,E=Math.min(Z.length,_.length);for(let z=0;z<E;z++)Z[z]|=_[z];return this}not(){const U=this.#e;for(let _=0;_<U.length;_++)U[_]=~U[_]&255;return this.#r(),this}clone(){const U=new he(this.#n);return U.words.set(this.#e.subarray(0,U.words.length)),U}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const U=this.#n&7;if(U===0)return;const _=this.#n>>3;_<this.#e.length&&(this.#e[_]&=(1<<U)-1)}static from(U){const _=Array.isArray(U)?U:Array.from(U),Z=new he(_.length);for(let E=0;E<_.length;E++)_[E]&&Z.set(E);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return U}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare;class U{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(Z=[]){this.#t=[];for(let E=0;E<Z.length;E++){const z=Z[E];this.#e.has(z)||(this.#e.set(z,this.#t.length),this.#t.push(z))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let Z=this.#t.length*8;for(let E=0;E<this.#t.length;E++){const z=this.#t[E];typeof z=="string"&&(Z+=z.length*2),Z+=16}return Z}codeOf(Z){const E=this.#e.get(Z);if(E!==void 0)return E;const z=this.#t.length;return this.#t.push(Z),this.#e.set(Z,z),this.#n++,z}lookup(Z){const E=this.#e.get(Z);return E===void 0?-1:E}has(Z){return this.#e.has(Z)}valueOf(Z){return this.#t[Z]}values(){return this.#t}ranks(Z){const E=Z||"";if(this.#r&&this.#i===this.#n&&this.#s===E)return this.#r;const z=this.#t.length,re=new Array(z);for(let H=0;H<z;H++)re[H]=H;const Y=he(Z).compare,se=this.#t;re.sort((H,T)=>this.#h(se[H],se[T],Y));const te=new Uint32Array(z);for(let H=0;H<z;H++)te[re[H]]=H;return this.#r=te,this.#i=this.#n,this.#s=E,te}#h(Z,E,z){return typeof Z=="string"&&typeof E=="string"?z(Z,E):W(Z,E)}}}),Ce("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return ae}});class ae{#t;#e;#n=0;#r=0;constructor(W={}){const U=Math.max(1,W.rows??16),_=Math.max(1,W.values??U);this.#t=new Int32Array(_),this.#e=new Uint32Array(U+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(W){return W<0||W>=this.#n?0:this.#e[W+1]-this.#e[W]}at(W){return W<0||W>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[W],this.#e[W+1])}has(W,U){if(W<0||W>=this.#n)return!1;const _=this.#t,Z=this.#e[W+1];for(let E=this.#e[W];E<Z;E++)if(_[E]===U)return!0;return!1}hasAny(W,U){for(let _=0;_<U.length;_++)if(this.has(W,U[_]))return!0;return!1}hasAll(W,U){for(let _=0;_<U.length;_++)if(!this.has(W,U[_]))return!1;return!0}hasNone(W,U){return!this.hasAny(W,U)}push(W){const U=this.#n,_=W.length;this.#i(U+1),this.#s(this.#r+_);const Z=this.#r;for(let E=0;E<_;E++)this.#t[Z+E]=W[E]|0;return this.#r+=_,this.#n=U+1,this.#e[U]=Z,this.#e[U+1]=this.#r,U}write(W,U){if(W===this.#n){this.push(U);return}if(W<0||W>this.#n)return;const _=this.#e[W],Z=this.#e[W+1],E=U.length;if(Z-_===E){for(let z=0;z<E;z++)this.#t[_+z]=U[z]|0;return}this.#h(W,U)}compact(W,U,_){const Z=this.#t,E=this.#e,z=this.#n,re=new Int32Array(Math.max(1,this.#r)),Y=new Uint32Array(U+1);let se=0;for(let te=0;te<z;te++){if(W[te]===_)continue;const H=E[te],T=E[te+1];Y[W[te]]=se;for(let V=H;V<T;V++)re[se++]=Z[V];Y[W[te]+1]=se}this.#t=re,this.#e=Y,this.#n=U,this.#r=se}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(W){if(W+1<=this.#e.length)return;let U=this.#e.length-1;for(;U<W;)U=U*2||16;const _=new Uint32Array(U+1);_.set(this.#e),this.#e=_}#s(W){if(W<=this.#t.length)return;let U=this.#t.length;for(;U<W;)U=U*2||16;const _=new Int32Array(U);_.set(this.#t),this.#t=_}#h(W,U){const _=this.#t,Z=this.#e,E=this.#n,z=U.length-(Z[W+1]-Z[W]),re=new Int32Array(Math.max(1,this.#r+z)),Y=new Uint32Array(Z.length);let se=0;for(let te=0;te<E;te++){if(Y[te]=se,te===W)for(let H=0;H<U.length;H++)re[se++]=U[H]|0;else for(let H=Z[te];H<Z[te+1];H++)re[se++]=_[H];Y[te+1]=se}this.#t=re,this.#e=Y,this.#r=se}}}),Ce("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return j}});const ae=me("packages/core/src/internal/util.js"),he=ae.collator,W=ae.defaultCompare,U=ae.warnOnce;function _(i){const a=new Uint32Array(i);for(let s=0;s<i;s++)a[s]=s;return a}function Z(i,a){if(a&&typeof a.count=="number")return a.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const s=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):s?i.kind==="bitset"?typeof s.size=="number"?s.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(U(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${s.length*8}`),s.length*8):s.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const E=new WeakMap;function z(i){const a=i.constructor;if(!a)return"unknown";const s=E.get(a);if(s)return s;let h="unknown";try{let u=null;typeof a.from=="function"?u=a.from([!1,!0]):(u=new a(8),u.set(1));const t=u&&u.words;t&&t.length&&(t[0]===2?h="lsb":t[0]===64&&(h="msb"))}catch{h="unknown"}return E.set(a,h),h}function re(i){if(!i)return()=>0;const a=i instanceof Uint8Array?i:i.words;if(a instanceof Uint8Array){const s=i instanceof Uint8Array?"lsb":z(i);if(s==="lsb")return h=>a[h>>>3]>>>(h&7)&1;if(s==="msb")return h=>a[h>>>3]>>>7-(h&7)&1}return typeof i.get=="function"?s=>i.get(s)?1:0:()=>0}function Y(i){return!i||!i.presence?null:re(i.presence)}function se(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function te(i,a){return i?typeof i.valueOf=="function"?i.valueOf(a):typeof i.values=="function"?i.values()[a]:null:null}function H(i,a){const s=i.offsets,h=i.values;if(!s||!h)return[];const u=s[a],t=s[a+1];if(!(t>u))return[];const l=i.dict,m=new Array(t-u);for(let e=u;e<t;e++)m[e-u]=l?te(l,h[e]):h[e];return m}function T(i){if(!i)return()=>{};const a=i.values,s=Y(i),h=i.kind;if(h==="dictionary"){const u=i.dict;return s?t=>s(t)?te(u,a[t]):null:t=>te(u,a[t])}if(h==="bitset"){const u=re(a);return s?t=>s(t)?u(t)===1:null:t=>u(t)===1}if(h==="multi")return s?u=>s(u)?H(i,u):null:u=>H(i,u);if(!a&&typeof i.get=="function"){const u=i.get.bind(i);return t=>{const l=u(t);return l===void 0?null:l}}return s?u=>{if(!s(u))return null;const t=a[u];return t===void 0?null:t}:u=>{const t=a[u];return t===void 0?null:t}}function V(i,a){if(i<a)return-1;if(i>a)return 1;if(i===a){const u=Object.is(i,-0),t=Object.is(a,-0);return u===t?0:u?-1:1}const s=Number.isNaN(i),h=Number.isNaN(a);return s&&h?0:s?1:-1}function ne(i){const a=he(i);return(s,h)=>{if(s===h)return 0;const u=typeof s,t=typeof h;if(u==="string"&&t==="string")return a.compare(s,h);if(u==="number"&&t==="number")return V(s,h);if(u==="boolean"&&t==="boolean")return s===h?0:s?1:-1;if(s instanceof Date||h instanceof Date){const l=s instanceof Date?s.getTime():Number(s),m=h instanceof Date?h.getTime():Number(h);return V(l,m)}return W(s,h)}}function R(i,a){if(i&&typeof i.ranks=="function")return i.ranks(a);const s=i&&typeof i.values=="function"?i.values():[],h=s.length,u=ne(a),t=new Array(h);for(let m=0;m<h;m++)t[m]=m;t.sort((m,e)=>u(s[m],s[e])||m-e);const l=new Uint32Array(h);for(let m=0;m<h;m++)l[t[m]]=m;return l}function j(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Ce("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return v}});const ae=me("packages/core/src/compute/handle.js"),he=ae.bitReader,W=ae.dictRanks,U=ae.dictSize,_=ae.identity,Z=ae.isMissing,E=ae.presenceReader,z=ae.rowCount,re=ae.valueComparator,Y=ae.valueReader,se=new Uint32Array(0),te=new ArrayBuffer(8),H=new Float64Array(te),T=new Uint32Array(te),V=(H[0]=-1,(T[1]&2147483648)!==0?1:0),ne=V===1?0:1;function R(S,N){H[0]=S;let I=T[V],K=T[ne];(I&2147483648)!==0?(I=~I>>>0,K=~K>>>0):I=(I^2147483648)>>>0,N[0]=K,N[1]=I}function j(S,N,I,K){if(K<2)return S;const B=new Uint32Array(256*8);for(let D=0;D<K;D++){const x=N[D],fe=I[D];B[x&255]++,B[256+(x>>>8&255)]++,B[512+(x>>>16&255)]++,B[768+(x>>>24&255)]++,B[1024+(fe&255)]++,B[1280+(fe>>>8&255)]++,B[1536+(fe>>>16&255)]++,B[1792+(fe>>>24&255)]++}let ee=S,J=N,ue=I,de=new Uint32Array(K),Oe=new Uint32Array(K),Ae=new Uint32Array(K);const Se=new Uint32Array(256);for(let D=0;D<8;D++){const x=D<<8,fe=(D&3)<<3,p=D>=4;let Q=!1;for(let le=0;le<256;le++)if(B[x+le]===K){Q=!0;break}if(Q)continue;let X=0;for(let le=0;le<256;le++)Se[le]=X,X+=B[x+le];for(let le=0;le<K;le++){const ge=J[le],Me=ue[le],be=(p?Me:ge)>>>fe&255,ye=Se[be]++;de[ye]=ee[le],Oe[ye]=ge,Ae[ye]=Me}let ce=ee;ee=de,de=ce,ce=J,J=Oe,Oe=ce,ce=ue,ue=Ae,Ae=ce}return ee}function i(S,N,I){if(I<2)return S;const K=new Uint32Array(256*4);for(let Oe=0;Oe<I;Oe++){const Ae=N[Oe];K[Ae&255]++,K[256+(Ae>>>8&255)]++,K[512+(Ae>>>16&255)]++,K[768+(Ae>>>24&255)]++}let B=S,ee=N,J=new Uint32Array(I),ue=new Uint32Array(I);const de=new Uint32Array(256);for(let Oe=0;Oe<4;Oe++){const Ae=Oe<<8,Se=Oe<<3;let D=!1;for(let p=0;p<256;p++)if(K[Ae+p]===I){D=!0;break}if(D)continue;let x=0;for(let p=0;p<256;p++)de[p]=x,x+=K[Ae+p];for(let p=0;p<I;p++){const Q=ee[p],X=de[Q>>>Se&255]++;J[X]=B[p],ue[X]=Q}let fe=B;B=J,J=fe,fe=ee,ee=ue,ue=fe}return B}function a(S,N,I,K){const B=new Uint32Array(K+1);for(let ue=0;ue<I;ue++)B[N[ue]]++;let ee=0;for(let ue=0;ue<=K;ue++){const de=B[ue];B[ue]=ee,ee+=de}const J=new Uint32Array(I);for(let ue=0;ue<I;ue++)J[B[N[ue]]++]=S[ue];return J}function s(S,N,I,K){return I<2?S:K<=65536||K<=I*2?a(S,N,I,K):i(S,N,I)}function h(S,N){return S.length===N&&S.byteOffset===0?S:Uint32Array.prototype.slice.call(S,0,N)}function u(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=new Uint32Array(B),J=new Uint32Array(B),ue=new Uint32Array(B),de=new Uint32Array(B),Oe=new Uint32Array(2);let Ae=0,Se=0;for(let fe=0;fe<B;fe++){const p=K[fe],Q=S[p];if(Number.isNaN(Q)){de[Se++]=p;continue}R(Q,Oe),I?(J[Ae]=~Oe[0]>>>0,ue[Ae]=~Oe[1]>>>0):(J[Ae]=Oe[0],ue[Ae]=Oe[1]),ee[Ae++]=p}const D=j(ee.subarray(0,Ae),J.subarray(0,Ae),ue.subarray(0,Ae),Ae);if(Se===0)return h(D,Ae);const x=new Uint32Array(B);return x.set(D.subarray(0,Ae),0),x.set(de.subarray(0,Se),Ae),x}function t(S,N,I=!1){const K=N||_(S.length),B=K.length;if(B<2)return Uint32Array.from(K);const ee=Uint32Array.from(K),J=new Uint32Array(B);for(let ue=0;ue<B;ue++){const de=(S[ee[ue]]^2147483648)>>>0;J[ue]=I?~de>>>0:de}return h(i(ee,J,B),B)}function l(S,N,I={}){const K=N||_(z(S,I)),B=K.length;if(B<2)return Uint32Array.from(K);const ee=W(S.dict,I.locale),J=S.values,ue=E(S),de=Math.max(U(S.dict),ee.length),Oe=de,Ae=Uint32Array.from(K),Se=new Uint32Array(B),D=!!I.descending;for(let x=0;x<B;x++){const fe=Ae[x];let p=ue&&ue(fe)===0?Oe:ee[J[fe]];p===void 0&&(p=Oe),Se[x]=D?Oe-p:p}return h(s(Ae,Se,B,de+1),B)}function m(S,N,I){const K=N.length;let B=Uint32Array.from(N);if(K<2)return B;let ee=new Uint32Array(K);for(let J=1;J<K;J<<=1){for(let de=0;de<K;de+=J<<1){const Oe=Math.min(de+J,K),Ae=Math.min(de+(J<<1),K);let Se=de,D=Oe,x=de;for(;Se<Oe&&D<Ae;)ee[x++]=I(S[B[Se]],S[B[D]])<=0?B[Se++]:B[D++];for(;Se<Oe;)ee[x++]=B[Se++];for(;D<Ae;)ee[x++]=B[D++]}const ue=B;B=ee,ee=ue}return B}function e(S,N,I){const K=he(S.values),B=N.length,ee=new Uint32Array(B),J=I?1:0;let ue=0;for(let de=0;de<B;de++)K(N[de])===J&&(ee[ue++]=N[de]);for(let de=0;de<B;de++)K(N[de])!==J&&(ee[ue++]=N[de]);return ee}function d(S,N){const I=S.values,K=S.kind;if((K==="object"||K===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!S.presence)return I;const ee=Y(S),J=new Array(z(S)||0);for(let ue=0;ue<N.length;ue++){const de=N[ue];J[de]=ee(de)}return J}function f(S,N){for(let I=0;I<N.length;I++)if(typeof S[N[I]]!="string")return!1;return!0}function r(S,N,I,K,B){const ee=S.length,J=Uint32Array.from(S);if(ee<2||K<1)return J;const ue=new Uint32Array(ee),de=K-1;for(let Oe=0;Oe<ee;Oe++){const Ae=I[N[Oe]];ue[Oe]=B?de-Ae:Ae}return h(s(J,ue,ee,K),ee)}function n(S,N,I){const K=re(I),B=new Array(N);for(let J=0;J<N;J++)B[J]=J;B.sort((J,ue)=>K(S[J],S[ue])||J-ue);const ee=new Uint32Array(N);for(let J=0;J<N;J++)ee[B[J]]=J;return ee}function c(S,N,I){const K=N.length,B=new Map,ee=[],J=new Uint32Array(K);for(let Oe=0;Oe<K;Oe++){const Ae=S[N[Oe]];let Se=B.get(Ae);Se===void 0&&(Se=ee.length,B.set(Ae,Se),ee.push(Ae)),J[Oe]=Se}const ue=ee.length,de=n(ee,ue,I.locale);return r(N,J,de,ue,!!I.descending)}function g(S,N,I){const K=d(S,N);if(N.length>=2&&f(K,N)){const J=S.stringRank;return J&&J.version===S.version&&J.usable(N,K,I.locale)?J.sort(N,I):c(K,N,I)}const B=re(I.locale),ee=I.descending?(J,ue)=>B(ue,J):B;return m(K,N,ee)}function A(S,N,I){const K=d(S,N),B=I.compare,J=!!I.descending?(ue,de)=>-B(ue,de,void 0,void 0,!0):(ue,de)=>B(ue,de,void 0,void 0,!1);return m(K,N,J)}function P(S,N){const I=N.length,K=E(S),B=S.values,ee=S.kind==="float64"&&!!B,J=S.kind==="object"||S.kind==="multi"||S.kind===void 0;if(!K&&!ee&&!J)return{present:N,absent:se};const ue=new Uint32Array(I),de=new Uint32Array(I);let Oe=0,Ae=0;if(K&&ee)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1&&!Number.isNaN(B[D])?ue[Oe++]=D:de[Ae++]=D}else if(ee&&!K)for(let Se=0;Se<I;Se++){const D=N[Se];Number.isNaN(B[D])?de[Ae++]=D:ue[Oe++]=D}else if(K&&!J)for(let Se=0;Se<I;Se++){const D=N[Se];K(D)===1?ue[Oe++]=D:de[Ae++]=D}else{const Se=Y(S);for(let D=0;D<I;D++){const x=N[D];Z(Se(x))?de[Ae++]=x:ue[Oe++]=x}}return Ae===0?{present:N,absent:se}:{present:ue.subarray(0,Oe),absent:de.subarray(0,Ae)}}function q(S,N,I){if(N.length===0)return S;const K=new Uint32Array(S.length+N.length);return I?(K.set(N,0),K.set(S,N.length)):(K.set(S,0),K.set(N,S.length)),K}function L(S,N,I={}){const K=N||_(z(S,I));if(!S||K.length<2)return Uint32Array.from(K);const{present:B,absent:ee}=P(S,K);if(B.length===0)return Uint32Array.from(K);const J=!!I.descending;let ue;if(typeof I.compare=="function")ue=A(S,B,I);else switch(S.kind){case"float64":ue=u(S.values,B,J);break;case"int32":ue=t(S.values,B,J);break;case"dictionary":ue=l(S,B,I);break;case"bitset":ue=e(S,B,J);break;default:ue=g(S,B,I);break}return q(ue,ee,!!I.nullsFirst)}function v(S,N,I,K={}){const B=N||[],ee=B.length&&(B[0].handle||G(S,B[0].col))||S&&S[0];let J=I||_(z(ee,K));for(let ue=B.length-1;ue>=0;ue--){const de=B[ue],Oe=de.handle||G(S,de.col)||S&&S[ue];Oe&&(J=L(Oe,J,{descending:de.descending!==void 0?!!de.descending:de.dir==="desc",nullsFirst:!!de.nullsFirst,locale:de.locale!==void 0?de.locale:K.locale,compare:de.compare}))}return J instanceof Uint32Array?J:Uint32Array.from(J)}function G(S,N){if(!(!S||N===void 0)){for(let I=0;I<S.length;I++)if(S[I]&&S[I].id===N)return S[I]}}}),Ce("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return _}});const ae=me("packages/core/src/compute/sort.js"),he=ae.collateStringRanks,W=ae.rankSortStrings,U=1e5;class _{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(E=U){this.#h=E>0?E:U,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(E){this.#s=E}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let E=this.#n.byteLength;const z=this.#t;for(let re=0;re<z.length;re++)E+=z[re].length*2+24;return E}#a(E,z){const re=this.#e.get(E);if(re!==void 0)return re;if(this.#u)return-1;if(z&&this.#t.length>=this.#h)return this.#u=!0,-1;const Y=this.#t.length;return this.#t.push(E),this.#e.set(E,Y),this.#i++,Y}build(E,z){const re=z|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let Y=0;Y<re;Y++){const se=E[Y],te=typeof se=="string"?this.#a(se,!1):-1;this.#n[Y]=te<0?0:te}this.#r=re}append(E,z,re){const Y=(z|0)+(re|0);if(Y>this.#n.length){const se=new Uint32Array(Y);se.set(this.#n.subarray(0,this.#r)),this.#n=se}for(let se=z|0;se<Y;se++){const te=E[se],H=typeof te=="string"?this.#a(te,!0):-1;this.#n[se]=H<0?0:H}this.#r=Math.max(this.#r,Y)}ranks(E){const z=E||"";if(this.#o&&this.#c===this.#i&&this.#l===z)return this.#o;const re=he(this.#t,this.#t.length,E);return this.#o=re,this.#c=this.#i,this.#l=z,re}usable(E,z,re){if(this.#u||this.#t.length===0)return!1;const Y=this.#n,se=this.#t,te=this.#r;for(let H=0;H<E.length;H++){const T=E[H];if(T>=te||se[Y[T]]!==z[T])return!1}return!0}sort(E,z){const re=this.ranks(z.locale),Y=this.#t.length,se=E.length,te=new Uint32Array(se),H=this.#n;for(let T=0;T<se;T++)te[T]=H[E[T]];return W(E,te,re,Y,!!z.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return H}}),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 l}});const ae=me("packages/core/src/internal/util.js"),he=ae.warnOnce,W=ae.isFunction,U=ae.pathGetter,Z=me("packages/core/src/store/bitset.js").Bitset,z=me("packages/core/src/store/dictionary.js").Dictionary,Y=me("packages/core/src/store/multivalue.js").MultiValue,te=me("packages/core/src/store/stringrank.js").StringRankIndex,H=4294967295,T=1024,V=5e3,ne=.2,R=new Set(["float64","int32","bitset","dictionary","object","multi"]);function j(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function a(m){const e=i(m);return Number.isFinite(e)?e|0:0}function s(m){return j(m)?[]:Array.isArray(m)?m:[m]}function h(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=m.dict.valueOf(d[r]);return f}default:return m.buf[e]}}function u(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],f=m.offsets[e+1],r=m.table||[],n=new Array(f-d);for(let c=d;c<f;c++)n[c-d]=r[m.values[c]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const f=R.has(e.kind)?e.kind:"object";e.kind&&!R.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=f,this.#e=f,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=W(e.read)?e.read:U(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const f=new te(this.#S());return f.build(e,d),f.version=this.#f,this.#d=f,this.#k=this.#f,f.capped?null:f}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),f=new Array(d.length);for(let r=0;r<d.length;r++)f[r]=this.#a.valueOf(d[r]);return f}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,f){if(this.#g||f<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,c=this.#m;let g=!1;switch(this.#e){case"float64":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]);if(typeof q=="number"){n&&c.set(d+P),A[d+P]=q;continue}const L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?NaN:i(q)}break}case"int32":{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?0:a(q)}break}case"bitset":{const A=this.#c;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A.assign(d+P,!L&&!!q)}break}case"dictionary":{const A=this.#o,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0),A[d+q]=v?0:P.codeOf(L)}break}case"multi":{const A=this.#l,P=this.#a;for(let q=0;q<f;q++){const L=r(e[q]),v=L==null;n?c.assign(d+q,!v):v&&(g=!0);const G=s(L),S=new Array(G.length);for(let N=0;N<G.length;N++)S[N]=P.codeOf(G[N]);A.write(d+q,S)}break}default:{const A=this.#o;for(let P=0;P<f;P++){const q=r(e[P]),L=q==null;n?c.assign(d+P,!L):L&&(g=!0),A[d+P]=L?null:q}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,f),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,f){if(this.#g||f<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<f;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<f;g++)r.set(d+g);const c=e.kind===this.#e;if(c&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(c&&this.#e==="bitset"){const g=e.values;for(let A=0;A<f;A++)this.#c.assign(d+A,(g[A>>3]&1<<(A&7))!==0);this.#f++;return}if(c&&this.#e==="dictionary"){const g=e.table||[],A=new Uint32Array(g.length);for(let v=0;v<g.length;v++)A[v]=this.#a.codeOf(g[v]);const P=e.values,q=this.#o,L=r;for(let v=0;v<f;v++){if(L&&(n&&(n[v>>3]&1<<(v&7))===0)){q[d+v]=0;continue}q[d+v]=A[P[v]]??0}this.#f++;return}if(c&&this.#e==="multi"){const g=e.table||[],A=new Uint32Array(g.length);for(let L=0;L<g.length;L++)A[L]=this.#a.codeOf(g[L]);const P=e.values,q=e.offsets;for(let L=0;L<f;L++){const v=q[L],G=q[L+1],S=new Array(G-v);for(let N=v;N<G;N++)S[N-v]=A[P[N]]??0;this.#l.write(d+L,S)}this.#f++;return}for(let g=0;g<f;g++){const A=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,A?null:u(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const f=new Array(d);for(let r=0;r<d;r++)f[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,f[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!R.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},f=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<f;n++){const c=r!==null&&r.get(n)===0;c&&e!=="multi"||this.#A(n,c?null:h(d,n))}return this.#j(),this.#f++,!0}compact(e,d,f){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[c,g]of r)e[c]!==H&&n.set(e[c],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==H&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=f;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,f,H);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==H&&r.assign(e[n],r.get(n)===1);for(let n=f;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new Z(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new z(this.#h??[]);break;case"multi":this.#l=new Y({rows:d,values:d}),this.#a=this.#a??new z(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new Z(d)),this.#p=d}#A(e,d){const f=j(d);switch(this.#r?this.#m.assign(e,!f):f&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=f?NaN:i(d);break;case"int32":this.#o[e]=f?0:a(d);break;case"bitset":this.#c.assign(e,!f&&!!d);break;case"dictionary":this.#o[e]=f?0:this.#a.codeOf(d);break;case"multi":{const r=s(d),n=new Array(r.length);for(let c=0;c<r.length;c++)n[c]=this.#a.codeOf(r[c]);this.#l.write(e,n);break}default:this.#o[e]=f?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),f=this.#r?new Z(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,f&&!j(n)&&f.set(r)}return this.#O={version:this.#f,values:d,presence:f},this.#O}}class l{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new Z(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??T),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??V:0,this.#w=d.compactRatio??ne;const f={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,f);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const f=e.length|0;if(f===0)return{from:d,to:d};if(this.#l)for(let n=0;n<f;n++)this.#r[d+n]=e[n];if(this.#i=d+f,this.#h+=f,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,f);return{from:d,to:this.#i}}appendPacked(e,d){const f=this.#i;if(this.#b||!e)return{from:f,to:f};const r=e.count|0;if(r===0)return{from:f,to:f};if(this.#l&&d)for(let c=0;c<r;c++)this.#r[f+c]=d[c];this.#i=f+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const c of e.columns)n.set(c.id,c);for(const c of this.#n){const g=n.get(c.id);g?c.appendPacked(g,f,r):c.grow(this.#s)}return{from:f,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const f=this.#e.get(e);return f?f.get(d):void 0}set(e,d,f){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,f)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,f=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)f[n]=this.#o.get(n)===1?H:r++;for(const n of this.#n)n.compact(f,d,r);if(this.#l){const n=this.#r;for(let c=0;c<d;c++)f[c]!==H&&(n[f[c]]=n[c]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new Z(Math.max(this.#s,r)),f}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 f=0;f<this.#i;f++)e[f]=f;return e}let d=0;for(let f=0;f<this.#i;f++)this.#o.get(f)===0&&(e[d++]=f);return e}convert(e,d){const f=this.#e.get(e);return f?f.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const f of this.#n)f.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const f of this.#n)d[f.id]=f.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Ce("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.now,W=ae.nextFrame,U=ae.infoOnce,_=ae.warnOnce,Z=ae.isFunction,E=ae.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,Y=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function se(j,i={}){if(i.multi)return"multi";if(j.length===0)return"object";let a=0,s=0,h=0,u=0,t=0;for(let m=0;m<j.length;m++){const e=j[m];typeof e=="number"?a++:typeof e=="boolean"?s++:typeof e=="string"?h++:e instanceof Date?u++:Array.isArray(e)&&t++}const l=j.length;return a===l?"float64":s===l?"bitset":u===l?"float64":h===l?"text":t===l?"multi":"object"}function te(j,i,a){return i<=0||j<a*i?"dictionary":"object"}function H(j,i,a){const s=new Map,h=new Map;for(const c of j){if(c.computed)continue;const g=Z(c.read)?c.read:E(c.field||c.id);h.set(c.id,g),s.set(c.id,g)}const u=i?.order??[],t=i?.fns??{},l=i?.deps??{},m=i?.wrapDeps??null,e=u.filter(c=>Z(t[c])),d=e.some(c=>l[c]==="*");let f=new WeakMap;const r=c=>{const g={};if(d)for(const[A,P]of h)g[A]=P(c);for(const A of e){const P=l[A];let q;if(P==="*")q=g;else{q={};const L=P||[];for(let v=0;v<L.length;v++){const G=L[v];q[G]=G in g?g[G]:h.get(G)?.(c)}}g[A]=t[A](m?m(q,A):q,{data:c,row:null,column:null,grid:null,context:a})}return g},n=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return r(c);let g=f.get(c);return g===void 0&&(g=r(c),f.set(c,g)),g};for(const c of e)s.set(c,g=>n(g)[c]);return{readers:s,reset(){f=new WeakMap}}}class T{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,a){this.spec=i,this.read=a,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class V{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,a={},s={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...Y,...s};const h=a.columns??[];this.#r=H(h,a.computed??null,a.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(h,a.computed??null),this.#n=new re(this.#e.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:a,chunkRows:s}=this.#s,h=this.#t.length;do{const u=Math.min(this.#i+s,h);this.#n.append(this.#t.slice(this.#i,u)),this.#a(this.#i,u),this.#i=u,this.#r.reset(),this.#w(!1)}while(this.#i<h&&he()-i<a);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:h}),this.#i>=h?(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,a){const s=this.#t,h=Math.min(this.#s.sampleSize,s.length),u=this.#s.dictionaryRatio,t=a?.pure instanceof Set?a.pure:new Set(a?.pure??a?.order??[]);for(const l of i){if(!l||!l.id)continue;if(l.computed&&(l.pure===!1||a&&!t.has(l.id))){_(`ingest.impure.${l.id}`,`column "${l.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(l.id)??(Z(l.read)?l.read:E(l.field||l.id)),e=new T(l,m);if(l.kind)e.kind=l.kind,e.reason="declared by the caller";else if(l.dictionary)e.kind=l.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<h&&d.length<this.#s.sampleSize;r++){const n=m(s[r]);n!=null&&d.push(n)}e.inferred=!0;const f=se(d,{multi:l.multi});if(f==="text"){const r=new Set(d).size;e.kind=te(r,d.length,u),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=f,e.reason=`inferred from ${d.length} sampled values`,f==="object"&&d.length&&U(`ingest.mixed.${l.id}`,`column "${l.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,a){const s=this.#t;for(const h of this.#e){if(!h.candidate||!h.distinct)continue;const u=h.distinct;for(let t=i;t<a;t++){const l=h.read(s[t]);l!=null&&u.add(l)}}}#d(i){if(i.distinct)return i.distinct.size;const a=this.#n.column(i.spec.id);return a?.dict?a.dict.size:0}#w(i){const a=this.#s.dictionaryRatio,s=this.#t.length;for(const h of this.#e){if(!h.candidate)continue;const u=this.#d(h);if(h.kind==="dictionary"&&u>=a*s){const t=this.#n.column(h.spec.id);h.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(h.spec.id,"object"),h.kind="object",h.change="demoted",h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}if(h.kind==="object"&&u>=a*s){h.candidate=!1,h.distinct=null,h.reason=`${u} distinct values is at or above ${a*100}% of ${s} rows`;continue}i&&h.kind==="object"&&u<a*s&&(this.#n.convert(h.spec.id,"dictionary"),h.kind="dictionary",h.change=h.change==="demoted"?null:"promoted",h.reason=`${u} distinct values is below ${a*100}% of ${s} rows`,h.distinct=null),i&&(h.candidate=!1)}}}async function ne(j,i={},a={}){const s=new V(j,i,a),h=a.scheduler?.frame??W;for(;s.slice();)await new Promise(u=>{h(u)});return s.result()}function R(j,i={},a={}){const s=new V(j,i,{...a,chunkMs:1/0});for(;s.slice(););return s.result()}}),Ce("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return V}});const he=me("packages/core/src/internal/util.js").pathGetter,W=me("packages/core/src/store/ingest.js"),U=W.inferKind,_=W.decideText,Z=W.INGEST_DEFAULTS,z=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function Y(ne){if(!Array.isArray(ne)||ne.length===0)return!1;for(const R of ne)if(!R||typeof R.id!="string"||typeof R.field!="string"||R.field===""||R.kind&&!re.has(R.kind))return!1;return!0}function se(ne){const R=z(ne);return Number.isFinite(R)?R|0:0}function te(ne){return ne==null?[]:Array.isArray(ne)?ne:[ne]}function H(ne,R,j,i){if(ne.kind)return ne.kind;const a=[];for(let u=0;u<R.length&&a.length<Z.sampleSize;u++){const t=R[u];t!=null&&a.push(t)}const s=U(a,{multi:ne.multi});if(s!=="text")return s;const h=new Set(a).size;return _(h,a.length,i)}function T(ne,R,j={}){const i=R.length|0,a=j.dictionaryRatio??Z.dictionaryRatio,s=[];for(const h of ne){const u=he(h.field||h.id),t=h.nullable!==!1,l=new Array(i);for(let r=0;r<i;r++){const n=u(R[r]);l[r]=n===void 0?null:n}const m=H(h,l,i,a),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let f;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?NaN:z(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),r[n]=g?0:se(c)}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const c=l[n],g=c===null;g||d(n),!g&&c&&(r[n>>3]|=1<<(n&7))}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],c=new Map;for(let g=0;g<i;g++){const A=l[g];if(A===null){r[g]=0;continue}d(g);let P=c.get(A);P===void 0&&(P=n.length,n.push(A),c.set(A,P)),r[g]=P}f={id:h.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,c=new Uint32Array(i+1),g=[];for(let A=0;A<i;A++){const P=l[A];c[A]=g.length,P===null||d(A);const L=te(P);for(let v=0;v<L.length;v++){const G=L[v];let S=n.get(G);S===void 0&&(S=r.length,r.push(G),n.set(G,S)),g.push(S)}}c[i]=g.length,f={id:h.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:c,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const c=l[n];c!==null&&d(n),r[n]=c}f={id:h.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}s.push(f)}return{count:i,columns:s}}function V(ne){const R=[];if(!ne||!Array.isArray(ne.columns))return R;const j=i=>{ArrayBuffer.isView(i)&&i.buffer&&!R.includes(i.buffer)&&R.push(i.buffer)};for(const i of ne.columns)j(i.values),j(i.presence),j(i.offsets);return R}}),Ce("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return _}});function ae(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function he(Z){return!!Z&&typeof Z.compare!="function"}function W(Z){if(!Z)return!0;for(let E=0;E<Z.length;E++)if(!he(Z[E]))return!1;return!0}function U(Z,E){const z=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,re=Z.locale!==void 0?Z.locale:E;return{col:z,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:ae(re)}}function _(Z,E){const z=Z||[],re=new Array(z.length);for(let Y=0;Y<z.length;Y++)re[Y]=U(z[Y],E);return re}}),Ce("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return R}});const ae=me("packages/core/src/internal/util.js"),he=ae.isNil,W=ae.warnOnce,U=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function _(j){const i=[];let a=0,s="";const h=()=>{s&&(i.push({token:null,text:s}),s="")};for(;a<j.length;){const u=j[a];if(u==="\'"){if(j[a+1]==="\'"){s+="\'",a+=2;continue}const l=j.indexOf("\'",a+1);if(l===-1){s+=j.slice(a+1),a=j.length;continue}s+=j.slice(a+1,l),a=l+1;continue}const t=U.find(l=>j.startsWith(l,a));if(t){h(),i.push({token:t,text:t}),a+=t.length;continue}/[A-Za-z]/.test(u)&&W(`date.pattern.token:${u}`,`the date pattern "${j}" contains \'${u}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${U.join(" ")}.`),s+=u,a+=1}return h(),i}const Z=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function E(j){if(he(j)||j==="")return null;if(j instanceof Date)return Number.isNaN(j.getTime())?null:j;if(typeof j=="number")return Number.isNaN(j)?null:new Date(j);if(typeof j=="string"){const i=Z.exec(j.trim());if(i){const[,s,h,u,t="0",l="0",m="0"]=i;return new Date(+s,+h-1,+u,+t,+l,+m)}const a=new Date(j);return Number.isNaN(a.getTime())?null:a}return null}function z(j,i){return String(j).padStart(i,"0")}function re(j){if(!j)return s=>({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate(),hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),ms:s.getMilliseconds(),weekday:s.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:j,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),a={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return s=>{const h={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:s.getMilliseconds(),weekday:0};for(const u of i.formatToParts(s))switch(u.type){case"year":h.year=Number(u.value);break;case"month":h.month=Number(u.value);break;case"day":h.day=Number(u.value);break;case"hour":h.hour=Number(u.value)%24;break;case"minute":h.minute=Number(u.value);break;case"second":h.second=Number(u.value);break;case"weekday":h.weekday=a[u.value]??0;break;default:break}return h}}function Y(j,i,a){const s=_(j),h=re(a),u=new Set(s.filter(d=>d.token).map(d=>d.token)),t=u.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:a}):null,l=u.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:a}):null,m=u.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:a}):null,e=u.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:a}):null;return d=>{const f=h(d);let r="";for(const n of s){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=z(f.year,4);break;case"yy":r+=z(f.year%100,2);break;case"MMMM":r+=l.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=z(f.month,2);break;case"M":r+=String(f.month);break;case"dd":r+=z(f.day,2);break;case"d":r+=String(f.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=z(f.hour,2);break;case"H":r+=String(f.hour);break;case"hh":r+=z(f.hour%12===0?12:f.hour%12,2);break;case"h":r+=String(f.hour%12===0?12:f.hour%12);break;case"mm":r+=z(f.minute,2);break;case"m":r+=String(f.minute);break;case"ss":r+=z(f.second,2);break;case"s":r+=String(f.second);break;case"SSS":r+=z(f.ms,3);break;case"a":r+=f.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const se=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function te(j,i){const a=j||{},s=a.locale||i||void 0,h=a.nullDisplay??"",u=a.timeZone;let t;if(a.pattern)t=Y(a.pattern,s,u);else if(a.dateStyle||a.timeStyle){const f={timeZone:u};a.dateStyle&&(f.dateStyle=a.dateStyle),a.timeStyle&&(f.timeStyle=a.timeStyle);const r=new Intl.DateTimeFormat(s,f);t=n=>r.format(n)}else{const f=new Intl.DateTimeFormat(s,{dateStyle:"medium",timeZone:u});t=r=>f.format(r)}const l=a.relative?new Intl.RelativeTimeFormat(s,{numeric:"auto"}):null,e=(typeof a.relative=="object"&&a.relative?a.relative.threshold??7:7)*24*36e5,d=(f,r)=>{const n=E(f);if(!n)return h;if(l){const c=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-c;if(Math.abs(g)<e){for(const[A,P]of se)if(Math.abs(g)>=P||A==="second")return l.format(Math.round(g/P),A)}}return t(n)};return d.spec=a,d}function H(j){if(he(j)||j==="")return null;if(typeof j=="string"){const s=/^(\\d{4}-\\d{2}-\\d{2})/.exec(j.trim());if(s)return s[1];const h=E(j);return h?H(h):null}const i=E(j);if(!i)return null;const a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}`}function T(j,i){if(he(j)||j==="")return null;if(typeof j=="string"){const s=j.trim();if(V.test(s)){const t=E(s);return t?ne(t,i):null}const h=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(s);if(h){const[,t,l,m,e]=h;return`${t}T${l}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(s))return`${s}T00:00`;const u=E(s);return u?T(u):null}const a=E(j);return a?ne(a,i):null}const V=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function ne(j,i){const a=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(j).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),l=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${l}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const s=`${j.getFullYear()}-${a(j.getMonth()+1)}-${a(j.getDate())}`,h=j.getSeconds(),u=`${a(j.getHours())}:${a(j.getMinutes())}${h?`:${a(h)}`:""}`;return`${s}T${u}`}function R(j,i){const a=he(j)||j===""?null:String(j),s=he(i)||i===""?null:String(i);return a===null?s===null?0:1:s===null||a<s?-1:a>s?1:0}}),Ce("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"wallMs",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return fe}});const ae=me("packages/core/src/internal/util.js"),he=ae.isBlank,W=ae.toArray,U=ae.warnOnce,_=me("packages/core/src/format/date.js"),Z=_.toDate,E=_.toIsoDate,z=me("packages/core/src/compute/handle.js"),re=z.bitReader,Y=z.dictSize,se=z.dictValue,te=z.presenceReader,H=z.valueComparator,T=z.valueReader,V=/^\\d{4}-\\d{2}-\\d{2}$/,ne="\\0null\\0";function R(p,Q){const X=p&&p.pool;if(X){const ce=X.mask||X.acquireMask||X.acquire||X.take;if(typeof ce=="function"){const le=ce.call(X,Q);if(le&&le.length>=Q)return le}}return new Uint8Array(Q)}function j(p,Q){const X=p&&p.pool;if(!X||!Q)return;const ce=X.release||X.releaseMask||X.free||X.recycle;typeof ce=="function"&&ce.call(X,Q)}function i(p,Q,X){return p.fill(X,0,Q),p}function a(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,Q){if(p==null)return p;if(Q==="number")return typeof p=="number"?p:Number(p);if(Q==="date"||Q==="dateString"){const X=E(p);return X===null?h(p):X}return Q==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function h(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function u(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function t(p,Q){const X=typeof p=="string"?p:String(p);return Q?X:X.toLowerCase()}function l(p,Q){return p==null?ne:typeof p=="string"?Q?p:p.toLowerCase():p instanceof Date?p.getTime():p}function m(p,Q,X){const ce=new Set;for(const le of W(p)){const ge=s(le,X);ce.add(l(ge,Q)),typeof ge=="string"&&ge!==""&&Number.isFinite(Number(ge))?ce.add(Number(ge)):typeof ge=="number"&&Number.isFinite(ge)&&ce.add(l(String(ge),Q))}return ce}function e(p,Q,X){if(p==null||Q===null||Q===void 0)return p==null&&Q==null;const ce=typeof p,le=typeof Q;return ce==="string"&&le==="string"?X?p===Q:p.toLowerCase()===Q.toLowerCase():p instanceof Date||Q instanceof Date?h(p)===h(Q):ce==="number"&&le==="number"?p===Q||Number.isNaN(p)&&Number.isNaN(Q):ce==="number"&&le==="string"?p===Number(Q):ce==="string"&&le==="number"?Number(p)===Q:ce==="boolean"||le==="boolean"?p===Q:Array.isArray(p)&&Array.isArray(Q)?p.length===Q.length&&p.every((ge,Me)=>e(ge,Q[Me],X)):p===Q}function d(p,Q){try{if(p instanceof RegExp){const X=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,Q||X.includes("i")?X:`${X}i`)}return new RegExp(String(p),Q?"":"i")}catch(X){return U(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,X),null}}function f(p,Q){if(p&&p.type==="datetime"&&r.has(p.op))return P(p,Q);const X=q(p,Q),ce=p&&p.type;return ce!=="date"&&ce!=="dateString"?X:le=>X(typeof le=="string"&&V.test(le)?le:E(le)??le)}const r=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),n=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?$/,c=new Map;function g(p,Q){let X=c.get(Q);if(X===void 0){try{X=new Intl.DateTimeFormat("en-CA",{timeZone:Q,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{X=null}c.set(Q,X)}if(!X)return null;const ce={};for(const le of X.formatToParts(p))le.type!=="literal"&&(ce[le.type]=le.value);return ce}function A(p,Q){if(p==null||p==="")return null;if(typeof p=="string"){const ge=n.exec(p.trim());if(ge)return Date.UTC(+ge[1],+ge[2]-1,+ge[3],+(ge[4]||0),+(ge[5]||0),+(ge[6]||0),+(ge[7]||"0").padEnd(3,"0"))}const X=Z(p);if(!X)return null;const ce=X.getUTCMilliseconds(),le=Q?g(X,Q):null;return le?Date.UTC(+le.year,+le.month-1,+le.day,le.hour==="24"?0:+le.hour,+le.minute,+le.second,ce):Date.UTC(X.getFullYear(),X.getMonth(),X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),ce)}function P(p,Q){const X=typeof p.timeZone=="string"&&p.timeZone?p.timeZone:void 0,ce=Me=>A(Me,X),le=Array.isArray(p.value)?p.value.map(ce):ce(p.value),ge=q({...p,type:"number",value:le},Q);return Me=>ge(A(Me))}function q(p,Q){const X=p&&p.op,ce=!!(p&&p.caseSensitive),le=p&&p.type,ge=H(Q),Me=be=>ye=>!be(ye);switch(X){case"eq":{const be=s(p.value,le);return ye=>e(ye,be,ce)}case"ne":{const be=s(p.value,le);return ye=>!e(ye,be,ce)}case"lt":case"lte":case"gt":case"gte":{const be=s(p.value,le);if(a(be))return()=>!1;const ye=X==="lt"?-1:X==="lte"?0:X==="gt"?1:2;return Re=>{if(a(Re))return!1;const Ne=ge(Re,be);return ye===-1?Ne<0:ye===0?Ne<=0:ye===1?Ne>0:Ne>=0}}case"between":case"notBetween":{const be=W(p.value),ye=s(be[0],le),Re=s(be[1],le),Ne=p.bounds||"[]",Ee=Ne.charAt(0)!=="(",Be=Ne.charAt(1)!==")";if(a(ye)||a(Re))return X==="between"?()=>!1:()=>!0;const ze=We=>{if(a(We))return!1;const Xe=ge(We,ye),Ye=ge(We,Re);return(Ee?Xe>=0:Xe>0)&&(Be?Ye<=0:Ye<0)};return X==="between"?ze:Me(ze)}case"in":case"notIn":{const be=m(p.value,ce,le),ye=Re=>be.has(l(Re,ce));return X==="in"?ye:Me(ye)}case"contains":case"notContains":{const be=t(s(p.value,le),ce),ye=Re=>Re==null?!1:t(Re,ce).includes(be);return X==="contains"?ye:Me(ye)}case"startsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).startsWith(be)}case"endsWith":{const be=t(s(p.value,le),ce);return ye=>ye==null?!1:t(ye,ce).endsWith(be)}case"matches":{const be=d(p.value,ce);return be?ye=>ye==null?!1:be.test(String(ye)):()=>!1}case"blank":return be=>he(be)||Array.isArray(be)&&be.length===0;case"notBlank":return be=>!(he(be)||Array.isArray(be)&&be.length===0);case"containsAny":case"containsNone":{const be=m(p.value,ce,le),ye=Re=>{const Ne=Re==null?[]:W(Re);for(let Ee=0;Ee<Ne.length;Ee++)if(be.has(l(Ne[Ee],ce)))return!0;return!1};return X==="containsAny"?ye:Me(ye)}case"containsAll":{const be=W(p.value).map(ye=>l(s(ye,le),ce));return ye=>{const Re=ye==null?[]:W(ye);if(be.length===0)return!0;const Ne=new Set(Re.map(Ee=>l(Ee,ce)));for(let Ee=0;Ee<be.length;Ee++)if(!Ne.has(be[Ee]))return!1;return!0}}default:{const be=fe(X);return be?be.compile(p.value):(U(`op:${String(X)}`,`unknown filter operator "${String(X)}"; the condition is refused rather than matching every row`),()=>!1)}}}function L(p,Q,X){return f(Q,X)(p)}const v=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),G=new Set(["containsAny","containsAll","containsNone"]);function S(p,Q,X){const ce=p&&p.op,le=v[ce]||ce,ge=f({...p,op:le,type:Q.type},X),Me=Q.items,be=ye=>{const Re=Me(ye);if(!Re)return!1;for(let Ne=0;Ne<Re.length;Ne++)if(ge(Re[Ne]))return!0;return!1};return v[ce]?ye=>!be(ye):be}function N(p,Q,X,ce){const le=te(p);if(le){const be=Q?1:0;for(let ye=0;ye<ce;ye++)X[ye]=le(ye)===be?1:0;return X}const ge=p.kind;if(ge==="float64"||ge==="int32"||ge==="bitset")return i(X,ce,Q?1:0);const Me=T(p);for(let be=0;be<ce;be++){const ye=Me(be),Re=he(ye)||Array.isArray(ye)&&ye.length===0;X[be]=Re===Q?0:1}return X}function I(p,Q,X,ce){const le=p.dict,ge=Y(le),Me=new Uint8Array(ge);for(let Ne=0;Ne<ge;Ne++)Me[Ne]=Q(se(le,Ne))?1:0;const be=p.values,ye=te(p);if(!ye){for(let Ne=0;Ne<ce;Ne++)X[Ne]=Me[be[Ne]];return X}const Re=Q(null)?1:0;for(let Ne=0;Ne<ce;Ne++)X[Ne]=ye(Ne)===1?Me[be[Ne]]:Re;return X}function K(p,Q,X,ce){const le=re(p.values),ge=Q(!0)?1:0,Me=Q(!1)?1:0,be=te(p);if(!be){for(let Re=0;Re<ce;Re++)X[Re]=le(Re)===1?ge:Me;return X}const ye=Q(null)?1:0;for(let Re=0;Re<ce;Re++)X[Re]=be(Re)===0?ye:le(Re)===1?ge:Me;return X}function B(p,Q,X,ce,le){const ge=p.values,Me=Q.type,be=Q.op;let ye=!0;switch(be){case"eq":case"ne":{const Ne=u(s(Q.value,Me)),Ee=typeof Q.value=="number"&&Number.isNaN(Q.value),Be=be==="ne"?1:0;if(Ee)for(let ze=0;ze<le;ze++)ce[ze]=(Number.isNaN(ge[ze])?1:0)^Be;else for(let ze=0;ze<le;ze++)ce[ze]=(ge[ze]===Ne?1:0)^Be;break}case"lt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<Ne?1:0;break}case"lte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]<=Ne?1:0;break}case"gt":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>Ne?1:0;break}case"gte":{const Ne=u(s(Q.value,Me));for(let Ee=0;Ee<le;Ee++)ce[Ee]=ge[Ee]>=Ne?1:0;break}case"between":case"notBetween":{const Ne=W(Q.value),Ee=u(s(Ne[0],Me)),Be=u(s(Ne[1],Me)),ze=Q.bounds||"[]",We=ze.charAt(0)!=="(",Xe=ze.charAt(1)!==")",Ye=be==="notBetween"?1:0;if(We&&Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<=Be?1:0)^Ye;else if(We)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>=Ee&ge[Ie]<Be?1:0)^Ye;else if(Xe)for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<=Be?1:0)^Ye;else for(let Ie=0;Ie<le;Ie++)ce[Ie]=(ge[Ie]>Ee&ge[Ie]<Be?1:0)^Ye;break}case"in":case"notIn":{const Ne=new Set;for(const Be of W(Q.value)){const ze=u(s(Be,Me));Number.isNaN(ze)||Ne.add(ze)}const Ee=be==="notIn"?1:0;for(let Be=0;Be<le;Be++)ce[Be]=(Ne.has(ge[Be])?1:0)^Ee;break}default:ye=!1;break}if(!ye)return!1;const Re=te(p);if(Re){const Ne=X(null)?1:0;for(let Ee=0;Ee<le;Ee++)Re(Ee)===0&&(ce[Ee]=Ne)}return!0}function ee(p,Q,X,ce){const le=T(p);for(let ge=0;ge<ce;ge++)X[ge]=Q(le(ge))?1:0;return X}function J(p,Q,X){const ce=Q.count|0,le=X||R(Q,ce);if(!p)return i(le,ce,1);const ge=typeof Q.handle=="function"?Q.handle(p.col):void 0,Me=typeof Q.custom=="function"?Q.custom:null;if(!ge){if(Me){for(let Ne=0;Ne<ce;Ne++)le[Ne]=Me(p,Ne)?1:0;return le}return U(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),i(le,ce,0)}const be=p.op;if(be==="blank"||be==="notBlank")return N(ge,be==="notBlank",le,ce);const ye=typeof Q.itemwise=="function"?Q.itemwise(p.col):null;if(ye&&!fe(be)&&!G.has(be))return ee(ge,S(p,ye,Q.locale),le,ce);const Re=f(p,Q.locale);switch(ge.kind){case"dictionary":return I(ge,Re,le,ce);case"bitset":return K(ge,Re,le,ce);case"float64":case"int32":return B(ge,p,Re,le,ce)?le:ee(ge,Re,le,ce);default:return ee(ge,Re,le,ce)}}function ue(p,Q,X){if(!p)return i(R(Q,X),X,1);if(Array.isArray(p.conditions)){const ce=p.conditions.filter(Me=>Me!=null),le=p.op==="or"?"or":p.op==="not"?"not":"and";if(ce.length===0)return i(R(Q,X),X,1);const ge=ue(ce[0],Q,X);for(let Me=1;Me<ce.length;Me++){const be=ue(ce[Me],Q,X);if(le==="or")for(let ye=0;ye<X;ye++)ge[ye]|=be[ye];else for(let ye=0;ye<X;ye++)ge[ye]&=be[ye];j(Q,be)}if(le==="not")for(let Me=0;Me<X;Me++)ge[Me]^=1;return ge}return J(p,Q,R(Q,X))}function de(p,Q){return ue(p,Q,Q.count|0)}function Oe(p,Q){if(!p||!Q)return p||null;const X=p;if(Array.isArray(X.conditions)){if((X.op==="or"?"or":X.op==="not"?"not":"and")!=="and")return Ae(X,Q)?null:p;const le=[];for(const ge of X.conditions){const Me=Oe(ge,Q);Me&&le.push(Me)}return le.length?{...X,op:"and",conditions:le}:null}return X.col===Q?null:p}function Ae(p,Q){if(!p||typeof p!="object")return!1;const X=p;if(X.col===Q)return!0;if(Array.isArray(X.conditions)){for(const ce of X.conditions)if(Ae(ce,Q))return!0}return!1}function Se(p,Q,X){if(X&&X.length>=Q){let Me=0;for(let be=0;be<Q;be++)p[be]&&(X[Me++]=be);return X.subarray(0,Me)}let ce=0;for(let Me=0;Me<Q;Me++)ce+=p[Me]?1:0;const le=new Uint32Array(ce);let ge=0;for(let Me=0;Me<Q;Me++)p[Me]&&(le[ge++]=Me);return le}const D=new Map;function x(p){if(!(!p||typeof p!="object"))for(const[Q,X]of Object.entries(p))X&&typeof X.compile=="function"&&D.set(Q,X)}function fe(p){return typeof p=="string"?D.get(p):void 0}}),Ce("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return te}});const ae=me("packages/core/src/compute/handle.js"),he=ae.dictSize,W=ae.identity,U=ae.presenceReader,_=ae.rowCount,Z=ae.valueReader,E="",z="\\0",re=1<<20;function Y(H,T,V,ne){const R=H.length,j=H.map(t=>Z(t)),i=Array.isArray(ne)&&ne.some(Boolean),a=i?j.map((t,l)=>ne[l]?m=>ne[l](t(m)):t):j;if(!i&&R>0&&H.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=H.map(m=>he(m.dict)+1);let l=1;for(let m=0;m<R;m++)l*=t[m];if(l<=Number.MAX_SAFE_INTEGER){const m=H.map(r=>r.values),e=H.map(r=>U(r)),d=r=>{let n=0;for(let c=0;c<R;c++){const g=e[c],A=g&&g(r)===0?t[c]-1:m[c][r];n=n*t[c]+A}return n},f=new Float64Array(V);for(let r=0;r<V;r++)f[r]=d(T[r]);return{packed:f,strings:null,product:l,readers:a,keyOf:d}}}const h=t=>{let l="";for(let m=0;m<R;m++){const e=a[m](t);l+=(m===0?"":E)+(e==null?z:String(e))}return l},u=new Array(V);for(let t=0;t<V;t++)u[t]=h(T[t]);return{packed:null,strings:u,product:1/0,readers:a,keyOf:h}}function se(H,T,V,ne){const R=new Uint32Array(ne+1);for(let s=0;s<V;s++)R[T[s]+1]++;for(let s=0;s<ne;s++)R[s+1]+=R[s];const j=new Uint32Array(V),i=R.slice(0,ne);for(let s=0;s<V;s++)j[i[T[s]]++]=H[s];const a=new Array(ne);for(let s=0;s<ne;s++)a[s]=j.subarray(R[s],R[s+1]);return a}function te(H,T,V={}){const ne=H||[],R=T||W(_(ne[0],V)),j=R.length;if(ne.length===0||j===0)return{keys:[],buckets:[]};const{packed:i,strings:a,product:s,readers:h}=Y(ne,R,j,V.project),u=new Uint32Array(j);let t=0,l=null;if(i&&s<=Math.max(1024,Math.min(re,j*4))){const f=s,r=new Int32Array(f).fill(-1);for(let n=0;n<j;n++)r[i[n]]=0;for(let n=0;n<f;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<j;n++)u[n]=r[i[n]];l=new Float64Array(t);for(let n=0;n<f;n++)r[n]>=0&&(l[r[n]]=n)}else if(i){const f=new Map;for(let r=0;r<j;r++){const n=i[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}l=new Float64Array(t);for(const[r,n]of f)l[n]=r}else{const f=new Map;for(let r=0;r<j;r++){const n=a[r];let c=f.get(n);c===void 0&&(c=t++,f.set(n,c)),u[r]=c}}const m=se(R,u,j,t),e=new Array(t);for(let f=0;f<t;f++){const r=m[f][0],n=new Array(h.length);for(let c=0;c<h.length;c++)n[c]=h[c](r);e[f]=n}const d={keys:e,buckets:m};return l&&(d.packed=l),d}}),Ce("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=ae.dictSize,_=ae.dictValue,Z=Object.freeze(["equal","quantile","log"]),E=Object.freeze(["hour","day","week","month","quarter","year"]),z=20,re=50,Y=1e4;function se(n,c){if(!n)return"none";const g=c;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const A=c&&c.base;if(A==="date"||A==="datetime"||A==="time"||A==="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 A==="number"?"numeric":A==="boolean"?"boolean":A==="text"?"category":"none"}}function te(n){const c=n.values,g=n.kind;if((g==="float64"||g==="int32")&&c)return P=>c[P];const A=W(n);return P=>H(A(P))}function H(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const c=Number(n);if(Number.isFinite(c))return c;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function T(n,c,g,A=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:U(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const P=W(n),q=c?c.length:g,L=new Set;for(let v=0;v<q;v++){const G=P(c?c[v]:v);if(G!=null&&(L.add(G),L.size>A))return{cardinality:L.size,exact:!1}}return{cardinality:L.size,exact:!0}}const V=36e5,ne=864e5;function R(n,c=z){const g=Number.isFinite(n)&&n>0?n:0,A=Math.max(1,c)*2;return g/V<=A?"hour":g/ne<=A?"day":g/(7*ne)<=A?"week":g/(30*ne)<=A?"month":g/(91*ne)<=A?"quarter":"year"}function j(n,c){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(c){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const A=(g.getDay()+6)%7;return g.setDate(g.getDate()-A),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,c){const g=new Date(n);switch(c){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function a(n,c,g){const A=te(n),P=he(n),q=c?c.length:g;let L=1/0,v=-1/0,G=0,S=0;for(let N=0;N<q;N++){const I=c?c[N]:N;if(P&&!P(I)){G++;continue}const K=A(I);if(!Number.isFinite(K)){G++;continue}K<L&&(L=K),K>v&&(v=K),S++}return{min:L,max:v,nulls:G,finite:S}}function s(n,c,g,A){const P=te(n),q=he(n),L=c?c.length:g,v=L>A?L/A:1,G=[];for(let N=0;N<L;N+=v){const I=c?c[Math.floor(N)]:Math.floor(N);if(q&&!q(I))continue;const K=P(I);Number.isFinite(K)&&G.push(K)}const S=Float64Array.from(G);return S.sort(),S}function h(n,c,g,A={}){const P=A.kind||se(n,A.type);return P==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:P==="boolean"?u(n,c,g):P==="category"?t(n,c,g,A):l(n,c,g,P,A)}function u(n,c,g){const A=he(n);let P=0;if(A){const L=c?c.length:g;for(let v=0;v<L;v++)A(c?c[v]:v)||P++}const q=[{value:!1,label:"false"},{value:!0,label:"true"}];return P>0&&q.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:q}}function t(n,c,g,A){const P=A.cardinalityLimit??re,{cardinality:q}=T(n,c,g,P);if(q>P&&(A.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:q};const L=W(n),v=c?c.length:g,G=new Map;let S=0;for(let ee=0;ee<v;ee++){const J=L(c?c[ee]:ee);if(J==null||J===""){S++;continue}if(Array.isArray(J)){if(!J.length){S++;continue}for(const ue of J)G.set(ue,(G.get(ue)||0)+1);continue}G.set(J,(G.get(J)||0)+1)}let N=[...G.entries()];A.order==="alpha"?N.sort((ee,J)=>String(ee[0]).localeCompare(String(J[0]))):N.sort((ee,J)=>J[1]-ee[1]);let I=0,K=0;if(N.length>P){K=N.length-P;for(let ee=P;ee<N.length;ee++)I+=N[ee][1];N=N.slice(0,P)}const B=N.map(([ee])=>({value:ee,label:String(ee)}));return I>0&&B.push({remainder:!0,label:`Other (${K} values)`}),S>0&&B.push({null:!0,label:"Empty"}),{kind:"category",buckets:B,cardinality:q}}function l(n,c,g,A,P){const{min:q,max:L,nulls:v,finite:G}=a(n,c,g);if(!G)return{kind:A,buckets:v?[{null:!0,label:"Empty"}]:[],empty:!0};const S=Math.max(1,Math.floor(P.buckets||z));let N=[];if(A==="date"){const K=E.includes(P.granularity)?P.granularity:R(L-q,S);let B=j(q,K);for(;B<=L&&N.length<4096;){const ee=i(B,K);if(!(ee>B))break;N.push({from:B,to:ee}),B=ee}return{kind:A,buckets:m(N,v),granularity:K}}const I=Z.includes(P.strategy)?P.strategy:"equal";if(I==="quantile"){const K=s(n,c,g,Y);if(K.length){const B=[K[0]];for(let ee=1;ee<S;ee++){const J=K[Math.min(K.length-1,Math.floor(ee/S*K.length))];J>B[B.length-1]&&B.push(J)}B.push(L);for(let ee=0;ee<B.length-1;ee++)N.push({from:B[ee],to:B[ee+1]})}}else if(I==="log"&&q>0){const K=Math.log10(q),ee=(Math.log10(L)-K)/S||1;for(let J=0;J<S;J++)N.push({from:10**(K+J*ee),to:10**(K+(J+1)*ee)})}if(!N.length){const K=(L-q)/S||1;for(let B=0;B<S;B++)N.push({from:q+B*K,to:q+(B+1)*K})}return N[N.length-1].to=L,{kind:A,buckets:m(N,v),strategy:I,min:q,max:L}}function m(n,c){return c>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,c,g,A,P){const q=A&&A.buckets||[],L=P&&P.length>=q.length?P.subarray(0,q.length):new Uint32Array(q.length);if(L.fill(0),!n||!q.length)return L;const v=q.length-1,G=!!q[v]&&q[v].null===!0,S=c?c.length:g;if(A.kind==="boolean"){const ee=W(n);for(let J=0;J<S;J++){const ue=ee(c?c[J]:J);if(ue==null){G&&L[v]++;continue}L[ue?1:0]++}return L}if(A.kind==="category"){const ee=new Map;for(let de=0;de<q.length;de++)!q[de].null&&!q[de].remainder&&ee.set(q[de].value,de);const J=q.findIndex(de=>de.remainder),ue=W(n);for(let de=0;de<S;de++){const Oe=ue(c?c[de]:de);if(Oe==null||Oe===""){G&&L[v]++;continue}if(Array.isArray(Oe)){if(!Oe.length){G&&L[v]++;continue}for(const Se of Oe){const D=ee.get(Se);D!==void 0?L[D]++:J>=0&&L[J]++}continue}const Ae=ee.get(Oe);Ae!==void 0?L[Ae]++:J>=0&&L[J]++}return L}const N=G?q.length-1:q.length,I=new Float64Array(N+1);for(let ee=0;ee<N;ee++)I[ee]=q[ee].from;I[N]=N?q[N-1].to:0;const K=te(n),B=he(n);for(let ee=0;ee<S;ee++){const J=c?c[ee]:ee;if(B&&!B(J)){G&&L[v]++;continue}const ue=K(J);if(!Number.isFinite(ue)){G&&L[v]++;continue}const de=d(I,N,ue);de>=0&&L[de]++}return L}function d(n,c,g){if(!c||g<n[0])return-1;if(g>=n[c])return g===n[c]?c-1:-1;let A=0,P=c-1;for(;A<P;){const q=A+P+1>>>1;g>=n[q]?A=q:P=q-1}return A}function f(n,c,g,A={}){const P=A.bounds||h(n,A.boundsIndices??c,g,A);return{bounds:P,counts:e(n,c,g,P)}}const r=f}),Ce("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return ne}});const ae=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,W=1e-300;function U(R){if(R<.5)return Math.log(Math.PI/Math.sin(Math.PI*R))-U(1-R);const j=R-1;let i=.9999999999998099;const a=j+7.5;for(let s=0;s<ae.length;s++)i+=ae[s]/(j+s+1);return .5*Math.log(2*Math.PI)+(j+.5)*Math.log(a)-a+Math.log(i)}function _(R,j,i){const a=R+j,s=R+1,h=R-1;let u=1,t=1-a*i/s;Math.abs(t)<W&&(t=W),t=1/t;let l=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(j-m)*i/((h+e)*(R+e));t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t,l*=t*u,d=-(R+m)*(a+m)*i/((R+e)*(s+e)),t=1+d*t,Math.abs(t)<W&&(t=W),u=1+d/u,Math.abs(u)<W&&(u=W),t=1/t;const f=t*u;if(l*=f,Math.abs(f-1)<he)break}return l}function Z(R,j,i){if(!(R>0)||!(j>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const a=Math.exp(U(R+j)-U(R)-U(j)+R*Math.log(i)+j*Math.log(1-i));return i<(R+1)/(R+j+2)?a*_(R,j,i)/R:1-a*_(j,R,1-i)/j}function E(R){if(!(R>0)||!(R<1))return R===0?-1/0:R===1?1/0:Number.NaN;const j=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],s=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],h=.02425;let u,t,l;R<h?(u=Math.sqrt(-2*Math.log(R)),l=(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1)):R<=1-h?(u=R-.5,t=u*u,l=(((((j[0]*t+j[1])*t+j[2])*t+j[3])*t+j[4])*t+j[5])*u/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(u=Math.sqrt(-2*Math.log(1-R)),l=-(((((a[0]*u+a[1])*u+a[2])*u+a[3])*u+a[4])*u+a[5])/((((s[0]*u+s[1])*u+s[2])*u+s[3])*u+1));const e=(.5*z(-l/Math.SQRT2)-R)*Math.sqrt(2*Math.PI)*Math.exp(l*l/2);return l-e/(1+l*e/2)}function z(R){const j=Math.abs(R),i=2/(2+j),a=4*i-2,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let h=0,u=0,t;for(let m=s.length-1;m>0;m--)t=u,u=a*u-h+s[m],h=t;const l=i*Math.exp(-j*j+.5*(s[0]+a*u)-h);return R>=0?l:2-l}function re(R){return .5*z(-R/Math.SQRT2)}function Y(R,j){if(!(j>0)||!Number.isFinite(R))return Number.NaN;const i=.5*Z(j/2,.5,j/(j+R*R));return R>0?1-i:i}function se(R,j){if(!(R>0)||!(R<1)||!(j>0))return Number.NaN;if(j>1e7)return E(R);let i=-1e4,a=1e4,s=E(R);const h=U(j/2)+U(.5)-U((j+1)/2);for(let u=0;u<60;u++){const t=Y(s,j);t<R?i=s:a=s;const l=Math.exp(-((j+1)/2)*Math.log(1+s*s/j)-h)/Math.sqrt(j),m=l>0?(t-R)/l:0;if(Math.abs(m)<1e-12)break;const e=s-m;if(s=e>i&&e<a&&Number.isFinite(e)?e:(i+a)/2,a-i<1e-12)break}return s}function te(R,j){let i=R,a=1/R,s=a;for(let h=0;h<300&&(i+=1,s*=j/i,a+=s,!(Math.abs(s)<Math.abs(a)*he));h++);return a*Math.exp(-j+R*Math.log(j)-U(R))}function H(R,j){let i=j+1-R,a=1/W,s=1/i,h=s;for(let u=1;u<=300;u++){const t=-u*(u-R);i+=2,s=t*s+i,Math.abs(s)<W&&(s=W),a=i+t/a,Math.abs(a)<W&&(a=W),s=1/s;const l=s*a;if(h*=l,Math.abs(l-1)<he)break}return Math.exp(-j+R*Math.log(j)-U(R))*h}function T(R,j){return!(R>0)||!(j>=0)||!Number.isFinite(j)?Number.NaN:j===0?0:j<R+1?te(R,j):1-H(R,j)}function V(R,j){return j>0?T(j/2,R/2):Number.NaN}function ne(R,j){const i=V(R,j);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Ce("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return Z}});function ae(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++)for(let se=0;se<=Y;se++){let te=E[Y][se];for(let H=0;H<se;H++)te-=re[Y][H]*re[se][H];if(Y===se){if(!(te>0))return null;re[Y][se]=Math.sqrt(te)}else re[Y][se]=te/re[se][se]}return re}function he(E,z){const re=E.length,Y=new Array(re).fill(0);for(let te=0;te<re;te++){let H=z[te];for(let T=0;T<te;T++)H-=E[te][T]*Y[T];Y[te]=H/E[te][te]}const se=new Array(re).fill(0);for(let te=re-1;te>=0;te--){let H=Y[te];for(let T=te+1;T<re;T++)H-=E[T][te]*se[T];se[te]=H/E[te][te]}return se}function W(E){const z=E.length,re=Array.from({length:z},()=>new Array(z).fill(0));for(let Y=0;Y<z;Y++){const se=new Array(z).fill(0);se[Y]=1;const te=he(E,se);for(let H=0;H<z;H++)re[H][Y]=te[H]}return re}function U(E,z,re){const Y=E.length,se=Y?E[0].length:0,te=Array.from({length:se},()=>new Array(se).fill(0)),H=new Array(se).fill(0);for(let T=0;T<Y;T++){const V=re?re[T]:1,ne=E[T];for(let R=0;R<se;R++){const j=V*ne[R];H[R]+=j*z[T];for(let i=R;i<se;i++)te[R][i]+=j*ne[i]}}for(let T=0;T<se;T++)for(let V=0;V<T;V++)te[T][V]=te[V][T];return{xtwx:te,xtwy:H}}function _(E,z){return E.map(re=>re.reduce((Y,se,te)=>Y+se*z[te],0))}function Z(E,z){let re=0;for(let Y=0;Y<E.length;Y++){let se=0;for(let te=0;te<E.length;te++)se+=z[Y][te]*E[te];re+=E[Y]*se}return re}}),Ce("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return te}});class ae{#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(T){if(!Number.isFinite(T))return;this.#t++;const V=T-this.#e;this.#e+=V/this.#t,this.#n+=V*(T-this.#e)}merge(T){if(T.#t===0)return;if(this.#t===0){this.#t=T.#t,this.#e=T.#e,this.#n=T.#n;return}const V=this.#t+T.#t,ne=T.#e-this.#e;this.#e+=ne*(T.#t/V),this.#n+=T.#n+ne*ne*(this.#t*T.#t/V),this.#t=V}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 T=this.variance();return T===null?null:Math.sqrt(T)}stddevP(){const T=this.varianceP();return T===null?null:Math.sqrt(T)}}class he{#t=[];#e=0;#n;#r;constructor(T,V=Math.random){if(!(T>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(T),this.#r=V}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(T){if(!Number.isFinite(T))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(T);return}const V=Math.floor(this.#r()*this.#e);V<this.#n&&(this.#t[V]=T)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let T=0;for(const V of this.#t)T+=V;return T/this.#t.length}quantile(T){const V=this.#t.length;if(!V)return null;const ne=this.#t.slice().sort((a,s)=>a-s);if(V===1)return ne[0];const R=(V-1)*Math.min(1,Math.max(0,T)),j=Math.floor(R),i=Math.ceil(R);return j===i?ne[j]:ne[j]+(R-j)*(ne[i]-ne[j])}}function W(H){return H^=H>>>16,H=Math.imul(H,2246822507),H^=H>>>13,H=Math.imul(H,3266489909),H^=H>>>15,H>>>0}function U(H){if(typeof H=="number"){const ne=new DataView(new ArrayBuffer(8));return ne.setFloat64(0,H===0?0:H),W(ne.getUint32(0)^ne.getUint32(4))}const T=typeof H=="string"?H:String(H);let V=2166136261;for(let ne=0;ne<T.length;ne++)V^=T.charCodeAt(ne),V=Math.imul(V,16777619);return W(V)}class _{#t;#e;#n;constructor(T=14){const V=Math.floor(T);if(V<4||V>16)throw new RangeError("HLL precision must be 4..16");this.#t=V,this.#e=1<<V,this.#n=new Uint8Array(this.#e)}static errorBoundFor(T=14){const V=1<<Math.floor(T),ne=1.04/Math.sqrt(V);return Object.freeze({kind:"probabilistic",metric:"relative",value:ne,statement:`distinct count within ~${(ne*100).toFixed(2)}% relative standard error (m=${V} buckets)`})}errorBound(){return _.errorBoundFor(this.#t)}add(T){const V=U(T),ne=V&this.#e-1,R=V>>>this.#t|1<<32-this.#t;let j=1,i=R;for(;(i&1)===0;)j++,i>>>=1;j>this.#n[ne]&&(this.#n[ne]=j)}count(){const T=this.#e,V=32-this.#t,ne=new Float64Array(V+2);for(let i=0;i<T;i++)ne[this.#n[i]]++;let R=T*z(1-ne[V+1]/T);for(let i=V;i>=1;i--)R=.5*(R+ne[i]);R+=T*E(ne[0]/T);const j=Z*T*T/R;return Math.round(j)}}const Z=.5/Math.log(2);function E(H){if(H===1)return 1/0;let T=1,V=H,ne;do H*=H,ne=V,V+=H*T,T+=T;while(V!==ne);return V}function z(H){if(H===0||H===1)return 0;let T=1,V=1-H,ne;do H=Math.sqrt(H),ne=V,T*=.5,V-=(1-H)**2*T;while(V!==ne);return V/3}class re{#t=new Map;#e;#n=0;constructor(T){if(!(T>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(T)}errorBoundFor(T){const V=T/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:V,statement:`each count overestimates the truth by at most N/m = ${V.toFixed(2)} (N=${T}, m=${this.#e})`})}get seen(){return this.#n}add(T){this.#n++;const V=this.#t.get(T);if(V){V.count++;return}if(this.#t.size<this.#e){this.#t.set(T,{count:1,error:0});return}let ne,R=1/0;for(const[j,i]of this.#t)i.count<R&&(R=i.count,ne=j);this.#t.delete(ne),this.#t.set(T,{count:R+1,error:R})}top(T=this.#e){return[...this.#t.entries()].map(([ne,R])=>({item:ne,count:R.count,error:R.error})).sort((ne,R)=>R.count-ne.count).slice(0,Math.max(0,Math.floor(T)))}}class Y{#t;#e=[[]];#n=0;#r;#i;constructor(T=200,V=Math.random){this.#t=Math.max(8,Math.floor(T)),this.#r=V,this.#i=2/3}static errorBoundFor(T=200){const V=1/Math.max(8,Math.floor(T));return Object.freeze({kind:"probabilistic",metric:"rank",value:V,statement:`queried quantile\'s true rank within ~${(V*100).toFixed(2)}% of N of the requested rank (k=${T})`})}errorBound(){return Y.errorBoundFor(this.#t)}get count(){return this.#n}#s(T){const ne=this.#e.length-1-T,R=Math.ceil(this.#t*this.#i**ne);return Math.max(2,R)}add(T){Number.isFinite(T)&&(this.#n++,this.#e[0].push(T),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(T){const V=this.#e[T];V.sort((j,i)=>j-i),T+1>=this.#e.length&&this.#e.push([]);const ne=this.#e[T+1],R=this.#r()<.5?0:1;for(let j=R;j<V.length;j+=2)ne.push(V[j]);this.#e[T]=[];for(let j=0;j<this.#e.length;j++)if(this.#e[j].length>=this.#s(j)){this.#h(j);return}}#u(){const T=[];for(let V=0;V<this.#e.length;V++){const ne=1<<V;for(const R of this.#e[V])T.push({v:R,w:ne})}return T}quantile(T){const V=this.#u();if(!V.length)return null;V.sort((i,a)=>i.v-a.v);let ne=0;for(const i of V)ne+=i.w;const R=Math.min(1,Math.max(0,T))*ne;let j=0;for(const i of V)if(j+=i.w,j>=R)return i.v;return V[V.length-1].v}rank(T){let V=0;for(let ne=0;ne<this.#e.length;ne++){const R=1<<ne;for(const j of this.#e[ne])j<=T&&(V+=R)}return V}}const se=Object.freeze({distinct:_.errorBoundFor(14),median:Y.errorBoundFor(200),p25:Y.errorBoundFor(200),p75:Y.errorBoundFor(200),p90:Y.errorBoundFor(200),p95:Y.errorBoundFor(200),p99:Y.errorBoundFor(200),iqr:Y.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"})}),te={Welford:ae,Reservoir:he,HyperLogLog:_,SpaceSaving:re,KLL:Y,hash32:U,SKETCH_BOUNDS:se}}),Ce("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return We}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ft}}),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 ht}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const ae=me("packages/core/src/compute/handle.js"),he=ae.presenceReader,W=ae.valueReader,U=me("packages/core/src/compute/special.js"),_=U.studentTQuantile,Z=U.studentT,E=U.normalQuantile,z=U.normalCdf,re=U.chiSquareUpperTail,Y=me("packages/core/src/compute/linalg.js"),se=Y.cholesky,te=Y.choleskySolve,H=Y.choleskyInverse,T=Y.normalEquations,V=Y.quadForm,R=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,j=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"}),a=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:R.distinct}),median:Object.freeze({sketch:"KLL",bound:R.median}),p25:Object.freeze({sketch:"KLL",bound:R.p25}),p75:Object.freeze({sketch:"KLL",bound:R.p75}),p90:Object.freeze({sketch:"KLL",bound:R.p90}),p95:Object.freeze({sketch:"KLL",bound:R.p95}),p99:Object.freeze({sketch:"KLL",bound:R.p99}),iqr:Object.freeze({sketch:"KLL",bound:R.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:R.topK})});function s(b){const k=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(a,b)?a[b]:null;return{stat:b,exact:k,approximate:y}}function h(b,k){const y=k.length,w=new Float64Array(y);let O=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const F=b.values,C=he(b);for(let ie=0;ie<y;ie++){const oe=k[ie];if(C&&C(oe)!==1)continue;const ke=F[oe];Number.isNaN(ke)||(w[O++]=ke)}return w.subarray(0,O)}const $=W(b);for(let F=0;F<y;F++){const C=$(k[F]);if(C==null||C==="")continue;const ie=typeof C=="number"?C:Number(C);Number.isFinite(ie)&&(w[O++]=ie)}return w.subarray(0,O)}function u(b,k){const y=new Map,w=W(b);let O=0;for(let $=0;$<k.length;$++){const F=w(k[$]);if(F==null||F===""||typeof F=="number"&&Number.isNaN(F))continue;const C=typeof F=="object"?String(F):F;y.set(C,(y.get(C)||0)+1),O++}const M=[...y.values()].sort(($,F)=>F-$);return{counts:M,total:O,distinct:M.length}}function t(b){return b.total>0?b.counts.map(k=>k/b.total):[]}function l(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))w+=O*O;return w}function m(b,k){const y=u(b,k);if(!y.total)return null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w}function e(b,k){const y=u(b,k);if(!y.total||y.distinct<2)return y.total?1:null;let w=0;for(const O of t(y))O>0&&(w-=O*Math.log2(O));return w/Math.log2(y.distinct)}function d(b,k,y=3){const w=u(b,k);if(!w.total)return null;const O=Math.max(1,Math.floor(y));let M=0;for(let $=0;$<Math.min(O,w.counts.length);$++)M+=w.counts[$];return M/w.total}function f(b,k){const y=h(b,k),w=y.length;if(!w)return null;const O=y.slice().sort();if(O[0]<0)return null;let M=0,$=0;for(let F=0;F<w;F++)M+=O[F],$+=(F+1)*O[F];return M===0?0:2*$/(w*M)-(w+1)/w}function r(b){let k=0,y=0,w=0;for(let O=0;O<b.length;O++){const M=b[O];k++;const $=M-y;y+=$/k,w+=$*(M-y)}return{n:k,mean:y,m2:w}}function n(b,k){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const w=(y-1)*Math.min(1,Math.max(0,k)),O=Math.floor(w),M=Math.ceil(w);return O===M?b[O]:b[O]+(w-O)*(b[M]-b[O])}function c(b,k){if(!b.length)return NaN;const y=b.slice().sort();return n(y,k)}function g(b,k){const y=W(b);let w=0,O=0,M=0;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=String(F).toUpperCase();C==="PASS"?w++:C==="FAIL"?O++:C==="WARN"&&M++}return{pass:w+M,fail:O,warn:M,judged:w+M+O}}const A=Object.freeze({hhi:(b,k)=>l(b,k),entropy:(b,k)=>m(b,k),evenness:(b,k)=>e(b,k),top3Share:(b,k)=>d(b,k,3),top10Share:(b,k)=>d(b,k,10),gini:(b,k)=>f(b,k),trimmedMean:(b,k)=>G(h(b,k),.1),winsorizedMean:(b,k)=>S(h(b,k),.1),robustOutliers:(b,k)=>N(h(b,k),3.5),jarqueBera:(b,k)=>I(h(b,k)),variance:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?w/(y-1):null},varianceP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?w/y:null},stddev:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>1?Math.sqrt(w/(y-1)):null},stddevP:(b,k)=>{const{n:y,m2:w}=r(h(b,k));return y>0?Math.sqrt(w/y):null},median:(b,k)=>{const y=h(b,k);return y.length?c(y,.5):null},p25:(b,k)=>{const y=h(b,k);return y.length?c(y,.25):null},p75:(b,k)=>{const y=h(b,k);return y.length?c(y,.75):null},p90:(b,k)=>{const y=h(b,k);return y.length?c(y,.9):null},p95:(b,k)=>{const y=h(b,k);return y.length?c(y,.95):null},p99:(b,k)=>{const y=h(b,k);return y.length?c(y,.99):null},iqr:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=y.slice().sort();return n(w,.75)-n(w,.25)},mad:(b,k)=>{const y=h(b,k);if(!y.length)return null;const w=c(y,.5),O=new Float64Array(y.length);for(let M=0;M<y.length;M++)O[M]=Math.abs(y[M]-w);return c(O,.5)},range:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=1/0,O=-1/0;for(let M=0;M<y.length;M++)y[M]<w&&(w=y[M]),y[M]>O&&(O=y[M]);return O-w},distinct:(b,k)=>{const y=W(b),w=new Set;for(let O=0;O<k.length;O++){const M=y(k[O]);M==null||M===""||w.add(M instanceof Date?M.getTime():M)}return w.size},mode:(b,k)=>{const y=W(b),w=new Map;for(let $=0;$<k.length;$++){const F=y(k[$]);if(F==null||F==="")continue;const C=F instanceof Date?F.getTime():F;w.set(C,(w.get(C)||0)+1)}let O=null,M=1;for(const[$,F]of w)F>M&&(M=F,O=$);return O},skewness:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<3||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let C=0;C<y.length;C++)F+=((y[C]-O)/$)**3;return w/((w-1)*(w-2))*F},kurtosis:(b,k)=>{const y=h(b,k),{n:w,mean:O,m2:M}=r(y);if(w<4||M<=0)return null;const $=Math.sqrt(M/(w-1));let F=0;for(let oe=0;oe<y.length;oe++)F+=((y[oe]-O)/$)**4;const C=w*(w+1)/((w-1)*(w-2)*(w-3)),ie=3*(w-1)**2/((w-2)*(w-3));return C*F-ie},geomean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]<=0)return null;w+=Math.log(y[O])}return Math.exp(w/y.length)},harmean:(b,k)=>{const y=h(b,k);if(!y.length)return null;let w=0;for(let O=0;O<y.length;O++){if(y[O]===0)return null;w+=1/y[O]}return y.length/w},sumSquares:(b,k)=>{const y=h(b,k);let w=0;for(let O=0;O<y.length;O++)w+=y[O]*y[O];return w},passRate:(b,k)=>{const{pass:y,judged:w}=g(b,k);return w?y/w:null},failureCount:(b,k)=>g(b,k).fail}),P=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function q(b,k,y){const w=W(b),O=W(k);let M=0,$=0;for(let F=0;F<y.length;F++){const C=y[F],ie=Number(w(C)),oe=Number(O(C));!Number.isFinite(ie)||!Number.isFinite(oe)||(M+=ie*oe,$+=oe)}return $===0?null:M/$}function L(b,k,y){const w=W(b);let O=null,M=y?-1/0:1/0;for(let $=0;$<k.length;$++){const F=k[$],C=Number(w(F));Number.isFinite(C)&&(y?C>M:C<M)&&(M=C,O=F)}return O}function v(b,k,y){const w=W(b),O=W(k);let M=0,$=0,F=0,C=0,ie=0,oe=0;for(let pe=0;pe<y.length;pe++){const ve=y[pe],Le=Number(w(ve)),we=Number(O(ve));!Number.isFinite(Le)||!Number.isFinite(we)||(M++,$+=Le,F+=we,C+=Le*Le,ie+=we*we,oe+=Le*we)}if(M<2)return null;const ke=M*oe-$*F,je=Math.sqrt((M*C-$*$)*(M*ie-F*F));if(je===0)return null;const Pe=ke/je;return Math.max(-1,Math.min(1,Pe))}function G(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((F,C)=>F-C),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w.slice(O,y-O);if(!M.length)return n(w,.5);let $=0;for(const F of M)$+=F;return $/M.length}function S(b,k=.1){const y=b.length;if(!y)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=Math.floor(y*Math.min(.49,Math.max(0,k))),M=w[O],$=w[y-1-O];let F=0;for(const C of w)F+=Math.min($,Math.max(M,C));return F/y}function N(b,k=3.5){if(!b.length)return null;const w=Array.from(b).sort((C,ie)=>C-ie),O=n(w,.5),M=w.map(C=>Math.abs(C-O)).sort((C,ie)=>C-ie),$=n(M,.5);if($===0)return null;let F=0;for(const C of w)Math.abs(.6745*(C-O)/$)>k&&F++;return F}function I(b){const k=b.length;if(k<8)return null;let y=0;for(const C of b)y+=C;y/=k;let w=0,O=0,M=0;for(const C of b){const ie=C-y;w+=ie*ie,O+=ie*ie*ie,M+=ie*ie*ie*ie}if(w/=k,O/=k,M/=k,w===0)return null;const $=O/w**1.5,F=M/(w*w)-3;return k/6*($*$+F*F/4)}function K(b,k,y){const w=[];let O=0;for(let C=0;C<b.length;C++){const ie=Number(b[C]),oe=Number(k[C]);!Number.isFinite(ie)||!Number.isFinite(oe)||oe<=0||(w.push([ie,oe]),O+=oe)}if(!w.length||O<=0)return null;if(w.sort((C,ie)=>C[0]-ie[0]),w.length===1)return w[0][0];const M=[];let $=0;for(const[,C]of w)M.push(($+C/2)/O),$+=C;const F=Math.max(0,Math.min(1,y));if(F<=M[0])return w[0][0];if(F>=M[M.length-1])return w[w.length-1][0];for(let C=1;C<M.length;C++){if(F>M[C])continue;const ie=M[C]-M[C-1],oe=ie>0?(F-M[C-1])/ie:0;return w[C-1][0]+(w[C][0]-w[C-1][0])*oe}return w[w.length-1][0]}function B(b,k,y){const w=W(b),O=W(k),M=new Float64Array(y.length),$=new Float64Array(y.length);let F=0;for(let C=0;C<y.length;C++){const ie=y[C],oe=Number(w(ie)),ke=Number(O(ie));!Number.isFinite(oe)||!Number.isFinite(ke)||(M[F]=oe,$[F]=ke,F++)}return{xs:M.subarray(0,F),ys:$.subarray(0,F),n:F}}function ee(b,k,y,w=!1){const{xs:O,ys:M,n:$}=B(b,k,y);if($<2)return null;let F=0,C=0;for(let oe=0;oe<$;oe++)F+=O[oe],C+=M[oe];F/=$,C/=$;let ie=0;for(let oe=0;oe<$;oe++)ie+=(O[oe]-F)*(M[oe]-C);return ie/(w?$:$-1)}function J(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;let $=0,F=0;for(let Le=0;Le<M;Le++)$+=w[Le],F+=O[Le];$/=M,F/=M;let C=0,ie=0,oe=0;for(let Le=0;Le<M;Le++){const we=w[Le]-$,De=O[Le]-F;C+=we*we,ie+=we*De,oe+=De*De}if(C===0)return null;const ke=ie/C,je=F-ke*$,Pe=oe===0?1:Math.max(0,Math.min(1,ie*ie/(C*oe))),pe=Math.max(0,oe-ke*ie),ve=M>2?Math.sqrt(pe/(M-2)/C):0;return{slope:ke,intercept:je,r2:Pe,stdError:ve,n:M}}const ue=new Set(["ols","wls","robust"]),de=new Set(["quantile"]),Oe=new Set(["ridge","lasso","elasticnet","mixed","gls"]),Ae=1.345;function Se(b,k,y){const{xtwx:w,xtwy:O}=T(b,k,y),M=se(w);if(!M)return null;const $=te(M,O),F=H(M),C=D(b,$),ie=k.map((oe,ke)=>oe-C[ke]);return{beta:$,cov:F,fitted:C,residuals:ie}}function D(b,k){return b.map(y=>y.reduce((w,O,M)=>w+O*k[M],0))}function x(b,k){const y=b.length,w=b.map(ie=>ie[k]),O=b.map(ie=>[1,...ie.filter((oe,ke)=>ke!==k)]),M=Se(O,w,null);if(!M)return 1;const $=w.reduce((ie,oe)=>ie+oe,0)/y;let F=0,C=0;for(let ie=0;ie<y;ie++)F+=M.residuals[ie]**2,C+=(w[ie]-$)**2;return C===0?1:Math.max(0,Math.min(1,1-F/C))}function fe(b){const k=[...b].sort((O,M)=>O-M),y=p(k),w=b.map(O=>Math.abs(O-y)).sort((O,M)=>O-M);return p(w)/.6745}function p(b){const k=b.length;if(!k)return 0;const y=Math.floor(k/2);return k%2?b[y]:(b[y-1]+b[y])/2}function Q(b,k,y={}){const w=y.method||"ols";if(Oe.has(w))throw new Error(`[lattice] regression method "${w}" is out of scope; use ols, wls or robust.`);if(de.has(w))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ue.has(w))throw new Error(`[lattice] unknown regression method "${w}"; use ols, wls or robust.`);const O=Array.isArray(k)?k.length:0,M=O&&Array.isArray(b[0])?b[0].length:0,$=M+1;if(!(O>$))return null;for(let Te=0;Te<O;Te++){if(!Number.isFinite(k[Te])||!Array.isArray(b[Te])||b[Te].length!==M)return null;for(let Fe=0;Fe<M;Fe++)if(!Number.isFinite(b[Te][Fe]))return null}let F=null;if(w==="wls"){if(F=y.weights,!Array.isArray(F)||F.length!==O)return null;for(let Te=0;Te<O;Te++)if(!(F[Te]>0)||!Number.isFinite(F[Te]))return null}const C=b.map(Te=>[1,...Te]);let ie,oe=null;if(w==="robust"){if(ie=Se(C,k,null),!ie)return null;for(let Te=0;Te<50;Te++){const Fe=fe(ie.residuals);if(!(Fe>0))break;const Ue=ie.residuals.map(Ge=>{const xe=Math.abs(Ge/Fe);return xe<=Ae?1:Ae/xe}),qe=Se(C,k,Ue);if(!qe)return null;const Je=qe.beta.reduce((Ge,xe,it)=>Math.max(Ge,Math.abs(xe-ie.beta[it])),0);if(ie=qe,oe=Ue,Je<1e-10)break}}else if(ie=Se(C,k,F),!ie)return null;const ke=w==="robust"?oe:F,{beta:je,cov:Pe,fitted:pe,residuals:ve}=ie;let Le=0,we=0,De=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Le+=Fe*ve[Te]**2,we+=Fe,De+=Fe*k[Te]}const $e=De/we;let Ke=0;for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1;Ke+=Fe*(k[Te]-$e)**2}const He=O-$,Qe=Le/He,Ve=Ke===0?1:Math.max(0,Math.min(1,1-Le/Ke)),ut=1-(1-Ve)*(O-1)/He,nt=Array.isArray(y.names)&&y.names.length===M?y.names:b[0].map((Te,Fe)=>`x${Fe+1}`),Ze=tt(y.confidence),rt=He>0?_(1-(1-Ze)/2,He):1/0,Lt=je.map((Te,Fe)=>{const Ue=Math.sqrt(Math.max(0,Qe*Pe[Fe][Fe])),qe=Ue>0?Te/Ue:Te===0?0:1/0,Je=Number.isFinite(qe)?2*(1-Z(Math.abs(qe),He)):0,Ge=Number.isFinite(rt)?rt*Ue:null;return{name:Fe===0?"(intercept)":nt[Fe-1],estimate:Te,stdError:Ue,t:qe,p:Math.max(0,Math.min(1,Je)),lower:Ge===null?null:Te-Ge,upper:Ge===null?null:Te+Ge}}),bt=new Array(O),yt=new Array(O);for(let Te=0;Te<O;Te++){const Fe=ke?ke[Te]:1,Ue=Math.max(0,Math.min(1,Fe*V(C[Te],Pe)));bt[Te]=Ue;const qe=(1-Ue)**2;yt[Te]=qe>0&&Qe>0?ve[Te]**2/($*Qe)*(Ue/qe):null}const Ft=b[0].map((Te,Fe)=>{if(M<2)return 1;const Ue=x(b,Fe);return Ue>=1?1/0:1/(1-Ue)});let pt=null;{const Te=ve.map(Ue=>Ue*Ue),Fe=Se(C,Te,null);if(Fe){const Ue=Te.reduce((et,Ct)=>et+Ct,0)/O;let qe=0,Je=0;for(let et=0;et<O;et++)qe+=Fe.residuals[et]**2,Je+=(Te[et]-Ue)**2;const Ge=Je===0?0:Math.max(0,Math.min(1,1-qe/Je)),xe=O*Ge,it=re(xe,M);pt={statistic:xe,df:M,p:it,heteroscedastic:it<.05}}}let wt=null;if(M===1){const Te=b.map((Fe,Ue)=>Ue).sort((Fe,Ue)=>b[Fe][0]-b[Ue][0]);wt={confidence:Ze,points:Te.map(Fe=>{const Ue=C[Fe],qe=Math.sqrt(Math.max(0,Qe*V(Ue,Pe)));return{x:b[Fe][0],yhat:pe[Fe],lower:pe[Fe]-rt*qe,upper:pe[Fe]+rt*qe}})}}return{method:w,coefficients:Lt,r2:Ve,adjR2:ut,n:O,df:He,sigma2:Qe,fitted:pe,residuals:ve,leverage:bt,cooksD:yt,vif:Ft,heteroscedasticity:pt,band:wt,weights:ke?[...ke]:null}}function X(b){const k=b.length,y=Array.from({length:k},(M,$)=>$).sort((M,$)=>b[M]-b[$]),w=new Float64Array(k);let O=0;for(;O<k;){let M=O;for(;M+1<k&&b[y[M+1]]===b[y[O]];)M++;const $=(O+M)/2+1;for(let F=O;F<=M;F++)w[y[F]]=$;O=M+1}return w}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function le(b){const k=[.01,.05,.1],y=[ce["1%"],ce["5%"],ce["10%"]];if(b<=y[0]){const M=(Math.log(k[1])-Math.log(k[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(k[0])+M*(b-y[0]))))}if(b>=y[2]){const M=(Math.log(k[2])-Math.log(k[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(k[2])+M*(b-y[2]))))}const w=b<y[1]?0:1,O=(b-y[w])/(y[w+1]-y[w]);return Math.exp(Math.log(k[w])+O*(Math.log(k[w+1])-Math.log(k[w])))}function ge(b,k,y,w){const O=y-w,M=w+3,$=new Array(O),F=new Array(O);let C=!0,ie=w;for(let pe=0;pe<O;pe++){const ve=w+pe,Le=new Float64Array(M);Le[0]=1,Le[1]=pe+1,Le[2]=b[ve];for(let we=1;we<=w;we++)Le[2+we]=k[ve-we];for(let we=1;we<M;we++)Number.isFinite(Le[we])||(ie=Math.min(ie,we-3));$[pe]=Le,F[pe]=k[ve],Number.isFinite(F[pe])||(C=!1)}if(!C)return 0;const{xtwx:oe,xtwy:ke}=T($,F,null);let je=0,Pe=1/0;for(let pe=0;pe<=ie;pe++){const ve=pe+3;if(!(O>ve))continue;const Le=new Array(ve);for(let Ve=0;Ve<ve;Ve++)Le[Ve]=oe[Ve].slice(0,ve);const we=se(Le);if(!we)continue;const De=te(we,ke.slice(0,ve));let $e=0;for(let Ve=0;Ve<O;Ve++){const ut=$[Ve];let nt=0;for(let Ze=0;Ze<ve;Ze++)nt+=ut[Ze]*De[Ze];$e+=(F[Ve]-nt)**2}const He=$e/(O-ve)*(O-ve);if(!(He>0))continue;const Qe=O*Math.log(He/O)+2*ve;Qe<Pe&&(Pe=Qe,je=pe)}return je}function Me(b,k={}){const y=[];for(let Pe=0;Pe<b.length;Pe++){const pe=Number(b[Pe]);Number.isFinite(pe)&&y.push(pe)}const w=y.length,O=w-1;if(w<8||O<6)return null;const M=new Array(O);for(let Pe=0;Pe<O;Pe++)M[Pe]=y[Pe+1]-y[Pe];let $=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.ceil(12*(w/100)**.25);$=Math.max(0,Math.min($,Math.floor((O-5)/2)));const F=(Pe,pe)=>{const ve=[],Le=[];for(let we=pe;we<O;we++){const De=[we-pe+1,y[we]];for(let $e=1;$e<=Pe;$e++)De.push(M[we-$e]);ve.push(De),Le.push(M[we])}return Q(ve,Le,{method:"ols"})},C=ge(y,M,O,$),ie=F(C,C);if(!ie||!ie.coefficients[2])return null;const oe=ie.coefficients[2].t,ke=le(oe),je=oe<ce["5%"];return{statistic:oe,usedLag:C,nobs:O-C,criticalValues:{...ce},pValue:ke,pApproximate:!0,stationary:je,verdict:je?"stationary":"non-stationary",regression:"ct"}}function be(b,k={}){const y=[];for(let je=0;je<b.length;je++){const Pe=Number(b[je]);Number.isFinite(Pe)&&y.push(Pe)}const w=y.length;if(w<3)return null;let O=Number.isFinite(k.maxlag)?Math.floor(k.maxlag):Math.min(10,w-1);O=Math.max(1,Math.min(O,w-1));let M=0;for(const je of y)M+=je;M/=w;const $=y.map(je=>je-M);let F=0;for(const je of $)F+=je*je;F/=w;const C=new Array(O+1).fill(0);C[0]=1;for(let je=1;je<=O;je++){let Pe=0;for(let pe=je;pe<w;pe++)Pe+=$[pe]*$[pe-je];C[je]=F>0?Pe/w/F:0}const ie=new Array(O+1).fill(0);ie[0]=1;let oe=[];for(let je=1;je<=O;je++){let Pe=C[je];for(let we=1;we<je;we++)Pe-=oe[we-1]*C[je-we];let pe=1;for(let we=1;we<je;we++)pe-=oe[we-1]*C[we];const ve=pe!==0?Pe/pe:0,Le=new Array(je);for(let we=1;we<je;we++)Le[we-1]=oe[we-1]-ve*oe[je-1-we];Le[je-1]=ve,ie[je]=ve,oe=Le}const ke=1.96/Math.sqrt(w);return{acf:C,pacf:ie,bounds:{upper:ke,lower:-ke},n:w,nlags:O,approximate:!0}}function ye(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2)return null;const $=X(w),F=X(O);let C=0,ie=0;for(let Pe=0;Pe<M;Pe++)C+=$[Pe],ie+=F[Pe];C/=M,ie/=M;let oe=0,ke=0,je=0;for(let Pe=0;Pe<M;Pe++){const pe=$[Pe]-C,ve=F[Pe]-ie;oe+=pe*ve,ke+=pe*pe,je+=ve*ve}return ke===0||je===0?null:Math.max(-1,Math.min(1,oe/Math.sqrt(ke*je)))}function Re(b,k,y){const{xs:w,ys:O,n:M}=B(b,k,y);if(M<2||M>j)return null;let $=0,F=0,C=0,ie=0;for(let je=0;je<M;je++)for(let Pe=je+1;Pe<M;Pe++){const pe=Math.sign(w[je]-w[Pe]),ve=Math.sign(O[je]-O[Pe]),Le=pe*ve;Le>0?$++:Le<0?F++:pe===0&&ve===0||(pe===0?C++:ie++)}const oe=$+F+ie,ke=$+F+C;return oe===0||ke===0?null:($-F)/Math.sqrt(oe*ke)}function Ne(b,k={}){const y=b.length;if(y<2)return null;const w=b[0],O=b[y-1],M=[];for(let we=1;we<y;we++){const De=b[we-1];De!==0&&M.push((b[we]-De)/Math.abs(De))}let $=null;if(M.length>1){let we=0;for(const $e of M)we+=$e;we/=M.length;let De=0;for(const $e of M)De+=($e-we)**2;$=Math.sqrt(De/(M.length-1))}const F=Number(k.periodsPerYear)>0?Number(k.periodsPerYear):null;let C=b[0],ie=0,oe=0,ke=0,je=0;for(let we=1;we<y;we++){if(b[we]>C){C=b[we],ie=we;continue}if(C<=0)continue;const De=(C-b[we])/C;De>oe&&(oe=De,ke=ie,je=we)}let Pe=null;if(y>2){let we=0;for(let Ke=0;Ke<y;Ke++)we+=b[Ke];we/=y;let De=0,$e=0;for(let Ke=0;Ke<y;Ke++){const He=b[Ke]-we;$e+=He*He,Ke>0&&(De+=He*(b[Ke-1]-we))}Pe=$e>0?De/$e:null}let pe=0,ve=0;for(const we of M)we>0?pe++:we<0&&ve++;let Le=null;if(w>0&&O>0){const we=(O/w)**(1/(y-1))-1;Le=F?(1+we)**F-1:we}return{n:y,first:w,last:O,change:O-w,changePercent:w===0?null:(O-w)/Math.abs(w)*100,volatility:$,annualisedVolatility:$!==null&&F?$*Math.sqrt(F):null,growth:Le,maxDrawdown:oe,maxDrawdownFrom:ke,maxDrawdownTo:je,autocorrelation:Pe,upDays:pe,downDays:ve}}const Ee=1.128,Be=3.267;function ze(b){const k=b.length;if(k<2)return null;const y=[];for(let O=1;O<k;O++)y.push(Math.abs(b[O]-b[O-1]));const w=y.reduce((O,M)=>O+M,0)/y.length;return{ranges:y,centre:w,upper:Be*w,lower:0}}function We(b){const k=b.length;if(k<2)return null;let y=0;for(let O=1;O<k;O++)y+=Math.abs(b[O]-b[O-1]);const w=y/(k-1);return{sigma:w/Ee,meanRange:w}}function Xe(b,k){const y=b.length;if(y<2||!k)return null;const w=Number.isFinite(Number(k.lower))?Number(k.lower):null,O=Number.isFinite(Number(k.upper))?Number(k.upper):null;if(w===null&&O===null)return null;let M=0;for(let pe=0;pe<y;pe++)M+=b[pe];M/=y;let $=0;for(let pe=0;pe<y;pe++)$+=(b[pe]-M)**2;const F=Math.sqrt($/(y-1)),C=We(b),ie=C?C.sigma:null,oe=pe=>{if(!pe||pe<=0)return{index:null,k:null};const Le=w!==null&&O!==null?(O-w)/(6*pe):null,we=O!==null?(O-M)/(3*pe):1/0,De=w!==null?(M-w)/(3*pe):1/0;return{index:Le,k:Math.min(we,De)}},ke=oe(ie),je=oe(F);let Pe=0;for(let pe=0;pe<y;pe++){if(w!==null&&b[pe]<w){Pe++;continue}O!==null&&b[pe]>O&&Pe++}return{n:y,mean:M,lower:w,upper:O,target:Number.isFinite(Number(k.target))?Number(k.target):null,sigmaWithin:ie,sigmaOverall:F,cp:ke.index,cpk:ke.k,pp:je.index,ppk:je.k,outOfSpec:Pe,defectRate:y?Pe/y:null}}function Ye(b){const k=b.length;if(k<2)return null;const y=We(b);if(!y||!(y.sigma>0))return null;let w=0;for(let O=0;O<k;O++)w+=b[O];return w/=k,{centre:w,sigma:y.sigma,upper:w+3*y.sigma,lower:w-3*y.sigma}}function Ie(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=F=>(b[F]-w)/O,$=[];for(let F=0;F<y;F++){if(Math.abs(M(F))>3&&$.push({index:F,rule:1,description:"beyond three sigma"}),F>=2)for(const C of[1,-1]){let ie=0;for(let oe=F-2;oe<=F;oe++)M(oe)*C>2&&ie++;if(ie>=2){$.push({index:F,rule:2,description:"two of three past two sigma"});break}}if(F>=4)for(const C of[1,-1]){let ie=0;for(let oe=F-4;oe<=F;oe++)M(oe)*C>1&&ie++;if(ie>=4){$.push({index:F,rule:3,description:"four of five past one sigma"});break}}if(F>=7)for(const C of[1,-1]){let ie=!0;for(let oe=F-7;oe<=F;oe++)if(M(oe)*C<=0){ie=!1;break}if(ie){$.push({index:F,rule:4,description:"eight in a row on one side"});break}}}return $}function ft(b,k){if(!k||!(k.sigma>0))return[];const y=b.length,{centre:w,sigma:O}=k,M=C=>(b[C]-w)/O,$=(C,ie,oe,ke)=>{for(const je of[1,-1]){let Pe=0;for(let pe=C;pe<=ie;pe++)M(pe)*je>oe&&Pe++;if(Pe>=ke)return!0}return!1},F=[];for(let C=0;C<y;C++){if(Math.abs(M(C))>3&&F.push({index:C,rule:1,description:"beyond three sigma"}),C>=8)for(const ie of[1,-1]){let oe=!0;for(let ke=C-8;ke<=C;ke++)if(M(ke)*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:2,description:"nine in a row on one side"});break}}if(C>=5)for(const ie of[1,-1]){let oe=!0;for(let ke=C-4;ke<=C;ke++)if((b[ke]-b[ke-1])*ie<=0){oe=!1;break}if(oe){F.push({index:C,rule:3,description:ie>0?"six rising":"six falling"});break}}if(C>=13){let ie=!0;for(let oe=C-12;oe<=C;oe++){const ke=b[oe]-b[oe-1],je=b[oe+1<=C?oe+1:oe]-b[oe];if(oe+1>C)break;if(ke===0||je===0||ke>0==je>0){ie=!1;break}}ie&&F.push({index:C,rule:4,description:"fourteen alternating"})}if(C>=2&&$(C-2,C,2,2)&&F.push({index:C,rule:5,description:"two of three past two sigma"}),C>=4&&$(C-4,C,1,4)&&F.push({index:C,rule:6,description:"four of five past one sigma"}),C>=14){let ie=!0;for(let oe=C-14;oe<=C;oe++)if(Math.abs(M(oe))>=1){ie=!1;break}ie&&F.push({index:C,rule:7,description:"fifteen within one sigma"})}if(C>=7){let ie=!0;for(let oe=C-7;oe<=C;oe++)if(Math.abs(M(oe))<=1){ie=!1;break}ie&&F.push({index:C,rule:8,description:"eight beyond one sigma"})}}return F}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,k,y="westernElectric"){return String(y)==="nelson"?ft(b,k):Ie(b,k)}function Mt(b,k,y){let w=0;for(let O=0;O<b.length;O++)(b[O]<k||b[O]>y)&&w++;return w}function Pt(b,k,y,w=20){const O=b.length;if(!O)return[];const M=b[0],$=b[O-1];if($===M)return[{from:M,to:$,count:O}];const F=y-k,C=1.5*F;let ie=F>0?Math.max(M,k-C):M,oe=F>0?Math.min($,y+C):$;oe>ie||(ie=M,oe=$);const ke=F>0?2*F/Math.cbrt(O):(oe-ie)/(Math.ceil(Math.log2(O))+1),je=ke>0?Math.min(w,Math.max(1,Math.ceil((oe-ie)/ke))):1,Pe=(oe-ie)/je,pe=[];for(let ve=0;ve<je;ve++)pe.push({from:ie+ve*Pe,to:ie+(ve+1)*Pe,count:0});for(let ve=0;ve<O;ve++){const Le=Math.min(je-1,Math.max(0,Math.floor((b[ve]-ie)/Pe)));pe[Le].count++}return pe[0].from=M,pe[je-1].to=$,pe}const _e=.95;function tt(b){const k=Number(b);return Number.isFinite(k)&&k>0&&k<1?k:_e}function Nt(b,k=_e){const y=b.length;if(y<2)return null;let w=0;for(let oe=0;oe<y;oe++)w+=b[oe];const O=w/y;let M=0;for(let oe=0;oe<y;oe++){const ke=b[oe]-O;M+=ke*ke}const $=Math.sqrt(M/(y-1)),F=tt(k),ie=_(1-(1-F)/2,y-1)*$/Math.sqrt(y);return{mean:O,lower:O-ie,upper:O+ie,margin:ie,n:y,confidence:F}}function St(b,k,y=_e){const w=Number(b),O=Number(k);if(!(O>0)||!(w>=0)||w>O)return null;const M=tt(y),$=E(1-(1-M)/2),F=w/O,C=$*$,ie=1+C/O,oe=(F+C/(2*O))/ie,ke=$/ie*Math.sqrt(F*(1-F)/O+C/(4*O*O));return{proportion:F,lower:Math.max(0,oe-ke),upper:Math.min(1,oe+ke),n:O,confidence:M}}function vt(b,k=_e){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=tt(k),O=_(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-O,upper:b.slope+O,margin:O,confidence:y}}function Tt(b,k,y=_e){const w=Number(b),O=Number(k);if(!Number.isFinite(w)||!(O>1))return null;const M=tt(y),F=E(1-(1-M)/2)*Math.sqrt(1/(9*O)+w*w/(2*(O-1)));return{index:w,lower:w-F,upper:w+F,margin:F,n:O,confidence:M}}function ht(b,k){return!b||!(b.sd>0)||!Number.isFinite(k)||!Number.isFinite(b.mean)?null:(k-b.mean)/b.sd}function dt(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*z(Math.abs(b)/2)-1)):0}function ot(b,k){const y=new Map,w=W(b);let O=0;for(let M=0;M<k.length;M++){const $=w(k[M]);if($==null||$===""||typeof $=="number"&&Number.isNaN($))continue;const F=$ instanceof Date?$.getTime():typeof $=="object"?String($):$;y.set(F,(y.get(F)||0)+1),O++}return{map:y,total:O}}function mt(b,k,y,w){if(!(k>0)||!(w>0))return null;let O=0;const M=new Set(b.keys());for(const $ of y.keys())M.add($);for(const $ of M){const F=(b.get($)||0)/k,C=(y.get($)||0)/w;O+=Math.abs(F-C)}return O/2}const st=10;function Et(b,k,y){if(y&&y.numeric){const F=h(b,k),{n:C,mean:ie}=r(F),oe=C>0?ht({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:oe,distance:oe===null?0:dt(oe),direction:oe===null?0:Math.sign(oe),subsetN:C,populationN:y.n||0,reliable:C>=st}}const{map:O,total:M}=ot(b,k),$=mt(O,M,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:$,distance:$===null?0:$,direction:0,subsetN:M,populationN:y.total||0,reliable:M>=st}}function gt(b,k){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=W(b);let w=0,O=0;for(let M=0;M<k.length&&w<200;M++){const $=y(k[M]);if($==null||$==="")continue;if($ instanceof Date)return!1;w++;const F=typeof $=="number"?$:Number($);Number.isFinite(F)&&O++}return w===0?!1:O/w>=.9}function Rt(b,k){if(gt(b,k)){const O=h(b,k),{n:M,mean:$,m2:F}=r(O);return{numeric:!0,mean:$,sd:M>0?Math.sqrt(F/M):0,n:M}}const{map:y,total:w}=ot(b,k);return{numeric:!1,map:y,total:w}}}),Ce("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return f}});const ae=me("packages/core/src/internal/util.js"),he=ae.isFunction,W=ae.warnOnce,U=me("packages/core/src/compute/handle.js"),_=U.presenceReader,Z=U.valueComparator,E=U.valueReader,z=me("packages/core/src/compute/statistics.js"),re=z.STAT_FNS,Y=z.STAT_LABELS;function se(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function te(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++){const v=P[n[L]];Number.isNaN(v)||(g+=v)}return g}for(let L=0;L<c;L++){const v=n[L];if(q(v)===1){const G=P[v];Number.isNaN(G)||(g+=G)}}return g}const A=E(r);for(let P=0;P<c;P++){const q=s(A(n[P]));q!==null&&(g+=q)}return g}te.kernel=!0;function H(r,n){const c=n.length;let g=0;if(se(r)){const P=r.values,q=_(r);if(!q){for(let L=0;L<c;L++)Number.isNaN(P[n[L]])||g++;return g}for(let L=0;L<c;L++){const v=n[L];q(v)===1&&!Number.isNaN(P[v])&&g++}return g}const A=E(r);for(let P=0;P<c;P++){const q=A(n[P]);q!=null&&!(typeof q=="number"&&Number.isNaN(q))&&g++}return g}H.kernel=!0;function T(r,n){return n.length}T.kernel=!0;function V(r,n){const c=H(r,n);return c===0?null:te(r,n)/c}V.kernel=!0;function ne(r,n,c,g){const A=n.length;if(se(r)){const v=r.values,G=_(r);let S=null;if(!G){for(let N=0;N<A;N++){const I=v[n[N]];Number.isNaN(I)||(S===null||(c<0?I<S:I>S))&&(S=I)}return S}for(let N=0;N<A;N++){const I=n[N];if(G(I)===0)continue;const K=v[I];Number.isNaN(K)||(S===null||(c<0?K<S:K>S))&&(S=K)}return S}const P=E(r),q=Z(g);let L=null;for(let v=0;v<A;v++){const G=P(n[v]);G==null||typeof G=="number"&&Number.isNaN(G)||(L===null||(c<0?q(G,L)<0:q(G,L)>0))&&(L=G)}return L}function R(r,n,c){return ne(r,n,-1,c&&c.locale)}R.kernel=!0;function j(r,n,c){return ne(r,n,1,c&&c.locale)}j.kernel=!0;function i(r,n){return n.length===0?null:E(r)(n[0])}i.kernel=!0;function a(r,n){return n.length===0?null:E(r)(n[n.length-1])}a.kernel=!0;function s(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 h={sum:te,min:R,max:j,avg:V,count:T,first:i,last:a,countValues:H,...re},u=Object.freeze({...Y,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"?u[r]||r:"Total":""}const l=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const c=l.filter(g=>g in h);for(const g of Object.keys(h))c.includes(g)||c.push(g);return c}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const c=E(r),g=[];for(let A=0;A<n.length;A++){const P=c(n[A]);P!=null&&g.push(P)}return g}function f(r,n,c,g){const A=n||[];if(typeof c=="string"){const P=h[c];return P?P(r,A,g):(W(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return he(c)?c.kernel===!0?c(r,A,g):c(d(r,A),g||{}):null}}),Ce("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/internal/util.js").warnOnce,U=me("packages/core/src/compute/handle.js").valueComparator,Z=me("packages/core/src/compute/group.js").packKeys,z=me("packages/core/src/compute/total.js").total,re="|",Y="/",se=2e3;function te(s,h,u){return`${s}${re}${h}${re}${u}`}function H(s,h){let u="";for(let t=0;t<s.length;t++){const l=s[t];u+=(t===0?"":h)+(l==null?"":String(l))}return u}function T(s,h,u={}){const t=u.separator||Y,l=h.length,{keyOf:m,readers:e}=Z(s,h,0),d=new Map,f=[],r=[];for(let L=0;L<l;L++){const v=h[L],G=m(v);if(d.has(G))continue;d.set(G,f.length),r.push(G);const S=new Array(e.length);for(let N=0;N<e.length;N++)S[N]=e[N](v);f.push(S)}const n=U(u.locale),c=f.map((L,v)=>v);c.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=V(G[N],S[N],n);if(I!==0)return I}return L-v});const g=new Array(c.length),A=new Array(c.length),P=new Map;for(let L=0;L<c.length;L++){const v=c[L];g[L]=f[v],A[L]=H(f[v],t),P.set(r[v],L)}return{keys:g,paths:A,idOf:L=>{const v=P.get(m(L));return v===void 0?-1:v}}}function V(s,h,u){const t=s==null,l=h==null;return t||l?t&&l?0:t?1:-1:u(s,h)}function ne(s){const h=s.values||s.totals||[];if(h.length&&typeof h[0]=="object"&&h[0]!==null)return h.filter(m=>m&&m.handle);const u=typeof s.handle=="function"?s.handle:null;if(!u)return h.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof s.totalOf=="function"?s.totalOf:null,l=[];for(const m of h){const e=u(m);e&&l.push({colId:m,handle:e,fn:t?t(m):"sum"})}return l}function R(s,h,u){if(Array.isArray(s)){const t=u||{};return{...t,pivotHandles:s,order:h||null,groups:t.groups||null}}return s||{}}function j(s,h,u){const t=R(s,h,u),l=t.separator||Y,m=ne(t),e=t.maxColumns===void 0?se:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,f=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(G=>H(G,l)):[""]),n=a(f),{keys:c,paths:g,idOf:A}=T(t.pivotHandles||[],n,t),P=g.length*Math.max(1,m.length),q=i(g,m,l);if(e&&P>e){const G=new Map;return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:G,cells:G,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${P} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:P,maxColumns:e}}}const L=new Map,v=g.length;for(let G=0;G<f.length;G++){const S=f[G],N=r[G]===void 0?"":r[G],I=S.length;if(I===0)continue;const K=new Int32Array(I),B=new Uint32Array(v+1);for(let ue=0;ue<I;ue++){const de=A(S[ue]);K[ue]=de,de>=0&&B[de+1]++}for(let ue=0;ue<v;ue++)B[ue+1]+=B[ue];const ee=new Uint32Array(I),J=B.slice(0,v);for(let ue=0;ue<I;ue++){const de=K[ue];de>=0&&(ee[J[de]++]=S[ue])}for(let ue=0;ue<v;ue++){const de=B[ue],Oe=B[ue+1];if(Oe===de)continue;const Ae=ee.subarray(de,Oe);for(let Se=0;Se<m.length;Se++){const D=m[Se],x=z(D.handle,Ae,D.fn,t.totalContext||{locale:t.locale});L.set(te(N,g[ue],D.colId),x)}}}return{keys:c,paths:g,fields:q,groupPaths:r,columns:P,values:L,cells:L,error:null}}function i(s,h,u){if(h.length===0)return s.slice();const t=[];for(const l of s)for(const m of h)t.push(`${l}${u}${m.colId}`);return t}function a(s){if(s.length===1)return s[0]||new Uint32Array(0);let h=0;for(const l of s)h+=l?l.length:0;const u=new Uint32Array(h);let t=0;for(const l of s)!l||l.length===0||(u.set(l,t),t+=l.length);return u}}),Ce("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return j}});const he=me("packages/core/src/compute/handle.js").valueComparator,U=me("packages/core/src/compute/total.js").total,Z=me("packages/core/src/compute/group.js").packKeys,E=me("packages/core/src/compute/pivot.js"),z=E.joinPath,re=E.DEFAULT_PATH_SEPARATOR,Y=E.DEFAULT_MAX_COLUMNS,se="";function te(i,a,s={}){const h=s.separator||re,u=i||[],t=a instanceof Uint32Array?a:Uint32Array.from(a||[]),l=t.length;if(u.length===0)return{tuples:[[]],paths:[se],buckets:[t]};const{keyOf:m,readers:e}=Z(u,t,0),d=new Map,f=[],r=[],n=[];for(let L=0;L<l;L++){const v=t[L],G=m(v);let S=d.get(G);if(S===void 0){S=f.length,d.set(G,S),r.push(G);const N=new Array(e.length);for(let I=0;I<e.length;I++)N[I]=e[I](v);f.push(N),n.push([])}n[S].push(v)}const c=he(s.locale),g=f.map((L,v)=>v);g.sort((L,v)=>{const G=f[L],S=f[v];for(let N=0;N<G.length;N++){const I=H(G[N],S[N],c);if(I!==0)return I}return L-v});const A=new Array(g.length),P=new Array(g.length),q=new Array(g.length);for(let L=0;L<g.length;L++){const v=g[L];A[L]=f[v],P[L]=z(f[v],h),q[L]=Uint32Array.from(n[v])}return{tuples:A,paths:P,buckets:q}}function H(i,a,s){const h=i==null,u=a==null;return h||u?h&&u?0:h?1:-1:s(i,a)}function T(i,a,s){const h=[];for(let u=0;u<i.length;u++)s.has(i[u])&&h.push(i[u]);return Uint32Array.from(h)}function V(i,a,s,h){return{value:a.length?U(i,a,s,h):null,leaves:a,count:a.length}}function ne(i){const a=i&&i.opts||{},s=a.separator||re,h=a.totalContext||{locale:a.locale},u=(i.measures||[]).filter(P=>P&&P.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),l=te(i.rowHandles||[],t,{...a,separator:s}),m=te(i.columnHandles||[],t,{...a,separator:s}),e=a.maxColumns===void 0?Y:a.maxColumns,d=m.paths.length*Math.max(1,u.length),f=new Map;if(e&&d>e)return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:f,rowMargin:f,columnMargin:f,grand:f,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,c=new Map,g=new Map,A=m.buckets.map(P=>new Set(P));for(let P=0;P<m.paths.length;P++){const q=m.buckets[P],L=m.paths[P];for(const v of u)c.set(j(L,v.colId),V(v.handle,q,v.fn,h))}for(let P=0;P<l.paths.length;P++){const q=l.buckets[P],L=l.paths[P];for(const v of u)n.set(j(L,v.colId),V(v.handle,q,v.fn,h));for(let v=0;v<m.paths.length;v++){const G=T(q,m.buckets[v],A[v]);if(G.length===0)continue;const S=m.paths[v];for(const N of u)r.set(R(L,S,N.colId),V(N.handle,G,N.fn,h))}}for(const P of u)g.set(P.colId,V(P.handle,t,P.fn,h));return{rowAxis:l,columnAxis:m,measures:u.map(P=>({colId:P.colId,fn:P.fn})),body:r,rowMargin:n,columnMargin:c,grand:g,columns:d,error:null}}function R(i,a,s){return`${i}\\0${a}\\0${s}`}function j(i,a){return`${i}\\0${a}`}}),Ce("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return ne}});const he=me("packages/core/src/internal/util.js").getPath,W=me("packages/core/src/compute/handle.js"),U=W.isMissing,_=W.valueComparator,E=me("packages/core/src/compute/filter.js").testValue,z="",re="\\0";function Y(i,a){const s=a.includes(".")?he(i,a):i?.[a];return s===void 0?null:s}function se(i,a,s={}){const h=a||[];let u=i.map((t,l)=>l);if(h.length===0)return u;for(let t=h.length-1;t>=0;t--)u=te(i,u,h[t],s);return u}function te(i,a,s,h){const u=s.locale!==void 0?s.locale:h.locale,t=_(u),l=s.descending!==void 0?!!s.descending:s.dir==="desc",m=[],e=[];for(const r of a){const n=Y(i[r],s.col);U(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const f=(r,n)=>{const c=Y(i[r],s.col),g=Y(i[n],s.col);let A;return typeof s.compare=="function"?(A=s.compare(c,g,i[r],i[n],l),l&&(A=-A)):A=l?t(g,c):t(c,g),A!==0?A:d.get(r)-d.get(n)};return m.sort(f),s.nullsFirst?e.concat(m):m.concat(e)}function H(i,a,s={}){const h=[];for(let u=0;u<i.length;u++)T(i[u],a,s,u)&&h.push(u);return h}function T(i,a,s,h){if(!a)return!0;if(Array.isArray(a.conditions)){const u=a.conditions.filter(l=>l!=null);if(u.length===0)return!0;if(a.op==="or")return u.some(l=>T(i,l,s,h));const t=u.every(l=>T(i,l,s,h));return a.op==="not"?!t:t}return a.col===void 0&&typeof s.custom=="function"?!!s.custom(a,i,h):E(Y(i,a.col),a,s.locale)}function V(i,a,s,h){const u=s||i.map((e,d)=>d),t=new Map,l=[],m=[];for(const e of u){const d=a.map((n,c)=>{const g=Y(i[e],n);return h&&h[c]?h[c](g):g}),f=d.map(n=>n==null?re:String(n)).join(z);let r=t.get(f);r===void 0&&(r=l.length,t.set(f,r),l.push(d),m.push([])),m[r].push(e)}return{keys:l,buckets:m}}function ne(i,a,s={}){const h=_(s.locale),u=i.filter(l=>!U(l)),t=u.map(R).filter(l=>l!==null);switch(a){case"count":return i.length;case"countValues":return u.length;case"sum":return t.reduce((l,m)=>l+m,0);case"avg":return u.length===0?null:t.reduce((l,m)=>l+m,0)/u.length;case"min":return u.length===0?null:u.reduce((l,m)=>h(m,l)<0?m:l);case"max":return u.length===0?null:u.reduce((l,m)=>h(m,l)>0?m:l);case"first":return i.length===0?null:j(i[0]);case"last":return i.length===0?null:j(i[i.length-1]);default:return null}}function R(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 a=Number(i);return Number.isNaN(a)?null:a}function j(i){return i===void 0?null:i}}),Ce("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return Z}});const he=me("packages/core/src/compute/sketch.js").Welford;class W{#t;#e;#n=[];#r;#i;constructor(z,re=0,Y=Date.now){if(z!=="count"&&z!=="time"&&z!=="session")throw new RangeError(`unknown window kind: ${z}`);if((z==="count"||z==="time")&&!(re>0))throw new RangeError(`a ${z} window needs a positive span`);this.#t=z,this.#e=Math.floor(re),this.#r=Y,this.#i=Y()}get size(){return this.#n.length}push(z,re=this.#r()){Number.isFinite(z)&&(this.#n.push({t:re,v:z}),this.#s(re))}#s(z){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=z-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const z=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:z,size:this.#n.length}}values(){return this.#n.map(z=>z.v)}aggregate(){const z=this.spec();if(!this.#n.length)return{over:z,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let Y=0,se=1/0,te=-1/0;for(const{v:H}of this.#n)Y+=H,H<se&&(se=H),H>te&&(te=H),re.add(H);return{over:z,count:this.#n.length,sum:Y,mean:re.mean(),min:se,max:te,variance:re.variance(),stddev:re.stddev()}}reduce(z){const re=this.aggregate(),Y={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(z in Y))throw new RangeError(`unknown windowed aggregate: ${z}`);return{value:Y[z],over:re.over}}}const U=Object.freeze(["count","time","session"]);function _(E,z=Date.now){const re=E.kind==="time"&&E.minutes!=null?E.minutes*6e4:E.span??0;return new W(E.kind,re,z)}const Z={Window:W,WINDOW_KINDS:U,openWindow:_}}),Ce("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return h}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,U=me("packages/core/src/compute/special.js").logGamma,_=.6745,Z=3.5,E=1.5,z=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function Y(u){if(!u.length)return null;const l=Array.from(u,Number).sort((f,r)=>f-r),m=he(l,.5),e=l.map(f=>Math.abs(f-m)).sort((f,r)=>f-r),d=he(e,.5);return{median:m,mad:d}}function se(u,t={}){const l=Number.isFinite(t.threshold)?t.threshold:Z,m=u.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),f=[];for(let c=0;c<m;c++){const g=Number(u[c]);Number.isFinite(g)&&f.push(g)}if(!f.length)return{median:null,mad:null,threshold:l,scores:e,flags:d,flagged:0};const r=Y(f);if(r.mad===0)return{median:r.median,mad:0,threshold:l,scores:e,flags:d,flagged:0};let n=0;for(let c=0;c<m;c++){const g=Number(u[c]);if(!Number.isFinite(g))continue;const A=_*(g-r.median)/r.mad;e[c]=A,Math.abs(A)>l&&(d[c]=!0,n++)}return{median:r.median,mad:r.mad,threshold:l,scores:e,flags:d,flagged:n}}function te(u,t={}){const l=Number.isFinite(t.k)?t.k:E,m=[];for(let n=0;n<u.length;n++){const c=Number(u[n]);Number.isFinite(c)&&m.push(c)}if(!m.length)return null;const e=m.sort((n,c)=>n-c),d=he(e,.25),f=he(e,.75),r=f-d;return{q1:d,q3:f,iqr:r,lower:d-l*r,upper:f+l*r,k:l}}function H(u,t){if(t<=0)return 0;const l=U(u);if(t<u+1){let c=u,g=1/u,A=g;for(let P=0;P<1e3&&(c+=1,A*=t/c,g+=A,!(Math.abs(A)<Math.abs(g)*1e-15));P++);return g*Math.exp(-t+u*Math.log(t)-l)}const m=1e-300;let e=t+1-u,d=1/m,f=1/e,r=f;for(let c=1;c<1e3;c++){const g=-c*(c-u);e+=2,f=g*f+e,Math.abs(f)<m&&(f=m),d=e+g/d,Math.abs(d)<m&&(d=m),f=1/f;const A=f*d;if(r*=A,Math.abs(A-1)<1e-15)break}return 1-Math.exp(-t+u*Math.log(t)-l)*r}function T(u,t){return u<=0?0:H(t/2,u/2)}function V(u,t=z){if(!(t>0)||!(t<1))return NaN;let l=0,m=Math.max(1,u);for(;T(m,u)<t;)m*=2;for(let e=0;e<200;e++){const d=(l+m)/2;if(T(d,u)<t?l=d:m=d,m-l<1e-10)break}return(l+m)/2}function ne(u){const t=u.length,l=u.map((m,e)=>{const d=m.slice();for(let f=0;f<t;f++)d.push(e===f?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let f=m+1;f<t;f++)Math.abs(l[f][m])>Math.abs(l[e][m])&&(e=f);if(Math.abs(l[e][m])<1e-12)return null;if(e!==m){const f=l[e];l[e]=l[m],l[m]=f}const d=l[m][m];for(let f=0;f<2*t;f++)l[m][f]/=d;for(let f=0;f<t;f++){if(f===m)continue;const r=l[f][m];if(r!==0)for(let n=0;n<2*t;n++)l[f][n]-=r*l[m][n]}}return l.map(m=>m.slice(t))}function R(u,t){const l=u.length,m=new Array(t).fill(0);for(const f of u)for(let r=0;r<t;r++)m[r]+=f[r];for(let f=0;f<t;f++)m[f]/=l;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const f of u)for(let r=0;r<t;r++){const n=f[r]-m[r];for(let c=r;c<t;c++)e[r][c]+=n*(f[c]-m[c])}const d=l>1?l-1:1;for(let f=0;f<t;f++)for(let r=f;r<t;r++)e[f][r]/=d,e[r][f]=e[f][r];return{mean:m,cov:e}}function j(u,t={}){const l=Number.isFinite(t.p)?t.p:z,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=u.length;if(!e)return null;const d=u[0].length;if(!d)return null;const f=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),c=[],g=[];for(let N=0;N<e;N++){const I=u[N];let K=I.length===d;const B=new Array(d);for(let ee=0;K&&ee<d;ee++){const J=Number(I[ee]);Number.isFinite(J)?B[ee]=J:K=!1}K&&(c.push(N),g.push(B))}const A=d,P=V(A,l);if(g.length<=d)return{center:[],df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0};const{mean:q,cov:L}=R(g,d);let v=ne(L),G=!1;if(!v){G=!0;let N=0;for(let B=0;B<d;B++)N+=L[B][B];const I=N/d*m||m,K=L.map((B,ee)=>B.map((J,ue)=>ee===ue?J+I:J));if(v=ne(K),!v)return{center:q,df:A,cutoff:P,singular:!0,used:g.length,distances:f,squared:r,flags:n,flagged:0}}let S=0;for(let N=0;N<g.length;N++){const I=g[N],K=new Array(d);for(let J=0;J<d;J++)K[J]=I[J]-q[J];let B=0;for(let J=0;J<d;J++){let ue=0;for(let de=0;de<d;de++)ue+=v[J][de]*K[de];B+=K[J]*ue}B<0&&(B=0);const ee=c[N];r[ee]=B,f[ee]=Math.sqrt(B),B>P&&(n[ee]=!0,S++)}return{center:q,df:A,cutoff:P,singular:G,used:g.length,distances:f,squared:r,flags:n,flagged:S}}const i=20,a=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function s(u,t={}){const l=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:Z,d=Number.isFinite(t.k)?t.k:E,f=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=u.length,n=new Array(r).fill(null),c=new Array(r).fill(!1);let g=0;for(let A=0;A<r;A++){const P=Number(u[A]);if(!Number.isFinite(P))continue;const q=Math.max(0,A-m+1),L=[];for(let v=q;v<=A;v++){const G=Number(u[v]);Number.isFinite(G)&&L.push(G)}if(!(L.length<f))if(l==="rollingIqr"){const v=te(L,{k:d});if(!v)continue;(P<v.lower||P>v.upper)&&(c[A]=!0,g++)}else{const v=Y(L);if(!v||v.mad===0)continue;const G=_*(P-v.median)/v.mad;n[A]=G,Math.abs(G)>e&&(c[A]=!0,g++)}}return{method:l,windowLen:m,minPeriods:f,threshold:e,k:d,scores:n,flags:c,flagged:g}}function h(u={}){const t=u||{},l=t.field;if(typeof l!="string"||!l)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||a.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,f=t.latest===!0,r=a.includes(m),n=c=>Number(c==null?NaN:c[l]);return c=>{const g=Array.isArray(c)?c.slice():[...c];d&&g.sort((v,G)=>{const S=v?.[d],N=G?.[d];return S===N?0:S==null?-1:N==null?1:S<N?-1:1});const A=g.map(n);let P,q;if(r)({flags:P,scores:q}=s(A,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const v=te(A,{k:t.k});P=A.map(G=>v?Number.isFinite(G)&&(G<v.lower||G>v.upper):!1),q=A.map(()=>null)}else({flags:P,scores:q}=se(A,{threshold:t.threshold}));if(f){const v=P.length-1;return v<0||!P[v]?!1:{method:m,field:l,flagged:[{row:g[v],score:q[v]}]}}const L=[];for(let v=0;v<P.length;v++)P[v]&&L.push({row:g[v],score:q[v]});return L.length?{method:m,field:l,flagged:L}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return u}});const ae=me("packages/core/src/compute/special.js"),he=ae.normalQuantile,W=ae.studentTQuantile,_=me("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),E=1e-4,z=1-1e-4;function re(t){const l=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,f=Number.isFinite(e.value)?e.value:null;l.push({at:d,value:f})}else l.push({at:m,value:Number.isFinite(e)?Number(e):null})}return l}function Y(t){const l=t.filter(r=>r.value!==null),m=l[0],e=l[l.length-1],d=e.at-m.at,f=l.length>1&&d>0?d/(l.length-1):1;return{lastAt:e.at,step:f}}function se(t){return Math.min(z,Math.max(E,t))}function te(t,l=E,m=z,e=80){const d=(Math.sqrt(5)-1)/2;let f=l,r=m,n=r-d*(r-f),c=f+d*(r-f),g=t(n),A=t(c);for(let P=0;P<e;P++)g<A?(r=c,c=n,A=g,n=r-d*(r-f),g=t(n)):(f=n,n=c,g=A,c=f+d*(r-f),A=t(c));return(f+r)/2}function H(t,l){let m=null,e=0,d=0;for(let f=0;f<t.length;f++){const r=t[f];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=l*r+(1-l)*m}}return{level:m,sse:e,m:d}}function T(t,l,m){let e=null,d=null,f=0,r=0;for(let n=0;n<t.length;n++){const c=t[n];if(c===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=c;continue}d===null&&(d=c-e);const g=e+d;f+=(c-g)**2,r+=1;const A=e;e=l*c+(1-l)*(A+d),d=m*(e-A)+(1-m)*d}return{level:e,trend:d,sse:f,m:r}}function V(t,l,m,e,d){const f=t.length;if(f<2*l)return null;const r=G=>{let S=0,N=0;for(let I=G;I<G+l&&I<f;I++)t[I]!==null&&(S+=t[I],N+=1);return N?S/N:null},n=r(0),c=r(l);if(n===null||c===null)return null;let g=n,A=(c-n)/l;const P=new Array(l).fill(0);for(let G=0;G<l;G++)P[G]=t[G]===null?0:t[G]-g;const q=P.reduce((G,S)=>G+S,0)/l;for(let G=0;G<l;G++)P[G]-=q;let L=0,v=0;for(let G=l;G<f;G++){const S=G%l,N=P[S],I=t[G];if(I===null){g+=A;continue}const K=g+A+N;L+=(I-K)**2,v+=1;const B=g;g=m*(I-N)+(1-m)*(g+A),A=e*(g-B)+(1-e)*A,P[S]=d*(I-g)+(1-d)*N}return{level:g,trend:A,season:P,phase:(f-1)%l,sse:L,count:v}}function ne(t,l,m){let e=1;for(const f of l)e+=f*f;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function R(t,l={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=Z.includes(l.method)?l.method:"linear",e=Math.max(1,Math.floor(Number(l.horizon)||1)),d=Number.isFinite(l.confidence)&&l.confidence>0&&l.confidence<1?l.confidence:.95,f=1-(1-d)/2,r=re(t),n=r.map(L=>L.value),c=n.filter(L=>L!==null),g=c.length,{lastAt:A,step:P}=g?Y(r):{lastAt:0,step:1},q=L=>A+L*P;return m==="linear"?j(r,g,e,d,f,q):m==="movingAverage"?i(c,g,e,d,f,l,q):m==="ses"?a(n,g,e,d,f,l,q):m==="holt"?s(n,g,e,d,f,l,q):h(n,g,e,d,f,l,q)}function j(t,l,m,e,d,f){if(l<2)return null;let r=0,n=0;for(const I of t)I.value!==null&&(r+=I.at,n+=I.value);r/=l,n/=l;let c=0,g=0,A=0;for(const I of t){if(I.value===null)continue;const K=I.at-r,B=I.value-n;c+=K*K,g+=K*B,A+=B*B}if(c===0)return null;const P=g/c,q=n-P*r,L=A===0?1:Math.max(0,Math.min(1,g*g/(c*A))),v=Math.max(0,A-P*g),G=l>2?Math.sqrt(v/(l-2)):null,S=l>2?W(d,l-2):null,N=[];for(let I=1;I<=m;I++){const K=f(I),B=q+P*K;let ee=null,J=null,ue=null,de=null,Oe=null;if(G!==null){const Ae=1/l+(K-r)**2/c,Se=G*Math.sqrt(1+Ae),D=G*Math.sqrt(Ae);Oe=Se,ee=B-S*Se,J=B+S*Se,ue=B-S*D,de=B+S*D}N.push({step:I,at:K,mean:B,lower:ee,upper:J,lowerMean:ue,upperMean:de,se:Oe})}return{method:"linear",horizon:m,confidence:e,n:l,sigma:G,r2:L,params:{slope:P,intercept:q},points:N}}function i(t,l,m,e,d,f,r){if(l<1)return null;const n=Math.max(1,Math.min(l,Math.floor(Number(f.windowLen)||l))),c=t.slice(l-n);let g=0;for(const G of c)g+=G;const A=g/n;let P=null,q=null;if(n>1){let G=0;for(const N of c)G+=(N-A)**2;P=Math.sqrt(G/(n-1))*Math.sqrt(1+1/n),q=W(d,n-1)}const L=P===null?null:q*P,v=[];for(let G=1;G<=m;G++)v.push({step:G,at:r(G),mean:A,lower:L===null?null:A-L,upper:L===null?null:A+L,se:P});return{method:"movingAverage",horizon:m,confidence:e,n:l,sigma:P===null?null:P,params:{windowLen:n},points:v}}function a(t,l,m,e,d,f,r){if(l<1)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null;n===null&&(n=te(q=>H(t,q).sse));const c=H(t,n),g=he(d),A=c.m>0?c.sse/c.m:null,P=[];for(let q=1;q<=m;q++){const L=c.level;let v=null,G=null,S=null;if(A!==null){const N=[];for(let K=1;K<q;K++)N.push(n);const I=ne(A,N,g);S=I.se,v=L-I.margin,G=L+I.margin}P.push({step:q,at:r(q),mean:L,lower:v,upper:G,se:S})}return{method:"ses",horizon:m,confidence:e,n:l,sigma:A===null?null:Math.sqrt(A),params:{alpha:n},points:P}}function s(t,l,m,e,d,f,r){if(l<2)return null;let n=Number.isFinite(f.alpha)?se(f.alpha):null,c=Number.isFinite(f.beta)?se(f.beta):null;if(n===null||c===null){let v=n===null?.5:n,G=c===null?.5:c;for(let S=0;S<6;S++)n===null&&(v=te(N=>T(t,N,G).sse)),c===null&&(G=te(N=>T(t,v,N).sse));n=n===null?v:n,c=c===null?G:c}const g=T(t,n,c),A=he(d),P=g.m>0?g.sse/g.m:null,q=n*c,L=[];for(let v=1;v<=m;v++){const G=g.level+v*g.trend;let S=null,N=null,I=null;if(P!==null){const K=[];for(let ee=1;ee<v;ee++)K.push(n+ee*q);const B=ne(P,K,A);I=B.se,S=G-B.margin,N=G+B.margin}L.push({step:v,at:r(v),mean:G,lower:S,upper:N,se:I})}return{method:"holt",horizon:m,confidence:e,n:l,sigma:P===null?null:Math.sqrt(P),params:{alpha:n,beta:c},points:L}}function h(t,l,m,e,d,f,r){const n=Math.floor(Number(f.period));if(!(n>=2))return _("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(l<2*n)return null;let c=Number.isFinite(f.alpha)?se(f.alpha):null,g=Number.isFinite(f.beta)?se(f.beta):null,A=Number.isFinite(f.gamma)?se(f.gamma):null;const P=(I,K,B)=>{const ee=V(t,n,I,K,B);return ee?ee.sse:1/0};if(c===null||g===null||A===null){let I=c===null?.5:c,K=g===null?.5:g,B=A===null?.5:A;for(let ee=0;ee<8;ee++)c===null&&(I=te(J=>P(J,K,B))),g===null&&(K=te(J=>P(I,J,B))),A===null&&(B=te(J=>P(I,K,J)));c=c===null?I:c,g=g===null?K:g,A=A===null?B:A}const q=V(t,n,c,g,A);if(!q)return null;const L=he(d),v=q.count>0?q.sse/q.count:null,G=c*g,S=A*(1-c),N=[];for(let I=1;I<=m;I++){const K=q.season[(q.phase+I)%n],B=q.level+I*q.trend+K;let ee=null,J=null,ue=null;if(v!==null){const de=[];for(let Ae=1;Ae<I;Ae++)de.push(c+Ae*G+(Ae%n===0?S:0));const Oe=ne(v,de,L);ue=Oe.se,ee=B-Oe.margin,J=B+Oe.margin}N.push({step:I,at:r(I),mean:B,lower:ee,upper:J,se:ue})}return{method:"holtWinters",horizon:m,confidence:e,n:l,sigma:v===null?null:Math.sqrt(v),params:{alpha:c,beta:g,gamma:A,period:n},points:N}}const u={FORECAST_METHODS:Z,forecast:R}}),Ce("packages/core/src/compute/index.js",function(o,me){"use strict";const ae=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return ae.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return ae.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return ae.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return ae.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return ae.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return ae.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return ae.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return ae.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const W=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return W.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return W.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return W.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return W.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return W.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return W.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return W.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return W.mentionsColumn}});const U=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return U.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return U.packKeys}});const _=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return _.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return _.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return _.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return _.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return _.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return _.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return _.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return _.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return _.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return _.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return _.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return _.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return _.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return _.QUANTILE_SAMPLE}});const Z=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const E=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return E.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return E.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return E.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return E.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return E.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return E.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return E.DEFAULT_MAX_COLUMNS}});const z=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return z.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return z.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return z.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return z.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return z.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const Y=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return Y.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return Y.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return Y.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return Y.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return Y.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return Y.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Y.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return Y.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return Y.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return Y.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return Y.isMissing}});const se=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return se.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return se.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return se.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return se.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return se.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return se.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return se.SKETCH_BOUNDS}});const te=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return te.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return te.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te.openWindow}});const H=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return H.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return H.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return H.maintenanceOf}});const T=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return T.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return T.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return T.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return T.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return T.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return T.anomalyCondition}});const V=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return V.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return V.forecast}})}),Ce("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return s}});const ae=me("packages/worker/src/transport.js"),he=ae.PROTOCOL,W=ae.OPS,U=ae.CONTROL,_=ae.ERRORS,Z=ae.unpackHandle,E=ae.unpackHandles,z=ae.createMaskPool,re=ae.collectTransfers,Y=me("packages/core/src/store/columnpack.js"),se=Y.packChunk,te=Y.packedTransfers;let H=null,T=null,V=null;async function ne(h){if(H)return H;if(!T){const u=h||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));T=Promise.resolve().then(u).then(t=>(H=t,t)).catch(t=>(V=t,H=null,null))}return T}function R(h){H=h,T=h?Promise.resolve(h):null,V=h?null:V}function j(h,u,t){const l=new Map;for(const m of h)m&&l.set(m.id,m);return{handle(m){return l.get(m)},count:u,pool:z(),locale:t}}function i(h,u){const{op:t,args:l}=h;if(t===W.COLUMNIZE)return se(l.schema||[],l.rows||[],l.opts||{});const m=u[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=_.NO_KERNEL,e}switch(t){case W.COLLATE_STRING_RANKS:return m(l.table||[],(l.table||[]).length,l.locale);case W.SORT_COLUMN:return m(Z(l.handle),l.order??null,l.opts||{});case W.SORT_MULTI:{const e=E(l.handles||[]),d=(l.entries||[]).map(f=>({...f,handle:e[f.index]}));return m(e,d,l.order??null)}case W.EVALUATE_FILTERS:return m(l.filters,j(E(l.handles||[]),l.count,l.locale));case W.COMPACT:return m(l.mask,l.count,void 0);case W.GROUP_BY_COLUMNS:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.TOTAL:return m(Z(l.handle),l.indices??null,l.fn);case W.PIVOT:return m(E(l.handles||[]),l.order??null,l.opts||{});case W.FACET:return m(Z(l.handle),l.indices??null,l.count,l.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=_.PROTOCOL,e}}}async function a(h,u={}){if(!h||h.lattice!==he)return null;const{id:t,op:l}=h;if(l===U.CANCEL)return u.cancelled?.add(h.target),null;if(l===U.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(l===W.COLUMNIZE){if(u.cancelled?.has(t))return u.cancelled.delete(t),null;try{const e=se(h.args.schema||[],h.args.rows||[],h.args.opts||{});return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:te(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await ne(u.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:_.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${V?V.message:"module not found"}`}},transfer:[]};if(u.cancelled?.has(t))return u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(h,m);return u.cancelled?.has(t)?(u.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:_.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||_.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function s(h,u={}){const t=new Set,l=async m=>{const e=await a(m.data,{loader:u.loader,cancelled:t});e&&h.postMessage(e.reply,e.transfer)};return h.addEventListener("message",l),ne(u.loader).then(m=>{h.postMessage({lattice:he,id:0,op:U.READY,compute:!!m})}),()=>h.removeEventListener("message",l)}});var kt=at("packages/worker/src/kernel.js");Ot.__latticeKernel=kt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Qe=Wn("packages/dom/src/index.js"),ro=Qe.createGrid,io=Qe.gridElementsWithin,oo=Qe.createStat,so=Qe.deltaOf,ao=Qe.toneOf,lo=Qe.readTable,uo=Qe.hydrateTable,co=Qe.autoInit,ho=Qe.createLocalViewStorage,fo=Qe.DEFAULT_VIEWS_KEY,po=Qe.createHeadlessGrid,mo=Qe.defaults,go=Qe.version,yo=Qe.getVersion,bo=Qe.Grid,wo=Qe.EventBus,vo=Qe.Registry,ko=Qe.sharedRegistry,So=Qe.registerModules,Oo=Qe.parseLicence,Ao=Qe.verifyLicence,jo=Qe.licenceInfo,Po=Qe.watermark,Co=Qe.setLicence,Eo=Qe.licenceState,To=Qe.isLocalHost,Mo=Qe.matchesDomain,No=Qe.LicenceHolder,Ro=Qe.ColumnModel,Lo=Qe.buildGraph,Fo=Qe.Lookup,xo=Qe.ValuePipeline,Io=Qe.compileFormat,$o=Qe.compileMask,Do=Qe.specToOoxml,zo=Qe.EXTENDED_TYPES,Bo=Qe.createRadixType,Uo=Qe.RADIX_PRESETS,Ho=Qe.parseRadix,Vo=Qe.formatRadix,Go=Qe.createUnitType,Ko=Qe.registerUnitSystem,Wo=Qe.defineUnit,_o=Qe.UNIT_SYSTEMS,qo=Qe.parseUnit,Zo=Qe.formatUnit,Yo=Qe.createCurrencyType,Xo=Qe.parseMoney,Qo=Qe.formatMoney,Jo=Qe.convertMoney,es=Qe.rateFunction,ts=Qe.MISSING_RATE,ns=Qe.Messages,rs=Qe.createMessages,is=Qe.auditCatalogue,os=Qe.EN_GB,ss=Qe.MESSAGE_KEYS,as=Qe.DEFAULT_LOCALE,ls=Qe.formatList,us=Qe.resolveLocale,cs=Qe.LOCALES,ds=Qe.resolveCatalogue,hs=Qe.EN_US,fs=Qe.FR_FR,ps=Qe.FR_CA,ms=Qe.IT_IT,gs=Qe.ES_ES,ys=Qe.PT_BR,bs=Qe.DE_DE,ws=Qe.NL_NL,vs=Qe.SV_SE,ks=Qe.DA_DK,Ss=Qe.NB_NO,Os=Qe.FI_FI,As=Qe.PL_PL,js=Qe.CS_CZ,Ps=Qe.HU_HU,Cs=Qe.RO_RO,Es=Qe.UK_UA,Ts=Qe.EL_GR,Ms=Qe.JA_JP,Ns=Qe.AR,Rs=Qe.AR_SA,Ls=Qe.ColumnStore,Fs=Qe.Bitset,xs=Qe.Dictionary,Is=Qe.MultiValue,$s=Qe.MaskPool,Ds=Qe.sortColumn,zs=Qe.sortMulti,Bs=Qe.evaluateFilters,Us=Qe.compact,Hs=Qe.testValue,Vs=Qe.groupByColumns,Gs=Qe.total,Ks=Qe.TOTAL_FNS,Ws=Qe.pivot,_s=Qe.Window,qs=Qe.openWindow,Zs=Qe.WINDOW_KINDS,Ys=Qe.ANOMALY_METHODS,Xs=Qe.modifiedZScores,Qs=Qe.iqrFences,Js=Qe.mahalanobis,ea=Qe.ROLLING_ANOMALY_METHODS,ta=Qe.rollingAnomalies,na=Qe.anomalyCondition,ra=Qe.FORECAST_METHODS,ia=Qe.forecast,oa=Qe.evaluateFormula,sa=Qe.parseFormula,aa=Qe.referencesOf,la=Qe.looksLikeFormula,ua=Qe.FormulaError,ca=Qe.FUNCTIONS,da=Qe.compileRules,ha=Qe.ingest,fa=Qe.ingestSync,pa=Qe.createSource,ma=Qe.createMemorySource,ga=Qe.createPagedSource,ya=Qe.createRemoteSource,ba=Qe.createStreamSource,wa=Qe.createUrlSource,va=Qe.PROTOCOL,ka=Qe.createPushdownSource,Sa=Qe.planQuery,Oa=Qe.splitFilters,Aa=Qe.applyResidual,ja=Qe.capabilitiesOf,Pa=Qe.resolveMutate,Ca=Qe.NO_CAPABILITIES,Ea=Qe.odataAdapter,Ta=Qe.filtersToOData,Ma=Qe.conditionToOData,Na=Qe.restAdapter,Ra=Qe.DEFAULT_PARAMS,La=Qe.dfqlAdapter,Fa=Qe.duckdbAdapter,xa=Qe.filtersToSql,Ia=Qe.graphqlAdapter,$a=Qe.splunkAdapter,Da=Qe.clickhouseAdapter,za=Qe.elasticsearchAdapter,Ba=Qe.RowModel,Ua=Qe.createRowKey,Ha=Qe.SelectionModel,Va=Qe.RangeModel,Ga=Qe.EditModel,Ka=Qe.ChangeModel,Wa=Qe.StateModel,_a=Qe.STATE_VERSION,qa=Qe.serialiseState,Za=Qe.restoreState,Ya=Qe.VERSION,Xa=Qe.DomRenderer,Qa=Qe.FilterMenu,Ja=Qe.mergeColumnFilter,el=Qe.branchFor,tl=Qe.ColumnMenu,nl=Qe.columnMenuItems,rl=Qe.cellMenuItems,il=Qe.autoGroupMenuItems,ol=Qe.AlignedGrids,sl=Qe.alignGrids,al=Qe.layoutState,ll=Qe.ToolPanelDock,ul=Qe.panelHost,cl=Qe.mountPanel,dl=Qe.CellEditController,hl=Qe.EditBar,fl=Qe.HistoryBar,pl=Qe.HISTORY_CLS,ml=Qe.DiffPainter,gl=Qe.ViewPicker,yl=Qe.VIEW_CLS,bl=Qe.summariseDiff,wl=Qe.PromptBar,vl=Qe.PROMPT_CLASS,kl=Qe.createCellLayer,Sl=Qe.compileTemplate,Ol=Qe.compileVariant,Al=Qe.checkVariant,jl=Qe.VariantRegistry,Pl=Qe.BUILTIN_RENDERERS,Cl=Qe.BUILTIN_VARIANTS,El=Qe.BUILTIN_PIPES,Tl=Qe.sanitiseHtml,Ml=Qe.editors,Nl=Qe.createEditor,Rl=Qe.editorFor,Ll=Qe.BaseEditor,Fl=Qe.filters,xl=Qe.createFilter,Il=Qe.filterFor,$l=Qe.parseExpression,Dl=Qe.ConditionFilter,zl=Qe.StatusBar,Bl=Qe.ContextMenu,Ul=Qe.ToolPanel,Hl=Qe.TooltipManager,Vl=Qe.Pagination,Gl=Qe.OverlayLayer,Kl=Qe.LatticeGrid,Wl=Qe.setLicense,_l=Qe.licenseInfo,ql=Qe.licenseState;var Zl=Qe.default;export{Ys as ANOMALY_METHODS,Ns as AR,Rs as AR_SA,ol as AlignedGrids,El as BUILTIN_PIPES,Pl as BUILTIN_RENDERERS,Cl as BUILTIN_VARIANTS,Ll as BaseEditor,Fs as Bitset,js as CS_CZ,dl as CellEditController,Ka as ChangeModel,tl as ColumnMenu,Ro as ColumnModel,Ls as ColumnStore,Dl as ConditionFilter,Bl as ContextMenu,ks as DA_DK,as as DEFAULT_LOCALE,Ra as DEFAULT_PARAMS,fo as DEFAULT_VIEWS_KEY,bs as DE_DE,xs as Dictionary,ml as DiffPainter,Xa as DomRenderer,Ts as EL_GR,os as EN_GB,hs as EN_US,gs as ES_ES,zo as EXTENDED_TYPES,hl as EditBar,Ga as EditModel,wo as EventBus,Os as FI_FI,ra as FORECAST_METHODS,ps as FR_CA,fs as FR_FR,ca as FUNCTIONS,Qa as FilterMenu,ua as FormulaError,bo as Grid,pl as HISTORY_CLS,Ps as HU_HU,fl as HistoryBar,ms as IT_IT,Ms as JA_JP,cs as LOCALES,Kl as LatticeGrid,No as LicenceHolder,Fo as Lookup,ss as MESSAGE_KEYS,ts as MISSING_RATE,$s as MaskPool,ns as Messages,Is as MultiValue,Ss as NB_NO,ws as NL_NL,Ca as NO_CAPABILITIES,Gl as OverlayLayer,As as PL_PL,vl as PROMPT_CLASS,va as PROTOCOL,ys as PT_BR,Vl as Pagination,wl as PromptBar,Uo as RADIX_PRESETS,ea as ROLLING_ANOMALY_METHODS,Cs as RO_RO,Va as RangeModel,vo as Registry,Ba as RowModel,_a as STATE_VERSION,vs as SV_SE,Ha as SelectionModel,Wa as StateModel,zl as StatusBar,Ks as TOTAL_FNS,Ul as ToolPanel,ll as ToolPanelDock,Hl as TooltipManager,Es as UK_UA,_o as UNIT_SYSTEMS,Ya as VERSION,yl as VIEW_CLS,xo as ValuePipeline,jl as VariantRegistry,gl as ViewPicker,Zs as WINDOW_KINDS,_s as Window,sl as alignGrids,na as anomalyCondition,Aa as applyResidual,is as auditCatalogue,il as autoGroupMenuItems,co as autoInit,el as branchFor,Lo as buildGraph,ja as capabilitiesOf,rl as cellMenuItems,Al as checkVariant,Da as clickhouseAdapter,nl as columnMenuItems,Us as compact,Io as compileFormat,$o as compileMask,da as compileRules,Sl as compileTemplate,Ol as compileVariant,Ma as conditionToOData,Jo as convertMoney,kl as createCellLayer,Yo as createCurrencyType,Nl as createEditor,xl as createFilter,ro as createGrid,po as createHeadlessGrid,ho as createLocalViewStorage,ma as createMemorySource,rs as createMessages,ga as createPagedSource,ka as createPushdownSource,Bo as createRadixType,ya as createRemoteSource,Ua as createRowKey,pa as createSource,oo as createStat,ba as createStreamSource,Go as createUnitType,wa as createUrlSource,Zl as default,mo as defaults,Wo as defineUnit,so as deltaOf,La as dfqlAdapter,Fa as duckdbAdapter,Rl as editorFor,Ml as editors,za as elasticsearchAdapter,Bs as evaluateFilters,oa as evaluateFormula,Il as filterFor,Fl as filters,Ta as filtersToOData,xa as filtersToSql,ia as forecast,ls as formatList,Qo as formatMoney,Vo as formatRadix,Zo as formatUnit,yo as getVersion,Ia as graphqlAdapter,io as gridElementsWithin,Vs as groupByColumns,uo as hydrateTable,ha as ingest,fa as ingestSync,Qs as iqrFences,To as isLocalHost,al as layoutState,jo as licenceInfo,Eo as licenceState,_l as licenseInfo,ql as licenseState,la as looksLikeFormula,Js as mahalanobis,Mo as matchesDomain,Ja as mergeColumnFilter,Xs as modifiedZScores,cl as mountPanel,Ea as odataAdapter,qs as openWindow,ul as panelHost,$l as parseExpression,sa as parseFormula,Oo as parseLicence,Xo as parseMoney,Ho as parseRadix,qo as parseUnit,Ws as pivot,Sa as planQuery,es as rateFunction,lo as readTable,aa as referencesOf,So as registerModules,Ko as registerUnitSystem,ds as resolveCatalogue,us as resolveLocale,Pa as resolveMutate,Na as restAdapter,Za as restoreState,ta as rollingAnomalies,Tl as sanitiseHtml,qa as serialiseState,Co as setLicence,Wl as setLicense,ko as sharedRegistry,Ds as sortColumn,zs as sortMulti,Do as specToOoxml,Oa as splitFilters,$a as splunkAdapter,bl as summariseDiff,Hs as testValue,ao as toneOf,Gs as total,Ao as verifyLicence,go as version,Po as watermark};
58
58
 
59
59
  //# sourceMappingURL=lattice-grid.esm.min.js.map