@toclocoinc/lattice-grid 1.71.1 → 1.71.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +42 -8
  5. package/docs/api/adapters.html +1 -1
  6. package/docs/api/ai.html +1 -1
  7. package/docs/api/alarms.html +1 -1
  8. package/docs/api/charts.html +39 -5
  9. package/docs/api/data-router.html +1 -1
  10. package/docs/api/gantt.html +1 -1
  11. package/docs/api/grid.html +2 -2
  12. package/docs/api/index.html +2 -2
  13. package/docs/api/kanban.html +1 -1
  14. package/docs/api/kpi.html +1 -1
  15. package/docs/api/layout.html +1 -1
  16. package/docs/api/mock-socket.html +1 -1
  17. package/docs/api/tabs.html +1 -1
  18. package/docs/api/types.html +1 -1
  19. package/docs/api-detail.html +4 -4
  20. package/docs/warnings.json +13 -2
  21. package/lattice-grid.d.ts +31 -7
  22. package/lattice-grid.esm.min.js +3 -3
  23. package/lattice-grid.min.cjs +3 -3
  24. package/lattice-grid.min.js +3 -3
  25. package/modules/ai.d.ts +1 -1
  26. package/modules/ai.esm.min.js +2 -2
  27. package/modules/ai.min.cjs +2 -2
  28. package/modules/ai.min.js +2 -2
  29. package/modules/alarms.d.ts +1 -1
  30. package/modules/alarms.esm.min.js +2 -2
  31. package/modules/alarms.min.cjs +2 -2
  32. package/modules/alarms.min.js +2 -2
  33. package/modules/angular.d.ts +1 -1
  34. package/modules/angular.esm.min.js +2 -2
  35. package/modules/angular.min.cjs +2 -2
  36. package/modules/angular.min.js +2 -2
  37. package/modules/chart-alluvial.d.ts +1 -1
  38. package/modules/chart-alluvial.esm.min.js +1 -1
  39. package/modules/chart-alluvial.min.cjs +1 -1
  40. package/modules/chart-alluvial.min.js +1 -1
  41. package/modules/chart-arc.d.ts +1 -1
  42. package/modules/chart-arc.esm.min.js +1 -1
  43. package/modules/chart-arc.min.cjs +1 -1
  44. package/modules/chart-arc.min.js +1 -1
  45. package/modules/chart-bubblemap.d.ts +1 -1
  46. package/modules/chart-bubblemap.esm.min.js +1 -1
  47. package/modules/chart-bubblemap.min.cjs +1 -1
  48. package/modules/chart-bubblemap.min.js +1 -1
  49. package/modules/chart-bump.d.ts +1 -1
  50. package/modules/chart-bump.esm.min.js +1 -1
  51. package/modules/chart-bump.min.cjs +1 -1
  52. package/modules/chart-bump.min.js +1 -1
  53. package/modules/chart-calendar.d.ts +1 -1
  54. package/modules/chart-calendar.esm.min.js +1 -1
  55. package/modules/chart-calendar.min.cjs +1 -1
  56. package/modules/chart-calendar.min.js +1 -1
  57. package/modules/chart-decomposition.d.ts +1 -1
  58. package/modules/chart-decomposition.esm.min.js +1 -1
  59. package/modules/chart-decomposition.min.cjs +1 -1
  60. package/modules/chart-decomposition.min.js +1 -1
  61. package/modules/chart-diverging.d.ts +1 -1
  62. package/modules/chart-diverging.esm.min.js +1 -1
  63. package/modules/chart-diverging.min.cjs +1 -1
  64. package/modules/chart-diverging.min.js +1 -1
  65. package/modules/chart-dumbbell.d.ts +1 -1
  66. package/modules/chart-dumbbell.esm.min.js +1 -1
  67. package/modules/chart-dumbbell.min.cjs +1 -1
  68. package/modules/chart-dumbbell.min.js +1 -1
  69. package/modules/chart-fan.d.ts +1 -1
  70. package/modules/chart-fan.esm.min.js +1 -1
  71. package/modules/chart-fan.min.cjs +1 -1
  72. package/modules/chart-fan.min.js +1 -1
  73. package/modules/chart-hexbin.d.ts +1 -1
  74. package/modules/chart-hexbin.esm.min.js +1 -1
  75. package/modules/chart-hexbin.min.cjs +1 -1
  76. package/modules/chart-hexbin.min.js +1 -1
  77. package/modules/chart-hexmap.d.ts +1 -1
  78. package/modules/chart-hexmap.esm.min.js +1 -1
  79. package/modules/chart-hexmap.min.cjs +1 -1
  80. package/modules/chart-hexmap.min.js +1 -1
  81. package/modules/chart-icicle.d.ts +1 -1
  82. package/modules/chart-icicle.esm.min.js +1 -1
  83. package/modules/chart-icicle.min.cjs +1 -1
  84. package/modules/chart-icicle.min.js +1 -1
  85. package/modules/chart-markermap.d.ts +1 -1
  86. package/modules/chart-markermap.esm.min.js +1 -1
  87. package/modules/chart-markermap.min.cjs +1 -1
  88. package/modules/chart-markermap.min.js +1 -1
  89. package/modules/chart-parallel.d.ts +1 -1
  90. package/modules/chart-parallel.esm.min.js +1 -1
  91. package/modules/chart-parallel.min.cjs +1 -1
  92. package/modules/chart-parallel.min.js +1 -1
  93. package/modules/chart-ridgeline.d.ts +1 -1
  94. package/modules/chart-ridgeline.esm.min.js +1 -1
  95. package/modules/chart-ridgeline.min.cjs +1 -1
  96. package/modules/chart-ridgeline.min.js +1 -1
  97. package/modules/chart-roc.d.ts +1 -1
  98. package/modules/chart-roc.esm.min.js +1 -1
  99. package/modules/chart-roc.min.cjs +1 -1
  100. package/modules/chart-roc.min.js +1 -1
  101. package/modules/chart-slope.d.ts +1 -1
  102. package/modules/chart-slope.esm.min.js +1 -1
  103. package/modules/chart-slope.min.cjs +1 -1
  104. package/modules/chart-slope.min.js +1 -1
  105. package/modules/chart-splom.d.ts +1 -1
  106. package/modules/chart-splom.esm.min.js +1 -1
  107. package/modules/chart-splom.min.cjs +1 -1
  108. package/modules/chart-splom.min.js +1 -1
  109. package/modules/chart-waffle.d.ts +1 -1
  110. package/modules/chart-waffle.esm.min.js +1 -1
  111. package/modules/chart-waffle.min.cjs +1 -1
  112. package/modules/chart-waffle.min.js +1 -1
  113. package/modules/charts.d.ts +1 -1
  114. package/modules/charts.esm.min.js +13 -9
  115. package/modules/charts.esm.min.js.map +2 -2
  116. package/modules/charts.min.cjs +141 -137
  117. package/modules/charts.min.js +141 -137
  118. package/modules/charts.min.js.map +2 -2
  119. package/modules/data-router.d.ts +1 -1
  120. package/modules/data-router.esm.min.js +2 -2
  121. package/modules/data-router.min.cjs +2 -2
  122. package/modules/data-router.min.js +2 -2
  123. package/modules/devtools.d.ts +1 -1
  124. package/modules/devtools.esm.min.js +1 -1
  125. package/modules/devtools.min.cjs +1 -1
  126. package/modules/devtools.min.js +1 -1
  127. package/modules/dhtmlx-compat.d.ts +1 -1
  128. package/modules/dhtmlx-compat.esm.min.js +2 -2
  129. package/modules/dhtmlx-compat.min.cjs +2 -2
  130. package/modules/dhtmlx-compat.min.js +2 -2
  131. package/modules/gantt.d.ts +1 -1
  132. package/modules/gantt.esm.min.js +2 -2
  133. package/modules/gantt.min.cjs +2 -2
  134. package/modules/gantt.min.js +2 -2
  135. package/modules/geo-europe-nuts.d.ts +1 -1
  136. package/modules/geo-europe-nuts.esm.min.js +1 -1
  137. package/modules/geo-europe-nuts.min.cjs +1 -1
  138. package/modules/geo-europe-nuts.min.js +1 -1
  139. package/modules/geo-uk.d.ts +1 -1
  140. package/modules/geo-uk.esm.min.js +1 -1
  141. package/modules/geo-uk.min.cjs +1 -1
  142. package/modules/geo-uk.min.js +1 -1
  143. package/modules/geo-us-states.d.ts +1 -1
  144. package/modules/geo-us-states.esm.min.js +1 -1
  145. package/modules/geo-us-states.min.cjs +1 -1
  146. package/modules/geo-us-states.min.js +1 -1
  147. package/modules/geo-world-110m.d.ts +1 -1
  148. package/modules/geo-world-110m.esm.min.js +1 -1
  149. package/modules/geo-world-110m.min.cjs +1 -1
  150. package/modules/geo-world-110m.min.js +1 -1
  151. package/modules/geo-world-50m.d.ts +1 -1
  152. package/modules/geo-world-50m.esm.min.js +1 -1
  153. package/modules/geo-world-50m.min.cjs +1 -1
  154. package/modules/geo-world-50m.min.js +1 -1
  155. package/modules/htmx.d.ts +1 -1
  156. package/modules/htmx.esm.min.js +3 -3
  157. package/modules/htmx.min.cjs +3 -3
  158. package/modules/htmx.min.js +3 -3
  159. package/modules/kanban.d.ts +1 -1
  160. package/modules/kanban.esm.min.js +2 -2
  161. package/modules/kanban.min.cjs +2 -2
  162. package/modules/kanban.min.js +2 -2
  163. package/modules/kpi.d.ts +1 -1
  164. package/modules/kpi.esm.min.js +2 -2
  165. package/modules/kpi.min.cjs +2 -2
  166. package/modules/kpi.min.js +2 -2
  167. package/modules/layout.d.ts +1 -1
  168. package/modules/layout.esm.min.js +2 -2
  169. package/modules/layout.min.cjs +2 -2
  170. package/modules/layout.min.js +2 -2
  171. package/modules/mock-socket.d.ts +1 -1
  172. package/modules/mock-socket.esm.min.js +1 -1
  173. package/modules/mock-socket.min.cjs +1 -1
  174. package/modules/mock-socket.min.js +1 -1
  175. package/modules/react.d.ts +1 -1
  176. package/modules/react.esm.min.js +2 -2
  177. package/modules/react.min.cjs +2 -2
  178. package/modules/react.min.js +2 -2
  179. package/modules/svelte.d.ts +1 -1
  180. package/modules/svelte.esm.min.js +2 -2
  181. package/modules/svelte.min.cjs +2 -2
  182. package/modules/svelte.min.js +2 -2
  183. package/modules/tabs.d.ts +1 -1
  184. package/modules/tabs.esm.min.js +2 -2
  185. package/modules/tabs.min.cjs +2 -2
  186. package/modules/tabs.min.js +2 -2
  187. package/modules/vue.d.ts +1 -1
  188. package/modules/vue.esm.min.js +2 -2
  189. package/modules/vue.min.cjs +2 -2
  190. package/modules/vue.min.js +2 -2
  191. package/modules/webcomponent.d.ts +1 -1
  192. package/modules/webcomponent.esm.min.js +3 -3
  193. package/modules/webcomponent.min.cjs +3 -3
  194. package/modules/webcomponent.min.js +3 -3
  195. package/package.json +1 -1
package/modules/ai.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, ai module type declarations
2
+ * Lattice Grid 1.71.3, ai module type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, ai module
2
+ * Lattice Grid 1.71.3, ai module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var we=Object.create(null),ve=Object.create(null);function pe(h,V){we[h]=V}function ke(h){var V=ve[h];if(V)return V;var m=Object.create(null);ve[h]=m;var C=we[h];if(!C)throw new Error("[lattice] missing module: "+h);return C(m,ke),m}pe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"reportedWarnings",{enumerable:!0,get:function(){return te}}),Object.defineProperty(h,"warnOnce",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(h,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"resetWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(h,"fail",{enumerable:!0,get:function(){return W}}),Object.defineProperty(h,"invariant",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return r}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"isFunction",{enumerable:!0,get:function(){return c}}),Object.defineProperty(h,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(h,"isBlank",{enumerable:!0,get:function(){return e}}),Object.defineProperty(h,"isCtor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(h,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(h,"collator",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(h,"defaultCompare",{enumerable:!0,get:function(){return l}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return se}});const m="1.71.1";async function C(){return m}const I="1.71.1",q=new Set,R=2e3;function _(y){if(q.add(y),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(y,w,P){K.push({key:y,level:w,message:P.map(H=>typeof H=="string"?H:U(H)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function U(y){if(y instanceof Error)return y.message;try{return JSON.stringify(y)}catch{return String(y)}}function te(){return K.map(y=>({...y}))}function ne(y,...w){q.has(y)||(_(y),Q(y,"warn",w),console.warn("[lattice]",...w))}function T(y,...w){q.has(y)||(_(y),Q(y,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(y,w){const P=new Error(`[lattice] ${y}`);throw w!==void 0&&(P.cause=w),P}function g(y,w){y||W(w)}const r=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(y){return y!==null&&typeof y=="object"&&!Array.isArray(y)}function c(y){return typeof y=="function"}function u(y){return y==null}function e(y){return y==null||y===""}function s(y){return typeof y!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(y))?!0:!!(y.prototype&&Object.getOwnPropertyNames(y.prototype).length>1)}const i=new Map;function t(y){let w=i.get(y);if(w)return w;if(!y.includes("."))w=P=>P?.[y];else{const P=y.split("."),H=P.length;w=le=>{let ue=le;for(let de=0;de<H;de++){if(ue==null)return;ue=ue[P[de]]}return ue}}return i.set(y,w),w}const d=new Map;function p(y){let w=d.get(y);if(w)return w;if(!y.includes("."))w=(P,H)=>{P!=null&&(P[y]=H)};else{const P=y.split("."),H=P.length-1;w=(le,ue)=>{let de=le;for(let ce=0;ce<H;ce++){if(de==null)return;const Y=P[ce];de[Y]==null&&(de[Y]={}),de=de[Y]}de!=null&&(de[P[H]]=ue)}}return d.set(y,w),w}function k(y,w){return t(w)(y)}function o(y,w,P){p(w)(y,P)}function a(y){return y?(y.includes(".")?y.slice(y.lastIndexOf(".")+1):y).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(/^./,P=>P.toUpperCase()):""}const f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(y){const w=y==null?"":String(y);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,P=>f[P]):w}function S(y){return String(y).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(y,w,P){if(y!==void 0)return y===!0?{enabled:!0,...P}:y===!1?{enabled:!1}:n(y)?y:{[w]:y,enabled:!0}}function E(y){return y==null?[]:Array.isArray(y)?y:[y]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(y,w){if(!n(y))return n(w)?{...w}:w;if(!n(w))return w===void 0?y:w;const P={...y};for(const H of Object.keys(w)){if(D.has(H))continue;const le=w[H];le!==void 0&&(P[H]=n(le)&&n(P[H])?A(P[H],le):le)}return P}function B(y,w){if(!n(y)||!n(w)||y===w)return w;const P=Object.create(Object.getPrototypeOf(y));return Object.assign(P,y,w),P}class X{#t;#e=new Map;#n;constructor(w=256,P=null){this.#t=w,this.#n=P}get size(){return this.#e.size}get max(){return this.#t}set max(w){this.#t=w,this.#r()}has(w){return this.#e.has(w)}get(w){const P=this.#e;if(!P.has(w))return;const H=P.get(w);return P.delete(w),P.set(w,H),H}peek(w){return this.#e.get(w)}set(w,P){const H=this.#e;return H.has(w)&&H.delete(w),H.set(w,P),this.#r(),P}delete(w){const P=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n(P,w),P}clear(){if(this.#n)for(const[w,P]of this.#e)this.#n(P,w);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const w=this.#e;for(;w.size>this.#t;){const P=w.keys().next().value,H=w.get(P);w.delete(P),this.#n&&this.#n(H,P)}}}const J=new Map;function oe(y,w){const P=`${y||""}|${w?JSON.stringify(w):""}`;let H=J.get(P);return H||(H=new Intl.Collator(y||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set(P,H)),H}function l(y,w){if(y===w)return 0;if(y==null)return 1;if(w==null)return-1;if(typeof y=="number"&&typeof w=="number")return Number.isNaN(y)?Number.isNaN(w)?0:1:Number.isNaN(w)||y<w?-1:y>w?1:0;const P=String(y),H=String(w);return P<H?-1:P>H?1:0}function O(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function $(y){return v?requestAnimationFrame(y):setTimeout(()=>y(O()),16)}function F(y){y!=null&&(v?cancelAnimationFrame(y):clearTimeout(y))}function j(y){let w=null,P=null;const H=()=>{w=null;const ue=P;P=null,y(...ue||[])},le=(...ue)=>{P=ue,w===null&&(w=$(H))};return le.cancel=()=>{F(w),w=null,P=null},le.flush=()=>{w!==null&&(F(w),H())},le}function L(y,w){let P=null,H=null;const le=()=>{if(P=null,H===null)return;const ce=H;H=null,y(...ce),ue()},ue=()=>{P=setTimeout(le,w),typeof P?.unref=="function"&&P.unref()},de=(...ce)=>{P===null?(y(...ce),ue()):(H=ce,clearTimeout(P),ue())};return de.flush=()=>{if(P!==null&&clearTimeout(P),P=null,H===null)return;const ce=H;H=null,y(...ce)},de.cancel=()=>{P!==null&&clearTimeout(P),P=null,H=null},de.pending=()=>P!==null||H!==null,de}function z(y,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(y,{timeout:w}):setTimeout(()=>y({timeRemaining:()=>0,didTimeout:!0}),1)}let Z=0;function se(y="l"){return`${y}${(++Z).toString(36)}`}}),pe("packages/modules/ai/reconcile.js",function(h,V){"use strict";Object.defineProperty(h,"UNVERIFIED",{enumerable:!0,get:function(){return R}}),Object.defineProperty(h,"formsOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(h,"buildRegistry",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(h,"collectNumbers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const C=V("packages/core/src/internal/util.js").isNil,I=1e-6,q=4,R="[unverified]";function _(e,s){const i=10**s,t=Math.round(e*i)/i;return t===0?0:t}function K(e){const s=e.indexOf(".");return s<0?0:Math.min(e.length-s-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const s=new Set([e]);for(let i=0;i<=q;i+=1)s.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let t=0;t<=q;t+=1)s.add(_(i,t))}return[...s]}function Q(e){const s=new Set,i=[];for(const d of e)if(Number.isFinite(d)){i.push(d);for(const p of G(d))s.add(p)}const t=[...s];return{size:i.length,values:i,has(d,p){for(const k of t)if(Math.abs(k-d)<=I||_(k,p)===d)return!0;return!1}}}function U(e,s=[],i=0){if(i>8||C(e))return s;if(typeof e=="number")return Number.isFinite(e)&&s.push(e),s;if(typeof e=="string"){const t=Number(e);return e.trim()!==""&&Number.isFinite(t)&&s.push(t),s}if(Array.isArray(e)){for(const t of e)U(t,s,i+1);return s}if(typeof e=="object")for(const t of Object.keys(e))U(e[t],s,i+1);return s}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,s,i,t){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(s)||e===":"&&/\d/.test(s)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(t))}function T(e){const s=[];if(typeof e!="string"||e==="")return s;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let t;for(;(t=i.exec(e))!==null;){const[,d,,p,k,o]=t,a=t.index+d.length,f=t.index+t[0].length,b=t.index>0?e[t.index-1]:"",S=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(d,b,S,N))continue;const E=p.replace(/,/g,"");let D=Number(E);if(!Number.isFinite(D))continue;const A=K(E);o&&Object.prototype.hasOwnProperty.call(te,o)&&(D*=te[o]),s.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:o||""})}return s}function x(e){return e===" "||e===" "||e===`
6
+ var we=Object.create(null),ve=Object.create(null);function pe(h,V){we[h]=V}function ke(h){var V=ve[h];if(V)return V;var m=Object.create(null);ve[h]=m;var C=we[h];if(!C)throw new Error("[lattice] missing module: "+h);return C(m,ke),m}pe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"reportedWarnings",{enumerable:!0,get:function(){return te}}),Object.defineProperty(h,"warnOnce",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(h,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"resetWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(h,"fail",{enumerable:!0,get:function(){return W}}),Object.defineProperty(h,"invariant",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return r}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"isFunction",{enumerable:!0,get:function(){return c}}),Object.defineProperty(h,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(h,"isBlank",{enumerable:!0,get:function(){return e}}),Object.defineProperty(h,"isCtor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(h,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(h,"collator",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(h,"defaultCompare",{enumerable:!0,get:function(){return l}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return se}});const m="1.71.3";async function C(){return m}const I="1.71.3",q=new Set,R=2e3;function _(y){if(q.add(y),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(y,w,P){K.push({key:y,level:w,message:P.map(H=>typeof H=="string"?H:U(H)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function U(y){if(y instanceof Error)return y.message;try{return JSON.stringify(y)}catch{return String(y)}}function te(){return K.map(y=>({...y}))}function ne(y,...w){q.has(y)||(_(y),Q(y,"warn",w),console.warn("[lattice]",...w))}function T(y,...w){q.has(y)||(_(y),Q(y,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(y,w){const P=new Error(`[lattice] ${y}`);throw w!==void 0&&(P.cause=w),P}function g(y,w){y||W(w)}const r=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(y){return y!==null&&typeof y=="object"&&!Array.isArray(y)}function c(y){return typeof y=="function"}function u(y){return y==null}function e(y){return y==null||y===""}function s(y){return typeof y!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(y))?!0:!!(y.prototype&&Object.getOwnPropertyNames(y.prototype).length>1)}const i=new Map;function t(y){let w=i.get(y);if(w)return w;if(!y.includes("."))w=P=>P?.[y];else{const P=y.split("."),H=P.length;w=le=>{let ue=le;for(let de=0;de<H;de++){if(ue==null)return;ue=ue[P[de]]}return ue}}return i.set(y,w),w}const d=new Map;function p(y){let w=d.get(y);if(w)return w;if(!y.includes("."))w=(P,H)=>{P!=null&&(P[y]=H)};else{const P=y.split("."),H=P.length-1;w=(le,ue)=>{let de=le;for(let ce=0;ce<H;ce++){if(de==null)return;const Y=P[ce];de[Y]==null&&(de[Y]={}),de=de[Y]}de!=null&&(de[P[H]]=ue)}}return d.set(y,w),w}function k(y,w){return t(w)(y)}function o(y,w,P){p(w)(y,P)}function a(y){return y?(y.includes(".")?y.slice(y.lastIndexOf(".")+1):y).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(/^./,P=>P.toUpperCase()):""}const f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(y){const w=y==null?"":String(y);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,P=>f[P]):w}function S(y){return String(y).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(y,w,P){if(y!==void 0)return y===!0?{enabled:!0,...P}:y===!1?{enabled:!1}:n(y)?y:{[w]:y,enabled:!0}}function E(y){return y==null?[]:Array.isArray(y)?y:[y]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(y,w){if(!n(y))return n(w)?{...w}:w;if(!n(w))return w===void 0?y:w;const P={...y};for(const H of Object.keys(w)){if(D.has(H))continue;const le=w[H];le!==void 0&&(P[H]=n(le)&&n(P[H])?A(P[H],le):le)}return P}function B(y,w){if(!n(y)||!n(w)||y===w)return w;const P=Object.create(Object.getPrototypeOf(y));return Object.assign(P,y,w),P}class X{#t;#e=new Map;#n;constructor(w=256,P=null){this.#t=w,this.#n=P}get size(){return this.#e.size}get max(){return this.#t}set max(w){this.#t=w,this.#r()}has(w){return this.#e.has(w)}get(w){const P=this.#e;if(!P.has(w))return;const H=P.get(w);return P.delete(w),P.set(w,H),H}peek(w){return this.#e.get(w)}set(w,P){const H=this.#e;return H.has(w)&&H.delete(w),H.set(w,P),this.#r(),P}delete(w){const P=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n(P,w),P}clear(){if(this.#n)for(const[w,P]of this.#e)this.#n(P,w);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const w=this.#e;for(;w.size>this.#t;){const P=w.keys().next().value,H=w.get(P);w.delete(P),this.#n&&this.#n(H,P)}}}const J=new Map;function oe(y,w){const P=`${y||""}|${w?JSON.stringify(w):""}`;let H=J.get(P);return H||(H=new Intl.Collator(y||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set(P,H)),H}function l(y,w){if(y===w)return 0;if(y==null)return 1;if(w==null)return-1;if(typeof y=="number"&&typeof w=="number")return Number.isNaN(y)?Number.isNaN(w)?0:1:Number.isNaN(w)||y<w?-1:y>w?1:0;const P=String(y),H=String(w);return P<H?-1:P>H?1:0}function O(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function $(y){return v?requestAnimationFrame(y):setTimeout(()=>y(O()),16)}function F(y){y!=null&&(v?cancelAnimationFrame(y):clearTimeout(y))}function j(y){let w=null,P=null;const H=()=>{w=null;const ue=P;P=null,y(...ue||[])},le=(...ue)=>{P=ue,w===null&&(w=$(H))};return le.cancel=()=>{F(w),w=null,P=null},le.flush=()=>{w!==null&&(F(w),H())},le}function L(y,w){let P=null,H=null;const le=()=>{if(P=null,H===null)return;const ce=H;H=null,y(...ce),ue()},ue=()=>{P=setTimeout(le,w),typeof P?.unref=="function"&&P.unref()},de=(...ce)=>{P===null?(y(...ce),ue()):(H=ce,clearTimeout(P),ue())};return de.flush=()=>{if(P!==null&&clearTimeout(P),P=null,H===null)return;const ce=H;H=null,y(...ce)},de.cancel=()=>{P!==null&&clearTimeout(P),P=null,H=null},de.pending=()=>P!==null||H!==null,de}function z(y,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(y,{timeout:w}):setTimeout(()=>y({timeRemaining:()=>0,didTimeout:!0}),1)}let Z=0;function se(y="l"){return`${y}${(++Z).toString(36)}`}}),pe("packages/modules/ai/reconcile.js",function(h,V){"use strict";Object.defineProperty(h,"UNVERIFIED",{enumerable:!0,get:function(){return R}}),Object.defineProperty(h,"formsOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(h,"buildRegistry",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(h,"collectNumbers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const C=V("packages/core/src/internal/util.js").isNil,I=1e-6,q=4,R="[unverified]";function _(e,s){const i=10**s,t=Math.round(e*i)/i;return t===0?0:t}function K(e){const s=e.indexOf(".");return s<0?0:Math.min(e.length-s-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const s=new Set([e]);for(let i=0;i<=q;i+=1)s.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let t=0;t<=q;t+=1)s.add(_(i,t))}return[...s]}function Q(e){const s=new Set,i=[];for(const d of e)if(Number.isFinite(d)){i.push(d);for(const p of G(d))s.add(p)}const t=[...s];return{size:i.length,values:i,has(d,p){for(const k of t)if(Math.abs(k-d)<=I||_(k,p)===d)return!0;return!1}}}function U(e,s=[],i=0){if(i>8||C(e))return s;if(typeof e=="number")return Number.isFinite(e)&&s.push(e),s;if(typeof e=="string"){const t=Number(e);return e.trim()!==""&&Number.isFinite(t)&&s.push(t),s}if(Array.isArray(e)){for(const t of e)U(t,s,i+1);return s}if(typeof e=="object")for(const t of Object.keys(e))U(e[t],s,i+1);return s}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,s,i,t){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(s)||e===":"&&/\d/.test(s)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(t))}function T(e){const s=[];if(typeof e!="string"||e==="")return s;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let t;for(;(t=i.exec(e))!==null;){const[,d,,p,k,o]=t,a=t.index+d.length,f=t.index+t[0].length,b=t.index>0?e[t.index-1]:"",S=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(d,b,S,N))continue;const E=p.replace(/,/g,"");let D=Number(E);if(!Number.isFinite(D))continue;const A=K(E);o&&Object.prototype.hasOwnProperty.call(te,o)&&(D*=te[o]),s.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:o||""})}return s}function x(e){return e===" "||e===" "||e===`
7
7
  `||e==="\r"}function W(e){const s=[],i=[];for(let t=0;t<e.length;t+=1)if(e[t]==="(")i.push(t);else if(e[t]===")"&&i.length){const d=i.pop();i.length===0&&s.push({start:d,end:t+1})}return s}function g(e){const s=[],i=e.length;let t=0,d=0;for(;d<i;){const p=e[d],k=p==="."||p==="!"||p==="?",o=d+1>=i||x(e[d+1]);if(k&&o||p===`
8
8
  `){let a=d+1;for(;a<i&&(e[a]==="."||e[a]==="!"||e[a]==="?");)a+=1;for(;a<i&&x(e[a]);)a+=1;s.push({start:t,end:a}),t=a,d=a;continue}d+=1}return t<i&&s.push({start:t,end:i}),s}function r(e){const s=e.slice().sort((t,d)=>t.start-d.start),i=[];for(const t of s){const d=i[i.length-1];d&&t.start<=d.end?d.end=Math.max(d.end,t.end):i.push({start:t.start,end:t.end})}return i}function n(e){return e.replace(/\(\s*\)/g,"").replace(/[ \t]{2,}/g," ").replace(/[ \t]+([,.;:!?)])/g,"$1").replace(/([([])[ \t]+/g,"$1").replace(/(^|[.!?\n])[ \t]*[.;:,!?]+(?=[ \t]|$|\n)/g,"$1").replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
9
9
  `).replace(/\n{3,}/g,`
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, ai module
2
+ * Lattice Grid 1.71.3, ai module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- (function(Oe){"use strict";var we=Object.create(null),ve=Object.create(null);function fe(h,V){we[h]=V}function ke(h){var V=ve[h];if(V)return V;var m=Object.create(null);ve[h]=m;var C=we[h];if(!C)throw new Error("[lattice] missing module: "+h);return C(m,ke),m}fe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return M}}),Object.defineProperty(h,"reportedWarnings",{enumerable:!0,get:function(){return te}}),Object.defineProperty(h,"warnOnce",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(h,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"resetWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(h,"fail",{enumerable:!0,get:function(){return W}}),Object.defineProperty(h,"invariant",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return r}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"isFunction",{enumerable:!0,get:function(){return c}}),Object.defineProperty(h,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(h,"isBlank",{enumerable:!0,get:function(){return e}}),Object.defineProperty(h,"isCtor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(h,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(h,"collator",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(h,"defaultCompare",{enumerable:!0,get:function(){return l}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return se}});const m="1.71.1";async function C(){return m}const M="1.71.1",q=new Set,R=2e3;function _(y){if(q.add(y),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(y,w,P){K.push({key:y,level:w,message:P.map(H=>typeof H=="string"?H:U(H)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function U(y){if(y instanceof Error)return y.message;try{return JSON.stringify(y)}catch{return String(y)}}function te(){return K.map(y=>({...y}))}function ne(y,...w){q.has(y)||(_(y),Q(y,"warn",w),console.warn("[lattice]",...w))}function T(y,...w){q.has(y)||(_(y),Q(y,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(y,w){const P=new Error(`[lattice] ${y}`);throw w!==void 0&&(P.cause=w),P}function g(y,w){y||W(w)}const r=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(y){return y!==null&&typeof y=="object"&&!Array.isArray(y)}function c(y){return typeof y=="function"}function u(y){return y==null}function e(y){return y==null||y===""}function s(y){return typeof y!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(y))?!0:!!(y.prototype&&Object.getOwnPropertyNames(y.prototype).length>1)}const i=new Map;function t(y){let w=i.get(y);if(w)return w;if(!y.includes("."))w=P=>P?.[y];else{const P=y.split("."),H=P.length;w=le=>{let ue=le;for(let de=0;de<H;de++){if(ue==null)return;ue=ue[P[de]]}return ue}}return i.set(y,w),w}const d=new Map;function p(y){let w=d.get(y);if(w)return w;if(!y.includes("."))w=(P,H)=>{P!=null&&(P[y]=H)};else{const P=y.split("."),H=P.length-1;w=(le,ue)=>{let de=le;for(let ce=0;ce<H;ce++){if(de==null)return;const Y=P[ce];de[Y]==null&&(de[Y]={}),de=de[Y]}de!=null&&(de[P[H]]=ue)}}return d.set(y,w),w}function k(y,w){return t(w)(y)}function o(y,w,P){p(w)(y,P)}function a(y){return y?(y.includes(".")?y.slice(y.lastIndexOf(".")+1):y).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(/^./,P=>P.toUpperCase()):""}const f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(y){const w=y==null?"":String(y);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,P=>f[P]):w}function S(y){return String(y).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(y,w,P){if(y!==void 0)return y===!0?{enabled:!0,...P}:y===!1?{enabled:!1}:n(y)?y:{[w]:y,enabled:!0}}function E(y){return y==null?[]:Array.isArray(y)?y:[y]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(y,w){if(!n(y))return n(w)?{...w}:w;if(!n(w))return w===void 0?y:w;const P={...y};for(const H of Object.keys(w)){if(D.has(H))continue;const le=w[H];le!==void 0&&(P[H]=n(le)&&n(P[H])?A(P[H],le):le)}return P}function B(y,w){if(!n(y)||!n(w)||y===w)return w;const P=Object.create(Object.getPrototypeOf(y));return Object.assign(P,y,w),P}class X{#t;#e=new Map;#n;constructor(w=256,P=null){this.#t=w,this.#n=P}get size(){return this.#e.size}get max(){return this.#t}set max(w){this.#t=w,this.#r()}has(w){return this.#e.has(w)}get(w){const P=this.#e;if(!P.has(w))return;const H=P.get(w);return P.delete(w),P.set(w,H),H}peek(w){return this.#e.get(w)}set(w,P){const H=this.#e;return H.has(w)&&H.delete(w),H.set(w,P),this.#r(),P}delete(w){const P=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n(P,w),P}clear(){if(this.#n)for(const[w,P]of this.#e)this.#n(P,w);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const w=this.#e;for(;w.size>this.#t;){const P=w.keys().next().value,H=w.get(P);w.delete(P),this.#n&&this.#n(H,P)}}}const J=new Map;function oe(y,w){const P=`${y||""}|${w?JSON.stringify(w):""}`;let H=J.get(P);return H||(H=new Intl.Collator(y||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set(P,H)),H}function l(y,w){if(y===w)return 0;if(y==null)return 1;if(w==null)return-1;if(typeof y=="number"&&typeof w=="number")return Number.isNaN(y)?Number.isNaN(w)?0:1:Number.isNaN(w)||y<w?-1:y>w?1:0;const P=String(y),H=String(w);return P<H?-1:P>H?1:0}function O(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function $(y){return v?requestAnimationFrame(y):setTimeout(()=>y(O()),16)}function F(y){y!=null&&(v?cancelAnimationFrame(y):clearTimeout(y))}function j(y){let w=null,P=null;const H=()=>{w=null;const ue=P;P=null,y(...ue||[])},le=(...ue)=>{P=ue,w===null&&(w=$(H))};return le.cancel=()=>{F(w),w=null,P=null},le.flush=()=>{w!==null&&(F(w),H())},le}function L(y,w){let P=null,H=null;const le=()=>{if(P=null,H===null)return;const ce=H;H=null,y(...ce),ue()},ue=()=>{P=setTimeout(le,w),typeof P?.unref=="function"&&P.unref()},de=(...ce)=>{P===null?(y(...ce),ue()):(H=ce,clearTimeout(P),ue())};return de.flush=()=>{if(P!==null&&clearTimeout(P),P=null,H===null)return;const ce=H;H=null,y(...ce)},de.cancel=()=>{P!==null&&clearTimeout(P),P=null,H=null},de.pending=()=>P!==null||H!==null,de}function z(y,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(y,{timeout:w}):setTimeout(()=>y({timeRemaining:()=>0,didTimeout:!0}),1)}let Z=0;function se(y="l"){return`${y}${(++Z).toString(36)}`}}),fe("packages/modules/ai/reconcile.js",function(h,V){"use strict";Object.defineProperty(h,"UNVERIFIED",{enumerable:!0,get:function(){return R}}),Object.defineProperty(h,"formsOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(h,"buildRegistry",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(h,"collectNumbers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const C=V("packages/core/src/internal/util.js").isNil,M=1e-6,q=4,R="[unverified]";function _(e,s){const i=10**s,t=Math.round(e*i)/i;return t===0?0:t}function K(e){const s=e.indexOf(".");return s<0?0:Math.min(e.length-s-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const s=new Set([e]);for(let i=0;i<=q;i+=1)s.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let t=0;t<=q;t+=1)s.add(_(i,t))}return[...s]}function Q(e){const s=new Set,i=[];for(const d of e)if(Number.isFinite(d)){i.push(d);for(const p of G(d))s.add(p)}const t=[...s];return{size:i.length,values:i,has(d,p){for(const k of t)if(Math.abs(k-d)<=M||_(k,p)===d)return!0;return!1}}}function U(e,s=[],i=0){if(i>8||C(e))return s;if(typeof e=="number")return Number.isFinite(e)&&s.push(e),s;if(typeof e=="string"){const t=Number(e);return e.trim()!==""&&Number.isFinite(t)&&s.push(t),s}if(Array.isArray(e)){for(const t of e)U(t,s,i+1);return s}if(typeof e=="object")for(const t of Object.keys(e))U(e[t],s,i+1);return s}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,s,i,t){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(s)||e===":"&&/\d/.test(s)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(t))}function T(e){const s=[];if(typeof e!="string"||e==="")return s;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let t;for(;(t=i.exec(e))!==null;){const[,d,,p,k,o]=t,a=t.index+d.length,f=t.index+t[0].length,b=t.index>0?e[t.index-1]:"",S=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(d,b,S,N))continue;const E=p.replace(/,/g,"");let D=Number(E);if(!Number.isFinite(D))continue;const A=K(E);o&&Object.prototype.hasOwnProperty.call(te,o)&&(D*=te[o]),s.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:o||""})}return s}function x(e){return e===" "||e===" "||e===`
6
+ (function(Oe){"use strict";var we=Object.create(null),ve=Object.create(null);function fe(h,V){we[h]=V}function ke(h){var V=ve[h];if(V)return V;var m=Object.create(null);ve[h]=m;var C=we[h];if(!C)throw new Error("[lattice] missing module: "+h);return C(m,ke),m}fe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return M}}),Object.defineProperty(h,"reportedWarnings",{enumerable:!0,get:function(){return te}}),Object.defineProperty(h,"warnOnce",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(h,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"resetWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(h,"fail",{enumerable:!0,get:function(){return W}}),Object.defineProperty(h,"invariant",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return r}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"isFunction",{enumerable:!0,get:function(){return c}}),Object.defineProperty(h,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(h,"isBlank",{enumerable:!0,get:function(){return e}}),Object.defineProperty(h,"isCtor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(h,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(h,"collator",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(h,"defaultCompare",{enumerable:!0,get:function(){return l}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return se}});const m="1.71.3";async function C(){return m}const M="1.71.3",q=new Set,R=2e3;function _(y){if(q.add(y),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(y,w,P){K.push({key:y,level:w,message:P.map(H=>typeof H=="string"?H:U(H)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function U(y){if(y instanceof Error)return y.message;try{return JSON.stringify(y)}catch{return String(y)}}function te(){return K.map(y=>({...y}))}function ne(y,...w){q.has(y)||(_(y),Q(y,"warn",w),console.warn("[lattice]",...w))}function T(y,...w){q.has(y)||(_(y),Q(y,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(y,w){const P=new Error(`[lattice] ${y}`);throw w!==void 0&&(P.cause=w),P}function g(y,w){y||W(w)}const r=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(y){return y!==null&&typeof y=="object"&&!Array.isArray(y)}function c(y){return typeof y=="function"}function u(y){return y==null}function e(y){return y==null||y===""}function s(y){return typeof y!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(y))?!0:!!(y.prototype&&Object.getOwnPropertyNames(y.prototype).length>1)}const i=new Map;function t(y){let w=i.get(y);if(w)return w;if(!y.includes("."))w=P=>P?.[y];else{const P=y.split("."),H=P.length;w=le=>{let ue=le;for(let de=0;de<H;de++){if(ue==null)return;ue=ue[P[de]]}return ue}}return i.set(y,w),w}const d=new Map;function p(y){let w=d.get(y);if(w)return w;if(!y.includes("."))w=(P,H)=>{P!=null&&(P[y]=H)};else{const P=y.split("."),H=P.length-1;w=(le,ue)=>{let de=le;for(let ce=0;ce<H;ce++){if(de==null)return;const Y=P[ce];de[Y]==null&&(de[Y]={}),de=de[Y]}de!=null&&(de[P[H]]=ue)}}return d.set(y,w),w}function k(y,w){return t(w)(y)}function o(y,w,P){p(w)(y,P)}function a(y){return y?(y.includes(".")?y.slice(y.lastIndexOf(".")+1):y).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(/^./,P=>P.toUpperCase()):""}const f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(y){const w=y==null?"":String(y);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,P=>f[P]):w}function S(y){return String(y).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(y,w,P){if(y!==void 0)return y===!0?{enabled:!0,...P}:y===!1?{enabled:!1}:n(y)?y:{[w]:y,enabled:!0}}function E(y){return y==null?[]:Array.isArray(y)?y:[y]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(y,w){if(!n(y))return n(w)?{...w}:w;if(!n(w))return w===void 0?y:w;const P={...y};for(const H of Object.keys(w)){if(D.has(H))continue;const le=w[H];le!==void 0&&(P[H]=n(le)&&n(P[H])?A(P[H],le):le)}return P}function B(y,w){if(!n(y)||!n(w)||y===w)return w;const P=Object.create(Object.getPrototypeOf(y));return Object.assign(P,y,w),P}class X{#t;#e=new Map;#n;constructor(w=256,P=null){this.#t=w,this.#n=P}get size(){return this.#e.size}get max(){return this.#t}set max(w){this.#t=w,this.#r()}has(w){return this.#e.has(w)}get(w){const P=this.#e;if(!P.has(w))return;const H=P.get(w);return P.delete(w),P.set(w,H),H}peek(w){return this.#e.get(w)}set(w,P){const H=this.#e;return H.has(w)&&H.delete(w),H.set(w,P),this.#r(),P}delete(w){const P=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n(P,w),P}clear(){if(this.#n)for(const[w,P]of this.#e)this.#n(P,w);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const w=this.#e;for(;w.size>this.#t;){const P=w.keys().next().value,H=w.get(P);w.delete(P),this.#n&&this.#n(H,P)}}}const J=new Map;function oe(y,w){const P=`${y||""}|${w?JSON.stringify(w):""}`;let H=J.get(P);return H||(H=new Intl.Collator(y||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set(P,H)),H}function l(y,w){if(y===w)return 0;if(y==null)return 1;if(w==null)return-1;if(typeof y=="number"&&typeof w=="number")return Number.isNaN(y)?Number.isNaN(w)?0:1:Number.isNaN(w)||y<w?-1:y>w?1:0;const P=String(y),H=String(w);return P<H?-1:P>H?1:0}function O(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function $(y){return v?requestAnimationFrame(y):setTimeout(()=>y(O()),16)}function F(y){y!=null&&(v?cancelAnimationFrame(y):clearTimeout(y))}function j(y){let w=null,P=null;const H=()=>{w=null;const ue=P;P=null,y(...ue||[])},le=(...ue)=>{P=ue,w===null&&(w=$(H))};return le.cancel=()=>{F(w),w=null,P=null},le.flush=()=>{w!==null&&(F(w),H())},le}function L(y,w){let P=null,H=null;const le=()=>{if(P=null,H===null)return;const ce=H;H=null,y(...ce),ue()},ue=()=>{P=setTimeout(le,w),typeof P?.unref=="function"&&P.unref()},de=(...ce)=>{P===null?(y(...ce),ue()):(H=ce,clearTimeout(P),ue())};return de.flush=()=>{if(P!==null&&clearTimeout(P),P=null,H===null)return;const ce=H;H=null,y(...ce)},de.cancel=()=>{P!==null&&clearTimeout(P),P=null,H=null},de.pending=()=>P!==null||H!==null,de}function z(y,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(y,{timeout:w}):setTimeout(()=>y({timeRemaining:()=>0,didTimeout:!0}),1)}let Z=0;function se(y="l"){return`${y}${(++Z).toString(36)}`}}),fe("packages/modules/ai/reconcile.js",function(h,V){"use strict";Object.defineProperty(h,"UNVERIFIED",{enumerable:!0,get:function(){return R}}),Object.defineProperty(h,"formsOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(h,"buildRegistry",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(h,"collectNumbers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const C=V("packages/core/src/internal/util.js").isNil,M=1e-6,q=4,R="[unverified]";function _(e,s){const i=10**s,t=Math.round(e*i)/i;return t===0?0:t}function K(e){const s=e.indexOf(".");return s<0?0:Math.min(e.length-s-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const s=new Set([e]);for(let i=0;i<=q;i+=1)s.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let t=0;t<=q;t+=1)s.add(_(i,t))}return[...s]}function Q(e){const s=new Set,i=[];for(const d of e)if(Number.isFinite(d)){i.push(d);for(const p of G(d))s.add(p)}const t=[...s];return{size:i.length,values:i,has(d,p){for(const k of t)if(Math.abs(k-d)<=M||_(k,p)===d)return!0;return!1}}}function U(e,s=[],i=0){if(i>8||C(e))return s;if(typeof e=="number")return Number.isFinite(e)&&s.push(e),s;if(typeof e=="string"){const t=Number(e);return e.trim()!==""&&Number.isFinite(t)&&s.push(t),s}if(Array.isArray(e)){for(const t of e)U(t,s,i+1);return s}if(typeof e=="object")for(const t of Object.keys(e))U(e[t],s,i+1);return s}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,s,i,t){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(s)||e===":"&&/\d/.test(s)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(t))}function T(e){const s=[];if(typeof e!="string"||e==="")return s;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let t;for(;(t=i.exec(e))!==null;){const[,d,,p,k,o]=t,a=t.index+d.length,f=t.index+t[0].length,b=t.index>0?e[t.index-1]:"",S=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(d,b,S,N))continue;const E=p.replace(/,/g,"");let D=Number(E);if(!Number.isFinite(D))continue;const A=K(E);o&&Object.prototype.hasOwnProperty.call(te,o)&&(D*=te[o]),s.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:o||""})}return s}function x(e){return e===" "||e===" "||e===`
7
7
  `||e==="\r"}function W(e){const s=[],i=[];for(let t=0;t<e.length;t+=1)if(e[t]==="(")i.push(t);else if(e[t]===")"&&i.length){const d=i.pop();i.length===0&&s.push({start:d,end:t+1})}return s}function g(e){const s=[],i=e.length;let t=0,d=0;for(;d<i;){const p=e[d],k=p==="."||p==="!"||p==="?",o=d+1>=i||x(e[d+1]);if(k&&o||p===`
8
8
  `){let a=d+1;for(;a<i&&(e[a]==="."||e[a]==="!"||e[a]==="?");)a+=1;for(;a<i&&x(e[a]);)a+=1;s.push({start:t,end:a}),t=a,d=a;continue}d+=1}return t<i&&s.push({start:t,end:i}),s}function r(e){const s=e.slice().sort((t,d)=>t.start-d.start),i=[];for(const t of s){const d=i[i.length-1];d&&t.start<=d.end?d.end=Math.max(d.end,t.end):i.push({start:t.start,end:t.end})}return i}function n(e){return e.replace(/\(\s*\)/g,"").replace(/[ \t]{2,}/g," ").replace(/[ \t]+([,.;:!?)])/g,"$1").replace(/([([])[ \t]+/g,"$1").replace(/(^|[.!?\n])[ \t]*[.;:,!?]+(?=[ \t]|$|\n)/g,"$1").replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
9
9
  `).replace(/\n{3,}/g,`
package/modules/ai.min.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, ai module
2
+ * Lattice Grid 1.71.3, ai module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- (function(Oe){"use strict";var we=Object.create(null),ve=Object.create(null);function fe(h,V){we[h]=V}function ke(h){var V=ve[h];if(V)return V;var m=Object.create(null);ve[h]=m;var C=we[h];if(!C)throw new Error("[lattice] missing module: "+h);return C(m,ke),m}fe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return M}}),Object.defineProperty(h,"reportedWarnings",{enumerable:!0,get:function(){return te}}),Object.defineProperty(h,"warnOnce",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(h,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"resetWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(h,"fail",{enumerable:!0,get:function(){return W}}),Object.defineProperty(h,"invariant",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return r}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"isFunction",{enumerable:!0,get:function(){return c}}),Object.defineProperty(h,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(h,"isBlank",{enumerable:!0,get:function(){return e}}),Object.defineProperty(h,"isCtor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(h,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(h,"collator",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(h,"defaultCompare",{enumerable:!0,get:function(){return l}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return se}});const m="1.71.1";async function C(){return m}const M="1.71.1",q=new Set,R=2e3;function _(y){if(q.add(y),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(y,w,P){K.push({key:y,level:w,message:P.map(H=>typeof H=="string"?H:U(H)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function U(y){if(y instanceof Error)return y.message;try{return JSON.stringify(y)}catch{return String(y)}}function te(){return K.map(y=>({...y}))}function ne(y,...w){q.has(y)||(_(y),Q(y,"warn",w),console.warn("[lattice]",...w))}function T(y,...w){q.has(y)||(_(y),Q(y,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(y,w){const P=new Error(`[lattice] ${y}`);throw w!==void 0&&(P.cause=w),P}function g(y,w){y||W(w)}const r=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(y){return y!==null&&typeof y=="object"&&!Array.isArray(y)}function c(y){return typeof y=="function"}function u(y){return y==null}function e(y){return y==null||y===""}function s(y){return typeof y!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(y))?!0:!!(y.prototype&&Object.getOwnPropertyNames(y.prototype).length>1)}const i=new Map;function t(y){let w=i.get(y);if(w)return w;if(!y.includes("."))w=P=>P?.[y];else{const P=y.split("."),H=P.length;w=le=>{let ue=le;for(let de=0;de<H;de++){if(ue==null)return;ue=ue[P[de]]}return ue}}return i.set(y,w),w}const d=new Map;function p(y){let w=d.get(y);if(w)return w;if(!y.includes("."))w=(P,H)=>{P!=null&&(P[y]=H)};else{const P=y.split("."),H=P.length-1;w=(le,ue)=>{let de=le;for(let ce=0;ce<H;ce++){if(de==null)return;const Y=P[ce];de[Y]==null&&(de[Y]={}),de=de[Y]}de!=null&&(de[P[H]]=ue)}}return d.set(y,w),w}function k(y,w){return t(w)(y)}function o(y,w,P){p(w)(y,P)}function a(y){return y?(y.includes(".")?y.slice(y.lastIndexOf(".")+1):y).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(/^./,P=>P.toUpperCase()):""}const f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(y){const w=y==null?"":String(y);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,P=>f[P]):w}function S(y){return String(y).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(y,w,P){if(y!==void 0)return y===!0?{enabled:!0,...P}:y===!1?{enabled:!1}:n(y)?y:{[w]:y,enabled:!0}}function E(y){return y==null?[]:Array.isArray(y)?y:[y]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(y,w){if(!n(y))return n(w)?{...w}:w;if(!n(w))return w===void 0?y:w;const P={...y};for(const H of Object.keys(w)){if(D.has(H))continue;const le=w[H];le!==void 0&&(P[H]=n(le)&&n(P[H])?A(P[H],le):le)}return P}function B(y,w){if(!n(y)||!n(w)||y===w)return w;const P=Object.create(Object.getPrototypeOf(y));return Object.assign(P,y,w),P}class X{#t;#e=new Map;#n;constructor(w=256,P=null){this.#t=w,this.#n=P}get size(){return this.#e.size}get max(){return this.#t}set max(w){this.#t=w,this.#r()}has(w){return this.#e.has(w)}get(w){const P=this.#e;if(!P.has(w))return;const H=P.get(w);return P.delete(w),P.set(w,H),H}peek(w){return this.#e.get(w)}set(w,P){const H=this.#e;return H.has(w)&&H.delete(w),H.set(w,P),this.#r(),P}delete(w){const P=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n(P,w),P}clear(){if(this.#n)for(const[w,P]of this.#e)this.#n(P,w);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const w=this.#e;for(;w.size>this.#t;){const P=w.keys().next().value,H=w.get(P);w.delete(P),this.#n&&this.#n(H,P)}}}const J=new Map;function oe(y,w){const P=`${y||""}|${w?JSON.stringify(w):""}`;let H=J.get(P);return H||(H=new Intl.Collator(y||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set(P,H)),H}function l(y,w){if(y===w)return 0;if(y==null)return 1;if(w==null)return-1;if(typeof y=="number"&&typeof w=="number")return Number.isNaN(y)?Number.isNaN(w)?0:1:Number.isNaN(w)||y<w?-1:y>w?1:0;const P=String(y),H=String(w);return P<H?-1:P>H?1:0}function O(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function $(y){return v?requestAnimationFrame(y):setTimeout(()=>y(O()),16)}function F(y){y!=null&&(v?cancelAnimationFrame(y):clearTimeout(y))}function j(y){let w=null,P=null;const H=()=>{w=null;const ue=P;P=null,y(...ue||[])},le=(...ue)=>{P=ue,w===null&&(w=$(H))};return le.cancel=()=>{F(w),w=null,P=null},le.flush=()=>{w!==null&&(F(w),H())},le}function L(y,w){let P=null,H=null;const le=()=>{if(P=null,H===null)return;const ce=H;H=null,y(...ce),ue()},ue=()=>{P=setTimeout(le,w),typeof P?.unref=="function"&&P.unref()},de=(...ce)=>{P===null?(y(...ce),ue()):(H=ce,clearTimeout(P),ue())};return de.flush=()=>{if(P!==null&&clearTimeout(P),P=null,H===null)return;const ce=H;H=null,y(...ce)},de.cancel=()=>{P!==null&&clearTimeout(P),P=null,H=null},de.pending=()=>P!==null||H!==null,de}function z(y,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(y,{timeout:w}):setTimeout(()=>y({timeRemaining:()=>0,didTimeout:!0}),1)}let Z=0;function se(y="l"){return`${y}${(++Z).toString(36)}`}}),fe("packages/modules/ai/reconcile.js",function(h,V){"use strict";Object.defineProperty(h,"UNVERIFIED",{enumerable:!0,get:function(){return R}}),Object.defineProperty(h,"formsOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(h,"buildRegistry",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(h,"collectNumbers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const C=V("packages/core/src/internal/util.js").isNil,M=1e-6,q=4,R="[unverified]";function _(e,s){const i=10**s,t=Math.round(e*i)/i;return t===0?0:t}function K(e){const s=e.indexOf(".");return s<0?0:Math.min(e.length-s-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const s=new Set([e]);for(let i=0;i<=q;i+=1)s.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let t=0;t<=q;t+=1)s.add(_(i,t))}return[...s]}function Q(e){const s=new Set,i=[];for(const d of e)if(Number.isFinite(d)){i.push(d);for(const p of G(d))s.add(p)}const t=[...s];return{size:i.length,values:i,has(d,p){for(const k of t)if(Math.abs(k-d)<=M||_(k,p)===d)return!0;return!1}}}function U(e,s=[],i=0){if(i>8||C(e))return s;if(typeof e=="number")return Number.isFinite(e)&&s.push(e),s;if(typeof e=="string"){const t=Number(e);return e.trim()!==""&&Number.isFinite(t)&&s.push(t),s}if(Array.isArray(e)){for(const t of e)U(t,s,i+1);return s}if(typeof e=="object")for(const t of Object.keys(e))U(e[t],s,i+1);return s}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,s,i,t){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(s)||e===":"&&/\d/.test(s)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(t))}function T(e){const s=[];if(typeof e!="string"||e==="")return s;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let t;for(;(t=i.exec(e))!==null;){const[,d,,p,k,o]=t,a=t.index+d.length,f=t.index+t[0].length,b=t.index>0?e[t.index-1]:"",S=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(d,b,S,N))continue;const E=p.replace(/,/g,"");let D=Number(E);if(!Number.isFinite(D))continue;const A=K(E);o&&Object.prototype.hasOwnProperty.call(te,o)&&(D*=te[o]),s.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:o||""})}return s}function x(e){return e===" "||e===" "||e===`
6
+ (function(Oe){"use strict";var we=Object.create(null),ve=Object.create(null);function fe(h,V){we[h]=V}function ke(h){var V=ve[h];if(V)return V;var m=Object.create(null);ve[h]=m;var C=we[h];if(!C)throw new Error("[lattice] missing module: "+h);return C(m,ke),m}fe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return M}}),Object.defineProperty(h,"reportedWarnings",{enumerable:!0,get:function(){return te}}),Object.defineProperty(h,"warnOnce",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(h,"infoOnce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"resetWarnings",{enumerable:!0,get:function(){return x}}),Object.defineProperty(h,"fail",{enumerable:!0,get:function(){return W}}),Object.defineProperty(h,"invariant",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return r}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"isFunction",{enumerable:!0,get:function(){return c}}),Object.defineProperty(h,"isNil",{enumerable:!0,get:function(){return u}}),Object.defineProperty(h,"isBlank",{enumerable:!0,get:function(){return e}}),Object.defineProperty(h,"isCtor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return b}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return B}}),Object.defineProperty(h,"Lru",{enumerable:!0,get:function(){return X}}),Object.defineProperty(h,"collator",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(h,"defaultCompare",{enumerable:!0,get:function(){return l}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return L}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return z}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return se}});const m="1.71.3";async function C(){return m}const M="1.71.3",q=new Set,R=2e3;function _(y){if(q.add(y),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(y,w,P){K.push({key:y,level:w,message:P.map(H=>typeof H=="string"?H:U(H)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function U(y){if(y instanceof Error)return y.message;try{return JSON.stringify(y)}catch{return String(y)}}function te(){return K.map(y=>({...y}))}function ne(y,...w){q.has(y)||(_(y),Q(y,"warn",w),console.warn("[lattice]",...w))}function T(y,...w){q.has(y)||(_(y),Q(y,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(y,w){const P=new Error(`[lattice] ${y}`);throw w!==void 0&&(P.cause=w),P}function g(y,w){y||W(w)}const r=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function n(y){return y!==null&&typeof y=="object"&&!Array.isArray(y)}function c(y){return typeof y=="function"}function u(y){return y==null}function e(y){return y==null||y===""}function s(y){return typeof y!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(y))?!0:!!(y.prototype&&Object.getOwnPropertyNames(y.prototype).length>1)}const i=new Map;function t(y){let w=i.get(y);if(w)return w;if(!y.includes("."))w=P=>P?.[y];else{const P=y.split("."),H=P.length;w=le=>{let ue=le;for(let de=0;de<H;de++){if(ue==null)return;ue=ue[P[de]]}return ue}}return i.set(y,w),w}const d=new Map;function p(y){let w=d.get(y);if(w)return w;if(!y.includes("."))w=(P,H)=>{P!=null&&(P[y]=H)};else{const P=y.split("."),H=P.length-1;w=(le,ue)=>{let de=le;for(let ce=0;ce<H;ce++){if(de==null)return;const Y=P[ce];de[Y]==null&&(de[Y]={}),de=de[Y]}de!=null&&(de[P[H]]=ue)}}return d.set(y,w),w}function k(y,w){return t(w)(y)}function o(y,w,P){p(w)(y,P)}function a(y){return y?(y.includes(".")?y.slice(y.lastIndexOf(".")+1):y).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(/^./,P=>P.toUpperCase()):""}const f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function b(y){const w=y==null?"":String(y);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,P=>f[P]):w}function S(y){return String(y).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(y,w,P){if(y!==void 0)return y===!0?{enabled:!0,...P}:y===!1?{enabled:!1}:n(y)?y:{[w]:y,enabled:!0}}function E(y){return y==null?[]:Array.isArray(y)?y:[y]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(y,w){if(!n(y))return n(w)?{...w}:w;if(!n(w))return w===void 0?y:w;const P={...y};for(const H of Object.keys(w)){if(D.has(H))continue;const le=w[H];le!==void 0&&(P[H]=n(le)&&n(P[H])?A(P[H],le):le)}return P}function B(y,w){if(!n(y)||!n(w)||y===w)return w;const P=Object.create(Object.getPrototypeOf(y));return Object.assign(P,y,w),P}class X{#t;#e=new Map;#n;constructor(w=256,P=null){this.#t=w,this.#n=P}get size(){return this.#e.size}get max(){return this.#t}set max(w){this.#t=w,this.#r()}has(w){return this.#e.has(w)}get(w){const P=this.#e;if(!P.has(w))return;const H=P.get(w);return P.delete(w),P.set(w,H),H}peek(w){return this.#e.get(w)}set(w,P){const H=this.#e;return H.has(w)&&H.delete(w),H.set(w,P),this.#r(),P}delete(w){const P=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n(P,w),P}clear(){if(this.#n)for(const[w,P]of this.#e)this.#n(P,w);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const w=this.#e;for(;w.size>this.#t;){const P=w.keys().next().value,H=w.get(P);w.delete(P),this.#n&&this.#n(H,P)}}}const J=new Map;function oe(y,w){const P=`${y||""}|${w?JSON.stringify(w):""}`;let H=J.get(P);return H||(H=new Intl.Collator(y||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set(P,H)),H}function l(y,w){if(y===w)return 0;if(y==null)return 1;if(w==null)return-1;if(typeof y=="number"&&typeof w=="number")return Number.isNaN(y)?Number.isNaN(w)?0:1:Number.isNaN(w)||y<w?-1:y>w?1:0;const P=String(y),H=String(w);return P<H?-1:P>H?1:0}function O(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const v=typeof requestAnimationFrame=="function";function $(y){return v?requestAnimationFrame(y):setTimeout(()=>y(O()),16)}function F(y){y!=null&&(v?cancelAnimationFrame(y):clearTimeout(y))}function j(y){let w=null,P=null;const H=()=>{w=null;const ue=P;P=null,y(...ue||[])},le=(...ue)=>{P=ue,w===null&&(w=$(H))};return le.cancel=()=>{F(w),w=null,P=null},le.flush=()=>{w!==null&&(F(w),H())},le}function L(y,w){let P=null,H=null;const le=()=>{if(P=null,H===null)return;const ce=H;H=null,y(...ce),ue()},ue=()=>{P=setTimeout(le,w),typeof P?.unref=="function"&&P.unref()},de=(...ce)=>{P===null?(y(...ce),ue()):(H=ce,clearTimeout(P),ue())};return de.flush=()=>{if(P!==null&&clearTimeout(P),P=null,H===null)return;const ce=H;H=null,y(...ce)},de.cancel=()=>{P!==null&&clearTimeout(P),P=null,H=null},de.pending=()=>P!==null||H!==null,de}function z(y,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(y,{timeout:w}):setTimeout(()=>y({timeRemaining:()=>0,didTimeout:!0}),1)}let Z=0;function se(y="l"){return`${y}${(++Z).toString(36)}`}}),fe("packages/modules/ai/reconcile.js",function(h,V){"use strict";Object.defineProperty(h,"UNVERIFIED",{enumerable:!0,get:function(){return R}}),Object.defineProperty(h,"formsOf",{enumerable:!0,get:function(){return G}}),Object.defineProperty(h,"buildRegistry",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(h,"collectNumbers",{enumerable:!0,get:function(){return U}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const C=V("packages/core/src/internal/util.js").isNil,M=1e-6,q=4,R="[unverified]";function _(e,s){const i=10**s,t=Math.round(e*i)/i;return t===0?0:t}function K(e){const s=e.indexOf(".");return s<0?0:Math.min(e.length-s-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const s=new Set([e]);for(let i=0;i<=q;i+=1)s.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let t=0;t<=q;t+=1)s.add(_(i,t))}return[...s]}function Q(e){const s=new Set,i=[];for(const d of e)if(Number.isFinite(d)){i.push(d);for(const p of G(d))s.add(p)}const t=[...s];return{size:i.length,values:i,has(d,p){for(const k of t)if(Math.abs(k-d)<=M||_(k,p)===d)return!0;return!1}}}function U(e,s=[],i=0){if(i>8||C(e))return s;if(typeof e=="number")return Number.isFinite(e)&&s.push(e),s;if(typeof e=="string"){const t=Number(e);return e.trim()!==""&&Number.isFinite(t)&&s.push(t),s}if(Array.isArray(e)){for(const t of e)U(t,s,i+1);return s}if(typeof e=="object")for(const t of Object.keys(e))U(e[t],s,i+1);return s}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,s,i,t){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(s)||e===":"&&/\d/.test(s)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(t))}function T(e){const s=[];if(typeof e!="string"||e==="")return s;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let t;for(;(t=i.exec(e))!==null;){const[,d,,p,k,o]=t,a=t.index+d.length,f=t.index+t[0].length,b=t.index>0?e[t.index-1]:"",S=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(d,b,S,N))continue;const E=p.replace(/,/g,"");let D=Number(E);if(!Number.isFinite(D))continue;const A=K(E);o&&Object.prototype.hasOwnProperty.call(te,o)&&(D*=te[o]),s.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:o||""})}return s}function x(e){return e===" "||e===" "||e===`
7
7
  `||e==="\r"}function W(e){const s=[],i=[];for(let t=0;t<e.length;t+=1)if(e[t]==="(")i.push(t);else if(e[t]===")"&&i.length){const d=i.pop();i.length===0&&s.push({start:d,end:t+1})}return s}function g(e){const s=[],i=e.length;let t=0,d=0;for(;d<i;){const p=e[d],k=p==="."||p==="!"||p==="?",o=d+1>=i||x(e[d+1]);if(k&&o||p===`
8
8
  `){let a=d+1;for(;a<i&&(e[a]==="."||e[a]==="!"||e[a]==="?");)a+=1;for(;a<i&&x(e[a]);)a+=1;s.push({start:t,end:a}),t=a,d=a;continue}d+=1}return t<i&&s.push({start:t,end:i}),s}function r(e){const s=e.slice().sort((t,d)=>t.start-d.start),i=[];for(const t of s){const d=i[i.length-1];d&&t.start<=d.end?d.end=Math.max(d.end,t.end):i.push({start:t.start,end:t.end})}return i}function n(e){return e.replace(/\(\s*\)/g,"").replace(/[ \t]{2,}/g," ").replace(/[ \t]+([,.;:!?)])/g,"$1").replace(/([([])[ \t]+/g,"$1").replace(/(^|[.!?\n])[ \t]*[.;:,!?]+(?=[ \t]|$|\n)/g,"$1").replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
9
9
  `).replace(/\n{3,}/g,`
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, alarms module type declarations
2
+ * Lattice Grid 1.71.3, alarms module type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, alarms module
2
+ * Lattice Grid 1.71.3, alarms module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var ce=Object.create(null),le=Object.create(null);function ue(d,K){ce[d]=K}function ae(d){var K=le[d];if(K)return K;var E=Object.create(null);le[d]=E;var x=ce[d];if(!x)throw new Error("[lattice] missing module: "+d);return x(E,ae),E}ue("packages/core/src/internal/util.js",function(d,K){"use strict";Object.defineProperty(d,"VERSION",{enumerable:!0,get:function(){return P}}),Object.defineProperty(d,"reportedWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"warnOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"infoOnce",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resetWarnings",{enumerable:!0,get:function(){return T}}),Object.defineProperty(d,"fail",{enumerable:!0,get:function(){return $}}),Object.defineProperty(d,"invariant",{enumerable:!0,get:function(){return U}}),Object.defineProperty(d,"DEV",{enumerable:!0,get:function(){return w}}),Object.defineProperty(d,"isObject",{enumerable:!0,get:function(){return y}}),Object.defineProperty(d,"isFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(d,"isNil",{enumerable:!0,get:function(){return A}}),Object.defineProperty(d,"isBlank",{enumerable:!0,get:function(){return D}}),Object.defineProperty(d,"isCtor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(d,"pathGetter",{enumerable:!0,get:function(){return q}}),Object.defineProperty(d,"pathSetter",{enumerable:!0,get:function(){return J}}),Object.defineProperty(d,"getPath",{enumerable:!0,get:function(){return _}}),Object.defineProperty(d,"setPath",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(d,"escapeHtml",{enumerable:!0,get:function(){return re}}),Object.defineProperty(d,"titleCase",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(d,"expand",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(d,"toArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(d,"merge",{enumerable:!0,get:function(){return l}}),Object.defineProperty(d,"mergeRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(d,"Lru",{enumerable:!0,get:function(){return m}}),Object.defineProperty(d,"collator",{enumerable:!0,get:function(){return u}}),Object.defineProperty(d,"defaultCompare",{enumerable:!0,get:function(){return c}}),Object.defineProperty(d,"now",{enumerable:!0,get:function(){return a}}),Object.defineProperty(d,"nextFrame",{enumerable:!0,get:function(){return p}}),Object.defineProperty(d,"cancelFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(d,"frameBatched",{enumerable:!0,get:function(){return O}}),Object.defineProperty(d,"settleDebounce",{enumerable:!0,get:function(){return I}}),Object.defineProperty(d,"whenIdle",{enumerable:!0,get:function(){return C}}),Object.defineProperty(d,"uid",{enumerable:!0,get:function(){return oe}});const E="1.71.1";async function x(){return E}const P="1.71.1",W=new Set,Y=2e3;function X(n){if(W.add(n),W.size>Y){const i=W.values().next().value;i!==void 0&&W.delete(i)}}const k=[],H=500;function L(n,i,s){k.push({key:n,level:i,message:s.map(h=>typeof h=="string"?h:g(h)).join(" "),at:Date.now()}),k.length>H&&k.shift()}function g(n){if(n instanceof Error)return n.message;try{return JSON.stringify(n)}catch{return String(n)}}function S(){return k.map(n=>({...n}))}function b(n,...i){W.has(n)||(X(n),L(n,"warn",i),console.warn("[lattice]",...i))}function j(n,...i){W.has(n)||(X(n),L(n,"info",i),console.info("[lattice]",...i))}function T(){W.clear(),k.length=0}function $(n,i){const s=new Error(`[lattice] ${n}`);throw i!==void 0&&(s.cause=i),s}function U(n,i){n||$(i)}const w=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function y(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return typeof n=="function"}function A(n){return n==null}function D(n){return n==null||n===""}function F(n){return typeof n!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(n))?!0:!!(n.prototype&&Object.getOwnPropertyNames(n.prototype).length>1)}const M=new Map;function q(n){let i=M.get(n);if(i)return i;if(!n.includes("."))i=s=>s?.[n];else{const s=n.split("."),h=s.length;i=V=>{let G=V;for(let z=0;z<h;z++){if(G==null)return;G=G[s[z]]}return G}}return M.set(n,i),i}const R=new Map;function J(n){let i=R.get(n);if(i)return i;if(!n.includes("."))i=(s,h)=>{s!=null&&(s[n]=h)};else{const s=n.split("."),h=s.length-1;i=(V,G)=>{let z=V;for(let Z=0;Z<h;Z++){if(z==null)return;const se=s[Z];z[se]==null&&(z[se]={}),z=z[se]}z!=null&&(z[s[h]]=G)}}return R.set(n,i),i}function _(n,i){return q(i)(n)}function ee(n,i,s){J(i)(n,s)}function te(n){return n?(n.includes(".")?n.slice(n.lastIndexOf(".")+1):n).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(/^./,s=>s.toUpperCase()):""}const ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function re(n){const i=n==null?"":String(n);return/[&<>"']/.test(i)?i.replace(/[&<>"']/g,s=>ne[s]):i}function Q(n){return String(n).replace(/\w\S*/g,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())}function ie(n,i,s){if(n!==void 0)return n===!0?{enabled:!0,...s}:n===!1?{enabled:!1}:y(n)?n:{[i]:n,enabled:!0}}function t(n){return n==null?[]:Array.isArray(n)?n:[n]}const r=Object.freeze(new Set(["__proto__","constructor","prototype"]));function l(n,i){if(!y(n))return y(i)?{...i}:i;if(!y(i))return i===void 0?n:i;const s={...n};for(const h of Object.keys(i)){if(r.has(h))continue;const V=i[h];V!==void 0&&(s[h]=y(V)&&y(s[h])?l(s[h],V):V)}return s}function o(n,i){if(!y(n)||!y(i)||n===i)return i;const s=Object.create(Object.getPrototypeOf(n));return Object.assign(s,n,i),s}class m{#t;#e=new Map;#n;constructor(i=256,s=null){this.#t=i,this.#n=s}get size(){return this.#e.size}get max(){return this.#t}set max(i){this.#t=i,this.#r()}has(i){return this.#e.has(i)}get(i){const s=this.#e;if(!s.has(i))return;const h=s.get(i);return s.delete(i),s.set(i,h),h}peek(i){return this.#e.get(i)}set(i,s){const h=this.#e;return h.has(i)&&h.delete(i),h.set(i,s),this.#r(),s}delete(i){const s=this.#e.get(i);return this.#e.delete(i)&&this.#n&&this.#n(s,i),s}clear(){if(this.#n)for(const[i,s]of this.#e)this.#n(s,i);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const i=this.#e;for(;i.size>this.#t;){const s=i.keys().next().value,h=i.get(s);i.delete(s),this.#n&&this.#n(h,s)}}}const e=new Map;function u(n,i){const s=`${n||""}|${i?JSON.stringify(i):""}`;let h=e.get(s);return h||(h=new Intl.Collator(n||void 0,{numeric:!0,sensitivity:"variant",...i}),e.set(s,h)),h}function c(n,i){if(n===i)return 0;if(n==null)return 1;if(i==null)return-1;if(typeof n=="number"&&typeof i=="number")return Number.isNaN(n)?Number.isNaN(i)?0:1:Number.isNaN(i)||n<i?-1:n>i?1:0;const s=String(n),h=String(i);return s<h?-1:s>h?1:0}function a(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const f=typeof requestAnimationFrame=="function";function p(n){return f?requestAnimationFrame(n):setTimeout(()=>n(a()),16)}function N(n){n!=null&&(f?cancelAnimationFrame(n):clearTimeout(n))}function O(n){let i=null,s=null;const h=()=>{i=null;const G=s;s=null,n(...G||[])},V=(...G)=>{s=G,i===null&&(i=p(h))};return V.cancel=()=>{N(i),i=null,s=null},V.flush=()=>{i!==null&&(N(i),h())},V}function I(n,i){let s=null,h=null;const V=()=>{if(s=null,h===null)return;const Z=h;h=null,n(...Z),G()},G=()=>{s=setTimeout(V,i),typeof s?.unref=="function"&&s.unref()},z=(...Z)=>{s===null?(n(...Z),G()):(h=Z,clearTimeout(s),G())};return z.flush=()=>{if(s!==null&&clearTimeout(s),s=null,h===null)return;const Z=h;h=null,n(...Z)},z.cancel=()=>{s!==null&&clearTimeout(s),s=null,h=null},z.pending=()=>s!==null||h!==null,z}function C(n,i=50){return typeof requestIdleCallback=="function"?requestIdleCallback(n,{timeout:i}):setTimeout(()=>n({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function oe(n="l"){return`${n}${(++B).toString(36)}`}}),ue("packages/core/src/formatting/rules.js",function(d,K){"use strict";Object.defineProperty(d,"RULE_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(d,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(d,"testRule",{enumerable:!0,get:function(){return L}}),Object.defineProperty(d,"mixColour",{enumerable:!0,get:function(){return g}}),Object.defineProperty(d,"summariseColumn",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"needsDistribution",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resolveDistribution",{enumerable:!0,get:function(){return w}}),Object.defineProperty(d,"ICON_SETS",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"compileRules",{enumerable:!0,get:function(){return ie}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),Y=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function k(t,r){const l=Number(t),o=Number(r);if(t!==null&&t!==""&&r!==null&&r!==""&&Number.isFinite(l)&&Number.isFinite(o))return l<o?-1:l>o?1:0;const e=String(t??"").toLowerCase(),u=String(r??"").toLowerCase();return e<u?-1:e>u?1:0}function H(t){return t==null||t===""}function L(t,r){if(!r||typeof r!="object")return!1;const{op:l}=r,o=r.value,m=r.value2;switch(l){case"blank":return H(t);case"notBlank":return!H(t);case"true":return t===!0;case"false":return t===!1;default:break}if(H(t))return!1;switch(l){case"eq":return k(t,o)===0;case"ne":return k(t,o)!==0;case"gt":return k(t,o)>0;case"gte":return k(t,o)>=0;case"lt":return k(t,o)<0;case"lte":return k(t,o)<=0;case"between":return k(t,o)>=0&&k(t,m)<=0;case"outside":return k(t,o)<0||k(t,m)>0;case"contains":return String(t).toLowerCase().includes(String(o??"").toLowerCase());case"notContains":return!String(t).toLowerCase().includes(String(o??"").toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(o??"").toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(o??"").toLowerCase());default:return!1}}function g(t,r,l){const o=O=>{const I=String(O).replace("#",""),C=I.length===3?I.split("").map(B=>B+B).join(""):I;return[0,2,4].map(B=>parseInt(C.slice(B,B+2),16)||0)},[m,e,u]=o(t),[c,a,f]=o(r),p=Math.max(0,Math.min(1,l)),N=(O,I)=>Math.round(O+(I-O)*p);return`#${[N(m,c),N(e,a),N(u,f)].map(O=>O.toString(16).padStart(2,"0")).join("")}`}function S(t){const r=[];for(const c of t||[]){if(c==null||c==="")continue;const a=c instanceof Date?c.getTime():Number(c);Number.isFinite(a)&&r.push(a)}if(!r.length)return null;r.sort((c,a)=>c-a);let l=0,o=0,m=0;for(const c of r){l++;const a=c-o;o+=a/l,m+=a*(c-o)}const e=b(r,.25),u=b(r,.75);return{n:r.length,min:r[0],max:r[r.length-1],mean:o,stddev:r.length>1?Math.sqrt(m/(r.length-1)):0,median:b(r,.5),q1:e,q3:u,iqr:u-e,sorted:r}}function b(t,r){if(!t.length)return 0;const l=(t.length-1)*Math.max(0,Math.min(1,r)),o=Math.floor(l),m=Math.ceil(l);return o===m?t[o]:t[o]+(l-o)*(t[m]-t[o])}function j(t){for(const r of Array.isArray(t)?t:[])if(!(!r||typeof r!="object")&&(r.when&&Y.includes(r.when.op)||r.scale&&r.scale.from||r.dataBar&&!(Number.isFinite(Number(r.dataBar.min))&&Number.isFinite(Number(r.dataBar.max)))||r.iconSet&&!Array.isArray(r.iconSet.thresholds)))return!0;return!1}function T(t,r){const l=Number(t.value),o=m=>b(r.sorted,m);switch(t.op){case"topPercent":{const m=$(l,10);return{op:"gte",value:o(1-m)}}case"bottomPercent":{const m=$(l,10);return{op:"lte",value:o(m)}}case"topN":{const m=Math.max(1,Math.floor(l)||1),e=Math.max(0,r.sorted.length-m);return{op:"gte",value:r.sorted[e]}}case"bottomN":{const m=Math.max(1,Math.floor(l)||1),e=Math.min(r.sorted.length-1,m-1);return{op:"lte",value:r.sorted[e]}}case"aboveMean":return{op:"gt",value:r.mean};case"belowMean":return{op:"lt",value:r.mean};case"aboveMedian":return{op:"gt",value:r.median};case"belowMedian":return{op:"lt",value:r.median};case"zAbove":return r.stddev?{op:"gte",value:r.mean+(Number.isFinite(l)?l:2)*r.stddev}:null;case"zBelow":return r.stddev?{op:"lte",value:r.mean-(Number.isFinite(l)?l:2)*r.stddev}:null;case"outlier":{const m=(Number.isFinite(l)&&l>0?l:1.5)*r.iqr;return r.iqr?{op:"outside",value:r.q1-m,value2:r.q3+m}:null}default:return null}}function $(t,r){const l=Number.isFinite(t)?t:r,o=l>1?l/100:l;return Math.max(0,Math.min(1,o))}function U(t,r){if(t.from==="minmax")return{...t,min:r.min,max:r.max};if(t.from==="quantile")return{...t,min:b(r.sorted,$(Number(t.low),5)),max:b(r.sorted,$(Number(t.high),95))};if(t.from==="stddev"){const l=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:r.mean-l*r.stddev,max:r.mean+l*r.stddev}}return t}function w(t,r){const l=Array.isArray(t)?t:[];return!r||!r.n?l.map(o=>o&&j([o])?{...o,enabled:!1}:o):l.map(o=>{if(!o||typeof o!="object")return o;if(o.scale&&o.scale.from)return{...o,scale:U(o.scale,r)};if(o.dataBar)return{...o,dataBar:y(o.dataBar,r)};if(o.iconSet)return{...o,iconSet:v(o.iconSet,r)};if(!o.when||!Y.includes(o.when.op))return o;const m=T(o.when,r);return m?{...o,when:m}:{...o,enabled:!1}})}function y(t,r){const l=Number.isFinite(Number(t.min))?Number(t.min):void 0,o=Number.isFinite(Number(t.max))?Number(t.max):void 0;if(l!==void 0&&o!==void 0)return{...t,min:l,max:o};if(t.from==="quantile")return{...t,min:l??b(r.sorted,$(Number(t.low),5)),max:o??b(r.sorted,$(Number(t.high),95))};if(t.from==="stddev"){const m=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:l??r.mean-m*r.stddev,max:o??r.mean+m*r.stddev}}return{...t,min:l??r.min,max:o??r.max}}function v(t,r){if(Array.isArray(t.thresholds))return t;const l=A(t),o=[];for(let m=1;m<l;m++)o.push(b(r.sorted,m/l));return{...t,thresholds:o}}function A(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.length;if(Number.isFinite(Number(t.count))&&Number(t.count)>=2)return Math.floor(Number(t.count));const r=_[t.set];return r?r.length:3}function D(t){return`url("data:image/svg+xml,${encodeURIComponent(t)}")`}function F(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${t}"/></svg>`}function M(t,r){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${r==="up"?"8,2 14,13 2,13":r==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${t}"/></svg>`}function q(t,r){const l="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let o=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r*16} 16">`;for(let m=0;m<r;m++){const e=m<t?"#f5a623":"#d0d0d0";o+=`<path transform="translate(${m*16},0)" d="${l}" fill="${e}"/>`}return`${o}</svg>`}const R=Object.freeze([M("#c0392b","down"),M("#e0a800","right"),M("#2e7d32","up")]),J=Object.freeze([F("#d13438"),F("#f5a623"),F("#2e9e44")]),_=Object.freeze({arrows:R,trafficLights:J,ratings:Object.freeze([1,2,3,4,5].map(t=>q(t,5)))}),ee=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function te(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.map(o=>/^\s*(url\(|data:|<)/.test(String(o))&&String(o).trim().startsWith("<")?D(String(o)):String(o));const r=t.set||"arrows";if(r==="ratings"){const o=A(t),m=[];for(let e=1;e<=o;e++)m.push(D(q(e,o)));return m}const l=_[r];return l?l.map(D):(P(`iconSet:${r}`,`unknown icon set '${r}'; falling back to arrows.`),R.map(D))}function ne(t){const r=Number(t.min),o=Number(t.max)-r,m=t.colour||t.color||"#5b9bd5",e=t.negativeColour||t.negativeColor||"#d13438",u=t.direction==="rtl"?"left":"right",c=f=>Math.max(0,Math.min(1,(f-r)/o))*100,a=o?Math.max(0,Math.min(100,(0-r)/o*100)):0;return f=>{if(H(f))return null;const p=Number(f);if(!Number.isFinite(p)||!o)return null;const N=c(p),O=Math.min(N,a),I=Math.max(N,a),C=p>=0?m:e;return{backgroundImage:`linear-gradient(to ${u}, transparent ${O}%, ${C} ${O}%, ${C} ${I}%, transparent ${I}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function re(t){const r=te(t),l=t.reverse?[...r].reverse():r,o=(Array.isArray(t.thresholds)?t.thresholds:[]).map(Number).filter(Number.isFinite),m=Number.isFinite(Number(t.size))?Number(t.size):16,e=t.set==="ratings"?m*A(t):m;return u=>{if(H(u))return null;const c=Number(u);if(!Number.isFinite(c))return null;let a=0;for(const p of o)c>=p&&a++;const f=l[Math.min(a,l.length-1)];return f?{backgroundImage:f,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${e}px ${m}px`,paddingLeft:`${e+4}px`}:null}}function Q(t){const r=Array.isArray(t.colours)&&t.colours.length>=2?t.colours:["#f8f9fa","#1a6bc7"],l=Number(t.min),o=Number(t.max),m=o-l,e=r.length-1,u=[];for(let a=0;a<=e;a++)u.push(e?a/e:0);const c=Number(t.mid);if(t.mid!==void 0&&t.mid!==null)if(r.length%2===0)P("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${r.length} were given, so "mid" was ignored.`);else if(Number.isFinite(c)&&m&&c>Math.min(l,o)&&c<Math.max(l,o)){const a=e/2,f=Math.max(0,Math.min(1,(c-l)/m));for(let p=0;p<=e;p++)u[p]=p<=a?a?p/a*f:f:f+(p-a)/(e-a)*(1-f)}else Number.isFinite(c)&&P("formatting.scale.mid.range",`a scale's "mid" (${c}) is outside its min..max range, so it was ignored.`);return a=>{const f=Number(a);if(!Number.isFinite(f)||!m)return null;const p=Math.max(0,Math.min(1,(f-l)/m));let N=0;for(;N<e-1&&p>u[N+1];)N++;const O=u[N+1]-u[N],I=O>0?(p-u[N])/O:0;return{background:g(r[N],r[N+1],Math.max(0,Math.min(1,I)))}}}function ie(t,r=null){const l=j(t)?w(t,r):t,o=(Array.isArray(l)?l:[]).filter(e=>e&&typeof e=="object");if(!o.length)return()=>null;const m=o.map(e=>e.scale?{scale:Q(e.scale),enabled:e.enabled!==!1}:e.dataBar?{scale:ne(e.dataBar),enabled:e.enabled!==!1}:e.iconSet?{scale:re(e.iconSet),enabled:e.enabled!==!1}:{when:e.when,style:e.style,stop:e.stopIfTrue!==!1,enabled:e.enabled!==!1});return e=>{const u=e?e.value:void 0;let c=null;for(const a of m){if(!a.enabled)continue;if(a.scale){const p=a.scale(u);p&&(c={...c||{},...p});continue}if(!L(u,a.when))continue;const f=x(a.style)?a.style(e):a.style;if(f&&(c={...c||{},...f}),a.stop)break}return c}}}),ue("packages/modules/shared/emitter.js",function(d,K){"use strict";Object.defineProperty(d,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"Emitter",{enumerable:!0,get:function(){return k}}),Object.defineProperty(d,"gate",{enumerable:!0,get:function(){return H}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W="*",Y=new Set(["api","user","init","ai"]);function X(L,g){return L&&L.name?L.name:`#${g}`}class k{#t=new Map;#e;constructor(g="module"){this.#e=String(g)}on(g,S){if(!x(S))return()=>{};let b=this.#t.get(g);return b||(b=new Set,this.#t.set(g,b)),b.add(S),()=>this.off(g,S)}off(g,S){const b=this.#t.get(g);b&&b.delete(S)}count(g){const S=this.#t.get(g);return S?S.size:0}emit(g,S){const b=this.#t.get(g),j=this.#t.get(W);if((!b||b.size===0)&&(!j||j.size===0))return;const T={...S||null,type:g};b&&b.size&&this.#n([...b],T,g),j&&j.size&&this.#n([...j],T,W)}#n(g,S,b){for(let j=0;j<g.length;j++)try{g[j](S)}catch(T){P(`${this.#e}.emit.throw:${b}:${X(g[j],j)}`,`${this.#e}: a '${b}' handler threw; other handlers were unaffected.`,T)}}emitBefore(g,S,b){const j=b??(S&&S.origin),T=Y.has(j)?j:"user";let $=!1,U=null;const w=M=>{$=!0,M!=null&&U===null&&(U=String(M))},y={...S||null,type:g,origin:T,get defaultPrevented(){return $},get reason(){return U},preventDefault(M){w(M)}},v=this.#t.get(g);if(!v||v.size===0)return!0;const A=[...v],D=()=>($&&U===null&&(U="prevented"),$&&S&&typeof S=="object"&&(S.reason=U),!$),F=[];for(let M=0;M<A.length;M++){const q=A[M];try{const R=q(y);R&&x(R.then)?F.push(R):R===!1&&w("prevented")}catch(R){w("error"),P(`${this.#e}.beforeThrow:${g}:${X(q,M)}`,`${this.#e}: a '${g}' before-handler threw; the action was cancelled.`,R)}}return F.length===0?D():Promise.allSettled(F).then(M=>{for(const q of M)q.status==="rejected"?(w("error"),P(`${this.#e}.beforeReject:${g}`,`${this.#e}: a '${g}' before-handler rejected; the action was cancelled.`,q.reason)):q.value===!1&&w("prevented");return D()})}clear(){this.#t.clear()}}function H(L,g,S,b,j){const T=L.emitBefore(g,b,b.origin),$=()=>(L.emit(S,{...b,reason:b.reason||"prevented"}),!1);return T===!1?$():T&&x(T.then)?T.then(U=>U?j():$()):j()}}),ue("packages/modules/alarms/index.js",function(d,K){"use strict";Object.defineProperty(d,"createAlarms",{enumerable:!0,get:function(){return $}}),Object.defineProperty(d,"default",{enumerable:!0,get:function(){return U}});const E=K("packages/core/src/internal/util.js"),x=E.warnOnce,P=E.isFunction,Y=K("packages/core/src/formatting/rules.js").testRule,k=K("packages/modules/shared/emitter.js").Emitter,H=Object.freeze(["alarm:raised","alarm:cleared"]),L=new Set(["warn","critical"]);function g(w){return typeof w=="string"&&L.has(w)}function S(w,y){if(typeof w!="number"||Number.isNaN(w))return null;if(Array.isArray(y&&y.bands)){for(const A of y.bands){const D=A.min===void 0||A.min===null?-1/0:A.min,F=A.max===void 0||A.max===null?1/0:A.max;if(w>=D&&w<F)return A.status??null}return null}const v=y&&y.thresholds;return!v||v.warn===void 0||v.warn===null||v.critical===void 0||v.critical===null?null:v.direction==="lowerIsBetter"?w<=v.warn?"good":w<=v.critical?"warn":"critical":w>=v.warn?"good":w>=v.critical?"warn":"critical"}function b(w){const y=w||{};return{now:P(y.now)?y.now:()=>Date.now(),setTimeout:P(y.setTimeout)?y.setTimeout:((v,A)=>setTimeout(v,A)),clearTimeout:P(y.clearTimeout)?y.clearTimeout:(v=>clearTimeout(v))}}function j(w,y){return Number.isFinite(w)&&Number(w)>=0?Number(w):y}function T(w,y){return`${typeof w=="string"?w:JSON.stringify(w)}/${y}`}function $(w={}){const y=w||{},v=b(y.clock),A=j(y.holdMs,0),D=new k("alarms"),F=new Map,M=[],q=new Map,R=[];let J=!1;const _=e=>{const u=(q.get(e)||0)+1;return q.set(e,u),`${e}#${u}`},ee=(e,u)=>`${e.source}:${e.sourceId}:${e.key}:${u}`,te=(e,u,c)=>({id:ee(e,u),source:e.source,sourceId:e.sourceId,key:e.key,level:u,previous:c,value:e.value,threshold:e.threshold??null,band:e.band??null,at:v.now(),holdMs:e.holdMs}),ne=(e,u)=>{D.emit(e,u);for(const c of R)c(u,e)},re=(e,u)=>{const c=e.committed;if(c!==u&&(e.committed=u,g(c)&&(e.active=null,ne("alarm:cleared",te(e,c,c))),g(u))){const a=te(e,u,c);e.active=a,ne("alarm:raised",a)}},Q=(e,u,c={})=>{if(J)return;const a=`${e.source}\0${e.sourceId}\0${e.key}`;let f=F.get(a);if(f||(f={source:e.source,sourceId:e.sourceId,key:e.key,holdMs:e.holdMs,committed:null,active:null,pending:null,timer:null,value:void 0,threshold:null,band:null},F.set(a,f)),f.holdMs=e.holdMs,f.value=c.value,f.threshold=c.threshold??null,f.band=c.band??null,u===f.committed){f.timer!==null&&(v.clearTimeout(f.timer),f.timer=null),f.pending=null;return}if(!(g(f.committed)||g(u))||f.holdMs<=0){re(f,u);return}f.pending={level:u,at:v.now()},f.timer===null&&(f.timer=v.setTimeout(()=>{f.timer=null;const N=f.pending;f.pending=null,N&&re(f,N.level)},f.holdMs))},ie=e=>{const u=`${e.source}\0${e.sourceId}\0${e.key}`,c=F.get(u);c&&(Q(e,null,{value:void 0}),c.timer===null&&c.pending===null&&F.delete(u))},t=e=>{const u=new Map;return(e&&e.config&&e.config.tiles||[]).forEach((a,f)=>{a&&u.set(String(a.id??a.label??`tile${f}`),a)}),u},r=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("kpi"),a=j(u.holdMs,A),f=t(e),p=(O,I,C)=>{const B=f.get(String(O))||{};Q({source:"kpi",sourceId:c,key:String(O),holdMs:a},I??null,{value:C,threshold:B.thresholds??null,band:Array.isArray(B.bands)?B.bands:null})};for(const O of e.model&&e.model.tiles||[])p(O.id,O.status,O.value);const N=e.on("tile:status",O=>p(O.id,O.status,O.value));return()=>{P(N)&&N()}},l=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("grid"),a=j(u.holdMs,A),f=u.columns&&typeof u.columns=="object"?u.columns:null;(!f||Object.keys(f).length===0)&&x("alarms:grid-no-columns","alarms.attach(grid) was given no `columns`, so no cell can raise anything. Declare the columns to watch: attach(grid, { columns: { cpu: { thresholds: { warn: 80, critical: 95, direction: 'lowerIsBetter' } } } }).");let p=new Set;const N=()=>{const I=new Set;if(!(!P(e.rows.forEachAll)||!P(e.rows.value))){e.rows.forEachAll(C=>{const B=C&&C.key;if(B!=null)for(const[oe,n]of Object.entries(f||{})){if(!n)continue;const i=T(B,oe);I.add(i);const s=e.rows.value(B,oe);if(n.when&&!Y(s,n.when)){Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},null,{value:s});continue}Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},S(s,n),{value:s,threshold:n.thresholds??null,band:Array.isArray(n.bands)?n.bands:null})}});for(const C of p)I.has(C)||ie({source:"grid",sourceId:c,key:C,holdMs:a});p=I}},O=[];for(const I of["rows:changed","cell:changed","stream:chunk","stream:evicted"]){const C=e.on(I,N);P(C)&&O.push(C)}return N(),()=>{for(const I of O)I()}},o=(e,u,c)=>{const a=c.sourceId?String(c.sourceId):_("router"),f=j(c.holdMs,A),p=String(c.label??(typeof u=="function"?"route":u)),N=P(c.value)?c.value:(I=>I.length),O=e.monitor(u,N,I=>{Q({source:"router",sourceId:a,key:p,holdMs:f},S(I,c),{value:I,threshold:c.thresholds??null,band:Array.isArray(c.bands)?c.bands:null})});return()=>{P(O)&&O()}};return{attach(e,u,c){if(J||!e||typeof e!="object")return this;if(P(e.monitor)){const f=c||{},p=o(e,u,f);return M.push({kind:"router",sourceId:f.sourceId||"",release:p}),this}const a=u&&typeof u=="object"?u:{};return e.model&&Array.isArray(e.model.tiles)&&P(e.on)?(M.push({kind:"kpi",sourceId:a.sourceId||"",release:r(e,a)}),this):e.rows&&P(e.on)?(M.push({kind:"grid",sourceId:a.sourceId||"",release:l(e,a)}),this):(x("alarms:unknown-source","alarms.attach() was given something that is not a KPI panel, a grid or a data router; nothing was attached and no alarm can be raised from it."),this)},on(e,u){return H.includes(e)?D.on(e,u):(x(`alarms:unknown-event:${e}`,`alarms.on('${e}') will never fire; an alarm set emits ${H.join(" and ")}.`),()=>{})},active(){const e=[];for(const u of F.values())u.active&&e.push({...u.active});return e},pending(){const e=[];for(const u of F.values())u.pending&&e.push({id:ee(u,u.pending.level),source:u.source,sourceId:u.sourceId,key:u.key,level:u.pending.level,previous:u.committed,value:u.value,at:u.pending.at,holdMs:u.holdMs});return e},publish(e,u="alarms"){if(J||!e||!P(e.addSource))return x("alarms:publish-no-router","alarms.publish() needs a data router with addSource(); nothing was published."),this;const c=e.addSource(String(u));let a=0;return R.push((f,p)=>{a+=1,c.push({op:"upsert",row:{...f,id:`${f.id}#${a}`,alarmId:f.id,kind:String(u),state:p==="alarm:raised"?"raised":"cleared"}})}),this},destroy(){if(!J){J=!0;for(const e of M)try{e.release()}catch{}M.length=0;for(const e of F.values())e.timer!==null&&(v.clearTimeout(e.timer),e.timer=null),e.pending=null;F.clear(),R.length=0,D.clear()}}}}const U=$});const fe=ae("packages/modules/alarms/index.js"),de=fe.createAlarms;var me=fe.default;export{de as createAlarms,me as default};
6
+ var ce=Object.create(null),le=Object.create(null);function ue(d,K){ce[d]=K}function ae(d){var K=le[d];if(K)return K;var E=Object.create(null);le[d]=E;var x=ce[d];if(!x)throw new Error("[lattice] missing module: "+d);return x(E,ae),E}ue("packages/core/src/internal/util.js",function(d,K){"use strict";Object.defineProperty(d,"VERSION",{enumerable:!0,get:function(){return P}}),Object.defineProperty(d,"reportedWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"warnOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"infoOnce",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resetWarnings",{enumerable:!0,get:function(){return T}}),Object.defineProperty(d,"fail",{enumerable:!0,get:function(){return $}}),Object.defineProperty(d,"invariant",{enumerable:!0,get:function(){return U}}),Object.defineProperty(d,"DEV",{enumerable:!0,get:function(){return w}}),Object.defineProperty(d,"isObject",{enumerable:!0,get:function(){return y}}),Object.defineProperty(d,"isFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(d,"isNil",{enumerable:!0,get:function(){return A}}),Object.defineProperty(d,"isBlank",{enumerable:!0,get:function(){return D}}),Object.defineProperty(d,"isCtor",{enumerable:!0,get:function(){return F}}),Object.defineProperty(d,"pathGetter",{enumerable:!0,get:function(){return q}}),Object.defineProperty(d,"pathSetter",{enumerable:!0,get:function(){return J}}),Object.defineProperty(d,"getPath",{enumerable:!0,get:function(){return _}}),Object.defineProperty(d,"setPath",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(d,"escapeHtml",{enumerable:!0,get:function(){return re}}),Object.defineProperty(d,"titleCase",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(d,"expand",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(d,"toArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(d,"merge",{enumerable:!0,get:function(){return l}}),Object.defineProperty(d,"mergeRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(d,"Lru",{enumerable:!0,get:function(){return m}}),Object.defineProperty(d,"collator",{enumerable:!0,get:function(){return u}}),Object.defineProperty(d,"defaultCompare",{enumerable:!0,get:function(){return c}}),Object.defineProperty(d,"now",{enumerable:!0,get:function(){return a}}),Object.defineProperty(d,"nextFrame",{enumerable:!0,get:function(){return p}}),Object.defineProperty(d,"cancelFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(d,"frameBatched",{enumerable:!0,get:function(){return O}}),Object.defineProperty(d,"settleDebounce",{enumerable:!0,get:function(){return I}}),Object.defineProperty(d,"whenIdle",{enumerable:!0,get:function(){return C}}),Object.defineProperty(d,"uid",{enumerable:!0,get:function(){return oe}});const E="1.71.3";async function x(){return E}const P="1.71.3",W=new Set,Y=2e3;function X(n){if(W.add(n),W.size>Y){const i=W.values().next().value;i!==void 0&&W.delete(i)}}const k=[],H=500;function L(n,i,s){k.push({key:n,level:i,message:s.map(h=>typeof h=="string"?h:g(h)).join(" "),at:Date.now()}),k.length>H&&k.shift()}function g(n){if(n instanceof Error)return n.message;try{return JSON.stringify(n)}catch{return String(n)}}function S(){return k.map(n=>({...n}))}function b(n,...i){W.has(n)||(X(n),L(n,"warn",i),console.warn("[lattice]",...i))}function j(n,...i){W.has(n)||(X(n),L(n,"info",i),console.info("[lattice]",...i))}function T(){W.clear(),k.length=0}function $(n,i){const s=new Error(`[lattice] ${n}`);throw i!==void 0&&(s.cause=i),s}function U(n,i){n||$(i)}const w=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function y(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return typeof n=="function"}function A(n){return n==null}function D(n){return n==null||n===""}function F(n){return typeof n!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(n))?!0:!!(n.prototype&&Object.getOwnPropertyNames(n.prototype).length>1)}const M=new Map;function q(n){let i=M.get(n);if(i)return i;if(!n.includes("."))i=s=>s?.[n];else{const s=n.split("."),h=s.length;i=V=>{let G=V;for(let z=0;z<h;z++){if(G==null)return;G=G[s[z]]}return G}}return M.set(n,i),i}const R=new Map;function J(n){let i=R.get(n);if(i)return i;if(!n.includes("."))i=(s,h)=>{s!=null&&(s[n]=h)};else{const s=n.split("."),h=s.length-1;i=(V,G)=>{let z=V;for(let Z=0;Z<h;Z++){if(z==null)return;const se=s[Z];z[se]==null&&(z[se]={}),z=z[se]}z!=null&&(z[s[h]]=G)}}return R.set(n,i),i}function _(n,i){return q(i)(n)}function ee(n,i,s){J(i)(n,s)}function te(n){return n?(n.includes(".")?n.slice(n.lastIndexOf(".")+1):n).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(/^./,s=>s.toUpperCase()):""}const ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function re(n){const i=n==null?"":String(n);return/[&<>"']/.test(i)?i.replace(/[&<>"']/g,s=>ne[s]):i}function Q(n){return String(n).replace(/\w\S*/g,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())}function ie(n,i,s){if(n!==void 0)return n===!0?{enabled:!0,...s}:n===!1?{enabled:!1}:y(n)?n:{[i]:n,enabled:!0}}function t(n){return n==null?[]:Array.isArray(n)?n:[n]}const r=Object.freeze(new Set(["__proto__","constructor","prototype"]));function l(n,i){if(!y(n))return y(i)?{...i}:i;if(!y(i))return i===void 0?n:i;const s={...n};for(const h of Object.keys(i)){if(r.has(h))continue;const V=i[h];V!==void 0&&(s[h]=y(V)&&y(s[h])?l(s[h],V):V)}return s}function o(n,i){if(!y(n)||!y(i)||n===i)return i;const s=Object.create(Object.getPrototypeOf(n));return Object.assign(s,n,i),s}class m{#t;#e=new Map;#n;constructor(i=256,s=null){this.#t=i,this.#n=s}get size(){return this.#e.size}get max(){return this.#t}set max(i){this.#t=i,this.#r()}has(i){return this.#e.has(i)}get(i){const s=this.#e;if(!s.has(i))return;const h=s.get(i);return s.delete(i),s.set(i,h),h}peek(i){return this.#e.get(i)}set(i,s){const h=this.#e;return h.has(i)&&h.delete(i),h.set(i,s),this.#r(),s}delete(i){const s=this.#e.get(i);return this.#e.delete(i)&&this.#n&&this.#n(s,i),s}clear(){if(this.#n)for(const[i,s]of this.#e)this.#n(s,i);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const i=this.#e;for(;i.size>this.#t;){const s=i.keys().next().value,h=i.get(s);i.delete(s),this.#n&&this.#n(h,s)}}}const e=new Map;function u(n,i){const s=`${n||""}|${i?JSON.stringify(i):""}`;let h=e.get(s);return h||(h=new Intl.Collator(n||void 0,{numeric:!0,sensitivity:"variant",...i}),e.set(s,h)),h}function c(n,i){if(n===i)return 0;if(n==null)return 1;if(i==null)return-1;if(typeof n=="number"&&typeof i=="number")return Number.isNaN(n)?Number.isNaN(i)?0:1:Number.isNaN(i)||n<i?-1:n>i?1:0;const s=String(n),h=String(i);return s<h?-1:s>h?1:0}function a(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const f=typeof requestAnimationFrame=="function";function p(n){return f?requestAnimationFrame(n):setTimeout(()=>n(a()),16)}function N(n){n!=null&&(f?cancelAnimationFrame(n):clearTimeout(n))}function O(n){let i=null,s=null;const h=()=>{i=null;const G=s;s=null,n(...G||[])},V=(...G)=>{s=G,i===null&&(i=p(h))};return V.cancel=()=>{N(i),i=null,s=null},V.flush=()=>{i!==null&&(N(i),h())},V}function I(n,i){let s=null,h=null;const V=()=>{if(s=null,h===null)return;const Z=h;h=null,n(...Z),G()},G=()=>{s=setTimeout(V,i),typeof s?.unref=="function"&&s.unref()},z=(...Z)=>{s===null?(n(...Z),G()):(h=Z,clearTimeout(s),G())};return z.flush=()=>{if(s!==null&&clearTimeout(s),s=null,h===null)return;const Z=h;h=null,n(...Z)},z.cancel=()=>{s!==null&&clearTimeout(s),s=null,h=null},z.pending=()=>s!==null||h!==null,z}function C(n,i=50){return typeof requestIdleCallback=="function"?requestIdleCallback(n,{timeout:i}):setTimeout(()=>n({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function oe(n="l"){return`${n}${(++B).toString(36)}`}}),ue("packages/core/src/formatting/rules.js",function(d,K){"use strict";Object.defineProperty(d,"RULE_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(d,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(d,"testRule",{enumerable:!0,get:function(){return L}}),Object.defineProperty(d,"mixColour",{enumerable:!0,get:function(){return g}}),Object.defineProperty(d,"summariseColumn",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"needsDistribution",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resolveDistribution",{enumerable:!0,get:function(){return w}}),Object.defineProperty(d,"ICON_SETS",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"compileRules",{enumerable:!0,get:function(){return ie}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),Y=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function k(t,r){const l=Number(t),o=Number(r);if(t!==null&&t!==""&&r!==null&&r!==""&&Number.isFinite(l)&&Number.isFinite(o))return l<o?-1:l>o?1:0;const e=String(t??"").toLowerCase(),u=String(r??"").toLowerCase();return e<u?-1:e>u?1:0}function H(t){return t==null||t===""}function L(t,r){if(!r||typeof r!="object")return!1;const{op:l}=r,o=r.value,m=r.value2;switch(l){case"blank":return H(t);case"notBlank":return!H(t);case"true":return t===!0;case"false":return t===!1;default:break}if(H(t))return!1;switch(l){case"eq":return k(t,o)===0;case"ne":return k(t,o)!==0;case"gt":return k(t,o)>0;case"gte":return k(t,o)>=0;case"lt":return k(t,o)<0;case"lte":return k(t,o)<=0;case"between":return k(t,o)>=0&&k(t,m)<=0;case"outside":return k(t,o)<0||k(t,m)>0;case"contains":return String(t).toLowerCase().includes(String(o??"").toLowerCase());case"notContains":return!String(t).toLowerCase().includes(String(o??"").toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(o??"").toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(o??"").toLowerCase());default:return!1}}function g(t,r,l){const o=O=>{const I=String(O).replace("#",""),C=I.length===3?I.split("").map(B=>B+B).join(""):I;return[0,2,4].map(B=>parseInt(C.slice(B,B+2),16)||0)},[m,e,u]=o(t),[c,a,f]=o(r),p=Math.max(0,Math.min(1,l)),N=(O,I)=>Math.round(O+(I-O)*p);return`#${[N(m,c),N(e,a),N(u,f)].map(O=>O.toString(16).padStart(2,"0")).join("")}`}function S(t){const r=[];for(const c of t||[]){if(c==null||c==="")continue;const a=c instanceof Date?c.getTime():Number(c);Number.isFinite(a)&&r.push(a)}if(!r.length)return null;r.sort((c,a)=>c-a);let l=0,o=0,m=0;for(const c of r){l++;const a=c-o;o+=a/l,m+=a*(c-o)}const e=b(r,.25),u=b(r,.75);return{n:r.length,min:r[0],max:r[r.length-1],mean:o,stddev:r.length>1?Math.sqrt(m/(r.length-1)):0,median:b(r,.5),q1:e,q3:u,iqr:u-e,sorted:r}}function b(t,r){if(!t.length)return 0;const l=(t.length-1)*Math.max(0,Math.min(1,r)),o=Math.floor(l),m=Math.ceil(l);return o===m?t[o]:t[o]+(l-o)*(t[m]-t[o])}function j(t){for(const r of Array.isArray(t)?t:[])if(!(!r||typeof r!="object")&&(r.when&&Y.includes(r.when.op)||r.scale&&r.scale.from||r.dataBar&&!(Number.isFinite(Number(r.dataBar.min))&&Number.isFinite(Number(r.dataBar.max)))||r.iconSet&&!Array.isArray(r.iconSet.thresholds)))return!0;return!1}function T(t,r){const l=Number(t.value),o=m=>b(r.sorted,m);switch(t.op){case"topPercent":{const m=$(l,10);return{op:"gte",value:o(1-m)}}case"bottomPercent":{const m=$(l,10);return{op:"lte",value:o(m)}}case"topN":{const m=Math.max(1,Math.floor(l)||1),e=Math.max(0,r.sorted.length-m);return{op:"gte",value:r.sorted[e]}}case"bottomN":{const m=Math.max(1,Math.floor(l)||1),e=Math.min(r.sorted.length-1,m-1);return{op:"lte",value:r.sorted[e]}}case"aboveMean":return{op:"gt",value:r.mean};case"belowMean":return{op:"lt",value:r.mean};case"aboveMedian":return{op:"gt",value:r.median};case"belowMedian":return{op:"lt",value:r.median};case"zAbove":return r.stddev?{op:"gte",value:r.mean+(Number.isFinite(l)?l:2)*r.stddev}:null;case"zBelow":return r.stddev?{op:"lte",value:r.mean-(Number.isFinite(l)?l:2)*r.stddev}:null;case"outlier":{const m=(Number.isFinite(l)&&l>0?l:1.5)*r.iqr;return r.iqr?{op:"outside",value:r.q1-m,value2:r.q3+m}:null}default:return null}}function $(t,r){const l=Number.isFinite(t)?t:r,o=l>1?l/100:l;return Math.max(0,Math.min(1,o))}function U(t,r){if(t.from==="minmax")return{...t,min:r.min,max:r.max};if(t.from==="quantile")return{...t,min:b(r.sorted,$(Number(t.low),5)),max:b(r.sorted,$(Number(t.high),95))};if(t.from==="stddev"){const l=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:r.mean-l*r.stddev,max:r.mean+l*r.stddev}}return t}function w(t,r){const l=Array.isArray(t)?t:[];return!r||!r.n?l.map(o=>o&&j([o])?{...o,enabled:!1}:o):l.map(o=>{if(!o||typeof o!="object")return o;if(o.scale&&o.scale.from)return{...o,scale:U(o.scale,r)};if(o.dataBar)return{...o,dataBar:y(o.dataBar,r)};if(o.iconSet)return{...o,iconSet:v(o.iconSet,r)};if(!o.when||!Y.includes(o.when.op))return o;const m=T(o.when,r);return m?{...o,when:m}:{...o,enabled:!1}})}function y(t,r){const l=Number.isFinite(Number(t.min))?Number(t.min):void 0,o=Number.isFinite(Number(t.max))?Number(t.max):void 0;if(l!==void 0&&o!==void 0)return{...t,min:l,max:o};if(t.from==="quantile")return{...t,min:l??b(r.sorted,$(Number(t.low),5)),max:o??b(r.sorted,$(Number(t.high),95))};if(t.from==="stddev"){const m=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:l??r.mean-m*r.stddev,max:o??r.mean+m*r.stddev}}return{...t,min:l??r.min,max:o??r.max}}function v(t,r){if(Array.isArray(t.thresholds))return t;const l=A(t),o=[];for(let m=1;m<l;m++)o.push(b(r.sorted,m/l));return{...t,thresholds:o}}function A(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.length;if(Number.isFinite(Number(t.count))&&Number(t.count)>=2)return Math.floor(Number(t.count));const r=_[t.set];return r?r.length:3}function D(t){return`url("data:image/svg+xml,${encodeURIComponent(t)}")`}function F(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${t}"/></svg>`}function M(t,r){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${r==="up"?"8,2 14,13 2,13":r==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${t}"/></svg>`}function q(t,r){const l="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let o=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r*16} 16">`;for(let m=0;m<r;m++){const e=m<t?"#f5a623":"#d0d0d0";o+=`<path transform="translate(${m*16},0)" d="${l}" fill="${e}"/>`}return`${o}</svg>`}const R=Object.freeze([M("#c0392b","down"),M("#e0a800","right"),M("#2e7d32","up")]),J=Object.freeze([F("#d13438"),F("#f5a623"),F("#2e9e44")]),_=Object.freeze({arrows:R,trafficLights:J,ratings:Object.freeze([1,2,3,4,5].map(t=>q(t,5)))}),ee=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function te(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.map(o=>/^\s*(url\(|data:|<)/.test(String(o))&&String(o).trim().startsWith("<")?D(String(o)):String(o));const r=t.set||"arrows";if(r==="ratings"){const o=A(t),m=[];for(let e=1;e<=o;e++)m.push(D(q(e,o)));return m}const l=_[r];return l?l.map(D):(P(`iconSet:${r}`,`unknown icon set '${r}'; falling back to arrows.`),R.map(D))}function ne(t){const r=Number(t.min),o=Number(t.max)-r,m=t.colour||t.color||"#5b9bd5",e=t.negativeColour||t.negativeColor||"#d13438",u=t.direction==="rtl"?"left":"right",c=f=>Math.max(0,Math.min(1,(f-r)/o))*100,a=o?Math.max(0,Math.min(100,(0-r)/o*100)):0;return f=>{if(H(f))return null;const p=Number(f);if(!Number.isFinite(p)||!o)return null;const N=c(p),O=Math.min(N,a),I=Math.max(N,a),C=p>=0?m:e;return{backgroundImage:`linear-gradient(to ${u}, transparent ${O}%, ${C} ${O}%, ${C} ${I}%, transparent ${I}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function re(t){const r=te(t),l=t.reverse?[...r].reverse():r,o=(Array.isArray(t.thresholds)?t.thresholds:[]).map(Number).filter(Number.isFinite),m=Number.isFinite(Number(t.size))?Number(t.size):16,e=t.set==="ratings"?m*A(t):m;return u=>{if(H(u))return null;const c=Number(u);if(!Number.isFinite(c))return null;let a=0;for(const p of o)c>=p&&a++;const f=l[Math.min(a,l.length-1)];return f?{backgroundImage:f,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${e}px ${m}px`,paddingLeft:`${e+4}px`}:null}}function Q(t){const r=Array.isArray(t.colours)&&t.colours.length>=2?t.colours:["#f8f9fa","#1a6bc7"],l=Number(t.min),o=Number(t.max),m=o-l,e=r.length-1,u=[];for(let a=0;a<=e;a++)u.push(e?a/e:0);const c=Number(t.mid);if(t.mid!==void 0&&t.mid!==null)if(r.length%2===0)P("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${r.length} were given, so "mid" was ignored.`);else if(Number.isFinite(c)&&m&&c>Math.min(l,o)&&c<Math.max(l,o)){const a=e/2,f=Math.max(0,Math.min(1,(c-l)/m));for(let p=0;p<=e;p++)u[p]=p<=a?a?p/a*f:f:f+(p-a)/(e-a)*(1-f)}else Number.isFinite(c)&&P("formatting.scale.mid.range",`a scale's "mid" (${c}) is outside its min..max range, so it was ignored.`);return a=>{const f=Number(a);if(!Number.isFinite(f)||!m)return null;const p=Math.max(0,Math.min(1,(f-l)/m));let N=0;for(;N<e-1&&p>u[N+1];)N++;const O=u[N+1]-u[N],I=O>0?(p-u[N])/O:0;return{background:g(r[N],r[N+1],Math.max(0,Math.min(1,I)))}}}function ie(t,r=null){const l=j(t)?w(t,r):t,o=(Array.isArray(l)?l:[]).filter(e=>e&&typeof e=="object");if(!o.length)return()=>null;const m=o.map(e=>e.scale?{scale:Q(e.scale),enabled:e.enabled!==!1}:e.dataBar?{scale:ne(e.dataBar),enabled:e.enabled!==!1}:e.iconSet?{scale:re(e.iconSet),enabled:e.enabled!==!1}:{when:e.when,style:e.style,stop:e.stopIfTrue!==!1,enabled:e.enabled!==!1});return e=>{const u=e?e.value:void 0;let c=null;for(const a of m){if(!a.enabled)continue;if(a.scale){const p=a.scale(u);p&&(c={...c||{},...p});continue}if(!L(u,a.when))continue;const f=x(a.style)?a.style(e):a.style;if(f&&(c={...c||{},...f}),a.stop)break}return c}}}),ue("packages/modules/shared/emitter.js",function(d,K){"use strict";Object.defineProperty(d,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"Emitter",{enumerable:!0,get:function(){return k}}),Object.defineProperty(d,"gate",{enumerable:!0,get:function(){return H}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W="*",Y=new Set(["api","user","init","ai"]);function X(L,g){return L&&L.name?L.name:`#${g}`}class k{#t=new Map;#e;constructor(g="module"){this.#e=String(g)}on(g,S){if(!x(S))return()=>{};let b=this.#t.get(g);return b||(b=new Set,this.#t.set(g,b)),b.add(S),()=>this.off(g,S)}off(g,S){const b=this.#t.get(g);b&&b.delete(S)}count(g){const S=this.#t.get(g);return S?S.size:0}emit(g,S){const b=this.#t.get(g),j=this.#t.get(W);if((!b||b.size===0)&&(!j||j.size===0))return;const T={...S||null,type:g};b&&b.size&&this.#n([...b],T,g),j&&j.size&&this.#n([...j],T,W)}#n(g,S,b){for(let j=0;j<g.length;j++)try{g[j](S)}catch(T){P(`${this.#e}.emit.throw:${b}:${X(g[j],j)}`,`${this.#e}: a '${b}' handler threw; other handlers were unaffected.`,T)}}emitBefore(g,S,b){const j=b??(S&&S.origin),T=Y.has(j)?j:"user";let $=!1,U=null;const w=M=>{$=!0,M!=null&&U===null&&(U=String(M))},y={...S||null,type:g,origin:T,get defaultPrevented(){return $},get reason(){return U},preventDefault(M){w(M)}},v=this.#t.get(g);if(!v||v.size===0)return!0;const A=[...v],D=()=>($&&U===null&&(U="prevented"),$&&S&&typeof S=="object"&&(S.reason=U),!$),F=[];for(let M=0;M<A.length;M++){const q=A[M];try{const R=q(y);R&&x(R.then)?F.push(R):R===!1&&w("prevented")}catch(R){w("error"),P(`${this.#e}.beforeThrow:${g}:${X(q,M)}`,`${this.#e}: a '${g}' before-handler threw; the action was cancelled.`,R)}}return F.length===0?D():Promise.allSettled(F).then(M=>{for(const q of M)q.status==="rejected"?(w("error"),P(`${this.#e}.beforeReject:${g}`,`${this.#e}: a '${g}' before-handler rejected; the action was cancelled.`,q.reason)):q.value===!1&&w("prevented");return D()})}clear(){this.#t.clear()}}function H(L,g,S,b,j){const T=L.emitBefore(g,b,b.origin),$=()=>(L.emit(S,{...b,reason:b.reason||"prevented"}),!1);return T===!1?$():T&&x(T.then)?T.then(U=>U?j():$()):j()}}),ue("packages/modules/alarms/index.js",function(d,K){"use strict";Object.defineProperty(d,"createAlarms",{enumerable:!0,get:function(){return $}}),Object.defineProperty(d,"default",{enumerable:!0,get:function(){return U}});const E=K("packages/core/src/internal/util.js"),x=E.warnOnce,P=E.isFunction,Y=K("packages/core/src/formatting/rules.js").testRule,k=K("packages/modules/shared/emitter.js").Emitter,H=Object.freeze(["alarm:raised","alarm:cleared"]),L=new Set(["warn","critical"]);function g(w){return typeof w=="string"&&L.has(w)}function S(w,y){if(typeof w!="number"||Number.isNaN(w))return null;if(Array.isArray(y&&y.bands)){for(const A of y.bands){const D=A.min===void 0||A.min===null?-1/0:A.min,F=A.max===void 0||A.max===null?1/0:A.max;if(w>=D&&w<F)return A.status??null}return null}const v=y&&y.thresholds;return!v||v.warn===void 0||v.warn===null||v.critical===void 0||v.critical===null?null:v.direction==="lowerIsBetter"?w<=v.warn?"good":w<=v.critical?"warn":"critical":w>=v.warn?"good":w>=v.critical?"warn":"critical"}function b(w){const y=w||{};return{now:P(y.now)?y.now:()=>Date.now(),setTimeout:P(y.setTimeout)?y.setTimeout:((v,A)=>setTimeout(v,A)),clearTimeout:P(y.clearTimeout)?y.clearTimeout:(v=>clearTimeout(v))}}function j(w,y){return Number.isFinite(w)&&Number(w)>=0?Number(w):y}function T(w,y){return`${typeof w=="string"?w:JSON.stringify(w)}/${y}`}function $(w={}){const y=w||{},v=b(y.clock),A=j(y.holdMs,0),D=new k("alarms"),F=new Map,M=[],q=new Map,R=[];let J=!1;const _=e=>{const u=(q.get(e)||0)+1;return q.set(e,u),`${e}#${u}`},ee=(e,u)=>`${e.source}:${e.sourceId}:${e.key}:${u}`,te=(e,u,c)=>({id:ee(e,u),source:e.source,sourceId:e.sourceId,key:e.key,level:u,previous:c,value:e.value,threshold:e.threshold??null,band:e.band??null,at:v.now(),holdMs:e.holdMs}),ne=(e,u)=>{D.emit(e,u);for(const c of R)c(u,e)},re=(e,u)=>{const c=e.committed;if(c!==u&&(e.committed=u,g(c)&&(e.active=null,ne("alarm:cleared",te(e,c,c))),g(u))){const a=te(e,u,c);e.active=a,ne("alarm:raised",a)}},Q=(e,u,c={})=>{if(J)return;const a=`${e.source}\0${e.sourceId}\0${e.key}`;let f=F.get(a);if(f||(f={source:e.source,sourceId:e.sourceId,key:e.key,holdMs:e.holdMs,committed:null,active:null,pending:null,timer:null,value:void 0,threshold:null,band:null},F.set(a,f)),f.holdMs=e.holdMs,f.value=c.value,f.threshold=c.threshold??null,f.band=c.band??null,u===f.committed){f.timer!==null&&(v.clearTimeout(f.timer),f.timer=null),f.pending=null;return}if(!(g(f.committed)||g(u))||f.holdMs<=0){re(f,u);return}f.pending={level:u,at:v.now()},f.timer===null&&(f.timer=v.setTimeout(()=>{f.timer=null;const N=f.pending;f.pending=null,N&&re(f,N.level)},f.holdMs))},ie=e=>{const u=`${e.source}\0${e.sourceId}\0${e.key}`,c=F.get(u);c&&(Q(e,null,{value:void 0}),c.timer===null&&c.pending===null&&F.delete(u))},t=e=>{const u=new Map;return(e&&e.config&&e.config.tiles||[]).forEach((a,f)=>{a&&u.set(String(a.id??a.label??`tile${f}`),a)}),u},r=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("kpi"),a=j(u.holdMs,A),f=t(e),p=(O,I,C)=>{const B=f.get(String(O))||{};Q({source:"kpi",sourceId:c,key:String(O),holdMs:a},I??null,{value:C,threshold:B.thresholds??null,band:Array.isArray(B.bands)?B.bands:null})};for(const O of e.model&&e.model.tiles||[])p(O.id,O.status,O.value);const N=e.on("tile:status",O=>p(O.id,O.status,O.value));return()=>{P(N)&&N()}},l=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("grid"),a=j(u.holdMs,A),f=u.columns&&typeof u.columns=="object"?u.columns:null;(!f||Object.keys(f).length===0)&&x("alarms:grid-no-columns","alarms.attach(grid) was given no `columns`, so no cell can raise anything. Declare the columns to watch: attach(grid, { columns: { cpu: { thresholds: { warn: 80, critical: 95, direction: 'lowerIsBetter' } } } }).");let p=new Set;const N=()=>{const I=new Set;if(!(!P(e.rows.forEachAll)||!P(e.rows.value))){e.rows.forEachAll(C=>{const B=C&&C.key;if(B!=null)for(const[oe,n]of Object.entries(f||{})){if(!n)continue;const i=T(B,oe);I.add(i);const s=e.rows.value(B,oe);if(n.when&&!Y(s,n.when)){Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},null,{value:s});continue}Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},S(s,n),{value:s,threshold:n.thresholds??null,band:Array.isArray(n.bands)?n.bands:null})}});for(const C of p)I.has(C)||ie({source:"grid",sourceId:c,key:C,holdMs:a});p=I}},O=[];for(const I of["rows:changed","cell:changed","stream:chunk","stream:evicted"]){const C=e.on(I,N);P(C)&&O.push(C)}return N(),()=>{for(const I of O)I()}},o=(e,u,c)=>{const a=c.sourceId?String(c.sourceId):_("router"),f=j(c.holdMs,A),p=String(c.label??(typeof u=="function"?"route":u)),N=P(c.value)?c.value:(I=>I.length),O=e.monitor(u,N,I=>{Q({source:"router",sourceId:a,key:p,holdMs:f},S(I,c),{value:I,threshold:c.thresholds??null,band:Array.isArray(c.bands)?c.bands:null})});return()=>{P(O)&&O()}};return{attach(e,u,c){if(J||!e||typeof e!="object")return this;if(P(e.monitor)){const f=c||{},p=o(e,u,f);return M.push({kind:"router",sourceId:f.sourceId||"",release:p}),this}const a=u&&typeof u=="object"?u:{};return e.model&&Array.isArray(e.model.tiles)&&P(e.on)?(M.push({kind:"kpi",sourceId:a.sourceId||"",release:r(e,a)}),this):e.rows&&P(e.on)?(M.push({kind:"grid",sourceId:a.sourceId||"",release:l(e,a)}),this):(x("alarms:unknown-source","alarms.attach() was given something that is not a KPI panel, a grid or a data router; nothing was attached and no alarm can be raised from it."),this)},on(e,u){return H.includes(e)?D.on(e,u):(x(`alarms:unknown-event:${e}`,`alarms.on('${e}') will never fire; an alarm set emits ${H.join(" and ")}.`),()=>{})},active(){const e=[];for(const u of F.values())u.active&&e.push({...u.active});return e},pending(){const e=[];for(const u of F.values())u.pending&&e.push({id:ee(u,u.pending.level),source:u.source,sourceId:u.sourceId,key:u.key,level:u.pending.level,previous:u.committed,value:u.value,at:u.pending.at,holdMs:u.holdMs});return e},publish(e,u="alarms"){if(J||!e||!P(e.addSource))return x("alarms:publish-no-router","alarms.publish() needs a data router with addSource(); nothing was published."),this;const c=e.addSource(String(u));let a=0;return R.push((f,p)=>{a+=1,c.push({op:"upsert",row:{...f,id:`${f.id}#${a}`,alarmId:f.id,kind:String(u),state:p==="alarm:raised"?"raised":"cleared"}})}),this},destroy(){if(!J){J=!0;for(const e of M)try{e.release()}catch{}M.length=0;for(const e of F.values())e.timer!==null&&(v.clearTimeout(e.timer),e.timer=null),e.pending=null;F.clear(),R.length=0,D.clear()}}}}const U=$});const fe=ae("packages/modules/alarms/index.js"),de=fe.createAlarms;var me=fe.default;export{de as createAlarms,me as default};
7
7
 
8
8
  //# sourceMappingURL=alarms.esm.min.js.map
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * Lattice Grid 1.71.1, alarms module
2
+ * Lattice Grid 1.71.3, alarms module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- (function(de){"use strict";var le=Object.create(null),ae=Object.create(null);function oe(d,K){le[d]=K}function fe(d){var K=ae[d];if(K)return K;var E=Object.create(null);ae[d]=E;var x=le[d];if(!x)throw new Error("[lattice] missing module: "+d);return x(E,fe),E}oe("packages/core/src/internal/util.js",function(d,K){"use strict";Object.defineProperty(d,"VERSION",{enumerable:!0,get:function(){return P}}),Object.defineProperty(d,"reportedWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"warnOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"infoOnce",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resetWarnings",{enumerable:!0,get:function(){return F}}),Object.defineProperty(d,"fail",{enumerable:!0,get:function(){return A}}),Object.defineProperty(d,"invariant",{enumerable:!0,get:function(){return U}}),Object.defineProperty(d,"DEV",{enumerable:!0,get:function(){return y}}),Object.defineProperty(d,"isObject",{enumerable:!0,get:function(){return w}}),Object.defineProperty(d,"isFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(d,"isNil",{enumerable:!0,get:function(){return $}}),Object.defineProperty(d,"isBlank",{enumerable:!0,get:function(){return D}}),Object.defineProperty(d,"isCtor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(d,"pathGetter",{enumerable:!0,get:function(){return q}}),Object.defineProperty(d,"pathSetter",{enumerable:!0,get:function(){return J}}),Object.defineProperty(d,"getPath",{enumerable:!0,get:function(){return _}}),Object.defineProperty(d,"setPath",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(d,"escapeHtml",{enumerable:!0,get:function(){return re}}),Object.defineProperty(d,"titleCase",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(d,"expand",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(d,"toArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(d,"merge",{enumerable:!0,get:function(){return l}}),Object.defineProperty(d,"mergeRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(d,"Lru",{enumerable:!0,get:function(){return m}}),Object.defineProperty(d,"collator",{enumerable:!0,get:function(){return u}}),Object.defineProperty(d,"defaultCompare",{enumerable:!0,get:function(){return c}}),Object.defineProperty(d,"now",{enumerable:!0,get:function(){return a}}),Object.defineProperty(d,"nextFrame",{enumerable:!0,get:function(){return p}}),Object.defineProperty(d,"cancelFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(d,"frameBatched",{enumerable:!0,get:function(){return O}}),Object.defineProperty(d,"settleDebounce",{enumerable:!0,get:function(){return I}}),Object.defineProperty(d,"whenIdle",{enumerable:!0,get:function(){return C}}),Object.defineProperty(d,"uid",{enumerable:!0,get:function(){return ue}});const E="1.71.1";async function x(){return E}const P="1.71.1",W=new Set,Y=2e3;function X(n){if(W.add(n),W.size>Y){const i=W.values().next().value;i!==void 0&&W.delete(i)}}const k=[],H=500;function L(n,i,s){k.push({key:n,level:i,message:s.map(h=>typeof h=="string"?h:g(h)).join(" "),at:Date.now()}),k.length>H&&k.shift()}function g(n){if(n instanceof Error)return n.message;try{return JSON.stringify(n)}catch{return String(n)}}function S(){return k.map(n=>({...n}))}function b(n,...i){W.has(n)||(X(n),L(n,"warn",i),console.warn("[lattice]",...i))}function j(n,...i){W.has(n)||(X(n),L(n,"info",i),console.info("[lattice]",...i))}function F(){W.clear(),k.length=0}function A(n,i){const s=new Error(`[lattice] ${n}`);throw i!==void 0&&(s.cause=i),s}function U(n,i){n||A(i)}const y=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function w(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return typeof n=="function"}function $(n){return n==null}function D(n){return n==null||n===""}function T(n){return typeof n!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(n))?!0:!!(n.prototype&&Object.getOwnPropertyNames(n.prototype).length>1)}const M=new Map;function q(n){let i=M.get(n);if(i)return i;if(!n.includes("."))i=s=>s?.[n];else{const s=n.split("."),h=s.length;i=V=>{let G=V;for(let z=0;z<h;z++){if(G==null)return;G=G[s[z]]}return G}}return M.set(n,i),i}const R=new Map;function J(n){let i=R.get(n);if(i)return i;if(!n.includes("."))i=(s,h)=>{s!=null&&(s[n]=h)};else{const s=n.split("."),h=s.length-1;i=(V,G)=>{let z=V;for(let Z=0;Z<h;Z++){if(z==null)return;const ce=s[Z];z[ce]==null&&(z[ce]={}),z=z[ce]}z!=null&&(z[s[h]]=G)}}return R.set(n,i),i}function _(n,i){return q(i)(n)}function ee(n,i,s){J(i)(n,s)}function te(n){return n?(n.includes(".")?n.slice(n.lastIndexOf(".")+1):n).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(/^./,s=>s.toUpperCase()):""}const ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function re(n){const i=n==null?"":String(n);return/[&<>"']/.test(i)?i.replace(/[&<>"']/g,s=>ne[s]):i}function Q(n){return String(n).replace(/\w\S*/g,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())}function ie(n,i,s){if(n!==void 0)return n===!0?{enabled:!0,...s}:n===!1?{enabled:!1}:w(n)?n:{[i]:n,enabled:!0}}function t(n){return n==null?[]:Array.isArray(n)?n:[n]}const r=Object.freeze(new Set(["__proto__","constructor","prototype"]));function l(n,i){if(!w(n))return w(i)?{...i}:i;if(!w(i))return i===void 0?n:i;const s={...n};for(const h of Object.keys(i)){if(r.has(h))continue;const V=i[h];V!==void 0&&(s[h]=w(V)&&w(s[h])?l(s[h],V):V)}return s}function o(n,i){if(!w(n)||!w(i)||n===i)return i;const s=Object.create(Object.getPrototypeOf(n));return Object.assign(s,n,i),s}class m{#t;#e=new Map;#n;constructor(i=256,s=null){this.#t=i,this.#n=s}get size(){return this.#e.size}get max(){return this.#t}set max(i){this.#t=i,this.#r()}has(i){return this.#e.has(i)}get(i){const s=this.#e;if(!s.has(i))return;const h=s.get(i);return s.delete(i),s.set(i,h),h}peek(i){return this.#e.get(i)}set(i,s){const h=this.#e;return h.has(i)&&h.delete(i),h.set(i,s),this.#r(),s}delete(i){const s=this.#e.get(i);return this.#e.delete(i)&&this.#n&&this.#n(s,i),s}clear(){if(this.#n)for(const[i,s]of this.#e)this.#n(s,i);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const i=this.#e;for(;i.size>this.#t;){const s=i.keys().next().value,h=i.get(s);i.delete(s),this.#n&&this.#n(h,s)}}}const e=new Map;function u(n,i){const s=`${n||""}|${i?JSON.stringify(i):""}`;let h=e.get(s);return h||(h=new Intl.Collator(n||void 0,{numeric:!0,sensitivity:"variant",...i}),e.set(s,h)),h}function c(n,i){if(n===i)return 0;if(n==null)return 1;if(i==null)return-1;if(typeof n=="number"&&typeof i=="number")return Number.isNaN(n)?Number.isNaN(i)?0:1:Number.isNaN(i)||n<i?-1:n>i?1:0;const s=String(n),h=String(i);return s<h?-1:s>h?1:0}function a(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const f=typeof requestAnimationFrame=="function";function p(n){return f?requestAnimationFrame(n):setTimeout(()=>n(a()),16)}function N(n){n!=null&&(f?cancelAnimationFrame(n):clearTimeout(n))}function O(n){let i=null,s=null;const h=()=>{i=null;const G=s;s=null,n(...G||[])},V=(...G)=>{s=G,i===null&&(i=p(h))};return V.cancel=()=>{N(i),i=null,s=null},V.flush=()=>{i!==null&&(N(i),h())},V}function I(n,i){let s=null,h=null;const V=()=>{if(s=null,h===null)return;const Z=h;h=null,n(...Z),G()},G=()=>{s=setTimeout(V,i),typeof s?.unref=="function"&&s.unref()},z=(...Z)=>{s===null?(n(...Z),G()):(h=Z,clearTimeout(s),G())};return z.flush=()=>{if(s!==null&&clearTimeout(s),s=null,h===null)return;const Z=h;h=null,n(...Z)},z.cancel=()=>{s!==null&&clearTimeout(s),s=null,h=null},z.pending=()=>s!==null||h!==null,z}function C(n,i=50){return typeof requestIdleCallback=="function"?requestIdleCallback(n,{timeout:i}):setTimeout(()=>n({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function ue(n="l"){return`${n}${(++B).toString(36)}`}}),oe("packages/core/src/formatting/rules.js",function(d,K){"use strict";Object.defineProperty(d,"RULE_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(d,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(d,"testRule",{enumerable:!0,get:function(){return L}}),Object.defineProperty(d,"mixColour",{enumerable:!0,get:function(){return g}}),Object.defineProperty(d,"summariseColumn",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"needsDistribution",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resolveDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(d,"ICON_SETS",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"compileRules",{enumerable:!0,get:function(){return ie}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),Y=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function k(t,r){const l=Number(t),o=Number(r);if(t!==null&&t!==""&&r!==null&&r!==""&&Number.isFinite(l)&&Number.isFinite(o))return l<o?-1:l>o?1:0;const e=String(t??"").toLowerCase(),u=String(r??"").toLowerCase();return e<u?-1:e>u?1:0}function H(t){return t==null||t===""}function L(t,r){if(!r||typeof r!="object")return!1;const{op:l}=r,o=r.value,m=r.value2;switch(l){case"blank":return H(t);case"notBlank":return!H(t);case"true":return t===!0;case"false":return t===!1;default:break}if(H(t))return!1;switch(l){case"eq":return k(t,o)===0;case"ne":return k(t,o)!==0;case"gt":return k(t,o)>0;case"gte":return k(t,o)>=0;case"lt":return k(t,o)<0;case"lte":return k(t,o)<=0;case"between":return k(t,o)>=0&&k(t,m)<=0;case"outside":return k(t,o)<0||k(t,m)>0;case"contains":return String(t).toLowerCase().includes(String(o??"").toLowerCase());case"notContains":return!String(t).toLowerCase().includes(String(o??"").toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(o??"").toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(o??"").toLowerCase());default:return!1}}function g(t,r,l){const o=O=>{const I=String(O).replace("#",""),C=I.length===3?I.split("").map(B=>B+B).join(""):I;return[0,2,4].map(B=>parseInt(C.slice(B,B+2),16)||0)},[m,e,u]=o(t),[c,a,f]=o(r),p=Math.max(0,Math.min(1,l)),N=(O,I)=>Math.round(O+(I-O)*p);return`#${[N(m,c),N(e,a),N(u,f)].map(O=>O.toString(16).padStart(2,"0")).join("")}`}function S(t){const r=[];for(const c of t||[]){if(c==null||c==="")continue;const a=c instanceof Date?c.getTime():Number(c);Number.isFinite(a)&&r.push(a)}if(!r.length)return null;r.sort((c,a)=>c-a);let l=0,o=0,m=0;for(const c of r){l++;const a=c-o;o+=a/l,m+=a*(c-o)}const e=b(r,.25),u=b(r,.75);return{n:r.length,min:r[0],max:r[r.length-1],mean:o,stddev:r.length>1?Math.sqrt(m/(r.length-1)):0,median:b(r,.5),q1:e,q3:u,iqr:u-e,sorted:r}}function b(t,r){if(!t.length)return 0;const l=(t.length-1)*Math.max(0,Math.min(1,r)),o=Math.floor(l),m=Math.ceil(l);return o===m?t[o]:t[o]+(l-o)*(t[m]-t[o])}function j(t){for(const r of Array.isArray(t)?t:[])if(!(!r||typeof r!="object")&&(r.when&&Y.includes(r.when.op)||r.scale&&r.scale.from||r.dataBar&&!(Number.isFinite(Number(r.dataBar.min))&&Number.isFinite(Number(r.dataBar.max)))||r.iconSet&&!Array.isArray(r.iconSet.thresholds)))return!0;return!1}function F(t,r){const l=Number(t.value),o=m=>b(r.sorted,m);switch(t.op){case"topPercent":{const m=A(l,10);return{op:"gte",value:o(1-m)}}case"bottomPercent":{const m=A(l,10);return{op:"lte",value:o(m)}}case"topN":{const m=Math.max(1,Math.floor(l)||1),e=Math.max(0,r.sorted.length-m);return{op:"gte",value:r.sorted[e]}}case"bottomN":{const m=Math.max(1,Math.floor(l)||1),e=Math.min(r.sorted.length-1,m-1);return{op:"lte",value:r.sorted[e]}}case"aboveMean":return{op:"gt",value:r.mean};case"belowMean":return{op:"lt",value:r.mean};case"aboveMedian":return{op:"gt",value:r.median};case"belowMedian":return{op:"lt",value:r.median};case"zAbove":return r.stddev?{op:"gte",value:r.mean+(Number.isFinite(l)?l:2)*r.stddev}:null;case"zBelow":return r.stddev?{op:"lte",value:r.mean-(Number.isFinite(l)?l:2)*r.stddev}:null;case"outlier":{const m=(Number.isFinite(l)&&l>0?l:1.5)*r.iqr;return r.iqr?{op:"outside",value:r.q1-m,value2:r.q3+m}:null}default:return null}}function A(t,r){const l=Number.isFinite(t)?t:r,o=l>1?l/100:l;return Math.max(0,Math.min(1,o))}function U(t,r){if(t.from==="minmax")return{...t,min:r.min,max:r.max};if(t.from==="quantile")return{...t,min:b(r.sorted,A(Number(t.low),5)),max:b(r.sorted,A(Number(t.high),95))};if(t.from==="stddev"){const l=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:r.mean-l*r.stddev,max:r.mean+l*r.stddev}}return t}function y(t,r){const l=Array.isArray(t)?t:[];return!r||!r.n?l.map(o=>o&&j([o])?{...o,enabled:!1}:o):l.map(o=>{if(!o||typeof o!="object")return o;if(o.scale&&o.scale.from)return{...o,scale:U(o.scale,r)};if(o.dataBar)return{...o,dataBar:w(o.dataBar,r)};if(o.iconSet)return{...o,iconSet:v(o.iconSet,r)};if(!o.when||!Y.includes(o.when.op))return o;const m=F(o.when,r);return m?{...o,when:m}:{...o,enabled:!1}})}function w(t,r){const l=Number.isFinite(Number(t.min))?Number(t.min):void 0,o=Number.isFinite(Number(t.max))?Number(t.max):void 0;if(l!==void 0&&o!==void 0)return{...t,min:l,max:o};if(t.from==="quantile")return{...t,min:l??b(r.sorted,A(Number(t.low),5)),max:o??b(r.sorted,A(Number(t.high),95))};if(t.from==="stddev"){const m=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:l??r.mean-m*r.stddev,max:o??r.mean+m*r.stddev}}return{...t,min:l??r.min,max:o??r.max}}function v(t,r){if(Array.isArray(t.thresholds))return t;const l=$(t),o=[];for(let m=1;m<l;m++)o.push(b(r.sorted,m/l));return{...t,thresholds:o}}function $(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.length;if(Number.isFinite(Number(t.count))&&Number(t.count)>=2)return Math.floor(Number(t.count));const r=_[t.set];return r?r.length:3}function D(t){return`url("data:image/svg+xml,${encodeURIComponent(t)}")`}function T(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${t}"/></svg>`}function M(t,r){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${r==="up"?"8,2 14,13 2,13":r==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${t}"/></svg>`}function q(t,r){const l="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let o=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r*16} 16">`;for(let m=0;m<r;m++){const e=m<t?"#f5a623":"#d0d0d0";o+=`<path transform="translate(${m*16},0)" d="${l}" fill="${e}"/>`}return`${o}</svg>`}const R=Object.freeze([M("#c0392b","down"),M("#e0a800","right"),M("#2e7d32","up")]),J=Object.freeze([T("#d13438"),T("#f5a623"),T("#2e9e44")]),_=Object.freeze({arrows:R,trafficLights:J,ratings:Object.freeze([1,2,3,4,5].map(t=>q(t,5)))}),ee=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function te(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.map(o=>/^\s*(url\(|data:|<)/.test(String(o))&&String(o).trim().startsWith("<")?D(String(o)):String(o));const r=t.set||"arrows";if(r==="ratings"){const o=$(t),m=[];for(let e=1;e<=o;e++)m.push(D(q(e,o)));return m}const l=_[r];return l?l.map(D):(P(`iconSet:${r}`,`unknown icon set '${r}'; falling back to arrows.`),R.map(D))}function ne(t){const r=Number(t.min),o=Number(t.max)-r,m=t.colour||t.color||"#5b9bd5",e=t.negativeColour||t.negativeColor||"#d13438",u=t.direction==="rtl"?"left":"right",c=f=>Math.max(0,Math.min(1,(f-r)/o))*100,a=o?Math.max(0,Math.min(100,(0-r)/o*100)):0;return f=>{if(H(f))return null;const p=Number(f);if(!Number.isFinite(p)||!o)return null;const N=c(p),O=Math.min(N,a),I=Math.max(N,a),C=p>=0?m:e;return{backgroundImage:`linear-gradient(to ${u}, transparent ${O}%, ${C} ${O}%, ${C} ${I}%, transparent ${I}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function re(t){const r=te(t),l=t.reverse?[...r].reverse():r,o=(Array.isArray(t.thresholds)?t.thresholds:[]).map(Number).filter(Number.isFinite),m=Number.isFinite(Number(t.size))?Number(t.size):16,e=t.set==="ratings"?m*$(t):m;return u=>{if(H(u))return null;const c=Number(u);if(!Number.isFinite(c))return null;let a=0;for(const p of o)c>=p&&a++;const f=l[Math.min(a,l.length-1)];return f?{backgroundImage:f,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${e}px ${m}px`,paddingLeft:`${e+4}px`}:null}}function Q(t){const r=Array.isArray(t.colours)&&t.colours.length>=2?t.colours:["#f8f9fa","#1a6bc7"],l=Number(t.min),o=Number(t.max),m=o-l,e=r.length-1,u=[];for(let a=0;a<=e;a++)u.push(e?a/e:0);const c=Number(t.mid);if(t.mid!==void 0&&t.mid!==null)if(r.length%2===0)P("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${r.length} were given, so "mid" was ignored.`);else if(Number.isFinite(c)&&m&&c>Math.min(l,o)&&c<Math.max(l,o)){const a=e/2,f=Math.max(0,Math.min(1,(c-l)/m));for(let p=0;p<=e;p++)u[p]=p<=a?a?p/a*f:f:f+(p-a)/(e-a)*(1-f)}else Number.isFinite(c)&&P("formatting.scale.mid.range",`a scale's "mid" (${c}) is outside its min..max range, so it was ignored.`);return a=>{const f=Number(a);if(!Number.isFinite(f)||!m)return null;const p=Math.max(0,Math.min(1,(f-l)/m));let N=0;for(;N<e-1&&p>u[N+1];)N++;const O=u[N+1]-u[N],I=O>0?(p-u[N])/O:0;return{background:g(r[N],r[N+1],Math.max(0,Math.min(1,I)))}}}function ie(t,r=null){const l=j(t)?y(t,r):t,o=(Array.isArray(l)?l:[]).filter(e=>e&&typeof e=="object");if(!o.length)return()=>null;const m=o.map(e=>e.scale?{scale:Q(e.scale),enabled:e.enabled!==!1}:e.dataBar?{scale:ne(e.dataBar),enabled:e.enabled!==!1}:e.iconSet?{scale:re(e.iconSet),enabled:e.enabled!==!1}:{when:e.when,style:e.style,stop:e.stopIfTrue!==!1,enabled:e.enabled!==!1});return e=>{const u=e?e.value:void 0;let c=null;for(const a of m){if(!a.enabled)continue;if(a.scale){const p=a.scale(u);p&&(c={...c||{},...p});continue}if(!L(u,a.when))continue;const f=x(a.style)?a.style(e):a.style;if(f&&(c={...c||{},...f}),a.stop)break}return c}}}),oe("packages/modules/shared/emitter.js",function(d,K){"use strict";Object.defineProperty(d,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"Emitter",{enumerable:!0,get:function(){return k}}),Object.defineProperty(d,"gate",{enumerable:!0,get:function(){return H}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W="*",Y=new Set(["api","user","init","ai"]);function X(L,g){return L&&L.name?L.name:`#${g}`}class k{#t=new Map;#e;constructor(g="module"){this.#e=String(g)}on(g,S){if(!x(S))return()=>{};let b=this.#t.get(g);return b||(b=new Set,this.#t.set(g,b)),b.add(S),()=>this.off(g,S)}off(g,S){const b=this.#t.get(g);b&&b.delete(S)}count(g){const S=this.#t.get(g);return S?S.size:0}emit(g,S){const b=this.#t.get(g),j=this.#t.get(W);if((!b||b.size===0)&&(!j||j.size===0))return;const F={...S||null,type:g};b&&b.size&&this.#n([...b],F,g),j&&j.size&&this.#n([...j],F,W)}#n(g,S,b){for(let j=0;j<g.length;j++)try{g[j](S)}catch(F){P(`${this.#e}.emit.throw:${b}:${X(g[j],j)}`,`${this.#e}: a '${b}' handler threw; other handlers were unaffected.`,F)}}emitBefore(g,S,b){const j=b??(S&&S.origin),F=Y.has(j)?j:"user";let A=!1,U=null;const y=M=>{A=!0,M!=null&&U===null&&(U=String(M))},w={...S||null,type:g,origin:F,get defaultPrevented(){return A},get reason(){return U},preventDefault(M){y(M)}},v=this.#t.get(g);if(!v||v.size===0)return!0;const $=[...v],D=()=>(A&&U===null&&(U="prevented"),A&&S&&typeof S=="object"&&(S.reason=U),!A),T=[];for(let M=0;M<$.length;M++){const q=$[M];try{const R=q(w);R&&x(R.then)?T.push(R):R===!1&&y("prevented")}catch(R){y("error"),P(`${this.#e}.beforeThrow:${g}:${X(q,M)}`,`${this.#e}: a '${g}' before-handler threw; the action was cancelled.`,R)}}return T.length===0?D():Promise.allSettled(T).then(M=>{for(const q of M)q.status==="rejected"?(y("error"),P(`${this.#e}.beforeReject:${g}`,`${this.#e}: a '${g}' before-handler rejected; the action was cancelled.`,q.reason)):q.value===!1&&y("prevented");return D()})}clear(){this.#t.clear()}}function H(L,g,S,b,j){const F=L.emitBefore(g,b,b.origin),A=()=>(L.emit(S,{...b,reason:b.reason||"prevented"}),!1);return F===!1?A():F&&x(F.then)?F.then(U=>U?j():A()):j()}}),oe("packages/modules/alarms/index.js",function(d,K){"use strict";Object.defineProperty(d,"createAlarms",{enumerable:!0,get:function(){return A}}),Object.defineProperty(d,"default",{enumerable:!0,get:function(){return U}});const E=K("packages/core/src/internal/util.js"),x=E.warnOnce,P=E.isFunction,Y=K("packages/core/src/formatting/rules.js").testRule,k=K("packages/modules/shared/emitter.js").Emitter,H=Object.freeze(["alarm:raised","alarm:cleared"]),L=new Set(["warn","critical"]);function g(y){return typeof y=="string"&&L.has(y)}function S(y,w){if(typeof y!="number"||Number.isNaN(y))return null;if(Array.isArray(w&&w.bands)){for(const $ of w.bands){const D=$.min===void 0||$.min===null?-1/0:$.min,T=$.max===void 0||$.max===null?1/0:$.max;if(y>=D&&y<T)return $.status??null}return null}const v=w&&w.thresholds;return!v||v.warn===void 0||v.warn===null||v.critical===void 0||v.critical===null?null:v.direction==="lowerIsBetter"?y<=v.warn?"good":y<=v.critical?"warn":"critical":y>=v.warn?"good":y>=v.critical?"warn":"critical"}function b(y){const w=y||{};return{now:P(w.now)?w.now:()=>Date.now(),setTimeout:P(w.setTimeout)?w.setTimeout:((v,$)=>setTimeout(v,$)),clearTimeout:P(w.clearTimeout)?w.clearTimeout:(v=>clearTimeout(v))}}function j(y,w){return Number.isFinite(y)&&Number(y)>=0?Number(y):w}function F(y,w){return`${typeof y=="string"?y:JSON.stringify(y)}/${w}`}function A(y={}){const w=y||{},v=b(w.clock),$=j(w.holdMs,0),D=new k("alarms"),T=new Map,M=[],q=new Map,R=[];let J=!1;const _=e=>{const u=(q.get(e)||0)+1;return q.set(e,u),`${e}#${u}`},ee=(e,u)=>`${e.source}:${e.sourceId}:${e.key}:${u}`,te=(e,u,c)=>({id:ee(e,u),source:e.source,sourceId:e.sourceId,key:e.key,level:u,previous:c,value:e.value,threshold:e.threshold??null,band:e.band??null,at:v.now(),holdMs:e.holdMs}),ne=(e,u)=>{D.emit(e,u);for(const c of R)c(u,e)},re=(e,u)=>{const c=e.committed;if(c!==u&&(e.committed=u,g(c)&&(e.active=null,ne("alarm:cleared",te(e,c,c))),g(u))){const a=te(e,u,c);e.active=a,ne("alarm:raised",a)}},Q=(e,u,c={})=>{if(J)return;const a=`${e.source}\0${e.sourceId}\0${e.key}`;let f=T.get(a);if(f||(f={source:e.source,sourceId:e.sourceId,key:e.key,holdMs:e.holdMs,committed:null,active:null,pending:null,timer:null,value:void 0,threshold:null,band:null},T.set(a,f)),f.holdMs=e.holdMs,f.value=c.value,f.threshold=c.threshold??null,f.band=c.band??null,u===f.committed){f.timer!==null&&(v.clearTimeout(f.timer),f.timer=null),f.pending=null;return}if(!(g(f.committed)||g(u))||f.holdMs<=0){re(f,u);return}f.pending={level:u,at:v.now()},f.timer===null&&(f.timer=v.setTimeout(()=>{f.timer=null;const N=f.pending;f.pending=null,N&&re(f,N.level)},f.holdMs))},ie=e=>{const u=`${e.source}\0${e.sourceId}\0${e.key}`,c=T.get(u);c&&(Q(e,null,{value:void 0}),c.timer===null&&c.pending===null&&T.delete(u))},t=e=>{const u=new Map;return(e&&e.config&&e.config.tiles||[]).forEach((a,f)=>{a&&u.set(String(a.id??a.label??`tile${f}`),a)}),u},r=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("kpi"),a=j(u.holdMs,$),f=t(e),p=(O,I,C)=>{const B=f.get(String(O))||{};Q({source:"kpi",sourceId:c,key:String(O),holdMs:a},I??null,{value:C,threshold:B.thresholds??null,band:Array.isArray(B.bands)?B.bands:null})};for(const O of e.model&&e.model.tiles||[])p(O.id,O.status,O.value);const N=e.on("tile:status",O=>p(O.id,O.status,O.value));return()=>{P(N)&&N()}},l=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("grid"),a=j(u.holdMs,$),f=u.columns&&typeof u.columns=="object"?u.columns:null;(!f||Object.keys(f).length===0)&&x("alarms:grid-no-columns","alarms.attach(grid) was given no `columns`, so no cell can raise anything. Declare the columns to watch: attach(grid, { columns: { cpu: { thresholds: { warn: 80, critical: 95, direction: 'lowerIsBetter' } } } }).");let p=new Set;const N=()=>{const I=new Set;if(!(!P(e.rows.forEachAll)||!P(e.rows.value))){e.rows.forEachAll(C=>{const B=C&&C.key;if(B!=null)for(const[ue,n]of Object.entries(f||{})){if(!n)continue;const i=F(B,ue);I.add(i);const s=e.rows.value(B,ue);if(n.when&&!Y(s,n.when)){Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},null,{value:s});continue}Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},S(s,n),{value:s,threshold:n.thresholds??null,band:Array.isArray(n.bands)?n.bands:null})}});for(const C of p)I.has(C)||ie({source:"grid",sourceId:c,key:C,holdMs:a});p=I}},O=[];for(const I of["rows:changed","cell:changed","stream:chunk","stream:evicted"]){const C=e.on(I,N);P(C)&&O.push(C)}return N(),()=>{for(const I of O)I()}},o=(e,u,c)=>{const a=c.sourceId?String(c.sourceId):_("router"),f=j(c.holdMs,$),p=String(c.label??(typeof u=="function"?"route":u)),N=P(c.value)?c.value:(I=>I.length),O=e.monitor(u,N,I=>{Q({source:"router",sourceId:a,key:p,holdMs:f},S(I,c),{value:I,threshold:c.thresholds??null,band:Array.isArray(c.bands)?c.bands:null})});return()=>{P(O)&&O()}};return{attach(e,u,c){if(J||!e||typeof e!="object")return this;if(P(e.monitor)){const f=c||{},p=o(e,u,f);return M.push({kind:"router",sourceId:f.sourceId||"",release:p}),this}const a=u&&typeof u=="object"?u:{};return e.model&&Array.isArray(e.model.tiles)&&P(e.on)?(M.push({kind:"kpi",sourceId:a.sourceId||"",release:r(e,a)}),this):e.rows&&P(e.on)?(M.push({kind:"grid",sourceId:a.sourceId||"",release:l(e,a)}),this):(x("alarms:unknown-source","alarms.attach() was given something that is not a KPI panel, a grid or a data router; nothing was attached and no alarm can be raised from it."),this)},on(e,u){return H.includes(e)?D.on(e,u):(x(`alarms:unknown-event:${e}`,`alarms.on('${e}') will never fire; an alarm set emits ${H.join(" and ")}.`),()=>{})},active(){const e=[];for(const u of T.values())u.active&&e.push({...u.active});return e},pending(){const e=[];for(const u of T.values())u.pending&&e.push({id:ee(u,u.pending.level),source:u.source,sourceId:u.sourceId,key:u.key,level:u.pending.level,previous:u.committed,value:u.value,at:u.pending.at,holdMs:u.holdMs});return e},publish(e,u="alarms"){if(J||!e||!P(e.addSource))return x("alarms:publish-no-router","alarms.publish() needs a data router with addSource(); nothing was published."),this;const c=e.addSource(String(u));let a=0;return R.push((f,p)=>{a+=1,c.push({op:"upsert",row:{...f,id:`${f.id}#${a}`,alarmId:f.id,kind:String(u),state:p==="alarm:raised"?"raised":"cleared"}})}),this},destroy(){if(!J){J=!0;for(const e of M)try{e.release()}catch{}M.length=0;for(const e of T.values())e.timer!==null&&(v.clearTimeout(e.timer),e.timer=null),e.pending=null;T.clear(),R.length=0,D.clear()}}}}const U=A});var se=fe("packages/modules/alarms/index.js");typeof module=="object"&&module.exports?module.exports=se:typeof define=="function"&&define.amd?define(function(){return se}):de.LatticeGridAlarms=se})(typeof globalThis<"u"?globalThis:this);
6
+ (function(de){"use strict";var le=Object.create(null),ae=Object.create(null);function oe(d,K){le[d]=K}function fe(d){var K=ae[d];if(K)return K;var E=Object.create(null);ae[d]=E;var x=le[d];if(!x)throw new Error("[lattice] missing module: "+d);return x(E,fe),E}oe("packages/core/src/internal/util.js",function(d,K){"use strict";Object.defineProperty(d,"VERSION",{enumerable:!0,get:function(){return P}}),Object.defineProperty(d,"reportedWarnings",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"warnOnce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"infoOnce",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resetWarnings",{enumerable:!0,get:function(){return F}}),Object.defineProperty(d,"fail",{enumerable:!0,get:function(){return A}}),Object.defineProperty(d,"invariant",{enumerable:!0,get:function(){return U}}),Object.defineProperty(d,"DEV",{enumerable:!0,get:function(){return y}}),Object.defineProperty(d,"isObject",{enumerable:!0,get:function(){return w}}),Object.defineProperty(d,"isFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(d,"isNil",{enumerable:!0,get:function(){return $}}),Object.defineProperty(d,"isBlank",{enumerable:!0,get:function(){return D}}),Object.defineProperty(d,"isCtor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(d,"pathGetter",{enumerable:!0,get:function(){return q}}),Object.defineProperty(d,"pathSetter",{enumerable:!0,get:function(){return J}}),Object.defineProperty(d,"getPath",{enumerable:!0,get:function(){return _}}),Object.defineProperty(d,"setPath",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(d,"escapeHtml",{enumerable:!0,get:function(){return re}}),Object.defineProperty(d,"titleCase",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(d,"expand",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(d,"toArray",{enumerable:!0,get:function(){return t}}),Object.defineProperty(d,"merge",{enumerable:!0,get:function(){return l}}),Object.defineProperty(d,"mergeRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(d,"Lru",{enumerable:!0,get:function(){return m}}),Object.defineProperty(d,"collator",{enumerable:!0,get:function(){return u}}),Object.defineProperty(d,"defaultCompare",{enumerable:!0,get:function(){return c}}),Object.defineProperty(d,"now",{enumerable:!0,get:function(){return a}}),Object.defineProperty(d,"nextFrame",{enumerable:!0,get:function(){return p}}),Object.defineProperty(d,"cancelFrame",{enumerable:!0,get:function(){return N}}),Object.defineProperty(d,"frameBatched",{enumerable:!0,get:function(){return O}}),Object.defineProperty(d,"settleDebounce",{enumerable:!0,get:function(){return I}}),Object.defineProperty(d,"whenIdle",{enumerable:!0,get:function(){return C}}),Object.defineProperty(d,"uid",{enumerable:!0,get:function(){return ue}});const E="1.71.3";async function x(){return E}const P="1.71.3",W=new Set,Y=2e3;function X(n){if(W.add(n),W.size>Y){const i=W.values().next().value;i!==void 0&&W.delete(i)}}const k=[],H=500;function L(n,i,s){k.push({key:n,level:i,message:s.map(h=>typeof h=="string"?h:g(h)).join(" "),at:Date.now()}),k.length>H&&k.shift()}function g(n){if(n instanceof Error)return n.message;try{return JSON.stringify(n)}catch{return String(n)}}function S(){return k.map(n=>({...n}))}function b(n,...i){W.has(n)||(X(n),L(n,"warn",i),console.warn("[lattice]",...i))}function j(n,...i){W.has(n)||(X(n),L(n,"info",i),console.info("[lattice]",...i))}function F(){W.clear(),k.length=0}function A(n,i){const s=new Error(`[lattice] ${n}`);throw i!==void 0&&(s.cause=i),s}function U(n,i){n||A(i)}const y=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function w(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n){return typeof n=="function"}function $(n){return n==null}function D(n){return n==null||n===""}function T(n){return typeof n!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(n))?!0:!!(n.prototype&&Object.getOwnPropertyNames(n.prototype).length>1)}const M=new Map;function q(n){let i=M.get(n);if(i)return i;if(!n.includes("."))i=s=>s?.[n];else{const s=n.split("."),h=s.length;i=V=>{let G=V;for(let z=0;z<h;z++){if(G==null)return;G=G[s[z]]}return G}}return M.set(n,i),i}const R=new Map;function J(n){let i=R.get(n);if(i)return i;if(!n.includes("."))i=(s,h)=>{s!=null&&(s[n]=h)};else{const s=n.split("."),h=s.length-1;i=(V,G)=>{let z=V;for(let Z=0;Z<h;Z++){if(z==null)return;const ce=s[Z];z[ce]==null&&(z[ce]={}),z=z[ce]}z!=null&&(z[s[h]]=G)}}return R.set(n,i),i}function _(n,i){return q(i)(n)}function ee(n,i,s){J(i)(n,s)}function te(n){return n?(n.includes(".")?n.slice(n.lastIndexOf(".")+1):n).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(/^./,s=>s.toUpperCase()):""}const ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function re(n){const i=n==null?"":String(n);return/[&<>"']/.test(i)?i.replace(/[&<>"']/g,s=>ne[s]):i}function Q(n){return String(n).replace(/\w\S*/g,i=>i[0].toUpperCase()+i.slice(1).toLowerCase())}function ie(n,i,s){if(n!==void 0)return n===!0?{enabled:!0,...s}:n===!1?{enabled:!1}:w(n)?n:{[i]:n,enabled:!0}}function t(n){return n==null?[]:Array.isArray(n)?n:[n]}const r=Object.freeze(new Set(["__proto__","constructor","prototype"]));function l(n,i){if(!w(n))return w(i)?{...i}:i;if(!w(i))return i===void 0?n:i;const s={...n};for(const h of Object.keys(i)){if(r.has(h))continue;const V=i[h];V!==void 0&&(s[h]=w(V)&&w(s[h])?l(s[h],V):V)}return s}function o(n,i){if(!w(n)||!w(i)||n===i)return i;const s=Object.create(Object.getPrototypeOf(n));return Object.assign(s,n,i),s}class m{#t;#e=new Map;#n;constructor(i=256,s=null){this.#t=i,this.#n=s}get size(){return this.#e.size}get max(){return this.#t}set max(i){this.#t=i,this.#r()}has(i){return this.#e.has(i)}get(i){const s=this.#e;if(!s.has(i))return;const h=s.get(i);return s.delete(i),s.set(i,h),h}peek(i){return this.#e.get(i)}set(i,s){const h=this.#e;return h.has(i)&&h.delete(i),h.set(i,s),this.#r(),s}delete(i){const s=this.#e.get(i);return this.#e.delete(i)&&this.#n&&this.#n(s,i),s}clear(){if(this.#n)for(const[i,s]of this.#e)this.#n(s,i);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const i=this.#e;for(;i.size>this.#t;){const s=i.keys().next().value,h=i.get(s);i.delete(s),this.#n&&this.#n(h,s)}}}const e=new Map;function u(n,i){const s=`${n||""}|${i?JSON.stringify(i):""}`;let h=e.get(s);return h||(h=new Intl.Collator(n||void 0,{numeric:!0,sensitivity:"variant",...i}),e.set(s,h)),h}function c(n,i){if(n===i)return 0;if(n==null)return 1;if(i==null)return-1;if(typeof n=="number"&&typeof i=="number")return Number.isNaN(n)?Number.isNaN(i)?0:1:Number.isNaN(i)||n<i?-1:n>i?1:0;const s=String(n),h=String(i);return s<h?-1:s>h?1:0}function a(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const f=typeof requestAnimationFrame=="function";function p(n){return f?requestAnimationFrame(n):setTimeout(()=>n(a()),16)}function N(n){n!=null&&(f?cancelAnimationFrame(n):clearTimeout(n))}function O(n){let i=null,s=null;const h=()=>{i=null;const G=s;s=null,n(...G||[])},V=(...G)=>{s=G,i===null&&(i=p(h))};return V.cancel=()=>{N(i),i=null,s=null},V.flush=()=>{i!==null&&(N(i),h())},V}function I(n,i){let s=null,h=null;const V=()=>{if(s=null,h===null)return;const Z=h;h=null,n(...Z),G()},G=()=>{s=setTimeout(V,i),typeof s?.unref=="function"&&s.unref()},z=(...Z)=>{s===null?(n(...Z),G()):(h=Z,clearTimeout(s),G())};return z.flush=()=>{if(s!==null&&clearTimeout(s),s=null,h===null)return;const Z=h;h=null,n(...Z)},z.cancel=()=>{s!==null&&clearTimeout(s),s=null,h=null},z.pending=()=>s!==null||h!==null,z}function C(n,i=50){return typeof requestIdleCallback=="function"?requestIdleCallback(n,{timeout:i}):setTimeout(()=>n({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function ue(n="l"){return`${n}${(++B).toString(36)}`}}),oe("packages/core/src/formatting/rules.js",function(d,K){"use strict";Object.defineProperty(d,"RULE_OPS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(d,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(d,"testRule",{enumerable:!0,get:function(){return L}}),Object.defineProperty(d,"mixColour",{enumerable:!0,get:function(){return g}}),Object.defineProperty(d,"summariseColumn",{enumerable:!0,get:function(){return S}}),Object.defineProperty(d,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(d,"needsDistribution",{enumerable:!0,get:function(){return j}}),Object.defineProperty(d,"resolveDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(d,"ICON_SETS",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(d,"compileRules",{enumerable:!0,get:function(){return ie}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),Y=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),X=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function k(t,r){const l=Number(t),o=Number(r);if(t!==null&&t!==""&&r!==null&&r!==""&&Number.isFinite(l)&&Number.isFinite(o))return l<o?-1:l>o?1:0;const e=String(t??"").toLowerCase(),u=String(r??"").toLowerCase();return e<u?-1:e>u?1:0}function H(t){return t==null||t===""}function L(t,r){if(!r||typeof r!="object")return!1;const{op:l}=r,o=r.value,m=r.value2;switch(l){case"blank":return H(t);case"notBlank":return!H(t);case"true":return t===!0;case"false":return t===!1;default:break}if(H(t))return!1;switch(l){case"eq":return k(t,o)===0;case"ne":return k(t,o)!==0;case"gt":return k(t,o)>0;case"gte":return k(t,o)>=0;case"lt":return k(t,o)<0;case"lte":return k(t,o)<=0;case"between":return k(t,o)>=0&&k(t,m)<=0;case"outside":return k(t,o)<0||k(t,m)>0;case"contains":return String(t).toLowerCase().includes(String(o??"").toLowerCase());case"notContains":return!String(t).toLowerCase().includes(String(o??"").toLowerCase());case"startsWith":return String(t).toLowerCase().startsWith(String(o??"").toLowerCase());case"endsWith":return String(t).toLowerCase().endsWith(String(o??"").toLowerCase());default:return!1}}function g(t,r,l){const o=O=>{const I=String(O).replace("#",""),C=I.length===3?I.split("").map(B=>B+B).join(""):I;return[0,2,4].map(B=>parseInt(C.slice(B,B+2),16)||0)},[m,e,u]=o(t),[c,a,f]=o(r),p=Math.max(0,Math.min(1,l)),N=(O,I)=>Math.round(O+(I-O)*p);return`#${[N(m,c),N(e,a),N(u,f)].map(O=>O.toString(16).padStart(2,"0")).join("")}`}function S(t){const r=[];for(const c of t||[]){if(c==null||c==="")continue;const a=c instanceof Date?c.getTime():Number(c);Number.isFinite(a)&&r.push(a)}if(!r.length)return null;r.sort((c,a)=>c-a);let l=0,o=0,m=0;for(const c of r){l++;const a=c-o;o+=a/l,m+=a*(c-o)}const e=b(r,.25),u=b(r,.75);return{n:r.length,min:r[0],max:r[r.length-1],mean:o,stddev:r.length>1?Math.sqrt(m/(r.length-1)):0,median:b(r,.5),q1:e,q3:u,iqr:u-e,sorted:r}}function b(t,r){if(!t.length)return 0;const l=(t.length-1)*Math.max(0,Math.min(1,r)),o=Math.floor(l),m=Math.ceil(l);return o===m?t[o]:t[o]+(l-o)*(t[m]-t[o])}function j(t){for(const r of Array.isArray(t)?t:[])if(!(!r||typeof r!="object")&&(r.when&&Y.includes(r.when.op)||r.scale&&r.scale.from||r.dataBar&&!(Number.isFinite(Number(r.dataBar.min))&&Number.isFinite(Number(r.dataBar.max)))||r.iconSet&&!Array.isArray(r.iconSet.thresholds)))return!0;return!1}function F(t,r){const l=Number(t.value),o=m=>b(r.sorted,m);switch(t.op){case"topPercent":{const m=A(l,10);return{op:"gte",value:o(1-m)}}case"bottomPercent":{const m=A(l,10);return{op:"lte",value:o(m)}}case"topN":{const m=Math.max(1,Math.floor(l)||1),e=Math.max(0,r.sorted.length-m);return{op:"gte",value:r.sorted[e]}}case"bottomN":{const m=Math.max(1,Math.floor(l)||1),e=Math.min(r.sorted.length-1,m-1);return{op:"lte",value:r.sorted[e]}}case"aboveMean":return{op:"gt",value:r.mean};case"belowMean":return{op:"lt",value:r.mean};case"aboveMedian":return{op:"gt",value:r.median};case"belowMedian":return{op:"lt",value:r.median};case"zAbove":return r.stddev?{op:"gte",value:r.mean+(Number.isFinite(l)?l:2)*r.stddev}:null;case"zBelow":return r.stddev?{op:"lte",value:r.mean-(Number.isFinite(l)?l:2)*r.stddev}:null;case"outlier":{const m=(Number.isFinite(l)&&l>0?l:1.5)*r.iqr;return r.iqr?{op:"outside",value:r.q1-m,value2:r.q3+m}:null}default:return null}}function A(t,r){const l=Number.isFinite(t)?t:r,o=l>1?l/100:l;return Math.max(0,Math.min(1,o))}function U(t,r){if(t.from==="minmax")return{...t,min:r.min,max:r.max};if(t.from==="quantile")return{...t,min:b(r.sorted,A(Number(t.low),5)),max:b(r.sorted,A(Number(t.high),95))};if(t.from==="stddev"){const l=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:r.mean-l*r.stddev,max:r.mean+l*r.stddev}}return t}function y(t,r){const l=Array.isArray(t)?t:[];return!r||!r.n?l.map(o=>o&&j([o])?{...o,enabled:!1}:o):l.map(o=>{if(!o||typeof o!="object")return o;if(o.scale&&o.scale.from)return{...o,scale:U(o.scale,r)};if(o.dataBar)return{...o,dataBar:w(o.dataBar,r)};if(o.iconSet)return{...o,iconSet:v(o.iconSet,r)};if(!o.when||!Y.includes(o.when.op))return o;const m=F(o.when,r);return m?{...o,when:m}:{...o,enabled:!1}})}function w(t,r){const l=Number.isFinite(Number(t.min))?Number(t.min):void 0,o=Number.isFinite(Number(t.max))?Number(t.max):void 0;if(l!==void 0&&o!==void 0)return{...t,min:l,max:o};if(t.from==="quantile")return{...t,min:l??b(r.sorted,A(Number(t.low),5)),max:o??b(r.sorted,A(Number(t.high),95))};if(t.from==="stddev"){const m=Number.isFinite(Number(t.deviations))?Number(t.deviations):2;return{...t,min:l??r.mean-m*r.stddev,max:o??r.mean+m*r.stddev}}return{...t,min:l??r.min,max:o??r.max}}function v(t,r){if(Array.isArray(t.thresholds))return t;const l=$(t),o=[];for(let m=1;m<l;m++)o.push(b(r.sorted,m/l));return{...t,thresholds:o}}function $(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.length;if(Number.isFinite(Number(t.count))&&Number(t.count)>=2)return Math.floor(Number(t.count));const r=_[t.set];return r?r.length:3}function D(t){return`url("data:image/svg+xml,${encodeURIComponent(t)}")`}function T(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${t}"/></svg>`}function M(t,r){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${r==="up"?"8,2 14,13 2,13":r==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${t}"/></svg>`}function q(t,r){const l="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let o=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${r*16} 16">`;for(let m=0;m<r;m++){const e=m<t?"#f5a623":"#d0d0d0";o+=`<path transform="translate(${m*16},0)" d="${l}" fill="${e}"/>`}return`${o}</svg>`}const R=Object.freeze([M("#c0392b","down"),M("#e0a800","right"),M("#2e7d32","up")]),J=Object.freeze([T("#d13438"),T("#f5a623"),T("#2e9e44")]),_=Object.freeze({arrows:R,trafficLights:J,ratings:Object.freeze([1,2,3,4,5].map(t=>q(t,5)))}),ee=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function te(t){if(Array.isArray(t.icons)&&t.icons.length>=2)return t.icons.map(o=>/^\s*(url\(|data:|<)/.test(String(o))&&String(o).trim().startsWith("<")?D(String(o)):String(o));const r=t.set||"arrows";if(r==="ratings"){const o=$(t),m=[];for(let e=1;e<=o;e++)m.push(D(q(e,o)));return m}const l=_[r];return l?l.map(D):(P(`iconSet:${r}`,`unknown icon set '${r}'; falling back to arrows.`),R.map(D))}function ne(t){const r=Number(t.min),o=Number(t.max)-r,m=t.colour||t.color||"#5b9bd5",e=t.negativeColour||t.negativeColor||"#d13438",u=t.direction==="rtl"?"left":"right",c=f=>Math.max(0,Math.min(1,(f-r)/o))*100,a=o?Math.max(0,Math.min(100,(0-r)/o*100)):0;return f=>{if(H(f))return null;const p=Number(f);if(!Number.isFinite(p)||!o)return null;const N=c(p),O=Math.min(N,a),I=Math.max(N,a),C=p>=0?m:e;return{backgroundImage:`linear-gradient(to ${u}, transparent ${O}%, ${C} ${O}%, ${C} ${I}%, transparent ${I}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function re(t){const r=te(t),l=t.reverse?[...r].reverse():r,o=(Array.isArray(t.thresholds)?t.thresholds:[]).map(Number).filter(Number.isFinite),m=Number.isFinite(Number(t.size))?Number(t.size):16,e=t.set==="ratings"?m*$(t):m;return u=>{if(H(u))return null;const c=Number(u);if(!Number.isFinite(c))return null;let a=0;for(const p of o)c>=p&&a++;const f=l[Math.min(a,l.length-1)];return f?{backgroundImage:f,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${e}px ${m}px`,paddingLeft:`${e+4}px`}:null}}function Q(t){const r=Array.isArray(t.colours)&&t.colours.length>=2?t.colours:["#f8f9fa","#1a6bc7"],l=Number(t.min),o=Number(t.max),m=o-l,e=r.length-1,u=[];for(let a=0;a<=e;a++)u.push(e?a/e:0);const c=Number(t.mid);if(t.mid!==void 0&&t.mid!==null)if(r.length%2===0)P("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${r.length} were given, so "mid" was ignored.`);else if(Number.isFinite(c)&&m&&c>Math.min(l,o)&&c<Math.max(l,o)){const a=e/2,f=Math.max(0,Math.min(1,(c-l)/m));for(let p=0;p<=e;p++)u[p]=p<=a?a?p/a*f:f:f+(p-a)/(e-a)*(1-f)}else Number.isFinite(c)&&P("formatting.scale.mid.range",`a scale's "mid" (${c}) is outside its min..max range, so it was ignored.`);return a=>{const f=Number(a);if(!Number.isFinite(f)||!m)return null;const p=Math.max(0,Math.min(1,(f-l)/m));let N=0;for(;N<e-1&&p>u[N+1];)N++;const O=u[N+1]-u[N],I=O>0?(p-u[N])/O:0;return{background:g(r[N],r[N+1],Math.max(0,Math.min(1,I)))}}}function ie(t,r=null){const l=j(t)?y(t,r):t,o=(Array.isArray(l)?l:[]).filter(e=>e&&typeof e=="object");if(!o.length)return()=>null;const m=o.map(e=>e.scale?{scale:Q(e.scale),enabled:e.enabled!==!1}:e.dataBar?{scale:ne(e.dataBar),enabled:e.enabled!==!1}:e.iconSet?{scale:re(e.iconSet),enabled:e.enabled!==!1}:{when:e.when,style:e.style,stop:e.stopIfTrue!==!1,enabled:e.enabled!==!1});return e=>{const u=e?e.value:void 0;let c=null;for(const a of m){if(!a.enabled)continue;if(a.scale){const p=a.scale(u);p&&(c={...c||{},...p});continue}if(!L(u,a.when))continue;const f=x(a.style)?a.style(e):a.style;if(f&&(c={...c||{},...f}),a.stop)break}return c}}}),oe("packages/modules/shared/emitter.js",function(d,K){"use strict";Object.defineProperty(d,"WILDCARD",{enumerable:!0,get:function(){return W}}),Object.defineProperty(d,"Emitter",{enumerable:!0,get:function(){return k}}),Object.defineProperty(d,"gate",{enumerable:!0,get:function(){return H}});const E=K("packages/core/src/internal/util.js"),x=E.isFunction,P=E.warnOnce,W="*",Y=new Set(["api","user","init","ai"]);function X(L,g){return L&&L.name?L.name:`#${g}`}class k{#t=new Map;#e;constructor(g="module"){this.#e=String(g)}on(g,S){if(!x(S))return()=>{};let b=this.#t.get(g);return b||(b=new Set,this.#t.set(g,b)),b.add(S),()=>this.off(g,S)}off(g,S){const b=this.#t.get(g);b&&b.delete(S)}count(g){const S=this.#t.get(g);return S?S.size:0}emit(g,S){const b=this.#t.get(g),j=this.#t.get(W);if((!b||b.size===0)&&(!j||j.size===0))return;const F={...S||null,type:g};b&&b.size&&this.#n([...b],F,g),j&&j.size&&this.#n([...j],F,W)}#n(g,S,b){for(let j=0;j<g.length;j++)try{g[j](S)}catch(F){P(`${this.#e}.emit.throw:${b}:${X(g[j],j)}`,`${this.#e}: a '${b}' handler threw; other handlers were unaffected.`,F)}}emitBefore(g,S,b){const j=b??(S&&S.origin),F=Y.has(j)?j:"user";let A=!1,U=null;const y=M=>{A=!0,M!=null&&U===null&&(U=String(M))},w={...S||null,type:g,origin:F,get defaultPrevented(){return A},get reason(){return U},preventDefault(M){y(M)}},v=this.#t.get(g);if(!v||v.size===0)return!0;const $=[...v],D=()=>(A&&U===null&&(U="prevented"),A&&S&&typeof S=="object"&&(S.reason=U),!A),T=[];for(let M=0;M<$.length;M++){const q=$[M];try{const R=q(w);R&&x(R.then)?T.push(R):R===!1&&y("prevented")}catch(R){y("error"),P(`${this.#e}.beforeThrow:${g}:${X(q,M)}`,`${this.#e}: a '${g}' before-handler threw; the action was cancelled.`,R)}}return T.length===0?D():Promise.allSettled(T).then(M=>{for(const q of M)q.status==="rejected"?(y("error"),P(`${this.#e}.beforeReject:${g}`,`${this.#e}: a '${g}' before-handler rejected; the action was cancelled.`,q.reason)):q.value===!1&&y("prevented");return D()})}clear(){this.#t.clear()}}function H(L,g,S,b,j){const F=L.emitBefore(g,b,b.origin),A=()=>(L.emit(S,{...b,reason:b.reason||"prevented"}),!1);return F===!1?A():F&&x(F.then)?F.then(U=>U?j():A()):j()}}),oe("packages/modules/alarms/index.js",function(d,K){"use strict";Object.defineProperty(d,"createAlarms",{enumerable:!0,get:function(){return A}}),Object.defineProperty(d,"default",{enumerable:!0,get:function(){return U}});const E=K("packages/core/src/internal/util.js"),x=E.warnOnce,P=E.isFunction,Y=K("packages/core/src/formatting/rules.js").testRule,k=K("packages/modules/shared/emitter.js").Emitter,H=Object.freeze(["alarm:raised","alarm:cleared"]),L=new Set(["warn","critical"]);function g(y){return typeof y=="string"&&L.has(y)}function S(y,w){if(typeof y!="number"||Number.isNaN(y))return null;if(Array.isArray(w&&w.bands)){for(const $ of w.bands){const D=$.min===void 0||$.min===null?-1/0:$.min,T=$.max===void 0||$.max===null?1/0:$.max;if(y>=D&&y<T)return $.status??null}return null}const v=w&&w.thresholds;return!v||v.warn===void 0||v.warn===null||v.critical===void 0||v.critical===null?null:v.direction==="lowerIsBetter"?y<=v.warn?"good":y<=v.critical?"warn":"critical":y>=v.warn?"good":y>=v.critical?"warn":"critical"}function b(y){const w=y||{};return{now:P(w.now)?w.now:()=>Date.now(),setTimeout:P(w.setTimeout)?w.setTimeout:((v,$)=>setTimeout(v,$)),clearTimeout:P(w.clearTimeout)?w.clearTimeout:(v=>clearTimeout(v))}}function j(y,w){return Number.isFinite(y)&&Number(y)>=0?Number(y):w}function F(y,w){return`${typeof y=="string"?y:JSON.stringify(y)}/${w}`}function A(y={}){const w=y||{},v=b(w.clock),$=j(w.holdMs,0),D=new k("alarms"),T=new Map,M=[],q=new Map,R=[];let J=!1;const _=e=>{const u=(q.get(e)||0)+1;return q.set(e,u),`${e}#${u}`},ee=(e,u)=>`${e.source}:${e.sourceId}:${e.key}:${u}`,te=(e,u,c)=>({id:ee(e,u),source:e.source,sourceId:e.sourceId,key:e.key,level:u,previous:c,value:e.value,threshold:e.threshold??null,band:e.band??null,at:v.now(),holdMs:e.holdMs}),ne=(e,u)=>{D.emit(e,u);for(const c of R)c(u,e)},re=(e,u)=>{const c=e.committed;if(c!==u&&(e.committed=u,g(c)&&(e.active=null,ne("alarm:cleared",te(e,c,c))),g(u))){const a=te(e,u,c);e.active=a,ne("alarm:raised",a)}},Q=(e,u,c={})=>{if(J)return;const a=`${e.source}\0${e.sourceId}\0${e.key}`;let f=T.get(a);if(f||(f={source:e.source,sourceId:e.sourceId,key:e.key,holdMs:e.holdMs,committed:null,active:null,pending:null,timer:null,value:void 0,threshold:null,band:null},T.set(a,f)),f.holdMs=e.holdMs,f.value=c.value,f.threshold=c.threshold??null,f.band=c.band??null,u===f.committed){f.timer!==null&&(v.clearTimeout(f.timer),f.timer=null),f.pending=null;return}if(!(g(f.committed)||g(u))||f.holdMs<=0){re(f,u);return}f.pending={level:u,at:v.now()},f.timer===null&&(f.timer=v.setTimeout(()=>{f.timer=null;const N=f.pending;f.pending=null,N&&re(f,N.level)},f.holdMs))},ie=e=>{const u=`${e.source}\0${e.sourceId}\0${e.key}`,c=T.get(u);c&&(Q(e,null,{value:void 0}),c.timer===null&&c.pending===null&&T.delete(u))},t=e=>{const u=new Map;return(e&&e.config&&e.config.tiles||[]).forEach((a,f)=>{a&&u.set(String(a.id??a.label??`tile${f}`),a)}),u},r=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("kpi"),a=j(u.holdMs,$),f=t(e),p=(O,I,C)=>{const B=f.get(String(O))||{};Q({source:"kpi",sourceId:c,key:String(O),holdMs:a},I??null,{value:C,threshold:B.thresholds??null,band:Array.isArray(B.bands)?B.bands:null})};for(const O of e.model&&e.model.tiles||[])p(O.id,O.status,O.value);const N=e.on("tile:status",O=>p(O.id,O.status,O.value));return()=>{P(N)&&N()}},l=(e,u)=>{const c=u.sourceId?String(u.sourceId):_("grid"),a=j(u.holdMs,$),f=u.columns&&typeof u.columns=="object"?u.columns:null;(!f||Object.keys(f).length===0)&&x("alarms:grid-no-columns","alarms.attach(grid) was given no `columns`, so no cell can raise anything. Declare the columns to watch: attach(grid, { columns: { cpu: { thresholds: { warn: 80, critical: 95, direction: 'lowerIsBetter' } } } }).");let p=new Set;const N=()=>{const I=new Set;if(!(!P(e.rows.forEachAll)||!P(e.rows.value))){e.rows.forEachAll(C=>{const B=C&&C.key;if(B!=null)for(const[ue,n]of Object.entries(f||{})){if(!n)continue;const i=F(B,ue);I.add(i);const s=e.rows.value(B,ue);if(n.when&&!Y(s,n.when)){Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},null,{value:s});continue}Q({source:"grid",sourceId:c,key:i,holdMs:j(n.holdMs,a)},S(s,n),{value:s,threshold:n.thresholds??null,band:Array.isArray(n.bands)?n.bands:null})}});for(const C of p)I.has(C)||ie({source:"grid",sourceId:c,key:C,holdMs:a});p=I}},O=[];for(const I of["rows:changed","cell:changed","stream:chunk","stream:evicted"]){const C=e.on(I,N);P(C)&&O.push(C)}return N(),()=>{for(const I of O)I()}},o=(e,u,c)=>{const a=c.sourceId?String(c.sourceId):_("router"),f=j(c.holdMs,$),p=String(c.label??(typeof u=="function"?"route":u)),N=P(c.value)?c.value:(I=>I.length),O=e.monitor(u,N,I=>{Q({source:"router",sourceId:a,key:p,holdMs:f},S(I,c),{value:I,threshold:c.thresholds??null,band:Array.isArray(c.bands)?c.bands:null})});return()=>{P(O)&&O()}};return{attach(e,u,c){if(J||!e||typeof e!="object")return this;if(P(e.monitor)){const f=c||{},p=o(e,u,f);return M.push({kind:"router",sourceId:f.sourceId||"",release:p}),this}const a=u&&typeof u=="object"?u:{};return e.model&&Array.isArray(e.model.tiles)&&P(e.on)?(M.push({kind:"kpi",sourceId:a.sourceId||"",release:r(e,a)}),this):e.rows&&P(e.on)?(M.push({kind:"grid",sourceId:a.sourceId||"",release:l(e,a)}),this):(x("alarms:unknown-source","alarms.attach() was given something that is not a KPI panel, a grid or a data router; nothing was attached and no alarm can be raised from it."),this)},on(e,u){return H.includes(e)?D.on(e,u):(x(`alarms:unknown-event:${e}`,`alarms.on('${e}') will never fire; an alarm set emits ${H.join(" and ")}.`),()=>{})},active(){const e=[];for(const u of T.values())u.active&&e.push({...u.active});return e},pending(){const e=[];for(const u of T.values())u.pending&&e.push({id:ee(u,u.pending.level),source:u.source,sourceId:u.sourceId,key:u.key,level:u.pending.level,previous:u.committed,value:u.value,at:u.pending.at,holdMs:u.holdMs});return e},publish(e,u="alarms"){if(J||!e||!P(e.addSource))return x("alarms:publish-no-router","alarms.publish() needs a data router with addSource(); nothing was published."),this;const c=e.addSource(String(u));let a=0;return R.push((f,p)=>{a+=1,c.push({op:"upsert",row:{...f,id:`${f.id}#${a}`,alarmId:f.id,kind:String(u),state:p==="alarm:raised"?"raised":"cleared"}})}),this},destroy(){if(!J){J=!0;for(const e of M)try{e.release()}catch{}M.length=0;for(const e of T.values())e.timer!==null&&(v.clearTimeout(e.timer),e.timer=null),e.pending=null;T.clear(),R.length=0,D.clear()}}}}const U=A});var se=fe("packages/modules/alarms/index.js");typeof module=="object"&&module.exports?module.exports=se:typeof define=="function"&&define.amd?define(function(){return se}):de.LatticeGridAlarms=se})(typeof globalThis<"u"?globalThis:this);
7
7
 
8
8
  //# sourceMappingURL=alarms.min.js.map