@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, mapview module
2
+ * Lattice Grid 1.89.1, mapview module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- (function(jn){"use strict";var bn=Object.create(null),yn=Object.create(null);function Xe(n,me){bn[n]=me}function wn(n){var me=yn[n];if(me)return me;var ye=Object.create(null);yn[n]=ye;var J=bn[n];if(!J)throw new Error("[lattice] missing module: "+n);return J(ye,wn),ye}Xe("packages/core/src/internal/util.js",function(n,me){"use strict";Object.defineProperty(n,"VERSION",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"reportedWarnings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"warnOnce",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"infoOnce",{enumerable:!0,get:function(){return I}}),Object.defineProperty(n,"resetWarnings",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"fail",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"invariant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"DEV",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"isFunction",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"isNil",{enumerable:!0,get:function(){return p}}),Object.defineProperty(n,"isBlank",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"isCtor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(n,"pathGetter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"pathSetter",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"getPath",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"setPath",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"humanise",{enumerable:!0,get:function(){return N}}),Object.defineProperty(n,"escapeHtml",{enumerable:!0,get:function(){return V}}),Object.defineProperty(n,"titleCase",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(n,"expand",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"toArray",{enumerable:!0,get:function(){return x}}),Object.defineProperty(n,"merge",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"mergeRow",{enumerable:!0,get:function(){return e}}),Object.defineProperty(n,"Lru",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"collator",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"defaultCompare",{enumerable:!0,get:function(){return E}}),Object.defineProperty(n,"now",{enumerable:!0,get:function(){return se}}),Object.defineProperty(n,"nextFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(n,"cancelFrame",{enumerable:!0,get:function(){return K}}),Object.defineProperty(n,"frameBatched",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"settleDebounce",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"whenIdle",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"uid",{enumerable:!0,get:function(){return T}});const ye="1.89.0";async function J(){return ye}const i="1.89.0",be=new Set,ce=2e3;function he(g){if(be.add(g),be.size>ce){const b=be.values().next().value;b!==void 0&&be.delete(b)}}const D=[],G=500;function le(g,b,L){D.push({key:g,level:b,message:L.map(f=>typeof f=="string"?f:U(f)).join(" "),at:Date.now()}),D.length>G&&D.shift()}function U(g){if(g instanceof Error)return g.message;try{return JSON.stringify(g)}catch{return String(g)}}function O(){return D.map(g=>({...g}))}function F(g){if(g.length===0||typeof g[0]!="string")return g;const b=g[0].replace(/^\[lattice\]\s*/,"");return b===g[0]?g:[b,...g.slice(1)]}function h(g,...b){if(be.has(g))return;he(g);const L=F(b);le(g,"warn",L),console.warn("[lattice]",...L)}function I(g,...b){if(be.has(g))return;he(g);const L=F(b);le(g,"info",L),console.info("[lattice]",...L)}function M(){be.clear(),D.length=0}function d(g,b){const L=new Error(`[lattice] ${g}`);throw b!==void 0&&(L.cause=b),L}function u(g,b){g||d(b)}const s=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(g){return g!==null&&typeof g=="object"&&!Array.isArray(g)}function y(g){return typeof g=="function"}function p(g){return g==null}function o(g){return g==null||g===""}function S(g){return typeof g!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(g))?!0:!!(g.prototype&&Object.getOwnPropertyNames(g.prototype).length>1)}const l=new Map;function _(g){let b=l.get(g);if(b)return b;if(!g.includes("."))b=L=>L?.[g];else{const L=g.split("."),f=L.length;b=R=>{let t=R;for(let v=0;v<f;v++){if(t==null)return;t=t[L[v]]}return t}}return l.set(g,b),b}const re=new Map;function te(g){let b=re.get(g);if(b)return b;if(!g.includes("."))b=(L,f)=>{L!=null&&(L[g]=f)};else{const L=g.split("."),f=L.length-1;b=(R,t)=>{let v=R;for(let a=0;a<f;a++){if(v==null)return;const z=L[a];v[z]==null&&(v[z]={}),v=v[z]}v!=null&&(v[L[f]]=t)}}return re.set(g,b),b}function ae(g,b){return _(b)(g)}function oe(g,b,L){te(b)(g,L)}function N(g){return g?(g.includes(".")?g.slice(g.lastIndexOf(".")+1):g).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(/^./,L=>L.toUpperCase()):""}const q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function V(g){const b=g==null?"":String(g);return/[&<>"']/.test(b)?b.replace(/[&<>"']/g,L=>q[L]):b}function ie(g){return String(g).replace(/\w\S*/g,b=>b[0].toUpperCase()+b.slice(1).toLowerCase())}function C(g,b,L){if(g!==void 0)return g===!0?{enabled:!0,...L}:g===!1?{enabled:!1}:r(g)?g:{[b]:g,enabled:!0}}function x(g){return g==null?[]:Array.isArray(g)?g:[g]}const Q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function c(g,b){if(!r(g))return r(b)?{...b}:b;if(!r(b))return b===void 0?g:b;const L={...g};for(const f of Object.keys(b)){if(Q.has(f))continue;const R=b[f];R!==void 0&&(L[f]=r(R)&&r(L[f])?c(L[f],R):R)}return L}function e(g,b){if(!r(g)||!r(b)||g===b)return b;const L=Object.create(Object.getPrototypeOf(g));return Object.assign(L,g,b),L}class w{#e;#t=new Map;#n;constructor(b=256,L=null){this.#e=b,this.#n=L}get size(){return this.#t.size}get max(){return this.#e}set max(b){this.#e=b,this.#r()}has(b){return this.#t.has(b)}get(b){const L=this.#t;if(!L.has(b))return;const f=L.get(b);return L.delete(b),L.set(b,f),f}peek(b){return this.#t.get(b)}set(b,L){const f=this.#t;return f.has(b)&&f.delete(b),f.set(b,L),this.#r(),L}delete(b){const L=this.#t.get(b);return this.#t.delete(b)&&this.#n&&this.#n(L,b),L}clear(){if(this.#n)for(const[b,L]of this.#t)this.#n(L,b);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const b=this.#t;for(;b.size>this.#e;){const L=b.keys().next().value,f=b.get(L);b.delete(L),this.#n&&this.#n(f,L)}}}const k=new Map;function B(g,b){const L=`${g||""}|${b?JSON.stringify(b):""}`;let f=k.get(L);return f||(f=new Intl.Collator(g||void 0,{numeric:!0,sensitivity:"variant",...b}),k.set(L,f)),f}function E(g,b){if(g===b)return 0;if(g==null)return 1;if(b==null)return-1;if(typeof g=="number"&&typeof b=="number")return Number.isNaN(g)?Number.isNaN(b)?0:1:Number.isNaN(b)||g<b?-1:g>b?1:0;const L=String(g),f=String(b);return L<f?-1:L>f?1:0}function se(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const X=typeof requestAnimationFrame=="function";function j(g){return X?requestAnimationFrame(g):setTimeout(()=>g(se()),16)}function K(g){g!=null&&(X?cancelAnimationFrame(g):clearTimeout(g))}function ee(g){let b=null,L=null;const f=()=>{b=null;const t=L;L=null,g(...t||[])},R=(...t)=>{L=t,b===null&&(b=j(f))};return R.cancel=()=>{K(b),b=null,L=null},R.flush=()=>{b!==null&&(K(b),f())},R}function pe(g,b){let L=null,f=null;const R=()=>{if(L=null,f===null)return;const a=f;f=null,g(...a),t()},t=()=>{L=setTimeout(R,b),typeof L?.unref=="function"&&L.unref()},v=(...a)=>{L===null?(g(...a),t()):(f=a,clearTimeout(L),t())};return v.flush=()=>{if(L!==null&&clearTimeout(L),L=null,f===null)return;const a=f;f=null,g(...a)},v.cancel=()=>{L!==null&&clearTimeout(L),L=null,f=null},v.pending=()=>L!==null||f!==null,v}function ne(g,b=50){return typeof requestIdleCallback=="function"?requestIdleCallback(g,{timeout:b}):setTimeout(()=>g({timeRemaining:()=>0,didTimeout:!0}),1)}let ke=0;function T(g="l"){return`${g}${(++ke).toString(36)}`}}),Xe("packages/modules/geometry/geodata.js",function(n,me){"use strict";Object.defineProperty(n,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"EARTH_RADIUS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"toWkt",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"toWkb",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(n,"readGeometry",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"parseGeometry",{enumerable:!0,get:function(){return se}}),Object.defineProperty(n,"haversine",{enumerable:!0,get:function(){return j}}),Object.defineProperty(n,"geometryInfo",{enumerable:!0,get:function(){return L}}),Object.defineProperty(n,"geometryKind",{enumerable:!0,get:function(){return f}}),Object.defineProperty(n,"spatialOperand",{enumerable:!0,get:function(){return t}}),Object.defineProperty(n,"spatialPredicate",{enumerable:!0,get:function(){return xe}});const ye=me("packages/core/src/internal/util.js"),J=ye.isNil,i=ye.isObject,be=ye.warnOnce,ce=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),he=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),D=Object.freeze([...he,"blank","notBlank"]),G=63710088e-1,le=Math.PI/180,U=16,O=1e-12;class F extends Error{}function h($){throw new F($)}function I($){(!Array.isArray($)||$.length<2)&&h("a position needs at least two numbers");const P=Number($[0]),W=Number($[1]);return(typeof $[0]!="number"||typeof $[1]!="number"||!Number.isFinite(P)||!Number.isFinite(W))&&h("a coordinate is not a finite number"),[P,W]}function M($,P,W){Array.isArray($)||h(`${W} is not an array of positions`);const fe=$.map(I);return fe.length<P&&h(`${W} needs at least ${P} positions, found ${fe.length}`),fe}function d($){const P=M($,3,"a polygon ring"),W=P[0],fe=P[P.length-1];return(W[0]!==fe[0]||W[1]!==fe[1])&&P.push([W[0],W[1]]),P.length<4&&h(`a polygon ring needs at least 3 distinct corners, found ${P.length-1}`),P}function u($){return(!Array.isArray($)||$.length===0)&&h("a polygon needs at least an outer ring"),$.map(d)}function s($,P){switch(P>U&&h("geometry collections nest too deeply"),i($)||h("GeoJSON must be an object"),$.type){case"Feature":return $.geometry==null?null:s($.geometry,P+1);case"FeatureCollection":return h("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:I($.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:M($.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:M($.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray($.coordinates)||!$.coordinates.length)&&h("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:$.coordinates.map(W=>M(W,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:u($.coordinates)};case"MultiPolygon":return(!Array.isArray($.coordinates)||!$.coordinates.length)&&h("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:$.coordinates.map(u)};case"GeometryCollection":{(!Array.isArray($.geometries)||!$.geometries.length)&&h("a GeometryCollection needs at least one geometry");const W=$.geometries.map(fe=>s(fe,P+1)).filter(Boolean);return W.length?{type:"GeometryCollection",geometries:W}:null}default:return h(`"${String($.type)}" is not a GeoJSON geometry type`)}}const r=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),y=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,p=/[A-Za-z]+/y,o=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class S{text;at=0;constructor(P){this.text=P}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(P){this.space(),this.text[this.at]!==P&&h(`WKT expected "${P}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(P){return this.space(),this.text[this.at]===P?(this.at++,!0):!1}word(){this.space(),p.lastIndex=this.at;const P=p.exec(this.text);return P?(this.at+=P[0].length,P[0].toUpperCase()):""}numberNext(){return this.space(),y.lastIndex=this.at,y.test(this.text)}number(){this.space(),y.lastIndex=this.at;const P=y.exec(this.text);return P||h(`WKT expected a number at character ${this.at+1}`),this.at+=P[0].length,Number(P[0])}position(){const P=this.number(),W=this.number();for(;this.numberNext();)this.number();return[P,W]}positionList(){this.expect("(");const P=[this.position()];for(;this.accept(",");)P.push(this.position());return this.expect(")"),P}empty(){const P=this.at;return this.word()==="EMPTY"?!0:(this.at=P,!1)}geometry(P){P>U&&h("geometry collections nest too deeply");const W=this.word(),fe=r[W];fe||h(W?`"${W}" is not a WKT geometry type`:"WKT expected a geometry type");const $e=this.at,ve=this.word();return ve!=="Z"&&ve!=="M"&&ve!=="ZM"&&(this.at=$e),this.empty()?null:this.body(fe,P)}body(P,W){switch(P){case"Point":{this.expect("(");const fe=this.position();return this.expect(")"),{type:"Point",coordinates:fe}}case"LineString":return{type:"LineString",coordinates:M(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const fe=[];do this.empty()||(this.accept("(")?(fe.push(this.position()),this.expect(")")):fe.push(this.position()));while(this.accept(","));return this.expect(")"),fe.length?{type:"MultiPoint",coordinates:fe}:null}case"MultiLineString":{const fe=this.parts(()=>M(this.positionList(),2,"a LineString"));return fe.length?{type:"MultiLineString",coordinates:fe}:null}case"MultiPolygon":{const fe=this.parts(()=>this.polygonBody());return fe.length?{type:"MultiPolygon",coordinates:fe}:null}default:{this.expect("(");const fe=[];do{const $e=this.geometry(W+1);$e&&fe.push($e)}while(this.accept(","));return this.expect(")"),fe.length?{type:"GeometryCollection",geometries:fe}:null}}}parts(P){this.expect("(");const W=[];do this.empty()||W.push(P());while(this.accept(","));return this.expect(")"),W}polygonBody(){return u(this.parts(()=>this.positionList()))}}function l($){const P=new S(String($).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),W=P.geometry(0);return P.space(),P.at<P.text.length&&h(`WKT has unexpected text after the geometry at character ${P.at+1}`),W}function _($){return Object.is($,-0)?"0":String($)}function re($){return`${_($[0])} ${_($[1])}`}function te($){return`(${$.map(re).join(", ")})`}function ae($){return`(${$.map(te).join(", ")})`}function oe($){const P=se($);return P?N(P):""}function N($){switch($.type){case"Point":return`POINT (${re($.coordinates)})`;case"LineString":return`LINESTRING ${te($.coordinates)}`;case"Polygon":return`POLYGON ${ae($.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${$.coordinates.map(P=>`(${re(P)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${$.coordinates.map(te).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${$.coordinates.map(ae).join(", ")})`;default:return`GEOMETRYCOLLECTION (${$.geometries.map(N).join(", ")})`}}class q{view;at=0;constructor(P){this.view=new DataView(P.buffer,P.byteOffset,P.byteLength)}need(P){this.at+P>this.view.byteLength&&h(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(P){this.need(4);const W=this.view.getUint32(this.at,P);return this.at+=4,W}f64(P){this.need(8);const W=this.view.getFloat64(this.at,P);return this.at+=8,W}count(P,W){const fe=this.u32(P);return fe*W>this.view.byteLength-this.at&&h(`WKB claims ${fe} elements, more than its bytes can hold`),fe}position(P,W){const fe=this.f64(P),$e=this.f64(P);for(let ve=2;ve<W;ve++)this.f64(P);return[fe,$e]}positions(P,W){const fe=this.count(P,8*W),$e=new Array(fe);for(let ve=0;ve<fe;ve++)$e[ve]=this.position(P,W);return $e}geometry(P,W){P>U&&h("geometry collections nest too deeply");const fe=this.u8();fe!==0&&fe!==1&&h(`WKB byte-order mark is ${fe}, not 0 or 1`);const $e=fe===1,ve=this.u32($e);let Me=2;ve&2147483648&&Me++,ve&1073741824&&Me++,ve&536870912&&this.u32($e);let Te=ve&268435455;if(Te>=1e3){const Ue=Math.floor(Te/1e3);Ue>3&&h(`WKB geometry type ${Te} is not one this reads`),Me=2+(Ue===3?2:1),Te%=1e3}const Be=ce[Te-1];switch(Be||h(`WKB geometry type ${Te} is not one this reads`),W&&Be!==W&&h(`a part of a WKB Multi${W} is a ${Be}`),Be){case"Point":{const Ue=this.position($e,Me);return Number.isNaN(Ue[0])&&Number.isNaN(Ue[1])?null:{type:"Point",coordinates:I(Ue)}}case"LineString":return{type:"LineString",coordinates:M(this.positions($e,Me),2,"a LineString")};case"Polygon":{const Ue=this.count($e,4),Re=[];for(let He=0;He<Ue;He++)Re.push(this.positions($e,Me));return Ue?{type:"Polygon",coordinates:u(Re)}:null}default:{const Ue=this.count($e,5),Re=Be==="GeometryCollection"?void 0:Be.slice(5),He=[];for(let We=0;We<Ue;We++){const pt=this.geometry(P+1,Re);pt&&He.push(pt)}return He.length?Be==="GeometryCollection"?{type:Be,geometries:He}:{type:Be,coordinates:He.map(We=>We.coordinates)}:null}}}}function V($){const P=new q($),W=P.geometry(0);return P.at!==$.byteLength&&h(`WKB has ${$.byteLength-P.at} bytes left over after the geometry`),W}function ie($){const P=se($);if(!P)return null;const W=[];let fe=0;const $e=Re=>{const He=new DataView(new ArrayBuffer(5));He.setUint8(0,1),He.setUint32(1,ce.indexOf(Re)+1,!0),W.push(He),fe+=5},ve=Re=>{const He=new DataView(new ArrayBuffer(4));He.setUint32(0,Re,!0),W.push(He),fe+=4},Me=Re=>{const He=new DataView(new ArrayBuffer(16*Re.length));Re.forEach((We,pt)=>{He.setFloat64(pt*16,We[0],!0),He.setFloat64(pt*16+8,We[1],!0)}),W.push(He),fe+=16*Re.length},Te=Re=>{switch($e(Re.type),Re.type){case"Point":Me([Re.coordinates]);break;case"LineString":ve(Re.coordinates.length),Me(Re.coordinates);break;case"Polygon":ve(Re.coordinates.length);for(const He of Re.coordinates)ve(He.length),Me(He);break;case"GeometryCollection":ve(Re.geometries.length);for(const He of Re.geometries)Te(He);break;default:{const He=Re.type.slice(5);ve(Re.coordinates.length);for(const We of Re.coordinates)Te({type:He,coordinates:We})}}};Te(P);const Be=new Uint8Array(fe);let Ue=0;for(const Re of W)Be.set(new Uint8Array(Re.buffer),Ue),Ue+=Re.byteLength;return Be}const C=/^0[01](?:[0-9a-fA-F]{2})+$/,x=/^[A-Za-z0-9+/_-]+={0,2}$/,Q=(()=>{const $=new Int16Array(128).fill(-1),P="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let W=0;W<P.length;W++)$[P.charCodeAt(W)]=W;return $[45]=62,$[95]=63,$})();function c($){const P=new Uint8Array($.length/2);for(let W=0;W<P.length;W++)P[W]=parseInt($.slice(W*2,W*2+2),16);return P}function e($){const P=$.replace(/=+$/,""),W=new Uint8Array(Math.floor(P.length*3/4));let fe=0,$e=0,ve=0;for(let Me=0;Me<P.length;Me++)$e=$e<<6|Q[P.charCodeAt(Me)],fe+=6,fe>=8&&(fe-=8,W[ve++]=$e>>fe&255);return W.subarray(0,ve)}function w($){const P=$.trim();if(P==="")return null;if(P[0]==="{"){let W;try{W=JSON.parse(P)}catch{return h("the text starts like GeoJSON but is not valid JSON")}return s(W,0)}if(C.test(P))return V(c(P));if(o.test(P))return l(P);if(x.test(P)){const W=e(P);if(W.length>=5&&(W[0]===0||W[0]===1))return V(W)}return h("the text is not WKT, GeoJSON, or hex or base64 WKB")}const k=new WeakSet;function B($){if(J($))return{geometry:null,reason:null};if(typeof $=="object"&&k.has($))return{geometry:$,reason:null};try{let P;return typeof $=="string"?P=w($):$ instanceof Uint8Array?P=V($):$ instanceof ArrayBuffer?P=V(new Uint8Array($)):ArrayBuffer.isView($)?P=V(new Uint8Array($.buffer,$.byteOffset,$.byteLength)):i($)?P=s($,0):h(`${Array.isArray($)?"an array":`a ${typeof $}`} is not a geometry`),P&&E(P),{geometry:P||null,reason:null}}catch(P){if(P instanceof F)return{geometry:null,reason:P.message};throw P}}function E($){if(k.add($),$.type==="GeometryCollection")for(const P of $.geometries)E(P)}function se($){return B($).geometry}function X($,P){switch($.type){case"Point":P($.coordinates);break;case"MultiPoint":case"LineString":$.coordinates.forEach(P);break;case"MultiLineString":case"Polygon":for(const W of $.coordinates)W.forEach(P);break;case"MultiPolygon":for(const W of $.coordinates)for(const fe of W)fe.forEach(P);break;default:for(const W of $.geometries)X(W,P)}}function j($,P){const W=$[1]*le,fe=P[1]*le,$e=fe-W,ve=(P[0]-$[0])*le,Me=Math.sin($e/2)**2+Math.cos(W)*Math.cos(fe)*Math.sin(ve/2)**2;return 2*G*Math.asin(Math.min(1,Math.sqrt(Me)))}function K($){let P=0;for(let W=1;W<$.length;W++)P+=j($[W-1],$[W]);return P}function ee($){const P=$.length-1;if(P<3)return 0;let W=0;for(let fe=0;fe<P;fe++){const $e=$[(fe-1+P)%P],ve=$[(fe+1)%P];W+=(ve[0]-$e[0])*le*Math.sin($[fe][1]*le)}return Math.abs(W)*G*G/2}function pe($){let P=ee($[0]);for(let W=1;W<$.length;W++)P-=ee($[W]);return Math.max(0,P)}function ne($){let P=0,W=0,fe=0;for(let $e=0;$e<$.length-1;$e++){const[ve,Me]=$[$e],[Te,Be]=$[$e+1],Ue=ve*Be-Te*Me;P+=Ue,W+=(ve+Te)*Ue,fe+=(Me+Be)*Ue}return{a:P,cx:W,cy:fe}}function ke(){let $=0,P=0,W=0;return{add(fe,$e,ve){$+=fe*ve,P+=$e*ve,W+=ve},get(){return W>0?[$/W,P/W]:null}}}function T($){let P=0,W=0;for(const fe of $)P+=fe[0],W+=fe[1];return[P/$.length,W/$.length]}function g($,P){switch($.type){case"Point":P[0].add($.coordinates[0],$.coordinates[1],1);break;case"MultiPoint":for(const W of $.coordinates)P[0].add(W[0],W[1],1);break;case"LineString":case"MultiLineString":{const W=$.type==="LineString"?[$.coordinates]:$.coordinates;for(const fe of W){for(let $e=1;$e<fe.length;$e++){const[ve,Me]=fe[$e-1],[Te,Be]=fe[$e],Ue=Math.hypot(Te-ve,Be-Me);P[1].add((ve+Te)/2,(Me+Be)/2,Ue)}for(const $e of fe)P[0].add($e[0],$e[1],1)}break}case"Polygon":case"MultiPolygon":{const W=$.type==="Polygon"?[$.coordinates]:$.coordinates;for(const fe of W){let $e=0,ve=0,Me=0;fe.forEach((Be,Ue)=>{const Re=ne(Be),He=(Ue===0?1:-1)*(Re.a<0?-1:1);$e+=He*Re.a,ve+=He*Re.cx,Me+=He*Re.cy}),Math.abs($e)>O&&P[2].add(ve/(3*$e),Me/(3*$e),Math.abs($e)/2);const Te=fe[0].slice(0,-1);for(const Be of Te)P[0].add(Be[0],Be[1],1)}break}default:for(const W of $.geometries)g(W,P)}}const b=new WeakMap;function L($){const P=se($);if(!P)return null;const W=b.get(P);if(W)return W;const fe=[1/0,1/0,-1/0,-1/0];X(P,Re=>{Re[0]<fe[0]&&(fe[0]=Re[0]),Re[1]<fe[1]&&(fe[1]=Re[1]),Re[0]>fe[2]&&(fe[2]=Re[0]),Re[1]>fe[3]&&(fe[3]=Re[1])});const $e=[ke(),ke(),ke()];g(P,$e);const ve=$e[2].get()||$e[1].get()||$e[0].get()||T([[fe[0],fe[1]],[fe[2],fe[3]]]);let Me=0,Te=0;const Be=Re=>{switch(Re.type){case"LineString":Me+=K(Re.coordinates);break;case"MultiLineString":for(const He of Re.coordinates)Me+=K(He);break;case"Polygon":Te+=pe(Re.coordinates);for(const He of Re.coordinates)Me+=K(He);break;case"MultiPolygon":for(const He of Re.coordinates){Te+=pe(He);for(const We of He)Me+=K(We)}break;case"GeometryCollection":for(const He of Re.geometries)Be(He);break;default:break}};Be(P);const Ue=Object.freeze({kind:P.type,bbox:Object.freeze(fe),centroid:Object.freeze(ve),length:Me,area:Te});return b.set(P,Ue),Ue}function f($){const P=L($);return P?P.kind:null}function R($,P){const W=typeof $=="string"?$.split(/[\s,;]+/).filter(Boolean):$;if(!Array.isArray(W)||W.length!==P)return null;const fe=W.map($e=>typeof $e=="number"?$e:typeof $e=="string"?Number($e):NaN);return fe.every(Number.isFinite)?fe:null}function t($,P){if($==="withinBbox"){const W=R(P,4);return W?W[0]>W[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:W[1]>W[3]?{reason:"the box's minLat is above its maxLat"}:{operand:W}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if($==="withinDistance"){let W=null;if(i(P)&&!Array.isArray(P)){const fe=P;W=R([fe.lon,fe.lat,fe.metres],3)}else W=R(P,3);return!W||W[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:W[0],lat:W[1],metres:W[2]}}}if($==="withinPolygon"||$==="intersects"){const W=$==="intersects"?R(P,4):null;if(W){if(W[0]>W[2]||W[1]>W[3])return{reason:"the box's minimum is above its maximum"};const[ve,Me,Te,Be]=W;return{operand:{type:"Polygon",coordinates:[[[ve,Me],[Te,Me],[Te,Be],[ve,Be],[ve,Me]]]}}}const{geometry:fe,reason:$e}=B(P);return fe?$==="withinPolygon"&&fe.type!=="Polygon"&&fe.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${fe.type}`}:{operand:fe}:{reason:`${$} needs a geometry: ${$e||"none was given"}`}}return{reason:`"${$}" is not a spatial operator`}}function v($,P){const[W,fe]=$;let $e=!1;for(let ve=0,Me=P.length-2;ve<P.length-1;Me=ve++){const[Te,Be]=P[ve],[Ue,Re]=P[Me];Be>fe!=Re>fe&&W<(Ue-Te)*(fe-Be)/(Re-Be)+Te&&($e=!$e)}return $e}function a($,P){if(!v($,P[0]))return!1;for(let W=1;W<P.length;W++)if(v($,P[W]))return!1;return!0}function z($,P={points:[],segments:[],polygons:[]}){const W=fe=>{for(let $e=1;$e<fe.length;$e++)P.segments.push([fe[$e-1],fe[$e]]);for(const $e of fe)P.points.push($e)};switch($.type){case"Point":P.points.push($.coordinates);break;case"MultiPoint":for(const fe of $.coordinates)P.points.push(fe);break;case"LineString":W($.coordinates);break;case"MultiLineString":$.coordinates.forEach(W);break;case"Polygon":P.polygons.push($.coordinates),$.coordinates.forEach(W);break;case"MultiPolygon":for(const fe of $.coordinates)P.polygons.push(fe),fe.forEach(W);break;default:for(const fe of $.geometries)z(fe,P)}return P}function H($,P,W){const fe=(P[0]-$[0])*(W[1]-$[1])-(P[1]-$[1])*(W[0]-$[0]);return Math.abs(fe)<=O?0:Math.sign(fe)}function Y($,P,W){return $[0]>=Math.min(P[0],W[0])-O&&$[0]<=Math.max(P[0],W[0])+O&&$[1]>=Math.min(P[1],W[1])-O&&$[1]<=Math.max(P[1],W[1])+O}function A($,P){const[W,fe]=$,[$e,ve]=P,Me=H(W,fe,$e),Te=H(W,fe,ve),Be=H($e,ve,W),Ue=H($e,ve,fe);return Me!==Te&&Be!==Ue?!0:Me===0&&Y($e,W,fe)||Te===0&&Y(ve,W,fe)||Be===0&&Y(W,$e,ve)||Ue===0&&Y(fe,$e,ve)}function Z($,P){return $[0]<=P[2]&&P[0]<=$[2]&&$[1]<=P[3]&&P[1]<=$[3]}function de($,P){const W=L($),fe=L(P);if(!Z(W.bbox,fe.bbox))return!1;const $e=z($),ve=z(P);for(const Me of ve.polygons)for(const Te of $e.points)if(a(Te,Me))return!0;for(const Me of $e.polygons)for(const Te of ve.points)if(a(Te,Me))return!0;for(const Me of $e.segments)for(const Te of ve.segments)if(A(Me,Te))return!0;for(const Me of $e.points){for(const Te of ve.points)if(Math.abs(Me[0]-Te[0])<=O&&Math.abs(Me[1]-Te[1])<=O)return!0;for(const Te of ve.segments)if(H(Te[0],Te[1],Me)===0&&Y(Me,Te[0],Te[1]))return!0}for(const Me of ve.points)for(const Te of $e.segments)if(H(Te[0],Te[1],Me)===0&&Y(Me,Te[0],Te[1]))return!0;return!1}function xe($,P){const{operand:W,reason:fe}=t($,P);if(fe)return be(`filter:geometry:${$}`,`a "${$}" condition was refused: ${fe}. It matches no row rather than guessing.`),()=>!1;switch($){case"withinBbox":return $e=>{const ve=L($e);if(!ve)return!1;const Me=ve.bbox;return Me[0]>=W[0]&&Me[1]>=W[1]&&Me[2]<=W[2]&&Me[3]<=W[3]};case"withinPolygon":{const $e=W.type==="Polygon"?[W.coordinates]:W.coordinates,ve=Me=>$e.some(Te=>a(Me,Te));return Me=>{const Te=se(Me);return Te?Te.type==="Point"?ve(Te.coordinates):Te.type==="MultiPoint"?Te.coordinates.every(ve):ve(L(Te).centroid):!1}}case"intersects":return $e=>{const ve=se($e);return!!ve&&de(ve,W)};default:{const $e=[W.lon,W.lat];return ve=>{const Me=L(ve);return!!Me&&j(Me.centroid,$e)<=W.metres}}}}}),Xe("packages/core/src/source/filterwire.js",function(n,me){"use strict";Object.defineProperty(n,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"warnWherePageRelative",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"warnWhereNotApplied",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"warnWhereOverThreshold",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"parseRelativeToken",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"resolveRelativeRange",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"relativeTokenOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(n,"relativeTokenHelp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"isResolvableRelative",{enumerable:!0,get:function(){return S}}),Object.defineProperty(n,"resolveRelativeCondition",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"isGroup",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"forEachCondition",{enumerable:!0,get:function(){return re}}),Object.defineProperty(n,"mapConditions",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"normaliseFilterSet",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"buildFilterSet",{enumerable:!0,get:function(){return N}}),Object.defineProperty(n,"wireFilters",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"querySignature",{enumerable:!0,get:function(){return V}});const J=me("packages/core/src/internal/util.js").warnOnce,i="source.remote.hostFilter",be="source.where.pageRelative";function ce(x,Q){!Array.isArray(x)||!x.length||J(be,`filters.where (${x.join(", ")}) runs over the rows the ${Q} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function he(x){const Q=(x||{}).config;!Q||!Q.hostFilter||J(i,"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 D="source.where.notApplied";function G(x,Q){J(`${D}:${x}`,`filters.where("${x}") is registered but the ${Q} 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 le="source.where.overThreshold";function U(x,Q,c,e){!Array.isArray(x)||!x.length||J(`${le}:${Q}`,`filters.where (${x.join(", ")}) is not applied to the ${Q} pushdown source:`,c===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${c.toLocaleString()} rows, at or past the whereRowLimit of ${e.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const O=new Map;function F(x){let Q=O.get(x);return Q||(Q=new Intl.DateTimeFormat("en-US",{timeZone:x,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),O.set(x,Q)),Q}function h(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function I(x,Q){const c=F(Q).formatToParts(new Date(x)),e={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const w of c)w.type==="year"?e.y=+w.value:w.type==="month"?e.m=+w.value:w.type==="day"?e.d=+w.value:w.type==="hour"?e.h=+w.value%24:w.type==="minute"?e.mi=+w.value:w.type==="second"&&(e.s=+w.value);return e}function M(x,Q){const c=I(x,Q);return Date.UTC(c.y,c.m-1,c.d,c.h,c.mi,c.s)-Math.floor(x/1e3)*1e3}function d(x,Q,c,e){const w=Date.UTC(x,Q-1,c),k=w-M(w,e);return w-M(k,e)}function u(x,Q,c){const e=new Date(Date.UTC(x.y,x.m-1,x.d+Q));return d(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),c)}const s=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(x,Q){if(typeof x!="string")return null;const c=x.trim().toLowerCase().replace(/[\s_-]+/g,""),e=/^last(\d*|n)days?$/.exec(c);if(e){const w=e[1]==="n"?"":e[1],k=Number(w||Q);return!Number.isFinite(k)||k<=0?null:{kind:"lastNDays",n:Math.floor(k)}}switch(c){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function y(x,Q={}){const c=r(x,Q.n);if(!c)return null;const e=Q.tz||h(),w=Q.now instanceof Date?Q.now.getTime():typeof Q.now=="number"?Q.now:Date.now(),k=I(w,e),B=d(k.y,k.m,k.d,e),E=u(k,1,e);let se=B,X=E;switch(c.kind){case"today":break;case"yesterday":se=u(k,-1,e),X=B;break;case"lastNDays":X=Q.includeToday?E:B,se=u(k,Q.includeToday?-(c.n-1):-c.n,e);break;case"thisWeek":{const j=Number.isFinite(Q.weekStartsOn)?Number(Q.weekStartsOn):1,ee=(new Date(Date.UTC(k.y,k.m-1,k.d)).getUTCDay()-j+7)%7;se=u(k,-ee,e),X=u(k,-ee+7,e);break}case"thisMonth":se=d(k.y,k.m,1,e),X=d(k.m===12?k.y+1:k.y,k.m===12?1:k.m+1,1,e);break;case"thisQuarter":case"quarterToDate":{const j=Math.floor((k.m-1)/3)*3+1;se=d(k.y,j,1,e),X=c.kind==="quarterToDate"?E:j===10?d(k.y+1,1,1,e):d(k.y,j+3,1,e);break}case"thisYear":case"yearToDate":se=d(k.y,1,1,e),X=c.kind==="yearToDate"?E:d(k.y+1,1,1,e);break;default:return null}return{from:new Date(se).toISOString(),to:new Date(X).toISOString(),bounds:"[)",tz:e,relative:c.kind==="lastNDays"?`last${c.n}Days`:c.kind,n:c.n}}function p(x){if(!x||typeof x!="object")return null;const Q=x.value;if(Q&&typeof Q=="object"&&!Array.isArray(Q)&&"relative"in Q)return{token:String(Q.relative),n:typeof Q.n=="number"?Q.n:void 0};if(x.op==="relative"&&typeof x.value=="string")return{token:x.value,n:void 0};const c=x.meta;return c&&typeof c.relative=="string"&&x.value===void 0?{token:c.relative,n:typeof c.n=="number"?c.n:void 0}:null}function o(){return`Known tokens: ${s.filter(Q=>Q!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function S(x){const Q=p(x);return Q?r(Q.token,Q.n)!==null:!1}function l(x,Q={}){const c=p(x);if(!c)return x;const e=y(c.token,{...Q,n:c.n});return e?{...x,type:x.type||"date",op:"between",value:[e.from,e.to],bounds:x.bounds||e.bounds,meta:{...x.meta||{},relative:e.relative,tz:e.tz}}:(J(`source.relative.${c.token}`,`unknown relative date token "${c.token}"; sending the condition unresolved.`,o()),x)}function _(x){return!!x&&typeof x=="object"&&Array.isArray(x.conditions)}function re(x,Q){if(x){if(_(x)){for(const c of x.conditions)re(c,Q);return}Q(x)}}function te(x,Q){if(!x)return null;if(!_(x))return Q(x);const c=x;let e=!1;const w=[];for(const k of c.conditions){const B=te(k,Q);B!==k&&(e=!0),B&&w.push(B)}return!e&&w.length===c.conditions.length?x:w.length?{...c,conditions:w}:null}function ae(x){if(!x)return null;if(!_(x))return x;const Q=x,c=[];for(const e of Q.conditions){const w=ae(e);w&&c.push(w)}return c.length?{op:Q.op,conditions:c}:null}function oe(x){const Q=ae(x);return Q?_(Q)&&Q.op==="and"?Q:{op:"and",conditions:[Q]}:null}function N(x){const Q=(x||[]).filter(Boolean);return Q.length?{op:"and",conditions:Q}:null}function q(x,Q={}){const c=te(x,e=>l(e,Q));return oe(c)}function V(x){const Q=ie(x.filters??null);return JSON.stringify([Q,x.sort??null,x.quick??"",x.groupBy??null,x.pivotBy??null,C(x.context)])}function ie(x){if(!x)return null;if(_(x)){const e=x;return{op:e.op,conditions:e.conditions.map(ie)}}const Q=x,c=Q.meta&&typeof Q.meta.relative=="string"?Q.meta.relative:p(Q)?.token;return{col:Q.col,op:Q.op,bounds:Q.bounds??null,caseSensitive:Q.caseSensitive??!1,value:c?`rel:${c}`:Q.value??null}}function C(x){if(x==null)return null;try{return JSON.parse(JSON.stringify(x))}catch{return J("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Xe("packages/core/src/source/aggregates.js",function(n,me){"use strict";Object.defineProperty(n,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"pushableAggregates",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"fillAggregateSql",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"resolveAggregatesConfig",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"routeAggregate",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"resolveAggregatePlan",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"groupKeysPushable",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"pushdownDocRows",{enumerable:!0,get:function(){return le}});const ye=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 J(){const U=new Set;for(const[O,F]of Object.entries(ye))F.pushable&&U.add(O);return U}function i(U,O,F){let h=U.split("%c").join(O);return F!==void 0&&(h=h.split("%w").join(F)),h}function be(U){const O=U||{},F=O.default==="engine"||O.default==="engine-if-identical"?O.default:"client",h={};if(O.overrides&&typeof O.overrides=="object")for(const[I,M]of Object.entries(O.overrides))(M==="engine"||M==="client")&&(h[I]=M);return{default:F,overrides:h}}function ce(U,O){const F=ye[U];if(!F||!F.pushable)return"client";const h=O.overrides[U];return h==="engine"||h==="client"?h:O.default==="client"?"client":O.default==="engine-if-identical"?F.class==="identical"?"engine":"client":"engine"}function he(U,O){const F=be(O),h=[],I=[];for(const M of U||[]){const d=ye[M.fn],u=ce(M.fn,F),s={id:M.id,col:M.col,fn:M.fn,class:d?d.class:"fallback"};M.weight!==void 0&&(s.weight=M.weight),M.params!==void 0&&(s.params=M.params),u==="engine"?h.push(s):(s.reason=d&&!d.pushable?d.note||"the engine cannot express this stat":"client by config",I.push(s))}return{engine:h,client:I,config:F}}const D=/^[A-Za-z_][A-Za-z0-9_$]*$/;function G(U,O=[]){return(U||[]).every(h=>{if(typeof h=="string")return D.test(h);if(!h||typeof h!="object")return!1;const I=h;return Array.isArray(O)&&O.includes(I.bucket)&&typeof I.col=="string"&&D.test(I.col)&&typeof I.size=="number"&&Number.isFinite(I.size)&&I.size>0})}function le(){return Object.entries(ye).map(([U,O])=>({stat:U,class:O.class,sql:O.sql?i(O.sql,"col",O.twoColumn?"weight":void 0):"",note:O.note||(O.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Xe("packages/core/src/source/abort.js",function(n,me){"use strict";Object.defineProperty(n,"SupersededError",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"RequestToken",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"AbortScope",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"createAbortScope",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"isAbortError",{enumerable:!0,get:function(){return ce}});class ye extends Error{constructor(D,G="superseded"){super(`[lattice] request ${D?`"${D}" `:""}${G}`),this.name="SupersededError",this.superseded=!0,this.key=D}}class J{#e;constructor(D,G,le,U){this.#e=D,this.key=G,this.controller=le,this.signal=le.signal,this.seq=U}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(D){this.signal.aborted||this.controller.abort(new ye(this.key,D)),this.#e.settle(this)}}class i{#e=new Map;#t=0;begin(D="",G="superseded"){const le=this.#e.get(D);le&&!le.signal.aborted&&le.controller.abort(new ye(D,G));const U=new J(this,D,new AbortController,++this.#t);return this.#e.set(D,U),U}tokenFor(D){return this.#e.get(D)}pending(D=""){const G=this.#e.get(D);return!!G&&!G.signal.aborted}get size(){return this.#e.size}settle(D){this.#e.get(D.key)===D&&this.#e.delete(D.key)}abort(D="",G="superseded"){const le=this.#e.get(D);le&&le.abort(G)}abortAll(D="superseded"){for(const G of[...this.#e.values()])G.abort(D);this.#e.clear()}}function be(){return new i}function ce(he){if(!he||typeof he!="object")return!1;const D=he;return D.superseded===!0||D.name==="AbortError"||D.name==="SupersededError"}}),Xe("packages/core/src/source/pushdown.js",function(n,me){"use strict";Object.defineProperty(n,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"NO_CAPABILITIES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"resolveMutate",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"capabilitiesOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"splitFilters",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return N}}),Object.defineProperty(n,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"planQuery",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(n,"applyResidual",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(n,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return k}}),Object.defineProperty(n,"createPushdownSource",{enumerable:!0,get:function(){return X}});const ye=me("packages/core/src/internal/util.js"),J=ye.defaultCompare,i=ye.isFunction,be=ye.toArray,ce=ye.warnOnce,he=me("packages/core/src/source/filterwire.js"),D=he.isGroup,G=he.warnWherePageRelative,le=he.warnWhereOverThreshold,U=me("packages/core/src/source/aggregates.js"),O=U.resolveAggregatePlan,F=U.groupKeysPushable,h=U.STAT_PUSHDOWN,M=me("packages/core/src/source/abort.js").SupersededError,d=1e3;function u(j){const K=j&&j.signal;if(!K||!K.aborted)return;const ee=K.reason;throw ee instanceof Error?ee:new M("","superseded before it was sent")}const s=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function r(j){if(!j||typeof j!="object")return!1;const K=j.returning==="row"||j.returning==="key"?j.returning:"none";return{append:j.append===!0,update:j.update===!0,delete:j.delete===!0,returning:K}}function y(j,K){if(!j||typeof K!="string")return;if(!K.includes("."))return j[K];let ee=j;for(const pe of K.split(".")){if(ee===null||typeof ee!="object")return;ee=ee[pe]}return ee}function p(j){if(j===!0)return!0;if(!j||typeof j!="object")return!1;const K=j;return K.enabled===!1?!1:K.enabled===!0||i(K.commit)}function o(j){const K={...s,...j||{}};return K.operators=new Set(K.operators||[]),K.mutate=r(K.mutate),K}function S(j,K){return!j||!j.op||!K.operators.size?!1:K.operators.has(j.op)}function l(j,K){if(!j)return{pushed:null,residual:null};if(!K.filter)return{pushed:null,residual:j};if(K.filter==="term"){if(D(j)){const ke=j.conditions||[];if(String(j.op)!=="and")return{pushed:null,residual:j};const T=ke.findIndex(b=>!D(b)&&S(b,K));if(T<0)return{pushed:null,residual:j};const g=ke.filter((b,L)=>L!==T);return{pushed:ke[T],residual:g.length?{op:"and",conditions:g}:null}}return S(j,K)?{pushed:j,residual:null}:{pushed:null,residual:j}}if(!D(j))return S(j,K)?{pushed:j,residual:null}:{pushed:null,residual:j};if(String(j.op)!=="and")return(j.conditions||[]).every(T=>D(T)?l(T,K).residual===null:S(T,K))?{pushed:j,residual:null}:{pushed:null,residual:j};const ee=[],pe=[];for(const ke of j.conditions||[]){if(D(ke)){if(K.filter==="flat"){pe.push(ke);continue}const T=l(ke,K);T.pushed&&ee.push(T.pushed),T.residual&&pe.push(T.residual);continue}(S(ke,K)?ee:pe).push(ke)}const ne=ke=>ke.length===0?null:ke.length===1?ke[0]:{op:"and",conditions:ke};return{pushed:ne(ee),residual:ne(pe)}}const _="__lattice_leaves";function re(j){return j.aggregates?j.aggregates instanceof Set?j.aggregates:new Set(be(j.aggregates)):new Set}function te(j){const K=re(j);return K.size?K.has("count")?j.filter!=="tree"||!j.operators||!j.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 ae(j,K,ee,pe,ne,ke,T){const g=Array.isArray(j.groupBy)?j.groupBy:[],b=Array.isArray(j.groupPath)?j.groupPath:[],L=Array.isArray(j.groupValues)?j.groupValues:null;if(!K.group){const f=te(K);if(f)return f}return F(g)?ee.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":pe?ne?ke?"a host `where` predicate can only run in the browser, over rows the engine grouped":T?"fullDataset holds the whole matching set, so the grid groups it itself":!L||L.length!==b.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 oe="pushdown:pivot-unsupported",N="pushdown:group-unsupported",q=Symbol("lattice.remote.ungroupedLevel");function V(j,K,ee,pe,ne,ke){const T=Array.isArray(j.pivotBy)?j.pivotBy:[],g=Array.isArray(j.groupBy)?j.groupBy:[],b=Array.isArray(j.groupPath)?j.groupPath:[],L=Array.isArray(j.groupValues)?j.groupValues:null;return K.pivot?F(T)?g.length&&!F(g)?"a grouping key is not a plain column the engine can name in a GROUP BY":ee.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":pe?ne?ke?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!L||L.length!==b.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 ie(j,K,ee=!1){const pe=l(j.filters||null,K),ne=[];pe.residual&&ne.push("filter");const ke=j.sort||[],T=ke.length===0||K.sort==="multi"&&ke.length>=1||K.sort==="single"&&ke.length===1;!T&&ke.length&&ne.push("sort");const g=j.quick?String(j.quick):"",b=!g||!!K.quick;b||ne.push("quick");const L=j.where&&j.where.active?j.where:null;L&&ne.push("where");const f={filters:pe.residual,sort:T?null:ke,quick:b?"":g,where:L},R=!!ee,t=Array.isArray(j.groupBy)&&j.groupBy.length>0,v=t?ae(j,K,pe,T,b,L,R):"",a=j.pivotMode!==!1&&Array.isArray(j.pivotBy)&&j.pivotBy.length>0,z=a?V(j,K,pe,T,b,L):"",H=a&&z==="";a&&!H&&ne.push("pivot");const Y=a?H&&t:t&&v==="";t&&!a&&!Y&&ne.push("group");const A=(Y||H)&&Array.isArray(j.groupValues)?j.groupValues.length:0,Z=Y||a?!1:R||!!(f.filters||f.sort||f.quick||f.where)||!K.range;return{pushed:{...j,filters:pe.pushed,sort:T?ke:[],quick:b?g:"",range:Z?null:j.range},residual:f,needsAll:Z,unpushed:ne,full:R,grouped:Y,groupLevel:A,groupReason:a?"":v,pivoted:H,pivotReason:z}}function C(j){const K=Array.isArray(j.totals)?j.totals:[],ee=j.totalFns&&typeof j.totalFns=="object"?j.totalFns:{},pe=[],ne=[];for(const ke of K){const T=String(ke),g=typeof ee[T]=="string"?ee[T]:null,b=g?h[g]:null;g?!b||!b.pushable||!b.sql?ne.push({id:T,fn:g,class:b?b.class:"fallback",reason:b&&b.note?b.note:`the pushdown map cannot express "${g}"`}):b.twoColumn?ne.push({id:T,fn:g,class:b.class,reason:`"${g}" reduces two columns, and a grouped request carries no weight column`}):pe.push({id:T,col:T,fn:g,class:b.class}):ne.push({id:T,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:pe,client:ne}}const x=Object.freeze({items:j=>j==null?[]:Array.isArray(j)?j:[j]});function Q(j,K,ee){if(!K)return j;let pe=j;if(K.filters&&i(ee.evaluateFilters)){const ne=pe,ke={count:pe.length,handle:b=>({id:b,get:L=>y(ne[L],b)}),itemwise:b=>ne.some(L=>Array.isArray(y(L,b)))?x:null},T=ee.evaluateFilters(K.filters,ke),g=[];for(let b=0;b<pe.length;b++)T[b]&&g.push(pe[b]);pe=g}if(K.where&&K.where.active&&(K.whole||G(K.where.names,"pushdown"),pe=pe.filter(ne=>K.where.passes(ne))),K.quick){const ne=K.quick.toLowerCase();pe=pe.filter(ke=>{if(!ke||typeof ke!="object")return!1;for(const T of Object.values(ke))if(T!=null&&String(T).toLowerCase().includes(ne))return!0;return!1})}if(K.sort&&K.sort.length&&i(ee.sortMulti)){const ne=[...new Set(K.sort.map(b=>b.col))],ke=pe,T=ne.map(b=>({id:b,get:L=>y(ke[L],b)})),g=ee.sortMulti(T,K.sort.map(b=>({col:b.col,dir:b.dir})),Uint32Array.from({length:pe.length},(b,L)=>L),{});pe=Array.from(g,b=>ke[b])}return pe}function c(j){return JSON.stringify({filters:j.filters||null,sort:j.sort||[],quick:j.quick||"",groupBy:j.groupBy||[],groupPath:j.groupPath||[],context:j.context??null})}function e(j){if(!j||typeof j!="object")return 16;let K="";try{K=JSON.stringify(j)}catch{return 200}return K.length*2+64}function w(j){const K=j||{};return{enabled:!!K.enabled,maxRows:Number.isFinite(K.maxRows)?K.maxRows:1e6,maxBytesEstimate:Number.isFinite(K.maxBytesEstimate)?K.maxBytesEstimate:512*1024*1024}}const k=5e4;function B(j){return Number.isFinite(j)&&j>=0?j:k}function E(j){return!!j&&i(j.then)}async function se(j){if(!j||j.total!==void 0||!E(j.pendingTotal))return j;const K=await j.pendingTotal,{pendingTotal:ee,...pe}=j;return typeof K=="number"?{...pe,total:K}:pe}function X(j={}){const K=j.adapter;if(!K||!i(K.execute))return ce("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...j,mode:"remote",fetch:async()=>({rows:[],total:0})};const ee=o(K.capabilities),pe=K.capabilities&&Object.getOwnPropertyDescriptor(K.capabilities,"operators");pe&&i(pe.get)&&Object.defineProperty(ee,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(K.capabilities.operators||[]),set:()=>{}});const ne=K.name||"adapter";let ke=null;const T=()=>i(K.ready)?(ke||(ke=Promise.resolve(K.ready()).then(()=>{Object.assign(ee,o(K.capabilities))},De=>{throw ke=null,De})),ke):null,g=w(j.fullDataset),b=!!j.allowPartialResults,L=B(j.whereRowLimit);let f=null;const R=j.aggregates;let t=null,v=null,a=null,z=null,H=null,Y,A=null,Z=0,de=null;const xe=()=>!g.enabled||!t?null:(de!==t.key&&(Z++,de=t.key),{rows:t.rows,version:Z}),$=async De=>{const Le=De.where&&De.where.active?De.where:null;if(!Le)return{request:De,probe:null};const{where:qe,...Ke}=De,Fe=ie(Ke,ee,g.enabled);if(Fe.needsAll)return{request:De,probe:null};const et=c(Fe.pushed);let tt=null;return(!f||f.key!==et)&&(ee.total?(u(De),tt=await se(await K.execute(Fe.pushed,De)),f={key:et,size:tt&&typeof tt.total=="number"?tt.total:null}):f={key:et,size:null}),f.size!==null&&f.size<L?{request:De,probe:null}:(le(Le.names,ne,f.size,L),{request:Ke,probe:tt})},P=async(De,Le)=>{A=null;const qe=C(De.pushed);a={engine:qe.engine,client:qe.client,groupBy:De.pushed.groupBy},qe.client.length&&ce(`source.pushdown.group.totals.${ne}.${qe.client.map(et=>et.id).join(".")}`,`the ${ne} adapter cannot compute the group subtotal for ${qe.client.map(et=>`"${et.id}" (${et.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 K.executeGroupLevel(De.pushed,qe.engine,Le)||{};let Fe=Ke.rows||[];return!ee.range&&Le.range&&(Fe=Fe.slice(Le.range.start,Le.range.end)),ve(Ke),Ke.total===void 0?{rows:Fe}:{rows:Fe,total:Ke.total}},W=new Map,fe=64,$e=async(De,Le)=>{A=null;const qe=De.pushed,Ke=qe.groupBy,Fe=Array.isArray(qe.groupValues)?qe.groupValues:[],et=Fe.length,tt=[...qe.filters?[qe.filters]:[],...Ke.slice(0,et).map((Pe,Ge)=>({col:Pe,op:"eq",value:Fe[Ge]===void 0?null:Fe[Ge],caseSensitive:!0}))],at=tt.length===0?null:tt.length===1?tt[0]:{op:"and",conditions:tt},ct=Le.range?Le.range.start:0;if(et>=Ke.length){const Pe={...qe,filters:at,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},Ge=await se(await K.execute(Pe,Le))||{};let Ce=Ge.rows||[];return!ee.range&&Le.range&&(Ce=Ce.slice(Le.range.start,Le.range.end)),typeof Ge.total=="number"?{rows:Ce,total:Ge.total}:{rows:Ce}}const st=Ke[et],kt=C(qe),gt=re(ee),vt=kt.engine.filter(Pe=>gt.has(Pe.fn)),Nt=[...kt.engine.filter(Pe=>!gt.has(Pe.fn)).map(Pe=>({id:Pe.id,fn:Pe.fn,class:Pe.class,reason:`the ${ne} adapter does not compute "${Pe.fn}"`})),...kt.client];a={engine:vt,client:Nt,groupBy:Ke},Nt.length&&ce(`source.pushdown.group.totals.${ne}.${Nt.map(Pe=>Pe.id).join(".")}`,`the ${ne} adapter cannot compute the group subtotal for ${Nt.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 lt=[...vt.map(Pe=>({id:Pe.id,col:Pe.col,fn:Pe.fn})),{id:_,col:st,fn:"count"}],ht={...qe,filters:at,range:null},Tt=JSON.stringify([c(ht),Fe,st,lt]);let Lt=ct>0?W.get(Tt):void 0;if(!Lt){for(Lt=Promise.resolve(K.executeGroupedAggregates(ht,[st],lt)),W.delete(Tt),W.set(Tt,Lt);W.size>fe;)W.delete(W.keys().next().value);Lt.catch(()=>{W.get(Tt)===Lt&&W.delete(Tt)})}const Ut=await Lt||[];u(Le);const Gt=Pe=>{const Ge={};for(const Ce of vt)Ge[Ce.id]=Pe?Pe[Ce.id]:void 0;return Ge},Qt=(qe.sort||[]).find(Pe=>Pe&&Pe.col===st),en=Qt&&Qt.dir==="desc"?-1:1,Wt=Ut.filter(Pe=>Pe&&Pe.level===1).map(Pe=>({[st]:Pe.keys[0]===void 0?null:Pe.keys[0],leafCount:Number(Pe.values&&Pe.values[_])||0,totals:Gt(Pe.values)})).sort((Pe,Ge)=>en*J(Pe[st],Ge[st]));if(et===0){const Pe=Ut.find(Ce=>Ce&&Ce.level===0),Ge=Pe?Number(Pe.values&&Pe.values[_]):NaN;ve({matchCount:Number.isFinite(Ge)?Ge:Wt.reduce((Ce,Je)=>Ce+Je.leafCount,0),...Pe?{grand:Gt(Pe.values)}:{}})}const Ne=Le.range?Le.range.end:Wt.length;return{rows:Wt.slice(ct,Ne),total:Wt.length}},ve=De=>{typeof De.matchCount=="number"&&(z=De.matchCount,H=De.grand?{totals:De.grand,leafCount:De.matchCount}:null,Y===void 0&&i(K.unfilteredCount)&&(Y=null,Promise.resolve(K.unfilteredCount()).then(Le=>{Y=typeof Le=="number"?Le:null}).catch(Le=>{ce(`source.pushdown.group.unfiltered.${ne}`,`the ${ne} adapter could not count the unfiltered set (${Le&&Le.message?Le.message:Le}), so "N of M" falls back to the display count for its denominator.`)})))},Me=async(De,Le)=>{A=null;const qe=C(De.pushed);a={engine:qe.engine,client:qe.client,groupBy:De.pushed.groupBy,pivotBy:De.pushed.pivotBy},qe.client.length&&ce(`source.pushdown.pivot.totals.${ne}.${qe.client.map(at=>at.id).join(".")}`,`the ${ne} adapter cannot compute the pivot cells for ${qe.client.map(at=>`"${at.id}" (${at.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 K.executePivotLevel(De.pushed,qe.engine,Le)||{};let Fe=Ke.rows||[];!ee.range&&Le.range&&(Fe=Fe.slice(Le.range.start,Le.range.end)),ve(Ke);const et=Ke.pivot&&typeof Ke.pivot=="object"?Ke.pivot:{},tt={cells:Array.isArray(et.cells)?et.cells:[],...Array.isArray(et.axis)?{axis:et.axis}:{}};return Ke.total===void 0?{rows:Fe,pivot:tt}:{rows:Fe,total:Ke.total,pivot:tt}},Te=De=>{ce(`source.pushdown.pivot.${ne}.${De}`,`pushdown:pivot-unsupported: the ${ne} adapter cannot pivot this query because ${De}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Le=new Error(`[lattice] ${oe}: the ${ne} adapter cannot pivot this query because ${De}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Le.code=oe,Le.reason=De,Le},Be=(De,Le)=>{const qe={key:Le,state:"pending",value:null};return A=qe,De.then(Ke=>(A===qe&&(A={key:Le,state:"settled",value:typeof Ke=="number"?Ke:null}),Ke),Ke=>{throw A===qe&&(A={key:Le,state:"failed",value:null}),Ke})};let Ue=0,Re=[];const He=()=>Ue===0?null:new Promise(De=>{const Le=setTimeout(De,d);Re.push(()=>{clearTimeout(Le),De()})});let We;const pt=async De=>{const Le=T();Le&&await Le;const Ke=De&&De.pivotMode!==!1&&Array.isArray(De.pivotBy)&&De.pivotBy.length>0?{request:De,probe:null}:await $(De);u(De);let Fe=ie(Ke.request,ee,g.enabled);if(ee.group&&Fe.grouped&&!Fe.pivoted&&!i(K.executeGroupLevel)&&(ce(`source.pushdown.group.method.${ne}`,`the ${ne} 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.`),Fe=ie(Ke.request,{...ee,group:!1,aggregates:null},g.enabled)),Fe.pivoted&&!i(K.executePivotLevel)&&(Fe=ie(Ke.request,{...ee,pivot:!1},g.enabled),Fe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),Fe.grouped&&!Fe.pivoted&&!ee.group&&!i(K.executeGroupedAggregates)&&(ce(`source.pushdown.group.aggregates.method.${ne}`,`the ${ne} 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\`.`),Fe=ie(Ke.request,{...ee,aggregates:null},g.enabled)),v=Fe,Fe.pivoted)return Me(Fe,De);if(Fe.pivotReason&&Te(Fe.pivotReason),Fe.grouped)return ee.group?P(Fe,De):$e(Fe,De);const tt=!!Fe.groupReason&&!Fe.full;tt?ce(`source.pushdown.group-unsupported.${ne}.${Fe.groupReason}`,`pushdown:group-unsupported: the ${ne} adapter was not asked to group this query because ${Fe.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.`):Fe.groupReason&&ce(`source.pushdown.group.${ne}.${Fe.groupReason}`,`the ${ne} adapter was not asked to group this query because ${Fe.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 at=lt=>tt?{...lt,[q]:!0}:lt;if(!Fe.needsAll){const lt=Ke.probe||await K.execute(Fe.pushed,De),ht=lt.rows||[];return E(lt.pendingTotal)&&lt.total===void 0?at({rows:ht,pendingTotal:Be(lt.pendingTotal,c(Fe.pushed))}):(A=null,!ee.total&&lt.total===void 0?at({rows:ht}):at({rows:ht,total:lt.total??ht.length}))}Fe.unpushed.length&&ce(`source.pushdown.residual.${ne}.${Fe.unpushed.join(".")}`,`the ${ne} adapter cannot push ${Fe.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 ct=c(Fe.pushed);if(!t||t.key!==ct){const lt=await se(await K.execute(Fe.pushed,De));A=null;const ht=lt.rows||[];if(Fe.full){const Tt=typeof lt.total=="number"?Math.max(lt.total,ht.length):ht.length;if(Tt>g.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ne} adapter's matching set is ${Tt.toLocaleString()} rows, past the configured maxRows of ${g.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 Lt=ht.length*e(ht[0]);if(Lt>g.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ne} adapter's matching set is an estimated ${Math.round(Lt/(1024*1024)).toLocaleString()} MB across ${ht.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(g.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 lt.total=="number"&&ht.length<lt.total){const Tt=!!(Fe.residual.filters||Fe.residual.quick||Fe.residual.sort&&Fe.residual.sort.length);if(Tt&&!b)throw new Error(`[lattice] the ${ne} adapter returned ${ht.length} of ${lt.total} matching rows when asked for the whole result, and the query has residual ${Fe.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.`);Tt?ce(`source.pushdown.partial.residual.${ne}`,`the ${ne} adapter returned ${ht.length} of ${lt.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.`):ce(`source.pushdown.partial.${ne}`,`the ${ne} adapter returned ${ht.length} of ${lt.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}t={key:ct,rows:ht,total:typeof lt.total=="number"?lt.total:null}}let st=Fe;if(Fe.residual.where){const lt=t.total??t.rows.length;if(lt>=L){le(Fe.residual.where.names,ne,lt,L);const{where:ht,...Tt}=Ke.request;st=ie(Tt,ee,g.enabled),v=st}}const kt=t.total!==null&&t.rows.length>=t.total,gt=Q(t.rows,{...st.residual,whole:kt},j.compute||{}),vt=De.range?De.range.start:0,Nt=De.range?De.range.end:gt.length;return at({rows:gt.slice(vt,Nt),total:gt.length})},At=async(De,Le,qe)=>{const Fe=qe&&qe.waitForPage&&We&&i(We.pageForegroundIdle)?We.pageForegroundIdle():He();Fe&&await Fe;const et=T();et&&await et;const tt=ie(De,ee,g.enabled);v=tt;const at=O(Le,R),ct=Array.isArray(De.groupBy)?De.groupBy:[],st=ct.length>0,kt=!tt.residual.filters&&!tt.residual.quick,gt=!st||F(ct,ee.buckets);let vt=at.engine,Nt=at.client;if(ee.aggregates&&vt.length){const Lt=ee.aggregates instanceof Set?ee.aggregates:new Set(be(ee.aggregates)),Ut=vt.filter(Gt=>!Lt.has(Gt.fn));Ut.length&&(vt=vt.filter(Gt=>Lt.has(Gt.fn)),Nt=[...Ut.map(Gt=>({...Gt,reason:`the ${ne} adapter does not compute "${Gt.fn}"`})),...Nt])}const lt=Lt=>{Nt=[...vt.map(Ut=>({...Ut,reason:Lt})),...Nt],vt=[]};vt.length&&!kt?lt(tt.residual.quick&&!tt.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):vt.length&&!gt&&lt("a grouping key the engine cannot form forces all-client (no mixed provenance)");let ht={},Tt;return vt.length&&(i(st?K.executeGroupedAggregates:K.executeAggregates)?st?Tt=await K.executeGroupedAggregates(tt.pushed,ct,vt)||[]:ht=await K.executeAggregates(tt.pushed,vt)||{}:(ce(`source.pushdown.aggregates.${ne}${st?".grouped":""}`,`the ${ne} adapter cannot compute ${st?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),lt(`adapter cannot compute ${st?"grouped ":""}aggregates`))),a={engine:vt,client:Nt,...st?{groupBy:ct}:{}},{values:ht,engine:vt,client:Nt,...Tt!==void 0?{groups:Tt}:{}}},Mt=async De=>{Ue++;try{return await pt(De)}finally{if(Ue--,Ue===0&&Re.length){const Le=Re;Re=[];for(const qe of Le)qe()}}},ut=p(j.edit),ft=j.edit&&typeof j.edit=="object"&&i(j.edit.commit);let zt=j.edit;if(ut&&!ft)if(ee.mutate&&ee.mutate.update){const De=Le=>{if(!ee.mutate||!ee.mutate.update)throw new Error(`[lattice] the ${ne} 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 qe={kind:"update",key:String(Le.key),patch:{[Le.colId]:Le.value}};return K.mutate(qe,Le.request||{})};zt={...j.edit===!0?{}:j.edit,commit:De}}else ce(`source.pushdown.readonly.${ne}`,`edit is enabled but the ${ne} adapter declares mutate: ${ee.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 Ft=ut&&ee.mutate&&(ee.mutate.append||ee.mutate.delete)?{append:ee.mutate.append===!0,remove:ee.mutate.delete===!0,returning:ee.mutate.returning,mutate:(De,Le)=>K.mutate(De,Le||{})}:null,wt=async De=>{const Le=T();Le&&await Le;const{range:qe,signal:Ke,export:Fe,...et}=De||{},tt={...et,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:ie(tt,ee,g.enabled),signal:Ke}};async function*dt(De,Le={}){const{plan:qe,signal:Ke}=await wt(De),Fe=Math.max(1,Math.floor(Number(Le.pageSize))||5e3),et={signal:Ke,stream:!0};if(!qe.needsAll)for(let ct=0;;ct+=Fe){u(et);const st=await K.execute({...qe.pushed,range:{start:ct,end:ct+Fe}},et);st&&E(st.pendingTotal)&&st.pendingTotal.then(null,()=>{});const kt=st&&st.rows||[];if(kt.length&&(yield kt),kt.length<Fe)return}u(et);const tt=await se(await K.execute({...qe.pushed,range:void 0},et)),at=Q(tt&&tt.rows||[],{...qe.residual,whole:!0},j.compute||{});for(let ct=0;ct<at.length;ct+=Fe)yield at.slice(ct,ct+Fe)}return We={...j,edit:zt,rowMutate:Ft,mode:"remote",fetch:Mt,foregroundIdle:He,aggregate:At,countMatching:async De=>{const{plan:Le,signal:qe}=await wt(De);if(!Le.needsAll&&ee.total){u({signal:qe});const Fe=await se(await K.execute({...Le.pushed,range:{start:0,end:0}},{signal:qe}));if(Fe&&typeof Fe.total=="number")return Fe.total}let Ke=0;for await(const Fe of dt(De))Ke+=Fe.length;return Ke},streamMatching:dt,lastPlan:()=>v?{...v,...a?{aggregates:a}:{},...A?{total:{deferred:!0,state:A.state,value:A.value}}:{}}:null,fullFrame:xe,counts:()=>({match:z,total:Y??null,pending:!!A&&A.state==="pending"}),grandTotals:()=>H},We}}),Xe("packages/modules/shared/engine.js",function(n,me){"use strict";Object.defineProperty(n,"sourceId",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"engineSource",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"gridPivoted",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"loadedAndMatching",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"gridHoldsWindow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"gridEngineRequest",{enumerable:!0,get:function(){return I}}),Object.defineProperty(n,"EngineFlight",{enumerable:!0,get:function(){return M}});const ye=me("packages/core/src/source/pushdown.js"),J=ye.capabilitiesOf,i=ye.planQuery,ce=me("packages/core/src/source/filterwire.js").wireFilters,he=new WeakMap;let D=0;function G(d){let u=he.get(d);return u===void 0&&(u=++D,he.set(d,u)),u}function le(d){const u=d&&typeof d.config=="function"?d.config():null,s=u&&u.source&&typeof u.source=="object"?u.source:null;if(!s||typeof s.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const r=J(s.adapter&&s.adapter.capabilities);return{source:s,caps:r,config:u}}function U(d){const u=d&&typeof d.config=="function"?d.config():null,s=u&&u.source&&typeof u.source=="object"?u.source:null;if(!s||typeof s.lastPlan!="function")return!1;const r=d&&d.state&&typeof d.state.get=="function"?d.state.get():null,y=r&&r.pivot;return!!(y&&y.enabled&&Array.isArray(y.columns)&&y.columns.length>0)}function O(d){const u=d.rows&&typeof d.rows.residentCount=="function"?d.rows.residentCount():0,s=typeof d.rows.matchCount=="function"?d.rows.matchCount():NaN;return{loaded:u,total:Number.isFinite(s)?s:NaN}}function F(d){const u=d&&typeof d.config=="function"?d.config():null,s=u&&u.source&&typeof u.source=="object"?u.source:null;if(!s||s.mode!=="remote"&&s.mode!=="paged")return!1;if(typeof d.rows.matchCount=="function"&&d.rows.matchCount()===null)return!0;const{loaded:r,total:y}=O(d);return Number.isFinite(y)&&r<y}function h(d,u){return u?d?{op:"and",conditions:[d,u]}:u:d||null}function I(d,u,s=null){const r=d.filters&&typeof d.filters.where=="function"?d.filters.where():[];if(Array.isArray(r)&&r.length)return{reason:`a \`where\` predicate is in force (${r.join(", ")}), which only the browser can run`};const y=d.filters&&typeof d.filters.quickState=="function"?d.filters.quickState():{text:""},p=y&&y.text?String(y.text):"",{config:o,caps:S}=u,l={filters:ce(h(d.filters.get(),s),{tz:o.timeZone,weekStartsOn:o.weekStartsOn}),sort:[],range:null,context:o.context??null,...p?{quick:p}:{}},_=i(l,S);return _.unpushed.includes("filter")?{reason:s?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:_.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:l,quick:p}}class M{#e=null;#t=null;#n=!1;answer(u){return this.#t&&this.#t.key===u?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(u,s,r){const y=this.#e;if(y){y.key!==u&&y.controller&&y.controller.abort();return}const p=globalThis.AbortController,o=typeof p=="function"?new p:null,S={key:u,controller:o};this.#e=S;let l;Promise.resolve().then(()=>s(o?o.signal:null)).then(_=>{l={key:u,result:_}},_=>{l={key:u,error:_}}).then(()=>{this.#e===S&&(this.#e=null),!this.#n&&(o&&o.signal.aborted||(this.#t=l),r())})}abort(){const u=this.#e;u&&u.controller&&u.controller.abort()}close(){this.#n=!0,this.abort()}}}),Xe("packages/modules/charts/scale.js",function(n,me){"use strict";Object.defineProperty(n,"isNumber",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"toNumber",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"toTime",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"extent",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"niceStep",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"niceDomain",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"measureDomain",{enumerable:!0,get:function(){return I}}),Object.defineProperty(n,"linearTicks",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"timeStepFor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"MONTH_STEPS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"timeTicks",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"linearScale",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"timeScale",{enumerable:!0,get:function(){return re}}),Object.defineProperty(n,"key",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"bandScale",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"sqrtScale",{enumerable:!0,get:function(){return oe}});const ye=[1,2,2.5,5,10],J=6e4,i=36e5,be=864e5,ce=365.25*be,he=[1,2,5,10,20,25,50,100],D=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,J,5*J,15*J,30*J,i,3*i,6*i,12*i,be,2*be,7*be,14*be,30*be,90*be,180*be,...he.map(N=>N*ce)];function G(N){return typeof N=="number"&&Number.isFinite(N)}function le(N){if(N==null||N==="")return null;if(N instanceof Date){const V=N.getTime();return Number.isFinite(V)?V:null}if(typeof N=="boolean")return N?1:0;const q=Number(N);return Number.isFinite(q)?q:null}function U(N){if(N==null||N==="")return null;if(N instanceof Date){const V=N.getTime();return Number.isFinite(V)?V:null}if(typeof N=="number")return Number.isFinite(N)?N:null;const q=Date.parse(String(N));return Number.isFinite(q)?q:null}function O(N){let q=1/0,V=-1/0;for(let ie=0;ie<N.length;ie++){const C=N[ie];G(C)&&(C<q&&(q=C),C>V&&(V=C))}return q===1/0?null:{min:q,max:V}}function F(N){if(!(N>0))return 1;const q=10**Math.floor(Math.log10(N));for(const V of ye)if(N<=V*q)return V*q;return 10*q}function h(N,q=5){const V=F((N.max-N.min)/Math.max(1,q));return{min:Math.floor(N.min/V)*V,max:Math.ceil(N.max/V)*V,step:V}}function I(N,q={}){const V=O(N)||{min:0,max:1};let{min:ie,max:C}=V;if(q.zero&&(ie>0&&(ie=0),C<0&&(C=0)),ie===C){const x=Math.abs(ie)>0?Math.abs(ie)/10:1;ie-=x,C+=x}if(q.nice!==!1){const x=h({min:ie,max:C},q.ticks||5);ie=x.min,C=x.max}return G(q.min)&&(ie=q.min),G(q.max)&&(C=q.max),ie===C&&(C=ie+1),{min:ie,max:C}}function M(N,q=5){const V=F((N.max-N.min)/Math.max(1,q)),ie=Math.ceil(N.min/V),C=Math.floor(N.max/V),x=[];for(let Q=ie;Q<=C;Q++){const c=Q*V;x.push(Math.abs(c)<V/1e6?0:Number(c.toPrecision(12)))}return x}function d(N,q=5){const V=Math.max(1,q),ie=N/V;let C=D[D.length-1];for(const c of D)if(c>=ie){C=c;break}if(C<ce)return C;let x=C,Q=Math.abs(N/C-V);for(const c of D){if(c<ce)continue;const e=Math.abs(N/c-V);e<Q&&(Q=e,x=c)}return x}const u=new Map;function s(N){let q=u.get(N);return q||(q=new Intl.DateTimeFormat("en-US",{timeZone:N,year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),u.set(N,q)),q}function r(N,q){const V={year:0,month:0,day:1,hour:0,minute:0,second:0};for(const ie of s(q).formatToParts(new Date(N)))switch(ie.type){case"year":V.year=Number(ie.value);break;case"month":V.month=Number(ie.value)-1;break;case"day":V.day=Number(ie.value);break;case"hour":V.hour=Number(ie.value)%24;break;case"minute":V.minute=Number(ie.value);break;case"second":V.second=Number(ie.value);break;default:break}return V}function y(N,q,V){const ie=Date.UTC(N,q,1);let C=ie;for(let x=0;x<2;x++){const Q=r(C,V),c=Date.UTC(Q.year,Q.month,Q.day,Q.hour,Q.minute,Q.second),e=ie-c;if(e===0)break;C+=e}return C}function p(N,q,V){const ie=V?r(N.min,V).year:new Date(N.min).getUTCFullYear();let C=Math.ceil(ie/q)*q;const x=c=>V?y(c,0,V):Date.UTC(c,0,1);x(C)<N.min&&(C+=q);const Q=[];for(;x(C)<=N.max;C+=q)Q.push(x(C));return Q}const o=new Map([[30*be,1],[90*be,3],[180*be,6]]);function S(N,q,V){const ie=V?r(N.min,V):{year:new Date(N.min).getUTCFullYear(),month:new Date(N.min).getUTCMonth()};let C=ie.year*12+ie.month;const x=c=>{const e=Math.floor(c/12),w=c-e*12;return V?y(e,w,V):Date.UTC(e,w,1)};x(C)<N.min&&(C+=1),C=Math.ceil(C/q)*q;const Q=[];for(;;C+=q){const c=x(C);if(c>N.max)break;Q.push(c)}return Q}function l(N,q=5,V){const ie=d(N.max-N.min,q);if(ie>=ce)return p(N,Math.round(ie/ce),V);const C=o.get(ie);if(C)return S(N,C,V);const x=[],Q=Math.ceil(N.min/ie)*ie;for(let c=Q;c<=N.max;c+=ie)x.push(c);return x}function _(N,q){const V=N.max-N.min||1,[ie,C]=q;return{kind:"linear",domain:N,range:q,of(x){return ie+(x-N.min)/V*(C-ie)},invert(x){return N.min+(x-ie)/(C-ie||1)*V},ticks(x=5){return M(N,x)}}}function re(N,q){return{..._(N,q),kind:"time",ticks(ie=5,C){return l(N,ie,C)}}}function te(N){if(N==null)return" null";if(N instanceof Date)return` date:${N.getTime()}`;if(typeof N=="object"){const q=N,V=q.id??q.key??q.value;return V!==void 0&&typeof V!="object"?` obj:${String(V)}`:` obj:${String(N)}`}return String(N)}function ae(N,q,V=.2){const ie=Math.min(.9,Math.max(0,V)),[C,x]=q,Q=new Map;for(let w=0;w<N.length;w++){const k=te(N[w]);Q.has(k)||Q.set(k,w)}const c=N.length?(x-C)/N.length:x-C,e=Math.max(0,c*(1-ie));return{kind:"band",domain:N,range:q,bandwidth:e,step:c,of(w){const k=Q.get(te(w));return k===void 0?NaN:C+k*c+(c-e)/2},centre(w){const k=this.of(w);return Number.isNaN(k)?NaN:k+e/2},ticks(){return N}}}function oe(N,q){const[V,ie]=q,C=Math.max(Math.abs(N.max),Math.abs(N.min),0)||1;return{kind:"sqrt",domain:N,range:q,of(x){const Q=Math.sqrt(Math.abs(x)/C);return V+Q*(ie-V)}}}}),Xe("packages/modules/charts/svg.js",function(n,me){"use strict";Object.defineProperty(n,"SVG_NS",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"el",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"svg",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"attr",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"attrs",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"setText",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"clear",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"append",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"path",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"ribbonPath",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"round",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"pathRings",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"insideRings",{enumerable:!0,get:function(){return I}});const ye="http://www.w3.org/2000/svg";function J(M){const d=M.indexOf(")");return d<0?M:M.slice(d+1).trim()||"#0072b2"}function i(M,d,u){const s=M.createElement(d);return u&&s.setAttribute("class",u),s}function be(M,d,u){const s=M.createElementNS(ye,d);if(u)for(const r of Object.keys(u))s.setAttribute(r,String(u[r]));return s}function ce(M,d,u){if(!M)return;if(u==null){M.removeAttribute(d);return}let s=String(u);s.startsWith("url(#")&&(d==="stroke"||d==="fill"&&M.localName==="text")&&(s=J(s)),M.setAttribute(d,s)}function he(M,d){if(M)for(const u of Object.keys(d))ce(M,u,d[u])}function D(M,d){M&&(M.textContent=d==null?"":String(d))}function G(M){if(M)for(;M.firstChild;)M.removeChild(M.firstChild)}function le(M,d){for(const u of d)u&&M.appendChild(u);return M}function U(M){return M.join(" ")}function O(M){if(!M||M.length<2)return"";const d=["M",M[0].x,M[0].upper];for(let u=1;u<M.length;u++)d.push("L",M[u].x,M[u].upper);for(let u=M.length-1;u>=0;u--)d.push("L",M[u].x,M[u].lower);return d.push("Z"),U(d)}function F(M){return Math.round(M*100)/100}function h(M){const d=[];let u=[];const s=String(M||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let r="",y=[];const p=()=>{if(!r||!y.length){y=[];return}if(r==="M"||r==="L")for(let o=0;o+1<y.length;o+=2)u.push([y[o],y[o+1]]);else r!=="Z"&&y.length>=2&&u.push([y[y.length-2],y[y.length-1]]);y=[]};for(const o of s){if(/[A-Za-z]/.test(o)){if(p(),o==="Z"||o==="z"){u.length>2&&d.push(u),u=[],r="";continue}o==="M"&&u.length>2&&(d.push(u),u=[]),r=o;continue}y.push(Number(o))}return p(),u.length>2&&d.push(u),d}function I(M,d,u){let s=!1;for(const r of M)for(let y=0,p=r.length-1;y<r.length;p=y++){const[o,S]=r[y],[l,_]=r[p];S>u!=_>u&&d<(l-o)*(u-S)/(_-S||1e-12)+o&&(s=!s)}return s}}),Xe("packages/modules/charts/typography.js",function(n,me){"use strict";Object.defineProperty(n,"BASE_SIZE",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"BASE_FAMILY",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"CHAR_RATIO",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"resolveType",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"textWidth",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"widestLabel",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"truncateTo",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"applySize",{enumerable:!0,get:function(){return le}});const ye=12,J="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",i=.62;function be(U){const O=U&&U.font,F=typeof O=="number"?{size:O}:O||{},h=ce(F.size,ye);return{family:F.family||J,size:h,small:ce(F.small??F.tickSize,Math.max(9,h-1)),title:ce(F.title,Math.round(h*1.15)),axisTitle:ce(F.axisTitle,Math.max(10,h-1)),weight:F.weight||"inherit"}}function ce(U,O){const F=Number(U);return Number.isFinite(F)&&F>0?F:O}function he(U,O){return String(U??"").length*O*i}function D(U,O){let F=0;for(const h of U||[]){const I=he(h,O);I>F&&(F=I)}return F}function G(U,O,F){const h=String(U??""),I=Math.floor(O/(F*i));return I<=0?"":h.length<=I?h:I===1?"…":`${h.slice(0,I-1)}…`}function le(U,O){!U||!Number.isFinite(O)||(U.style?U.style.fontSize=`${O}px`:U.setAttribute("style",`font-size:${O}px`))}}),Xe("packages/modules/charts/frame.js",function(n,me){"use strict";Object.defineProperty(n,"LABEL_GAP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"resolveMargin",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"plotRect",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"shouldRotate",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"Pool",{enumerable:!0,get:function(){return F}});const J=me("packages/modules/charts/svg.js").SVG_NS,i=me("packages/modules/charts/typography.js"),be=i.textWidth,ce=i.widestLabel,he=8,D=6,G=.4;function le(h,I){const M=typeof h=="number"?h:I,d=h&&typeof h=="object"?h:{},u=s=>Number.isFinite(s)&&s>=0?Number(s):M;return{base:M,top:u(d.top),right:u(d.right),bottom:u(d.bottom),left:u(d.left)}}function U(h){const I=le(h.margin,typeof h.padding=="number"?h.padding:8),M=I.base,d=h.fontSize||12,u=h.yLabels||[],s=h.xLabels||[],r=h.ySide==="right"?"right":"left",y=r==="right"?"left":"right",p=h.titles||{},o=h.titleSize||d,S=C=>C?o+D:0,l=ce(u,d),_=u.length?Math.min(h.width*G,I[r]+l+D):Math.max(he,I[r]),re=I[y]+(h.rightGutter||0),te=(r==="left"?_:re)+S(p.left),ae=ce(s.map(C=>String(C).slice(0,14)),d),oe=(s.length?h.rotated?Math.min(h.height*G,D+ae):d+D+I.bottom:Math.max(he,I.bottom))+S(p.bottom),N=(r==="right"?_:re)+S(p.right),q=I.top+(h.topGutter||0),V=Math.max(0,h.width-te-N),ie=Math.max(0,h.height-q-oe);return{left:te,top:q,width:V,height:ie,right:te+V,bottom:q+ie,gutter:{left:te,bottom:oe,right:N,top:q}}}function O(h,I,M,d){if(!h.length||I<=0)return!1;const u=Number.isFinite(d)&&d>0?Number(d):1;return ce(h,M)>I*u-4}class F{#e;#t=0;static#n="data-pool-key";constructor(I,M=0){this.#e=I,this.#t=M>0?M:0}next(I,M,d){if(d!=null)return this.#r(I,M,String(d));const u=this.#e.childNodes[this.#t],s=u&&u.tagName,r=/(^|\s)\S*__axis-title(\s|$)/,y=s&&r.test(String(u.getAttribute("class")||"")),p=!!M&&r.test(String(M));if(s&&(!y||p)&&String(s).toLowerCase()===I.toLowerCase())return M&&u.setAttribute("class",M),this.#t++,u;const o=this.#e.ownerDocument.createElementNS(J,I);return M&&o.setAttribute("class",M),u?this.#e.insertBefore(o,u):this.#e.appendChild(o),this.#t++,o}#r(I,M,d){const u=I.toLowerCase();for(let y=this.#t;y<this.#e.childNodes.length;y++){const p=this.#e.childNodes[y],o=p&&p.tagName;if(o&&String(o).toLowerCase()===u&&p.getAttribute(F.#n)===d)return y!==this.#t&&this.#e.insertBefore(p,this.#e.childNodes[this.#t]),M&&p.setAttribute("class",M),this.#t++,p}const s=this.#e.ownerDocument.createElementNS(J,I);s.setAttribute(F.#n,d),M&&s.setAttribute("class",M);const r=this.#e.childNodes[this.#t];return r?this.#e.insertBefore(s,r):this.#e.appendChild(s),this.#t++,s}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Xe("packages/modules/charts/fills.js",function(n,me){"use strict";Object.defineProperty(n,"PATTERNS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"GRADIENTS",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"isFill",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"isPaintRef",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"paintFallback",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"normaliseFill",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"swatchCss",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"createFillRegistry",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"rowPaint",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"patternSeries",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"paintSolid",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"rowFillSource",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"nodePaint",{enumerable:!0,get:function(){return p}});const J=me("packages/core/src/internal/util.js").warnOnce,i=Object.freeze(["hatch","crosshatch","dots","grid"]),be=Object.freeze(["linear","radial"]),ce=8,he="#0072b2";let D=0;const G=new Map;function le(o){return!!o&&typeof o=="object"&&!Array.isArray(o)&&(typeof o.gradient=="string"||typeof o.pattern=="string")}function U(o){return typeof o=="string"&&o.startsWith("url(#")}function O(o){if(typeof o!="string")return o==null?"":String(o);if(!o.startsWith("url("))return o;const S=o.indexOf(")");return(S<0?"":o.slice(S+1).trim())||he}function F(o,S){J(`chart:fill:invalid:${o}`,`a chart fill object was ignored: ${S} The mark was drawn in a solid colour instead. A fill is a gradient object (gradient: "linear" or "radial", with stops of [offset, colour]) or a pattern object (pattern: "hatch", "crosshatch", "dots" or "grid", with a colour).`)}function h(o,S){if(!le(o))return null;const l=S||he;if(typeof o.gradient=="string"){if(!be.includes(o.gradient))return F("gradient",`the gradient "${o.gradient}" is not one of ${be.join(", ")}.`),null;const ae=Array.isArray(o.stops)?o.stops:[],oe=[];for(const q of ae){const V=Array.isArray(q)?Number(q[0]):Number(q&&q.offset),ie=Array.isArray(q)?q[1]:q&&q.colour;!Number.isFinite(V)||typeof ie!="string"||!ie||oe.push({offset:Math.min(1,Math.max(0,V)),colour:ie})}if(oe.length<2)return F("stops","a gradient needs at least two [offset, colour] stops."),null;oe.sort((q,V)=>q.offset-V.offset);const N=Number.isFinite(Number(o.angle))?Number(o.angle):180;return{kind:o.gradient,angle:N,stops:oe,solid:oe[0].colour}}if(!i.includes(o.pattern))return F("pattern",`the pattern "${o.pattern}" is not one of ${i.join(", ")}.`),null;const _=Number(o.size),re=Number(o.angle),te=typeof o.colour=="string"&&o.colour?o.colour:l;return{kind:"pattern",pattern:o.pattern,colour:te,background:typeof o.background=="string"&&o.background?o.background:null,size:Number.isFinite(_)&&_>=2?_:ce,angle:Number.isFinite(re)?re:o.pattern==="grid"||o.pattern==="dots"?0:45,solid:te}}function I(o){if(o.kind==="pattern"){const l=o.colour,_=o.size,re=Math.max(1,_/5),te=o.background||"transparent",ae=oe=>`repeating-linear-gradient(${oe+90}deg,${l} 0 ${re}px,transparent ${re}px ${_}px)`;return o.pattern==="hatch"?`${ae(o.angle)},${te}`:o.pattern==="crosshatch"?`${ae(o.angle)},${ae(o.angle+90)},${te}`:o.pattern==="grid"?`${ae(o.angle)},${ae(o.angle+90)},${te}`:`radial-gradient(circle at 50% 50%,${l} ${_/6}px,transparent ${_/6+.5}px) 0 0/${_}px ${_}px,${te}`}const S=o.stops.map(l=>`${l.colour} ${Math.round(l.offset*100)}%`).join(",");return o.kind==="radial"?`radial-gradient(circle,${S})`:`linear-gradient(${o.angle}deg,${S})`}function M(o){if(!U(o))return typeof o=="string"?o:"";const S=String(o).indexOf(")"),l=String(o).slice(5,S),_=G.get(l);return _?I(_):O(o)}function d(o){const S=`lattice-fill-${++D}`;let l=new Map,_=0;const re=(ae,oe)=>{const N=o.ownerDocument.createElementNS("http://www.w3.org/2000/svg",ae);for(const q of Object.keys(oe))N.setAttribute(q,String(oe[q]));return N},te=(ae,oe)=>{if(oe.kind==="pattern"){const q=oe.size,V=Math.max(1,q/5),ie=re("pattern",{id:ae,width:q,height:q,patternUnits:"userSpaceOnUse"});oe.angle&&ie.setAttribute("patternTransform",`rotate(${oe.angle})`),oe.background&&ie.appendChild(re("rect",{width:q,height:q,fill:oe.background}));const C={stroke:oe.colour,"stroke-width":V};oe.pattern==="dots"?ie.appendChild(re("circle",{cx:q/2,cy:q/2,r:Math.max(1,q/6),fill:oe.colour})):(ie.appendChild(re("line",{x1:q/2,y1:0,x2:q/2,y2:q,...C})),oe.pattern!=="hatch"&&ie.appendChild(re("line",{x1:0,y1:q/2,x2:q,y2:q/2,...C}))),o.appendChild(ie);return}let N;if(oe.kind==="radial")N=re("radialGradient",{id:ae,cx:.5,cy:.5,r:.5});else{const q=oe.angle*Math.PI/180,V=Math.sin(q)/2,ie=-Math.cos(q)/2;N=re("linearGradient",{id:ae,x1:+(.5-V).toFixed(4),y1:+(.5-ie).toFixed(4),x2:+(.5+V).toFixed(4),y2:+(.5+ie).toFixed(4)})}for(const q of oe.stops)N.appendChild(re("stop",{offset:q.offset,"stop-color":q.colour}));o.appendChild(N)};return{prefix:S,paint(ae,oe){const N=h(ae,oe);if(!N)return oe||he;if(!o||!o.ownerDocument)return N.solid;const q=JSON.stringify(N);let V=l.get(q);if(!V){const ie=`${S}-${_++}`;te(ie,N),G.set(ie,N),V=`url(#${ie}) ${N.solid}`,l.set(q,V)}return V},reset(){for(const ae of l.values())G.delete(ae.slice(5,ae.indexOf(")")));if(l=new Map,_=0,o)for(;o.firstChild;)o.removeChild(o.firstChild)},ids(){return[...l.values()].map(ae=>ae.slice(5,ae.indexOf(")")))}}}function u(o,S,l){if(o==null||o==="")return null;const _=O(l);if(le(o))return S?S.paint(o,_):(h(o,_)||{}).solid||null;if(typeof o=="string"){if(i.includes(o)){const re={pattern:o,colour:_};return S?S.paint(re,_):_}return o}return null}function s(o){const S=[{pattern:"hatch",angle:45},{pattern:"dots"},{pattern:"crosshatch",angle:45},{pattern:"hatch",angle:135},{pattern:"grid"},{pattern:"dots",size:5},{pattern:"hatch",angle:0},{pattern:"crosshatch",angle:0,size:6}];return o.map((l,_)=>({...S[_%S.length],colour:l,background:"var(--lattice-background, #fff)"}))}function r(o){return U(o)?String(o).replace(/^url\([^)]*\)\s*/,""):o}function y(o,S){const l=o.fill;if(le(l))return(re,te)=>u(l,S.fills,r(te));if(typeof l=="function")return(re,te)=>{let ae=null;try{ae=l({label:re.label,x:re.x,y:re.y,rowKey:re.rowKey})}catch{ae=null}return u(ae,S.fills,r(te))};const _=typeof l=="string"?l:l&&typeof l=="object"&&typeof l.col=="string"?l.col:null;return _?(re,te)=>re.rowKey===void 0||re.rowKey===null?null:u(o.grid.rows.value(re.rowKey,_),S.fills,r(te)):null}function p(o,S,l){return o&&o({label:S.label,x:S.value,y:S.total,rowKey:S.rowKey},l)||l}}),Xe("packages/modules/charts/scheme.js",function(n,me){"use strict";Object.defineProperty(n,"PALETTE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"SCHEMES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"registerScheme",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"setDefaultScheme",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"schemeNames",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"resolveScheme",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"RAMP_SCALES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"toRgb",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"rampStops",{enumerable:!0,get:function(){return S}});const J=me("packages/core/src/internal/util.js").warnOnce,i=me("packages/modules/charts/fills.js"),be=i.isFill,ce=i.patternSeries,he=i.rowPaint,D=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),G=Object.freeze({default:{series:D,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"},patterns:{series:ce(D),sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"}}),le=new Map;let U="default";function O(l,_){!l||!_||le.set(String(l),_)}function F(l){if(typeof l=="string"){U=l;return}l&&typeof l=="object"&&(le.set("__default__",l),U="__default__")}function h(){return[...Object.keys(G),...le.keys()].filter(l=>!l.startsWith("__"))}function I(l){return le.has(l)?le.get(l):G[l]||null}const M=["series","sequential","diverging","positive","negative"];function d(l){return!l||typeof l!="object"||Array.isArray(l)?!1:!M.some(_=>_ in l)}function u(l,_){const re=_&&_.fills||null,te=I(U)||G.default,ae=l&&l.scheme,oe=d(ae)?ae:null,N=Array.isArray(ae)&&ae.length?ae:null,q=typeof ae=="string"?I(ae):oe||Array.isArray(ae)?null:ae||null,V=(l&&Array.isArray(l.palette)&&l.palette.length?l.palette:null)||N;oe&&V&&J("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const ie=oe?null:V,C={...G.default,...te,...q||{}};ie&&(C.series=ie);const x=l&&l.ramp&&typeof l.ramp=="object"&&!Array.isArray(l.ramp)?l.ramp:null,Q=x?x.colours:l&&l.ramp,c=Array.isArray(Q)&&Q.length>=2?Q:null;c&&(C.sequential=c);const e=x?y(x.scale):null,w=!!(q||ie||oe),k=C.series&&C.series.length?C.series:D,B=new Map;let E=0;return{...C,series:(X,j)=>{if(oe&&j!==void 0&&j!==null){const K=String(j);return Object.prototype.hasOwnProperty.call(oe,K)?s(oe[K],re,X):(B.has(K)||B.set(K,E++),s(p(k,B.get(K),!0),re,B.get(K)))}return s(p(k,X,w),re,X)},explicit:w,nameMap:!!oe,rampScale:e,fills:re}}function s(l,_,re){if(!be(l))return l;const te=D[(re%D.length+D.length)%D.length];return he(l,_,te)||te}const r=Object.freeze(["linear","log","quantile"]);function y(l){return l==null?null:r.includes(l)?l:(J(`chart:ramp:scale:${String(l)}`,`chart "ramp.scale" was "${String(l)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function p(l,_,re){const te=(_%l.length+l.length)%l.length;return re||typeof l[te]!="string"?l[te]:`var(--lattice-chart-${te+1}, ${l[te]})`}function o(l){if(typeof l!="string")return null;const _=l.trim(),re=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(_);if(re){const oe=re[1];return oe.length===3?[0,1,2].map(N=>parseInt(oe[N]+oe[N],16)):[0,2,4].map(N=>parseInt(oe.slice(N,N+2),16))}const te=/^rgba?\(([^)]+)\)$/i.exec(_);if(!te)return null;const ae=te[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return ae.length===3&&ae.every(oe=>Number.isFinite(oe))?ae:null}function S(l,_){const re=_?l.diverging:l.sequential,te=_?G.default.diverging:G.default.sequential,ae=(Array.isArray(re)?re:te).map((oe,N)=>o(oe)||o(te[N])||[0,0,0]);return ae.length>=2?ae:te.map(oe=>o(oe))}}),Xe("packages/modules/charts/styles.js",function(n,me){"use strict";Object.defineProperty(n,"NS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"seriesColour",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"css",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"injectStyles",{enumerable:!0,get:function(){return D}});const J=me("packages/modules/charts/scheme.js").PALETTE,i="lat-chartview",be="data-lattice-chartview";function ce(G){const le=(G%J.length+J.length)%J.length;return`var(--lattice-chart-${le+1}, ${J[le]})`}function he(){return`
6
+ (function(jn){"use strict";var bn=Object.create(null),yn=Object.create(null);function Xe(n,me){bn[n]=me}function wn(n){var me=yn[n];if(me)return me;var ye=Object.create(null);yn[n]=ye;var J=bn[n];if(!J)throw new Error("[lattice] missing module: "+n);return J(ye,wn),ye}Xe("packages/core/src/internal/util.js",function(n,me){"use strict";Object.defineProperty(n,"VERSION",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"reportedWarnings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"warnOnce",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"infoOnce",{enumerable:!0,get:function(){return I}}),Object.defineProperty(n,"resetWarnings",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"fail",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"invariant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"DEV",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"isObject",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"isFunction",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"isNil",{enumerable:!0,get:function(){return p}}),Object.defineProperty(n,"isBlank",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"isCtor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(n,"pathGetter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"pathSetter",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"getPath",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"setPath",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"humanise",{enumerable:!0,get:function(){return N}}),Object.defineProperty(n,"escapeHtml",{enumerable:!0,get:function(){return V}}),Object.defineProperty(n,"titleCase",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(n,"expand",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"toArray",{enumerable:!0,get:function(){return x}}),Object.defineProperty(n,"merge",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"mergeRow",{enumerable:!0,get:function(){return e}}),Object.defineProperty(n,"Lru",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"collator",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"defaultCompare",{enumerable:!0,get:function(){return E}}),Object.defineProperty(n,"now",{enumerable:!0,get:function(){return se}}),Object.defineProperty(n,"nextFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(n,"cancelFrame",{enumerable:!0,get:function(){return K}}),Object.defineProperty(n,"frameBatched",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"settleDebounce",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"whenIdle",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"uid",{enumerable:!0,get:function(){return T}});const ye="1.89.1";async function J(){return ye}const i="1.89.1",be=new Set,ce=2e3;function he(g){if(be.add(g),be.size>ce){const b=be.values().next().value;b!==void 0&&be.delete(b)}}const D=[],G=500;function le(g,b,L){D.push({key:g,level:b,message:L.map(f=>typeof f=="string"?f:U(f)).join(" "),at:Date.now()}),D.length>G&&D.shift()}function U(g){if(g instanceof Error)return g.message;try{return JSON.stringify(g)}catch{return String(g)}}function O(){return D.map(g=>({...g}))}function F(g){if(g.length===0||typeof g[0]!="string")return g;const b=g[0].replace(/^\[lattice\]\s*/,"");return b===g[0]?g:[b,...g.slice(1)]}function h(g,...b){if(be.has(g))return;he(g);const L=F(b);le(g,"warn",L),console.warn("[lattice]",...L)}function I(g,...b){if(be.has(g))return;he(g);const L=F(b);le(g,"info",L),console.info("[lattice]",...L)}function M(){be.clear(),D.length=0}function d(g,b){const L=new Error(`[lattice] ${g}`);throw b!==void 0&&(L.cause=b),L}function u(g,b){g||d(b)}const s=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function r(g){return g!==null&&typeof g=="object"&&!Array.isArray(g)}function y(g){return typeof g=="function"}function p(g){return g==null}function o(g){return g==null||g===""}function S(g){return typeof g!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(g))?!0:!!(g.prototype&&Object.getOwnPropertyNames(g.prototype).length>1)}const l=new Map;function _(g){let b=l.get(g);if(b)return b;if(!g.includes("."))b=L=>L?.[g];else{const L=g.split("."),f=L.length;b=R=>{let t=R;for(let v=0;v<f;v++){if(t==null)return;t=t[L[v]]}return t}}return l.set(g,b),b}const re=new Map;function te(g){let b=re.get(g);if(b)return b;if(!g.includes("."))b=(L,f)=>{L!=null&&(L[g]=f)};else{const L=g.split("."),f=L.length-1;b=(R,t)=>{let v=R;for(let a=0;a<f;a++){if(v==null)return;const z=L[a];v[z]==null&&(v[z]={}),v=v[z]}v!=null&&(v[L[f]]=t)}}return re.set(g,b),b}function ae(g,b){return _(b)(g)}function oe(g,b,L){te(b)(g,L)}function N(g){return g?(g.includes(".")?g.slice(g.lastIndexOf(".")+1):g).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(/^./,L=>L.toUpperCase()):""}const q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function V(g){const b=g==null?"":String(g);return/[&<>"']/.test(b)?b.replace(/[&<>"']/g,L=>q[L]):b}function ie(g){return String(g).replace(/\w\S*/g,b=>b[0].toUpperCase()+b.slice(1).toLowerCase())}function C(g,b,L){if(g!==void 0)return g===!0?{enabled:!0,...L}:g===!1?{enabled:!1}:r(g)?g:{[b]:g,enabled:!0}}function x(g){return g==null?[]:Array.isArray(g)?g:[g]}const Q=Object.freeze(new Set(["__proto__","constructor","prototype"]));function c(g,b){if(!r(g))return r(b)?{...b}:b;if(!r(b))return b===void 0?g:b;const L={...g};for(const f of Object.keys(b)){if(Q.has(f))continue;const R=b[f];R!==void 0&&(L[f]=r(R)&&r(L[f])?c(L[f],R):R)}return L}function e(g,b){if(!r(g)||!r(b)||g===b)return b;const L=Object.create(Object.getPrototypeOf(g));return Object.assign(L,g,b),L}class w{#e;#t=new Map;#n;constructor(b=256,L=null){this.#e=b,this.#n=L}get size(){return this.#t.size}get max(){return this.#e}set max(b){this.#e=b,this.#r()}has(b){return this.#t.has(b)}get(b){const L=this.#t;if(!L.has(b))return;const f=L.get(b);return L.delete(b),L.set(b,f),f}peek(b){return this.#t.get(b)}set(b,L){const f=this.#t;return f.has(b)&&f.delete(b),f.set(b,L),this.#r(),L}delete(b){const L=this.#t.get(b);return this.#t.delete(b)&&this.#n&&this.#n(L,b),L}clear(){if(this.#n)for(const[b,L]of this.#t)this.#n(L,b);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const b=this.#t;for(;b.size>this.#e;){const L=b.keys().next().value,f=b.get(L);b.delete(L),this.#n&&this.#n(f,L)}}}const k=new Map;function B(g,b){const L=`${g||""}|${b?JSON.stringify(b):""}`;let f=k.get(L);return f||(f=new Intl.Collator(g||void 0,{numeric:!0,sensitivity:"variant",...b}),k.set(L,f)),f}function E(g,b){if(g===b)return 0;if(g==null)return 1;if(b==null)return-1;if(typeof g=="number"&&typeof b=="number")return Number.isNaN(g)?Number.isNaN(b)?0:1:Number.isNaN(b)||g<b?-1:g>b?1:0;const L=String(g),f=String(b);return L<f?-1:L>f?1:0}function se(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const X=typeof requestAnimationFrame=="function";function j(g){return X?requestAnimationFrame(g):setTimeout(()=>g(se()),16)}function K(g){g!=null&&(X?cancelAnimationFrame(g):clearTimeout(g))}function ee(g){let b=null,L=null;const f=()=>{b=null;const t=L;L=null,g(...t||[])},R=(...t)=>{L=t,b===null&&(b=j(f))};return R.cancel=()=>{K(b),b=null,L=null},R.flush=()=>{b!==null&&(K(b),f())},R}function pe(g,b){let L=null,f=null;const R=()=>{if(L=null,f===null)return;const a=f;f=null,g(...a),t()},t=()=>{L=setTimeout(R,b),typeof L?.unref=="function"&&L.unref()},v=(...a)=>{L===null?(g(...a),t()):(f=a,clearTimeout(L),t())};return v.flush=()=>{if(L!==null&&clearTimeout(L),L=null,f===null)return;const a=f;f=null,g(...a)},v.cancel=()=>{L!==null&&clearTimeout(L),L=null,f=null},v.pending=()=>L!==null||f!==null,v}function ne(g,b=50){return typeof requestIdleCallback=="function"?requestIdleCallback(g,{timeout:b}):setTimeout(()=>g({timeRemaining:()=>0,didTimeout:!0}),1)}let ke=0;function T(g="l"){return`${g}${(++ke).toString(36)}`}}),Xe("packages/modules/geometry/geodata.js",function(n,me){"use strict";Object.defineProperty(n,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"EARTH_RADIUS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"toWkt",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"toWkb",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(n,"readGeometry",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"parseGeometry",{enumerable:!0,get:function(){return se}}),Object.defineProperty(n,"haversine",{enumerable:!0,get:function(){return j}}),Object.defineProperty(n,"geometryInfo",{enumerable:!0,get:function(){return L}}),Object.defineProperty(n,"geometryKind",{enumerable:!0,get:function(){return f}}),Object.defineProperty(n,"spatialOperand",{enumerable:!0,get:function(){return t}}),Object.defineProperty(n,"spatialPredicate",{enumerable:!0,get:function(){return xe}});const ye=me("packages/core/src/internal/util.js"),J=ye.isNil,i=ye.isObject,be=ye.warnOnce,ce=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),he=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),D=Object.freeze([...he,"blank","notBlank"]),G=63710088e-1,le=Math.PI/180,U=16,O=1e-12;class F extends Error{}function h($){throw new F($)}function I($){(!Array.isArray($)||$.length<2)&&h("a position needs at least two numbers");const P=Number($[0]),W=Number($[1]);return(typeof $[0]!="number"||typeof $[1]!="number"||!Number.isFinite(P)||!Number.isFinite(W))&&h("a coordinate is not a finite number"),[P,W]}function M($,P,W){Array.isArray($)||h(`${W} is not an array of positions`);const fe=$.map(I);return fe.length<P&&h(`${W} needs at least ${P} positions, found ${fe.length}`),fe}function d($){const P=M($,3,"a polygon ring"),W=P[0],fe=P[P.length-1];return(W[0]!==fe[0]||W[1]!==fe[1])&&P.push([W[0],W[1]]),P.length<4&&h(`a polygon ring needs at least 3 distinct corners, found ${P.length-1}`),P}function u($){return(!Array.isArray($)||$.length===0)&&h("a polygon needs at least an outer ring"),$.map(d)}function s($,P){switch(P>U&&h("geometry collections nest too deeply"),i($)||h("GeoJSON must be an object"),$.type){case"Feature":return $.geometry==null?null:s($.geometry,P+1);case"FeatureCollection":return h("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:I($.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:M($.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:M($.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray($.coordinates)||!$.coordinates.length)&&h("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:$.coordinates.map(W=>M(W,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:u($.coordinates)};case"MultiPolygon":return(!Array.isArray($.coordinates)||!$.coordinates.length)&&h("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:$.coordinates.map(u)};case"GeometryCollection":{(!Array.isArray($.geometries)||!$.geometries.length)&&h("a GeometryCollection needs at least one geometry");const W=$.geometries.map(fe=>s(fe,P+1)).filter(Boolean);return W.length?{type:"GeometryCollection",geometries:W}:null}default:return h(`"${String($.type)}" is not a GeoJSON geometry type`)}}const r=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),y=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,p=/[A-Za-z]+/y,o=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class S{text;at=0;constructor(P){this.text=P}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(P){this.space(),this.text[this.at]!==P&&h(`WKT expected "${P}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(P){return this.space(),this.text[this.at]===P?(this.at++,!0):!1}word(){this.space(),p.lastIndex=this.at;const P=p.exec(this.text);return P?(this.at+=P[0].length,P[0].toUpperCase()):""}numberNext(){return this.space(),y.lastIndex=this.at,y.test(this.text)}number(){this.space(),y.lastIndex=this.at;const P=y.exec(this.text);return P||h(`WKT expected a number at character ${this.at+1}`),this.at+=P[0].length,Number(P[0])}position(){const P=this.number(),W=this.number();for(;this.numberNext();)this.number();return[P,W]}positionList(){this.expect("(");const P=[this.position()];for(;this.accept(",");)P.push(this.position());return this.expect(")"),P}empty(){const P=this.at;return this.word()==="EMPTY"?!0:(this.at=P,!1)}geometry(P){P>U&&h("geometry collections nest too deeply");const W=this.word(),fe=r[W];fe||h(W?`"${W}" is not a WKT geometry type`:"WKT expected a geometry type");const $e=this.at,ve=this.word();return ve!=="Z"&&ve!=="M"&&ve!=="ZM"&&(this.at=$e),this.empty()?null:this.body(fe,P)}body(P,W){switch(P){case"Point":{this.expect("(");const fe=this.position();return this.expect(")"),{type:"Point",coordinates:fe}}case"LineString":return{type:"LineString",coordinates:M(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const fe=[];do this.empty()||(this.accept("(")?(fe.push(this.position()),this.expect(")")):fe.push(this.position()));while(this.accept(","));return this.expect(")"),fe.length?{type:"MultiPoint",coordinates:fe}:null}case"MultiLineString":{const fe=this.parts(()=>M(this.positionList(),2,"a LineString"));return fe.length?{type:"MultiLineString",coordinates:fe}:null}case"MultiPolygon":{const fe=this.parts(()=>this.polygonBody());return fe.length?{type:"MultiPolygon",coordinates:fe}:null}default:{this.expect("(");const fe=[];do{const $e=this.geometry(W+1);$e&&fe.push($e)}while(this.accept(","));return this.expect(")"),fe.length?{type:"GeometryCollection",geometries:fe}:null}}}parts(P){this.expect("(");const W=[];do this.empty()||W.push(P());while(this.accept(","));return this.expect(")"),W}polygonBody(){return u(this.parts(()=>this.positionList()))}}function l($){const P=new S(String($).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),W=P.geometry(0);return P.space(),P.at<P.text.length&&h(`WKT has unexpected text after the geometry at character ${P.at+1}`),W}function _($){return Object.is($,-0)?"0":String($)}function re($){return`${_($[0])} ${_($[1])}`}function te($){return`(${$.map(re).join(", ")})`}function ae($){return`(${$.map(te).join(", ")})`}function oe($){const P=se($);return P?N(P):""}function N($){switch($.type){case"Point":return`POINT (${re($.coordinates)})`;case"LineString":return`LINESTRING ${te($.coordinates)}`;case"Polygon":return`POLYGON ${ae($.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${$.coordinates.map(P=>`(${re(P)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${$.coordinates.map(te).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${$.coordinates.map(ae).join(", ")})`;default:return`GEOMETRYCOLLECTION (${$.geometries.map(N).join(", ")})`}}class q{view;at=0;constructor(P){this.view=new DataView(P.buffer,P.byteOffset,P.byteLength)}need(P){this.at+P>this.view.byteLength&&h(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(P){this.need(4);const W=this.view.getUint32(this.at,P);return this.at+=4,W}f64(P){this.need(8);const W=this.view.getFloat64(this.at,P);return this.at+=8,W}count(P,W){const fe=this.u32(P);return fe*W>this.view.byteLength-this.at&&h(`WKB claims ${fe} elements, more than its bytes can hold`),fe}position(P,W){const fe=this.f64(P),$e=this.f64(P);for(let ve=2;ve<W;ve++)this.f64(P);return[fe,$e]}positions(P,W){const fe=this.count(P,8*W),$e=new Array(fe);for(let ve=0;ve<fe;ve++)$e[ve]=this.position(P,W);return $e}geometry(P,W){P>U&&h("geometry collections nest too deeply");const fe=this.u8();fe!==0&&fe!==1&&h(`WKB byte-order mark is ${fe}, not 0 or 1`);const $e=fe===1,ve=this.u32($e);let Me=2;ve&2147483648&&Me++,ve&1073741824&&Me++,ve&536870912&&this.u32($e);let Te=ve&268435455;if(Te>=1e3){const Ue=Math.floor(Te/1e3);Ue>3&&h(`WKB geometry type ${Te} is not one this reads`),Me=2+(Ue===3?2:1),Te%=1e3}const Be=ce[Te-1];switch(Be||h(`WKB geometry type ${Te} is not one this reads`),W&&Be!==W&&h(`a part of a WKB Multi${W} is a ${Be}`),Be){case"Point":{const Ue=this.position($e,Me);return Number.isNaN(Ue[0])&&Number.isNaN(Ue[1])?null:{type:"Point",coordinates:I(Ue)}}case"LineString":return{type:"LineString",coordinates:M(this.positions($e,Me),2,"a LineString")};case"Polygon":{const Ue=this.count($e,4),Re=[];for(let He=0;He<Ue;He++)Re.push(this.positions($e,Me));return Ue?{type:"Polygon",coordinates:u(Re)}:null}default:{const Ue=this.count($e,5),Re=Be==="GeometryCollection"?void 0:Be.slice(5),He=[];for(let We=0;We<Ue;We++){const pt=this.geometry(P+1,Re);pt&&He.push(pt)}return He.length?Be==="GeometryCollection"?{type:Be,geometries:He}:{type:Be,coordinates:He.map(We=>We.coordinates)}:null}}}}function V($){const P=new q($),W=P.geometry(0);return P.at!==$.byteLength&&h(`WKB has ${$.byteLength-P.at} bytes left over after the geometry`),W}function ie($){const P=se($);if(!P)return null;const W=[];let fe=0;const $e=Re=>{const He=new DataView(new ArrayBuffer(5));He.setUint8(0,1),He.setUint32(1,ce.indexOf(Re)+1,!0),W.push(He),fe+=5},ve=Re=>{const He=new DataView(new ArrayBuffer(4));He.setUint32(0,Re,!0),W.push(He),fe+=4},Me=Re=>{const He=new DataView(new ArrayBuffer(16*Re.length));Re.forEach((We,pt)=>{He.setFloat64(pt*16,We[0],!0),He.setFloat64(pt*16+8,We[1],!0)}),W.push(He),fe+=16*Re.length},Te=Re=>{switch($e(Re.type),Re.type){case"Point":Me([Re.coordinates]);break;case"LineString":ve(Re.coordinates.length),Me(Re.coordinates);break;case"Polygon":ve(Re.coordinates.length);for(const He of Re.coordinates)ve(He.length),Me(He);break;case"GeometryCollection":ve(Re.geometries.length);for(const He of Re.geometries)Te(He);break;default:{const He=Re.type.slice(5);ve(Re.coordinates.length);for(const We of Re.coordinates)Te({type:He,coordinates:We})}}};Te(P);const Be=new Uint8Array(fe);let Ue=0;for(const Re of W)Be.set(new Uint8Array(Re.buffer),Ue),Ue+=Re.byteLength;return Be}const C=/^0[01](?:[0-9a-fA-F]{2})+$/,x=/^[A-Za-z0-9+/_-]+={0,2}$/,Q=(()=>{const $=new Int16Array(128).fill(-1),P="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let W=0;W<P.length;W++)$[P.charCodeAt(W)]=W;return $[45]=62,$[95]=63,$})();function c($){const P=new Uint8Array($.length/2);for(let W=0;W<P.length;W++)P[W]=parseInt($.slice(W*2,W*2+2),16);return P}function e($){const P=$.replace(/=+$/,""),W=new Uint8Array(Math.floor(P.length*3/4));let fe=0,$e=0,ve=0;for(let Me=0;Me<P.length;Me++)$e=$e<<6|Q[P.charCodeAt(Me)],fe+=6,fe>=8&&(fe-=8,W[ve++]=$e>>fe&255);return W.subarray(0,ve)}function w($){const P=$.trim();if(P==="")return null;if(P[0]==="{"){let W;try{W=JSON.parse(P)}catch{return h("the text starts like GeoJSON but is not valid JSON")}return s(W,0)}if(C.test(P))return V(c(P));if(o.test(P))return l(P);if(x.test(P)){const W=e(P);if(W.length>=5&&(W[0]===0||W[0]===1))return V(W)}return h("the text is not WKT, GeoJSON, or hex or base64 WKB")}const k=new WeakSet;function B($){if(J($))return{geometry:null,reason:null};if(typeof $=="object"&&k.has($))return{geometry:$,reason:null};try{let P;return typeof $=="string"?P=w($):$ instanceof Uint8Array?P=V($):$ instanceof ArrayBuffer?P=V(new Uint8Array($)):ArrayBuffer.isView($)?P=V(new Uint8Array($.buffer,$.byteOffset,$.byteLength)):i($)?P=s($,0):h(`${Array.isArray($)?"an array":`a ${typeof $}`} is not a geometry`),P&&E(P),{geometry:P||null,reason:null}}catch(P){if(P instanceof F)return{geometry:null,reason:P.message};throw P}}function E($){if(k.add($),$.type==="GeometryCollection")for(const P of $.geometries)E(P)}function se($){return B($).geometry}function X($,P){switch($.type){case"Point":P($.coordinates);break;case"MultiPoint":case"LineString":$.coordinates.forEach(P);break;case"MultiLineString":case"Polygon":for(const W of $.coordinates)W.forEach(P);break;case"MultiPolygon":for(const W of $.coordinates)for(const fe of W)fe.forEach(P);break;default:for(const W of $.geometries)X(W,P)}}function j($,P){const W=$[1]*le,fe=P[1]*le,$e=fe-W,ve=(P[0]-$[0])*le,Me=Math.sin($e/2)**2+Math.cos(W)*Math.cos(fe)*Math.sin(ve/2)**2;return 2*G*Math.asin(Math.min(1,Math.sqrt(Me)))}function K($){let P=0;for(let W=1;W<$.length;W++)P+=j($[W-1],$[W]);return P}function ee($){const P=$.length-1;if(P<3)return 0;let W=0;for(let fe=0;fe<P;fe++){const $e=$[(fe-1+P)%P],ve=$[(fe+1)%P];W+=(ve[0]-$e[0])*le*Math.sin($[fe][1]*le)}return Math.abs(W)*G*G/2}function pe($){let P=ee($[0]);for(let W=1;W<$.length;W++)P-=ee($[W]);return Math.max(0,P)}function ne($){let P=0,W=0,fe=0;for(let $e=0;$e<$.length-1;$e++){const[ve,Me]=$[$e],[Te,Be]=$[$e+1],Ue=ve*Be-Te*Me;P+=Ue,W+=(ve+Te)*Ue,fe+=(Me+Be)*Ue}return{a:P,cx:W,cy:fe}}function ke(){let $=0,P=0,W=0;return{add(fe,$e,ve){$+=fe*ve,P+=$e*ve,W+=ve},get(){return W>0?[$/W,P/W]:null}}}function T($){let P=0,W=0;for(const fe of $)P+=fe[0],W+=fe[1];return[P/$.length,W/$.length]}function g($,P){switch($.type){case"Point":P[0].add($.coordinates[0],$.coordinates[1],1);break;case"MultiPoint":for(const W of $.coordinates)P[0].add(W[0],W[1],1);break;case"LineString":case"MultiLineString":{const W=$.type==="LineString"?[$.coordinates]:$.coordinates;for(const fe of W){for(let $e=1;$e<fe.length;$e++){const[ve,Me]=fe[$e-1],[Te,Be]=fe[$e],Ue=Math.hypot(Te-ve,Be-Me);P[1].add((ve+Te)/2,(Me+Be)/2,Ue)}for(const $e of fe)P[0].add($e[0],$e[1],1)}break}case"Polygon":case"MultiPolygon":{const W=$.type==="Polygon"?[$.coordinates]:$.coordinates;for(const fe of W){let $e=0,ve=0,Me=0;fe.forEach((Be,Ue)=>{const Re=ne(Be),He=(Ue===0?1:-1)*(Re.a<0?-1:1);$e+=He*Re.a,ve+=He*Re.cx,Me+=He*Re.cy}),Math.abs($e)>O&&P[2].add(ve/(3*$e),Me/(3*$e),Math.abs($e)/2);const Te=fe[0].slice(0,-1);for(const Be of Te)P[0].add(Be[0],Be[1],1)}break}default:for(const W of $.geometries)g(W,P)}}const b=new WeakMap;function L($){const P=se($);if(!P)return null;const W=b.get(P);if(W)return W;const fe=[1/0,1/0,-1/0,-1/0];X(P,Re=>{Re[0]<fe[0]&&(fe[0]=Re[0]),Re[1]<fe[1]&&(fe[1]=Re[1]),Re[0]>fe[2]&&(fe[2]=Re[0]),Re[1]>fe[3]&&(fe[3]=Re[1])});const $e=[ke(),ke(),ke()];g(P,$e);const ve=$e[2].get()||$e[1].get()||$e[0].get()||T([[fe[0],fe[1]],[fe[2],fe[3]]]);let Me=0,Te=0;const Be=Re=>{switch(Re.type){case"LineString":Me+=K(Re.coordinates);break;case"MultiLineString":for(const He of Re.coordinates)Me+=K(He);break;case"Polygon":Te+=pe(Re.coordinates);for(const He of Re.coordinates)Me+=K(He);break;case"MultiPolygon":for(const He of Re.coordinates){Te+=pe(He);for(const We of He)Me+=K(We)}break;case"GeometryCollection":for(const He of Re.geometries)Be(He);break;default:break}};Be(P);const Ue=Object.freeze({kind:P.type,bbox:Object.freeze(fe),centroid:Object.freeze(ve),length:Me,area:Te});return b.set(P,Ue),Ue}function f($){const P=L($);return P?P.kind:null}function R($,P){const W=typeof $=="string"?$.split(/[\s,;]+/).filter(Boolean):$;if(!Array.isArray(W)||W.length!==P)return null;const fe=W.map($e=>typeof $e=="number"?$e:typeof $e=="string"?Number($e):NaN);return fe.every(Number.isFinite)?fe:null}function t($,P){if($==="withinBbox"){const W=R(P,4);return W?W[0]>W[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:W[1]>W[3]?{reason:"the box's minLat is above its maxLat"}:{operand:W}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if($==="withinDistance"){let W=null;if(i(P)&&!Array.isArray(P)){const fe=P;W=R([fe.lon,fe.lat,fe.metres],3)}else W=R(P,3);return!W||W[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:W[0],lat:W[1],metres:W[2]}}}if($==="withinPolygon"||$==="intersects"){const W=$==="intersects"?R(P,4):null;if(W){if(W[0]>W[2]||W[1]>W[3])return{reason:"the box's minimum is above its maximum"};const[ve,Me,Te,Be]=W;return{operand:{type:"Polygon",coordinates:[[[ve,Me],[Te,Me],[Te,Be],[ve,Be],[ve,Me]]]}}}const{geometry:fe,reason:$e}=B(P);return fe?$==="withinPolygon"&&fe.type!=="Polygon"&&fe.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${fe.type}`}:{operand:fe}:{reason:`${$} needs a geometry: ${$e||"none was given"}`}}return{reason:`"${$}" is not a spatial operator`}}function v($,P){const[W,fe]=$;let $e=!1;for(let ve=0,Me=P.length-2;ve<P.length-1;Me=ve++){const[Te,Be]=P[ve],[Ue,Re]=P[Me];Be>fe!=Re>fe&&W<(Ue-Te)*(fe-Be)/(Re-Be)+Te&&($e=!$e)}return $e}function a($,P){if(!v($,P[0]))return!1;for(let W=1;W<P.length;W++)if(v($,P[W]))return!1;return!0}function z($,P={points:[],segments:[],polygons:[]}){const W=fe=>{for(let $e=1;$e<fe.length;$e++)P.segments.push([fe[$e-1],fe[$e]]);for(const $e of fe)P.points.push($e)};switch($.type){case"Point":P.points.push($.coordinates);break;case"MultiPoint":for(const fe of $.coordinates)P.points.push(fe);break;case"LineString":W($.coordinates);break;case"MultiLineString":$.coordinates.forEach(W);break;case"Polygon":P.polygons.push($.coordinates),$.coordinates.forEach(W);break;case"MultiPolygon":for(const fe of $.coordinates)P.polygons.push(fe),fe.forEach(W);break;default:for(const fe of $.geometries)z(fe,P)}return P}function H($,P,W){const fe=(P[0]-$[0])*(W[1]-$[1])-(P[1]-$[1])*(W[0]-$[0]);return Math.abs(fe)<=O?0:Math.sign(fe)}function Y($,P,W){return $[0]>=Math.min(P[0],W[0])-O&&$[0]<=Math.max(P[0],W[0])+O&&$[1]>=Math.min(P[1],W[1])-O&&$[1]<=Math.max(P[1],W[1])+O}function A($,P){const[W,fe]=$,[$e,ve]=P,Me=H(W,fe,$e),Te=H(W,fe,ve),Be=H($e,ve,W),Ue=H($e,ve,fe);return Me!==Te&&Be!==Ue?!0:Me===0&&Y($e,W,fe)||Te===0&&Y(ve,W,fe)||Be===0&&Y(W,$e,ve)||Ue===0&&Y(fe,$e,ve)}function Z($,P){return $[0]<=P[2]&&P[0]<=$[2]&&$[1]<=P[3]&&P[1]<=$[3]}function de($,P){const W=L($),fe=L(P);if(!Z(W.bbox,fe.bbox))return!1;const $e=z($),ve=z(P);for(const Me of ve.polygons)for(const Te of $e.points)if(a(Te,Me))return!0;for(const Me of $e.polygons)for(const Te of ve.points)if(a(Te,Me))return!0;for(const Me of $e.segments)for(const Te of ve.segments)if(A(Me,Te))return!0;for(const Me of $e.points){for(const Te of ve.points)if(Math.abs(Me[0]-Te[0])<=O&&Math.abs(Me[1]-Te[1])<=O)return!0;for(const Te of ve.segments)if(H(Te[0],Te[1],Me)===0&&Y(Me,Te[0],Te[1]))return!0}for(const Me of ve.points)for(const Te of $e.segments)if(H(Te[0],Te[1],Me)===0&&Y(Me,Te[0],Te[1]))return!0;return!1}function xe($,P){const{operand:W,reason:fe}=t($,P);if(fe)return be(`filter:geometry:${$}`,`a "${$}" condition was refused: ${fe}. It matches no row rather than guessing.`),()=>!1;switch($){case"withinBbox":return $e=>{const ve=L($e);if(!ve)return!1;const Me=ve.bbox;return Me[0]>=W[0]&&Me[1]>=W[1]&&Me[2]<=W[2]&&Me[3]<=W[3]};case"withinPolygon":{const $e=W.type==="Polygon"?[W.coordinates]:W.coordinates,ve=Me=>$e.some(Te=>a(Me,Te));return Me=>{const Te=se(Me);return Te?Te.type==="Point"?ve(Te.coordinates):Te.type==="MultiPoint"?Te.coordinates.every(ve):ve(L(Te).centroid):!1}}case"intersects":return $e=>{const ve=se($e);return!!ve&&de(ve,W)};default:{const $e=[W.lon,W.lat];return ve=>{const Me=L(ve);return!!Me&&j(Me.centroid,$e)<=W.metres}}}}}),Xe("packages/core/src/source/filterwire.js",function(n,me){"use strict";Object.defineProperty(n,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"warnWherePageRelative",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"warnWhereNotApplied",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"warnWhereOverThreshold",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"parseRelativeToken",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"resolveRelativeRange",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"relativeTokenOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(n,"relativeTokenHelp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"isResolvableRelative",{enumerable:!0,get:function(){return S}}),Object.defineProperty(n,"resolveRelativeCondition",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"isGroup",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"forEachCondition",{enumerable:!0,get:function(){return re}}),Object.defineProperty(n,"mapConditions",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"normaliseFilterSet",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"buildFilterSet",{enumerable:!0,get:function(){return N}}),Object.defineProperty(n,"wireFilters",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"querySignature",{enumerable:!0,get:function(){return V}});const J=me("packages/core/src/internal/util.js").warnOnce,i="source.remote.hostFilter",be="source.where.pageRelative";function ce(x,Q){!Array.isArray(x)||!x.length||J(be,`filters.where (${x.join(", ")}) runs over the rows the ${Q} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function he(x){const Q=(x||{}).config;!Q||!Q.hostFilter||J(i,"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 D="source.where.notApplied";function G(x,Q){J(`${D}:${x}`,`filters.where("${x}") is registered but the ${Q} 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 le="source.where.overThreshold";function U(x,Q,c,e){!Array.isArray(x)||!x.length||J(`${le}:${Q}`,`filters.where (${x.join(", ")}) is not applied to the ${Q} pushdown source:`,c===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${c.toLocaleString()} rows, at or past the whereRowLimit of ${e.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const O=new Map;function F(x){let Q=O.get(x);return Q||(Q=new Intl.DateTimeFormat("en-US",{timeZone:x,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),O.set(x,Q)),Q}function h(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function I(x,Q){const c=F(Q).formatToParts(new Date(x)),e={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const w of c)w.type==="year"?e.y=+w.value:w.type==="month"?e.m=+w.value:w.type==="day"?e.d=+w.value:w.type==="hour"?e.h=+w.value%24:w.type==="minute"?e.mi=+w.value:w.type==="second"&&(e.s=+w.value);return e}function M(x,Q){const c=I(x,Q);return Date.UTC(c.y,c.m-1,c.d,c.h,c.mi,c.s)-Math.floor(x/1e3)*1e3}function d(x,Q,c,e){const w=Date.UTC(x,Q-1,c),k=w-M(w,e);return w-M(k,e)}function u(x,Q,c){const e=new Date(Date.UTC(x.y,x.m-1,x.d+Q));return d(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate(),c)}const s=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function r(x,Q){if(typeof x!="string")return null;const c=x.trim().toLowerCase().replace(/[\s_-]+/g,""),e=/^last(\d*|n)days?$/.exec(c);if(e){const w=e[1]==="n"?"":e[1],k=Number(w||Q);return!Number.isFinite(k)||k<=0?null:{kind:"lastNDays",n:Math.floor(k)}}switch(c){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function y(x,Q={}){const c=r(x,Q.n);if(!c)return null;const e=Q.tz||h(),w=Q.now instanceof Date?Q.now.getTime():typeof Q.now=="number"?Q.now:Date.now(),k=I(w,e),B=d(k.y,k.m,k.d,e),E=u(k,1,e);let se=B,X=E;switch(c.kind){case"today":break;case"yesterday":se=u(k,-1,e),X=B;break;case"lastNDays":X=Q.includeToday?E:B,se=u(k,Q.includeToday?-(c.n-1):-c.n,e);break;case"thisWeek":{const j=Number.isFinite(Q.weekStartsOn)?Number(Q.weekStartsOn):1,ee=(new Date(Date.UTC(k.y,k.m-1,k.d)).getUTCDay()-j+7)%7;se=u(k,-ee,e),X=u(k,-ee+7,e);break}case"thisMonth":se=d(k.y,k.m,1,e),X=d(k.m===12?k.y+1:k.y,k.m===12?1:k.m+1,1,e);break;case"thisQuarter":case"quarterToDate":{const j=Math.floor((k.m-1)/3)*3+1;se=d(k.y,j,1,e),X=c.kind==="quarterToDate"?E:j===10?d(k.y+1,1,1,e):d(k.y,j+3,1,e);break}case"thisYear":case"yearToDate":se=d(k.y,1,1,e),X=c.kind==="yearToDate"?E:d(k.y+1,1,1,e);break;default:return null}return{from:new Date(se).toISOString(),to:new Date(X).toISOString(),bounds:"[)",tz:e,relative:c.kind==="lastNDays"?`last${c.n}Days`:c.kind,n:c.n}}function p(x){if(!x||typeof x!="object")return null;const Q=x.value;if(Q&&typeof Q=="object"&&!Array.isArray(Q)&&"relative"in Q)return{token:String(Q.relative),n:typeof Q.n=="number"?Q.n:void 0};if(x.op==="relative"&&typeof x.value=="string")return{token:x.value,n:void 0};const c=x.meta;return c&&typeof c.relative=="string"&&x.value===void 0?{token:c.relative,n:typeof c.n=="number"?c.n:void 0}:null}function o(){return`Known tokens: ${s.filter(Q=>Q!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function S(x){const Q=p(x);return Q?r(Q.token,Q.n)!==null:!1}function l(x,Q={}){const c=p(x);if(!c)return x;const e=y(c.token,{...Q,n:c.n});return e?{...x,type:x.type||"date",op:"between",value:[e.from,e.to],bounds:x.bounds||e.bounds,meta:{...x.meta||{},relative:e.relative,tz:e.tz}}:(J(`source.relative.${c.token}`,`unknown relative date token "${c.token}"; sending the condition unresolved.`,o()),x)}function _(x){return!!x&&typeof x=="object"&&Array.isArray(x.conditions)}function re(x,Q){if(x){if(_(x)){for(const c of x.conditions)re(c,Q);return}Q(x)}}function te(x,Q){if(!x)return null;if(!_(x))return Q(x);const c=x;let e=!1;const w=[];for(const k of c.conditions){const B=te(k,Q);B!==k&&(e=!0),B&&w.push(B)}return!e&&w.length===c.conditions.length?x:w.length?{...c,conditions:w}:null}function ae(x){if(!x)return null;if(!_(x))return x;const Q=x,c=[];for(const e of Q.conditions){const w=ae(e);w&&c.push(w)}return c.length?{op:Q.op,conditions:c}:null}function oe(x){const Q=ae(x);return Q?_(Q)&&Q.op==="and"?Q:{op:"and",conditions:[Q]}:null}function N(x){const Q=(x||[]).filter(Boolean);return Q.length?{op:"and",conditions:Q}:null}function q(x,Q={}){const c=te(x,e=>l(e,Q));return oe(c)}function V(x){const Q=ie(x.filters??null);return JSON.stringify([Q,x.sort??null,x.quick??"",x.groupBy??null,x.pivotBy??null,C(x.context)])}function ie(x){if(!x)return null;if(_(x)){const e=x;return{op:e.op,conditions:e.conditions.map(ie)}}const Q=x,c=Q.meta&&typeof Q.meta.relative=="string"?Q.meta.relative:p(Q)?.token;return{col:Q.col,op:Q.op,bounds:Q.bounds??null,caseSensitive:Q.caseSensitive??!1,value:c?`rel:${c}`:Q.value??null}}function C(x){if(x==null)return null;try{return JSON.parse(JSON.stringify(x))}catch{return J("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Xe("packages/core/src/source/aggregates.js",function(n,me){"use strict";Object.defineProperty(n,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"pushableAggregates",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"fillAggregateSql",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"resolveAggregatesConfig",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"routeAggregate",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"resolveAggregatePlan",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"groupKeysPushable",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"pushdownDocRows",{enumerable:!0,get:function(){return le}});const ye=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 J(){const U=new Set;for(const[O,F]of Object.entries(ye))F.pushable&&U.add(O);return U}function i(U,O,F){let h=U.split("%c").join(O);return F!==void 0&&(h=h.split("%w").join(F)),h}function be(U){const O=U||{},F=O.default==="engine"||O.default==="engine-if-identical"?O.default:"client",h={};if(O.overrides&&typeof O.overrides=="object")for(const[I,M]of Object.entries(O.overrides))(M==="engine"||M==="client")&&(h[I]=M);return{default:F,overrides:h}}function ce(U,O){const F=ye[U];if(!F||!F.pushable)return"client";const h=O.overrides[U];return h==="engine"||h==="client"?h:O.default==="client"?"client":O.default==="engine-if-identical"?F.class==="identical"?"engine":"client":"engine"}function he(U,O){const F=be(O),h=[],I=[];for(const M of U||[]){const d=ye[M.fn],u=ce(M.fn,F),s={id:M.id,col:M.col,fn:M.fn,class:d?d.class:"fallback"};M.weight!==void 0&&(s.weight=M.weight),M.params!==void 0&&(s.params=M.params),u==="engine"?h.push(s):(s.reason=d&&!d.pushable?d.note||"the engine cannot express this stat":"client by config",I.push(s))}return{engine:h,client:I,config:F}}const D=/^[A-Za-z_][A-Za-z0-9_$]*$/;function G(U,O=[]){return(U||[]).every(h=>{if(typeof h=="string")return D.test(h);if(!h||typeof h!="object")return!1;const I=h;return Array.isArray(O)&&O.includes(I.bucket)&&typeof I.col=="string"&&D.test(I.col)&&typeof I.size=="number"&&Number.isFinite(I.size)&&I.size>0})}function le(){return Object.entries(ye).map(([U,O])=>({stat:U,class:O.class,sql:O.sql?i(O.sql,"col",O.twoColumn?"weight":void 0):"",note:O.note||(O.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Xe("packages/core/src/source/abort.js",function(n,me){"use strict";Object.defineProperty(n,"SupersededError",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"RequestToken",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"AbortScope",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"createAbortScope",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"isAbortError",{enumerable:!0,get:function(){return ce}});class ye extends Error{constructor(D,G="superseded"){super(`[lattice] request ${D?`"${D}" `:""}${G}`),this.name="SupersededError",this.superseded=!0,this.key=D}}class J{#e;constructor(D,G,le,U){this.#e=D,this.key=G,this.controller=le,this.signal=le.signal,this.seq=U}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(D){this.signal.aborted||this.controller.abort(new ye(this.key,D)),this.#e.settle(this)}}class i{#e=new Map;#t=0;begin(D="",G="superseded"){const le=this.#e.get(D);le&&!le.signal.aborted&&le.controller.abort(new ye(D,G));const U=new J(this,D,new AbortController,++this.#t);return this.#e.set(D,U),U}tokenFor(D){return this.#e.get(D)}pending(D=""){const G=this.#e.get(D);return!!G&&!G.signal.aborted}get size(){return this.#e.size}settle(D){this.#e.get(D.key)===D&&this.#e.delete(D.key)}abort(D="",G="superseded"){const le=this.#e.get(D);le&&le.abort(G)}abortAll(D="superseded"){for(const G of[...this.#e.values()])G.abort(D);this.#e.clear()}}function be(){return new i}function ce(he){if(!he||typeof he!="object")return!1;const D=he;return D.superseded===!0||D.name==="AbortError"||D.name==="SupersededError"}}),Xe("packages/core/src/source/pushdown.js",function(n,me){"use strict";Object.defineProperty(n,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"NO_CAPABILITIES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"resolveMutate",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"capabilitiesOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"splitFilters",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return N}}),Object.defineProperty(n,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"planQuery",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(n,"applyResidual",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(n,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return k}}),Object.defineProperty(n,"createPushdownSource",{enumerable:!0,get:function(){return X}});const ye=me("packages/core/src/internal/util.js"),J=ye.defaultCompare,i=ye.isFunction,be=ye.toArray,ce=ye.warnOnce,he=me("packages/core/src/source/filterwire.js"),D=he.isGroup,G=he.warnWherePageRelative,le=he.warnWhereOverThreshold,U=me("packages/core/src/source/aggregates.js"),O=U.resolveAggregatePlan,F=U.groupKeysPushable,h=U.STAT_PUSHDOWN,M=me("packages/core/src/source/abort.js").SupersededError,d=1e3;function u(j){const K=j&&j.signal;if(!K||!K.aborted)return;const ee=K.reason;throw ee instanceof Error?ee:new M("","superseded before it was sent")}const s=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function r(j){if(!j||typeof j!="object")return!1;const K=j.returning==="row"||j.returning==="key"?j.returning:"none";return{append:j.append===!0,update:j.update===!0,delete:j.delete===!0,returning:K}}function y(j,K){if(!j||typeof K!="string")return;if(!K.includes("."))return j[K];let ee=j;for(const pe of K.split(".")){if(ee===null||typeof ee!="object")return;ee=ee[pe]}return ee}function p(j){if(j===!0)return!0;if(!j||typeof j!="object")return!1;const K=j;return K.enabled===!1?!1:K.enabled===!0||i(K.commit)}function o(j){const K={...s,...j||{}};return K.operators=new Set(K.operators||[]),K.mutate=r(K.mutate),K}function S(j,K){return!j||!j.op||!K.operators.size?!1:K.operators.has(j.op)}function l(j,K){if(!j)return{pushed:null,residual:null};if(!K.filter)return{pushed:null,residual:j};if(K.filter==="term"){if(D(j)){const ke=j.conditions||[];if(String(j.op)!=="and")return{pushed:null,residual:j};const T=ke.findIndex(b=>!D(b)&&S(b,K));if(T<0)return{pushed:null,residual:j};const g=ke.filter((b,L)=>L!==T);return{pushed:ke[T],residual:g.length?{op:"and",conditions:g}:null}}return S(j,K)?{pushed:j,residual:null}:{pushed:null,residual:j}}if(!D(j))return S(j,K)?{pushed:j,residual:null}:{pushed:null,residual:j};if(String(j.op)!=="and")return(j.conditions||[]).every(T=>D(T)?l(T,K).residual===null:S(T,K))?{pushed:j,residual:null}:{pushed:null,residual:j};const ee=[],pe=[];for(const ke of j.conditions||[]){if(D(ke)){if(K.filter==="flat"){pe.push(ke);continue}const T=l(ke,K);T.pushed&&ee.push(T.pushed),T.residual&&pe.push(T.residual);continue}(S(ke,K)?ee:pe).push(ke)}const ne=ke=>ke.length===0?null:ke.length===1?ke[0]:{op:"and",conditions:ke};return{pushed:ne(ee),residual:ne(pe)}}const _="__lattice_leaves";function re(j){return j.aggregates?j.aggregates instanceof Set?j.aggregates:new Set(be(j.aggregates)):new Set}function te(j){const K=re(j);return K.size?K.has("count")?j.filter!=="tree"||!j.operators||!j.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 ae(j,K,ee,pe,ne,ke,T){const g=Array.isArray(j.groupBy)?j.groupBy:[],b=Array.isArray(j.groupPath)?j.groupPath:[],L=Array.isArray(j.groupValues)?j.groupValues:null;if(!K.group){const f=te(K);if(f)return f}return F(g)?ee.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":pe?ne?ke?"a host `where` predicate can only run in the browser, over rows the engine grouped":T?"fullDataset holds the whole matching set, so the grid groups it itself":!L||L.length!==b.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 oe="pushdown:pivot-unsupported",N="pushdown:group-unsupported",q=Symbol("lattice.remote.ungroupedLevel");function V(j,K,ee,pe,ne,ke){const T=Array.isArray(j.pivotBy)?j.pivotBy:[],g=Array.isArray(j.groupBy)?j.groupBy:[],b=Array.isArray(j.groupPath)?j.groupPath:[],L=Array.isArray(j.groupValues)?j.groupValues:null;return K.pivot?F(T)?g.length&&!F(g)?"a grouping key is not a plain column the engine can name in a GROUP BY":ee.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":pe?ne?ke?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!L||L.length!==b.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 ie(j,K,ee=!1){const pe=l(j.filters||null,K),ne=[];pe.residual&&ne.push("filter");const ke=j.sort||[],T=ke.length===0||K.sort==="multi"&&ke.length>=1||K.sort==="single"&&ke.length===1;!T&&ke.length&&ne.push("sort");const g=j.quick?String(j.quick):"",b=!g||!!K.quick;b||ne.push("quick");const L=j.where&&j.where.active?j.where:null;L&&ne.push("where");const f={filters:pe.residual,sort:T?null:ke,quick:b?"":g,where:L},R=!!ee,t=Array.isArray(j.groupBy)&&j.groupBy.length>0,v=t?ae(j,K,pe,T,b,L,R):"",a=j.pivotMode!==!1&&Array.isArray(j.pivotBy)&&j.pivotBy.length>0,z=a?V(j,K,pe,T,b,L):"",H=a&&z==="";a&&!H&&ne.push("pivot");const Y=a?H&&t:t&&v==="";t&&!a&&!Y&&ne.push("group");const A=(Y||H)&&Array.isArray(j.groupValues)?j.groupValues.length:0,Z=Y||a?!1:R||!!(f.filters||f.sort||f.quick||f.where)||!K.range;return{pushed:{...j,filters:pe.pushed,sort:T?ke:[],quick:b?g:"",range:Z?null:j.range},residual:f,needsAll:Z,unpushed:ne,full:R,grouped:Y,groupLevel:A,groupReason:a?"":v,pivoted:H,pivotReason:z}}function C(j){const K=Array.isArray(j.totals)?j.totals:[],ee=j.totalFns&&typeof j.totalFns=="object"?j.totalFns:{},pe=[],ne=[];for(const ke of K){const T=String(ke),g=typeof ee[T]=="string"?ee[T]:null,b=g?h[g]:null;g?!b||!b.pushable||!b.sql?ne.push({id:T,fn:g,class:b?b.class:"fallback",reason:b&&b.note?b.note:`the pushdown map cannot express "${g}"`}):b.twoColumn?ne.push({id:T,fn:g,class:b.class,reason:`"${g}" reduces two columns, and a grouped request carries no weight column`}):pe.push({id:T,col:T,fn:g,class:b.class}):ne.push({id:T,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:pe,client:ne}}const x=Object.freeze({items:j=>j==null?[]:Array.isArray(j)?j:[j]});function Q(j,K,ee){if(!K)return j;let pe=j;if(K.filters&&i(ee.evaluateFilters)){const ne=pe,ke={count:pe.length,handle:b=>({id:b,get:L=>y(ne[L],b)}),itemwise:b=>ne.some(L=>Array.isArray(y(L,b)))?x:null},T=ee.evaluateFilters(K.filters,ke),g=[];for(let b=0;b<pe.length;b++)T[b]&&g.push(pe[b]);pe=g}if(K.where&&K.where.active&&(K.whole||G(K.where.names,"pushdown"),pe=pe.filter(ne=>K.where.passes(ne))),K.quick){const ne=K.quick.toLowerCase();pe=pe.filter(ke=>{if(!ke||typeof ke!="object")return!1;for(const T of Object.values(ke))if(T!=null&&String(T).toLowerCase().includes(ne))return!0;return!1})}if(K.sort&&K.sort.length&&i(ee.sortMulti)){const ne=[...new Set(K.sort.map(b=>b.col))],ke=pe,T=ne.map(b=>({id:b,get:L=>y(ke[L],b)})),g=ee.sortMulti(T,K.sort.map(b=>({col:b.col,dir:b.dir})),Uint32Array.from({length:pe.length},(b,L)=>L),{});pe=Array.from(g,b=>ke[b])}return pe}function c(j){return JSON.stringify({filters:j.filters||null,sort:j.sort||[],quick:j.quick||"",groupBy:j.groupBy||[],groupPath:j.groupPath||[],context:j.context??null})}function e(j){if(!j||typeof j!="object")return 16;let K="";try{K=JSON.stringify(j)}catch{return 200}return K.length*2+64}function w(j){const K=j||{};return{enabled:!!K.enabled,maxRows:Number.isFinite(K.maxRows)?K.maxRows:1e6,maxBytesEstimate:Number.isFinite(K.maxBytesEstimate)?K.maxBytesEstimate:512*1024*1024}}const k=5e4;function B(j){return Number.isFinite(j)&&j>=0?j:k}function E(j){return!!j&&i(j.then)}async function se(j){if(!j||j.total!==void 0||!E(j.pendingTotal))return j;const K=await j.pendingTotal,{pendingTotal:ee,...pe}=j;return typeof K=="number"?{...pe,total:K}:pe}function X(j={}){const K=j.adapter;if(!K||!i(K.execute))return ce("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...j,mode:"remote",fetch:async()=>({rows:[],total:0})};const ee=o(K.capabilities),pe=K.capabilities&&Object.getOwnPropertyDescriptor(K.capabilities,"operators");pe&&i(pe.get)&&Object.defineProperty(ee,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(K.capabilities.operators||[]),set:()=>{}});const ne=K.name||"adapter";let ke=null;const T=()=>i(K.ready)?(ke||(ke=Promise.resolve(K.ready()).then(()=>{Object.assign(ee,o(K.capabilities))},De=>{throw ke=null,De})),ke):null,g=w(j.fullDataset),b=!!j.allowPartialResults,L=B(j.whereRowLimit);let f=null;const R=j.aggregates;let t=null,v=null,a=null,z=null,H=null,Y,A=null,Z=0,de=null;const xe=()=>!g.enabled||!t?null:(de!==t.key&&(Z++,de=t.key),{rows:t.rows,version:Z}),$=async De=>{const Le=De.where&&De.where.active?De.where:null;if(!Le)return{request:De,probe:null};const{where:qe,...Ke}=De,Fe=ie(Ke,ee,g.enabled);if(Fe.needsAll)return{request:De,probe:null};const et=c(Fe.pushed);let tt=null;return(!f||f.key!==et)&&(ee.total?(u(De),tt=await se(await K.execute(Fe.pushed,De)),f={key:et,size:tt&&typeof tt.total=="number"?tt.total:null}):f={key:et,size:null}),f.size!==null&&f.size<L?{request:De,probe:null}:(le(Le.names,ne,f.size,L),{request:Ke,probe:tt})},P=async(De,Le)=>{A=null;const qe=C(De.pushed);a={engine:qe.engine,client:qe.client,groupBy:De.pushed.groupBy},qe.client.length&&ce(`source.pushdown.group.totals.${ne}.${qe.client.map(et=>et.id).join(".")}`,`the ${ne} adapter cannot compute the group subtotal for ${qe.client.map(et=>`"${et.id}" (${et.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 K.executeGroupLevel(De.pushed,qe.engine,Le)||{};let Fe=Ke.rows||[];return!ee.range&&Le.range&&(Fe=Fe.slice(Le.range.start,Le.range.end)),ve(Ke),Ke.total===void 0?{rows:Fe}:{rows:Fe,total:Ke.total}},W=new Map,fe=64,$e=async(De,Le)=>{A=null;const qe=De.pushed,Ke=qe.groupBy,Fe=Array.isArray(qe.groupValues)?qe.groupValues:[],et=Fe.length,tt=[...qe.filters?[qe.filters]:[],...Ke.slice(0,et).map((Pe,Ge)=>({col:Pe,op:"eq",value:Fe[Ge]===void 0?null:Fe[Ge],caseSensitive:!0}))],at=tt.length===0?null:tt.length===1?tt[0]:{op:"and",conditions:tt},ct=Le.range?Le.range.start:0;if(et>=Ke.length){const Pe={...qe,filters:at,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},Ge=await se(await K.execute(Pe,Le))||{};let Ce=Ge.rows||[];return!ee.range&&Le.range&&(Ce=Ce.slice(Le.range.start,Le.range.end)),typeof Ge.total=="number"?{rows:Ce,total:Ge.total}:{rows:Ce}}const st=Ke[et],kt=C(qe),gt=re(ee),vt=kt.engine.filter(Pe=>gt.has(Pe.fn)),Nt=[...kt.engine.filter(Pe=>!gt.has(Pe.fn)).map(Pe=>({id:Pe.id,fn:Pe.fn,class:Pe.class,reason:`the ${ne} adapter does not compute "${Pe.fn}"`})),...kt.client];a={engine:vt,client:Nt,groupBy:Ke},Nt.length&&ce(`source.pushdown.group.totals.${ne}.${Nt.map(Pe=>Pe.id).join(".")}`,`the ${ne} adapter cannot compute the group subtotal for ${Nt.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 lt=[...vt.map(Pe=>({id:Pe.id,col:Pe.col,fn:Pe.fn})),{id:_,col:st,fn:"count"}],ht={...qe,filters:at,range:null},Tt=JSON.stringify([c(ht),Fe,st,lt]);let Lt=ct>0?W.get(Tt):void 0;if(!Lt){for(Lt=Promise.resolve(K.executeGroupedAggregates(ht,[st],lt)),W.delete(Tt),W.set(Tt,Lt);W.size>fe;)W.delete(W.keys().next().value);Lt.catch(()=>{W.get(Tt)===Lt&&W.delete(Tt)})}const Ut=await Lt||[];u(Le);const Gt=Pe=>{const Ge={};for(const Ce of vt)Ge[Ce.id]=Pe?Pe[Ce.id]:void 0;return Ge},Qt=(qe.sort||[]).find(Pe=>Pe&&Pe.col===st),en=Qt&&Qt.dir==="desc"?-1:1,Wt=Ut.filter(Pe=>Pe&&Pe.level===1).map(Pe=>({[st]:Pe.keys[0]===void 0?null:Pe.keys[0],leafCount:Number(Pe.values&&Pe.values[_])||0,totals:Gt(Pe.values)})).sort((Pe,Ge)=>en*J(Pe[st],Ge[st]));if(et===0){const Pe=Ut.find(Ce=>Ce&&Ce.level===0),Ge=Pe?Number(Pe.values&&Pe.values[_]):NaN;ve({matchCount:Number.isFinite(Ge)?Ge:Wt.reduce((Ce,Je)=>Ce+Je.leafCount,0),...Pe?{grand:Gt(Pe.values)}:{}})}const Ne=Le.range?Le.range.end:Wt.length;return{rows:Wt.slice(ct,Ne),total:Wt.length}},ve=De=>{typeof De.matchCount=="number"&&(z=De.matchCount,H=De.grand?{totals:De.grand,leafCount:De.matchCount}:null,Y===void 0&&i(K.unfilteredCount)&&(Y=null,Promise.resolve(K.unfilteredCount()).then(Le=>{Y=typeof Le=="number"?Le:null}).catch(Le=>{ce(`source.pushdown.group.unfiltered.${ne}`,`the ${ne} adapter could not count the unfiltered set (${Le&&Le.message?Le.message:Le}), so "N of M" falls back to the display count for its denominator.`)})))},Me=async(De,Le)=>{A=null;const qe=C(De.pushed);a={engine:qe.engine,client:qe.client,groupBy:De.pushed.groupBy,pivotBy:De.pushed.pivotBy},qe.client.length&&ce(`source.pushdown.pivot.totals.${ne}.${qe.client.map(at=>at.id).join(".")}`,`the ${ne} adapter cannot compute the pivot cells for ${qe.client.map(at=>`"${at.id}" (${at.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 K.executePivotLevel(De.pushed,qe.engine,Le)||{};let Fe=Ke.rows||[];!ee.range&&Le.range&&(Fe=Fe.slice(Le.range.start,Le.range.end)),ve(Ke);const et=Ke.pivot&&typeof Ke.pivot=="object"?Ke.pivot:{},tt={cells:Array.isArray(et.cells)?et.cells:[],...Array.isArray(et.axis)?{axis:et.axis}:{}};return Ke.total===void 0?{rows:Fe,pivot:tt}:{rows:Fe,total:Ke.total,pivot:tt}},Te=De=>{ce(`source.pushdown.pivot.${ne}.${De}`,`pushdown:pivot-unsupported: the ${ne} adapter cannot pivot this query because ${De}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Le=new Error(`[lattice] ${oe}: the ${ne} adapter cannot pivot this query because ${De}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Le.code=oe,Le.reason=De,Le},Be=(De,Le)=>{const qe={key:Le,state:"pending",value:null};return A=qe,De.then(Ke=>(A===qe&&(A={key:Le,state:"settled",value:typeof Ke=="number"?Ke:null}),Ke),Ke=>{throw A===qe&&(A={key:Le,state:"failed",value:null}),Ke})};let Ue=0,Re=[];const He=()=>Ue===0?null:new Promise(De=>{const Le=setTimeout(De,d);Re.push(()=>{clearTimeout(Le),De()})});let We;const pt=async De=>{const Le=T();Le&&await Le;const Ke=De&&De.pivotMode!==!1&&Array.isArray(De.pivotBy)&&De.pivotBy.length>0?{request:De,probe:null}:await $(De);u(De);let Fe=ie(Ke.request,ee,g.enabled);if(ee.group&&Fe.grouped&&!Fe.pivoted&&!i(K.executeGroupLevel)&&(ce(`source.pushdown.group.method.${ne}`,`the ${ne} 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.`),Fe=ie(Ke.request,{...ee,group:!1,aggregates:null},g.enabled)),Fe.pivoted&&!i(K.executePivotLevel)&&(Fe=ie(Ke.request,{...ee,pivot:!1},g.enabled),Fe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),Fe.grouped&&!Fe.pivoted&&!ee.group&&!i(K.executeGroupedAggregates)&&(ce(`source.pushdown.group.aggregates.method.${ne}`,`the ${ne} 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\`.`),Fe=ie(Ke.request,{...ee,aggregates:null},g.enabled)),v=Fe,Fe.pivoted)return Me(Fe,De);if(Fe.pivotReason&&Te(Fe.pivotReason),Fe.grouped)return ee.group?P(Fe,De):$e(Fe,De);const tt=!!Fe.groupReason&&!Fe.full;tt?ce(`source.pushdown.group-unsupported.${ne}.${Fe.groupReason}`,`pushdown:group-unsupported: the ${ne} adapter was not asked to group this query because ${Fe.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.`):Fe.groupReason&&ce(`source.pushdown.group.${ne}.${Fe.groupReason}`,`the ${ne} adapter was not asked to group this query because ${Fe.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 at=lt=>tt?{...lt,[q]:!0}:lt;if(!Fe.needsAll){const lt=Ke.probe||await K.execute(Fe.pushed,De),ht=lt.rows||[];return E(lt.pendingTotal)&&lt.total===void 0?at({rows:ht,pendingTotal:Be(lt.pendingTotal,c(Fe.pushed))}):(A=null,!ee.total&&lt.total===void 0?at({rows:ht}):at({rows:ht,total:lt.total??ht.length}))}Fe.unpushed.length&&ce(`source.pushdown.residual.${ne}.${Fe.unpushed.join(".")}`,`the ${ne} adapter cannot push ${Fe.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 ct=c(Fe.pushed);if(!t||t.key!==ct){const lt=await se(await K.execute(Fe.pushed,De));A=null;const ht=lt.rows||[];if(Fe.full){const Tt=typeof lt.total=="number"?Math.max(lt.total,ht.length):ht.length;if(Tt>g.maxRows)throw new Error(`[lattice] fullDataset refused: the ${ne} adapter's matching set is ${Tt.toLocaleString()} rows, past the configured maxRows of ${g.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 Lt=ht.length*e(ht[0]);if(Lt>g.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${ne} adapter's matching set is an estimated ${Math.round(Lt/(1024*1024)).toLocaleString()} MB across ${ht.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(g.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 lt.total=="number"&&ht.length<lt.total){const Tt=!!(Fe.residual.filters||Fe.residual.quick||Fe.residual.sort&&Fe.residual.sort.length);if(Tt&&!b)throw new Error(`[lattice] the ${ne} adapter returned ${ht.length} of ${lt.total} matching rows when asked for the whole result, and the query has residual ${Fe.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.`);Tt?ce(`source.pushdown.partial.residual.${ne}`,`the ${ne} adapter returned ${ht.length} of ${lt.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.`):ce(`source.pushdown.partial.${ne}`,`the ${ne} adapter returned ${ht.length} of ${lt.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}t={key:ct,rows:ht,total:typeof lt.total=="number"?lt.total:null}}let st=Fe;if(Fe.residual.where){const lt=t.total??t.rows.length;if(lt>=L){le(Fe.residual.where.names,ne,lt,L);const{where:ht,...Tt}=Ke.request;st=ie(Tt,ee,g.enabled),v=st}}const kt=t.total!==null&&t.rows.length>=t.total,gt=Q(t.rows,{...st.residual,whole:kt},j.compute||{}),vt=De.range?De.range.start:0,Nt=De.range?De.range.end:gt.length;return at({rows:gt.slice(vt,Nt),total:gt.length})},At=async(De,Le,qe)=>{const Fe=qe&&qe.waitForPage&&We&&i(We.pageForegroundIdle)?We.pageForegroundIdle():He();Fe&&await Fe;const et=T();et&&await et;const tt=ie(De,ee,g.enabled);v=tt;const at=O(Le,R),ct=Array.isArray(De.groupBy)?De.groupBy:[],st=ct.length>0,kt=!tt.residual.filters&&!tt.residual.quick,gt=!st||F(ct,ee.buckets);let vt=at.engine,Nt=at.client;if(ee.aggregates&&vt.length){const Lt=ee.aggregates instanceof Set?ee.aggregates:new Set(be(ee.aggregates)),Ut=vt.filter(Gt=>!Lt.has(Gt.fn));Ut.length&&(vt=vt.filter(Gt=>Lt.has(Gt.fn)),Nt=[...Ut.map(Gt=>({...Gt,reason:`the ${ne} adapter does not compute "${Gt.fn}"`})),...Nt])}const lt=Lt=>{Nt=[...vt.map(Ut=>({...Ut,reason:Lt})),...Nt],vt=[]};vt.length&&!kt?lt(tt.residual.quick&&!tt.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):vt.length&&!gt&&lt("a grouping key the engine cannot form forces all-client (no mixed provenance)");let ht={},Tt;return vt.length&&(i(st?K.executeGroupedAggregates:K.executeAggregates)?st?Tt=await K.executeGroupedAggregates(tt.pushed,ct,vt)||[]:ht=await K.executeAggregates(tt.pushed,vt)||{}:(ce(`source.pushdown.aggregates.${ne}${st?".grouped":""}`,`the ${ne} adapter cannot compute ${st?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),lt(`adapter cannot compute ${st?"grouped ":""}aggregates`))),a={engine:vt,client:Nt,...st?{groupBy:ct}:{}},{values:ht,engine:vt,client:Nt,...Tt!==void 0?{groups:Tt}:{}}},Mt=async De=>{Ue++;try{return await pt(De)}finally{if(Ue--,Ue===0&&Re.length){const Le=Re;Re=[];for(const qe of Le)qe()}}},ut=p(j.edit),ft=j.edit&&typeof j.edit=="object"&&i(j.edit.commit);let zt=j.edit;if(ut&&!ft)if(ee.mutate&&ee.mutate.update){const De=Le=>{if(!ee.mutate||!ee.mutate.update)throw new Error(`[lattice] the ${ne} 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 qe={kind:"update",key:String(Le.key),patch:{[Le.colId]:Le.value}};return K.mutate(qe,Le.request||{})};zt={...j.edit===!0?{}:j.edit,commit:De}}else ce(`source.pushdown.readonly.${ne}`,`edit is enabled but the ${ne} adapter declares mutate: ${ee.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 Ft=ut&&ee.mutate&&(ee.mutate.append||ee.mutate.delete)?{append:ee.mutate.append===!0,remove:ee.mutate.delete===!0,returning:ee.mutate.returning,mutate:(De,Le)=>K.mutate(De,Le||{})}:null,wt=async De=>{const Le=T();Le&&await Le;const{range:qe,signal:Ke,export:Fe,...et}=De||{},tt={...et,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:ie(tt,ee,g.enabled),signal:Ke}};async function*dt(De,Le={}){const{plan:qe,signal:Ke}=await wt(De),Fe=Math.max(1,Math.floor(Number(Le.pageSize))||5e3),et={signal:Ke,stream:!0};if(!qe.needsAll)for(let ct=0;;ct+=Fe){u(et);const st=await K.execute({...qe.pushed,range:{start:ct,end:ct+Fe}},et);st&&E(st.pendingTotal)&&st.pendingTotal.then(null,()=>{});const kt=st&&st.rows||[];if(kt.length&&(yield kt),kt.length<Fe)return}u(et);const tt=await se(await K.execute({...qe.pushed,range:void 0},et)),at=Q(tt&&tt.rows||[],{...qe.residual,whole:!0},j.compute||{});for(let ct=0;ct<at.length;ct+=Fe)yield at.slice(ct,ct+Fe)}return We={...j,edit:zt,rowMutate:Ft,mode:"remote",fetch:Mt,foregroundIdle:He,aggregate:At,countMatching:async De=>{const{plan:Le,signal:qe}=await wt(De);if(!Le.needsAll&&ee.total){u({signal:qe});const Fe=await se(await K.execute({...Le.pushed,range:{start:0,end:0}},{signal:qe}));if(Fe&&typeof Fe.total=="number")return Fe.total}let Ke=0;for await(const Fe of dt(De))Ke+=Fe.length;return Ke},streamMatching:dt,lastPlan:()=>v?{...v,...a?{aggregates:a}:{},...A?{total:{deferred:!0,state:A.state,value:A.value}}:{}}:null,fullFrame:xe,counts:()=>({match:z,total:Y??null,pending:!!A&&A.state==="pending"}),grandTotals:()=>H},We}}),Xe("packages/modules/shared/engine.js",function(n,me){"use strict";Object.defineProperty(n,"sourceId",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"engineSource",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"gridPivoted",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"loadedAndMatching",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"gridHoldsWindow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"gridEngineRequest",{enumerable:!0,get:function(){return I}}),Object.defineProperty(n,"EngineFlight",{enumerable:!0,get:function(){return M}});const ye=me("packages/core/src/source/pushdown.js"),J=ye.capabilitiesOf,i=ye.planQuery,ce=me("packages/core/src/source/filterwire.js").wireFilters,he=new WeakMap;let D=0;function G(d){let u=he.get(d);return u===void 0&&(u=++D,he.set(d,u)),u}function le(d){const u=d&&typeof d.config=="function"?d.config():null,s=u&&u.source&&typeof u.source=="object"?u.source:null;if(!s||typeof s.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const r=J(s.adapter&&s.adapter.capabilities);return{source:s,caps:r,config:u}}function U(d){const u=d&&typeof d.config=="function"?d.config():null,s=u&&u.source&&typeof u.source=="object"?u.source:null;if(!s||typeof s.lastPlan!="function")return!1;const r=d&&d.state&&typeof d.state.get=="function"?d.state.get():null,y=r&&r.pivot;return!!(y&&y.enabled&&Array.isArray(y.columns)&&y.columns.length>0)}function O(d){const u=d.rows&&typeof d.rows.residentCount=="function"?d.rows.residentCount():0,s=typeof d.rows.matchCount=="function"?d.rows.matchCount():NaN;return{loaded:u,total:Number.isFinite(s)?s:NaN}}function F(d){const u=d&&typeof d.config=="function"?d.config():null,s=u&&u.source&&typeof u.source=="object"?u.source:null;if(!s||s.mode!=="remote"&&s.mode!=="paged")return!1;if(typeof d.rows.matchCount=="function"&&d.rows.matchCount()===null)return!0;const{loaded:r,total:y}=O(d);return Number.isFinite(y)&&r<y}function h(d,u){return u?d?{op:"and",conditions:[d,u]}:u:d||null}function I(d,u,s=null){const r=d.filters&&typeof d.filters.where=="function"?d.filters.where():[];if(Array.isArray(r)&&r.length)return{reason:`a \`where\` predicate is in force (${r.join(", ")}), which only the browser can run`};const y=d.filters&&typeof d.filters.quickState=="function"?d.filters.quickState():{text:""},p=y&&y.text?String(y.text):"",{config:o,caps:S}=u,l={filters:ce(h(d.filters.get(),s),{tz:o.timeZone,weekStartsOn:o.weekStartsOn}),sort:[],range:null,context:o.context??null,...p?{quick:p}:{}},_=i(l,S);return _.unpushed.includes("filter")?{reason:s?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:_.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:l,quick:p}}class M{#e=null;#t=null;#n=!1;answer(u){return this.#t&&this.#t.key===u?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(u,s,r){const y=this.#e;if(y){y.key!==u&&y.controller&&y.controller.abort();return}const p=globalThis.AbortController,o=typeof p=="function"?new p:null,S={key:u,controller:o};this.#e=S;let l;Promise.resolve().then(()=>s(o?o.signal:null)).then(_=>{l={key:u,result:_}},_=>{l={key:u,error:_}}).then(()=>{this.#e===S&&(this.#e=null),!this.#n&&(o&&o.signal.aborted||(this.#t=l),r())})}abort(){const u=this.#e;u&&u.controller&&u.controller.abort()}close(){this.#n=!0,this.abort()}}}),Xe("packages/modules/charts/scale.js",function(n,me){"use strict";Object.defineProperty(n,"isNumber",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"toNumber",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"toTime",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"extent",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"niceStep",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"niceDomain",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"measureDomain",{enumerable:!0,get:function(){return I}}),Object.defineProperty(n,"linearTicks",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"timeStepFor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"MONTH_STEPS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"timeTicks",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"linearScale",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"timeScale",{enumerable:!0,get:function(){return re}}),Object.defineProperty(n,"key",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"bandScale",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"sqrtScale",{enumerable:!0,get:function(){return oe}});const ye=[1,2,2.5,5,10],J=6e4,i=36e5,be=864e5,ce=365.25*be,he=[1,2,5,10,20,25,50,100],D=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,J,5*J,15*J,30*J,i,3*i,6*i,12*i,be,2*be,7*be,14*be,30*be,90*be,180*be,...he.map(N=>N*ce)];function G(N){return typeof N=="number"&&Number.isFinite(N)}function le(N){if(N==null||N==="")return null;if(N instanceof Date){const V=N.getTime();return Number.isFinite(V)?V:null}if(typeof N=="boolean")return N?1:0;const q=Number(N);return Number.isFinite(q)?q:null}function U(N){if(N==null||N==="")return null;if(N instanceof Date){const V=N.getTime();return Number.isFinite(V)?V:null}if(typeof N=="number")return Number.isFinite(N)?N:null;const q=Date.parse(String(N));return Number.isFinite(q)?q:null}function O(N){let q=1/0,V=-1/0;for(let ie=0;ie<N.length;ie++){const C=N[ie];G(C)&&(C<q&&(q=C),C>V&&(V=C))}return q===1/0?null:{min:q,max:V}}function F(N){if(!(N>0))return 1;const q=10**Math.floor(Math.log10(N));for(const V of ye)if(N<=V*q)return V*q;return 10*q}function h(N,q=5){const V=F((N.max-N.min)/Math.max(1,q));return{min:Math.floor(N.min/V)*V,max:Math.ceil(N.max/V)*V,step:V}}function I(N,q={}){const V=O(N)||{min:0,max:1};let{min:ie,max:C}=V;if(q.zero&&(ie>0&&(ie=0),C<0&&(C=0)),ie===C){const x=Math.abs(ie)>0?Math.abs(ie)/10:1;ie-=x,C+=x}if(q.nice!==!1){const x=h({min:ie,max:C},q.ticks||5);ie=x.min,C=x.max}return G(q.min)&&(ie=q.min),G(q.max)&&(C=q.max),ie===C&&(C=ie+1),{min:ie,max:C}}function M(N,q=5){const V=F((N.max-N.min)/Math.max(1,q)),ie=Math.ceil(N.min/V),C=Math.floor(N.max/V),x=[];for(let Q=ie;Q<=C;Q++){const c=Q*V;x.push(Math.abs(c)<V/1e6?0:Number(c.toPrecision(12)))}return x}function d(N,q=5){const V=Math.max(1,q),ie=N/V;let C=D[D.length-1];for(const c of D)if(c>=ie){C=c;break}if(C<ce)return C;let x=C,Q=Math.abs(N/C-V);for(const c of D){if(c<ce)continue;const e=Math.abs(N/c-V);e<Q&&(Q=e,x=c)}return x}const u=new Map;function s(N){let q=u.get(N);return q||(q=new Intl.DateTimeFormat("en-US",{timeZone:N,year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),u.set(N,q)),q}function r(N,q){const V={year:0,month:0,day:1,hour:0,minute:0,second:0};for(const ie of s(q).formatToParts(new Date(N)))switch(ie.type){case"year":V.year=Number(ie.value);break;case"month":V.month=Number(ie.value)-1;break;case"day":V.day=Number(ie.value);break;case"hour":V.hour=Number(ie.value)%24;break;case"minute":V.minute=Number(ie.value);break;case"second":V.second=Number(ie.value);break;default:break}return V}function y(N,q,V){const ie=Date.UTC(N,q,1);let C=ie;for(let x=0;x<2;x++){const Q=r(C,V),c=Date.UTC(Q.year,Q.month,Q.day,Q.hour,Q.minute,Q.second),e=ie-c;if(e===0)break;C+=e}return C}function p(N,q,V){const ie=V?r(N.min,V).year:new Date(N.min).getUTCFullYear();let C=Math.ceil(ie/q)*q;const x=c=>V?y(c,0,V):Date.UTC(c,0,1);x(C)<N.min&&(C+=q);const Q=[];for(;x(C)<=N.max;C+=q)Q.push(x(C));return Q}const o=new Map([[30*be,1],[90*be,3],[180*be,6]]);function S(N,q,V){const ie=V?r(N.min,V):{year:new Date(N.min).getUTCFullYear(),month:new Date(N.min).getUTCMonth()};let C=ie.year*12+ie.month;const x=c=>{const e=Math.floor(c/12),w=c-e*12;return V?y(e,w,V):Date.UTC(e,w,1)};x(C)<N.min&&(C+=1),C=Math.ceil(C/q)*q;const Q=[];for(;;C+=q){const c=x(C);if(c>N.max)break;Q.push(c)}return Q}function l(N,q=5,V){const ie=d(N.max-N.min,q);if(ie>=ce)return p(N,Math.round(ie/ce),V);const C=o.get(ie);if(C)return S(N,C,V);const x=[],Q=Math.ceil(N.min/ie)*ie;for(let c=Q;c<=N.max;c+=ie)x.push(c);return x}function _(N,q){const V=N.max-N.min||1,[ie,C]=q;return{kind:"linear",domain:N,range:q,of(x){return ie+(x-N.min)/V*(C-ie)},invert(x){return N.min+(x-ie)/(C-ie||1)*V},ticks(x=5){return M(N,x)}}}function re(N,q){return{..._(N,q),kind:"time",ticks(ie=5,C){return l(N,ie,C)}}}function te(N){if(N==null)return" null";if(N instanceof Date)return` date:${N.getTime()}`;if(typeof N=="object"){const q=N,V=q.id??q.key??q.value;return V!==void 0&&typeof V!="object"?` obj:${String(V)}`:` obj:${String(N)}`}return String(N)}function ae(N,q,V=.2){const ie=Math.min(.9,Math.max(0,V)),[C,x]=q,Q=new Map;for(let w=0;w<N.length;w++){const k=te(N[w]);Q.has(k)||Q.set(k,w)}const c=N.length?(x-C)/N.length:x-C,e=Math.max(0,c*(1-ie));return{kind:"band",domain:N,range:q,bandwidth:e,step:c,of(w){const k=Q.get(te(w));return k===void 0?NaN:C+k*c+(c-e)/2},centre(w){const k=this.of(w);return Number.isNaN(k)?NaN:k+e/2},ticks(){return N}}}function oe(N,q){const[V,ie]=q,C=Math.max(Math.abs(N.max),Math.abs(N.min),0)||1;return{kind:"sqrt",domain:N,range:q,of(x){const Q=Math.sqrt(Math.abs(x)/C);return V+Q*(ie-V)}}}}),Xe("packages/modules/charts/svg.js",function(n,me){"use strict";Object.defineProperty(n,"SVG_NS",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"el",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"svg",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"attr",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"attrs",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"setText",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"clear",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"append",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"path",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"ribbonPath",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"round",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"pathRings",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"insideRings",{enumerable:!0,get:function(){return I}});const ye="http://www.w3.org/2000/svg";function J(M){const d=M.indexOf(")");return d<0?M:M.slice(d+1).trim()||"#0072b2"}function i(M,d,u){const s=M.createElement(d);return u&&s.setAttribute("class",u),s}function be(M,d,u){const s=M.createElementNS(ye,d);if(u)for(const r of Object.keys(u))s.setAttribute(r,String(u[r]));return s}function ce(M,d,u){if(!M)return;if(u==null){M.removeAttribute(d);return}let s=String(u);s.startsWith("url(#")&&(d==="stroke"||d==="fill"&&M.localName==="text")&&(s=J(s)),M.setAttribute(d,s)}function he(M,d){if(M)for(const u of Object.keys(d))ce(M,u,d[u])}function D(M,d){M&&(M.textContent=d==null?"":String(d))}function G(M){if(M)for(;M.firstChild;)M.removeChild(M.firstChild)}function le(M,d){for(const u of d)u&&M.appendChild(u);return M}function U(M){return M.join(" ")}function O(M){if(!M||M.length<2)return"";const d=["M",M[0].x,M[0].upper];for(let u=1;u<M.length;u++)d.push("L",M[u].x,M[u].upper);for(let u=M.length-1;u>=0;u--)d.push("L",M[u].x,M[u].lower);return d.push("Z"),U(d)}function F(M){return Math.round(M*100)/100}function h(M){const d=[];let u=[];const s=String(M||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let r="",y=[];const p=()=>{if(!r||!y.length){y=[];return}if(r==="M"||r==="L")for(let o=0;o+1<y.length;o+=2)u.push([y[o],y[o+1]]);else r!=="Z"&&y.length>=2&&u.push([y[y.length-2],y[y.length-1]]);y=[]};for(const o of s){if(/[A-Za-z]/.test(o)){if(p(),o==="Z"||o==="z"){u.length>2&&d.push(u),u=[],r="";continue}o==="M"&&u.length>2&&(d.push(u),u=[]),r=o;continue}y.push(Number(o))}return p(),u.length>2&&d.push(u),d}function I(M,d,u){let s=!1;for(const r of M)for(let y=0,p=r.length-1;y<r.length;p=y++){const[o,S]=r[y],[l,_]=r[p];S>u!=_>u&&d<(l-o)*(u-S)/(_-S||1e-12)+o&&(s=!s)}return s}}),Xe("packages/modules/charts/typography.js",function(n,me){"use strict";Object.defineProperty(n,"BASE_SIZE",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(n,"BASE_FAMILY",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"CHAR_RATIO",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"resolveType",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"textWidth",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"widestLabel",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"truncateTo",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"applySize",{enumerable:!0,get:function(){return le}});const ye=12,J="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",i=.62;function be(U){const O=U&&U.font,F=typeof O=="number"?{size:O}:O||{},h=ce(F.size,ye);return{family:F.family||J,size:h,small:ce(F.small??F.tickSize,Math.max(9,h-1)),title:ce(F.title,Math.round(h*1.15)),axisTitle:ce(F.axisTitle,Math.max(10,h-1)),weight:F.weight||"inherit"}}function ce(U,O){const F=Number(U);return Number.isFinite(F)&&F>0?F:O}function he(U,O){return String(U??"").length*O*i}function D(U,O){let F=0;for(const h of U||[]){const I=he(h,O);I>F&&(F=I)}return F}function G(U,O,F){const h=String(U??""),I=Math.floor(O/(F*i));return I<=0?"":h.length<=I?h:I===1?"…":`${h.slice(0,I-1)}…`}function le(U,O){!U||!Number.isFinite(O)||(U.style?U.style.fontSize=`${O}px`:U.setAttribute("style",`font-size:${O}px`))}}),Xe("packages/modules/charts/frame.js",function(n,me){"use strict";Object.defineProperty(n,"LABEL_GAP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"resolveMargin",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"plotRect",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"shouldRotate",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"Pool",{enumerable:!0,get:function(){return F}});const J=me("packages/modules/charts/svg.js").SVG_NS,i=me("packages/modules/charts/typography.js"),be=i.textWidth,ce=i.widestLabel,he=8,D=6,G=.4;function le(h,I){const M=typeof h=="number"?h:I,d=h&&typeof h=="object"?h:{},u=s=>Number.isFinite(s)&&s>=0?Number(s):M;return{base:M,top:u(d.top),right:u(d.right),bottom:u(d.bottom),left:u(d.left)}}function U(h){const I=le(h.margin,typeof h.padding=="number"?h.padding:8),M=I.base,d=h.fontSize||12,u=h.yLabels||[],s=h.xLabels||[],r=h.ySide==="right"?"right":"left",y=r==="right"?"left":"right",p=h.titles||{},o=h.titleSize||d,S=C=>C?o+D:0,l=ce(u,d),_=u.length?Math.min(h.width*G,I[r]+l+D):Math.max(he,I[r]),re=I[y]+(h.rightGutter||0),te=(r==="left"?_:re)+S(p.left),ae=ce(s.map(C=>String(C).slice(0,14)),d),oe=(s.length?h.rotated?Math.min(h.height*G,D+ae):d+D+I.bottom:Math.max(he,I.bottom))+S(p.bottom),N=(r==="right"?_:re)+S(p.right),q=I.top+(h.topGutter||0),V=Math.max(0,h.width-te-N),ie=Math.max(0,h.height-q-oe);return{left:te,top:q,width:V,height:ie,right:te+V,bottom:q+ie,gutter:{left:te,bottom:oe,right:N,top:q}}}function O(h,I,M,d){if(!h.length||I<=0)return!1;const u=Number.isFinite(d)&&d>0?Number(d):1;return ce(h,M)>I*u-4}class F{#e;#t=0;static#n="data-pool-key";constructor(I,M=0){this.#e=I,this.#t=M>0?M:0}next(I,M,d){if(d!=null)return this.#r(I,M,String(d));const u=this.#e.childNodes[this.#t],s=u&&u.tagName,r=/(^|\s)\S*__axis-title(\s|$)/,y=s&&r.test(String(u.getAttribute("class")||"")),p=!!M&&r.test(String(M));if(s&&(!y||p)&&String(s).toLowerCase()===I.toLowerCase())return M&&u.setAttribute("class",M),this.#t++,u;const o=this.#e.ownerDocument.createElementNS(J,I);return M&&o.setAttribute("class",M),u?this.#e.insertBefore(o,u):this.#e.appendChild(o),this.#t++,o}#r(I,M,d){const u=I.toLowerCase();for(let y=this.#t;y<this.#e.childNodes.length;y++){const p=this.#e.childNodes[y],o=p&&p.tagName;if(o&&String(o).toLowerCase()===u&&p.getAttribute(F.#n)===d)return y!==this.#t&&this.#e.insertBefore(p,this.#e.childNodes[this.#t]),M&&p.setAttribute("class",M),this.#t++,p}const s=this.#e.ownerDocument.createElementNS(J,I);s.setAttribute(F.#n,d),M&&s.setAttribute("class",M);const r=this.#e.childNodes[this.#t];return r?this.#e.insertBefore(s,r):this.#e.appendChild(s),this.#t++,s}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Xe("packages/modules/charts/fills.js",function(n,me){"use strict";Object.defineProperty(n,"PATTERNS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"GRADIENTS",{enumerable:!0,get:function(){return be}}),Object.defineProperty(n,"isFill",{enumerable:!0,get:function(){return le}}),Object.defineProperty(n,"isPaintRef",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"paintFallback",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"normaliseFill",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"swatchCss",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"createFillRegistry",{enumerable:!0,get:function(){return d}}),Object.defineProperty(n,"rowPaint",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"patternSeries",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"paintSolid",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"rowFillSource",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"nodePaint",{enumerable:!0,get:function(){return p}});const J=me("packages/core/src/internal/util.js").warnOnce,i=Object.freeze(["hatch","crosshatch","dots","grid"]),be=Object.freeze(["linear","radial"]),ce=8,he="#0072b2";let D=0;const G=new Map;function le(o){return!!o&&typeof o=="object"&&!Array.isArray(o)&&(typeof o.gradient=="string"||typeof o.pattern=="string")}function U(o){return typeof o=="string"&&o.startsWith("url(#")}function O(o){if(typeof o!="string")return o==null?"":String(o);if(!o.startsWith("url("))return o;const S=o.indexOf(")");return(S<0?"":o.slice(S+1).trim())||he}function F(o,S){J(`chart:fill:invalid:${o}`,`a chart fill object was ignored: ${S} The mark was drawn in a solid colour instead. A fill is a gradient object (gradient: "linear" or "radial", with stops of [offset, colour]) or a pattern object (pattern: "hatch", "crosshatch", "dots" or "grid", with a colour).`)}function h(o,S){if(!le(o))return null;const l=S||he;if(typeof o.gradient=="string"){if(!be.includes(o.gradient))return F("gradient",`the gradient "${o.gradient}" is not one of ${be.join(", ")}.`),null;const ae=Array.isArray(o.stops)?o.stops:[],oe=[];for(const q of ae){const V=Array.isArray(q)?Number(q[0]):Number(q&&q.offset),ie=Array.isArray(q)?q[1]:q&&q.colour;!Number.isFinite(V)||typeof ie!="string"||!ie||oe.push({offset:Math.min(1,Math.max(0,V)),colour:ie})}if(oe.length<2)return F("stops","a gradient needs at least two [offset, colour] stops."),null;oe.sort((q,V)=>q.offset-V.offset);const N=Number.isFinite(Number(o.angle))?Number(o.angle):180;return{kind:o.gradient,angle:N,stops:oe,solid:oe[0].colour}}if(!i.includes(o.pattern))return F("pattern",`the pattern "${o.pattern}" is not one of ${i.join(", ")}.`),null;const _=Number(o.size),re=Number(o.angle),te=typeof o.colour=="string"&&o.colour?o.colour:l;return{kind:"pattern",pattern:o.pattern,colour:te,background:typeof o.background=="string"&&o.background?o.background:null,size:Number.isFinite(_)&&_>=2?_:ce,angle:Number.isFinite(re)?re:o.pattern==="grid"||o.pattern==="dots"?0:45,solid:te}}function I(o){if(o.kind==="pattern"){const l=o.colour,_=o.size,re=Math.max(1,_/5),te=o.background||"transparent",ae=oe=>`repeating-linear-gradient(${oe+90}deg,${l} 0 ${re}px,transparent ${re}px ${_}px)`;return o.pattern==="hatch"?`${ae(o.angle)},${te}`:o.pattern==="crosshatch"?`${ae(o.angle)},${ae(o.angle+90)},${te}`:o.pattern==="grid"?`${ae(o.angle)},${ae(o.angle+90)},${te}`:`radial-gradient(circle at 50% 50%,${l} ${_/6}px,transparent ${_/6+.5}px) 0 0/${_}px ${_}px,${te}`}const S=o.stops.map(l=>`${l.colour} ${Math.round(l.offset*100)}%`).join(",");return o.kind==="radial"?`radial-gradient(circle,${S})`:`linear-gradient(${o.angle}deg,${S})`}function M(o){if(!U(o))return typeof o=="string"?o:"";const S=String(o).indexOf(")"),l=String(o).slice(5,S),_=G.get(l);return _?I(_):O(o)}function d(o){const S=`lattice-fill-${++D}`;let l=new Map,_=0;const re=(ae,oe)=>{const N=o.ownerDocument.createElementNS("http://www.w3.org/2000/svg",ae);for(const q of Object.keys(oe))N.setAttribute(q,String(oe[q]));return N},te=(ae,oe)=>{if(oe.kind==="pattern"){const q=oe.size,V=Math.max(1,q/5),ie=re("pattern",{id:ae,width:q,height:q,patternUnits:"userSpaceOnUse"});oe.angle&&ie.setAttribute("patternTransform",`rotate(${oe.angle})`),oe.background&&ie.appendChild(re("rect",{width:q,height:q,fill:oe.background}));const C={stroke:oe.colour,"stroke-width":V};oe.pattern==="dots"?ie.appendChild(re("circle",{cx:q/2,cy:q/2,r:Math.max(1,q/6),fill:oe.colour})):(ie.appendChild(re("line",{x1:q/2,y1:0,x2:q/2,y2:q,...C})),oe.pattern!=="hatch"&&ie.appendChild(re("line",{x1:0,y1:q/2,x2:q,y2:q/2,...C}))),o.appendChild(ie);return}let N;if(oe.kind==="radial")N=re("radialGradient",{id:ae,cx:.5,cy:.5,r:.5});else{const q=oe.angle*Math.PI/180,V=Math.sin(q)/2,ie=-Math.cos(q)/2;N=re("linearGradient",{id:ae,x1:+(.5-V).toFixed(4),y1:+(.5-ie).toFixed(4),x2:+(.5+V).toFixed(4),y2:+(.5+ie).toFixed(4)})}for(const q of oe.stops)N.appendChild(re("stop",{offset:q.offset,"stop-color":q.colour}));o.appendChild(N)};return{prefix:S,paint(ae,oe){const N=h(ae,oe);if(!N)return oe||he;if(!o||!o.ownerDocument)return N.solid;const q=JSON.stringify(N);let V=l.get(q);if(!V){const ie=`${S}-${_++}`;te(ie,N),G.set(ie,N),V=`url(#${ie}) ${N.solid}`,l.set(q,V)}return V},reset(){for(const ae of l.values())G.delete(ae.slice(5,ae.indexOf(")")));if(l=new Map,_=0,o)for(;o.firstChild;)o.removeChild(o.firstChild)},ids(){return[...l.values()].map(ae=>ae.slice(5,ae.indexOf(")")))}}}function u(o,S,l){if(o==null||o==="")return null;const _=O(l);if(le(o))return S?S.paint(o,_):(h(o,_)||{}).solid||null;if(typeof o=="string"){if(i.includes(o)){const re={pattern:o,colour:_};return S?S.paint(re,_):_}return o}return null}function s(o){const S=[{pattern:"hatch",angle:45},{pattern:"dots"},{pattern:"crosshatch",angle:45},{pattern:"hatch",angle:135},{pattern:"grid"},{pattern:"dots",size:5},{pattern:"hatch",angle:0},{pattern:"crosshatch",angle:0,size:6}];return o.map((l,_)=>({...S[_%S.length],colour:l,background:"var(--lattice-background, #fff)"}))}function r(o){return U(o)?String(o).replace(/^url\([^)]*\)\s*/,""):o}function y(o,S){const l=o.fill;if(le(l))return(re,te)=>u(l,S.fills,r(te));if(typeof l=="function")return(re,te)=>{let ae=null;try{ae=l({label:re.label,x:re.x,y:re.y,rowKey:re.rowKey})}catch{ae=null}return u(ae,S.fills,r(te))};const _=typeof l=="string"?l:l&&typeof l=="object"&&typeof l.col=="string"?l.col:null;return _?(re,te)=>re.rowKey===void 0||re.rowKey===null?null:u(o.grid.rows.value(re.rowKey,_),S.fills,r(te)):null}function p(o,S,l){return o&&o({label:S.label,x:S.value,y:S.total,rowKey:S.rowKey},l)||l}}),Xe("packages/modules/charts/scheme.js",function(n,me){"use strict";Object.defineProperty(n,"PALETTE",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"SCHEMES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"registerScheme",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"setDefaultScheme",{enumerable:!0,get:function(){return F}}),Object.defineProperty(n,"schemeNames",{enumerable:!0,get:function(){return h}}),Object.defineProperty(n,"resolveScheme",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"RAMP_SCALES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"toRgb",{enumerable:!0,get:function(){return o}}),Object.defineProperty(n,"rampStops",{enumerable:!0,get:function(){return S}});const J=me("packages/core/src/internal/util.js").warnOnce,i=me("packages/modules/charts/fills.js"),be=i.isFill,ce=i.patternSeries,he=i.rowPaint,D=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),G=Object.freeze({default:{series:D,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"},patterns:{series:ce(D),sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"}}),le=new Map;let U="default";function O(l,_){!l||!_||le.set(String(l),_)}function F(l){if(typeof l=="string"){U=l;return}l&&typeof l=="object"&&(le.set("__default__",l),U="__default__")}function h(){return[...Object.keys(G),...le.keys()].filter(l=>!l.startsWith("__"))}function I(l){return le.has(l)?le.get(l):G[l]||null}const M=["series","sequential","diverging","positive","negative"];function d(l){return!l||typeof l!="object"||Array.isArray(l)?!1:!M.some(_=>_ in l)}function u(l,_){const re=_&&_.fills||null,te=I(U)||G.default,ae=l&&l.scheme,oe=d(ae)?ae:null,N=Array.isArray(ae)&&ae.length?ae:null,q=typeof ae=="string"?I(ae):oe||Array.isArray(ae)?null:ae||null,V=(l&&Array.isArray(l.palette)&&l.palette.length?l.palette:null)||N;oe&&V&&J("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const ie=oe?null:V,C={...G.default,...te,...q||{}};ie&&(C.series=ie);const x=l&&l.ramp&&typeof l.ramp=="object"&&!Array.isArray(l.ramp)?l.ramp:null,Q=x?x.colours:l&&l.ramp,c=Array.isArray(Q)&&Q.length>=2?Q:null;c&&(C.sequential=c);const e=x?y(x.scale):null,w=!!(q||ie||oe),k=C.series&&C.series.length?C.series:D,B=new Map;let E=0;return{...C,series:(X,j)=>{if(oe&&j!==void 0&&j!==null){const K=String(j);return Object.prototype.hasOwnProperty.call(oe,K)?s(oe[K],re,X):(B.has(K)||B.set(K,E++),s(p(k,B.get(K),!0),re,B.get(K)))}return s(p(k,X,w),re,X)},explicit:w,nameMap:!!oe,rampScale:e,fills:re}}function s(l,_,re){if(!be(l))return l;const te=D[(re%D.length+D.length)%D.length];return he(l,_,te)||te}const r=Object.freeze(["linear","log","quantile"]);function y(l){return l==null?null:r.includes(l)?l:(J(`chart:ramp:scale:${String(l)}`,`chart "ramp.scale" was "${String(l)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function p(l,_,re){const te=(_%l.length+l.length)%l.length;return re||typeof l[te]!="string"?l[te]:`var(--lattice-chart-${te+1}, ${l[te]})`}function o(l){if(typeof l!="string")return null;const _=l.trim(),re=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(_);if(re){const oe=re[1];return oe.length===3?[0,1,2].map(N=>parseInt(oe[N]+oe[N],16)):[0,2,4].map(N=>parseInt(oe.slice(N,N+2),16))}const te=/^rgba?\(([^)]+)\)$/i.exec(_);if(!te)return null;const ae=te[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return ae.length===3&&ae.every(oe=>Number.isFinite(oe))?ae:null}function S(l,_){const re=_?l.diverging:l.sequential,te=_?G.default.diverging:G.default.sequential,ae=(Array.isArray(re)?re:te).map((oe,N)=>o(oe)||o(te[N])||[0,0,0]);return ae.length>=2?ae:te.map(oe=>o(oe))}}),Xe("packages/modules/charts/styles.js",function(n,me){"use strict";Object.defineProperty(n,"NS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"seriesColour",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(n,"css",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"injectStyles",{enumerable:!0,get:function(){return D}});const J=me("packages/modules/charts/scheme.js").PALETTE,i="lat-chartview",be="data-lattice-chartview";function ce(G){const le=(G%J.length+J.length)%J.length;return`var(--lattice-chart-${le+1}, ${J[le]})`}function he(){return`
7
7
  .${i}{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;
8
8
  width:100%;height:100%;box-sizing:border-box;
9
9
  font-family:var(--lattice-font-family,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.89.0, mock-socket module type declarations
2
+ * Lattice Grid 1.89.1, mock-socket module type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.89.0, mock-socket module
2
+ * Lattice Grid 1.89.1, mock-socket module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.89.0, mock-socket module
2
+ * Lattice Grid 1.89.1, mock-socket module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.89.0, mock-socket module
2
+ * Lattice Grid 1.89.1, mock-socket module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -67,6 +67,15 @@
67
67
  */
68
68
  .lattice {
69
69
  --lattice-radius: 6px; /* antd seed borderRadius */
70
+ /* Designer editing chrome type scale and spacing (BACKLOG-0002086): fixed,
71
+ not scaled, so the editing chrome stays legible at any density. */
72
+ --lattice-designer-font-title: 16px/24px;
73
+ --lattice-designer-font-heading: 14px/20px;
74
+ --lattice-designer-font-body: 13px/18px;
75
+ --lattice-designer-space-1: 4px;
76
+ --lattice-designer-space-2: 8px;
77
+ --lattice-designer-space-3: 12px;
78
+ --lattice-designer-space-4: 16px;
70
79
  --lattice-radius-sm: 4px; /* antd borderRadiusSM */
71
80
  --lattice-radius-pill: 100px;
72
81