@synnaxlabs/pluto 0.28.5 → 0.30.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/README.md +1 -1
- package/dist/{Animated-BpXi9NWe.js → Animated-CADTcu8B.js} +2 -2
- package/dist/{Animated-DFza4wCT.cjs → Animated-DZSBu1oS.cjs} +1 -1
- package/dist/{Keyboard-D7ybWHn0.js → Keyboard-Bc_uxMTG.js} +2 -2
- package/dist/{Keyboard-CbKUH8Eh.cjs → Keyboard-BvHL3Wf2.cjs} +1 -1
- package/dist/{LinePlot-BK8esSwO.js → LinePlot-CUYMMNNX.js} +2292 -2247
- package/dist/LinePlot-DUHbDcz3.cjs +66 -0
- package/dist/{Link-B8NxnNli.cjs → Link-BUlcFhdF.cjs} +1 -1
- package/dist/{Link-D2fnWjvq.js → Link-CurnG57L.js} +1 -1
- package/dist/{List-Dukgv-S0.js → List-DD-MkX0Z.js} +2 -2
- package/dist/{List-DFXYScV1.cjs → List-d1KJe77_.cjs} +1 -1
- package/dist/{Pack-BNnq0Pnk.cjs → Pack-BgzS2BHo.cjs} +1 -1
- package/dist/{Pack-CcDPYCmE.js → Pack-l3j3YWpE.js} +4 -2
- package/dist/{Toggle-m9N7HK8Z.js → Toggle-BGyo9v6o.js} +7898 -7846
- package/dist/Toggle-DWKDszrQ.cjs +143 -0
- package/dist/{Video-CA6Au-LV.js → Video-Ciw4h8eF.js} +1 -1
- package/dist/{Video-Ch_mMn__.cjs → Video-JYqTPKDk.cjs} +1 -1
- package/dist/aggregator-C7n8uv-R.cjs +57 -0
- package/dist/{aggregator-J7DZKy5x.js → aggregator-Dgqx_W5g.js} +2170 -2171
- package/dist/align.cjs +1 -1
- package/dist/align.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/css-Cc1vb61S.cjs +1 -0
- package/dist/{css-BHfxGWOW.js → css-CiSR0WsA.js} +10 -10
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dropdown.cjs +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +33 -32
- package/dist/{external-BrqfXbHQ.cjs → external--tP96O6n.cjs} +1 -1
- package/dist/{external-QDpeV2Bg.cjs → external-1ZU7gP__.cjs} +1 -1
- package/dist/{external-fuYYBaX1.cjs → external-5teQpcGD.cjs} +1 -1
- package/dist/{external-ecHPjGBQ.js → external-B-gkanM-.js} +4 -4
- package/dist/{external-DqipSbJg.js → external-B-qyhpkX.js} +2 -2
- package/dist/{external-D8deprwW.js → external-B0zpdR1h.js} +3 -3
- package/dist/{external-CObl_IIp.js → external-B6F5s5aQ.js} +4 -4
- package/dist/{external-DVOz9Cj-.cjs → external-B8UhV4HB.cjs} +1 -1
- package/dist/{external-Cv1PHg1z.js → external-B_mVlkww.js} +1 -1
- package/dist/{external-BdCCLUUg.js → external-BjZo74zS.js} +7 -7
- package/dist/{external-Cg7eMkiE.js → external-C2rLSz0G.js} +5 -5
- package/dist/{external-CpeeWTtO.cjs → external-C4beOlX2.cjs} +1 -1
- package/dist/{external-BEfayRpy.cjs → external-C5nr86pR.cjs} +1 -1
- package/dist/{external-Bad1CwNW.cjs → external-CNl6YOd-.cjs} +1 -1
- package/dist/{external-PZRTTZBD.cjs → external-CTth9RPW.cjs} +1 -1
- package/dist/{external-CuEzRxQ1.js → external-CW9xTNHG.js} +7 -7
- package/dist/{external-BCVvWczs.cjs → external-Clb-pmsS.cjs} +1 -1
- package/dist/{external-DY98yrhu.cjs → external-Co2r9DLy.cjs} +1 -1
- package/dist/{external-BMtI6oH4.js → external-CulLnj8B.js} +4 -4
- package/dist/{external-DsWUD-xw.js → external-Dds3S09i.js} +4 -4
- package/dist/{external-qVdtuqZn.js → external-Dh0igrIc.js} +5 -5
- package/dist/{external-DiHS7NGb.js → external-E30UptW0.js} +2 -2
- package/dist/{external-Drm1djcp.cjs → external-FuH8ekoj.cjs} +1 -1
- package/dist/{external-CwLyjDOU.cjs → external-HLgDxDKN.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2341 -2265
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/src/aether/aether/aether.d.ts.map +1 -1
- package/dist/src/align/Pack.d.ts.map +1 -1
- package/dist/src/breadcrumb/Breadcrumb.d.ts +6 -1
- package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/src/icon/Icon.d.ts +1 -1
- package/dist/src/input/DragButton.d.ts.map +1 -1
- package/dist/src/menu/ContextMenu.d.ts +2 -2
- package/dist/src/menu/ContextMenu.d.ts.map +1 -1
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/status/aether/aggregator.d.ts.map +1 -1
- package/dist/src/status/aether/types.d.ts.map +1 -1
- package/dist/src/synnax/aether/provider.d.ts +18 -18
- package/dist/src/synnax/aether/provider.d.ts.map +1 -1
- package/dist/src/telem/aether/remote.d.ts.map +1 -1
- package/dist/src/telem/aether/transformers.d.ts.map +1 -1
- package/dist/src/telem/control/aether/chip.d.ts +12 -12
- package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
- package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
- package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
- package/dist/src/telem/control/aether/state.d.ts.map +1 -1
- package/dist/src/tooltip/wrap.d.ts.map +1 -1
- package/dist/src/triggers/Text.d.ts.map +1 -1
- package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
- package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
- package/dist/src/vis/draw2d/canvas.d.ts +1 -1
- package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
- package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
- package/dist/src/vis/legend/Container.d.ts.map +1 -1
- package/dist/src/vis/light/aether/index.d.ts +2 -0
- package/dist/src/vis/light/aether/index.d.ts.map +1 -0
- package/dist/src/vis/light/aether/light.d.ts +112 -0
- package/dist/src/vis/light/aether/light.d.ts.map +1 -0
- package/dist/src/vis/light/index.d.ts +2 -0
- package/dist/src/vis/light/index.d.ts.map +1 -0
- package/dist/src/vis/light/use.d.ts +9 -0
- package/dist/src/vis/light/use.d.ts.map +1 -0
- package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
- package/dist/src/vis/lineplot/range/aether/provider.d.ts +40 -40
- package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
- package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
- package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
- package/dist/src/vis/schematic/Forms.d.ts +1 -5
- package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
- package/dist/src/vis/schematic/Symbols.d.ts +15 -14
- package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
- package/dist/src/vis/schematic/primitives/Primitives.d.ts +13 -16
- package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
- package/dist/src/vis/schematic/registry.d.ts.map +1 -1
- package/dist/src/vis/value/aether/value.d.ts.map +1 -1
- package/dist/src/vis/value/use.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/dist/{units-t-SdMRna.js → units-BAK8qzqy.js} +1 -1
- package/dist/{units-CKv8dczK.cjs → units-C59nowP2.cjs} +1 -1
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +21 -21
- package/dist/LinePlot-D-BHnuDg.cjs +0 -66
- package/dist/Toggle-CGbCK-dz.cjs +0 -143
- package/dist/aggregator-C5NNOlCt.cjs +0 -57
- package/dist/css-C4GOlJsi.cjs +0 -1
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";var hc=Object.defineProperty;var dc=(t,e,r)=>e in t?hc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var P=(t,e,r)=>dc(t,typeof e!="symbol"?e+"":e,r);const s=require("zod"),O=require("./css-C4GOlJsi.cjs"),Xn=require("react");var fc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gc(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}const vt=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var pc=Object.defineProperty,mc=(t,e,r)=>e in t?pc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ot=(t,e,r)=>mc(t,typeof e!="symbol"?e+"":e,r);let wc=class{constructor(){Ot(this,"contentType","application/json"),Ot(this,"decoder"),Ot(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=JSON.parse(e),i=O.T(n);return r!=null?r.parse(i):i}encodeString(e){const r=O.C(e);return JSON.stringify(r,(n,i)=>ArrayBuffer.isView(i)?Array.from(i):vt(i)&&"encode_value"in i?typeof i.value=="bigint"?i.value.toString():i.value:typeof i=="bigint"?i.toString():i)}static registerCustomType(){}},bc=class{constructor(){Ot(this,"contentType","text/csv")}encode(e){const r=this.encodeString(e);return new TextEncoder().encode(r).buffer}decode(e,r){const n=new TextDecoder().decode(e);return this.decodeString(n,r)}encodeString(e){if(!Array.isArray(e)||e.length===0||!vt(e[0]))throw new Error("Payload must be an array of objects");const r=Object.keys(e[0]),n=[r.join(",")];return e.forEach(i=>{const a=r.map(o=>JSON.stringify(i[o]??""));n.push(a.join(","))}),n.join(`
|
|
2
|
-
`)}decodeString(e,r){const[n,...i]=e.trim().split(`
|
|
3
|
-
`).map(l=>l.trim());if(n.length===0)return r!=null?r.parse({}):{};const a=n.split(",").map(l=>l.trim()),o={};return a.forEach(l=>{o[l]=[]}),i.forEach(l=>{const u=l.split(",").map(d=>d.trim());a.forEach((d,f)=>{const h=this.parseValue(u[f]);h!=null&&o[d].push(h)})}),r!=null?r.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const r=Number(e);return isNaN(r)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:r}static registerCustomType(){}},vc=class{constructor(){Ot(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,r){const n=new TextDecoder().decode(e);return r!=null?r.parse(n):n}};const er=new wc;new bc;new vc;const ji=t=>t!=null&&typeof t=="object"&&"toString"in t,Oc=t=>{if(ji(t))return(t==null?void 0:t.toString().length)===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t===null}},Ur=(t,e=!1)=>{const r=ji(t)?"stringer":typeof t;let n;switch(r){case"string":n=(i,a)=>i.localeCompare(a);break;case"stringer":n=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":n=(i,a)=>Number(i)-Number(a);break;case"bigint":n=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":n=(i,a)=>Number(i)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?Ri(n):n},Tc=(t,e,r)=>{const n=Ur(e[t],r);return(i,a)=>n(i[t],a[t])},Sc=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,zc=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=Ur(t[0]),n=[...t].sort(r),i=[...e].sort(r);return n.every((a,o)=>a===i[o])?0:-1},Nc=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,Ri=t=>(e,r)=>t(r,e),Ec=0,en=-1,tn=1,Mi=t=>t<0,Di=t=>t>0,Ic=t=>t>=0,Pi=t=>t===0,kc=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),i=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!i)return 0;for(let a=0;a<Math.min(n.length,i.length);a++){const o=n[a],l=i[a];if(isNaN(Number(o))&&isNaN(Number(l))){const u=o.localeCompare(l);if(u!==0)return u}else if(!isNaN(Number(o))&&!isNaN(Number(l))){const u=Number(o)-Number(l);if(u!==0)return u}else return isNaN(Number(o))?-1:1}return n.length-i.length},Ac=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:0,GREATER_THAN:1,LESS_THAN:-1,isEqualTo:Pi,isGreaterThan:Di,isGreaterThanEqual:Ic,isLessThan:Mi,newF:Ur,newFieldF:Tc,order:Nc,primitiveArrays:Sc,reverseF:Ri,stringsWithNumbers:kc,unorderedPrimitiveArrays:zc},Symbol.toStringTag,{value:"Module"})),xc=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Cc=(t,e)=>{let r=null;return e===0?t:(...n)=>{r===null&&(r=setTimeout(()=>{t(...n),r=null},e))}},Bi=(t,e,r=".")=>{const n=t.split(r);return n.map((i,a)=>{const o=e(i,a,n);return o==null?null:typeof o=="string"?o:o.join(r)}).filter(i=>i!=null).join(r)},Qn=(t,e,r={optional:!1,separator:"."})=>{r.separator??(r.separator=".");const{optional:n,getter:i=(l,u)=>l[u]}=r,a=e.split(r.separator);if(a.length===1&&a[0]==="")return t;let o=t;for(const l of a){const u=i(o,l);if(u==null){if(n)return null;throw new Error(`Path ${e} does not exist. ${l} is null`)}o=u}return o},$c=(t,e,r)=>{const n=e.split(".");let i=t;for(let a=0;a<n.length-1;a++){const o=n[a];i[o]==null&&(i[o]={}),i=i[o]}i[n[n.length-1]]=r},jc=(t,e)=>{const r=e.split(".");let n=t;for(let i=0;i<r.length-1;i++){const a=r[i];if(n[a]==null)return;n=n[a]}if(Array.isArray(n)){const i=parseInt(r[r.length-1],10);if(isNaN(i))return;n.splice(i,1);return}delete n[r[r.length-1]]},Rc=(t,e)=>{const r=t.split(".");return e<0?r[r.length+e]:r[e]},Mc=(t,e)=>{try{return Qn(t,e),!0}catch{return!1}},Dc=(t,e)=>{if(e.length===0)return!0;const r=t.split("."),n=e.split(".");if(n.length>r.length)return!1;for(let i=0;i<n.length;i++){const a=r[i],o=n[i];if(o!=="*"&&a!==o)return!1}return!0},Pc=t=>JSON.parse(JSON.stringify(t)),Bc=(t,...e)=>(e.forEach(r=>{let n=t;const i=r.split(".");i.forEach((a,o)=>{o===i.length-1?delete n[a]:a in n&&(n=n[a])})}),t),Uc=(t,e,r="")=>{const n={},i=(a,o,l)=>{if(typeof a!=typeof o||a===null||o===null){n[l]=[a,o];return}if(typeof a=="object"&&typeof o=="object")if(Array.isArray(a)&&Array.isArray(o)){if(a.length!==o.length){n[l]=[a,o];return}for(let u=0;u<a.length;u++)i(a[u],o[u],`${l}[${u}]`)}else new Set([...Object.keys(a),...Object.keys(o)]).forEach(u=>{i(a[u],o[u],l!==""?`${l}.${u}`:u)});else a!==o&&(n[l]=[a,o])};return i(t,e,r),n},kn=(t,e)=>{const r=Array.isArray(t),n=Array.isArray(e);if(r!==n)return!1;if(r&&n){const o=t,l=e;if(o.length!==l.length)return!1;for(let u=0;u<o.length;u++)if(!kn(o[u],l[u]))return!1;return!0}if(t==null||e==null||typeof t!="object"||typeof e!="object")return t===e;if("equals"in t)return t.equals(e);const i=Object.keys(t),a=Object.keys(e);if(i.length!==a.length)return!1;for(const o of i){const l=t[o],u=e[o];if(typeof l=="object"&&typeof u=="object"){if(!kn(l,u))return!1}else if(l!==u)return!1}return!0},Ui=(t,e)=>{if(typeof t!="object"||t==null)return t===e;const r=Object.keys(t),n=Object.keys(e);if(n.length>r.length)return!1;for(const i of n){const a=t[i],o=e[i];if(typeof a=="object"&&typeof o=="object"){if(!Ui(a,o))return!1}else if(a!==o)return!1}return!0},An=(t,...e)=>{if(e.length===0)return t;const r=e.shift();if(vt(t)&&vt(r))for(const n in r)try{vt(r[n])?(n in t||Object.assign(t,{[n]:{}}),An(t[n],r[n])):Object.assign(t,{[n]:r[n]})}catch(i){throw i instanceof TypeError?new TypeError(`.${n}: ${i.message}`):i}return An(t,...e)},Lc=(t,e,r)=>{const n=(i,a,o)=>{for(const l in a){const u=a[l];if(o!=null&&o.shape[l]){const d=o.shape[l].safeParse(u);d.success&&(i[l]=d.data)}else typeof u=="object"&&!Array.isArray(u)&&u!==null&&o&&o.shape&&o.shape[l]&&(i[l]||(i[l]={}),n(i[l],u,o.shape[l]))}return i};return n({...t},e,r)},Li=Object.freeze(Object.defineProperty({__proto__:null,copy:Pc,deleteD:Bc,difference:Uc,element:Rc,equal:kn,get:Qn,has:Mc,override:An,overrideValidItems:Lc,partialEqual:Ui,pathsMatch:Dc,remove:jc,set:$c,transformPath:Bi},Symbol.toStringTag,{value:"Module"}));var Yc=Object.defineProperty,qc=(t,e,r)=>e in t?Yc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,m=(t,e,r)=>qc(t,typeof e!="symbol"?e+"":e,r);let _c=(t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n};const Fc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Yi=_c(Fc,11),Wc=Object.freeze(Object.defineProperty({__proto__:null,id:Yi},Symbol.toStringTag,{value:"Module"})),qi=(t,e)=>{const r=new F(e);if(![V.DAY,V.HOUR,V.MINUTE,V.SECOND,V.MILLISECOND,V.MICROSECOND,V.NANOSECOND].some(i=>i.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof F?new F(n):new V(n)},B=class T{constructor(e,r="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=T.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*T.MILLISECOND.valueOf();else if(typeof e=="string")this.value=T.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=T.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const i=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(i.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=T.hours(parseInt(n??"00",10)).add(T.minutes(parseInt(i??"00",10))).add(T.seconds(parseInt(o??"00",10))).add(T.milliseconds(parseInt(l??"00",10)));return r==="local"&&(u=u.add(T.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new V(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new It(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new T(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return qi(this,e)}get isToday(){return this.truncate(V.DAY).equals(T.now().truncate(V.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const i=new T(n);i.after(r)&&(r=i)}return r}static min(...e){let r=T.MAX;for(const n of e){const i=new T(n);i.before(r)&&(r=i)}return r}static nanoseconds(e){return new T(e)}static microseconds(e){return T.nanoseconds(e*1e3)}static milliseconds(e){return T.microseconds(e*1e3)}static seconds(e){return T.milliseconds(e*1e3)}static minutes(e){return T.seconds(e*60)}static hours(e){return T.minutes(e*60)}static days(e){return T.hours(e*24)}};m(B,"NANOSECOND",B.nanoseconds(1)),m(B,"MICROSECOND",B.microseconds(1)),m(B,"MILLISECOND",B.milliseconds(1)),m(B,"SECOND",B.seconds(1)),m(B,"MINUTE",B.minutes(1)),m(B,"HOUR",B.hours(1)),m(B,"DAY",B.days(1)),m(B,"MAX",new B((1n<<63n)-1n)),m(B,"MIN",new B(0)),m(B,"ZERO",new B(0)),m(B,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new B(t.value)),s.z.string().transform(t=>new B(BigInt(t))),s.z.instanceof(Number).transform(t=>new B(t)),s.z.number().transform(t=>new B(t)),s.z.instanceof(B)]));let F=B;const U=class A{constructor(e){m(this,"value"),m(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new A(e).valueOf()}greaterThan(e){return this.valueOf()>new A(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new A(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new A(e).valueOf()}remainder(e){return qi(this,e)}truncate(e){return new A(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(A.DAY),r=this.truncate(A.HOUR),n=this.truncate(A.MINUTE),i=this.truncate(A.SECOND),a=this.truncate(A.MILLISECOND),o=this.truncate(A.MICROSECOND),l=this.truncate(A.NANOSECOND),u=e,d=r.sub(e),f=n.sub(r),h=i.sub(n),j=a.sub(i),W=o.sub(a),se=l.sub(o);let R="";return u.isZero||(R+=`${u.days}d `),d.isZero||(R+=`${d.hours}h `),f.isZero||(R+=`${f.minutes}m `),h.isZero||(R+=`${h.seconds}s `),j.isZero||(R+=`${j.milliseconds}ms `),W.isZero||(R+=`${W.microseconds}µs `),se.isZero||(R+=`${se.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(A.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(A.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new A(e).valueOf()}add(e){return new A(this.valueOf()+new A(e).valueOf())}sub(e){return new A(this.valueOf()-new A(e).valueOf())}static nanoseconds(e=1){return new A(e)}static microseconds(e=1){return A.nanoseconds(e*1e3)}static milliseconds(e=1){return A.microseconds(e*1e3)}static seconds(e=1){return A.milliseconds(e*1e3)}static minutes(e){return A.seconds(e.valueOf()*60)}static hours(e){return A.minutes(e*60)}static days(e){return A.hours(e*24)}};m(U,"NANOSECOND",U.nanoseconds(1)),m(U,"MICROSECOND",U.microseconds(1)),m(U,"MILLISECOND",U.milliseconds(1)),m(U,"SECOND",U.seconds(1)),m(U,"MINUTE",U.minutes(1)),m(U,"HOUR",U.hours(1)),m(U,"DAY",U.days(1)),m(U,"MAX",new U((1n<<63n)-1n)),m(U,"MIN",new U(0)),m(U,"ZERO",new U(0)),m(U,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new U(t.value)),s.z.string().transform(t=>new U(BigInt(t))),s.z.instanceof(Number).transform(t=>new U(t)),s.z.number().transform(t=>new U(t)),s.z.instanceof(U)]));let V=U;const at=class tr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new tr(e).valueOf()}get period(){return V.seconds(1/this.valueOf())}sampleCount(e){return new V(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ce(r).valueOf()}span(e){return V.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new tr(e)}static khz(e){return tr.hz(e*1e3)}};m(at,"z",s.z.union([s.z.number().transform(t=>new at(t)),s.z.instanceof(Number).transform(t=>new at(t)),s.z.instanceof(at)]));let Vc=at;const X=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Lr(e*this.valueOf())}};m(X,"UNKNOWN",new X(0)),m(X,"BIT128",new X(16)),m(X,"BIT64",new X(8)),m(X,"BIT32",new X(4)),m(X,"BIT16",new X(2)),m(X,"BIT8",new X(1)),m(X,"z",s.z.union([s.z.number().transform(t=>new X(t)),s.z.instanceof(Number).transform(t=>new X(t)),s.z.instanceof(X)]));let ce=X;const Oe=class rr{constructor(e,r){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new F(e.start),this.end=new F(e.end)):(this.start=new F(e),this.end=new F(r))}get span(){return new V(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new rr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=V.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const i=F.max(n.start,e.start),a=F.min(n.end,e.end);return a.before(i)?!1:new V(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof rr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new rr(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};m(Oe,"MAX",new Oe(F.MIN,F.MAX)),m(Oe,"MIN",new Oe(F.MAX,F.MIN)),m(Oe,"ZERO",new Oe(F.ZERO,F.ZERO)),m(Oe,"z",s.z.union([s.z.object({start:F.z,end:F.z}).transform(t=>new Oe(t.start,t.end)),s.z.instanceof(Oe)]));let It=Oe;const y=class Te extends String{constructor(e){if(e instanceof Te||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Te.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Te.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Te.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(Te.JSON)||this.equals(Te.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Te.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Te.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Te.BIG_INT_TYPES.some(e=>e.equals(this))}};m(y,"UNKNOWN",new y("unknown")),m(y,"FLOAT64",new y("float64")),m(y,"FLOAT32",new y("float32")),m(y,"INT64",new y("int64")),m(y,"INT32",new y("int32")),m(y,"INT16",new y("int16")),m(y,"INT8",new y("int8")),m(y,"UINT64",new y("uint64")),m(y,"UINT32",new y("uint32")),m(y,"UINT16",new y("uint16")),m(y,"UINT8",new y("uint8")),m(y,"BOOLEAN",y.UINT8),m(y,"TIMESTAMP",new y("timestamp")),m(y,"UUID",new y("uuid")),m(y,"STRING",new y("string")),m(y,"JSON",new y("json")),m(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),m(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),m(y,"DENSITIES",new Map([[y.UINT8.toString(),ce.BIT8],[y.UINT16.toString(),ce.BIT16],[y.UINT32.toString(),ce.BIT32],[y.UINT64.toString(),ce.BIT64],[y.FLOAT32.toString(),ce.BIT32],[y.FLOAT64.toString(),ce.BIT64],[y.INT8.toString(),ce.BIT8],[y.INT16.toString(),ce.BIT16],[y.INT32.toString(),ce.BIT32],[y.INT64.toString(),ce.BIT64],[y.TIMESTAMP.toString(),ce.BIT64],[y.STRING.toString(),ce.UNKNOWN],[y.JSON.toString(),ce.UNKNOWN],[y.UUID.toString(),ce.BIT128]])),m(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),m(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),m(y,"z",s.z.union([s.z.string().transform(t=>new y(t)),s.z.instanceof(y)]));let M=y;const ie=class Z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Z.bytes(this.valueOf()+e.valueOf())}sub(e){return Z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Z.TERABYTE.valueOf()}toString(){const e=this.truncate(Z.TERABYTE),r=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),i=this.truncate(Z.KILOBYTE),a=this.truncate(Z.BYTE),o=e,l=r.sub(e),u=n.sub(r),d=i.sub(n),f=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),d.isZero||(h+=`${d.kilobytes}KB `),(!f.isZero||h==="")&&(h+=`${f.valueOf()}B`),h.trim()}static bytes(e=1){return new Z(e)}static kilobytes(e=1){return Z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Z.megabytes(e.valueOf()*1e3)}static terabytes(e){return Z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(ie,"BYTE",new ie(1)),m(ie,"KILOBYTE",ie.kilobytes(1)),m(ie,"MEGABYTE",ie.megabytes(1)),m(ie,"GIGABYTE",ie.gigabytes(1)),m(ie,"TERABYTE",ie.terabytes(1)),m(ie,"ZERO",new ie(0)),m(ie,"z",s.z.union([s.z.number().transform(t=>new ie(t)),s.z.instanceof(ie)]));let Lr=ie;const Gc=s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]),_i=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof F||t instanceof V||t instanceof Date},Zc=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):ot(r,-n),Kc=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Fi?!0:_i(t),Le=-1;let Fi=class ke{constructor(e){m(this,"key",""),m(this,"isSynnaxSeries",!0),m(this,"dataType"),m(this,"sampleOffset"),m(this,"gl"),m(this,"_data"),m(this,"_timeRange"),m(this,"alignment",0n),m(this,"_cachedMin"),m(this,"_cachedMax"),m(this,"writePos",Le),m(this,"_refCount",0),m(this,"_cachedLength"),Kc(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:l=Yi()}=e,{data:u}=e;if(u instanceof ke||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const h=u;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const d=_i(u),f=Array.isArray(u);if(r!=null)this.dataType=new M(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||d){let h=u;if(!d){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");h=u[0]}if(typeof h=="string")this.dataType=M.STRING;else if(typeof h=="number")this.dataType=M.FLOAT64;else if(typeof h=="bigint")this.dataType=M.INT64;else if(typeof h=="boolean")this.dataType=M.BOOLEAN;else if(h instanceof F||h instanceof Date||h instanceof F)this.dataType=M.TIMESTAMP;else if(typeof h=="object")this.dataType=M.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new M(u)}if(!f&&!d)this._data=u;else{let h=d?[u]:u;const j=h[0];(j instanceof F||j instanceof Date||j instanceof V)&&(h=h.map(W=>new F(W).valueOf())),this.dataType.equals(M.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
|
|
4
|
-
`)+`
|
|
5
|
-
`)):this.dataType.equals(M.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(W=>er.encodeString(W)).join(`
|
|
6
|
-
`)+`
|
|
7
|
-
`)):this._data=new this.dataType.Array(h).buffer}this.key=l,this.alignment=o,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new M(r).Array(e),a=new ke({data:i.buffer,dataType:r,...n});return a.writePos=0,a}static generateTimestamps(e,r,n){const i=n.spanRange(r.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(r.span(o)).valueOf());return new ke({data:a,dataType:M.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
|
|
8
|
-
`)+`
|
|
9
|
-
`);return new ke({data:n,dataType:M.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(i=>er.encodeString(i)).join(`
|
|
10
|
-
`)+`
|
|
11
|
-
`);return new ke({data:n,dataType:M.JSON,timeRange:r})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Le)return 0;const r=this.capacity-this.writePos,n=r<e.length?e.slice(0,r):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Le?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(M.STRING,M.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
12
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(M.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=M.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const i=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=a}return r}parseJSON(e){if(!this.dataType.equals(M.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
13
|
-
`).slice(0,-1).map(r=>e.parse(er.decodeString(r)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Lr(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Le?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(r=>{r===10&&e++}),this._cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let i=0;i<this.length;i++)n[i]=Zc(this.dataType,e,this.data[i],r);return new ke({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(M.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),ot(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(M.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),ot(this._cachedMin,this.sampleOffset))}get bounds(){return O.o(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const r=e._cachedMin??e.calcRawMin();r<this._cachedMin&&(this._cachedMin=r)}if(this._cachedMax!=null){const r=e._cachedMax??e.calcRawMax();r>this._cachedMax&&(this._cachedMax=r)}}enrich(){this.max,this.min}get range(){return ot(this.max,-this.min)}at(e,r){if(this.dataType.isVariable)return this.atVariable(e,r??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return ot(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,i=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){i=o;break}n=o+1,e--}if(i===0&&(i=this.data.length),n>=i||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,i);return this.dataType.equals(M.STRING)?new TextDecoder().decode(a):O.T(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let r=0,n=this.length-1;const i=Ur(e);for(;r<=n;){const a=Math.floor((r+n)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?r=a+1:n=a-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(M.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:i}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Le}as(e){if(e==="string"){if(!this.dataType.equals(M.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(M.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return O.o(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Jc(this);return this.dataType.equals(M.JSON)?new Hc(e):e}return new Xc(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new ke({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new ke({data:this.buffer,dataType:this.dataType,timeRange:It.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};class Jc{constructor(e){if(m(this,"series"),m(this,"index"),m(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var js,Rs;let Hc=class{constructor(e){m(this,"wrapped"),m(this,js,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:er.decodeString(e.value)}}[(Rs=Symbol.iterator,js=Symbol.toStringTag,Rs)](){return this}};var Ms,Ds;let Xc=class{constructor(e){m(this,"series"),m(this,"index"),m(this,Ms,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Ds=Symbol.iterator,Ms=Symbol.toStringTag,Ds)](){return this}};const ot=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);let Qc=class{constructor(e){if(m(this,"series"),e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new M(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?M.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?It.ZERO:new It(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,r)=>e+r.length,0)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new Lr(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new el(this.series)}};var Ps,Bs;class el{constructor(e){m(this,"series"),m(this,"seriesIndex"),m(this,"internal"),m(this,Ps,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(Bs=Symbol.iterator,Ps=Symbol.toStringTag,Bs)](){return this}}s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const Wi=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",tl=Wi(),Vi=["MacOS","Windows","Linux","Docker"],rl=s.z.enum(Vi);let rn;const nl=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},sl=(t={})=>{const{force:e,default:r}=t;return e??rn??(rn=nl(),rn??r)},Gi=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Vi,RUNTIME:tl,detect:Wi,getOS:sl,osZ:rl},Symbol.toStringTag,{value:"Module"})),il=t=>Array.isArray(t)?t:[t],al=t=>Array.isArray(t)?t:t===null?[]:[t],ol=t=>[...new Set(t)];var cl=Object.defineProperty,ll=(t,e,r)=>e in t?cl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ct=(t,e,r)=>ll(t,typeof e!="symbol"?e+"":e,r);const ul=(...t)=>t.map(Zi).join(""),Zi=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),hl=t=>t.endsWith("/")?t.slice(0,-1):t,Us=class xn{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){ct(this,"protocol"),ct(this,"host"),ct(this,"port"),ct(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=Zi(i)}replace(e){return new xn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new xn({...this,pathPrefix:ul(this.path,e)})}toString(){return hl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};ct(Us,"UNKNOWN",new Us({host:"unknown",port:0}));var dl=Object.defineProperty,fl=(t,e,r)=>e in t?dl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ar=(t,e,r)=>fl(t,typeof e!="symbol"?e+"":e,r);let yl=class{constructor(e){Ar(this,"sender"),Ar(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var r;const n=(r=this.handlers.get(e.type))==null?void 0:r.handler;n==null?console.warn(`No handler for ${e.type}`):n(e.payload)}route(e){const r=gl(e,this.sender),n=new pl(r);return this.handlers.set(e,n),n}};const gl=(t,e)=>(r,n)=>e({type:t,payload:r},n);let pl=class{constructor(e){Ar(this,"_send"),Ar(this,"handler"),this._send=e,this.handler=null}send(e,r=[]){this._send(e,r)}handle(e){this.handler=e}};var ml=Object.defineProperty,wl=(t,e,r)=>e in t?ml(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nr=(t,e,r)=>wl(t,typeof e!="symbol"?e+"":e,r);const qe=class extends Number{};nr(qe,"Absolute",255),nr(qe,"Default",1),nr(qe,"z",s.z.union([s.z.instanceof(qe),s.z.number().int().min(0).max(255).transform(t=>new qe(t)),s.z.instanceof(Number).transform(t=>new qe(t))]));let Ki=qe;const Ji=s.z.object({name:s.z.string(),key:s.z.string()}),bl=t=>s.z.object({subject:Ji,resource:t,authority:Ki.z}),vl=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),Ol=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ki,filterTransfersByChannelKey:vl,stateZ:bl,subjectZ:Ji},Symbol.toStringTag,{value:"Module"})),Hi=class lt extends Error{constructor(){super(lt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(lt.MESSAGE):e instanceof lt||e.message.includes(lt.MESSAGE)}};nr(Hi,"MESSAGE","canceled");let Tl=Hi;new Tl;const Sl=t=>t?-1:1,Cn=s.z.string().regex(/^\d+\.\d+\.\d+$/),Mt=(t,e,r={})=>{r.checkMajor??(r.checkMajor=!0),r.checkMinor??(r.checkMinor=!0),r.checkPatch??(r.checkPatch=!0);const n=Cn.parse(t),i=Cn.parse(e),[a,o,l]=n.split(".").map(Number),[u,d,f]=i.split(".").map(Number);if(r.checkMajor){if(a<u)return en;if(a>u)return tn}if(r.checkMinor){if(o<d)return en;if(o>d)return tn}if(r.checkPatch){if(l<f)return en;if(l>f)return tn}return Ec},zl=(t,e,r={})=>Pi(Mt(t,e,r)),Xi=(t,e,r={})=>Di(Mt(t,e,r)),Nl=(t,e,r={})=>Mi(Mt(t,e,r)),El=({name:t,migrate:e})=>r=>{try{const n=e(r);return console.log(`${t} migrated: ${r.version} -> ${n.version}`),n}catch(n){throw console.log(`${t} failed to migrate from ${r.version}`),console.error(n),n}},Il=({name:t,migrations:e,targetSchema:r,def:n})=>{const i=Object.keys(e).sort(Mt).pop();if(i==null)return u=>{if(u.version!==n.version)return console.log(`${t} version ${u.version} is newer than latest version of ${n.version}.
|
|
14
|
-
Returning default instead.
|
|
15
|
-
`),n;try{return r!=null?r.parse(u):u}catch(d){return console.log(`${t} failed to parse default. Exiting with default`),console.error(d),n}};const a=Object.keys(e).length;let o=!1;const l=u=>{try{if(a===0||Xi(u.version,i))return console.log(o?`${t} ${u.version} now up to date`:`${t} version ${u.version} is up to date with target version ${n.version}`),u;const d=u.version,f=e[d],h=f(u);return o=!0,l(h)}catch(d){return console.log(`${t} failed to migrate from ${u.version} to ${i}`),console.error(d),n}};return u=>{try{return l(u)}catch(d){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(d),n}}},kl=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Mt,createMigration:El,migrator:Il,semVerNewer:Xi,semVerOlder:Nl,semVerZ:Cn,versionsEqual:zl},Symbol.toStringTag,{value:"Module"})),Al=t=>{if(t===void 0||typeof t=="string"||typeof t=="number")return t;if(t.toString===void 0)throw new Error("invalid renderer");return t.toString()},xl=t=>Array.isArray(t)?[...t]:typeof t=="object"&&t!==null?{...t}:t,es=t=>typeof t=="function",ts=(t,e)=>es(t)?t(e):t,Dt=t=>Qi(t)?t():t,Qi=t=>typeof t=="function",ea=({initial:t,value:e,onChange:r})=>{const[n,i]=Xn.useState(Dt(e??t));return e!=null&&r!=null?[e,r]:[n,i]},ta=({initial:t,value:e,onChange:r})=>{const[n,i]=Xn.useState(Dt(e??t));return e!=null&&r!=null?[e,r]:[n,i]},Cl=(t,e)=>{const[r,n]=Xn.useState(()=>{const i=localStorage.getItem(e);return i==null?Dt(t):JSON.parse(i)});return[r,i=>{n(i),localStorage.setItem(e,JSON.stringify(i))}]},$l=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:Dt,executeSetter:ts,isInitialSetter:Qi,isSetter:es,usePassthrough:ea,usePersisted:Cl,usePurePassthrough:ta},Symbol.toStringTag,{value:"Module"})),ra=["h1","h2","h3","h4","h5","p","small"],jl=s.z.enum(ra),Me=s.z.object({size:s.z.number(),weight:s.z.union([s.z.number(),s.z.string()]),lineHeight:s.z.number(),textTransform:s.z.string().optional()}),na={small:"small",medium:"p",large:"h5",huge:"h2"},Rl={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"};let nn=null;const Ml=()=>(nn==null&&(nn=document.createElement("canvas")),nn),Dl=(t,e,r)=>{if(Gi.RUNTIME==="node")return{width:0,height:0};r==null&&(r=Ml().getContext("2d")),r.font=e;const n=r.measureText(t);return{width:Math.trunc(Math.abs(n.actualBoundingBoxLeft)+Math.abs(n.actualBoundingBoxRight)),height:Math.trunc(Math.abs(n.actualBoundingBoxAscent)+Math.abs(n.actualBoundingBoxDescent))}},Pl=s.z.object({l0:O.Color.z,l1:O.Color.z,l2:O.Color.z,l3:O.Color.z,l4:O.Color.z,l5:O.Color.z,l6:O.Color.z,l7:O.Color.z,l8:O.Color.z,l9:O.Color.z,l10:O.Color.z}),pe=(t,e)=>[t[0],t[1],e,t[3]],Bl=s.z.object({m2:O.Color.z,m1:O.Color.z,z:O.Color.z,p1:O.Color.z,p2:O.Color.z}),Ft=Bl.or(O.Color.z.transform(t=>{const e=t.hsla;return{m2:new O.Color(O.fromHSLA(pe(e,40))),m1:new O.Color(O.fromHSLA(pe(e,45))),z:t,p1:new O.Color(O.fromHSLA(pe(e,55))),p2:new O.Color(O.fromHSLA(pe(e,65)))}})),sa=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:O.Color.z,primary:Ft,gray:Pl,error:Ft,secondary:Ft,warning:Ft,visualization:s.z.object({palettes:s.z.record(s.z.array(O.Color.z))}).optional().default({palettes:{}}),white:O.Color.z,black:O.Color.z,text:O.Color.z,textInverted:O.Color.z,textOnPrimary:O.Color.z.optional().default(O.ZERO),logo:s.z.string()}),sizes:s.z.object({base:s.z.number(),border:s.z.object({radius:s.z.number(),width:s.z.number()}),schematic:s.z.object({elementStrokeWidth:s.z.number()})}),typography:s.z.object({family:s.z.string(),h1:Me,h2:Me,h3:Me,h4:Me,h5:Me,p:Me,small:Me})}).transform(t=>((t.colors.textOnPrimary==null||t.colors.textOnPrimary.isZero)&&(t.colors.textOnPrimary=t.colors.primary.z.pickByContrast(t.colors.text,t.colors.textInverted)),t)),Ul="'Inter Variable', sans-serif",Ll=6,rt=[357,91,55,1],nt=[42,100,50,1],Yl=["#FCFCFC","#F9F9F9","#F4F4F4","#ededed","#d9d9d9","#ADADAD","#878787","#616161","#404040","#1C1C1C","#050505"],Wt=Object.fromEntries(Yl.map((t,e)=>[`l${e}`,t])),$n={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#164FA0",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:Wt,border:Wt.l3,error:{m2:O.fromHSLA(pe(rt,30)),m1:O.fromHSLA(pe(rt,40)),z:O.fromHSLA(rt),p1:O.fromHSLA(pe(rt,65)),p2:O.fromHSLA(pe(rt,77))},warning:{m2:O.fromHSLA(pe(nt,30)),m1:O.fromHSLA(pe(nt,40)),z:O.fromHSLA(nt),p1:O.fromHSLA(pe(nt,65)),p2:O.fromHSLA(pe(nt,75))},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:Wt.l9,textInverted:Wt.l0},sizes:{base:Ll,border:{radius:3,width:1},schematic:{elementStrokeWidth:2}},typography:{family:Ul,h1:{size:7,weight:"500",lineHeight:7*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:1.9166666*1.5}}},ia=Object.freeze({...$n,key:"synnaxLight",name:"Synnax Light"}),ql=["#020202","#060606","#0D0D0D","#191919","#242424","#434343","#646464","#8A8A8A","#AFAFAF","#D5D5D5","#FDFDFD"],Vt=Object.fromEntries(ql.map((t,e)=>[`l${e}`,t])),aa=Object.freeze({...$n,key:"synnaxDark",name:"Synnax Dark",colors:{...$n.colors,gray:Vt,logo:"var(--pluto-text-color)",border:Vt.l3,text:Vt.l9,textInverted:Vt.l0}}),_l={synnaxDark:aa,synnaxLight:ia},Fl=["small","medium","large","huge"],Wl=s.z.enum(Fl),Vl=t=>Wl.safeParse(t).success,Gl=(t,e,r)=>{const{typography:n,sizes:{base:i}}=t,a=n[Vl(e)?na[e]:e].size,o=i*a,[l,u]=n.family.split(", ");return r!=null?` ${r} ${o}px ${l}, ${u}`:` ${o}px ${n.family}`};var Zl=Object.defineProperty,Kl=(t,e,r)=>e in t?Zl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e,r)=>Kl(t,typeof e!="symbol"?e+"":e,r),Jl=Object.defineProperty,Hl=(t,e,r)=>e in t?Jl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,D=(t,e,r)=>Hl(t,typeof e!="symbol"?e+"":e,r);const Xl=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()?e:e[0].toLowerCase()+e.slice(1)},oa=t=>{const e=(r,n=jn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!sn(r))return r;n=ru(n);const i={},a=r;return Object.keys(a).forEach(o=>{let l=a[o];const u=t(o);n.recursive&&(sn(l)?Ys(l,n.keepTypesOnRecursion)||(l=e(l,n)):n.recursiveInArray&&Ls(l)&&(l=[...l].map(d=>{let f=d;return sn(d)?Ys(f,n.keepTypesOnRecursion)||(f=e(d,n)):Ls(d)&&(f=e({key:d},n).key),f}))),i[u]=l}),i};return e},Ql=oa(Xl),eu=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),tu=oa(eu),jn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},ru=(t=jn)=>(t.recursive==null?t=jn:t.recursiveInArray==null&&(t.recursiveInArray=!1),t),Ls=t=>t!=null&&Array.isArray(t),sn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Ys=(t,e)=>(e||[]).some(r=>t instanceof r),ca=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var nu=Object.defineProperty,su=(t,e,r)=>e in t?nu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tt=(t,e,r)=>su(t,typeof e!="symbol"?e+"":e,r);let iu=class{constructor(){Tt(this,"contentType","application/json"),Tt(this,"decoder"),Tt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=Ql(r);return e!=null?e.parse(n):n}encodeString(t){const e=tu(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):ca(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},au=class{constructor(){Tt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!ca(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const i=e.map(a=>JSON.stringify(n[a]??""));r.push(i.join(","))}),r.join(`
|
|
16
|
-
`)}decodeString(t,e){const[r,...n]=t.trim().split(`
|
|
17
|
-
`).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),n.forEach(o=>{const l=o.split(",").map(u=>u.trim());i.forEach((u,d)=>{const f=this.parseValue(l[d]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},ou=class{constructor(){Tt(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};new iu;new au;new ou;const Yr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const la=s.z.object({width:s.z.number(),height:s.z.number()}),cu=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),lu=["width","height"];s.z.enum(lu);const uu=["start","center","end"],hu=["signedWidth","signedHeight"];s.z.enum(hu);const xr=s.z.object({x:s.z.number(),y:s.z.number()}),du=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),fu=["x","y"],ua=s.z.enum(fu),ha=["top","right","bottom","left"];s.z.enum(ha);const yu=["left","right"],da=s.z.enum(yu),gu=["top","bottom"],fa=s.z.enum(gu),ya=["center"],qs=s.z.enum(ya),pu=[...ha,...ya],ga=s.z.enum(pu);s.z.enum(uu);const mu=["first","last"];s.z.enum(mu);const wu=s.z.object({lower:s.z.number(),upper:s.z.number()}),bu=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([wu,Yr]);s.z.union([bu,Yr]);s.z.union([ua,ga]);s.z.union([ua,ga,s.z.instanceof(String)]);const an=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return _s(t);return _s(r)},_s=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;s.z.object({x:da.or(qs),y:fa.or(qs)});const vu=s.z.object({x:da,y:fa}),Ou=Object.freeze({x:"left",y:"top"}),Tu=(t,e)=>t.x===e.x&&t.y===e.y,Fs=s.z.union([s.z.number(),xr,Yr,la,cu,du]),Su=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},Ws=Object.freeze({x:0,y:0}),Gt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Gt,left:Gt,width:Gt,height:Gt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:xr,two:xr,root:vu});const rs=(t,e,r=0,n=0,i)=>{const a={one:{...Ws},two:{...Ws},root:i??Ou};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+r,y:a.one.y+n},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},on=t=>{const e=rs(t);return{lower:e.one.x,upper:e.two.x}},cn=t=>{const e=rs(t);return{lower:e.one.y,upper:e.two.y}},zu=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var Nu=Object.defineProperty,Eu=(t,e,r)=>e in t?Nu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ce=(t,e,r)=>Eu(t,typeof e!="symbol"?e+"":e,r);const Iu=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:Fs,scale:Fs});const ku=t=>(e,r,n,i)=>r==="dimension"?[e,n]:[e,i?n-t:n+t],Au=t=>(e,r,n,i)=>[e,i?n/t:n*t],xu=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:i,upper:a}=e,{lower:o,upper:l}=t,u=a-i,d=l-o;if(r==="dimension")return[t,n*(d/u)];const f=(n-i)*(d/u)+o;return[t,f]},Cu=t=>(e,r,n)=>[t,n],$u=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:i}=t;return[t,i-(r-n)]},ju=t=>(e,r,n)=>{const{lower:i,upper:a}=t;return n=Iu(n,i,a),[e,n]},Rn=class ut{constructor(){Ce(this,"ops",[]),Ce(this,"currBounds",null),Ce(this,"currType",null),Ce(this,"reversed",!1),this.ops=[]}static translate(e){return new ut().translate(e)}static magnify(e){return new ut().magnify(e)}static scale(e,r){return new ut().scale(e,r)}translate(e){const r=this.new(),n=ku(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Au(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=an(e,r),i=this.new(),a=xu(n);return a.type="scale",i.ops.push(a),i}clamp(e,r){const n=an(e,r),i=this.new(),a=ju(n);return a.type="clamp",i.ops.push(a),i}reBound(e,r){const n=an(e,r),i=this.new(),a=Cu(n);return a.type="re-bound",i.ops.push(a),i}invert(){const e=$u();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new ut;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,i],a)=>a(n,e,i,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,i)=>{if(n.type==="scale"||r.some(([o,l])=>i>=o&&i<=l))return;const a=e.ops.findIndex((o,l)=>o.type==="scale"&&l>i);a!==-1&&r.push([i,a])}),r.forEach(([n,i])=>{const a=e.ops.slice(n,i);a.unshift(e.ops[i]),e.ops.splice(n,i-n+1,...a)}),e.reversed=!e.reversed,e}};Ce(Rn,"IDENTITY",new Rn);let Vs=Rn;const Gs=class Ae{constructor(e=new Vs,r=new Vs,n=null){Ce(this,"x"),Ce(this,"y"),Ce(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ae().translate(e,r)}static translateX(e){return new Ae().translateX(e)}static translateY(e){return new Ae().translateY(e)}static clamp(e){return new Ae().clamp(e)}static magnify(e){return new Ae().magnify(e)}static scale(e){return new Ae().scale(e)}static reBound(e){return new Ae().reBound(e)}translate(e,r){const n=Su(e,r),i=this.copy();return i.x=this.x.translate(n.x),i.y=this.y.translate(n.y),i}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(zu(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Tu(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(on(e)),r.y=r.y.scale(cn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(on(e)),r.y=this.y.reBound(cn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(on(e)),r.y=this.y.clamp(cn(e)),r}copy(){const e=new Ae;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return rs(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ce(Gs,"IDENTITY",new Gs);const Ru=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([la,Ru,xr,Yr]);var Mu=Object.defineProperty,Du=(t,e,r)=>e in t?Mu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,b=(t,e,r)=>Du(t,typeof e!="symbol"?e+"":e,r);const pa=(t,e)=>{const r=new te(e);if(![re.DAY,re.HOUR,re.MINUTE,re.SECOND,re.MILLISECOND,re.MICROSECOND,re.NANOSECOND].some(i=>i.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof te?new te(n):new re(n)},L=class S{constructor(e,r="UTC"){if(b(this,"value"),b(this,"encodeValue",!0),e==null)this.value=S.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*S.MILLISECOND.valueOf();else if(typeof e=="string")this.value=S.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=S.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=S.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=S.MAX:e=S.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const i=new Date(e,r-1,n,0,0,0,0);return new S(BigInt(i.getTime())*S.MILLISECOND.valueOf()).truncate(S.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=S.hours(parseInt(n??"00",10)).add(S.minutes(parseInt(i??"00",10))).add(S.seconds(parseInt(o??"00",10))).add(S.milliseconds(parseInt(l??"00",10)));return r==="local"&&(u=u.add(S.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return S.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new S(BigInt(n.getTime())*S.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(S.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new re(BigInt(new Date().getTimezoneOffset())*S.MINUTE.valueOf())}static since(e){return new S().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new S(e).valueOf()}span(e){return this.range(e).span}range(e){return new Pu(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new S(e).valueOf()}afterEq(e){return this.valueOf()>=new S(e).valueOf()}before(e){return this.valueOf()<new S(e).valueOf()}beforeEq(e){return this.valueOf()<=new S(e).valueOf()}add(e){return new S(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new S(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(S.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return pa(this,e)}get isToday(){return this.truncate(re.DAY).equals(S.now().truncate(re.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new S(new Date)}static max(...e){let r=S.MIN;for(const n of e){const i=new S(n);i.after(r)&&(r=i)}return r}static min(...e){let r=S.MAX;for(const n of e){const i=new S(n);i.before(r)&&(r=i)}return r}static nanoseconds(e){return new S(e)}static microseconds(e){return S.nanoseconds(e*1e3)}static milliseconds(e){return S.microseconds(e*1e3)}static seconds(e){return S.milliseconds(e*1e3)}static minutes(e){return S.seconds(e*60)}static hours(e){return S.minutes(e*60)}static days(e){return S.hours(e*24)}};b(L,"NANOSECOND",L.nanoseconds(1)),b(L,"MICROSECOND",L.microseconds(1)),b(L,"MILLISECOND",L.milliseconds(1)),b(L,"SECOND",L.seconds(1)),b(L,"MINUTE",L.minutes(1)),b(L,"HOUR",L.hours(1)),b(L,"DAY",L.days(1)),b(L,"MAX",new L((1n<<63n)-1n)),b(L,"MIN",new L(0)),b(L,"ZERO",new L(0)),b(L,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new L(t.value)),s.z.string().transform(t=>new L(BigInt(t))),s.z.instanceof(Number).transform(t=>new L(t)),s.z.number().transform(t=>new L(t)),s.z.instanceof(L)]));let te=L;const Y=class x{constructor(e){b(this,"value"),b(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new x(e).valueOf()}greaterThan(e){return this.valueOf()>new x(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new x(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new x(e).valueOf()}remainder(e){return pa(this,e)}truncate(e){return new x(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(x.DAY),r=this.truncate(x.HOUR),n=this.truncate(x.MINUTE),i=this.truncate(x.SECOND),a=this.truncate(x.MILLISECOND),o=this.truncate(x.MICROSECOND),l=this.truncate(x.NANOSECOND),u=e,d=r.sub(e),f=n.sub(r),h=i.sub(n),j=a.sub(i),W=o.sub(a),se=l.sub(o);let R="";return u.isZero||(R+=`${u.days}d `),d.isZero||(R+=`${d.hours}h `),f.isZero||(R+=`${f.minutes}m `),h.isZero||(R+=`${h.seconds}s `),j.isZero||(R+=`${j.milliseconds}ms `),W.isZero||(R+=`${W.microseconds}µs `),se.isZero||(R+=`${se.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(x.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(x.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(x.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(x.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(x.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(x.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new x(e).valueOf()}add(e){return new x(this.valueOf()+new x(e).valueOf())}sub(e){return new x(this.valueOf()-new x(e).valueOf())}static nanoseconds(e=1){return new x(e)}static microseconds(e=1){return x.nanoseconds(e*1e3)}static milliseconds(e=1){return x.microseconds(e*1e3)}static seconds(e=1){return x.milliseconds(e*1e3)}static minutes(e){return x.seconds(e.valueOf()*60)}static hours(e){return x.minutes(e*60)}static days(e){return x.hours(e*24)}};b(Y,"NANOSECOND",Y.nanoseconds(1)),b(Y,"MICROSECOND",Y.microseconds(1)),b(Y,"MILLISECOND",Y.milliseconds(1)),b(Y,"SECOND",Y.seconds(1)),b(Y,"MINUTE",Y.minutes(1)),b(Y,"HOUR",Y.hours(1)),b(Y,"DAY",Y.days(1)),b(Y,"MAX",new Y((1n<<63n)-1n)),b(Y,"MIN",new Y(0)),b(Y,"ZERO",new Y(0)),b(Y,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new Y(t.value)),s.z.string().transform(t=>new Y(BigInt(t))),s.z.instanceof(Number).transform(t=>new Y(t)),s.z.number().transform(t=>new Y(t)),s.z.instanceof(Y)]));let re=Y;const Zt=class sr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new sr(e).valueOf()}get period(){return re.seconds(1/this.valueOf())}sampleCount(e){return new re(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new le(r).valueOf()}span(e){return re.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new sr(e)}static khz(e){return sr.hz(e*1e3)}};b(Zt,"z",s.z.union([s.z.number().transform(t=>new Zt(t)),s.z.instanceof(Number).transform(t=>new Zt(t)),s.z.instanceof(Zt)]));const Q=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Bu(e*this.valueOf())}};b(Q,"UNKNOWN",new Q(0)),b(Q,"BIT128",new Q(16)),b(Q,"BIT64",new Q(8)),b(Q,"BIT32",new Q(4)),b(Q,"BIT16",new Q(2)),b(Q,"BIT8",new Q(1)),b(Q,"z",s.z.union([s.z.number().transform(t=>new Q(t)),s.z.instanceof(Number).transform(t=>new Q(t)),s.z.instanceof(Q)]));let le=Q;const Se=class ir{constructor(e,r){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new te(e.start),this.end=new te(e.end)):(this.start=new te(e),this.end=new te(r))}get span(){return new re(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new ir(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=re.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const i=te.max(n.start,e.start),a=te.min(n.end,e.end);return a.before(i)?!1:new re(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof ir?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new ir(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};b(Se,"MAX",new Se(te.MIN,te.MAX)),b(Se,"MIN",new Se(te.MAX,te.MIN)),b(Se,"ZERO",new Se(te.ZERO,te.ZERO)),b(Se,"z",s.z.union([s.z.object({start:te.z,end:te.z}).transform(t=>new Se(t.start,t.end)),s.z.instanceof(Se)]));let Pu=Se;const p=class ze extends String{constructor(e){if(e instanceof ze||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=ze.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(ze.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ze.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(ze.JSON)||this.equals(ze.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ze.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ze.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return ze.BIG_INT_TYPES.some(e=>e.equals(this))}};b(p,"UNKNOWN",new p("unknown")),b(p,"FLOAT64",new p("float64")),b(p,"FLOAT32",new p("float32")),b(p,"INT64",new p("int64")),b(p,"INT32",new p("int32")),b(p,"INT16",new p("int16")),b(p,"INT8",new p("int8")),b(p,"UINT64",new p("uint64")),b(p,"UINT32",new p("uint32")),b(p,"UINT16",new p("uint16")),b(p,"UINT8",new p("uint8")),b(p,"BOOLEAN",p.UINT8),b(p,"TIMESTAMP",new p("timestamp")),b(p,"UUID",new p("uuid")),b(p,"STRING",new p("string")),b(p,"JSON",new p("json")),b(p,"ARRAY_CONSTRUCTORS",new Map([[p.UINT8.toString(),Uint8Array],[p.UINT16.toString(),Uint16Array],[p.UINT32.toString(),Uint32Array],[p.UINT64.toString(),BigUint64Array],[p.FLOAT32.toString(),Float32Array],[p.FLOAT64.toString(),Float64Array],[p.INT8.toString(),Int8Array],[p.INT16.toString(),Int16Array],[p.INT32.toString(),Int32Array],[p.INT64.toString(),BigInt64Array],[p.TIMESTAMP.toString(),BigInt64Array],[p.STRING.toString(),Uint8Array],[p.JSON.toString(),Uint8Array],[p.UUID.toString(),Uint8Array]])),b(p,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,p.UINT8],[Uint16Array.name,p.UINT16],[Uint32Array.name,p.UINT32],[BigUint64Array.name,p.UINT64],[Float32Array.name,p.FLOAT32],[Float64Array.name,p.FLOAT64],[Int8Array.name,p.INT8],[Int16Array.name,p.INT16],[Int32Array.name,p.INT32],[BigInt64Array.name,p.INT64]])),b(p,"DENSITIES",new Map([[p.UINT8.toString(),le.BIT8],[p.UINT16.toString(),le.BIT16],[p.UINT32.toString(),le.BIT32],[p.UINT64.toString(),le.BIT64],[p.FLOAT32.toString(),le.BIT32],[p.FLOAT64.toString(),le.BIT64],[p.INT8.toString(),le.BIT8],[p.INT16.toString(),le.BIT16],[p.INT32.toString(),le.BIT32],[p.INT64.toString(),le.BIT64],[p.TIMESTAMP.toString(),le.BIT64],[p.STRING.toString(),le.UNKNOWN],[p.JSON.toString(),le.UNKNOWN],[p.UUID.toString(),le.BIT128]])),b(p,"ALL",[p.UNKNOWN,p.FLOAT64,p.FLOAT32,p.INT64,p.INT32,p.INT16,p.INT8,p.UINT64,p.UINT32,p.UINT16,p.UINT8,p.TIMESTAMP,p.UUID,p.STRING,p.JSON]),b(p,"BIG_INT_TYPES",[p.INT64,p.UINT64,p.TIMESTAMP]),b(p,"z",s.z.union([s.z.string().transform(t=>new p(t)),s.z.instanceof(p)]));const ae=class K extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return K.bytes(this.valueOf()+e.valueOf())}sub(e){return K.bytes(this.valueOf()-e.valueOf())}truncate(e){return new K(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return K.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/K.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/K.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/K.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/K.TERABYTE.valueOf()}toString(){const e=this.truncate(K.TERABYTE),r=this.truncate(K.GIGABYTE),n=this.truncate(K.MEGABYTE),i=this.truncate(K.KILOBYTE),a=this.truncate(K.BYTE),o=e,l=r.sub(e),u=n.sub(r),d=i.sub(n),f=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),d.isZero||(h+=`${d.kilobytes}KB `),(!f.isZero||h==="")&&(h+=`${f.valueOf()}B`),h.trim()}static bytes(e=1){return new K(e)}static kilobytes(e=1){return K.bytes(e.valueOf()*1e3)}static megabytes(e=1){return K.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return K.megabytes(e.valueOf()*1e3)}static terabytes(e){return K.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(ae,"BYTE",new ae(1)),b(ae,"KILOBYTE",ae.kilobytes(1)),b(ae,"MEGABYTE",ae.megabytes(1)),b(ae,"GIGABYTE",ae.gigabytes(1)),b(ae,"TERABYTE",ae.terabytes(1)),b(ae,"ZERO",new ae(0)),b(ae,"z",s.z.union([s.z.number().transform(t=>new ae(t)),s.z.instanceof(ae)]));let Bu=ae;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const ma=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Uu=ma(),wa=["MacOS","Windows","Linux","Docker"],Lu=s.z.enum(wa);let ln;const Yu=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},qu=(t={})=>{const{force:e,default:r}=t;return e??ln??(ln=Yu(),ln??r)},ba=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:wa,RUNTIME:Uu,detect:ma,getOS:qu,osZ:Lu},Symbol.toStringTag,{value:"Module"}));var _u=Object.defineProperty,Fu=(t,e,r)=>e in t?_u(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ht=(t,e,r)=>Fu(t,typeof e!="symbol"?e+"":e,r);const Wu=(...t)=>t.map(va).join(""),va=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Vu=t=>t.endsWith("/")?t.slice(0,-1):t,Gu=(t,e="")=>t===null?"":"?"+Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&"),Mn=class Dn{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){ht(this,"protocol"),ht(this,"host"),ht(this,"port"),ht(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=va(i)}replace(e){return new Dn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Dn({...this,pathPrefix:Wu(this.path,e)})}toString(){return Vu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};ht(Mn,"UNKNOWN",new Mn({host:"unknown",port:0}));let Zu=Mn;var Ku=Object.defineProperty,Ju=(t,e,r)=>e in t?Ku(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ar=(t,e,r)=>Ju(t,typeof e!="symbol"?e+"":e,r);const Ze=class extends Number{};ar(Ze,"Absolute",255),ar(Ze,"Default",1),ar(Ze,"z",s.z.union([s.z.instanceof(Ze),s.z.number().int().min(0).max(255).transform(t=>new Ze(t)),s.z.instanceof(Number).transform(t=>new Ze(t))]));s.z.object({name:s.z.string(),key:s.z.string()});const Oa=class dt extends Error{constructor(){super(dt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(dt.MESSAGE):e instanceof dt||e.message.includes(dt.MESSAGE)}};ar(Oa,"MESSAGE","canceled");let Hu=Oa;new Hu;s.z.string().regex(/^\d+\.\d+\.\d+$/);const de=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(t):e instanceof Error?e.message.includes(t):typeof e!="string"?!1:e.includes(t);let ve=class extends Error{constructor(e){super(e),D(this,"discriminator","FreighterError"),D(this,"type","")}};const Xu=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Zs="unknown",Ks="nil",Qu="freighter",Pt=s.z.object({type:s.z.string(),data:s.z.string()});class eh{constructor(){D(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ks,data:""};if(Xu(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}return{type:Zs,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Ks)return null;if(e.type===Zs)return new Js(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Js(e.data)}}const Ta=new eh,Sa=({encode:t,decode:e})=>Ta.register({encode:t,decode:e}),ns=t=>Ta.decode(t);class Js extends ve{constructor(e){super(e),D(this,"type","unknown")}}const qr="freighter.",or=class za extends ve{constructor(){super("EOF"),D(this,"type",za.TYPE)}};D(or,"TYPE",qr+"eof"),D(or,"matches",de(or.TYPE));let De=or;const cr=class Na extends ve{constructor(){super("StreamClosed"),D(this,"type",Na.TYPE)}};D(cr,"TYPE",qr+"stream_closed"),D(cr,"matches",de(cr.TYPE));let He=cr;const lr=class Ea extends ve{constructor(e={}){const{message:r="Unreachable",url:n=Zu.UNKNOWN}=e;super(r),D(this,"type",Ea.TYPE),D(this,"url"),this.url=n}};D(lr,"TYPE",qr+"unreachable"),D(lr,"matches",de(lr.TYPE));let We=lr;const th=t=>{if(!t.type.startsWith(Qu))return null;if(De.matches(t))return{type:De.TYPE,data:"EOF"};if(He.matches(t))return{type:He.TYPE,data:"StreamClosed"};if(We.matches(t))return{type:We.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},rh=t=>{if(!t.type.startsWith(qr))return null;switch(t.type){case De.TYPE:return new De;case He.TYPE:return new He;case We.TYPE:return new We;default:throw new Error(`Unknown error type: ${t.data}`)}};Sa({encode:th,decode:rh});class Ia{constructor(){D(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const i=async a=>{if(n===this.middleware.length)return await r(a);const o=this.middleware[n];return n++,await o(a,i)};return await i(e)}}const ka="Content-Type",Hs=t=>{if(ba.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const r=require("https"),n=new r.Agent({rejectUnauthorized:!1});return async(i,a)=>await e(i,{...a,agent:n})};class nh extends Ia{constructor(e,r,n=!1){return super(),D(this,"endpoint"),D(this,"encoder"),D(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=r,this.fetch=Hs(this.endpoint.protocol),new Proxy(this,{get:(i,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(i,a,o)})}get headers(){return{[ka]:this.encoder.contentType}}async send(e,r,n,i){r=n==null?void 0:n.parse(r);let a=null;const o=this.endpoint.child(e),l={};l.method="POST",l.body=this.encoder.encode(r??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async d=>{const f={...d,params:{}};l.headers={...this.headers,...d.params};let h;try{h=await Hs(d.protocol)(d.target,l)}catch(W){let se=W;return se.message==="Load failed"&&(se=new We({url:o})),[f,se]}const j=await h.arrayBuffer();if(h!=null&&h.ok)return i!=null&&(a=this.encoder.decode(j,i)),[f,null];try{if(h.status!==400)return[f,new Error(h.statusText)];const W=this.encoder.decode(j,Pt),se=ns(W);return[f,se]}catch(W){return[f,new Error(`[freighter] - failed to decode error: ${h.statusText}: ${W.message}`)]}});return[a,u]}}const v=async(t,e,r,n,i)=>{const[a,o]=await t.send(e,r,n,i);if(o!=null)throw o;return a},sh=()=>ba.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),ih=s.z.object({type:s.z.union([s.z.literal("data"),s.z.literal("close")]),payload:s.z.unknown().optional(),error:s.z.optional(Pt)});class ah{constructor(e,r,n,i){D(this,"encoder"),D(this,"reqSchema"),D(this,"resSchema"),D(this,"ws"),D(this,"serverClosed"),D(this,"sendClosed"),D(this,"receiveDataQueue",[]),D(this,"receiveCallbacksQueue",[]),this.encoder=r,this.reqSchema=n,this.resSchema=i,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new De;if(this.sendClosed)throw new He;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=ns(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,r)=>this.receiveCallbacksQueue.push({resolve:e,reject:r}))}addMessage(e){const r=this.receiveCallbacksQueue.shift();r!=null?r.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,ih)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:hh(e)?De.TYPE:He.TYPE,data:""}})}}const oh="freighterctx",ch=1e3,lh=1001,uh=[ch,lh],hh=t=>uh.includes(t.code),Aa=class xa extends Ia{constructor(e,r,n=!1){super(),D(this,"baseUrl"),D(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}async stream(e,r,n){const i=sh();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async l=>{const u=i(this.buildURL(e,l)),d={...l,params:{}};u.binaryType=xa.MESSAGE_TYPE;const f=await this.wrapSocket(u,r,n);return f instanceof Error?[d,f]:(a=f,[d,null])});if(o!=null)throw o;return a}buildURL(e,r){const n=Gu({[ka]:this.encoder.contentType,...r.params},oh);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(i=>{e.onopen=()=>{i(new ah(e,this.encoder,r,n))},e.onerror=a=>{const o=a;i(new Error(o.message))}})}};D(Aa,"MESSAGE_TYPE","arraybuffer");let dh=Aa;const fh=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()?e:e[0].toLowerCase()+e.slice(1)},Ca=t=>{const e=(r,n=Pn)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!un(r))return r;n=ph(n);const i={},a=r;return Object.keys(a).forEach(o=>{let l=a[o];const u=t(o);n.recursive&&(un(l)?Qs(l,n.keepTypesOnRecursion)||(l=e(l,n)):n.recursiveInArray&&Xs(l)&&(l=[...l].map(d=>{let f=d;return un(d)?Qs(f,n.keepTypesOnRecursion)||(f=e(d,n)):Xs(d)&&(f=e({key:d},n).key),f}))),i[u]=l}),i};return e},$a=Ca(fh),yh=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),gh=Ca(yh),Pn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},ph=(t=Pn)=>(t.recursive==null?t=Pn:t.recursiveInArray==null&&(t.recursiveInArray=!1),t),Xs=t=>t!=null&&Array.isArray(t),un=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Qs=(t,e)=>(e||[]).some(r=>t instanceof r),ss=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var mh=Object.defineProperty,wh=(t,e,r)=>e in t?mh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,St=(t,e,r)=>wh(t,typeof e!="symbol"?e+"":e,r);let ja=class{constructor(){St(this,"contentType","application/json"),St(this,"decoder"),St(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=$a(r);return e!=null?e.parse(n):n}encodeString(t){const e=gh(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):ss(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}},Ra=class{constructor(){St(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const r=new TextDecoder().decode(t);return this.decodeString(r,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!ss(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),r=[e.join(",")];return t.forEach(n=>{const i=e.map(a=>JSON.stringify(n[a]??""));r.push(i.join(","))}),r.join(`
|
|
18
|
-
`)}decodeString(t,e){const[r,...n]=t.trim().split(`
|
|
19
|
-
`).map(o=>o.trim());if(r.length===0)return e!=null?e.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),n.forEach(o=>{const l=o.split(",").map(u=>u.trim());i.forEach((u,d)=>{const f=this.parseValue(l[d]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},Ma=class{constructor(){St(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const r=new TextDecoder().decode(t);return e!=null?e.parse(r):r}};const Je=new ja,bh=new Ra,vh=new Ma,Oh=[Je],Qe=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Ra,CSV_CODEC:bh,ENCODERS:Oh,JSONCodec:ja,JSON_CODEC:Je,TEXT_CODEC:vh,TextCodec:Ma},Symbol.toStringTag,{value:"Module"})),Th=t=>t!=null&&typeof t=="object"&&"toString"in t,Sh=(t,e=!1)=>{const r=Th(t)?"stringer":typeof t;let n;switch(r){case"string":n=(i,a)=>i.localeCompare(a);break;case"stringer":n=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":n=(i,a)=>Number(i)-Number(a);break;case"bigint":n=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":n=(i,a)=>Number(i)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?zh(n):n},zh=t=>(e,r)=>t(r,e),Nh=0,hn=-1,dn=1,Eh=t=>t<0,Ih=t=>t>0,kh=t=>t===0,_r=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const Da=s.z.object({width:s.z.number(),height:s.z.number()}),Ah=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),xh=["width","height"];s.z.enum(xh);const Ch=["start","center","end"],$h=["signedWidth","signedHeight"];s.z.enum($h);const Cr=s.z.object({x:s.z.number(),y:s.z.number()}),jh=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Rh=["x","y"],Pa=s.z.enum(Rh),Ba=["top","right","bottom","left"];s.z.enum(Ba);const Mh=["left","right"],Ua=s.z.enum(Mh),Dh=["top","bottom"],La=s.z.enum(Dh),Ya=["center"],ei=s.z.enum(Ya),Ph=[...Ba,...Ya],qa=s.z.enum(Ph);s.z.enum(Ch);const Bh=["first","last"];s.z.enum(Bh);const Uh=s.z.object({lower:s.z.number(),upper:s.z.number()}),Lh=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Uh,_r]);s.z.union([Lh,_r]);s.z.union([Pa,qa]);s.z.union([Pa,qa,s.z.instanceof(String)]);const zt=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return ti(t);return ti(r)},ti=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;s.z.object({x:Ua.or(ei),y:La.or(ei)});const Yh=s.z.object({x:Ua,y:La}),qh=Object.freeze({x:"left",y:"top"}),_h=(t,e)=>t.x===e.x&&t.y===e.y,ri=s.z.union([s.z.number(),Cr,_r,Da,Ah,jh]),Fh=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},ni=Object.freeze({x:0,y:0}),Kt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:Kt,left:Kt,width:Kt,height:Kt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Cr,two:Cr,root:Yh});const is=(t,e,r=0,n=0,i)=>{const a={one:{...ni},two:{...ni},root:i??qh};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+r,y:a.one.y+n},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},fn=t=>{const e=is(t);return{lower:e.one.x,upper:e.two.x}},yn=t=>{const e=is(t);return{lower:e.one.y,upper:e.two.y}},Wh=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Vh=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([Da,Vh,Cr,_r]);var Gh=Object.defineProperty,Zh=(t,e,r)=>e in t?Gh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$e=(t,e,r)=>Zh(t,typeof e!="symbol"?e+"":e,r);const Kh=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;s.z.object({offset:ri,scale:ri});const Jh=t=>(e,r,n,i)=>r==="dimension"?[e,n]:[e,i?n-t:n+t],Hh=t=>(e,r,n,i)=>[e,i?n/t:n*t],Xh=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:i,upper:a}=e,{lower:o,upper:l}=t,u=a-i,d=l-o;if(r==="dimension")return[t,n*(d/u)];const f=(n-i)*(d/u)+o;return[t,f]},Qh=t=>(e,r,n)=>[t,n],ed=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:i}=t;return[t,i-(r-n)]},td=t=>(e,r,n)=>{const{lower:i,upper:a}=t;return n=Kh(n,i,a),[e,n]},Bn=class ft{constructor(){$e(this,"ops",[]),$e(this,"currBounds",null),$e(this,"currType",null),$e(this,"reversed",!1),this.ops=[]}static translate(e){return new ft().translate(e)}static magnify(e){return new ft().magnify(e)}static scale(e,r){return new ft().scale(e,r)}translate(e){const r=this.new(),n=Jh(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Hh(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=zt(e,r),i=this.new(),a=Xh(n);return a.type="scale",i.ops.push(a),i}clamp(e,r){const n=zt(e,r),i=this.new(),a=td(n);return a.type="clamp",i.ops.push(a),i}reBound(e,r){const n=zt(e,r),i=this.new(),a=Qh(n);return a.type="re-bound",i.ops.push(a),i}invert(){const e=ed();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new ft;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,i],a)=>a(n,e,i,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,i)=>{if(n.type==="scale"||r.some(([o,l])=>i>=o&&i<=l))return;const a=e.ops.findIndex((o,l)=>o.type==="scale"&&l>i);a!==-1&&r.push([i,a])}),r.forEach(([n,i])=>{const a=e.ops.slice(n,i);a.unshift(e.ops[i]),e.ops.splice(n,i-n+1,...a)}),e.reversed=!e.reversed,e}};$e(Bn,"IDENTITY",new Bn);let si=Bn;const ii=class xe{constructor(e=new si,r=new si,n=null){$e(this,"x"),$e(this,"y"),$e(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new xe().translate(e,r)}static translateX(e){return new xe().translateX(e)}static translateY(e){return new xe().translateY(e)}static clamp(e){return new xe().clamp(e)}static magnify(e){return new xe().magnify(e)}static scale(e){return new xe().scale(e)}static reBound(e){return new xe().reBound(e)}translate(e,r){const n=Fh(e,r),i=this.copy();return i.x=this.x.translate(n.x),i.y=this.y.translate(n.y),i}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Wh(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!_h(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(fn(e)),r.y=r.y.scale(yn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(fn(e)),r.y=this.y.reBound(yn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(fn(e)),r.y=this.y.clamp(yn(e)),r}copy(){const e=new xe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return is(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};$e(ii,"IDENTITY",new ii);var rd=Object.defineProperty,nd=(t,e,r)=>e in t?rd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,w=(t,e,r)=>nd(t,typeof e!="symbol"?e+"":e,r);let sd=(t,e=21)=>(r=e)=>{let n="",i=r;for(;i--;)n+=t[Math.random()*t.length|0];return n};const id="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",_a=sd(id,11),ad=Object.freeze(Object.defineProperty({__proto__:null,id:_a},Symbol.toStringTag,{value:"Module"})),Fa=(t,e)=>{const r=new E(e);if(![k.DAY,k.HOUR,k.MINUTE,k.SECOND,k.MILLISECOND,k.MICROSECOND,k.NANOSECOND].some(i=>i.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof E?new E(n):new k(n)},q=class z{constructor(e,r="UTC"){if(w(this,"value"),w(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const i=new Date(e,r-1,n,0,0,0,0);return new z(BigInt(i.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,i,a]=e.split(":");let o="00",l="00";a!=null&&([o,l]=a.split("."));let u=z.hours(parseInt(n??"00",10)).add(z.minutes(parseInt(i??"00",10))).add(z.seconds(parseInt(o??"00",10))).add(z.milliseconds(parseInt(l??"00",10)));return r==="local"&&(u=u.add(z.utcOffset)),u.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new z(BigInt(n.getTime())*z.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new k(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new ne(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Fa(this,e)}get isToday(){return this.truncate(k.DAY).equals(z.now().truncate(k.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let r=z.MIN;for(const n of e){const i=new z(n);i.after(r)&&(r=i)}return r}static min(...e){let r=z.MAX;for(const n of e){const i=new z(n);i.before(r)&&(r=i)}return r}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};w(q,"NANOSECOND",q.nanoseconds(1)),w(q,"MICROSECOND",q.microseconds(1)),w(q,"MILLISECOND",q.milliseconds(1)),w(q,"SECOND",q.seconds(1)),w(q,"MINUTE",q.minutes(1)),w(q,"HOUR",q.hours(1)),w(q,"DAY",q.days(1)),w(q,"MAX",new q((1n<<63n)-1n)),w(q,"MIN",new q(0)),w(q,"ZERO",new q(0)),w(q,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new q(t.value)),s.z.string().transform(t=>new q(BigInt(t))),s.z.instanceof(Number).transform(t=>new q(t)),s.z.number().transform(t=>new q(t)),s.z.instanceof(q)]));let E=q;const _=class C{constructor(e){w(this,"value"),w(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new C(e).valueOf()}greaterThan(e){return this.valueOf()>new C(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new C(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new C(e).valueOf()}remainder(e){return Fa(this,e)}truncate(e){return new C(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(C.DAY),r=this.truncate(C.HOUR),n=this.truncate(C.MINUTE),i=this.truncate(C.SECOND),a=this.truncate(C.MILLISECOND),o=this.truncate(C.MICROSECOND),l=this.truncate(C.NANOSECOND),u=e,d=r.sub(e),f=n.sub(r),h=i.sub(n),j=a.sub(i),W=o.sub(a),se=l.sub(o);let R="";return u.isZero||(R+=`${u.days}d `),d.isZero||(R+=`${d.hours}h `),f.isZero||(R+=`${f.minutes}m `),h.isZero||(R+=`${h.seconds}s `),j.isZero||(R+=`${j.milliseconds}ms `),W.isZero||(R+=`${W.microseconds}µs `),se.isZero||(R+=`${se.nanoseconds}ns`),R.trim()}get days(){return Number(this.valueOf())/Number(C.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(C.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(C.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(C.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(C.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(C.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new C(e).valueOf()}add(e){return new C(this.valueOf()+new C(e).valueOf())}sub(e){return new C(this.valueOf()-new C(e).valueOf())}static nanoseconds(e=1){return new C(e)}static microseconds(e=1){return C.nanoseconds(e*1e3)}static milliseconds(e=1){return C.microseconds(e*1e3)}static seconds(e=1){return C.milliseconds(e*1e3)}static minutes(e){return C.seconds(e.valueOf()*60)}static hours(e){return C.minutes(e*60)}static days(e){return C.hours(e*24)}};w(_,"NANOSECOND",_.nanoseconds(1)),w(_,"MICROSECOND",_.microseconds(1)),w(_,"MILLISECOND",_.milliseconds(1)),w(_,"SECOND",_.seconds(1)),w(_,"MINUTE",_.minutes(1)),w(_,"HOUR",_.hours(1)),w(_,"DAY",_.days(1)),w(_,"MAX",new _((1n<<63n)-1n)),w(_,"MIN",new _(0)),w(_,"ZERO",new _(0)),w(_,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new _(t.value)),s.z.string().transform(t=>new _(BigInt(t))),s.z.instanceof(Number).transform(t=>new _(t)),s.z.number().transform(t=>new _(t)),s.z.instanceof(_)]));let k=_;const yt=class ur extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ur(e).valueOf()}get period(){return k.seconds(1/this.valueOf())}sampleCount(e){return new k(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new ue(r).valueOf()}span(e){return k.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new ur(e)}static khz(e){return ur.hz(e*1e3)}};w(yt,"z",s.z.union([s.z.number().transform(t=>new yt(t)),s.z.instanceof(Number).transform(t=>new yt(t)),s.z.instanceof(yt)]));let as=yt;const ee=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new kt(e*this.valueOf())}};w(ee,"UNKNOWN",new ee(0)),w(ee,"BIT128",new ee(16)),w(ee,"BIT64",new ee(8)),w(ee,"BIT32",new ee(4)),w(ee,"BIT16",new ee(2)),w(ee,"BIT8",new ee(1)),w(ee,"z",s.z.union([s.z.number().transform(t=>new ee(t)),s.z.instanceof(Number).transform(t=>new ee(t)),s.z.instanceof(ee)]));let ue=ee;const Ne=class hr{constructor(e,r){w(this,"start"),w(this,"end"),typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(r))}get span(){return new k(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new hr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=k.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const i=E.max(n.start,e.start),a=E.min(n.end,e.end);return a.before(i)?!1:new k(a.sub(i)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=r.valueOf()&&i<=r.valueOf()}contains(e){return e instanceof hr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new hr(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};w(Ne,"MAX",new Ne(E.MIN,E.MAX)),w(Ne,"MIN",new Ne(E.MAX,E.MIN)),w(Ne,"ZERO",new Ne(E.ZERO,E.ZERO)),w(Ne,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(t=>new Ne(t.start,t.end)),s.z.instanceof(Ne)]));let ne=Ne;const g=class Ee extends String{constructor(e){if(e instanceof Ee||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=Ee.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(Ee.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Ee.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(){return this.valueOf()}get isVariable(){return this.equals(Ee.JSON)||this.equals(Ee.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Ee.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Ee.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Ee.BIG_INT_TYPES.some(e=>e.equals(this))}};w(g,"UNKNOWN",new g("unknown")),w(g,"FLOAT64",new g("float64")),w(g,"FLOAT32",new g("float32")),w(g,"INT64",new g("int64")),w(g,"INT32",new g("int32")),w(g,"INT16",new g("int16")),w(g,"INT8",new g("int8")),w(g,"UINT64",new g("uint64")),w(g,"UINT32",new g("uint32")),w(g,"UINT16",new g("uint16")),w(g,"UINT8",new g("uint8")),w(g,"BOOLEAN",g.UINT8),w(g,"TIMESTAMP",new g("timestamp")),w(g,"UUID",new g("uuid")),w(g,"STRING",new g("string")),w(g,"JSON",new g("json")),w(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),w(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),w(g,"DENSITIES",new Map([[g.UINT8.toString(),ue.BIT8],[g.UINT16.toString(),ue.BIT16],[g.UINT32.toString(),ue.BIT32],[g.UINT64.toString(),ue.BIT64],[g.FLOAT32.toString(),ue.BIT32],[g.FLOAT64.toString(),ue.BIT64],[g.INT8.toString(),ue.BIT8],[g.INT16.toString(),ue.BIT16],[g.INT32.toString(),ue.BIT32],[g.INT64.toString(),ue.BIT64],[g.TIMESTAMP.toString(),ue.BIT64],[g.STRING.toString(),ue.UNKNOWN],[g.JSON.toString(),ue.UNKNOWN],[g.UUID.toString(),ue.BIT128]])),w(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),w(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),w(g,"z",s.z.union([s.z.string().transform(t=>new g(t)),s.z.instanceof(g)]));let I=g;const oe=class J extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return J.bytes(this.valueOf()+e.valueOf())}sub(e){return J.bytes(this.valueOf()-e.valueOf())}truncate(e){return new J(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return J.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/J.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/J.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/J.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/J.TERABYTE.valueOf()}toString(){const e=this.truncate(J.TERABYTE),r=this.truncate(J.GIGABYTE),n=this.truncate(J.MEGABYTE),i=this.truncate(J.KILOBYTE),a=this.truncate(J.BYTE),o=e,l=r.sub(e),u=n.sub(r),d=i.sub(n),f=a.sub(i);let h="";return o.isZero||(h+=`${o.terabytes}TB `),l.isZero||(h+=`${l.gigabytes}GB `),u.isZero||(h+=`${u.megabytes}MB `),d.isZero||(h+=`${d.kilobytes}KB `),(!f.isZero||h==="")&&(h+=`${f.valueOf()}B`),h.trim()}static bytes(e=1){return new J(e)}static kilobytes(e=1){return J.bytes(e.valueOf()*1e3)}static megabytes(e=1){return J.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return J.megabytes(e.valueOf()*1e3)}static terabytes(e){return J.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};w(oe,"BYTE",new oe(1)),w(oe,"KILOBYTE",oe.kilobytes(1)),w(oe,"MEGABYTE",oe.megabytes(1)),w(oe,"GIGABYTE",oe.gigabytes(1)),w(oe,"TERABYTE",oe.terabytes(1)),w(oe,"ZERO",new oe(0)),w(oe,"z",s.z.union([s.z.number().transform(t=>new oe(t)),s.z.instanceof(oe)]));let kt=oe;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const Wa=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof E||t instanceof k||t instanceof Date},od=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r)-BigInt(n):gt(r,-n),cd=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof he?!0:Wa(t),Ye=-1;class he{constructor(e){w(this,"key",""),w(this,"isSynnaxSeries",!0),w(this,"dataType"),w(this,"sampleOffset"),w(this,"gl"),w(this,"_data"),w(this,"_timeRange"),w(this,"alignment",0n),w(this,"_cachedMin"),w(this,"_cachedMax"),w(this,"writePos",Ye),w(this,"_refCount",0),w(this,"_cachedLength"),cd(e)&&(e={data:e});const{dataType:r,timeRange:n,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:l=_a()}=e,{data:u}=e;if(u instanceof he||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const h=u;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const d=Wa(u),f=Array.isArray(u);if(r!=null)this.dataType=new I(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||d){let h=u;if(!d){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");h=u[0]}if(typeof h=="string")this.dataType=I.STRING;else if(typeof h=="number")this.dataType=I.FLOAT64;else if(typeof h=="bigint")this.dataType=I.INT64;else if(typeof h=="boolean")this.dataType=I.BOOLEAN;else if(h instanceof E||h instanceof Date||h instanceof E)this.dataType=I.TIMESTAMP;else if(typeof h=="object")this.dataType=I.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new I(u)}if(!f&&!d)this._data=u;else{let h=d?[u]:u;const j=h[0];(j instanceof E||j instanceof Date||j instanceof k)&&(h=h.map(W=>new E(W).valueOf())),this.dataType.equals(I.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
|
|
20
|
-
`)+`
|
|
21
|
-
`)):this.dataType.equals(I.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(W=>Je.encodeString(W)).join(`
|
|
22
|
-
`)+`
|
|
23
|
-
`)):this._data=new this.dataType.Array(h).buffer}this.key=l,this.alignment=o,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new I(r).Array(e),a=new he({data:i.buffer,dataType:r,...n});return a.writePos=0,a}static generateTimestamps(e,r,n){const i=n.spanRange(r.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(n.add(r.span(o)).valueOf());return new he({data:a,dataType:I.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,r){const n=new TextEncoder().encode(e.join(`
|
|
24
|
-
`)+`
|
|
25
|
-
`);return new he({data:n,dataType:I.STRING,timeRange:r})}static fromJSON(e,r){const n=new TextEncoder().encode(e.map(i=>Je.encodeString(i)).join(`
|
|
26
|
-
`)+`
|
|
27
|
-
`);return new he({data:n,dataType:I.JSON,timeRange:r})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Ye)return 0;const r=this.capacity-this.writePos,n=r<e.length?e.slice(0,r):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ye?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(I.STRING,I.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
28
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(I.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=I.UUID.density.valueOf(),r=Array(this.length);for(let n=0;n<this.length;n++){const i=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");r[n]=a}return r}parseJSON(e){if(!this.dataType.equals(I.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
29
|
-
`).slice(0,-1).map(r=>e.parse(Je.decodeString(r)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new kt(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ye?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ye?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(r=>{r===10&&e++}),this._cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let i=0;i<this.length;i++)n[i]=od(this.dataType,e,this.data[i],r);return new he({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(I.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this._cachedMax=e.reduce((r,n)=>r>n?r:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),gt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(I.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this._cachedMin=e.reduce((r,n)=>r<n?r:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),gt(this._cachedMin,this.sampleOffset))}get bounds(){return zt(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const r=e._cachedMin??e.calcRawMin();r<this._cachedMin&&(this._cachedMin=r)}if(this._cachedMax!=null){const r=e._cachedMax??e.calcRawMax();r>this._cachedMax&&(this._cachedMax=r)}}enrich(){this.max,this.min}get range(){return gt(this.max,-this.min)}at(e,r){if(this.dataType.isVariable)return this.atVariable(e,r??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return gt(n,this.sampleOffset)}atVariable(e,r){e<0&&(e=this.length+e);let n=0,i=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){i=o;break}n=o+1,e--}if(i===0&&(i=this.data.length),n>=i||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,i);return this.dataType.equals(I.STRING)?new TextDecoder().decode(a):$a(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let r=0,n=this.length-1;const i=Sh(e);for(;r<=n;){const a=Math.floor((r+n)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?r=a+1:n=a-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(I.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:i}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ye){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ye}as(e){if(e==="string"){if(!this.dataType.equals(I.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(I.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return zt(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new ld(this);return this.dataType.equals(I.JSON)?new ud(e):e}return new hd(this)}slice(e,r){if(e<=0&&(r==null||r>=this.length))return this;const n=this.data.slice(e,r);return new he({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new he({data:this.buffer,dataType:this.dataType,timeRange:ne.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class ld{constructor(e){if(w(this,"series"),w(this,"index"),w(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var ai,oi;class ud{constructor(e){w(this,"wrapped"),w(this,ai,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Je.decodeString(e.value)}}[(oi=Symbol.iterator,ai=Symbol.toStringTag,oi)](){return this}}var ci,li;class hd{constructor(e){w(this,"series"),w(this,"index"),w(this,ci,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(li=Symbol.iterator,ci=Symbol.toStringTag,li)](){return this}}const gt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);class dd{constructor(e){if(w(this,"series"),e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new I(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?I.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?ne.ZERO:new ne(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,r)=>e+r.length,0)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new kt(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new fd(this.series)}}var ui,hi;class fd{constructor(e){w(this,"series"),w(this,"seriesIndex"),w(this,"internal"),w(this,ui,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(hi=Symbol.iterator,ui=Symbol.toStringTag,hi)](){return this}}const N=t=>Array.isArray(t)?t:[t],yd=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}};s.z.object({key:s.z.string(),value:s.z.string()});var gd=Object.defineProperty,pd=(t,e,r)=>e in t?gd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dr=(t,e,r)=>pd(t,typeof e!="symbol"?e+"":e,r);let md=class{constructor(t,e){dr(this,"handlers"),dr(this,"transform"),dr(this,"closer"),this.transform=t,this.handlers=e??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let e=t;if(this.transform!=null){const[r,n]=this.transform(t);if(!n)return;e=r}this.handlers.forEach((r,n)=>n(e))}setCloser(t){this.closer=t}async close(){var t;return await((t=this.closer)==null?void 0:t.call(this))}},wd=class{constructor(t){dr(this,"handlers"),this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,r)=>r(t))}};const Ve=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:wd,Observer:md},Symbol.toStringTag,{value:"Module"})),os=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),bd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";bd();const vd=["MacOS","Windows","Linux","Docker"];s.z.enum(vd);const di=t=>[...new Set(t)];var Od=Object.defineProperty,Td=(t,e,r)=>e in t?Od(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pt=(t,e,r)=>Td(t,typeof e!="symbol"?e+"":e,r);const Sd=(...t)=>t.map(Va).join(""),Va=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),zd=t=>t.endsWith("/")?t.slice(0,-1):t,Un=class Ln{constructor({host:e,port:r,protocol:n="",pathPrefix:i=""}){pt(this,"protocol"),pt(this,"host"),pt(this,"port"),pt(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=Va(i)}replace(e){return new Ln({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Ln({...this,pathPrefix:Sd(this.path,e)})}toString(){return zd(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};pt(Un,"UNKNOWN",new Un({host:"unknown",port:0}));let Nd=Un;var Ed=Object.defineProperty,Id=(t,e,r)=>e in t?Ed(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fr=(t,e,r)=>Id(t,typeof e!="symbol"?e+"":e,r);const _e=class extends Number{};fr(_e,"Absolute",255),fr(_e,"Default",1),fr(_e,"z",s.z.union([s.z.instanceof(_e),s.z.number().int().min(0).max(255).transform(t=>new _e(t)),s.z.instanceof(Number).transform(t=>new _e(t))]));let Ga=_e;const Za=s.z.object({name:s.z.string(),key:s.z.string()}),kd=t=>s.z.object({subject:Za,resource:t,authority:Ga.z}),Ad=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),Xe=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ga,filterTransfersByChannelKey:Ad,stateZ:kd,subjectZ:Za},Symbol.toStringTag,{value:"Module"})),Ka=class mt extends Error{constructor(){super(mt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(mt.MESSAGE):e instanceof mt||e.message.includes(mt.MESSAGE)}};fr(Ka,"MESSAGE","canceled");let xd=Ka;new xd;const Yn=s.z.string().regex(/^\d+\.\d+\.\d+$/),Bt=(t,e,r={})=>{r.checkMajor??(r.checkMajor=!0),r.checkMinor??(r.checkMinor=!0),r.checkPatch??(r.checkPatch=!0);const n=Yn.parse(t),i=Yn.parse(e),[a,o,l]=n.split(".").map(Number),[u,d,f]=i.split(".").map(Number);if(r.checkMajor){if(a<u)return hn;if(a>u)return dn}if(r.checkMinor){if(o<d)return hn;if(o>d)return dn}if(r.checkPatch){if(l<f)return hn;if(l>f)return dn}return Nh},Cd=(t,e,r={})=>kh(Bt(t,e,r)),Ja=(t,e,r={})=>Ih(Bt(t,e,r)),$d=(t,e,r={})=>Eh(Bt(t,e,r)),jd=({name:t,migrate:e})=>r=>{try{const n=e(r);return console.log(`${t} migrated: ${r.version} -> ${n.version}`),n}catch(n){throw console.log(`${t} failed to migrate from ${r.version}`),console.error(n),n}},Rd=({name:t,migrations:e,targetSchema:r,def:n})=>{const i=Object.keys(e).sort(Bt).pop();if(i==null)return u=>{if(u.version!==n.version)return console.log(`${t} version ${u.version} is newer than latest version of ${n.version}.
|
|
30
|
-
Returning default instead.
|
|
31
|
-
`),n;try{return r!=null?r.parse(u):u}catch(d){return console.log(`${t} failed to parse default. Exiting with default`),console.error(d),n}};const a=Object.keys(e).length;let o=!1;const l=u=>{try{if(a===0||Ja(u.version,i))return console.log(o?`${t} ${u.version} now up to date`:`${t} version ${u.version} is up to date with target version ${n.version}`),u;const d=u.version,f=e[d],h=f(u);return o=!0,l(h)}catch(d){return console.log(`${t} failed to migrate from ${u.version} to ${i}`),console.error(d),n}};return u=>{try{return l(u)}catch(d){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(d),n}}},fi=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Bt,createMigration:jd,migrator:Rd,semVerNewer:Ja,semVerOlder:$d,semVerZ:Yn,versionsEqual:Cd},Symbol.toStringTag,{value:"Module"})),Pe="sy.",yr=class Ha extends ve{constructor(){super(...arguments),c(this,"type",Ha.TYPE)}};c(yr,"TYPE",Pe+"validation"),c(yr,"matches",de(yr.TYPE));let G=yr;const gr=class Xa extends G{constructor(e,r){super(e+": "+r),c(this,"type",Xa.TYPE),c(this,"field"),c(this,"message"),this.field=e,this.message=r}};c(gr,"TYPE",G.TYPE+".field"),c(gr,"matches",de(gr.TYPE));let yi=gr;const pr=class Qa extends ve{constructor(){super(...arguments),c(this,"type",Qa.TYPE)}};c(pr,"TYPE",Pe+"auth"),c(pr,"matches",de(pr.TYPE));let $r=pr;const mr=class eo extends $r{constructor(){super(...arguments),c(this,"type",eo.TYPE)}};c(mr,"TYPE",$r.TYPE+".invalid-token"),c(mr,"matches",de(mr.TYPE));let qn=mr;const wr=class to extends ve{constructor(e){super(`
|
|
32
|
-
Unexpected error encountered:
|
|
33
|
-
|
|
34
|
-
${e}
|
|
35
|
-
|
|
36
|
-
Please report this to the Synnax team.
|
|
37
|
-
`),c(this,"type",to.TYPE)}};c(wr,"TYPE",Pe+"unexpected"),c(wr,"matches",de(wr.TYPE));let me=wr;const br=class ro extends ve{constructor(){super(...arguments),c(this,"type",ro.TYPE)}};c(br,"TYPE",Pe+"query"),c(br,"matches",de(br.TYPE));let be=br;const vr=class no extends be{constructor(){super(...arguments),c(this,"type",no.TYPE)}};c(vr,"TYPE",be.TYPE+".not_found"),c(vr,"matches",de(vr.TYPE));let jr=vr;const Or=class so extends be{constructor(){super(...arguments),c(this,"type",so.TYPE)}};c(Or,"TYPE",be.TYPE+".multiple_results"),c(Or,"matches",de(Or.TYPE));let Rr=Or;const Tr=class io extends ve{constructor(e,r){super(e),c(this,"type",io.TYPE),c(this,"path"),this.path=r}};c(Tr,"TYPE",Pe+"route"),c(Tr,"matches",de(Tr.TYPE));let gi=Tr;const Sr=class ao extends ve{constructor(){super(...arguments),c(this,"type",ao.TYPE)}};c(Sr,"TYPE",Pe+"control"),c(Sr,"matches",de(Sr.TYPE));let Mr=Sr;const zr=class oo extends Mr{constructor(){super(...arguments),c(this,"type",oo.TYPE)}};c(zr,"TYPE",Mr.TYPE+".unauthorized"),c(zr,"matches",de(zr.TYPE));let pi=zr;const gn=class co extends ve{constructor(){super(...arguments),c(this,"type",co.TYPE)}};c(gn,"TYPE",Pe+"contiguity"),c(gn,"matches",de(gn.TYPE));const Md=t=>{if(!t.type.startsWith(Pe))return null;if(t.type.startsWith(G.TYPE)){if(t.type===yi.TYPE){const e=t.data.split(": ");return e.length<2?new G(t.data):new yi(e[0],e[1])}return new G(t.data)}return t.type.startsWith($r.TYPE)?t.type.startsWith(qn.TYPE)?new qn(t.data):new $r(t.data):t.type.startsWith(me.TYPE)?new me(t.data):t.type.startsWith(be.TYPE)?t.type.startsWith(jr.TYPE)?new jr(t.data):t.type.startsWith(Rr.TYPE)?new Rr(t.data):new be(t.data):t.type.startsWith(Mr.TYPE)?t.type.startsWith(pi.TYPE)?new pi(t.data):new Mr(t.data):t.type.startsWith(gi.TYPE)?new gi(t.data,t.data):new me(t.data)},Dd=()=>{throw new Error("Not implemented")};Sa({encode:Dd,decode:Md});const Pd=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof We?[r,new We({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]};class lo{constructor(e,r){c(this,"key"),c(this,"name"),this.key=r,this.name=e}get ontologyID(){return new $({type:"group",key:this.key})}}const Bd=s.z.string().uuid(),uo=s.z.object({key:Bd,name:s.z.string()}),cs=s.z.union([s.z.literal("label"),s.z.literal("builtin"),s.z.literal("cluster"),s.z.literal("channel"),s.z.literal("node"),s.z.literal("group"),s.z.literal("range"),s.z.literal("range-alias"),s.z.literal("user"),s.z.literal("workspace"),s.z.literal("schematic"),s.z.literal("lineplot"),s.z.literal("rack"),s.z.literal("device"),s.z.literal("task"),s.z.literal("policy")]),ye=s.z.object({type:cs,key:s.z.string()}),Ud=s.z.string().transform(t=>{const[e,r]=t.split(":");return{type:e,key:r}}),Ld=s.z.union([Ud,ye]),Nr=class ho{constructor(e){if(c(this,"type"),c(this,"key"),e instanceof ho)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[r,n]=e.split(":");this.type=r,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};c(Nr,"z",s.z.union([Ld,s.z.instanceof(Nr)]).transform(t=>new Nr(t)));let $=Nr;new $({type:"builtin",key:"root"});const Yd=s.z.object({type:s.z.number()}),qd=s.z.object({type:cs,fields:s.z.record(Yd)}),_d=s.z.object({id:$.z,name:s.z.string(),schema:qd.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));s.z.object({from:$.z,type:s.z.string(),to:$.z});const mi=t=>{const[e,r,n]=t.split("->");return{from:new $(e),type:r,to:new $(n)}},Fd=s.z.object({group:uo}),Wd=s.z.object({parent:ye,key:s.z.string().uuid().optional(),name:s.z.string()}),Vd=s.z.object({key:s.z.string(),name:s.z.string()}),Gd=s.z.object({keys:s.z.array(s.z.string())});var Re;let Zd=(Re=class{constructor(t){c(this,"client"),this.client=t}async create(t,e,r){return(await v(this.client,Re.ENDPOINT,{parent:t,name:e,key:r},Wd,Fd)).group}async rename(t,e){await v(this.client,Re.ENDPOINT_RENAME,{key:t,name:e},Vd,s.z.object({}))}async delete(t){await v(this.client,Re.ENDPOINT_DELETE,{keys:t},Gd,s.z.object({}))}},c(Re,"ENDPOINT","/ontology/create-group"),c(Re,"ENDPOINT_RENAME","/ontology/rename-group"),c(Re,"ENDPOINT_DELETE","/ontology/delete-group"),Re),Kd=class{constructor(t){c(this,"creator"),this.creator=new Zd(t)}async create(t,e,r){return this.sugar(await this.creator.create(t,e,r))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new lo(t.name,t.key)}};const pn={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},wi=s.z.object({id:ye,children:ye.array()}),Jd=s.z.object({from:ye,to:ye,children:ye.array()});let Hd=class{constructor(t){c(this,"client"),this.client=t}async addChildren(t,...e){await v(this.client,pn.ADD_CHILDREN,{id:new $(t).payload,children:e.map(r=>new $(r).payload)},wi,s.z.object({}))}async removeChildren(t,...e){await v(this.client,pn.REMOVE_CHILDREN,{id:new $(t).payload,children:e.map(r=>new $(r).payload)},wi,s.z.object({}))}async moveChildren(t,e,...r){const n={from:new $(t).payload,to:new $(e).payload,children:r.map(i=>new $(i).payload)};await v(this.client,pn.MOVE_CHILDREN,n,Jd,s.z.object({}))}};const Xd="/ontology/retrieve",Qd=s.z.object({ids:ye.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),includeSchema:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),term:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),types:cs.array().optional()}),ef=s.z.object({resources:_d.array()}),mn=t=>N(t).map(e=>new $(e).payload);let tf=class{constructor(t,e){c(this,"type","ontology"),c(this,"groups"),c(this,"client"),c(this,"writer"),c(this,"framer"),this.client=t,this.writer=new Hd(t),this.groups=new Kd(t),this.framer=e}async search(t,e){return await this.execRetrieve({term:t,...e})}async retrieve(t,e){const r=await this.execRetrieve({ids:mn(t),...e});if(Array.isArray(t))return r;if(r.length===0)throw new be(`No resource found with ID ${t.toString()}`);return r[0]}async page(t,e,r){return await this.execRetrieve({offset:t,limit:e,...r})}async retrieveChildren(t,e){return await this.execRetrieve({ids:mn(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:mn(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async openChangeTracker(){return await Fr.open(this.framer,this)}async openDependentTracker(t){return await ls.open(t,this.framer,this)}newSearcherWithOptions(t){return{type:this.type,search:e=>this.search(e,t),retrieve:e=>this.retrieve(e,t),page:(e,r)=>this.page(e,r,t)}}async execRetrieve(t){const{resources:e}=await v(this.client,Xd,t,Qd,ef);return e}};const bi="sy_ontology_resource_set",vi="sy_ontology_resource_delete",Oi="sy_ontology_relationship_set",Ti="sy_ontology_relationship_delete";class Fr{constructor(e,r){c(this,"relationships"),c(this,"resources"),c(this,"resourceObs"),c(this,"relationshipObs"),c(this,"streamer"),c(this,"client"),c(this,"closePromise"),this.relationshipObs=new Ve.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Ve.Observer,this.resources=this.resourceObs,this.client=r,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const r=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);r.concat(n).length>0&&this.resourceObs.notify(r.concat(n));const i=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);i.concat(a).length>0&&this.relationshipObs.notify(i.concat(a))}parseRelationshipSets(e){const r=e.get(Oi);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"set",key:mi(n),value:void 0}))}parseRelationshipDeletes(e){const r=e.get(Ti);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:mi(n)}))}async parseResourceSets(e){const r=e.get(bi);if(r.length===0)return[];const n=Array.from(r.as("string")).map(i=>new $(i));try{return(await this.client.retrieve(n)).map(i=>({variant:"set",key:i.id,value:i}))}catch(i){if(i instanceof be)return[];throw i}}parseResourceDeletes(e){const r=e.get(vi);return r.length===0?[]:Array.from(r.as("string")).map(n=>({variant:"delete",key:new $(n)}))}static async open(e,r){const n=await e.openStreamer([bi,vi,Oi,Ti]);return new Fr(n,r)}}const Si=t=>t==="from"?"to":"from";class ls extends Ve.Observer{constructor({target:e,dependents:r,relationshipType:n="parent",relationshipDirection:i="from",resourceType:a},o,l){super(),c(this,"internal"),c(this,"target"),c(this,"relDir"),c(this,"resourceType"),c(this,"dependents"),c(this,"client"),c(this,"relType"),c(this,"handleResourceChange",u=>{this.dependents=this.dependents.map(d=>{const f=u.find(h=>h.key.toString()==d.id.toString());return f==null||f.variant==="delete"?d:f.value}),this.notify(this.dependents)}),c(this,"handleRelationshipChange",u=>{const d=u.filter(h=>h.variant==="delete"&&h.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||h.key[Si(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(h=>!d.some(j=>j.key.to.toString()===h.id.toString()&&j.key.type===this.relType));const f=u.filter(h=>h.variant==="set"&&h.key.type===this.relType&&h.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||h.key[Si(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(h=>h.key.to)).then(h=>{this.dependents=this.dependents.concat(h),this.notify(this.dependents)})}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=r,this.resourceType!=null&&(this.dependents=this.dependents.filter(u=>u.id.type===this.resourceType)),this.client=l,this.relType=n,this.relDir=i,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,r,n){const i=await Fr.open(r,n);return new ls(e,i,n)}async close(){await this.internal.close()}}const Be=s.z.number(),Ut=s.z.object({name:s.z.string(),key:s.z.number(),rate:as.z,dataType:I.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional()}),fo=Ut.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:as.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),yo="channel",rf=t=>new $({type:yo,key:t.toString()}),nf=new Error("request for lock canceled");var sf=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class af{constructor(e,r=nf){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const a={resolve:n,reject:i,weight:e,priority:r},o=go(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return sf(this,arguments,void 0,function*(r,n=1,i=0){const[a,o]=yield this.acquire(n,i);try{return yield r(a)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),of(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const i=n.findIndex(a=>a.priority<=e);(i===-1?n:n.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function of(t,e){const r=go(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function go(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var cf=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class lf{constructor(e){this._semaphore=new af(1,e)}acquire(){return cf(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Wr=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let i=N(t);const a=i[0],o=typeof a;let l;return o==="string"&&r&&!isNaN(parseInt(a))&&"number"in e?(l=e.number,i=i.map(u=>parseInt(u))):l=e[o],{single:n,variant:l,normalized:i,actual:t}},Vr=(t,e,r,n)=>{if(n){if(r.length===0)throw new jr(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new Rr(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},Ue=t=>s.z.union([s.z.null().transform(()=>[]),t.array()]),uf=s.z.object({leaseholder:s.z.number().optional(),keys:s.z.number().array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:I.z.array().optional(),notDataTypes:I.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),hf=s.z.object({channels:Ue(Ut)}),je=t=>Wr(t,{number:"keys",string:"names"}),po=class mo{constructor(e){c(this,"client"),this.client=e}async search(e,r){return await this.execute({search:e,...r})}async retrieve(e,r){const n=je(e),{variant:i}=n;let{normalized:a}=n;return i==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[i]:a,...r})}async page(e,r,n){return await this.execute({offset:e,limit:r,...n})}async execute(e){const[r,n]=await this.client.send(mo.ENDPOINT,e,uf,hf);if(n!=null)throw n;return r.channels}};c(po,"ENDPOINT","/channel/retrieve");let us=po;class hs{constructor(e){c(this,"cache"),c(this,"namesToKeys"),c(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,r){return await this.wrapped.search(e,r)}async page(e,r,n){return await this.wrapped.page(e,r,n)}async retrieve(e,r){const{normalized:n}=Wr(e,{string:"names",number:"keys"}),i=[],a=[];if(n.forEach(l=>{const u=this.get(l);u!=null?i.push(...u):a.push(l)}),a.length===0)return i;const o=await this.wrapped.retrieve(a,r);return this.set(o),i.concat(o)}delete(e){const{variant:r,normalized:n}=je(e);r==="names"?n.forEach(i=>{const a=this.namesToKeys.get(i);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(i))}):n.forEach(i=>{const a=this.cache.get(i);a!=null&&(this.cache.delete(i),this.namesToKeys.delete(a.name))})}rename(e,r){e.forEach((n,i)=>{const a=r[i],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const l=this.namesToKeys.get(o.name);l!=null&&(l.delete(n),l.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(n,o);const u=this.namesToKeys.get(a);u==null?this.namesToKeys.set(a,new Set([n])):u.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const i=this.cache.get(e);return i==null?void 0:[i]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(i=>{const a=this.cache.get(i);a!=null&&n.push(a)}),n.length!==0)return n}}class wo{constructor(e,r){c(this,"mu",new lf),c(this,"requests",new Map),c(this,"wrapped"),c(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=yd(()=>{this.run()},r)}async search(e,r){return await this.wrapped.search(e,r)}async page(e,r,n){return await this.wrapped.page(e,r,n)}async retrieve(e){const{normalized:r,variant:n}=je(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((i,a)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:i,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(i=>e.add(i)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,i)=>n.resolve(r.filter(a=>i.includes(a.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const bo=async(t,e)=>{const{normalized:r}=je(e),n=await t.retrieve(r),i=[];if(r.forEach(a=>{n.find(o=>o.name===a||o.key===a)==null&&i.push(a)}),i.length>0)throw new be(`Could not find channels: ${JSON.stringify(i)}`);return n};class vo{constructor({dataType:e,rate:r,name:n,leaseholder:i=0,key:a=0,isIndex:o=!1,index:l=0,internal:u=!1,virtual:d=!1,frameClient:f,alias:h}){c(this,"_frameClient"),c(this,"key"),c(this,"name"),c(this,"rate"),c(this,"dataType"),c(this,"leaseholder"),c(this,"index"),c(this,"isIndex"),c(this,"internal"),c(this,"alias"),c(this,"virtual"),this.key=a,this.name=n,this.rate=new as(r??0),this.dataType=new I(e),this.leaseholder=i,this.index=l,this.isIndex=o,this.internal=u,this.alias=h,this.virtual=d,this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new G("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Ut.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal})}get ontologyID(){return new $({type:"channel",key:this.key.toString()})}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const df="/channel/retrieve-group",ff=s.z.object({}),yf=s.z.object({group:uo});let Oo=class{constructor(t,e,r,n){c(this,"type","channel"),c(this,"frameClient"),c(this,"client"),c(this,"retriever"),c(this,"writer"),this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let i=N(t),a=[];if(r){const o=await this.retriever.retrieve(i.map(u=>u.name)),l=new Set(o.map(u=>u.name));i=i.filter(u=>!l.has(u.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(i))),n?a[0]:a}async retrieve(t,e){const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return Vr("channel",t,n,r),r?n[0]:n}async search(t,e){return this.sugar(await this.retriever.search(t,e))}async delete(t){const{normalized:e,variant:r}=je(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(N(t),N(e))}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,r)=>await this.page(e,r,t)}}async page(t,e,r){return this.sugar(await this.retriever.page(t,e,r))}createDebouncedBatchRetriever(t=10){return new hs(new wo(new us(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(r=>new vo({...r,frameClient:e}))}async retrieveGroup(){const t=await v(this.client,df,{},ff,yf);return new lo(t.group.name,t.group.key)}};const gf=s.z.object({channels:fo.array()}),pf=s.z.object({channels:Ut.array()}),mf=s.z.object({keys:Be.array().optional(),names:s.z.string().array().optional()}),wf=s.z.object({}),bf=s.z.object({keys:Be.array(),names:s.z.string().array()}),vf=s.z.object({}),Of="/channel/create",Tf="/channel/delete",Sf="/channel/rename";let To=class{constructor(t,e){c(this,"client"),c(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await v(this.client,Of,{channels:t},gf,pf);return this.cache.set(e),e}async delete(t){await v(this.client,Tf,t,mf,wf),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await v(this.client,Sf,{keys:t,names:e},bf,vf),this.cache.rename(t,e)}};const zf=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:hs,Channel:vo,ChannelOntologyType:yo,Client:Oo,ClusterRetriever:us,DebouncedBatchRetriever:wo,Writer:To,analyzeChannelParams:je,keyZ:Be,newPayload:fo,ontologyID:rf,payload:Ut,retrieveRequired:bo},Symbol.toStringTag,{value:"Module"})),ds=s.z.string().uuid(),fs=s.z.object({key:ds,subjects:ye.array(),objects:ye.array(),actions:s.z.string().array()}),Nf=fs.extend({key:ds.optional()}),Ef="/access/policy/create",If="/access/policy/delete",kf="/access/policy/retrieve",Af=s.z.object({policies:Nf.array()}),xf=s.z.object({policies:fs.array()}),Cf=s.z.object({keys:ds.array()}),$f=s.z.object({}),jf=s.z.object({subject:ye}),Rf=s.z.object({policies:fs.array().optional().default([])});let Mf=class{constructor(t){c(this,"client"),this.client=t}async create(t){const e=!Array.isArray(t),{policies:r}=await v(this.client,Ef,{policies:N(t)},Af,xf);return e?r[0]:r}async retrieve(t){const{policies:e}=await v(this.client,kf,{subject:t},jf,Rf);return e}async delete(t){await v(this.client,If,{keys:N(t)},Cf,$f)}};const Df="/user/register";let Pf=class{constructor(t){c(this,"client"),this.client=t}async register(t,e){const{user:r}=await v(this.client,Df,{username:t,password:e},So,zo);return r}};s.z.string().uuid();const Bf=s.z.object({key:s.z.string(),username:s.z.string()}),So=s.z.object({username:s.z.string(),password:s.z.string()}),zo=s.z.object({token:s.z.string(),user:Bf}),zi="/auth/login",Uf=3;let Lf=class{constructor(t,e){c(this,"token"),c(this,"client"),c(this,"credentials"),c(this,"authenticating"),c(this,"authenticated"),c(this,"user"),c(this,"retryCount"),this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(zi)){this.authenticating==null&&(this.authenticating=new Promise((o,l)=>{this.client.send(zi,this.credentials,So,zo).then(([u,d])=>{if(d!=null)return o(d);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}).catch(l)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[n,i]=await r(e);return qn.matches(i)&&this.retryCount<Uf?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,i])};return t}};const Yf=["disconnected","connecting","connected","failed"],qf=s.z.enum(Yf),_f=s.z.object({status:qf,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string(),clientVersion:s.z.string(),clientServerCompatible:s.z.boolean(),nodeVersion:s.z.string().optional()}),Ff=s.z.object({clusterKey:s.z.string(),nodeVersion:s.z.string().optional()}),No={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.28.0"},Ni=(t,e,r)=>{const n=r?"cluster":"client";return`Synnax cluster node version ${t!=null?t+" ":""}is too ${r?"old":"new"} for client version ${e}.
|
|
38
|
-
This may cause compatibility issues. We recommend updating the ${n}. For more information, see
|
|
39
|
-
https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${n}-version`},Er=class Eo{constructor(e,r=k.seconds(30),n,i){c(this,"_state"),c(this,"pollFrequency",k.seconds(30)),c(this,"client"),c(this,"name"),c(this,"interval"),c(this,"clientVersion"),c(this,"onChangeHandlers",[]),c(this,"versionWarned",!1),this._state={...No},this.client=e,this.pollFrequency=r,this.clientVersion=n,this.name=i,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const r=this._state.status;try{const[n,i]=await this.client.send(Eo.ENDPOINT,{},s.z.object({}),Ff);if(i!=null)throw i;const a=n.nodeVersion,o=this.clientVersion,l=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,l||(console.warn(Ni(null,o,!0)),this.versionWarned=!0)):fi.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,l||(console.warn(Ni(a,o,fi.semVerNewer(o,a))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey,this._state.nodeVersion=n.nodeVersion,this._state.clientVersion=this.clientVersion}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&r!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};c(Er,"ENDPOINT","/connectivity/check"),c(Er,"DEFAULT",No),c(Er,"connectionStateZ",_f);let Io=Er;const Wf=s.z.object({keys:Be.array().optional(),bounds:ne.z,names:s.z.string().array().optional()}),Vf=s.z.object({}),Gf="/frame/delete";class Zf{constructor(e){c(this,"client"),this.client=e}async delete(e){await v(this.client,Gf,e,Wf,Vf)}}const Ei=t=>{const e=N(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ii=(t,e)=>{const r=N(t);if(r.length===e.length)return;const n=Ei(t);throw Ei===null?new G("[Frame] - channel keys or names must be provided when constructing a frame."):new G(`[Frame] - ${n}s and series must be the same length.
|
|
40
|
-
Got ${r.length} ${n}s and ${e.length} series.`)};let we=class Ke{constructor(e=[],r=[]){if(c(this,"columns",[]),c(this,"series",[]),e instanceof Ke){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,i)=>this.push(i,...N(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e,i=n.series.map(a=>Jf(a));Ii(n.keys,i),n.keys.forEach((a,o)=>this.push(a,i[o]))}else Object.entries(e).forEach(([n,i])=>{const a=parseInt(n);if(isNaN(a))this.push(n,...N(i));else return this.push(a,...N(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=N(r),i=N(e);Ii(i,n),n.forEach((a,o)=>this.push(i[o],a));return}throw new G(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
41
|
-
payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
|
|
42
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new me("colType is not key");return this.columns??[]}get uniqueKeys(){return di(this.keys)}get names(){if(this.colType==="key")throw new me("colType is not name");return this.columns??[]}get uniqueNames(){return di(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Hf(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(r=>r.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return ne.ZERO;const n=E.min(...this.series.map(a=>a.timeRange.start)),i=E.max(...this.series.map(a=>a.timeRange.end));return new ne(n,i)}const r=this.get(e);return r==null?ne.ZERO:r.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(r=>e.includes(r)):new dd(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof Ke){if(this.colType!==null&&e.colType!==this.colType)throw new G("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...r),typeof e=="string"&&this.colType==="key")throw new G("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new G("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new Ke([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const r=new Ke;return this.forEach((n,i,a)=>r.push(...e(n,i,a))),r}forEach(e){this.columns.forEach((r,n)=>{const i=this.series[n];e(r,i,n)})}at(e,r=!1){const n={};return this.uniqueColumns.forEach(i=>{n[i]=this.get(i).at(e,r)}),n}filter(e){const r=new Ke;return this.columns.forEach((n,i)=>{const a=this.series[i];e(n,a,i)&&r.push(n,a)}),r}get byteLength(){return new kt(this.series.reduce((e,r)=>e.add(r.byteLength),kt.ZERO))}get length(){return this.series.reduce((e,r)=>e+r.length,0)}};const Kf=s.z.object({timeRange:ne.z.optional(),alignment:s.z.bigint().or(s.z.string().transform(t=>BigInt(t))).optional(),dataType:I.z,data:s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer)}),ys=s.z.object({keys:s.z.union([s.z.null().transform(()=>[]),s.z.number().array().optional().default([])]),series:s.z.union([s.z.null().transform(()=>[]),Kf.array().optional().default([])])}),Jf=t=>{const{dataType:e,data:r,timeRange:n,alignment:i}=t;return new he({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:i})},Hf=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});class Gr{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new Gr(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=je(e);if(r==="keys"){this.adapter=null,this.keys=n;return}const i=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(o=>{const l=i.find(u=>u.name===o);if(l==null)throw new Error(`Channel ${o} not found`);a.set(l.key,l.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const r=this.adapter;return e.map((n,i)=>{if(typeof n=="number"){const a=r.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,i]}return[n,i]})}}class gs{constructor(e){c(this,"adapter"),c(this,"retriever"),c(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,r){const n=new gs(e);return await n.update(r),n}async adaptObjectKeys(e){const r={};for(const[n,i]of Object.entries(e))r[await this.adaptToKey(n)]=i;return r}async update(e){const r=await bo(this.retriever,e);this.adapter=new Map(r.map(n=>[n.name,n.key])),this.keys=r.map(n=>n.key)}async fetchChannel(e){const r=await this.retriever.retrieve(e);if(r.length===0)throw new Error(`Channel ${e} not found`);return r[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}async adapt(e,r){if(typeof e=="string"||typeof e=="number"){if(r==null)throw new G(`
|
|
43
|
-
Received a single channel name or key but no series.
|
|
44
|
-
`);if(Array.isArray(r)){if(r.some(u=>u instanceof he||Array.isArray(u)))throw new G(`
|
|
45
|
-
Received a single channel name or key but multiple series.
|
|
46
|
-
`);r=r}const o=await this.fetchChannel(e),l=new he({data:r,dataType:o.dataType});return new we(o.key,l)}if(Array.isArray(e)){if(r==null)throw new G(`
|
|
47
|
-
Received an array of channel names or keys but no series.
|
|
48
|
-
`);if(!Array.isArray(r))throw new G(`
|
|
49
|
-
Received an array of channel names or keys but no array of series.
|
|
50
|
-
`);const o=[],l=[];for(let u=0;u<e.length;u++){const d=await this.fetchChannel(e[u]);if(u>=r.length)throw new G(`
|
|
51
|
-
Received an array of channel names or keys but not enough series.
|
|
52
|
-
`);const f=new he({data:r[u],dataType:d.dataType});o.push(d.key),l.push(f)}return new we(o,l)}if(e instanceof we||e instanceof Map){const o=new we(e);if(this.adapter==null)return o;let l=[];return l=o.columns.map(u=>{var d;const f=typeof u=="string"?(d=this.adapter)==null?void 0:d.get(u):u;if(f==null)throw new G(`
|
|
53
|
-
Channel ${u} was not provided in the list of channels when opening the writer
|
|
54
|
-
`);return f}),new we(l,o.series)}const n=[],i=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[l,u]=a[o],d=await this.fetchChannel(l),f=new he({data:u,dataType:d.dataType});n.push(d.key),i.push(f)}return new we(n,i)}}class ps{constructor(e,r){c(this,"name"),c(this,"stream"),this.stream=r,this.name=e}async receive(){const[e,r]=await this.stream.receive();if(r!=null)throw r;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,r]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
55
|
-
Please report this error to the Synnax team. ${JSON.stringify(e)}`),r!=null){if(De.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const ki=new k(-1);var ms=(t=>(t[t.Open=0]="Open",t[t.Next=1]="Next",t[t.Prev=2]="Prev",t[t.SeekFirst=3]="SeekFirst",t[t.SeekLast=4]="SeekLast",t[t.SeekLE=5]="SeekLE",t[t.SeekGE=6]="SeekGE",t[t.Valid=7]="Valid",t[t.Error=8]="Error",t))(ms||{}),ko=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(ko||{});const Xf=s.z.object({command:s.z.nativeEnum(ms),span:k.z.optional(),bounds:ne.z.optional(),stamp:E.z.optional(),keys:s.z.number().array().optional(),chunkSize:s.z.number().optional()}),Qf=s.z.object({variant:s.z.nativeEnum(ko),ack:s.z.boolean(),command:s.z.nativeEnum(ms),error:Pt.optional().nullable(),frame:ys.optional()}),Ao=class _n{constructor(e,r){c(this,"stream"),c(this,"adapter"),c(this,"value"),this.stream=new ps("Iterator",e),this.value=new we,this.adapter=r}static async _open(e,r,n,i,a={}){const o=await Gr.open(n,r),l=await i.stream(_n.ENDPOINT,Xf,Qf),u=new _n(l,o);return await u.execute({command:0,keys:o.keys,bounds:new ne(e),chunkSize:a.chunkSize??1e5}),u}async next(e=ki){return await this.execute({command:1,span:new k(e)})}async prev(e=ki){return await this.execute({command:2,span:new k(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new E(e)})}async seekGE(e){return await this.execute({command:6,stamp:new E(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new ty(this)}async execute(e){for(this.stream.send(e),this.value=new we;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new we(r.frame)))}}};c(Ao,"ENDPOINT","/frame/iterate");let ey=Ao;class ty{constructor(e){c(this,"iter"),c(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const ry=s.z.object({start:E.z.optional(),keys:s.z.number().array()}),ny=s.z.object({frame:ys,error:Pt.optional().nullable()}),sy="/frame/stream";class ws{constructor(e,r){c(this,"stream"),c(this,"adapter"),this.stream=new ps("Streamer",e),this.adapter=r}get keys(){return this.adapter.keys}static async _open(e,r,{channels:n,from:i}){const a=await Gr.open(e,n),o=await r.stream(sy,ry,ny),l=new ws(o,a);return o.send({start:new E(i),keys:a.keys}),l}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(De.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new we((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class Zr extends Ve.Observer{constructor(e,r){super(r),c(this,"streamer"),c(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var bs=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.Error=3]="Error",t[t.SetAuthority=4]="SetAuthority",t))(bs||{}),At=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(At||{});const iy=t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof t=="number"&&t in At)return t;throw new Error(`invalid writer mode: ${t}`)}};new k(-1);const ay=s.z.object({start:E.z.optional(),controlSubject:Xe.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:Xe.Authority.z.array().optional(),mode:s.z.nativeEnum(At).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:k.z.optional()}),oy=s.z.object({command:s.z.nativeEnum(bs),config:ay.optional(),frame:ys.optional()}),cy=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(bs),error:Pt.optional().nullable()});var st;let ly=(st=class{constructor(t,e){c(this,"stream"),c(this,"adapter"),this.stream=new ps("Writer",t),this.adapter=e}static async _open(t,e,{channels:r,start:n=E.now(),authorities:i=Xe.Authority.Absolute,controlSubject:a,mode:o=1,errOnUnauthorized:l=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:d=k.SECOND}){const f=await gs.open(t,r),h=await e.stream(st.ENDPOINT,oy,cy),j=new st(h,f);return await j.execute({command:0,config:{start:new E(n),keys:f.keys,controlSubject:a,authorities:N(i),mode:iy(o),errOnUnauthorized:l,enableAutoCommit:u,autoIndexPersistInterval:d}}),j}async write(t,e){const r=await this.adapter.adapt(t,e);return this.stream.send({command:1,frame:r.toPayload()}),!0}async setAuthority(t,e){let r={keys:[],authorities:[]};if(typeof t=="number"&&e==null)r={keys:[],authorities:[t]};else{let n;typeof t=="string"||typeof t=="number"?n={[t]:e}:n=t,n=await this.adapter.adaptObjectKeys(n),r={keys:Object.keys(n).map(i=>Number(i)),authorities:Object.values(n)}}return(await this.execute({command:4,config:r})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const t=await this.execute({command:3});return t.error!=null?ns(t.error):null}async close(){await this.stream.closeAndAck()}async execute(t){for(this.stream.send(t);;){const e=await this.stream.receive();if(e.command===t.command)return e;console.warn("writer received unexpected response",e)}}get errorAccumulated(){return this.stream.received()}},c(st,"ENDPOINT","/frame/write"),st),uy=class{constructor(t,e,r){c(this,"streamClient"),c(this,"retriever"),c(this,"deleter"),this.streamClient=t,this.retriever=r,this.deleter=new Zf(e)}async openIterator(t,e,r){return await ey._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await ly._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await ws._open(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const i=e,a=await this.openWriter({start:t,channels:Object.keys(i),mode:At.Persist});try{await a.write(i),await a.commit()}finally{await a.close()}return}const n=await this.openWriter({start:t,channels:e,mode:At.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:k.MAX});try{await n.write(e,r)}finally{await n.close()}}async read(t,e){const{single:r}=je(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new we;try{for await(const i of r)n.push(i)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=je(t);return n==="keys"?await this.deleter.delete({keys:r,bounds:e}):await this.deleter.delete({names:r,bounds:e})}};const hy=Xe.Authority,dy=Xe.stateZ(s.z.number()),fy=t=>{var e,r;return t.to==null?`${(e=t.from)==null?void 0:e.resource} - ${(r=t.from)==null?void 0:r.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`};class xo extends Zr{constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer);return this.merge(n),[n.transfers,!0]}),c(this,"states"),c(this,"codec"),this.states=new Map,this.codec=new Qe.JSONCodec}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const yy="sy_node_1_control";let Co=class{constructor(t){c(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(yy);return new xo(t)}};const gy=Object.freeze(Object.defineProperty({__proto__:null,Authority:hy,Client:Co,StateTracker:xo,stateZ:dy,transferString:fy},Symbol.toStringTag,{value:"Module"}));let py=class{constructor(t,e,r){c(this,"tasks"),c(this,"racks"),c(this,"devices"),this.tasks=t,this.racks=e,this.devices=r}};const Lt=s.z.number(),vs=s.z.object({key:Lt,name:s.z.string()}),my=vs.partial({key:!0}),Os=s.z.string(),Kr=s.z.object({key:Os,rack:Lt,name:s.z.string(),make:s.z.string(),model:s.z.string(),location:s.z.string(),configured:s.z.boolean().optional(),properties:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:Qe.JSON_CODEC.decodeString(t)))}),wy=Kr.extend({properties:s.z.unknown().transform(t=>Qe.JSON_CODEC.encodeString(t))}),et=async(t,e,r,n)=>{const i=await t.openStreamer([e,r]),a=o=>{const l=[];return r!=null&&l.push(...o.get(r).series.flatMap(u=>n("delete",u))),e!=null&&l.push(...o.get(e).series.flatMap(u=>n("set",u))),[l,l.length>0]};return new Zr(i,a)},by="sy_device_set",vy="sy_device_delete",wn="/hardware/device/retrieve",Oy="/hardware/device/create",Ty="/hardware/device/delete",Sy=s.z.object({devices:wy.array()}),zy=s.z.object({devices:Kr.array()}),Ny=s.z.object({keys:Os.array()}),Ey=s.z.object({}),bn=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:Os.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),vn=s.z.object({devices:Ue(Kr)});let Iy=class{constructor(t,e){c(this,"type","device"),c(this,"client"),c(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const r=!Array.isArray(t),n=await v(this.client,wn,{keys:N(t),...e},bn,vn);return Vr("Device",t,n.devices,r),r?n.devices[0]:n.devices}async search(t,e){return(await v(this.client,wn,{search:t,...e},bn,vn)).devices}async page(t,e,r){return(await v(this.client,wn,{offset:t,limit:e,...r},bn,vn)).devices}async create(t){const e=!Array.isArray(t),r=await v(this.client,Oy,{devices:N(t)},Sy,zy);return e?r.devices[0]:r.devices}async delete(t){await v(this.client,Ty,{keys:N(t)},Ny,Ey)}async openDeviceTracker(){return await et(this.frameClient,by,vy,ky)}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,r)=>await this.page(e,r,t)}}};const ky=(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):e.parseJSON(Kr).map(r=>({variant:t,key:r.key,value:r})),On="/hardware/rack/retrieve",Ay="/hardware/rack/create",xy="/hardware/rack/delete",Tn=s.z.object({keys:Lt.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Sn=s.z.object({racks:Ue(vs)}),Cy=s.z.object({racks:my.array()}),$y=s.z.object({racks:vs.array()}),jy=s.z.object({keys:Lt.array()}),Ry=s.z.object({});let My=class{constructor(t,e,r){c(this,"type","rack"),c(this,"client"),c(this,"frameClient"),c(this,"tasks"),this.client=t,this.frameClient=e,this.tasks=r}async delete(t){await v(this.client,xy,{keys:N(t)},jy,Ry)}async create(t){const e=!Array.isArray(t),r=await v(this.client,Ay,{racks:N(t)},Cy,$y),n=this.sugar(r.racks);return e?n[0]:n}async search(t){const e=await v(this.client,On,{search:t},Tn,Sn);return this.sugar(e.racks)}async page(t,e){const r=await v(this.client,On,{offset:t,limit:e},Tn,Sn);return this.sugar(r.racks)}async retrieve(t){const{variant:e,normalized:r,single:n}=Wr(t,{string:"names",number:"keys"}),i=await v(this.client,On,{[e]:r},Tn,Sn),a=this.sugar(i.racks);return Vr("Rack",t,a,n),n?a[0]:a}sugar(t){return t.map(({key:e,name:r})=>new Dy(e,r,this.tasks))}};class Dy{constructor(e,r,n){c(this,"key"),c(this,"name"),c(this,"tasks"),this.key=e,this.name=r,this.tasks=n}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const tt=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),Dr=s.z.object({task:tt,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t))).or(s.z.array(s.z.unknown())).or(s.z.null())}),Jr=s.z.object({key:tt,name:s.z.string(),type:s.z.string(),internal:s.z.boolean().optional(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:Qe.JSON_CODEC.decodeString(t))),state:Dr.optional().nullable(),snapshot:s.z.boolean().optional()}),Py=Jr.omit({key:!0}).extend({key:tt.transform(t=>t.toString()).optional(),config:s.z.unknown().transform(t=>Qe.JSON_CODEC.encodeString(t))});s.z.object({task:tt,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t)))});const Nt="sy_task_state",Ai="sy_task_cmd",Jt=new Error("Task not created");class By{constructor(e,r,n,i,a=!1,o=!1,l,u=null,d=null,f=null){c(this,"key"),c(this,"name"),c(this,"internal"),c(this,"type"),c(this,"config"),c(this,"snapshot"),c(this,"state"),c(this,"frameClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.key=e,this.name=r,this.type=n,this.config=i,this.internal=a,this.snapshot=o,l!==null&&(this.state=l),this.frameClient=u,this.ontologyClient=d,this.rangeClient=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state,internal:this.internal}}get ontologyID(){return new $({type:"task",key:this.key})}async executeCommand(e,r){if(this.frameClient==null)throw Jt;const n=await this.frameClient.openWriter(Ai),i=ad.id();return await n.write(Ai,[{task:this.key,type:e,key:i,args:r}]),await n.close(),i}async executeCommandSync(e,r,n){if(this.frameClient==null)throw Jt;const i=await this.frameClient.openStreamer(Nt),a=await this.executeCommand(e,r);let o;const l=new Promise(u=>setTimeout(()=>u(!1),new k(n).milliseconds));for(;;){const u=await Promise.any([i.read(),l]);if(u===!1)throw new Error("Command timed out");const d=Dr.safeParse(u.at(-1).sy_task_state);if(d.success){if(o=d.data,o.key===a)break}else console.error(d.error)}return i.close(),o}async openStateObserver(){if(this.frameClient==null)throw Jt;return new Zr(await this.frameClient.openStreamer(Nt),e=>{const r=e.get(Nt);if(r.length===0)return[null,!1];const n=Dr.safeParse(r.at(-1));if(!n.success)return[null,!1];const i=n.data;return i.task!==this.key?[null,!1]:[i,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw Jt;if(!this.snapshot)return null;const e=await this.ontologyClient.retrieveParents(this.ontologyID);return e.length==0?null:e[0]}}const Uy=s.z.object({rack:Lt.optional(),keys:s.z.string().array().optional(),names:s.z.string().array().optional(),offset:s.z.number().optional(),limit:s.z.number().optional(),includeState:s.z.boolean().optional()}),Ly=s.z.object({tasks:Ue(Jr)}),Yy="/hardware/task/retrieve",qy="/hardware/task/create",_y="/hardware/task/delete",Fy="/hardware/task/copy",Wy=s.z.object({tasks:Py.array()}),Vy=s.z.object({tasks:Jr.array()}),Gy=s.z.object({keys:tt.array()}),Zy=s.z.object({}),Ky=s.z.object({key:tt,name:s.z.string(),snapshot:s.z.boolean()}),Jy=s.z.object({task:Jr});let Hy=class{constructor(t,e,r,n){c(this,"type","task"),c(this,"client"),c(this,"frameClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.client=t,this.frameClient=e,this.ontologyClient=r,this.rangeClient=n}async create(t){const e=!Array.isArray(t),r=await v(this.client,qy,{tasks:N(t)},Wy,Vy),n=this.sugar(r.tasks);return e?n[0]:n}async delete(t){await v(this.client,_y,{keys:N(t)},Gy,Zy)}async search(t){return await this.execRetrieve({keys:[t]})}async page(t,e){return await this.execRetrieve({offset:t,limit:e})}async list(t={}){return this.sugar(await this.execRetrieve(t))}async retrieve(t,e){const{single:r,normalized:n,variant:i}=Wr(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};i==="rack"?a.rack=t:a.keys=n;const o=await this.execRetrieve(a),l=this.sugar(o);return r&&i!=="rack"?l[0]:l}async copy(t,e,r){const n=await v(this.client,Fy,{key:t,name:e,snapshot:r},Ky,Jy);return this.sugar([n.task])[0]}async retrieveByName(t,e){const r=await this.execRetrieve({names:[t],rack:e});return Vr("Task",t,r,!0),this.sugar(r)[0]}async execRetrieve(t){return(await v(this.client,Yy,t,Uy,Ly)).tasks}sugar(t){return t.map(({key:e,name:r,type:n,config:i,state:a,internal:o,snapshot:l})=>new By(e,r,n,i,o,l,a,this.frameClient,this.ontologyClient,this.rangeClient))}async openTracker(){return await et(this.frameClient,"sy_task_set","sy_task_delete",(t,e)=>Array.from(e).map(r=>({variant:t,key:r.toString(),value:r.toString()})))}async openStateObserver(){return new Zr(await this.frameClient.openStreamer(Nt),t=>{const e=t.get(Nt);if(e.length===0)return[null,!1];const r=Dr.safeParse(e.at(-1));return r.success?[r.data,!0]:[null,!1]})}};const Yt=s.z.string().uuid(),Hr=s.z.object({key:Yt,name:s.z.string().min(1),color:s.z.string()}),Xy=s.z.object({keys:Yt.array().optional(),for:ye.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Qy=s.z.object({labels:Ue(Hr)});var Ht;let eg=(Ht=class{constructor(t){c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return await this.execute({keys:e})}async retrieveFor(t){return await this.execute({for:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){const[e,r]=await this.client.send(Ht.ENDPOINT,t,Xy,Qy);if(r!=null)throw r;return e.labels}},c(Ht,"ENDPOINT","/label/retrieve"),Ht);const tg=Hr.extend({key:Yt.optional()}),rg=s.z.object({labels:tg.array()}),ng=s.z.object({labels:Hr.array()}),sg=s.z.object({keys:Yt.array()}),$o=s.z.object({id:ye,labels:Yt.array(),replace:s.z.boolean().optional()}),ig=$o.omit({replace:!0}),zn=s.z.object({}),ag="/label/create",og="/label/delete",cg="/label/set",lg="/label/remove";let ug=class{constructor(t){c(this,"client"),this.client=t}async create(t){return(await v(this.client,ag,{labels:N(t)},rg,ng)).labels}async delete(t){await v(this.client,og,{keys:N(t)},sg,zn)}async set(t,e,{replace:r}={}){await v(this.client,cg,{id:t,labels:e,replace:r},$o,zn)}async remove(t,e){await v(this.client,lg,{id:t,labels:e},ig,zn)}};const hg="sy_label_set",dg="sy_label_delete";let fg=class{constructor(t,e,r){c(this,"type","label"),c(this,"retriever"),c(this,"writer"),c(this,"frameClient"),c(this,"ontology"),this.writer=new ug(t),this.retriever=new eg(t),this.frameClient=e,this.ontology=r}async search(t){return await this.retriever.search(t)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async retrieveFor(t){return await this.retriever.retrieveFor(new $(t))}async label(t,e,r={}){await this.writer.set(new $(t),e,r)}async removeLabels(t,e){await this.writer.remove(new $(t),e)}async page(t,e){return await this.retriever.page(t,e)}async create(t){const e=Array.isArray(t),r=await this.writer.create(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}async openChangeTracker(){return await et(this.frameClient,hg,dg,yg)}async trackLabelsOf(t){const e=new Ve.Observer,r=(await this.retrieveFor(t)).map(n=>({id:new $({key:n.key,type:"label"}),key:n.key,name:n.name,data:n}));return(await this.ontology.openDependentTracker({target:new $(t),dependents:r,relationshipType:"labeled_by"})).onChange(n=>e.notify(n.map(i=>{var a,o;return{key:i.id.key,color:(a=i.data)==null?void 0:a.color,name:(o=i.data)==null?void 0:o.name}}))),e}};const yg=(t,e)=>t==="delete"?e.toUUIDs().map(r=>({variant:t,key:r})):e.parseJSON(Hr).map(r=>({variant:t,key:r.key,value:r})),fe=s.z.string().uuid(),qt=s.z.object({key:fe,name:s.z.string().min(1),timeRange:ne.z,color:s.z.string().optional()}),jo=qt.extend({key:s.z.string().uuid().optional()}),Ro=t=>{const e=N(t),r=e.length===0;let n=!1;return r||(n=fe.safeParse(e[0]).success),{single:!Array.isArray(t),variant:n?"keys":"names",normalized:e,actual:t,empty:r}},Mo="range",Do="range-alias",gg=t=>new $({type:Mo,key:t}),pg=t=>new $({type:Do,key:t}),mg="sy_range_alias_set",wg="sy_range_alias_delete",bg=s.z.object({range:fe,aliases:s.z.string().array()}),vg=s.z.object({aliases:s.z.record(s.z.string(),Be)}),Og=s.z.object({range:fe,aliases:s.z.record(Be.or(s.z.string()),s.z.string())}),Tg=s.z.unknown(),Sg=s.z.object({range:fe,channels:Be.array()}),zg=s.z.unknown(),Ng=s.z.object({range:fe}),Eg=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),wt=class bt{constructor(e,r,n){c(this,"frameClient"),c(this,"cache",new Map),c(this,"client"),c(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=r}async resolve(e){const r=[],n=typeof e=="string",i={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?i[o]=l:r.push(o)});if(r.length===0)return i;const a=await v(this.client,bt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:r},bg,vg);return Object.entries(a.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?a.aliases[r[0]]:{...i,...a.aliases}}async set(e){await v(this.client,bt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Og,Tg)}async list(){return(await v(this.client,bt.LIST_ENDPOINT,{range:this.rangeKey},Ng,Eg)).aliases}async delete(e){await v(this.client,bt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},Sg,zg)}async openChangeTracker(){return await et(this.frameClient,mg,wg,xg(this.rangeKey))}};c(wt,"SET_ENDPOINT","/range/alias/set"),c(wt,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(wt,"LIST_ENDPOINT","/range/alias/list"),c(wt,"DELETE_ENDPOINT","/range/alias/delete");let Ig=wt;const kg=s.z.object({range:fe,channel:Be,alias:s.z.string()}),Ag="---",xg=t=>(e,r)=>e==="delete"?r.toStrings().filter(n=>n.split(Ag)[0]===t).map(n=>({variant:e,key:n,value:void 0})):r.parseJSON(kg).map(n=>({variant:e,key:n.alias,value:n})),Cg=s.z.object({range:fe,keys:s.z.string().array()}),Ts=s.z.object({range:fe,key:s.z.string(),value:s.z.string()}),$g=s.z.object({pairs:Ue(Ts)}),jg=s.z.object({range:fe,pairs:Ts.array()}),Rg=s.z.object({range:fe,keys:s.z.string().array()}),Ir=class kr{constructor(e,r,n){c(this,"rangeKey"),c(this,"client"),c(this,"frameClient"),this.rangeKey=e,this.client=r,this.frameClient=n}async get(e){const r=await v(this.client,kr.GET_ENDPOINT,{range:this.rangeKey,keys:N(e)},Cg,$g);return typeof e=="string"?r.pairs[0].value:Object.fromEntries(r.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,r=""){let n;ss(e)?n=Object.entries(e).map(([i,a])=>({range:this.rangeKey,key:i,value:a})):n=[{range:this.rangeKey,key:e,value:r}],await v(this.client,kr.SET_ENDPOINT,{range:this.rangeKey,pairs:n},jg,s.z.unknown())}async delete(e){await v(this.client,kr.DELETE_ENDPOINT,{range:this.rangeKey,keys:N(e)},Rg,s.z.unknown())}async openTracker(){return await et(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,r)=>e==="delete"?r.toStrings().map(n=>{const[i,a]=n.split("<--->",2);return{variant:e,key:n,value:{range:i,key:a,value:""}}}):r.parseJSON(Ts).map(n=>({variant:e,key:`${n.range}${n.key}`,value:n})))}};c(Ir,"GET_ENDPOINT","/range/kv/get"),c(Ir,"SET_ENDPOINT","/range/kv/set"),c(Ir,"DELETE_ENDPOINT","/range/kv/delete");let Fn=Ir;const Nn=t=>new $({type:"range",key:t});class Po{constructor(e,r=ne.ZERO,n,i,a,o,l,u,d,f,h){c(this,"key"),c(this,"name"),c(this,"kv"),c(this,"timeRange"),c(this,"color"),c(this,"channels"),c(this,"aliaser"),c(this,"frameClient"),c(this,"labelClient"),c(this,"ontologyClient"),c(this,"rangeClient"),this.key=n,this.name=e,this.timeRange=r,this.frameClient=a,this.color=i,this.kv=o,this.aliaser=l,this.channels=u,this.labelClient=d,this.ontologyClient=f,this.rangeClient=h}get ontologyID(){return new $({key:this.key,type:"range"})}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new be(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(r=>r.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Nn(this.key))}async addLabel(...e){await this.labelClient.label(Nn(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Nn(this.key),e)}async openChildRangeTracker(){const e=new Ve.Observer,r=(await this.retrieveChildren()).map(i=>{const a=new $({key:i.key,type:"range"});return{id:a,key:a.toString(),name:i.name,data:i.payload}}),n=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:r,resourceType:"range"});return n.onChange(i=>e.notify(this.rangeClient.resourcesToRanges(i))),e.setCloser(async()=>await n.close()),e}async openParentRangeTracker(){const e=new Ve.Observer,r=await this.retrieveParent();if(r==null)return null;const n=new $({key:r.key,type:"range"}),i={id:n,key:n.toString(),name:r.name,data:r.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[i],relationshipDirection:"to"});return a.onChange(o=>{const l=this.rangeClient.resourcesToRanges(o);if(l.length===0)return;const u=l[0];e.notify(u)}),e.setCloser(async()=>await a.close()),e}}const Mg=s.z.object({keys:fe.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:ne.z.optional(),limit:s.z.number().int().optional(),offset:s.z.number().int().optional()}),Dg="/range/retrieve",Pg=s.z.object({ranges:Ue(qt)});let Bo=class{constructor(t,e,r,n,i,a){c(this,"type","range"),c(this,"frameClient"),c(this,"writer"),c(this,"unaryClient"),c(this,"channels"),c(this,"labelClient"),c(this,"ontologyClient"),this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.labelClient=i,this.ontologyClient=a}async create(t,e){const r=!Array.isArray(t),n=this.sugarMany(await this.writer.create(N(t),e));return r?n[0]:n}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(N(t))}async search(t){return this.sugarMany(await this.execRetrieve({term:t}))}async page(t,e){return this.sugarMany(await this.execRetrieve({offset:t,limit:e}))}async retrieve(t){if(typeof t=="object"&&"start"in t)return await this.execRetrieve({overlapsWith:new ne(t)});const{single:e,actual:r,variant:n,normalized:i,empty:a}=Ro(t);if(a)return[];const o=await this.execRetrieve({[n]:i});if(!e)return o;if(o.length===0)throw new jr(`range matching ${r} not found`);if(o.length>1)throw new Rr(`multiple ranges matching ${r} found`);return o[0]}getKV(t){return new Fn(t,this.unaryClient,this.frameClient)}async execRetrieve(t){const{ranges:e}=await v(this.unaryClient,Dg,t,Mg,Pg);return this.sugarMany(e)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents({key:t,type:"range"});if(e.length===0)return null;const r=e[0];return r.id.type!=="range"?null:await this.retrieve(r.id.key)}sugarOne(t){return new Po(t.name,t.timeRange,t.key,t.color,this.frameClient,new Fn(t.key,this.unaryClient,this.frameClient),new Ig(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(t){return t.map(e=>this.sugarOne(e))}async openTracker(){return await et(this.frameClient,"sy_range_set","sy_range_delete",(t,e)=>t==="delete"?e.toStrings().map(r=>({variant:t,key:r,value:void 0})):this.sugarMany(e.parseJSON(qt)).map(r=>({variant:t,key:r.key,value:r})))}resourcesToRanges(t){return t.map(e=>this.resourceToRange(e))}resourceToRange(t){var e,r,n;return this.sugarOne({key:t.id.key,name:(e=t.data)==null?void 0:e.name,timeRange:new ne((r=t.data)==null?void 0:r.timeRange),color:(n=t.data)==null?void 0:n.color})}};const Bg=s.z.object({ranges:qt.array()}),Ug=s.z.object({parent:ye.optional(),ranges:jo.array()}),Lg=s.z.object({keys:fe.array()}),Yg=s.z.object({}),qg=s.z.object({key:fe,name:s.z.string()}),_g=s.z.object({}),Fg="/range/create",Wg="/range/delete",Vg="/range/rename";let Uo=class{constructor(t){c(this,"client"),this.client=t}async rename(t,e){await v(this.client,Vg,{key:t,name:e},qg,_g)}async create(t,e){return(await v(this.client,Fg,{ranges:t,...e},Ug,Bg)).ranges}async delete(t){await v(this.client,Wg,{keys:t},Lg,Yg)}};const Gg=Object.freeze(Object.defineProperty({__proto__:null,Client:Bo,KV:Fn,Range:Po,RangeAliasOntologyType:Do,RangeOntologyType:Mo,Writer:Uo,analyzeParams:Ro,keyZ:fe,newPayloadZ:jo,payloadZ:qt,rangeAliasOntologyID:pg,rangeOntologyID:gg},Symbol.toStringTag,{value:"Module"})),Zg="/api/v1/";class Kg{constructor(e,r=!1){c(this,"url"),c(this,"unary"),c(this,"stream"),c(this,"secure"),this.secure=r,this.url=e.child(Zg);const n=new Qe.JSONCodec;this.unary=new nh(this.url,n,this.secure),this.stream=new dh(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Ss=s.z.string().uuid(),zs=s.z.object({key:s.z.string(),name:s.z.string(),data:os.or(s.z.string().transform(t=>JSON.parse(t)))}),Jg=s.z.object({keys:s.z.string().array()}),Hg=s.z.object({linePlots:zs.array()});let Xg=class{constructor(t){c(this,"ENDPOINT","/workspace/lineplot/retrieve"),c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return(await v(this.client,this.ENDPOINT,{keys:e},Jg,Hg)).linePlots}};const Ge=s.z.string().uuid(),Lo=t=>JSON.parse(t),Yo=s.z.object({name:s.z.string(),key:Ge,layout:os.or(s.z.string().transform(t=>Lo(t)))}),qo=Yo.omit({layout:!0}).extend({layout:s.z.string().transform(t=>Lo(t))}),Qg=zs.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ep=s.z.object({workspace:Ge,linePlots:Qg.array()}),tp=s.z.object({linePlots:zs.array()}),rp=s.z.object({keys:Ss.array()}),np=s.z.object({}),sp=s.z.object({key:Ss,name:s.z.string()}),ip=s.z.object({}),ap=s.z.object({key:Ss,data:s.z.string()}),op=s.z.object({}),cp="/workspace/lineplot/create",lp="/workspace/lineplot/delete",up="/workspace/lineplot/rename",hp="/workspace/lineplot/set-data";let dp=class{constructor(t){c(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await v(this.client,cp,{workspace:t,linePlots:[r]},ep,tp)).linePlots[0]}async delete(t){const e=N(t);await v(this.client,lp,{keys:e},rp,np)}async rename(t,e){await v(this.client,up,{key:t,name:e},sp,ip)}async setData(t,e){await v(this.client,hp,{key:t,data:JSON.stringify(e)},ap,op)}},fp=class{constructor(t){c(this,"writer"),c(this,"retriever"),this.writer=new dp(t),this.retriever=new Xg(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}};const yp=s.z.object({keys:Ge.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),gp=s.z.object({workspaces:Ue(qo)});var Xt;let pp=(Xt=class{constructor(t){c(this,"client"),this.client=t}async retrieve(t){const e=N(t);return await this.execute({keys:e})}async retrieveByAuthor(t){return await this.execute({author:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){return(await v(this.client,Xt.ENDPOINT,t,yp,gp)).workspaces}},c(Xt,"ENDPOINT","/workspace/retrieve"),Xt);const Xr=s.z.string().uuid(),mp=s.z.object({key:s.z.string(),name:s.z.string(),data:os.or(s.z.string().transform(t=>JSON.parse(t))),snapshot:s.z.boolean()}),Ns=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(t=>JSON.parse(t))}),wp=s.z.object({keys:s.z.string().array()}),bp=s.z.object({schematics:Ns.array()});class vp{constructor(e){c(this,"ENDPOINT","/workspace/schematic/retrieve"),c(this,"client"),this.client=e}async retrieve(e){return(await v(this.client,this.ENDPOINT,{keys:N(e)},wp,bp)).schematics}}const Op=mp.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Tp=s.z.object({workspace:Ge,schematics:Op.array()}),Sp=s.z.object({schematics:Ns.array()}),zp=s.z.object({keys:Xr.array()}),Np=s.z.object({}),Ep=s.z.object({key:Xr,name:s.z.string()}),xi=s.z.object({}),Ip=s.z.object({key:Xr,data:s.z.string()});s.z.object({});const kp=s.z.object({key:Xr,name:s.z.string(),snapshot:s.z.boolean()}),Ap=s.z.object({schematic:Ns}),xp="/workspace/schematic/create",Cp="/workspace/schematic/delete",$p="/workspace/schematic/rename",jp="/workspace/schematic/set-data",Rp="/workspace/schematic/copy";let Mp=class{constructor(t){c(this,"client"),this.client=t}async create(t,e){const r={...e,data:JSON.stringify(e.data)};return(await v(this.client,xp,{workspace:t,schematics:[r]},Tp,Sp)).schematics[0]}async copy(t,e,r){return(await v(this.client,Rp,{key:t,name:e,snapshot:r},kp,Ap)).schematic}async delete(t){const e=N(t);await v(this.client,Cp,{keys:e},zp,Np)}async rename(t,e){await v(this.client,$p,{key:t,name:e},Ep,xi)}async setData(t,e){await v(this.client,jp,{key:t,data:JSON.stringify(e)},Ip,xi)}},Dp=class{constructor(t){c(this,"writer"),c(this,"retriever"),this.writer=new Mp(t),this.retriever=new vp(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),r=await this.retriever.retrieve(t);return e?r:r[0]}async delete(t){await this.writer.delete(t)}async copy(t,e,r){return await this.writer.copy(t,e,r)}};const Pp=Yo.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),Bp=s.z.object({workspaces:Pp.array()}),Up=s.z.object({workspaces:qo.array()}),Lp=s.z.object({keys:Ge.array()}),Yp=s.z.object({}),qp=s.z.object({key:Ge,name:s.z.string()}),_p=s.z.object({}),Fp=s.z.object({key:Ge,layout:s.z.string()}),Wp=s.z.object({}),Vp="/workspace/create",Gp="/workspace/delete",Zp="/workspace/rename",Kp="/workspace/set-layout";class Jp{constructor(e){c(this,"client"),this.client=e}async create(e){return(await v(this.client,Vp,{workspaces:N(e)},Bp,Up)).workspaces}async delete(e){await v(this.client,Gp,{keys:N(e)},Lp,Yp)}async rename(e,r){await v(this.client,Zp,{key:e,name:r},qp,_p)}async setLayout(e,r){await v(this.client,Kp,{key:e,layout:JSON.stringify(r)},Fp,Wp)}}class Hp{constructor(e){c(this,"type","workspace"),c(this,"schematic"),c(this,"linePlot"),c(this,"retriever"),c(this,"writer"),this.schematic=new Dp(e),this.linePlot=new fp(e),this.retriever=new pp(e),this.writer=new Jp(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const r=Array.isArray(e),n=await this.retriever.retrieve(e);return r?n:n[0]}async page(e,r){return await this.retriever.page(e,r)}async create(e){const r=Array.isArray(e),n=await this.writer.create(e);return r?n:n[0]}async rename(e,r){await this.writer.rename(e,r)}async setLayout(e,r){await this.writer.setLayout(e,r)}async delete(...e){await this.writer.delete(e)}}const _o=s.z.object({host:s.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:s.z.number({required_error:"Port is required"}).or(s.z.string({required_error:"Port is required"})),username:s.z.string().min(1,"Username is required"),password:s.z.string().min(1,"Password is required"),connectivityPollFrequency:k.z.default(k.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class Fo extends uy{constructor(e){const r=_o.parse(e),{host:n,port:i,username:a,password:o,connectivityPollFrequency:l,secure:u}=r,d=new Kg(new Nd({host:n,port:Number(i)}),u);d.use(Pd);let f;a!=null&&o!=null&&(f=new Lf(d.unary,{username:a,password:o}),d.use(f.middleware()));const h=new hs(new us(d.unary)),j=new To(d.unary,h);super(d.stream,d.unary,h),c(this,"createdAt"),c(this,"props"),c(this,"ranges"),c(this,"channels"),c(this,"auth"),c(this,"user"),c(this,"access"),c(this,"connectivity"),c(this,"ontology"),c(this,"workspaces"),c(this,"labels"),c(this,"hardware"),c(this,"control"),c(this,"transport"),c(this,"clientVersion","0.28.0"),this.createdAt=E.now(),this.props=r,this.auth=f,this.transport=d,this.channels=new Oo(this,h,d.unary,j),this.connectivity=new Io(d.unary,l,this.clientVersion,r.name),this.control=new Co(this),this.ontology=new tf(d.unary,this);const W=new Uo(this.transport.unary);this.labels=new fg(this.transport.unary,this,this.ontology),this.ranges=new Bo(this,W,this.transport.unary,h,this.labels,this.ontology),this.access=new Mf(this.transport.unary),this.user=new Pf(this.transport.unary),this.workspaces=new Hp(this.transport.unary);const se=new Iy(this.transport.unary,this),R=new Hy(this.transport.unary,this,this.ontology,this.ranges),uc=new My(this.transport.unary,this,R);this.hardware=new py(R,uc,se)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c(Fo,"connectivity",Io);const Xp=Xe.Authority,Wn=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof s.z.ZodError){const i=n.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${r} - ${i.join(`
|
|
56
|
-
`)}`)}else throw n}};var Qp=Object.defineProperty,em=(t,e,r)=>e in t?Qp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,H=(t,e,r)=>em(t,typeof e!="symbol"?e+"":e,r);const Vn=class Wo{constructor(e,r,n="",i=!1){H(this,"_noop",!1),H(this,"key"),H(this,"path"),H(this,"serviceName"),this.key=e,this.path=r,this.serviceName=n,this._noop=i}child(e){return new Wo(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};H(Vn,"NOOP",new Vn("","",""));let Es=Vn;const Gn=["debug","info","warn","error"],tm=t=>{const e=Gn.indexOf(t);return({level:r})=>Gn.indexOf(r)>=e},rm=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(i=>n.startsWith(i))||r!=null&&r.some(i=>n.startsWith(i)))},Zn=class Vo{constructor(e={}){H(this,"meta",Es.NOOP),H(this,"filters");const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new Vo({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,Qt(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,Qt(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,Qt(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,Qt(r)))}};H(Zn,"NOOP",new Zn);let Go=Zn;const Qt=t=>typeof t=="function"?t():t;var nm=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Fe="1.8.0",Ci=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function sm(t){var e=new Set([t]),r=new Set,n=t.match(Ci);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(l){return l===t};function a(l){return r.add(l),!1}function o(l){return e.add(l),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;var u=l.match(Ci);if(!u)return a(l);var d={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return d.prerelease!=null||i.major!==d.major?a(l):i.major===0?i.minor===d.minor&&i.patch<=d.patch?o(l):a(l):i.minor<=d.minor?o(l):a(l)}}var im=sm(Fe),am=Fe.split(".")[0],xt=Symbol.for("opentelemetry.js.api."+am),Ct=nm;function Is(t,e,r,n){var i;n===void 0&&(n=!1);var a=Ct[xt]=(i=Ct[xt])!==null&&i!==void 0?i:{version:Fe};if(!n&&a[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(a.version!==Fe){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+Fe);return r.error(o.stack||o.message),!1}return a[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Fe+"."),!0}function $t(t){var e,r,n=(e=Ct[xt])===null||e===void 0?void 0:e.version;if(!(!n||!im(n)))return(r=Ct[xt])===null||r===void 0?void 0:r[t]}function ks(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Fe+".");var r=Ct[xt];r&&delete r[t]}var om=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},cm=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},lm=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return it("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return it("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return it("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return it("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return it("verbose",this._namespace,e)},t}();function it(t,e,r){var n=$t("diag");if(n)return r.unshift(e),n[t].apply(n,cm([],om(r),!1))}var ge;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(ge||(ge={}));function um(t,e){t<ge.NONE?t=ge.NONE:t>ge.ALL&&(t=ge.ALL),e=e||{};function r(n,i){var a=e[n];return typeof a=="function"&&t>=i?a.bind(e):function(){}}return{error:r("error",ge.ERROR),warn:r("warn",ge.WARN),info:r("info",ge.INFO),debug:r("debug",ge.DEBUG),verbose:r("verbose",ge.VERBOSE)}}var hm=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},dm=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},fm="diag",jt=function(){function t(){function e(i){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var l=$t("diag");if(l)return l[i].apply(l,dm([],hm(a),!1))}}var r=this,n=function(i,a){var o,l,u;if(a===void 0&&(a={logLevel:ge.INFO}),i===r){var d=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=d.stack)!==null&&o!==void 0?o:d.message),!1}typeof a=="number"&&(a={logLevel:a});var f=$t("diag"),h=um((l=a.logLevel)!==null&&l!==void 0?l:ge.INFO,i);if(f&&!a.suppressOverrideMessage){var j=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+j),h.warn("Current logger will overwrite one already registered from "+j)}return Is("diag",h,r,!0)};r.setLogger=n,r.disable=function(){ks(fm,r)},r.createComponentLogger=function(i){return new lm(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),ym=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},gm=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},pm=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=ym(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var a=new t(this._entries);try{for(var o=gm(n),l=o.next();!l.done;l=o.next()){var u=l.value;a._entries.delete(u)}}catch(d){e={error:d}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return a},t.prototype.clear=function(){return new t},t}();jt.instance();function mm(t){return t===void 0&&(t={}),new pm(new Map(Object.entries(t)))}function wm(t){return Symbol.for(t)}var bm=function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var a=new t(r._currentContext);return a._currentContext.set(n,i),a},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t}(),vm=new bm,Om={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Tm={set:function(t,e,r){t!=null&&(t[e]=r)}},Sm=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},zm=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},Nm=function(){function t(){}return t.prototype.active=function(){return vm},t.prototype.with=function(e,r,n){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return r.call.apply(r,zm([n],Sm(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Em=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a},Im=function(t,e,r){if(arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},En="context",km=new Nm,Zo=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Is(En,e,jt.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Im([e,r,n],Em(a),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return $t(En)||km},t.prototype.disable=function(){this._getContextManager().disable(),ks(En,jt.instance())},t}(),Kn;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Kn||(Kn={}));var Am=Zo.getInstance(),xm=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}(),As=wm("OpenTelemetry Baggage Key");function Ko(t){return t.getValue(As)||void 0}function Cm(){return Ko(Zo.getInstance().active())}function $m(t,e){return t.setValue(As,e)}function jm(t){return t.deleteValue(As)}var In="propagation",Rm=new xm,Mm=function(){function t(){this.createBaggage=mm,this.getBaggage=Ko,this.getActiveBaggage=Cm,this.setBaggage=$m,this.deleteBaggage=jm}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Is(In,e,jt.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Tm),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Om),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ks(In,jt.instance())},t.prototype._getGlobalPropagator=function(){return $t(In)||Rm},t}(),Dm=Mm.getInstance();const $i=["bench","debug","prod"],Pm=t=>e=>$i.indexOf(e)>=$i.indexOf(t),Jn=class Jo{constructor(e,r=Pm("debug")){H(this,"meta",Es.NOOP),H(this,"tracer"),H(this,"filter"),this.tracer=e,this.filter=r}child(e){const r=new Jo(this.tracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){return this.meta.noop||!this.filter(r)?n(new Qo(e)):this.tracer.startActiveSpan(e,i=>{const a=new Xo(e,i),o=n(a);return i.end(),o})}propagate(e){if(this.meta.noop)return;const r=Am.active();Dm.inject(r,e,{set:(n,i,a)=>{n[i]=a}})}};H(Jn,"NOOP",new Jn);let Ho=Jn;class Xo{constructor(e,r){H(this,"key"),H(this,"otel"),this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Kn.ERROR}))}}class Qo{constructor(e){H(this,"key"),this.key=e}set(){}recordError(e){}}const Hn=class ec{constructor({key:e="",serviceName:r="",logger:n=Go.NOOP,tracer:i=Ho.NOOP,noop:a=!1,__meta:o}){H(this,"meta"),H(this,"T"),H(this,"L"),this.meta=o??new Es(e,e,r,a),this.T=i.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new ec({__meta:r,tracer:this.T,logger:this.L})}};H(Hn,"NOOP",new Hn({noop:!0}));let xs=Hn;const Bm=xs.NOOP,tc=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:xs,LOG_LEVELS:Gn,Logger:Go,NOOP:Bm,NoopSpan:Qo,Tracer:Ho,_Span:Xo,logLevelKeyFiler:rm,logThresholdFilter:tm},Symbol.toStringTag,{value:"Module"})),Um=new Error("request for lock canceled");var Lm=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class Ym{constructor(e,r=Um){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,i)=>{const a={resolve:n,reject:i,weight:e,priority:r},o=rc(this._queue,l=>r<=l.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Lm(this,arguments,void 0,function*(r,n=1,i=0){const[a,o]=yield this.acquire(n,i);try{return yield r(a)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),qm(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const i=n.findIndex(a=>a.priority<=e);(i===-1?n:n.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function qm(t,e){const r=rc(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function rc(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var _m=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{d(n.next(f))}catch(h){o(h)}}function u(f){try{d(n.throw(f))}catch(h){o(h)}}function d(f){f.done?a(f.value):i(f.value).then(l,u)}d((n=n.apply(t,e||[])).next())})};class nc{constructor(e){this._semaphore=new Ym(1,e)}acquire(){return _m(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class Qr{constructor(e,r,n=new Map){P(this,"providers");P(this,"registry");P(this,"sender");P(this,"changedKeys");this.providers=n,this.registry=r,this.changedKeys=[],this.sender=e}propagateState(e,r,n=[]){this.sender.send({key:e,state:r},n)}copyAndMerge(e){const r=new Qr(this.sender,this.registry,new Map);return e==null||e.providers.forEach((n,i)=>r.providers.set(i,n)),this.providers.forEach((n,i)=>r.providers.set(i,n)),r.changedKeys=[],r}get changed(){return this.changedKeys.length>0}set(e,r,n=!0){this.providers.set(e,r),n&&this.changedKeys.push(e)}setIfNotHas(e,r){this.providers.has(e)||this.set(e,r)}async create(e){const r=this.registry[e.type];if(r==null)throw new Error(`[AetherRoot.create] - could not find component ${e.type}`);const n=new r(e);return await n.internalUpdate(e),n}getOptional(e){return this.providers.get(e)??null}has(e){return this.providers.has(e)}get(e){const r=this.getOptional(e);if(r==null)throw new Error(`[AetherRoot.get] - could not find provider ${e}`);return r}}class Cs{constructor(e){P(this,"type");P(this,"key");P(this,"_ctx");P(this,"_internalState");P(this,"_state");P(this,"_prevState");P(this,"_deleted",!1);P(this,"instrumentation");P(this,"schema");this.type=e.type,this.key=e.path[0],this._ctx=e.ctx,this._internalState={},this.instrumentation=e.instrumentation.child(`${this.type}(${this.key})`)}get _schema(){if(this.schema==null)throw new G(`[AetherLeaf] - expected subclass to define component schema, but none was found.
|
|
57
|
-
Make sure to defne a property 'schema' on the class.`);return this.schema}setState(e){const r=ts(e,this._state);this._prevState={...this._state},this._state=Wn(this._schema,r,`${this.type}:${this.key}`),this.ctx.propagateState(this.key,r)}get ctx(){if(this._ctx==null)throw new me("context not defined");return this._ctx}get state(){if(this._state==null)throw new me("state not defined");return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}async internalUpdate({variant:e,path:r,ctx:n,state:i}){if(!this.deleted){if(this._ctx=n,e==="state"){this.validatePath(r);const a=Wn(this._schema,i,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:Li.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:i}),this._prevState=this._state??a,this._state=a}else this.instrumentation.L.debug("updating context");await this.afterUpdate()}}async internalDelete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete()}beforeUpdate(){}async afterUpdate(){}async afterDelete(){}validatePath(e){if(e.length===0)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new me(`[Leaf.setState] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`)}}class _t extends Cs{constructor(r){super(r);P(this,"_children");this._children=new Map}get children(){return Array.from(this._children.values())}async internalUpdate(r){const{variant:n,path:i}=r;if(n==="context")return this._ctx=r.ctx.copyAndMerge(this._ctx),await this.updateContext({...r,ctx:this.ctx});const[a,o]=this.getRequiredKey(i),l={...r,ctx:this.ctx};return o.length===0?await this.updateThis(a,l):await this.updateChild(o,l)}async updateContext(r){await super.internalUpdate(r);for(const n of this.children)await n.internalUpdate({...r,ctx:this.ctx,variant:"context"})}async updateChild(r,n){const i=r[0],a=this.getChild(i);if(a!=null)return await a.internalUpdate({...n,path:r});if(r.length>1)throw new Error(`[Composite.setState] - ${this.type}:${this.key} could not find child with key ${i} while updating `);this._children.set(i,await n.ctx.create({...n,path:r}))}async updateThis(r,n){const i=n.ctx.copyAndMerge(this._ctx);if(r!==this.key)throw new me(`[Composite.update] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);if(await super.internalUpdate({...n,ctx:i}),!!i.changed){this.instrumentation.L.debug("context changed",{changedKeys:i.changedKeys});for(const a of this.children)await a.internalUpdate({...n,ctx:this.ctx,variant:"context"})}}async internalDelete(r){const[n,i]=this.getRequiredKey(r);if(i.length===0){if(n!==this.key)throw new Error(`[Composite.delete] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`);const o=this.children;this._children=new Map;for(const l of o)await l.internalDelete([l.key]);await super.internalDelete([this.key])}const a=this.getChild(i[0]);a!=null&&(i.length>1?await a.internalDelete(i):(this._children.delete(a.key),await a.internalDelete(i)))}getRequiredKey(r,n){const[i,...a]=r;if(i==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path`+(n!=null?` for ${n}`:""));return[i,a]}getChild(r){return this._children.get(r)??null}childrenOfType(...r){return this.children.filter(n=>r.includes(n.type))}}const Fm=s.z.object({}),Ie=class Ie extends _t{constructor({worker:r,registry:n,instrumentation:i=tc.Instrumentation.NOOP}){const o={ctx:new Qr(r,n,new Map),...Ie.ZERO_UPDATE,instrumentation:i};super(o);P(this,"wrap");P(this,"schema",Ie.schema);P(this,"mu",new nc);this.mu.runExclusive(async()=>await this.internalUpdate(o)),this.wrap=r,this.wrap.handle(l=>{this.mu.runExclusive(async()=>await this.handle(l))})}async handle(r){if(r.variant==="delete")await this.internalDelete(r.path);else{const n={...r,variant:"state",ctx:this.ctx,instrumentation:this.instrumentation};await this.internalUpdate(n)}}};P(Ie,"TYPE","root"),P(Ie,"KEY","root"),P(Ie,"ZERO_UPDATE",{path:[Ie.KEY],type:Ie.TYPE,variant:"state",state:{}}),P(Ie,"schema",Fm);let Pr=Ie;const sc=t=>new Pr(t),Wm=Object.freeze(Object.defineProperty({__proto__:null,Composite:_t,Context:Qr,Leaf:Cs,Root:Pr,render:sc},Symbol.toStringTag,{value:"Module"})),ic="pluto-theming-context",Vm=s.z.object({theme:sa}),Et=class Et extends _t{constructor(){super(...arguments);P(this,"schema",Et.z)}async afterUpdate(){this.ctx.set(ic,this.state.theme)}};P(Et,"TYPE","theming.Provider"),P(Et,"z",Vm);let Rt=Et;const Gm=t=>t.get(ic),Zm={[Rt.TYPE]:Rt},ac=["success","error","warning","info","loading","disabled","secondary"],oc=s.z.enum(ac),cc=s.z.object({key:s.z.string(),variant:oc,message:s.z.string(),description:s.z.string().optional(),time:F.z,data:s.z.record(s.z.unknown()).optional()}),lc=s.z.object({statuses:cc.array()}),$s="status.aggregator";class Br extends _t{constructor(){super(...arguments);P(this,"schema",lc)}async afterUpdate(){this.ctx.set($s,this)}add(r){const n=F.now();this.setState(i=>({...i,statuses:[...i.statuses,{time:n,key:n.toString(),...r}]}))}}P(Br,"TYPE","status.Aggregator");const Km=t=>{const e=t.get($s);return e.add.bind(e)},Jm=t=>{const e=t.getOptional($s);return e!=null?e.add.bind(e):()=>{}},Hm={[Br.TYPE]:Br};exports.$=Vc;exports.A=il;exports.Aggregator=Br;exports.Ay=Fo;exports.B=Al;exports.B$1=xs;exports.C=Lr;exports.C$1=Sl;exports.ComponentSizeLevels=na;exports.Composite=_t;exports.H=xl;exports.I=ce;exports.Id=Xp;exports.Jy=zf;exports.LEVELS=ra;exports.Leaf=Cs;exports.LevelComponentSizes=Rl;exports.Mutex=nc;exports.N=k;exports.N$1=Fi;exports.P=G;exports.Provider=Rt;exports.REGISTRY=Zm;exports.REGISTRY$1=Hm;exports.S=Oc;exports.S$1=E;exports.SYNNAX_DARK=aa;exports.SYNNAX_LIGHT=ia;exports.SYNNAX_THEMES=_l;exports.Se=me;exports.U=It;exports.V=ne;exports.VARIANTS=ac;exports.W=kl;exports._=Li;exports._$1=Ol;exports.aether=Wm;exports.aggregatorStateZ=lc;exports.bd=Gg;exports.c=Bi;exports.commonjsGlobal=fc;exports.d=M;exports.dimensions=Dl;exports.ee=be;exports.executeInitialSetter=Dt;exports.executeSetter=ts;exports.fontString=Gl;exports.g=tc;exports.getAugmentedNamespace=gc;exports.getDefaultExportFromCjs=yc;exports.isSetter=es;exports.ky=_o;exports.l=yl;exports.levelZ=jl;exports.m=F;exports.mt=Wc;exports.n=ol;exports.o=al;exports.o$1=xc;exports.prettyParse=Wn;exports.r=Cc;exports.render=sc;exports.sd=gy;exports.specZ=Me;exports.specZ$1=cc;exports.state=$l;exports.themeZ=sa;exports.u=Qn;exports.use=Gm;exports.useAggregate=Km;exports.useOptionalAggregate=Jm;exports.usePassthrough=ea;exports.usePurePassthrough=ta;exports.variantZ=oc;exports.w=V;exports.w$1=Gi;exports.wt=Gc;exports.y=Ac;exports.yt=Qc;
|