@synnaxlabs/client 0.54.0 → 0.54.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 +5 -5
- package/dist/client.cjs +3 -3
- package/dist/client.js +7 -6
- package/dist/src/arc/ir/types.gen.d.ts +1 -1
- package/dist/src/arc/ir/types.gen.d.ts.map +1 -1
- package/dist/src/channel/payload.d.ts +9 -7
- package/dist/src/channel/payload.d.ts.map +1 -1
- package/dist/src/channel/types.gen.d.ts +9 -5
- package/dist/src/channel/types.gen.d.ts.map +1 -1
- package/dist/src/framer/streamer.d.ts +18 -14
- package/dist/src/framer/streamer.d.ts.map +1 -1
- package/dist/src/framer/writer.d.ts +18 -14
- package/dist/src/framer/writer.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/arc/ir/types.gen.ts +1 -1
- package/src/channel/types.gen.ts +1 -1
package/dist/client.cjs
CHANGED
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
10
10
|
`)}\n`).buffer):this.dataType.usesBigInt&&typeof t==`number`?this._data=new this.dataType.Array(e.map(e=>BigInt(Math.round(e)))).buffer:!this.dataType.usesBigInt&&typeof t==`bigint`?this._data=new this.dataType.Array(e.map(Number)).buffer:this._data=new this.dataType.Array(e).buffer}this.key=s,this.alignment=a,this.alignmentMultiple=o,this.sampleOffset=r??0,this.timeRange=n??A.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:t,dataType:n,...r}){if(t===0)throw Error(`[Series] - cannot allocate an array of length 0`);let i=new e({data:new new j(n).Array(t).buffer,dataType:n,...r});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn(`cannot release a series with a negative reference count`)}write(e){if(!e.dataType.equals(this.dataType))throw Error(`buffer must be of the same type as this array`);return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Go)return 0;let t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===Go)return 0;let t=this.capacity-this.writePos,n=e.sub(0,t);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data==`object`&&`buffer`in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Go?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
|
|
11
11
|
`).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(j.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(li.decodeString(t)))}get byteCapacity(){return new Oo(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Go?this.byteCapacity:this.dataType.isVariable?new Oo(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Go?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos:this.cachedLength}calculateCachedLength(){if(!this.dataType.isVariable)throw Error(`cannot calculate length of a non-variable length data type`);let e=0,t=[0];return this.data.forEach((n,r)=>{n===Yo&&(e++,t.push(r+1))}),this._cachedIndexes=t,this.cachedLength=e,e}convert(t,n=0){if(this.dataType.equals(t))return this;let r=new t.Array(this.length);for(let e=0;e<this.length;e++)r[e]=Mo(this.dataType,t,this.data[e],n);return new e({data:r.buffer,dataType:t,timeRange:this.timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){return this.length===0?-1/0:(this.dataType.equals(j.TIMESTAMP)?this.cachedMax=this.data[this.data.length-1]:(this.dataType.usesBigInt,this.cachedMax=this.data.reduce((e,t)=>e>t?e:t)),this.cachedMax)}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw Error(`cannot calculate maximum on a variable length data type`);return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),na(this.cachedMax,this.sampleOffset))}calcRawMin(){return this.length===0?1/0:(this.dataType.equals(j.TIMESTAMP)?this.cachedMin=this.data[0]:(this.dataType.usesBigInt,this.cachedMin=this.data.reduce((e,t)=>e<t?e:t)),this.cachedMin)}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw Error(`cannot calculate minimum on a variable length data type`);return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),na(this.cachedMin,this.sampleOffset))}get bounds(){return E(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){let t=e.cachedMin??e.calcRawMin();t<this.cachedMin&&(this.cachedMin=t)}if(this.cachedMax!=null){let t=e.cachedMax??e.calcRawMax();t>this.cachedMax&&(this.cachedMax=t)}}atAlignment(e,t){let n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(t===!0)throw Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t??!1);if(this.dataType.equals(j.UUID))return this.atUUID(e,t);e<0&&(e=this.length+e);let n=this.data[e];if(n==null){if(t===!0)throw Error(`[series] - no value at index ${e}`);return}return na(n,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=Wo(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(t)throw Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let t=0;t<this.data.length;t++)if(this.data[t]===Yo){if(e===0){r=t;break}n=t+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw Error(`[series] - no value at index ${e}`);return}}let i=this.data.slice(n,r);return this.dataType.equals(j.STRING)?new TextDecoder().decode(i):Xr(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,n=this.length-1,r=xi(e);for(;t<=n;){let i=Math.floor((t+n)/2),a=r(this.at(i,!0),e);if(a===0)return i;a<0?t=i+1:n=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(j.FLOAT32)&&!this.dataType.equals(j.UINT8))throw Error(`Only FLOAT32 and UINT8 arrays can be used in WebGL`);let{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t??(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Go){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);let t=this.dataType.density.size(r).valueOf(),n=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,t,n.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=Go}as(e){return Xo(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:ls(this.alignmentBounds.lower),upper:ls(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return E(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 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){let e=new ns(this);return this.dataType.equals(j.JSON)?new rs(e):e}return this.dataType.equals(j.UUID)?new is(this):new as(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new ts(this,e,t??this.length)}subAlignmentIterator(e,t){let n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),r=Math.ceil(Number(t-this.alignment)/Number(this.alignmentMultiple));return new ts(this,n,r)}subBytes(t,n){return t>=0&&(n==null||n>=this.byteLength.valueOf())?this:new e({data:this.data.subarray(t,n),dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return i=t?this.data.subarray(n,r):this.data.slice(n,r),new e({data:i,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(t){return new e({data:this.buffer,dataType:this.dataType,timeRange:A.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:`static`,alignment:t})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(e=>e.toString());else{for(let t=0;t<5;t++)e+=`${this.at(t)?.toString()}`,e+=`,`;e+=`...,`;for(let t=-5;t<0;t++)e+=this.at(t)?.toString(),t<-1&&(e+=`,`)}return e+=`])`,e}},$o=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof Qo?!0:jo(e),es=Ui(Zo,Qo),ts=class{series;end;index;constructor(e,t,n){this.series=e;let r=E(0,e.length+1);this.end=ja(r,n),this.index=ja(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},ns=class{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.index=0,this.decoder=new TextDecoder}next(){let e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==Yo;)this.index++;let 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))})}},rs=class e{wrapped;static schema=l.z.record(l.z.string(),l.z.unknown());constructor(e){this.wrapped=e}next(){let t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:li.decodeString(t.value,e.schema)}}},is=class{series;index;data;density;constructor(e){if(!e.dataType.equals(j.UUID))throw Error(`cannot create a UUID series iterator for a non-UUID series`);this.series=e,this.index=0,this.data=new Uint8Array(e.buffer),this.density=j.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=Wo(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},as=class{series;index;constructor(e){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)}}},os=class{series;constructor(e=[]){if(e.length!==0){let t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw Error(`[multi-series] - series must have the same data type`)}this.series=e}as(e){return Xo(e,this.dataType),this}get dataType(){return this.series.length===0?j.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?A.ZERO:new A(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?E(0n,0n):E(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){let t=()=>Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(es(e)){if(this.series.length!==0&&!n)throw t();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw t();this.series.push(...e.series)}}get length(){return this.series.reduce((e,t)=>e+t.length,0)}atAlignment(e,t){for(let n of this.series)if(Ma(n.alignmentBounds,e))return n.atAlignment(e,t);if(t)throw Error(`[series] - no value at alignment ${e}`)}at(e,t=!1){e<0&&(e=this.length+e);for(let n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw Error(`[series] - no value at index ${e}`)}subIterator(e,t){return new cs(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return Ko;let n=0;for(let t=0;t<this.series.length;t++){let r=this.series[t];if(e<r.alignment)break;if(e>=r.alignmentBounds.upper)n+=r.length;else if(Ma(r.alignmentBounds,e)){n+=Math.ceil(Number(e-r.alignment)/Number(r.alignmentMultiple));break}}let r=0;for(let e=0;e<this.series.length;e++){let n=this.series[e];if(t<n.alignment)break;if(t>=n.alignmentBounds.upper)r+=n.length;else if(Ma(n.alignmentBounds,t)){r+=Math.ceil(Number(t-n.alignment)/Number(n.alignmentMultiple));break}}return new cs(this,n,r)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return Ko;t=Math.min(t,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let t=0;t<this.series.length;t++){let r=this.series[t];if(e<r.alignment)break;if(e>=r.alignmentBounds.upper)n+=r.length;else if(Ma(r.alignmentBounds,e)){n+=Number(e-r.alignment);break}}return new cs(this,n,n+t)}updateGLBuffer(e){this.series.forEach(t=>t.updateGLBuffer(e))}get bounds(){return Na(this.series.map(e=>e.bounds))}get byteLength(){return new Oo(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){let e=new this.dataType.Array(this.length),t=0;for(let n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,t){return Pa(this.series.map(e=>e.alignmentBounds),e,t)}acquire(e){this.series.forEach(t=>t.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,t){return Fa(this.series.map(e=>e.alignmentBounds),e,t)}parseJSON(e){if(!this.dataType.equals(j.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.series.flatMap(t=>t.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new ss(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}},ss=class{series;seriesIndex;internal;constructor(e){this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){let 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}},cs=class{series;index;end;constructor(e,t,n){this.series=e,this.end=n,this.index=t}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}},ls=e=>({domain:e>>32n,sample:e&4294967295n}),us=C({DataType:()=>j,Density:()=>k,MultiSeries:()=>os,Rate:()=>Do,Series:()=>Qo,Size:()=>Oo,TimeRange:()=>A,TimeSpan:()=>O,TimeStamp:()=>D,convertDataType:()=>Mo,dataTypeZ:()=>Ro,isCrudeSeries:()=>$o,isTelemValue:()=>jo,numericTimeRangeZ:()=>ko,rateZ:()=>Io,sizeZ:()=>Lo,timeRangeBoundedZ:()=>zo,timeRangeZ:()=>No,timeSpanZ:()=>Fo,timeStampZ:()=>Po,typedArrayZ:()=>Ao}),ds=async e=>await new Promise(t=>setTimeout(t,O.fromMilliseconds(e).milliseconds)),fs=C({Breaker:()=>ps,breakerConfigZ:()=>ms}),ps=class{config;retries;interval;constructor(e){this.config={baseInterval:new O(e?.baseInterval??O.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??ds},this.retries=0,this.interval=new O(this.config.baseInterval)}async wait(){let{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}},ms=l.z.object({baseInterval:O.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),hs=e=>e.nullable().transform(e=>e===null?void 0:e).optional(),gs=l.z.int().min(qi).max(127),_s=l.z.int().min(Ji).max(Yi),vs=l.z.int().min(Qi).max($i),ys=l.z.int().min(0).max(255),bs=l.z.int().min(0).max(Wi),xs=l.z.int().min(0).max(Gi),Ss=l.z.int().min(0).max(Ki),Cs=e=>l.default.array(e).or(e.transform(e=>[e])),ws=(e,t)=>{let n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r){let n=e,r=t;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(!ws(n[e],r[e]))return!1;return!0}if(e==null||t==null||typeof e!=`object`||typeof t!=`object`)return e===t;if(`equals`in e)return e.equals(t);let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n of i){let r=e[n],i=t[n];if(typeof r==`object`&&typeof i==`object`){if(!ws(r,i))return!1}else if(r!==i)return!1}return!0},Ts=(e,t)=>{if(typeof e!=`object`||!e)return e===t;let n=Object.keys(e),r=Object.keys(t);if(r.length>n.length)return!1;for(let n of r){let r=e[n],i=t[n];if(typeof r==`object`&&typeof i==`object`){if(!Ts(r,i))return!1}else if(r!==i)return!1}return!0},Es=(e,t,n=`.`)=>{let r=e.split(n);return r.map((e,i)=>{let a=t(e,i,r);return a==null?null:typeof a==`string`?a:a.join(n)}).filter(e=>e!=null).join(n)},Ds=(e,t)=>{if(!Array.isArray(e))return e[t];let n=e[t];if(n!=null||e.length==0)return n;let r=e[0];if(typeof r==`object`&&`key`in r)return e.find(e=>e.key===t)},Os=((e,t,n={optional:!1})=>{let{optional:r,getter:i=Ds}=n;if(t===``)return e;let a=t.split(`.`);if(a.length===1){let n=i(e,a[0]);if(n===void 0){if(r)return null;throw Error(`Path ${t} does not exist. ${a[0]} is undefined`)}return n}let o=(e,n)=>{if(n>=a.length)return e;for(let s=a.length-n;s>=1;s--){let c=a.slice(n,n+s).join(`.`),l=i(e,c);if(l!==void 0){if(n+s===a.length)return l;if(l===null){if(r)return null;throw Error(`Path ${t} does not exist. ${c} is null`)}return o(l,n+s)}}if(r)return null;throw Error(`Path ${t} does not exist. ${a[n]} is undefined`)};return o(e,0)}),ks=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if(ii(e)&&ii(n))for(let t in n)try{ii(n[t])?(t in e||Object.assign(e,{[t]:{}}),ks(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):e}return ks(e,...t)},As=e=>e._zod.def.output,js=e=>Es(e,(e,t,n)=>{let r=t===n.length-1,i=!isNaN(parseInt(e,10)),a=!isNaN(parseInt(n[t+1],10));return i&&(e=`element`),r||a?e:[e,`shape`]}),Ms=(e,t)=>{if(e==null)return null;let n=e[t];return n==null&&typeof e==`object`&&`sourceType`in e?e.sourceType()[t]:n},Ns=((e,t,n)=>t===``?e:Os(Ms(e,`shape`),js(t),{...n,getter:Ms})),N=C({functionOutput:()=>As,getFieldSchema:()=>Ns,getFieldSchemaPath:()=>js,int16:()=>_s,int64:()=>vs,int8:()=>gs,nullToUndefined:()=>hs,toArray:()=>Cs,uint12:()=>bs,uint16:()=>xs,uint20:()=>Ss,uint8:()=>ys}),Ps=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),Fs=ys,Is=l.z.number().min(0).max(1),Ls=l.z.tuple([Fs,Fs,Fs,Is]),Rs=l.z.tuple([Fs,Fs,Fs]),zs=l.z.object({rgba255:Ls}),Bs=l.z.object({r:Fs,g:Fs,b:Fs,a:Is}),Vs=l.z.number().min(0).max(360),Hs=l.z.number().min(0).max(100),Us=l.z.number().min(0).max(100),Ws=l.z.tuple([Vs,Hs,Us,Is]),Gs=l.z.union([Ps,Rs,Ls,Ws,zs,Bs]),Ks=Gs.transform(e=>P(e)),qs=e=>Ks.safeParse(e).success,Js=e=>Ls.safeParse(e).success,Ys=(e=>{if(e==null)return;let t=Ks.safeParse(e);if(t.success)return Qs(t.data);if(typeof e==`string`)return e;throw t.error}),P=(e,t=1)=>{if(e=Gs.parse(e),typeof e==`string`)return gc(e,t);if(Array.isArray(e)){if(e.length<3||e.length>4)throw Error(`Invalid color: [${e.join(`, `)}]`);return e.length===3?[...e,t]:e}return`a`in e&&`r`in e?[e.r,e.g,e.b,e.a]:e.rgba255},Xs=(e,t)=>{if(e==null||t==null)return e==t;let n=P(e),r=P(t);return n.every((e,t)=>e===r[t])},Zs=(e=>{if(e==null)return;let[t,n,r,i]=P(e),a=Math.round(i*255);return`#${vc(t)}${vc(n)}${vc(r)}${a===255?``:vc(a)}`}),Qs=e=>{let[t,n,r,i]=P(e);return`rgba(${t}, ${n}, ${r}, ${i})`},$s=e=>`rgb(${ec(e)})`,ec=e=>{let[t,n,r]=P(e);return`${t}, ${n}, ${r}`},tc=e=>[...nc(e),oc(e)],nc=e=>[rc(e)/255,ic(e)/255,ac(e)/255],rc=e=>P(e)[0],ic=e=>P(e)[1],ac=e=>P(e)[2],oc=e=>P(e)[3],sc=e=>Xs(_c,e),cc=e=>Tc(P(e)),lc=(e,t)=>{let[n,r,i]=P(e);if(t>100)throw Error(`Color opacity must be between 0 and 100, got ${t}`);return t>1&&(t/=100),[n,r,i,t]},uc=e=>{let[t,n,r]=nc(e).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},dc=e=>{let[t,n,r]=nc(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},fc=(e,t)=>{let n=P(e),r=P(t),i=uc(n),a=uc(r);return(Math.max(i,a)+.5)/(Math.min(i,a)+.5)},pc=(e,...t)=>{if(t.length===0)throw Error(`[Color.pickByContrast] - must provide at least one color`);let n=P(e),[r]=t.sort((e,t)=>fc(n,t)-fc(n,e));return P(r)},mc=e=>uc(e)<.5,hc=e=>uc(e)>.5,gc=(e,t=1)=>(e=Ps.parse(e),e=bc(e),[yc(e,0),yc(e,2),yc(e,4),e.length===8?yc(e,6)/255:t]),_c=[0,0,0,0],vc=e=>Math.floor(e).toString(16).padStart(2,`0`),yc=(e,t)=>parseInt(e.slice(t,t+2),16),bc=e=>e.startsWith(`#`)?e.slice(1):e,xc={black:`#000000`,white:`#ffffff`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,yellow:`#ffff00`,cyan:`#00ffff`,magenta:`#ff00ff`,silver:`#c0c0c0`,gray:`#808080`,grey:`#808080`,maroon:`#800000`,olive:`#808000`,lime:`#00ff00`,aqua:`#00ffff`,teal:`#008080`,navy:`#000080`,fuchsia:`#ff00ff`,purple:`#800080`,orange:`#ffa500`,brown:`#a52a2a`,tan:`#d2b48c`,gold:`#ffd700`,indigo:`#4b0082`,violet:`#ee82ee`,pink:`#ffc0cb`,coral:`#ff7f50`,salmon:`#fa8072`,khaki:`#f0e68c`,crimson:`#dc143c`,transparent:`transparent`},Sc=e=>{if(!e)return;let t=e.trim().toLowerCase();if(!(t===`transparent`||t===`none`)){if(t.startsWith(`#`)){if(t.length===4){let e=t[1],n=t[2],r=t[3],i=`#${e}${e}${n}${n}${r}${r}`;if(Ps.safeParse(i).success)return gc(i)}return(t.length===7||t.length===9)&&Ps.safeParse(t).success?gc(t):void 0}if(t.startsWith(`rgb`)){let e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(e){let[,t,n,r,i]=e;return[parseInt(t,10),parseInt(n,10),parseInt(r,10),i?parseFloat(i):1]}}if(xc[t])return gc(xc[t])}},Cc=e=>{e=Ws.parse(e);let[t,n,r]=e,i=e[3];t/=360,n/=100,r/=100;let a,o,s;if(n===0)a=o=s=r;else{let e=r<.5?r*(1+n):r+n-r*n,i=2*r-e;a=wc(i,e,t+1/3),o=wc(i,e,t),s=wc(i,e,t-1/3)}return[Math.round(a*255),Math.round(o*255),Math.round(s*255),i]},wc=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Tc=e=>{e=Ls.parse(e);let[t,n,r]=e,i=e[3];t/=255,n/=255,r/=255;let a=Math.max(t,n,r),o=Math.min(t,n,r),s,c,l=(a+o)/2;if(a===o)s=c=0;else{let e=a-o;c=l>.5?e/(2-a-o):e/(a+o),s=a===t?(n-r)/e+(n<r?6:0):a===n?(r-t)/e+2:(t-n)/e+4,s/=6}return s*=360,c*=100,l*=100,[Math.round(s),Math.round(c),Math.round(l),i]},Ec=P(`#000000`),Dc=P(`#ffffff`),Oc=l.z.object({key:l.z.string(),color:Gs,position:l.z.number(),switched:l.z.boolean().optional()}),kc=l.z.array(Oc),Ac=(e,t)=>{if(e.length===0)return _c;if(e=e.slice().sort((e,t)=>e.position-t.position),t<=e[0].position)return P(e[0].color);if(t>=e[e.length-1].position)return P(e[e.length-1].color);for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];if(t<r.position||t>i.position)continue;if(t===r.position)return P(r.color);if(t===i.position)return P(i.color);let a=(t-r.position)/(i.position-r.position),o=P(r.color),s=P(i.color);return P([Math.round(rc(o)+a*(rc(s)-rc(o))),Math.round(ic(o)+a*(ic(s)-ic(o))),Math.round(ac(o)+a*(ac(s)-ac(o))),oc(o)+a*(oc(s)-oc(o))])}return P(e[e.length-1].color)},jc=l.z.object({key:l.z.string(),name:l.z.string(),color:Ks}),Mc=l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(jc)}),Nc=C({BLACK:()=>Ec,WHITE:()=>Dc,ZERO:()=>_c,aValue:()=>oc,bValue:()=>ac,colorZ:()=>Ks,construct:()=>P,contrast:()=>fc,crudeZ:()=>Gs,cssString:()=>Ys,equals:()=>Xs,fromCSS:()=>Sc,fromGradient:()=>Ac,fromHSLA:()=>Cc,gValue:()=>ic,gradientZ:()=>kc,grayness:()=>dc,hex:()=>Zs,hsla:()=>cc,isColor:()=>Js,isCrude:()=>qs,isDark:()=>mc,isLight:()=>hc,isZero:()=>sc,luminance:()=>uc,paletteZ:()=>Mc,pickByContrast:()=>pc,rValue:()=>rc,rgbCSS:()=>$s,rgbString:()=>ec,rgba1:()=>tc,rgbaCSS:()=>Qs,setAlpha:()=>lc,stopZ:()=>Oc}),Pc=ys,Fc=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({}),Ic=l.z.enum(Fc),Lc=l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),Rc=e=>l.z.object({subject:Lc,resource:e,authority:Pc}),zc={lower:0,upper:256},Bc=(...e)=>t=>t.filter(t=>{let n=!1;return t.to!=null&&(n=e.includes(t.to.resource)),t.from!=null&&!n&&(n=e.includes(t.from.resource)),n}),Vc=e=>l.z.object({from:Rc(e),to:l.z.null().optional()}),Hc=e=>l.z.object({from:l.z.null().optional(),to:Rc(e)}),Uc=e=>l.z.union([Vc(e),Hc(e),l.z.object({from:Rc(e),to:Rc(e)})]),F=C({ABSOLUTE_AUTHORITY:()=>255,AUTHORITY_BOUNDS:()=>zc,Concurrency:()=>Fc,ZERO_AUTHORITY:()=>0,acquireZ:()=>Hc,authorityZ:()=>Pc,concurrencyZ:()=>Ic,filterTransfersByChannelKey:()=>Bc,releaseZ:()=>Vc,stateZ:()=>Rc,subjectZ:()=>Lc,transferZ:()=>Uc}),Wc=C({formatValue:()=>Gc}),Gc=e=>{switch(typeof e){case`bigint`:case`number`:return e.toString();case`boolean`:return e?`1`:`0`;case`undefined`:return``;case`string`:case`symbol`:case`function`:return qc(e.toString());case`object`:return e==null?``:qc(JSON.stringify(e))}},Kc=/[",\n]/,qc=e=>Kc.test(e)?`"${e.replace(/"/g,`""`)}"`:e,Jc=(e,t)=>{let n=null;return t===0?e:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>e(...r),t)}},Yc=e=>Object.getOwnPropertySymbols(globalThis).includes(e),Xc=(e,t)=>{let n=Symbol.for(e);if(!Yc(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},Zc=C({Canceled:()=>ul,NONE:()=>`nil`,NotImplemented:()=>dl,UNKNOWN:()=>nl,Unknown:()=>cl,createTyped:()=>el,decode:()=>sl,encode:()=>ol,isTyped:()=>tl,payloadZ:()=>ll,register:()=>al}),Qc=`sy_x_error`,$c=e=>t=>typeof t==`object`&&t&&`type`in t&&typeof t.type==`string`?t.type.startsWith(e):t instanceof Error?t.message.startsWith(e):typeof t==`string`?t.startsWith(e):!1,el=e=>class t extends Error{static discriminator=Qc;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=$c(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return el(`${e}.${t}`)}},tl=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==Qc)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},nl=`unknown`,rl=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(tl(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:nl,data:e.message};if(typeof e==`string`)return{type:nl,data:e};try{return{type:nl,data:JSON.stringify(e)}}catch{return{type:nl,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return new cl(e.data);for(let t of this.providers){let n=t.decode(e);if(n!=null)return n}return new cl(e.data)}},il=Xc(`synnax-error-registry`,()=>new rl),al=({encode:e,decode:t})=>il().register({encode:e,decode:t}),ol=e=>il().encode(e),sl=e=>e==null?null:il().decode(e),cl=class extends el(`unknown`){},ll=l.z.object({type:l.z.string(),data:l.z.string()}),ul=class extends el(`canceled`){},dl=class extends el(`not_implemented`){};l.z.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/,`must be a valid JSON pointer (RFC 6901)`),l.z.union([l.z.string(),l.z.number(),l.z.boolean(),l.z.null()]),l.z.enum([`string`,`number`,`boolean`,`null`]),l.z.object({key:l.z.string(),value:l.z.string()});var fl=C({keyZ:()=>pl,labelZ:()=>ml,newZ:()=>hl}),pl=l.z.uuid(),ml=l.z.object({key:pl,name:l.z.string().min(1),color:Ks}),hl=ml.partial({key:!0}),gl=C({compareSemVer:()=>yl,createMigration:()=>Cl,migrator:()=>wl,semVerNewer:()=>xl,semVerOlder:()=>Sl,semVerZ:()=>_l,versionsEqual:()=>bl}),_l=l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),vl=(e,t)=>{let n=e.split(`.`),r=t.split(`.`),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&!o)return-1;if(!a&&o)return 1;if(a&&o){let e=parseInt(t,10),n=parseInt(i,10);if(e<n)return-1;if(e>n)return 1}else{if(t<i)return-1;if(t>i)return 1}}return 0},yl=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;let r=_l.parse(e),i=_l.parse(t),[a,o]=r.split(`-`),[s,c]=i.split(`-`),[l,u,d]=a.split(`.`).map(Number),[f,p,m]=s.split(`.`).map(Number);if(n.checkMajor){if(l<f)return-1;if(l>f)return 1}if(n.checkMinor){if(u<p)return-1;if(u>p)return 1}if(n.checkPatch){if(d<m)return-1;if(d>m)return 1}return o===void 0&&c===void 0?0:o===void 0?1:c===void 0?-1:vl(o,c)}),bl=(e,t,n={})=>ji(yl(e,t,n)),xl=(e,t,n={})=>ki(yl(e,t,n)),Sl=(e,t,n={})=>Oi(yl(e,t,n)),Cl=({name:e,migrate:t})=>n=>{try{let r=t(n);return console.log(`${e} migrated: ${n.version} -> ${r.version}`),r}catch(t){throw console.log(`${e} failed to migrate from ${n.version}`),console.error(t),t}},wl=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:i})=>{let a=Object.keys(t).sort(yl).pop();if(a==null)return t=>{if(t.version??=r,t.version!==i.version)return console.log(`${e} version ${t.version} is newer than latest version of ${i.version}.
|
|
12
12
|
Returning default instead.
|
|
13
|
-
`),i;try{return n==null?t:n.parse(t)}catch(t){return console.log(`${e} failed to parse default. Exiting with default`),console.error(t),i}};let o=Object.keys(t).length,s=!1,c=n=>{try{if(o===0||xl(n.version,a))return console.log(s?`${e} ${n.version} now up to date`:`${e} version ${n.version} is up to date with target version ${i.version}`),n;let r=t[n.version],l=r(n);return s=!0,c(l)}catch(t){return console.log(`${e} failed to migrate from ${n.version} to ${a}`),console.error(t),i}};return t=>{try{if(t.version==null)if(r!=null)console.log(`${e} version is null. Setting version to default of ${r}`),t.version=r;else return console.log(`${e} version is null and no default version set. Exiting with default`),i;return c(t)}catch(t){return console.log(`${e} failed to parse final result. Exiting with default`),console.error(t),i}}};l.z.enum([`standard`,`scientific`,`engineering`]);var Tl=C({BaseObserver:()=>Dl,Observer:()=>El}),El=class{handlers;transform;closer;constructor(e,t){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){let[n,r]=this.transform(e);if(!r)return;t=n}this.handlers.forEach((e,n)=>n(t))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}},Dl=class{handlers;constructor(e){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))}},I=C({entries:()=>Al,keyZ:()=>Ol,map:()=>jl,nullishToEmpty:()=>Pl,omit:()=>Nl,purgeUndefined:()=>Ml,unknownZ:()=>kl}),Ol=l.z.union([l.z.string(),l.z.number()]),kl=()=>l.z.record(Ol,l.z.unknown()),Al=e=>Object.entries(e),jl=(e,t)=>Object.fromEntries(Al(e).map(([e,n])=>[e,t(n,e)])),Ml=e=>Object.fromEntries(Al(e).filter(([e,t])=>t!==void 0)),Nl=(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n},Pl=()=>l.z.union([l.z.union([l.z.null(),l.z.undefined()]).transform(()=>({})),kl()]),Fl=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null?`node`:typeof window>`u`||window.document===void 0?`webworker`:`browser`,Il=Fl(),Ll=[`macOS`,`Windows`,`Linux`],Rl=[`macos`,`windows`,`linux`],zl={macos:`macOS`,windows:`Windows`,linux:`Linux`},Bl=l.z.enum(Ll).or(l.z.enum(Rl).transform(e=>zl[e])),Vl=()=>{if(typeof window>`u`)return;let e=window.navigator.userAgent.toLowerCase();if(e.includes(`mac`))return`macOS`;if(e.includes(`win`))return`Windows`;if(e.includes(`linux`))return`Linux`},Hl,Ul=((e={})=>{let{force:t,default:n}=e;return t??Hl??(Hl=Vl(),Hl??n)}),Wl=C({OPERATING_SYSTEMS:()=>Ll,RUNTIME:()=>Il,detect:()=>Fl,getOS:()=>Ul,osZ:()=>Bl}),Gl=l.z.object({stack:l.z.string(),error:l.z.instanceof(Error)}),Kl=(e,t)=>{if(!(e instanceof Error))throw e;return ql({variant:`error`,message:t??e.message,description:t==null?void 0:e.message,details:{stack:e.stack??``,error:e}})},ql=e=>({key:Hi(),time:D.now(),name:``,...e}),Jl=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},Yl=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},Xl={includeTimestamp:!1,includeName:!0},Zl=(e,t={})=>{let n={...Xl,...t},r=[],i=e.variant.toUpperCase();if(n.includeName&&e.name
|
|
13
|
+
`),i;try{return n==null?t:n.parse(t)}catch(t){return console.log(`${e} failed to parse default. Exiting with default`),console.error(t),i}};let o=Object.keys(t).length,s=!1,c=n=>{try{if(o===0||xl(n.version,a))return console.log(s?`${e} ${n.version} now up to date`:`${e} version ${n.version} is up to date with target version ${i.version}`),n;let r=t[n.version],l=r(n);return s=!0,c(l)}catch(t){return console.log(`${e} failed to migrate from ${n.version} to ${a}`),console.error(t),i}};return t=>{try{if(t.version==null)if(r!=null)console.log(`${e} version is null. Setting version to default of ${r}`),t.version=r;else return console.log(`${e} version is null and no default version set. Exiting with default`),i;return c(t)}catch(t){return console.log(`${e} failed to parse final result. Exiting with default`),console.error(t),i}}};l.z.enum([`standard`,`scientific`,`engineering`]);var Tl=C({BaseObserver:()=>Dl,Observer:()=>El}),El=class{handlers;transform;closer;constructor(e,t){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){let[n,r]=this.transform(e);if(!r)return;t=n}this.handlers.forEach((e,n)=>n(t))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}},Dl=class{handlers;constructor(e){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))}},I=C({entries:()=>Al,keyZ:()=>Ol,map:()=>jl,nullishToEmpty:()=>Pl,omit:()=>Nl,purgeUndefined:()=>Ml,unknownZ:()=>kl}),Ol=l.z.union([l.z.string(),l.z.number()]),kl=()=>l.z.record(Ol,l.z.unknown()),Al=e=>Object.entries(e),jl=(e,t)=>Object.fromEntries(Al(e).map(([e,n])=>[e,t(n,e)])),Ml=e=>Object.fromEntries(Al(e).filter(([e,t])=>t!==void 0)),Nl=(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n},Pl=()=>l.z.union([l.z.union([l.z.null(),l.z.undefined()]).transform(()=>({})),kl()]),Fl=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null?`node`:typeof window>`u`||window.document===void 0?`webworker`:`browser`,Il=Fl(),Ll=[`macOS`,`Windows`,`Linux`],Rl=[`macos`,`windows`,`linux`],zl={macos:`macOS`,windows:`Windows`,linux:`Linux`},Bl=l.z.enum(Ll).or(l.z.enum(Rl).transform(e=>zl[e])),Vl=()=>{if(typeof window>`u`)return;let e=window.navigator.userAgent.toLowerCase();if(e.includes(`mac`))return`macOS`;if(e.includes(`win`))return`Windows`;if(e.includes(`linux`))return`Linux`},Hl,Ul=((e={})=>{let{force:t,default:n}=e;return t??Hl??(Hl=Vl(),Hl??n)}),Wl=C({OPERATING_SYSTEMS:()=>Ll,RUNTIME:()=>Il,detect:()=>Fl,getOS:()=>Ul,osZ:()=>Bl}),Gl=l.z.object({stack:l.z.string(),error:l.z.instanceof(Error)}),Kl=(e,t)=>{if(!(e instanceof Error))throw e;return ql({variant:`error`,message:t??e.message,description:t==null?void 0:e.message,details:{stack:e.stack??``,error:e}})},ql=e=>({key:Hi(),time:D.now(),name:``,...e}),Jl=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},Yl=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},Xl={includeTimestamp:!1,includeName:!0},Zl=(e,t={})=>{let n={...Xl,...t},r=[],i=e.variant.toUpperCase();if(n.includeName&&_i(e.name)&&(i+=` [${e.name}]`),i+=`: ${e.message}`,n.includeTimestamp&&(i+=` (${e.time.toString(`dateTime`,`local`)})`),r.push(i),e.description!=null){let t;try{let n=JSON.parse(e.description);t=`Description:\n${JSON.stringify(n,null,2)}`}catch{t=`Description: ${e.description}`}r.push(t)}if(`details`in e&&ii(e.details)){let t=e.details;`stack`in t&&r.push(`Stack Trace:\n${String(t.stack)}`);let n=Object.fromEntries(Object.entries(t).filter(([e])=>e!==`stack`&&e!==`error`));Object.keys(n).length>0&&r.push(`Details:\n${JSON.stringify(n,null,2)}`)}return r.join(`
|
|
14
14
|
|
|
15
15
|
`)},Ql=[`success`,`info`,`warning`,`error`,`loading`,`disabled`],$l=l.z.enum(Ql),eu=l.z.literal(`success`),tu=l.z.literal(`info`),nu=l.z.literal(`warning`),ru=l.z.literal(`error`),iu=l.z.literal(`loading`),au=l.z.literal(`disabled`),ou=({details:e,v:t}={})=>l.z.object({key:l.z.string().default(()=>Hi()),name:l.z.string().default(``),variant:t??$l,message:l.z.string(),description:l.z.string().optional(),time:Po.default(()=>D.now()),details:e??l.z.unknown().optional(),labels:hs(ml.array())}),su=({details:e,v:t}={})=>ou({details:e,v:t}).partial({key:!0,name:!0,time:!0}),cu=C({VARIANTS:()=>Ql,create:()=>ql,disabledVariantZ:()=>au,errorVariantZ:()=>ru,exceptionDetailsSchema:()=>Gl,fromException:()=>Kl,infoVariantZ:()=>tu,keepVariants:()=>Jl,loadingVariantZ:()=>iu,newZ:()=>su,removeVariants:()=>Yl,statusZ:()=>ou,successVariantZ:()=>eu,toString:()=>Zl,variantZ:()=>$l,warningVariantZ:()=>nu}),lu=(e,t)=>{if(!t.has(e))return e;let n,r,i=e;for(;t.has(i);){let e=i.match(uu);e?(n=i.slice(0,e.index).trim(),r=parseInt(e[1],10)+1):(n=i,r=1),i=`${n} (${r})`}return i},uu=/\((\d+)\)$/,du=(e,t=``)=>{if(typeof e==`string`)return e;let n=e.length;return n===0?t:n===1?e[0]:n===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e[n-1]}`},fu=e=>{let t=e.split(` `),n=new Set,r=t.map(e=>e.charAt(0).toLowerCase()).join(``);n.add(r.replace(/-/g,`_`)),n.add(r.replace(/(.)(.)/g,`$1_$2`).replace(/-/g,`_`));let i=/\d+/g;e.match(i)&&t.forEach((e,r)=>{if(i.test(e)){let e=t.map((e,t)=>t===r?e:e.charAt(0).toLowerCase()).join(``);n.add(e.replace(/-/g,`_`)),n.add(e.replace(/(.)(.)/g,`$1_$2`).replace(/-/g,`_`))}});let a=t.map(e=>(e.length>3?e.substring(0,3):e).toLowerCase());return n.add(a.join(``).replace(/-/g,`_`)),n.add(a.join(`_`).replace(/-/g,`_`)),Array.from(n).filter(e=>e.length>=2&&e.length<=12&&!/^\d/.test(e))},pu=(e,t)=>e.startsWith(t)?e.slice(t.length):e,mu=C({createShortIdentifiers:()=>fu,deduplicateFileName:()=>lu,naturalLanguageJoin:()=>du,trimPrefix:()=>pu}),hu=(...e)=>e.map(gu).join(``),gu=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),_u=e=>e.endsWith(`/`)?e.slice(0,-1):e,vu=class e{protocol;host;port;path;constructor({host:e,port:t,protocol:n=``,pathPrefix:r=``}){this.protocol=n,this.host=e,this.port=t,this.path=gu(r)}replace(t){return new e({host:t.host??this.host,port:t.port??this.port,protocol:t.protocol??this.protocol,pathPrefix:t.pathPrefix??this.path})}child(t){return new e({...this,pathPrefix:hu(this.path,t)})}toString(){return _u(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},yu=class extends Zc.createTyped(`sy`){},L=class extends yu.sub(`validation`){},bu=class e extends L.sub(`path`){path;error;static encodedSchema=l.z.object({path:l.z.string().array(),error:Zc.payloadZ});constructor(e,t){let n=w.toArray(e);super(`${n.join(`.`)}: ${t.message}`),this.path=n.flatMap(e=>e.split(`.`)),this.error=t}static decode(t){let n=e.encodedSchema.parse(JSON.parse(t.data));return new e(n.path,Zc.decode(n.error))}},xu=class extends yu.sub(`auth`){},Su=class extends xu.sub(`invalid_token`){},Cu=class extends xu.sub(`expired_token`){};xu.sub(`access_denied`);var wu=class extends yu.sub(`unexpected`){constructor(e){super(`
|
|
16
16
|
Unexpected error encountered:
|
|
@@ -56,7 +56,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
56
56
|
|
|
57
57
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Lf,s=!Cf.jitless,c=s&&Rf.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?eh([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function rh(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!$f(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>np(e,r,wf())))}),t)}var ih=B(`$ZodUnion`,(e,t)=>{W.init(e,t),V(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),V(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),V(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),V(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>kf(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>rh(t,i,e,a)):rh(s,i,e,a)}}),ah=B(`$ZodIntersection`,(e,t)=>{W.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>sh(e,t,n)):sh(e,i,a)}});function oh(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(zf(e)&&zf(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=oh(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=oh(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function sh(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),$f(e))return e;let o=oh(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ch=B(`$ZodEnum`,(e,t)=>{W.init(e,t);let n=Tf(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Vf.has(typeof e)).map(e=>typeof e==`string`?Hf(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),lh=B(`$ZodTransform`,(e,t)=>{W.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Sf(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new xf;return n.value=i,n}});function uh(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var dh=B(`$ZodOptional`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,V(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${kf(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>uh(t,e.value)):uh(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),fh=B(`$ZodExactOptional`,(e,t)=>{dh.init(e,t),V(e._zod,`values`,()=>t.innerType._zod.values),V(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ph=B(`$ZodNullable`,(e,t)=>{W.init(e,t),V(e._zod,`optin`,()=>t.innerType._zod.optin),V(e._zod,`optout`,()=>t.innerType._zod.optout),V(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${kf(e.source)}|null)$`):void 0}),V(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),mh=B(`$ZodDefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,V(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>hh(e,t)):hh(r,t)}});function hh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var gh=B(`$ZodPrefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,V(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),_h=B(`$ZodNonOptional`,(e,t)=>{W.init(e,t),V(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>vh(t,e)):vh(i,e)}});function vh(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var yh=B(`$ZodCatch`,(e,t)=>{W.init(e,t),V(e._zod,`optin`,()=>t.innerType._zod.optin),V(e._zod,`optout`,()=>t.innerType._zod.optout),V(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>np(e,n,wf()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>np(e,n,wf()))},input:e.value}),e.issues=[]),e)}}),bh=B(`$ZodPipe`,(e,t)=>{W.init(e,t),V(e._zod,`values`,()=>t.in._zod.values),V(e._zod,`optin`,()=>t.in._zod.optin),V(e._zod,`optout`,()=>t.out._zod.optout),V(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>xh(e,t.in,n)):xh(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>xh(e,t.out,n)):xh(r,t.out,n)}});function xh(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Sh=B(`$ZodReadonly`,(e,t)=>{W.init(e,t),V(e._zod,`propValues`,()=>t.innerType._zod.propValues),V(e._zod,`values`,()=>t.innerType._zod.values),V(e._zod,`optin`,()=>t.innerType?._zod?.optin),V(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ch):Ch(r)}});function Ch(e){return e.value=Object.freeze(e.value),e}var wh=B(`$ZodCustom`,(e,t)=>{U.init(e,t),W.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Th(t,n,r,e));Th(i,n,r,e)}});function Th(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ip(e))}}var Eh,Dh=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Oh(){return new Dh}(Eh=globalThis).__zod_globalRegistry??(Eh.__zod_globalRegistry=Oh());var kh=globalThis.__zod_globalRegistry;function Ah(e,t){return new e({type:`string`,...H(t)})}function jh(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...H(t)})}function Mh(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...H(t)})}function Nh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...H(t)})}function Ph(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...H(t)})}function Fh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...H(t)})}function Ih(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...H(t)})}function Lh(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function Rh(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...H(t)})}function zh(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...H(t)})}function Bh(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...H(t)})}function Vh(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...H(t)})}function Hh(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...H(t)})}function Uh(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...H(t)})}function Wh(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...H(t)})}function Gh(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...H(t)})}function Kh(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...H(t)})}function qh(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...H(t)})}function Jh(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...H(t)})}function Yh(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...H(t)})}function Xh(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...H(t)})}function Zh(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...H(t)})}function Qh(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...H(t)})}function $h(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function eg(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...H(t)})}function tg(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...H(t)})}function ng(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...H(t)})}function rg(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function ig(e,t){return new e({type:`boolean`,...H(t)})}function ag(e){return new e({type:`unknown`})}function og(e,t){return new e({type:`never`,...H(t)})}function sg(e,t){return new tm({check:`less_than`,...H(t),value:e,inclusive:!1})}function cg(e,t){return new tm({check:`less_than`,...H(t),value:e,inclusive:!0})}function lg(e,t){return new nm({check:`greater_than`,...H(t),value:e,inclusive:!1})}function ug(e,t){return new nm({check:`greater_than`,...H(t),value:e,inclusive:!0})}function dg(e,t){return new rm({check:`multiple_of`,...H(t),value:e})}function fg(e,t){return new am({check:`max_length`,...H(t),maximum:e})}function pg(e,t){return new om({check:`min_length`,...H(t),minimum:e})}function mg(e,t){return new sm({check:`length_equals`,...H(t),length:e})}function hg(e,t){return new lm({check:`string_format`,format:`regex`,...H(t),pattern:e})}function gg(e){return new um({check:`string_format`,format:`lowercase`,...H(e)})}function _g(e){return new dm({check:`string_format`,format:`uppercase`,...H(e)})}function vg(e,t){return new fm({check:`string_format`,format:`includes`,...H(t),includes:e})}function yg(e,t){return new pm({check:`string_format`,format:`starts_with`,...H(t),prefix:e})}function bg(e,t){return new mm({check:`string_format`,format:`ends_with`,...H(t),suffix:e})}function xg(e){return new hm({check:`overwrite`,tx:e})}function Sg(e){return xg(t=>t.normalize(e))}function Cg(){return xg(e=>e.trim())}function wg(){return xg(e=>e.toLowerCase())}function Tg(){return xg(e=>e.toUpperCase())}function Eg(){return xg(e=>Ff(e))}function Dg(e,t,n){return new e({type:`array`,element:t,...H(n)})}function Og(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...H(n)})}function kg(e){let t=Ag(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(ip(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(ip(r))}},e(n.value,n)));return t}function Ag(e,t){let n=new U({check:`custom`,...H(t)});return n._zod.check=e,n}function jg(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??kh,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function K(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,K(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&q(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Mg(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
58
58
|
|
|
59
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ng(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Fg(t,`input`,e.processors),output:Fg(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var Pg=(e,t={})=>n=>{let r=jg({...n,processors:t});return K(e,r),Mg(r,e),Ng(r,e)},Fg=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=jg({...i??{},target:a,io:t,processors:n});return K(e,o),Mg(o,e),Ng(o,e)},Ig={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Lg=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ig[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Rg=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},zg=(e,t,n,r)=>{n.type=`boolean`},Bg=(e,t,n,r)=>{n.not={}},Vg=(e,t,n,r)=>{let i=e._zod.def,a=Tf(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Hg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ug=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Wg=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},Gg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Kg=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},qg=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Jg=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Yg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Zg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Qg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},$g=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;K(a,t,r);let o=t.seen.get(e);o.ref=a},e_=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},t_=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},n_=B(`ZodISODateTime`,(e,t)=>{Am.init(e,t),Y.init(e,t)});function r_(e){return $h(n_,e)}var i_=B(`ZodISODate`,(e,t)=>{jm.init(e,t),Y.init(e,t)});function a_(e){return eg(i_,e)}var o_=B(`ZodISOTime`,(e,t)=>{Mm.init(e,t),Y.init(e,t)});function s_(e){return tg(o_,e)}var c_=B(`ZodISODuration`,(e,t)=>{Nm.init(e,t),Y.init(e,t)});function l_(e){return ng(c_,e)}var u_=(e,t)=>{op.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>lp(e,t)},flatten:{value:t=>cp(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ef,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ef,2)}},isEmpty:{get(){return e.issues.length===0}}})};B(`ZodError`,u_);var d_=B(`ZodError`,u_,{Parent:Error}),f_=up(d_),p_=dp(d_),m_=fp(d_),h_=mp(d_),g_=gp(d_),__=_p(d_),v_=vp(d_),y_=yp(d_),b_=bp(d_),x_=xp(d_),S_=Sp(d_),C_=Cp(d_),J=B(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Fg(e,`input`),output:Fg(e,`output`)}}),e.toJSONSchema=Pg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(Nf(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Uf(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>f_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>m_(e,t,n),e.parseAsync=async(t,n)=>p_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>h_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>g_(e,t,n),e.decode=(t,n)=>__(e,t,n),e.encodeAsync=async(t,n)=>v_(e,t,n),e.decodeAsync=async(t,n)=>y_(e,t,n),e.safeEncode=(t,n)=>b_(e,t,n),e.safeDecode=(t,n)=>x_(e,t,n),e.safeEncodeAsync=async(t,n)=>S_(e,t,n),e.safeDecodeAsync=async(t,n)=>C_(e,t,n),e.refine=(t,n)=>e.check(Mv(t,n)),e.superRefine=t=>e.check(Nv(t)),e.overwrite=t=>e.check(xg(t)),e.optional=()=>mv(e),e.exactOptional=()=>gv(e),e.nullable=()=>vv(e),e.nullish=()=>mv(vv(e)),e.nonoptional=t=>wv(e,t),e.array=()=>nv(e),e.or=t=>ov([e,t]),e.and=t=>cv(e,t),e.transform=t=>Ov(e,fv(t)),e.default=t=>bv(e,t),e.prefault=t=>Sv(e,t),e.catch=t=>Ev(e,t),e.pipe=t=>Ov(e,t),e.readonly=()=>Av(e),e.describe=t=>{let n=e.clone();return kh.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return kh.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return kh.get(e);let n=e.clone();return kh.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),w_=B(`_ZodString`,(e,t)=>{vm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lg(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(hg(...t)),e.includes=(...t)=>e.check(vg(...t)),e.startsWith=(...t)=>e.check(yg(...t)),e.endsWith=(...t)=>e.check(bg(...t)),e.min=(...t)=>e.check(pg(...t)),e.max=(...t)=>e.check(fg(...t)),e.length=(...t)=>e.check(mg(...t)),e.nonempty=(...t)=>e.check(pg(1,...t)),e.lowercase=t=>e.check(gg(t)),e.uppercase=t=>e.check(_g(t)),e.trim=()=>e.check(Cg()),e.normalize=(...t)=>e.check(Sg(...t)),e.toLowerCase=()=>e.check(wg()),e.toUpperCase=()=>e.check(Tg()),e.slugify=()=>e.check(Eg())}),T_=B(`ZodString`,(e,t)=>{vm.init(e,t),w_.init(e,t),e.email=t=>e.check(jh(D_,t)),e.url=t=>e.check(Lh(A_,t)),e.jwt=t=>e.check(Qh(G_,t)),e.emoji=t=>e.check(Rh(j_,t)),e.guid=t=>e.check(Mh(O_,t)),e.uuid=t=>e.check(Nh(k_,t)),e.uuidv4=t=>e.check(Ph(k_,t)),e.uuidv6=t=>e.check(Fh(k_,t)),e.uuidv7=t=>e.check(Ih(k_,t)),e.nanoid=t=>e.check(zh(M_,t)),e.guid=t=>e.check(Mh(O_,t)),e.cuid=t=>e.check(Bh(N_,t)),e.cuid2=t=>e.check(Vh(P_,t)),e.ulid=t=>e.check(Hh(F_,t)),e.base64=t=>e.check(Yh(H_,t)),e.base64url=t=>e.check(Xh(U_,t)),e.xid=t=>e.check(Uh(I_,t)),e.ksuid=t=>e.check(Wh(L_,t)),e.ipv4=t=>e.check(Gh(R_,t)),e.ipv6=t=>e.check(Kh(z_,t)),e.cidrv4=t=>e.check(qh(B_,t)),e.cidrv6=t=>e.check(Jh(V_,t)),e.e164=t=>e.check(Zh(W_,t)),e.datetime=t=>e.check(r_(t)),e.date=t=>e.check(a_(t)),e.time=t=>e.check(s_(t)),e.duration=t=>e.check(l_(t))});function E_(e){return Ah(T_,e)}var Y=B(`ZodStringFormat`,(e,t)=>{G.init(e,t),w_.init(e,t)}),D_=B(`ZodEmail`,(e,t)=>{xm.init(e,t),Y.init(e,t)}),O_=B(`ZodGUID`,(e,t)=>{ym.init(e,t),Y.init(e,t)}),k_=B(`ZodUUID`,(e,t)=>{bm.init(e,t),Y.init(e,t)}),A_=B(`ZodURL`,(e,t)=>{Sm.init(e,t),Y.init(e,t)}),j_=B(`ZodEmoji`,(e,t)=>{Cm.init(e,t),Y.init(e,t)}),M_=B(`ZodNanoID`,(e,t)=>{wm.init(e,t),Y.init(e,t)}),N_=B(`ZodCUID`,(e,t)=>{Tm.init(e,t),Y.init(e,t)}),P_=B(`ZodCUID2`,(e,t)=>{Em.init(e,t),Y.init(e,t)}),F_=B(`ZodULID`,(e,t)=>{Dm.init(e,t),Y.init(e,t)}),I_=B(`ZodXID`,(e,t)=>{Om.init(e,t),Y.init(e,t)}),L_=B(`ZodKSUID`,(e,t)=>{km.init(e,t),Y.init(e,t)}),R_=B(`ZodIPv4`,(e,t)=>{Pm.init(e,t),Y.init(e,t)}),z_=B(`ZodIPv6`,(e,t)=>{Fm.init(e,t),Y.init(e,t)}),B_=B(`ZodCIDRv4`,(e,t)=>{Im.init(e,t),Y.init(e,t)}),V_=B(`ZodCIDRv6`,(e,t)=>{Lm.init(e,t),Y.init(e,t)}),H_=B(`ZodBase64`,(e,t)=>{zm.init(e,t),Y.init(e,t)}),U_=B(`ZodBase64URL`,(e,t)=>{Vm.init(e,t),Y.init(e,t)}),W_=B(`ZodE164`,(e,t)=>{Hm.init(e,t),Y.init(e,t)}),G_=B(`ZodJWT`,(e,t)=>{Wm.init(e,t),Y.init(e,t)}),K_=B(`ZodNumber`,(e,t)=>{Gm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rg(e,t,n,r),e.gt=(t,n)=>e.check(lg(t,n)),e.gte=(t,n)=>e.check(ug(t,n)),e.min=(t,n)=>e.check(ug(t,n)),e.lt=(t,n)=>e.check(sg(t,n)),e.lte=(t,n)=>e.check(cg(t,n)),e.max=(t,n)=>e.check(cg(t,n)),e.int=t=>e.check(J_(t)),e.safe=t=>e.check(J_(t)),e.positive=t=>e.check(lg(0,t)),e.nonnegative=t=>e.check(ug(0,t)),e.negative=t=>e.check(sg(0,t)),e.nonpositive=t=>e.check(cg(0,t)),e.multipleOf=(t,n)=>e.check(dg(t,n)),e.step=(t,n)=>e.check(dg(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),q_=B(`ZodNumberFormat`,(e,t)=>{Km.init(e,t),K_.init(e,t)});function J_(e){return rg(q_,e)}var Y_=B(`ZodBoolean`,(e,t)=>{qm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zg(e,t,n,r)});function X_(e){return ig(Y_,e)}var Z_=B(`ZodUnknown`,(e,t)=>{Jm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Q_(){return ag(Z_)}var $_=B(`ZodNever`,(e,t)=>{Ym.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bg(e,t,n,r)});function ev(e){return og($_,e)}var tv=B(`ZodArray`,(e,t)=>{Zm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wg(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(pg(t,n)),e.nonempty=t=>e.check(pg(1,t)),e.max=(t,n)=>e.check(fg(t,n)),e.length=(t,n)=>e.check(mg(t,n)),e.unwrap=()=>e.element});function nv(e,t){return Dg(tv,e,t)}var rv=B(`ZodObject`,(e,t)=>{nh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gg(e,t,n,r),V(e,`shape`,()=>t.shape),e.keyof=()=>uv(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Q_()}),e.loose=()=>e.clone({...e._zod.def,catchall:Q_()}),e.strict=()=>e.clone({...e._zod.def,catchall:ev()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Jf(e,t),e.safeExtend=t=>Yf(e,t),e.merge=t=>Xf(e,t),e.pick=t=>Kf(e,t),e.omit=t=>qf(e,t),e.partial=(...t)=>Zf(pv,e,t[0]),e.required=(...t)=>Qf(Cv,e,t[0])});function iv(e,t){return new rv({type:`object`,shape:e??{},...H(t)})}var av=B(`ZodUnion`,(e,t)=>{ih.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kg(e,t,n,r),e.options=t.options});function ov(e,t){return new av({type:`union`,options:e,...H(t)})}var sv=B(`ZodIntersection`,(e,t)=>{ah.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qg(e,t,n,r)});function cv(e,t){return new sv({type:`intersection`,left:e,right:t})}var lv=B(`ZodEnum`,(e,t)=>{ch.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vg(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new lv({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new lv({...t,checks:[],...H(r),entries:i})}});function uv(e,t){return new lv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var dv=B(`ZodTransform`,(e,t)=>{lh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ug(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Sf(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ip(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(ip(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function fv(e){return new dv({type:`transform`,transform:e})}var pv=B(`ZodOptional`,(e,t)=>{dh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mv(e){return new pv({type:`optional`,innerType:e})}var hv=B(`ZodExactOptional`,(e,t)=>{fh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gv(e){return new hv({type:`optional`,innerType:e})}var _v=B(`ZodNullable`,(e,t)=>{ph.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vv(e){return new _v({type:`nullable`,innerType:e})}var yv=B(`ZodDefault`,(e,t)=>{mh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function bv(e,t){return new yv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Bf(t)}})}var xv=B(`ZodPrefault`,(e,t)=>{gh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sv(e,t){return new xv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Bf(t)}})}var Cv=B(`ZodNonOptional`,(e,t)=>{_h.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wv(e,t){return new Cv({type:`nonoptional`,innerType:e,...H(t)})}var Tv=B(`ZodCatch`,(e,t)=>{yh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ev(e,t){return new Tv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Dv=B(`ZodPipe`,(e,t)=>{bh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$g(e,t,n,r),e.in=t.in,e.out=t.out});function Ov(e,t){return new Dv({type:`pipe`,in:e,out:t})}var kv=B(`ZodReadonly`,(e,t)=>{Sh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Av(e){return new kv({type:`readonly`,innerType:e})}var jv=B(`ZodCustom`,(e,t)=>{wh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hg(e,t,n,r)});function Mv(e,t={}){return Og(jv,e,t)}function Nv(e){return kg(e)}var Pv=function(e){return e[e.invalid=0]=`invalid`,e[e.u8=1]=`u8`,e[e.u16=2]=`u16`,e[e.u32=3]=`u32`,e[e.u64=4]=`u64`,e[e.i8=5]=`i8`,e[e.i16=6]=`i16`,e[e.i32=7]=`i32`,e[e.i64=8]=`i64`,e[e.f32=9]=`f32`,e[e.f64=10]=`f64`,e[e.string=11]=`string`,e[e.chan=14]=`chan`,e[e.series=15]=`series`,e[e.variable=16]=`variable`,e[e.numeric_constant=17]=`numeric_constant`,e[e.integer_constant=18]=`integer_constant`,e[e.float_constant=19]=`float_constant`,e[e.exact_integer_float_constant=20]=`exact_integer_float_constant`,e[e.function=21]=`function`,e[e.sequence=22]=`sequence`,e[e.stage=23]=`stage`,e}({}),Fv=l.z.enum(Pv),Iv=function(e){return e[e.none=0]=`none`,e[e.read=1]=`read`,e[e.write=2]=`write`,e}({}),Lv=l.z.enum(Iv),Rv=l.z.object({read:l.z.record(l.z.uint32(),l.z.string()),write:l.z.record(l.z.uint32(),l.z.string())}),zv=l.z.object({length:N.int8,mass:N.int8,time:N.int8,current:N.int8,temperature:N.int8,angle:N.int8,count:N.int8,data:N.int8}),Bv=l.z.object({dimensions:zv,scale:l.z.number(),name:l.z.string()}),Vv=l.z.object({get inputs(){return Uv.optional()},get outputs(){return Uv.optional()},get config(){return Uv.optional()}}).extend({kind:Fv,name:l.z.string(),get elem(){return Vv.optional()},unit:Bv.optional(),get constraint(){return Vv.optional()},chanDirection:Lv.optional()}),Hv=l.z.object({name:l.z.string(),type:Vv,value:l.z.unknown().optional()}),Uv=w.nullishToEmpty(Hv),Wv=o({EdgeKind:()=>Gv,authoritiesZ:()=>Xv,bodyZ:()=>Jv,edgeKindZ:()=>Kv,edgeZ:()=>Qv,edgesZ:()=>ny,functionZ:()=>$v,functionsZ:()=>ry,handleZ:()=>qv,irZ:()=>cy,nodeZ:()=>Yv,nodesZ:()=>ey,sequenceZ:()=>ay,sequencesZ:()=>sy,stageZ:()=>iy,stagesZ:()=>oy,strataZ:()=>ty,stratumZ:()=>Zv}),Gv=function(e){return e[e.unspecified=0]=`unspecified`,e[e.continuous=1]=`continuous`,e[e.one_shot=2]=`one_shot`,e}({}),Kv=l.z.enum(Gv),qv=l.z.object({node:l.z.string(),param:l.z.string()}),Jv=l.z.object({raw:l.z.string()}),Yv=l.z.object({key:l.z.string(),type:l.z.string(),config:Uv.optional(),inputs:Uv.optional(),outputs:Uv.optional(),channels:Rv.optional()}),Xv=l.z.object({default:N.uint8.optional(),channels:l.z.record(l.z.uint32(),N.uint8).optional()}),Zv=w.nullishToEmpty(l.z.string()),Qv=l.z.object({source:qv,target:qv,kind:Kv.optional()}),$v=l.z.object({key:l.z.string(),body:Jv.optional(),config:Uv.optional(),inputs:Uv.optional(),outputs:Uv.optional(),channels:Rv.optional()}),ey=w.nullishToEmpty(Yv),ty=w.nullishToEmpty(Zv),ny=w.nullishToEmpty(Qv),ry=w.nullishToEmpty($v),iy=l.z.object({key:l.z.string(),nodes:w.nullishToEmpty(l.z.string()),strata:ty}),ay=l.z.object({key:l.z.string(),stages:w.nullishToEmpty(iy)}),oy=w.nullishToEmpty(iy),sy=w.nullishToEmpty(ay),cy=l.z.object({functions:ry.optional(),nodes:ey.optional(),edges:ny.optional(),strata:ty.optional(),sequences:sy.optional(),authorities:Xv.optional()}),ly=o({graphZ:()=>py,nodeZ:()=>uy,nodesZ:()=>fy,viewportZ:()=>dy}),uy=l.z.object({key:l.z.string(),type:l.z.string(),config:I.nullishToEmpty(),position:xo.xyZ}),dy=l.z.object({position:xo.xyZ,zoom:l.z.number()}),fy=w.nullishToEmpty(uy),py=l.z.object({viewport:dy,functions:ry,edges:ny,nodes:fy}),my=o({outputZ:()=>hy}),hy=l.z.object({wasm:l.z.instanceof(Uint8Array),outputMemoryBases:l.z.record(l.z.string(),l.z.uint32())}),gy=cy.extend(hy.shape),_y=o({textZ:()=>vy}),vy=l.z.object({raw:l.z.string()}),yy=[`text`,`graph`],by=l.z.enum(yy),xy=l.z.object({running:l.z.boolean()}),Sy=l.z.uuid(),Cy=cu.statusZ({details:xy}),wy=l.z.object({key:Sy.optional(),name:l.z.string(),mode:by,graph:py,text:vy}),Ty=l.z.object({key:Sy,name:l.z.string(),mode:by,graph:py,text:vy,program:gy.optional(),status:Cy.optional()}),Ey=z(`arc`),Dy=Ey(``),Oy=(e,t,{convertNumericStrings:n=!0}={})=>{let r=!Array.isArray(e),i=w.toArray(e),a=i[0],o=typeof a,s;return o===`string`&&n&&!isNaN(parseInt(a,10))&&`number`in t?(s=t.number,i=i.map(e=>parseInt(e,10))):s=t[o],{single:r,variant:s,normalized:i,actual:e}},X=(e,t,n,r)=>{if(r){if(n.length===0)throw new Eu(`${e} not found matching ${JSON.stringify(t)}`);if(n.length>1)throw new Du(`Expected one ${e} matching ${JSON.stringify(t)}, but found ${n.length}`)}},ky=`sy_arc_set`,Ay=`sy_arc_delete`,jy=iv({keys:Sy.array().optional(),names:E_().array().optional(),searchTerm:E_().optional(),limit:J_().optional(),offset:J_().optional(),includeStatus:X_().optional()}),My=iv({arcs:wy.array()}),Ny=iv({keys:Sy.array()}),Py=iv({arcs:w.nullishToEmpty(Ty)}),Fy=iv({arcs:Ty.array()}),Iy=iv({}),Ly=iv({content:E_()}),Ry=ov([iv({key:Sy,includeStatus:X_().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),iv({name:E_(),includeStatus:X_().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t}))]),zy=ov([Ry,jy]),By=class{client;streamClient;constructor(e,t){this.client=e,this.streamClient=t}async create(e){let t=Array.isArray(e),n=await S(this.client,`/arc/create`,{arcs:w.toArray(e)},My,Fy);return t?n.arcs:n.arcs[0]}async retrieve(e){let t=`key`in e||`name`in e,n=await S(this.client,`/arc/retrieve`,e,zy,Py);return X(`Arc`,e,n.arcs,t),t?n.arcs[0]:n.arcs}async delete(e){await S(this.client,`/arc/delete`,{keys:w.toArray(e)},Ny,Iy)}async openLSP(){return await this.streamClient.stream(`/arc/lsp`,Ly,Ly)}},Vy=o({moduleZ:()=>Hy}),Hy=cy.extend(hy.shape),Uy=o({Client:()=>By,DELETE_CHANNEL_NAME:()=>Ay,MODES:()=>yy,SET_CHANNEL_NAME:()=>ky,TYPE_ONTOLOGY_ID:()=>Dy,arcZ:()=>Ty,compiler:()=>my,graph:()=>ly,ir:()=>Wv,keyZ:()=>Sy,lspMessageZ:()=>Ly,modeZ:()=>by,module:()=>Vy,newZ:()=>wy,ontologyID:()=>Ey,singleRetrieveArgsZ:()=>Ry,statusDetailsZ:()=>xy,statusZ:()=>Cy,text:()=>_y}),Wy=Error(`request for lock canceled`),Gy=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ky=class{constructor(e,t=Wy){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=Jy(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return Gy(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw 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]=[]),qy(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 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){let 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--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function qy(e,t){let n=Jy(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function Jy(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Yy=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Xy=class{constructor(e){this._semaphore=new Ky(1,e)}acquire(){return Yy(this,arguments,void 0,function*(e=0){let[,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()}},Zy=N.uint12,Z=l.z.uint32().or(l.z.string().refine(e=>!isNaN(Number(e))).transform(Number)),Qy=N.uint20,$y=[`min`,`max`,`avg`,`none`],eb=l.z.enum($y),tb=l.z.object({type:eb,resetChannel:Z.default(0),duration:us.timeSpanZ.default(O.ZERO)}),nb=l.z.string().min(1,`Name is required`),rb=cu.statusZ(),ib=l.z.object({key:Z,name:nb,leaseholder:Zy,dataType:us.dataTypeZ,isIndex:l.z.boolean(),index:Z,alias:l.z.string().optional(),virtual:l.z.boolean().default(!1),internal:l.z.boolean().default(!1),expression:l.z.string().default(``),operations:N.nullToUndefined(tb.array()),concurrency:F.concurrencyZ.default(F.Concurrency.exclusive).optional(),status:rb.optional()}),ab=ib.omit({leaseholder:!0}).partial({key:!0,index:!0,isIndex:!0,internal:!0,virtual:!0,expression:!0}).extend({leaseholder:N.uint12.optional()}),ob=z(`channel`),sb=ob(0),Q=l.z.uuid(),cb=l.z.object({key:Q,name:l.z.string().min(1),timeRange:us.timeRangeZ,color:Nc.colorZ.optional()}),lb=cb.extend({labels:N.nullToUndefined(fl.labelZ.array()),get parent(){return lb.optional()}}),ub=cb.omit({timeRange:!0}).extend({labels:N.nullToUndefined(fl.labelZ.array()),get parent(){return ub.optional()},timeRange:us.timeRangeBoundedZ}),db=ub.omit({parent:!0,labels:!0}).partial({key:!0}),fb=z(`range`),pb=fb(``),mb=l.z.object({nodeKey:N.uint12.optional(),keys:Z.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),rangeKey:Q.optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),dataTypes:j.z.array().optional(),notDataTypes:j.z.array().optional(),virtual:l.z.boolean().optional(),isIndex:l.z.boolean().optional(),internal:l.z.boolean().optional(),legacyCalculated:l.z.boolean().optional()}),hb=l.z.object({channels:w.nullishToEmpty(ib)}),gb=e=>(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`?e=e.map(e=>e.key):typeof e==`object`&&`key`in e&&(e=[e.key]),Oy(e,{number:`keys`,string:`names`})),_b=class{client;constructor(e){this.client=e}async retrieve(e,t){if(!Array.isArray(e)&&typeof e==`object`)return await this.execute(e);let n=gb(e),{variant:r}=n,{normalized:i}=n;return r===`keys`&&i.indexOf(0)!==-1&&(i=i.filter(e=>e!==0)),i.length===0?[]:await this.execute({[r]:i,...t})}async execute(e){return(await S(this.client,`/channel/retrieve`,e,mb,hb)).channels}},vb=class{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,t){if(!Array.isArray(e)&&typeof e==`object`)return await this.wrapped.retrieve(e);let{normalized:n}=gb(e),r=[],i=[];if(n.forEach(e=>{let t=this.get(e);t==null?i.push(e):r.push(...t)}),i.length===0)return r;let a=await this.wrapped.retrieve(i,t);return this.set(a),r.concat(a)}delete(e){let{variant:t,normalized:n}=gb(e);t===`names`?n.forEach(e=>{let t=this.namesToKeys.get(e);t!=null&&(t.forEach(e=>this.cache.delete(e)),this.namesToKeys.delete(e))}):n.forEach(e=>{let t=this.cache.get(e);t!=null&&(this.cache.delete(e),this.namesToKeys.delete(t.name))})}rename(e,t){e.forEach((e,n)=>{let r=t[n],i=this.cache.get(e);if(i==null)return;this.cache.delete(e);let a=this.namesToKeys.get(i.name);a!=null&&(a.delete(e),a.size===0&&this.namesToKeys.delete(i.name)),i.name=r,this.cache.set(e,i);let o=this.namesToKeys.get(r);o==null?this.namesToKeys.set(r,new Set([e])):o.add(e)})}set(e){e.forEach(e=>{this.cache.set(e.key,e);let t=this.namesToKeys.get(e.name);t==null?this.namesToKeys.set(e.name,new Set([e.key])):t.add(e.key)})}get(e){if(typeof e==`number`){let t=this.cache.get(e);return t==null?void 0:[t]}let t=this.namesToKeys.get(e);if(t==null)return;let n=[];if(t.forEach(e=>{let t=this.cache.get(e);t!=null&&n.push(t)}),n.length!==0)return n}},yb=class{mu=new Xy;requests=new Map;wrapped;debouncedRun;constructor(e,t){this.wrapped=e,this.debouncedRun=Jc(()=>{this.run()},t)}async retrieve(e){if(!Array.isArray(e)&&typeof e==`object`)return await this.wrapped.retrieve(e);let{normalized:t,variant:n}=gb(e);return n===`names`?await this.wrapped.retrieve(t):await new Promise((e,n)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:e,reject:n}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{let e=new Set;this.requests.forEach((t,n)=>n.forEach(t=>e.add(t)));try{let t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((e,n)=>e.resolve(t.filter(e=>n.includes(e.key))))}catch(e){this.requests.forEach(t=>t.reject(e))}finally{this.requests.clear()}})}},bb=async(e,t)=>{let{normalized:n}=gb(t),r=await e.retrieve(n),i=[];if(n.forEach(e=>{r.find(t=>t.name===e||t.key===e)??i.push(e)}),i.length>0)throw new Tu(`Could not find channels: ${JSON.stringify(i)}`);return r},xb=l.z.uuid(),Sb=l.z.object({key:xb,name:l.z.string()}),Cb=z(`group`),wb=Cb(``),Tb=`sy_group_set`,Eb=`sy_group_delete`,Db=l.default.object({group:Sb}),Ob=l.default.object({parent:R,key:xb.optional(),name:l.default.string()}),kb=l.default.object({key:xb,name:l.default.string()}),Ab=l.default.object({keys:l.default.array(xb)}),jb=class{client;constructor(e){this.client=e}async create(e){return(await S(this.client,`/ontology/create-group`,e,Ob,Db)).group}async rename(e,t){await S(this.client,`/ontology/rename-group`,{key:e,name:t},kb,l.default.object({}))}async delete(e){await S(this.client,`/ontology/delete-group`,{keys:w.toArray(e)},Ab,l.default.object({}))}},Mb=o({Client:()=>jb,DELETE_CHANNEL_NAME:()=>Eb,SET_CHANNEL_NAME:()=>Tb,TYPE_ONTOLOGY_ID:()=>wb,groupZ:()=>Sb,keyZ:()=>xb,ontologyID:()=>Cb}),Nb=`sy_channel_set`,Pb=`sy_channel_delete`,Fb=class{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;operations;status;constructor({dataType:e,name:t,leaseholder:n=0,key:r=0,isIndex:i=!1,index:a=0,internal:o=!1,virtual:s=!1,frameClient:c,alias:l,status:u,expression:d=``,operations:f=[]}){this.key=Z.parse(r),this.name=t,this.dataType=new j(e),this.leaseholder=n,this.index=Z.parse(a),this.isIndex=i,this.internal=o,this.alias=l,this.virtual=s,this.expression=d,this.operations=f,u!=null&&(this.status=cu.create(u)),this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new L(`cannot read from a channel that has not been created`);return this._frameClient}get payload(){return ib.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,status:this.status,operations:this.operations})}get isCalculated(){return zb(this.payload)}get ontologyID(){return ob(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}},Ib=l.z.object({}),Lb=l.z.object({group:Sb}),Rb=class{frameClient;client;retriever;writer;constructor(e,t,n,r){this.frameClient=e,this.retriever=t,this.client=n,this.writer=r}async create(e,t={}){let{retrieveIfNameExists:n=!1}=t,r=!Array.isArray(e),i=w.toArray(e),a=[];if(n){let e=await this.retriever.retrieve(i.map(e=>e.name)),t=new Set(e.map(e=>e.name));i=i.filter(e=>!t.has(e.name)),a=this.sugar(e)}return a=a.concat(this.sugar(await this.writer.create(i))),r?a[0]:a}async retrieve(e,t){if(typeof e==`object`&&!Array.isArray(e))return this.sugar(await this.retriever.retrieve(e));let n=!Array.isArray(e),r=this.sugar(await this.retriever.retrieve(e,t));return X(`channel`,e,r,n),n?r[0]:r}async delete(e){let{normalized:t,variant:n}=gb(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(w.toArray(e),w.toArray(t))}createDebouncedBatchRetriever(e=10){return new vb(new yb(new _b(this.client),e))}sugar(e){let{frameClient:t}=this;return Array.isArray(e)?e.map(e=>new Fb({...e,frameClient:t})):new Fb({...e,frameClient:t})}async retrieveGroup(){return(await S(this.client,`/channel/retrieve-group`,{},Ib,Lb)).group}},zb=({virtual:e,expression:t})=>e&&t!==``,Bb=l.z.union([N.toArray(Z),N.toArray(nb),N.toArray(ib).transform(e=>e.map(e=>e.key))]),Vb=/[a-zA-Z0-9_]/,Hb=/^[a-zA-Z_][a-zA-Z0-9_]*$/,Ub=(e,t=!1)=>{if(e===``)return t?`_`:``;if(e.match(Hb))return e;let n=``;for(let t of e)t.match(Vb)?n+=t:n+=`_`;return n[0].match(/^\d/)&&(n=`_${n}`),n},Wb=e=>Ru(ob(e)),Gb=l.z.object({channels:ab.array()}),Kb=l.z.object({channels:ib.array()}),qb=l.z.object({keys:Z.array().optional(),names:nb.array().optional()}),Jb=l.z.object({}),Yb=l.z.object({keys:Z.array(),names:nb.array()}),Xb=l.z.object({}),Zb=class{client;cache;constructor(e,t){this.client=e,this.cache=t}async create(e){let{channels:t}=await S(this.client,`/channel/create`,{channels:e.map(e=>({...e,dataType:e.dataType}))},Gb,Kb);return this.cache.set(t),t}async delete(e){let t=Z.array().parse(e.keys??[]);await S(this.client,`/channel/delete`,e,qb,Jb),t.length>0&&this.cache.delete(t),e.names!=null&&this.cache.delete(e.names)}async rename(e,t){await S(this.client,`/channel/rename`,{keys:e,names:t},Yb,Xb),this.cache.rename(e,t)}},Qb=o({CacheRetriever:()=>vb,Channel:()=>Fb,Client:()=>Rb,ClusterRetriever:()=>_b,DELETE_CHANNEL_NAME:()=>Pb,DebouncedBatchRetriever:()=>yb,OPERATION_TYPES:()=>$y,SET_CHANNEL_NAME:()=>Nb,TYPE_ONTOLOGY_ID:()=>sb,Writer:()=>Zb,analyzeParams:()=>gb,escapeInvalidName:()=>Ub,isCalculated:()=>zb,keyZ:()=>Z,localKeyZ:()=>Qy,nameZ:()=>nb,newZ:()=>ab,ontologyID:()=>ob,operationTypeZ:()=>eb,operationZ:()=>tb,paramsZ:()=>Bb,payloadZ:()=>ib,retrieveRequired:()=>bb,statusKey:()=>Wb,statusZ:()=>rb}),$b=l.z.object({username:l.z.string(),password:l.z.string()}),ex=l.z.object({token:l.z.string(),user:jd}),tx=`/auth/login`,nx=3,rx=l.z.object({username:l.z.string(),password:l.z.string(),newPassword:l.z.string().min(1)}),ix=l.z.object({}),ax=[Su,Cu],ox=class{client;credentials;authState={authenticated:!1};authenticating;retryCount;constructor(e,t){this.client=e,this.credentials=t,this.retryCount=0}get authenticated(){return this.authState.authenticated}get user(){return this.authState.authenticated?this.authState.user:void 0}get token(){return this.authState.authenticated?this.authState.token:void 0}async retrieveUser(){this.authState.authenticated||await this.authenticating;let{authState:e}=this;if(!e.authenticated)throw Error(`Authentication failed: user not available`);return e.user}async changePassword(e){if(!this.authenticated)throw Error(`Not authenticated`);await S(this.client,`/auth/change-password`,{username:this.credentials.username,password:this.credentials.password,newPassword:e},rx,ix),this.credentials.password=e}middleware(){let e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(tx)){this.authenticating??=new Promise((e,t)=>{this.client.send(tx,this.credentials,$b,ex).then(([t,n])=>{if(n!=null)return e(n);if(t==null)return e(Error(`No response from login`));this.authState={authenticated:!0,user:t.user,token:t.token},e(null)}).catch(t)});let e=await this.authenticating;if(e!=null)return[t,e]}t.params.Authorization=`Bearer ${this.token}`;let[r,i]=await n(t);return ax.some(e=>e.matches(i))&&this.retryCount<nx?(this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[r,i])};return e}},sx=o({Checker:()=>mx,stateZ:()=>lx,statusZ:()=>cx}),cx=l.z.enum([`disconnected`,`connecting`,`connected`,`failed`]),lx=l.z.object({status:cx,error:l.z.instanceof(Error).optional(),message:l.z.string().optional(),clusterKey:l.z.string(),clientVersion:l.z.string(),clientServerCompatible:l.z.boolean(),nodeVersion:l.z.string().optional()}),ux=l.z.object({clusterKey:l.z.string(),nodeVersion:l.z.string().optional()}),dx=l.z.void(),fx={clusterKey:``,status:`disconnected`,error:void 0,message:`Disconnected`,clientServerCompatible:!1,clientVersion:`0.54.0`},px=(e,t,n)=>{let r=n?`Core`:`client`;return`Synnax Core version ${e==null?``:`${e} `}is too ${n?`old`:`new`} for client version ${t}.
|
|
59
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ng(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Fg(t,`input`,e.processors),output:Fg(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var Pg=(e,t={})=>n=>{let r=jg({...n,processors:t});return K(e,r),Mg(r,e),Ng(r,e)},Fg=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=jg({...i??{},target:a,io:t,processors:n});return K(e,o),Mg(o,e),Ng(o,e)},Ig={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Lg=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ig[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Rg=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},zg=(e,t,n,r)=>{n.type=`boolean`},Bg=(e,t,n,r)=>{n.not={}},Vg=(e,t,n,r)=>{let i=e._zod.def,a=Tf(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Hg=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ug=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Wg=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},Gg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Kg=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},qg=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Jg=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Yg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Zg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Qg=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},$g=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;K(a,t,r);let o=t.seen.get(e);o.ref=a},e_=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},t_=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},n_=B(`ZodISODateTime`,(e,t)=>{Am.init(e,t),Y.init(e,t)});function r_(e){return $h(n_,e)}var i_=B(`ZodISODate`,(e,t)=>{jm.init(e,t),Y.init(e,t)});function a_(e){return eg(i_,e)}var o_=B(`ZodISOTime`,(e,t)=>{Mm.init(e,t),Y.init(e,t)});function s_(e){return tg(o_,e)}var c_=B(`ZodISODuration`,(e,t)=>{Nm.init(e,t),Y.init(e,t)});function l_(e){return ng(c_,e)}var u_=(e,t)=>{op.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>lp(e,t)},flatten:{value:t=>cp(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ef,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ef,2)}},isEmpty:{get(){return e.issues.length===0}}})};B(`ZodError`,u_);var d_=B(`ZodError`,u_,{Parent:Error}),f_=up(d_),p_=dp(d_),m_=fp(d_),h_=mp(d_),g_=gp(d_),__=_p(d_),v_=vp(d_),y_=yp(d_),b_=bp(d_),x_=xp(d_),S_=Sp(d_),C_=Cp(d_),J=B(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Fg(e,`input`),output:Fg(e,`output`)}}),e.toJSONSchema=Pg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(Nf(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Uf(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>f_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>m_(e,t,n),e.parseAsync=async(t,n)=>p_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>h_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>g_(e,t,n),e.decode=(t,n)=>__(e,t,n),e.encodeAsync=async(t,n)=>v_(e,t,n),e.decodeAsync=async(t,n)=>y_(e,t,n),e.safeEncode=(t,n)=>b_(e,t,n),e.safeDecode=(t,n)=>x_(e,t,n),e.safeEncodeAsync=async(t,n)=>S_(e,t,n),e.safeDecodeAsync=async(t,n)=>C_(e,t,n),e.refine=(t,n)=>e.check(Mv(t,n)),e.superRefine=t=>e.check(Nv(t)),e.overwrite=t=>e.check(xg(t)),e.optional=()=>mv(e),e.exactOptional=()=>gv(e),e.nullable=()=>vv(e),e.nullish=()=>mv(vv(e)),e.nonoptional=t=>wv(e,t),e.array=()=>nv(e),e.or=t=>ov([e,t]),e.and=t=>cv(e,t),e.transform=t=>Ov(e,fv(t)),e.default=t=>bv(e,t),e.prefault=t=>Sv(e,t),e.catch=t=>Ev(e,t),e.pipe=t=>Ov(e,t),e.readonly=()=>Av(e),e.describe=t=>{let n=e.clone();return kh.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return kh.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return kh.get(e);let n=e.clone();return kh.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),w_=B(`_ZodString`,(e,t)=>{vm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lg(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(hg(...t)),e.includes=(...t)=>e.check(vg(...t)),e.startsWith=(...t)=>e.check(yg(...t)),e.endsWith=(...t)=>e.check(bg(...t)),e.min=(...t)=>e.check(pg(...t)),e.max=(...t)=>e.check(fg(...t)),e.length=(...t)=>e.check(mg(...t)),e.nonempty=(...t)=>e.check(pg(1,...t)),e.lowercase=t=>e.check(gg(t)),e.uppercase=t=>e.check(_g(t)),e.trim=()=>e.check(Cg()),e.normalize=(...t)=>e.check(Sg(...t)),e.toLowerCase=()=>e.check(wg()),e.toUpperCase=()=>e.check(Tg()),e.slugify=()=>e.check(Eg())}),T_=B(`ZodString`,(e,t)=>{vm.init(e,t),w_.init(e,t),e.email=t=>e.check(jh(D_,t)),e.url=t=>e.check(Lh(A_,t)),e.jwt=t=>e.check(Qh(G_,t)),e.emoji=t=>e.check(Rh(j_,t)),e.guid=t=>e.check(Mh(O_,t)),e.uuid=t=>e.check(Nh(k_,t)),e.uuidv4=t=>e.check(Ph(k_,t)),e.uuidv6=t=>e.check(Fh(k_,t)),e.uuidv7=t=>e.check(Ih(k_,t)),e.nanoid=t=>e.check(zh(M_,t)),e.guid=t=>e.check(Mh(O_,t)),e.cuid=t=>e.check(Bh(N_,t)),e.cuid2=t=>e.check(Vh(P_,t)),e.ulid=t=>e.check(Hh(F_,t)),e.base64=t=>e.check(Yh(H_,t)),e.base64url=t=>e.check(Xh(U_,t)),e.xid=t=>e.check(Uh(I_,t)),e.ksuid=t=>e.check(Wh(L_,t)),e.ipv4=t=>e.check(Gh(R_,t)),e.ipv6=t=>e.check(Kh(z_,t)),e.cidrv4=t=>e.check(qh(B_,t)),e.cidrv6=t=>e.check(Jh(V_,t)),e.e164=t=>e.check(Zh(W_,t)),e.datetime=t=>e.check(r_(t)),e.date=t=>e.check(a_(t)),e.time=t=>e.check(s_(t)),e.duration=t=>e.check(l_(t))});function E_(e){return Ah(T_,e)}var Y=B(`ZodStringFormat`,(e,t)=>{G.init(e,t),w_.init(e,t)}),D_=B(`ZodEmail`,(e,t)=>{xm.init(e,t),Y.init(e,t)}),O_=B(`ZodGUID`,(e,t)=>{ym.init(e,t),Y.init(e,t)}),k_=B(`ZodUUID`,(e,t)=>{bm.init(e,t),Y.init(e,t)}),A_=B(`ZodURL`,(e,t)=>{Sm.init(e,t),Y.init(e,t)}),j_=B(`ZodEmoji`,(e,t)=>{Cm.init(e,t),Y.init(e,t)}),M_=B(`ZodNanoID`,(e,t)=>{wm.init(e,t),Y.init(e,t)}),N_=B(`ZodCUID`,(e,t)=>{Tm.init(e,t),Y.init(e,t)}),P_=B(`ZodCUID2`,(e,t)=>{Em.init(e,t),Y.init(e,t)}),F_=B(`ZodULID`,(e,t)=>{Dm.init(e,t),Y.init(e,t)}),I_=B(`ZodXID`,(e,t)=>{Om.init(e,t),Y.init(e,t)}),L_=B(`ZodKSUID`,(e,t)=>{km.init(e,t),Y.init(e,t)}),R_=B(`ZodIPv4`,(e,t)=>{Pm.init(e,t),Y.init(e,t)}),z_=B(`ZodIPv6`,(e,t)=>{Fm.init(e,t),Y.init(e,t)}),B_=B(`ZodCIDRv4`,(e,t)=>{Im.init(e,t),Y.init(e,t)}),V_=B(`ZodCIDRv6`,(e,t)=>{Lm.init(e,t),Y.init(e,t)}),H_=B(`ZodBase64`,(e,t)=>{zm.init(e,t),Y.init(e,t)}),U_=B(`ZodBase64URL`,(e,t)=>{Vm.init(e,t),Y.init(e,t)}),W_=B(`ZodE164`,(e,t)=>{Hm.init(e,t),Y.init(e,t)}),G_=B(`ZodJWT`,(e,t)=>{Wm.init(e,t),Y.init(e,t)}),K_=B(`ZodNumber`,(e,t)=>{Gm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rg(e,t,n,r),e.gt=(t,n)=>e.check(lg(t,n)),e.gte=(t,n)=>e.check(ug(t,n)),e.min=(t,n)=>e.check(ug(t,n)),e.lt=(t,n)=>e.check(sg(t,n)),e.lte=(t,n)=>e.check(cg(t,n)),e.max=(t,n)=>e.check(cg(t,n)),e.int=t=>e.check(J_(t)),e.safe=t=>e.check(J_(t)),e.positive=t=>e.check(lg(0,t)),e.nonnegative=t=>e.check(ug(0,t)),e.negative=t=>e.check(sg(0,t)),e.nonpositive=t=>e.check(cg(0,t)),e.multipleOf=(t,n)=>e.check(dg(t,n)),e.step=(t,n)=>e.check(dg(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),q_=B(`ZodNumberFormat`,(e,t)=>{Km.init(e,t),K_.init(e,t)});function J_(e){return rg(q_,e)}var Y_=B(`ZodBoolean`,(e,t)=>{qm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zg(e,t,n,r)});function X_(e){return ig(Y_,e)}var Z_=B(`ZodUnknown`,(e,t)=>{Jm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Q_(){return ag(Z_)}var $_=B(`ZodNever`,(e,t)=>{Ym.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bg(e,t,n,r)});function ev(e){return og($_,e)}var tv=B(`ZodArray`,(e,t)=>{Zm.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wg(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(pg(t,n)),e.nonempty=t=>e.check(pg(1,t)),e.max=(t,n)=>e.check(fg(t,n)),e.length=(t,n)=>e.check(mg(t,n)),e.unwrap=()=>e.element});function nv(e,t){return Dg(tv,e,t)}var rv=B(`ZodObject`,(e,t)=>{nh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gg(e,t,n,r),V(e,`shape`,()=>t.shape),e.keyof=()=>uv(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Q_()}),e.loose=()=>e.clone({...e._zod.def,catchall:Q_()}),e.strict=()=>e.clone({...e._zod.def,catchall:ev()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Jf(e,t),e.safeExtend=t=>Yf(e,t),e.merge=t=>Xf(e,t),e.pick=t=>Kf(e,t),e.omit=t=>qf(e,t),e.partial=(...t)=>Zf(pv,e,t[0]),e.required=(...t)=>Qf(Cv,e,t[0])});function iv(e,t){return new rv({type:`object`,shape:e??{},...H(t)})}var av=B(`ZodUnion`,(e,t)=>{ih.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kg(e,t,n,r),e.options=t.options});function ov(e,t){return new av({type:`union`,options:e,...H(t)})}var sv=B(`ZodIntersection`,(e,t)=>{ah.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qg(e,t,n,r)});function cv(e,t){return new sv({type:`intersection`,left:e,right:t})}var lv=B(`ZodEnum`,(e,t)=>{ch.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vg(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new lv({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new lv({...t,checks:[],...H(r),entries:i})}});function uv(e,t){return new lv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var dv=B(`ZodTransform`,(e,t)=>{lh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ug(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Sf(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ip(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(ip(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function fv(e){return new dv({type:`transform`,transform:e})}var pv=B(`ZodOptional`,(e,t)=>{dh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mv(e){return new pv({type:`optional`,innerType:e})}var hv=B(`ZodExactOptional`,(e,t)=>{fh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gv(e){return new hv({type:`optional`,innerType:e})}var _v=B(`ZodNullable`,(e,t)=>{ph.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vv(e){return new _v({type:`nullable`,innerType:e})}var yv=B(`ZodDefault`,(e,t)=>{mh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function bv(e,t){return new yv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Bf(t)}})}var xv=B(`ZodPrefault`,(e,t)=>{gh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sv(e,t){return new xv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Bf(t)}})}var Cv=B(`ZodNonOptional`,(e,t)=>{_h.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wv(e,t){return new Cv({type:`nonoptional`,innerType:e,...H(t)})}var Tv=B(`ZodCatch`,(e,t)=>{yh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ev(e,t){return new Tv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Dv=B(`ZodPipe`,(e,t)=>{bh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$g(e,t,n,r),e.in=t.in,e.out=t.out});function Ov(e,t){return new Dv({type:`pipe`,in:e,out:t})}var kv=B(`ZodReadonly`,(e,t)=>{Sh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Av(e){return new kv({type:`readonly`,innerType:e})}var jv=B(`ZodCustom`,(e,t)=>{wh.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hg(e,t,n,r)});function Mv(e,t={}){return Og(jv,e,t)}function Nv(e){return kg(e)}var Pv=function(e){return e[e.invalid=0]=`invalid`,e[e.u8=1]=`u8`,e[e.u16=2]=`u16`,e[e.u32=3]=`u32`,e[e.u64=4]=`u64`,e[e.i8=5]=`i8`,e[e.i16=6]=`i16`,e[e.i32=7]=`i32`,e[e.i64=8]=`i64`,e[e.f32=9]=`f32`,e[e.f64=10]=`f64`,e[e.string=11]=`string`,e[e.chan=14]=`chan`,e[e.series=15]=`series`,e[e.variable=16]=`variable`,e[e.numeric_constant=17]=`numeric_constant`,e[e.integer_constant=18]=`integer_constant`,e[e.float_constant=19]=`float_constant`,e[e.exact_integer_float_constant=20]=`exact_integer_float_constant`,e[e.function=21]=`function`,e[e.sequence=22]=`sequence`,e[e.stage=23]=`stage`,e}({}),Fv=l.z.enum(Pv),Iv=function(e){return e[e.none=0]=`none`,e[e.read=1]=`read`,e[e.write=2]=`write`,e}({}),Lv=l.z.enum(Iv),Rv=l.z.object({read:l.z.record(l.z.uint32(),l.z.string()),write:l.z.record(l.z.uint32(),l.z.string())}),zv=l.z.object({length:N.int8,mass:N.int8,time:N.int8,current:N.int8,temperature:N.int8,angle:N.int8,count:N.int8,data:N.int8}),Bv=l.z.object({dimensions:zv,scale:l.z.number(),name:l.z.string()}),Vv=l.z.object({get inputs(){return Uv.optional()},get outputs(){return Uv.optional()},get config(){return Uv.optional()}}).extend({kind:Fv,name:l.z.string(),get elem(){return Vv.optional()},unit:Bv.optional(),get constraint(){return Vv.optional()},chanDirection:Lv.optional()}),Hv=l.z.object({name:l.z.string(),type:Vv,value:l.z.unknown().optional()}),Uv=w.nullishToEmpty(Hv),Wv=o({EdgeKind:()=>Gv,authoritiesZ:()=>Xv,bodyZ:()=>Jv,edgeKindZ:()=>Kv,edgeZ:()=>Qv,edgesZ:()=>ny,functionZ:()=>$v,functionsZ:()=>ry,handleZ:()=>qv,irZ:()=>cy,nodeZ:()=>Yv,nodesZ:()=>ey,sequenceZ:()=>ay,sequencesZ:()=>sy,stageZ:()=>iy,stagesZ:()=>oy,strataZ:()=>ty,stratumZ:()=>Zv}),Gv=function(e){return e[e.unspecified=0]=`unspecified`,e[e.continuous=1]=`continuous`,e[e.conditional=2]=`conditional`,e}({}),Kv=l.z.enum(Gv),qv=l.z.object({node:l.z.string(),param:l.z.string()}),Jv=l.z.object({raw:l.z.string()}),Yv=l.z.object({key:l.z.string(),type:l.z.string(),config:Uv.optional(),inputs:Uv.optional(),outputs:Uv.optional(),channels:Rv.optional()}),Xv=l.z.object({default:N.uint8.optional(),channels:l.z.record(l.z.uint32(),N.uint8).optional()}),Zv=w.nullishToEmpty(l.z.string()),Qv=l.z.object({source:qv,target:qv,kind:Kv.optional()}),$v=l.z.object({key:l.z.string(),body:Jv.optional(),config:Uv.optional(),inputs:Uv.optional(),outputs:Uv.optional(),channels:Rv.optional()}),ey=w.nullishToEmpty(Yv),ty=w.nullishToEmpty(Zv),ny=w.nullishToEmpty(Qv),ry=w.nullishToEmpty($v),iy=l.z.object({key:l.z.string(),nodes:w.nullishToEmpty(l.z.string()),strata:ty}),ay=l.z.object({key:l.z.string(),stages:w.nullishToEmpty(iy)}),oy=w.nullishToEmpty(iy),sy=w.nullishToEmpty(ay),cy=l.z.object({functions:ry.optional(),nodes:ey.optional(),edges:ny.optional(),strata:ty.optional(),sequences:sy.optional(),authorities:Xv.optional()}),ly=o({graphZ:()=>py,nodeZ:()=>uy,nodesZ:()=>fy,viewportZ:()=>dy}),uy=l.z.object({key:l.z.string(),type:l.z.string(),config:I.nullishToEmpty(),position:xo.xyZ}),dy=l.z.object({position:xo.xyZ,zoom:l.z.number()}),fy=w.nullishToEmpty(uy),py=l.z.object({viewport:dy,functions:ry,edges:ny,nodes:fy}),my=o({outputZ:()=>hy}),hy=l.z.object({wasm:l.z.instanceof(Uint8Array),outputMemoryBases:l.z.record(l.z.string(),l.z.uint32())}),gy=cy.extend(hy.shape),_y=o({textZ:()=>vy}),vy=l.z.object({raw:l.z.string()}),yy=[`text`,`graph`],by=l.z.enum(yy),xy=l.z.object({running:l.z.boolean()}),Sy=l.z.uuid(),Cy=cu.statusZ({details:xy}),wy=l.z.object({key:Sy.optional(),name:l.z.string(),mode:by,graph:py,text:vy}),Ty=l.z.object({key:Sy,name:l.z.string(),mode:by,graph:py,text:vy,program:gy.optional(),status:Cy.optional()}),Ey=z(`arc`),Dy=Ey(``),Oy=(e,t,{convertNumericStrings:n=!0}={})=>{let r=!Array.isArray(e),i=w.toArray(e),a=i[0],o=typeof a,s;return o===`string`&&n&&!isNaN(parseInt(a,10))&&`number`in t?(s=t.number,i=i.map(e=>parseInt(e,10))):s=t[o],{single:r,variant:s,normalized:i,actual:e}},X=(e,t,n,r)=>{if(r){if(n.length===0)throw new Eu(`${e} not found matching ${JSON.stringify(t)}`);if(n.length>1)throw new Du(`Expected one ${e} matching ${JSON.stringify(t)}, but found ${n.length}`)}},ky=`sy_arc_set`,Ay=`sy_arc_delete`,jy=iv({keys:Sy.array().optional(),names:E_().array().optional(),searchTerm:E_().optional(),limit:J_().optional(),offset:J_().optional(),includeStatus:X_().optional()}),My=iv({arcs:wy.array()}),Ny=iv({keys:Sy.array()}),Py=iv({arcs:w.nullishToEmpty(Ty)}),Fy=iv({arcs:Ty.array()}),Iy=iv({}),Ly=iv({content:E_()}),Ry=ov([iv({key:Sy,includeStatus:X_().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),iv({name:E_(),includeStatus:X_().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t}))]),zy=ov([Ry,jy]),By=class{client;streamClient;constructor(e,t){this.client=e,this.streamClient=t}async create(e){let t=Array.isArray(e),n=await S(this.client,`/arc/create`,{arcs:w.toArray(e)},My,Fy);return t?n.arcs:n.arcs[0]}async retrieve(e){let t=`key`in e||`name`in e,n=await S(this.client,`/arc/retrieve`,e,zy,Py);return X(`Arc`,e,n.arcs,t),t?n.arcs[0]:n.arcs}async delete(e){await S(this.client,`/arc/delete`,{keys:w.toArray(e)},Ny,Iy)}async openLSP(){return await this.streamClient.stream(`/arc/lsp`,Ly,Ly)}},Vy=o({moduleZ:()=>Hy}),Hy=cy.extend(hy.shape),Uy=o({Client:()=>By,DELETE_CHANNEL_NAME:()=>Ay,MODES:()=>yy,SET_CHANNEL_NAME:()=>ky,TYPE_ONTOLOGY_ID:()=>Dy,arcZ:()=>Ty,compiler:()=>my,graph:()=>ly,ir:()=>Wv,keyZ:()=>Sy,lspMessageZ:()=>Ly,modeZ:()=>by,module:()=>Vy,newZ:()=>wy,ontologyID:()=>Ey,singleRetrieveArgsZ:()=>Ry,statusDetailsZ:()=>xy,statusZ:()=>Cy,text:()=>_y}),Wy=Error(`request for lock canceled`),Gy=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ky=class{constructor(e,t=Wy){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=Jy(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return Gy(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw 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]=[]),qy(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 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){let 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--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function qy(e,t){let n=Jy(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function Jy(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Yy=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Xy=class{constructor(e){this._semaphore=new Ky(1,e)}acquire(){return Yy(this,arguments,void 0,function*(e=0){let[,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()}},Zy=N.uint12,Z=l.z.uint32().or(l.z.string().refine(e=>!isNaN(Number(e))).transform(Number)),Qy=N.uint20,$y=[`min`,`max`,`avg`,`none`,`derivative`],eb=l.z.enum($y),tb=l.z.object({type:eb,resetChannel:Z.default(0),duration:us.timeSpanZ.default(O.ZERO)}),nb=l.z.string().min(1,`Name is required`),rb=cu.statusZ(),ib=l.z.object({key:Z,name:nb,leaseholder:Zy,dataType:us.dataTypeZ,isIndex:l.z.boolean(),index:Z,alias:l.z.string().optional(),virtual:l.z.boolean().default(!1),internal:l.z.boolean().default(!1),expression:l.z.string().default(``),operations:N.nullToUndefined(tb.array()),concurrency:F.concurrencyZ.default(F.Concurrency.exclusive).optional(),status:rb.optional()}),ab=ib.omit({leaseholder:!0}).partial({key:!0,index:!0,isIndex:!0,internal:!0,virtual:!0,expression:!0}).extend({leaseholder:N.uint12.optional()}),ob=z(`channel`),sb=ob(0),Q=l.z.uuid(),cb=l.z.object({key:Q,name:l.z.string().min(1),timeRange:us.timeRangeZ,color:Nc.colorZ.optional()}),lb=cb.extend({labels:N.nullToUndefined(fl.labelZ.array()),get parent(){return lb.optional()}}),ub=cb.omit({timeRange:!0}).extend({labels:N.nullToUndefined(fl.labelZ.array()),get parent(){return ub.optional()},timeRange:us.timeRangeBoundedZ}),db=ub.omit({parent:!0,labels:!0}).partial({key:!0}),fb=z(`range`),pb=fb(``),mb=l.z.object({nodeKey:N.uint12.optional(),keys:Z.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),rangeKey:Q.optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),dataTypes:j.z.array().optional(),notDataTypes:j.z.array().optional(),virtual:l.z.boolean().optional(),isIndex:l.z.boolean().optional(),internal:l.z.boolean().optional(),legacyCalculated:l.z.boolean().optional()}),hb=l.z.object({channels:w.nullishToEmpty(ib)}),gb=e=>(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`?e=e.map(e=>e.key):typeof e==`object`&&`key`in e&&(e=[e.key]),Oy(e,{number:`keys`,string:`names`})),_b=class{client;constructor(e){this.client=e}async retrieve(e,t){if(!Array.isArray(e)&&typeof e==`object`)return await this.execute(e);let n=gb(e),{variant:r}=n,{normalized:i}=n;return r===`keys`&&i.indexOf(0)!==-1&&(i=i.filter(e=>e!==0)),i.length===0?[]:await this.execute({[r]:i,...t})}async execute(e){return(await S(this.client,`/channel/retrieve`,e,mb,hb)).channels}},vb=class{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,t){if(!Array.isArray(e)&&typeof e==`object`)return await this.wrapped.retrieve(e);let{normalized:n}=gb(e),r=[],i=[];if(n.forEach(e=>{let t=this.get(e);t==null?i.push(e):r.push(...t)}),i.length===0)return r;let a=await this.wrapped.retrieve(i,t);return this.set(a),r.concat(a)}delete(e){let{variant:t,normalized:n}=gb(e);t===`names`?n.forEach(e=>{let t=this.namesToKeys.get(e);t!=null&&(t.forEach(e=>this.cache.delete(e)),this.namesToKeys.delete(e))}):n.forEach(e=>{let t=this.cache.get(e);t!=null&&(this.cache.delete(e),this.namesToKeys.delete(t.name))})}rename(e,t){e.forEach((e,n)=>{let r=t[n],i=this.cache.get(e);if(i==null)return;this.cache.delete(e);let a=this.namesToKeys.get(i.name);a!=null&&(a.delete(e),a.size===0&&this.namesToKeys.delete(i.name)),i.name=r,this.cache.set(e,i);let o=this.namesToKeys.get(r);o==null?this.namesToKeys.set(r,new Set([e])):o.add(e)})}set(e){e.forEach(e=>{this.cache.set(e.key,e);let t=this.namesToKeys.get(e.name);t==null?this.namesToKeys.set(e.name,new Set([e.key])):t.add(e.key)})}get(e){if(typeof e==`number`){let t=this.cache.get(e);return t==null?void 0:[t]}let t=this.namesToKeys.get(e);if(t==null)return;let n=[];if(t.forEach(e=>{let t=this.cache.get(e);t!=null&&n.push(t)}),n.length!==0)return n}},yb=class{mu=new Xy;requests=new Map;wrapped;debouncedRun;constructor(e,t){this.wrapped=e,this.debouncedRun=Jc(()=>{this.run()},t)}async retrieve(e){if(!Array.isArray(e)&&typeof e==`object`)return await this.wrapped.retrieve(e);let{normalized:t,variant:n}=gb(e);return n===`names`?await this.wrapped.retrieve(t):await new Promise((e,n)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:e,reject:n}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{let e=new Set;this.requests.forEach((t,n)=>n.forEach(t=>e.add(t)));try{let t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((e,n)=>e.resolve(t.filter(e=>n.includes(e.key))))}catch(e){this.requests.forEach(t=>t.reject(e))}finally{this.requests.clear()}})}},bb=async(e,t)=>{let{normalized:n}=gb(t),r=await e.retrieve(n),i=[];if(n.forEach(e=>{r.find(t=>t.name===e||t.key===e)??i.push(e)}),i.length>0)throw new Tu(`Could not find channels: ${JSON.stringify(i)}`);return r},xb=l.z.uuid(),Sb=l.z.object({key:xb,name:l.z.string()}),Cb=z(`group`),wb=Cb(``),Tb=`sy_group_set`,Eb=`sy_group_delete`,Db=l.default.object({group:Sb}),Ob=l.default.object({parent:R,key:xb.optional(),name:l.default.string()}),kb=l.default.object({key:xb,name:l.default.string()}),Ab=l.default.object({keys:l.default.array(xb)}),jb=class{client;constructor(e){this.client=e}async create(e){return(await S(this.client,`/ontology/create-group`,e,Ob,Db)).group}async rename(e,t){await S(this.client,`/ontology/rename-group`,{key:e,name:t},kb,l.default.object({}))}async delete(e){await S(this.client,`/ontology/delete-group`,{keys:w.toArray(e)},Ab,l.default.object({}))}},Mb=o({Client:()=>jb,DELETE_CHANNEL_NAME:()=>Eb,SET_CHANNEL_NAME:()=>Tb,TYPE_ONTOLOGY_ID:()=>wb,groupZ:()=>Sb,keyZ:()=>xb,ontologyID:()=>Cb}),Nb=`sy_channel_set`,Pb=`sy_channel_delete`,Fb=class{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;operations;status;constructor({dataType:e,name:t,leaseholder:n=0,key:r=0,isIndex:i=!1,index:a=0,internal:o=!1,virtual:s=!1,frameClient:c,alias:l,status:u,expression:d=``,operations:f=[]}){this.key=Z.parse(r),this.name=t,this.dataType=new j(e),this.leaseholder=n,this.index=Z.parse(a),this.isIndex=i,this.internal=o,this.alias=l,this.virtual=s,this.expression=d,this.operations=f,u!=null&&(this.status=cu.create(u)),this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new L(`cannot read from a channel that has not been created`);return this._frameClient}get payload(){return ib.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,status:this.status,operations:this.operations})}get isCalculated(){return zb(this.payload)}get ontologyID(){return ob(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}},Ib=l.z.object({}),Lb=l.z.object({group:Sb}),Rb=class{frameClient;client;retriever;writer;constructor(e,t,n,r){this.frameClient=e,this.retriever=t,this.client=n,this.writer=r}async create(e,t={}){let{retrieveIfNameExists:n=!1}=t,r=!Array.isArray(e),i=w.toArray(e),a=[];if(n){let e=await this.retriever.retrieve(i.map(e=>e.name)),t=new Set(e.map(e=>e.name));i=i.filter(e=>!t.has(e.name)),a=this.sugar(e)}return a=a.concat(this.sugar(await this.writer.create(i))),r?a[0]:a}async retrieve(e,t){if(typeof e==`object`&&!Array.isArray(e))return this.sugar(await this.retriever.retrieve(e));let n=!Array.isArray(e),r=this.sugar(await this.retriever.retrieve(e,t));return X(`channel`,e,r,n),n?r[0]:r}async delete(e){let{normalized:t,variant:n}=gb(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(w.toArray(e),w.toArray(t))}createDebouncedBatchRetriever(e=10){return new vb(new yb(new _b(this.client),e))}sugar(e){let{frameClient:t}=this;return Array.isArray(e)?e.map(e=>new Fb({...e,frameClient:t})):new Fb({...e,frameClient:t})}async retrieveGroup(){return(await S(this.client,`/channel/retrieve-group`,{},Ib,Lb)).group}},zb=({virtual:e,expression:t})=>e&&t!==``,Bb=l.z.union([N.toArray(Z),N.toArray(nb),N.toArray(ib).transform(e=>e.map(e=>e.key))]),Vb=/[a-zA-Z0-9_]/,Hb=/^[a-zA-Z_][a-zA-Z0-9_]*$/,Ub=(e,t=!1)=>{if(e===``)return t?`_`:``;if(e.match(Hb))return e;let n=``;for(let t of e)t.match(Vb)?n+=t:n+=`_`;return n[0].match(/^\d/)&&(n=`_${n}`),n},Wb=e=>Ru(ob(e)),Gb=l.z.object({channels:ab.array()}),Kb=l.z.object({channels:ib.array()}),qb=l.z.object({keys:Z.array().optional(),names:nb.array().optional()}),Jb=l.z.object({}),Yb=l.z.object({keys:Z.array(),names:nb.array()}),Xb=l.z.object({}),Zb=class{client;cache;constructor(e,t){this.client=e,this.cache=t}async create(e){let{channels:t}=await S(this.client,`/channel/create`,{channels:e.map(e=>({...e,dataType:e.dataType}))},Gb,Kb);return this.cache.set(t),t}async delete(e){let t=Z.array().parse(e.keys??[]);await S(this.client,`/channel/delete`,e,qb,Jb),t.length>0&&this.cache.delete(t),e.names!=null&&this.cache.delete(e.names)}async rename(e,t){await S(this.client,`/channel/rename`,{keys:e,names:t},Yb,Xb),this.cache.rename(e,t)}},Qb=o({CacheRetriever:()=>vb,Channel:()=>Fb,Client:()=>Rb,ClusterRetriever:()=>_b,DELETE_CHANNEL_NAME:()=>Pb,DebouncedBatchRetriever:()=>yb,OPERATION_TYPES:()=>$y,SET_CHANNEL_NAME:()=>Nb,TYPE_ONTOLOGY_ID:()=>sb,Writer:()=>Zb,analyzeParams:()=>gb,escapeInvalidName:()=>Ub,isCalculated:()=>zb,keyZ:()=>Z,localKeyZ:()=>Qy,nameZ:()=>nb,newZ:()=>ab,ontologyID:()=>ob,operationTypeZ:()=>eb,operationZ:()=>tb,paramsZ:()=>Bb,payloadZ:()=>ib,retrieveRequired:()=>bb,statusKey:()=>Wb,statusZ:()=>rb}),$b=l.z.object({username:l.z.string(),password:l.z.string()}),ex=l.z.object({token:l.z.string(),user:jd}),tx=`/auth/login`,nx=3,rx=l.z.object({username:l.z.string(),password:l.z.string(),newPassword:l.z.string().min(1)}),ix=l.z.object({}),ax=[Su,Cu],ox=class{client;credentials;authState={authenticated:!1};authenticating;retryCount;constructor(e,t){this.client=e,this.credentials=t,this.retryCount=0}get authenticated(){return this.authState.authenticated}get user(){return this.authState.authenticated?this.authState.user:void 0}get token(){return this.authState.authenticated?this.authState.token:void 0}async retrieveUser(){this.authState.authenticated||await this.authenticating;let{authState:e}=this;if(!e.authenticated)throw Error(`Authentication failed: user not available`);return e.user}async changePassword(e){if(!this.authenticated)throw Error(`Not authenticated`);await S(this.client,`/auth/change-password`,{username:this.credentials.username,password:this.credentials.password,newPassword:e},rx,ix),this.credentials.password=e}middleware(){let e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(tx)){this.authenticating??=new Promise((e,t)=>{this.client.send(tx,this.credentials,$b,ex).then(([t,n])=>{if(n!=null)return e(n);if(t==null)return e(Error(`No response from login`));this.authState={authenticated:!0,user:t.user,token:t.token},e(null)}).catch(t)});let e=await this.authenticating;if(e!=null)return[t,e]}t.params.Authorization=`Bearer ${this.token}`;let[r,i]=await n(t);return ax.some(e=>e.matches(i))&&this.retryCount<nx?(this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[r,i])};return e}},sx=o({Checker:()=>mx,stateZ:()=>lx,statusZ:()=>cx}),cx=l.z.enum([`disconnected`,`connecting`,`connected`,`failed`]),lx=l.z.object({status:cx,error:l.z.instanceof(Error).optional(),message:l.z.string().optional(),clusterKey:l.z.string(),clientVersion:l.z.string(),clientServerCompatible:l.z.boolean(),nodeVersion:l.z.string().optional()}),ux=l.z.object({clusterKey:l.z.string(),nodeVersion:l.z.string().optional()}),dx=l.z.void(),fx={clusterKey:``,status:`disconnected`,error:void 0,message:`Disconnected`,clientServerCompatible:!1,clientVersion:`0.54.1`},px=(e,t,n)=>{let r=n?`Core`:`client`;return`Synnax Core version ${e==null?``:`${e} `}is too ${n?`old`:`new`} for client version ${t}.
|
|
60
60
|
This may cause compatibility issues. We recommend updating the ${r}. For more information, see
|
|
61
61
|
https://docs.synnaxlabs.com/reference/client/resources/troubleshooting#old-${r}-version`},mx=class{static DEFAULT=fx;_state;pollFrequency=O.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=lx;versionWarned=!1;constructor(e,t=O.seconds(30),n,r){this._state={...fx},this.client=e,this.pollFrequency=t,this.clientVersion=n,this.name=r,this.check(),this.start()}stop(){this.interval!=null&&clearInterval(this.interval)}async check(){let e=this._state.status;try{let e=await S(this.client,`/connectivity/check`,void 0,dx,ux),t=e.nodeVersion,n=this.clientVersion,r=this.versionWarned;t==null?(this._state.clientServerCompatible=!1,r||(console.warn(px(null,n,!0)),this.versionWarned=!0)):gl.versionsEqual(n,t,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,r||(console.warn(px(t,n,gl.semVerNewer(n,t))),this.versionWarned=!0)),this._state.status=`connected`,this._state.message=`Connected to ${this.name??`cluster`}`,this._state.clusterKey=e.clusterKey,this._state.nodeVersion=e.nodeVersion,this._state.clientVersion=this.clientVersion}catch(e){this._state.status=`failed`,this._state.error=e,this._state.message=this.state.error?.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(e=>e(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}start(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}},hx=l.z.object({keys:Z.array().optional(),bounds:A.z,names:nb.array().optional()}),gx=l.z.object({}),_x=class{client;constructor(e){this.client=e}async delete(e){await S(this.client,`/frame/delete`,e,hx,gx)}},vx=e=>{let t=w.toArray(e);return t.length===0?null:typeof t[0]==`number`||!isNaN(parseInt(t[0],10))?`key`:`name`},yx=(e,t)=>{let n=w.toArray(e);if(n.length===t.length)return;let r=vx(e);throw r===null?new L(`[Frame] - channel keys or names must be provided when constructing a frame.`):new L(`[Frame] - ${r}s and series must be the same length.
|
|
62
62
|
Got ${n.length} ${r}s and ${t.length} series.`)},$=class e{columns=[];series=[];constructor(t=[],n=[]){if(t instanceof e){this.columns=t.columns,this.series=t.series;return}if(t instanceof Map){t.forEach((e,t)=>this.push(t,...w.toArray(e)));return}if(typeof t==`object`&&!Array.isArray(t)){if(`keys`in t&&`series`in t){let e=t;e.series??=[],e.keys??=[];let n=e.series.map(e=>xx(e));yx(e.keys,n),e.keys.forEach((e,t)=>this.push(e,n[t]))}else Object.entries(t).forEach(([e,t])=>{let n=parseInt(e,10);if(!isNaN(n))return this.push(n,...w.toArray(t));this.push(e,...w.toArray(t))});return}if(Array.isArray(t)||[`string`,`number`].includes(typeof t)){let e=w.toArray(n),r=w.toArray(t);yx(r,e),e.forEach((e,t)=>this.push(r[t],e));return}throw new L(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
@@ -80,4 +80,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
80
80
|
`);return t}),t.series)}let n=[],r=[],i=Object.entries(e);for(let e=0;e<i.length;e++){let[t,a]=i[e],o=await this.fetchChannel(t),s=new Qo({data:a,dataType:o.dataType});n.push(o.key),r.push(s)}return new $(n,r)}},qx=class{name;stream;constructor(e,t){this.stream=t,this.name=e}async receive(){let[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){let[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on ${JSON.stringify(e)} closure.
|
|
81
81
|
Please report this error to the Synnax team.`),t!=null){if(br.matches(t))return;throw t}}}closeSend(){this.stream.closeSend()}send(e){let t=this.stream.send(e);if(t!=null)throw t}},Jx=new O(-1),Yx=function(e){return e[e.Open=0]=`Open`,e[e.Next=1]=`Next`,e[e.Prev=2]=`Prev`,e[e.SeekFirst=3]=`SeekFirst`,e[e.SeekLast=4]=`SeekLast`,e[e.SeekLE=5]=`SeekLE`,e[e.SeekGE=6]=`SeekGE`,e[e.Valid=7]=`Valid`,e[e.Error=8]=`Error`,e}(Yx||{}),Xx=function(e){return e[e.None=0]=`None`,e[e.Ack=1]=`Ack`,e[e.Data=2]=`Data`,e}(Xx||{}),Zx=l.z.object({command:l.z.enum(Yx),span:O.z.optional(),bounds:A.z.optional(),stamp:D.z.optional(),keys:Z.array().optional(),chunkSize:l.z.number().optional(),downsampleFactor:l.z.int().optional()}),Qx=l.z.object({variant:l.z.enum(Xx),ack:l.z.boolean(),command:l.z.enum(Yx),error:Zc.payloadZ.optional().nullable(),frame:bx.optional()}),$x=class e{stream;adapter;value;constructor(e,t){this.stream=new qx(`Iterator`,e),this.value=new $,this.adapter=t}static async _open(t,n,r,i,a={}){let o=await Gx.open(r,n),s=new e(await i.stream(`/frame/iterate`,Zx,Qx),o);return await s.execute({command:Yx.Open,keys:Array.from(o.keys),bounds:new A(t),chunkSize:a.chunkSize??1e5,downsampleFactor:a.downsampleFactor??1}),s}async next(e=Jx){return await this.execute({command:Yx.Next,span:new O(e)})}async prev(e=Jx){return await this.execute({command:Yx.Prev,span:new O(e)})}async seekFirst(){return await this.execute({command:Yx.SeekFirst})}async seekLast(){return await this.execute({command:Yx.SeekLast})}async seekLE(e){return await this.execute({command:Yx.SeekLE,stamp:new D(e)})}async seekGE(e){return await this.execute({command:Yx.SeekGE,stamp:new D(e)})}async valid(){return await this.execute({command:Yx.Valid})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new eS(this)}async execute(e){for(this.stream.send(e),this.value=new $;;){let e=await this.stream.receive();if(e.variant===Xx.Ack)return e.ack;this.value.push(this.adapter.adapt(new $(e.frame)))}}},eS=class{iter;open=!1;constructor(e){this.iter=e}async next(){try{let e=!0;return this.open||=(await this.iter.seekFirst()||(e=!1),!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}}},tS=class{retriever;streamClient;constructor(e,t){this.retriever=e,this.streamClient=t}async read(e){let{channels:t,timeRange:n,channelNames:r,iteratorConfig:i}=e,a=await this.retriever.retrieve(t),o=new Set;a.forEach(e=>{o.add(e.key),e.index!==0&&o.add(e.index)});let s=Array.from(o).filter(e=>!a.some(t=>t.key===e));if(s.length>0){let e=await this.retriever.retrieve(s);a.push(...e)}return nS({iterator:await $x._open(n,Array.from(o),this.retriever,this.streamClient,i),channelPayloads:a,headers:r})}},nS=({iterator:e,channelPayloads:t,headers:n})=>{let r=Wl.getOS()===`Windows`?`\r
|
|
82
82
|
`:`
|
|
83
|
-
`,i=new TextEncoder,a=!1,o=!1,s=rS(t),{columns:c,columnsByIndexKey:l,emptyGroupStrings:u}=iS(t,s,n),d=[],f=0,p=[],m=e=>{for(let[t]of s){let n=e.get(t);if(n.length===0)continue;let r=(l.get(t)??[]).map(t=>e.get(t.key));for(let e=0;e<n.length;e++){let i=n.at(e,!0),a=r.map(t=>Wc.formatValue(t.at(e,!0)));p.push({time:i,values:a,indexKey:t})}}},h=(e,t=!1)=>{p.length>0&&(p.sort((e,t)=>Number(e.time-t.time)),f>0&&(d=d.slice(f),f=0),d=aS(d,p),p=[]);let n=[],r=d.length;for(;f<r&&n.length<e;){let e=d[f].time;if(!t&&d[r-1].time===e)break;let i=new Map;for(;f<r&&d[f].time===e;){let e=d[f++];i.set(e.indexKey,e)}let a=[];for(let[e]of s){let t=i.get(e);a.push(t?.values.join(`,`)??u.get(e)??``)}n.push(a.join(`,`))}return n};return new ReadableStream({async pull(t){try{if(o||=(await e.seekFirst(),!0),!a){let e=c.map(e=>Wc.formatValue(e.header)).join(`,`);t.enqueue(i.encode(`${e}${r}`)),a=!0}d.length-f+p.length<oS&&await e.next()&&m(e.value);let n=h(oS);if(n.length>0&&t.enqueue(i.encode(`${n.join(r)}${r}`)),d.length-f===0||p.length===0){if(!await e.next()){let n=h(1/0,!0);n.length>0&&t.enqueue(i.encode(`${n.join(r)}${r}`)),await e.close(),t.close();return}m(e.value)}}catch(n){await e.close(),t.error(n)}},async cancel(){await e.close()}})},rS=e=>{let t=new Map;for(let n of e){if(n.index===0)continue;let e=t.get(n.index);e??(e=[n.index],t.set(n.index,e)),!n.isIndex&&!e.includes(n.key)&&e.push(n.key)}return t},iS=(e,t,n)=>{let r=new Map(e.map(e=>[e.key,e])),i=[],a=new Map,o=new Map;for(let[e,s]of t){let t=[];for(let e of s){let a=r.get(e);if(a==null)throw new wu(`Channel ${e} not found`);let o={key:e,header:n?.[e]??n?.[a.name]??a.name};i.push(o),t.push(o)}a.set(e,t),o.set(e,`,`.repeat(t.length-1))}return{columns:i,columnsByIndexKey:a,emptyGroupStrings:o}},aS=(e,t)=>{let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)e[r].time<=t[i].time?n.push(e[r++]):n.push(t[i++]);return n.push(...e.slice(r),...t.slice(i)),n},oS=1e3,sS=l.z.object({keys:l.z.number().array(),downsampleFactor:l.z.int(),throttleRate:Do.z.optional(),excludeGroups:l.z.uint32().array().optional()}),cS=l.z.object({frame:bx}),lS=l.z.object({channels:Bb,downsampleFactor:l.z.int().default(1),throttleRate:Do.z.default(new Do(0)),useHighPerformanceCodec:l.z.boolean().default(!0),excludeGroups:l.z.uint32().array().default([])}),uS=lS.or(Bb.transform(e=>lS.parse({channels:e}))),dS=(e,t)=>async n=>{let r=uS.parse(n),i=await Gx.open(e,r.channels);r.useHighPerformanceCodec&&(t=t.withCodec(new Wx(i.codec)));let a=await t.stream(`/frame/stream`,sS,cS),o=new pS(a,i,r.downsampleFactor,r.throttleRate,r.excludeGroups);a.send({keys:Array.from(i.keys),downsampleFactor:r.downsampleFactor,throttleRate:r.throttleRate,excludeGroups:r.excludeGroups});let[,s]=await a.receive();if(s!=null)throw s;return o},fS=async(e,t,n)=>await dS(e,t)(n),pS=class{stream;adapter;downsampleFactor;throttleRate;excludeGroups;constructor(e,t,n=1,r=new Do(0),i=[]){this.stream=new qx(`Streamer`,e),this.adapter=t,this.downsampleFactor=n,this.throttleRate=r,this.excludeGroups=i}get keys(){return Array.from(this.adapter.keys)}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(br.matches(e))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:Array.from(this.adapter.keys),downsampleFactor:this.downsampleFactor,throttleRate:this.throttleRate,excludeGroups:this.excludeGroups})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}},mS=class e{wrapped_=null;breaker;opener;config;constructor(e,t,n={}){this.opener=e,this.config=uS.parse(t);let{maxRetries:r=5e3,baseInterval:i=O.seconds(1),scale:a=1}=n??{};this.breaker=new fs.Breaker({maxRetries:r,baseInterval:i,scale:a})}static async open(t,n,r){let i=new e(t,n,r);return await i.runStreamer(),i}async runStreamer(){for(;;)try{this.wrapped_!=null&&this.wrapped_.close(),this.wrapped_=await this.opener(this.config),this.breaker.reset();return}catch(e){if(this.wrapped_=null,!await this.breaker.wait())throw e;console.error(`failed to open streamer`,e);continue}}get wrapped(){if(this.wrapped_==null)throw Error(`stream closed`);return this.wrapped_}async update(e){this.config.channels=Bb.parse(e);try{await this.wrapped.update(e)}catch{return await this.runStreamer(),await this.update(e)}}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(br.matches(e))return{done:!0,value:void 0};throw e}}async read(){try{let e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(br.matches(e))throw e;return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}},hS=class extends Tl.Observer{streamer;closePromise;constructor(e,t){super(t),this.streamer=e,this.closePromise=this.stream()}async update(e){await this.streamer.update(e)}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(let e of this.streamer)this.notify(e)}},gS=function(e){return e[e.PersistStream=1]=`PersistStream`,e[e.Persist=2]=`Persist`,e[e.Stream=3]=`Stream`,e}({}),_S=new O(-1),vS=class extends yu.sub(`writer_closed`){constructor(){super(`WriterClosed`)}},yS=l.z.enum(gS).or(l.z.enum([`persist`,`stream`,`persistStream`]).transform(e=>{switch(e){case`persist`:return gS.Persist;case`stream`:return gS.Stream;case`persistStream`:return gS.PersistStream}})),bS=l.z.object({start:D.z.optional(),controlSubject:F.subjectZ.optional(),authorities:l.z.union([F.authorityZ.transform(e=>[e]),F.authorityZ.array()]).default([F.ABSOLUTE_AUTHORITY]),mode:yS.default(gS.PersistStream),errOnUnauthorized:l.z.boolean().default(!1),enableAutoCommit:l.z.boolean().default(!0),autoIndexPersistInterval:O.z.default(O.SECOND),useHighPerformanceCodec:l.z.boolean().default(!0)}),xS=bS.extend({keys:Z.array().optional()}),SS=bS.extend({channels:Bb}),CS=SS.or(Bb.transform(e=>SS.parse({channels:e,start:D.now()}))),wS=l.z.object({command:l.z.enum(Cx),config:xS.optional(),frame:bx.optional(),buffer:l.z.instanceof(Uint8Array).optional()}),TS=l.z.object({command:l.z.enum(Cx),end:D.z,err:Zc.payloadZ.optional()}),ES=l.z.tuple([l.z.union([l.z.record(Z.or(nb),F.authorityZ),Z.or(nb),F.authorityZ]),F.authorityZ.optional()]).transform(([e,t])=>{if(F.authorityZ.safeParse(e).success)return{keys:[],authorities:[e]};if(Z.or(nb).safeParse(e).success){if(t==null)throw Error(`authority is required when setting authority for a single channel`);return{keys:[e],authorities:[t]}}let n=e;return{keys:Object.keys(n),authorities:Object.values(n)}}),DS=class e{stream;adapter;closeErr=null;constructor(e,t){this.stream=e,this.adapter=t}static async _open(t,n,r){let i=CS.parse(r),a=await Kx.open(t,i.channels);i.useHighPerformanceCodec&&(n=n.withCodec(new Ux(a.codec)));let o=new e(await n.stream(`/frame/write`,wS,TS),a);return await o.execute({command:Cx.Open,config:{...i,keys:a.keys}}),o}async write(e,t){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();let n=await this.adapter.adapt(e,t);this.stream.send({command:Cx.Write,frame:n.toPayload()})}async setAuthority(e,t){if(this.closeErr!=null)throw this.closeErr;let n=ES.parse([e,t]),r={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Cx.SetAuthority,config:r})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),D.ZERO):(await this.execute({command:Cx.Commit})).end}async close(){await this.closeInternal(null)}async closeInternal(e){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=e,this.stream.closeSend();;){if(this.closeErr!=null){if(vS.matches(this.closeErr))return null;throw this.closeErr}let[e,t]=await this.stream.receive();t==null?this.closeErr=Zc.decode(e?.err):this.closeErr=br.matches(t)?new vS:t}}async execute(e){let t=this.stream.send(e);for(t!=null&&await this.closeInternal(t);;){let[t,n]=await this.stream.receive();n!=null&&await this.closeInternal(n);let r=Zc.decode(t?.err);if(r!=null&&await this.closeInternal(r),t?.command==e.command)return t}}},OS=z(`framer`),kS=OS(``),AS=class{streamClient;retriever;deleter;reader;constructor(e,t,n){this.streamClient=e,this.retriever=n,this.deleter=new _x(t),this.reader=new tS(n,e)}async openIterator(e,t,n){return await $x._open(e,t,this.retriever,this.streamClient,n)}async openWriter(e){return await DS._open(this.retriever,this.streamClient,e)}async openStreamer(e){return await fS(this.retriever,this.streamClient,e)}async write(e,t,n){if(n==null){let n=t,r=await this.openWriter({start:e,channels:Object.keys(n),mode:gS.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:O.MAX});return await r.write(n),await r.close()}let r=await this.openWriter({start:e,channels:t,mode:gS.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:O.MAX});await r.write(t,n),await r.close()}async read(e,t){if(!(`start`in e))return this.reader.read(e);let{single:n}=gb(t),r=await this.readFrame(e,t);return n?r.get(t):r}async readFrame(e,t){let n=await this.openIterator(e,t),r=new $;try{for await(let e of n)r.push(e)}finally{await n.close()}return r}async readLatest(e,t=1){let{single:n}=gb(e),r=await this.readLatestNFrame(e,t);return n?r.get(e):r}async readLatestNFrame(e,t){let n=await this.openIterator(A.MAX,e,{chunkSize:t}),r=new $;if(t>0)try{await n.seekLast(),await n.prev(Jx),r.push(n.value)}finally{await n.close()}return r}async delete(e,t){let{normalized:n,variant:r}=gb(e),i=new A(t);return r===`keys`?await this.deleter.delete({keys:n,bounds:i}):await this.deleter.delete({names:n,bounds:i})}},jS=o({ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:()=>_S,AUTO_SPAN:()=>Jx,Client:()=>AS,Frame:()=>$,HardenedStreamer:()=>mS,Iterator:()=>$x,ObservableStreamer:()=>hS,Reader:()=>tS,TYPE_ONTOLOGY_ID:()=>kS,Writer:()=>DS,WriterClosedError:()=>vS,WriterCommand:()=>Cx,WriterMode:()=>gS,createStreamOpener:()=>dS,frameZ:()=>bx,ontologyID:()=>OS,openStreamer:()=>fS,seriesFromPayload:()=>xx,seriesToPayload:()=>Sx,streamerConfigZ:()=>uS,writerCommandZ:()=>wx,writerConfigZ:()=>CS}),MS=F.ABSOLUTE_AUTHORITY,NS=F.ZERO_AUTHORITY,PS=F.stateZ(l.z.number()),FS=e=>{let t=e.from?.resource,n=e.to?.resource;return e.to==null?`${t} - ${e.from?.subject.name} -> released`:e.from==null?`${n} - released -> ${e.to.subject.name} (${e.to.authority.toString()})`:`${n} - ${e.from.subject.name} -> ${e.to.subject.name} (${e.to.authority.toString()})`},IS=l.z.object({transfers:l.z.array(F.transferZ(Z))}),LS=class extends hS{states;codec;constructor(e){super(e,e=>{let t=this.codec.decode(e.series[0].buffer,IS);return this.merge(t),[t.transfers,!0]}),this.states=new Map,this.codec=new ai.JSONCodec}subjects(){let e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(e=>{e.from==null&&e.to==null&&console.warn(`Invalid transfer: `,e),e.to==null?this.states.delete(e.from.resource):this.states.set(e.to.resource,e.to)})}},RS=`sy_node_1_control`,zS=class{framer;constructor(e){this.framer=e}async openStateTracker(){return new LS(await mS.open(async e=>await this.framer.openStreamer(e),RS))}},BS=o({ABSOLUTE_AUTHORITY:()=>MS,CONTROL_STATE_CHANNEL_NAME:()=>RS,Client:()=>zS,StateTracker:()=>LS,ZERO_AUTHORITY:()=>NS,stateZ:()=>PS,transferString:()=>FS}),VS=l.z.uint32(),HS=l.z.object({rack:VS}),US=cu.statusZ({details:HS}),WS=l.z.object({key:VS,name:l.z.string().min(1,`Name is required`),taskCounter:l.z.uint32().optional(),embedded:l.z.boolean().optional(),status:US.optional(),integrations:N.nullToUndefined(l.z.string().array())}),GS=WS.omit({taskCounter:!0,embedded:!0,key:!0}).extend({key:l.z.uint32().default(0)}),KS=z(`rack`),qS=KS(0),JS=`sy_rack_set`,YS=`sy_rack_delete`,XS=l.z.object({keys:VS.array().optional(),names:l.z.string().array().optional(),integration:l.z.string().optional(),searchTerm:l.z.string().optional(),embedded:l.z.boolean().optional(),hostIsNode:l.z.boolean().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeStatus:l.z.boolean().optional()}),ZS=l.z.object({racks:w.nullishToEmpty(WS)}),QS=WS,$S=l.z.union([l.z.object({key:VS,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),l.z.object({name:l.z.string(),includeStatus:l.z.boolean().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t}))]),eC=XS,tC=l.z.union([$S,eC]),nC=l.z.object({racks:GS.array()}),rC=l.z.object({racks:WS.array()}),iC=l.z.object({keys:VS.array()}),aC=l.z.object({}),oC=class{client;tasks;constructor(e,t){this.client=e,this.tasks=t}async delete(e){await S(this.client,`/rack/delete`,{keys:w.toArray(e)},iC,aC)}async create(e){let t=!Array.isArray(e),n=await S(this.client,`/rack/create`,{racks:w.toArray(e)},nC,rC),r=this.sugar(n.racks);return t?r[0]:r}async retrieve(e){let t=`key`in e||`name`in e,n=await S(this.client,`/rack/retrieve`,e,tC,ZS),r=this.sugar(n.racks);return X(`Rack`,e,r,t),t?r[0]:r}sugar(e){let t=!Array.isArray(e),n=w.toArray(e).map(({key:e,name:t,status:n,integrations:r})=>new sC(e,t,this.tasks,n,r));return t?n[0]:n}},sC=class{key;name;status;integrations;tasks;constructor(e,t,n,r,i){this.key=e,this.name=t,this.tasks=n,this.status=r,this.integrations=i}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async createTask(e,t){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&4294967295n)).toString(),await this.tasks.create(e,t)}async deleteTask(e){await this.tasks.delete([e])}get payload(){return{key:this.key,name:this.name,status:this.status,integrations:this.integrations}}},cC=e=>Ru(KS(e)),lC=o({Client:()=>oC,DELETE_CHANNEL_NAME:()=>YS,Rack:()=>sC,SET_CHANNEL_NAME:()=>JS,TYPE_ONTOLOGY_ID:()=>qS,keyZ:()=>VS,newZ:()=>GS,ontologyID:()=>KS,payloadZ:()=>WS,rackZ:()=>QS,statusDetailsZ:()=>HS,statusKey:()=>cC,statusZ:()=>US}),uC=l.z.object({rack:VS,device:l.z.string()}),dC=l.z.string(),fC=cu.statusZ({details:uC}),pC=({properties:e,make:t,model:n}={})=>l.z.object({key:dC,rack:VS,location:l.z.string().min(1,`Location is required`),make:t??l.z.string().min(1,`Make is required`),model:n??l.z.string().min(1,`Model is required`),name:l.z.string().min(1,`Name is required`),configured:l.z.boolean().default(!1),properties:e??I.nullishToEmpty(),status:fC.optional(),parent:R.optional()}),mC=({properties:e,make:t,model:n}={})=>pC({properties:e,make:t,model:n}).partial({key:!0,configured:!0}),hC=z(`device`),gC=hC(``),_C=`sy_device_set`,vC=`sy_device_delete`,yC=e=>l.z.object({devices:N.toArray(mC(e))}),bC=e=>l.z.object({devices:pC(e).array()}),xC=l.z.object({keys:dC.array()}),SC=l.z.object({}),CC=l.z.object({keys:dC.array().optional(),names:l.z.string().array().optional(),makes:l.z.string().array().optional(),models:l.z.string().array().optional(),locations:l.z.string().array().optional(),racks:VS.array().optional(),searchTerm:l.z.string().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeStatus:l.z.boolean().optional(),includeParent:l.z.boolean().optional()}),wC=e=>l.z.object({devices:w.nullishToEmpty(pC(e))}),TC=l.z.object({key:dC,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),EC=l.z.union([TC,CC]),DC=class{client;constructor(e){this.client=e}async retrieve(e){let{schemas:t,...n}=e,r=typeof n==`object`&&`key`in n,i=await S(this.client,`/device/retrieve`,n,EC,wC(t));return X(`Device`,n,i.devices,r),r?i.devices[0]:i.devices}async create(e,t){let n=!Array.isArray(e),r=await S(this.client,`/device/create`,{devices:w.toArray(e)},yC(t),bC(t));return n?r.devices[0]:r.devices}async delete(e){await S(this.client,`/device/delete`,{keys:w.toArray(e)},xC,SC)}},OC=e=>Ru(hC(e)),kC=o({Client:()=>DC,DELETE_CHANNEL_NAME:()=>vC,SET_CHANNEL_NAME:()=>_C,TYPE_ONTOLOGY_ID:()=>gC,deviceZ:()=>pC,keyZ:()=>dC,newZ:()=>mC,ontologyID:()=>hC,statusDetailsZ:()=>uC,statusKey:()=>OC,statusZ:()=>fC}),AC=fl.keyZ,jC=fl.labelZ,MC=fl.newZ,NC=`labeled_by`,PC=`sy_label_set`,FC=`sy_label_delete`,IC=l.default.object({labels:MC.array()}),LC=l.default.object({labels:jC.array()}),RC=l.default.object({keys:AC.array()}),zC=l.default.object({id:R,labels:AC.array(),replace:l.default.boolean().optional()}),BC=zC.omit({replace:!0}),VC=l.default.object({}),HC=l.default.object({keys:AC.array().optional(),names:l.default.string().array().optional(),for:R.optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional()}),UC=l.default.object({key:AC}).transform(({key:e})=>({keys:[e]})),WC=l.default.union([UC,HC]),GC=l.default.object({labels:w.nullishToEmpty(jC)}),KC=class{type=`label`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await S(this.client,`/label/retrieve`,e,WC,GC);return X(`Label`,e,n.labels,t),t?n.labels[0]:n.labels}async label(e,t,n={}){await S(this.client,`/label/set`,{id:e,labels:t,replace:n.replace},zC,VC)}async remove(e,t){await S(this.client,`/label/remove`,{id:e,labels:t},BC,VC)}async create(e){let t=Array.isArray(e),n=await S(this.client,`/label/create`,{labels:w.toArray(e)},IC,LC);return t?n.labels:n.labels[0]}async delete(e){await S(this.client,`/label/delete`,{keys:w.toArray(e)},RC,VC)}},qC=z(`label`),JC=qC(``),YC=o({Client:()=>KC,DELETE_CHANNEL_NAME:()=>FC,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:()=>NC,SET_CHANNEL_NAME:()=>PC,TYPE_ONTOLOGY_ID:()=>JC,keyZ:()=>AC,labelZ:()=>jC,newZ:()=>MC,ontologyID:()=>qC}),XC=l.z.uuid(),ZC=l.z.object({key:XC,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty())}),QC=ZC.partial({key:!0}),$C=z(`lineplot`),ew=$C(``),tw=l.z.uuid(),nw=l.z.object({key:tw,name:l.z.string().min(1,`Name is required`),author:l.z.uuid().optional(),layout:Hr.preserveCase(I.nullishToEmpty())}),rw=nw.omit({author:!0}).partial({key:!0}),iw=z(`workspace`),aw=iw(``),ow=l.z.object({keys:tw.array().optional(),searchTerm:l.z.string().optional(),author:Ad.optional(),offset:l.z.int().optional(),limit:l.z.int().optional()}),sw=l.z.object({workspaces:rw.array()}),cw=l.z.object({key:tw,name:l.z.string()}),lw=l.z.object({key:tw,layout:Hr.preserveCase(I.unknownZ())}),uw=l.z.object({keys:tw.array()}),dw=l.z.object({workspaces:w.nullishToEmpty(nw)}),fw=l.z.object({workspaces:nw.array()}),pw=l.z.object({}),mw=`sy_workspace_set`,hw=`sy_workspace_delete`,gw=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await S(this.client,`/workspace/create`,{workspaces:w.toArray(e)},sw,fw);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await S(this.client,`/workspace/rename`,{key:e,name:t},cw,pw)}async setLayout(e,t){await S(this.client,`/workspace/set-layout`,{key:e,layout:t},lw,pw)}async retrieve(e){let t,n=typeof e!=`string`;t=typeof e==`string`||Array.isArray(e)?{keys:w.toArray(e)}:e;let r=await S(this.client,`/workspace/retrieve`,t,ow,dw);return n?r.workspaces:r.workspaces[0]}async delete(e){await S(this.client,`/workspace/delete`,{keys:w.toArray(e)},uw,pw)}},_w=o({Client:()=>gw,DELETE_CHANNEL_NAME:()=>hw,SET_CHANNEL_NAME:()=>mw,TYPE_ONTOLOGY_ID:()=>aw,keyZ:()=>tw,newZ:()=>rw,ontologyID:()=>iw,workspaceZ:()=>nw}),vw=l.z.object({key:XC,name:l.z.string()}),yw=l.z.object({key:XC,data:Hr.preserveCase(I.unknownZ())}),bw=l.z.object({keys:XC.array()}),xw=l.z.object({keys:XC.array()}),Sw=l.z.object({key:XC}).transform(({key:e})=>({keys:[e]})),Cw=l.z.union([Sw,xw]),ww=l.z.object({linePlots:w.nullishToEmpty(ZC)}),Tw=l.z.object({workspace:tw,linePlots:QC.array()}),Ew=l.z.object({linePlots:ZC.array()}),Dw=l.z.object({}),Ow=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/lineplot/create`,{workspace:e,linePlots:w.toArray(t)},Tw,Ew);return n?r.linePlots:r.linePlots[0]}async rename(e,t){await S(this.client,`/lineplot/rename`,{key:e,name:t},vw,Dw)}async setData(e,t){await S(this.client,`/lineplot/set-data`,{key:e,data:t},yw,Dw)}async retrieve(e){let t=Sw.safeParse(e).success,n=await S(this.client,`/lineplot/retrieve`,e,Cw,ww);return X(`LinePlot`,e,n.linePlots,t),t?n.linePlots[0]:n.linePlots}async delete(e){await S(this.client,`/lineplot/delete`,{keys:w.toArray(e)},bw,Dw)}},kw=o({Client:()=>Ow,TYPE_ONTOLOGY_ID:()=>ew,keyZ:()=>XC,linePlotZ:()=>ZC,newZ:()=>QC,ontologyID:()=>$C,retrieveArgsZ:()=>Cw}),Aw=l.z.uuid(),jw=l.z.object({key:Aw,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty())}),Mw=jw.partial({key:!0}),Nw=z(`log`),Pw=Nw(``),Fw=l.z.object({key:Aw,name:l.z.string()}),Iw=l.z.object({key:Aw,data:Hr.preserveCase(I.unknownZ())}),Lw=l.z.object({keys:Aw.array()}),Rw=l.z.object({keys:Aw.array()}),zw=l.z.object({key:Aw}).transform(({key:e})=>({keys:[e]})),Bw=l.z.union([zw,Rw]),Vw=l.z.object({logs:w.nullishToEmpty(jw)}),Hw=l.z.object({workspace:tw,logs:Mw.array()}),Uw=l.z.object({logs:jw.array()}),Ww=l.z.object({}),Gw=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/log/create`,{workspace:e,logs:w.toArray(t)},Hw,Uw);return n?r.logs:r.logs[0]}async rename(e,t){await S(this.client,`/log/rename`,{key:e,name:t},Fw,Ww)}async setData(e,t){await S(this.client,`/log/set-data`,{key:e,data:t},Iw,Ww)}async retrieve(e){let t=zw.safeParse(e).success,n=await S(this.client,`/log/retrieve`,e,Bw,Vw);return X(`Log`,e,n.logs,t),t?n.logs[0]:n.logs}async delete(e){await S(this.client,`/log/delete`,{keys:w.toArray(e)},Lw,Ww)}},Kw=o({Client:()=>Gw,TYPE_ONTOLOGY_ID:()=>Pw,keyZ:()=>Aw,logZ:()=>jw,newZ:()=>Mw,ontologyID:()=>Nw,retrieveArgsZ:()=>Bw}),qw=l.z.object({range:Q,aliases:l.z.string().array()}),Jw=l.z.object({aliases:l.z.record(l.z.string(),Z)}),Yw=l.z.object({range:Q,aliases:l.z.record(Z,l.z.string())}),Xw=l.z.unknown(),Zw=l.z.object({range:Q,channels:Z.array()}),Qw=l.z.unknown(),$w=l.z.object({range:Q}),eT=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),tT=l.z.object({range:Q,channels:Z.array()}),nT=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),rT=class{cache=new Map;client;rangeKey;constructor(e,t){this.rangeKey=e,this.cache=new Map,this.client=t}async resolve(e){let t=[],n=typeof e==`string`,r={};if(n){let n=this.cache.get(e);if(n!=null)return n;t.push(e)}else e.forEach(e=>{let n=this.cache.get(e);n==null?t.push(e):r[e]=n});if(t.length===0)return r;let i=await S(this.client,`/range/alias/resolve`,{range:this.rangeKey,aliases:t},qw,Jw);return Object.entries(i.aliases).forEach(([e,t])=>this.cache.set(e,t)),n?i.aliases[t[0]]:{...r,...i.aliases}}async set(e){await S(this.client,`/range/alias/set`,{range:this.rangeKey,aliases:e},Yw,Xw)}async list(){return(await S(this.client,`/range/alias/list`,{range:this.rangeKey},$w,eT)).aliases}async retrieve(e){let t=typeof e==`number`,n=await S(this.client,`/range/alias/retrieve`,{range:this.rangeKey,channels:w.toArray(e)},tT,nT);return t?n.aliases[e]:n.aliases}async delete(e){await S(this.client,`/range/alias/delete`,{range:this.rangeKey,channels:w.toArray(e)},Zw,Qw)}},iT=`sy_range_alias_set`,aT=`sy_range_alias_delete`,oT=`---`,sT=e=>`${e.range}${oT}${e.channel}`,cT=(e,t)=>({type:`range-alias`,key:sT({range:e,channel:t})}),lT={type:`range-alias`,key:``},uT=e=>{let[t,n]=e.split(oT);return{range:t,channel:Number(n)}},dT=iT,fT=aT,pT=sT,mT=uT,hT=l.z.object({range:Q,channel:Z,alias:l.z.string()}),gT=o({Client:()=>rT,DELETE_ALIAS_CHANNEL_NAME:()=>fT,DELETE_CHANNEL_NAME:()=>aT,SET_ALIAS_CHANNEL_NAME:()=>dT,SET_CHANNEL_NAME:()=>iT,TYPE_ONTOLOGY_ID:()=>lT,aliasKey:()=>pT,aliasZ:()=>hT,createKey:()=>sT,decodeDeleteAliasChange:()=>mT,decodeDeleteChange:()=>uT,ontologyID:()=>cT}),_T=`sy_range_set`,vT=`sy_range_delete`,yT=class{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:t=A.ZERO,key:n,color:r,parent:i,labels:a},{frameClient:o,kv:s,aliaser:c,channels:l,labelClient:u,ontologyClient:d,rangeClient:f}){this.key=n,this.name=e,this.timeRange=t,this.parent=i,this.labels=a,this.frameClient=o,this.color=r,this.kv=s,this.aliaser=c,this.channels=l,this.labelClient=u,this.ontologyClient=d,this.rangeClient=f}get ontologyID(){return fb(this.key)}get payload(){let e={key:this.key,name:this.name,timeRange:this.timeRange,color:this.color,labels:this.labels};return this.parent!=null&&(`payload`in this.parent?e.parent=this.parent.payload:e.parent=this.parent),e}async setAlias(e,t){let n=await this.channels.retrieve(e);if(n.length===0)throw new Tu(`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 resolveAlias(e){return await this.aliaser.resolve(e)}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){let e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:[`range`]})).map(e=>e.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async retrieveLabels(){return await this.labelClient.retrieve({for:fb(this.key)})}async addLabel(...e){await this.labelClient.label(fb(this.key),e)}async removeLabel(...e){await this.labelClient.remove(fb(this.key),e)}static sort(e,t){return A.sort(e.timeRange,t.timeRange)}},bT=l.z.object({keys:Q.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),overlapsWith:A.z.optional(),hasLabels:AC.array().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeLabels:l.z.boolean().optional(),includeParent:l.z.boolean().optional()}).or(Q.array().transform(e=>({keys:e}))).or(Q.transform(e=>({keys:[e]}))).or(l.z.string().transform(e=>({names:[e]}))).or(l.z.string().array().transform(e=>({names:e}))).or(A.z.transform(e=>({overlapsWith:e}))),xT=l.z.object({ranges:w.nullishToEmpty(ub)}),ST=class{type=`range`;frameClient;writer;unaryClient;channels;labelClient;ontologyClient;createAliasClient;createKVClient;constructor(e,t,n,r,i,a,o,s){this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=r,this.labelClient=i,this.ontologyClient=a,this.createAliasClient=o,this.createKVClient=s}async create(e,t){let n=!Array.isArray(e),r=this.sugarMany(await this.writer.create(w.toArray(e),t));return n?r[0]:r}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(w.toArray(e))}async retrieve(e){let t=typeof e==`string`,{ranges:n}=await S(this.unaryClient,`/range/retrieve`,e,bT,xT);return X(`Range`,e,n,t),t?this.sugarMany(n)[0]:this.sugarMany(n)}getKV(e){return this.createKVClient(e)}async retrieveParent(e){let t=await this.ontologyClient.retrieveParents(fb(e));if(t.length===0)return null;let n=t[0];return n.id.type===`range`?await this.retrieve(n.id.key):null}sugarOntologyResource(e){return this.sugarOne(wT(e))}async retrieveAlias(e,t){return await this.createAliasClient(e).retrieve(t)}async retrieveAliases(e,t){return await this.createAliasClient(e).retrieve(t)}async listAliases(e){return await this.createAliasClient(e).list()}async setAlias(e,t,n){await this.createAliasClient(e).set({[t]:n})}async deleteAlias(e,t){await this.createAliasClient(e).delete(t)}sugarOne(e){return new yT(e,{frameClient:this.frameClient,kv:this.createKVClient(e.key),aliaser:this.createAliasClient(e.key),channels:this.channels,labelClient:this.labelClient,ontologyClient:this.ontologyClient,rangeClient:this})}sugarMany(e){return e.map(e=>this.sugarOne(e))}resourceToRange(e){return this.sugarOne(wT(e))}},CT=e=>({type:`range-alias`,key:e}),wT=({data:e,id:{key:t},name:n})=>{let r=A.z.parse(e?.timeRange),i=Nc.colorZ.safeParse(e?.color);return{key:t,name:n,timeRange:r,color:i.success?i.data:void 0,labels:[],parent:void 0}},TT=l.z.object({range:Q,key:l.z.string(),value:l.z.string()}),ET=l.z.object({range:Q,keys:l.z.string().array()}),DT=l.z.object({pairs:w.nullishToEmpty(TT)}),OT=l.z.object({range:Q,pairs:TT.array()}),kT=l.z.object({range:Q,keys:l.z.string().array()}),AT=class{rangeKey;client;constructor(e,t){this.rangeKey=e,this.client=t}async get(e){let t=await S(this.client,`/range/kv/get`,{range:this.rangeKey,keys:w.toArray(e)},ET,DT);return typeof e==`string`?t.pairs[0].value:Object.fromEntries(t.pairs.map(e=>[e.key,e.value]))}async list(){return this.get([])}async set(e,t=``){let n;n=typeof e==`string`?[{range:this.rangeKey,key:e,value:t}]:Object.entries(e).map(([e,t])=>({range:this.rangeKey,key:e,value:t})),await S(this.client,`/range/kv/set`,{range:this.rangeKey,pairs:n},OT,l.z.unknown())}async delete(e){await S(this.client,`/range/kv/delete`,{range:this.rangeKey,keys:w.toArray(e)},kT,l.z.unknown())}},jT=`sy_range_kv_set`,MT=`sy_range_kv_delete`,NT=({range:e,key:t})=>`${e}<--->${t}`,PT=jT,FT=MT,IT=TT,LT=NT,RT=o({Client:()=>AT,DELETE_CHANNEL_NAME:()=>MT,KV_DELETE_CHANNEL:()=>FT,KV_SET_CHANNEL:()=>PT,SET_CHANNEL_NAME:()=>jT,createPairKey:()=>NT,kvPairKey:()=>LT,kvPairZ:()=>IT,pairZ:()=>TT}),zT=l.z.string().min(1),BT=l.z.object({ranges:ub.array()}),VT=l.z.object({parent:R.optional(),ranges:db.array()}),HT=l.z.object({keys:Q.array()}),UT=l.z.object({}),WT=l.z.object({key:Q,name:zT}),GT=l.z.object({}),KT=class{client;constructor(e){this.client=e}async rename(e,t){await S(this.client,`/range/rename`,{key:e,name:t},WT,GT)}async create(e,t){return(await S(this.client,`/range/create`,{ranges:e,...t},VT,BT)).ranges}async delete(e){await S(this.client,`/range/delete`,{keys:e},HT,UT)}},qT=o({Client:()=>ST,DELETE_ALIAS_CHANNEL_NAME:()=>aT,DELETE_CHANNEL_NAME:()=>vT,KV_DELETE_CHANNEL:()=>MT,KV_SET_CHANNEL:()=>jT,Range:()=>yT,SET_ALIAS_CHANNEL_NAME:()=>iT,SET_CHANNEL_NAME:()=>_T,TYPE_ONTOLOGY_ID:()=>pb,Writer:()=>KT,alias:()=>gT,aliasKey:()=>sT,aliasOntologyID:()=>CT,apiRangeZ:()=>lb,baseZ:()=>cb,convertOntologyResourceToPayload:()=>wT,decodeDeleteAliasChange:()=>uT,keyZ:()=>Q,kv:()=>RT,kvPairKey:()=>NT,nameZ:()=>zT,newZ:()=>db,ontologyID:()=>fb,payloadZ:()=>ub}),JT=l.z.object({key:l.z.string(),name:l.z.string(),selectors:w.nullishToEmpty(l.z.string()),strokeColor:l.z.string().optional(),fillColor:l.z.string().optional()}),YT=l.z.object({key:l.z.string(),position:xo.xyZ,orientation:xo.outerLocationZ}),XT=l.z.object({zoom:l.z.number().default(1),position:xo.xyZ}),ZT=l.z.uuid(),QT=l.z.object({key:l.z.string(),name:l.z.string(),regions:w.nullishToEmpty(JT)}),$T=l.z.object({svg:l.z.string().min(1),states:w.nullishToEmpty(QT),variant:l.z.string().min(1),handles:w.nullishToEmpty(YT),scale:l.z.number().default(1),scaleStroke:l.z.boolean().default(!1),previewViewport:XT.optional()}),eE=l.z.object({key:ZT,version:l.z.uint32().default(1),name:l.z.string().min(1),data:$T}),tE=l.z.object({key:ZT.optional(),version:l.z.uint32().default(1),name:l.z.string().min(1),data:$T}),nE=z(`schematic_symbol`),rE=nE(``),iE=l.z.object({symbols:tE.array(),parent:R}),aE=l.z.object({key:ZT,name:l.z.string()}),oE=l.z.object({keys:ZT.array()}),sE=l.z.object({keys:ZT.array().optional(),searchTerm:l.z.string().optional()}),cE=l.z.object({key:ZT}).transform(({key:e})=>({keys:[e]})),lE=l.z.union([cE,sE]),uE=l.z.object({symbols:w.nullishToEmpty(eE)}),dE=l.z.object({symbols:eE.array()}),fE=l.z.object({}),pE=l.z.object({}),mE=l.z.object({group:Sb}),hE=`sy_schematic_symbol_set`,gE=`sy_schematic_symbol_delete`,_E=class{client;constructor(e){this.client=e}async create(e){let t=`symbols`in e,n=t?e.symbols:[e],r=await S(this.client,`/schematic/symbol/create`,{symbols:n,parent:e.parent},iE,dE);return t?r.symbols:r.symbols[0]}async rename(e,t){await S(this.client,`/schematic/symbol/rename`,{key:e,name:t},aE,fE)}async retrieve(e){let t=`key`in e,n=await S(this.client,`/schematic/symbol/retrieve`,e,lE,uE);return X(`Schematic Symbol`,e,n.symbols,t),t?n.symbols[0]:n.symbols}async delete(e){await S(this.client,`/schematic/symbol/delete`,{keys:w.toArray(e)},oE,fE)}async retrieveGroup(){return(await S(this.client,`/schematic/symbol/retrieve-group`,{},pE,mE)).group}},vE=o({Client:()=>_E,DELETE_CHANNEL_NAME:()=>gE,SET_CHANNEL_NAME:()=>hE,TYPE_ONTOLOGY_ID:()=>rE,handleZ:()=>YT,keyZ:()=>ZT,newZ:()=>tE,ontologyID:()=>nE,regionZ:()=>JT,specZ:()=>$T,stateZ:()=>QT,symbolZ:()=>eE,viewportZ:()=>XT}),yE=l.z.uuid(),bE=l.z.object({key:yE,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty()),snapshot:l.z.boolean()}),xE=bE.partial({key:!0,snapshot:!0}),SE=z(`schematic`),CE=SE(``),wE=l.z.object({key:yE,name:l.z.string()}),TE=l.z.object({key:yE,data:Hr.preserveCase(I.unknownZ())}),EE=l.z.object({keys:yE.array()}),DE=l.z.object({key:yE,name:l.z.string(),snapshot:l.z.boolean()}),OE=l.z.object({keys:yE.array()}),kE=l.z.object({key:yE}).transform(({key:e})=>({keys:[e]})),AE=l.z.union([kE,OE]),jE=l.z.object({schematics:bE.array()}),ME=l.z.object({workspace:tw,schematics:xE.array()}),NE=l.z.object({schematics:bE.array()}),PE=l.z.object({schematic:bE}),FE=l.z.object({}),IE=class{symbols;client;constructor(e){this.client=e,this.symbols=new _E(e)}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/schematic/create`,{workspace:e,schematics:w.toArray(t)},ME,NE);return n?r.schematics:r.schematics[0]}async rename(e,t){await S(this.client,`/schematic/rename`,{key:e,name:t},wE,FE)}async setData(e,t){await S(this.client,`/schematic/set-data`,{key:e,data:t},TE,FE)}async retrieve(e){let t=kE.safeParse(e).success,n=await S(this.client,`/schematic/retrieve`,e,AE,jE);return X(`Schematic`,e,n.schematics,t),t?n.schematics[0]:n.schematics}async delete(e){await S(this.client,`/schematic/delete`,{keys:w.toArray(e)},EE,FE)}async copy(e){return(await S(this.client,`/schematic/copy`,e,DE,PE)).schematic}},LE=o({Client:()=>IE,TYPE_ONTOLOGY_ID:()=>CE,keyZ:()=>yE,newZ:()=>xE,ontologyID:()=>SE,retrieveArgsZ:()=>AE,schematicZ:()=>bE,symbol:()=>vE}),RE=l.z.string(),zE=e=>cu.statusZ({details:e}),BE=e=>cu.newZ({details:e}).omit({labels:!0}),VE=`sy_status_set`,HE=`sy_status_delete`,UE=z(`status`),WE=UE(``),GE=e=>l.default.object({parent:R.optional(),statuses:BE(e).array()}),KE=e=>l.default.object({statuses:zE(e).array()}),qE=l.default.object({keys:RE.array()}),JE=l.default.object({}),YE=l.default.object({keys:RE.array().optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional(),includeLabels:l.default.boolean().optional(),hasLabels:AC.array().optional(),variants:l.default.string().array().optional()}),XE=l.default.object({key:RE,includeLabels:l.default.boolean().optional()}).transform(({key:e,includeLabels:t})=>({keys:[e],includeLabels:t})),ZE=l.default.union([XE,YE]),QE=e=>l.default.object({statuses:w.nullishToEmpty(zE(e))}),$E=class{type=`status`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await S(this.client,`/status/retrieve`,e,ZE,QE(e.detailsSchema));X(`Status`,e,n.statuses,t);let r=n.statuses;return t?r[0]:r}async set(e,t={}){let n=Array.isArray(e),r=(await S(this.client,`/status/set`,{statuses:w.toArray(e),parent:t.parent},GE(t.detailsSchema),KE(t.detailsSchema))).statuses;return n?r:r[0]}async delete(e){await S(this.client,`/status/delete`,{keys:w.toArray(e)},qE,JE)}},eD=o({Client:()=>$E,DELETE_CHANNEL_NAME:()=>HE,SET_CHANNEL_NAME:()=>VE,TYPE_ONTOLOGY_ID:()=>WE,keyZ:()=>RE,newZ:()=>BE,ontologyID:()=>UE,statusZ:()=>zE}),tD=l.z.uuid(),nD=l.z.object({key:tD,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty())}),rD=nD.partial({key:!0}),iD=z(`table`),aD=iD(``),oD=l.z.object({key:tD,name:l.z.string()}),sD=l.z.object({key:tD,data:Hr.preserveCase(I.unknownZ())}),cD=l.z.object({keys:tD.array()}),lD=l.z.object({keys:tD.array()}),uD=l.z.object({key:tD}).transform(({key:e})=>({keys:[e]})),dD=l.z.union([uD,lD]),fD=l.z.object({tables:w.nullishToEmpty(nD)}),pD=l.z.object({workspace:tw,tables:rD.array()}),mD=l.z.object({tables:nD.array()}),hD=l.z.object({}),gD=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/table/create`,{workspace:e,tables:w.toArray(t)},pD,mD);return n?r.tables:r.tables[0]}async rename(e,t){await S(this.client,`/table/rename`,{key:e,name:t},oD,hD)}async setData(e,t){await S(this.client,`/table/set-data`,{key:e,data:t},sD,hD)}async retrieve(e){let t=uD.safeParse(e).success,n=await S(this.client,`/table/retrieve`,e,dD,fD);return X(`Table`,e,n.tables,t),t?n.tables[0]:n.tables}async delete(e){await S(this.client,`/table/delete`,{keys:w.toArray(e)},cD,hD)}},_D=o({Client:()=>gD,TYPE_ONTOLOGY_ID:()=>aD,keyZ:()=>tD,newZ:()=>rD,ontologyID:()=>iD,retrieveArgsZ:()=>dD,tableZ:()=>nD}),vD=l.z.string().or(l.z.number().transform(String).or(l.z.bigint().transform(String))),yD=e=>l.z.object({task:vD,running:l.z.boolean(),cmd:l.z.string().optional(),data:e??l.z.unknown().optional()}),bD=e=>l.z.object({task:vD.optional(),running:l.z.boolean(),cmd:l.z.string().optional(),data:e??l.z.unknown().optional()}),xD=l.z.object({task:vD,type:l.z.string(),key:l.z.string(),args:Hr.preserveCase(N.nullToUndefined(I.unknownZ()))}),SD=e=>cu.statusZ({details:yD(e)}),CD=e=>cu.newZ({details:bD(e)}),wD=({type:e,config:t,statusData:n}={})=>l.z.object({key:vD,name:l.z.string(),type:e??l.z.string(),config:t??I.nullishToEmpty(),internal:l.z.boolean().optional(),snapshot:l.z.boolean().optional(),status:cu.statusZ({details:yD(n)}).optional()}),TD=({type:e,config:t,statusData:n}={})=>wD({type:e,config:t,statusData:n}).omit({internal:!0,snapshot:!0,status:!0}).partial({key:!0}).extend({status:cu.newZ({details:bD(n)}).optional()}),ED=z(`task`),DD=ED(``),OD=`sy_task_cmd`,kD=`sy_task_set`,AD=`sy_task_delete`,jD=Error(`Task not created`),MD=e=>Number(BigInt(e)>>32n),ND=(e,t=0)=>((BigInt(e)<<32n)+BigInt(t)).toString(),PD=async(e,t)=>{let n=await t.retrieveParents(ED(e));return n.length===0?null:n[0]},FD=class{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw jD;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw jD;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw jD;return this.rangeClient_}constructor({key:e,type:t,name:n,config:r,internal:i=!1,snapshot:a=!1,status:o},s,c,u,d){this.key=e,this.name=n,this.type=t,this.config=r,this.schemas=s??{type:l.z.string(),config:l.z.unknown(),statusData:l.z.unknown()},this.internal=i,this.snapshot=a,this.status=o,this.frameClient_=c,this.ontologyClient_=u,this.rangeClient_=d}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,status:this.status,internal:this.internal}}get ontologyID(){return ED(this.key)}async executeCommand(e){return await YD({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await ZD({...e,frameClient:this.frameClient,task:this.key,name:this.name,statusDataZ:this.schemas.statusData})}async start(){await this.executeCommand({type:`start`})}async stop(){await this.executeCommand({type:`stop`})}async run(e){await this.start();try{return await e()}finally{await this.stop()}}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw jD;return this.snapshot?await PD(this.key,this.ontologyClient):null}},ID=l.z.object({rack:VS.optional(),keys:vD.array().optional(),names:l.z.string().array().optional(),types:l.z.string().array().optional(),includeStatus:l.z.boolean().optional(),internal:l.z.boolean().optional(),snapshot:l.z.boolean().optional(),searchTerm:l.z.string().optional(),offset:l.z.int().optional(),limit:l.z.int().optional()}),LD=l.z.union([l.z.object({key:vD,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),l.z.object({name:l.z.string(),includeStatus:l.z.boolean().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t})),l.z.object({type:l.z.string(),rack:VS.optional()}).transform(({type:e,rack:t})=>({types:[e],rack:t}))]),RD=ID,zD=l.z.union([LD,RD]),BD=e=>l.z.object({tasks:w.nullishToEmpty(wD(e))}),VD=e=>l.z.object({tasks:TD(e).array()}),HD=e=>l.z.object({tasks:wD(e).array()}),UD=l.z.object({keys:vD.array()}),WD=l.z.object({}),GD=l.z.object({key:vD,name:l.z.string(),snapshot:l.z.boolean()}),KD=e=>l.z.object({task:wD(e)}),qD=class{client;frameClient;ontologyClient;rangeClient;constructor(e,t,n,r){this.client=e,this.frameClient=t,this.ontologyClient=n,this.rangeClient=r}async create(e,t){let n=!Array.isArray(e),r=VD(t),i=HD(t),a=await S(this.client,`/task/create`,{tasks:w.toArray(e)},r,i),o=this.sugar(a.tasks,t);return n?o[0]:o}async delete(e){await S(this.client,`/task/delete`,{keys:w.toArray(e)},UD,WD)}async retrieve({schemas:e,...t}){let n=LD.safeParse(t).success,r=(await S(this.client,`/task/retrieve`,t,zD,BD(e))).tasks,i=this.sugar(r,e);return X(`Task`,t,i,n),n?i[0]:i}async copy(e,t,n){let r=KD(),i=await S(this.client,`/task/copy`,{key:e,name:t,snapshot:n},GD,r);return this.sugar(i.task)}async list(e){let t={internal:!1};return e!==void 0&&(t.rack=e),await this.retrieve(t)}async retrieveSnapshottedTo(e){if(this.ontologyClient==null)throw jD;return await PD(e,this.ontologyClient)}sugar(e,t){let n=!Array.isArray(e),r=w.toArray(e).map(({key:e,name:n,type:r,config:i,status:a,internal:o,snapshot:s})=>new FD({key:e,name:n,type:r,config:i,internal:o,snapshot:s,status:a},t,this.frameClient,this.ontologyClient,this.rangeClient));return n?r[0]:r}async executeCommand(e){return`commands`in e?await XD({...e,frameClient:this.frameClient}):await YD({...e,frameClient:this.frameClient})}async executeCommandSync(e){if(`commands`in e){let t=async()=>{let{commands:t}=e;return(await this.retrieve({keys:t.map(e=>e.task)})).map(e=>e.name)};return await QD({...e,frameClient:this.frameClient,name:t})}return await ZD({frameClient:this.frameClient,name:async()=>{let{task:t}=e;return(await this.retrieve({key:t})).name},...e})}},JD=e=>Ru(ED(e)),YD=async({frameClient:e,task:t,type:n,args:r})=>(await XD({frameClient:e,commands:[{args:r,task:t,type:n}]}))[0],XD=async({frameClient:e,commands:t})=>{if(e==null)throw jD;let n=await e.openWriter(OD),r=t.map(e=>({...e,key:Li.create()}));return await n.write(OD,r),await n.close(),r.map(e=>e.key)},ZD=async({frameClient:e,task:t,type:n,timeout:r,name:i,statusDataZ:a,args:o})=>(await QD({frameClient:e,commands:[{args:o,task:t,type:n}],timeout:r,statusDataZ:a,name:i}))[0],QD=async({frameClient:e,commands:t,timeout:n=O.seconds(10),statusDataZ:r,name:i})=>{if(e==null)throw jD;let a=await e.openStreamer(VE),o=await XD({frameClient:e,commands:t}),s=new O(n),c=[],l,u=new Promise((e,n)=>{l=setTimeout(()=>{(async()=>{n(await $D(`command`,i,s,t.map(e=>e.task)))})()},s.milliseconds)});try{for(;;){let e=await Promise.race([a.read(),u]),t=SD(r).safeParse(e.at(-1)[VE]);if(!t.success)continue;let n=t.data;if(!(n.details.cmd==null||!o.includes(n.details.cmd))&&(c=[...c.filter(e=>e.key!==n.key),n],c.length===o.length))return c}}finally{clearTimeout(l),a.close()}},$D=async(e,t,n,r)=>{let i=Hr.capitalize(e),a=n.toString();try{let e;e=typeof t==`string`?[t]:Array.isArray(t)?t:w.toArray(await t());let n=mu.naturalLanguageJoin(e);return Error(`${i} command to ${n} timed out after ${a}`)}catch(e){return console.error(`Failed to retrieve task name for timeout error:`,e),Error(`${i} command to task with key ${mu.naturalLanguageJoin(w.toArray(r).map(e=>e.toString()))} timed out after ${a}`)}},eO=o({COMMAND_CHANNEL_NAME:()=>OD,Client:()=>qD,DELETE_CHANNEL_NAME:()=>AD,SET_CHANNEL_NAME:()=>kD,TYPE_ONTOLOGY_ID:()=>DD,Task:()=>FD,commandZ:()=>xD,keyZ:()=>vD,newKey:()=>ND,newStatusDetailsZ:()=>bD,newStatusZ:()=>CD,newZ:()=>TD,ontologyID:()=>ED,payloadZ:()=>wD,rackKey:()=>MD,statusDetailsZ:()=>yD,statusKey:()=>JD,statusZ:()=>SD}),tO=class{url;unary;stream;secure;constructor(e,t={},n=!1){this.secure=n,this.url=e.child(`/api/v1/`);let r=new ai.JSONCodec;this.unary=kr(new Or(this.url,r,this.secure),t),this.stream=new Pr(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}},nO=l.z.uuid(),rO=l.z.object({key:nO,name:l.z.string(),type:l.z.string(),query:I.nullishToEmpty()}),iO=rO.partial({key:!0}),aO=z(`view`),oO=aO(``),sO=`sy_view_set`,cO=`sy_view_delete`,lO=l.z.object({views:iO.array()}),uO=l.z.object({views:rO.array()}),dO=l.z.object({keys:nO.array()}),fO=l.z.object({}),pO=l.z.object({keys:nO.array().optional(),types:l.z.string().array().optional(),searchTerm:l.z.string().optional(),offset:l.z.number().optional(),limit:l.z.number().optional()}),mO=l.z.object({key:nO}).transform(({key:e})=>({keys:[e]})),hO=l.z.union([mO,pO]),gO=l.z.object({views:w.nullishToEmpty(rO)}),_O=class{client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await S(this.client,`/view/retrieve`,e,hO,gO);return X(`View`,e,n.views,t),t?n.views[0]:n.views}async create(e){let t=Array.isArray(e),n=await S(this.client,`/view/create`,{views:w.toArray(e)},lO,uO);return t?n.views:n.views[0]}async delete(e){await S(this.client,`/view/delete`,{keys:w.toArray(e)},dO,fO)}},vO=o({Client:()=>_O,DELETE_CHANNEL_NAME:()=>cO,SET_CHANNEL_NAME:()=>sO,TYPE_ONTOLOGY_ID:()=>oO,keyZ:()=>nO,newZ:()=>iO,ontologyID:()=>aO,viewZ:()=>rO}),yO=l.z.object({host:l.z.string({error:`Host is required`}).min(1,`Host is required`),port:l.z.number({error:`Port is required`}).or(l.z.string({error:`Port is required`})),username:l.z.string().min(1,`Username is required`),password:l.z.string().min(1,`Password is required`),connectivityPollFrequency:O.z.default(O.seconds(30)),secure:l.z.boolean().default(!1),name:l.z.string().optional(),retry:fs.breakerConfigZ.optional()}),bO=class extends AS{createdAt;params;ranges;channels;auth;users;access;connectivity;ontology;workspaces;labels;statuses;tasks;racks;devices;control;arcs;views;schematics;lineplots;logs;tables;groups;static connectivity=mx;transport;clientVersion=`0.54.0`;constructor(e){let t=yO.parse(e),{host:n,port:r,username:i,password:a,connectivityPollFrequency:o,secure:s,retry:c}=t,l=new tO(new vu({host:n,port:Number(r)}),c,s);l.use(Nu);let u=new vb(new _b(l.unary));super(l.stream,l.unary,u),this.auth=new ox(l.unary,{username:i,password:a}),l.use(this.auth.middleware());let d=new Zb(l.unary,u);this.createdAt=D.now(),this.params=t,this.transport=l,this.channels=new Rb(this,u,l.unary,d),this.connectivity=new mx(l.unary,o,this.clientVersion,t.name),this.control=new zS(this),this.ontology=new $u(this.transport.unary);let f=new KT(this.transport.unary);this.labels=new KC(this.transport.unary),this.statuses=new $E(this.transport.unary),this.ranges=new ST(this,f,this.transport.unary,u,this.labels,this.ontology,e=>new rT(e,this.transport.unary),e=>new AT(e,this.transport.unary)),this.access=new vf(this.transport.unary),this.users=new Yd(this.transport.unary),this.workspaces=new gw(this.transport.unary),this.tasks=new qD(this.transport.unary,this,this.ontology,this.ranges),this.racks=new oC(this.transport.unary,this.tasks),this.devices=new DC(this.transport.unary),this.arcs=new By(this.transport.unary,this.transport.stream),this.views=new _O(this.transport.unary),this.schematics=new IE(this.transport.unary),this.lineplots=new Ow(this.transport.unary),this.logs=new Gw(this.transport.unary),this.tables=new gD(this.transport.unary),this.groups=new jb(this.transport.unary)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}},xO=async e=>await SO(e).check(),SO=e=>{let{host:t,port:n,secure:r,name:i,retry:a}=e,o=fs.breakerConfigZ.optional().parse(a);return new mx(new tO(new vu({host:t,port:Number(n)}),o,r).unary,void 0,`0.54.0`,i)},CO={host:`localhost`,port:9090,username:`synnax`,password:`seldon`,retry:{maxRetries:4,baseInterval:O.seconds(1),scale:1.5}},wO=e=>new bO({...CO,...e}),TO=async(e,t)=>{let n=Li.create(),r=await e.users.create({username:n,password:`test`,firstName:`test`,lastName:`test`}),i=await e.access.policies.create(t),a=await e.access.roles.create({name:`test`,description:`test`});return await e.ontology.addChildren(Od(a.key),cd(i.key)),await e.access.roles.assign({user:r.key,role:a.key}),wO({username:n,password:`test`})};exports.AuthError=xu,exports.Channel=Fb,exports.ContiguityError=Mu,exports.DataType=j,exports.Density=k,exports.DisconnectedError=ju,exports.Frame=$,exports.MultiSeries=os,exports.MultipleFoundError=Du,exports.NotFoundError=Eu,exports.QueryError=Tu,exports.Rate=Do,exports.RouteError=Ou,exports.Series=Qo,exports.Synnax=bO,exports.TEST_CLIENT_PARAMS=CO,exports.TimeRange=A,exports.TimeSpan=O,exports.TimeStamp=D,exports.UnexpectedError=wu,exports.ValidationError=L,Object.defineProperty(exports,`access`,{enumerable:!0,get:function(){return bf}}),Object.defineProperty(exports,`arc`,{enumerable:!0,get:function(){return Uy}}),Object.defineProperty(exports,`channel`,{enumerable:!0,get:function(){return Qb}}),exports.checkConnection=xO,Object.defineProperty(exports,`connection`,{enumerable:!0,get:function(){return sx}}),Object.defineProperty(exports,`control`,{enumerable:!0,get:function(){return BS}}),exports.createTestClient=wO,exports.createTestClientWithPolicy=TO,Object.defineProperty(exports,`device`,{enumerable:!0,get:function(){return kC}}),Object.defineProperty(exports,`framer`,{enumerable:!0,get:function(){return jS}}),Object.defineProperty(exports,`group`,{enumerable:!0,get:function(){return Mb}}),exports.isCalculated=zb,Object.defineProperty(exports,`label`,{enumerable:!0,get:function(){return YC}}),Object.defineProperty(exports,`lineplot`,{enumerable:!0,get:function(){return kw}}),Object.defineProperty(exports,`log`,{enumerable:!0,get:function(){return Kw}}),exports.newConnectionChecker=SO,Object.defineProperty(exports,`ontology`,{enumerable:!0,get:function(){return id}}),Object.defineProperty(exports,`rack`,{enumerable:!0,get:function(){return lC}}),Object.defineProperty(exports,`ranger`,{enumerable:!0,get:function(){return qT}}),Object.defineProperty(exports,`schematic`,{enumerable:!0,get:function(){return LE}}),Object.defineProperty(exports,`status`,{enumerable:!0,get:function(){return eD}}),exports.synnaxParamsZ=yO,Object.defineProperty(exports,`table`,{enumerable:!0,get:function(){return _D}}),Object.defineProperty(exports,`task`,{enumerable:!0,get:function(){return eO}}),Object.defineProperty(exports,`user`,{enumerable:!0,get:function(){return Qd}}),Object.defineProperty(exports,`view`,{enumerable:!0,get:function(){return vO}}),Object.defineProperty(exports,`workspace`,{enumerable:!0,get:function(){return _w}});
|
|
83
|
+
`,i=new TextEncoder,a=!1,o=!1,s=rS(t),{columns:c,columnsByIndexKey:l,emptyGroupStrings:u}=iS(t,s,n),d=[],f=0,p=[],m=e=>{for(let[t]of s){let n=e.get(t);if(n.length===0)continue;let r=(l.get(t)??[]).map(t=>e.get(t.key));for(let e=0;e<n.length;e++){let i=n.at(e,!0),a=r.map(t=>Wc.formatValue(t.at(e,!0)));p.push({time:i,values:a,indexKey:t})}}},h=(e,t=!1)=>{p.length>0&&(p.sort((e,t)=>Number(e.time-t.time)),f>0&&(d=d.slice(f),f=0),d=aS(d,p),p=[]);let n=[],r=d.length;for(;f<r&&n.length<e;){let e=d[f].time;if(!t&&d[r-1].time===e)break;let i=new Map;for(;f<r&&d[f].time===e;){let e=d[f++];i.set(e.indexKey,e)}let a=[];for(let[e]of s){let t=i.get(e);a.push(t?.values.join(`,`)??u.get(e)??``)}n.push(a.join(`,`))}return n};return new ReadableStream({async pull(t){try{if(o||=(await e.seekFirst(),!0),!a){let e=c.map(e=>Wc.formatValue(e.header)).join(`,`);t.enqueue(i.encode(`${e}${r}`)),a=!0}d.length-f+p.length<oS&&await e.next()&&m(e.value);let n=h(oS);if(n.length>0&&t.enqueue(i.encode(`${n.join(r)}${r}`)),d.length-f===0||p.length===0){if(!await e.next()){let n=h(1/0,!0);n.length>0&&t.enqueue(i.encode(`${n.join(r)}${r}`)),await e.close(),t.close();return}m(e.value)}}catch(n){await e.close(),t.error(n)}},async cancel(){await e.close()}})},rS=e=>{let t=new Map;for(let n of e){if(n.index===0)continue;let e=t.get(n.index);e??(e=[n.index],t.set(n.index,e)),!n.isIndex&&!e.includes(n.key)&&e.push(n.key)}return t},iS=(e,t,n)=>{let r=new Map(e.map(e=>[e.key,e])),i=[],a=new Map,o=new Map;for(let[e,s]of t){let t=[];for(let e of s){let a=r.get(e);if(a==null)throw new wu(`Channel ${e} not found`);let o={key:e,header:n?.[e]??n?.[a.name]??a.name};i.push(o),t.push(o)}a.set(e,t),o.set(e,`,`.repeat(t.length-1))}return{columns:i,columnsByIndexKey:a,emptyGroupStrings:o}},aS=(e,t)=>{let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)e[r].time<=t[i].time?n.push(e[r++]):n.push(t[i++]);return n.push(...e.slice(r),...t.slice(i)),n},oS=1e3,sS=l.z.object({keys:l.z.number().array(),downsampleFactor:l.z.int(),throttleRate:Do.z.optional(),excludeGroups:l.z.uint32().array().optional()}),cS=l.z.object({frame:bx}),lS=l.z.object({channels:Bb,downsampleFactor:l.z.int().default(1),throttleRate:Do.z.default(new Do(0)),useHighPerformanceCodec:l.z.boolean().default(!0),excludeGroups:l.z.uint32().array().default([])}),uS=lS.or(Bb.transform(e=>lS.parse({channels:e}))),dS=(e,t)=>async n=>{let r=uS.parse(n),i=await Gx.open(e,r.channels);r.useHighPerformanceCodec&&(t=t.withCodec(new Wx(i.codec)));let a=await t.stream(`/frame/stream`,sS,cS),o=new pS(a,i,r.downsampleFactor,r.throttleRate,r.excludeGroups);a.send({keys:Array.from(i.keys),downsampleFactor:r.downsampleFactor,throttleRate:r.throttleRate,excludeGroups:r.excludeGroups});let[,s]=await a.receive();if(s!=null)throw s;return o},fS=async(e,t,n)=>await dS(e,t)(n),pS=class{stream;adapter;downsampleFactor;throttleRate;excludeGroups;constructor(e,t,n=1,r=new Do(0),i=[]){this.stream=new qx(`Streamer`,e),this.adapter=t,this.downsampleFactor=n,this.throttleRate=r,this.excludeGroups=i}get keys(){return Array.from(this.adapter.keys)}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(br.matches(e))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:Array.from(this.adapter.keys),downsampleFactor:this.downsampleFactor,throttleRate:this.throttleRate,excludeGroups:this.excludeGroups})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}},mS=class e{wrapped_=null;breaker;opener;config;constructor(e,t,n={}){this.opener=e,this.config=uS.parse(t);let{maxRetries:r=5e3,baseInterval:i=O.seconds(1),scale:a=1}=n??{};this.breaker=new fs.Breaker({maxRetries:r,baseInterval:i,scale:a})}static async open(t,n,r){let i=new e(t,n,r);return await i.runStreamer(),i}async runStreamer(){for(;;)try{this.wrapped_!=null&&this.wrapped_.close(),this.wrapped_=await this.opener(this.config),this.breaker.reset();return}catch(e){if(this.wrapped_=null,!await this.breaker.wait())throw e;console.error(`failed to open streamer`,e);continue}}get wrapped(){if(this.wrapped_==null)throw Error(`stream closed`);return this.wrapped_}async update(e){this.config.channels=Bb.parse(e);try{await this.wrapped.update(e)}catch{return await this.runStreamer(),await this.update(e)}}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(br.matches(e))return{done:!0,value:void 0};throw e}}async read(){try{let e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(br.matches(e))throw e;return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}},hS=class extends Tl.Observer{streamer;closePromise;constructor(e,t){super(t),this.streamer=e,this.closePromise=this.stream()}async update(e){await this.streamer.update(e)}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(let e of this.streamer)this.notify(e)}},gS=function(e){return e[e.PersistStream=1]=`PersistStream`,e[e.Persist=2]=`Persist`,e[e.Stream=3]=`Stream`,e}({}),_S=new O(-1),vS=class extends yu.sub(`writer_closed`){constructor(){super(`WriterClosed`)}},yS=l.z.enum(gS).or(l.z.enum([`persist`,`stream`,`persistStream`]).transform(e=>{switch(e){case`persist`:return gS.Persist;case`stream`:return gS.Stream;case`persistStream`:return gS.PersistStream}})),bS=l.z.object({start:D.z.optional(),controlSubject:F.subjectZ.optional(),authorities:l.z.union([F.authorityZ.transform(e=>[e]),F.authorityZ.array()]).default([F.ABSOLUTE_AUTHORITY]),mode:yS.default(gS.PersistStream),errOnUnauthorized:l.z.boolean().default(!1),enableAutoCommit:l.z.boolean().default(!0),autoIndexPersistInterval:O.z.default(O.SECOND),useHighPerformanceCodec:l.z.boolean().default(!0)}),xS=bS.extend({keys:Z.array().optional()}),SS=bS.extend({channels:Bb}),CS=SS.or(Bb.transform(e=>SS.parse({channels:e,start:D.now()}))),wS=l.z.object({command:l.z.enum(Cx),config:xS.optional(),frame:bx.optional(),buffer:l.z.instanceof(Uint8Array).optional()}),TS=l.z.object({command:l.z.enum(Cx),end:D.z,err:Zc.payloadZ.optional()}),ES=l.z.tuple([l.z.union([l.z.record(Z.or(nb),F.authorityZ),Z.or(nb),F.authorityZ]),F.authorityZ.optional()]).transform(([e,t])=>{if(F.authorityZ.safeParse(e).success)return{keys:[],authorities:[e]};if(Z.or(nb).safeParse(e).success){if(t==null)throw Error(`authority is required when setting authority for a single channel`);return{keys:[e],authorities:[t]}}let n=e;return{keys:Object.keys(n),authorities:Object.values(n)}}),DS=class e{stream;adapter;closeErr=null;constructor(e,t){this.stream=e,this.adapter=t}static async _open(t,n,r){let i=CS.parse(r),a=await Kx.open(t,i.channels);i.useHighPerformanceCodec&&(n=n.withCodec(new Ux(a.codec)));let o=new e(await n.stream(`/frame/write`,wS,TS),a);return await o.execute({command:Cx.Open,config:{...i,keys:a.keys}}),o}async write(e,t){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();let n=await this.adapter.adapt(e,t);this.stream.send({command:Cx.Write,frame:n.toPayload()})}async setAuthority(e,t){if(this.closeErr!=null)throw this.closeErr;let n=ES.parse([e,t]),r={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Cx.SetAuthority,config:r})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),D.ZERO):(await this.execute({command:Cx.Commit})).end}async close(){await this.closeInternal(null)}async closeInternal(e){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=e,this.stream.closeSend();;){if(this.closeErr!=null){if(vS.matches(this.closeErr))return null;throw this.closeErr}let[e,t]=await this.stream.receive();t==null?this.closeErr=Zc.decode(e?.err):this.closeErr=br.matches(t)?new vS:t}}async execute(e){let t=this.stream.send(e);for(t!=null&&await this.closeInternal(t);;){let[t,n]=await this.stream.receive();n!=null&&await this.closeInternal(n);let r=Zc.decode(t?.err);if(r!=null&&await this.closeInternal(r),t?.command==e.command)return t}}},OS=z(`framer`),kS=OS(``),AS=class{streamClient;retriever;deleter;reader;constructor(e,t,n){this.streamClient=e,this.retriever=n,this.deleter=new _x(t),this.reader=new tS(n,e)}async openIterator(e,t,n){return await $x._open(e,t,this.retriever,this.streamClient,n)}async openWriter(e){return await DS._open(this.retriever,this.streamClient,e)}async openStreamer(e){return await fS(this.retriever,this.streamClient,e)}async write(e,t,n){if(n==null){let n=t,r=await this.openWriter({start:e,channels:Object.keys(n),mode:gS.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:O.MAX});return await r.write(n),await r.close()}let r=await this.openWriter({start:e,channels:t,mode:gS.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:O.MAX});await r.write(t,n),await r.close()}async read(e,t){if(!(`start`in e))return this.reader.read(e);let{single:n}=gb(t),r=await this.readFrame(e,t);return n?r.get(t):r}async readFrame(e,t){let n=await this.openIterator(e,t),r=new $;try{for await(let e of n)r.push(e)}finally{await n.close()}return r}async readLatest(e,t=1){let{single:n}=gb(e),r=await this.readLatestNFrame(e,t);return n?r.get(e):r}async readLatestNFrame(e,t){let n=await this.openIterator(A.MAX,e,{chunkSize:t}),r=new $;if(t>0)try{await n.seekLast(),await n.prev(Jx),r.push(n.value)}finally{await n.close()}return r}async delete(e,t){let{normalized:n,variant:r}=gb(e),i=new A(t);return r===`keys`?await this.deleter.delete({keys:n,bounds:i}):await this.deleter.delete({names:n,bounds:i})}},jS=o({ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:()=>_S,AUTO_SPAN:()=>Jx,Client:()=>AS,Frame:()=>$,HardenedStreamer:()=>mS,Iterator:()=>$x,ObservableStreamer:()=>hS,Reader:()=>tS,TYPE_ONTOLOGY_ID:()=>kS,Writer:()=>DS,WriterClosedError:()=>vS,WriterCommand:()=>Cx,WriterMode:()=>gS,createStreamOpener:()=>dS,frameZ:()=>bx,ontologyID:()=>OS,openStreamer:()=>fS,seriesFromPayload:()=>xx,seriesToPayload:()=>Sx,streamerConfigZ:()=>uS,writerCommandZ:()=>wx,writerConfigZ:()=>CS}),MS=F.ABSOLUTE_AUTHORITY,NS=F.ZERO_AUTHORITY,PS=F.stateZ(l.z.number()),FS=e=>{let t=e.from?.resource,n=e.to?.resource;return e.to==null?`${t} - ${e.from?.subject.name} -> released`:e.from==null?`${n} - released -> ${e.to.subject.name} (${e.to.authority.toString()})`:`${n} - ${e.from.subject.name} -> ${e.to.subject.name} (${e.to.authority.toString()})`},IS=l.z.object({transfers:l.z.array(F.transferZ(Z))}),LS=class extends hS{states;codec;constructor(e){super(e,e=>{let t=this.codec.decode(e.series[0].buffer,IS);return this.merge(t),[t.transfers,!0]}),this.states=new Map,this.codec=new ai.JSONCodec}subjects(){let e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(e=>{e.from==null&&e.to==null&&console.warn(`Invalid transfer: `,e),e.to==null?this.states.delete(e.from.resource):this.states.set(e.to.resource,e.to)})}},RS=`sy_node_1_control`,zS=class{framer;constructor(e){this.framer=e}async openStateTracker(){return new LS(await mS.open(async e=>await this.framer.openStreamer(e),RS))}},BS=o({ABSOLUTE_AUTHORITY:()=>MS,CONTROL_STATE_CHANNEL_NAME:()=>RS,Client:()=>zS,StateTracker:()=>LS,ZERO_AUTHORITY:()=>NS,stateZ:()=>PS,transferString:()=>FS}),VS=l.z.uint32(),HS=l.z.object({rack:VS}),US=cu.statusZ({details:HS}),WS=l.z.object({key:VS,name:l.z.string().min(1,`Name is required`),taskCounter:l.z.uint32().optional(),embedded:l.z.boolean().optional(),status:US.optional(),integrations:N.nullToUndefined(l.z.string().array())}),GS=WS.omit({taskCounter:!0,embedded:!0,key:!0}).extend({key:l.z.uint32().default(0)}),KS=z(`rack`),qS=KS(0),JS=`sy_rack_set`,YS=`sy_rack_delete`,XS=l.z.object({keys:VS.array().optional(),names:l.z.string().array().optional(),integration:l.z.string().optional(),searchTerm:l.z.string().optional(),embedded:l.z.boolean().optional(),hostIsNode:l.z.boolean().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeStatus:l.z.boolean().optional()}),ZS=l.z.object({racks:w.nullishToEmpty(WS)}),QS=WS,$S=l.z.union([l.z.object({key:VS,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),l.z.object({name:l.z.string(),includeStatus:l.z.boolean().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t}))]),eC=XS,tC=l.z.union([$S,eC]),nC=l.z.object({racks:GS.array()}),rC=l.z.object({racks:WS.array()}),iC=l.z.object({keys:VS.array()}),aC=l.z.object({}),oC=class{client;tasks;constructor(e,t){this.client=e,this.tasks=t}async delete(e){await S(this.client,`/rack/delete`,{keys:w.toArray(e)},iC,aC)}async create(e){let t=!Array.isArray(e),n=await S(this.client,`/rack/create`,{racks:w.toArray(e)},nC,rC),r=this.sugar(n.racks);return t?r[0]:r}async retrieve(e){let t=`key`in e||`name`in e,n=await S(this.client,`/rack/retrieve`,e,tC,ZS),r=this.sugar(n.racks);return X(`Rack`,e,r,t),t?r[0]:r}sugar(e){let t=!Array.isArray(e),n=w.toArray(e).map(({key:e,name:t,status:n,integrations:r})=>new sC(e,t,this.tasks,n,r));return t?n[0]:n}},sC=class{key;name;status;integrations;tasks;constructor(e,t,n,r,i){this.key=e,this.name=t,this.tasks=n,this.status=r,this.integrations=i}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async createTask(e,t){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&4294967295n)).toString(),await this.tasks.create(e,t)}async deleteTask(e){await this.tasks.delete([e])}get payload(){return{key:this.key,name:this.name,status:this.status,integrations:this.integrations}}},cC=e=>Ru(KS(e)),lC=o({Client:()=>oC,DELETE_CHANNEL_NAME:()=>YS,Rack:()=>sC,SET_CHANNEL_NAME:()=>JS,TYPE_ONTOLOGY_ID:()=>qS,keyZ:()=>VS,newZ:()=>GS,ontologyID:()=>KS,payloadZ:()=>WS,rackZ:()=>QS,statusDetailsZ:()=>HS,statusKey:()=>cC,statusZ:()=>US}),uC=l.z.object({rack:VS,device:l.z.string()}),dC=l.z.string(),fC=cu.statusZ({details:uC}),pC=({properties:e,make:t,model:n}={})=>l.z.object({key:dC,rack:VS,location:l.z.string().min(1,`Location is required`),make:t??l.z.string().min(1,`Make is required`),model:n??l.z.string().min(1,`Model is required`),name:l.z.string().min(1,`Name is required`),configured:l.z.boolean().default(!1),properties:e??I.nullishToEmpty(),status:fC.optional(),parent:R.optional()}),mC=({properties:e,make:t,model:n}={})=>pC({properties:e,make:t,model:n}).partial({key:!0,configured:!0}),hC=z(`device`),gC=hC(``),_C=`sy_device_set`,vC=`sy_device_delete`,yC=e=>l.z.object({devices:N.toArray(mC(e))}),bC=e=>l.z.object({devices:pC(e).array()}),xC=l.z.object({keys:dC.array()}),SC=l.z.object({}),CC=l.z.object({keys:dC.array().optional(),names:l.z.string().array().optional(),makes:l.z.string().array().optional(),models:l.z.string().array().optional(),locations:l.z.string().array().optional(),racks:VS.array().optional(),searchTerm:l.z.string().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeStatus:l.z.boolean().optional(),includeParent:l.z.boolean().optional()}),wC=e=>l.z.object({devices:w.nullishToEmpty(pC(e))}),TC=l.z.object({key:dC,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),EC=l.z.union([TC,CC]),DC=class{client;constructor(e){this.client=e}async retrieve(e){let{schemas:t,...n}=e,r=typeof n==`object`&&`key`in n,i=await S(this.client,`/device/retrieve`,n,EC,wC(t));return X(`Device`,n,i.devices,r),r?i.devices[0]:i.devices}async create(e,t){let n=!Array.isArray(e),r=await S(this.client,`/device/create`,{devices:w.toArray(e)},yC(t),bC(t));return n?r.devices[0]:r.devices}async delete(e){await S(this.client,`/device/delete`,{keys:w.toArray(e)},xC,SC)}},OC=e=>Ru(hC(e)),kC=o({Client:()=>DC,DELETE_CHANNEL_NAME:()=>vC,SET_CHANNEL_NAME:()=>_C,TYPE_ONTOLOGY_ID:()=>gC,deviceZ:()=>pC,keyZ:()=>dC,newZ:()=>mC,ontologyID:()=>hC,statusDetailsZ:()=>uC,statusKey:()=>OC,statusZ:()=>fC}),AC=fl.keyZ,jC=fl.labelZ,MC=fl.newZ,NC=`labeled_by`,PC=`sy_label_set`,FC=`sy_label_delete`,IC=l.default.object({labels:MC.array()}),LC=l.default.object({labels:jC.array()}),RC=l.default.object({keys:AC.array()}),zC=l.default.object({id:R,labels:AC.array(),replace:l.default.boolean().optional()}),BC=zC.omit({replace:!0}),VC=l.default.object({}),HC=l.default.object({keys:AC.array().optional(),names:l.default.string().array().optional(),for:R.optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional()}),UC=l.default.object({key:AC}).transform(({key:e})=>({keys:[e]})),WC=l.default.union([UC,HC]),GC=l.default.object({labels:w.nullishToEmpty(jC)}),KC=class{type=`label`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await S(this.client,`/label/retrieve`,e,WC,GC);return X(`Label`,e,n.labels,t),t?n.labels[0]:n.labels}async label(e,t,n={}){await S(this.client,`/label/set`,{id:e,labels:t,replace:n.replace},zC,VC)}async remove(e,t){await S(this.client,`/label/remove`,{id:e,labels:t},BC,VC)}async create(e){let t=Array.isArray(e),n=await S(this.client,`/label/create`,{labels:w.toArray(e)},IC,LC);return t?n.labels:n.labels[0]}async delete(e){await S(this.client,`/label/delete`,{keys:w.toArray(e)},RC,VC)}},qC=z(`label`),JC=qC(``),YC=o({Client:()=>KC,DELETE_CHANNEL_NAME:()=>FC,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:()=>NC,SET_CHANNEL_NAME:()=>PC,TYPE_ONTOLOGY_ID:()=>JC,keyZ:()=>AC,labelZ:()=>jC,newZ:()=>MC,ontologyID:()=>qC}),XC=l.z.uuid(),ZC=l.z.object({key:XC,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty())}),QC=ZC.partial({key:!0}),$C=z(`lineplot`),ew=$C(``),tw=l.z.uuid(),nw=l.z.object({key:tw,name:l.z.string().min(1,`Name is required`),author:l.z.uuid().optional(),layout:Hr.preserveCase(I.nullishToEmpty())}),rw=nw.omit({author:!0}).partial({key:!0}),iw=z(`workspace`),aw=iw(``),ow=l.z.object({keys:tw.array().optional(),searchTerm:l.z.string().optional(),author:Ad.optional(),offset:l.z.int().optional(),limit:l.z.int().optional()}),sw=l.z.object({workspaces:rw.array()}),cw=l.z.object({key:tw,name:l.z.string()}),lw=l.z.object({key:tw,layout:Hr.preserveCase(I.unknownZ())}),uw=l.z.object({keys:tw.array()}),dw=l.z.object({workspaces:w.nullishToEmpty(nw)}),fw=l.z.object({workspaces:nw.array()}),pw=l.z.object({}),mw=`sy_workspace_set`,hw=`sy_workspace_delete`,gw=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await S(this.client,`/workspace/create`,{workspaces:w.toArray(e)},sw,fw);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await S(this.client,`/workspace/rename`,{key:e,name:t},cw,pw)}async setLayout(e,t){await S(this.client,`/workspace/set-layout`,{key:e,layout:t},lw,pw)}async retrieve(e){let t,n=typeof e!=`string`;t=typeof e==`string`||Array.isArray(e)?{keys:w.toArray(e)}:e;let r=await S(this.client,`/workspace/retrieve`,t,ow,dw);return n?r.workspaces:r.workspaces[0]}async delete(e){await S(this.client,`/workspace/delete`,{keys:w.toArray(e)},uw,pw)}},_w=o({Client:()=>gw,DELETE_CHANNEL_NAME:()=>hw,SET_CHANNEL_NAME:()=>mw,TYPE_ONTOLOGY_ID:()=>aw,keyZ:()=>tw,newZ:()=>rw,ontologyID:()=>iw,workspaceZ:()=>nw}),vw=l.z.object({key:XC,name:l.z.string()}),yw=l.z.object({key:XC,data:Hr.preserveCase(I.unknownZ())}),bw=l.z.object({keys:XC.array()}),xw=l.z.object({keys:XC.array()}),Sw=l.z.object({key:XC}).transform(({key:e})=>({keys:[e]})),Cw=l.z.union([Sw,xw]),ww=l.z.object({linePlots:w.nullishToEmpty(ZC)}),Tw=l.z.object({workspace:tw,linePlots:QC.array()}),Ew=l.z.object({linePlots:ZC.array()}),Dw=l.z.object({}),Ow=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/lineplot/create`,{workspace:e,linePlots:w.toArray(t)},Tw,Ew);return n?r.linePlots:r.linePlots[0]}async rename(e,t){await S(this.client,`/lineplot/rename`,{key:e,name:t},vw,Dw)}async setData(e,t){await S(this.client,`/lineplot/set-data`,{key:e,data:t},yw,Dw)}async retrieve(e){let t=Sw.safeParse(e).success,n=await S(this.client,`/lineplot/retrieve`,e,Cw,ww);return X(`LinePlot`,e,n.linePlots,t),t?n.linePlots[0]:n.linePlots}async delete(e){await S(this.client,`/lineplot/delete`,{keys:w.toArray(e)},bw,Dw)}},kw=o({Client:()=>Ow,TYPE_ONTOLOGY_ID:()=>ew,keyZ:()=>XC,linePlotZ:()=>ZC,newZ:()=>QC,ontologyID:()=>$C,retrieveArgsZ:()=>Cw}),Aw=l.z.uuid(),jw=l.z.object({key:Aw,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty())}),Mw=jw.partial({key:!0}),Nw=z(`log`),Pw=Nw(``),Fw=l.z.object({key:Aw,name:l.z.string()}),Iw=l.z.object({key:Aw,data:Hr.preserveCase(I.unknownZ())}),Lw=l.z.object({keys:Aw.array()}),Rw=l.z.object({keys:Aw.array()}),zw=l.z.object({key:Aw}).transform(({key:e})=>({keys:[e]})),Bw=l.z.union([zw,Rw]),Vw=l.z.object({logs:w.nullishToEmpty(jw)}),Hw=l.z.object({workspace:tw,logs:Mw.array()}),Uw=l.z.object({logs:jw.array()}),Ww=l.z.object({}),Gw=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/log/create`,{workspace:e,logs:w.toArray(t)},Hw,Uw);return n?r.logs:r.logs[0]}async rename(e,t){await S(this.client,`/log/rename`,{key:e,name:t},Fw,Ww)}async setData(e,t){await S(this.client,`/log/set-data`,{key:e,data:t},Iw,Ww)}async retrieve(e){let t=zw.safeParse(e).success,n=await S(this.client,`/log/retrieve`,e,Bw,Vw);return X(`Log`,e,n.logs,t),t?n.logs[0]:n.logs}async delete(e){await S(this.client,`/log/delete`,{keys:w.toArray(e)},Lw,Ww)}},Kw=o({Client:()=>Gw,TYPE_ONTOLOGY_ID:()=>Pw,keyZ:()=>Aw,logZ:()=>jw,newZ:()=>Mw,ontologyID:()=>Nw,retrieveArgsZ:()=>Bw}),qw=l.z.object({range:Q,aliases:l.z.string().array()}),Jw=l.z.object({aliases:l.z.record(l.z.string(),Z)}),Yw=l.z.object({range:Q,aliases:l.z.record(Z,l.z.string())}),Xw=l.z.unknown(),Zw=l.z.object({range:Q,channels:Z.array()}),Qw=l.z.unknown(),$w=l.z.object({range:Q}),eT=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),tT=l.z.object({range:Q,channels:Z.array()}),nT=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),rT=class{cache=new Map;client;rangeKey;constructor(e,t){this.rangeKey=e,this.cache=new Map,this.client=t}async resolve(e){let t=[],n=typeof e==`string`,r={};if(n){let n=this.cache.get(e);if(n!=null)return n;t.push(e)}else e.forEach(e=>{let n=this.cache.get(e);n==null?t.push(e):r[e]=n});if(t.length===0)return r;let i=await S(this.client,`/range/alias/resolve`,{range:this.rangeKey,aliases:t},qw,Jw);return Object.entries(i.aliases).forEach(([e,t])=>this.cache.set(e,t)),n?i.aliases[t[0]]:{...r,...i.aliases}}async set(e){await S(this.client,`/range/alias/set`,{range:this.rangeKey,aliases:e},Yw,Xw)}async list(){return(await S(this.client,`/range/alias/list`,{range:this.rangeKey},$w,eT)).aliases}async retrieve(e){let t=typeof e==`number`,n=await S(this.client,`/range/alias/retrieve`,{range:this.rangeKey,channels:w.toArray(e)},tT,nT);return t?n.aliases[e]:n.aliases}async delete(e){await S(this.client,`/range/alias/delete`,{range:this.rangeKey,channels:w.toArray(e)},Zw,Qw)}},iT=`sy_range_alias_set`,aT=`sy_range_alias_delete`,oT=`---`,sT=e=>`${e.range}${oT}${e.channel}`,cT=(e,t)=>({type:`range-alias`,key:sT({range:e,channel:t})}),lT={type:`range-alias`,key:``},uT=e=>{let[t,n]=e.split(oT);return{range:t,channel:Number(n)}},dT=iT,fT=aT,pT=sT,mT=uT,hT=l.z.object({range:Q,channel:Z,alias:l.z.string()}),gT=o({Client:()=>rT,DELETE_ALIAS_CHANNEL_NAME:()=>fT,DELETE_CHANNEL_NAME:()=>aT,SET_ALIAS_CHANNEL_NAME:()=>dT,SET_CHANNEL_NAME:()=>iT,TYPE_ONTOLOGY_ID:()=>lT,aliasKey:()=>pT,aliasZ:()=>hT,createKey:()=>sT,decodeDeleteAliasChange:()=>mT,decodeDeleteChange:()=>uT,ontologyID:()=>cT}),_T=`sy_range_set`,vT=`sy_range_delete`,yT=class{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:t=A.ZERO,key:n,color:r,parent:i,labels:a},{frameClient:o,kv:s,aliaser:c,channels:l,labelClient:u,ontologyClient:d,rangeClient:f}){this.key=n,this.name=e,this.timeRange=t,this.parent=i,this.labels=a,this.frameClient=o,this.color=r,this.kv=s,this.aliaser=c,this.channels=l,this.labelClient=u,this.ontologyClient=d,this.rangeClient=f}get ontologyID(){return fb(this.key)}get payload(){let e={key:this.key,name:this.name,timeRange:this.timeRange,color:this.color,labels:this.labels};return this.parent!=null&&(`payload`in this.parent?e.parent=this.parent.payload:e.parent=this.parent),e}async setAlias(e,t){let n=await this.channels.retrieve(e);if(n.length===0)throw new Tu(`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 resolveAlias(e){return await this.aliaser.resolve(e)}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){let e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:[`range`]})).map(e=>e.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async retrieveLabels(){return await this.labelClient.retrieve({for:fb(this.key)})}async addLabel(...e){await this.labelClient.label(fb(this.key),e)}async removeLabel(...e){await this.labelClient.remove(fb(this.key),e)}static sort(e,t){return A.sort(e.timeRange,t.timeRange)}},bT=l.z.object({keys:Q.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),overlapsWith:A.z.optional(),hasLabels:AC.array().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeLabels:l.z.boolean().optional(),includeParent:l.z.boolean().optional()}).or(Q.array().transform(e=>({keys:e}))).or(Q.transform(e=>({keys:[e]}))).or(l.z.string().transform(e=>({names:[e]}))).or(l.z.string().array().transform(e=>({names:e}))).or(A.z.transform(e=>({overlapsWith:e}))),xT=l.z.object({ranges:w.nullishToEmpty(ub)}),ST=class{type=`range`;frameClient;writer;unaryClient;channels;labelClient;ontologyClient;createAliasClient;createKVClient;constructor(e,t,n,r,i,a,o,s){this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=r,this.labelClient=i,this.ontologyClient=a,this.createAliasClient=o,this.createKVClient=s}async create(e,t){let n=!Array.isArray(e),r=this.sugarMany(await this.writer.create(w.toArray(e),t));return n?r[0]:r}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(w.toArray(e))}async retrieve(e){let t=typeof e==`string`,{ranges:n}=await S(this.unaryClient,`/range/retrieve`,e,bT,xT);return X(`Range`,e,n,t),t?this.sugarMany(n)[0]:this.sugarMany(n)}getKV(e){return this.createKVClient(e)}async retrieveParent(e){let t=await this.ontologyClient.retrieveParents(fb(e));if(t.length===0)return null;let n=t[0];return n.id.type===`range`?await this.retrieve(n.id.key):null}sugarOntologyResource(e){return this.sugarOne(wT(e))}async retrieveAlias(e,t){return await this.createAliasClient(e).retrieve(t)}async retrieveAliases(e,t){return await this.createAliasClient(e).retrieve(t)}async listAliases(e){return await this.createAliasClient(e).list()}async setAlias(e,t,n){await this.createAliasClient(e).set({[t]:n})}async deleteAlias(e,t){await this.createAliasClient(e).delete(t)}sugarOne(e){return new yT(e,{frameClient:this.frameClient,kv:this.createKVClient(e.key),aliaser:this.createAliasClient(e.key),channels:this.channels,labelClient:this.labelClient,ontologyClient:this.ontologyClient,rangeClient:this})}sugarMany(e){return e.map(e=>this.sugarOne(e))}resourceToRange(e){return this.sugarOne(wT(e))}},CT=e=>({type:`range-alias`,key:e}),wT=({data:e,id:{key:t},name:n})=>{let r=A.z.parse(e?.timeRange),i=Nc.colorZ.safeParse(e?.color);return{key:t,name:n,timeRange:r,color:i.success?i.data:void 0,labels:[],parent:void 0}},TT=l.z.object({range:Q,key:l.z.string(),value:l.z.string()}),ET=l.z.object({range:Q,keys:l.z.string().array()}),DT=l.z.object({pairs:w.nullishToEmpty(TT)}),OT=l.z.object({range:Q,pairs:TT.array()}),kT=l.z.object({range:Q,keys:l.z.string().array()}),AT=class{rangeKey;client;constructor(e,t){this.rangeKey=e,this.client=t}async get(e){let t=await S(this.client,`/range/kv/get`,{range:this.rangeKey,keys:w.toArray(e)},ET,DT);return typeof e==`string`?t.pairs[0].value:Object.fromEntries(t.pairs.map(e=>[e.key,e.value]))}async list(){return this.get([])}async set(e,t=``){let n;n=typeof e==`string`?[{range:this.rangeKey,key:e,value:t}]:Object.entries(e).map(([e,t])=>({range:this.rangeKey,key:e,value:t})),await S(this.client,`/range/kv/set`,{range:this.rangeKey,pairs:n},OT,l.z.unknown())}async delete(e){await S(this.client,`/range/kv/delete`,{range:this.rangeKey,keys:w.toArray(e)},kT,l.z.unknown())}},jT=`sy_range_kv_set`,MT=`sy_range_kv_delete`,NT=({range:e,key:t})=>`${e}<--->${t}`,PT=jT,FT=MT,IT=TT,LT=NT,RT=o({Client:()=>AT,DELETE_CHANNEL_NAME:()=>MT,KV_DELETE_CHANNEL:()=>FT,KV_SET_CHANNEL:()=>PT,SET_CHANNEL_NAME:()=>jT,createPairKey:()=>NT,kvPairKey:()=>LT,kvPairZ:()=>IT,pairZ:()=>TT}),zT=l.z.string().min(1),BT=l.z.object({ranges:ub.array()}),VT=l.z.object({parent:R.optional(),ranges:db.array()}),HT=l.z.object({keys:Q.array()}),UT=l.z.object({}),WT=l.z.object({key:Q,name:zT}),GT=l.z.object({}),KT=class{client;constructor(e){this.client=e}async rename(e,t){await S(this.client,`/range/rename`,{key:e,name:t},WT,GT)}async create(e,t){return(await S(this.client,`/range/create`,{ranges:e,...t},VT,BT)).ranges}async delete(e){await S(this.client,`/range/delete`,{keys:e},HT,UT)}},qT=o({Client:()=>ST,DELETE_ALIAS_CHANNEL_NAME:()=>aT,DELETE_CHANNEL_NAME:()=>vT,KV_DELETE_CHANNEL:()=>MT,KV_SET_CHANNEL:()=>jT,Range:()=>yT,SET_ALIAS_CHANNEL_NAME:()=>iT,SET_CHANNEL_NAME:()=>_T,TYPE_ONTOLOGY_ID:()=>pb,Writer:()=>KT,alias:()=>gT,aliasKey:()=>sT,aliasOntologyID:()=>CT,apiRangeZ:()=>lb,baseZ:()=>cb,convertOntologyResourceToPayload:()=>wT,decodeDeleteAliasChange:()=>uT,keyZ:()=>Q,kv:()=>RT,kvPairKey:()=>NT,nameZ:()=>zT,newZ:()=>db,ontologyID:()=>fb,payloadZ:()=>ub}),JT=l.z.object({key:l.z.string(),name:l.z.string(),selectors:w.nullishToEmpty(l.z.string()),strokeColor:l.z.string().optional(),fillColor:l.z.string().optional()}),YT=l.z.object({key:l.z.string(),position:xo.xyZ,orientation:xo.outerLocationZ}),XT=l.z.object({zoom:l.z.number().default(1),position:xo.xyZ}),ZT=l.z.uuid(),QT=l.z.object({key:l.z.string(),name:l.z.string(),regions:w.nullishToEmpty(JT)}),$T=l.z.object({svg:l.z.string().min(1),states:w.nullishToEmpty(QT),variant:l.z.string().min(1),handles:w.nullishToEmpty(YT),scale:l.z.number().default(1),scaleStroke:l.z.boolean().default(!1),previewViewport:XT.optional()}),eE=l.z.object({key:ZT,version:l.z.uint32().default(1),name:l.z.string().min(1),data:$T}),tE=l.z.object({key:ZT.optional(),version:l.z.uint32().default(1),name:l.z.string().min(1),data:$T}),nE=z(`schematic_symbol`),rE=nE(``),iE=l.z.object({symbols:tE.array(),parent:R}),aE=l.z.object({key:ZT,name:l.z.string()}),oE=l.z.object({keys:ZT.array()}),sE=l.z.object({keys:ZT.array().optional(),searchTerm:l.z.string().optional()}),cE=l.z.object({key:ZT}).transform(({key:e})=>({keys:[e]})),lE=l.z.union([cE,sE]),uE=l.z.object({symbols:w.nullishToEmpty(eE)}),dE=l.z.object({symbols:eE.array()}),fE=l.z.object({}),pE=l.z.object({}),mE=l.z.object({group:Sb}),hE=`sy_schematic_symbol_set`,gE=`sy_schematic_symbol_delete`,_E=class{client;constructor(e){this.client=e}async create(e){let t=`symbols`in e,n=t?e.symbols:[e],r=await S(this.client,`/schematic/symbol/create`,{symbols:n,parent:e.parent},iE,dE);return t?r.symbols:r.symbols[0]}async rename(e,t){await S(this.client,`/schematic/symbol/rename`,{key:e,name:t},aE,fE)}async retrieve(e){let t=`key`in e,n=await S(this.client,`/schematic/symbol/retrieve`,e,lE,uE);return X(`Schematic Symbol`,e,n.symbols,t),t?n.symbols[0]:n.symbols}async delete(e){await S(this.client,`/schematic/symbol/delete`,{keys:w.toArray(e)},oE,fE)}async retrieveGroup(){return(await S(this.client,`/schematic/symbol/retrieve-group`,{},pE,mE)).group}},vE=o({Client:()=>_E,DELETE_CHANNEL_NAME:()=>gE,SET_CHANNEL_NAME:()=>hE,TYPE_ONTOLOGY_ID:()=>rE,handleZ:()=>YT,keyZ:()=>ZT,newZ:()=>tE,ontologyID:()=>nE,regionZ:()=>JT,specZ:()=>$T,stateZ:()=>QT,symbolZ:()=>eE,viewportZ:()=>XT}),yE=l.z.uuid(),bE=l.z.object({key:yE,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty()),snapshot:l.z.boolean()}),xE=bE.partial({key:!0,snapshot:!0}),SE=z(`schematic`),CE=SE(``),wE=l.z.object({key:yE,name:l.z.string()}),TE=l.z.object({key:yE,data:Hr.preserveCase(I.unknownZ())}),EE=l.z.object({keys:yE.array()}),DE=l.z.object({key:yE,name:l.z.string(),snapshot:l.z.boolean()}),OE=l.z.object({keys:yE.array()}),kE=l.z.object({key:yE}).transform(({key:e})=>({keys:[e]})),AE=l.z.union([kE,OE]),jE=l.z.object({schematics:bE.array()}),ME=l.z.object({workspace:tw,schematics:xE.array()}),NE=l.z.object({schematics:bE.array()}),PE=l.z.object({schematic:bE}),FE=l.z.object({}),IE=class{symbols;client;constructor(e){this.client=e,this.symbols=new _E(e)}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/schematic/create`,{workspace:e,schematics:w.toArray(t)},ME,NE);return n?r.schematics:r.schematics[0]}async rename(e,t){await S(this.client,`/schematic/rename`,{key:e,name:t},wE,FE)}async setData(e,t){await S(this.client,`/schematic/set-data`,{key:e,data:t},TE,FE)}async retrieve(e){let t=kE.safeParse(e).success,n=await S(this.client,`/schematic/retrieve`,e,AE,jE);return X(`Schematic`,e,n.schematics,t),t?n.schematics[0]:n.schematics}async delete(e){await S(this.client,`/schematic/delete`,{keys:w.toArray(e)},EE,FE)}async copy(e){return(await S(this.client,`/schematic/copy`,e,DE,PE)).schematic}},LE=o({Client:()=>IE,TYPE_ONTOLOGY_ID:()=>CE,keyZ:()=>yE,newZ:()=>xE,ontologyID:()=>SE,retrieveArgsZ:()=>AE,schematicZ:()=>bE,symbol:()=>vE}),RE=l.z.string(),zE=e=>cu.statusZ({details:e}),BE=e=>cu.newZ({details:e}).omit({labels:!0}),VE=`sy_status_set`,HE=`sy_status_delete`,UE=z(`status`),WE=UE(``),GE=e=>l.default.object({parent:R.optional(),statuses:BE(e).array()}),KE=e=>l.default.object({statuses:zE(e).array()}),qE=l.default.object({keys:RE.array()}),JE=l.default.object({}),YE=l.default.object({keys:RE.array().optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional(),includeLabels:l.default.boolean().optional(),hasLabels:AC.array().optional(),variants:l.default.string().array().optional()}),XE=l.default.object({key:RE,includeLabels:l.default.boolean().optional()}).transform(({key:e,includeLabels:t})=>({keys:[e],includeLabels:t})),ZE=l.default.union([XE,YE]),QE=e=>l.default.object({statuses:w.nullishToEmpty(zE(e))}),$E=class{type=`status`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await S(this.client,`/status/retrieve`,e,ZE,QE(e.detailsSchema));X(`Status`,e,n.statuses,t);let r=n.statuses;return t?r[0]:r}async set(e,t={}){let n=Array.isArray(e),r=(await S(this.client,`/status/set`,{statuses:w.toArray(e),parent:t.parent},GE(t.detailsSchema),KE(t.detailsSchema))).statuses;return n?r:r[0]}async delete(e){await S(this.client,`/status/delete`,{keys:w.toArray(e)},qE,JE)}},eD=o({Client:()=>$E,DELETE_CHANNEL_NAME:()=>HE,SET_CHANNEL_NAME:()=>VE,TYPE_ONTOLOGY_ID:()=>WE,keyZ:()=>RE,newZ:()=>BE,ontologyID:()=>UE,statusZ:()=>zE}),tD=l.z.uuid(),nD=l.z.object({key:tD,name:l.z.string(),data:Hr.preserveCase(I.nullishToEmpty())}),rD=nD.partial({key:!0}),iD=z(`table`),aD=iD(``),oD=l.z.object({key:tD,name:l.z.string()}),sD=l.z.object({key:tD,data:Hr.preserveCase(I.unknownZ())}),cD=l.z.object({keys:tD.array()}),lD=l.z.object({keys:tD.array()}),uD=l.z.object({key:tD}).transform(({key:e})=>({keys:[e]})),dD=l.z.union([uD,lD]),fD=l.z.object({tables:w.nullishToEmpty(nD)}),pD=l.z.object({workspace:tw,tables:rD.array()}),mD=l.z.object({tables:nD.array()}),hD=l.z.object({}),gD=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await S(this.client,`/table/create`,{workspace:e,tables:w.toArray(t)},pD,mD);return n?r.tables:r.tables[0]}async rename(e,t){await S(this.client,`/table/rename`,{key:e,name:t},oD,hD)}async setData(e,t){await S(this.client,`/table/set-data`,{key:e,data:t},sD,hD)}async retrieve(e){let t=uD.safeParse(e).success,n=await S(this.client,`/table/retrieve`,e,dD,fD);return X(`Table`,e,n.tables,t),t?n.tables[0]:n.tables}async delete(e){await S(this.client,`/table/delete`,{keys:w.toArray(e)},cD,hD)}},_D=o({Client:()=>gD,TYPE_ONTOLOGY_ID:()=>aD,keyZ:()=>tD,newZ:()=>rD,ontologyID:()=>iD,retrieveArgsZ:()=>dD,tableZ:()=>nD}),vD=l.z.string().or(l.z.number().transform(String).or(l.z.bigint().transform(String))),yD=e=>l.z.object({task:vD,running:l.z.boolean(),cmd:l.z.string().optional(),data:e??l.z.unknown().optional()}),bD=e=>l.z.object({task:vD.optional(),running:l.z.boolean(),cmd:l.z.string().optional(),data:e??l.z.unknown().optional()}),xD=l.z.object({task:vD,type:l.z.string(),key:l.z.string(),args:Hr.preserveCase(N.nullToUndefined(I.unknownZ()))}),SD=e=>cu.statusZ({details:yD(e)}),CD=e=>cu.newZ({details:bD(e)}),wD=({type:e,config:t,statusData:n}={})=>l.z.object({key:vD,name:l.z.string(),type:e??l.z.string(),config:t??I.nullishToEmpty(),internal:l.z.boolean().optional(),snapshot:l.z.boolean().optional(),status:cu.statusZ({details:yD(n)}).optional()}),TD=({type:e,config:t,statusData:n}={})=>wD({type:e,config:t,statusData:n}).omit({internal:!0,snapshot:!0,status:!0}).partial({key:!0}).extend({status:cu.newZ({details:bD(n)}).optional()}),ED=z(`task`),DD=ED(``),OD=`sy_task_cmd`,kD=`sy_task_set`,AD=`sy_task_delete`,jD=Error(`Task not created`),MD=e=>Number(BigInt(e)>>32n),ND=(e,t=0)=>((BigInt(e)<<32n)+BigInt(t)).toString(),PD=async(e,t)=>{let n=await t.retrieveParents(ED(e));return n.length===0?null:n[0]},FD=class{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw jD;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw jD;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw jD;return this.rangeClient_}constructor({key:e,type:t,name:n,config:r,internal:i=!1,snapshot:a=!1,status:o},s,c,u,d){this.key=e,this.name=n,this.type=t,this.config=r,this.schemas=s??{type:l.z.string(),config:l.z.unknown(),statusData:l.z.unknown()},this.internal=i,this.snapshot=a,this.status=o,this.frameClient_=c,this.ontologyClient_=u,this.rangeClient_=d}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,status:this.status,internal:this.internal}}get ontologyID(){return ED(this.key)}async executeCommand(e){return await YD({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await ZD({...e,frameClient:this.frameClient,task:this.key,name:this.name,statusDataZ:this.schemas.statusData})}async start(){await this.executeCommand({type:`start`})}async stop(){await this.executeCommand({type:`stop`})}async run(e){await this.start();try{return await e()}finally{await this.stop()}}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw jD;return this.snapshot?await PD(this.key,this.ontologyClient):null}},ID=l.z.object({rack:VS.optional(),keys:vD.array().optional(),names:l.z.string().array().optional(),types:l.z.string().array().optional(),includeStatus:l.z.boolean().optional(),internal:l.z.boolean().optional(),snapshot:l.z.boolean().optional(),searchTerm:l.z.string().optional(),offset:l.z.int().optional(),limit:l.z.int().optional()}),LD=l.z.union([l.z.object({key:vD,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),l.z.object({name:l.z.string(),includeStatus:l.z.boolean().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t})),l.z.object({type:l.z.string(),rack:VS.optional()}).transform(({type:e,rack:t})=>({types:[e],rack:t}))]),RD=ID,zD=l.z.union([LD,RD]),BD=e=>l.z.object({tasks:w.nullishToEmpty(wD(e))}),VD=e=>l.z.object({tasks:TD(e).array()}),HD=e=>l.z.object({tasks:wD(e).array()}),UD=l.z.object({keys:vD.array()}),WD=l.z.object({}),GD=l.z.object({key:vD,name:l.z.string(),snapshot:l.z.boolean()}),KD=e=>l.z.object({task:wD(e)}),qD=class{client;frameClient;ontologyClient;rangeClient;constructor(e,t,n,r){this.client=e,this.frameClient=t,this.ontologyClient=n,this.rangeClient=r}async create(e,t){let n=!Array.isArray(e),r=VD(t),i=HD(t),a=await S(this.client,`/task/create`,{tasks:w.toArray(e)},r,i),o=this.sugar(a.tasks,t);return n?o[0]:o}async delete(e){await S(this.client,`/task/delete`,{keys:w.toArray(e)},UD,WD)}async retrieve({schemas:e,...t}){let n=LD.safeParse(t).success,r=(await S(this.client,`/task/retrieve`,t,zD,BD(e))).tasks,i=this.sugar(r,e);return X(`Task`,t,i,n),n?i[0]:i}async copy(e,t,n){let r=KD(),i=await S(this.client,`/task/copy`,{key:e,name:t,snapshot:n},GD,r);return this.sugar(i.task)}async list(e){let t={internal:!1};return e!==void 0&&(t.rack=e),await this.retrieve(t)}async retrieveSnapshottedTo(e){if(this.ontologyClient==null)throw jD;return await PD(e,this.ontologyClient)}sugar(e,t){let n=!Array.isArray(e),r=w.toArray(e).map(({key:e,name:n,type:r,config:i,status:a,internal:o,snapshot:s})=>new FD({key:e,name:n,type:r,config:i,internal:o,snapshot:s,status:a},t,this.frameClient,this.ontologyClient,this.rangeClient));return n?r[0]:r}async executeCommand(e){return`commands`in e?await XD({...e,frameClient:this.frameClient}):await YD({...e,frameClient:this.frameClient})}async executeCommandSync(e){if(`commands`in e){let t=async()=>{let{commands:t}=e;return(await this.retrieve({keys:t.map(e=>e.task)})).map(e=>e.name)};return await QD({...e,frameClient:this.frameClient,name:t})}return await ZD({frameClient:this.frameClient,name:async()=>{let{task:t}=e;return(await this.retrieve({key:t})).name},...e})}},JD=e=>Ru(ED(e)),YD=async({frameClient:e,task:t,type:n,args:r})=>(await XD({frameClient:e,commands:[{args:r,task:t,type:n}]}))[0],XD=async({frameClient:e,commands:t})=>{if(e==null)throw jD;let n=await e.openWriter(OD),r=t.map(e=>({...e,key:Li.create()}));return await n.write(OD,r),await n.close(),r.map(e=>e.key)},ZD=async({frameClient:e,task:t,type:n,timeout:r,name:i,statusDataZ:a,args:o})=>(await QD({frameClient:e,commands:[{args:o,task:t,type:n}],timeout:r,statusDataZ:a,name:i}))[0],QD=async({frameClient:e,commands:t,timeout:n=O.seconds(10),statusDataZ:r,name:i})=>{if(e==null)throw jD;let a=await e.openStreamer(VE),o=await XD({frameClient:e,commands:t}),s=new O(n),c=[],l,u=new Promise((e,n)=>{l=setTimeout(()=>{(async()=>{n(await $D(`command`,i,s,t.map(e=>e.task)))})()},s.milliseconds)});try{for(;;){let e=await Promise.race([a.read(),u]),t=SD(r).safeParse(e.at(-1)[VE]);if(!t.success)continue;let n=t.data;if(!(n.details.cmd==null||!o.includes(n.details.cmd))&&(c=[...c.filter(e=>e.key!==n.key),n],c.length===o.length))return c}}finally{clearTimeout(l),a.close()}},$D=async(e,t,n,r)=>{let i=Hr.capitalize(e),a=n.toString();try{let e;e=typeof t==`string`?[t]:Array.isArray(t)?t:w.toArray(await t());let n=mu.naturalLanguageJoin(e);return Error(`${i} command to ${n} timed out after ${a}`)}catch(e){return console.error(`Failed to retrieve task name for timeout error:`,e),Error(`${i} command to task with key ${mu.naturalLanguageJoin(w.toArray(r).map(e=>e.toString()))} timed out after ${a}`)}},eO=o({COMMAND_CHANNEL_NAME:()=>OD,Client:()=>qD,DELETE_CHANNEL_NAME:()=>AD,SET_CHANNEL_NAME:()=>kD,TYPE_ONTOLOGY_ID:()=>DD,Task:()=>FD,commandZ:()=>xD,keyZ:()=>vD,newKey:()=>ND,newStatusDetailsZ:()=>bD,newStatusZ:()=>CD,newZ:()=>TD,ontologyID:()=>ED,payloadZ:()=>wD,rackKey:()=>MD,statusDetailsZ:()=>yD,statusKey:()=>JD,statusZ:()=>SD}),tO=class{url;unary;stream;secure;constructor(e,t={},n=!1){this.secure=n,this.url=e.child(`/api/v1/`);let r=new ai.JSONCodec;this.unary=kr(new Or(this.url,r,this.secure),t),this.stream=new Pr(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}},nO=l.z.uuid(),rO=l.z.object({key:nO,name:l.z.string(),type:l.z.string(),query:I.nullishToEmpty()}),iO=rO.partial({key:!0}),aO=z(`view`),oO=aO(``),sO=`sy_view_set`,cO=`sy_view_delete`,lO=l.z.object({views:iO.array()}),uO=l.z.object({views:rO.array()}),dO=l.z.object({keys:nO.array()}),fO=l.z.object({}),pO=l.z.object({keys:nO.array().optional(),types:l.z.string().array().optional(),searchTerm:l.z.string().optional(),offset:l.z.number().optional(),limit:l.z.number().optional()}),mO=l.z.object({key:nO}).transform(({key:e})=>({keys:[e]})),hO=l.z.union([mO,pO]),gO=l.z.object({views:w.nullishToEmpty(rO)}),_O=class{client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await S(this.client,`/view/retrieve`,e,hO,gO);return X(`View`,e,n.views,t),t?n.views[0]:n.views}async create(e){let t=Array.isArray(e),n=await S(this.client,`/view/create`,{views:w.toArray(e)},lO,uO);return t?n.views:n.views[0]}async delete(e){await S(this.client,`/view/delete`,{keys:w.toArray(e)},dO,fO)}},vO=o({Client:()=>_O,DELETE_CHANNEL_NAME:()=>cO,SET_CHANNEL_NAME:()=>sO,TYPE_ONTOLOGY_ID:()=>oO,keyZ:()=>nO,newZ:()=>iO,ontologyID:()=>aO,viewZ:()=>rO}),yO=l.z.object({host:l.z.string({error:`Host is required`}).min(1,`Host is required`),port:l.z.number({error:`Port is required`}).or(l.z.string({error:`Port is required`})),username:l.z.string().min(1,`Username is required`),password:l.z.string().min(1,`Password is required`),connectivityPollFrequency:O.z.default(O.seconds(30)),secure:l.z.boolean().default(!1),name:l.z.string().optional(),retry:fs.breakerConfigZ.optional()}),bO=class extends AS{createdAt;params;ranges;channels;auth;users;access;connectivity;ontology;workspaces;labels;statuses;tasks;racks;devices;control;arcs;views;schematics;lineplots;logs;tables;groups;static connectivity=mx;transport;clientVersion=`0.54.1`;constructor(e){let t=yO.parse(e),{host:n,port:r,username:i,password:a,connectivityPollFrequency:o,secure:s,retry:c}=t,l=new tO(new vu({host:n,port:Number(r)}),c,s);l.use(Nu);let u=new vb(new _b(l.unary));super(l.stream,l.unary,u),this.auth=new ox(l.unary,{username:i,password:a}),l.use(this.auth.middleware());let d=new Zb(l.unary,u);this.createdAt=D.now(),this.params=t,this.transport=l,this.channels=new Rb(this,u,l.unary,d),this.connectivity=new mx(l.unary,o,this.clientVersion,t.name),this.control=new zS(this),this.ontology=new $u(this.transport.unary);let f=new KT(this.transport.unary);this.labels=new KC(this.transport.unary),this.statuses=new $E(this.transport.unary),this.ranges=new ST(this,f,this.transport.unary,u,this.labels,this.ontology,e=>new rT(e,this.transport.unary),e=>new AT(e,this.transport.unary)),this.access=new vf(this.transport.unary),this.users=new Yd(this.transport.unary),this.workspaces=new gw(this.transport.unary),this.tasks=new qD(this.transport.unary,this,this.ontology,this.ranges),this.racks=new oC(this.transport.unary,this.tasks),this.devices=new DC(this.transport.unary),this.arcs=new By(this.transport.unary,this.transport.stream),this.views=new _O(this.transport.unary),this.schematics=new IE(this.transport.unary),this.lineplots=new Ow(this.transport.unary),this.logs=new Gw(this.transport.unary),this.tables=new gD(this.transport.unary),this.groups=new jb(this.transport.unary)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}},xO=async e=>await SO(e).check(),SO=e=>{let{host:t,port:n,secure:r,name:i,retry:a}=e,o=fs.breakerConfigZ.optional().parse(a);return new mx(new tO(new vu({host:t,port:Number(n)}),o,r).unary,void 0,`0.54.1`,i)},CO={host:`localhost`,port:9090,username:`synnax`,password:`seldon`,retry:{maxRetries:4,baseInterval:O.seconds(1),scale:1.5}},wO=e=>new bO({...CO,...e}),TO=async(e,t)=>{let n=Li.create(),r=await e.users.create({username:n,password:`test`,firstName:`test`,lastName:`test`}),i=await e.access.policies.create(t),a=await e.access.roles.create({name:`test`,description:`test`});return await e.ontology.addChildren(Od(a.key),cd(i.key)),await e.access.roles.assign({user:r.key,role:a.key}),wO({username:n,password:`test`})};exports.AuthError=xu,exports.Channel=Fb,exports.ContiguityError=Mu,exports.DataType=j,exports.Density=k,exports.DisconnectedError=ju,exports.Frame=$,exports.MultiSeries=os,exports.MultipleFoundError=Du,exports.NotFoundError=Eu,exports.QueryError=Tu,exports.Rate=Do,exports.RouteError=Ou,exports.Series=Qo,exports.Synnax=bO,exports.TEST_CLIENT_PARAMS=CO,exports.TimeRange=A,exports.TimeSpan=O,exports.TimeStamp=D,exports.UnexpectedError=wu,exports.ValidationError=L,Object.defineProperty(exports,`access`,{enumerable:!0,get:function(){return bf}}),Object.defineProperty(exports,`arc`,{enumerable:!0,get:function(){return Uy}}),Object.defineProperty(exports,`channel`,{enumerable:!0,get:function(){return Qb}}),exports.checkConnection=xO,Object.defineProperty(exports,`connection`,{enumerable:!0,get:function(){return sx}}),Object.defineProperty(exports,`control`,{enumerable:!0,get:function(){return BS}}),exports.createTestClient=wO,exports.createTestClientWithPolicy=TO,Object.defineProperty(exports,`device`,{enumerable:!0,get:function(){return kC}}),Object.defineProperty(exports,`framer`,{enumerable:!0,get:function(){return jS}}),Object.defineProperty(exports,`group`,{enumerable:!0,get:function(){return Mb}}),exports.isCalculated=zb,Object.defineProperty(exports,`label`,{enumerable:!0,get:function(){return YC}}),Object.defineProperty(exports,`lineplot`,{enumerable:!0,get:function(){return kw}}),Object.defineProperty(exports,`log`,{enumerable:!0,get:function(){return Kw}}),exports.newConnectionChecker=SO,Object.defineProperty(exports,`ontology`,{enumerable:!0,get:function(){return id}}),Object.defineProperty(exports,`rack`,{enumerable:!0,get:function(){return lC}}),Object.defineProperty(exports,`ranger`,{enumerable:!0,get:function(){return qT}}),Object.defineProperty(exports,`schematic`,{enumerable:!0,get:function(){return LE}}),Object.defineProperty(exports,`status`,{enumerable:!0,get:function(){return eD}}),exports.synnaxParamsZ=yO,Object.defineProperty(exports,`table`,{enumerable:!0,get:function(){return _D}}),Object.defineProperty(exports,`task`,{enumerable:!0,get:function(){return eO}}),Object.defineProperty(exports,`user`,{enumerable:!0,get:function(){return Qd}}),Object.defineProperty(exports,`view`,{enumerable:!0,get:function(){return vO}}),Object.defineProperty(exports,`workspace`,{enumerable:!0,get:function(){return _w}});
|