@toclocoinc/lattice-grid 1.74.0 → 1.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +44 -6
- package/docs/CHART-CODES.md +8 -0
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.html +1 -1
- package/docs/api/charts.html +28 -2
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +2 -2
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +13 -1
- package/docs/api-detail.html +13 -4
- package/docs/warnings.json +36 -3
- package/lattice-grid.d.ts +37 -2
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- package/lattice-grid.min.js +3 -3
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +2 -2
- package/modules/ai.min.cjs +2 -2
- package/modules/ai.min.js +2 -2
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +2 -2
- package/modules/alarms.min.cjs +2 -2
- package/modules/alarms.min.js +2 -2
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +2 -2
- package/modules/chart-calendar.esm.min.js.map +1 -1
- package/modules/chart-calendar.min.cjs +2 -2
- package/modules/chart-calendar.min.js +2 -2
- package/modules/chart-calendar.min.js.map +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +2 -2
- package/modules/chart-choropleth.esm.min.js.map +1 -1
- package/modules/chart-choropleth.min.cjs +2 -2
- package/modules/chart-choropleth.min.js +2 -2
- package/modules/chart-choropleth.min.js.map +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +2 -2
- package/modules/chart-hexbin.esm.min.js.map +1 -1
- package/modules/chart-hexbin.min.cjs +2 -2
- package/modules/chart-hexbin.min.js +2 -2
- package/modules/chart-hexbin.min.js.map +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +2 -2
- package/modules/chart-hexmap.esm.min.js.map +1 -1
- package/modules/chart-hexmap.min.cjs +2 -2
- package/modules/chart-hexmap.min.js +2 -2
- package/modules/chart-hexmap.min.js.map +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +185 -178
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +185 -178
- package/modules/charts.min.js +185 -178
- package/modules/charts.min.js.map +2 -2
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +2 -2
- package/modules/data-router.min.cjs +2 -2
- package/modules/data-router.min.js +2 -2
- package/modules/deckgl.d.ts +9 -3
- package/modules/deckgl.esm.min.js +18 -11
- package/modules/deckgl.esm.min.js.map +2 -2
- package/modules/deckgl.min.cjs +18 -11
- package/modules/deckgl.min.js +18 -11
- package/modules/deckgl.min.js.map +2 -2
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +1 -1
- package/modules/devtools.min.cjs +1 -1
- package/modules/devtools.min.js +1 -1
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +2 -2
- package/modules/dhtmlx-compat.min.cjs +2 -2
- package/modules/dhtmlx-compat.min.js +2 -2
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +2 -2
- package/modules/gantt.min.cjs +2 -2
- package/modules/gantt.min.js +2 -2
- package/modules/geo-europe-nuts.d.ts +1 -1
- package/modules/geo-europe-nuts.esm.min.js +1 -1
- package/modules/geo-europe-nuts.min.cjs +1 -1
- package/modules/geo-europe-nuts.min.js +1 -1
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +1 -1
- package/modules/geo-uk.min.js +1 -1
- package/modules/geo-us-states.d.ts +1 -1
- package/modules/geo-us-states.esm.min.js +1 -1
- package/modules/geo-us-states.min.cjs +1 -1
- package/modules/geo-us-states.min.js +1 -1
- package/modules/geo-world-110m.d.ts +1 -1
- package/modules/geo-world-110m.esm.min.js +1 -1
- package/modules/geo-world-110m.min.cjs +1 -1
- package/modules/geo-world-110m.min.js +1 -1
- package/modules/geo-world-50m.d.ts +1 -1
- package/modules/geo-world-50m.esm.min.js +1 -1
- package/modules/geo-world-50m.min.cjs +1 -1
- package/modules/geo-world-50m.min.js +1 -1
- package/modules/geometry.d.ts +1 -1
- package/modules/geometry.esm.min.js +2 -2
- package/modules/geometry.min.cjs +2 -2
- package/modules/geometry.min.js +2 -2
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +3 -3
- package/modules/htmx.min.cjs +3 -3
- package/modules/htmx.min.js +3 -3
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +2 -2
- package/modules/kanban.min.cjs +2 -2
- package/modules/kanban.min.js +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +2 -2
- package/modules/kpi.min.cjs +2 -2
- package/modules/kpi.min.js +2 -2
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +2 -2
- package/modules/layout.min.cjs +2 -2
- package/modules/layout.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +1 -1
- package/modules/mock-socket.min.cjs +1 -1
- package/modules/mock-socket.min.js +1 -1
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +2 -2
- package/modules/tabs.min.cjs +2 -2
- package/modules/tabs.min.js +2 -2
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +3 -3
- package/modules/webcomponent.min.cjs +3 -3
- package/modules/webcomponent.min.js +3 -3
- package/package.json +1 -1
package/modules/ai.d.ts
CHANGED
package/modules/ai.esm.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, 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 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 P=we[h];if(!P)throw new Error("[lattice] missing module: "+h);return P(m,ke),m}fe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return L}}),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 F}}),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 y}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return t}}),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 l}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return z}}),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 he}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return Z}});const m="1.74.0";async function P(){return m}const L="1.74.0",q=new Set,R=2e3;function _(b){if(q.add(b),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(b,w,$){K.push({key:b,level:w,message:$.map(U=>typeof U=="string"?U:H(U)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function H(b){if(b instanceof Error)return b.message;try{return JSON.stringify(b)}catch{return String(b)}}function te(){return K.map(b=>({...b}))}function ne(b,...w){q.has(b)||(_(b),Q(b,"warn",w),console.warn("[lattice]",...w))}function F(b,...w){q.has(b)||(_(b),Q(b,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(b,w){const $=new Error(`[lattice] ${b}`);throw w!==void 0&&($.cause=w),$}function y(b,w){b||W(w)}const o=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function t(b){return b!==null&&typeof b=="object"&&!Array.isArray(b)}function c(b){return typeof b=="function"}function u(b){return b==null}function e(b){return b==null||b===""}function l(b){return typeof b!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(b))?!0:!!(b.prototype&&Object.getOwnPropertyNames(b.prototype).length>1)}const i=new Map;function p(b){let w=i.get(b);if(w)return w;if(!b.includes("."))w=$=>$?.[b];else{const $=b.split("."),U=$.length;w=ie=>{let le=ie;for(let ce=0;ce<U;ce++){if(le==null)return;le=le[$[ce]]}return le}}return i.set(b,w),w}const r=new Map;function d(b){let w=r.get(b);if(w)return w;if(!b.includes("."))w=($,U)=>{$!=null&&($[b]=U)};else{const $=b.split("."),U=$.length-1;w=(ie,le)=>{let ce=ie;for(let ue=0;ue<U;ue++){if(ce==null)return;const Y=$[ue];ce[Y]==null&&(ce[Y]={}),ce=ce[Y]}ce!=null&&(ce[$[U]]=le)}}return r.set(b,w),w}function v(b,w){return p(w)(b)}function n(b,w,$){d(w)(b,$)}function a(b){return b?(b.includes(".")?b.slice(b.lastIndexOf(".")+1):b).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(/^./,$=>$.toUpperCase()):""}const f={"&":"&","<":"<",">":">",'"':""","'":"'"};function g(b){const w=b==null?"":String(b);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,$=>f[$]):w}function C(b){return String(b).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(b,w,$){if(b!==void 0)return b===!0?{enabled:!0,...$}:b===!1?{enabled:!1}:t(b)?b:{[w]:b,enabled:!0}}function S(b){return b==null?[]:Array.isArray(b)?b:[b]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(b,w){if(!t(b))return t(w)?{...w}:w;if(!t(w))return w===void 0?b:w;const $={...b};for(const U of Object.keys(w)){if(D.has(U))continue;const ie=w[U];ie!==void 0&&($[U]=t(ie)&&t($[U])?A($[U],ie):ie)}return $}function z(b,w){if(!t(b)||!t(w)||b===w)return w;const $=Object.create(Object.getPrototypeOf(b));return Object.assign($,b,w),$}class X{#t;#e=new Map;#n;constructor(w=256,$=null){this.#t=w,this.#n=$}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 $=this.#e;if(!$.has(w))return;const U=$.get(w);return $.delete(w),$.set(w,U),U}peek(w){return this.#e.get(w)}set(w,$){const U=this.#e;return U.has(w)&&U.delete(w),U.set(w,$),this.#r(),$}delete(w){const $=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n($,w),$}clear(){if(this.#n)for(const[w,$]of this.#e)this.#n($,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 $=w.keys().next().value,U=w.get($);w.delete($),this.#n&&this.#n(U,$)}}}const J=new Map;function oe(b,w){const $=`${b||""}|${w?JSON.stringify(w):""}`;let U=J.get($);return U||(U=new Intl.Collator(b||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set($,U)),U}function he(b,w){if(b===w)return 0;if(b==null)return 1;if(w==null)return-1;if(typeof b=="number"&&typeof w=="number")return Number.isNaN(b)?Number.isNaN(w)?0:1:Number.isNaN(w)||b<w?-1:b>w?1:0;const $=String(b),U=String(w);return $<U?-1:$>U?1:0}function s(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function O(b){return k?requestAnimationFrame(b):setTimeout(()=>b(s()),16)}function j(b){b!=null&&(k?cancelAnimationFrame(b):clearTimeout(b))}function E(b){let w=null,$=null;const U=()=>{w=null;const le=$;$=null,b(...le||[])},ie=(...le)=>{$=le,w===null&&(w=O(U))};return ie.cancel=()=>{j(w),w=null,$=null},ie.flush=()=>{w!==null&&(j(w),U())},ie}function T(b,w){let $=null,U=null;const ie=()=>{if($=null,U===null)return;const ue=U;U=null,b(...ue),le()},le=()=>{$=setTimeout(ie,w),typeof $?.unref=="function"&&$.unref()},ce=(...ue)=>{$===null?(b(...ue),le()):(U=ue,clearTimeout($),le())};return ce.flush=()=>{if($!==null&&clearTimeout($),$=null,U===null)return;const ue=U;U=null,b(...ue)},ce.cancel=()=>{$!==null&&clearTimeout($),$=null,U=null},ce.pending=()=>$!==null||U!==null,ce}function I(b,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(b,{timeout:w}):setTimeout(()=>b({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function Z(b="l"){return`${b}${(++B).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 H}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const P=V("packages/core/src/internal/util.js").isNil,L=1e-6,q=4,R="[unverified]";function _(e,l){const i=10**l,p=Math.round(e*i)/i;return p===0?0:p}function K(e){const l=e.indexOf(".");return l<0?0:Math.min(e.length-l-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const l=new Set([e]);for(let i=0;i<=q;i+=1)l.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let p=0;p<=q;p+=1)l.add(_(i,p))}return[...l]}function Q(e){const l=new Set,i=[];for(const r of e)if(Number.isFinite(r)){i.push(r);for(const d of G(r))l.add(d)}const p=[...l];return{size:i.length,values:i,has(r,d){for(const v of p)if(Math.abs(v-r)<=L||_(v,d)===r)return!0;return!1}}}function H(e,l=[],i=0){if(i>8||P(e))return l;if(typeof e=="number")return Number.isFinite(e)&&l.push(e),l;if(typeof e=="string"){const p=Number(e);return e.trim()!==""&&Number.isFinite(p)&&l.push(p),l}if(Array.isArray(e)){for(const p of e)H(p,l,i+1);return l}if(typeof e=="object")for(const p of Object.keys(e))H(e[p],l,i+1);return l}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,l,i,p){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(l)||e===":"&&/\d/.test(l)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(p))}function F(e){const l=[];if(typeof e!="string"||e==="")return l;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let p;for(;(p=i.exec(e))!==null;){const[,r,,d,v,n]=p,a=p.index+r.length,f=p.index+p[0].length,g=p.index>0?e[p.index-1]:"",C=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(r,g,C,N))continue;const S=d.replace(/,/g,"");let D=Number(S);if(!Number.isFinite(D))continue;const A=K(S);n&&Object.prototype.hasOwnProperty.call(te,n)&&(D*=te[n]),l.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:n||""})}return l}function x(e){return e===" "||e===" "||e===`
|
|
6
|
+
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 P=we[h];if(!P)throw new Error("[lattice] missing module: "+h);return P(m,ke),m}fe("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return L}}),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 F}}),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 y}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return t}}),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 l}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return z}}),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 he}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return Z}});const m="1.75.0";async function P(){return m}const L="1.75.0",q=new Set,R=2e3;function _(b){if(q.add(b),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(b,w,$){K.push({key:b,level:w,message:$.map(U=>typeof U=="string"?U:H(U)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function H(b){if(b instanceof Error)return b.message;try{return JSON.stringify(b)}catch{return String(b)}}function te(){return K.map(b=>({...b}))}function ne(b,...w){q.has(b)||(_(b),Q(b,"warn",w),console.warn("[lattice]",...w))}function F(b,...w){q.has(b)||(_(b),Q(b,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(b,w){const $=new Error(`[lattice] ${b}`);throw w!==void 0&&($.cause=w),$}function y(b,w){b||W(w)}const o=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function t(b){return b!==null&&typeof b=="object"&&!Array.isArray(b)}function c(b){return typeof b=="function"}function u(b){return b==null}function e(b){return b==null||b===""}function l(b){return typeof b!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(b))?!0:!!(b.prototype&&Object.getOwnPropertyNames(b.prototype).length>1)}const i=new Map;function p(b){let w=i.get(b);if(w)return w;if(!b.includes("."))w=$=>$?.[b];else{const $=b.split("."),U=$.length;w=ie=>{let le=ie;for(let ce=0;ce<U;ce++){if(le==null)return;le=le[$[ce]]}return le}}return i.set(b,w),w}const r=new Map;function d(b){let w=r.get(b);if(w)return w;if(!b.includes("."))w=($,U)=>{$!=null&&($[b]=U)};else{const $=b.split("."),U=$.length-1;w=(ie,le)=>{let ce=ie;for(let ue=0;ue<U;ue++){if(ce==null)return;const Y=$[ue];ce[Y]==null&&(ce[Y]={}),ce=ce[Y]}ce!=null&&(ce[$[U]]=le)}}return r.set(b,w),w}function v(b,w){return p(w)(b)}function n(b,w,$){d(w)(b,$)}function a(b){return b?(b.includes(".")?b.slice(b.lastIndexOf(".")+1):b).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(/^./,$=>$.toUpperCase()):""}const f={"&":"&","<":"<",">":">",'"':""","'":"'"};function g(b){const w=b==null?"":String(b);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,$=>f[$]):w}function C(b){return String(b).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(b,w,$){if(b!==void 0)return b===!0?{enabled:!0,...$}:b===!1?{enabled:!1}:t(b)?b:{[w]:b,enabled:!0}}function S(b){return b==null?[]:Array.isArray(b)?b:[b]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(b,w){if(!t(b))return t(w)?{...w}:w;if(!t(w))return w===void 0?b:w;const $={...b};for(const U of Object.keys(w)){if(D.has(U))continue;const ie=w[U];ie!==void 0&&($[U]=t(ie)&&t($[U])?A($[U],ie):ie)}return $}function z(b,w){if(!t(b)||!t(w)||b===w)return w;const $=Object.create(Object.getPrototypeOf(b));return Object.assign($,b,w),$}class X{#t;#e=new Map;#n;constructor(w=256,$=null){this.#t=w,this.#n=$}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 $=this.#e;if(!$.has(w))return;const U=$.get(w);return $.delete(w),$.set(w,U),U}peek(w){return this.#e.get(w)}set(w,$){const U=this.#e;return U.has(w)&&U.delete(w),U.set(w,$),this.#r(),$}delete(w){const $=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n($,w),$}clear(){if(this.#n)for(const[w,$]of this.#e)this.#n($,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 $=w.keys().next().value,U=w.get($);w.delete($),this.#n&&this.#n(U,$)}}}const J=new Map;function oe(b,w){const $=`${b||""}|${w?JSON.stringify(w):""}`;let U=J.get($);return U||(U=new Intl.Collator(b||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set($,U)),U}function he(b,w){if(b===w)return 0;if(b==null)return 1;if(w==null)return-1;if(typeof b=="number"&&typeof w=="number")return Number.isNaN(b)?Number.isNaN(w)?0:1:Number.isNaN(w)||b<w?-1:b>w?1:0;const $=String(b),U=String(w);return $<U?-1:$>U?1:0}function s(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function O(b){return k?requestAnimationFrame(b):setTimeout(()=>b(s()),16)}function j(b){b!=null&&(k?cancelAnimationFrame(b):clearTimeout(b))}function E(b){let w=null,$=null;const U=()=>{w=null;const le=$;$=null,b(...le||[])},ie=(...le)=>{$=le,w===null&&(w=O(U))};return ie.cancel=()=>{j(w),w=null,$=null},ie.flush=()=>{w!==null&&(j(w),U())},ie}function T(b,w){let $=null,U=null;const ie=()=>{if($=null,U===null)return;const ue=U;U=null,b(...ue),le()},le=()=>{$=setTimeout(ie,w),typeof $?.unref=="function"&&$.unref()},ce=(...ue)=>{$===null?(b(...ue),le()):(U=ue,clearTimeout($),le())};return ce.flush=()=>{if($!==null&&clearTimeout($),$=null,U===null)return;const ue=U;U=null,b(...ue)},ce.cancel=()=>{$!==null&&clearTimeout($),$=null,U=null},ce.pending=()=>$!==null||U!==null,ce}function I(b,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(b,{timeout:w}):setTimeout(()=>b({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function Z(b="l"){return`${b}${(++B).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 H}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const P=V("packages/core/src/internal/util.js").isNil,L=1e-6,q=4,R="[unverified]";function _(e,l){const i=10**l,p=Math.round(e*i)/i;return p===0?0:p}function K(e){const l=e.indexOf(".");return l<0?0:Math.min(e.length-l-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const l=new Set([e]);for(let i=0;i<=q;i+=1)l.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let p=0;p<=q;p+=1)l.add(_(i,p))}return[...l]}function Q(e){const l=new Set,i=[];for(const r of e)if(Number.isFinite(r)){i.push(r);for(const d of G(r))l.add(d)}const p=[...l];return{size:i.length,values:i,has(r,d){for(const v of p)if(Math.abs(v-r)<=L||_(v,d)===r)return!0;return!1}}}function H(e,l=[],i=0){if(i>8||P(e))return l;if(typeof e=="number")return Number.isFinite(e)&&l.push(e),l;if(typeof e=="string"){const p=Number(e);return e.trim()!==""&&Number.isFinite(p)&&l.push(p),l}if(Array.isArray(e)){for(const p of e)H(p,l,i+1);return l}if(typeof e=="object")for(const p of Object.keys(e))H(e[p],l,i+1);return l}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,l,i,p){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(l)||e===":"&&/\d/.test(l)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(p))}function F(e){const l=[];if(typeof e!="string"||e==="")return l;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let p;for(;(p=i.exec(e))!==null;){const[,r,,d,v,n]=p,a=p.index+r.length,f=p.index+p[0].length,g=p.index>0?e[p.index-1]:"",C=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(r,g,C,N))continue;const S=d.replace(/,/g,"");let D=Number(S);if(!Number.isFinite(D))continue;const A=K(S);n&&Object.prototype.hasOwnProperty.call(te,n)&&(D*=te[n]),l.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:n||""})}return l}function x(e){return e===" "||e===" "||e===`
|
|
7
7
|
`||e==="\r"}function W(e){const l=[],i=[];for(let p=0;p<e.length;p+=1)if(e[p]==="(")i.push(p);else if(e[p]===")"&&i.length){const r=i.pop();i.length===0&&l.push({start:r,end:p+1})}return l}function y(e){const l=[],i=e.length;let p=0,r=0;for(;r<i;){const d=e[r],v=d==="."||d==="!"||d==="?",n=r+1>=i||x(e[r+1]);if(v&&n||d===`
|
|
8
8
|
`){let a=r+1;for(;a<i&&(e[a]==="."||e[a]==="!"||e[a]==="?");)a+=1;for(;a<i&&x(e[a]);)a+=1;l.push({start:p,end:a}),p=a,r=a;continue}r+=1}return p<i&&l.push({start:p,end:i}),l}function o(e){const l=e.slice().sort((p,r)=>p.start-r.start),i=[];for(const p of l){const r=i[i.length-1];r&&p.start<=r.end?r.end=Math.max(r.end,p.end):i.push({start:p.start,end:p.end})}return i}function t(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.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, 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 de(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 P=we[h];if(!P)throw new Error("[lattice] missing module: "+h);return P(m,ke),m}de("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return L}}),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 F}}),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 y}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return t}}),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 l}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return z}}),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 he}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return Z}});const m="1.74.0";async function P(){return m}const L="1.74.0",q=new Set,R=2e3;function _(b){if(q.add(b),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(b,w,$){K.push({key:b,level:w,message:$.map(U=>typeof U=="string"?U:H(U)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function H(b){if(b instanceof Error)return b.message;try{return JSON.stringify(b)}catch{return String(b)}}function te(){return K.map(b=>({...b}))}function ne(b,...w){q.has(b)||(_(b),Q(b,"warn",w),console.warn("[lattice]",...w))}function F(b,...w){q.has(b)||(_(b),Q(b,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(b,w){const $=new Error(`[lattice] ${b}`);throw w!==void 0&&($.cause=w),$}function y(b,w){b||W(w)}const o=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function t(b){return b!==null&&typeof b=="object"&&!Array.isArray(b)}function c(b){return typeof b=="function"}function u(b){return b==null}function e(b){return b==null||b===""}function l(b){return typeof b!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(b))?!0:!!(b.prototype&&Object.getOwnPropertyNames(b.prototype).length>1)}const i=new Map;function p(b){let w=i.get(b);if(w)return w;if(!b.includes("."))w=$=>$?.[b];else{const $=b.split("."),U=$.length;w=ie=>{let le=ie;for(let ce=0;ce<U;ce++){if(le==null)return;le=le[$[ce]]}return le}}return i.set(b,w),w}const r=new Map;function d(b){let w=r.get(b);if(w)return w;if(!b.includes("."))w=($,U)=>{$!=null&&($[b]=U)};else{const $=b.split("."),U=$.length-1;w=(ie,le)=>{let ce=ie;for(let ue=0;ue<U;ue++){if(ce==null)return;const Y=$[ue];ce[Y]==null&&(ce[Y]={}),ce=ce[Y]}ce!=null&&(ce[$[U]]=le)}}return r.set(b,w),w}function v(b,w){return p(w)(b)}function n(b,w,$){d(w)(b,$)}function a(b){return b?(b.includes(".")?b.slice(b.lastIndexOf(".")+1):b).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(/^./,$=>$.toUpperCase()):""}const f={"&":"&","<":"<",">":">",'"':""","'":"'"};function g(b){const w=b==null?"":String(b);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,$=>f[$]):w}function C(b){return String(b).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(b,w,$){if(b!==void 0)return b===!0?{enabled:!0,...$}:b===!1?{enabled:!1}:t(b)?b:{[w]:b,enabled:!0}}function S(b){return b==null?[]:Array.isArray(b)?b:[b]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(b,w){if(!t(b))return t(w)?{...w}:w;if(!t(w))return w===void 0?b:w;const $={...b};for(const U of Object.keys(w)){if(D.has(U))continue;const ie=w[U];ie!==void 0&&($[U]=t(ie)&&t($[U])?A($[U],ie):ie)}return $}function z(b,w){if(!t(b)||!t(w)||b===w)return w;const $=Object.create(Object.getPrototypeOf(b));return Object.assign($,b,w),$}class X{#t;#e=new Map;#n;constructor(w=256,$=null){this.#t=w,this.#n=$}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 $=this.#e;if(!$.has(w))return;const U=$.get(w);return $.delete(w),$.set(w,U),U}peek(w){return this.#e.get(w)}set(w,$){const U=this.#e;return U.has(w)&&U.delete(w),U.set(w,$),this.#r(),$}delete(w){const $=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n($,w),$}clear(){if(this.#n)for(const[w,$]of this.#e)this.#n($,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 $=w.keys().next().value,U=w.get($);w.delete($),this.#n&&this.#n(U,$)}}}const J=new Map;function oe(b,w){const $=`${b||""}|${w?JSON.stringify(w):""}`;let U=J.get($);return U||(U=new Intl.Collator(b||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set($,U)),U}function he(b,w){if(b===w)return 0;if(b==null)return 1;if(w==null)return-1;if(typeof b=="number"&&typeof w=="number")return Number.isNaN(b)?Number.isNaN(w)?0:1:Number.isNaN(w)||b<w?-1:b>w?1:0;const $=String(b),U=String(w);return $<U?-1:$>U?1:0}function s(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function O(b){return k?requestAnimationFrame(b):setTimeout(()=>b(s()),16)}function j(b){b!=null&&(k?cancelAnimationFrame(b):clearTimeout(b))}function E(b){let w=null,$=null;const U=()=>{w=null;const le=$;$=null,b(...le||[])},ie=(...le)=>{$=le,w===null&&(w=O(U))};return ie.cancel=()=>{j(w),w=null,$=null},ie.flush=()=>{w!==null&&(j(w),U())},ie}function T(b,w){let $=null,U=null;const ie=()=>{if($=null,U===null)return;const ue=U;U=null,b(...ue),le()},le=()=>{$=setTimeout(ie,w),typeof $?.unref=="function"&&$.unref()},ce=(...ue)=>{$===null?(b(...ue),le()):(U=ue,clearTimeout($),le())};return ce.flush=()=>{if($!==null&&clearTimeout($),$=null,U===null)return;const ue=U;U=null,b(...ue)},ce.cancel=()=>{$!==null&&clearTimeout($),$=null,U=null},ce.pending=()=>$!==null||U!==null,ce}function I(b,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(b,{timeout:w}):setTimeout(()=>b({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function Z(b="l"){return`${b}${(++B).toString(36)}`}}),de("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 H}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const P=V("packages/core/src/internal/util.js").isNil,L=1e-6,q=4,R="[unverified]";function _(e,l){const i=10**l,p=Math.round(e*i)/i;return p===0?0:p}function K(e){const l=e.indexOf(".");return l<0?0:Math.min(e.length-l-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const l=new Set([e]);for(let i=0;i<=q;i+=1)l.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let p=0;p<=q;p+=1)l.add(_(i,p))}return[...l]}function Q(e){const l=new Set,i=[];for(const r of e)if(Number.isFinite(r)){i.push(r);for(const d of G(r))l.add(d)}const p=[...l];return{size:i.length,values:i,has(r,d){for(const v of p)if(Math.abs(v-r)<=L||_(v,d)===r)return!0;return!1}}}function H(e,l=[],i=0){if(i>8||P(e))return l;if(typeof e=="number")return Number.isFinite(e)&&l.push(e),l;if(typeof e=="string"){const p=Number(e);return e.trim()!==""&&Number.isFinite(p)&&l.push(p),l}if(Array.isArray(e)){for(const p of e)H(p,l,i+1);return l}if(typeof e=="object")for(const p of Object.keys(e))H(e[p],l,i+1);return l}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,l,i,p){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(l)||e===":"&&/\d/.test(l)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(p))}function F(e){const l=[];if(typeof e!="string"||e==="")return l;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let p;for(;(p=i.exec(e))!==null;){const[,r,,d,v,n]=p,a=p.index+r.length,f=p.index+p[0].length,g=p.index>0?e[p.index-1]:"",C=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(r,g,C,N))continue;const S=d.replace(/,/g,"");let D=Number(S);if(!Number.isFinite(D))continue;const A=K(S);n&&Object.prototype.hasOwnProperty.call(te,n)&&(D*=te[n]),l.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:n||""})}return l}function x(e){return e===" "||e===" "||e===`
|
|
6
|
+
(function(Oe){"use strict";var we=Object.create(null),ve=Object.create(null);function de(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 P=we[h];if(!P)throw new Error("[lattice] missing module: "+h);return P(m,ke),m}de("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return L}}),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 F}}),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 y}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return t}}),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 l}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return z}}),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 he}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return Z}});const m="1.75.0";async function P(){return m}const L="1.75.0",q=new Set,R=2e3;function _(b){if(q.add(b),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(b,w,$){K.push({key:b,level:w,message:$.map(U=>typeof U=="string"?U:H(U)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function H(b){if(b instanceof Error)return b.message;try{return JSON.stringify(b)}catch{return String(b)}}function te(){return K.map(b=>({...b}))}function ne(b,...w){q.has(b)||(_(b),Q(b,"warn",w),console.warn("[lattice]",...w))}function F(b,...w){q.has(b)||(_(b),Q(b,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(b,w){const $=new Error(`[lattice] ${b}`);throw w!==void 0&&($.cause=w),$}function y(b,w){b||W(w)}const o=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function t(b){return b!==null&&typeof b=="object"&&!Array.isArray(b)}function c(b){return typeof b=="function"}function u(b){return b==null}function e(b){return b==null||b===""}function l(b){return typeof b!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(b))?!0:!!(b.prototype&&Object.getOwnPropertyNames(b.prototype).length>1)}const i=new Map;function p(b){let w=i.get(b);if(w)return w;if(!b.includes("."))w=$=>$?.[b];else{const $=b.split("."),U=$.length;w=ie=>{let le=ie;for(let ce=0;ce<U;ce++){if(le==null)return;le=le[$[ce]]}return le}}return i.set(b,w),w}const r=new Map;function d(b){let w=r.get(b);if(w)return w;if(!b.includes("."))w=($,U)=>{$!=null&&($[b]=U)};else{const $=b.split("."),U=$.length-1;w=(ie,le)=>{let ce=ie;for(let ue=0;ue<U;ue++){if(ce==null)return;const Y=$[ue];ce[Y]==null&&(ce[Y]={}),ce=ce[Y]}ce!=null&&(ce[$[U]]=le)}}return r.set(b,w),w}function v(b,w){return p(w)(b)}function n(b,w,$){d(w)(b,$)}function a(b){return b?(b.includes(".")?b.slice(b.lastIndexOf(".")+1):b).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(/^./,$=>$.toUpperCase()):""}const f={"&":"&","<":"<",">":">",'"':""","'":"'"};function g(b){const w=b==null?"":String(b);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,$=>f[$]):w}function C(b){return String(b).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(b,w,$){if(b!==void 0)return b===!0?{enabled:!0,...$}:b===!1?{enabled:!1}:t(b)?b:{[w]:b,enabled:!0}}function S(b){return b==null?[]:Array.isArray(b)?b:[b]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(b,w){if(!t(b))return t(w)?{...w}:w;if(!t(w))return w===void 0?b:w;const $={...b};for(const U of Object.keys(w)){if(D.has(U))continue;const ie=w[U];ie!==void 0&&($[U]=t(ie)&&t($[U])?A($[U],ie):ie)}return $}function z(b,w){if(!t(b)||!t(w)||b===w)return w;const $=Object.create(Object.getPrototypeOf(b));return Object.assign($,b,w),$}class X{#t;#e=new Map;#n;constructor(w=256,$=null){this.#t=w,this.#n=$}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 $=this.#e;if(!$.has(w))return;const U=$.get(w);return $.delete(w),$.set(w,U),U}peek(w){return this.#e.get(w)}set(w,$){const U=this.#e;return U.has(w)&&U.delete(w),U.set(w,$),this.#r(),$}delete(w){const $=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n($,w),$}clear(){if(this.#n)for(const[w,$]of this.#e)this.#n($,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 $=w.keys().next().value,U=w.get($);w.delete($),this.#n&&this.#n(U,$)}}}const J=new Map;function oe(b,w){const $=`${b||""}|${w?JSON.stringify(w):""}`;let U=J.get($);return U||(U=new Intl.Collator(b||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set($,U)),U}function he(b,w){if(b===w)return 0;if(b==null)return 1;if(w==null)return-1;if(typeof b=="number"&&typeof w=="number")return Number.isNaN(b)?Number.isNaN(w)?0:1:Number.isNaN(w)||b<w?-1:b>w?1:0;const $=String(b),U=String(w);return $<U?-1:$>U?1:0}function s(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function O(b){return k?requestAnimationFrame(b):setTimeout(()=>b(s()),16)}function j(b){b!=null&&(k?cancelAnimationFrame(b):clearTimeout(b))}function E(b){let w=null,$=null;const U=()=>{w=null;const le=$;$=null,b(...le||[])},ie=(...le)=>{$=le,w===null&&(w=O(U))};return ie.cancel=()=>{j(w),w=null,$=null},ie.flush=()=>{w!==null&&(j(w),U())},ie}function T(b,w){let $=null,U=null;const ie=()=>{if($=null,U===null)return;const ue=U;U=null,b(...ue),le()},le=()=>{$=setTimeout(ie,w),typeof $?.unref=="function"&&$.unref()},ce=(...ue)=>{$===null?(b(...ue),le()):(U=ue,clearTimeout($),le())};return ce.flush=()=>{if($!==null&&clearTimeout($),$=null,U===null)return;const ue=U;U=null,b(...ue)},ce.cancel=()=>{$!==null&&clearTimeout($),$=null,U=null},ce.pending=()=>$!==null||U!==null,ce}function I(b,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(b,{timeout:w}):setTimeout(()=>b({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function Z(b="l"){return`${b}${(++B).toString(36)}`}}),de("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 H}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const P=V("packages/core/src/internal/util.js").isNil,L=1e-6,q=4,R="[unverified]";function _(e,l){const i=10**l,p=Math.round(e*i)/i;return p===0?0:p}function K(e){const l=e.indexOf(".");return l<0?0:Math.min(e.length-l-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const l=new Set([e]);for(let i=0;i<=q;i+=1)l.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let p=0;p<=q;p+=1)l.add(_(i,p))}return[...l]}function Q(e){const l=new Set,i=[];for(const r of e)if(Number.isFinite(r)){i.push(r);for(const d of G(r))l.add(d)}const p=[...l];return{size:i.length,values:i,has(r,d){for(const v of p)if(Math.abs(v-r)<=L||_(v,d)===r)return!0;return!1}}}function H(e,l=[],i=0){if(i>8||P(e))return l;if(typeof e=="number")return Number.isFinite(e)&&l.push(e),l;if(typeof e=="string"){const p=Number(e);return e.trim()!==""&&Number.isFinite(p)&&l.push(p),l}if(Array.isArray(e)){for(const p of e)H(p,l,i+1);return l}if(typeof e=="object")for(const p of Object.keys(e))H(e[p],l,i+1);return l}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,l,i,p){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(l)||e===":"&&/\d/.test(l)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(p))}function F(e){const l=[];if(typeof e!="string"||e==="")return l;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let p;for(;(p=i.exec(e))!==null;){const[,r,,d,v,n]=p,a=p.index+r.length,f=p.index+p[0].length,g=p.index>0?e[p.index-1]:"",C=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(r,g,C,N))continue;const S=d.replace(/,/g,"");let D=Number(S);if(!Number.isFinite(D))continue;const A=K(S);n&&Object.prototype.hasOwnProperty.call(te,n)&&(D*=te[n]),l.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:n||""})}return l}function x(e){return e===" "||e===" "||e===`
|
|
7
7
|
`||e==="\r"}function W(e){const l=[],i=[];for(let p=0;p<e.length;p+=1)if(e[p]==="(")i.push(p);else if(e[p]===")"&&i.length){const r=i.pop();i.length===0&&l.push({start:r,end:p+1})}return l}function y(e){const l=[],i=e.length;let p=0,r=0;for(;r<i;){const d=e[r],v=d==="."||d==="!"||d==="?",n=r+1>=i||x(e[r+1]);if(v&&n||d===`
|
|
8
8
|
`){let a=r+1;for(;a<i&&(e[a]==="."||e[a]==="!"||e[a]==="?");)a+=1;for(;a<i&&x(e[a]);)a+=1;l.push({start:p,end:a}),p=a,r=a;continue}r+=1}return p<i&&l.push({start:p,end:i}),l}function o(e){const l=e.slice().sort((p,r)=>p.start-r.start),i=[];for(const p of l){const r=i[i.length-1];r&&p.start<=r.end?r.end=Math.max(r.end,p.end):i.push({start:p.start,end:p.end})}return i}function t(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.
|
|
2
|
+
* Lattice Grid 1.75.0, 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 de(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 P=we[h];if(!P)throw new Error("[lattice] missing module: "+h);return P(m,ke),m}de("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return L}}),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 F}}),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 y}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return t}}),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 l}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return z}}),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 he}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return Z}});const m="1.74.0";async function P(){return m}const L="1.74.0",q=new Set,R=2e3;function _(b){if(q.add(b),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(b,w,$){K.push({key:b,level:w,message:$.map(U=>typeof U=="string"?U:H(U)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function H(b){if(b instanceof Error)return b.message;try{return JSON.stringify(b)}catch{return String(b)}}function te(){return K.map(b=>({...b}))}function ne(b,...w){q.has(b)||(_(b),Q(b,"warn",w),console.warn("[lattice]",...w))}function F(b,...w){q.has(b)||(_(b),Q(b,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(b,w){const $=new Error(`[lattice] ${b}`);throw w!==void 0&&($.cause=w),$}function y(b,w){b||W(w)}const o=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function t(b){return b!==null&&typeof b=="object"&&!Array.isArray(b)}function c(b){return typeof b=="function"}function u(b){return b==null}function e(b){return b==null||b===""}function l(b){return typeof b!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(b))?!0:!!(b.prototype&&Object.getOwnPropertyNames(b.prototype).length>1)}const i=new Map;function p(b){let w=i.get(b);if(w)return w;if(!b.includes("."))w=$=>$?.[b];else{const $=b.split("."),U=$.length;w=ie=>{let le=ie;for(let ce=0;ce<U;ce++){if(le==null)return;le=le[$[ce]]}return le}}return i.set(b,w),w}const r=new Map;function d(b){let w=r.get(b);if(w)return w;if(!b.includes("."))w=($,U)=>{$!=null&&($[b]=U)};else{const $=b.split("."),U=$.length-1;w=(ie,le)=>{let ce=ie;for(let ue=0;ue<U;ue++){if(ce==null)return;const Y=$[ue];ce[Y]==null&&(ce[Y]={}),ce=ce[Y]}ce!=null&&(ce[$[U]]=le)}}return r.set(b,w),w}function v(b,w){return p(w)(b)}function n(b,w,$){d(w)(b,$)}function a(b){return b?(b.includes(".")?b.slice(b.lastIndexOf(".")+1):b).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(/^./,$=>$.toUpperCase()):""}const f={"&":"&","<":"<",">":">",'"':""","'":"'"};function g(b){const w=b==null?"":String(b);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,$=>f[$]):w}function C(b){return String(b).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(b,w,$){if(b!==void 0)return b===!0?{enabled:!0,...$}:b===!1?{enabled:!1}:t(b)?b:{[w]:b,enabled:!0}}function S(b){return b==null?[]:Array.isArray(b)?b:[b]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(b,w){if(!t(b))return t(w)?{...w}:w;if(!t(w))return w===void 0?b:w;const $={...b};for(const U of Object.keys(w)){if(D.has(U))continue;const ie=w[U];ie!==void 0&&($[U]=t(ie)&&t($[U])?A($[U],ie):ie)}return $}function z(b,w){if(!t(b)||!t(w)||b===w)return w;const $=Object.create(Object.getPrototypeOf(b));return Object.assign($,b,w),$}class X{#t;#e=new Map;#n;constructor(w=256,$=null){this.#t=w,this.#n=$}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 $=this.#e;if(!$.has(w))return;const U=$.get(w);return $.delete(w),$.set(w,U),U}peek(w){return this.#e.get(w)}set(w,$){const U=this.#e;return U.has(w)&&U.delete(w),U.set(w,$),this.#r(),$}delete(w){const $=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n($,w),$}clear(){if(this.#n)for(const[w,$]of this.#e)this.#n($,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 $=w.keys().next().value,U=w.get($);w.delete($),this.#n&&this.#n(U,$)}}}const J=new Map;function oe(b,w){const $=`${b||""}|${w?JSON.stringify(w):""}`;let U=J.get($);return U||(U=new Intl.Collator(b||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set($,U)),U}function he(b,w){if(b===w)return 0;if(b==null)return 1;if(w==null)return-1;if(typeof b=="number"&&typeof w=="number")return Number.isNaN(b)?Number.isNaN(w)?0:1:Number.isNaN(w)||b<w?-1:b>w?1:0;const $=String(b),U=String(w);return $<U?-1:$>U?1:0}function s(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function O(b){return k?requestAnimationFrame(b):setTimeout(()=>b(s()),16)}function j(b){b!=null&&(k?cancelAnimationFrame(b):clearTimeout(b))}function E(b){let w=null,$=null;const U=()=>{w=null;const le=$;$=null,b(...le||[])},ie=(...le)=>{$=le,w===null&&(w=O(U))};return ie.cancel=()=>{j(w),w=null,$=null},ie.flush=()=>{w!==null&&(j(w),U())},ie}function T(b,w){let $=null,U=null;const ie=()=>{if($=null,U===null)return;const ue=U;U=null,b(...ue),le()},le=()=>{$=setTimeout(ie,w),typeof $?.unref=="function"&&$.unref()},ce=(...ue)=>{$===null?(b(...ue),le()):(U=ue,clearTimeout($),le())};return ce.flush=()=>{if($!==null&&clearTimeout($),$=null,U===null)return;const ue=U;U=null,b(...ue)},ce.cancel=()=>{$!==null&&clearTimeout($),$=null,U=null},ce.pending=()=>$!==null||U!==null,ce}function I(b,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(b,{timeout:w}):setTimeout(()=>b({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function Z(b="l"){return`${b}${(++B).toString(36)}`}}),de("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 H}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const P=V("packages/core/src/internal/util.js").isNil,L=1e-6,q=4,R="[unverified]";function _(e,l){const i=10**l,p=Math.round(e*i)/i;return p===0?0:p}function K(e){const l=e.indexOf(".");return l<0?0:Math.min(e.length-l-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const l=new Set([e]);for(let i=0;i<=q;i+=1)l.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let p=0;p<=q;p+=1)l.add(_(i,p))}return[...l]}function Q(e){const l=new Set,i=[];for(const r of e)if(Number.isFinite(r)){i.push(r);for(const d of G(r))l.add(d)}const p=[...l];return{size:i.length,values:i,has(r,d){for(const v of p)if(Math.abs(v-r)<=L||_(v,d)===r)return!0;return!1}}}function H(e,l=[],i=0){if(i>8||P(e))return l;if(typeof e=="number")return Number.isFinite(e)&&l.push(e),l;if(typeof e=="string"){const p=Number(e);return e.trim()!==""&&Number.isFinite(p)&&l.push(p),l}if(Array.isArray(e)){for(const p of e)H(p,l,i+1);return l}if(typeof e=="object")for(const p of Object.keys(e))H(e[p],l,i+1);return l}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,l,i,p){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(l)||e===":"&&/\d/.test(l)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(p))}function F(e){const l=[];if(typeof e!="string"||e==="")return l;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let p;for(;(p=i.exec(e))!==null;){const[,r,,d,v,n]=p,a=p.index+r.length,f=p.index+p[0].length,g=p.index>0?e[p.index-1]:"",C=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(r,g,C,N))continue;const S=d.replace(/,/g,"");let D=Number(S);if(!Number.isFinite(D))continue;const A=K(S);n&&Object.prototype.hasOwnProperty.call(te,n)&&(D*=te[n]),l.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:n||""})}return l}function x(e){return e===" "||e===" "||e===`
|
|
6
|
+
(function(Oe){"use strict";var we=Object.create(null),ve=Object.create(null);function de(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 P=we[h];if(!P)throw new Error("[lattice] missing module: "+h);return P(m,ke),m}de("packages/core/src/internal/util.js",function(h,V){"use strict";Object.defineProperty(h,"VERSION",{enumerable:!0,get:function(){return L}}),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 F}}),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 y}}),Object.defineProperty(h,"DEV",{enumerable:!0,get:function(){return o}}),Object.defineProperty(h,"isObject",{enumerable:!0,get:function(){return t}}),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 l}}),Object.defineProperty(h,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(h,"pathSetter",{enumerable:!0,get:function(){return d}}),Object.defineProperty(h,"getPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(h,"setPath",{enumerable:!0,get:function(){return n}}),Object.defineProperty(h,"humanise",{enumerable:!0,get:function(){return a}}),Object.defineProperty(h,"escapeHtml",{enumerable:!0,get:function(){return g}}),Object.defineProperty(h,"titleCase",{enumerable:!0,get:function(){return C}}),Object.defineProperty(h,"expand",{enumerable:!0,get:function(){return N}}),Object.defineProperty(h,"toArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(h,"merge",{enumerable:!0,get:function(){return A}}),Object.defineProperty(h,"mergeRow",{enumerable:!0,get:function(){return z}}),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 he}}),Object.defineProperty(h,"now",{enumerable:!0,get:function(){return s}}),Object.defineProperty(h,"nextFrame",{enumerable:!0,get:function(){return O}}),Object.defineProperty(h,"cancelFrame",{enumerable:!0,get:function(){return j}}),Object.defineProperty(h,"frameBatched",{enumerable:!0,get:function(){return E}}),Object.defineProperty(h,"settleDebounce",{enumerable:!0,get:function(){return T}}),Object.defineProperty(h,"whenIdle",{enumerable:!0,get:function(){return I}}),Object.defineProperty(h,"uid",{enumerable:!0,get:function(){return Z}});const m="1.75.0";async function P(){return m}const L="1.75.0",q=new Set,R=2e3;function _(b){if(q.add(b),q.size>R){const w=q.values().next().value;w!==void 0&&q.delete(w)}}const K=[],G=500;function Q(b,w,$){K.push({key:b,level:w,message:$.map(U=>typeof U=="string"?U:H(U)).join(" "),at:Date.now()}),K.length>G&&K.shift()}function H(b){if(b instanceof Error)return b.message;try{return JSON.stringify(b)}catch{return String(b)}}function te(){return K.map(b=>({...b}))}function ne(b,...w){q.has(b)||(_(b),Q(b,"warn",w),console.warn("[lattice]",...w))}function F(b,...w){q.has(b)||(_(b),Q(b,"info",w),console.info("[lattice]",...w))}function x(){q.clear(),K.length=0}function W(b,w){const $=new Error(`[lattice] ${b}`);throw w!==void 0&&($.cause=w),$}function y(b,w){b||W(w)}const o=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function t(b){return b!==null&&typeof b=="object"&&!Array.isArray(b)}function c(b){return typeof b=="function"}function u(b){return b==null}function e(b){return b==null||b===""}function l(b){return typeof b!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(b))?!0:!!(b.prototype&&Object.getOwnPropertyNames(b.prototype).length>1)}const i=new Map;function p(b){let w=i.get(b);if(w)return w;if(!b.includes("."))w=$=>$?.[b];else{const $=b.split("."),U=$.length;w=ie=>{let le=ie;for(let ce=0;ce<U;ce++){if(le==null)return;le=le[$[ce]]}return le}}return i.set(b,w),w}const r=new Map;function d(b){let w=r.get(b);if(w)return w;if(!b.includes("."))w=($,U)=>{$!=null&&($[b]=U)};else{const $=b.split("."),U=$.length-1;w=(ie,le)=>{let ce=ie;for(let ue=0;ue<U;ue++){if(ce==null)return;const Y=$[ue];ce[Y]==null&&(ce[Y]={}),ce=ce[Y]}ce!=null&&(ce[$[U]]=le)}}return r.set(b,w),w}function v(b,w){return p(w)(b)}function n(b,w,$){d(w)(b,$)}function a(b){return b?(b.includes(".")?b.slice(b.lastIndexOf(".")+1):b).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(/^./,$=>$.toUpperCase()):""}const f={"&":"&","<":"<",">":">",'"':""","'":"'"};function g(b){const w=b==null?"":String(b);return/[&<>"']/.test(w)?w.replace(/[&<>"']/g,$=>f[$]):w}function C(b){return String(b).replace(/\w\S*/g,w=>w[0].toUpperCase()+w.slice(1).toLowerCase())}function N(b,w,$){if(b!==void 0)return b===!0?{enabled:!0,...$}:b===!1?{enabled:!1}:t(b)?b:{[w]:b,enabled:!0}}function S(b){return b==null?[]:Array.isArray(b)?b:[b]}const D=Object.freeze(new Set(["__proto__","constructor","prototype"]));function A(b,w){if(!t(b))return t(w)?{...w}:w;if(!t(w))return w===void 0?b:w;const $={...b};for(const U of Object.keys(w)){if(D.has(U))continue;const ie=w[U];ie!==void 0&&($[U]=t(ie)&&t($[U])?A($[U],ie):ie)}return $}function z(b,w){if(!t(b)||!t(w)||b===w)return w;const $=Object.create(Object.getPrototypeOf(b));return Object.assign($,b,w),$}class X{#t;#e=new Map;#n;constructor(w=256,$=null){this.#t=w,this.#n=$}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 $=this.#e;if(!$.has(w))return;const U=$.get(w);return $.delete(w),$.set(w,U),U}peek(w){return this.#e.get(w)}set(w,$){const U=this.#e;return U.has(w)&&U.delete(w),U.set(w,$),this.#r(),$}delete(w){const $=this.#e.get(w);return this.#e.delete(w)&&this.#n&&this.#n($,w),$}clear(){if(this.#n)for(const[w,$]of this.#e)this.#n($,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 $=w.keys().next().value,U=w.get($);w.delete($),this.#n&&this.#n(U,$)}}}const J=new Map;function oe(b,w){const $=`${b||""}|${w?JSON.stringify(w):""}`;let U=J.get($);return U||(U=new Intl.Collator(b||void 0,{numeric:!0,sensitivity:"variant",...w}),J.set($,U)),U}function he(b,w){if(b===w)return 0;if(b==null)return 1;if(w==null)return-1;if(typeof b=="number"&&typeof w=="number")return Number.isNaN(b)?Number.isNaN(w)?0:1:Number.isNaN(w)||b<w?-1:b>w?1:0;const $=String(b),U=String(w);return $<U?-1:$>U?1:0}function s(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const k=typeof requestAnimationFrame=="function";function O(b){return k?requestAnimationFrame(b):setTimeout(()=>b(s()),16)}function j(b){b!=null&&(k?cancelAnimationFrame(b):clearTimeout(b))}function E(b){let w=null,$=null;const U=()=>{w=null;const le=$;$=null,b(...le||[])},ie=(...le)=>{$=le,w===null&&(w=O(U))};return ie.cancel=()=>{j(w),w=null,$=null},ie.flush=()=>{w!==null&&(j(w),U())},ie}function T(b,w){let $=null,U=null;const ie=()=>{if($=null,U===null)return;const ue=U;U=null,b(...ue),le()},le=()=>{$=setTimeout(ie,w),typeof $?.unref=="function"&&$.unref()},ce=(...ue)=>{$===null?(b(...ue),le()):(U=ue,clearTimeout($),le())};return ce.flush=()=>{if($!==null&&clearTimeout($),$=null,U===null)return;const ue=U;U=null,b(...ue)},ce.cancel=()=>{$!==null&&clearTimeout($),$=null,U=null},ce.pending=()=>$!==null||U!==null,ce}function I(b,w=50){return typeof requestIdleCallback=="function"?requestIdleCallback(b,{timeout:w}):setTimeout(()=>b({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function Z(b="l"){return`${b}${(++B).toString(36)}`}}),de("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 H}}),Object.defineProperty(h,"extractNumbers",{enumerable:!0,get:function(){return F}}),Object.defineProperty(h,"reconcileNumbers",{enumerable:!0,get:function(){return u}});const P=V("packages/core/src/internal/util.js").isNil,L=1e-6,q=4,R="[unverified]";function _(e,l){const i=10**l,p=Math.round(e*i)/i;return p===0?0:p}function K(e){const l=e.indexOf(".");return l<0?0:Math.min(e.length-l-1,q+4)}function G(e){if(!Number.isFinite(e))return[];const l=new Set([e]);for(let i=0;i<=q;i+=1)l.add(_(e,i));if(Math.abs(e)<=1&&e!==0){const i=e*100;for(let p=0;p<=q;p+=1)l.add(_(i,p))}return[...l]}function Q(e){const l=new Set,i=[];for(const r of e)if(Number.isFinite(r)){i.push(r);for(const d of G(r))l.add(d)}const p=[...l];return{size:i.length,values:i,has(r,d){for(const v of p)if(Math.abs(v-r)<=L||_(v,d)===r)return!0;return!1}}}function H(e,l=[],i=0){if(i>8||P(e))return l;if(typeof e=="number")return Number.isFinite(e)&&l.push(e),l;if(typeof e=="string"){const p=Number(e);return e.trim()!==""&&Number.isFinite(p)&&l.push(p),l}if(Array.isArray(e)){for(const p of e)H(p,l,i+1);return l}if(typeof e=="object")for(const p of Object.keys(e))H(e[p],l,i+1);return l}const te=Object.freeze({k:1e3,K:1e3,m:1e6,M:1e6,bn:1e9,b:1e9,B:1e9});function ne(e,l,i,p){return!!((e==="-"||e==="/")&&/[A-Za-z0-9]/.test(l)||e===":"&&/\d/.test(l)||/[A-Za-z_]/.test(i)||(i==="-"||i==="/"||i===":")&&/\d/.test(p))}function F(e){const l=[];if(typeof e!="string"||e==="")return l;const i=/(^|[^\w.])([$£€¥]?)(-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?)(%?)(bn|[kKmMbB])?/g;let p;for(;(p=i.exec(e))!==null;){const[,r,,d,v,n]=p,a=p.index+r.length,f=p.index+p[0].length,g=p.index>0?e[p.index-1]:"",C=f<e.length?e[f]:"",N=f+1<e.length?e[f+1]:"";if(ne(r,g,C,N))continue;const S=d.replace(/,/g,"");let D=Number(S);if(!Number.isFinite(D))continue;const A=K(S);n&&Object.prototype.hasOwnProperty.call(te,n)&&(D*=te[n]),l.push({raw:e.slice(a,f),start:a,end:f,value:D,decimals:A,suffix:n||""})}return l}function x(e){return e===" "||e===" "||e===`
|
|
7
7
|
`||e==="\r"}function W(e){const l=[],i=[];for(let p=0;p<e.length;p+=1)if(e[p]==="(")i.push(p);else if(e[p]===")"&&i.length){const r=i.pop();i.length===0&&l.push({start:r,end:p+1})}return l}function y(e){const l=[],i=e.length;let p=0,r=0;for(;r<i;){const d=e[r],v=d==="."||d==="!"||d==="?",n=r+1>=i||x(e[r+1]);if(v&&n||d===`
|
|
8
8
|
`){let a=r+1;for(;a<i&&(e[a]==="."||e[a]==="!"||e[a]==="?");)a+=1;for(;a<i&&x(e[a]);)a+=1;l.push({start:p,end:a}),p=a,r=a;continue}r+=1}return p<i&&l.push({start:p,end:i}),l}function o(e){const l=e.slice().sort((p,r)=>p.start-r.start),i=[];for(const p of l){const r=i[i.length-1];r&&p.start<=r.end?r.end=Math.max(r.end,p.end):i.push({start:p.start,end:p.end})}return i}function t(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/alarms.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, 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.74.0";async function x(){return E}const P="1.74.0",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={"&":"&","<":"<",">":">",'"':""","'":"'"};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.75.0";async function x(){return E}const P="1.75.0",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={"&":"&","<":"<",">":">",'"':""","'":"'"};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
|
package/modules/alarms.min.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, 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.74.0";async function x(){return E}const P="1.74.0",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={"&":"&","<":"<",">":">",'"':""","'":"'"};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.75.0";async function x(){return E}const P="1.75.0",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={"&":"&","<":"<",">":">",'"':""","'":"'"};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
|