@synnaxlabs/client 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -6
- package/dist/client.cjs +11 -11
- package/dist/client.js +328 -344
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/hardware/task/client.ts +3 -3
package/dist/client.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ni=Object.defineProperty;var Ai=(r,e,t)=>e in r?Ni(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>(Ai(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("zod");var te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},O={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0});function Ii(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Kt.default=Ii;var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});function ki(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Vt.default=ki;var Ft={};Object.defineProperty(Ft,"__esModule",{value:!0});function $i(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}Ft.default=$i;var Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});function Ci(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Qr.default=Ci;var en={};Object.defineProperty(en,"__esModule",{value:!0});function Ri(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}en.default=Ri;var tn={};Object.defineProperty(tn,"__esModule",{value:!0});function ji(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}tn.default=ji;var rn={};Object.defineProperty(rn,"__esModule",{value:!0});function xi(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,a){return n+"_"+a.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}rn.default=xi;var nn={};Object.defineProperty(nn,"__esModule",{value:!0});function Di(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,a){return t+n.charAt(0).toUpperCase()+n.slice(1)+a}):""}nn.default=Di;var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0});function Pi(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Jt.default=Pi;var sn={},Ze={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Ze);var Zi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(sn,"__esModule",{value:!0});var ue=Ze;function Tt(r,e){if(e===void 0&&(e=ue.DefaultOption),!ue.isValidObject(r))return null;e=ue.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toLowerCase();e.recursive&&(ue.isValidObject(a)?ue.belongToTypes(a,e.keepTypesOnRecursion)||(a=Tt(a,e)):e.recursiveInArray&&ue.isArrayObject(a)&&(a=Zi(a).map(function(o){var l=o;if(ue.isValidObject(o))ue.belongToTypes(l,e.keepTypesOnRecursion)||(l=Tt(o,e));else if(ue.isArrayObject(o)){var u=Tt({key:o},e);l=u.key}return l}))),t[i]=a}),t}sn.default=Tt;var an={},Mi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(an,"__esModule",{value:!0});var he=Ze;function zt(r,e){if(e===void 0&&(e=he.DefaultOption),!he.isValidObject(r))return null;e=he.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toUpperCase();e.recursive&&(he.isValidObject(a)?he.belongToTypes(a,e.keepTypesOnRecursion)||(a=zt(a,e)):e.recursiveInArray&&he.isArrayObject(a)&&(a=Mi(a).map(function(o){var l=o;if(he.isValidObject(o))he.belongToTypes(l,e.keepTypesOnRecursion)||(l=zt(o,e));else if(he.isArrayObject(o)){var u=zt({key:o},e);l=u.key}return l}))),t[i]=a}),t}an.default=zt;var on={},_i=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(on,"__esModule",{value:!0});var fe=Ze,Ui=Kt;function Et(r,e){if(e===void 0&&(e=fe.DefaultOption),!fe.isValidObject(r))return null;e=fe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Ui.default(n);e.recursive&&(fe.isValidObject(a)?fe.belongToTypes(a,e.keepTypesOnRecursion)||(a=Et(a,e)):e.recursiveInArray&&fe.isArrayObject(a)&&(a=_i(a).map(function(o){var l=o;if(fe.isValidObject(o))fe.belongToTypes(l,e.keepTypesOnRecursion)||(l=Et(o,e));else if(fe.isArrayObject(o)){var u=Et({key:o},e);l=u.key}return l}))),t[i]=a}),t}on.default=Et;var cn={},Li=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(cn,"__esModule",{value:!0});var de=Ze,Bi=Vt;function St(r,e){if(e===void 0&&(e=de.DefaultOption),!de.isValidObject(r))return null;e=de.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Bi.default(n);e.recursive&&(de.isValidObject(a)?de.belongToTypes(a,e.keepTypesOnRecursion)||(a=St(a,e)):e.recursiveInArray&&de.isArrayObject(a)&&(a=Li(a).map(function(o){var l=o;if(de.isValidObject(o))de.belongToTypes(l,e.keepTypesOnRecursion)||(l=St(o,e));else if(de.isArrayObject(o)){var u=St({key:o},e);l=u.key}return l}))),t[i]=a}),t}cn.default=St;var ln={},qi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(ln,"__esModule",{value:!0});var ye=Ze,Yi=Ft;function Nt(r,e){if(e===void 0&&(e=ye.DefaultOption),!ye.isValidObject(r))return null;e=ye.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Yi.default(n);e.recursive&&(ye.isValidObject(a)?ye.belongToTypes(a,e.keepTypesOnRecursion)||(a=Nt(a,e)):e.recursiveInArray&&ye.isArrayObject(a)&&(a=qi(a).map(function(o){var l=o;if(ye.isValidObject(o))ye.belongToTypes(l,e.keepTypesOnRecursion)||(l=Nt(o,e));else if(ye.isArrayObject(o)){var u=Nt({key:o},e);l=u.key}return l}))),t[i]=a}),t}ln.default=Nt;var un={},Wi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(un,"__esModule",{value:!0});var pe=Ze,Ki=Jt;function At(r,e){if(e===void 0&&(e=pe.DefaultOption),!pe.isValidObject(r))return null;e=pe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Ki.default(n);e.recursive&&(pe.isValidObject(a)?pe.belongToTypes(a,e.keepTypesOnRecursion)||(a=At(a,e)):e.recursiveInArray&&pe.isArrayObject(a)&&(a=Wi(a).map(function(o){var l=o;if(pe.isValidObject(o))pe.belongToTypes(l,e.keepTypesOnRecursion)||(l=At(o,e));else if(pe.isArrayObject(o)){var u=At({key:o},e);l=u.key}return l}))),t[i]=a}),t}un.default=At;Object.defineProperty(O,"__esModule",{value:!0});O.kebabKeys=O.pascalKeys=O.snakeKeys=O.camelKeys=O.upperKeys=O.lowerKeys=O.toLowerCase=O.toUpperCase=O.toKebabCase=O.toHeaderCase=O.toSentenceCase=O.toTextCase=O.toPathCase=O.toDotCase=O.toPascalCase=O.toSnakeCase=O.toCamelCase=void 0;var hs=Kt;O.toCamelCase=hs.default;var fs=Vt;O.toSnakeCase=fs.default;var ds=Ft;O.toPascalCase=ds.default;var ys=Qr;O.toDotCase=ys.default;var ps=en;O.toPathCase=ps.default;var gs=tn;O.toTextCase=gs.default;var ms=rn;O.toSentenceCase=ms.default;var ws=nn;O.toHeaderCase=ws.default;var vs=Jt;O.toKebabCase=vs.default;var bs=sn;O.lowerKeys=bs.default;var Os=an;O.upperKeys=Os.default;var Ts=on;O.camelKeys=Ts.default;var zs=cn;O.snakeKeys=zs.default;var Es=ln;O.pascalKeys=Es.default;var Ss=un;O.kebabKeys=Ss.default;var Ns=function(r){return String(r||"").toLowerCase()};O.toLowerCase=Ns;var As=function(r){return String(r||"").toUpperCase()};O.toUpperCase=As;var Vi={toCamelCase:hs.default,toSnakeCase:fs.default,toPascalCase:ds.default,toDotCase:ys.default,toPathCase:ps.default,toTextCase:gs.default,toSentenceCase:ms.default,toHeaderCase:ws.default,toKebabCase:vs.default,toUpperCase:As,toLowerCase:Ns,lowerKeys:bs.default,upperKeys:Os.default,camelKeys:Ts.default,snakeKeys:zs.default,pascalKeys:Es.default,kebabKeys:Ss.default};O.default=Vi;var Is=O;const ks={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Fi=r=>Is.snakeKeys(r,ks),Mt=r=>Is.camelKeys(r,ks),Ji=r=>r!=null&&typeof r=="object"&&"toString"in r,Gi=(r,e=!1)=>{const t=Ji(r)?"stringer":typeof r;let n;switch(t){case"string":n=(a,i)=>a.localeCompare(i);break;case"stringer":n=(a,i)=>a.toString().localeCompare(i.toString());break;case"number":n=(a,i)=>Number(a)-Number(i);break;case"bigint":n=(a,i)=>BigInt(a)-BigInt(i)>0n?1:-1;break;case"boolean":n=(a,i)=>Number(a)-Number(i);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?Hi(n):n},Hi=r=>(e,t)=>r(t,e),Gt=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const $s=s.z.object({width:s.z.number(),height:s.z.number()}),Xi=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Qi=["width","height"];s.z.enum(Qi);const eo=["start","center","end"],to=["signedWidth","signedHeight"];s.z.enum(to);const _t=s.z.object({x:s.z.number(),y:s.z.number()}),ro=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),no=["x","y"],Cs=s.z.enum(no),Rs=["top","right","bottom","left"];s.z.enum(Rs);const so=["left","right"],js=s.z.enum(so),ao=["top","bottom"],xs=s.z.enum(ao),Ds=["center"],Mn=s.z.enum(Ds),io=[...Rs,...Ds],Ps=s.z.enum(io);s.z.enum(eo);const oo=["first","last"];s.z.enum(oo);const co=s.z.object({lower:s.z.number(),upper:s.z.number()}),lo=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([co,Gt]);s.z.union([lo,Gt]);s.z.union([Cs,Ps]);s.z.union([Cs,Ps,s.z.instanceof(String)]);const at=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return _n(r);return _n(t)},_n=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;s.z.object({x:js.or(Mn),y:xs.or(Mn)});const uo=s.z.object({x:js,y:xs}),ho=Object.freeze({x:"left",y:"top"}),fo=(r,e)=>r.x===e.x&&r.y===e.y,Un=s.z.union([s.z.number(),_t,Gt,$s,Xi,ro]),yo=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Ln=Object.freeze({x:0,y:0}),vt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:vt,left:vt,width:vt,height:vt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:_t,two:_t,root:uo});const hn=(r,e,t=0,n=0,a)=>{const i={one:{...Ln},two:{...Ln},root:a??ho};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:r,y:e},i.two={x:i.one.x+t,y:i.one.y+n},i}return"one"in r&&"two"in r&&"root"in r?{...r,root:a??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(i.one={x:r.left,y:r.top},i.two={x:r.right,y:r.bottom},i):(i.one=r,e==null?i.two={x:i.one.x+t,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},mr=r=>{const e=hn(r);return{lower:e.one.x,upper:e.two.x}},wr=r=>{const e=hn(r);return{lower:e.one.y,upper:e.two.y}},po=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,go=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([$s,go,_t,Gt]);var mo=Object.defineProperty,wo=(r,e,t)=>e in r?mo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ee=(r,e,t)=>(wo(r,typeof e!="symbol"?e+"":e,t),t);const vo=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);s.z.object({offset:Un,scale:Un});const bo=r=>(e,t,n,a)=>t==="dimension"?[e,n]:[e,a?n-r:n+r],Oo=r=>(e,t,n,a)=>[e,a?n/r:n*r],To=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=r,u=i-a,p=l-o;if(t==="dimension")return[r,n*(p/u)];const g=(n-a)*(p/u)+o;return[r,g]},zo=r=>(e,t,n)=>[r,n],Eo=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:a}=r;return[r,a-(t-n)]},So=r=>(e,t,n)=>{const{lower:a,upper:i}=r;return n=vo(n,a,i),[e,n]},Mr=class Qe{constructor(){Ee(this,"ops",[]),Ee(this,"currBounds",null),Ee(this,"currType",null),Ee(this,"reversed",!1),this.ops=[]}static translate(e){return new Qe().translate(e)}static magnify(e){return new Qe().magnify(e)}static scale(e,t){return new Qe().scale(e,t)}translate(e){const t=this.new(),n=bo(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Oo(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=at(e,t),a=this.new(),i=To(n);return i.type="scale",a.ops.push(i),a}clamp(e,t){const n=at(e,t),a=this.new(),i=So(n);return i.type="clamp",a.ops.push(i),a}reBound(e,t){const n=at(e,t),a=this.new(),i=zo(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Eo();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Qe;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||t.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&t.push([a,i])}),t.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}};Ee(Mr,"IDENTITY",new Mr);let Bn=Mr;const qn=class Te{constructor(e=new Bn,t=new Bn,n=null){Ee(this,"x"),Ee(this,"y"),Ee(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Te().translate(e,t)}static translateX(e){return new Te().translateX(e)}static translateY(e){return new Te().translateY(e)}static clamp(e){return new Te().clamp(e)}static magnify(e){return new Te().magnify(e)}static scale(e){return new Te().scale(e)}static reBound(e){return new Te().reBound(e)}translate(e,t){const n=yo(e,t),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(po(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!fo(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(mr(e)),t.y=t.y.scale(wr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(mr(e)),t.y=this.y.reBound(wr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(mr(e)),t.y=this.y.clamp(wr(e)),t}copy(){const e=new Te;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 hn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ee(qn,"IDENTITY",new qn);var No=Object.defineProperty,Ao=(r,e,t)=>e in r?No(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e,t)=>(Ao(r,typeof e!="symbol"?e+"":e,t),t);let Io="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ko=(r=21)=>{let e="",t=r;for(;t--;)e+=Io[Math.random()*64|0];return e};const Zs=(r,e)=>{const t=new E(e);if(![N.DAY,N.HOUR,N.MINUTE,N.SECOND,N.MILLISECOND,N.MICROSECOND,N.NANOSECOND].some(a=>a.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof E?new E(n):new N(n)},k=class v{constructor(e,t="UTC"){if(d(this,"value"),d(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const a=new Date(e,t-1,n,0,0,0,0);return new v(BigInt(a.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let u=v.hours(parseInt(n??"00",10)).add(v.minutes(parseInt(a??"00",10))).add(v.seconds(parseInt(o??"00",10))).add(v.milliseconds(parseInt(l??"00",10)));return t==="local"&&(u=u.add(v.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new v(BigInt(n.getTime())*v.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new N(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new J(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 v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Zs(this,e)}get isToday(){return this.truncate(N.DAY).equals(v.now().truncate(N.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let t=v.MIN;for(const n of e){const a=new v(n);a.after(t)&&(t=a)}return t}static min(...e){let t=v.MAX;for(const n of e){const a=new v(n);a.before(t)&&(t=a)}return t}static nanoseconds(e){return new v(e)}static microseconds(e){return v.nanoseconds(e*1e3)}static milliseconds(e){return v.microseconds(e*1e3)}static seconds(e){return v.milliseconds(e*1e3)}static minutes(e){return v.seconds(e*60)}static hours(e){return v.minutes(e*60)}static days(e){return v.hours(e*24)}};d(k,"NANOSECOND",k.nanoseconds(1)),d(k,"MICROSECOND",k.microseconds(1)),d(k,"MILLISECOND",k.milliseconds(1)),d(k,"SECOND",k.seconds(1)),d(k,"MINUTE",k.minutes(1)),d(k,"HOUR",k.hours(1)),d(k,"DAY",k.days(1)),d(k,"MAX",new k((1n<<63n)-1n)),d(k,"MIN",new k(0)),d(k,"ZERO",new k(0)),d(k,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new k(r.value)),s.z.string().transform(r=>new k(BigInt(r))),s.z.instanceof(Number).transform(r=>new k(r)),s.z.number().transform(r=>new k(r)),s.z.instanceof(k)]));let E=k;const $=class A{constructor(e){d(this,"value"),d(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 Zs(this,e)}truncate(e){return new A(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(A.DAY),t=this.truncate(A.HOUR),n=this.truncate(A.MINUTE),a=this.truncate(A.SECOND),i=this.truncate(A.MILLISECOND),o=this.truncate(A.MICROSECOND),l=this.truncate(A.NANOSECOND),u=e,p=t.sub(e),g=n.sub(t),y=a.sub(n),U=i.sub(a),x=o.sub(i),Q=l.sub(o);let P="";return u.isZero||(P+=`${u.days}d `),p.isZero||(P+=`${p.hours}h `),g.isZero||(P+=`${g.minutes}m `),y.isZero||(P+=`${y.seconds}s `),U.isZero||(P+=`${U.milliseconds}ms `),x.isZero||(P+=`${x.microseconds}µs `),Q.isZero||(P+=`${Q.nanoseconds}ns`),P.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)}};d($,"NANOSECOND",$.nanoseconds(1)),d($,"MICROSECOND",$.microseconds(1)),d($,"MILLISECOND",$.milliseconds(1)),d($,"SECOND",$.seconds(1)),d($,"MINUTE",$.minutes(1)),d($,"HOUR",$.hours(1)),d($,"DAY",$.days(1)),d($,"MAX",new $((1n<<63n)-1n)),d($,"MIN",new $(0)),d($,"ZERO",new $(0)),d($,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new $(r.value)),s.z.string().transform(r=>new $(BigInt(r))),s.z.instanceof(Number).transform(r=>new $(r)),s.z.number().transform(r=>new $(r)),s.z.instanceof($)]));let N=$;const et=class It extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new It(e).valueOf()}get period(){return N.seconds(1/this.valueOf())}sampleCount(e){return new N(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new V(t).valueOf()}span(e){return N.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new It(e)}static khz(e){return It.hz(e*1e3)}};d(et,"z",s.z.union([s.z.number().transform(r=>new et(r)),s.z.instanceof(Number).transform(r=>new et(r)),s.z.instanceof(et)]));let Ht=et;const L=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new ot(e*this.valueOf())}};d(L,"UNKNOWN",new L(0)),d(L,"BIT128",new L(16)),d(L,"BIT64",new L(8)),d(L,"BIT32",new L(4)),d(L,"BIT16",new L(2)),d(L,"BIT8",new L(1)),d(L,"z",s.z.union([s.z.number().transform(r=>new L(r)),s.z.instanceof(Number).transform(r=>new L(r)),s.z.instanceof(L)]));let V=L;const se=class kt{constructor(e,t){d(this,"start"),d(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(t))}get span(){return new N(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}swap(){return new kt(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,t=N.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 a=E.max(n.start,e.start),i=E.min(n.end,e.end);return i.before(a)?!1:new N(i.sub(a)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=t.valueOf()&&a<=t.valueOf()}contains(e){return e instanceof kt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new kt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};d(se,"MAX",new se(E.MIN,E.MAX)),d(se,"MIN",new se(E.MAX,E.MIN)),d(se,"ZERO",new se(E.ZERO,E.ZERO)),d(se,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(r=>new se(r.start,r.end)),s.z.instanceof(se)]));let J=se;const h=class ae extends String{constructor(e){if(e instanceof ae||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=ae.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(ae.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ae.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()}toString(){return this.valueOf()}get isVariable(){return this.equals(ae.JSON)||this.equals(ae.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ae.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ae.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 ae.BIG_INT_TYPES.some(e=>e.equals(this))}};d(h,"UNKNOWN",new h("unknown")),d(h,"FLOAT64",new h("float64")),d(h,"FLOAT32",new h("float32")),d(h,"INT64",new h("int64")),d(h,"INT32",new h("int32")),d(h,"INT16",new h("int16")),d(h,"INT8",new h("int8")),d(h,"UINT64",new h("uint64")),d(h,"UINT32",new h("uint32")),d(h,"UINT16",new h("uint16")),d(h,"UINT8",new h("uint8")),d(h,"BOOLEAN",h.UINT8),d(h,"TIMESTAMP",new h("timestamp")),d(h,"UUID",new h("uuid")),d(h,"STRING",new h("string")),d(h,"JSON",new h("json")),d(h,"ARRAY_CONSTRUCTORS",new Map([[h.UINT8.toString(),Uint8Array],[h.UINT16.toString(),Uint16Array],[h.UINT32.toString(),Uint32Array],[h.UINT64.toString(),BigUint64Array],[h.FLOAT32.toString(),Float32Array],[h.FLOAT64.toString(),Float64Array],[h.INT8.toString(),Int8Array],[h.INT16.toString(),Int16Array],[h.INT32.toString(),Int32Array],[h.INT64.toString(),BigInt64Array],[h.TIMESTAMP.toString(),BigInt64Array],[h.STRING.toString(),Uint8Array],[h.JSON.toString(),Uint8Array],[h.UUID.toString(),Uint8Array]])),d(h,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,h.UINT8],[Uint16Array.name,h.UINT16],[Uint32Array.name,h.UINT32],[BigUint64Array.name,h.UINT64],[Float32Array.name,h.FLOAT32],[Float64Array.name,h.FLOAT64],[Int8Array.name,h.INT8],[Int16Array.name,h.INT16],[Int32Array.name,h.INT32],[BigInt64Array.name,h.INT64]])),d(h,"DENSITIES",new Map([[h.UINT8.toString(),V.BIT8],[h.UINT16.toString(),V.BIT16],[h.UINT32.toString(),V.BIT32],[h.UINT64.toString(),V.BIT64],[h.FLOAT32.toString(),V.BIT32],[h.FLOAT64.toString(),V.BIT64],[h.INT8.toString(),V.BIT8],[h.INT16.toString(),V.BIT16],[h.INT32.toString(),V.BIT32],[h.INT64.toString(),V.BIT64],[h.TIMESTAMP.toString(),V.BIT64],[h.STRING.toString(),V.UNKNOWN],[h.JSON.toString(),V.UNKNOWN],[h.UUID.toString(),V.BIT128]])),d(h,"ALL",[h.UNKNOWN,h.FLOAT64,h.FLOAT32,h.INT64,h.INT32,h.INT16,h.INT8,h.UINT64,h.UINT32,h.UINT16,h.UINT8,h.TIMESTAMP,h.UUID,h.STRING,h.JSON]),d(h,"BIG_INT_TYPES",[h.INT64,h.UINT64,h.TIMESTAMP]),d(h,"z",s.z.union([s.z.string().transform(r=>new h(r)),s.z.instanceof(h)]));let S=h;const W=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),t=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),a=this.truncate(Z.KILOBYTE),i=this.truncate(Z.BYTE),o=e,l=t.sub(e),u=n.sub(t),p=a.sub(n),g=i.sub(a);let y="";return o.isZero||(y+=`${o.terabytes}TB `),l.isZero||(y+=`${l.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),p.isZero||(y+=`${p.kilobytes}KB `),(!g.isZero||y==="")&&(y+=`${g.valueOf()}B`),y.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}};d(W,"BYTE",new W(1)),d(W,"KILOBYTE",W.kilobytes(1)),d(W,"MEGABYTE",W.megabytes(1)),d(W,"GIGABYTE",W.gigabytes(1)),d(W,"TERABYTE",W.terabytes(1)),d(W,"ZERO",new W(0)),d(W,"z",s.z.union([s.z.number().transform(r=>new W(r)),s.z.instanceof(W)]));let ot=W;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 Ms=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof E||r instanceof N||r instanceof Date},$o=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):tt(t,-n),Co=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof F?!0:Ms(r),Re=-1;class F{constructor(e){d(this,"key",""),d(this,"isSynnaxSeries",!0),d(this,"dataType"),d(this,"sampleOffset"),d(this,"gl"),d(this,"_data"),d(this,"_timeRange"),d(this,"alignment",0n),d(this,"_cachedMin"),d(this,"_cachedMax"),d(this,"writePos",Re),d(this,"_refCount",0),d(this,"_cachedLength"),Co(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:a=0,glBufferUsage:i="static",alignment:o=0n,key:l=ko()}=e,{data:u}=e;if(u instanceof F||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const y=u;this.key=y.key,this.dataType=y.dataType,this.sampleOffset=y.sampleOffset,this.gl=y.gl,this._data=y._data,this._timeRange=y._timeRange,this.alignment=y.alignment,this._cachedMin=y._cachedMin,this._cachedMax=y._cachedMax,this.writePos=y.writePos,this._refCount=y._refCount,this._cachedLength=y._cachedLength;return}const p=Ms(u),g=Array.isArray(u);if(t!=null)this.dataType=new S(t);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(g||p){let y=u;if(!p){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.");y=u[0]}if(typeof y=="string")this.dataType=S.STRING;else if(typeof y=="number")this.dataType=S.FLOAT64;else if(typeof y=="bigint")this.dataType=S.INT64;else if(typeof y=="boolean")this.dataType=S.BOOLEAN;else if(y instanceof E||y instanceof Date||y instanceof E)this.dataType=S.TIMESTAMP;else if(typeof y=="object")this.dataType=S.JSON;else throw new Error(`cannot infer data type of ${typeof y} when constructing a Series from a JS array`)}else this.dataType=new S(u)}if(!g&&!p)this._data=u;else{let y=p?[u]:u;const U=y[0];(U instanceof E||U instanceof Date||U instanceof N)&&(y=y.map(x=>new E(x).valueOf())),this.dataType.equals(S.STRING)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(y.join(`
|
|
1
|
+
"use strict";var Ni=Object.defineProperty;var Ai=(r,e,t)=>e in r?Ni(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>(Ai(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("zod");var te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},O={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0});function Ii(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Kt.default=Ii;var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});function ki(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Vt.default=ki;var Ft={};Object.defineProperty(Ft,"__esModule",{value:!0});function $i(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}Ft.default=$i;var Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});function Ci(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Qr.default=Ci;var en={};Object.defineProperty(en,"__esModule",{value:!0});function Ri(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}en.default=Ri;var tn={};Object.defineProperty(tn,"__esModule",{value:!0});function ji(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}tn.default=ji;var rn={};Object.defineProperty(rn,"__esModule",{value:!0});function xi(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,a){return n+"_"+a.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}rn.default=xi;var nn={};Object.defineProperty(nn,"__esModule",{value:!0});function Pi(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,a){return t+n.charAt(0).toUpperCase()+n.slice(1)+a}):""}nn.default=Pi;var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0});function Di(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Jt.default=Di;var sn={},Ze={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Ze);var Zi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(sn,"__esModule",{value:!0});var ue=Ze;function Tt(r,e){if(e===void 0&&(e=ue.DefaultOption),!ue.isValidObject(r))return null;e=ue.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toLowerCase();e.recursive&&(ue.isValidObject(a)?ue.belongToTypes(a,e.keepTypesOnRecursion)||(a=Tt(a,e)):e.recursiveInArray&&ue.isArrayObject(a)&&(a=Zi(a).map(function(o){var l=o;if(ue.isValidObject(o))ue.belongToTypes(l,e.keepTypesOnRecursion)||(l=Tt(o,e));else if(ue.isArrayObject(o)){var u=Tt({key:o},e);l=u.key}return l}))),t[i]=a}),t}sn.default=Tt;var an={},Mi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(an,"__esModule",{value:!0});var he=Ze;function zt(r,e){if(e===void 0&&(e=he.DefaultOption),!he.isValidObject(r))return null;e=he.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toUpperCase();e.recursive&&(he.isValidObject(a)?he.belongToTypes(a,e.keepTypesOnRecursion)||(a=zt(a,e)):e.recursiveInArray&&he.isArrayObject(a)&&(a=Mi(a).map(function(o){var l=o;if(he.isValidObject(o))he.belongToTypes(l,e.keepTypesOnRecursion)||(l=zt(o,e));else if(he.isArrayObject(o)){var u=zt({key:o},e);l=u.key}return l}))),t[i]=a}),t}an.default=zt;var on={},_i=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(on,"__esModule",{value:!0});var fe=Ze,Ui=Kt;function Et(r,e){if(e===void 0&&(e=fe.DefaultOption),!fe.isValidObject(r))return null;e=fe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Ui.default(n);e.recursive&&(fe.isValidObject(a)?fe.belongToTypes(a,e.keepTypesOnRecursion)||(a=Et(a,e)):e.recursiveInArray&&fe.isArrayObject(a)&&(a=_i(a).map(function(o){var l=o;if(fe.isValidObject(o))fe.belongToTypes(l,e.keepTypesOnRecursion)||(l=Et(o,e));else if(fe.isArrayObject(o)){var u=Et({key:o},e);l=u.key}return l}))),t[i]=a}),t}on.default=Et;var cn={},Li=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(cn,"__esModule",{value:!0});var de=Ze,Bi=Vt;function St(r,e){if(e===void 0&&(e=de.DefaultOption),!de.isValidObject(r))return null;e=de.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Bi.default(n);e.recursive&&(de.isValidObject(a)?de.belongToTypes(a,e.keepTypesOnRecursion)||(a=St(a,e)):e.recursiveInArray&&de.isArrayObject(a)&&(a=Li(a).map(function(o){var l=o;if(de.isValidObject(o))de.belongToTypes(l,e.keepTypesOnRecursion)||(l=St(o,e));else if(de.isArrayObject(o)){var u=St({key:o},e);l=u.key}return l}))),t[i]=a}),t}cn.default=St;var ln={},qi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(ln,"__esModule",{value:!0});var ye=Ze,Yi=Ft;function Nt(r,e){if(e===void 0&&(e=ye.DefaultOption),!ye.isValidObject(r))return null;e=ye.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Yi.default(n);e.recursive&&(ye.isValidObject(a)?ye.belongToTypes(a,e.keepTypesOnRecursion)||(a=Nt(a,e)):e.recursiveInArray&&ye.isArrayObject(a)&&(a=qi(a).map(function(o){var l=o;if(ye.isValidObject(o))ye.belongToTypes(l,e.keepTypesOnRecursion)||(l=Nt(o,e));else if(ye.isArrayObject(o)){var u=Nt({key:o},e);l=u.key}return l}))),t[i]=a}),t}ln.default=Nt;var un={},Wi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(un,"__esModule",{value:!0});var pe=Ze,Ki=Jt;function At(r,e){if(e===void 0&&(e=pe.DefaultOption),!pe.isValidObject(r))return null;e=pe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Ki.default(n);e.recursive&&(pe.isValidObject(a)?pe.belongToTypes(a,e.keepTypesOnRecursion)||(a=At(a,e)):e.recursiveInArray&&pe.isArrayObject(a)&&(a=Wi(a).map(function(o){var l=o;if(pe.isValidObject(o))pe.belongToTypes(l,e.keepTypesOnRecursion)||(l=At(o,e));else if(pe.isArrayObject(o)){var u=At({key:o},e);l=u.key}return l}))),t[i]=a}),t}un.default=At;Object.defineProperty(O,"__esModule",{value:!0});O.kebabKeys=O.pascalKeys=O.snakeKeys=O.camelKeys=O.upperKeys=O.lowerKeys=O.toLowerCase=O.toUpperCase=O.toKebabCase=O.toHeaderCase=O.toSentenceCase=O.toTextCase=O.toPathCase=O.toDotCase=O.toPascalCase=O.toSnakeCase=O.toCamelCase=void 0;var hs=Kt;O.toCamelCase=hs.default;var fs=Vt;O.toSnakeCase=fs.default;var ds=Ft;O.toPascalCase=ds.default;var ys=Qr;O.toDotCase=ys.default;var ps=en;O.toPathCase=ps.default;var gs=tn;O.toTextCase=gs.default;var ms=rn;O.toSentenceCase=ms.default;var ws=nn;O.toHeaderCase=ws.default;var vs=Jt;O.toKebabCase=vs.default;var bs=sn;O.lowerKeys=bs.default;var Os=an;O.upperKeys=Os.default;var Ts=on;O.camelKeys=Ts.default;var zs=cn;O.snakeKeys=zs.default;var Es=ln;O.pascalKeys=Es.default;var Ss=un;O.kebabKeys=Ss.default;var Ns=function(r){return String(r||"").toLowerCase()};O.toLowerCase=Ns;var As=function(r){return String(r||"").toUpperCase()};O.toUpperCase=As;var Vi={toCamelCase:hs.default,toSnakeCase:fs.default,toPascalCase:ds.default,toDotCase:ys.default,toPathCase:ps.default,toTextCase:gs.default,toSentenceCase:ms.default,toHeaderCase:ws.default,toKebabCase:vs.default,toUpperCase:As,toLowerCase:Ns,lowerKeys:bs.default,upperKeys:Os.default,camelKeys:Ts.default,snakeKeys:zs.default,pascalKeys:Es.default,kebabKeys:Ss.default};O.default=Vi;var Is=O;const ks={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Fi=r=>Is.snakeKeys(r,ks),Mt=r=>Is.camelKeys(r,ks),Ji=r=>r!=null&&typeof r=="object"&&"toString"in r,Gi=(r,e=!1)=>{const t=Ji(r)?"stringer":typeof r;let n;switch(t){case"string":n=(a,i)=>a.localeCompare(i);break;case"stringer":n=(a,i)=>a.toString().localeCompare(i.toString());break;case"number":n=(a,i)=>Number(a)-Number(i);break;case"bigint":n=(a,i)=>BigInt(a)-BigInt(i)>0n?1:-1;break;case"boolean":n=(a,i)=>Number(a)-Number(i);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?Hi(n):n},Hi=r=>(e,t)=>r(t,e),Gt=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const $s=s.z.object({width:s.z.number(),height:s.z.number()}),Xi=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Qi=["width","height"];s.z.enum(Qi);const eo=["start","center","end"],to=["signedWidth","signedHeight"];s.z.enum(to);const _t=s.z.object({x:s.z.number(),y:s.z.number()}),ro=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),no=["x","y"],Cs=s.z.enum(no),Rs=["top","right","bottom","left"];s.z.enum(Rs);const so=["left","right"],js=s.z.enum(so),ao=["top","bottom"],xs=s.z.enum(ao),Ps=["center"],Mn=s.z.enum(Ps),io=[...Rs,...Ps],Ds=s.z.enum(io);s.z.enum(eo);const oo=["first","last"];s.z.enum(oo);const co=s.z.object({lower:s.z.number(),upper:s.z.number()}),lo=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([co,Gt]);s.z.union([lo,Gt]);s.z.union([Cs,Ds]);s.z.union([Cs,Ds,s.z.instanceof(String)]);const at=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return _n(r);return _n(t)},_n=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;s.z.object({x:js.or(Mn),y:xs.or(Mn)});const uo=s.z.object({x:js,y:xs}),ho=Object.freeze({x:"left",y:"top"}),fo=(r,e)=>r.x===e.x&&r.y===e.y,Un=s.z.union([s.z.number(),_t,Gt,$s,Xi,ro]),yo=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Ln=Object.freeze({x:0,y:0}),vt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:vt,left:vt,width:vt,height:vt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:_t,two:_t,root:uo});const hn=(r,e,t=0,n=0,a)=>{const i={one:{...Ln},two:{...Ln},root:a??ho};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:r,y:e},i.two={x:i.one.x+t,y:i.one.y+n},i}return"one"in r&&"two"in r&&"root"in r?{...r,root:a??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(i.one={x:r.left,y:r.top},i.two={x:r.right,y:r.bottom},i):(i.one=r,e==null?i.two={x:i.one.x+t,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},mr=r=>{const e=hn(r);return{lower:e.one.x,upper:e.two.x}},wr=r=>{const e=hn(r);return{lower:e.one.y,upper:e.two.y}},po=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,go=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([$s,go,_t,Gt]);var mo=Object.defineProperty,wo=(r,e,t)=>e in r?mo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ee=(r,e,t)=>(wo(r,typeof e!="symbol"?e+"":e,t),t);const vo=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);s.z.object({offset:Un,scale:Un});const bo=r=>(e,t,n,a)=>t==="dimension"?[e,n]:[e,a?n-r:n+r],Oo=r=>(e,t,n,a)=>[e,a?n/r:n*r],To=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=r,u=i-a,p=l-o;if(t==="dimension")return[r,n*(p/u)];const g=(n-a)*(p/u)+o;return[r,g]},zo=r=>(e,t,n)=>[r,n],Eo=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:a}=r;return[r,a-(t-n)]},So=r=>(e,t,n)=>{const{lower:a,upper:i}=r;return n=vo(n,a,i),[e,n]},Mr=class Qe{constructor(){Ee(this,"ops",[]),Ee(this,"currBounds",null),Ee(this,"currType",null),Ee(this,"reversed",!1),this.ops=[]}static translate(e){return new Qe().translate(e)}static magnify(e){return new Qe().magnify(e)}static scale(e,t){return new Qe().scale(e,t)}translate(e){const t=this.new(),n=bo(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Oo(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=at(e,t),a=this.new(),i=To(n);return i.type="scale",a.ops.push(i),a}clamp(e,t){const n=at(e,t),a=this.new(),i=So(n);return i.type="clamp",a.ops.push(i),a}reBound(e,t){const n=at(e,t),a=this.new(),i=zo(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Eo();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Qe;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||t.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&t.push([a,i])}),t.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}};Ee(Mr,"IDENTITY",new Mr);let Bn=Mr;const qn=class Te{constructor(e=new Bn,t=new Bn,n=null){Ee(this,"x"),Ee(this,"y"),Ee(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Te().translate(e,t)}static translateX(e){return new Te().translateX(e)}static translateY(e){return new Te().translateY(e)}static clamp(e){return new Te().clamp(e)}static magnify(e){return new Te().magnify(e)}static scale(e){return new Te().scale(e)}static reBound(e){return new Te().reBound(e)}translate(e,t){const n=yo(e,t),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(po(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!fo(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(mr(e)),t.y=t.y.scale(wr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(mr(e)),t.y=this.y.reBound(wr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(mr(e)),t.y=this.y.clamp(wr(e)),t}copy(){const e=new Te;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 hn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ee(qn,"IDENTITY",new qn);var No=Object.defineProperty,Ao=(r,e,t)=>e in r?No(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e,t)=>(Ao(r,typeof e!="symbol"?e+"":e,t),t);let Io="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ko=(r=21)=>{let e="",t=r;for(;t--;)e+=Io[Math.random()*64|0];return e};const Zs=(r,e)=>{const t=new E(e);if(![N.DAY,N.HOUR,N.MINUTE,N.SECOND,N.MILLISECOND,N.MICROSECOND,N.NANOSECOND].some(a=>a.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof E?new E(n):new N(n)},k=class v{constructor(e,t="UTC"){if(d(this,"value"),d(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const a=new Date(e,t-1,n,0,0,0,0);return new v(BigInt(a.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let u=v.hours(parseInt(n??"00",10)).add(v.minutes(parseInt(a??"00",10))).add(v.seconds(parseInt(o??"00",10))).add(v.milliseconds(parseInt(l??"00",10)));return t==="local"&&(u=u.add(v.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new v(BigInt(n.getTime())*v.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new N(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new J(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 v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Zs(this,e)}get isToday(){return this.truncate(N.DAY).equals(v.now().truncate(N.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let t=v.MIN;for(const n of e){const a=new v(n);a.after(t)&&(t=a)}return t}static min(...e){let t=v.MAX;for(const n of e){const a=new v(n);a.before(t)&&(t=a)}return t}static nanoseconds(e){return new v(e)}static microseconds(e){return v.nanoseconds(e*1e3)}static milliseconds(e){return v.microseconds(e*1e3)}static seconds(e){return v.milliseconds(e*1e3)}static minutes(e){return v.seconds(e*60)}static hours(e){return v.minutes(e*60)}static days(e){return v.hours(e*24)}};d(k,"NANOSECOND",k.nanoseconds(1)),d(k,"MICROSECOND",k.microseconds(1)),d(k,"MILLISECOND",k.milliseconds(1)),d(k,"SECOND",k.seconds(1)),d(k,"MINUTE",k.minutes(1)),d(k,"HOUR",k.hours(1)),d(k,"DAY",k.days(1)),d(k,"MAX",new k((1n<<63n)-1n)),d(k,"MIN",new k(0)),d(k,"ZERO",new k(0)),d(k,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new k(r.value)),s.z.string().transform(r=>new k(BigInt(r))),s.z.instanceof(Number).transform(r=>new k(r)),s.z.number().transform(r=>new k(r)),s.z.instanceof(k)]));let E=k;const $=class A{constructor(e){d(this,"value"),d(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 Zs(this,e)}truncate(e){return new A(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(A.DAY),t=this.truncate(A.HOUR),n=this.truncate(A.MINUTE),a=this.truncate(A.SECOND),i=this.truncate(A.MILLISECOND),o=this.truncate(A.MICROSECOND),l=this.truncate(A.NANOSECOND),u=e,p=t.sub(e),g=n.sub(t),y=a.sub(n),U=i.sub(a),x=o.sub(i),Q=l.sub(o);let D="";return u.isZero||(D+=`${u.days}d `),p.isZero||(D+=`${p.hours}h `),g.isZero||(D+=`${g.minutes}m `),y.isZero||(D+=`${y.seconds}s `),U.isZero||(D+=`${U.milliseconds}ms `),x.isZero||(D+=`${x.microseconds}µs `),Q.isZero||(D+=`${Q.nanoseconds}ns`),D.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)}};d($,"NANOSECOND",$.nanoseconds(1)),d($,"MICROSECOND",$.microseconds(1)),d($,"MILLISECOND",$.milliseconds(1)),d($,"SECOND",$.seconds(1)),d($,"MINUTE",$.minutes(1)),d($,"HOUR",$.hours(1)),d($,"DAY",$.days(1)),d($,"MAX",new $((1n<<63n)-1n)),d($,"MIN",new $(0)),d($,"ZERO",new $(0)),d($,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new $(r.value)),s.z.string().transform(r=>new $(BigInt(r))),s.z.instanceof(Number).transform(r=>new $(r)),s.z.number().transform(r=>new $(r)),s.z.instanceof($)]));let N=$;const et=class It extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new It(e).valueOf()}get period(){return N.seconds(1/this.valueOf())}sampleCount(e){return new N(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new V(t).valueOf()}span(e){return N.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new It(e)}static khz(e){return It.hz(e*1e3)}};d(et,"z",s.z.union([s.z.number().transform(r=>new et(r)),s.z.instanceof(Number).transform(r=>new et(r)),s.z.instanceof(et)]));let Ht=et;const L=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new ot(e*this.valueOf())}};d(L,"UNKNOWN",new L(0)),d(L,"BIT128",new L(16)),d(L,"BIT64",new L(8)),d(L,"BIT32",new L(4)),d(L,"BIT16",new L(2)),d(L,"BIT8",new L(1)),d(L,"z",s.z.union([s.z.number().transform(r=>new L(r)),s.z.instanceof(Number).transform(r=>new L(r)),s.z.instanceof(L)]));let V=L;const se=class kt{constructor(e,t){d(this,"start"),d(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(t))}get span(){return new N(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}swap(){return new kt(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,t=N.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 a=E.max(n.start,e.start),i=E.min(n.end,e.end);return i.before(a)?!1:new N(i.sub(a)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=t.valueOf()&&a<=t.valueOf()}contains(e){return e instanceof kt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new kt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};d(se,"MAX",new se(E.MIN,E.MAX)),d(se,"MIN",new se(E.MAX,E.MIN)),d(se,"ZERO",new se(E.ZERO,E.ZERO)),d(se,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(r=>new se(r.start,r.end)),s.z.instanceof(se)]));let J=se;const h=class ae extends String{constructor(e){if(e instanceof ae||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=ae.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(ae.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ae.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()}toString(){return this.valueOf()}get isVariable(){return this.equals(ae.JSON)||this.equals(ae.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ae.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ae.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 ae.BIG_INT_TYPES.some(e=>e.equals(this))}};d(h,"UNKNOWN",new h("unknown")),d(h,"FLOAT64",new h("float64")),d(h,"FLOAT32",new h("float32")),d(h,"INT64",new h("int64")),d(h,"INT32",new h("int32")),d(h,"INT16",new h("int16")),d(h,"INT8",new h("int8")),d(h,"UINT64",new h("uint64")),d(h,"UINT32",new h("uint32")),d(h,"UINT16",new h("uint16")),d(h,"UINT8",new h("uint8")),d(h,"BOOLEAN",h.UINT8),d(h,"TIMESTAMP",new h("timestamp")),d(h,"UUID",new h("uuid")),d(h,"STRING",new h("string")),d(h,"JSON",new h("json")),d(h,"ARRAY_CONSTRUCTORS",new Map([[h.UINT8.toString(),Uint8Array],[h.UINT16.toString(),Uint16Array],[h.UINT32.toString(),Uint32Array],[h.UINT64.toString(),BigUint64Array],[h.FLOAT32.toString(),Float32Array],[h.FLOAT64.toString(),Float64Array],[h.INT8.toString(),Int8Array],[h.INT16.toString(),Int16Array],[h.INT32.toString(),Int32Array],[h.INT64.toString(),BigInt64Array],[h.TIMESTAMP.toString(),BigInt64Array],[h.STRING.toString(),Uint8Array],[h.JSON.toString(),Uint8Array],[h.UUID.toString(),Uint8Array]])),d(h,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,h.UINT8],[Uint16Array.name,h.UINT16],[Uint32Array.name,h.UINT32],[BigUint64Array.name,h.UINT64],[Float32Array.name,h.FLOAT32],[Float64Array.name,h.FLOAT64],[Int8Array.name,h.INT8],[Int16Array.name,h.INT16],[Int32Array.name,h.INT32],[BigInt64Array.name,h.INT64]])),d(h,"DENSITIES",new Map([[h.UINT8.toString(),V.BIT8],[h.UINT16.toString(),V.BIT16],[h.UINT32.toString(),V.BIT32],[h.UINT64.toString(),V.BIT64],[h.FLOAT32.toString(),V.BIT32],[h.FLOAT64.toString(),V.BIT64],[h.INT8.toString(),V.BIT8],[h.INT16.toString(),V.BIT16],[h.INT32.toString(),V.BIT32],[h.INT64.toString(),V.BIT64],[h.TIMESTAMP.toString(),V.BIT64],[h.STRING.toString(),V.UNKNOWN],[h.JSON.toString(),V.UNKNOWN],[h.UUID.toString(),V.BIT128]])),d(h,"ALL",[h.UNKNOWN,h.FLOAT64,h.FLOAT32,h.INT64,h.INT32,h.INT16,h.INT8,h.UINT64,h.UINT32,h.UINT16,h.UINT8,h.TIMESTAMP,h.UUID,h.STRING,h.JSON]),d(h,"BIG_INT_TYPES",[h.INT64,h.UINT64,h.TIMESTAMP]),d(h,"z",s.z.union([s.z.string().transform(r=>new h(r)),s.z.instanceof(h)]));let S=h;const W=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),t=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),a=this.truncate(Z.KILOBYTE),i=this.truncate(Z.BYTE),o=e,l=t.sub(e),u=n.sub(t),p=a.sub(n),g=i.sub(a);let y="";return o.isZero||(y+=`${o.terabytes}TB `),l.isZero||(y+=`${l.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),p.isZero||(y+=`${p.kilobytes}KB `),(!g.isZero||y==="")&&(y+=`${g.valueOf()}B`),y.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}};d(W,"BYTE",new W(1)),d(W,"KILOBYTE",W.kilobytes(1)),d(W,"MEGABYTE",W.megabytes(1)),d(W,"GIGABYTE",W.gigabytes(1)),d(W,"TERABYTE",W.terabytes(1)),d(W,"ZERO",new W(0)),d(W,"z",s.z.union([s.z.number().transform(r=>new W(r)),s.z.instanceof(W)]));let ot=W;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 Ms=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof E||r instanceof N||r instanceof Date},$o=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):tt(t,-n),Co=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof F?!0:Ms(r),Re=-1;class F{constructor(e){d(this,"key",""),d(this,"isSynnaxSeries",!0),d(this,"dataType"),d(this,"sampleOffset"),d(this,"gl"),d(this,"_data"),d(this,"_timeRange"),d(this,"alignment",0n),d(this,"_cachedMin"),d(this,"_cachedMax"),d(this,"writePos",Re),d(this,"_refCount",0),d(this,"_cachedLength"),Co(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:a=0,glBufferUsage:i="static",alignment:o=0n,key:l=ko()}=e,{data:u}=e;if(u instanceof F||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const y=u;this.key=y.key,this.dataType=y.dataType,this.sampleOffset=y.sampleOffset,this.gl=y.gl,this._data=y._data,this._timeRange=y._timeRange,this.alignment=y.alignment,this._cachedMin=y._cachedMin,this._cachedMax=y._cachedMax,this.writePos=y.writePos,this._refCount=y._refCount,this._cachedLength=y._cachedLength;return}const p=Ms(u),g=Array.isArray(u);if(t!=null)this.dataType=new S(t);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(g||p){let y=u;if(!p){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.");y=u[0]}if(typeof y=="string")this.dataType=S.STRING;else if(typeof y=="number")this.dataType=S.FLOAT64;else if(typeof y=="bigint")this.dataType=S.INT64;else if(typeof y=="boolean")this.dataType=S.BOOLEAN;else if(y instanceof E||y instanceof Date||y instanceof E)this.dataType=S.TIMESTAMP;else if(typeof y=="object")this.dataType=S.JSON;else throw new Error(`cannot infer data type of ${typeof y} when constructing a Series from a JS array`)}else this.dataType=new S(u)}if(!g&&!p)this._data=u;else{let y=p?[u]:u;const U=y[0];(U instanceof E||U instanceof Date||U instanceof N)&&(y=y.map(x=>new E(x).valueOf())),this.dataType.equals(S.STRING)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(y.join(`
|
|
2
2
|
`)+`
|
|
3
3
|
`)):this.dataType.equals(S.JSON)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(y.map(x=>JSON.stringify(x)).join(`
|
|
4
4
|
`)+`
|
|
@@ -8,26 +8,26 @@
|
|
|
8
8
|
`)+`
|
|
9
9
|
`);return new F({data:n,dataType:S.JSON,timeRange:t})}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===Re)return 0;const t=this.capacity-this.writePos,n=t<e.length?e.slice(0,t):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===Re?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(S.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
10
10
|
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(S.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=S.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const a=this.buffer.slice(n*e,(n+1)*e),i=Array.from(new Uint8Array(a),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=i}return t}parseJSON(e){if(!this.dataType.equals(S.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
11
|
-
`).slice(0,-1).map(t=>e.parse(Mt(JSON.parse(t))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new ot(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Re?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Re?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(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let a=0;a<this.length;a++)n[a]=$o(this.dataType,e,this.data[a],t);return new F({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(S.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t: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()),tt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(S.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t: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()),tt(this._cachedMin,this.sampleOffset))}get bounds(){return at(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return tt(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return tt(n,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let n=0,a=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){a=o;break}n=o+1,e--}if(a===0&&(a=this.data.length),n>=a||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const i=this.data.slice(n,a);return this.dataType.equals(S.STRING)?new TextDecoder().decode(i):Mt(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,n=this.length-1;const a=Gi(e);for(;t<=n;){const i=Math.floor((t+n)/2),o=a(this.at(i,!0),e);if(o===0)return i;o<0?t=i+1:n=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(S.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:a}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==a)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Re){a===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(a).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,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=Re}as(e){if(e==="string"){if(!this.dataType.equals(S.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(S.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 at(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 Ro(this);return this.dataType.equals(S.JSON)?new jo(e):e}return new xo(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new F({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new F({data:this.buffer,dataType:this.dataType,timeRange:J.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Ro{constructor(e){if(d(this,"series"),d(this,"index"),d(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,t=this.series.data;for(;this.index<t.length&&t[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 _s;let jo=class{constructor(e){d(this,"wrapped"),d(this,_s,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Mt(JSON.parse(e.value))}}[Symbol.iterator](){return this}};_s=Symbol.toStringTag;var Us;let xo=class{constructor(e){d(this,"series"),d(this,"index"),d(this,Us,"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)}}[Symbol.iterator](){return this}};Us=Symbol.toStringTag;const tt=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);let Ls=class{constructor(e){if(d(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new S(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?S.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?J.ZERO:new J(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,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new ot(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Do(this.series)}};var Bs;let Do=class{constructor(e){d(this,"series"),d(this,"seriesIndex"),d(this,"internal"),d(this,Bs,"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())}[Symbol.iterator](){return this}};Bs=Symbol.toStringTag;const z=r=>Array.isArray(r)?r:[r],$e=s.z.number(),yt=s.z.object({name:s.z.string(),key:s.z.number(),rate:Ht.z,dataType:S.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),alias:s.z.string().optional()}),qs=yt.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:Ht.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),Po=(r,e)=>{let t=null;return e===0?r:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...n),e)}},Zo=new Error("request for lock canceled");var Mo=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function l(g){try{p(n.next(g))}catch(y){o(y)}}function u(g){try{p(n.throw(g))}catch(y){o(y)}}function p(g){g.done?i(g.value):a(g.value).then(l,u)}p((n=n.apply(r,e||[])).next())})};class _o{constructor(e,t=Zo){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,a)=>{const i={resolve:n,reject:a,weight:e,priority:t},o=Ys(this._queue,l=>t<=l.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return Mo(this,arguments,void 0,function*(t,n=1,a=0){const[i,o]=yield this.acquire(n,a);try{return yield t(i)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Uo(this._weightedWaiters[e-1],{resolve:n,priority:t})})}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 t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const a=n.findIndex(i=>i.priority<=e);(a===-1?n:n.splice(0,a)).forEach(i=>i.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Uo(r,e){const t=Ys(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function Ys(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var Lo=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function l(g){try{p(n.next(g))}catch(y){o(y)}}function u(g){try{p(n.throw(g))}catch(y){o(y)}}function p(g){g.done?i(g.value):a(g.value).then(l,u)}p((n=n.apply(r,e||[])).next())})};class Bo{constructor(e){this._semaphore=new _o(1,e)}acquire(){return Lo(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}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()}}var qo=Object.defineProperty,Yo=(r,e,t)=>e in r?qo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,j=(r,e,t)=>(Yo(r,typeof e!="symbol"?e+"":e,t),t),re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},T={},Xt={};Object.defineProperty(Xt,"__esModule",{value:!0});function Wo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Xt.default=Wo;var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0});function Ko(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Qt.default=Ko;var er={};Object.defineProperty(er,"__esModule",{value:!0});function Vo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}er.default=Vo;var fn={};Object.defineProperty(fn,"__esModule",{value:!0});function Fo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}fn.default=Fo;var dn={};Object.defineProperty(dn,"__esModule",{value:!0});function Jo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}dn.default=Jo;var yn={};Object.defineProperty(yn,"__esModule",{value:!0});function Go(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}yn.default=Go;var pn={};Object.defineProperty(pn,"__esModule",{value:!0});function Ho(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,a){return n+"_"+a.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}pn.default=Ho;var gn={};Object.defineProperty(gn,"__esModule",{value:!0});function Xo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,a){return t+n.charAt(0).toUpperCase()+n.slice(1)+a}):""}gn.default=Xo;var tr={};Object.defineProperty(tr,"__esModule",{value:!0});function Qo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}tr.default=Qo;var mn={},Me={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Me);var ec=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(mn,"__esModule",{value:!0});var ge=Me;function $t(r,e){if(e===void 0&&(e=ge.DefaultOption),!ge.isValidObject(r))return null;e=ge.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toLowerCase();e.recursive&&(ge.isValidObject(a)?ge.belongToTypes(a,e.keepTypesOnRecursion)||(a=$t(a,e)):e.recursiveInArray&&ge.isArrayObject(a)&&(a=ec(a).map(function(o){var l=o;if(ge.isValidObject(o))ge.belongToTypes(l,e.keepTypesOnRecursion)||(l=$t(o,e));else if(ge.isArrayObject(o)){var u=$t({key:o},e);l=u.key}return l}))),t[i]=a}),t}mn.default=$t;var wn={},tc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(wn,"__esModule",{value:!0});var me=Me;function Ct(r,e){if(e===void 0&&(e=me.DefaultOption),!me.isValidObject(r))return null;e=me.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toUpperCase();e.recursive&&(me.isValidObject(a)?me.belongToTypes(a,e.keepTypesOnRecursion)||(a=Ct(a,e)):e.recursiveInArray&&me.isArrayObject(a)&&(a=tc(a).map(function(o){var l=o;if(me.isValidObject(o))me.belongToTypes(l,e.keepTypesOnRecursion)||(l=Ct(o,e));else if(me.isArrayObject(o)){var u=Ct({key:o},e);l=u.key}return l}))),t[i]=a}),t}wn.default=Ct;var vn={},rc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(vn,"__esModule",{value:!0});var we=Me,nc=Xt;function Rt(r,e){if(e===void 0&&(e=we.DefaultOption),!we.isValidObject(r))return null;e=we.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=nc.default(n);e.recursive&&(we.isValidObject(a)?we.belongToTypes(a,e.keepTypesOnRecursion)||(a=Rt(a,e)):e.recursiveInArray&&we.isArrayObject(a)&&(a=rc(a).map(function(o){var l=o;if(we.isValidObject(o))we.belongToTypes(l,e.keepTypesOnRecursion)||(l=Rt(o,e));else if(we.isArrayObject(o)){var u=Rt({key:o},e);l=u.key}return l}))),t[i]=a}),t}vn.default=Rt;var bn={},sc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(bn,"__esModule",{value:!0});var ve=Me,ac=Qt;function jt(r,e){if(e===void 0&&(e=ve.DefaultOption),!ve.isValidObject(r))return null;e=ve.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=ac.default(n);e.recursive&&(ve.isValidObject(a)?ve.belongToTypes(a,e.keepTypesOnRecursion)||(a=jt(a,e)):e.recursiveInArray&&ve.isArrayObject(a)&&(a=sc(a).map(function(o){var l=o;if(ve.isValidObject(o))ve.belongToTypes(l,e.keepTypesOnRecursion)||(l=jt(o,e));else if(ve.isArrayObject(o)){var u=jt({key:o},e);l=u.key}return l}))),t[i]=a}),t}bn.default=jt;var On={},ic=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(On,"__esModule",{value:!0});var be=Me,oc=er;function xt(r,e){if(e===void 0&&(e=be.DefaultOption),!be.isValidObject(r))return null;e=be.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=oc.default(n);e.recursive&&(be.isValidObject(a)?be.belongToTypes(a,e.keepTypesOnRecursion)||(a=xt(a,e)):e.recursiveInArray&&be.isArrayObject(a)&&(a=ic(a).map(function(o){var l=o;if(be.isValidObject(o))be.belongToTypes(l,e.keepTypesOnRecursion)||(l=xt(o,e));else if(be.isArrayObject(o)){var u=xt({key:o},e);l=u.key}return l}))),t[i]=a}),t}On.default=xt;var Tn={},cc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(Tn,"__esModule",{value:!0});var Oe=Me,lc=tr;function Dt(r,e){if(e===void 0&&(e=Oe.DefaultOption),!Oe.isValidObject(r))return null;e=Oe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=lc.default(n);e.recursive&&(Oe.isValidObject(a)?Oe.belongToTypes(a,e.keepTypesOnRecursion)||(a=Dt(a,e)):e.recursiveInArray&&Oe.isArrayObject(a)&&(a=cc(a).map(function(o){var l=o;if(Oe.isValidObject(o))Oe.belongToTypes(l,e.keepTypesOnRecursion)||(l=Dt(o,e));else if(Oe.isArrayObject(o)){var u=Dt({key:o},e);l=u.key}return l}))),t[i]=a}),t}Tn.default=Dt;Object.defineProperty(T,"__esModule",{value:!0});T.kebabKeys=T.pascalKeys=T.snakeKeys=T.camelKeys=T.upperKeys=T.lowerKeys=T.toLowerCase=T.toUpperCase=T.toKebabCase=T.toHeaderCase=T.toSentenceCase=T.toTextCase=T.toPathCase=T.toDotCase=T.toPascalCase=T.toSnakeCase=T.toCamelCase=void 0;var Ws=Xt;T.toCamelCase=Ws.default;var Ks=Qt;T.toSnakeCase=Ks.default;var Vs=er;T.toPascalCase=Vs.default;var Fs=fn;T.toDotCase=Fs.default;var Js=dn;T.toPathCase=Js.default;var Gs=yn;T.toTextCase=Gs.default;var Hs=pn;T.toSentenceCase=Hs.default;var Xs=gn;T.toHeaderCase=Xs.default;var Qs=tr;T.toKebabCase=Qs.default;var ea=mn;T.lowerKeys=ea.default;var ta=wn;T.upperKeys=ta.default;var ra=vn;T.camelKeys=ra.default;var na=bn;T.snakeKeys=na.default;var sa=On;T.pascalKeys=sa.default;var aa=Tn;T.kebabKeys=aa.default;var ia=function(r){return String(r||"").toLowerCase()};T.toLowerCase=ia;var oa=function(r){return String(r||"").toUpperCase()};T.toUpperCase=oa;var uc={toCamelCase:Ws.default,toSnakeCase:Ks.default,toPascalCase:Vs.default,toDotCase:Fs.default,toPathCase:Js.default,toTextCase:Gs.default,toSentenceCase:Hs.default,toHeaderCase:Xs.default,toKebabCase:Qs.default,toUpperCase:oa,toLowerCase:ia,lowerKeys:ea.default,upperKeys:ta.default,camelKeys:ra.default,snakeKeys:na.default,pascalKeys:sa.default,kebabKeys:aa.default};T.default=uc;var ca=T;const la={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},hc=r=>ca.snakeKeys(r,la),fc=r=>ca.camelKeys(r,la),dc=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var yc=Object.defineProperty,pc=(r,e,t)=>e in r?yc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vr=(r,e,t)=>(pc(r,typeof e!="symbol"?e+"":e,t),t);let gc=class{constructor(){vr(this,"contentType","application/json"),vr(this,"decoder"),vr(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(r){return this.encoder.encode(this.encodeString(r)).buffer}decode(r,e){return this.decodeString(this.decoder.decode(r),e)}decodeString(r,e){const t=fc(JSON.parse(r));return e!=null?e.parse(t):t}encodeString(r){return JSON.stringify(hc(r),(e,t)=>ArrayBuffer.isView(t)?Array.from(t):dc(t)&&"encode_value"in t?typeof t.value=="bigint"?t.value.toString():t.value:typeof t=="bigint"?t.toString():t)}static registerCustomType(){}};new gc;const rr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const ua=s.z.object({width:s.z.number(),height:s.z.number()}),mc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),wc=["width","height"];s.z.enum(wc);const vc=["start","center","end"],bc=["signedWidth","signedHeight"];s.z.enum(bc);const Ut=s.z.object({x:s.z.number(),y:s.z.number()}),Oc=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Tc=["x","y"],ha=s.z.enum(Tc),fa=["top","right","bottom","left"];s.z.enum(fa);const zc=["left","right"],da=s.z.enum(zc),Ec=["top","bottom"],ya=s.z.enum(Ec),pa=["center"],Yn=s.z.enum(pa),Sc=[...fa,...pa],ga=s.z.enum(Sc);s.z.enum(vc);const Nc=["first","last"];s.z.enum(Nc);const Ac=s.z.object({lower:s.z.number(),upper:s.z.number()}),Ic=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Ac,rr]);s.z.union([Ic,rr]);s.z.union([ha,ga]);s.z.union([ha,ga,s.z.instanceof(String)]);const br=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return Wn(r);return Wn(t)},Wn=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;s.z.object({x:da.or(Yn),y:ya.or(Yn)});const kc=s.z.object({x:da,y:ya}),$c=Object.freeze({x:"left",y:"top"}),Cc=(r,e)=>r.x===e.x&&r.y===e.y,Kn=s.z.union([s.z.number(),Ut,rr,ua,mc,Oc]),Rc=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Vn=Object.freeze({x:0,y:0}),bt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:bt,left:bt,width:bt,height:bt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Ut,two:Ut,root:kc});const zn=(r,e,t=0,n=0,a)=>{const i={one:{...Vn},two:{...Vn},root:a??$c};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:r,y:e},i.two={x:i.one.x+t,y:i.one.y+n},i}return"one"in r&&"two"in r&&"root"in r?{...r,root:a??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(i.one={x:r.left,y:r.top},i.two={x:r.right,y:r.bottom},i):(i.one=r,e==null?i.two={x:i.one.x+t,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Or=r=>{const e=zn(r);return{lower:e.one.x,upper:e.two.x}},Tr=r=>{const e=zn(r);return{lower:e.one.y,upper:e.two.y}},jc=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r;var xc=Object.defineProperty,Dc=(r,e,t)=>e in r?xc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Se=(r,e,t)=>(Dc(r,typeof e!="symbol"?e+"":e,t),t);const Pc=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);s.z.object({offset:Kn,scale:Kn});const Zc=r=>(e,t,n,a)=>t==="dimension"?[e,n]:[e,a?n-r:n+r],Mc=r=>(e,t,n,a)=>[e,a?n/r:n*r],_c=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=r,u=i-a,p=l-o;if(t==="dimension")return[r,n*(p/u)];const g=(n-a)*(p/u)+o;return[r,g]},Uc=r=>(e,t,n)=>[r,n],Lc=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:a}=r;return[r,a-(t-n)]},Bc=r=>(e,t,n)=>{const{lower:a,upper:i}=r;return n=Pc(n,a,i),[e,n]},_r=class rt{constructor(){Se(this,"ops",[]),Se(this,"currBounds",null),Se(this,"currType",null),Se(this,"reversed",!1),this.ops=[]}static translate(e){return new rt().translate(e)}static magnify(e){return new rt().magnify(e)}static scale(e,t){return new rt().scale(e,t)}translate(e){const t=this.new(),n=Zc(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Mc(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=br(e,t),a=this.new(),i=_c(n);return i.type="scale",a.ops.push(i),a}clamp(e,t){const n=br(e,t),a=this.new(),i=Bc(n);return i.type="clamp",a.ops.push(i),a}reBound(e,t){const n=br(e,t),a=this.new(),i=Uc(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Lc();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new rt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||t.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&t.push([a,i])}),t.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}};Se(_r,"IDENTITY",new _r);let Fn=_r;const Jn=class ze{constructor(e=new Fn,t=new Fn,n=null){Se(this,"x"),Se(this,"y"),Se(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new ze().translate(e,t)}static translateX(e){return new ze().translateX(e)}static translateY(e){return new ze().translateY(e)}static clamp(e){return new ze().clamp(e)}static magnify(e){return new ze().magnify(e)}static scale(e){return new ze().scale(e)}static reBound(e){return new ze().reBound(e)}translate(e,t){const n=Rc(e,t),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(jc(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Cc(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Or(e)),t.y=t.y.scale(Tr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Or(e)),t.y=this.y.reBound(Tr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Or(e)),t.y=this.y.clamp(Tr(e)),t}copy(){const e=new ze;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 zn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Se(Jn,"IDENTITY",new Jn);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",qc=ma(),wa=["MacOS","Windows","Linux","Docker"],Yc=s.z.enum(wa);let zr;const Wc=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Kc=(r={})=>{const{force:e,default:t}=r;return e??zr??(zr=Wc(),zr??t)},va=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:wa,RUNTIME:qc,detect:ma,getOS:Kc,osZ:Yc},Symbol.toStringTag,{value:"Module"})),Vc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([ua,Vc,Ut,rr]);var Fc=Object.defineProperty,Jc=(r,e,t)=>e in r?Fc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e,t)=>(Jc(r,typeof e!="symbol"?e+"":e,t),t);const ba=(r,e)=>{const t=new q(e);if(![Y.DAY,Y.HOUR,Y.MINUTE,Y.SECOND,Y.MILLISECOND,Y.MICROSECOND,Y.NANOSECOND].some(a=>a.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof q?new q(n):new Y(n)},C=class b{constructor(e,t="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=b.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*b.MILLISECOND.valueOf();else if(typeof e=="string")this.value=b.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=b.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=b.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=b.MAX:e=b.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const a=new Date(e,t-1,n,0,0,0,0);return new b(BigInt(a.getTime())*b.MILLISECOND.valueOf()).truncate(b.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let u=b.hours(parseInt(n??"00",10)).add(b.minutes(parseInt(a??"00",10))).add(b.seconds(parseInt(o??"00",10))).add(b.milliseconds(parseInt(l??"00",10)));return t==="local"&&(u=u.add(b.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return b.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new b(BigInt(n.getTime())*b.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(b.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new Y(BigInt(new Date().getTimezoneOffset())*b.MINUTE.valueOf())}static since(e){return new b().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new b(e).valueOf()}span(e){return this.range(e).span}range(e){return new Gc(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 b(e).valueOf()}afterEq(e){return this.valueOf()>=new b(e).valueOf()}before(e){return this.valueOf()<new b(e).valueOf()}beforeEq(e){return this.valueOf()<=new b(e).valueOf()}add(e){return new b(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new b(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(b.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ba(this,e)}get isToday(){return this.truncate(Y.DAY).equals(b.now().truncate(Y.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new b(new Date)}static max(...e){let t=b.MIN;for(const n of e){const a=new b(n);a.after(t)&&(t=a)}return t}static min(...e){let t=b.MAX;for(const n of e){const a=new b(n);a.before(t)&&(t=a)}return t}static nanoseconds(e){return new b(e)}static microseconds(e){return b.nanoseconds(e*1e3)}static milliseconds(e){return b.microseconds(e*1e3)}static seconds(e){return b.milliseconds(e*1e3)}static minutes(e){return b.seconds(e*60)}static hours(e){return b.minutes(e*60)}static days(e){return b.hours(e*24)}};m(C,"NANOSECOND",C.nanoseconds(1)),m(C,"MICROSECOND",C.microseconds(1)),m(C,"MILLISECOND",C.milliseconds(1)),m(C,"SECOND",C.seconds(1)),m(C,"MINUTE",C.minutes(1)),m(C,"HOUR",C.hours(1)),m(C,"DAY",C.days(1)),m(C,"MAX",new C((1n<<63n)-1n)),m(C,"MIN",new C(0)),m(C,"ZERO",new C(0)),m(C,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new C(r.value)),s.z.string().transform(r=>new C(BigInt(r))),s.z.instanceof(Number).transform(r=>new C(r)),s.z.number().transform(r=>new C(r)),s.z.instanceof(C)]));let q=C;const R=class I{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 I(e).valueOf()}greaterThan(e){return this.valueOf()>new I(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new I(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new I(e).valueOf()}remainder(e){return ba(this,e)}truncate(e){return new I(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(I.DAY),t=this.truncate(I.HOUR),n=this.truncate(I.MINUTE),a=this.truncate(I.SECOND),i=this.truncate(I.MILLISECOND),o=this.truncate(I.MICROSECOND),l=this.truncate(I.NANOSECOND),u=e,p=t.sub(e),g=n.sub(t),y=a.sub(n),U=i.sub(a),x=o.sub(i),Q=l.sub(o);let P="";return u.isZero||(P+=`${u.days}d `),p.isZero||(P+=`${p.hours}h `),g.isZero||(P+=`${g.minutes}m `),y.isZero||(P+=`${y.seconds}s `),U.isZero||(P+=`${U.milliseconds}ms `),x.isZero||(P+=`${x.microseconds}µs `),Q.isZero||(P+=`${Q.nanoseconds}ns`),P.trim()}get days(){return Number(this.valueOf())/Number(I.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(I.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(I.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(I.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(I.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(I.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new I(e).valueOf()}add(e){return new I(this.valueOf()+new I(e).valueOf())}sub(e){return new I(this.valueOf()-new I(e).valueOf())}static nanoseconds(e=1){return new I(e)}static microseconds(e=1){return I.nanoseconds(e*1e3)}static milliseconds(e=1){return I.microseconds(e*1e3)}static seconds(e=1){return I.milliseconds(e*1e3)}static minutes(e){return I.seconds(e.valueOf()*60)}static hours(e){return I.minutes(e*60)}static days(e){return I.hours(e*24)}};m(R,"NANOSECOND",R.nanoseconds(1)),m(R,"MICROSECOND",R.microseconds(1)),m(R,"MILLISECOND",R.milliseconds(1)),m(R,"SECOND",R.seconds(1)),m(R,"MINUTE",R.minutes(1)),m(R,"HOUR",R.hours(1)),m(R,"DAY",R.days(1)),m(R,"MAX",new R((1n<<63n)-1n)),m(R,"MIN",new R(0)),m(R,"ZERO",new R(0)),m(R,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new R(r.value)),s.z.string().transform(r=>new R(BigInt(r))),s.z.instanceof(Number).transform(r=>new R(r)),s.z.number().transform(r=>new R(r)),s.z.instanceof(R)]));let Y=R;const Ot=class Pt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Pt(e).valueOf()}get period(){return Y.seconds(1/this.valueOf())}sampleCount(e){return new Y(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new H(t).valueOf()}span(e){return Y.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Pt(e)}static khz(e){return Pt.hz(e*1e3)}};m(Ot,"z",s.z.union([s.z.number().transform(r=>new Ot(r)),s.z.instanceof(Number).transform(r=>new Ot(r)),s.z.instanceof(Ot)]));const B=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new Hc(r*this.valueOf())}};m(B,"UNKNOWN",new B(0)),m(B,"BIT128",new B(16)),m(B,"BIT64",new B(8)),m(B,"BIT32",new B(4)),m(B,"BIT16",new B(2)),m(B,"BIT8",new B(1)),m(B,"z",s.z.union([s.z.number().transform(r=>new B(r)),s.z.instanceof(Number).transform(r=>new B(r)),s.z.instanceof(B)]));let H=B;const ie=class Zt{constructor(e,t){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new q(e.start),this.end=new q(e.end)):(this.start=new q(e),this.end=new q(t))}get span(){return new Y(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}swap(){return new Zt(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,t=Y.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 a=q.max(n.start,e.start),i=q.min(n.end,e.end);return i.before(a)?!1:new Y(i.sub(a)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=t.valueOf()&&a<=t.valueOf()}contains(e){return e instanceof Zt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Zt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};m(ie,"MAX",new ie(q.MIN,q.MAX)),m(ie,"MIN",new ie(q.MAX,q.MIN)),m(ie,"ZERO",new ie(q.ZERO,q.ZERO)),m(ie,"z",s.z.union([s.z.object({start:q.z,end:q.z}).transform(r=>new ie(r.start,r.end)),s.z.instanceof(ie)]));let Gc=ie;const f=class oe extends String{constructor(e){if(e instanceof oe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=oe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(oe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=oe.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()}toString(){return this.valueOf()}get isVariable(){return this.equals(oe.JSON)||this.equals(oe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(oe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=oe.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 oe.BIG_INT_TYPES.some(e=>e.equals(this))}};m(f,"UNKNOWN",new f("unknown")),m(f,"FLOAT64",new f("float64")),m(f,"FLOAT32",new f("float32")),m(f,"INT64",new f("int64")),m(f,"INT32",new f("int32")),m(f,"INT16",new f("int16")),m(f,"INT8",new f("int8")),m(f,"UINT64",new f("uint64")),m(f,"UINT32",new f("uint32")),m(f,"UINT16",new f("uint16")),m(f,"UINT8",new f("uint8")),m(f,"BOOLEAN",f.UINT8),m(f,"TIMESTAMP",new f("timestamp")),m(f,"UUID",new f("uuid")),m(f,"STRING",new f("string")),m(f,"JSON",new f("json")),m(f,"ARRAY_CONSTRUCTORS",new Map([[f.UINT8.toString(),Uint8Array],[f.UINT16.toString(),Uint16Array],[f.UINT32.toString(),Uint32Array],[f.UINT64.toString(),BigUint64Array],[f.FLOAT32.toString(),Float32Array],[f.FLOAT64.toString(),Float64Array],[f.INT8.toString(),Int8Array],[f.INT16.toString(),Int16Array],[f.INT32.toString(),Int32Array],[f.INT64.toString(),BigInt64Array],[f.TIMESTAMP.toString(),BigInt64Array],[f.STRING.toString(),Uint8Array],[f.JSON.toString(),Uint8Array],[f.UUID.toString(),Uint8Array]])),m(f,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,f.UINT8],[Uint16Array.name,f.UINT16],[Uint32Array.name,f.UINT32],[BigUint64Array.name,f.UINT64],[Float32Array.name,f.FLOAT32],[Float64Array.name,f.FLOAT64],[Int8Array.name,f.INT8],[Int16Array.name,f.INT16],[Int32Array.name,f.INT32],[BigInt64Array.name,f.INT64]])),m(f,"DENSITIES",new Map([[f.UINT8.toString(),H.BIT8],[f.UINT16.toString(),H.BIT16],[f.UINT32.toString(),H.BIT32],[f.UINT64.toString(),H.BIT64],[f.FLOAT32.toString(),H.BIT32],[f.FLOAT64.toString(),H.BIT64],[f.INT8.toString(),H.BIT8],[f.INT16.toString(),H.BIT16],[f.INT32.toString(),H.BIT32],[f.INT64.toString(),H.BIT64],[f.TIMESTAMP.toString(),H.BIT64],[f.STRING.toString(),H.UNKNOWN],[f.JSON.toString(),H.UNKNOWN],[f.UUID.toString(),H.BIT128]])),m(f,"ALL",[f.UNKNOWN,f.FLOAT64,f.FLOAT32,f.INT64,f.INT32,f.INT16,f.INT8,f.UINT64,f.UINT32,f.UINT16,f.UINT8,f.TIMESTAMP,f.UUID,f.STRING,f.JSON]),m(f,"BIG_INT_TYPES",[f.INT64,f.UINT64,f.TIMESTAMP]),m(f,"z",s.z.union([s.z.string().transform(r=>new f(r)),s.z.instanceof(f)]));const K=class M extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return M.bytes(this.valueOf()+e.valueOf())}sub(e){return M.bytes(this.valueOf()-e.valueOf())}truncate(e){return new M(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return M.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/M.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/M.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/M.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/M.TERABYTE.valueOf()}toString(){const e=this.truncate(M.TERABYTE),t=this.truncate(M.GIGABYTE),n=this.truncate(M.MEGABYTE),a=this.truncate(M.KILOBYTE),i=this.truncate(M.BYTE),o=e,l=t.sub(e),u=n.sub(t),p=a.sub(n),g=i.sub(a);let y="";return o.isZero||(y+=`${o.terabytes}TB `),l.isZero||(y+=`${l.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),p.isZero||(y+=`${p.kilobytes}KB `),(!g.isZero||y==="")&&(y+=`${g.valueOf()}B`),y.trim()}static bytes(e=1){return new M(e)}static kilobytes(e=1){return M.bytes(e.valueOf()*1e3)}static megabytes(e=1){return M.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return M.megabytes(e.valueOf()*1e3)}static terabytes(e){return M.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(K,"BYTE",new K(1)),m(K,"KILOBYTE",K.kilobytes(1)),m(K,"MEGABYTE",K.megabytes(1)),m(K,"GIGABYTE",K.gigabytes(1)),m(K,"TERABYTE",K.terabytes(1)),m(K,"ZERO",new K(0)),m(K,"z",s.z.union([s.z.number().transform(r=>new K(r)),s.z.instanceof(K)]));let Hc=K;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)]);var Xc=Object.defineProperty,Qc=(r,e,t)=>e in r?Xc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nt=(r,e,t)=>(Qc(r,typeof e!="symbol"?e+"":e,t),t);const el=(...r)=>r.map(Oa).join(""),Oa=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),tl=r=>r.endsWith("/")?r.slice(0,-1):r,rl=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&"),Ur=class Lr{constructor({host:e,port:t,protocol:n="",pathPrefix:a=""}){nt(this,"protocol"),nt(this,"host"),nt(this,"port"),nt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Oa(a)}replace(e){return new Lr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Lr({...this,pathPrefix:el(this.path,e)})}toString(){return tl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};nt(Ur,"UNKNOWN",new Ur({host:"unknown",port:0}));let nl=Ur;var sl=Object.defineProperty,al=(r,e,t)=>e in r?sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Er=(r,e,t)=>(al(r,typeof e!="symbol"?e+"":e,t),t);const Ue=class extends Number{};Er(Ue,"Absolute",255),Er(Ue,"Default",1),Er(Ue,"z",s.z.union([s.z.instanceof(Ue),s.z.number().int().min(0).max(255).transform(r=>new Ue(r)),s.z.instanceof(Number).transform(r=>new Ue(r))]));s.z.object({name:s.z.string(),key:s.z.string()});const il=s.z.string().regex(/^\d+\.\d+\.\d+$/);s.z.object({version:il});class nr extends Error{constructor(e,t){super(e),j(this,"discriminator","FreighterError"),j(this,"type"),this.type=t}}const ol=r=>{if(r==null||typeof r!="object")return!1;const e=r;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},Br="unknown",Gn="nil",sr="freighter",pt=s.z.object({type:s.z.string(),data:s.z.string()});class cl{constructor(){j(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Gn,data:""};if(ol(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Br,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Gn)return null;if(e.type===Br)return new Hn(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Hn(e.data)}}const Ta=new cl,za=({encode:r,decode:e})=>Ta.register({encode:r,decode:e}),En=r=>Ta.decode(r);class Hn extends nr{constructor(e){super(e,Br)}}const ar="freighter.";class Ne extends nr{constructor(){super("EOF",sr)}}j(Ne,"TYPE",ar+"eof");class Pe extends nr{constructor(){super("StreamClosed",sr)}}j(Pe,"TYPE",ar+"stream_closed");class Ie extends nr{constructor(e={}){const{message:t="Unreachable",url:n=nl.UNKNOWN}=e;super(t,sr),j(this,"url"),this.url=n}}j(Ie,"TYPE",ar+"unreachable");const ll=r=>{if(r.type!==sr)return null;if(r instanceof Ne)return{type:Ne.TYPE,data:"EOF"};if(r instanceof Pe)return{type:Pe.TYPE,data:"StreamClosed"};if(r instanceof Ie)return{type:Ie.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},ul=r=>{if(!r.type.startsWith(ar))return null;switch(r.type){case Ne.TYPE:return new Ne;case Pe.TYPE:return new Pe;case Ie.TYPE:return new Ie;default:throw new Error(`Unknown error type: ${r.data}`)}};za({encode:ll,decode:ul});class Ea{constructor(){j(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const a=async i=>{if(n===this.middleware.length)return await t(i);const o=this.middleware[n];return n++,await o(i,a)};return await a(e)}}const Sa="Content-Type",Xn=r=>{if(va.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(a,i)=>await e(a,{...i,agent:n})};class hl extends Ea{constructor(e,t,n=!1){return super(),j(this,"endpoint"),j(this,"encoder"),j(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Xn(this.endpoint.protocol),new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[Sa]:this.encoder.contentType}}async send(e,t,n,a){t=n==null?void 0:n.parse(t);let i=null;const o=this.endpoint.child(e),l={};l.method="POST",l.body=this.encoder.encode(t??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async p=>{const g={...p,params:{}};l.headers={...this.headers,...p.params};let y;try{y=await Xn(p.protocol)(p.target,l)}catch(x){let Q=x;return Q.message==="Load failed"&&(Q=new Ie({url:o})),[g,Q]}const U=await y.arrayBuffer();if(y!=null&&y.ok)return a!=null&&(i=this.encoder.decode(U,a)),[g,null];try{if(y.status!==400)return[g,new Error(y.statusText)];const x=this.encoder.decode(U,pt),Q=En(x);return[g,Q]}catch(x){return[g,new Error(`[freighter] - failed to decode error: ${y.statusText}: ${x.message}`)]}});return[i,u]}}const w=async(r,e,t,n,a)=>{const[i,o]=await r.send(e,t,n,a);if(o!=null)throw o;return i},fl=()=>va.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),dl=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 yl{constructor(e,t,n,a){j(this,"encoder"),j(this,"reqSchema"),j(this,"resSchema"),j(this,"ws"),j(this,"serverClosed"),j(this,"sendClosed"),j(this,"receiveDataQueue",[]),j(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=a,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Ne;if(this.sendClosed)throw new Pe;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=En(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((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,dl)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:vl(e)?Ne.TYPE:Pe.TYPE,data:""}})}}const pl="freighterctx",gl=1e3,ml=1001,wl=[gl,ml],vl=r=>wl.includes(r.code),Na=class Aa extends Ea{constructor(e,t,n=!1){super(),j(this,"baseUrl"),j(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const a=fl();let i;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async l=>{const u=a(this.buildURL(e,l)),p={...l,params:{}};u.binaryType=Aa.MESSAGE_TYPE;const g=await this.wrapSocket(u,t,n);return g instanceof Error?[p,g]:(i=g,[p,null])});if(o!=null)throw o;return i}buildURL(e,t){const n=rl({[Sa]:this.encoder.contentType,...t.params},pl);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(a=>{e.onopen=()=>{a(new yl(e,this.encoder,t,n))},e.onerror=i=>{const o=i;a(new Error(o.message))}})}};j(Na,"MESSAGE_TYPE","arraybuffer");let bl=Na;const _e="sy.";class D extends Error{}c(D,"TYPE",_e+"validation");class qr extends D{constructor(t,n){super(t+": "+n);c(this,"field");c(this,"message");this.field=t,this.message=n}}c(qr,"TYPE",D.TYPE+".field");class We extends Error{}c(We,"TYPE",_e+"auth");class Lt extends We{}c(Lt,"TYPE",We.TYPE+".invalid-token");class xe extends Error{constructor(e){super(`
|
|
11
|
+
`).slice(0,-1).map(t=>e.parse(Mt(JSON.parse(t))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new ot(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Re?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Re?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(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let a=0;a<this.length;a++)n[a]=$o(this.dataType,e,this.data[a],t);return new F({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(S.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t: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()),tt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(S.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t: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()),tt(this._cachedMin,this.sampleOffset))}get bounds(){return at(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return tt(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return tt(n,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let n=0,a=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){a=o;break}n=o+1,e--}if(a===0&&(a=this.data.length),n>=a||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const i=this.data.slice(n,a);return this.dataType.equals(S.STRING)?new TextDecoder().decode(i):Mt(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,n=this.length-1;const a=Gi(e);for(;t<=n;){const i=Math.floor((t+n)/2),o=a(this.at(i,!0),e);if(o===0)return i;o<0?t=i+1:n=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(S.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:a}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==a)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Re){a===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(a).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,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=Re}as(e){if(e==="string"){if(!this.dataType.equals(S.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(S.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 at(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 Ro(this);return this.dataType.equals(S.JSON)?new jo(e):e}return new xo(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new F({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new F({data:this.buffer,dataType:this.dataType,timeRange:J.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Ro{constructor(e){if(d(this,"series"),d(this,"index"),d(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,t=this.series.data;for(;this.index<t.length&&t[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 _s;let jo=class{constructor(e){d(this,"wrapped"),d(this,_s,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Mt(JSON.parse(e.value))}}[Symbol.iterator](){return this}};_s=Symbol.toStringTag;var Us;let xo=class{constructor(e){d(this,"series"),d(this,"index"),d(this,Us,"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)}}[Symbol.iterator](){return this}};Us=Symbol.toStringTag;const tt=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);let Ls=class{constructor(e){if(d(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new S(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?S.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?J.ZERO:new J(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,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new ot(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Po(this.series)}};var Bs;let Po=class{constructor(e){d(this,"series"),d(this,"seriesIndex"),d(this,"internal"),d(this,Bs,"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())}[Symbol.iterator](){return this}};Bs=Symbol.toStringTag;const z=r=>Array.isArray(r)?r:[r],$e=s.z.number(),yt=s.z.object({name:s.z.string(),key:s.z.number(),rate:Ht.z,dataType:S.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),alias:s.z.string().optional()}),qs=yt.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:Ht.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),Do=(r,e)=>{let t=null;return e===0?r:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...n),e)}},Zo=new Error("request for lock canceled");var Mo=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function l(g){try{p(n.next(g))}catch(y){o(y)}}function u(g){try{p(n.throw(g))}catch(y){o(y)}}function p(g){g.done?i(g.value):a(g.value).then(l,u)}p((n=n.apply(r,e||[])).next())})};class _o{constructor(e,t=Zo){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,a)=>{const i={resolve:n,reject:a,weight:e,priority:t},o=Ys(this._queue,l=>t<=l.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return Mo(this,arguments,void 0,function*(t,n=1,a=0){const[i,o]=yield this.acquire(n,a);try{return yield t(i)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Uo(this._weightedWaiters[e-1],{resolve:n,priority:t})})}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 t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const a=n.findIndex(i=>i.priority<=e);(a===-1?n:n.splice(0,a)).forEach(i=>i.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Uo(r,e){const t=Ys(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function Ys(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var Lo=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function l(g){try{p(n.next(g))}catch(y){o(y)}}function u(g){try{p(n.throw(g))}catch(y){o(y)}}function p(g){g.done?i(g.value):a(g.value).then(l,u)}p((n=n.apply(r,e||[])).next())})};class Bo{constructor(e){this._semaphore=new _o(1,e)}acquire(){return Lo(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}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()}}var qo=Object.defineProperty,Yo=(r,e,t)=>e in r?qo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,j=(r,e,t)=>(Yo(r,typeof e!="symbol"?e+"":e,t),t),re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},T={},Xt={};Object.defineProperty(Xt,"__esModule",{value:!0});function Wo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Xt.default=Wo;var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0});function Ko(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Qt.default=Ko;var er={};Object.defineProperty(er,"__esModule",{value:!0});function Vo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}er.default=Vo;var fn={};Object.defineProperty(fn,"__esModule",{value:!0});function Fo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}fn.default=Fo;var dn={};Object.defineProperty(dn,"__esModule",{value:!0});function Jo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}dn.default=Jo;var yn={};Object.defineProperty(yn,"__esModule",{value:!0});function Go(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}yn.default=Go;var pn={};Object.defineProperty(pn,"__esModule",{value:!0});function Ho(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,a){return n+"_"+a.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}pn.default=Ho;var gn={};Object.defineProperty(gn,"__esModule",{value:!0});function Xo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,a){return t+n.charAt(0).toUpperCase()+n.slice(1)+a}):""}gn.default=Xo;var tr={};Object.defineProperty(tr,"__esModule",{value:!0});function Qo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}tr.default=Qo;var mn={},Me={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Me);var ec=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(mn,"__esModule",{value:!0});var ge=Me;function $t(r,e){if(e===void 0&&(e=ge.DefaultOption),!ge.isValidObject(r))return null;e=ge.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toLowerCase();e.recursive&&(ge.isValidObject(a)?ge.belongToTypes(a,e.keepTypesOnRecursion)||(a=$t(a,e)):e.recursiveInArray&&ge.isArrayObject(a)&&(a=ec(a).map(function(o){var l=o;if(ge.isValidObject(o))ge.belongToTypes(l,e.keepTypesOnRecursion)||(l=$t(o,e));else if(ge.isArrayObject(o)){var u=$t({key:o},e);l=u.key}return l}))),t[i]=a}),t}mn.default=$t;var wn={},tc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(wn,"__esModule",{value:!0});var me=Me;function Ct(r,e){if(e===void 0&&(e=me.DefaultOption),!me.isValidObject(r))return null;e=me.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toUpperCase();e.recursive&&(me.isValidObject(a)?me.belongToTypes(a,e.keepTypesOnRecursion)||(a=Ct(a,e)):e.recursiveInArray&&me.isArrayObject(a)&&(a=tc(a).map(function(o){var l=o;if(me.isValidObject(o))me.belongToTypes(l,e.keepTypesOnRecursion)||(l=Ct(o,e));else if(me.isArrayObject(o)){var u=Ct({key:o},e);l=u.key}return l}))),t[i]=a}),t}wn.default=Ct;var vn={},rc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(vn,"__esModule",{value:!0});var we=Me,nc=Xt;function Rt(r,e){if(e===void 0&&(e=we.DefaultOption),!we.isValidObject(r))return null;e=we.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=nc.default(n);e.recursive&&(we.isValidObject(a)?we.belongToTypes(a,e.keepTypesOnRecursion)||(a=Rt(a,e)):e.recursiveInArray&&we.isArrayObject(a)&&(a=rc(a).map(function(o){var l=o;if(we.isValidObject(o))we.belongToTypes(l,e.keepTypesOnRecursion)||(l=Rt(o,e));else if(we.isArrayObject(o)){var u=Rt({key:o},e);l=u.key}return l}))),t[i]=a}),t}vn.default=Rt;var bn={},sc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(bn,"__esModule",{value:!0});var ve=Me,ac=Qt;function jt(r,e){if(e===void 0&&(e=ve.DefaultOption),!ve.isValidObject(r))return null;e=ve.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=ac.default(n);e.recursive&&(ve.isValidObject(a)?ve.belongToTypes(a,e.keepTypesOnRecursion)||(a=jt(a,e)):e.recursiveInArray&&ve.isArrayObject(a)&&(a=sc(a).map(function(o){var l=o;if(ve.isValidObject(o))ve.belongToTypes(l,e.keepTypesOnRecursion)||(l=jt(o,e));else if(ve.isArrayObject(o)){var u=jt({key:o},e);l=u.key}return l}))),t[i]=a}),t}bn.default=jt;var On={},ic=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(On,"__esModule",{value:!0});var be=Me,oc=er;function xt(r,e){if(e===void 0&&(e=be.DefaultOption),!be.isValidObject(r))return null;e=be.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=oc.default(n);e.recursive&&(be.isValidObject(a)?be.belongToTypes(a,e.keepTypesOnRecursion)||(a=xt(a,e)):e.recursiveInArray&&be.isArrayObject(a)&&(a=ic(a).map(function(o){var l=o;if(be.isValidObject(o))be.belongToTypes(l,e.keepTypesOnRecursion)||(l=xt(o,e));else if(be.isArrayObject(o)){var u=xt({key:o},e);l=u.key}return l}))),t[i]=a}),t}On.default=xt;var Tn={},cc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(Tn,"__esModule",{value:!0});var Oe=Me,lc=tr;function Pt(r,e){if(e===void 0&&(e=Oe.DefaultOption),!Oe.isValidObject(r))return null;e=Oe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=lc.default(n);e.recursive&&(Oe.isValidObject(a)?Oe.belongToTypes(a,e.keepTypesOnRecursion)||(a=Pt(a,e)):e.recursiveInArray&&Oe.isArrayObject(a)&&(a=cc(a).map(function(o){var l=o;if(Oe.isValidObject(o))Oe.belongToTypes(l,e.keepTypesOnRecursion)||(l=Pt(o,e));else if(Oe.isArrayObject(o)){var u=Pt({key:o},e);l=u.key}return l}))),t[i]=a}),t}Tn.default=Pt;Object.defineProperty(T,"__esModule",{value:!0});T.kebabKeys=T.pascalKeys=T.snakeKeys=T.camelKeys=T.upperKeys=T.lowerKeys=T.toLowerCase=T.toUpperCase=T.toKebabCase=T.toHeaderCase=T.toSentenceCase=T.toTextCase=T.toPathCase=T.toDotCase=T.toPascalCase=T.toSnakeCase=T.toCamelCase=void 0;var Ws=Xt;T.toCamelCase=Ws.default;var Ks=Qt;T.toSnakeCase=Ks.default;var Vs=er;T.toPascalCase=Vs.default;var Fs=fn;T.toDotCase=Fs.default;var Js=dn;T.toPathCase=Js.default;var Gs=yn;T.toTextCase=Gs.default;var Hs=pn;T.toSentenceCase=Hs.default;var Xs=gn;T.toHeaderCase=Xs.default;var Qs=tr;T.toKebabCase=Qs.default;var ea=mn;T.lowerKeys=ea.default;var ta=wn;T.upperKeys=ta.default;var ra=vn;T.camelKeys=ra.default;var na=bn;T.snakeKeys=na.default;var sa=On;T.pascalKeys=sa.default;var aa=Tn;T.kebabKeys=aa.default;var ia=function(r){return String(r||"").toLowerCase()};T.toLowerCase=ia;var oa=function(r){return String(r||"").toUpperCase()};T.toUpperCase=oa;var uc={toCamelCase:Ws.default,toSnakeCase:Ks.default,toPascalCase:Vs.default,toDotCase:Fs.default,toPathCase:Js.default,toTextCase:Gs.default,toSentenceCase:Hs.default,toHeaderCase:Xs.default,toKebabCase:Qs.default,toUpperCase:oa,toLowerCase:ia,lowerKeys:ea.default,upperKeys:ta.default,camelKeys:ra.default,snakeKeys:na.default,pascalKeys:sa.default,kebabKeys:aa.default};T.default=uc;var ca=T;const la={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},hc=r=>ca.snakeKeys(r,la),fc=r=>ca.camelKeys(r,la),dc=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var yc=Object.defineProperty,pc=(r,e,t)=>e in r?yc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vr=(r,e,t)=>(pc(r,typeof e!="symbol"?e+"":e,t),t);let gc=class{constructor(){vr(this,"contentType","application/json"),vr(this,"decoder"),vr(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(r){return this.encoder.encode(this.encodeString(r)).buffer}decode(r,e){return this.decodeString(this.decoder.decode(r),e)}decodeString(r,e){const t=fc(JSON.parse(r));return e!=null?e.parse(t):t}encodeString(r){return JSON.stringify(hc(r),(e,t)=>ArrayBuffer.isView(t)?Array.from(t):dc(t)&&"encode_value"in t?typeof t.value=="bigint"?t.value.toString():t.value:typeof t=="bigint"?t.toString():t)}static registerCustomType(){}};new gc;const rr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const ua=s.z.object({width:s.z.number(),height:s.z.number()}),mc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),wc=["width","height"];s.z.enum(wc);const vc=["start","center","end"],bc=["signedWidth","signedHeight"];s.z.enum(bc);const Ut=s.z.object({x:s.z.number(),y:s.z.number()}),Oc=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Tc=["x","y"],ha=s.z.enum(Tc),fa=["top","right","bottom","left"];s.z.enum(fa);const zc=["left","right"],da=s.z.enum(zc),Ec=["top","bottom"],ya=s.z.enum(Ec),pa=["center"],Yn=s.z.enum(pa),Sc=[...fa,...pa],ga=s.z.enum(Sc);s.z.enum(vc);const Nc=["first","last"];s.z.enum(Nc);const Ac=s.z.object({lower:s.z.number(),upper:s.z.number()}),Ic=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Ac,rr]);s.z.union([Ic,rr]);s.z.union([ha,ga]);s.z.union([ha,ga,s.z.instanceof(String)]);const br=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return Wn(r);return Wn(t)},Wn=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;s.z.object({x:da.or(Yn),y:ya.or(Yn)});const kc=s.z.object({x:da,y:ya}),$c=Object.freeze({x:"left",y:"top"}),Cc=(r,e)=>r.x===e.x&&r.y===e.y,Kn=s.z.union([s.z.number(),Ut,rr,ua,mc,Oc]),Rc=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Vn=Object.freeze({x:0,y:0}),bt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:bt,left:bt,width:bt,height:bt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Ut,two:Ut,root:kc});const zn=(r,e,t=0,n=0,a)=>{const i={one:{...Vn},two:{...Vn},root:a??$c};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:r,y:e},i.two={x:i.one.x+t,y:i.one.y+n},i}return"one"in r&&"two"in r&&"root"in r?{...r,root:a??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(i.one={x:r.left,y:r.top},i.two={x:r.right,y:r.bottom},i):(i.one=r,e==null?i.two={x:i.one.x+t,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Or=r=>{const e=zn(r);return{lower:e.one.x,upper:e.two.x}},Tr=r=>{const e=zn(r);return{lower:e.one.y,upper:e.two.y}},jc=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r;var xc=Object.defineProperty,Pc=(r,e,t)=>e in r?xc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Se=(r,e,t)=>(Pc(r,typeof e!="symbol"?e+"":e,t),t);const Dc=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);s.z.object({offset:Kn,scale:Kn});const Zc=r=>(e,t,n,a)=>t==="dimension"?[e,n]:[e,a?n-r:n+r],Mc=r=>(e,t,n,a)=>[e,a?n/r:n*r],_c=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=r,u=i-a,p=l-o;if(t==="dimension")return[r,n*(p/u)];const g=(n-a)*(p/u)+o;return[r,g]},Uc=r=>(e,t,n)=>[r,n],Lc=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:a}=r;return[r,a-(t-n)]},Bc=r=>(e,t,n)=>{const{lower:a,upper:i}=r;return n=Dc(n,a,i),[e,n]},_r=class rt{constructor(){Se(this,"ops",[]),Se(this,"currBounds",null),Se(this,"currType",null),Se(this,"reversed",!1),this.ops=[]}static translate(e){return new rt().translate(e)}static magnify(e){return new rt().magnify(e)}static scale(e,t){return new rt().scale(e,t)}translate(e){const t=this.new(),n=Zc(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Mc(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=br(e,t),a=this.new(),i=_c(n);return i.type="scale",a.ops.push(i),a}clamp(e,t){const n=br(e,t),a=this.new(),i=Bc(n);return i.type="clamp",a.ops.push(i),a}reBound(e,t){const n=br(e,t),a=this.new(),i=Uc(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Lc();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new rt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||t.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&t.push([a,i])}),t.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}};Se(_r,"IDENTITY",new _r);let Fn=_r;const Jn=class ze{constructor(e=new Fn,t=new Fn,n=null){Se(this,"x"),Se(this,"y"),Se(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new ze().translate(e,t)}static translateX(e){return new ze().translateX(e)}static translateY(e){return new ze().translateY(e)}static clamp(e){return new ze().clamp(e)}static magnify(e){return new ze().magnify(e)}static scale(e){return new ze().scale(e)}static reBound(e){return new ze().reBound(e)}translate(e,t){const n=Rc(e,t),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(jc(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Cc(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Or(e)),t.y=t.y.scale(Tr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Or(e)),t.y=this.y.reBound(Tr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Or(e)),t.y=this.y.clamp(Tr(e)),t}copy(){const e=new ze;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 zn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Se(Jn,"IDENTITY",new Jn);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",qc=ma(),wa=["MacOS","Windows","Linux","Docker"],Yc=s.z.enum(wa);let zr;const Wc=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Kc=(r={})=>{const{force:e,default:t}=r;return e??zr??(zr=Wc(),zr??t)},va=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:wa,RUNTIME:qc,detect:ma,getOS:Kc,osZ:Yc},Symbol.toStringTag,{value:"Module"})),Vc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([ua,Vc,Ut,rr]);var Fc=Object.defineProperty,Jc=(r,e,t)=>e in r?Fc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e,t)=>(Jc(r,typeof e!="symbol"?e+"":e,t),t);const ba=(r,e)=>{const t=new q(e);if(![Y.DAY,Y.HOUR,Y.MINUTE,Y.SECOND,Y.MILLISECOND,Y.MICROSECOND,Y.NANOSECOND].some(a=>a.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof q?new q(n):new Y(n)},C=class b{constructor(e,t="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=b.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*b.MILLISECOND.valueOf();else if(typeof e=="string")this.value=b.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=b.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=b.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=b.MAX:e=b.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const a=new Date(e,t-1,n,0,0,0,0);return new b(BigInt(a.getTime())*b.MILLISECOND.valueOf()).truncate(b.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let u=b.hours(parseInt(n??"00",10)).add(b.minutes(parseInt(a??"00",10))).add(b.seconds(parseInt(o??"00",10))).add(b.milliseconds(parseInt(l??"00",10)));return t==="local"&&(u=u.add(b.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return b.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new b(BigInt(n.getTime())*b.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(b.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new Y(BigInt(new Date().getTimezoneOffset())*b.MINUTE.valueOf())}static since(e){return new b().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new b(e).valueOf()}span(e){return this.range(e).span}range(e){return new Gc(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 b(e).valueOf()}afterEq(e){return this.valueOf()>=new b(e).valueOf()}before(e){return this.valueOf()<new b(e).valueOf()}beforeEq(e){return this.valueOf()<=new b(e).valueOf()}add(e){return new b(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new b(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(b.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ba(this,e)}get isToday(){return this.truncate(Y.DAY).equals(b.now().truncate(Y.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new b(new Date)}static max(...e){let t=b.MIN;for(const n of e){const a=new b(n);a.after(t)&&(t=a)}return t}static min(...e){let t=b.MAX;for(const n of e){const a=new b(n);a.before(t)&&(t=a)}return t}static nanoseconds(e){return new b(e)}static microseconds(e){return b.nanoseconds(e*1e3)}static milliseconds(e){return b.microseconds(e*1e3)}static seconds(e){return b.milliseconds(e*1e3)}static minutes(e){return b.seconds(e*60)}static hours(e){return b.minutes(e*60)}static days(e){return b.hours(e*24)}};m(C,"NANOSECOND",C.nanoseconds(1)),m(C,"MICROSECOND",C.microseconds(1)),m(C,"MILLISECOND",C.milliseconds(1)),m(C,"SECOND",C.seconds(1)),m(C,"MINUTE",C.minutes(1)),m(C,"HOUR",C.hours(1)),m(C,"DAY",C.days(1)),m(C,"MAX",new C((1n<<63n)-1n)),m(C,"MIN",new C(0)),m(C,"ZERO",new C(0)),m(C,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new C(r.value)),s.z.string().transform(r=>new C(BigInt(r))),s.z.instanceof(Number).transform(r=>new C(r)),s.z.number().transform(r=>new C(r)),s.z.instanceof(C)]));let q=C;const R=class I{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 I(e).valueOf()}greaterThan(e){return this.valueOf()>new I(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new I(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new I(e).valueOf()}remainder(e){return ba(this,e)}truncate(e){return new I(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(I.DAY),t=this.truncate(I.HOUR),n=this.truncate(I.MINUTE),a=this.truncate(I.SECOND),i=this.truncate(I.MILLISECOND),o=this.truncate(I.MICROSECOND),l=this.truncate(I.NANOSECOND),u=e,p=t.sub(e),g=n.sub(t),y=a.sub(n),U=i.sub(a),x=o.sub(i),Q=l.sub(o);let D="";return u.isZero||(D+=`${u.days}d `),p.isZero||(D+=`${p.hours}h `),g.isZero||(D+=`${g.minutes}m `),y.isZero||(D+=`${y.seconds}s `),U.isZero||(D+=`${U.milliseconds}ms `),x.isZero||(D+=`${x.microseconds}µs `),Q.isZero||(D+=`${Q.nanoseconds}ns`),D.trim()}get days(){return Number(this.valueOf())/Number(I.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(I.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(I.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(I.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(I.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(I.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new I(e).valueOf()}add(e){return new I(this.valueOf()+new I(e).valueOf())}sub(e){return new I(this.valueOf()-new I(e).valueOf())}static nanoseconds(e=1){return new I(e)}static microseconds(e=1){return I.nanoseconds(e*1e3)}static milliseconds(e=1){return I.microseconds(e*1e3)}static seconds(e=1){return I.milliseconds(e*1e3)}static minutes(e){return I.seconds(e.valueOf()*60)}static hours(e){return I.minutes(e*60)}static days(e){return I.hours(e*24)}};m(R,"NANOSECOND",R.nanoseconds(1)),m(R,"MICROSECOND",R.microseconds(1)),m(R,"MILLISECOND",R.milliseconds(1)),m(R,"SECOND",R.seconds(1)),m(R,"MINUTE",R.minutes(1)),m(R,"HOUR",R.hours(1)),m(R,"DAY",R.days(1)),m(R,"MAX",new R((1n<<63n)-1n)),m(R,"MIN",new R(0)),m(R,"ZERO",new R(0)),m(R,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new R(r.value)),s.z.string().transform(r=>new R(BigInt(r))),s.z.instanceof(Number).transform(r=>new R(r)),s.z.number().transform(r=>new R(r)),s.z.instanceof(R)]));let Y=R;const Ot=class Dt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Dt(e).valueOf()}get period(){return Y.seconds(1/this.valueOf())}sampleCount(e){return new Y(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new H(t).valueOf()}span(e){return Y.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Dt(e)}static khz(e){return Dt.hz(e*1e3)}};m(Ot,"z",s.z.union([s.z.number().transform(r=>new Ot(r)),s.z.instanceof(Number).transform(r=>new Ot(r)),s.z.instanceof(Ot)]));const B=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new Hc(r*this.valueOf())}};m(B,"UNKNOWN",new B(0)),m(B,"BIT128",new B(16)),m(B,"BIT64",new B(8)),m(B,"BIT32",new B(4)),m(B,"BIT16",new B(2)),m(B,"BIT8",new B(1)),m(B,"z",s.z.union([s.z.number().transform(r=>new B(r)),s.z.instanceof(Number).transform(r=>new B(r)),s.z.instanceof(B)]));let H=B;const ie=class Zt{constructor(e,t){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new q(e.start),this.end=new q(e.end)):(this.start=new q(e),this.end=new q(t))}get span(){return new Y(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}swap(){return new Zt(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,t=Y.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 a=q.max(n.start,e.start),i=q.min(n.end,e.end);return i.before(a)?!1:new Y(i.sub(a)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=t.valueOf()&&a<=t.valueOf()}contains(e){return e instanceof Zt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Zt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};m(ie,"MAX",new ie(q.MIN,q.MAX)),m(ie,"MIN",new ie(q.MAX,q.MIN)),m(ie,"ZERO",new ie(q.ZERO,q.ZERO)),m(ie,"z",s.z.union([s.z.object({start:q.z,end:q.z}).transform(r=>new ie(r.start,r.end)),s.z.instanceof(ie)]));let Gc=ie;const f=class oe extends String{constructor(e){if(e instanceof oe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=oe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(oe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=oe.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()}toString(){return this.valueOf()}get isVariable(){return this.equals(oe.JSON)||this.equals(oe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(oe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=oe.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 oe.BIG_INT_TYPES.some(e=>e.equals(this))}};m(f,"UNKNOWN",new f("unknown")),m(f,"FLOAT64",new f("float64")),m(f,"FLOAT32",new f("float32")),m(f,"INT64",new f("int64")),m(f,"INT32",new f("int32")),m(f,"INT16",new f("int16")),m(f,"INT8",new f("int8")),m(f,"UINT64",new f("uint64")),m(f,"UINT32",new f("uint32")),m(f,"UINT16",new f("uint16")),m(f,"UINT8",new f("uint8")),m(f,"BOOLEAN",f.UINT8),m(f,"TIMESTAMP",new f("timestamp")),m(f,"UUID",new f("uuid")),m(f,"STRING",new f("string")),m(f,"JSON",new f("json")),m(f,"ARRAY_CONSTRUCTORS",new Map([[f.UINT8.toString(),Uint8Array],[f.UINT16.toString(),Uint16Array],[f.UINT32.toString(),Uint32Array],[f.UINT64.toString(),BigUint64Array],[f.FLOAT32.toString(),Float32Array],[f.FLOAT64.toString(),Float64Array],[f.INT8.toString(),Int8Array],[f.INT16.toString(),Int16Array],[f.INT32.toString(),Int32Array],[f.INT64.toString(),BigInt64Array],[f.TIMESTAMP.toString(),BigInt64Array],[f.STRING.toString(),Uint8Array],[f.JSON.toString(),Uint8Array],[f.UUID.toString(),Uint8Array]])),m(f,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,f.UINT8],[Uint16Array.name,f.UINT16],[Uint32Array.name,f.UINT32],[BigUint64Array.name,f.UINT64],[Float32Array.name,f.FLOAT32],[Float64Array.name,f.FLOAT64],[Int8Array.name,f.INT8],[Int16Array.name,f.INT16],[Int32Array.name,f.INT32],[BigInt64Array.name,f.INT64]])),m(f,"DENSITIES",new Map([[f.UINT8.toString(),H.BIT8],[f.UINT16.toString(),H.BIT16],[f.UINT32.toString(),H.BIT32],[f.UINT64.toString(),H.BIT64],[f.FLOAT32.toString(),H.BIT32],[f.FLOAT64.toString(),H.BIT64],[f.INT8.toString(),H.BIT8],[f.INT16.toString(),H.BIT16],[f.INT32.toString(),H.BIT32],[f.INT64.toString(),H.BIT64],[f.TIMESTAMP.toString(),H.BIT64],[f.STRING.toString(),H.UNKNOWN],[f.JSON.toString(),H.UNKNOWN],[f.UUID.toString(),H.BIT128]])),m(f,"ALL",[f.UNKNOWN,f.FLOAT64,f.FLOAT32,f.INT64,f.INT32,f.INT16,f.INT8,f.UINT64,f.UINT32,f.UINT16,f.UINT8,f.TIMESTAMP,f.UUID,f.STRING,f.JSON]),m(f,"BIG_INT_TYPES",[f.INT64,f.UINT64,f.TIMESTAMP]),m(f,"z",s.z.union([s.z.string().transform(r=>new f(r)),s.z.instanceof(f)]));const K=class M extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return M.bytes(this.valueOf()+e.valueOf())}sub(e){return M.bytes(this.valueOf()-e.valueOf())}truncate(e){return new M(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return M.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/M.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/M.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/M.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/M.TERABYTE.valueOf()}toString(){const e=this.truncate(M.TERABYTE),t=this.truncate(M.GIGABYTE),n=this.truncate(M.MEGABYTE),a=this.truncate(M.KILOBYTE),i=this.truncate(M.BYTE),o=e,l=t.sub(e),u=n.sub(t),p=a.sub(n),g=i.sub(a);let y="";return o.isZero||(y+=`${o.terabytes}TB `),l.isZero||(y+=`${l.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),p.isZero||(y+=`${p.kilobytes}KB `),(!g.isZero||y==="")&&(y+=`${g.valueOf()}B`),y.trim()}static bytes(e=1){return new M(e)}static kilobytes(e=1){return M.bytes(e.valueOf()*1e3)}static megabytes(e=1){return M.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return M.megabytes(e.valueOf()*1e3)}static terabytes(e){return M.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(K,"BYTE",new K(1)),m(K,"KILOBYTE",K.kilobytes(1)),m(K,"MEGABYTE",K.megabytes(1)),m(K,"GIGABYTE",K.gigabytes(1)),m(K,"TERABYTE",K.terabytes(1)),m(K,"ZERO",new K(0)),m(K,"z",s.z.union([s.z.number().transform(r=>new K(r)),s.z.instanceof(K)]));let Hc=K;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)]);var Xc=Object.defineProperty,Qc=(r,e,t)=>e in r?Xc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nt=(r,e,t)=>(Qc(r,typeof e!="symbol"?e+"":e,t),t);const el=(...r)=>r.map(Oa).join(""),Oa=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),tl=r=>r.endsWith("/")?r.slice(0,-1):r,rl=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&"),Ur=class Lr{constructor({host:e,port:t,protocol:n="",pathPrefix:a=""}){nt(this,"protocol"),nt(this,"host"),nt(this,"port"),nt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Oa(a)}replace(e){return new Lr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Lr({...this,pathPrefix:el(this.path,e)})}toString(){return tl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};nt(Ur,"UNKNOWN",new Ur({host:"unknown",port:0}));let nl=Ur;var sl=Object.defineProperty,al=(r,e,t)=>e in r?sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Er=(r,e,t)=>(al(r,typeof e!="symbol"?e+"":e,t),t);const Ue=class extends Number{};Er(Ue,"Absolute",255),Er(Ue,"Default",1),Er(Ue,"z",s.z.union([s.z.instanceof(Ue),s.z.number().int().min(0).max(255).transform(r=>new Ue(r)),s.z.instanceof(Number).transform(r=>new Ue(r))]));s.z.object({name:s.z.string(),key:s.z.string()});const il=s.z.string().regex(/^\d+\.\d+\.\d+$/);s.z.object({version:il});class nr extends Error{constructor(e,t){super(e),j(this,"discriminator","FreighterError"),j(this,"type"),this.type=t}}const ol=r=>{if(r==null||typeof r!="object")return!1;const e=r;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},Br="unknown",Gn="nil",sr="freighter",pt=s.z.object({type:s.z.string(),data:s.z.string()});class cl{constructor(){j(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Gn,data:""};if(ol(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Br,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Gn)return null;if(e.type===Br)return new Hn(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Hn(e.data)}}const Ta=new cl,za=({encode:r,decode:e})=>Ta.register({encode:r,decode:e}),En=r=>Ta.decode(r);class Hn extends nr{constructor(e){super(e,Br)}}const ar="freighter.";class Ne extends nr{constructor(){super("EOF",sr)}}j(Ne,"TYPE",ar+"eof");class De extends nr{constructor(){super("StreamClosed",sr)}}j(De,"TYPE",ar+"stream_closed");class Ie extends nr{constructor(e={}){const{message:t="Unreachable",url:n=nl.UNKNOWN}=e;super(t,sr),j(this,"url"),this.url=n}}j(Ie,"TYPE",ar+"unreachable");const ll=r=>{if(r.type!==sr)return null;if(r instanceof Ne)return{type:Ne.TYPE,data:"EOF"};if(r instanceof De)return{type:De.TYPE,data:"StreamClosed"};if(r instanceof Ie)return{type:Ie.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},ul=r=>{if(!r.type.startsWith(ar))return null;switch(r.type){case Ne.TYPE:return new Ne;case De.TYPE:return new De;case Ie.TYPE:return new Ie;default:throw new Error(`Unknown error type: ${r.data}`)}};za({encode:ll,decode:ul});class Ea{constructor(){j(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const a=async i=>{if(n===this.middleware.length)return await t(i);const o=this.middleware[n];return n++,await o(i,a)};return await a(e)}}const Sa="Content-Type",Xn=r=>{if(va.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(a,i)=>await e(a,{...i,agent:n})};class hl extends Ea{constructor(e,t,n=!1){return super(),j(this,"endpoint"),j(this,"encoder"),j(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Xn(this.endpoint.protocol),new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[Sa]:this.encoder.contentType}}async send(e,t,n,a){t=n==null?void 0:n.parse(t);let i=null;const o=this.endpoint.child(e),l={};l.method="POST",l.body=this.encoder.encode(t??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async p=>{const g={...p,params:{}};l.headers={...this.headers,...p.params};let y;try{y=await Xn(p.protocol)(p.target,l)}catch(x){let Q=x;return Q.message==="Load failed"&&(Q=new Ie({url:o})),[g,Q]}const U=await y.arrayBuffer();if(y!=null&&y.ok)return a!=null&&(i=this.encoder.decode(U,a)),[g,null];try{if(y.status!==400)return[g,new Error(y.statusText)];const x=this.encoder.decode(U,pt),Q=En(x);return[g,Q]}catch(x){return[g,new Error(`[freighter] - failed to decode error: ${y.statusText}: ${x.message}`)]}});return[i,u]}}const w=async(r,e,t,n,a)=>{const[i,o]=await r.send(e,t,n,a);if(o!=null)throw o;return i},fl=()=>va.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),dl=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 yl{constructor(e,t,n,a){j(this,"encoder"),j(this,"reqSchema"),j(this,"resSchema"),j(this,"ws"),j(this,"serverClosed"),j(this,"sendClosed"),j(this,"receiveDataQueue",[]),j(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=a,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Ne;if(this.sendClosed)throw new De;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=En(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((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,dl)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:vl(e)?Ne.TYPE:De.TYPE,data:""}})}}const pl="freighterctx",gl=1e3,ml=1001,wl=[gl,ml],vl=r=>wl.includes(r.code),Na=class Aa extends Ea{constructor(e,t,n=!1){super(),j(this,"baseUrl"),j(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const a=fl();let i;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async l=>{const u=a(this.buildURL(e,l)),p={...l,params:{}};u.binaryType=Aa.MESSAGE_TYPE;const g=await this.wrapSocket(u,t,n);return g instanceof Error?[p,g]:(i=g,[p,null])});if(o!=null)throw o;return i}buildURL(e,t){const n=rl({[Sa]:this.encoder.contentType,...t.params},pl);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(a=>{e.onopen=()=>{a(new yl(e,this.encoder,t,n))},e.onerror=i=>{const o=i;a(new Error(o.message))}})}};j(Na,"MESSAGE_TYPE","arraybuffer");let bl=Na;const _e="sy.";class P extends Error{}c(P,"TYPE",_e+"validation");class qr extends P{constructor(t,n){super(t+": "+n);c(this,"field");c(this,"message");this.field=t,this.message=n}}c(qr,"TYPE",P.TYPE+".field");class We extends Error{}c(We,"TYPE",_e+"auth");class Lt extends We{}c(Lt,"TYPE",We.TYPE+".invalid-token");class xe extends Error{constructor(e){super(`
|
|
12
12
|
Unexpected error encountered:
|
|
13
13
|
|
|
14
14
|
${e}
|
|
15
15
|
|
|
16
16
|
Please report this to the Synnax team.
|
|
17
|
-
`)}}c(xe,"TYPE",_e+"unexpected");class ee extends Error{}c(ee,"TYPE",_e+"query");class ct extends ee{}c(ct,"TYPE",ee.TYPE+".not_found");class lt extends ee{}c(lt,"TYPE",ee.TYPE+".multiple_results");class Bt extends Error{constructor(t,n){super(t);c(this,"path");this.path=n}}c(Bt,"TYPE",_e+"route");class ut extends Error{}c(ut,"TYPE",_e+"control");class Yr extends ut{}c(Yr,"TYPE",ut.TYPE+".unauthorized");class Ol extends Error{}const Tl=r=>{if(!r.type.startsWith(_e))return null;if(r.type.startsWith(D.TYPE)){if(r.type===qr.TYPE){const e=r.data.split(": ");return e.length<2?new D(r.data):new qr(e[0],e[1])}return new D(r.data)}return r.type.startsWith(We.TYPE)?r.type.startsWith(Lt.TYPE)?new Lt(r.data):new We(r.data):r.type.startsWith(xe.TYPE)?new xe(r.data):r.type.startsWith(ee.TYPE)?r.type.startsWith(ct.TYPE)?new ct(r.data):r.type.startsWith(lt.TYPE)?new lt(r.data):new ee(r.data):r.type.startsWith(ut.TYPE)?r.type.startsWith(Yr.TYPE)?new Yr(r.data):new ut(r.data):r.type.startsWith(Bt.TYPE)?new Bt(r.data,r.data):new xe(r.data)},zl=()=>{throw new Error("Not implemented")};za({encode:zl,decode:Tl});const El=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof Ie?[t,new Ie({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},Ia=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var Sl=Object.defineProperty,Nl=(r,e,t)=>e in r?Sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sr=(r,e,t)=>(Nl(r,typeof e!="symbol"?e+"":e,t),t);let ka=class{constructor(){Sr(this,"contentType","application/json"),Sr(this,"decoder"),Sr(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const n=Mt(JSON.parse(e));return t!=null?t.parse(n):n}encodeString(e){return JSON.stringify(Fi(e),(t,n)=>ArrayBuffer.isView(n)?Array.from(n):Ia(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}};const $a=new ka,Al=[$a],Ve=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Al,JSONEncoderDecoder:ka,JSON_ECD:$a},Symbol.toStringTag,{value:"Module"}));var Il=Object.defineProperty,kl=(r,e,t)=>e in r?Il(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wr=(r,e,t)=>(kl(r,typeof e!="symbol"?e+"":e,t),t);class $l{constructor(e,t){Wr(this,"handlers"),Wr(this,"transform"),this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[n,a]=this.transform(e);if(!a)return;t=n}this.handlers.forEach((n,a)=>a(t))}}let Cl=class{constructor(e){Wr(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Kr=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Cl,Observer:$l},Symbol.toStringTag,{value:"Module"})),Sn=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Rl=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Rl();const jl=["MacOS","Windows","Linux","Docker"];s.z.enum(jl);const Qn=r=>[...new Set(r)];var xl=Object.defineProperty,Dl=(r,e,t)=>e in r?xl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e,t)=>(Dl(r,typeof e!="symbol"?e+"":e,t),t);const Pl=(...r)=>r.map(Ca).join(""),Ca=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Zl=r=>r.endsWith("/")?r.slice(0,-1):r,Vr=class Fr{constructor({host:e,port:t,protocol:n="",pathPrefix:a=""}){st(this,"protocol"),st(this,"host"),st(this,"port"),st(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Ca(a)}replace(e){return new Fr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Fr({...this,pathPrefix:Pl(this.path,e)})}toString(){return Zl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};st(Vr,"UNKNOWN",new Vr({host:"unknown",port:0}));let Ml=Vr;var _l=Object.defineProperty,Ul=(r,e,t)=>e in r?_l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nr=(r,e,t)=>(Ul(r,typeof e!="symbol"?e+"":e,t),t);const je=class extends Number{};Nr(je,"Absolute",255),Nr(je,"Default",1),Nr(je,"z",s.z.union([s.z.instanceof(je),s.z.number().int().min(0).max(255).transform(r=>new je(r)),s.z.instanceof(Number).transform(r=>new je(r))]));let Ra=je;const ja=s.z.object({name:s.z.string(),key:s.z.string()}),Ll=r=>s.z.object({subject:ja,resource:r,authority:Ra.z}),Bl=(...r)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=r.includes(t.to.resource)),t.from!=null&&!n&&(n=r.includes(t.from.resource)),n}),Ke=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ra,filterTransfersByChannelKey:Bl,stateZ:Ll,subjectZ:ja},Symbol.toStringTag,{value:"Module"})),ql=s.z.string().regex(/^\d+\.\d+\.\d+$/);s.z.object({version:ql});const ir=(r,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(r);let a=z(r);const i=a[0],o=typeof i;let l;return o==="string"&&t&&!isNaN(parseInt(i))&&"number"in e?(l=e.number,a=a.map(u=>parseInt(u))):l=e[o],{single:n,variant:l,normalized:a,actual:r}},or=(r,e,t,n)=>{if(n){if(t.length===0)throw new ct(`${r} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new lt(`Expected one ${r} matching ${JSON.stringify(e)}, but found ${t.length}`)}},Fe=r=>s.z.union([s.z.null().transform(()=>[]),r.array()]),Yl=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:S.z.array().optional(),notDataTypes:S.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),Wl=s.z.object({channels:Fe(yt)}),ke=r=>ir(r,{number:"keys",string:"names"}),Wt=class Wt{constructor(e){c(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){const n=ke(e),{variant:a}=n;let{normalized:i}=n;return a==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[a]:i,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(Wt.ENDPOINT,e,Yl,Wl);if(n!=null)throw n;return t.channels}};c(Wt,"ENDPOINT","/channel/retrieve");let ht=Wt;class Nn{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,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=ir(e,{string:"names",number:"keys"}),a=[],i=[];if(n.forEach(l=>{const u=this.getFromCache(l);u!=null?a.push(u):i.push(l)}),i.length===0)return a;const o=await this.wrapped.retrieve(i,t);return this.updateCache(o),a.concat(o)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}class xa{constructor(e,t){c(this,"mu",new Bo);c(this,"requests",new Map);c(this,"wrapped");c(this,"debouncedRun");this.wrapped=e,this.debouncedRun=Po(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=ke(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((i,o)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:i,reject:o}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(a=>e.add(a)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,a)=>n.resolve(t.filter(i=>a.includes(i.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const Da=async(r,e)=>{const{normalized:t}=ke(e),n=await r.retrieve(t),a=[];if(t.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&a.push(i)}),a.length>0)throw new ee(`Could not find channels: ${JSON.stringify(a)}`);return n};class An{constructor({dataType:e,rate:t,name:n,leaseholder:a=0,key:i=0,isIndex:o=!1,index:l=0,internal:u=!1,frameClient:p,alias:g}){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");this.key=i,this.name=n,this.rate=new Ht(t??0),this.dataType=new S(e),this.leaseholder=a,this.index=l,this.isIndex=o,this.internal=u,this.alias=g,this._frameClient=p??null}get framer(){if(this._frameClient==null)throw new D("cannot read from a channel that has not been created");return this._frameClient}get payload(){return yt.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})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let Pa=class{constructor(e,t,n,a){c(this,"type","channel");c(this,"frameClient");c(this,"client");c(this,"retriever");c(this,"writer");this.frameClient=e,this.retriever=t,this.client=n,this.writer=a}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,a=!Array.isArray(e);let i=z(e),o=[];if(n){const l=await this.retriever.retrieve(i.map(p=>p.name)),u=new Set(l.map(p=>p.name));i=i.filter(p=>!u.has(p.name)),o=this.sugar(l)}return o=o.concat(this.sugar(await this.writer.create(i))),a?o[0]:o}async retrieve(e,t){const n=!Array.isArray(e),a=this.sugar(await this.retriever.retrieve(e,t));return or("channel",e,a,n),n?a[0]:a}async search(e,t){return this.sugar(await this.retriever.search(e,t))}async delete(e){const{normalized:t,variant:n}=ke(e);return n==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}async rename(e,t){return await this.writer.rename(z(e),z(t))}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new Nn(new xa(new ht(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new An({...n,frameClient:t}))}};const Kl=s.z.object({channels:qs.array()}),Vl=s.z.object({channels:yt.array()}),Fl=s.z.object({keys:$e.array().optional(),names:s.z.string().array().optional()}),Jl=s.z.object({}),Gl=s.z.object({keys:$e.array(),names:s.z.string().array()}),Hl=s.z.object({}),Xl="/channel/create",Ql="/channel/delete",eu="/channel/rename";let Za=class{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Xl,{channels:e},Kl,Vl)).channels}async delete(e){await w(this.client,Ql,e,Fl,Jl)}async rename(e,t){await w(this.client,eu,{keys:e,names:t},Gl,Hl)}};const tu=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Nn,Channel:An,Client:Pa,ClusterRetriever:ht,DebouncedBatchRetriever:xa,Writer:Za,analyzeChannelParams:ke,keyZ:$e,newPayload:qs,payload:yt,retrieveRequired:Da},Symbol.toStringTag,{value:"Module"})),ru=s.z.object({key:s.z.string(),username:s.z.string()}),nu=s.z.object({username:s.z.string(),password:s.z.string()}),su=s.z.object({token:s.z.string(),user:ru}),es="/auth/login",au=3;let iu=class{constructor(e,t){c(this,"token");c(this,"client");c(this,"credentials");c(this,"authenticating");c(this,"authenticated");c(this,"user");c(this,"retryCount");this.client=e,this.authenticated=!1,this.credentials=t,this.retryCount=0}middleware(){const e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(es)){this.authenticating==null&&(this.authenticating=new Promise((l,u)=>{this.client.send(es,this.credentials,nu,su).then(([p,g])=>{if(g!=null)return l(g);this.token=p==null?void 0:p.token,this.user=p==null?void 0:p.user,this.authenticated=!0,l(null)}).catch(u)}));const o=await this.authenticating;if(o!=null)return[t,o]}t.params.Authorization=`Bearer ${this.token}`;const[a,i]=await n(t);return i instanceof Lt&&this.retryCount<au?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[a,i])};return e}};const ou=["disconnected","connecting","connected","failed"],Ma=s.z.enum(ou),_a=s.z.object({status:Ma,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string()}),cu=s.z.object({clusterKey:s.z.string()}),ts={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Le=class Le{constructor(e,t=N.seconds(30),n){c(this,"_state");c(this,"pollFrequency",N.seconds(30));c(this,"client");c(this,"name");c(this,"interval");c(this,"onChangeHandlers",[]);this._state={...ts},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,a]=await this.client.send(Le.ENDPOINT,{},s.z.object({}),cu);if(a!=null)throw a;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==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(Le,"ENDPOINT","/connectivity/check"),c(Le,"DEFAULT",ts),c(Le,"connectionStateZ",_a);let ft=Le;const lu=Object.freeze(Object.defineProperty({__proto__:null,Checker:ft,state:_a,status:Ma},Symbol.toStringTag,{value:"Module"})),rs=r=>{const e=z(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ns=(r,e)=>{const t=z(r);if(t.length===e.length)return;const n=rs(r);throw rs===null?new D("[Frame] - channel keys or names must be provided when constructing a frame."):new D(`[Frame] - ${n}s and arrays must be the same length.
|
|
18
|
-
Got ${t.length} ${n}s and ${e.length} arrays.`)};class _{constructor(e=[],t=[]){c(this,"columns",[]);c(this,"series",[]);if(e instanceof _){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((a,i)=>this.push(i,...z(a)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const a=e,i=a.series.map(o=>La(o));ns(a.keys,i),a.keys.forEach((o,l)=>this.push(o,i[l]))}else Object.entries(e).forEach(([a,i])=>{const o=parseInt(a);if(isNaN(o))this.push(a,...z(i));else return this.push(o,...z(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const a=z(t),i=z(e);ns(i,a),a.forEach((o,l)=>this.push(i[l],o));return}throw new
|
|
17
|
+
`)}}c(xe,"TYPE",_e+"unexpected");class ee extends Error{}c(ee,"TYPE",_e+"query");class ct extends ee{}c(ct,"TYPE",ee.TYPE+".not_found");class lt extends ee{}c(lt,"TYPE",ee.TYPE+".multiple_results");class Bt extends Error{constructor(t,n){super(t);c(this,"path");this.path=n}}c(Bt,"TYPE",_e+"route");class ut extends Error{}c(ut,"TYPE",_e+"control");class Yr extends ut{}c(Yr,"TYPE",ut.TYPE+".unauthorized");class Ol extends Error{}const Tl=r=>{if(!r.type.startsWith(_e))return null;if(r.type.startsWith(P.TYPE)){if(r.type===qr.TYPE){const e=r.data.split(": ");return e.length<2?new P(r.data):new qr(e[0],e[1])}return new P(r.data)}return r.type.startsWith(We.TYPE)?r.type.startsWith(Lt.TYPE)?new Lt(r.data):new We(r.data):r.type.startsWith(xe.TYPE)?new xe(r.data):r.type.startsWith(ee.TYPE)?r.type.startsWith(ct.TYPE)?new ct(r.data):r.type.startsWith(lt.TYPE)?new lt(r.data):new ee(r.data):r.type.startsWith(ut.TYPE)?r.type.startsWith(Yr.TYPE)?new Yr(r.data):new ut(r.data):r.type.startsWith(Bt.TYPE)?new Bt(r.data,r.data):new xe(r.data)},zl=()=>{throw new Error("Not implemented")};za({encode:zl,decode:Tl});const El=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof Ie?[t,new Ie({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},Ia=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var Sl=Object.defineProperty,Nl=(r,e,t)=>e in r?Sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sr=(r,e,t)=>(Nl(r,typeof e!="symbol"?e+"":e,t),t);let ka=class{constructor(){Sr(this,"contentType","application/json"),Sr(this,"decoder"),Sr(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const n=Mt(JSON.parse(e));return t!=null?t.parse(n):n}encodeString(e){return JSON.stringify(Fi(e),(t,n)=>ArrayBuffer.isView(n)?Array.from(n):Ia(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}};const $a=new ka,Al=[$a],Ve=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Al,JSONEncoderDecoder:ka,JSON_ECD:$a},Symbol.toStringTag,{value:"Module"}));var Il=Object.defineProperty,kl=(r,e,t)=>e in r?Il(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wr=(r,e,t)=>(kl(r,typeof e!="symbol"?e+"":e,t),t);class $l{constructor(e,t){Wr(this,"handlers"),Wr(this,"transform"),this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[n,a]=this.transform(e);if(!a)return;t=n}this.handlers.forEach((n,a)=>a(t))}}let Cl=class{constructor(e){Wr(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Kr=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Cl,Observer:$l},Symbol.toStringTag,{value:"Module"})),Sn=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Rl=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Rl();const jl=["MacOS","Windows","Linux","Docker"];s.z.enum(jl);const Qn=r=>[...new Set(r)];var xl=Object.defineProperty,Pl=(r,e,t)=>e in r?xl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e,t)=>(Pl(r,typeof e!="symbol"?e+"":e,t),t);const Dl=(...r)=>r.map(Ca).join(""),Ca=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Zl=r=>r.endsWith("/")?r.slice(0,-1):r,Vr=class Fr{constructor({host:e,port:t,protocol:n="",pathPrefix:a=""}){st(this,"protocol"),st(this,"host"),st(this,"port"),st(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Ca(a)}replace(e){return new Fr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Fr({...this,pathPrefix:Dl(this.path,e)})}toString(){return Zl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};st(Vr,"UNKNOWN",new Vr({host:"unknown",port:0}));let Ml=Vr;var _l=Object.defineProperty,Ul=(r,e,t)=>e in r?_l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nr=(r,e,t)=>(Ul(r,typeof e!="symbol"?e+"":e,t),t);const je=class extends Number{};Nr(je,"Absolute",255),Nr(je,"Default",1),Nr(je,"z",s.z.union([s.z.instanceof(je),s.z.number().int().min(0).max(255).transform(r=>new je(r)),s.z.instanceof(Number).transform(r=>new je(r))]));let Ra=je;const ja=s.z.object({name:s.z.string(),key:s.z.string()}),Ll=r=>s.z.object({subject:ja,resource:r,authority:Ra.z}),Bl=(...r)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=r.includes(t.to.resource)),t.from!=null&&!n&&(n=r.includes(t.from.resource)),n}),Ke=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ra,filterTransfersByChannelKey:Bl,stateZ:Ll,subjectZ:ja},Symbol.toStringTag,{value:"Module"})),ql=s.z.string().regex(/^\d+\.\d+\.\d+$/);s.z.object({version:ql});const ir=(r,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(r);let a=z(r);const i=a[0],o=typeof i;let l;return o==="string"&&t&&!isNaN(parseInt(i))&&"number"in e?(l=e.number,a=a.map(u=>parseInt(u))):l=e[o],{single:n,variant:l,normalized:a,actual:r}},or=(r,e,t,n)=>{if(n){if(t.length===0)throw new ct(`${r} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new lt(`Expected one ${r} matching ${JSON.stringify(e)}, but found ${t.length}`)}},Fe=r=>s.z.union([s.z.null().transform(()=>[]),r.array()]),Yl=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:S.z.array().optional(),notDataTypes:S.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),Wl=s.z.object({channels:Fe(yt)}),ke=r=>ir(r,{number:"keys",string:"names"}),Wt=class Wt{constructor(e){c(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){const n=ke(e),{variant:a}=n;let{normalized:i}=n;return a==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[a]:i,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(Wt.ENDPOINT,e,Yl,Wl);if(n!=null)throw n;return t.channels}};c(Wt,"ENDPOINT","/channel/retrieve");let ht=Wt;class Nn{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,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=ir(e,{string:"names",number:"keys"}),a=[],i=[];if(n.forEach(l=>{const u=this.getFromCache(l);u!=null?a.push(u):i.push(l)}),i.length===0)return a;const o=await this.wrapped.retrieve(i,t);return this.updateCache(o),a.concat(o)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}class xa{constructor(e,t){c(this,"mu",new Bo);c(this,"requests",new Map);c(this,"wrapped");c(this,"debouncedRun");this.wrapped=e,this.debouncedRun=Do(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=ke(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((i,o)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:i,reject:o}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(a=>e.add(a)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,a)=>n.resolve(t.filter(i=>a.includes(i.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const Pa=async(r,e)=>{const{normalized:t}=ke(e),n=await r.retrieve(t),a=[];if(t.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&a.push(i)}),a.length>0)throw new ee(`Could not find channels: ${JSON.stringify(a)}`);return n};class An{constructor({dataType:e,rate:t,name:n,leaseholder:a=0,key:i=0,isIndex:o=!1,index:l=0,internal:u=!1,frameClient:p,alias:g}){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");this.key=i,this.name=n,this.rate=new Ht(t??0),this.dataType=new S(e),this.leaseholder=a,this.index=l,this.isIndex=o,this.internal=u,this.alias=g,this._frameClient=p??null}get framer(){if(this._frameClient==null)throw new P("cannot read from a channel that has not been created");return this._frameClient}get payload(){return yt.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})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let Da=class{constructor(e,t,n,a){c(this,"type","channel");c(this,"frameClient");c(this,"client");c(this,"retriever");c(this,"writer");this.frameClient=e,this.retriever=t,this.client=n,this.writer=a}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,a=!Array.isArray(e);let i=z(e),o=[];if(n){const l=await this.retriever.retrieve(i.map(p=>p.name)),u=new Set(l.map(p=>p.name));i=i.filter(p=>!u.has(p.name)),o=this.sugar(l)}return o=o.concat(this.sugar(await this.writer.create(i))),a?o[0]:o}async retrieve(e,t){const n=!Array.isArray(e),a=this.sugar(await this.retriever.retrieve(e,t));return or("channel",e,a,n),n?a[0]:a}async search(e,t){return this.sugar(await this.retriever.search(e,t))}async delete(e){const{normalized:t,variant:n}=ke(e);return n==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}async rename(e,t){return await this.writer.rename(z(e),z(t))}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new Nn(new xa(new ht(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new An({...n,frameClient:t}))}};const Kl=s.z.object({channels:qs.array()}),Vl=s.z.object({channels:yt.array()}),Fl=s.z.object({keys:$e.array().optional(),names:s.z.string().array().optional()}),Jl=s.z.object({}),Gl=s.z.object({keys:$e.array(),names:s.z.string().array()}),Hl=s.z.object({}),Xl="/channel/create",Ql="/channel/delete",eu="/channel/rename";let Za=class{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Xl,{channels:e},Kl,Vl)).channels}async delete(e){await w(this.client,Ql,e,Fl,Jl)}async rename(e,t){await w(this.client,eu,{keys:e,names:t},Gl,Hl)}};const tu=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Nn,Channel:An,Client:Da,ClusterRetriever:ht,DebouncedBatchRetriever:xa,Writer:Za,analyzeChannelParams:ke,keyZ:$e,newPayload:qs,payload:yt,retrieveRequired:Pa},Symbol.toStringTag,{value:"Module"})),ru=s.z.object({key:s.z.string(),username:s.z.string()}),nu=s.z.object({username:s.z.string(),password:s.z.string()}),su=s.z.object({token:s.z.string(),user:ru}),es="/auth/login",au=3;let iu=class{constructor(e,t){c(this,"token");c(this,"client");c(this,"credentials");c(this,"authenticating");c(this,"authenticated");c(this,"user");c(this,"retryCount");this.client=e,this.authenticated=!1,this.credentials=t,this.retryCount=0}middleware(){const e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(es)){this.authenticating==null&&(this.authenticating=new Promise((l,u)=>{this.client.send(es,this.credentials,nu,su).then(([p,g])=>{if(g!=null)return l(g);this.token=p==null?void 0:p.token,this.user=p==null?void 0:p.user,this.authenticated=!0,l(null)}).catch(u)}));const o=await this.authenticating;if(o!=null)return[t,o]}t.params.Authorization=`Bearer ${this.token}`;const[a,i]=await n(t);return i instanceof Lt&&this.retryCount<au?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[a,i])};return e}};const ou=["disconnected","connecting","connected","failed"],Ma=s.z.enum(ou),_a=s.z.object({status:Ma,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string()}),cu=s.z.object({clusterKey:s.z.string()}),ts={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Le=class Le{constructor(e,t=N.seconds(30),n){c(this,"_state");c(this,"pollFrequency",N.seconds(30));c(this,"client");c(this,"name");c(this,"interval");c(this,"onChangeHandlers",[]);this._state={...ts},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,a]=await this.client.send(Le.ENDPOINT,{},s.z.object({}),cu);if(a!=null)throw a;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==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(Le,"ENDPOINT","/connectivity/check"),c(Le,"DEFAULT",ts),c(Le,"connectionStateZ",_a);let ft=Le;const lu=Object.freeze(Object.defineProperty({__proto__:null,Checker:ft,state:_a,status:Ma},Symbol.toStringTag,{value:"Module"})),rs=r=>{const e=z(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ns=(r,e)=>{const t=z(r);if(t.length===e.length)return;const n=rs(r);throw rs===null?new P("[Frame] - channel keys or names must be provided when constructing a frame."):new P(`[Frame] - ${n}s and arrays must be the same length.
|
|
18
|
+
Got ${t.length} ${n}s and ${e.length} arrays.`)};class _{constructor(e=[],t=[]){c(this,"columns",[]);c(this,"series",[]);if(e instanceof _){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((a,i)=>this.push(i,...z(a)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const a=e,i=a.series.map(o=>La(o));ns(a.keys,i),a.keys.forEach((o,l)=>this.push(o,i[l]))}else Object.entries(e).forEach(([a,i])=>{const o=parseInt(a);if(isNaN(o))this.push(a,...z(i));else return this.push(o,...z(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const a=z(t),i=z(e);ns(i,a),a.forEach((o,l)=>this.push(i[l],o));return}throw new P(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
19
19
|
payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
|
|
20
|
-
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 xe("colType is not key");return this.columns??[]}get uniqueKeys(){return Qn(this.keys)}get names(){if(this.colType==="key")throw new xe("colType is not name");return this.columns??[]}get uniqueNames(){return Qn(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Ba(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(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return J.ZERO;const n=E.min(...this.series.map(i=>i.timeRange.start)),a=E.max(...this.series.map(i=>i.timeRange.end));return new J(n,a)}const t=this.get(e);return t==null?J.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Ls(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof _){if(this.colType!==null&&e.colType!==this.colType)throw new
|
|
20
|
+
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 xe("colType is not key");return this.columns??[]}get uniqueKeys(){return Qn(this.keys)}get names(){if(this.colType==="key")throw new xe("colType is not name");return this.columns??[]}get uniqueNames(){return Qn(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Ba(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(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return J.ZERO;const n=E.min(...this.series.map(i=>i.timeRange.start)),a=E.max(...this.series.map(i=>i.timeRange.end));return new J(n,a)}const t=this.get(e);return t==null?J.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Ls(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof _){if(this.colType!==null&&e.colType!==this.colType)throw new P("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new P("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new P("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new _([...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 t=new _;return this.forEach((n,a,i)=>t.push(...e(n,a,i))),t}forEach(e){this.columns.forEach((t,n)=>{const a=this.series[n];e(t,a,n)})}at(e,t=!1){const n={};return this.uniqueColumns.forEach(a=>{n[a]=this.get(a).at(e,t)}),n}filter(e){const t=new _;return this.columns.forEach((n,a)=>{const i=this.series[a];e(n,i,a)&&t.push(n,i)}),t}get byteLength(){return new ot(this.series.reduce((e,t)=>e.add(t.byteLength),ot.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const Ua=s.z.object({timeRange:J.z.optional(),alignment:s.z.bigint().or(s.z.string().transform(r=>BigInt(r))).optional(),dataType:S.z,data:s.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),cr=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(()=>[]),Ua.array().optional().default([])])}),La=r=>{const{dataType:e,data:t,timeRange:n,alignment:a}=r;return new F({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:a})},Ba=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class lr{constructor(e){c(this,"adapter");c(this,"retriever");c(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new lr(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=ke(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const a=await this.retriever.retrieve(n),i=new Map;this.adapter=i,n.forEach(o=>{const l=a.find(u=>u.name===o);if(l==null)throw new Error(`Channel ${o} not found`);i.set(l.key,l.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,a)=>{if(typeof n=="number"){const i=t.get(n);if(i==null)throw new Error(`Channel ${n} not found`);return[i,a]}return[n,a]})}}class In{constructor(e){c(this,"adapter");c(this,"retriever");c(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new In(e);return await n.update(t),n}async update(e){const t=await Pa(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new P(`
|
|
21
21
|
Received a single channel name or key but no series.
|
|
22
|
-
`);if(Array.isArray(t)){if(t.some(u=>u instanceof F||Array.isArray(u)))throw new
|
|
22
|
+
`);if(Array.isArray(t)){if(t.some(u=>u instanceof F||Array.isArray(u)))throw new P(`
|
|
23
23
|
Received a single channel name or key but multiple series.
|
|
24
|
-
`);t=t}const o=await this.fetchChannel(e),l=new F({data:t,dataType:o.dataType});return new _(o.key,l)}if(Array.isArray(e)){if(t==null)throw new
|
|
24
|
+
`);t=t}const o=await this.fetchChannel(e),l=new F({data:t,dataType:o.dataType});return new _(o.key,l)}if(Array.isArray(e)){if(t==null)throw new P(`
|
|
25
25
|
Received an array of channel names or keys but no series.
|
|
26
|
-
`);if(!Array.isArray(t))throw new
|
|
26
|
+
`);if(!Array.isArray(t))throw new P(`
|
|
27
27
|
Received an array of channel names or keys but no array of series.
|
|
28
|
-
`);const o=[],l=[];for(let u=0;u<e.length;u++){const p=await this.fetchChannel(e[u]);if(u>=t.length)throw new
|
|
28
|
+
`);const o=[],l=[];for(let u=0;u<e.length;u++){const p=await this.fetchChannel(e[u]);if(u>=t.length)throw new P(`
|
|
29
29
|
Received an array of channel names or keys but not enough series.
|
|
30
|
-
`);const g=new F({data:t[u],dataType:p.dataType});o.push(p.key),l.push(g)}return new _(o,l)}if(e instanceof _||e instanceof Map){const o=new _(e);if(this.adapter==null)return o;let l=[];return l=o.columns.map(u=>{var g;const p=typeof u=="string"?(g=this.adapter)==null?void 0:g.get(u):u;if(p==null)throw new
|
|
30
|
+
`);const g=new F({data:t[u],dataType:p.dataType});o.push(p.key),l.push(g)}return new _(o,l)}if(e instanceof _||e instanceof Map){const o=new _(e);if(this.adapter==null)return o;let l=[];return l=o.columns.map(u=>{var g;const p=typeof u=="string"?(g=this.adapter)==null?void 0:g.get(u):u;if(p==null)throw new P(`
|
|
31
31
|
Channel ${u} was not provided in the list of channels when opening the writer
|
|
32
32
|
`);return p}),new _(l,o.series)}const n=[],a=[],i=Object.entries(e);for(let o=0;o<i.length;o++){const[l,u]=i[o],p=await this.fetchChannel(l),g=new F({data:u,dataType:p.dataType});n.push(p.key),a.push(g)}return new _(n,a)}}class kn{constructor(e,t){c(this,"name");c(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
33
|
-
Please report this error to the Synnax team. ${JSON.stringify(e)}`),t!=null){if(t instanceof Ne)return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Jr=new N(-1);var $n=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))($n||{}),qa=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(qa||{});const uu=s.z.object({command:s.z.nativeEnum($n),span:N.z.optional(),bounds:J.z.optional(),stamp:E.z.optional(),keys:s.z.number().array().optional()}),hu=s.z.object({variant:s.z.nativeEnum(qa),ack:s.z.boolean(),command:s.z.nativeEnum($n),error:pt.optional().nullable(),frame:cr.optional()}),it=class it{constructor(e,t){c(this,"stream");c(this,"adapter");c(this,"value");this.stream=new kn("Iterator",e),this.value=new _,this.adapter=t}static async _open(e,t,n,a){const i=await lr.open(n,t),o=await a.stream(it.ENDPOINT,uu,hu),l=new it(o,i);return await l.execute({command:0,keys:i.keys,bounds:new J(e)}),l}async next(e=Jr){return await this.execute({command:1,span:new N(e)})}async prev(e=Jr){return await this.execute({command:2,span:new N(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 fu(this)}async execute(e){for(this.stream.send(e),this.value=new _;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new _(t.frame)))}}};c(it,"ENDPOINT","/frame/iterate");let qt=it;class fu{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 du=s.z.object({start:E.z.optional(),keys:s.z.number().array()}),yu=s.z.object({frame:cr,error:pt.optional().nullable()}),pu="/frame/stream";class ur{constructor(e,t){c(this,"stream");c(this,"adapter");this.stream=new kn("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:n,from:a}){const i=await lr.open(e,n),o=await t.stream(pu,du,yu),l=new ur(o,i);return o.send({start:new E(a),keys:i.keys}),l}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(e instanceof Ne)return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new _((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 hr extends Kr.Observer{constructor(t,n){super(n);c(this,"streamer");c(this,"closePromise");this.streamer=t,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const t of this.streamer)this.notify(t)}}var Cn=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r))(Cn||{}),dt=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(dt||{});const gu=new N(-1),mu=s.z.object({start:E.z.optional(),controlSubject:Ke.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:Ke.Authority.z.array().optional(),mode:s.z.nativeEnum(dt).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:N.z.optional()}),wu=s.z.object({command:s.z.nativeEnum(Cn),config:mu.optional(),frame:cr.optional()}),vu=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(Cn),error:pt.optional().nullable()});var De;let Ya=(De=class{constructor(e,t){c(this,"stream");c(this,"adapter");this.stream=new kn("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,start:a=E.now(),authorities:i=Ke.Authority.Absolute,controlSubject:o,mode:l=1,errOnUnauthorized:u=!1,enableAutoCommit:p=!1,autoIndexPersistInterval:g=N.SECOND}){const y=await In.open(e,n),U=await t.stream(De.ENDPOINT,wu,vu),x=new De(U,y);return await x.execute({command:0,config:{start:new E(a),keys:y.keys,controlSubject:o,authorities:z(i),mode:l,errOnUnauthorized:u,enableAutoCommit:p,autoIndexPersistInterval:g}}),x}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?En(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},c(De,"ENDPOINT","/frame/write"),De);const bu=s.z.object({keys:$e.array().optional(),names:s.z.string().array().optional(),bounds:J.z}),Ou=s.z.object({}),Tu="/frame/delete";class zu{constructor(e){c(this,"client");this.client=e}async delete(e){await w(this.client,Tu,e,bu,Ou)}}let Wa=class{constructor(e,t,n){c(this,"streamClient");c(this,"retriever");c(this,"deleter");this.streamClient=e,this.retriever=n,this.deleter=new zu(t)}async openIterator(e,t){return await qt._open(e,t,this.retriever,this.streamClient)}async openWriter(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await Ya._open(this.retriever,this.streamClient,e)}async openStreamer(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await ur._open(this.retriever,this.streamClient,e)}async write(e,t,n){if(n==null){const i=t,o=await this.openWriter({start:e,channels:Object.keys(i),mode:dt.PersistOnly});try{await o.write(i),await o.commit()}finally{await o.close()}return}const a=await this.openWriter({start:e,channels:t,mode:dt.PersistOnly,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:N.MAX});try{await a.write(t,n)}finally{await a.close()}}async read(e,t){const{single:n}=ke(t),a=await this.readFrame(e,t);return n?a.get(t):a}async readFrame(e,t){const n=await this.openIterator(e,t),a=new _;try{for await(const i of n)a.push(i)}finally{await n.close()}return a}async delete(e,t){const{normalized:n,variant:a}=ke(e);return a==="keys"?await this.deleter.delete({keys:n,bounds:t}):await this.deleter.delete({names:n,bounds:t})}};const Eu=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:gu,AUTO_SPAN:Jr,Client:Wa,Frame:_,Iterator:qt,ObservableStreamer:hr,Streamer:ur,Writer:Ya,WriterMode:dt,frameZ:cr,series:Ua,seriesFromPayload:La,seriesToPayload:Ba},Symbol.toStringTag,{value:"Module"})),Su=Ke.Authority,Nu=Ke.stateZ(s.z.number()),Au=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Ka extends hr{constructor(t){super(t,n=>{const a=this.ecd.decode(n.series[0].buffer);return this.merge(a),[a.transfers,!0]});c(this,"states");c(this,"ecd");this.states=new Map,this.ecd=new Ve.JSONEncoderDecoder}subjects(){const t=new Map;return this.states.forEach(n=>t.set(n.subject.key,n.subject)),Array.from(t.values())}merge(t){t.transfers.forEach(n=>{n.from==null&&n.to==null&&console.warn("Invalid transfer: ",n),n.to==null?this.states.delete(n.from.resource):this.states.set(n.to.resource,n.to)})}}const Iu="sy_node_1_control";let Va=class{constructor(e){c(this,"framer");this.framer=e}async openStateTracker(){const e=await this.framer.openStreamer(Iu);return new Ka(e)}};const ku=Object.freeze(Object.defineProperty({__proto__:null,Authority:Su,Client:Va,StateTracker:Ka,stateZ:Nu,transferString:Au},Symbol.toStringTag,{value:"Module"}));let Fa=class{constructor(e,t,n){c(this,"tasks");c(this,"racks");c(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const $u=Object.freeze(Object.defineProperty({__proto__:null,Client:Fa},Symbol.toStringTag,{value:"Module"})),Je=s.z.number(),fr=s.z.object({key:Je,name:s.z.string()}),Ja=fr.partial({key:!0}),Ar="/hardware/rack/retrieve",Cu="/hardware/rack/create",Ru="/hardware/rack/delete",Ir=s.z.object({keys:Je.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),kr=s.z.object({racks:Fe(fr)}),ju=s.z.object({racks:Ja.array()}),xu=s.z.object({racks:fr.array()}),Du=s.z.object({keys:Je.array()}),Pu=s.z.object({});let Ga=class{constructor(e,t,n){c(this,"type","rack");c(this,"client");c(this,"frameClient");c(this,"tasks");this.client=e,this.frameClient=t,this.tasks=n}async delete(e){await w(this.client,Ru,{keys:z(e)},Du,Pu)}async create(e){const t=!Array.isArray(e),n=await w(this.client,Cu,{racks:z(e)},ju,xu),a=this.sugar(n.racks);return t?a[0]:a}async search(e){const t=await w(this.client,Ar,{search:e},Ir,kr);return this.sugar(t.racks)}async page(e,t){const n=await w(this.client,Ar,{offset:e,limit:t},Ir,kr);return this.sugar(n.racks)}async retrieve(e){const{variant:t,normalized:n,single:a}=ir(e,{string:"names",number:"keys"}),i=await w(this.client,Ar,{[t]:n},Ir,kr),o=this.sugar(i.racks);return or("Rack",e,o,a),a?o[0]:o}sugar(e){return e.map(({key:t,name:n})=>new Ha(t,n,this.tasks))}};class Ha{constructor(e,t,n){c(this,"key");c(this,"name");c(this,"tasks");this.key=e,this.name=t,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 gt=async(r,e,t,n)=>{const a=await r.openStreamer([e,t]),i=o=>{const l=[];return t!=null&&l.push(...o.get(t).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 hr(a,i)},Zu=Object.freeze(Object.defineProperty({__proto__:null,openObservable:gt},Symbol.toStringTag,{value:"Module"})),Mu="sy_device_set",_u="sy_device_delete",$r="/hardware/device/retrieve",Uu="/hardware/device/create",Lu="/hardware/device/delete",dr=s.z.string(),mt=s.z.object({key:dr,rack:Je,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(r=>r===""?{}:Ve.JSON_ECD.decodeString(r)))}),Xa=mt.extend({properties:s.z.unknown().transform(r=>Ve.JSON_ECD.encodeString(r))}),Bu=s.z.object({devices:Xa.array()}),qu=s.z.object({devices:mt.array()}),Yu=s.z.object({keys:dr.array()}),Wu=s.z.object({}),Cr=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:dr.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),Rr=s.z.object({devices:Fe(mt)});let Qa=class{constructor(e,t){c(this,"type","device");c(this,"client");c(this,"frameClient");this.client=e,this.frameClient=t}async retrieve(e,t){const n=!Array.isArray(e),a=await w(this.client,$r,{keys:z(e),...t},Cr,Rr);return or("Device",e,a.devices,n),n?a.devices[0]:a.devices}async search(e,t){return(await w(this.client,$r,{search:e,...t},Cr,Rr)).devices}async page(e,t,n){return(await w(this.client,$r,{offset:e,limit:t,...n},Cr,Rr)).devices}async create(e){const t=!Array.isArray(e),n=await w(this.client,Uu,{devices:z(e)},Bu,qu);return t?n.devices[0]:n.devices}async delete(e){await w(this.client,Lu,{keys:z(e)},Yu,Wu)}async openDeviceTracker(){return await gt(this.frameClient,Mu,_u,Ku)}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}};const Ku=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(mt).map(t=>({variant:r,key:t.key,value:t})),Vu=Object.freeze(Object.defineProperty({__proto__:null,Client:Qa,deviceKeyZ:dr,deviceZ:mt,newDeviceZ:Xa},Symbol.toStringTag,{value:"Module"})),Fu=Object.freeze(Object.defineProperty({__proto__:null,Client:Ga,Rack:Ha,newRackZ:Ja,rackKeyZ:Je,rackZ:fr},Symbol.toStringTag,{value:"Module"}));if(process.env.NODE_ENV!=="production"){if(typeof navigator<"u"&&navigator.product==="ReactNative"&&!self.crypto)throw new Error("React Native does not have a built-in secure random generator. If you don’t need unpredictable IDs, you can use `nanoid/non-secure`. For secure IDs, import `react-native-get-random-values` before Nano ID.");if(typeof self<"u"&&self.msCrypto&&!self.crypto)throw new Error("Add self.crypto = self.msCrypto before Nano ID to fix IE 11 support");if(typeof self>"u"||!self.crypto)throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.")}let Ju=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;){let n=t[r]&63;n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n<63?e+="_":e+="-"}return e};const jr="sy_task_state",ss="sy_task_cmd",Ge=s.z.union([s.z.string(),s.z.bigint().transform(r=>r.toString()),s.z.number().transform(r=>r.toString())]),Yt=s.z.object({task:Ge,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:JSON.parse(r))).or(s.z.array(s.z.unknown())).or(s.z.null())}),yr=s.z.object({key:Ge,name:s.z.string(),type:s.z.string(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:Ve.JSON_ECD.decodeString(r))),state:Yt.optional().nullable()}),ei=yr.omit({key:!0}).extend({key:Ge.transform(r=>r.toString()).optional(),config:s.z.unknown().transform(r=>Ve.JSON_ECD.encodeString(r))}),Gu=s.z.object({task:Ge,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:JSON.parse(r)))});class ti{constructor(e,t,n,a,i,o){c(this,"key");c(this,"name");c(this,"type");c(this,"config");c(this,"state");c(this,"frameClient");this.key=e,this.name=t,this.type=n,this.config=a,o!==null&&(this.state=o),this.frameClient=i}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state}}async executeCommand(e,t){const n=await this.frameClient.openWriter(ss),a=Ju();return await n.write(ss,[{task:this.key,type:e,key:a,args:t}]),await n.close(),a}async executeCommandSync(e,t,n){const a=await this.frameClient.openStreamer(jr),i=await this.executeCommand(e,t);let o;const l=new Promise(u=>setTimeout(()=>u(!1),new N(n).milliseconds));for(;;){const u=await Promise.any([a.read(),l]);if(u===!1)throw new Error("Command timed out");const p=Yt.safeParse(u.at(-1).sy_task_state);if(p.success){if(o=p.data,o.key===i)break}else console.error(p.error)}return a.close(),o}async openStateObserver(){return new hr(await this.frameClient.openStreamer(jr),e=>{const t=e.get(jr);if(t.length===0)return[null,!1];const n=Yt.safeParse(t.at(-1));if(!n.success)return[null,!1];const a=n.data;return a.task!==this.key?[null,!1]:[a,!0]})}}const Hu=s.z.object({rack:Je.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()}),Xu=s.z.object({tasks:Fe(yr)}),Qu="/hardware/task/retrieve",eh="/hardware/task/create",th="/hardware/task/delete",rh=s.z.object({tasks:ei.array()}),nh=s.z.object({tasks:yr.array()}),sh=s.z.object({keys:Ge.array()}),ah=s.z.object({});let ri=class{constructor(e,t){c(this,"type","task");c(this,"client");c(this,"frameClient");this.client=e,this.frameClient=t}async create(e){const t=!Array.isArray(e),n=await w(this.client,eh,{tasks:z(e)},rh,nh),a=this.sugar(n.tasks);return t?a[0]:a}async delete(e){await w(this.client,th,{keys:z(e)},sh,ah)}async search(e){return await this.execRetrieve({keys:[e]})}async page(e,t){return this.execRetrieve({offset:e,limit:t})}async retrieve(e,t){const{single:n,normalized:a,variant:i}=ir(e,{number:"rack",string:"keys"},{convertNumericStrings:!1}),o={...t};i==="rack"?o.rack=e:o.keys=a;const l=await this.execRetrieve(o),u=this.sugar(l);return n&&i!=="rack"?u[0]:u}async retrieveByName(e,t){const n=await this.execRetrieve({names:[e],rack:t});return or("Task",e,n,!0),this.sugar(n)[0]}async execRetrieve(e){return(await w(this.client,Qu,e,Hu,Xu)).tasks}sugar(e){return e.map(({key:t,name:n,type:a,config:i,state:o})=>new ti(t,n,a,i,this.frameClient,o))}};const ih=Object.freeze(Object.defineProperty({__proto__:null,Client:ri,Task:ti,commandZ:Gu,newTaskZ:ei,stateZ:Yt,taskKeyZ:Ge,taskZ:yr},Symbol.toStringTag,{value:"Module"}));class oh{constructor(e,t){c(this,"key");c(this,"name");this.key=t,this.name=e}get ontologyID(){return new X({type:"group",key:this.key})}}const ch=s.z.string().uuid(),lh=s.z.object({key:ch,name:s.z.string()}),ni=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")]),ne=s.z.object({type:ni,key:s.z.string()}),si=s.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),ai=s.z.union([si,ne]),Be=class Be{constructor(e){c(this,"type");c(this,"key");if(e instanceof Be)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,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(Be,"z",s.z.union([ai,s.z.instanceof(Be)]).transform(e=>new Be(e)));let X=Be;const uh=new X({type:"builtin",key:"root"}),ii=s.z.object({type:s.z.number()}),oi=s.z.object({type:ni,fields:s.z.record(ii)}),ci=s.z.object({id:X.z,name:s.z.string(),schema:oi.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(r=>({key:r.id.toString(),...r})),hh=s.z.object({from:X.z,type:s.z.string(),to:X.z}),Gr=r=>{const[e,t,n]=r.split("->");return{from:new X(e),type:t,to:new X(n)}},fh=s.z.object({group:lh}),dh=s.z.object({parent:ne,key:s.z.string().uuid().optional(),name:s.z.string()}),yh=s.z.object({key:s.z.string(),name:s.z.string()}),ph=s.z.object({keys:s.z.array(s.z.string())});var le;let gh=(le=class{constructor(e){c(this,"client");this.client=e}async create(e,t,n){const[a,i]=await this.client.send(le.ENDPOINT,{parent:e,name:t,key:n},dh,fh);if(i!=null)throw i;return a.group}async rename(e,t){const n={key:e,name:t},[,a]=await this.client.send(le.ENDPOINT_RENAME,n,yh,s.z.object({}));if(a!=null)throw a}async delete(e){const t={keys:e},[,n]=await this.client.send(le.ENDPOINT_DELETE,t,ph,s.z.object({}));if(n!=null)throw n}},c(le,"ENDPOINT","/ontology/create-group"),c(le,"ENDPOINT_RENAME","/ontology/rename-group"),c(le,"ENDPOINT_DELETE","/ontology/delete-group"),le),mh=class{constructor(e){c(this,"creator");this.creator=new gh(e)}async create(e,t,n){return this.sugar(await this.creator.create(e,t,n))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new oh(e.name,e.key)}};const xr={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},as=s.z.object({id:ne,children:ne.array()}),wh=s.z.object({from:ne,to:ne,children:ne.array()});let vh=class{constructor(e){c(this,"client");this.client=e}async addChildren(e,...t){await w(this.client,xr.ADD_CHILDREN,{id:e,children:t},as,s.z.object({}))}async removeChildren(e,...t){await w(this.client,xr.REMOVE_CHILDREN,{id:e,children:t},as,s.z.object({}))}async moveChildren(e,t,...n){const a={from:e,to:t,children:n};await w(this.client,xr.MOVE_CHILDREN,a,wh,s.z.object({}))}};const bh="/ontology/retrieve",Oh=s.z.object({ids:ne.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()}),Th=s.z.object({resources:ci.array()}),Dr=r=>z(r).map(e=>new X(e).payload);let li=class{constructor(e,t){c(this,"type","ontology");c(this,"groups");c(this,"client");c(this,"writer");c(this,"framer");this.client=e,this.writer=new vh(e),this.groups=new mh(e),this.framer=t}async search(e,t){return await this.execRetrieve({term:e,...t})}async retrieve(e,t){const n=await this.execRetrieve({ids:Dr(e),...t});if(Array.isArray(e))return n;if(n.length===0)throw new ee(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t,n){return await this.execRetrieve({offset:e,limit:t,...n})}async retrieveChildren(e,t){return await this.execRetrieve({ids:Dr(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:Dr(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await pr.open(this.framer,this)}newSearcherWithOptions(e){return{type:this.type,search:t=>this.search(t,e),retrieve:t=>this.retrieve(t,e),page:(t,n)=>this.page(t,n,e)}}async execRetrieve(e){const{resources:t}=await w(this.client,bh,e,Oh,Th);return t}};const is="sy_ontology_resource_set",os="sy_ontology_resource_delete",cs="sy_ontology_relationship_set",ls="sy_ontology_relationship_delete";class pr{constructor(e,t){c(this,"resourceObs");c(this,"relationshipObs");c(this,"relationships");c(this,"resources");c(this,"streamer");c(this,"client");c(this,"closePromise");this.relationshipObs=new Kr.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Kr.Observer,this.resources=this.resourceObs,this.client=t,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 t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const i=this.parseRelationshipSets(e),o=this.parseRelationshipDeletes(e);i.concat(o).length>0&&this.relationshipObs.notify(i.concat(o))}parseRelationshipSets(e){const t=e.get(cs);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:Gr(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(ls);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:Gr(n)}))}async parseResourceSets(e){const t=e.get(is);if(t.length===0)return[];const n=Array.from(t.as("string")).map(a=>new X(a));try{return(await this.client.retrieve(n)).map(i=>({variant:"set",key:i.id,value:i}))}catch(a){if(a instanceof ee)return[];throw a}}parseResourceDeletes(e){const t=e.get(os);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new X(n)}))}static async open(e,t){const n=await e.openStreamer([is,os,cs,ls]);return new pr(n,t)}}const zh=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:pr,Client:li,ID:X,Root:uh,crudeIDZ:ai,idZ:ne,parseRelationship:Gr,relationshipSchemaZ:hh,resourceSchemaZ:ci,schemaFieldZ:ii,schemaZ:oi,stringIDZ:si},Symbol.toStringTag,{value:"Module"})),He=s.z.string().uuid(),wt=s.z.object({key:He,name:s.z.string().min(1),color:s.z.string()}),Eh=r=>new X({type:"label",key:r}),Sh=s.z.object({keys:He.array().optional(),for:ne.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Nh=s.z.object({labels:wt.array().optional().default([])});var qe;let ui=(qe=class{constructor(e){c(this,"client");this.client=e}async retrieve(e){const t=z(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(qe.ENDPOINT,e,Sh,Nh);if(n!=null)throw n;return t.labels}},c(qe,"ENDPOINT","/label/retrieve"),qe);const hi=wt.extend({key:He.optional()}),Ah=s.z.object({labels:hi.array()}),Ih=s.z.object({labels:wt.array()}),kh=s.z.object({keys:He.array()}),fi=s.z.object({id:ne,labels:He.array()}),$h=fi,Pr=s.z.object({}),Ch="/label/create",Rh="/label/delete",jh="/label/set",xh="/label/remove";let di=class{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Ch,{labels:z(e)},Ah,Ih)).labels}async delete(e){await w(this.client,Rh,{keys:z(e)},kh,Pr)}async set(e,t){await w(this.client,jh,{id:e,labels:t},fi,Pr)}async remove(e,t){await w(this.client,xh,{id:e,labels:t},$h,Pr)}};const Dh="sy_label_set",Ph="sy_label_delete";let yi=class{constructor(e,t){c(this,"type","label");c(this,"retriever");c(this,"writer");c(this,"frameClient");this.writer=new di(e),this.retriever=new ui(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await gt(this.frameClient,Dh,Ph,Zh)}};const Zh=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(wt).map(t=>({variant:r,key:t.key,value:t})),Mh=Object.freeze(Object.defineProperty({__proto__:null,Client:yi,Retriever:ui,Writer:di,keyZ:He,labelZ:wt,newLabelPayloadZ:hi,ontologyID:Eh},Symbol.toStringTag,{value:"Module"})),G=s.z.string().uuid(),Xe=s.z.object({key:G,name:s.z.string().min(1),timeRange:J.z,color:s.z.string().optional()}),pi=Xe.extend({key:s.z.string().uuid().optional()}),gi=r=>{const e=z(r);if(e.length===0)throw new Error("Range params must not be empty");const t=G.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},_h=s.z.object({}),Uh=s.z.object({range:Xe}),Lh=s.z.object({range:G}),Bh=s.z.object({range:G}),qh=s.z.object({}),Yh="/range/set-active",Wh="/range/retrieve-active",Kh="/range/clear-active";class Vh{constructor(e){c(this,"client");this.client=e}async setActive(e){await w(this.client,Yh,{range:e},Lh,_h)}async retrieveActive(){const[e,t]=await this.client.send(Wh,{},s.z.object({}),Uh);if(t instanceof ee)return null;if(t!=null)throw t;return e.range}async clearActive(e){await w(this.client,Kh,{range:e},Bh,qh)}}const Fh="sy_range_alias_set",Jh="sy_range_alias_delete",Gh=s.z.object({range:G,aliases:s.z.string().array()}),Hh=s.z.object({aliases:s.z.record(s.z.string(),$e)}),Xh=s.z.object({range:G,aliases:s.z.record($e.or(s.z.string()),s.z.string())}),Qh=s.z.unknown(),ef=s.z.object({range:G,channels:$e.array()}),tf=s.z.unknown(),rf=s.z.object({range:G}),nf=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),ce=class ce{constructor(e,t,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=t}async resolve(e){const t=[],n=typeof e=="string",a={};if(n){const o=this.cache.get(e);if(o!=null)return o;t.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?a[o]=l:t.push(o)});if(t.length===0)return a;const i=await w(this.client,ce.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},Gh,Hh);return Object.entries(i.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?i.aliases[t[0]]:{...a,...i.aliases}}async set(e){await w(this.client,ce.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Xh,Qh)}async list(){return(await w(this.client,ce.LIST_ENDPOINT,{range:this.rangeKey},rf,nf)).aliases}async delete(e){await w(this.client,ce.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},ef,tf)}async openChangeTracker(){return await gt(this.frameClient,Fh,Jh,of(this.rangeKey))}};c(ce,"SET_ENDPOINT","/range/alias/set"),c(ce,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(ce,"LIST_ENDPOINT","/range/alias/list"),c(ce,"DELETE_ENDPOINT","/range/alias/delete");let Hr=ce;const sf=s.z.object({range:G,channel:$e,alias:s.z.string()}),af="---",of=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(af)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(sf).map(n=>({variant:e,key:n.alias,value:n})),cf=s.z.object({range:G,keys:s.z.string().array()}),lf=s.z.object({pairs:s.z.record(s.z.string(),s.z.string())}),uf=s.z.object({range:G,pairs:s.z.record(s.z.string(),s.z.string())}),hf=s.z.object({range:G,keys:s.z.string().array()}),Ae=class Ae{constructor(e,t){c(this,"rangeKey");c(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(Ae.GET_ENDPOINT,{range:this.rangeKey,keys:z(e)},cf,lf);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async list(){return this.get([])}async set(e,t=""){await w(this.client,Ae.SET_ENDPOINT,{range:this.rangeKey,pairs:Ia(e)?e:{[e]:t}},uf,s.z.unknown())}async delete(e){await w(this.client,Ae.DELETE_ENDPOINT,{range:this.rangeKey,keys:z(e)},hf,s.z.unknown())}};c(Ae,"GET_ENDPOINT","/range/kv/get"),c(Ae,"SET_ENDPOINT","/range/kv/set"),c(Ae,"DELETE_ENDPOINT","/range/kv/delete");let Xr=Ae;const Zr=r=>new X({type:"range",key:r});class mi{constructor(e,t=J.ZERO,n,a,i,o,l,u,p){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");this.key=n,this.name=e,this.timeRange=t,this.frameClient=i,this.color=a,this.kv=o,this.aliaser=l,this.channels=u,this.labelClient=p}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new ee(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Zr(this.key))}async addLabel(...e){await this.labelClient.label(Zr(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Zr(this.key),e)}}const ff=s.z.object({keys:G.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:J.z.optional()}),df="/range/retrieve",yf=s.z.object({ranges:Fe(Xe)});let wi=class{constructor(e,t,n,a,i){c(this,"type","range");c(this,"frameClient");c(this,"writer");c(this,"unaryClient");c(this,"channels");c(this,"active");c(this,"labelClient");this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=a,this.active=new Vh(n),this.labelClient=i}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(z(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(z(e))}async search(e){return this.sugar(await this.execRetrieve({term:e}))}async page(){return[]}async retrieve(e){if(typeof e=="object"&&"start"in e)return await this.execRetrieve({overlapsWith:new J(e)});const{single:t,actual:n,variant:a,normalized:i}=gi(e),o=await this.execRetrieve({[a]:i});if(!t)return o;if(o.length===0)throw new ct(`range matching ${n} not found`);if(o.length>1)throw new lt(`multiple ranges matching ${n} found`);return o[0]}async execRetrieve(e){const{ranges:t}=await w(this.unaryClient,df,e,ff,yf);return this.sugar(t)}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new mi(t.name,t.timeRange,t.key,t.color,this.frameClient,new Xr(t.key,this.unaryClient),new Hr(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await gt(this.frameClient,"sy_range_set","sy_range_delete",(e,t)=>e==="delete"?t.toStrings().map(a=>({variant:e,key:a,value:void 0})):this.sugar(t.parseJSON(Xe)).map(a=>({variant:e,key:a.key,value:a})))}};const pf=s.z.object({ranges:Xe.array()}),gf=s.z.object({ranges:pi.array()}),mf=s.z.object({keys:G.array()}),wf=s.z.object({}),vf=s.z.object({key:G,name:s.z.string()}),bf=s.z.object({}),Of="/range/create",Tf="/range/delete",zf="/range/rename";let vi=class{constructor(e){c(this,"client");this.client=e}async rename(e,t){await w(this.client,zf,{key:e,name:t},vf,bf)}async create(e){return(await w(this.client,Of,{ranges:e},gf,pf)).ranges}async delete(e){await w(this.client,Tf,{keys:e},mf,wf)}};const Ef=Object.freeze(Object.defineProperty({__proto__:null,Client:wi,Range:mi,Writer:vi,analyzeParams:gi,keyZ:G,newPayloadZ:pi,payloadZ:Xe},Symbol.toStringTag,{value:"Module"})),Sf="/api/v1/";class Nf{constructor(e,t=!1){c(this,"url");c(this,"unary");c(this,"stream");c(this,"secure");this.secure=t,this.url=e.child(Sf);const n=new Ve.JSONEncoderDecoder;this.unary=new hl(this.url,n,this.secure),this.stream=new bl(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Rn=s.z.string().uuid(),jn=s.z.object({key:s.z.string(),name:s.z.string(),data:Sn.or(s.z.string().transform(r=>JSON.parse(r)))}),Af=s.z.object({keys:s.z.string().array()}),If=s.z.object({linePlots:jn.array()});let kf=class{constructor(e){c(this,"ENDPOINT","/workspace/lineplot/retrieve");c(this,"client");this.client=e}async retrieve(e){const t=z(e);return(await w(this.client,this.ENDPOINT,{keys:t},Af,If)).linePlots}};const Ce=s.z.string().uuid(),bi=r=>JSON.parse(r),xn=s.z.object({name:s.z.string(),key:Ce,layout:Sn.or(s.z.string().transform(r=>bi(r)))}),Dn=xn.omit({layout:!0}).extend({layout:s.z.string().transform(r=>bi(r))}),$f=jn.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Cf=s.z.object({workspace:Ce,linePlots:$f.array()}),Rf=s.z.object({linePlots:jn.array()}),jf=s.z.object({keys:Rn.array()}),xf=s.z.object({}),Df=s.z.object({key:Rn,name:s.z.string()}),Pf=s.z.object({}),Zf=s.z.object({key:Rn,data:s.z.string()}),Mf=s.z.object({}),_f="/workspace/lineplot/create",Uf="/workspace/lineplot/delete",Lf="/workspace/lineplot/rename",Bf="/workspace/lineplot/set-data";let qf=class{constructor(e){c(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await w(this.client,_f,{workspace:e,linePlots:[n]},Cf,Rf)).linePlots[0]}async delete(e){const t=z(e);await w(this.client,Uf,{keys:t},jf,xf)}async rename(e,t){await w(this.client,Lf,{key:e,name:t},Df,Pf)}async setData(e,t){await w(this.client,Bf,{key:e,data:JSON.stringify(t)},Zf,Mf)}},Yf=class{constructor(e){c(this,"writer");c(this,"retriever");this.writer=new qf(e),this.retriever=new kf(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Wf=s.z.object({keys:Ce.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Kf=s.z.object({workspaces:Fe(Dn)});var Ye;let Vf=(Ye=class{constructor(e){c(this,"client");this.client=e}async retrieve(e){const t=z(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await w(this.client,Ye.ENDPOINT,e,Wf,Kf)).workspaces}},c(Ye,"ENDPOINT","/workspace/retrieve"),Ye);const gr=s.z.string().uuid(),Ff=s.z.object({key:s.z.string(),name:s.z.string(),data:Sn.or(s.z.string().transform(r=>JSON.parse(r))),snapshot:s.z.boolean()}),Pn=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(r=>JSON.parse(r))}),Jf=s.z.object({keys:s.z.string().array()}),Gf=s.z.object({schematics:Pn.array()});class Hf{constructor(e){c(this,"ENDPOINT","/workspace/schematic/retrieve");c(this,"client");this.client=e}async retrieve(e){return(await w(this.client,this.ENDPOINT,{keys:z(e)},Jf,Gf)).schematics}}const Xf=Ff.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Qf=s.z.object({workspace:Ce,schematics:Xf.array()}),ed=s.z.object({schematics:Pn.array()}),td=s.z.object({keys:gr.array()}),rd=s.z.object({}),nd=s.z.object({key:gr,name:s.z.string()}),us=s.z.object({}),sd=s.z.object({key:gr,data:s.z.string()});s.z.object({});const ad=s.z.object({key:gr,name:s.z.string(),snapshot:s.z.boolean()}),id=s.z.object({schematic:Pn}),od="/workspace/schematic/create",cd="/workspace/schematic/delete",ld="/workspace/schematic/rename",ud="/workspace/schematic/set-data",hd="/workspace/schematic/copy";let fd=class{constructor(e){c(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await w(this.client,od,{workspace:e,schematics:[n]},Qf,ed)).schematics[0]}async copy(e,t,n){return(await w(this.client,hd,{key:e,name:t,snapshot:n},ad,id)).schematic}async delete(e){const t=z(e);await w(this.client,cd,{keys:t},td,rd)}async rename(e,t){await w(this.client,ld,{key:e,name:t},nd,us)}async setData(e,t){await w(this.client,ud,{key:e,data:JSON.stringify(t)},sd,us)}},dd=class{constructor(e){c(this,"writer");c(this,"retriever");this.writer=new fd(e),this.retriever=new Hf(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const yd=xn.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),pd=s.z.object({workspaces:yd.array()}),gd=s.z.object({workspaces:Dn.array()}),md=s.z.object({keys:Ce.array()}),wd=s.z.object({}),vd=s.z.object({key:Ce,name:s.z.string()}),bd=s.z.object({}),Od=s.z.object({key:Ce,layout:s.z.string()}),Td=s.z.object({}),zd="/workspace/create",Ed="/workspace/delete",Sd="/workspace/rename",Nd="/workspace/set-layout";class Ad{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,zd,{workspaces:z(e)},pd,gd)).workspaces}async delete(e){await w(this.client,Ed,{keys:z(e)},md,wd)}async rename(e,t){await w(this.client,Sd,{key:e,name:t},vd,bd)}async setLayout(e,t){await w(this.client,Nd,{key:e,layout:JSON.stringify(t)},Od,Td)}}class Oi{constructor(e){c(this,"type","workspace");c(this,"schematic");c(this,"linePlot");c(this,"retriever");c(this,"writer");this.schematic=new dd(e),this.linePlot=new Yf(e),this.retriever=new Vf(e),this.writer=new Ad(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const Id=Object.freeze(Object.defineProperty({__proto__:null,Client:Oi,keyZ:Ce,workspaceRemoteZ:Dn,workspaceZ:xn},Symbol.toStringTag,{value:"Module"})),Ti=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().optional(),password:s.z.string().optional(),connectivityPollFrequency:N.z.default(N.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class zi extends Wa{constructor(t){const n=Ti.parse(t),{host:a,port:i,username:o,password:l,connectivityPollFrequency:u,secure:p}=n,g=new Nf(new Ml({host:a,port:Number(i)}),p);g.use(El);let y;if(o!=null&&l!=null){const Si=new iu(g.unary,{username:o,password:l});g.use(Si.middleware())}const U=new Nn(new ht(g.unary)),x=new Za(g.unary);super(g.stream,g.unary,U);c(this,"createdAt");c(this,"props");c(this,"ranges");c(this,"channels");c(this,"auth");c(this,"connectivity");c(this,"ontology");c(this,"workspaces");c(this,"labels");c(this,"hardware");c(this,"control");c(this,"transport");this.createdAt=E.now(),this.props=n,this.auth=y,this.transport=g,this.channels=new Pa(this,U,g.unary,x),this.connectivity=new ft(g.unary,u,n.name),this.control=new Va(this),this.ontology=new li(g.unary,this);const Q=new vi(this.transport.unary);this.labels=new yi(this.transport.unary,this),this.ranges=new wi(this,Q,this.transport.unary,U,this.labels),this.workspaces=new Oi(this.transport.unary);const P=new Qa(this.transport.unary,this),Zn=new ri(this.transport.unary,this),Ei=new Ga(this.transport.unary,this,Zn);this.hardware=new Fa(Zn,Ei,P)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c(zi,"connectivity",ft);const kd=Ke.Authority;exports.AuthError=We;exports.Authority=kd;exports.Channel=An;exports.ContiguityError=Ol;exports.DataType=S;exports.Density=V;exports.Frame=_;exports.MultiSeries=Ls;exports.QueryError=ee;exports.Rate=Ht;exports.RouteError=Bt;exports.Series=F;exports.Synnax=zi;exports.TimeRange=J;exports.TimeSpan=N;exports.TimeStamp=E;exports.UnexpectedError=xe;exports.ValidationError=D;exports.channel=tu;exports.connection=lu;exports.control=ku;exports.device=Vu;exports.framer=Eu;exports.hardware=$u;exports.label=Mh;exports.ontology=zh;exports.rack=Fu;exports.ranger=Ef;exports.signals=Zu;exports.synnaxPropsZ=Ti;exports.task=ih;exports.workspace=Id;
|
|
33
|
+
Please report this error to the Synnax team. ${JSON.stringify(e)}`),t!=null){if(t instanceof Ne)return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Jr=new N(-1);var $n=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))($n||{}),qa=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(qa||{});const uu=s.z.object({command:s.z.nativeEnum($n),span:N.z.optional(),bounds:J.z.optional(),stamp:E.z.optional(),keys:s.z.number().array().optional()}),hu=s.z.object({variant:s.z.nativeEnum(qa),ack:s.z.boolean(),command:s.z.nativeEnum($n),error:pt.optional().nullable(),frame:cr.optional()}),it=class it{constructor(e,t){c(this,"stream");c(this,"adapter");c(this,"value");this.stream=new kn("Iterator",e),this.value=new _,this.adapter=t}static async _open(e,t,n,a){const i=await lr.open(n,t),o=await a.stream(it.ENDPOINT,uu,hu),l=new it(o,i);return await l.execute({command:0,keys:i.keys,bounds:new J(e)}),l}async next(e=Jr){return await this.execute({command:1,span:new N(e)})}async prev(e=Jr){return await this.execute({command:2,span:new N(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 fu(this)}async execute(e){for(this.stream.send(e),this.value=new _;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new _(t.frame)))}}};c(it,"ENDPOINT","/frame/iterate");let qt=it;class fu{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 du=s.z.object({start:E.z.optional(),keys:s.z.number().array()}),yu=s.z.object({frame:cr,error:pt.optional().nullable()}),pu="/frame/stream";class ur{constructor(e,t){c(this,"stream");c(this,"adapter");this.stream=new kn("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:n,from:a}){const i=await lr.open(e,n),o=await t.stream(pu,du,yu),l=new ur(o,i);return o.send({start:new E(a),keys:i.keys}),l}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(e instanceof Ne)return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new _((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 hr extends Kr.Observer{constructor(t,n){super(n);c(this,"streamer");c(this,"closePromise");this.streamer=t,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const t of this.streamer)this.notify(t)}}var Cn=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r))(Cn||{}),dt=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(dt||{});const gu=new N(-1),mu=s.z.object({start:E.z.optional(),controlSubject:Ke.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:Ke.Authority.z.array().optional(),mode:s.z.nativeEnum(dt).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:N.z.optional()}),wu=s.z.object({command:s.z.nativeEnum(Cn),config:mu.optional(),frame:cr.optional()}),vu=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(Cn),error:pt.optional().nullable()});var Pe;let Ya=(Pe=class{constructor(e,t){c(this,"stream");c(this,"adapter");this.stream=new kn("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,start:a=E.now(),authorities:i=Ke.Authority.Absolute,controlSubject:o,mode:l=1,errOnUnauthorized:u=!1,enableAutoCommit:p=!1,autoIndexPersistInterval:g=N.SECOND}){const y=await In.open(e,n),U=await t.stream(Pe.ENDPOINT,wu,vu),x=new Pe(U,y);return await x.execute({command:0,config:{start:new E(a),keys:y.keys,controlSubject:o,authorities:z(i),mode:l,errOnUnauthorized:u,enableAutoCommit:p,autoIndexPersistInterval:g}}),x}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?En(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},c(Pe,"ENDPOINT","/frame/write"),Pe);const bu=s.z.object({keys:$e.array().optional(),names:s.z.string().array().optional(),bounds:J.z}),Ou=s.z.object({}),Tu="/frame/delete";class zu{constructor(e){c(this,"client");this.client=e}async delete(e){await w(this.client,Tu,e,bu,Ou)}}let Wa=class{constructor(e,t,n){c(this,"streamClient");c(this,"retriever");c(this,"deleter");this.streamClient=e,this.retriever=n,this.deleter=new zu(t)}async openIterator(e,t){return await qt._open(e,t,this.retriever,this.streamClient)}async openWriter(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await Ya._open(this.retriever,this.streamClient,e)}async openStreamer(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await ur._open(this.retriever,this.streamClient,e)}async write(e,t,n){if(n==null){const i=t,o=await this.openWriter({start:e,channels:Object.keys(i),mode:dt.PersistOnly});try{await o.write(i),await o.commit()}finally{await o.close()}return}const a=await this.openWriter({start:e,channels:t,mode:dt.PersistOnly,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:N.MAX});try{await a.write(t,n)}finally{await a.close()}}async read(e,t){const{single:n}=ke(t),a=await this.readFrame(e,t);return n?a.get(t):a}async readFrame(e,t){const n=await this.openIterator(e,t),a=new _;try{for await(const i of n)a.push(i)}finally{await n.close()}return a}async delete(e,t){const{normalized:n,variant:a}=ke(e);return a==="keys"?await this.deleter.delete({keys:n,bounds:t}):await this.deleter.delete({names:n,bounds:t})}};const Eu=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:gu,AUTO_SPAN:Jr,Client:Wa,Frame:_,Iterator:qt,ObservableStreamer:hr,Streamer:ur,Writer:Ya,WriterMode:dt,frameZ:cr,series:Ua,seriesFromPayload:La,seriesToPayload:Ba},Symbol.toStringTag,{value:"Module"})),Su=Ke.Authority,Nu=Ke.stateZ(s.z.number()),Au=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Ka extends hr{constructor(t){super(t,n=>{const a=this.ecd.decode(n.series[0].buffer);return this.merge(a),[a.transfers,!0]});c(this,"states");c(this,"ecd");this.states=new Map,this.ecd=new Ve.JSONEncoderDecoder}subjects(){const t=new Map;return this.states.forEach(n=>t.set(n.subject.key,n.subject)),Array.from(t.values())}merge(t){t.transfers.forEach(n=>{n.from==null&&n.to==null&&console.warn("Invalid transfer: ",n),n.to==null?this.states.delete(n.from.resource):this.states.set(n.to.resource,n.to)})}}const Iu="sy_node_1_control";let Va=class{constructor(e){c(this,"framer");this.framer=e}async openStateTracker(){const e=await this.framer.openStreamer(Iu);return new Ka(e)}};const ku=Object.freeze(Object.defineProperty({__proto__:null,Authority:Su,Client:Va,StateTracker:Ka,stateZ:Nu,transferString:Au},Symbol.toStringTag,{value:"Module"}));let Fa=class{constructor(e,t,n){c(this,"tasks");c(this,"racks");c(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const $u=Object.freeze(Object.defineProperty({__proto__:null,Client:Fa},Symbol.toStringTag,{value:"Module"})),Je=s.z.number(),fr=s.z.object({key:Je,name:s.z.string()}),Ja=fr.partial({key:!0}),Ar="/hardware/rack/retrieve",Cu="/hardware/rack/create",Ru="/hardware/rack/delete",Ir=s.z.object({keys:Je.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),kr=s.z.object({racks:Fe(fr)}),ju=s.z.object({racks:Ja.array()}),xu=s.z.object({racks:fr.array()}),Pu=s.z.object({keys:Je.array()}),Du=s.z.object({});let Ga=class{constructor(e,t,n){c(this,"type","rack");c(this,"client");c(this,"frameClient");c(this,"tasks");this.client=e,this.frameClient=t,this.tasks=n}async delete(e){await w(this.client,Ru,{keys:z(e)},Pu,Du)}async create(e){const t=!Array.isArray(e),n=await w(this.client,Cu,{racks:z(e)},ju,xu),a=this.sugar(n.racks);return t?a[0]:a}async search(e){const t=await w(this.client,Ar,{search:e},Ir,kr);return this.sugar(t.racks)}async page(e,t){const n=await w(this.client,Ar,{offset:e,limit:t},Ir,kr);return this.sugar(n.racks)}async retrieve(e){const{variant:t,normalized:n,single:a}=ir(e,{string:"names",number:"keys"}),i=await w(this.client,Ar,{[t]:n},Ir,kr),o=this.sugar(i.racks);return or("Rack",e,o,a),a?o[0]:o}sugar(e){return e.map(({key:t,name:n})=>new Ha(t,n,this.tasks))}};class Ha{constructor(e,t,n){c(this,"key");c(this,"name");c(this,"tasks");this.key=e,this.name=t,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 gt=async(r,e,t,n)=>{const a=await r.openStreamer([e,t]),i=o=>{const l=[];return t!=null&&l.push(...o.get(t).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 hr(a,i)},Zu=Object.freeze(Object.defineProperty({__proto__:null,openObservable:gt},Symbol.toStringTag,{value:"Module"})),Mu="sy_device_set",_u="sy_device_delete",$r="/hardware/device/retrieve",Uu="/hardware/device/create",Lu="/hardware/device/delete",dr=s.z.string(),mt=s.z.object({key:dr,rack:Je,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(r=>r===""?{}:Ve.JSON_ECD.decodeString(r)))}),Xa=mt.extend({properties:s.z.unknown().transform(r=>Ve.JSON_ECD.encodeString(r))}),Bu=s.z.object({devices:Xa.array()}),qu=s.z.object({devices:mt.array()}),Yu=s.z.object({keys:dr.array()}),Wu=s.z.object({}),Cr=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:dr.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),Rr=s.z.object({devices:Fe(mt)});let Qa=class{constructor(e,t){c(this,"type","device");c(this,"client");c(this,"frameClient");this.client=e,this.frameClient=t}async retrieve(e,t){const n=!Array.isArray(e),a=await w(this.client,$r,{keys:z(e),...t},Cr,Rr);return or("Device",e,a.devices,n),n?a.devices[0]:a.devices}async search(e,t){return(await w(this.client,$r,{search:e,...t},Cr,Rr)).devices}async page(e,t,n){return(await w(this.client,$r,{offset:e,limit:t,...n},Cr,Rr)).devices}async create(e){const t=!Array.isArray(e),n=await w(this.client,Uu,{devices:z(e)},Bu,qu);return t?n.devices[0]:n.devices}async delete(e){await w(this.client,Lu,{keys:z(e)},Yu,Wu)}async openDeviceTracker(){return await gt(this.frameClient,Mu,_u,Ku)}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}};const Ku=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(mt).map(t=>({variant:r,key:t.key,value:t})),Vu=Object.freeze(Object.defineProperty({__proto__:null,Client:Qa,deviceKeyZ:dr,deviceZ:mt,newDeviceZ:Xa},Symbol.toStringTag,{value:"Module"})),Fu=Object.freeze(Object.defineProperty({__proto__:null,Client:Ga,Rack:Ha,newRackZ:Ja,rackKeyZ:Je,rackZ:fr},Symbol.toStringTag,{value:"Module"}));let Ju="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Gu=(r=21)=>{let e="",t=r;for(;t--;)e+=Ju[Math.random()*64|0];return e};const jr="sy_task_state",ss="sy_task_cmd",Ge=s.z.union([s.z.string(),s.z.bigint().transform(r=>r.toString()),s.z.number().transform(r=>r.toString())]),Yt=s.z.object({task:Ge,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:JSON.parse(r))).or(s.z.array(s.z.unknown())).or(s.z.null())}),yr=s.z.object({key:Ge,name:s.z.string(),type:s.z.string(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:Ve.JSON_ECD.decodeString(r))),state:Yt.optional().nullable()}),ei=yr.omit({key:!0}).extend({key:Ge.transform(r=>r.toString()).optional(),config:s.z.unknown().transform(r=>Ve.JSON_ECD.encodeString(r))}),Hu=s.z.object({task:Ge,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:JSON.parse(r)))});class ti{constructor(e,t,n,a,i,o){c(this,"key");c(this,"name");c(this,"type");c(this,"config");c(this,"state");c(this,"frameClient");this.key=e,this.name=t,this.type=n,this.config=a,o!==null&&(this.state=o),this.frameClient=i}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state}}async executeCommand(e,t){const n=await this.frameClient.openWriter(ss),a=Gu();return await n.write(ss,[{task:this.key,type:e,key:a,args:t}]),await n.close(),a}async executeCommandSync(e,t,n){const a=await this.frameClient.openStreamer(jr),i=await this.executeCommand(e,t);let o;const l=new Promise(u=>setTimeout(()=>u(!1),new N(n).milliseconds));for(;;){const u=await Promise.any([a.read(),l]);if(u===!1)throw new Error("Command timed out");const p=Yt.safeParse(u.at(-1).sy_task_state);if(p.success){if(o=p.data,o.key===i)break}else console.error(p.error)}return a.close(),o}async openStateObserver(){return new hr(await this.frameClient.openStreamer(jr),e=>{const t=e.get(jr);if(t.length===0)return[null,!1];const n=Yt.safeParse(t.at(-1));if(!n.success)return[null,!1];const a=n.data;return a.task!==this.key?[null,!1]:[a,!0]})}}const Xu=s.z.object({rack:Je.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()}),Qu=s.z.object({tasks:Fe(yr)}),eh="/hardware/task/retrieve",th="/hardware/task/create",rh="/hardware/task/delete",nh=s.z.object({tasks:ei.array()}),sh=s.z.object({tasks:yr.array()}),ah=s.z.object({keys:Ge.array()}),ih=s.z.object({});let ri=class{constructor(e,t){c(this,"type","task");c(this,"client");c(this,"frameClient");this.client=e,this.frameClient=t}async create(e){const t=!Array.isArray(e),n=await w(this.client,th,{tasks:z(e)},nh,sh),a=this.sugar(n.tasks);return t?a[0]:a}async delete(e){await w(this.client,rh,{keys:z(e)},ah,ih)}async search(e){return await this.execRetrieve({keys:[e]})}async page(e,t){return this.execRetrieve({offset:e,limit:t})}async retrieve(e,t){const{single:n,normalized:a,variant:i}=ir(e,{number:"rack",string:"keys"},{convertNumericStrings:!1}),o={...t};i==="rack"?o.rack=e:o.keys=a;const l=await this.execRetrieve(o),u=this.sugar(l);return n&&i!=="rack"?u[0]:u}async retrieveByName(e,t){const n=await this.execRetrieve({names:[e],rack:t});return or("Task",e,n,!0),this.sugar(n)[0]}async execRetrieve(e){return(await w(this.client,eh,e,Xu,Qu)).tasks}sugar(e){return e.map(({key:t,name:n,type:a,config:i,state:o})=>new ti(t,n,a,i,this.frameClient,o))}};const oh=Object.freeze(Object.defineProperty({__proto__:null,Client:ri,Task:ti,commandZ:Hu,newTaskZ:ei,stateZ:Yt,taskKeyZ:Ge,taskZ:yr},Symbol.toStringTag,{value:"Module"}));class ch{constructor(e,t){c(this,"key");c(this,"name");this.key=t,this.name=e}get ontologyID(){return new X({type:"group",key:this.key})}}const lh=s.z.string().uuid(),uh=s.z.object({key:lh,name:s.z.string()}),ni=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")]),ne=s.z.object({type:ni,key:s.z.string()}),si=s.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),ai=s.z.union([si,ne]),Be=class Be{constructor(e){c(this,"type");c(this,"key");if(e instanceof Be)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,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(Be,"z",s.z.union([ai,s.z.instanceof(Be)]).transform(e=>new Be(e)));let X=Be;const hh=new X({type:"builtin",key:"root"}),ii=s.z.object({type:s.z.number()}),oi=s.z.object({type:ni,fields:s.z.record(ii)}),ci=s.z.object({id:X.z,name:s.z.string(),schema:oi.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(r=>({key:r.id.toString(),...r})),fh=s.z.object({from:X.z,type:s.z.string(),to:X.z}),Gr=r=>{const[e,t,n]=r.split("->");return{from:new X(e),type:t,to:new X(n)}},dh=s.z.object({group:uh}),yh=s.z.object({parent:ne,key:s.z.string().uuid().optional(),name:s.z.string()}),ph=s.z.object({key:s.z.string(),name:s.z.string()}),gh=s.z.object({keys:s.z.array(s.z.string())});var le;let mh=(le=class{constructor(e){c(this,"client");this.client=e}async create(e,t,n){const[a,i]=await this.client.send(le.ENDPOINT,{parent:e,name:t,key:n},yh,dh);if(i!=null)throw i;return a.group}async rename(e,t){const n={key:e,name:t},[,a]=await this.client.send(le.ENDPOINT_RENAME,n,ph,s.z.object({}));if(a!=null)throw a}async delete(e){const t={keys:e},[,n]=await this.client.send(le.ENDPOINT_DELETE,t,gh,s.z.object({}));if(n!=null)throw n}},c(le,"ENDPOINT","/ontology/create-group"),c(le,"ENDPOINT_RENAME","/ontology/rename-group"),c(le,"ENDPOINT_DELETE","/ontology/delete-group"),le),wh=class{constructor(e){c(this,"creator");this.creator=new mh(e)}async create(e,t,n){return this.sugar(await this.creator.create(e,t,n))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new ch(e.name,e.key)}};const xr={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},as=s.z.object({id:ne,children:ne.array()}),vh=s.z.object({from:ne,to:ne,children:ne.array()});let bh=class{constructor(e){c(this,"client");this.client=e}async addChildren(e,...t){await w(this.client,xr.ADD_CHILDREN,{id:e,children:t},as,s.z.object({}))}async removeChildren(e,...t){await w(this.client,xr.REMOVE_CHILDREN,{id:e,children:t},as,s.z.object({}))}async moveChildren(e,t,...n){const a={from:e,to:t,children:n};await w(this.client,xr.MOVE_CHILDREN,a,vh,s.z.object({}))}};const Oh="/ontology/retrieve",Th=s.z.object({ids:ne.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()}),zh=s.z.object({resources:ci.array()}),Pr=r=>z(r).map(e=>new X(e).payload);let li=class{constructor(e,t){c(this,"type","ontology");c(this,"groups");c(this,"client");c(this,"writer");c(this,"framer");this.client=e,this.writer=new bh(e),this.groups=new wh(e),this.framer=t}async search(e,t){return await this.execRetrieve({term:e,...t})}async retrieve(e,t){const n=await this.execRetrieve({ids:Pr(e),...t});if(Array.isArray(e))return n;if(n.length===0)throw new ee(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t,n){return await this.execRetrieve({offset:e,limit:t,...n})}async retrieveChildren(e,t){return await this.execRetrieve({ids:Pr(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:Pr(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await pr.open(this.framer,this)}newSearcherWithOptions(e){return{type:this.type,search:t=>this.search(t,e),retrieve:t=>this.retrieve(t,e),page:(t,n)=>this.page(t,n,e)}}async execRetrieve(e){const{resources:t}=await w(this.client,Oh,e,Th,zh);return t}};const is="sy_ontology_resource_set",os="sy_ontology_resource_delete",cs="sy_ontology_relationship_set",ls="sy_ontology_relationship_delete";class pr{constructor(e,t){c(this,"resourceObs");c(this,"relationshipObs");c(this,"relationships");c(this,"resources");c(this,"streamer");c(this,"client");c(this,"closePromise");this.relationshipObs=new Kr.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Kr.Observer,this.resources=this.resourceObs,this.client=t,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 t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const i=this.parseRelationshipSets(e),o=this.parseRelationshipDeletes(e);i.concat(o).length>0&&this.relationshipObs.notify(i.concat(o))}parseRelationshipSets(e){const t=e.get(cs);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:Gr(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(ls);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:Gr(n)}))}async parseResourceSets(e){const t=e.get(is);if(t.length===0)return[];const n=Array.from(t.as("string")).map(a=>new X(a));try{return(await this.client.retrieve(n)).map(i=>({variant:"set",key:i.id,value:i}))}catch(a){if(a instanceof ee)return[];throw a}}parseResourceDeletes(e){const t=e.get(os);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new X(n)}))}static async open(e,t){const n=await e.openStreamer([is,os,cs,ls]);return new pr(n,t)}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:pr,Client:li,ID:X,Root:hh,crudeIDZ:ai,idZ:ne,parseRelationship:Gr,relationshipSchemaZ:fh,resourceSchemaZ:ci,schemaFieldZ:ii,schemaZ:oi,stringIDZ:si},Symbol.toStringTag,{value:"Module"})),He=s.z.string().uuid(),wt=s.z.object({key:He,name:s.z.string().min(1),color:s.z.string()}),Sh=r=>new X({type:"label",key:r}),Nh=s.z.object({keys:He.array().optional(),for:ne.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Ah=s.z.object({labels:wt.array().optional().default([])});var qe;let ui=(qe=class{constructor(e){c(this,"client");this.client=e}async retrieve(e){const t=z(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(qe.ENDPOINT,e,Nh,Ah);if(n!=null)throw n;return t.labels}},c(qe,"ENDPOINT","/label/retrieve"),qe);const hi=wt.extend({key:He.optional()}),Ih=s.z.object({labels:hi.array()}),kh=s.z.object({labels:wt.array()}),$h=s.z.object({keys:He.array()}),fi=s.z.object({id:ne,labels:He.array()}),Ch=fi,Dr=s.z.object({}),Rh="/label/create",jh="/label/delete",xh="/label/set",Ph="/label/remove";let di=class{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Rh,{labels:z(e)},Ih,kh)).labels}async delete(e){await w(this.client,jh,{keys:z(e)},$h,Dr)}async set(e,t){await w(this.client,xh,{id:e,labels:t},fi,Dr)}async remove(e,t){await w(this.client,Ph,{id:e,labels:t},Ch,Dr)}};const Dh="sy_label_set",Zh="sy_label_delete";let yi=class{constructor(e,t){c(this,"type","label");c(this,"retriever");c(this,"writer");c(this,"frameClient");this.writer=new di(e),this.retriever=new ui(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await gt(this.frameClient,Dh,Zh,Mh)}};const Mh=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(wt).map(t=>({variant:r,key:t.key,value:t})),_h=Object.freeze(Object.defineProperty({__proto__:null,Client:yi,Retriever:ui,Writer:di,keyZ:He,labelZ:wt,newLabelPayloadZ:hi,ontologyID:Sh},Symbol.toStringTag,{value:"Module"})),G=s.z.string().uuid(),Xe=s.z.object({key:G,name:s.z.string().min(1),timeRange:J.z,color:s.z.string().optional()}),pi=Xe.extend({key:s.z.string().uuid().optional()}),gi=r=>{const e=z(r);if(e.length===0)throw new Error("Range params must not be empty");const t=G.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},Uh=s.z.object({}),Lh=s.z.object({range:Xe}),Bh=s.z.object({range:G}),qh=s.z.object({range:G}),Yh=s.z.object({}),Wh="/range/set-active",Kh="/range/retrieve-active",Vh="/range/clear-active";class Fh{constructor(e){c(this,"client");this.client=e}async setActive(e){await w(this.client,Wh,{range:e},Bh,Uh)}async retrieveActive(){const[e,t]=await this.client.send(Kh,{},s.z.object({}),Lh);if(t instanceof ee)return null;if(t!=null)throw t;return e.range}async clearActive(e){await w(this.client,Vh,{range:e},qh,Yh)}}const Jh="sy_range_alias_set",Gh="sy_range_alias_delete",Hh=s.z.object({range:G,aliases:s.z.string().array()}),Xh=s.z.object({aliases:s.z.record(s.z.string(),$e)}),Qh=s.z.object({range:G,aliases:s.z.record($e.or(s.z.string()),s.z.string())}),ef=s.z.unknown(),tf=s.z.object({range:G,channels:$e.array()}),rf=s.z.unknown(),nf=s.z.object({range:G}),sf=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),ce=class ce{constructor(e,t,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=t}async resolve(e){const t=[],n=typeof e=="string",a={};if(n){const o=this.cache.get(e);if(o!=null)return o;t.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?a[o]=l:t.push(o)});if(t.length===0)return a;const i=await w(this.client,ce.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},Hh,Xh);return Object.entries(i.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?i.aliases[t[0]]:{...a,...i.aliases}}async set(e){await w(this.client,ce.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Qh,ef)}async list(){return(await w(this.client,ce.LIST_ENDPOINT,{range:this.rangeKey},nf,sf)).aliases}async delete(e){await w(this.client,ce.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},tf,rf)}async openChangeTracker(){return await gt(this.frameClient,Jh,Gh,cf(this.rangeKey))}};c(ce,"SET_ENDPOINT","/range/alias/set"),c(ce,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(ce,"LIST_ENDPOINT","/range/alias/list"),c(ce,"DELETE_ENDPOINT","/range/alias/delete");let Hr=ce;const af=s.z.object({range:G,channel:$e,alias:s.z.string()}),of="---",cf=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(of)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(af).map(n=>({variant:e,key:n.alias,value:n})),lf=s.z.object({range:G,keys:s.z.string().array()}),uf=s.z.object({pairs:s.z.record(s.z.string(),s.z.string())}),hf=s.z.object({range:G,pairs:s.z.record(s.z.string(),s.z.string())}),ff=s.z.object({range:G,keys:s.z.string().array()}),Ae=class Ae{constructor(e,t){c(this,"rangeKey");c(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(Ae.GET_ENDPOINT,{range:this.rangeKey,keys:z(e)},lf,uf);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async list(){return this.get([])}async set(e,t=""){await w(this.client,Ae.SET_ENDPOINT,{range:this.rangeKey,pairs:Ia(e)?e:{[e]:t}},hf,s.z.unknown())}async delete(e){await w(this.client,Ae.DELETE_ENDPOINT,{range:this.rangeKey,keys:z(e)},ff,s.z.unknown())}};c(Ae,"GET_ENDPOINT","/range/kv/get"),c(Ae,"SET_ENDPOINT","/range/kv/set"),c(Ae,"DELETE_ENDPOINT","/range/kv/delete");let Xr=Ae;const Zr=r=>new X({type:"range",key:r});class mi{constructor(e,t=J.ZERO,n,a,i,o,l,u,p){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");this.key=n,this.name=e,this.timeRange=t,this.frameClient=i,this.color=a,this.kv=o,this.aliaser=l,this.channels=u,this.labelClient=p}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new ee(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Zr(this.key))}async addLabel(...e){await this.labelClient.label(Zr(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Zr(this.key),e)}}const df=s.z.object({keys:G.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:J.z.optional()}),yf="/range/retrieve",pf=s.z.object({ranges:Fe(Xe)});let wi=class{constructor(e,t,n,a,i){c(this,"type","range");c(this,"frameClient");c(this,"writer");c(this,"unaryClient");c(this,"channels");c(this,"active");c(this,"labelClient");this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=a,this.active=new Fh(n),this.labelClient=i}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(z(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(z(e))}async search(e){return this.sugar(await this.execRetrieve({term:e}))}async page(){return[]}async retrieve(e){if(typeof e=="object"&&"start"in e)return await this.execRetrieve({overlapsWith:new J(e)});const{single:t,actual:n,variant:a,normalized:i}=gi(e),o=await this.execRetrieve({[a]:i});if(!t)return o;if(o.length===0)throw new ct(`range matching ${n} not found`);if(o.length>1)throw new lt(`multiple ranges matching ${n} found`);return o[0]}async execRetrieve(e){const{ranges:t}=await w(this.unaryClient,yf,e,df,pf);return this.sugar(t)}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new mi(t.name,t.timeRange,t.key,t.color,this.frameClient,new Xr(t.key,this.unaryClient),new Hr(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await gt(this.frameClient,"sy_range_set","sy_range_delete",(e,t)=>e==="delete"?t.toStrings().map(a=>({variant:e,key:a,value:void 0})):this.sugar(t.parseJSON(Xe)).map(a=>({variant:e,key:a.key,value:a})))}};const gf=s.z.object({ranges:Xe.array()}),mf=s.z.object({ranges:pi.array()}),wf=s.z.object({keys:G.array()}),vf=s.z.object({}),bf=s.z.object({key:G,name:s.z.string()}),Of=s.z.object({}),Tf="/range/create",zf="/range/delete",Ef="/range/rename";let vi=class{constructor(e){c(this,"client");this.client=e}async rename(e,t){await w(this.client,Ef,{key:e,name:t},bf,Of)}async create(e){return(await w(this.client,Tf,{ranges:e},mf,gf)).ranges}async delete(e){await w(this.client,zf,{keys:e},wf,vf)}};const Sf=Object.freeze(Object.defineProperty({__proto__:null,Client:wi,Range:mi,Writer:vi,analyzeParams:gi,keyZ:G,newPayloadZ:pi,payloadZ:Xe},Symbol.toStringTag,{value:"Module"})),Nf="/api/v1/";class Af{constructor(e,t=!1){c(this,"url");c(this,"unary");c(this,"stream");c(this,"secure");this.secure=t,this.url=e.child(Nf);const n=new Ve.JSONEncoderDecoder;this.unary=new hl(this.url,n,this.secure),this.stream=new bl(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Rn=s.z.string().uuid(),jn=s.z.object({key:s.z.string(),name:s.z.string(),data:Sn.or(s.z.string().transform(r=>JSON.parse(r)))}),If=s.z.object({keys:s.z.string().array()}),kf=s.z.object({linePlots:jn.array()});let $f=class{constructor(e){c(this,"ENDPOINT","/workspace/lineplot/retrieve");c(this,"client");this.client=e}async retrieve(e){const t=z(e);return(await w(this.client,this.ENDPOINT,{keys:t},If,kf)).linePlots}};const Ce=s.z.string().uuid(),bi=r=>JSON.parse(r),xn=s.z.object({name:s.z.string(),key:Ce,layout:Sn.or(s.z.string().transform(r=>bi(r)))}),Pn=xn.omit({layout:!0}).extend({layout:s.z.string().transform(r=>bi(r))}),Cf=jn.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Rf=s.z.object({workspace:Ce,linePlots:Cf.array()}),jf=s.z.object({linePlots:jn.array()}),xf=s.z.object({keys:Rn.array()}),Pf=s.z.object({}),Df=s.z.object({key:Rn,name:s.z.string()}),Zf=s.z.object({}),Mf=s.z.object({key:Rn,data:s.z.string()}),_f=s.z.object({}),Uf="/workspace/lineplot/create",Lf="/workspace/lineplot/delete",Bf="/workspace/lineplot/rename",qf="/workspace/lineplot/set-data";let Yf=class{constructor(e){c(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await w(this.client,Uf,{workspace:e,linePlots:[n]},Rf,jf)).linePlots[0]}async delete(e){const t=z(e);await w(this.client,Lf,{keys:t},xf,Pf)}async rename(e,t){await w(this.client,Bf,{key:e,name:t},Df,Zf)}async setData(e,t){await w(this.client,qf,{key:e,data:JSON.stringify(t)},Mf,_f)}},Wf=class{constructor(e){c(this,"writer");c(this,"retriever");this.writer=new Yf(e),this.retriever=new $f(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Kf=s.z.object({keys:Ce.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Vf=s.z.object({workspaces:Fe(Pn)});var Ye;let Ff=(Ye=class{constructor(e){c(this,"client");this.client=e}async retrieve(e){const t=z(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await w(this.client,Ye.ENDPOINT,e,Kf,Vf)).workspaces}},c(Ye,"ENDPOINT","/workspace/retrieve"),Ye);const gr=s.z.string().uuid(),Jf=s.z.object({key:s.z.string(),name:s.z.string(),data:Sn.or(s.z.string().transform(r=>JSON.parse(r))),snapshot:s.z.boolean()}),Dn=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(r=>JSON.parse(r))}),Gf=s.z.object({keys:s.z.string().array()}),Hf=s.z.object({schematics:Dn.array()});class Xf{constructor(e){c(this,"ENDPOINT","/workspace/schematic/retrieve");c(this,"client");this.client=e}async retrieve(e){return(await w(this.client,this.ENDPOINT,{keys:z(e)},Gf,Hf)).schematics}}const Qf=Jf.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),ed=s.z.object({workspace:Ce,schematics:Qf.array()}),td=s.z.object({schematics:Dn.array()}),rd=s.z.object({keys:gr.array()}),nd=s.z.object({}),sd=s.z.object({key:gr,name:s.z.string()}),us=s.z.object({}),ad=s.z.object({key:gr,data:s.z.string()});s.z.object({});const id=s.z.object({key:gr,name:s.z.string(),snapshot:s.z.boolean()}),od=s.z.object({schematic:Dn}),cd="/workspace/schematic/create",ld="/workspace/schematic/delete",ud="/workspace/schematic/rename",hd="/workspace/schematic/set-data",fd="/workspace/schematic/copy";let dd=class{constructor(e){c(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await w(this.client,cd,{workspace:e,schematics:[n]},ed,td)).schematics[0]}async copy(e,t,n){return(await w(this.client,fd,{key:e,name:t,snapshot:n},id,od)).schematic}async delete(e){const t=z(e);await w(this.client,ld,{keys:t},rd,nd)}async rename(e,t){await w(this.client,ud,{key:e,name:t},sd,us)}async setData(e,t){await w(this.client,hd,{key:e,data:JSON.stringify(t)},ad,us)}},yd=class{constructor(e){c(this,"writer");c(this,"retriever");this.writer=new dd(e),this.retriever=new Xf(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const pd=xn.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),gd=s.z.object({workspaces:pd.array()}),md=s.z.object({workspaces:Pn.array()}),wd=s.z.object({keys:Ce.array()}),vd=s.z.object({}),bd=s.z.object({key:Ce,name:s.z.string()}),Od=s.z.object({}),Td=s.z.object({key:Ce,layout:s.z.string()}),zd=s.z.object({}),Ed="/workspace/create",Sd="/workspace/delete",Nd="/workspace/rename",Ad="/workspace/set-layout";class Id{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Ed,{workspaces:z(e)},gd,md)).workspaces}async delete(e){await w(this.client,Sd,{keys:z(e)},wd,vd)}async rename(e,t){await w(this.client,Nd,{key:e,name:t},bd,Od)}async setLayout(e,t){await w(this.client,Ad,{key:e,layout:JSON.stringify(t)},Td,zd)}}class Oi{constructor(e){c(this,"type","workspace");c(this,"schematic");c(this,"linePlot");c(this,"retriever");c(this,"writer");this.schematic=new yd(e),this.linePlot=new Wf(e),this.retriever=new Ff(e),this.writer=new Id(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const kd=Object.freeze(Object.defineProperty({__proto__:null,Client:Oi,keyZ:Ce,workspaceRemoteZ:Pn,workspaceZ:xn},Symbol.toStringTag,{value:"Module"})),Ti=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().optional(),password:s.z.string().optional(),connectivityPollFrequency:N.z.default(N.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class zi extends Wa{constructor(t){const n=Ti.parse(t),{host:a,port:i,username:o,password:l,connectivityPollFrequency:u,secure:p}=n,g=new Af(new Ml({host:a,port:Number(i)}),p);g.use(El);let y;if(o!=null&&l!=null){const Si=new iu(g.unary,{username:o,password:l});g.use(Si.middleware())}const U=new Nn(new ht(g.unary)),x=new Za(g.unary);super(g.stream,g.unary,U);c(this,"createdAt");c(this,"props");c(this,"ranges");c(this,"channels");c(this,"auth");c(this,"connectivity");c(this,"ontology");c(this,"workspaces");c(this,"labels");c(this,"hardware");c(this,"control");c(this,"transport");this.createdAt=E.now(),this.props=n,this.auth=y,this.transport=g,this.channels=new Da(this,U,g.unary,x),this.connectivity=new ft(g.unary,u,n.name),this.control=new Va(this),this.ontology=new li(g.unary,this);const Q=new vi(this.transport.unary);this.labels=new yi(this.transport.unary,this),this.ranges=new wi(this,Q,this.transport.unary,U,this.labels),this.workspaces=new Oi(this.transport.unary);const D=new Qa(this.transport.unary,this),Zn=new ri(this.transport.unary,this),Ei=new Ga(this.transport.unary,this,Zn);this.hardware=new Fa(Zn,Ei,D)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c(zi,"connectivity",ft);const $d=Ke.Authority;exports.AuthError=We;exports.Authority=$d;exports.Channel=An;exports.ContiguityError=Ol;exports.DataType=S;exports.Density=V;exports.Frame=_;exports.MultiSeries=Ls;exports.QueryError=ee;exports.Rate=Ht;exports.RouteError=Bt;exports.Series=F;exports.Synnax=zi;exports.TimeRange=J;exports.TimeSpan=N;exports.TimeStamp=E;exports.UnexpectedError=xe;exports.ValidationError=P;exports.channel=tu;exports.connection=lu;exports.control=ku;exports.device=Vu;exports.framer=Eu;exports.hardware=$u;exports.label=_h;exports.ontology=Eh;exports.rack=Fu;exports.ranger=Sf;exports.signals=Zu;exports.synnaxPropsZ=Ti;exports.task=oh;exports.workspace=kd;
|