@synnaxlabs/client 0.56.0 → 0.56.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 +4 -4
- package/dist/client.cjs +26 -26
- package/dist/client.js +2614 -2589
- package/dist/src/connection/checker.d.ts.map +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/framer/streamProxy.d.ts.map +1 -1
- package/dist/src/framer/streamer.d.ts.map +1 -1
- package/dist/src/framer/writer.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/auth/auth.ts +4 -4
- package/src/connection/checker.ts +2 -1
- package/src/errors.ts +2 -1
- package/src/framer/client.ts +1 -1
- package/src/framer/iterator.ts +1 -1
- package/src/framer/streamProxy.ts +2 -1
- package/src/framer/streamer.spec.ts +11 -2
- package/src/framer/streamer.ts +5 -5
- package/src/framer/writer.ts +5 -7
- package/src/ontology/client.ts +1 -1
- package/src/ranger/client.ts +1 -1
- package/src/ranger/kv/client.ts +1 -1
- package/src/table/table.spec.ts +1 -1
package/dist/client.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`zod`);l=c(l,1);var u=[`create`,`delete`,`retrieve`,`update`],d=l.z.enum(u),f=Object.defineProperty,p=(e,t)=>{let n={};for(var r in e)f(n,r,{get:e[r],enumerable:!0});return t||f(n,Symbol.toStringTag,{value:`Module`}),n},m=e=>l.default.union([l.default.null().transform(()=>[]),e.array()]).default(()=>[]),h=e=>Array.isArray(e)?e:e==null?[]:[e],g=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>g(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},ee=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e)):e.filter(e=>e!=t)}),te=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>te(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},ne=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e.key)):e.filter(e=>e.key!==t)}),_=p({nullishToEmpty:()=>m,remove:()=>ee,removeKeyed:()=>ne,toArray:()=>h,upsert:()=>g,upsertKeyed:()=>te}),re=p({camelToSnake:()=>fe,capitalize:()=>pe,preserveCase:()=>ae,snakeToCamel:()=>de,toKebab:()=>_e,toProperNoun:()=>ve}),ie=`synnax.caseconv.preserveCase`,ae=e=>(e[ie]=!0,e),oe=e=>{if(typeof e!=`object`||!e)return!1;if(ie in e)return!0;let t=e._zod?.def;return t==null?!1:t.innerType&&oe(t.innerType)?!0:t.type===`union`&&Array.isArray(t.options)?t.options.some(oe):t.type===`pipe`?oe(t.in)||oe(t.out):!1},se=e=>{if(e==null)return;let t=e._zod?.def;if(t?.type===`array`&&t.element!=null)return t.element;if(t?.innerType!=null)return se(t.innerType);if(t?.type===`union`&&Array.isArray(t.options))for(let e of t.options){let t=se(e);if(t!=null)return t}},ce=e=>{if(e==null)return null;let t=e;if(t.shape!=null)return t.shape;if(typeof t.sourceType==`function`){let e=t.sourceType();if(e?.shape!=null)return e.shape}let n=t._zod?.def;if(n==null)return null;if(n.innerType!=null)return ce(n.innerType);if(n.type===`union`&&Array.isArray(n.options)){let e=null;for(let t of n.options){let n=ce(t);if(n!=null)if(e==null)e={...n};else for(let t in n)t in e||(e[t]=n[t])}return e}return n.type===`pipe`?ce(n.in)??ce(n.out):null},le=e=>{if(e.length===0)return e;let t=e.indexOf(`_`)===-1?e:e.replace(/_[a-z]/g,e=>e[1].toUpperCase()),n=t.charCodeAt(0);return n<65||n>90||t.length>1&&t.charCodeAt(1)>=65&&t.charCodeAt(1)<=90?t:String.fromCharCode(n+32)+t.slice(1)},ue=e=>{let t=(n,r=me)=>{if(typeof n==`string`)return e(n);if(Array.isArray(n)){let e=se(r.schema),i={recursive:r.recursive,recursiveInArray:r.recursiveInArray,schema:e};return n.map(e=>t(e,i))}if(!he(n)||r.schema!=null&&oe(r.schema))return n;let i=r.recursive??!0,a=r.recursiveInArray??i,o=r.schema,s={},c=n;if(`toJSON`in c&&typeof c.toJSON==`function`)return t(c.toJSON(),r);let l=ce(o),u={recursive:i,recursiveInArray:a,schema:void 0},d=Object.keys(c);for(let n=0;n<d.length;n++){let r=d[n],o=c[r],f=e(r),p=l==null?void 0:l[r]??l[f]??void 0;i&&(he(o)?ge(o)||(u.schema=p,o=t(o,u)):a&&Array.isArray(o)&&(u.schema=se(p),o=o.map(e=>{if(he(e)){if(!ge(e))return t(e,u)}else if(Array.isArray(e))return t({key:e},u).key;return e}))),s[f]=o}return s};return t},de=ue(le),fe=ue(e=>e.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`)),pe=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),me={recursive:!0,recursiveInArray:!0,schema:void 0},he=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ge=e=>e instanceof Uint8Array||e instanceof Number||e instanceof String,_e=ue(e=>e.replace(/[\s_]+/g,`-`).replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}-${n.toLowerCase()}`).toLowerCase()),ve=ue(e=>{if(e.length===0)return e;let t=e.replace(/[_-]/g,` `);return t=t.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/\s+/g,` `).trim(),t=t.replace(/\b\w/g,e=>e.toUpperCase()),t}),ye=e=>typeof e==`object`&&!!e&&!Array.isArray(e),be=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},xe=e=>e.nullable().transform(e=>e===null?void 0:e).optional(),Se=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return{present:!1,value:void 0};let t=n;if(!(e in t))return{present:!1,value:void 0};n=t[e]}return{present:!0,value:n}},Ce=(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(!Ce(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(!Ce(r,i))return!1}else if(r!==i)return!1}return!0},we=(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(!we(r,i))return!1}else if(r!==i)return!1}return!0},Te=(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)},Ee=(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)},De=((e,t,n={optional:!1})=>{let{optional:r,getter:i=Ee}=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)}),Oe=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if(ye(e)&&ye(n))for(let t in n)try{ye(n[t])?(t in e||Object.assign(e,{[t]:{}}),Oe(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):e}return Oe(e,...t)},ke=e=>Object.getOwnPropertySymbols(globalThis).includes(e),Ae=(e,t)=>{let n=Symbol.for(e);if(!ke(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},je=p({Canceled:()=>Ke,NONE:()=>`nil`,NotImplemented:()=>qe,UNKNOWN:()=>Ie,Unknown:()=>We,createTyped:()=>Pe,decode:()=>Ue,encode:()=>He,isTyped:()=>Fe,payloadZ:()=>Ge,register:()=>Ve}),Me=`sy_x_error`,Ne=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,Pe=e=>class t extends Error{static discriminator=Me;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=Ne(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return Pe(`${e}.${t}`)}},Fe=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==Me)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},Ie=`unknown`,Le=(e,t)=>({...e,name:t.name,stack:t.stack}),Re=(e,t)=>(t.name!=null&&(e.name=t.name),t.stack!=null&&(e.stack=t.stack),e),ze=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(Fe(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return Le(n,e)}if(e instanceof Error)return Le({type:Ie,data:e.message},e);if(typeof e==`string`)return{type:Ie,data:e};try{return{type:Ie,data:JSON.stringify(e)}}catch{return{type:Ie,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return Re(new We(e.data),e);for(let t of this.providers){let n=t.decode(e);if(n!=null)return Re(n,e)}return Re(new We(e.data),e)}},Be=Ae(`synnax-error-registry`,()=>new ze),Ve=({encode:e,decode:t})=>Be().register({encode:e,decode:t}),He=e=>Be().encode(e),Ue=e=>e==null?null:Be().decode(e),We=class extends Pe(`unknown`){},Ge=l.z.object({type:l.z.string(),data:l.z.string(),name:l.z.string().optional(),stack:l.z.string().optional()}),Ke=class extends Pe(`canceled`){},qe=class extends Pe(`not_implemented`){},Je=e=>{if(e.length===0)return`<root>`;let t=``;return e.forEach((e,n)=>{typeof e==`number`?t+=`[${e}]`:n===0?t+=String(e):t+=`.${String(e)}`}),t},Ye=200,Xe=10,Ze=8,Qe=(e,t={})=>{let n=t.maxStringLength??Ye,r=t.maxArrayLength??Xe,i=t.maxDepth??Ze,a=(e,t)=>{if(e===null)return null;if(e===void 0)return`[undefined]`;let o=typeof e;if(o===`string`){let t=e;return t.length>n?`${t.slice(0,n)}…(+${t.length-n} chars)`:t}if(o===`number`||o===`boolean`)return e;if(o===`bigint`)return`${e.toString()}n`;if(o===`symbol`||o===`function`)return`[${o}]`;if(Array.isArray(e)){if(t>=i)return`[Array(${e.length})]`;let n=e.slice(0,r).map(e=>a(e,t+1));return e.length>r&&n.push(`…(+${e.length-r} more)`),n}if(be(e)){if(t>=i)return`[Object]`;let n={};for(let[r,i]of Object.entries(e))n[r]=a(i,t+1);return n}if(e instanceof Date)return e.toISOString();if(e instanceof Error)return`[Error: ${e.message}]`;try{return`[${Object.prototype.toString.call(e)}]`}catch{return`[unknown]`}};return a(e,0)},$e=(e,t={})=>JSON.stringify(Qe(e,t),null,2),et=p({ValueExtension:()=>nt,is:()=>st,isCrudeValueExtension:()=>tt,isHashable:()=>it,isNonZero:()=>ot,isStringer:()=>rt,isZero:()=>at}),tt=e=>typeof e==`object`&&!!e&&`value`in e,nt=class{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}},rt=e=>typeof e==`object`&&!!e&&`toString`in e,it=e=>typeof e==`object`&&!!e&&`hash`in e&&typeof e.hash==`function`,at=e=>{if(rt(e))return e?.toString().length===0;switch(typeof e){case`string`:return e.length===0;case`number`:return e===0;case`bigint`:return e===0n;case`boolean`:return!e;case`undefined`:return!0;case`object`:return e==null;default:return!1}},ot=e=>!at(e),st=e=>e==null||typeof e!=`object`&&typeof e!=`function`,ct=`value`,lt=`zod.parse`,ut=`✗`,dt=60,ft={maxStringLength:60,maxArrayLength:3,maxDepth:3},pt=e=>e.slice(0,-1),mt=e=>{switch(e.code){case`invalid_type`:return`expected ${e.expected}`;case`invalid_value`:return`expected one of ${JSON.stringify(e.values)}`;case`unrecognized_keys`:return`unexpected key`;case`too_small`:{let t=e.inclusive===!1?`>`:`>=`;return`${e.origin} too small: expected ${t}${e.minimum}`}case`too_big`:{let t=e.inclusive===!1?`<`:`<=`;return`${e.origin} too large: expected ${t}${e.maximum}`}case`invalid_format`:return`expected ${e.format} format`;case`not_multiple_of`:return`expected multiple of ${e.divisor}`;case`custom`:return e.message||`custom validation failed`;default:return e.message}},ht=(e,t,n)=>{let r=JSON.stringify(Qe(t,n));return`${mt(e)}, received ${r}`},gt=e=>{let t=0;for(let n of e){if(n.path.length>t&&(t=n.path.length),n.code===`invalid_union`&&`errors`in n)for(let e of n.errors){let n=gt(e);n>t&&(t=n)}if((n.code===`invalid_key`||n.code===`invalid_element`)&&`issues`in n){let e=gt(n.issues);e>t&&(t=e)}}return t},_t=(e,t=[])=>{let n=[];for(let r of e){let e=[...t,...r.path];if(r.code===`invalid_union`&&`errors`in r&&r.errors.length>0){let t=r.errors[0],i=gt(t);for(let e=1;e<r.errors.length;e++){let n=gt(r.errors[e]);n>i&&(t=r.errors[e],i=n)}n.push(..._t(t,e));continue}if(r.code===`invalid_element`&&`issues`in r&&`key`in r&&(typeof r.key==`string`||typeof r.key==`number`)){n.push(..._t(r.issues,[...e,r.key]));continue}if(r.code===`invalid_key`&&`issues`in r){n.push(..._t(r.issues,e));continue}n.push({...r,path:e})}return n},vt=e=>{let t=[];for(let n of e){if(n.code===`unrecognized_keys`&&`keys`in n&&Array.isArray(n.keys)){for(let e of n.keys)t.push({...n,path:[...n.path,e]});continue}t.push(n)}return t},yt=(e,t,n,r)=>{let i=`${n} `,a=`${n+ut} `,o={...ft,...r};if(Array.isArray(e)){let e=-1;for(let n of t.keys()){let t=Number(n);Number.isInteger(t)&&t>e&&(e=t)}let n=o.maxArrayLength??3;e>=n&&(o={...o,maxArrayLength:e+2})}let s=Qe(e,o);if(typeof s!=`object`||!s){let e=JSON.stringify(s),n=t.values().next().value;return[`${a}${e}${n?` × ${n.reason}`:``}`]}let c=[],l=Array.isArray(s);c.push(`${n}${l?`[`:`{`}`);let u=[];if(l){let e=s;for(let n=0;n<e.length;n++){let r=t.get(String(n));u.push({content:JSON.stringify(e[n]),mark:r&&!r.missing?r:void 0})}}else{let e=s;for(let n of Object.keys(e)){let r=t.get(n);u.push({content:`"${n}": ${JSON.stringify(e[n])}`,mark:r&&!r.missing?r:void 0})}for(let[e,n]of t.entries())n.missing&&u.push({content:`"${e}": <missing>`,mark:n})}let d=0;return u.forEach((e,t)=>{if(e.mark==null)return;let n=+(t<u.length-1),r=e.content.length+n;r>d&&r<=dt&&(d=r)}),u.forEach((e,t)=>{let n=t<u.length-1?`,`:``,r=e.content+n;if(e.mark!=null){let t=` `.repeat(Math.max(2,d-r.length+2));c.push(`${a}${r}${t}× ${e.mark.reason}`)}else c.push(`${i}${r}`)}),c.push(n+(l?`]`:`}`)),c},bt=`__root__`,xt=(e,t,n)=>{let r=new Map;for(let t of e){let e=t.path.length===0?bt:`::${Je(pt(t.path))}`,n=r.get(e);n==null?r.set(e,[t]):n.push(t)}let i=[];for(let[e,a]of r){if(e===bt){i.push(a.map(e=>` × ${ht(e,t,n)}`).join(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`zod`);l=c(l,1);var u=[`create`,`delete`,`retrieve`,`update`],d=l.z.enum(u),f=Object.defineProperty,p=(e,t)=>{let n={};for(var r in e)f(n,r,{get:e[r],enumerable:!0});return t||f(n,Symbol.toStringTag,{value:`Module`}),n},m=e=>l.default.union([l.default.null().transform(()=>[]),e.array()]).default(()=>[]),h=e=>Array.isArray(e)?e:e==null?[]:[e],g=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>g(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},ee=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e)):e.filter(e=>e!=t)}),te=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>te(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},ne=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e.key)):e.filter(e=>e.key!==t)}),_=p({nullishToEmpty:()=>m,remove:()=>ee,removeKeyed:()=>ne,toArray:()=>h,upsert:()=>g,upsertKeyed:()=>te}),re=p({camelToSnake:()=>fe,capitalize:()=>pe,preserveCase:()=>ae,snakeToCamel:()=>de,toKebab:()=>_e,toProperNoun:()=>ve}),ie=`synnax.caseconv.preserveCase`,ae=e=>(e[ie]=!0,e),oe=e=>{if(typeof e!=`object`||!e)return!1;if(ie in e)return!0;let t=e._zod?.def;return t==null?!1:t.innerType&&oe(t.innerType)?!0:t.type===`union`&&Array.isArray(t.options)?t.options.some(oe):t.type===`pipe`?oe(t.in)||oe(t.out):!1},se=e=>{if(e==null)return;let t=e._zod?.def;if(t?.type===`array`&&t.element!=null)return t.element;if(t?.innerType!=null)return se(t.innerType);if(t?.type===`union`&&Array.isArray(t.options))for(let e of t.options){let t=se(e);if(t!=null)return t}},ce=e=>{if(e==null)return null;let t=e;if(t.shape!=null)return t.shape;if(typeof t.sourceType==`function`){let e=t.sourceType();if(e?.shape!=null)return e.shape}let n=t._zod?.def;if(n==null)return null;if(n.innerType!=null)return ce(n.innerType);if(n.type===`union`&&Array.isArray(n.options)){let e=null;for(let t of n.options){let n=ce(t);if(n!=null)if(e==null)e={...n};else for(let t in n)t in e||(e[t]=n[t])}return e}return n.type===`pipe`?ce(n.in)??ce(n.out):null},le=e=>{if(e.length===0)return e;let t=e.indexOf(`_`)===-1?e:e.replace(/_[a-z]/g,e=>e[1].toUpperCase()),n=t.charCodeAt(0);return n<65||n>90||t.length>1&&t.charCodeAt(1)>=65&&t.charCodeAt(1)<=90?t:String.fromCharCode(n+32)+t.slice(1)},ue=e=>{let t=(n,r=me)=>{if(typeof n==`string`)return e(n);if(Array.isArray(n)){let e=se(r.schema),i={recursive:r.recursive,recursiveInArray:r.recursiveInArray,schema:e};return n.map(e=>t(e,i))}if(!he(n)||r.schema!=null&&oe(r.schema))return n;let i=r.recursive??!0,a=r.recursiveInArray??i,o=r.schema,s={},c=n;if(`toJSON`in c&&typeof c.toJSON==`function`)return t(c.toJSON(),r);let l=ce(o),u={recursive:i,recursiveInArray:a,schema:void 0},d=Object.keys(c);for(let n=0;n<d.length;n++){let r=d[n],o=c[r],f=e(r),p=l==null?void 0:l[r]??l[f]??void 0;i&&(he(o)?ge(o)||(u.schema=p,o=t(o,u)):a&&Array.isArray(o)&&(u.schema=se(p),o=o.map(e=>{if(he(e)){if(!ge(e))return t(e,u)}else if(Array.isArray(e))return t({key:e},u).key;return e}))),s[f]=o}return s};return t},de=ue(le),fe=ue(e=>e.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`)),pe=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),me={recursive:!0,recursiveInArray:!0,schema:void 0},he=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ge=e=>e instanceof Uint8Array||e instanceof Number||e instanceof String,_e=ue(e=>e.replace(/[\s_]+/g,`-`).replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}-${n.toLowerCase()}`).toLowerCase()),ve=ue(e=>{if(e.length===0)return e;let t=e.replace(/[_-]/g,` `);return t=t.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/\s+/g,` `).trim(),t=t.replace(/\b\w/g,e=>e.toUpperCase()),t}),ye=e=>typeof e==`object`&&!!e&&!Array.isArray(e),be=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},xe=e=>e.nullable().transform(e=>e===null?void 0:e).optional(),Se=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return{present:!1,value:void 0};let t=n;if(!(e in t))return{present:!1,value:void 0};n=t[e]}return{present:!0,value:n}},Ce=(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(!Ce(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(!Ce(r,i))return!1}else if(r!==i)return!1}return!0},we=(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(!we(r,i))return!1}else if(r!==i)return!1}return!0},Te=(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)},Ee=(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)},De=((e,t,n={optional:!1})=>{let{optional:r,getter:i=Ee}=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)}),Oe=e=>Object.getOwnPropertySymbols(globalThis).includes(e),ke=(e,t)=>{let n=Symbol.for(e);if(!Oe(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},v=p({Canceled:()=>Ge,NONE:()=>`nil`,NotImplemented:()=>Ke,UNKNOWN:()=>Fe,Unknown:()=>Ue,createTyped:()=>Me,decode:()=>He,encode:()=>Ve,fromUnknown:()=>Pe,isTyped:()=>Ne,payloadZ:()=>We,register:()=>Be}),Ae=`sy_x_error`,je=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,Me=e=>class t extends Error{static discriminator=Ae;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=je(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return Me(`${e}.${t}`)}},Ne=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==Ae)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},Pe=e=>{if(e instanceof Error)return e;let t;try{t=JSON.stringify(e)??String(e)}catch{t=String(e)}return Error(t,{cause:e})},Fe=`unknown`,Ie=(e,t)=>({...e,name:t.name,stack:t.stack}),Le=(e,t)=>(t.name!=null&&(e.name=t.name),t.stack!=null&&(e.stack=t.stack),e),Re=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(Ne(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return Ie(n,e)}if(e instanceof Error)return Ie({type:Fe,data:e.message},e);if(typeof e==`string`)return{type:Fe,data:e};try{return{type:Fe,data:JSON.stringify(e)}}catch{return{type:Fe,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return Le(new Ue(e.data),e);for(let t of this.providers){let n=t.decode(e);if(n!=null)return Le(n,e)}return Le(new Ue(e.data),e)}},ze=ke(`synnax-error-registry`,()=>new Re),Be=({encode:e,decode:t})=>ze().register({encode:e,decode:t}),Ve=e=>ze().encode(e),He=e=>e==null?null:ze().decode(e),Ue=class extends Me(`unknown`){},We=l.z.object({type:l.z.string(),data:l.z.string(),name:l.z.string().optional(),stack:l.z.string().optional()}),Ge=class extends Me(`canceled`){},Ke=class extends Me(`not_implemented`){},qe=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if(ye(e)&&ye(n))for(let t in n)try{ye(n[t])?(t in e||Object.assign(e,{[t]:{}}),qe(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):Pe(e)}return qe(e,...t)},Je=e=>{if(e.length===0)return`<root>`;let t=``;return e.forEach((e,n)=>{typeof e==`number`?t+=`[${e}]`:n===0?t+=String(e):t+=`.${String(e)}`}),t},Ye=200,Xe=10,Ze=8,Qe=(e,t={})=>{let n=t.maxStringLength??Ye,r=t.maxArrayLength??Xe,i=t.maxDepth??Ze,a=(e,t)=>{if(e===null)return null;if(e===void 0)return`[undefined]`;let o=typeof e;if(o===`string`){let t=e;return t.length>n?`${t.slice(0,n)}…(+${t.length-n} chars)`:t}if(o===`number`||o===`boolean`)return e;if(o===`bigint`)return`${e.toString()}n`;if(o===`symbol`||o===`function`)return`[${o}]`;if(Array.isArray(e)){if(t>=i)return`[Array(${e.length})]`;let n=e.slice(0,r).map(e=>a(e,t+1));return e.length>r&&n.push(`…(+${e.length-r} more)`),n}if(be(e)){if(t>=i)return`[Object]`;let n={};for(let[r,i]of Object.entries(e))n[r]=a(i,t+1);return n}if(e instanceof Date)return e.toISOString();if(e instanceof Error)return`[Error: ${e.message}]`;try{return`[${Object.prototype.toString.call(e)}]`}catch{return`[unknown]`}};return a(e,0)},$e=(e,t={})=>JSON.stringify(Qe(e,t),null,2),et=p({ValueExtension:()=>nt,is:()=>st,isCrudeValueExtension:()=>tt,isHashable:()=>it,isNonZero:()=>ot,isStringer:()=>rt,isZero:()=>at}),tt=e=>typeof e==`object`&&!!e&&`value`in e,nt=class{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}},rt=e=>typeof e==`object`&&!!e&&`toString`in e,it=e=>typeof e==`object`&&!!e&&`hash`in e&&typeof e.hash==`function`,at=e=>{if(rt(e))return e?.toString().length===0;switch(typeof e){case`string`:return e.length===0;case`number`:return e===0;case`bigint`:return e===0n;case`boolean`:return!e;case`undefined`:return!0;case`object`:return e==null;default:return!1}},ot=e=>!at(e),st=e=>e==null||typeof e!=`object`&&typeof e!=`function`,ct=`value`,lt=`zod.parse`,ut=`✗`,dt=60,ft={maxStringLength:60,maxArrayLength:3,maxDepth:3},pt=e=>e.slice(0,-1),mt=e=>{switch(e.code){case`invalid_type`:return`expected ${e.expected}`;case`invalid_value`:return`expected one of ${JSON.stringify(e.values)}`;case`unrecognized_keys`:return`unexpected key`;case`too_small`:{let t=e.inclusive===!1?`>`:`>=`;return`${e.origin} too small: expected ${t}${e.minimum}`}case`too_big`:{let t=e.inclusive===!1?`<`:`<=`;return`${e.origin} too large: expected ${t}${e.maximum}`}case`invalid_format`:return`expected ${e.format} format`;case`not_multiple_of`:return`expected multiple of ${e.divisor}`;case`custom`:return e.message||`custom validation failed`;default:return e.message}},ht=(e,t,n)=>{let r=JSON.stringify(Qe(t,n));return`${mt(e)}, received ${r}`},gt=e=>{let t=0;for(let n of e){if(n.path.length>t&&(t=n.path.length),n.code===`invalid_union`&&`errors`in n)for(let e of n.errors){let n=gt(e);n>t&&(t=n)}if((n.code===`invalid_key`||n.code===`invalid_element`)&&`issues`in n){let e=gt(n.issues);e>t&&(t=e)}}return t},_t=(e,t=[])=>{let n=[];for(let r of e){let e=[...t,...r.path];if(r.code===`invalid_union`&&`errors`in r&&r.errors.length>0){let t=r.errors[0],i=gt(t);for(let e=1;e<r.errors.length;e++){let n=gt(r.errors[e]);n>i&&(t=r.errors[e],i=n)}n.push(..._t(t,e));continue}if(r.code===`invalid_element`&&`issues`in r&&`key`in r&&(typeof r.key==`string`||typeof r.key==`number`)){n.push(..._t(r.issues,[...e,r.key]));continue}if(r.code===`invalid_key`&&`issues`in r){n.push(..._t(r.issues,e));continue}n.push({...r,path:e})}return n},vt=e=>{let t=[];for(let n of e){if(n.code===`unrecognized_keys`&&`keys`in n&&Array.isArray(n.keys)){for(let e of n.keys)t.push({...n,path:[...n.path,e]});continue}t.push(n)}return t},yt=(e,t,n,r)=>{let i=`${n} `,a=`${n+ut} `,o={...ft,...r};if(Array.isArray(e)){let e=-1;for(let n of t.keys()){let t=Number(n);Number.isInteger(t)&&t>e&&(e=t)}let n=o.maxArrayLength??3;e>=n&&(o={...o,maxArrayLength:e+2})}let s=Qe(e,o);if(typeof s!=`object`||!s){let e=JSON.stringify(s),n=t.values().next().value;return[`${a}${e}${n?` × ${n.reason}`:``}`]}let c=[],l=Array.isArray(s);c.push(`${n}${l?`[`:`{`}`);let u=[];if(l){let e=s;for(let n=0;n<e.length;n++){let r=t.get(String(n));u.push({content:JSON.stringify(e[n]),mark:r&&!r.missing?r:void 0})}}else{let e=s;for(let n of Object.keys(e)){let r=t.get(n);u.push({content:`"${n}": ${JSON.stringify(e[n])}`,mark:r&&!r.missing?r:void 0})}for(let[e,n]of t.entries())n.missing&&u.push({content:`"${e}": <missing>`,mark:n})}let d=0;return u.forEach((e,t)=>{if(e.mark==null)return;let n=+(t<u.length-1),r=e.content.length+n;r>d&&r<=dt&&(d=r)}),u.forEach((e,t)=>{let n=t<u.length-1?`,`:``,r=e.content+n;if(e.mark!=null){let t=` `.repeat(Math.max(2,d-r.length+2));c.push(`${a}${r}${t}× ${e.mark.reason}`)}else c.push(`${i}${r}`)}),c.push(n+(l?`]`:`}`)),c},bt=`__root__`,xt=(e,t,n)=>{let r=new Map;for(let t of e){let e=t.path.length===0?bt:`::${Je(pt(t.path))}`,n=r.get(e);n==null?r.set(e,[t]):n.push(t)}let i=[];for(let[e,a]of r){if(e===bt){i.push(a.map(e=>` × ${ht(e,t,n)}`).join(`
|
|
2
2
|
`));continue}let r=pt(a[0].path),{present:o,value:s}=Se(t,r);if(!o){i.push(a.map(e=>` at ${Je(e.path)}\n × ${ht(e,t,n)}`).join(`
|
|
3
3
|
`));continue}let c=new Map;for(let e of a){let n=String(e.path[e.path.length-1]),r=Se(t,e.path);c.set(n,{reason:mt(e),missing:!r.present})}let l=r.length===0,u=yt(s,c,l?` `:` `,n);l?i.push(u.join(`
|
|
4
4
|
`)):i.push([` at ${Je(r)}`,...u].join(`
|
|
@@ -6,32 +6,32 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
6
6
|
|
|
7
7
|
`)},St=(e,t)=>{let n=Object.entries(e);return n.every(([,e])=>st(e))?n.map(([e,t])=>`${e}=${typeof t==`string`?t:String(t)}`).join(`, `):$e(e,t)},Ct=({issues:e,input:t,label:n,context:r,formatOptions:i})=>{let a=i??{},o=vt(_t(e)),s=[`Failed to parse ${n} (${o.length===1?`1 issue`:`${o.length} issues`})`];return s.push(xt(o,t,a)),r!=null&&Object.keys(r).length>0&&s.push(` context: ${St(r,a)}`),s.join(`
|
|
8
8
|
|
|
9
|
-
`)},wt=class extends
|
|
9
|
+
`)},wt=class extends Me(lt){issues;input;label;context;constructor({issues:e,input:t,label:n,context:r,cause:i,formatOptions:a}){super(Ct({issues:e,input:t,label:n,context:r,formatOptions:a}),{cause:i}),this.issues=e,this.input=t,this.label=n,this.context=r}toStatus(){let e={input:Qe(this.input),issues:this.issues};return this.context!=null&&(e.context=this.context),{message:`Failed to parse ${this.label}`,description:this.message,details:e}}};Be({encode:e=>{if(!wt.matches(e))return null;let t=e,n={label:t.label,context:t.context,issues:t.issues,input:Qe(t.input)};return{type:lt,data:JSON.stringify(n)}},decode:e=>{if(e.type!==lt)return null;let t=JSON.parse(e.data);return new wt({issues:t.issues,input:t.input,label:t.label,context:t.context})}});var Tt=(e,t,n={})=>{let r=e.safeParse(t);if(r.success)return r.data;throw new wt({issues:r.error.issues,input:t,label:n.label??ct,context:n.context,cause:r.error})},Et=2**12-1,Dt=2**16-1,Ot=2**20-1,kt=-128,At=-(2**15),jt=2**15-1,Mt=-(2n**63n),Nt=2n**63n-1n,Pt=-(2**63),Ft=2**63-1,It=e=>(t,n)=>{if(typeof t==`bigint`){if(Vt(n))return e(t,BigInt(n));let r=e(Number(t),Number(n));return typeof r==`number`?BigInt(Math.round(r)):r}return e(Number(t),Number(n))},Lt=It((e,t)=>e-t),Rt=It((e,t)=>e+t),zt=(e,t)=>{let n=typeof e==`bigint`,r=typeof t==`bigint`;return n&&r?e===t:n&&Vt(t)?e===BigInt(t):r&&Vt(e)?t===BigInt(e):e===t},Bt=It((e,t)=>e<=t?e:t),Vt=e=>typeof e==`bigint`?!0:Number.isInteger(e),Ht=e=>typeof e==`bigint`?e<0n?-e:e:e<0?-e:e,Ut=It((e,t)=>e*t),Wt=It((e,t)=>e/t),Gt=p({ALIGNMENTS:()=>ln,ANGULAR_DIRECTIONS:()=>nn,CENTER_LOCATIONS:()=>an,DIMENSIONS:()=>pn,DIRECTIONS:()=>en,LOCATIONS:()=>sn,ORDERS:()=>dn,OUTER_LOCATIONS:()=>Qt,SIGNED_DIMENSIONS:()=>hn,STICKY_UNITS:()=>Xt,X_LOCATIONS:()=>Kt,Y_LOCATIONS:()=>Jt,alignmentZ:()=>un,angularDirectionZ:()=>rn,boundsZ:()=>Cn,centerLocationZ:()=>on,clientXYZ:()=>Sn,cornerLocationZ:()=>vn,dimensionZ:()=>mn,dimensionsZ:()=>bn,directionZ:()=>tn,locationZ:()=>cn,orderZ:()=>fn,outerLocationZ:()=>$t,signedDimensionZ:()=>gn,signedDimensionsZ:()=>xn,stickyUnitZ:()=>Zt,stickyUnitsZ:()=>yn,stickyXYZ:()=>Tn,viewportZ:()=>wn,xLocationZ:()=>qt,xyZ:()=>_n,yLocationZ:()=>Yt}),Kt=[`left`,`right`],qt=l.z.enum(Kt),Jt=[`top`,`bottom`],Yt=l.z.enum(Jt),Xt=[`px`,`decimal`],Zt=l.z.enum(Xt),Qt=[`top`,`right`,`bottom`,`left`],$t=l.z.enum(Qt),en=[`x`,`y`],tn=l.z.enum(en),nn=[`clockwise`,`counterclockwise`],rn=l.z.enum(nn),an=[`center`],on=l.z.enum(an),sn=[`top`,`right`,`bottom`,`left`,`center`],cn=l.z.enum(sn),ln=[`start`,`center`,`end`],un=l.z.enum(ln),dn=[`first`,`last`],fn=l.z.enum(dn),pn=[`width`,`height`],mn=l.z.enum(pn),hn=[`signedWidth`,`signedHeight`],gn=l.z.enum(hn),_n=l.z.object({x:l.z.number(),y:l.z.number()}),vn=l.z.object({x:qt,y:Yt}),yn=l.z.object({x:Zt,y:Zt}),bn=l.z.object({width:l.z.number(),height:l.z.number()}),xn=l.z.object({signedWidth:l.z.number(),signedHeight:l.z.number()}),Sn=l.z.object({clientX:l.z.number(),clientY:l.z.number()}),Cn=e=>l.z.object({lower:e??l.z.number(),upper:e??l.z.number()}),wn=l.z.object({zoom:l.z.number().default(1),position:_n}),Tn=l.z.object({x:l.z.number(),y:l.z.number(),root:vn.optional(),units:yn.optional()}),En=l.z.tuple([l.z.number(),l.z.number()]),y=(e,t,n)=>{let r={};if(typeof t==`object`&&(n=t,t=void 0),n={makeValid:!0,...n},typeof e==`number`||typeof e==`bigint`)t==null?(r.lower=typeof e==`bigint`?0n:0,r.upper=e):(r.lower=e,r.upper=t);else if(Array.isArray(e)){if(e.length!==2)throw Error(`bounds: expected array of length 2`);[r.lower,r.upper]=e}else r.lower=e.lower,r.upper=e.upper;return n?.makeValid?Dn(r):r};Object.freeze({lower:0,upper:0}),Object.freeze({lower:-1/0,upper:1/0}),Object.freeze({lower:0,upper:1}),Object.freeze({lower:-1,upper:1});var Dn=e=>e.lower>e.upper?{lower:e.upper,upper:e.lower}:e,On=(e,t)=>{let n=y(e);return t<n.lower?n.lower:t>=n.upper?n.upper-(typeof n.upper==`number`?1:1n):t},kn=(e,t)=>{let n=y(e);if(typeof t==`number`||typeof t==`bigint`)return t>=n.lower&&t<n.upper;let r=y(t);return r.lower>=n.lower&&r.upper<=n.upper},An=e=>({lower:Math.min(...e.map(e=>y(e).lower)),upper:Math.max(...e.map(e=>y(e).upper))}),jn=(e,t,n)=>{let r=e.map(e=>y(e)),i=n>0?1:n<0?-1:0;if(i===0)return t;let a=n,o=t;for(;zt(a,0)===!1;){let e=r.findIndex(e=>i>0?o>=e.lower&&o<e.upper:o>e.lower&&o<=e.upper);if(e!==-1){let t=r[e],n;if(n=i>0?Lt(t.upper,o):Lt(o,t.lower),n>0){let e=Bt(Ht(a),n);if(o=Rt(o,i>0?e:-e),a=Lt(a,i>0?e:-e),zt(a,0))return o;continue}}if(i>0){let e=r.filter(e=>e.lower>o);if(e.length>0)o=e[0].lower;else return o}else{let e=r.filter(e=>e.upper<o);if(e.length>0)o=e[e.length-1].upper;else return o}}return o},Mn=(e,t,n)=>{let r=e.map(e=>y(e));if(t===n)return typeof t==`bigint`?0n:0;let i=y(t<n?[t,n]:[n,t]),a=typeof t==`bigint`?0n:0;for(let e of r){let t=e.lower>i.lower?e.lower:i.lower,n=e.upper<i.upper?e.upper:i.upper;if(t<n){let e=n-t;a+=e}}return a},Nn=l.z.int().min(kt).max(127),Pn=l.z.int().min(At).max(jt),Fn=l.z.int().min(Pt).max(Ft),In=l.z.int().min(0).max(255),Ln=l.z.int().min(0).max(Et),Rn=l.z.int().min(0).max(Dt),zn=l.z.int().min(0).max(Ot),Bn=e=>l.default.array(e).or(e.transform(e=>[e])),Vn=e=>e._zod.def.output,Hn=e=>Te(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`]}),Un=(e,t)=>{if(e==null)return null;let n=e[t];return n==null&&typeof e==`object`&&`sourceType`in e?e.sourceType()[t]:n},Wn=((e,t,n)=>t===``?e:De(Un(e,`shape`),Hn(t),{...n,getter:Un})),b=p({ParseError:()=>wt,functionOutput:()=>Vn,getFieldSchema:()=>Wn,getFieldSchemaPath:()=>Hn,int16:()=>Pn,int64:()=>Fn,int8:()=>Nn,nullToUndefined:()=>xe,parse:()=>Tt,toArray:()=>Bn,uint12:()=>Ln,uint16:()=>Rn,uint20:()=>zn,uint8:()=>In}),Gn=p({CSVCodec:()=>qn,CSV_CODEC:()=>Xn,ENCODERS:()=>Qn,JSONCodec:()=>Kn,JSON_CODEC:()=>Yn,TEXT_CODEC:()=>Zn,TextCodec:()=>Jn}),Kn=class{contentType=`application/json`;decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e,t){return this.encoder.encode(this.encodeString(e,t))}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){let n=de(JSON.parse(e),{schema:t});return t==null?n:Tt(t,n)}encodeString(e,t){let n=fe((t==null?e:Tt(t,e))??{},{schema:t});return JSON.stringify(n,(e,t)=>ArrayBuffer.isView(t)?Array.from(t):typeof t==`bigint`?t.toString():t)}},qn=class{contentType=`text/csv`;encode(e){let t=this.encodeString(e);return new TextEncoder().encode(t)}decode(e,t){let n=new TextDecoder().decode(e);return this.decodeString(n,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!ye(e[0]))throw Error(`Payload must be an array of objects`);let t=Object.keys(e[0]),n=[t.join(`,`)];return e.forEach(e=>{let r=t.map(t=>JSON.stringify(e[t]??``));n.push(r.join(`,`))}),n.join(`
|
|
10
10
|
`)}decodeString(e,t){let[n,...r]=e.trim().split(`
|
|
11
|
-
`).map(e=>e.trim());if(n.length===0)return t==null?{}:t.parse({});let i=n.split(`,`).map(e=>e.trim()),a={};return i.forEach(e=>{a[e]=[]}),r.forEach(e=>{let t=e.split(`,`).map(e=>e.trim());i.forEach((e,n)=>{let r=this.parseValue(t[n]);r!=null&&a[e].push(r)})}),t==null?a:t.parse(a)}parseValue(e){if(e==null||e.length===0)return null;let t=Number(e);return isNaN(t)?e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e:t}},Jn=class{contentType=`text/plain`;encode(e){if(typeof e!=`string`)throw Error(`TextCodec.encode payload must be a string`);return new TextEncoder().encode(e)}decode(e,t){let n=new TextDecoder().decode(e);return t==null?n:t.parse(n)}},Yn=new Kn,Xn=new qn,Zn=new Jn,Qn=[Yn],$n=365,er=30,tr=l.z.union([l.z.tuple([l.z.int()]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12)]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12),l.z.int().min(1).max(31)])]),nr=(e,t)=>{let n=new b(t);if(![x.DAY,x.HOUR,x.MINUTE,x.SECOND,x.MILLISECOND,x.MICROSECOND,x.NANOSECOND].some(e=>e.equals(n)))throw Error(`Invalid argument for remainder. Must be an even TimeSpan or Timestamp`);let r=e.valueOf()%n.valueOf();return e instanceof b?new b(r):new x(r)},b=class e extends nt{hash(){return this.value.toString()}constructor(t,n=`UTC`){if(t==null)super(e.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*e.MILLISECOND.valueOf());else if(typeof t==`string`)super(e.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(e.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n===`local`&&(r=e.utcOffset.valueOf()),typeof t==`number`&&(isFinite(t)?t=t===Ft?Nt:Math.trunc(t):(isNaN(t)&&(t=0),t=t===1/0?e.MAX:e.MIN)),tt(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){let i=new Date(t,n-1,r,0,0,0,0);return new e(BigInt(i.getTime())*e.MILLISECOND.valueOf()).truncate(e.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n=`UTC`){let[r,i,a]=t.split(`:`),o=`00`,s=`00`;a!=null&&([o,s]=a.split(`.`));let c=e.hours(parseInt(r??`00`,10)).add(e.minutes(parseInt(i??`00`,10))).add(e.seconds(parseInt(o??`00`,10))).add(e.milliseconds(parseInt(s??`00`,10)));return n===`local`&&(c=c.add(e.utcOffset)),c.valueOf()}static parseDateTimeString(t,n=`UTC`){if(!t.includes(`/`)&&!t.includes(`-`))return e.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let r=t,i=0;if(t.includes(`.`)){let e=t.split(`.`);r=e[0];let n=e[1]||`0`;i=parseInt(n.padEnd(3,`0`).slice(0,3),10)}let a=n===`local`?new Date(r.replace(`T`,` `)):new Date(`${r}Z`);return BigInt(a.getTime())*e.MILLISECOND.valueOf()+BigInt(i)*e.MILLISECOND.valueOf()}let r=new Date(t);return t.includes(`:`)||r.setUTCHours(0,0,0,0),new e(BigInt(r.getTime())*e.MILLISECOND.valueOf(),n).valueOf()}toISOString(t=`UTC`){if(t===`UTC`)return this.date().toISOString();let n=this.date(),r=new x(BigInt(n.getTimezoneOffset())*e.MINUTE.valueOf());return this.sub(r).date().toISOString()}timeString(e=!1,t=`UTC`){let n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){let e=this.date();return`${e.toLocaleString(`default`,{month:`short`})} ${e.toLocaleString(`default`,{day:`numeric`})}`}static get utcOffset(){return new x(BigInt(new Date().getTimezoneOffset())*e.MINUTE.valueOf())}static since(t){return new e().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new e(t).valueOf()}span(e){return this.range(e).span}range(e){return new C(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new e(t).valueOf()}afterEq(t){return this.valueOf()>=new e(t).valueOf()}before(t){return this.valueOf()<new e(t).valueOf()}beforeEq(t){return this.valueOf()<=new e(t).valueOf()}add(t){return new e(Rt(this.valueOf(),new x(t).valueOf()))}sub(t){return new e(Lt(this.valueOf(),new x(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(x.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(x.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(x.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(x.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){let n=this.date();return n.setUTCFullYear(t),new e(n)}setLocalYear(t){let n=this.date();return n.setFullYear(t),new e(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){let n=this.date();return n.setUTCMonth(t),new e(n)}setLocalMonth(t){let n=this.date();return n.setMonth(t),new e(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){let n=this.date();return n.setUTCDate(t),new e(n)}setLocalDay(t){let n=this.date();return n.setDate(t),new e(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){let n=this.date();return n.setHours(t),new e(n)}setHour(t){let n=this.date();return n.setUTCHours(t),new e(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){let n=this.date();return n.setUTCMinutes(t),new e(n)}setLocalMinute(t){let n=this.date();return n.setMinutes(t),new e(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){let n=this.date();return n.setUTCSeconds(t),new e(n)}setLocalSecond(t){let n=this.date();return n.setSeconds(t),new e(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){let n=this.date();return n.setUTCMilliseconds(t),new e(n)}setLocalMillisecond(t){let n=this.date();return n.setMilliseconds(t),new e(n)}toString(e=`ISO`,t=`UTC`){switch(e){case`ISODate`:return this.toISOString(t).slice(0,10);case`time`:return this.timeString(!1,t);case`preciseTime`:return this.timeString(!0,t);case`date`:return this.dateString();case`preciseDate`:return`${this.dateString()} ${this.timeString(!0,t)}`;case`dateTime`:return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}remainder(e){return nr(this,e)}get isToday(){return this.truncate(x.DAY).equals(e.now().truncate(x.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(x.days(30))?`date`:e.greaterThanOrEqual(x.DAY)?`dateTime`:e.greaterThanOrEqual(x.HOUR)?`time`:`preciseTime`}static now(){return new e(new Date)}static max(...t){let n=e.MIN;for(let r of t){let t=new e(r);t.after(n)&&(n=t)}return n}static min(...t){let n=e.MAX;for(let r of t){let t=new e(r);t.before(n)&&(n=t)}return n}static nanoseconds(t,n=`UTC`){return new e(t,n)}static NANOSECOND=e.nanoseconds(1);static microseconds(t,n=`UTC`){return e.nanoseconds(t*1e3,n)}static MICROSECOND=e.microseconds(1);static milliseconds(t,n=`UTC`){return e.microseconds(t*1e3,n)}static MILLISECOND=e.milliseconds(1);static seconds(t,n=`UTC`){return e.milliseconds(t*1e3,n)}static SECOND=e.seconds(1);static minutes(t,n=`UTC`){return e.seconds(t*60,n)}static MINUTE=e.minutes(1);static hours(t,n=`UTC`){return e.minutes(t*60,n)}static HOUR=e.hours(1);static days(t,n=`UTC`){return e.hours(t*24,n)}static DAY=e.days(1);static MAX=new e(Nt);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.instanceof(e),l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.date().transform(t=>new e(t)),l.z.custom(e=>e instanceof x).transform(t=>new e(t)),tr.transform(t=>new e(t))]);static sort(e,t){return Number(e.valueOf()-t.valueOf())}},x=class e extends nt{constructor(e){typeof e==`number`&&(e=Math.trunc(e.valueOf())),tt(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(t){return t instanceof e?t:t instanceof rr?t.period:t instanceof b?new e(t):(tt(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.seconds(t):new e(t))}static fromMilliseconds(t){return t instanceof e?t:t instanceof rr?t.period:t instanceof b?new e(t):(tt(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.milliseconds(t):new e(t))}valueOf(){return this.value}hash(){return this.value.toString()}lessThan(t){return this.valueOf()<new e(t).valueOf()}greaterThan(t){return this.valueOf()>new e(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new e(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new e(t).valueOf()}remainder(e){return nr(this,e)}truncate(t){return new e(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t=`full`){if(t===`semantic`)return this.toSemanticString();let n=this.truncate(e.DAY),r=this.truncate(e.HOUR),i=this.truncate(e.MINUTE),a=this.truncate(e.SECOND),o=this.truncate(e.MILLISECOND),s=this.truncate(e.MICROSECOND),c=this.truncate(e.NANOSECOND),l=n,u=r.sub(n),d=i.sub(r),f=a.sub(i),p=o.sub(a),m=s.sub(o),h=c.sub(s),g=``;return l.isZero||(g+=`${l.days}d `),u.isZero||(g+=`${u.hours}h `),d.isZero||(g+=`${d.minutes}m `),f.isZero||(g+=`${f.seconds}s `),p.isZero||(g+=`${p.milliseconds}ms `),m.isZero||(g+=`${m.microseconds}µs `),h.isZero||(g+=`${h.nanoseconds}ns`),g.trim()}toSemanticString(){let t=new e(this.valueOf()<0n?-this.valueOf():this.valueOf()),n=this.valueOf()<0n;if(t.valueOf()===0n)return`0s`;if(t.lessThan(e.SECOND))return`< 1s`;let r=t.days,i=t.hours,a=t.minutes,o=t.seconds,s=Math.floor(r/$n),c=Math.floor(r/er),l=Math.floor(r/7),u=Math.floor(r),d=Math.floor(i),f=Math.floor(a),p=Math.floor(o),m=n?`-`:``;if(s>=1){let e=`${s}y`;if(s<2){let t=Math.floor(r%$n/er);t>0&&(e+=` ${t}mo`)}return m+e}if(l>=1&&r<er&&r%7==0){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(c>=1){let e=`${c}mo`;if(c<3){let t=Math.floor(r%er);t>0&&(e+=` ${t}d`)}return m+e}if(l>=1){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(u>=1){let e=`${u}d`,t=Math.floor(i-u*24);return u<2&&t>0&&(e+=` ${t}h`),m+e}if(d>=1){let e=`${d}h`;if(d<3){let t=Math.floor(a-d*60);t>0&&(e+=` ${t}m`)}return m+e}if(f>=1){let e=`${f}m`;if(f<5){let t=Math.floor(o-f*60);t>0&&(e+=` ${t}s`)}return m+e}return`${m}${p}s`}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(e.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(e.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(e.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(e.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new e(t).valueOf()}add(t){return new e(this.valueOf()+new e(t).valueOf())}sub(t){return new e(this.valueOf()-new e(t).valueOf())}abs(){let t=this.valueOf();return new e(t<0n?-t:t)}static nanoseconds(t=1){return new e(t)}static NANOSECOND=e.nanoseconds(1);static microseconds(t=1){return e.nanoseconds(Ut(t,1e3))}static MICROSECOND=e.microseconds(1);static milliseconds(t=1){return e.microseconds(Ut(t,1e3))}static MILLISECOND=e.milliseconds(1);static seconds(t=1){return e.milliseconds(Ut(t,1e3))}static SECOND=e.seconds(1);static minutes(t=1){return e.seconds(Ut(t,60))}static MINUTE=e.minutes(1);static hours(t){return e.minutes(Ut(t,60))}static HOUR=e.hours(1);static days(t){return e.hours(Ut(t,24))}static DAY=e.days(1);static MAX=new e(Nt);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.instanceof(e),l.z.instanceof(b).transform(t=>new e(t)),l.z.custom(e=>e instanceof rr).transform(t=>new e(t))])},rr=class e extends nt{constructor(e){tt(e)&&(e=e.value),super(e.valueOf())}hash(){return this.value.toString()}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new e(t).valueOf()}get period(){return x.seconds(1/this.valueOf())}sampleCount(e){return new x(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new S(t).valueOf()}span(e){return x.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/new S(t).valueOf())}add(t){return new e(Rt(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(Lt(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}static hz(t){return new e(t)}static khz(t){return e.hz(t*1e3)}static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},S=class e extends nt{constructor(e){tt(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new ir(e*this.valueOf())}add(t){return new e(Rt(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(Lt(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}static UNKNOWN=new e(0);static BIT128=new e(16);static BIT64=new e(8);static BIT32=new e(4);static BIT16=new e(2);static BIT8=new e(1);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},C=class e{hash(){return`${this.start.hash()}-${this.end.hash()}`}start;end;constructor(e,t){typeof e==`object`&&`start`in e?(this.start=new b(e.start),this.end=new b(e.end)):(this.start=new b(e),this.end=new b(t))}get span(){return new x(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new e(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=x.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString(`preciseDate`)} - ${this.span.toString()}`}overlapsWith(e,t=x.ZERO){e=e.makeValid();let n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;let r=b.max(n.start,e.start),i=b.min(n.end,e.end);return i.before(r)?!1:new x(i.sub(r)).greaterThanOrEqual(t)}contains(t){return t instanceof e?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){let n=new e(this.start,this.end);return t.start.after(this.start)&&(n.start=t.start),t.start.after(this.end)&&(n.end=t.start),t.end.before(this.end)&&(n.end=t.end),t.end.before(this.start)&&(n.start=t.end),n}static max(...t){return new e(b.min(...t.map(e=>e.start)),b.max(...t.map(e=>e.end)))}static MAX=new e(b.MIN,b.MAX);static ZERO=new e(b.ZERO,b.ZERO);static z=l.z.union([l.z.object({start:b.z,end:b.z}).transform(t=>new e(t.start,t.end)),l.z.instanceof(e)]);static boundedZ=e.z.refine(({isValid:e})=>e,{message:`Time range start time must be before or equal to time range end time`}).refine(({end:e})=>e.valueOf()<=Nt,{message:`Time range end time must be less than or equal to the maximum value of an int64`}).refine(({start:e})=>e.valueOf()>=Mt,{message:`Time range start time must be greater than or equal to the minimum value of an int64`});static sort(e,t){return b.sort(e.start,t.start)||b.sort(e.end,t.end)}static merge(...t){return e.max(...t.map(t=>new e(t).makeValid()))}},w=class e extends nt{hash(){return this.value}constructor(t){if(tt(t)&&(t=t.value),t instanceof e||typeof t==`string`||typeof t.valueOf()==`string`)super(t.valueOf());else{let n=e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){let t=e.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(e=>this.equals(e))}toString(t=!1){return t?e.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(e.JSON)||this.equals(e.STRING)||this.equals(e.BYTES)}get isNumeric(){return!this.isVariable&&!this.equals(e.UUID)}get isInteger(){let e=this.toString();return e.startsWith(`int`)||e.startsWith(`uint`)}get isFloat(){return this.toString().startsWith(`float`)}get density(){let t=e.DENSITIES.get(this.toString());if(t==null)throw Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(e.UINT8)||this.equals(e.UINT16)||this.equals(e.UINT32)||this.equals(e.UINT64)}get isSignedInteger(){return this.equals(e.INT8)||this.equals(e.INT16)||this.equals(e.INT32)||this.equals(e.INT64)}canSafelyCastTo(t){return this.equals(t)?!0:!this.isNumeric||!t.isNumeric||this.isVariable||t.isVariable||this.isUnsignedInteger&&t.isSignedInteger?!1:this.isFloat?t.isFloat&&this.density.valueOf()<=t.density.valueOf():this.equals(e.INT32)&&t.equals(e.FLOAT64)||this.equals(e.INT8)&&t.equals(e.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return e.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new e(`unknown`);static FLOAT64=new e(`float64`);static FLOAT32=new e(`float32`);static INT64=new e(`int64`);static INT32=new e(`int32`);static INT16=new e(`int16`);static INT8=new e(`int8`);static UINT64=new e(`uint64`);static UINT32=new e(`uint32`);static UINT16=new e(`uint16`);static UINT8=new e(`uint8`);static TIMESTAMP=new e(`timestamp`);static UUID=new e(`uuid`);static STRING=new e(`string`);static JSON=new e(`json`);static BYTES=new e(`bytes`);static ARRAY_CONSTRUCTORS=new Map([[e.UINT8.toString(),Uint8Array],[e.UINT16.toString(),Uint16Array],[e.UINT32.toString(),Uint32Array],[e.UINT64.toString(),BigUint64Array],[e.FLOAT32.toString(),Float32Array],[e.FLOAT64.toString(),Float64Array],[e.INT8.toString(),Int8Array],[e.INT16.toString(),Int16Array],[e.INT32.toString(),Int32Array],[e.INT64.toString(),BigInt64Array],[e.TIMESTAMP.toString(),BigInt64Array],[e.STRING.toString(),Uint8Array],[e.JSON.toString(),Uint8Array],[e.UUID.toString(),Uint8Array],[e.BYTES.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,e.UINT8],[Uint16Array.name,e.UINT16],[Uint32Array.name,e.UINT32],[BigUint64Array.name,e.UINT64],[Float32Array.name,e.FLOAT32],[Float64Array.name,e.FLOAT64],[Int8Array.name,e.INT8],[Int16Array.name,e.INT16],[Int32Array.name,e.INT32],[BigInt64Array.name,e.INT64]]);static DENSITIES=new Map([[e.UINT8.toString(),S.BIT8],[e.UINT16.toString(),S.BIT16],[e.UINT32.toString(),S.BIT32],[e.UINT64.toString(),S.BIT64],[e.FLOAT32.toString(),S.BIT32],[e.FLOAT64.toString(),S.BIT64],[e.INT8.toString(),S.BIT8],[e.INT16.toString(),S.BIT16],[e.INT32.toString(),S.BIT32],[e.INT64.toString(),S.BIT64],[e.TIMESTAMP.toString(),S.BIT64],[e.STRING.toString(),S.UNKNOWN],[e.JSON.toString(),S.UNKNOWN],[e.UUID.toString(),S.BIT128],[e.BYTES.toString(),S.UNKNOWN]]);static ALL=[e.UNKNOWN,e.UINT8,e.UINT16,e.UINT32,e.UINT64,e.INT8,e.INT16,e.INT32,e.INT64,e.FLOAT32,e.FLOAT64,e.TIMESTAMP,e.UUID,e.STRING,e.JSON,e.BYTES];static SHORT_STRINGS=new Map([[e.UINT8.toString(),`u8`],[e.UINT16.toString(),`u16`],[e.UINT32.toString(),`u32`],[e.UINT64.toString(),`u64`],[e.INT8.toString(),`i8`],[e.INT16.toString(),`i16`],[e.INT32.toString(),`i32`],[e.INT64.toString(),`i64`],[e.FLOAT32.toString(),`f32`],[e.FLOAT64.toString(),`f64`],[e.TIMESTAMP.toString(),`ts`],[e.UUID.toString(),`uuid`],[e.STRING.toString(),`str`],[e.JSON.toString(),`json`],[e.BYTES.toString(),`bytes`]]);static BIG_INT_TYPES=[e.INT64,e.UINT64,e.TIMESTAMP];static z=l.z.union([l.z.string().transform(t=>new e(t)),l.z.instanceof(e)])},ir=class e extends nt{constructor(e){tt(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return tt(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return tt(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(t){return tt(t)&&(t=t.value),new e(Rt(this.valueOf(),t.valueOf()))}sub(t){return tt(t)&&(t=t.value),new e(Lt(this.valueOf(),t.valueOf()))}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}truncate(t){return new e(Math.trunc(this.valueOf()/new e(t).valueOf())*new e(t).valueOf())}remainder(t){return e.bytes(this.valueOf()%new e(t).valueOf())}get gigabytes(){return this.valueOf()/e.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/e.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/e.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/e.TERABYTE.valueOf()}toString(){let t=this.truncate(e.TERABYTE),n=this.truncate(e.GIGABYTE),r=this.truncate(e.MEGABYTE),i=this.truncate(e.KILOBYTE),a=this.truncate(e.BYTE),o=t,s=n.sub(t),c=r.sub(n),l=i.sub(r),u=a.sub(i),d=``;return o.isZero||(d+=`${o.terabytes}TB `),s.isZero||(d+=`${s.gigabytes}GB `),c.isZero||(d+=`${c.megabytes}MB `),l.isZero||(d+=`${l.kilobytes}KB `),(!u.isZero||d===``)&&(d+=`${u.valueOf()}B`),d.trim()}static bytes(t=1){return new e(t)}static BYTE=new e(1);static kilobytes(t=1){return e.bytes(new e(t).valueOf()*1e3)}static KILOBYTE=e.kilobytes(1);static megabytes(t=1){return e.kilobytes(new e(t).valueOf()*1e3)}static MEGABYTE=e.megabytes(1);static gigabytes(t=1){return e.megabytes(new e(t).valueOf()*1e3)}static GIGABYTE=e.gigabytes(1);static terabytes(t){return e.gigabytes(new e(t).valueOf()*1e3)}static TERABYTE=e.terabytes(1);static ZERO=new e(0);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)]);get isZero(){return this.valueOf()===0}},ar=l.z.object({start:l.z.number(),end:l.z.number()}),or=l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]),sr=e=>{let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===`bigint`||e instanceof b||e instanceof x||e instanceof Date},cr=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(BigInt(n.valueOf())-BigInt(r.valueOf())):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):Lt(n,r),lr=C.z,ur=b.z,dr=x.z,fr=rr.z,pr=ir.z,mr=w.z,hr=C.boundedZ,gr=class{now;localStartT=new b(0);lastSkew=x.ZERO;constructor(e=()=>b.now()){this.now=e}start(){this.localStartT=this.now()}end(e){let t=this.now().span(this.localStartT).valueOf()/2n,n=this.localStartT.add(t);this.lastSkew=new x(n.valueOf()-e.valueOf())}get skew(){return this.lastSkew}exceeds(e){let t=this.skew.valueOf();return(t<0n?-t:t)>new x(e).valueOf()}},_r=p({by:()=>yr,unique:()=>vr}),vr=e=>[...new Set(e)],yr=(e,t,n=!0)=>{let r=new Map;return e.forEach(e=>{let i=t(e);if(r.has(i)){if(n)return;r.delete(i)}r.set(i,e)}),Array.from(r.values())},br=(e,t=!1)=>{let n=rt(e)?`stringer`:typeof e,r;switch(n){case`string`:r=(e,t)=>e.localeCompare(t);break;case`stringer`:r=(e,t)=>e.toString().localeCompare(t.toString());break;case`number`:r=(e,t)=>Number(e)-Number(t);break;case`bigint`:r=(e,t)=>BigInt(e)-BigInt(t)>0n?1:-1;break;case`boolean`:r=(e,t)=>Number(e)-Number(t);break;case`undefined`:r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?Or(r):r},xr=(e,t,n)=>{let r=br(t[e],n);return(t,n)=>r(t[e],n[e])},Sr=(e,t)=>e.length===t.length?e.every((e,n)=>e===t[n])?0:-1:e.length-t.length,Cr=(e,t)=>{if(e.length!==t.length)return e.length-t.length;if(e.length===0)return 0;let n=br(e[0]),r=[...e].sort(n),i=[...t].sort(n);return r.every((e,t)=>e===i[t])?0:-1},wr=(e,t)=>Cr(vr(e),vr(t)),Tr=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0},Er=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Dr=(e,t)=>e===t?0:e===`first`&&t===`last`?1:-1,Or=e=>(t,n)=>e(n,t),kr=e=>e<0,Ar=e=>e>0,jr=e=>e>=0,Mr=e=>e===0,Nr=(e,t)=>{let n=/([a-zA-Z]+)|(\d+)/g,r=e.replace(/[\s_.-]+/g,``).match(n),i=t.replace(/[\s_.-]+/g,``).match(n);if(!r||!i)return 0;for(let e=0;e<Math.min(r.length,i.length);e++){let t=r[e],n=i[e];if(isNaN(Number(t))&&isNaN(Number(n))){let e=t.localeCompare(n);if(e!==0)return e}else if(!isNaN(Number(t))&&!isNaN(Number(n))){let e=Number(t)-Number(n);if(e!==0)return e}else return isNaN(Number(t))?-1:1}return r.length-i.length},Pr=(e,t,n)=>{let r=0,i=e.length,a=n??br(t);for(;r<i;){let n=Math.floor((r+i)/2),o=a(e[n],t);if(o===0)return n;o<0?r=n+1:i=n}return r},Fr=(e,t,n)=>{let r=Pr(e,t,n);e.splice(r,0,t)},Ir=p({EQUAL:()=>0,GREATER_THAN:()=>1,LESS_THAN:()=>-1,arraysEqual:()=>Er,insert:()=>Fr,isEqualTo:()=>Mr,isGreaterThan:()=>Ar,isGreaterThanEqual:()=>jr,isLessThan:()=>kr,mapsEqual:()=>Tr,newF:()=>br,newFieldF:()=>xr,order:()=>Dr,primitiveArrays:()=>Sr,reverseF:()=>Or,search:()=>Pr,stringsWithNumbers:()=>Nr,uniqueUnorderedPrimitiveArrays:()=>wr,unorderedPrimitiveArrays:()=>Cr}),Lr=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Rr=p({LENGTH:()=>11,create:()=>Ur}),zr=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Br=`0123456789${zr}`,Vr=Lr(zr,1),Hr=Lr(Br,10),Ur=()=>`${Vr()}${Hr()}`,Wr=(e,t)=>n=>n instanceof t||typeof n==`object`&&!!n&&`discriminator`in n&&n.discriminator===e;l.default.enum([`x`,`y`,...Qt,...an]);var Gr=vn;l.z.union([tn,l.z.enum([...Qt,...an]),l.z.instanceof(String)]),l.z.object({x:qt.or(on),y:Yt.or(on)});var Kr=Object.freeze({x:`left`,y:`top`}),qr=Object.freeze({x:`right`,y:`top`}),Jr=Object.freeze({x:`left`,y:`bottom`}),Yr=Object.freeze({x:`right`,y:`bottom`}),Xr=Object.freeze({x:`center`,y:`center`}),Zr=Object.freeze({x:`center`,y:`top`}),Qr=Object.freeze({x:`center`,y:`bottom`}),$r=Object.freeze({x:`right`,y:`center`}),ei=Object.freeze({x:`left`,y:`center`});Object.freeze([ei,$r,Zr,Qr,Kr,qr,Jr,Yr,Xr]);var ti=(e,t)=>e.x===t.x&&e.y===t.y,ni=e=>[e.x,e.y],ri=l.z.union([l.z.number(),_n,En,bn,xn,Sn]),ii=(e,t)=>{if(typeof e==`string`){if(t===void 0)throw Error(`The y coordinate must be given.`);return e===`x`?{x:t,y:0}:{x:0,y:t}}return typeof e==`number`?{x:e,y:t??e}:Array.isArray(e)?{x:e[0],y:e[1]}:`signedWidth`in e?{x:e.signedWidth,y:e.signedHeight}:`clientX`in e?{x:e.clientX,y:e.clientY}:`width`in e?{x:e.width,y:e.height}:{x:e.x,y:e.y}},ai=Object.freeze({x:0,y:0});Object.freeze({x:1,y:1}),Object.freeze({x:1/0,y:1/0}),Object.freeze({x:NaN,y:NaN});var oi=(e,t)=>{let n=ii(e);return{x:n.x+t,y:n.y}},si=(e,t)=>{let n=ii(e);return{x:n.x,y:n.y+t}},ci=(e,t,n,...r)=>{if(typeof t==`string`){if(typeof n!=`number`)throw Error(`The value must be a number.`);return t===`x`?oi(e,n):si(e,n)}if(typeof t==`object`&&`x`in t&&typeof t.x==`string`){let r=ii(n),i=ii(e);return t.x===`left`?r.x=-r.x:t.x===`center`&&(r.x=0),t.y===`top`?r.y=-r.y:t.y===`center`&&(r.y=0),{x:i.x+r.x,y:i.y+r.y}}return[e,t,n??ai,...r].reduce((e,t)=>{let n=ii(t);return{x:e.x+n.x,y:e.y+n.y}},ai)},li=l.z.union([l.z.number(),l.z.string()]);l.z.object({top:li,left:li,width:li,height:li}),l.z.object({left:l.z.number(),top:l.z.number(),right:l.z.number(),bottom:l.z.number()}),l.z.object({one:_n,two:_n,root:Gr});var ui=(e,t,n=0,r=0,i)=>{let a={one:{...ai},two:{...ai},root:i??Kr};if(typeof e==`number`){if(typeof t!=`number`)throw Error(`Box constructor called with invalid arguments`);return a.one={x:e,y:t},a.two={x:a.one.x+n,y:a.one.y+r},a}return`one`in e&&`two`in e&&`root`in e?{...e,root:i??e.root}:(`getBoundingClientRect`in e&&(e=e.getBoundingClientRect()),`left`in e?(a.one={x:e.left,y:e.top},a.two={x:e.right,y:e.bottom},a):(a.one=e,t==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof t==`number`?a.two={x:a.one.x+t,y:a.one.y+n}:`width`in t?a.two={x:a.one.x+t.width,y:a.one.y+t.height}:`signedWidth`in t?a.two={x:a.one.x+t.signedWidth,y:a.one.y+t.signedHeight}:a.two=t,a))},di=(e,t)=>{let n=ui(e);return{x:t.x===`center`?gi(n).x:fi(n,t.x),y:t.y===`center`?gi(n).y:fi(n,t.y)}},fi=(e,t)=>{let n=ui(e),r=ni(n.root).includes(t)?Math.min:Math.max;return Kt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},pi=e=>{let t=ui(e);return t.two.x-t.one.x},mi=e=>{let t=ui(e);return t.two.y-t.one.y},hi=e=>di(e,Kr),gi=e=>ci(hi(e),{x:pi(e)/2,y:mi(e)/2}),_i=e=>{let t=ui(e);return{lower:t.one.x,upper:t.two.x}},vi=e=>{let t=ui(e);return{lower:t.one.y,upper:t.two.y}},yi=e=>typeof e!=`object`||!e?!1:`one`in e&&`two`in e&&`root`in e;l.z.union([bn,xn,_n,En]);var bi=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e;l.z.object({offset:ri,scale:ri}),l.z.object({offset:l.z.number(),scale:l.z.number()});var xi=e=>(t,n,r,i)=>n===`dimension`?[t,r]:[t,i?r-e:r+e],Si=e=>(t,n,r,i)=>[t,i?r/e:r*e],Ci=e=>(t,n,r)=>{if(t===null)return[e,r];let{lower:i,upper:a}=t,{lower:o,upper:s}=e,c=a-i,l=s-o;return n===`dimension`?[e,l/c*r]:[e,(r-i)*(l/c)+o]},wi=e=>(t,n,r)=>[e,r],Ti=()=>(e,t,n)=>{if(e===null)throw Error(`cannot invert without bounds`);if(t===`dimension`)return[e,n];let{lower:r,upper:i}=e;return[e,i-(n-r)]},Ei=e=>(t,n,r)=>{let{lower:i,upper:a}=e;return r=bi(r,i,a),[t,r]},Di=class e{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new e().translate(t)}static magnify(t){return new e().magnify(t)}static scale(t,n){return new e().scale(t,n)}translate(e){let t=this.new(),n=xi(e);return n.type=`translate`,t.ops.push(n),t}magnify(e){let t=this.new(),n=Si(e);return n.type=`magnify`,t.ops.push(n),t}scale(e,t){let n=v(e,t),r=this.new(),i=Ci(n);return i.type=`scale`,r.ops.push(i),r}clamp(e,t){let n=v(e,t),r=this.new(),i=Ei(n);return i.type=`clamp`,r.ops.push(i),r}reBound(e,t){let n=v(e,t),r=this.new(),i=wi(n);return i.type=`re-bound`,r.ops.push(i),r}invert(){let e=Ti();e.type=`invert`;let t=this.new();return t.ops.push(e),t}pos(e){return this.exec(`position`,e)}dim(e){return this.exec(`dimension`,e)}new(){let t=new e;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(e,t){return this.currBounds=null,this.ops.reduce(([t,n],r)=>r(t,e,n,this.reversed),[null,t])[1]}reverse(){let e=this.new();e.ops.reverse();let t=[];return e.ops.forEach((n,r)=>{if(n.type===`scale`||t.some(([e,t])=>r>=e&&r<=t))return;let i=e.ops.findIndex((e,t)=>e.type===`scale`&&t>r);i!==-1&&t.push([r,i])}),t.forEach(([t,n])=>{let r=e.ops.slice(t,n);r.unshift(e.ops[n]),e.ops.splice(t,n-t+1,...r)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new e};(class e{x;y;currRoot;constructor(e=new Di,t=new Di,n=null){this.x=e,this.y=t,this.currRoot=n}static translate(t,n){return new e().translate(t,n)}static translateX(t){return new e().translateX(t)}static translateY(t){return new e().translateY(t)}static clamp(t){return new e().clamp(t)}static magnify(t){return new e().magnify(t)}static scale(t){return new e().scale(t)}static reBound(t){return new e().reBound(t)}translate(e,t){let n=ii(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){let t=this.copy();return t.x=this.x.translate(e),t}translateY(e){let t=this.copy();return t.y=this.y.translate(e),t}magnify(e){let t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){let t=this.copy();if(yi(e)){let n=this.currRoot;return t.currRoot=e.root,n!=null&&!ti(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(_i(e)),t.y=t.y.scale(vi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){let t=this.copy();return t.x=this.x.reBound(_i(e)),t.y=this.y.reBound(vi(e)),t}clamp(e){let t=this.copy();return t.x=this.x.clamp(_i(e)),t.y=this.y.clamp(vi(e)),t}copy(){let t=new e;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){let e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ui(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new e}),Tn.required({root:!0,units:!0});var Oi=l.z.enum([`static`,`dynamic`]),ki=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Ai(e){return typeof e==`string`&&ki.test(e)}var T=[];for(let e=0;e<256;++e)T.push((e+256).toString(16).slice(1));function ji(e,t=0){return(T[e[t+0]]+T[e[t+1]]+T[e[t+2]]+T[e[t+3]]+`-`+T[e[t+4]]+T[e[t+5]]+`-`+T[e[t+6]]+T[e[t+7]]+`-`+T[e[t+8]]+T[e[t+9]]+`-`+T[e[t+10]]+T[e[t+11]]+T[e[t+12]]+T[e[t+13]]+T[e[t+14]]+T[e[t+15]]).toLowerCase()}function Mi(e,t=0){let n=ji(e,t);if(!Ai(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ni=(e,t)=>Mi(e,t),Pi=e=>{let t=Math.fround(e);if(!Number.isFinite(t))return t.toString();for(let e=1;e<=9;e++){let n=parseFloat(t.toPrecision(e));if(Math.fround(n)===t)return n.toString()}return t.toString()},Fi=-1,Ii={[Symbol.iterator]:()=>Ii,next:()=>({done:!0,value:void 0})},Li=l.z.string().transform(e=>new Uint8Array(atob(e).split(``).map(e=>e.charCodeAt(0))).buffer),Ri=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),E=4,zi=(e,t)=>{if(e===`number`&&!t.isNumeric)throw Error(`cannot convert series of type ${t.toString()} to number`);if(e===`bigint`&&!t.usesBigInt)throw Error(`cannot convert series of type ${t.toString()} to bigint`)},Bi=`sy_x_telem_series`,Vi=class e{key;discriminator=Bi;dataType;sampleOffset;gl;_data;timeRange=C.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Fi;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=l.z.object({timeRange:C.z.optional(),dataType:w.z,alignment:l.z.coerce.bigint().optional(),data:l.z.union([Li,Ri,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]).default(()=>new Uint8Array().buffer),glBufferUsage:Oi.default(`static`).optional()});static z=e.crudeZ.transform(t=>new e(t));constructor(e){Hi(e)&&(e={data:e}),e.data??=[];let{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:i=`static`,alignment:a=0n,alignmentMultiple:o=1n,key:s=Ur(),data:c}=e;if(Ui(c)){let e=c;this.key=e.key,this.dataType=e.dataType,this.sampleOffset=e.sampleOffset,this.gl=e.gl,this._data=e._data,this.timeRange=e.timeRange,this.alignment=e.alignment,this.alignmentMultiple=e.alignmentMultiple,this.cachedMin=e.cachedMin,this.cachedMax=e.cachedMax,this.writePos=e.writePos,this._refCount=e._refCount,this.cachedLength=e.cachedLength;return}let l=sr(c),u=Array.isArray(c);if(t!=null)this.dataType=new w(t);else if(c instanceof ArrayBuffer)throw Error(`cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.`);else if(u||l){let e=c;if(!l){if(c.length===0)throw Error(`cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.`);e=c[0]}if(typeof e==`string`)this.dataType=w.STRING;else if(typeof e==`number`)this.dataType=w.FLOAT64;else if(typeof e==`bigint`)this.dataType=w.INT64;else if(typeof e==`boolean`)this.dataType=w.UINT8;else if(e instanceof b||e instanceof Date||e instanceof b)this.dataType=w.TIMESTAMP;else if(typeof e==`object`)this.dataType=w.JSON;else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`)}else this.dataType=new w(c);if(!u&&!l)this._data=c;else if(u&&c.length===0)this._data=new this.dataType.Array([]).buffer;else{let e=l?[c]:c,t=e[0];if((t instanceof b||t instanceof Date||t instanceof x)&&(e=e.map(e=>new b(e).valueOf())),this.dataType.equals(w.STRING)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(e)),n=t.reduce((e,t)=>e+E+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=E,a.set(e,o),o+=e.byteLength;this._data=r}else if(this.dataType.equals(w.JSON)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(Yn.encodeString(e))),n=t.reduce((e,t)=>e+E+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=E,a.set(e,o),o+=e.byteLength;this._data=r}else 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??C.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 w(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===Fi)return 0;let t=this.byteCapacity.valueOf()-this.writePos,n=e.buffer,r=e.byteLength.valueOf(),i=new DataView(n),a=0,o=0;for(;a+E<=r;){let e=E+i.getUint32(a,!0);if(a+e>t)break;a+=e,o++}if(a===0)return 0;let s=e.subBytes(0,a);return this.writeToUnderlyingData(s),this.writePos+=a,this.cachedLength=(this.cachedLength??0)+o,this._cachedIndexes=void 0,o}writeFixed(e){if(this.writePos===Fi)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===Fi?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(this.dataType.isVariable){let e=[],t=this.buffer,n=this.byteLength.valueOf(),r=new DataView(t),i=new TextDecoder,a=0;for(;a+E<=n;){let n=r.getUint32(a,!0);a+=E,e.push(i.decode(new Uint8Array(t,a,n))),a+=n}return e}return Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(w.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(Yn.decodeString(t)))}get byteCapacity(){return new ir(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Fi?this.byteCapacity:this.dataType.isVariable?new ir(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Fi?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=[],n=this.buffer,r=this.byteLength.valueOf(),i=new DataView(n),a=0;for(;a+E<=r;){let n=i.getUint32(a,!0);a+=E,t.push(a),a+=n,e++}return 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]=cr(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(){if(this.length===0)return-1/0;if(this.dataType.equals(w.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}else{let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}return 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(),this.applyOffset(this.cachedMax))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(w.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}else{let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}return 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(),this.applyOffset(this.cachedMin))}get bounds(){return v(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){let n=this.atVariable(e,t);return n==null?void 0:this.dataType.equals(w.STRING)?n:de(JSON.parse(n))}if(this.dataType.equals(w.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 this.applyOffset(n)}applyOffset(e){return typeof this.sampleOffset==`bigint`&&typeof e==`number`?BigInt(Math.round(e))+this.sampleOffset:Rt(e,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=Ni(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}asString(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t);if(this.dataType.equals(w.UUID))return this.atUUID(e,t);let n=this.at(e,t);if(n!=null)return this.dataType.equals(w.FLOAT32)?Pi(n):String(n)}atVariable(e,t){let n=0,r=0,i=this.buffer,a=new DataView(i);if(this._cachedIndexes!=null){if(e<0&&(e=this._cachedIndexes.length+e),e<0||e>=this._cachedIndexes.length){if(t)throw Error(`[series] - no value at index ${e}`);return}n=this._cachedIndexes[e],r=a.getUint32(n-E,!0)}else{e<0&&(e=this.length+e);let i=this.byteLength.valueOf(),o=0,s=!1;for(;o+E<=i;){let t=a.getUint32(o,!0);if(o+=E,e===0){n=o,r=t,s=!0;break}o+=t,e--}if(!s){if(t)throw Error(`[series] - no value at index ${e}`);return}}let o=new Uint8Array(i,n,r);return new TextDecoder().decode(o)}binarySearch(e){let t=0,n=this.length-1,r=br(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(w.FLOAT32)&&!this.dataType.equals(w.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!==Fi){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=Fi}as(e){return zi(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Qi(this.alignmentBounds.lower),upper:Qi(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return v(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 Gi(this);return this.dataType.equals(w.JSON)?new Ki(e):e}return this.dataType.equals(w.UUID)?new qi(this):new Ji(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Wi(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 Wi(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:C.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}},Hi=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof Vi?!0:sr(e),Ui=Wr(Bi,Vi),Wi=class{series;end;index;constructor(e,t,n){this.series=e;let r=v(0,e.length+1);this.end=On(r,n),this.index=On(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},Gi=class{series;byteOffset;decoder;view;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.byteOffset=0,this.decoder=new TextDecoder,this.view=new DataView(e.buffer)}next(){let e=this.series.byteLength.valueOf();if(this.byteOffset+E>e)return{done:!0,value:void 0};let t=this.view.getUint32(this.byteOffset,!0);this.byteOffset+=E;let n=this.decoder.decode(new Uint8Array(this.series.buffer,this.byteOffset,t));return this.byteOffset+=t,{done:!1,value:n}}},Ki=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:Yn.decodeString(t.value,e.schema)}}},qi=class{series;index;data;density;constructor(e){if(!e.dataType.equals(w.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=w.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=Ni(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},Ji=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)}}},Yi=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 zi(e,this.dataType),this}get dataType(){return this.series.length===0?w.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?C.ZERO:new C(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?v(0n,0n):v(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(Ui(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(kn(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 Zi(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return Ii;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(kn(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(kn(n.alignmentBounds,t)){r+=Math.ceil(Number(t-n.alignment)/Number(n.alignmentMultiple));break}}return new Zi(this,n,r)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return Ii;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(kn(r.alignmentBounds,e)){n+=Number(e-r.alignment);break}}return new Zi(this,n,n+t)}updateGLBuffer(e){this.series.forEach(t=>t.updateGLBuffer(e))}get bounds(){return An(this.series.map(e=>e.bounds))}get byteLength(){return new ir(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 jn(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 Mn(this.series.map(e=>e.alignmentBounds),e,t)}parseJSON(e){if(!this.dataType.equals(w.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 Xi(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}},Xi=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}},Zi=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}},Qi=e=>({domain:e>>32n,sample:e&4294967295n}),$i=[`ISO`,`ISODate`,`time`,`preciseTime`,`date`,`preciseDate`,`dateTime`],ea=l.z.enum($i),ta=[`local`,`UTC`],na=l.z.enum(ta),ra=p({ClockSkewCalculator:()=>gr,DataType:()=>w,Density:()=>S,MultiSeries:()=>Yi,Rate:()=>rr,Series:()=>Vi,Size:()=>ir,TIMESTAMP_FORMATS:()=>$i,TIME_ZONES:()=>ta,TimeRange:()=>C,TimeSpan:()=>x,TimeStamp:()=>b,convertDataType:()=>cr,dataTypeZ:()=>mr,isCrudeSeries:()=>Hi,isTelemValue:()=>sr,numericTimeRangeZ:()=>ar,rateZ:()=>fr,sizeZ:()=>pr,timeRangeBoundedZ:()=>hr,timeRangeZ:()=>lr,timeSpanZ:()=>dr,timeStampZ:()=>ur,timeZoneZ:()=>na,timestampFormatZ:()=>ea,typedArrayZ:()=>or}),ia=async e=>await new Promise(t=>setTimeout(t,x.fromMilliseconds(e).milliseconds)),aa=p({Breaker:()=>oa,breakerConfigZ:()=>sa}),oa=class{config;retries;interval;constructor(e){this.config={baseInterval:new x(e?.baseInterval??x.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??ia},this.retries=0,this.interval=new x(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}},sa=l.z.object({baseInterval:x.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),ca=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),la=In,ua=l.z.number().min(0).max(1),da=l.z.tuple([la,la,la,ua]),fa=l.z.tuple([la,la,la]),pa=l.z.object({rgba255:da}),ma=l.z.object({r:la,g:la,b:la,a:ua}),ha=l.z.number().min(0).max(360),ga=l.z.number().min(0).max(100),_a=l.z.number().min(0).max(100),va=l.z.tuple([ha,ga,_a,ua]),ya=l.z.union([ca,fa,da,va,pa,ma]),ba=ya.transform(e=>D(e)),xa=e=>ba.safeParse(e).success,Sa=e=>da.safeParse(e).success,Ca=(e=>{if(e==null)return;let t=ba.safeParse(e);if(t.success)return Ea(t.data);if(typeof e==`string`)return e;throw t.error}),D=(e,t=1)=>{if(e=ya.parse(e),typeof e==`string`)return Wa(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},wa=(e,t)=>{if(e==null||t==null)return e==t;let n=D(e),r=D(t);return n.every((e,t)=>e===r[t])},Ta=(e=>{if(e==null)return;let[t,n,r,i]=D(e),a=Math.round(i*255);return`#${Ka(t)}${Ka(n)}${Ka(r)}${a===255?``:Ka(a)}`}),Ea=e=>{let[t,n,r,i]=D(e);return`rgba(${t}, ${n}, ${r}, ${i})`},Da=e=>`rgb(${Oa(e)})`,Oa=e=>{let[t,n,r]=D(e);return`${t}, ${n}, ${r}`},ka=e=>[...Aa(e),Pa(e)],Aa=e=>[ja(e)/255,Ma(e)/255,Na(e)/255],ja=e=>D(e)[0],Ma=e=>D(e)[1],Na=e=>D(e)[2],Pa=e=>D(e)[3],Fa=e=>wa(Ga,e),Ia=e=>$a(D(e)),La=(e,t)=>{let[n,r,i]=D(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]},Ra=e=>{let[t,n,r]=Aa(e).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},za=e=>{let[t,n,r]=Aa(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},Ba=(e,t)=>{let n=D(e),r=D(t),i=Ra(n),a=Ra(r);return(Math.max(i,a)+.5)/(Math.min(i,a)+.5)},Va=(e,...t)=>{if(t.length===0)throw Error(`[Color.pickByContrast] - must provide at least one color`);let n=D(e),[r]=t.sort((e,t)=>Ba(n,t)-Ba(n,e));return D(r)},Ha=e=>Ra(e)<.5,Ua=e=>Ra(e)>.5,Wa=(e,t=1)=>(e=ca.parse(e),e=Ja(e),[qa(e,0),qa(e,2),qa(e,4),e.length===8?qa(e,6)/255:t]),Ga=[0,0,0,0],Ka=e=>Math.floor(e).toString(16).padStart(2,`0`),qa=(e,t)=>parseInt(e.slice(t,t+2),16),Ja=e=>e.startsWith(`#`)?e.slice(1):e,Ya={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`},Xa=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(ca.safeParse(i).success)return Wa(i)}return(t.length===7||t.length===9)&&ca.safeParse(t).success?Wa(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(Ya[t])return Wa(Ya[t])}},Za=e=>{e=va.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=Qa(i,e,t+1/3),o=Qa(i,e,t),s=Qa(i,e,t-1/3)}return[Math.round(a*255),Math.round(o*255),Math.round(s*255),i]},Qa=(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),$a=e=>{e=da.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]},eo=D(`#000000`),to=D(`#ffffff`),no=l.z.object({key:l.z.string(),color:ya,position:l.z.number(),switched:l.z.boolean().optional()}),ro=l.z.array(no),io=(e,t)=>{if(e.length===0)return Ga;if(e=e.slice().sort((e,t)=>e.position-t.position),t<=e[0].position)return D(e[0].color);if(t>=e[e.length-1].position)return D(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 D(r.color);if(t===i.position)return D(i.color);let a=(t-r.position)/(i.position-r.position),o=D(r.color),s=D(i.color);return D([Math.round(ja(o)+a*(ja(s)-ja(o))),Math.round(Ma(o)+a*(Ma(s)-Ma(o))),Math.round(Na(o)+a*(Na(s)-Na(o))),Pa(o)+a*(Pa(s)-Pa(o))])}return D(e[e.length-1].color)},ao=l.z.object({key:l.z.string(),name:l.z.string(),color:ba}),oo=l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(ao)}),so=p({BLACK:()=>eo,WHITE:()=>to,ZERO:()=>Ga,aValue:()=>Pa,bValue:()=>Na,colorZ:()=>ba,construct:()=>D,contrast:()=>Ba,crudeZ:()=>ya,cssString:()=>Ca,equals:()=>wa,fromCSS:()=>Xa,fromGradient:()=>io,fromHSLA:()=>Za,gValue:()=>Ma,gradientZ:()=>ro,grayness:()=>za,hex:()=>Ta,hsla:()=>Ia,isColor:()=>Sa,isCrude:()=>xa,isDark:()=>Ha,isLight:()=>Ua,isZero:()=>Fa,luminance:()=>Ra,paletteZ:()=>oo,pickByContrast:()=>Va,rValue:()=>ja,rgbCSS:()=>Da,rgbString:()=>Oa,rgba1:()=>ka,rgbaCSS:()=>Ea,setAlpha:()=>La,stopZ:()=>no}),co=In,lo=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({}),uo=l.z.enum(lo),fo=l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),po=e=>l.z.object({subject:fo,resource:e,authority:co}),mo={lower:0,upper:256},ho=(...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}),go=e=>l.z.object({from:po(e),to:l.z.null().optional()}),_o=e=>l.z.object({from:l.z.null().optional(),to:po(e)}),vo=e=>l.z.union([go(e),_o(e),l.z.object({from:po(e),to:po(e)})]),O=p({ABSOLUTE_AUTHORITY:()=>255,AUTHORITY_BOUNDS:()=>mo,Concurrency:()=>lo,ZERO_AUTHORITY:()=>0,acquireZ:()=>_o,authorityZ:()=>co,concurrencyZ:()=>uo,filterTransfersByChannelKey:()=>ho,releaseZ:()=>go,stateZ:()=>po,subjectZ:()=>fo,transferZ:()=>vo}),yo=p({formatValue:()=>bo}),bo=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 So(e.toString());case`object`:return e==null?``:So(JSON.stringify(e))}},xo=/[",\n]/,So=e=>xo.test(e)?`"${e.replace(/"/g,`""`)}"`:e,Co=()=>{},wo=(e,t)=>{let n=new x(t);if(n.valueOf()<=0){let t=((...t)=>e(...t));return t.cancel=Co,t.flush=Co,t}let r,i=null,a=()=>{if(i===null)return;let t=i;i=null,e(...t)},o=((...e)=>{i=e,clearTimeout(r),r=setTimeout(()=>{r=void 0,a()},n.milliseconds)});return o.cancel=()=>{clearTimeout(r),r=void 0,i=null},o.flush=()=>{r!==void 0&&(clearTimeout(r),r=void 0,a())},o};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 To=p({keyZ:()=>Eo,labelZ:()=>Do,newZ:()=>Oo}),Eo=l.z.uuid(),Do=l.z.object({key:Eo,name:l.z.string().min(1),color:ba}),Oo=Do.partial({key:!0}),ko=p({compareSemVer:()=>Mo,createMigration:()=>Io,migrator:()=>Lo,semVerNewer:()=>Po,semVerOlder:()=>Fo,semVerZ:()=>Ao,versionsEqual:()=>No}),Ao=l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),jo=(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},Mo=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;let r=Ao.parse(e),i=Ao.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:jo(o,c)}),No=(e,t,n={})=>Mr(Mo(e,t,n)),Po=(e,t,n={})=>Ar(Mo(e,t,n)),Fo=(e,t,n={})=>kr(Mo(e,t,n)),Io=({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}},Lo=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:i})=>{let a=Object.keys(t).sort(Mo).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}.
|
|
11
|
+
`).map(e=>e.trim());if(n.length===0)return t==null?{}:t.parse({});let i=n.split(`,`).map(e=>e.trim()),a={};return i.forEach(e=>{a[e]=[]}),r.forEach(e=>{let t=e.split(`,`).map(e=>e.trim());i.forEach((e,n)=>{let r=this.parseValue(t[n]);r!=null&&a[e].push(r)})}),t==null?a:t.parse(a)}parseValue(e){if(e==null||e.length===0)return null;let t=Number(e);return isNaN(t)?e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e:t}},Jn=class{contentType=`text/plain`;encode(e){if(typeof e!=`string`)throw Error(`TextCodec.encode payload must be a string`);return new TextEncoder().encode(e)}decode(e,t){let n=new TextDecoder().decode(e);return t==null?n:t.parse(n)}},Yn=new Kn,Xn=new qn,Zn=new Jn,Qn=[Yn],$n=365,er=30,tr=l.z.union([l.z.tuple([l.z.int()]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12)]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12),l.z.int().min(1).max(31)])]),nr=(e,t)=>{let n=new x(t);if(![S.DAY,S.HOUR,S.MINUTE,S.SECOND,S.MILLISECOND,S.MICROSECOND,S.NANOSECOND].some(e=>e.equals(n)))throw Error(`Invalid argument for remainder. Must be an even TimeSpan or Timestamp`);let r=e.valueOf()%n.valueOf();return e instanceof x?new x(r):new S(r)},x=class e extends nt{hash(){return this.value.toString()}constructor(t,n=`UTC`){if(t==null)super(e.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*e.MILLISECOND.valueOf());else if(typeof t==`string`)super(e.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(e.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n===`local`&&(r=e.utcOffset.valueOf()),typeof t==`number`&&(isFinite(t)?t=t===Ft?Nt:Math.trunc(t):(isNaN(t)&&(t=0),t=t===1/0?e.MAX:e.MIN)),tt(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){let i=new Date(t,n-1,r,0,0,0,0);return new e(BigInt(i.getTime())*e.MILLISECOND.valueOf()).truncate(e.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n=`UTC`){let[r,i,a]=t.split(`:`),o=`00`,s=`00`;a!=null&&([o,s]=a.split(`.`));let c=e.hours(parseInt(r??`00`,10)).add(e.minutes(parseInt(i??`00`,10))).add(e.seconds(parseInt(o??`00`,10))).add(e.milliseconds(parseInt(s??`00`,10)));return n===`local`&&(c=c.add(e.utcOffset)),c.valueOf()}static parseDateTimeString(t,n=`UTC`){if(!t.includes(`/`)&&!t.includes(`-`))return e.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let r=t,i=0;if(t.includes(`.`)){let e=t.split(`.`);r=e[0];let n=e[1]||`0`;i=parseInt(n.padEnd(3,`0`).slice(0,3),10)}let a=n===`local`?new Date(r.replace(`T`,` `)):new Date(`${r}Z`);return BigInt(a.getTime())*e.MILLISECOND.valueOf()+BigInt(i)*e.MILLISECOND.valueOf()}let r=new Date(t);return t.includes(`:`)||r.setUTCHours(0,0,0,0),new e(BigInt(r.getTime())*e.MILLISECOND.valueOf(),n).valueOf()}toISOString(t=`UTC`){if(t===`UTC`)return this.date().toISOString();let n=this.date(),r=new S(BigInt(n.getTimezoneOffset())*e.MINUTE.valueOf());return this.sub(r).date().toISOString()}timeString(e=!1,t=`UTC`){let n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){let e=this.date();return`${e.toLocaleString(`default`,{month:`short`})} ${e.toLocaleString(`default`,{day:`numeric`})}`}static get utcOffset(){return new S(BigInt(new Date().getTimezoneOffset())*e.MINUTE.valueOf())}static since(t){return new e().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new e(t).valueOf()}span(e){return this.range(e).span}range(e){return new w(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new e(t).valueOf()}afterEq(t){return this.valueOf()>=new e(t).valueOf()}before(t){return this.valueOf()<new e(t).valueOf()}beforeEq(t){return this.valueOf()<=new e(t).valueOf()}add(t){return new e(Rt(this.valueOf(),new S(t).valueOf()))}sub(t){return new e(Lt(this.valueOf(),new S(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(S.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(S.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(S.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(S.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){let n=this.date();return n.setUTCFullYear(t),new e(n)}setLocalYear(t){let n=this.date();return n.setFullYear(t),new e(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){let n=this.date();return n.setUTCMonth(t),new e(n)}setLocalMonth(t){let n=this.date();return n.setMonth(t),new e(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){let n=this.date();return n.setUTCDate(t),new e(n)}setLocalDay(t){let n=this.date();return n.setDate(t),new e(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){let n=this.date();return n.setHours(t),new e(n)}setHour(t){let n=this.date();return n.setUTCHours(t),new e(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){let n=this.date();return n.setUTCMinutes(t),new e(n)}setLocalMinute(t){let n=this.date();return n.setMinutes(t),new e(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){let n=this.date();return n.setUTCSeconds(t),new e(n)}setLocalSecond(t){let n=this.date();return n.setSeconds(t),new e(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){let n=this.date();return n.setUTCMilliseconds(t),new e(n)}setLocalMillisecond(t){let n=this.date();return n.setMilliseconds(t),new e(n)}toString(e=`ISO`,t=`UTC`){switch(e){case`ISODate`:return this.toISOString(t).slice(0,10);case`time`:return this.timeString(!1,t);case`preciseTime`:return this.timeString(!0,t);case`date`:return this.dateString();case`preciseDate`:return`${this.dateString()} ${this.timeString(!0,t)}`;case`dateTime`:return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}remainder(e){return nr(this,e)}get isToday(){return this.truncate(S.DAY).equals(e.now().truncate(S.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(S.days(30))?`date`:e.greaterThanOrEqual(S.DAY)?`dateTime`:e.greaterThanOrEqual(S.HOUR)?`time`:`preciseTime`}static now(){return new e(new Date)}static max(...t){let n=e.MIN;for(let r of t){let t=new e(r);t.after(n)&&(n=t)}return n}static min(...t){let n=e.MAX;for(let r of t){let t=new e(r);t.before(n)&&(n=t)}return n}static nanoseconds(t,n=`UTC`){return new e(t,n)}static NANOSECOND=e.nanoseconds(1);static microseconds(t,n=`UTC`){return e.nanoseconds(t*1e3,n)}static MICROSECOND=e.microseconds(1);static milliseconds(t,n=`UTC`){return e.microseconds(t*1e3,n)}static MILLISECOND=e.milliseconds(1);static seconds(t,n=`UTC`){return e.milliseconds(t*1e3,n)}static SECOND=e.seconds(1);static minutes(t,n=`UTC`){return e.seconds(t*60,n)}static MINUTE=e.minutes(1);static hours(t,n=`UTC`){return e.minutes(t*60,n)}static HOUR=e.hours(1);static days(t,n=`UTC`){return e.hours(t*24,n)}static DAY=e.days(1);static MAX=new e(Nt);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.instanceof(e),l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.date().transform(t=>new e(t)),l.z.custom(e=>e instanceof S).transform(t=>new e(t)),tr.transform(t=>new e(t))]);static sort(e,t){return Number(e.valueOf()-t.valueOf())}},S=class e extends nt{constructor(e){typeof e==`number`&&(e=Math.trunc(e.valueOf())),tt(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(t){return t instanceof e?t:t instanceof rr?t.period:t instanceof x?new e(t):(tt(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.seconds(t):new e(t))}static fromMilliseconds(t){return t instanceof e?t:t instanceof rr?t.period:t instanceof x?new e(t):(tt(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.milliseconds(t):new e(t))}valueOf(){return this.value}hash(){return this.value.toString()}lessThan(t){return this.valueOf()<new e(t).valueOf()}greaterThan(t){return this.valueOf()>new e(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new e(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new e(t).valueOf()}remainder(e){return nr(this,e)}truncate(t){return new e(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t=`full`){if(t===`semantic`)return this.toSemanticString();let n=this.truncate(e.DAY),r=this.truncate(e.HOUR),i=this.truncate(e.MINUTE),a=this.truncate(e.SECOND),o=this.truncate(e.MILLISECOND),s=this.truncate(e.MICROSECOND),c=this.truncate(e.NANOSECOND),l=n,u=r.sub(n),d=i.sub(r),f=a.sub(i),p=o.sub(a),m=s.sub(o),h=c.sub(s),g=``;return l.isZero||(g+=`${l.days}d `),u.isZero||(g+=`${u.hours}h `),d.isZero||(g+=`${d.minutes}m `),f.isZero||(g+=`${f.seconds}s `),p.isZero||(g+=`${p.milliseconds}ms `),m.isZero||(g+=`${m.microseconds}µs `),h.isZero||(g+=`${h.nanoseconds}ns`),g.trim()}toSemanticString(){let t=new e(this.valueOf()<0n?-this.valueOf():this.valueOf()),n=this.valueOf()<0n;if(t.valueOf()===0n)return`0s`;if(t.lessThan(e.SECOND))return`< 1s`;let r=t.days,i=t.hours,a=t.minutes,o=t.seconds,s=Math.floor(r/$n),c=Math.floor(r/er),l=Math.floor(r/7),u=Math.floor(r),d=Math.floor(i),f=Math.floor(a),p=Math.floor(o),m=n?`-`:``;if(s>=1){let e=`${s}y`;if(s<2){let t=Math.floor(r%$n/er);t>0&&(e+=` ${t}mo`)}return m+e}if(l>=1&&r<er&&r%7==0){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(c>=1){let e=`${c}mo`;if(c<3){let t=Math.floor(r%er);t>0&&(e+=` ${t}d`)}return m+e}if(l>=1){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(u>=1){let e=`${u}d`,t=Math.floor(i-u*24);return u<2&&t>0&&(e+=` ${t}h`),m+e}if(d>=1){let e=`${d}h`;if(d<3){let t=Math.floor(a-d*60);t>0&&(e+=` ${t}m`)}return m+e}if(f>=1){let e=`${f}m`;if(f<5){let t=Math.floor(o-f*60);t>0&&(e+=` ${t}s`)}return m+e}return`${m}${p}s`}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(e.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(e.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(e.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(e.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new e(t).valueOf()}add(t){return new e(this.valueOf()+new e(t).valueOf())}sub(t){return new e(this.valueOf()-new e(t).valueOf())}abs(){let t=this.valueOf();return new e(t<0n?-t:t)}static nanoseconds(t=1){return new e(t)}static NANOSECOND=e.nanoseconds(1);static microseconds(t=1){return e.nanoseconds(Ut(t,1e3))}static MICROSECOND=e.microseconds(1);static milliseconds(t=1){return e.microseconds(Ut(t,1e3))}static MILLISECOND=e.milliseconds(1);static seconds(t=1){return e.milliseconds(Ut(t,1e3))}static SECOND=e.seconds(1);static minutes(t=1){return e.seconds(Ut(t,60))}static MINUTE=e.minutes(1);static hours(t){return e.minutes(Ut(t,60))}static HOUR=e.hours(1);static days(t){return e.hours(Ut(t,24))}static DAY=e.days(1);static MAX=new e(Nt);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.instanceof(e),l.z.instanceof(x).transform(t=>new e(t)),l.z.custom(e=>e instanceof rr).transform(t=>new e(t))])},rr=class e extends nt{constructor(e){tt(e)&&(e=e.value),super(e.valueOf())}hash(){return this.value.toString()}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new e(t).valueOf()}get period(){return S.seconds(1/this.valueOf())}sampleCount(e){return new S(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new C(t).valueOf()}span(e){return S.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/new C(t).valueOf())}add(t){return new e(Rt(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(Lt(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}static hz(t){return new e(t)}static khz(t){return e.hz(t*1e3)}static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},C=class e extends nt{constructor(e){tt(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new ir(e*this.valueOf())}add(t){return new e(Rt(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(Lt(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}static UNKNOWN=new e(0);static BIT128=new e(16);static BIT64=new e(8);static BIT32=new e(4);static BIT16=new e(2);static BIT8=new e(1);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},w=class e{hash(){return`${this.start.hash()}-${this.end.hash()}`}start;end;constructor(e,t){typeof e==`object`&&`start`in e?(this.start=new x(e.start),this.end=new x(e.end)):(this.start=new x(e),this.end=new x(t))}get span(){return new S(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new e(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=S.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString(`preciseDate`)} - ${this.span.toString()}`}overlapsWith(e,t=S.ZERO){e=e.makeValid();let n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;let r=x.max(n.start,e.start),i=x.min(n.end,e.end);return i.before(r)?!1:new S(i.sub(r)).greaterThanOrEqual(t)}contains(t){return t instanceof e?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){let n=new e(this.start,this.end);return t.start.after(this.start)&&(n.start=t.start),t.start.after(this.end)&&(n.end=t.start),t.end.before(this.end)&&(n.end=t.end),t.end.before(this.start)&&(n.start=t.end),n}static max(...t){return new e(x.min(...t.map(e=>e.start)),x.max(...t.map(e=>e.end)))}static MAX=new e(x.MIN,x.MAX);static ZERO=new e(x.ZERO,x.ZERO);static z=l.z.union([l.z.object({start:x.z,end:x.z}).transform(t=>new e(t.start,t.end)),l.z.instanceof(e)]);static boundedZ=e.z.refine(({isValid:e})=>e,{message:`Time range start time must be before or equal to time range end time`}).refine(({end:e})=>e.valueOf()<=Nt,{message:`Time range end time must be less than or equal to the maximum value of an int64`}).refine(({start:e})=>e.valueOf()>=Mt,{message:`Time range start time must be greater than or equal to the minimum value of an int64`});static sort(e,t){return x.sort(e.start,t.start)||x.sort(e.end,t.end)}static merge(...t){return e.max(...t.map(t=>new e(t).makeValid()))}},T=class e extends nt{hash(){return this.value}constructor(t){if(tt(t)&&(t=t.value),t instanceof e||typeof t==`string`||typeof t.valueOf()==`string`)super(t.valueOf());else{let n=e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){let t=e.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(e=>this.equals(e))}toString(t=!1){return t?e.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(e.JSON)||this.equals(e.STRING)||this.equals(e.BYTES)}get isNumeric(){return!this.isVariable&&!this.equals(e.UUID)}get isInteger(){let e=this.toString();return e.startsWith(`int`)||e.startsWith(`uint`)}get isFloat(){return this.toString().startsWith(`float`)}get density(){let t=e.DENSITIES.get(this.toString());if(t==null)throw Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(e.UINT8)||this.equals(e.UINT16)||this.equals(e.UINT32)||this.equals(e.UINT64)}get isSignedInteger(){return this.equals(e.INT8)||this.equals(e.INT16)||this.equals(e.INT32)||this.equals(e.INT64)}canSafelyCastTo(t){return this.equals(t)?!0:!this.isNumeric||!t.isNumeric||this.isVariable||t.isVariable||this.isUnsignedInteger&&t.isSignedInteger?!1:this.isFloat?t.isFloat&&this.density.valueOf()<=t.density.valueOf():this.equals(e.INT32)&&t.equals(e.FLOAT64)||this.equals(e.INT8)&&t.equals(e.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return e.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new e(`unknown`);static FLOAT64=new e(`float64`);static FLOAT32=new e(`float32`);static INT64=new e(`int64`);static INT32=new e(`int32`);static INT16=new e(`int16`);static INT8=new e(`int8`);static UINT64=new e(`uint64`);static UINT32=new e(`uint32`);static UINT16=new e(`uint16`);static UINT8=new e(`uint8`);static TIMESTAMP=new e(`timestamp`);static UUID=new e(`uuid`);static STRING=new e(`string`);static JSON=new e(`json`);static BYTES=new e(`bytes`);static ARRAY_CONSTRUCTORS=new Map([[e.UINT8.toString(),Uint8Array],[e.UINT16.toString(),Uint16Array],[e.UINT32.toString(),Uint32Array],[e.UINT64.toString(),BigUint64Array],[e.FLOAT32.toString(),Float32Array],[e.FLOAT64.toString(),Float64Array],[e.INT8.toString(),Int8Array],[e.INT16.toString(),Int16Array],[e.INT32.toString(),Int32Array],[e.INT64.toString(),BigInt64Array],[e.TIMESTAMP.toString(),BigInt64Array],[e.STRING.toString(),Uint8Array],[e.JSON.toString(),Uint8Array],[e.UUID.toString(),Uint8Array],[e.BYTES.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,e.UINT8],[Uint16Array.name,e.UINT16],[Uint32Array.name,e.UINT32],[BigUint64Array.name,e.UINT64],[Float32Array.name,e.FLOAT32],[Float64Array.name,e.FLOAT64],[Int8Array.name,e.INT8],[Int16Array.name,e.INT16],[Int32Array.name,e.INT32],[BigInt64Array.name,e.INT64]]);static DENSITIES=new Map([[e.UINT8.toString(),C.BIT8],[e.UINT16.toString(),C.BIT16],[e.UINT32.toString(),C.BIT32],[e.UINT64.toString(),C.BIT64],[e.FLOAT32.toString(),C.BIT32],[e.FLOAT64.toString(),C.BIT64],[e.INT8.toString(),C.BIT8],[e.INT16.toString(),C.BIT16],[e.INT32.toString(),C.BIT32],[e.INT64.toString(),C.BIT64],[e.TIMESTAMP.toString(),C.BIT64],[e.STRING.toString(),C.UNKNOWN],[e.JSON.toString(),C.UNKNOWN],[e.UUID.toString(),C.BIT128],[e.BYTES.toString(),C.UNKNOWN]]);static ALL=[e.UNKNOWN,e.UINT8,e.UINT16,e.UINT32,e.UINT64,e.INT8,e.INT16,e.INT32,e.INT64,e.FLOAT32,e.FLOAT64,e.TIMESTAMP,e.UUID,e.STRING,e.JSON,e.BYTES];static SHORT_STRINGS=new Map([[e.UINT8.toString(),`u8`],[e.UINT16.toString(),`u16`],[e.UINT32.toString(),`u32`],[e.UINT64.toString(),`u64`],[e.INT8.toString(),`i8`],[e.INT16.toString(),`i16`],[e.INT32.toString(),`i32`],[e.INT64.toString(),`i64`],[e.FLOAT32.toString(),`f32`],[e.FLOAT64.toString(),`f64`],[e.TIMESTAMP.toString(),`ts`],[e.UUID.toString(),`uuid`],[e.STRING.toString(),`str`],[e.JSON.toString(),`json`],[e.BYTES.toString(),`bytes`]]);static BIG_INT_TYPES=[e.INT64,e.UINT64,e.TIMESTAMP];static z=l.z.union([l.z.string().transform(t=>new e(t)),l.z.instanceof(e)])},ir=class e extends nt{constructor(e){tt(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return tt(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return tt(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(t){return tt(t)&&(t=t.value),new e(Rt(this.valueOf(),t.valueOf()))}sub(t){return tt(t)&&(t=t.value),new e(Lt(this.valueOf(),t.valueOf()))}mult(t){return new e(Ut(this.valueOf(),t))}div(t){return new e(Wt(this.valueOf(),t))}truncate(t){return new e(Math.trunc(this.valueOf()/new e(t).valueOf())*new e(t).valueOf())}remainder(t){return e.bytes(this.valueOf()%new e(t).valueOf())}get gigabytes(){return this.valueOf()/e.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/e.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/e.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/e.TERABYTE.valueOf()}toString(){let t=this.truncate(e.TERABYTE),n=this.truncate(e.GIGABYTE),r=this.truncate(e.MEGABYTE),i=this.truncate(e.KILOBYTE),a=this.truncate(e.BYTE),o=t,s=n.sub(t),c=r.sub(n),l=i.sub(r),u=a.sub(i),d=``;return o.isZero||(d+=`${o.terabytes}TB `),s.isZero||(d+=`${s.gigabytes}GB `),c.isZero||(d+=`${c.megabytes}MB `),l.isZero||(d+=`${l.kilobytes}KB `),(!u.isZero||d===``)&&(d+=`${u.valueOf()}B`),d.trim()}static bytes(t=1){return new e(t)}static BYTE=new e(1);static kilobytes(t=1){return e.bytes(new e(t).valueOf()*1e3)}static KILOBYTE=e.kilobytes(1);static megabytes(t=1){return e.kilobytes(new e(t).valueOf()*1e3)}static MEGABYTE=e.megabytes(1);static gigabytes(t=1){return e.megabytes(new e(t).valueOf()*1e3)}static GIGABYTE=e.gigabytes(1);static terabytes(t){return e.gigabytes(new e(t).valueOf()*1e3)}static TERABYTE=e.terabytes(1);static ZERO=new e(0);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)]);get isZero(){return this.valueOf()===0}},ar=l.z.object({start:l.z.number(),end:l.z.number()}),or=l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]),sr=e=>{let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===`bigint`||e instanceof x||e instanceof S||e instanceof Date},cr=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(BigInt(n.valueOf())-BigInt(r.valueOf())):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):Lt(n,r),lr=w.z,ur=x.z,dr=S.z,fr=rr.z,pr=ir.z,mr=T.z,hr=w.boundedZ,gr=class{now;localStartT=new x(0);lastSkew=S.ZERO;constructor(e=()=>x.now()){this.now=e}start(){this.localStartT=this.now()}end(e){let t=this.now().span(this.localStartT).valueOf()/2n,n=this.localStartT.add(t);this.lastSkew=new S(n.valueOf()-e.valueOf())}get skew(){return this.lastSkew}exceeds(e){let t=this.skew.valueOf();return(t<0n?-t:t)>new S(e).valueOf()}},_r=p({by:()=>yr,unique:()=>vr}),vr=e=>[...new Set(e)],yr=(e,t,n=!0)=>{let r=new Map;return e.forEach(e=>{let i=t(e);if(r.has(i)){if(n)return;r.delete(i)}r.set(i,e)}),Array.from(r.values())},br=(e,t=!1)=>{let n=rt(e)?`stringer`:typeof e,r;switch(n){case`string`:r=(e,t)=>e.localeCompare(t);break;case`stringer`:r=(e,t)=>e.toString().localeCompare(t.toString());break;case`number`:r=(e,t)=>Number(e)-Number(t);break;case`bigint`:r=(e,t)=>BigInt(e)-BigInt(t)>0n?1:-1;break;case`boolean`:r=(e,t)=>Number(e)-Number(t);break;case`undefined`:r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?Or(r):r},xr=(e,t,n)=>{let r=br(t[e],n);return(t,n)=>r(t[e],n[e])},Sr=(e,t)=>e.length===t.length?e.every((e,n)=>e===t[n])?0:-1:e.length-t.length,Cr=(e,t)=>{if(e.length!==t.length)return e.length-t.length;if(e.length===0)return 0;let n=br(e[0]),r=[...e].sort(n),i=[...t].sort(n);return r.every((e,t)=>e===i[t])?0:-1},wr=(e,t)=>Cr(vr(e),vr(t)),Tr=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0},Er=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Dr=(e,t)=>e===t?0:e===`first`&&t===`last`?1:-1,Or=e=>(t,n)=>e(n,t),kr=e=>e<0,Ar=e=>e>0,jr=e=>e>=0,Mr=e=>e===0,Nr=(e,t)=>{let n=/([a-zA-Z]+)|(\d+)/g,r=e.replace(/[\s_.-]+/g,``).match(n),i=t.replace(/[\s_.-]+/g,``).match(n);if(!r||!i)return 0;for(let e=0;e<Math.min(r.length,i.length);e++){let t=r[e],n=i[e];if(isNaN(Number(t))&&isNaN(Number(n))){let e=t.localeCompare(n);if(e!==0)return e}else if(!isNaN(Number(t))&&!isNaN(Number(n))){let e=Number(t)-Number(n);if(e!==0)return e}else return isNaN(Number(t))?-1:1}return r.length-i.length},Pr=(e,t,n)=>{let r=0,i=e.length,a=n??br(t);for(;r<i;){let n=Math.floor((r+i)/2),o=a(e[n],t);if(o===0)return n;o<0?r=n+1:i=n}return r},Fr=(e,t,n)=>{let r=Pr(e,t,n);e.splice(r,0,t)},Ir=p({EQUAL:()=>0,GREATER_THAN:()=>1,LESS_THAN:()=>-1,arraysEqual:()=>Er,insert:()=>Fr,isEqualTo:()=>Mr,isGreaterThan:()=>Ar,isGreaterThanEqual:()=>jr,isLessThan:()=>kr,mapsEqual:()=>Tr,newF:()=>br,newFieldF:()=>xr,order:()=>Dr,primitiveArrays:()=>Sr,reverseF:()=>Or,search:()=>Pr,stringsWithNumbers:()=>Nr,uniqueUnorderedPrimitiveArrays:()=>wr,unorderedPrimitiveArrays:()=>Cr}),Lr=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Rr=p({LENGTH:()=>11,create:()=>Ur}),zr=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Br=`0123456789${zr}`,Vr=Lr(zr,1),Hr=Lr(Br,10),Ur=()=>`${Vr()}${Hr()}`,Wr=(e,t)=>n=>n instanceof t||typeof n==`object`&&!!n&&`discriminator`in n&&n.discriminator===e;l.default.enum([`x`,`y`,...Qt,...an]);var Gr=vn;l.z.union([tn,l.z.enum([...Qt,...an]),l.z.instanceof(String)]),l.z.object({x:qt.or(on),y:Yt.or(on)});var Kr=Object.freeze({x:`left`,y:`top`}),qr=Object.freeze({x:`right`,y:`top`}),Jr=Object.freeze({x:`left`,y:`bottom`}),Yr=Object.freeze({x:`right`,y:`bottom`}),Xr=Object.freeze({x:`center`,y:`center`}),Zr=Object.freeze({x:`center`,y:`top`}),Qr=Object.freeze({x:`center`,y:`bottom`}),$r=Object.freeze({x:`right`,y:`center`}),ei=Object.freeze({x:`left`,y:`center`});Object.freeze([ei,$r,Zr,Qr,Kr,qr,Jr,Yr,Xr]);var ti=(e,t)=>e.x===t.x&&e.y===t.y,ni=e=>[e.x,e.y],ri=l.z.union([l.z.number(),_n,En,bn,xn,Sn]),ii=(e,t)=>{if(typeof e==`string`){if(t===void 0)throw Error(`The y coordinate must be given.`);return e===`x`?{x:t,y:0}:{x:0,y:t}}return typeof e==`number`?{x:e,y:t??e}:Array.isArray(e)?{x:e[0],y:e[1]}:`signedWidth`in e?{x:e.signedWidth,y:e.signedHeight}:`clientX`in e?{x:e.clientX,y:e.clientY}:`width`in e?{x:e.width,y:e.height}:{x:e.x,y:e.y}},ai=Object.freeze({x:0,y:0});Object.freeze({x:1,y:1}),Object.freeze({x:1/0,y:1/0}),Object.freeze({x:NaN,y:NaN});var oi=(e,t)=>{let n=ii(e);return{x:n.x+t,y:n.y}},si=(e,t)=>{let n=ii(e);return{x:n.x,y:n.y+t}},ci=(e,t,n,...r)=>{if(typeof t==`string`){if(typeof n!=`number`)throw Error(`The value must be a number.`);return t===`x`?oi(e,n):si(e,n)}if(typeof t==`object`&&`x`in t&&typeof t.x==`string`){let r=ii(n),i=ii(e);return t.x===`left`?r.x=-r.x:t.x===`center`&&(r.x=0),t.y===`top`?r.y=-r.y:t.y===`center`&&(r.y=0),{x:i.x+r.x,y:i.y+r.y}}return[e,t,n??ai,...r].reduce((e,t)=>{let n=ii(t);return{x:e.x+n.x,y:e.y+n.y}},ai)},li=l.z.union([l.z.number(),l.z.string()]);l.z.object({top:li,left:li,width:li,height:li}),l.z.object({left:l.z.number(),top:l.z.number(),right:l.z.number(),bottom:l.z.number()}),l.z.object({one:_n,two:_n,root:Gr});var ui=(e,t,n=0,r=0,i)=>{let a={one:{...ai},two:{...ai},root:i??Kr};if(typeof e==`number`){if(typeof t!=`number`)throw Error(`Box constructor called with invalid arguments`);return a.one={x:e,y:t},a.two={x:a.one.x+n,y:a.one.y+r},a}return`one`in e&&`two`in e&&`root`in e?{...e,root:i??e.root}:(`getBoundingClientRect`in e&&(e=e.getBoundingClientRect()),`left`in e?(a.one={x:e.left,y:e.top},a.two={x:e.right,y:e.bottom},a):(a.one=e,t==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof t==`number`?a.two={x:a.one.x+t,y:a.one.y+n}:`width`in t?a.two={x:a.one.x+t.width,y:a.one.y+t.height}:`signedWidth`in t?a.two={x:a.one.x+t.signedWidth,y:a.one.y+t.signedHeight}:a.two=t,a))},di=(e,t)=>{let n=ui(e);return{x:t.x===`center`?gi(n).x:fi(n,t.x),y:t.y===`center`?gi(n).y:fi(n,t.y)}},fi=(e,t)=>{let n=ui(e),r=ni(n.root).includes(t)?Math.min:Math.max;return Kt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},pi=e=>{let t=ui(e);return t.two.x-t.one.x},mi=e=>{let t=ui(e);return t.two.y-t.one.y},hi=e=>di(e,Kr),gi=e=>ci(hi(e),{x:pi(e)/2,y:mi(e)/2}),_i=e=>{let t=ui(e);return{lower:t.one.x,upper:t.two.x}},vi=e=>{let t=ui(e);return{lower:t.one.y,upper:t.two.y}},yi=e=>typeof e!=`object`||!e?!1:`one`in e&&`two`in e&&`root`in e;l.z.union([bn,xn,_n,En]);var bi=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e;l.z.object({offset:ri,scale:ri}),l.z.object({offset:l.z.number(),scale:l.z.number()});var xi=e=>(t,n,r,i)=>n===`dimension`?[t,r]:[t,i?r-e:r+e],Si=e=>(t,n,r,i)=>[t,i?r/e:r*e],Ci=e=>(t,n,r)=>{if(t===null)return[e,r];let{lower:i,upper:a}=t,{lower:o,upper:s}=e,c=a-i,l=s-o;return n===`dimension`?[e,l/c*r]:[e,(r-i)*(l/c)+o]},wi=e=>(t,n,r)=>[e,r],Ti=()=>(e,t,n)=>{if(e===null)throw Error(`cannot invert without bounds`);if(t===`dimension`)return[e,n];let{lower:r,upper:i}=e;return[e,i-(n-r)]},Ei=e=>(t,n,r)=>{let{lower:i,upper:a}=e;return r=bi(r,i,a),[t,r]},Di=class e{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new e().translate(t)}static magnify(t){return new e().magnify(t)}static scale(t,n){return new e().scale(t,n)}translate(e){let t=this.new(),n=xi(e);return n.type=`translate`,t.ops.push(n),t}magnify(e){let t=this.new(),n=Si(e);return n.type=`magnify`,t.ops.push(n),t}scale(e,t){let n=y(e,t),r=this.new(),i=Ci(n);return i.type=`scale`,r.ops.push(i),r}clamp(e,t){let n=y(e,t),r=this.new(),i=Ei(n);return i.type=`clamp`,r.ops.push(i),r}reBound(e,t){let n=y(e,t),r=this.new(),i=wi(n);return i.type=`re-bound`,r.ops.push(i),r}invert(){let e=Ti();e.type=`invert`;let t=this.new();return t.ops.push(e),t}pos(e){return this.exec(`position`,e)}dim(e){return this.exec(`dimension`,e)}new(){let t=new e;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(e,t){return this.currBounds=null,this.ops.reduce(([t,n],r)=>r(t,e,n,this.reversed),[null,t])[1]}reverse(){let e=this.new();e.ops.reverse();let t=[];return e.ops.forEach((n,r)=>{if(n.type===`scale`||t.some(([e,t])=>r>=e&&r<=t))return;let i=e.ops.findIndex((e,t)=>e.type===`scale`&&t>r);i!==-1&&t.push([r,i])}),t.forEach(([t,n])=>{let r=e.ops.slice(t,n);r.unshift(e.ops[n]),e.ops.splice(t,n-t+1,...r)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new e};(class e{x;y;currRoot;constructor(e=new Di,t=new Di,n=null){this.x=e,this.y=t,this.currRoot=n}static translate(t,n){return new e().translate(t,n)}static translateX(t){return new e().translateX(t)}static translateY(t){return new e().translateY(t)}static clamp(t){return new e().clamp(t)}static magnify(t){return new e().magnify(t)}static scale(t){return new e().scale(t)}static reBound(t){return new e().reBound(t)}translate(e,t){let n=ii(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){let t=this.copy();return t.x=this.x.translate(e),t}translateY(e){let t=this.copy();return t.y=this.y.translate(e),t}magnify(e){let t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){let t=this.copy();if(yi(e)){let n=this.currRoot;return t.currRoot=e.root,n!=null&&!ti(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(_i(e)),t.y=t.y.scale(vi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){let t=this.copy();return t.x=this.x.reBound(_i(e)),t.y=this.y.reBound(vi(e)),t}clamp(e){let t=this.copy();return t.x=this.x.clamp(_i(e)),t.y=this.y.clamp(vi(e)),t}copy(){let t=new e;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){let e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ui(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new e}),Tn.required({root:!0,units:!0});var Oi=l.z.enum([`static`,`dynamic`]),ki=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Ai(e){return typeof e==`string`&&ki.test(e)}var E=[];for(let e=0;e<256;++e)E.push((e+256).toString(16).slice(1));function ji(e,t=0){return(E[e[t+0]]+E[e[t+1]]+E[e[t+2]]+E[e[t+3]]+`-`+E[e[t+4]]+E[e[t+5]]+`-`+E[e[t+6]]+E[e[t+7]]+`-`+E[e[t+8]]+E[e[t+9]]+`-`+E[e[t+10]]+E[e[t+11]]+E[e[t+12]]+E[e[t+13]]+E[e[t+14]]+E[e[t+15]]).toLowerCase()}function Mi(e,t=0){let n=ji(e,t);if(!Ai(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ni=(e,t)=>Mi(e,t),Pi=e=>{let t=Math.fround(e);if(!Number.isFinite(t))return t.toString();for(let e=1;e<=9;e++){let n=parseFloat(t.toPrecision(e));if(Math.fround(n)===t)return n.toString()}return t.toString()},Fi=-1,Ii={[Symbol.iterator]:()=>Ii,next:()=>({done:!0,value:void 0})},Li=l.z.string().transform(e=>new Uint8Array(atob(e).split(``).map(e=>e.charCodeAt(0))).buffer),Ri=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),D=4,zi=(e,t)=>{if(e===`number`&&!t.isNumeric)throw Error(`cannot convert series of type ${t.toString()} to number`);if(e===`bigint`&&!t.usesBigInt)throw Error(`cannot convert series of type ${t.toString()} to bigint`)},Bi=`sy_x_telem_series`,Vi=class e{key;discriminator=Bi;dataType;sampleOffset;gl;_data;timeRange=w.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Fi;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=l.z.object({timeRange:w.z.optional(),dataType:T.z,alignment:l.z.coerce.bigint().optional(),data:l.z.union([Li,Ri,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]).default(()=>new Uint8Array().buffer),glBufferUsage:Oi.default(`static`).optional()});static z=e.crudeZ.transform(t=>new e(t));constructor(e){Hi(e)&&(e={data:e}),e.data??=[];let{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:i=`static`,alignment:a=0n,alignmentMultiple:o=1n,key:s=Ur(),data:c}=e;if(Ui(c)){let e=c;this.key=e.key,this.dataType=e.dataType,this.sampleOffset=e.sampleOffset,this.gl=e.gl,this._data=e._data,this.timeRange=e.timeRange,this.alignment=e.alignment,this.alignmentMultiple=e.alignmentMultiple,this.cachedMin=e.cachedMin,this.cachedMax=e.cachedMax,this.writePos=e.writePos,this._refCount=e._refCount,this.cachedLength=e.cachedLength;return}let l=sr(c),u=Array.isArray(c);if(t!=null)this.dataType=new T(t);else if(c instanceof ArrayBuffer)throw Error(`cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.`);else if(u||l){let e=c;if(!l){if(c.length===0)throw Error(`cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.`);e=c[0]}if(typeof e==`string`)this.dataType=T.STRING;else if(typeof e==`number`)this.dataType=T.FLOAT64;else if(typeof e==`bigint`)this.dataType=T.INT64;else if(typeof e==`boolean`)this.dataType=T.UINT8;else if(e instanceof x||e instanceof Date||e instanceof x)this.dataType=T.TIMESTAMP;else if(typeof e==`object`)this.dataType=T.JSON;else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`)}else this.dataType=new T(c);if(!u&&!l)this._data=c;else if(u&&c.length===0)this._data=new this.dataType.Array([]).buffer;else{let e=l?[c]:c,t=e[0];if((t instanceof x||t instanceof Date||t instanceof S)&&(e=e.map(e=>new x(e).valueOf())),this.dataType.equals(T.STRING)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(e)),n=t.reduce((e,t)=>e+D+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=D,a.set(e,o),o+=e.byteLength;this._data=r}else if(this.dataType.equals(T.JSON)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(Yn.encodeString(e))),n=t.reduce((e,t)=>e+D+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=D,a.set(e,o),o+=e.byteLength;this._data=r}else 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??w.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 T(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===Fi)return 0;let t=this.byteCapacity.valueOf()-this.writePos,n=e.buffer,r=e.byteLength.valueOf(),i=new DataView(n),a=0,o=0;for(;a+D<=r;){let e=D+i.getUint32(a,!0);if(a+e>t)break;a+=e,o++}if(a===0)return 0;let s=e.subBytes(0,a);return this.writeToUnderlyingData(s),this.writePos+=a,this.cachedLength=(this.cachedLength??0)+o,this._cachedIndexes=void 0,o}writeFixed(e){if(this.writePos===Fi)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===Fi?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(this.dataType.isVariable){let e=[],t=this.buffer,n=this.byteLength.valueOf(),r=new DataView(t),i=new TextDecoder,a=0;for(;a+D<=n;){let n=r.getUint32(a,!0);a+=D,e.push(i.decode(new Uint8Array(t,a,n))),a+=n}return e}return Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(T.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(Yn.decodeString(t)))}get byteCapacity(){return new ir(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Fi?this.byteCapacity:this.dataType.isVariable?new ir(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Fi?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=[],n=this.buffer,r=this.byteLength.valueOf(),i=new DataView(n),a=0;for(;a+D<=r;){let n=i.getUint32(a,!0);a+=D,t.push(a),a+=n,e++}return 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]=cr(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(){if(this.length===0)return-1/0;if(this.dataType.equals(T.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}else{let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}return 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(),this.applyOffset(this.cachedMax))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(T.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}else{let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}return 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(),this.applyOffset(this.cachedMin))}get bounds(){return y(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){let n=this.atVariable(e,t);return n==null?void 0:this.dataType.equals(T.STRING)?n:de(JSON.parse(n))}if(this.dataType.equals(T.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 this.applyOffset(n)}applyOffset(e){return typeof this.sampleOffset==`bigint`&&typeof e==`number`?BigInt(Math.round(e))+this.sampleOffset:Rt(e,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=Ni(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}asString(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t);if(this.dataType.equals(T.UUID))return this.atUUID(e,t);let n=this.at(e,t);if(n!=null)return this.dataType.equals(T.FLOAT32)?Pi(n):String(n)}atVariable(e,t){let n=0,r=0,i=this.buffer,a=new DataView(i);if(this._cachedIndexes!=null){if(e<0&&(e=this._cachedIndexes.length+e),e<0||e>=this._cachedIndexes.length){if(t)throw Error(`[series] - no value at index ${e}`);return}n=this._cachedIndexes[e],r=a.getUint32(n-D,!0)}else{e<0&&(e=this.length+e);let i=this.byteLength.valueOf(),o=0,s=!1;for(;o+D<=i;){let t=a.getUint32(o,!0);if(o+=D,e===0){n=o,r=t,s=!0;break}o+=t,e--}if(!s){if(t)throw Error(`[series] - no value at index ${e}`);return}}let o=new Uint8Array(i,n,r);return new TextDecoder().decode(o)}binarySearch(e){let t=0,n=this.length-1,r=br(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(T.FLOAT32)&&!this.dataType.equals(T.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!==Fi){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=Fi}as(e){return zi(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Qi(this.alignmentBounds.lower),upper:Qi(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return y(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 Gi(this);return this.dataType.equals(T.JSON)?new Ki(e):e}return this.dataType.equals(T.UUID)?new qi(this):new Ji(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Wi(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 Wi(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:w.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}},Hi=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof Vi?!0:sr(e),Ui=Wr(Bi,Vi),Wi=class{series;end;index;constructor(e,t,n){this.series=e;let r=y(0,e.length+1);this.end=On(r,n),this.index=On(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},Gi=class{series;byteOffset;decoder;view;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.byteOffset=0,this.decoder=new TextDecoder,this.view=new DataView(e.buffer)}next(){let e=this.series.byteLength.valueOf();if(this.byteOffset+D>e)return{done:!0,value:void 0};let t=this.view.getUint32(this.byteOffset,!0);this.byteOffset+=D;let n=this.decoder.decode(new Uint8Array(this.series.buffer,this.byteOffset,t));return this.byteOffset+=t,{done:!1,value:n}}},Ki=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:Yn.decodeString(t.value,e.schema)}}},qi=class{series;index;data;density;constructor(e){if(!e.dataType.equals(T.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=T.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=Ni(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},Ji=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)}}},Yi=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 zi(e,this.dataType),this}get dataType(){return this.series.length===0?T.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?w.ZERO:new w(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?y(0n,0n):y(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(Ui(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(kn(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 Zi(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return Ii;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(kn(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(kn(n.alignmentBounds,t)){r+=Math.ceil(Number(t-n.alignment)/Number(n.alignmentMultiple));break}}return new Zi(this,n,r)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return Ii;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(kn(r.alignmentBounds,e)){n+=Number(e-r.alignment);break}}return new Zi(this,n,n+t)}updateGLBuffer(e){this.series.forEach(t=>t.updateGLBuffer(e))}get bounds(){return An(this.series.map(e=>e.bounds))}get byteLength(){return new ir(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 jn(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 Mn(this.series.map(e=>e.alignmentBounds),e,t)}parseJSON(e){if(!this.dataType.equals(T.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 Xi(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}},Xi=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}},Zi=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}},Qi=e=>({domain:e>>32n,sample:e&4294967295n}),$i=[`ISO`,`ISODate`,`time`,`preciseTime`,`date`,`preciseDate`,`dateTime`],ea=l.z.enum($i),ta=[`local`,`UTC`],na=l.z.enum(ta),ra=p({ClockSkewCalculator:()=>gr,DataType:()=>T,Density:()=>C,MultiSeries:()=>Yi,Rate:()=>rr,Series:()=>Vi,Size:()=>ir,TIMESTAMP_FORMATS:()=>$i,TIME_ZONES:()=>ta,TimeRange:()=>w,TimeSpan:()=>S,TimeStamp:()=>x,convertDataType:()=>cr,dataTypeZ:()=>mr,isCrudeSeries:()=>Hi,isTelemValue:()=>sr,numericTimeRangeZ:()=>ar,rateZ:()=>fr,sizeZ:()=>pr,timeRangeBoundedZ:()=>hr,timeRangeZ:()=>lr,timeSpanZ:()=>dr,timeStampZ:()=>ur,timeZoneZ:()=>na,timestampFormatZ:()=>ea,typedArrayZ:()=>or}),ia=async e=>await new Promise(t=>setTimeout(t,S.fromMilliseconds(e).milliseconds)),aa=p({Breaker:()=>oa,breakerConfigZ:()=>sa}),oa=class{config;retries;interval;constructor(e){this.config={baseInterval:new S(e?.baseInterval??S.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??ia},this.retries=0,this.interval=new S(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}},sa=l.z.object({baseInterval:S.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),ca=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),la=In,ua=l.z.number().min(0).max(1),da=l.z.tuple([la,la,la,ua]),fa=l.z.tuple([la,la,la]),pa=l.z.object({rgba255:da}),ma=l.z.object({r:la,g:la,b:la,a:ua}),ha=l.z.number().min(0).max(360),ga=l.z.number().min(0).max(100),_a=l.z.number().min(0).max(100),va=l.z.tuple([ha,ga,_a,ua]),ya=l.z.union([ca,fa,da,va,pa,ma]),ba=ya.transform(e=>O(e)),xa=e=>ba.safeParse(e).success,Sa=e=>da.safeParse(e).success,Ca=(e=>{if(e==null)return;let t=ba.safeParse(e);if(t.success)return Ea(t.data);if(typeof e==`string`)return e;throw t.error}),O=(e,t=1)=>{if(e=ya.parse(e),typeof e==`string`)return Wa(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},wa=(e,t)=>{if(e==null||t==null)return e==t;let n=O(e),r=O(t);return n.every((e,t)=>e===r[t])},Ta=(e=>{if(e==null)return;let[t,n,r,i]=O(e),a=Math.round(i*255);return`#${Ka(t)}${Ka(n)}${Ka(r)}${a===255?``:Ka(a)}`}),Ea=e=>{let[t,n,r,i]=O(e);return`rgba(${t}, ${n}, ${r}, ${i})`},Da=e=>`rgb(${Oa(e)})`,Oa=e=>{let[t,n,r]=O(e);return`${t}, ${n}, ${r}`},ka=e=>[...Aa(e),Pa(e)],Aa=e=>[ja(e)/255,Ma(e)/255,Na(e)/255],ja=e=>O(e)[0],Ma=e=>O(e)[1],Na=e=>O(e)[2],Pa=e=>O(e)[3],Fa=e=>wa(Ga,e),Ia=e=>$a(O(e)),La=(e,t)=>{let[n,r,i]=O(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]},Ra=e=>{let[t,n,r]=Aa(e).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},za=e=>{let[t,n,r]=Aa(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},Ba=(e,t)=>{let n=O(e),r=O(t),i=Ra(n),a=Ra(r);return(Math.max(i,a)+.5)/(Math.min(i,a)+.5)},Va=(e,...t)=>{if(t.length===0)throw Error(`[Color.pickByContrast] - must provide at least one color`);let n=O(e),[r]=t.sort((e,t)=>Ba(n,t)-Ba(n,e));return O(r)},Ha=e=>Ra(e)<.5,Ua=e=>Ra(e)>.5,Wa=(e,t=1)=>(e=ca.parse(e),e=Ja(e),[qa(e,0),qa(e,2),qa(e,4),e.length===8?qa(e,6)/255:t]),Ga=[0,0,0,0],Ka=e=>Math.floor(e).toString(16).padStart(2,`0`),qa=(e,t)=>parseInt(e.slice(t,t+2),16),Ja=e=>e.startsWith(`#`)?e.slice(1):e,Ya={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`},Xa=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(ca.safeParse(i).success)return Wa(i)}return(t.length===7||t.length===9)&&ca.safeParse(t).success?Wa(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(Ya[t])return Wa(Ya[t])}},Za=e=>{e=va.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=Qa(i,e,t+1/3),o=Qa(i,e,t),s=Qa(i,e,t-1/3)}return[Math.round(a*255),Math.round(o*255),Math.round(s*255),i]},Qa=(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),$a=e=>{e=da.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]},eo=O(`#000000`),to=O(`#ffffff`),no=l.z.object({key:l.z.string(),color:ya,position:l.z.number(),switched:l.z.boolean().optional()}),ro=l.z.array(no),io=(e,t)=>{if(e.length===0)return Ga;if(e=e.slice().sort((e,t)=>e.position-t.position),t<=e[0].position)return O(e[0].color);if(t>=e[e.length-1].position)return O(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 O(r.color);if(t===i.position)return O(i.color);let a=(t-r.position)/(i.position-r.position),o=O(r.color),s=O(i.color);return O([Math.round(ja(o)+a*(ja(s)-ja(o))),Math.round(Ma(o)+a*(Ma(s)-Ma(o))),Math.round(Na(o)+a*(Na(s)-Na(o))),Pa(o)+a*(Pa(s)-Pa(o))])}return O(e[e.length-1].color)},ao=l.z.object({key:l.z.string(),name:l.z.string(),color:ba}),oo=l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(ao)}),so=p({BLACK:()=>eo,WHITE:()=>to,ZERO:()=>Ga,aValue:()=>Pa,bValue:()=>Na,colorZ:()=>ba,construct:()=>O,contrast:()=>Ba,crudeZ:()=>ya,cssString:()=>Ca,equals:()=>wa,fromCSS:()=>Xa,fromGradient:()=>io,fromHSLA:()=>Za,gValue:()=>Ma,gradientZ:()=>ro,grayness:()=>za,hex:()=>Ta,hsla:()=>Ia,isColor:()=>Sa,isCrude:()=>xa,isDark:()=>Ha,isLight:()=>Ua,isZero:()=>Fa,luminance:()=>Ra,paletteZ:()=>oo,pickByContrast:()=>Va,rValue:()=>ja,rgbCSS:()=>Da,rgbString:()=>Oa,rgba1:()=>ka,rgbaCSS:()=>Ea,setAlpha:()=>La,stopZ:()=>no}),co=In,lo=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({}),uo=l.z.enum(lo),fo=l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),po=e=>l.z.object({subject:fo,resource:e,authority:co}),mo={lower:0,upper:256},ho=(...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}),go=e=>l.z.object({from:po(e),to:l.z.null().optional()}),_o=e=>l.z.object({from:l.z.null().optional(),to:po(e)}),vo=e=>l.z.union([go(e),_o(e),l.z.object({from:po(e),to:po(e)})]),k=p({ABSOLUTE_AUTHORITY:()=>255,AUTHORITY_BOUNDS:()=>mo,Concurrency:()=>lo,ZERO_AUTHORITY:()=>0,acquireZ:()=>_o,authorityZ:()=>co,concurrencyZ:()=>uo,filterTransfersByChannelKey:()=>ho,releaseZ:()=>go,stateZ:()=>po,subjectZ:()=>fo,transferZ:()=>vo}),yo=p({formatValue:()=>bo}),bo=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 So(e.toString());case`object`:return e==null?``:So(JSON.stringify(e))}},xo=/[",\n]/,So=e=>xo.test(e)?`"${e.replace(/"/g,`""`)}"`:e,Co=()=>{},wo=(e,t)=>{let n=new S(t);if(n.valueOf()<=0){let t=((...t)=>e(...t));return t.cancel=Co,t.flush=Co,t}let r,i=null,a=()=>{if(i===null)return;let t=i;i=null,e(...t)},o=((...e)=>{i=e,clearTimeout(r),r=setTimeout(()=>{r=void 0,a()},n.milliseconds)});return o.cancel=()=>{clearTimeout(r),r=void 0,i=null},o.flush=()=>{r!==void 0&&(clearTimeout(r),r=void 0,a())},o};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 To=p({keyZ:()=>Eo,labelZ:()=>Do,newZ:()=>Oo}),Eo=l.z.uuid(),Do=l.z.object({key:Eo,name:l.z.string().min(1),color:ba}),Oo=Do.partial({key:!0}),ko=p({compareSemVer:()=>Mo,createMigration:()=>Io,migrator:()=>Lo,semVerNewer:()=>Po,semVerOlder:()=>Fo,semVerZ:()=>Ao,versionsEqual:()=>No}),Ao=l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),jo=(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},Mo=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;let r=Ao.parse(e),i=Ao.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:jo(o,c)}),No=(e,t,n={})=>Mr(Mo(e,t,n)),Po=(e,t,n={})=>Ar(Mo(e,t,n)),Fo=(e,t,n={})=>kr(Mo(e,t,n)),Io=({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),Pe(t)}},Lo=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:i})=>{let a=Object.keys(t).sort(Mo).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||Po(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 Ro=p({BaseObserver:()=>Bo,Observer:()=>zo}),zo=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?.()}},Bo=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))}},
|
|
14
|
-
`))return`Description:\n${e}`;try{let t=JSON.parse(e);return`Description:\n${JSON.stringify(t,null,2)}`}catch{return`Description: ${e}`}},
|
|
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||Po(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 Ro=p({BaseObserver:()=>Bo,Observer:()=>zo}),zo=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?.()}},Bo=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))}},A=p({entries:()=>Uo,keyZ:()=>Vo,map:()=>Wo,nullishToEmpty:()=>qo,omit:()=>Ko,purgeUndefined:()=>Go,unknownZ:()=>Ho}),Vo=l.z.union([l.z.string(),l.z.number()]),Ho=()=>l.z.record(Vo,l.z.unknown()),Uo=e=>Object.entries(e),Wo=(e,t)=>Object.fromEntries(Uo(e).map(([e,n])=>[e,t(n,e)])),Go=e=>Object.fromEntries(Uo(e).filter(([e,t])=>t!==void 0)),Ko=(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n},qo=((e,t)=>e===void 0||t===void 0?l.z.union([l.z.null().transform(()=>({})),Ho()]).default(()=>({})):l.z.union([l.z.null().transform(()=>({})),l.z.record(e,t)]).default(()=>({}))),Jo=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null?`node`:typeof window>`u`||window.document===void 0?`webworker`:`browser`,Yo=Jo(),Xo=[`macOS`,`Windows`,`Linux`],Zo=[`macos`,`windows`,`linux`],Qo={macos:`macOS`,windows:`Windows`,linux:`Linux`},$o=l.z.enum(Xo).or(l.z.enum(Zo).transform(e=>Qo[e])),es=()=>{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`},ts,ns=((e={})=>{let{force:t,default:n}=e;return t??ts??(ts=es(),ts??n)}),rs=p({OPERATING_SYSTEMS:()=>Xo,RUNTIME:()=>Yo,detect:()=>Jo,getOS:()=>ns,osZ:()=>$o}),is=l.z.object({message:l.z.string().optional(),description:l.z.string().optional(),details:Ho().optional()}),as=e=>{if(typeof e!=`object`||!e||!(`toStatus`in e)||typeof e.toStatus!=`function`)return;let t;try{t=e.toStatus()}catch{return}let n=is.safeParse(t);return n.success?n.data:void 0},os=l.z.object({stack:l.z.string(),error:l.z.instanceof(Error)}).and(Ho()),ss=(e,t)=>{let n=Pe(e),r={variant:`error`,message:t??n.message,description:t==null?void 0:n.message,details:{stack:n.stack??``,error:n}},i=as(e);return i!=null&&(t!=null&&i.message!=null?r.message=`${t}: ${i.message}`:i.message!=null&&(r.message=i.message),i.description!=null&&(r.description=i.description),i.details!=null&&r.details!=null&&(r.details={...r.details,...i.details})),ls(r)},cs=e=>{let t=e.details.error,n=Error(e.message,{cause:e});return n.name=t.name,n.stack=t.stack,n},ls=e=>({key:Ur(),time:x.now(),name:``,...e}),us=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},ds=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},fs={includeTimestamp:!1,includeName:!0},ps=e=>{if(e.includes(`
|
|
14
|
+
`))return`Description:\n${e}`;try{let t=JSON.parse(e);return`Description:\n${JSON.stringify(t,null,2)}`}catch{return`Description: ${e}`}},ms=(e,t={})=>{let n={...fs,...t},r=[],i=e.variant.toUpperCase();if(n.includeName&&ot(e.name)&&(i+=` [${e.name}]`),i+=`: ${e.message}`,n.includeTimestamp&&(i+=` (${e.time.toString(`dateTime`,`local`)})`),r.push(i),e.description!=null&&r.push(ps(e.description)),`details`in e&&ye(e.details)){let t=e.details;`stack`in t&&typeof t.stack==`string`&&t.stack!==``&&r.push(`Stack Trace:\n${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(`
|
|
15
15
|
|
|
16
|
-
`)},gs=[`success`,`info`,`warning`,`error`,`loading`,`disabled`],_s=l.z.enum(gs),vs=l.z.literal(`success`),ys=l.z.literal(`info`),bs=l.z.literal(`warning`),xs=l.z.literal(`error`),Ss=l.z.literal(`loading`),Cs=l.z.literal(`disabled`),ws=({details:e,v:t}={})=>l.z.object({key:l.z.string().default(()=>Ur()),name:l.z.string().default(``),variant:t??_s,message:l.z.string(),description:l.z.string().optional(),time:ur.default(()=>b.now()),details:e??l.z.unknown().optional(),labels:xe(Do.array())}),Ts=({details:e,v:t}={})=>ws({details:e,v:t}).partial({key:!0,name:!0,time:!0}),Es=p({VARIANTS:()=>gs,create:()=>us,disabledVariantZ:()=>Cs,errorVariantZ:()=>xs,exceptionDetailsSchema:()=>ss,fromException:()=>cs,infoVariantZ:()=>ys,keepVariants:()=>ds,loadingVariantZ:()=>Ss,newZ:()=>Ts,removeVariants:()=>fs,statusZ:()=>ws,successVariantZ:()=>vs,toError:()=>ls,toString:()=>hs,variantZ:()=>_s,warningVariantZ:()=>bs}),Ds=(e,t)=>{if(!t.has(e))return e;let n,r,i=e;for(;t.has(i);){let e=i.match(Os);e?(n=i.slice(0,e.index).trim(),r=parseInt(e[1],10)+1):(n=i,r=1),i=`${n} (${r})`}return i},Os=/\((\d+)\)$/,ks=(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]}`},As=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))},js=(e,t)=>e.startsWith(t)?e.slice(t.length):e,Ms=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Ns=p({createShortIdentifiers:()=>As,deduplicateFileName:()=>Ds,escapeHTML:()=>Ms,naturalLanguageJoin:()=>ks,trimPrefix:()=>js});l.z.enum([`h1`,`h2`,`h3`,`h4`,`h5`,`p`,`small`]),l.z.union([l.z.number(),l.z.enum([`normal`,`bold`,`bolder`,`lighter`])]),l.z.object({size:l.z.number(),weight:l.z.union([l.z.number(),l.z.string()]),lineHeight:l.z.number(),textTransform:l.z.string().optional()});var Ps=(...e)=>e.map(Fs).join(``),Fs=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),Is=e=>e.endsWith(`/`)?e.slice(0,-1):e,Ls=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=Fs(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:Ps(this.path,t)})}toString(){return Is(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},Rs=Object.defineProperty,zs=(e,t)=>{let n={};for(var r in e)Rs(n,r,{get:e[r],enumerable:!0});return t||Rs(n,Symbol.toStringTag,{value:`Module`}),n},Bs=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>Bs(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},Vs=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>Vs(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},Hs=`synnax.caseconv.preserveCase`,Us=e=>{if(typeof e!=`object`||!e)return!1;if(Hs in e)return!0;let t=e._zod?.def;return t==null?!1:t.innerType&&Us(t.innerType)?!0:t.type===`union`&&Array.isArray(t.options)?t.options.some(Us):t.type===`pipe`?Us(t.in)||Us(t.out):!1},Ws=e=>{if(e==null)return;let t=e._zod?.def;if(t?.type===`array`&&t.element!=null)return t.element;if(t?.innerType!=null)return Ws(t.innerType);if(t?.type===`union`&&Array.isArray(t.options))for(let e of t.options){let t=Ws(e);if(t!=null)return t}},Gs=e=>{if(e==null)return null;let t=e;if(t.shape!=null)return t.shape;if(typeof t.sourceType==`function`){let e=t.sourceType();if(e?.shape!=null)return e.shape}let n=t._zod?.def;if(n==null)return null;if(n.innerType!=null)return Gs(n.innerType);if(n.type===`union`&&Array.isArray(n.options)){let e=null;for(let t of n.options){let n=Gs(t);if(n!=null)if(e==null)e={...n};else for(let t in n)t in e||(e[t]=n[t])}return e}return n.type===`pipe`?Gs(n.in)??Gs(n.out):null},Ks=e=>{if(e.length===0)return e;let t=e.indexOf(`_`)===-1?e:e.replace(/_[a-z]/g,e=>e[1].toUpperCase()),n=t.charCodeAt(0);return n<65||n>90||t.length>1&&t.charCodeAt(1)>=65&&t.charCodeAt(1)<=90?t:String.fromCharCode(n+32)+t.slice(1)},qs=e=>{let t=(n,r=Xs)=>{if(typeof n==`string`)return e(n);if(Array.isArray(n)){let e=Ws(r.schema),i={recursive:r.recursive,recursiveInArray:r.recursiveInArray,schema:e};return n.map(e=>t(e,i))}if(!Zs(n)||r.schema!=null&&Us(r.schema))return n;let i=r.recursive??!0,a=r.recursiveInArray??i,o=r.schema,s={},c=n;if(`toJSON`in c&&typeof c.toJSON==`function`)return t(c.toJSON(),r);let l=Gs(o),u={recursive:i,recursiveInArray:a,schema:void 0},d=Object.keys(c);for(let n=0;n<d.length;n++){let r=d[n],o=c[r],f=e(r),p=l==null?void 0:l[r]??l[f]??void 0;i&&(Zs(o)?Qs(o)||(u.schema=p,o=t(o,u)):a&&Array.isArray(o)&&(u.schema=Ws(p),o=o.map(e=>{if(Zs(e)){if(!Qs(e))return t(e,u)}else if(Array.isArray(e))return t({key:e},u).key;return e}))),s[f]=o}return s};return t},Js=qs(Ks),Ys=qs(e=>e.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`)),Xs={recursive:!0,recursiveInArray:!0,schema:void 0},Zs=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Qs=e=>e instanceof Uint8Array||e instanceof Number||e instanceof String,$s=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ec=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},tc=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return{present:!1,value:void 0};let t=n;if(!(e in t))return{present:!1,value:void 0};n=t[e]}return{present:!0,value:n}},nc=(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(!nc(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(!nc(r,i))return!1}else if(r!==i)return!1}return!0},rc=(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(!rc(r,i))return!1}else if(r!==i)return!1}return!0},ic=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if($s(e)&&$s(n))for(let t in n)try{$s(n[t])?(t in e||Object.assign(e,{[t]:{}}),ic(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):e}return ic(e,...t)},ac=e=>Object.getOwnPropertySymbols(globalThis).includes(e),oc=(e,t)=>{let n=Symbol.for(e);if(!ac(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},sc=zs({Canceled:()=>Sc,NONE:()=>`nil`,NotImplemented:()=>Cc,UNKNOWN:()=>fc,Unknown:()=>bc,createTyped:()=>uc,decode:()=>yc,encode:()=>vc,isTyped:()=>dc,payloadZ:()=>xc,register:()=>_c}),cc=`sy_x_error`,lc=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,uc=e=>class t extends Error{static discriminator=cc;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=lc(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return uc(`${e}.${t}`)}},dc=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==cc)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},fc=`unknown`,pc=(e,t)=>({...e,name:t.name,stack:t.stack}),mc=(e,t)=>(t.name!=null&&(e.name=t.name),t.stack!=null&&(e.stack=t.stack),e),hc=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(dc(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return pc(n,e)}if(e instanceof Error)return pc({type:fc,data:e.message},e);if(typeof e==`string`)return{type:fc,data:e};try{return{type:fc,data:JSON.stringify(e)}}catch{return{type:fc,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return mc(new bc(e.data),e);for(let t of this.providers){let n=t.decode(e);if(n!=null)return mc(n,e)}return mc(new bc(e.data),e)}},gc=oc(`synnax-error-registry`,()=>new hc),_c=({encode:e,decode:t})=>gc().register({encode:e,decode:t}),vc=e=>gc().encode(e),yc=e=>e==null?null:gc().decode(e),bc=class extends uc(`unknown`){},xc=l.z.object({type:l.z.string(),data:l.z.string(),name:l.z.string().optional(),stack:l.z.string().optional()}),Sc=class extends uc(`canceled`){},Cc=class extends uc(`not_implemented`){},wc=e=>{if(e.length===0)return`<root>`;let t=``;return e.forEach((e,n)=>{typeof e==`number`?t+=`[${e}]`:n===0?t+=String(e):t+=`.${String(e)}`}),t},Tc=200,Ec=10,Dc=8,Oc=(e,t={})=>{let n=t.maxStringLength??Tc,r=t.maxArrayLength??Ec,i=t.maxDepth??Dc,a=(e,t)=>{if(e===null)return null;if(e===void 0)return`[undefined]`;let o=typeof e;if(o===`string`){let t=e;return t.length>n?`${t.slice(0,n)}…(+${t.length-n} chars)`:t}if(o===`number`||o===`boolean`)return e;if(o===`bigint`)return`${e.toString()}n`;if(o===`symbol`||o===`function`)return`[${o}]`;if(Array.isArray(e)){if(t>=i)return`[Array(${e.length})]`;let n=e.slice(0,r).map(e=>a(e,t+1));return e.length>r&&n.push(`…(+${e.length-r} more)`),n}if(ec(e)){if(t>=i)return`[Object]`;let n={};for(let[r,i]of Object.entries(e))n[r]=a(i,t+1);return n}if(e instanceof Date)return e.toISOString();if(e instanceof Error)return`[Error: ${e.message}]`;try{return`[${Object.prototype.toString.call(e)}]`}catch{return`[unknown]`}};return a(e,0)},kc=(e,t={})=>JSON.stringify(Oc(e,t),null,2),Ac=e=>typeof e==`object`&&!!e&&`value`in e,jc=class{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}},Mc=e=>typeof e==`object`&&!!e&&`toString`in e,Nc=e=>e==null||typeof e!=`object`&&typeof e!=`function`,Pc=`value`,Fc=`zod.parse`,Ic=`✗`,Lc=60,Rc={maxStringLength:60,maxArrayLength:3,maxDepth:3},zc=e=>e.slice(0,-1),Bc=e=>{switch(e.code){case`invalid_type`:return`expected ${e.expected}`;case`invalid_value`:return`expected one of ${JSON.stringify(e.values)}`;case`unrecognized_keys`:return`unexpected key`;case`too_small`:{let t=e.inclusive===!1?`>`:`>=`;return`${e.origin} too small: expected ${t}${e.minimum}`}case`too_big`:{let t=e.inclusive===!1?`<`:`<=`;return`${e.origin} too large: expected ${t}${e.maximum}`}case`invalid_format`:return`expected ${e.format} format`;case`not_multiple_of`:return`expected multiple of ${e.divisor}`;case`custom`:return e.message||`custom validation failed`;default:return e.message}},Vc=(e,t,n)=>{let r=JSON.stringify(Oc(t,n));return`${Bc(e)}, received ${r}`},Hc=e=>{let t=0;for(let n of e){if(n.path.length>t&&(t=n.path.length),n.code===`invalid_union`&&`errors`in n)for(let e of n.errors){let n=Hc(e);n>t&&(t=n)}if((n.code===`invalid_key`||n.code===`invalid_element`)&&`issues`in n){let e=Hc(n.issues);e>t&&(t=e)}}return t},Uc=(e,t=[])=>{let n=[];for(let r of e){let e=[...t,...r.path];if(r.code===`invalid_union`&&`errors`in r&&r.errors.length>0){let t=r.errors[0],i=Hc(t);for(let e=1;e<r.errors.length;e++){let n=Hc(r.errors[e]);n>i&&(t=r.errors[e],i=n)}n.push(...Uc(t,e));continue}if(r.code===`invalid_element`&&`issues`in r&&`key`in r&&(typeof r.key==`string`||typeof r.key==`number`)){n.push(...Uc(r.issues,[...e,r.key]));continue}if(r.code===`invalid_key`&&`issues`in r){n.push(...Uc(r.issues,e));continue}n.push({...r,path:e})}return n},Wc=e=>{let t=[];for(let n of e){if(n.code===`unrecognized_keys`&&`keys`in n&&Array.isArray(n.keys)){for(let e of n.keys)t.push({...n,path:[...n.path,e]});continue}t.push(n)}return t},Gc=(e,t,n,r)=>{let i=`${n} `,a=`${n+Ic} `,o={...Rc,...r};if(Array.isArray(e)){let e=-1;for(let n of t.keys()){let t=Number(n);Number.isInteger(t)&&t>e&&(e=t)}let n=o.maxArrayLength??3;e>=n&&(o={...o,maxArrayLength:e+2})}let s=Oc(e,o);if(typeof s!=`object`||!s){let e=JSON.stringify(s),n=t.values().next().value;return[`${a}${e}${n?` × ${n.reason}`:``}`]}let c=[],l=Array.isArray(s);c.push(`${n}${l?`[`:`{`}`);let u=[];if(l){let e=s;for(let n=0;n<e.length;n++){let r=t.get(String(n));u.push({content:JSON.stringify(e[n]),mark:r&&!r.missing?r:void 0})}}else{let e=s;for(let n of Object.keys(e)){let r=t.get(n);u.push({content:`"${n}": ${JSON.stringify(e[n])}`,mark:r&&!r.missing?r:void 0})}for(let[e,n]of t.entries())n.missing&&u.push({content:`"${e}": <missing>`,mark:n})}let d=0;return u.forEach((e,t)=>{if(e.mark==null)return;let n=+(t<u.length-1),r=e.content.length+n;r>d&&r<=Lc&&(d=r)}),u.forEach((e,t)=>{let n=t<u.length-1?`,`:``,r=e.content+n;if(e.mark!=null){let t=` `.repeat(Math.max(2,d-r.length+2));c.push(`${a}${r}${t}× ${e.mark.reason}`)}else c.push(`${i}${r}`)}),c.push(n+(l?`]`:`}`)),c},Kc=`__root__`,qc=(e,t,n)=>{let r=new Map;for(let t of e){let e=t.path.length===0?Kc:`::${wc(zc(t.path))}`,n=r.get(e);n==null?r.set(e,[t]):n.push(t)}let i=[];for(let[e,a]of r){if(e===Kc){i.push(a.map(e=>` × ${Vc(e,t,n)}`).join(`
|
|
17
|
-
`));continue}let r=zc(a[0].path),{present:o,value:s}=
|
|
18
|
-
`));continue}let c=new Map;for(let e of a){let n=String(e.path[e.path.length-1]),r=
|
|
16
|
+
`)},hs=[`success`,`info`,`warning`,`error`,`loading`,`disabled`],gs=l.z.enum(hs),_s=l.z.literal(`success`),vs=l.z.literal(`info`),ys=l.z.literal(`warning`),bs=l.z.literal(`error`),xs=l.z.literal(`loading`),Ss=l.z.literal(`disabled`),Cs=({details:e,v:t}={})=>l.z.object({key:l.z.string().default(()=>Ur()),name:l.z.string().default(``),variant:t??gs,message:l.z.string(),description:l.z.string().optional(),time:ur.default(()=>x.now()),details:e??l.z.unknown().optional(),labels:xe(Do.array())}),ws=({details:e,v:t}={})=>Cs({details:e,v:t}).partial({key:!0,name:!0,time:!0}),Ts=p({VARIANTS:()=>hs,create:()=>ls,disabledVariantZ:()=>Ss,errorVariantZ:()=>bs,exceptionDetailsSchema:()=>os,fromException:()=>ss,infoVariantZ:()=>vs,keepVariants:()=>us,loadingVariantZ:()=>xs,newZ:()=>ws,removeVariants:()=>ds,statusZ:()=>Cs,successVariantZ:()=>_s,toError:()=>cs,toString:()=>ms,variantZ:()=>gs,warningVariantZ:()=>ys}),Es=(e,t)=>{if(!t.has(e))return e;let n,r,i=e;for(;t.has(i);){let e=i.match(Ds);e?(n=i.slice(0,e.index).trim(),r=parseInt(e[1],10)+1):(n=i,r=1),i=`${n} (${r})`}return i},Ds=/\((\d+)\)$/,Os=(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]}`},ks=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))},As=(e,t)=>e.startsWith(t)?e.slice(t.length):e,js=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Ms=p({createShortIdentifiers:()=>ks,deduplicateFileName:()=>Es,escapeHTML:()=>js,naturalLanguageJoin:()=>Os,trimPrefix:()=>As});l.z.enum([`h1`,`h2`,`h3`,`h4`,`h5`,`p`,`small`]),l.z.union([l.z.number(),l.z.enum([`normal`,`bold`,`bolder`,`lighter`])]),l.z.object({size:l.z.number(),weight:l.z.union([l.z.number(),l.z.string()]),lineHeight:l.z.number(),textTransform:l.z.string().optional()});var Ns=(...e)=>e.map(Ps).join(``),Ps=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),Fs=e=>e.endsWith(`/`)?e.slice(0,-1):e,Is=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=Ps(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:Ns(this.path,t)})}toString(){return Fs(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},Ls=Object.defineProperty,Rs=(e,t)=>{let n={};for(var r in e)Ls(n,r,{get:e[r],enumerable:!0});return t||Ls(n,Symbol.toStringTag,{value:`Module`}),n},zs=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>zs(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},Bs=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>Bs(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},Vs=`synnax.caseconv.preserveCase`,Hs=e=>{if(typeof e!=`object`||!e)return!1;if(Vs in e)return!0;let t=e._zod?.def;return t==null?!1:t.innerType&&Hs(t.innerType)?!0:t.type===`union`&&Array.isArray(t.options)?t.options.some(Hs):t.type===`pipe`?Hs(t.in)||Hs(t.out):!1},Us=e=>{if(e==null)return;let t=e._zod?.def;if(t?.type===`array`&&t.element!=null)return t.element;if(t?.innerType!=null)return Us(t.innerType);if(t?.type===`union`&&Array.isArray(t.options))for(let e of t.options){let t=Us(e);if(t!=null)return t}},Ws=e=>{if(e==null)return null;let t=e;if(t.shape!=null)return t.shape;if(typeof t.sourceType==`function`){let e=t.sourceType();if(e?.shape!=null)return e.shape}let n=t._zod?.def;if(n==null)return null;if(n.innerType!=null)return Ws(n.innerType);if(n.type===`union`&&Array.isArray(n.options)){let e=null;for(let t of n.options){let n=Ws(t);if(n!=null)if(e==null)e={...n};else for(let t in n)t in e||(e[t]=n[t])}return e}return n.type===`pipe`?Ws(n.in)??Ws(n.out):null},Gs=e=>{if(e.length===0)return e;let t=e.indexOf(`_`)===-1?e:e.replace(/_[a-z]/g,e=>e[1].toUpperCase()),n=t.charCodeAt(0);return n<65||n>90||t.length>1&&t.charCodeAt(1)>=65&&t.charCodeAt(1)<=90?t:String.fromCharCode(n+32)+t.slice(1)},Ks=e=>{let t=(n,r=Ys)=>{if(typeof n==`string`)return e(n);if(Array.isArray(n)){let e=Us(r.schema),i={recursive:r.recursive,recursiveInArray:r.recursiveInArray,schema:e};return n.map(e=>t(e,i))}if(!Xs(n)||r.schema!=null&&Hs(r.schema))return n;let i=r.recursive??!0,a=r.recursiveInArray??i,o=r.schema,s={},c=n;if(`toJSON`in c&&typeof c.toJSON==`function`)return t(c.toJSON(),r);let l=Ws(o),u={recursive:i,recursiveInArray:a,schema:void 0},d=Object.keys(c);for(let n=0;n<d.length;n++){let r=d[n],o=c[r],f=e(r),p=l==null?void 0:l[r]??l[f]??void 0;i&&(Xs(o)?Zs(o)||(u.schema=p,o=t(o,u)):a&&Array.isArray(o)&&(u.schema=Us(p),o=o.map(e=>{if(Xs(e)){if(!Zs(e))return t(e,u)}else if(Array.isArray(e))return t({key:e},u).key;return e}))),s[f]=o}return s};return t},qs=Ks(Gs),Js=Ks(e=>e.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`)),Ys={recursive:!0,recursiveInArray:!0,schema:void 0},Xs=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Zs=e=>e instanceof Uint8Array||e instanceof Number||e instanceof String,Qs=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$s=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ec=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return{present:!1,value:void 0};let t=n;if(!(e in t))return{present:!1,value:void 0};n=t[e]}return{present:!0,value:n}},tc=(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(!tc(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(!tc(r,i))return!1}else if(r!==i)return!1}return!0},nc=(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(!nc(r,i))return!1}else if(r!==i)return!1}return!0},rc=e=>Object.getOwnPropertySymbols(globalThis).includes(e),ic=(e,t)=>{let n=Symbol.for(e);if(!rc(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},ac=Rs({Canceled:()=>xc,NONE:()=>`nil`,NotImplemented:()=>Sc,UNKNOWN:()=>dc,Unknown:()=>yc,createTyped:()=>cc,decode:()=>vc,encode:()=>_c,fromUnknown:()=>uc,isTyped:()=>lc,payloadZ:()=>bc,register:()=>gc}),oc=`sy_x_error`,sc=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,cc=e=>class t extends Error{static discriminator=oc;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=sc(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return cc(`${e}.${t}`)}},lc=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==oc)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},uc=e=>{if(e instanceof Error)return e;let t;try{t=JSON.stringify(e)??String(e)}catch{t=String(e)}return Error(t,{cause:e})},dc=`unknown`,fc=(e,t)=>({...e,name:t.name,stack:t.stack}),pc=(e,t)=>(t.name!=null&&(e.name=t.name),t.stack!=null&&(e.stack=t.stack),e),mc=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(lc(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return fc(n,e)}if(e instanceof Error)return fc({type:dc,data:e.message},e);if(typeof e==`string`)return{type:dc,data:e};try{return{type:dc,data:JSON.stringify(e)}}catch{return{type:dc,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return pc(new yc(e.data),e);for(let t of this.providers){let n=t.decode(e);if(n!=null)return pc(n,e)}return pc(new yc(e.data),e)}},hc=ic(`synnax-error-registry`,()=>new mc),gc=({encode:e,decode:t})=>hc().register({encode:e,decode:t}),_c=e=>hc().encode(e),vc=e=>e==null?null:hc().decode(e),yc=class extends cc(`unknown`){},bc=l.z.object({type:l.z.string(),data:l.z.string(),name:l.z.string().optional(),stack:l.z.string().optional()}),xc=class extends cc(`canceled`){},Sc=class extends cc(`not_implemented`){},Cc=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if(Qs(e)&&Qs(n))for(let t in n)try{Qs(n[t])?(t in e||Object.assign(e,{[t]:{}}),Cc(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):uc(e)}return Cc(e,...t)},wc=e=>{if(e.length===0)return`<root>`;let t=``;return e.forEach((e,n)=>{typeof e==`number`?t+=`[${e}]`:n===0?t+=String(e):t+=`.${String(e)}`}),t},Tc=200,Ec=10,Dc=8,Oc=(e,t={})=>{let n=t.maxStringLength??Tc,r=t.maxArrayLength??Ec,i=t.maxDepth??Dc,a=(e,t)=>{if(e===null)return null;if(e===void 0)return`[undefined]`;let o=typeof e;if(o===`string`){let t=e;return t.length>n?`${t.slice(0,n)}…(+${t.length-n} chars)`:t}if(o===`number`||o===`boolean`)return e;if(o===`bigint`)return`${e.toString()}n`;if(o===`symbol`||o===`function`)return`[${o}]`;if(Array.isArray(e)){if(t>=i)return`[Array(${e.length})]`;let n=e.slice(0,r).map(e=>a(e,t+1));return e.length>r&&n.push(`…(+${e.length-r} more)`),n}if($s(e)){if(t>=i)return`[Object]`;let n={};for(let[r,i]of Object.entries(e))n[r]=a(i,t+1);return n}if(e instanceof Date)return e.toISOString();if(e instanceof Error)return`[Error: ${e.message}]`;try{return`[${Object.prototype.toString.call(e)}]`}catch{return`[unknown]`}};return a(e,0)},kc=(e,t={})=>JSON.stringify(Oc(e,t),null,2),Ac=e=>typeof e==`object`&&!!e&&`value`in e,jc=class{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}},Mc=e=>typeof e==`object`&&!!e&&`toString`in e,Nc=e=>e==null||typeof e!=`object`&&typeof e!=`function`,Pc=`value`,Fc=`zod.parse`,Ic=`✗`,Lc=60,Rc={maxStringLength:60,maxArrayLength:3,maxDepth:3},zc=e=>e.slice(0,-1),Bc=e=>{switch(e.code){case`invalid_type`:return`expected ${e.expected}`;case`invalid_value`:return`expected one of ${JSON.stringify(e.values)}`;case`unrecognized_keys`:return`unexpected key`;case`too_small`:{let t=e.inclusive===!1?`>`:`>=`;return`${e.origin} too small: expected ${t}${e.minimum}`}case`too_big`:{let t=e.inclusive===!1?`<`:`<=`;return`${e.origin} too large: expected ${t}${e.maximum}`}case`invalid_format`:return`expected ${e.format} format`;case`not_multiple_of`:return`expected multiple of ${e.divisor}`;case`custom`:return e.message||`custom validation failed`;default:return e.message}},Vc=(e,t,n)=>{let r=JSON.stringify(Oc(t,n));return`${Bc(e)}, received ${r}`},Hc=e=>{let t=0;for(let n of e){if(n.path.length>t&&(t=n.path.length),n.code===`invalid_union`&&`errors`in n)for(let e of n.errors){let n=Hc(e);n>t&&(t=n)}if((n.code===`invalid_key`||n.code===`invalid_element`)&&`issues`in n){let e=Hc(n.issues);e>t&&(t=e)}}return t},Uc=(e,t=[])=>{let n=[];for(let r of e){let e=[...t,...r.path];if(r.code===`invalid_union`&&`errors`in r&&r.errors.length>0){let t=r.errors[0],i=Hc(t);for(let e=1;e<r.errors.length;e++){let n=Hc(r.errors[e]);n>i&&(t=r.errors[e],i=n)}n.push(...Uc(t,e));continue}if(r.code===`invalid_element`&&`issues`in r&&`key`in r&&(typeof r.key==`string`||typeof r.key==`number`)){n.push(...Uc(r.issues,[...e,r.key]));continue}if(r.code===`invalid_key`&&`issues`in r){n.push(...Uc(r.issues,e));continue}n.push({...r,path:e})}return n},Wc=e=>{let t=[];for(let n of e){if(n.code===`unrecognized_keys`&&`keys`in n&&Array.isArray(n.keys)){for(let e of n.keys)t.push({...n,path:[...n.path,e]});continue}t.push(n)}return t},Gc=(e,t,n,r)=>{let i=`${n} `,a=`${n+Ic} `,o={...Rc,...r};if(Array.isArray(e)){let e=-1;for(let n of t.keys()){let t=Number(n);Number.isInteger(t)&&t>e&&(e=t)}let n=o.maxArrayLength??3;e>=n&&(o={...o,maxArrayLength:e+2})}let s=Oc(e,o);if(typeof s!=`object`||!s){let e=JSON.stringify(s),n=t.values().next().value;return[`${a}${e}${n?` × ${n.reason}`:``}`]}let c=[],l=Array.isArray(s);c.push(`${n}${l?`[`:`{`}`);let u=[];if(l){let e=s;for(let n=0;n<e.length;n++){let r=t.get(String(n));u.push({content:JSON.stringify(e[n]),mark:r&&!r.missing?r:void 0})}}else{let e=s;for(let n of Object.keys(e)){let r=t.get(n);u.push({content:`"${n}": ${JSON.stringify(e[n])}`,mark:r&&!r.missing?r:void 0})}for(let[e,n]of t.entries())n.missing&&u.push({content:`"${e}": <missing>`,mark:n})}let d=0;return u.forEach((e,t)=>{if(e.mark==null)return;let n=+(t<u.length-1),r=e.content.length+n;r>d&&r<=Lc&&(d=r)}),u.forEach((e,t)=>{let n=t<u.length-1?`,`:``,r=e.content+n;if(e.mark!=null){let t=` `.repeat(Math.max(2,d-r.length+2));c.push(`${a}${r}${t}× ${e.mark.reason}`)}else c.push(`${i}${r}`)}),c.push(n+(l?`]`:`}`)),c},Kc=`__root__`,qc=(e,t,n)=>{let r=new Map;for(let t of e){let e=t.path.length===0?Kc:`::${wc(zc(t.path))}`,n=r.get(e);n==null?r.set(e,[t]):n.push(t)}let i=[];for(let[e,a]of r){if(e===Kc){i.push(a.map(e=>` × ${Vc(e,t,n)}`).join(`
|
|
17
|
+
`));continue}let r=zc(a[0].path),{present:o,value:s}=ec(t,r);if(!o){i.push(a.map(e=>` at ${wc(e.path)}\n × ${Vc(e,t,n)}`).join(`
|
|
18
|
+
`));continue}let c=new Map;for(let e of a){let n=String(e.path[e.path.length-1]),r=ec(t,e.path);c.set(n,{reason:Bc(e),missing:!r.present})}let l=r.length===0,u=Gc(s,c,l?` `:` `,n);l?i.push(u.join(`
|
|
19
19
|
`)):i.push([` at ${wc(r)}`,...u].join(`
|
|
20
20
|
`))}return i.join(`
|
|
21
21
|
|
|
22
22
|
`)},Jc=(e,t)=>{let n=Object.entries(e);return n.every(([,e])=>Nc(e))?n.map(([e,t])=>`${e}=${typeof t==`string`?t:String(t)}`).join(`, `):kc(e,t)},Yc=({issues:e,input:t,label:n,context:r,formatOptions:i})=>{let a=i??{},o=Wc(Uc(e)),s=[`Failed to parse ${n} (${o.length===1?`1 issue`:`${o.length} issues`})`];return s.push(qc(o,t,a)),r!=null&&Object.keys(r).length>0&&s.push(` context: ${Jc(r,a)}`),s.join(`
|
|
23
23
|
|
|
24
|
-
`)},Xc=class extends
|
|
24
|
+
`)},Xc=class extends cc(Fc){issues;input;label;context;constructor({issues:e,input:t,label:n,context:r,cause:i,formatOptions:a}){super(Yc({issues:e,input:t,label:n,context:r,formatOptions:a}),{cause:i}),this.issues=e,this.input=t,this.label=n,this.context=r}toStatus(){let e={input:Oc(this.input),issues:this.issues};return this.context!=null&&(e.context=this.context),{message:`Failed to parse ${this.label}`,description:this.message,details:e}}};gc({encode:e=>{if(!Xc.matches(e))return null;let t=e,n={label:t.label,context:t.context,issues:t.issues,input:Oc(t.input)};return{type:Fc,data:JSON.stringify(n)}},decode:e=>{if(e.type!==Fc)return null;let t=JSON.parse(e.data);return new Xc({issues:t.issues,input:t.input,label:t.label,context:t.context})}});var Zc=(e,t,n={})=>{let r=e.safeParse(t);if(r.success)return r.data;throw new Xc({issues:r.error.issues,input:t,label:n.label??Pc,context:n.context,cause:r.error})},Qc=2**12-1,$c=2**16-1,el=2**20-1,tl=-128,nl=-(2**15),rl=2**15-1,il=-(2n**63n),al=2n**63n-1n,ol=-(2**63),sl=2**63-1,cl=e=>(t,n)=>{if(typeof t==`bigint`){if(dl(n))return e(t,BigInt(n));let r=e(Number(t),Number(n));return typeof r==`number`?BigInt(Math.round(r)):r}return e(Number(t),Number(n))},ll=cl((e,t)=>e-t),ul=cl((e,t)=>e+t),dl=e=>typeof e==`bigint`?!0:Number.isInteger(e),fl=cl((e,t)=>e*t),pl=cl((e,t)=>e/t),ml=[`left`,`right`],hl=l.z.enum(ml),gl=l.z.enum([`top`,`bottom`]),_l=l.z.enum([`px`,`decimal`]),vl=[`top`,`right`,`bottom`,`left`];l.z.enum(vl);var yl=l.z.enum([`x`,`y`]);l.z.enum([`clockwise`,`counterclockwise`]);var bl=[`center`],xl=l.z.enum(bl);l.z.enum([`top`,`right`,`bottom`,`left`,`center`]),l.z.enum([`start`,`center`,`end`]),l.z.enum([`first`,`last`]),l.z.enum([`width`,`height`]),l.z.enum([`signedWidth`,`signedHeight`]);var Sl=l.z.object({x:l.z.number(),y:l.z.number()}),Cl=l.z.object({x:hl,y:gl}),wl=l.z.object({x:_l,y:_l}),Tl=l.z.object({width:l.z.number(),height:l.z.number()}),El=l.z.object({signedWidth:l.z.number(),signedHeight:l.z.number()}),Dl=l.z.object({clientX:l.z.number(),clientY:l.z.number()});l.z.object({zoom:l.z.number().default(1),position:Sl});var Ol=l.z.object({x:l.z.number(),y:l.z.number(),root:Cl.optional(),units:wl.optional()}),kl=l.z.tuple([l.z.number(),l.z.number()]),Al=(e,t,n)=>{let r={};if(typeof t==`object`&&(n=t,t=void 0),n={makeValid:!0,...n},typeof e==`number`||typeof e==`bigint`)t==null?(r.lower=typeof e==`bigint`?0n:0,r.upper=e):(r.lower=e,r.upper=t);else if(Array.isArray(e)){if(e.length!==2)throw Error(`bounds: expected array of length 2`);[r.lower,r.upper]=e}else r.lower=e.lower,r.upper=e.upper;return n?.makeValid?jl(r):r};Object.freeze({lower:0,upper:0}),Object.freeze({lower:-1/0,upper:1/0}),Object.freeze({lower:0,upper:1}),Object.freeze({lower:-1,upper:1});var jl=e=>e.lower>e.upper?{lower:e.upper,upper:e.lower}:e,Ml=(e,t)=>{let n=Al(e);return t<n.lower?n.lower:t>=n.upper?n.upper-(typeof n.upper==`number`?1:1n):t};l.z.int().min(tl).max(127),l.z.int().min(nl).max(rl),l.z.int().min(ol).max(sl);var Nl=l.z.int().min(0).max(255);l.z.int().min(0).max(Qc),l.z.int().min(0).max($c),l.z.int().min(0).max(el);var Pl=class{contentType=`application/json`;decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e,t){return this.encoder.encode(this.encodeString(e,t))}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){let n=qs(JSON.parse(e),{schema:t});return t==null?n:Zc(t,n)}encodeString(e,t){let n=Js((t==null?e:Zc(t,e))??{},{schema:t});return JSON.stringify(n,(e,t)=>ArrayBuffer.isView(t)?Array.from(t):typeof t==`bigint`?t.toString():t)}},Fl=class{contentType=`text/csv`;encode(e){let t=this.encodeString(e);return new TextEncoder().encode(t)}decode(e,t){let n=new TextDecoder().decode(e);return this.decodeString(n,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Qs(e[0]))throw Error(`Payload must be an array of objects`);let t=Object.keys(e[0]),n=[t.join(`,`)];return e.forEach(e=>{let r=t.map(t=>JSON.stringify(e[t]??``));n.push(r.join(`,`))}),n.join(`
|
|
25
25
|
`)}decodeString(e,t){let[n,...r]=e.trim().split(`
|
|
26
|
-
`).map(e=>e.trim());if(n.length===0)return t==null?{}:t.parse({});let i=n.split(`,`).map(e=>e.trim()),a={};return i.forEach(e=>{a[e]=[]}),r.forEach(e=>{let t=e.split(`,`).map(e=>e.trim());i.forEach((e,n)=>{let r=this.parseValue(t[n]);r!=null&&a[e].push(r)})}),t==null?a:t.parse(a)}parseValue(e){if(e==null||e.length===0)return null;let t=Number(e);return isNaN(t)?e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e:t}},Il=class{contentType=`text/plain`;encode(e){if(typeof e!=`string`)throw Error(`TextCodec.encode payload must be a string`);return new TextEncoder().encode(e)}decode(e,t){let n=new TextDecoder().decode(e);return t==null?n:t.parse(n)}},Ll=new Pl;new Fl,new Il;var Rl=365,zl=30,Bl=l.z.union([l.z.tuple([l.z.int()]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12)]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12),l.z.int().min(1).max(31)])]),Vl=(e,t)=>{let n=new A(t);if(![j.DAY,j.HOUR,j.MINUTE,j.SECOND,j.MILLISECOND,j.MICROSECOND,j.NANOSECOND].some(e=>e.equals(n)))throw Error(`Invalid argument for remainder. Must be an even TimeSpan or Timestamp`);let r=e.valueOf()%n.valueOf();return e instanceof A?new A(r):new j(r)},A=class e extends jc{hash(){return this.value.toString()}constructor(t,n=`UTC`){if(t==null)super(e.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*e.MILLISECOND.valueOf());else if(typeof t==`string`)super(e.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(e.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n===`local`&&(r=e.utcOffset.valueOf()),typeof t==`number`&&(isFinite(t)?t=t===sl?al:Math.trunc(t):(isNaN(t)&&(t=0),t=t===1/0?e.MAX:e.MIN)),Ac(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){let i=new Date(t,n-1,r,0,0,0,0);return new e(BigInt(i.getTime())*e.MILLISECOND.valueOf()).truncate(e.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n=`UTC`){let[r,i,a]=t.split(`:`),o=`00`,s=`00`;a!=null&&([o,s]=a.split(`.`));let c=e.hours(parseInt(r??`00`,10)).add(e.minutes(parseInt(i??`00`,10))).add(e.seconds(parseInt(o??`00`,10))).add(e.milliseconds(parseInt(s??`00`,10)));return n===`local`&&(c=c.add(e.utcOffset)),c.valueOf()}static parseDateTimeString(t,n=`UTC`){if(!t.includes(`/`)&&!t.includes(`-`))return e.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let r=t,i=0;if(t.includes(`.`)){let e=t.split(`.`);r=e[0];let n=e[1]||`0`;i=parseInt(n.padEnd(3,`0`).slice(0,3),10)}let a=n===`local`?new Date(r.replace(`T`,` `)):new Date(`${r}Z`);return BigInt(a.getTime())*e.MILLISECOND.valueOf()+BigInt(i)*e.MILLISECOND.valueOf()}let r=new Date(t);return t.includes(`:`)||r.setUTCHours(0,0,0,0),new e(BigInt(r.getTime())*e.MILLISECOND.valueOf(),n).valueOf()}toISOString(t=`UTC`){if(t===`UTC`)return this.date().toISOString();let n=this.date(),r=new j(BigInt(n.getTimezoneOffset())*e.MINUTE.valueOf());return this.sub(r).date().toISOString()}timeString(e=!1,t=`UTC`){let n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){let e=this.date();return`${e.toLocaleString(`default`,{month:`short`})} ${e.toLocaleString(`default`,{day:`numeric`})}`}static get utcOffset(){return new j(BigInt(new Date().getTimezoneOffset())*e.MINUTE.valueOf())}static since(t){return new e().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new e(t).valueOf()}span(e){return this.range(e).span}range(e){return new Ul(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new e(t).valueOf()}afterEq(t){return this.valueOf()>=new e(t).valueOf()}before(t){return this.valueOf()<new e(t).valueOf()}beforeEq(t){return this.valueOf()<=new e(t).valueOf()}add(t){return new e(ul(this.valueOf(),new j(t).valueOf()))}sub(t){return new e(ll(this.valueOf(),new j(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(j.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(j.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(j.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(j.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){let n=this.date();return n.setUTCFullYear(t),new e(n)}setLocalYear(t){let n=this.date();return n.setFullYear(t),new e(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){let n=this.date();return n.setUTCMonth(t),new e(n)}setLocalMonth(t){let n=this.date();return n.setMonth(t),new e(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){let n=this.date();return n.setUTCDate(t),new e(n)}setLocalDay(t){let n=this.date();return n.setDate(t),new e(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){let n=this.date();return n.setHours(t),new e(n)}setHour(t){let n=this.date();return n.setUTCHours(t),new e(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){let n=this.date();return n.setUTCMinutes(t),new e(n)}setLocalMinute(t){let n=this.date();return n.setMinutes(t),new e(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){let n=this.date();return n.setUTCSeconds(t),new e(n)}setLocalSecond(t){let n=this.date();return n.setSeconds(t),new e(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){let n=this.date();return n.setUTCMilliseconds(t),new e(n)}setLocalMillisecond(t){let n=this.date();return n.setMilliseconds(t),new e(n)}toString(e=`ISO`,t=`UTC`){switch(e){case`ISODate`:return this.toISOString(t).slice(0,10);case`time`:return this.timeString(!1,t);case`preciseTime`:return this.timeString(!0,t);case`date`:return this.dateString();case`preciseDate`:return`${this.dateString()} ${this.timeString(!0,t)}`;case`dateTime`:return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}remainder(e){return Vl(this,e)}get isToday(){return this.truncate(j.DAY).equals(e.now().truncate(j.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(j.days(30))?`date`:e.greaterThanOrEqual(j.DAY)?`dateTime`:e.greaterThanOrEqual(j.HOUR)?`time`:`preciseTime`}static now(){return new e(new Date)}static max(...t){let n=e.MIN;for(let r of t){let t=new e(r);t.after(n)&&(n=t)}return n}static min(...t){let n=e.MAX;for(let r of t){let t=new e(r);t.before(n)&&(n=t)}return n}static nanoseconds(t,n=`UTC`){return new e(t,n)}static NANOSECOND=e.nanoseconds(1);static microseconds(t,n=`UTC`){return e.nanoseconds(t*1e3,n)}static MICROSECOND=e.microseconds(1);static milliseconds(t,n=`UTC`){return e.microseconds(t*1e3,n)}static MILLISECOND=e.milliseconds(1);static seconds(t,n=`UTC`){return e.milliseconds(t*1e3,n)}static SECOND=e.seconds(1);static minutes(t,n=`UTC`){return e.seconds(t*60,n)}static MINUTE=e.minutes(1);static hours(t,n=`UTC`){return e.minutes(t*60,n)}static HOUR=e.hours(1);static days(t,n=`UTC`){return e.hours(t*24,n)}static DAY=e.days(1);static MAX=new e(al);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.instanceof(e),l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.date().transform(t=>new e(t)),l.z.custom(e=>e instanceof j).transform(t=>new e(t)),Bl.transform(t=>new e(t))]);static sort(e,t){return Number(e.valueOf()-t.valueOf())}},j=class e extends jc{constructor(e){typeof e==`number`&&(e=Math.trunc(e.valueOf())),Ac(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(t){return t instanceof e?t:t instanceof Hl?t.period:t instanceof A?new e(t):(Ac(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.seconds(t):new e(t))}static fromMilliseconds(t){return t instanceof e?t:t instanceof Hl?t.period:t instanceof A?new e(t):(Ac(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.milliseconds(t):new e(t))}valueOf(){return this.value}hash(){return this.value.toString()}lessThan(t){return this.valueOf()<new e(t).valueOf()}greaterThan(t){return this.valueOf()>new e(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new e(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new e(t).valueOf()}remainder(e){return Vl(this,e)}truncate(t){return new e(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t=`full`){if(t===`semantic`)return this.toSemanticString();let n=this.truncate(e.DAY),r=this.truncate(e.HOUR),i=this.truncate(e.MINUTE),a=this.truncate(e.SECOND),o=this.truncate(e.MILLISECOND),s=this.truncate(e.MICROSECOND),c=this.truncate(e.NANOSECOND),l=n,u=r.sub(n),d=i.sub(r),f=a.sub(i),p=o.sub(a),m=s.sub(o),h=c.sub(s),g=``;return l.isZero||(g+=`${l.days}d `),u.isZero||(g+=`${u.hours}h `),d.isZero||(g+=`${d.minutes}m `),f.isZero||(g+=`${f.seconds}s `),p.isZero||(g+=`${p.milliseconds}ms `),m.isZero||(g+=`${m.microseconds}µs `),h.isZero||(g+=`${h.nanoseconds}ns`),g.trim()}toSemanticString(){let t=new e(this.valueOf()<0n?-this.valueOf():this.valueOf()),n=this.valueOf()<0n;if(t.valueOf()===0n)return`0s`;if(t.lessThan(e.SECOND))return`< 1s`;let r=t.days,i=t.hours,a=t.minutes,o=t.seconds,s=Math.floor(r/Rl),c=Math.floor(r/zl),l=Math.floor(r/7),u=Math.floor(r),d=Math.floor(i),f=Math.floor(a),p=Math.floor(o),m=n?`-`:``;if(s>=1){let e=`${s}y`;if(s<2){let t=Math.floor(r%Rl/zl);t>0&&(e+=` ${t}mo`)}return m+e}if(l>=1&&r<zl&&r%7==0){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(c>=1){let e=`${c}mo`;if(c<3){let t=Math.floor(r%zl);t>0&&(e+=` ${t}d`)}return m+e}if(l>=1){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(u>=1){let e=`${u}d`,t=Math.floor(i-u*24);return u<2&&t>0&&(e+=` ${t}h`),m+e}if(d>=1){let e=`${d}h`;if(d<3){let t=Math.floor(a-d*60);t>0&&(e+=` ${t}m`)}return m+e}if(f>=1){let e=`${f}m`;if(f<5){let t=Math.floor(o-f*60);t>0&&(e+=` ${t}s`)}return m+e}return`${m}${p}s`}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(e.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(e.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(e.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(e.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new e(t).valueOf()}add(t){return new e(this.valueOf()+new e(t).valueOf())}sub(t){return new e(this.valueOf()-new e(t).valueOf())}abs(){let t=this.valueOf();return new e(t<0n?-t:t)}static nanoseconds(t=1){return new e(t)}static NANOSECOND=e.nanoseconds(1);static microseconds(t=1){return e.nanoseconds(fl(t,1e3))}static MICROSECOND=e.microseconds(1);static milliseconds(t=1){return e.microseconds(fl(t,1e3))}static MILLISECOND=e.milliseconds(1);static seconds(t=1){return e.milliseconds(fl(t,1e3))}static SECOND=e.seconds(1);static minutes(t=1){return e.seconds(fl(t,60))}static MINUTE=e.minutes(1);static hours(t){return e.minutes(fl(t,60))}static HOUR=e.hours(1);static days(t){return e.hours(fl(t,24))}static DAY=e.days(1);static MAX=new e(al);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.instanceof(e),l.z.instanceof(A).transform(t=>new e(t)),l.z.custom(e=>e instanceof Hl).transform(t=>new e(t))])},Hl=class e extends jc{constructor(e){Ac(e)&&(e=e.value),super(e.valueOf())}hash(){return this.value.toString()}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new e(t).valueOf()}get period(){return j.seconds(1/this.valueOf())}sampleCount(e){return new j(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new M(t).valueOf()}span(e){return j.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/new M(t).valueOf())}add(t){return new e(ul(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(ll(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}static hz(t){return new e(t)}static khz(t){return e.hz(t*1e3)}static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},M=class e extends jc{constructor(e){Ac(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Wl(e*this.valueOf())}add(t){return new e(ul(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(ll(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}static UNKNOWN=new e(0);static BIT128=new e(16);static BIT64=new e(8);static BIT32=new e(4);static BIT16=new e(2);static BIT8=new e(1);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},Ul=class e{hash(){return`${this.start.hash()}-${this.end.hash()}`}start;end;constructor(e,t){typeof e==`object`&&`start`in e?(this.start=new A(e.start),this.end=new A(e.end)):(this.start=new A(e),this.end=new A(t))}get span(){return new j(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new e(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=j.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString(`preciseDate`)} - ${this.span.toString()}`}overlapsWith(e,t=j.ZERO){e=e.makeValid();let n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;let r=A.max(n.start,e.start),i=A.min(n.end,e.end);return i.before(r)?!1:new j(i.sub(r)).greaterThanOrEqual(t)}contains(t){return t instanceof e?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){let n=new e(this.start,this.end);return t.start.after(this.start)&&(n.start=t.start),t.start.after(this.end)&&(n.end=t.start),t.end.before(this.end)&&(n.end=t.end),t.end.before(this.start)&&(n.start=t.end),n}static max(...t){return new e(A.min(...t.map(e=>e.start)),A.max(...t.map(e=>e.end)))}static MAX=new e(A.MIN,A.MAX);static ZERO=new e(A.ZERO,A.ZERO);static z=l.z.union([l.z.object({start:A.z,end:A.z}).transform(t=>new e(t.start,t.end)),l.z.instanceof(e)]);static boundedZ=e.z.refine(({isValid:e})=>e,{message:`Time range start time must be before or equal to time range end time`}).refine(({end:e})=>e.valueOf()<=al,{message:`Time range end time must be less than or equal to the maximum value of an int64`}).refine(({start:e})=>e.valueOf()>=il,{message:`Time range start time must be greater than or equal to the minimum value of an int64`});static sort(e,t){return A.sort(e.start,t.start)||A.sort(e.end,t.end)}static merge(...t){return e.max(...t.map(t=>new e(t).makeValid()))}},N=class e extends jc{hash(){return this.value}constructor(t){if(Ac(t)&&(t=t.value),t instanceof e||typeof t==`string`||typeof t.valueOf()==`string`)super(t.valueOf());else{let n=e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){let t=e.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(e=>this.equals(e))}toString(t=!1){return t?e.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(e.JSON)||this.equals(e.STRING)||this.equals(e.BYTES)}get isNumeric(){return!this.isVariable&&!this.equals(e.UUID)}get isInteger(){let e=this.toString();return e.startsWith(`int`)||e.startsWith(`uint`)}get isFloat(){return this.toString().startsWith(`float`)}get density(){let t=e.DENSITIES.get(this.toString());if(t==null)throw Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(e.UINT8)||this.equals(e.UINT16)||this.equals(e.UINT32)||this.equals(e.UINT64)}get isSignedInteger(){return this.equals(e.INT8)||this.equals(e.INT16)||this.equals(e.INT32)||this.equals(e.INT64)}canSafelyCastTo(t){return this.equals(t)?!0:!this.isNumeric||!t.isNumeric||this.isVariable||t.isVariable||this.isUnsignedInteger&&t.isSignedInteger?!1:this.isFloat?t.isFloat&&this.density.valueOf()<=t.density.valueOf():this.equals(e.INT32)&&t.equals(e.FLOAT64)||this.equals(e.INT8)&&t.equals(e.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return e.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new e(`unknown`);static FLOAT64=new e(`float64`);static FLOAT32=new e(`float32`);static INT64=new e(`int64`);static INT32=new e(`int32`);static INT16=new e(`int16`);static INT8=new e(`int8`);static UINT64=new e(`uint64`);static UINT32=new e(`uint32`);static UINT16=new e(`uint16`);static UINT8=new e(`uint8`);static TIMESTAMP=new e(`timestamp`);static UUID=new e(`uuid`);static STRING=new e(`string`);static JSON=new e(`json`);static BYTES=new e(`bytes`);static ARRAY_CONSTRUCTORS=new Map([[e.UINT8.toString(),Uint8Array],[e.UINT16.toString(),Uint16Array],[e.UINT32.toString(),Uint32Array],[e.UINT64.toString(),BigUint64Array],[e.FLOAT32.toString(),Float32Array],[e.FLOAT64.toString(),Float64Array],[e.INT8.toString(),Int8Array],[e.INT16.toString(),Int16Array],[e.INT32.toString(),Int32Array],[e.INT64.toString(),BigInt64Array],[e.TIMESTAMP.toString(),BigInt64Array],[e.STRING.toString(),Uint8Array],[e.JSON.toString(),Uint8Array],[e.UUID.toString(),Uint8Array],[e.BYTES.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,e.UINT8],[Uint16Array.name,e.UINT16],[Uint32Array.name,e.UINT32],[BigUint64Array.name,e.UINT64],[Float32Array.name,e.FLOAT32],[Float64Array.name,e.FLOAT64],[Int8Array.name,e.INT8],[Int16Array.name,e.INT16],[Int32Array.name,e.INT32],[BigInt64Array.name,e.INT64]]);static DENSITIES=new Map([[e.UINT8.toString(),M.BIT8],[e.UINT16.toString(),M.BIT16],[e.UINT32.toString(),M.BIT32],[e.UINT64.toString(),M.BIT64],[e.FLOAT32.toString(),M.BIT32],[e.FLOAT64.toString(),M.BIT64],[e.INT8.toString(),M.BIT8],[e.INT16.toString(),M.BIT16],[e.INT32.toString(),M.BIT32],[e.INT64.toString(),M.BIT64],[e.TIMESTAMP.toString(),M.BIT64],[e.STRING.toString(),M.UNKNOWN],[e.JSON.toString(),M.UNKNOWN],[e.UUID.toString(),M.BIT128],[e.BYTES.toString(),M.UNKNOWN]]);static ALL=[e.UNKNOWN,e.UINT8,e.UINT16,e.UINT32,e.UINT64,e.INT8,e.INT16,e.INT32,e.INT64,e.FLOAT32,e.FLOAT64,e.TIMESTAMP,e.UUID,e.STRING,e.JSON,e.BYTES];static SHORT_STRINGS=new Map([[e.UINT8.toString(),`u8`],[e.UINT16.toString(),`u16`],[e.UINT32.toString(),`u32`],[e.UINT64.toString(),`u64`],[e.INT8.toString(),`i8`],[e.INT16.toString(),`i16`],[e.INT32.toString(),`i32`],[e.INT64.toString(),`i64`],[e.FLOAT32.toString(),`f32`],[e.FLOAT64.toString(),`f64`],[e.TIMESTAMP.toString(),`ts`],[e.UUID.toString(),`uuid`],[e.STRING.toString(),`str`],[e.JSON.toString(),`json`],[e.BYTES.toString(),`bytes`]]);static BIG_INT_TYPES=[e.INT64,e.UINT64,e.TIMESTAMP];static z=l.z.union([l.z.string().transform(t=>new e(t)),l.z.instanceof(e)])},Wl=class e extends jc{constructor(e){Ac(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return Ac(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return Ac(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(t){return Ac(t)&&(t=t.value),new e(ul(this.valueOf(),t.valueOf()))}sub(t){return Ac(t)&&(t=t.value),new e(ll(this.valueOf(),t.valueOf()))}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}truncate(t){return new e(Math.trunc(this.valueOf()/new e(t).valueOf())*new e(t).valueOf())}remainder(t){return e.bytes(this.valueOf()%new e(t).valueOf())}get gigabytes(){return this.valueOf()/e.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/e.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/e.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/e.TERABYTE.valueOf()}toString(){let t=this.truncate(e.TERABYTE),n=this.truncate(e.GIGABYTE),r=this.truncate(e.MEGABYTE),i=this.truncate(e.KILOBYTE),a=this.truncate(e.BYTE),o=t,s=n.sub(t),c=r.sub(n),l=i.sub(r),u=a.sub(i),d=``;return o.isZero||(d+=`${o.terabytes}TB `),s.isZero||(d+=`${s.gigabytes}GB `),c.isZero||(d+=`${c.megabytes}MB `),l.isZero||(d+=`${l.kilobytes}KB `),(!u.isZero||d===``)&&(d+=`${u.valueOf()}B`),d.trim()}static bytes(t=1){return new e(t)}static BYTE=new e(1);static kilobytes(t=1){return e.bytes(new e(t).valueOf()*1e3)}static KILOBYTE=e.kilobytes(1);static megabytes(t=1){return e.kilobytes(new e(t).valueOf()*1e3)}static MEGABYTE=e.megabytes(1);static gigabytes(t=1){return e.megabytes(new e(t).valueOf()*1e3)}static GIGABYTE=e.gigabytes(1);static terabytes(t){return e.gigabytes(new e(t).valueOf()*1e3)}static TERABYTE=e.terabytes(1);static ZERO=new e(0);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)]);get isZero(){return this.valueOf()===0}};l.z.object({start:l.z.number(),end:l.z.number()}),l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]);var Gl=e=>{let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===`bigint`||e instanceof A||e instanceof j||e instanceof Date},Kl=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(BigInt(n.valueOf())-BigInt(r.valueOf())):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):ll(n,r);Ul.z,A.z,j.z,Hl.z,Wl.z,N.z,Ul.boundedZ;var ql=(e,t=!1)=>{let n=Mc(e)?`stringer`:typeof e,r;switch(n){case`string`:r=(e,t)=>e.localeCompare(t);break;case`stringer`:r=(e,t)=>e.toString().localeCompare(t.toString());break;case`number`:r=(e,t)=>Number(e)-Number(t);break;case`bigint`:r=(e,t)=>BigInt(e)-BigInt(t)>0n?1:-1;break;case`boolean`:r=(e,t)=>Number(e)-Number(t);break;case`undefined`:r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?Jl(r):r},Jl=e=>(t,n)=>e(n,t),Yl=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Xl=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Zl=`0123456789${Xl}`,Ql=Yl(Xl,1),$l=Yl(Zl,10),eu=()=>`${Ql()}${$l()}`,tu=(e,t)=>n=>n instanceof t||typeof n==`object`&&!!n&&`discriminator`in n&&n.discriminator===e;l.default.enum([`x`,`y`,...vl,...bl]);var nu=Cl;l.z.union([yl,l.z.enum([...vl,...bl]),l.z.instanceof(String)]),l.z.object({x:hl.or(xl),y:gl.or(xl)});var ru=Object.freeze({x:`left`,y:`top`}),iu=Object.freeze({x:`right`,y:`top`}),au=Object.freeze({x:`left`,y:`bottom`}),ou=Object.freeze({x:`right`,y:`bottom`}),su=Object.freeze({x:`center`,y:`center`}),cu=Object.freeze({x:`center`,y:`top`}),lu=Object.freeze({x:`center`,y:`bottom`}),uu=Object.freeze({x:`right`,y:`center`}),du=Object.freeze({x:`left`,y:`center`});Object.freeze([du,uu,cu,lu,ru,iu,au,ou,su]);var fu=(e,t)=>e.x===t.x&&e.y===t.y,pu=e=>[e.x,e.y],mu=l.z.union([l.z.number(),Sl,kl,Tl,El,Dl]),hu=(e,t)=>{if(typeof e==`string`){if(t===void 0)throw Error(`The y coordinate must be given.`);return e===`x`?{x:t,y:0}:{x:0,y:t}}return typeof e==`number`?{x:e,y:t??e}:Array.isArray(e)?{x:e[0],y:e[1]}:`signedWidth`in e?{x:e.signedWidth,y:e.signedHeight}:`clientX`in e?{x:e.clientX,y:e.clientY}:`width`in e?{x:e.width,y:e.height}:{x:e.x,y:e.y}},gu=Object.freeze({x:0,y:0});Object.freeze({x:1,y:1}),Object.freeze({x:1/0,y:1/0}),Object.freeze({x:NaN,y:NaN});var _u=(e,t)=>{let n=hu(e);return{x:n.x+t,y:n.y}},vu=(e,t)=>{let n=hu(e);return{x:n.x,y:n.y+t}},yu=(e,t,n,...r)=>{if(typeof t==`string`){if(typeof n!=`number`)throw Error(`The value must be a number.`);return t===`x`?_u(e,n):vu(e,n)}if(typeof t==`object`&&`x`in t&&typeof t.x==`string`){let r=hu(n),i=hu(e);return t.x===`left`?r.x=-r.x:t.x===`center`&&(r.x=0),t.y===`top`?r.y=-r.y:t.y===`center`&&(r.y=0),{x:i.x+r.x,y:i.y+r.y}}return[e,t,n??gu,...r].reduce((e,t)=>{let n=hu(t);return{x:e.x+n.x,y:e.y+n.y}},gu)},bu=l.z.union([l.z.number(),l.z.string()]);l.z.object({top:bu,left:bu,width:bu,height:bu}),l.z.object({left:l.z.number(),top:l.z.number(),right:l.z.number(),bottom:l.z.number()}),l.z.object({one:Sl,two:Sl,root:nu});var xu=(e,t,n=0,r=0,i)=>{let a={one:{...gu},two:{...gu},root:i??ru};if(typeof e==`number`){if(typeof t!=`number`)throw Error(`Box constructor called with invalid arguments`);return a.one={x:e,y:t},a.two={x:a.one.x+n,y:a.one.y+r},a}return`one`in e&&`two`in e&&`root`in e?{...e,root:i??e.root}:(`getBoundingClientRect`in e&&(e=e.getBoundingClientRect()),`left`in e?(a.one={x:e.left,y:e.top},a.two={x:e.right,y:e.bottom},a):(a.one=e,t==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof t==`number`?a.two={x:a.one.x+t,y:a.one.y+n}:`width`in t?a.two={x:a.one.x+t.width,y:a.one.y+t.height}:`signedWidth`in t?a.two={x:a.one.x+t.signedWidth,y:a.one.y+t.signedHeight}:a.two=t,a))},Su=(e,t)=>{let n=xu(e);return{x:t.x===`center`?Du(n).x:Cu(n,t.x),y:t.y===`center`?Du(n).y:Cu(n,t.y)}},Cu=(e,t)=>{let n=xu(e),r=pu(n.root).includes(t)?Math.min:Math.max;return ml.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},wu=e=>{let t=xu(e);return t.two.x-t.one.x},Tu=e=>{let t=xu(e);return t.two.y-t.one.y},Eu=e=>Su(e,ru),Du=e=>yu(Eu(e),{x:wu(e)/2,y:Tu(e)/2}),Ou=e=>{let t=xu(e);return{lower:t.one.x,upper:t.two.x}},ku=e=>{let t=xu(e);return{lower:t.one.y,upper:t.two.y}},Au=e=>typeof e!=`object`||!e?!1:`one`in e&&`two`in e&&`root`in e;l.z.union([Tl,El,Sl,kl]);var ju=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e;l.z.object({offset:mu,scale:mu}),l.z.object({offset:l.z.number(),scale:l.z.number()});var Mu=e=>(t,n,r,i)=>n===`dimension`?[t,r]:[t,i?r-e:r+e],Nu=e=>(t,n,r,i)=>[t,i?r/e:r*e],Pu=e=>(t,n,r)=>{if(t===null)return[e,r];let{lower:i,upper:a}=t,{lower:o,upper:s}=e,c=a-i,l=s-o;return n===`dimension`?[e,l/c*r]:[e,(r-i)*(l/c)+o]},Fu=e=>(t,n,r)=>[e,r],Iu=()=>(e,t,n)=>{if(e===null)throw Error(`cannot invert without bounds`);if(t===`dimension`)return[e,n];let{lower:r,upper:i}=e;return[e,i-(n-r)]},Lu=e=>(t,n,r)=>{let{lower:i,upper:a}=e;return r=ju(r,i,a),[t,r]},Ru=class e{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new e().translate(t)}static magnify(t){return new e().magnify(t)}static scale(t,n){return new e().scale(t,n)}translate(e){let t=this.new(),n=Mu(e);return n.type=`translate`,t.ops.push(n),t}magnify(e){let t=this.new(),n=Nu(e);return n.type=`magnify`,t.ops.push(n),t}scale(e,t){let n=Al(e,t),r=this.new(),i=Pu(n);return i.type=`scale`,r.ops.push(i),r}clamp(e,t){let n=Al(e,t),r=this.new(),i=Lu(n);return i.type=`clamp`,r.ops.push(i),r}reBound(e,t){let n=Al(e,t),r=this.new(),i=Fu(n);return i.type=`re-bound`,r.ops.push(i),r}invert(){let e=Iu();e.type=`invert`;let t=this.new();return t.ops.push(e),t}pos(e){return this.exec(`position`,e)}dim(e){return this.exec(`dimension`,e)}new(){let t=new e;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(e,t){return this.currBounds=null,this.ops.reduce(([t,n],r)=>r(t,e,n,this.reversed),[null,t])[1]}reverse(){let e=this.new();e.ops.reverse();let t=[];return e.ops.forEach((n,r)=>{if(n.type===`scale`||t.some(([e,t])=>r>=e&&r<=t))return;let i=e.ops.findIndex((e,t)=>e.type===`scale`&&t>r);i!==-1&&t.push([r,i])}),t.forEach(([t,n])=>{let r=e.ops.slice(t,n);r.unshift(e.ops[n]),e.ops.splice(t,n-t+1,...r)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new e};(class e{x;y;currRoot;constructor(e=new Ru,t=new Ru,n=null){this.x=e,this.y=t,this.currRoot=n}static translate(t,n){return new e().translate(t,n)}static translateX(t){return new e().translateX(t)}static translateY(t){return new e().translateY(t)}static clamp(t){return new e().clamp(t)}static magnify(t){return new e().magnify(t)}static scale(t){return new e().scale(t)}static reBound(t){return new e().reBound(t)}translate(e,t){let n=hu(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){let t=this.copy();return t.x=this.x.translate(e),t}translateY(e){let t=this.copy();return t.y=this.y.translate(e),t}magnify(e){let t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){let t=this.copy();if(Au(e)){let n=this.currRoot;return t.currRoot=e.root,n!=null&&!fu(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Ou(e)),t.y=t.y.scale(ku(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){let t=this.copy();return t.x=this.x.reBound(Ou(e)),t.y=this.y.reBound(ku(e)),t}clamp(e){let t=this.copy();return t.x=this.x.clamp(Ou(e)),t.y=this.y.clamp(ku(e)),t}copy(){let t=new e;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){let e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return xu(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new e}),Ol.required({root:!0,units:!0});var zu=l.z.enum([`static`,`dynamic`]),Bu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Vu(e){return typeof e==`string`&&Bu.test(e)}var P=[];for(let e=0;e<256;++e)P.push((e+256).toString(16).slice(1));function Hu(e,t=0){return(P[e[t+0]]+P[e[t+1]]+P[e[t+2]]+P[e[t+3]]+`-`+P[e[t+4]]+P[e[t+5]]+`-`+P[e[t+6]]+P[e[t+7]]+`-`+P[e[t+8]]+P[e[t+9]]+`-`+P[e[t+10]]+P[e[t+11]]+P[e[t+12]]+P[e[t+13]]+P[e[t+14]]+P[e[t+15]]).toLowerCase()}function Uu(e,t=0){let n=Hu(e,t);if(!Vu(n))throw TypeError(`Stringified UUID is invalid`);return n}var Wu=(e,t)=>Uu(e,t),Gu=e=>{let t=Math.fround(e);if(!Number.isFinite(t))return t.toString();for(let e=1;e<=9;e++){let n=parseFloat(t.toPrecision(e));if(Math.fround(n)===t)return n.toString()}return t.toString()},Ku=-1,qu={[Symbol.iterator]:()=>qu,next:()=>({done:!0,value:void 0})},Ju=l.z.string().transform(e=>new Uint8Array(atob(e).split(``).map(e=>e.charCodeAt(0))).buffer),Yu=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),F=4,Xu=(e,t)=>{if(e===`number`&&!t.isNumeric)throw Error(`cannot convert series of type ${t.toString()} to number`);if(e===`bigint`&&!t.usesBigInt)throw Error(`cannot convert series of type ${t.toString()} to bigint`)},Zu=`sy_x_telem_series`,Qu=class e{key;discriminator=Zu;dataType;sampleOffset;gl;_data;timeRange=Ul.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ku;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=l.z.object({timeRange:Ul.z.optional(),dataType:N.z,alignment:l.z.coerce.bigint().optional(),data:l.z.union([Ju,Yu,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]).default(()=>new Uint8Array().buffer),glBufferUsage:zu.default(`static`).optional()});static z=e.crudeZ.transform(t=>new e(t));constructor(e){$u(e)&&(e={data:e}),e.data??=[];let{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:i=`static`,alignment:a=0n,alignmentMultiple:o=1n,key:s=eu(),data:c}=e;if(ed(c)){let e=c;this.key=e.key,this.dataType=e.dataType,this.sampleOffset=e.sampleOffset,this.gl=e.gl,this._data=e._data,this.timeRange=e.timeRange,this.alignment=e.alignment,this.alignmentMultiple=e.alignmentMultiple,this.cachedMin=e.cachedMin,this.cachedMax=e.cachedMax,this.writePos=e.writePos,this._refCount=e._refCount,this.cachedLength=e.cachedLength;return}let l=Gl(c),u=Array.isArray(c);if(t!=null)this.dataType=new N(t);else if(c instanceof ArrayBuffer)throw Error(`cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.`);else if(u||l){let e=c;if(!l){if(c.length===0)throw Error(`cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.`);e=c[0]}if(typeof e==`string`)this.dataType=N.STRING;else if(typeof e==`number`)this.dataType=N.FLOAT64;else if(typeof e==`bigint`)this.dataType=N.INT64;else if(typeof e==`boolean`)this.dataType=N.UINT8;else if(e instanceof A||e instanceof Date||e instanceof A)this.dataType=N.TIMESTAMP;else if(typeof e==`object`)this.dataType=N.JSON;else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`)}else this.dataType=new N(c);if(!u&&!l)this._data=c;else if(u&&c.length===0)this._data=new this.dataType.Array([]).buffer;else{let e=l?[c]:c,t=e[0];if((t instanceof A||t instanceof Date||t instanceof j)&&(e=e.map(e=>new A(e).valueOf())),this.dataType.equals(N.STRING)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(e)),n=t.reduce((e,t)=>e+F+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=F,a.set(e,o),o+=e.byteLength;this._data=r}else if(this.dataType.equals(N.JSON)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(Ll.encodeString(e))),n=t.reduce((e,t)=>e+F+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=F,a.set(e,o),o+=e.byteLength;this._data=r}else 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??Ul.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 N(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===Ku)return 0;let t=this.byteCapacity.valueOf()-this.writePos,n=e.buffer,r=e.byteLength.valueOf(),i=new DataView(n),a=0,o=0;for(;a+F<=r;){let e=F+i.getUint32(a,!0);if(a+e>t)break;a+=e,o++}if(a===0)return 0;let s=e.subBytes(0,a);return this.writeToUnderlyingData(s),this.writePos+=a,this.cachedLength=(this.cachedLength??0)+o,this._cachedIndexes=void 0,o}writeFixed(e){if(this.writePos===Ku)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===Ku?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(this.dataType.isVariable){let e=[],t=this.buffer,n=this.byteLength.valueOf(),r=new DataView(t),i=new TextDecoder,a=0;for(;a+F<=n;){let n=r.getUint32(a,!0);a+=F,e.push(i.decode(new Uint8Array(t,a,n))),a+=n}return e}return Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(N.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(Ll.decodeString(t)))}get byteCapacity(){return new Wl(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ku?this.byteCapacity:this.dataType.isVariable?new Wl(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ku?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=[],n=this.buffer,r=this.byteLength.valueOf(),i=new DataView(n),a=0;for(;a+F<=r;){let n=i.getUint32(a,!0);a+=F,t.push(a),a+=n,e++}return 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]=Kl(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(){if(this.length===0)return-1/0;if(this.dataType.equals(N.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}else{let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}return 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(),this.applyOffset(this.cachedMax))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(N.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}else{let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}return 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(),this.applyOffset(this.cachedMin))}get bounds(){return Al(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){let n=this.atVariable(e,t);return n==null?void 0:this.dataType.equals(N.STRING)?n:Js(JSON.parse(n))}if(this.dataType.equals(N.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 this.applyOffset(n)}applyOffset(e){return typeof this.sampleOffset==`bigint`&&typeof e==`number`?BigInt(Math.round(e))+this.sampleOffset:ul(e,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=Wu(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}asString(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t);if(this.dataType.equals(N.UUID))return this.atUUID(e,t);let n=this.at(e,t);if(n!=null)return this.dataType.equals(N.FLOAT32)?Gu(n):String(n)}atVariable(e,t){let n=0,r=0,i=this.buffer,a=new DataView(i);if(this._cachedIndexes!=null){if(e<0&&(e=this._cachedIndexes.length+e),e<0||e>=this._cachedIndexes.length){if(t)throw Error(`[series] - no value at index ${e}`);return}n=this._cachedIndexes[e],r=a.getUint32(n-F,!0)}else{e<0&&(e=this.length+e);let i=this.byteLength.valueOf(),o=0,s=!1;for(;o+F<=i;){let t=a.getUint32(o,!0);if(o+=F,e===0){n=o,r=t,s=!0;break}o+=t,e--}if(!s){if(t)throw Error(`[series] - no value at index ${e}`);return}}let o=new Uint8Array(i,n,r);return new TextDecoder().decode(o)}binarySearch(e){let t=0,n=this.length-1,r=ql(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(N.FLOAT32)&&!this.dataType.equals(N.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!==Ku){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=Ku}as(e){return Xu(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:od(this.alignmentBounds.lower),upper:od(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return Al(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 nd(this);return this.dataType.equals(N.JSON)?new rd(e):e}return this.dataType.equals(N.UUID)?new id(this):new ad(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new td(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 td(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:Ul.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}},$u=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof Qu?!0:Gl(e),ed=tu(Zu,Qu),td=class{series;end;index;constructor(e,t,n){this.series=e;let r=Al(0,e.length+1);this.end=Ml(r,n),this.index=Ml(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},nd=class{series;byteOffset;decoder;view;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.byteOffset=0,this.decoder=new TextDecoder,this.view=new DataView(e.buffer)}next(){let e=this.series.byteLength.valueOf();if(this.byteOffset+F>e)return{done:!0,value:void 0};let t=this.view.getUint32(this.byteOffset,!0);this.byteOffset+=F;let n=this.decoder.decode(new Uint8Array(this.series.buffer,this.byteOffset,t));return this.byteOffset+=t,{done:!1,value:n}}},rd=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:Ll.decodeString(t.value,e.schema)}}},id=class{series;index;data;density;constructor(e){if(!e.dataType.equals(N.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=N.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=Wu(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},ad=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)}}},od=e=>({domain:e>>32n,sample:e&4294967295n});l.z.enum([`ISO`,`ISODate`,`time`,`preciseTime`,`date`,`preciseDate`,`dateTime`]),l.z.enum([`local`,`UTC`]);var sd=async e=>await new Promise(t=>setTimeout(t,j.fromMilliseconds(e).milliseconds)),cd=zs({Breaker:()=>ld,breakerConfigZ:()=>ud}),ld=class{config;retries;interval;constructor(e){this.config={baseInterval:new j(e?.baseInterval??j.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??sd},this.retries=0,this.interval=new j(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}},ud=l.z.object({baseInterval:j.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),dd=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),fd=Nl,pd=l.z.number().min(0).max(1),md=l.z.tuple([fd,fd,fd,pd]),hd=l.z.tuple([fd,fd,fd]),gd=l.z.object({rgba255:md}),_d=l.z.object({r:fd,g:fd,b:fd,a:pd}),vd=l.z.number().min(0).max(360),yd=l.z.number().min(0).max(100),bd=l.z.number().min(0).max(100),xd=l.z.tuple([vd,yd,bd,pd]),Sd=l.z.union([dd,hd,md,xd,gd,_d]),Cd=Sd.transform(e=>wd(e)),wd=(e,t=1)=>{if(e=Sd.parse(e),typeof e==`string`)return Td(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},Td=(e,t=1)=>(e=dd.parse(e),e=Dd(e),[Ed(e,0),Ed(e,2),Ed(e,4),e.length===8?Ed(e,6)/255:t]),Ed=(e,t)=>parseInt(e.slice(t,t+2),16),Dd=e=>e.startsWith(`#`)?e.slice(1):e;wd(`#000000`),wd(`#ffffff`);var Od=l.z.object({key:l.z.string(),color:Sd,position:l.z.number(),switched:l.z.boolean().optional()});l.z.array(Od);var kd=l.z.object({key:l.z.string(),name:l.z.string(),color:Cd});l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(kd)});var Ad=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({});l.z.enum(Ad),l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),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 jd=l.z.uuid();l.z.object({key:jd,name:l.z.string().min(1),color:Cd}).partial({key:!0}),l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),l.z.enum([`standard`,`scientific`,`engineering`]);var Md=l.z.union([l.z.string(),l.z.number()]),Nd=()=>l.z.record(Md,l.z.unknown());typeof process<`u`&&process.versions!=null&&process.versions.node!=null||typeof window>`u`||window.document;var Pd=[`macOS`,`Windows`,`Linux`],Fd=[`macos`,`windows`,`linux`],Id={macos:`macOS`,windows:`Windows`,linux:`Linux`};l.z.enum(Pd).or(l.z.enum(Fd).transform(e=>Id[e])),l.z.object({message:l.z.string().optional(),description:l.z.string().optional(),details:Nd().optional()}),l.z.object({stack:l.z.string(),error:l.z.instanceof(Error)}).and(Nd()),l.z.enum([`success`,`info`,`warning`,`error`,`loading`,`disabled`]),l.z.literal(`success`),l.z.literal(`info`),l.z.literal(`warning`),l.z.literal(`error`),l.z.literal(`loading`),l.z.literal(`disabled`),l.z.enum([`h1`,`h2`,`h3`,`h4`,`h5`,`p`,`small`]),l.z.union([l.z.number(),l.z.enum([`normal`,`bold`,`bolder`,`lighter`])]),l.z.object({size:l.z.number(),weight:l.z.union([l.z.number(),l.z.string()]),lineHeight:l.z.number(),textTransform:l.z.string().optional()});var Ld=(...e)=>e.map(Rd).join(``),Rd=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),zd=e=>e.endsWith(`/`)?e.slice(0,-1):e,Bd=(e,t=``)=>e===null?``:`?${Object.entries(e).filter(([,e])=>e==null?!1:Array.isArray(e)?e.length>0:!0).map(([e,n])=>`${t}${e}=${n}`).join(`&`)}`,Vd=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=Rd(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:Ld(this.path,t)})}toString(){return zd(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},Hd=class extends sc.createTyped(`freighter`){},Ud=class extends Hd.sub(`eof`){constructor(){super(`EOF`)}},Wd=class extends Hd.sub(`stream_closed`){constructor(){super(`StreamClosed`)}},Gd=class extends Hd.sub(`unreachable`){url;constructor(e={}){let{message:t=`Unreachable`,url:n=Vd.UNKNOWN}=e;super(t),this.url=n}};sc.register({encode:e=>{if(!e.type.startsWith(Hd.TYPE))return null;if(Ud.matches(e))return{type:Ud.TYPE,data:`EOF`};if(Wd.matches(e))return{type:Wd.TYPE,data:`StreamClosed`};if(Gd.matches(e))return{type:Gd.TYPE,data:`Unreachable`};throw Error(`Unknown error type: ${e.type}: ${e.message}`)},decode:e=>{if(!e.type.startsWith(Hd.TYPE))return null;switch(e.type){case Ud.TYPE:return new Ud;case Wd.TYPE:return new Wd;case Gd.TYPE:return new Gd;default:throw new sc.Unknown(`Unknown error type: ${e.data}`)}}});var Kd=class{middleware=[];use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0,r=async e=>{if(n===this.middleware.length)return await t(e);let i=this.middleware[n];return n++,await i(e,r)};return await r(e)}},qd=`Content-Type`,Jd=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`EPIPE`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_SOCKET`]),Yd=e=>{let t=e?.cause?.code??e?.code??e?.errno;if(typeof t==`string`&&Jd.has(t))return!0;if(e.name===`TypeError`){let t=String(e.message||``).toLowerCase();if(/load failed|failed to fetch|networkerror|network error/.test(t))return typeof navigator<`u`&&navigator.onLine,!0}return e?.name===`AbortError`||e?.code,!1},Xd=400,Zd=class extends Kd{endpoint;encoder;constructor(e,t,n=!1){return super(),this.endpoint=e.replace({protocol:n?`https`:`http`}),this.encoder=t,new Proxy(this,{get:(e,t,n)=>t===`endpoint`?this.endpoint:Reflect.get(e,t,n)})}get headers(){return{[qd]:this.encoder.contentType}}async send(e,t,n,r){let i=null,a=this.endpoint.child(e),o={};if(o.method=`POST`,o.body=this.encoder.encode(t,n),await this.executeMiddleware({target:a.toString(),protocol:this.endpoint.protocol,params:{},role:`client`},async e=>{let t={...e,params:{}};o.headers={...this.headers,...e.params};let n;try{n=await fetch(e.target,o)}catch(e){throw e instanceof Error&&Yd(e)?new Gd({url:a}):e}let s=await n.arrayBuffer();if(n?.ok)return r!=null&&(i=this.encoder.decode(s,r)),t;if(n.status!==Xd)throw Error(n.statusText);let c;try{c=sc.decode(this.encoder.decode(s,sc.payloadZ))}catch(e){throw e instanceof Error?Error(`[freighter] - failed to decode error: ${n.statusText}: ${e.message}`,{cause:e}):e}throw c??Error(n.statusText)}),i==null)throw Error(`Response must be defined`);return i}},Qd=(e,t)=>{class n{wrapped;constructor(e){this.wrapped=e}use(...e){this.wrapped.use(...e)}async send(e,n,r,i){let a=new cd.Breaker(t);do try{return await this.wrapped.send(e,n,r,i)}catch(e){if(!Gd.matches(e)||(console.warn(`[freighter] ${a.retryMessage}`,e),!await a.wait()))throw e}while(!0)}}return new n(e)},$d=l.z.object({type:l.z.enum([`data`,`close`,`open`]),payload:l.z.unknown(),error:l.z.optional(sc.payloadZ)}),ef=class{codec;reqSchema;resSchema;ws;serverClosed;sendClosed;receiveDataQueue=[];receiveCallbacksQueue=[];constructor(e,t,n,r){this.codec=t,this.reqSchema=n,this.resSchema=r,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){let e=await this.receiveMsg();if(e.type!==`open`)throw e.error==null?Error(`Message error must be defined`):sc.decode(e.error)??Error(`Unexpected open-ack message type: ${e.type}`)}send(e){if(this.serverClosed!=null)throw new Ud;if(this.sendClosed)throw new Wd;this.ws.send(this.codec.encode({type:`data`,payload:e}))}async receive(){if(this.serverClosed!=null)throw this.serverClosed;let e=await this.receiveMsg();if(e.type===`close`)throw e.error==null||(this.serverClosed=sc.decode(e.error),this.serverClosed==null)?Error(`Message error must be defined`):this.serverClosed;return this.resSchema.parse(e.payload)}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;let e={type:`close`};try{this.ws.send(this.codec.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,t)=>this.receiveCallbacksQueue.push({resolve:e,reject:t}))}addMessage(e){let t=this.receiveCallbacksQueue.shift();t==null?this.receiveDataQueue.push(e):t.resolve(e)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(e){this.addMessage(this.codec.decode(e.data,$d))}onClose(e){this.addMessage({type:`close`,error:{type:e.code===nf?Ud.TYPE:Wd.TYPE,data:``}})}},tf=`freighterctx`,nf=1e3,rf=class e extends Kd{baseUrl;encoder;secure;static MESSAGE_TYPE=`arraybuffer`;constructor(e,t,n=!1){super(),this.secure=n,this.baseUrl=e.replace({protocol:n?`wss`:`ws`}),this.encoder=t}withCodec(t){let n=new e(this.baseUrl,t,this.secure);return n.use(...this.middleware),n}async stream(t,n,r){let i;return await this.executeMiddleware({target:t,protocol:`websocket`,params:{},role:`client`},async a=>{let o=new WebSocket(this.buildURL(t,a)),s={...a,params:{}};return o.binaryType=e.MESSAGE_TYPE,i=await this.wrapSocket(o,n,r),s}),i}buildURL(e,t){let n=Bd({[qd]:this.encoder.contentType,...t.params},tf);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise((r,i)=>{e.onopen=()=>{let a=new ef(e,this.encoder,t,n);a.receiveOpenAck().then(()=>r(a)).catch(e=>i(e))},e.onerror=e=>{i(Error(e.message))}})}},af=class extends je.createTyped(`sy`){},I=class extends af.sub(`validation`){},of=class e extends I.sub(`path`){path;error;static encodedSchema=l.z.object({path:l.z.string().array(),error:je.payloadZ});constructor(e,t){let n=_.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,je.decode(n.error))}},sf=class extends af.sub(`auth`){},cf=class extends sf.sub(`invalid_token`){},lf=class extends sf.sub(`expired_token`){};sf.sub(`access_denied`);var uf=class extends af.sub(`unexpected`){constructor(e){super(`
|
|
26
|
+
`).map(e=>e.trim());if(n.length===0)return t==null?{}:t.parse({});let i=n.split(`,`).map(e=>e.trim()),a={};return i.forEach(e=>{a[e]=[]}),r.forEach(e=>{let t=e.split(`,`).map(e=>e.trim());i.forEach((e,n)=>{let r=this.parseValue(t[n]);r!=null&&a[e].push(r)})}),t==null?a:t.parse(a)}parseValue(e){if(e==null||e.length===0)return null;let t=Number(e);return isNaN(t)?e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e:t}},Il=class{contentType=`text/plain`;encode(e){if(typeof e!=`string`)throw Error(`TextCodec.encode payload must be a string`);return new TextEncoder().encode(e)}decode(e,t){let n=new TextDecoder().decode(e);return t==null?n:t.parse(n)}},Ll=new Pl;new Fl,new Il;var Rl=365,zl=30,Bl=l.z.union([l.z.tuple([l.z.int()]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12)]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12),l.z.int().min(1).max(31)])]),Vl=(e,t)=>{let n=new j(t);if(![M.DAY,M.HOUR,M.MINUTE,M.SECOND,M.MILLISECOND,M.MICROSECOND,M.NANOSECOND].some(e=>e.equals(n)))throw Error(`Invalid argument for remainder. Must be an even TimeSpan or Timestamp`);let r=e.valueOf()%n.valueOf();return e instanceof j?new j(r):new M(r)},j=class e extends jc{hash(){return this.value.toString()}constructor(t,n=`UTC`){if(t==null)super(e.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*e.MILLISECOND.valueOf());else if(typeof t==`string`)super(e.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(e.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n===`local`&&(r=e.utcOffset.valueOf()),typeof t==`number`&&(isFinite(t)?t=t===sl?al:Math.trunc(t):(isNaN(t)&&(t=0),t=t===1/0?e.MAX:e.MIN)),Ac(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){let i=new Date(t,n-1,r,0,0,0,0);return new e(BigInt(i.getTime())*e.MILLISECOND.valueOf()).truncate(e.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n=`UTC`){let[r,i,a]=t.split(`:`),o=`00`,s=`00`;a!=null&&([o,s]=a.split(`.`));let c=e.hours(parseInt(r??`00`,10)).add(e.minutes(parseInt(i??`00`,10))).add(e.seconds(parseInt(o??`00`,10))).add(e.milliseconds(parseInt(s??`00`,10)));return n===`local`&&(c=c.add(e.utcOffset)),c.valueOf()}static parseDateTimeString(t,n=`UTC`){if(!t.includes(`/`)&&!t.includes(`-`))return e.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let r=t,i=0;if(t.includes(`.`)){let e=t.split(`.`);r=e[0];let n=e[1]||`0`;i=parseInt(n.padEnd(3,`0`).slice(0,3),10)}let a=n===`local`?new Date(r.replace(`T`,` `)):new Date(`${r}Z`);return BigInt(a.getTime())*e.MILLISECOND.valueOf()+BigInt(i)*e.MILLISECOND.valueOf()}let r=new Date(t);return t.includes(`:`)||r.setUTCHours(0,0,0,0),new e(BigInt(r.getTime())*e.MILLISECOND.valueOf(),n).valueOf()}toISOString(t=`UTC`){if(t===`UTC`)return this.date().toISOString();let n=this.date(),r=new M(BigInt(n.getTimezoneOffset())*e.MINUTE.valueOf());return this.sub(r).date().toISOString()}timeString(e=!1,t=`UTC`){let n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){let e=this.date();return`${e.toLocaleString(`default`,{month:`short`})} ${e.toLocaleString(`default`,{day:`numeric`})}`}static get utcOffset(){return new M(BigInt(new Date().getTimezoneOffset())*e.MINUTE.valueOf())}static since(t){return new e().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new e(t).valueOf()}span(e){return this.range(e).span}range(e){return new Ul(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new e(t).valueOf()}afterEq(t){return this.valueOf()>=new e(t).valueOf()}before(t){return this.valueOf()<new e(t).valueOf()}beforeEq(t){return this.valueOf()<=new e(t).valueOf()}add(t){return new e(ul(this.valueOf(),new M(t).valueOf()))}sub(t){return new e(ll(this.valueOf(),new M(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(M.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(M.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(M.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(M.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){let n=this.date();return n.setUTCFullYear(t),new e(n)}setLocalYear(t){let n=this.date();return n.setFullYear(t),new e(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){let n=this.date();return n.setUTCMonth(t),new e(n)}setLocalMonth(t){let n=this.date();return n.setMonth(t),new e(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){let n=this.date();return n.setUTCDate(t),new e(n)}setLocalDay(t){let n=this.date();return n.setDate(t),new e(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){let n=this.date();return n.setHours(t),new e(n)}setHour(t){let n=this.date();return n.setUTCHours(t),new e(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){let n=this.date();return n.setUTCMinutes(t),new e(n)}setLocalMinute(t){let n=this.date();return n.setMinutes(t),new e(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){let n=this.date();return n.setUTCSeconds(t),new e(n)}setLocalSecond(t){let n=this.date();return n.setSeconds(t),new e(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){let n=this.date();return n.setUTCMilliseconds(t),new e(n)}setLocalMillisecond(t){let n=this.date();return n.setMilliseconds(t),new e(n)}toString(e=`ISO`,t=`UTC`){switch(e){case`ISODate`:return this.toISOString(t).slice(0,10);case`time`:return this.timeString(!1,t);case`preciseTime`:return this.timeString(!0,t);case`date`:return this.dateString();case`preciseDate`:return`${this.dateString()} ${this.timeString(!0,t)}`;case`dateTime`:return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}remainder(e){return Vl(this,e)}get isToday(){return this.truncate(M.DAY).equals(e.now().truncate(M.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(M.days(30))?`date`:e.greaterThanOrEqual(M.DAY)?`dateTime`:e.greaterThanOrEqual(M.HOUR)?`time`:`preciseTime`}static now(){return new e(new Date)}static max(...t){let n=e.MIN;for(let r of t){let t=new e(r);t.after(n)&&(n=t)}return n}static min(...t){let n=e.MAX;for(let r of t){let t=new e(r);t.before(n)&&(n=t)}return n}static nanoseconds(t,n=`UTC`){return new e(t,n)}static NANOSECOND=e.nanoseconds(1);static microseconds(t,n=`UTC`){return e.nanoseconds(t*1e3,n)}static MICROSECOND=e.microseconds(1);static milliseconds(t,n=`UTC`){return e.microseconds(t*1e3,n)}static MILLISECOND=e.milliseconds(1);static seconds(t,n=`UTC`){return e.milliseconds(t*1e3,n)}static SECOND=e.seconds(1);static minutes(t,n=`UTC`){return e.seconds(t*60,n)}static MINUTE=e.minutes(1);static hours(t,n=`UTC`){return e.minutes(t*60,n)}static HOUR=e.hours(1);static days(t,n=`UTC`){return e.hours(t*24,n)}static DAY=e.days(1);static MAX=new e(al);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.instanceof(e),l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.date().transform(t=>new e(t)),l.z.custom(e=>e instanceof M).transform(t=>new e(t)),Bl.transform(t=>new e(t))]);static sort(e,t){return Number(e.valueOf()-t.valueOf())}},M=class e extends jc{constructor(e){typeof e==`number`&&(e=Math.trunc(e.valueOf())),Ac(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(t){return t instanceof e?t:t instanceof Hl?t.period:t instanceof j?new e(t):(Ac(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.seconds(t):new e(t))}static fromMilliseconds(t){return t instanceof e?t:t instanceof Hl?t.period:t instanceof j?new e(t):(Ac(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.milliseconds(t):new e(t))}valueOf(){return this.value}hash(){return this.value.toString()}lessThan(t){return this.valueOf()<new e(t).valueOf()}greaterThan(t){return this.valueOf()>new e(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new e(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new e(t).valueOf()}remainder(e){return Vl(this,e)}truncate(t){return new e(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t=`full`){if(t===`semantic`)return this.toSemanticString();let n=this.truncate(e.DAY),r=this.truncate(e.HOUR),i=this.truncate(e.MINUTE),a=this.truncate(e.SECOND),o=this.truncate(e.MILLISECOND),s=this.truncate(e.MICROSECOND),c=this.truncate(e.NANOSECOND),l=n,u=r.sub(n),d=i.sub(r),f=a.sub(i),p=o.sub(a),m=s.sub(o),h=c.sub(s),g=``;return l.isZero||(g+=`${l.days}d `),u.isZero||(g+=`${u.hours}h `),d.isZero||(g+=`${d.minutes}m `),f.isZero||(g+=`${f.seconds}s `),p.isZero||(g+=`${p.milliseconds}ms `),m.isZero||(g+=`${m.microseconds}µs `),h.isZero||(g+=`${h.nanoseconds}ns`),g.trim()}toSemanticString(){let t=new e(this.valueOf()<0n?-this.valueOf():this.valueOf()),n=this.valueOf()<0n;if(t.valueOf()===0n)return`0s`;if(t.lessThan(e.SECOND))return`< 1s`;let r=t.days,i=t.hours,a=t.minutes,o=t.seconds,s=Math.floor(r/Rl),c=Math.floor(r/zl),l=Math.floor(r/7),u=Math.floor(r),d=Math.floor(i),f=Math.floor(a),p=Math.floor(o),m=n?`-`:``;if(s>=1){let e=`${s}y`;if(s<2){let t=Math.floor(r%Rl/zl);t>0&&(e+=` ${t}mo`)}return m+e}if(l>=1&&r<zl&&r%7==0){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(c>=1){let e=`${c}mo`;if(c<3){let t=Math.floor(r%zl);t>0&&(e+=` ${t}d`)}return m+e}if(l>=1){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(u>=1){let e=`${u}d`,t=Math.floor(i-u*24);return u<2&&t>0&&(e+=` ${t}h`),m+e}if(d>=1){let e=`${d}h`;if(d<3){let t=Math.floor(a-d*60);t>0&&(e+=` ${t}m`)}return m+e}if(f>=1){let e=`${f}m`;if(f<5){let t=Math.floor(o-f*60);t>0&&(e+=` ${t}s`)}return m+e}return`${m}${p}s`}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(e.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(e.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(e.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(e.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new e(t).valueOf()}add(t){return new e(this.valueOf()+new e(t).valueOf())}sub(t){return new e(this.valueOf()-new e(t).valueOf())}abs(){let t=this.valueOf();return new e(t<0n?-t:t)}static nanoseconds(t=1){return new e(t)}static NANOSECOND=e.nanoseconds(1);static microseconds(t=1){return e.nanoseconds(fl(t,1e3))}static MICROSECOND=e.microseconds(1);static milliseconds(t=1){return e.microseconds(fl(t,1e3))}static MILLISECOND=e.milliseconds(1);static seconds(t=1){return e.milliseconds(fl(t,1e3))}static SECOND=e.seconds(1);static minutes(t=1){return e.seconds(fl(t,60))}static MINUTE=e.minutes(1);static hours(t){return e.minutes(fl(t,60))}static HOUR=e.hours(1);static days(t){return e.hours(fl(t,24))}static DAY=e.days(1);static MAX=new e(al);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.instanceof(e),l.z.instanceof(j).transform(t=>new e(t)),l.z.custom(e=>e instanceof Hl).transform(t=>new e(t))])},Hl=class e extends jc{constructor(e){Ac(e)&&(e=e.value),super(e.valueOf())}hash(){return this.value.toString()}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new e(t).valueOf()}get period(){return M.seconds(1/this.valueOf())}sampleCount(e){return new M(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new N(t).valueOf()}span(e){return M.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/new N(t).valueOf())}add(t){return new e(ul(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(ll(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}static hz(t){return new e(t)}static khz(t){return e.hz(t*1e3)}static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},N=class e extends jc{constructor(e){Ac(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Wl(e*this.valueOf())}add(t){return new e(ul(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(ll(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}static UNKNOWN=new e(0);static BIT128=new e(16);static BIT64=new e(8);static BIT32=new e(4);static BIT16=new e(2);static BIT8=new e(1);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},Ul=class e{hash(){return`${this.start.hash()}-${this.end.hash()}`}start;end;constructor(e,t){typeof e==`object`&&`start`in e?(this.start=new j(e.start),this.end=new j(e.end)):(this.start=new j(e),this.end=new j(t))}get span(){return new M(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new e(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=M.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString(`preciseDate`)} - ${this.span.toString()}`}overlapsWith(e,t=M.ZERO){e=e.makeValid();let n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;let r=j.max(n.start,e.start),i=j.min(n.end,e.end);return i.before(r)?!1:new M(i.sub(r)).greaterThanOrEqual(t)}contains(t){return t instanceof e?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){let n=new e(this.start,this.end);return t.start.after(this.start)&&(n.start=t.start),t.start.after(this.end)&&(n.end=t.start),t.end.before(this.end)&&(n.end=t.end),t.end.before(this.start)&&(n.start=t.end),n}static max(...t){return new e(j.min(...t.map(e=>e.start)),j.max(...t.map(e=>e.end)))}static MAX=new e(j.MIN,j.MAX);static ZERO=new e(j.ZERO,j.ZERO);static z=l.z.union([l.z.object({start:j.z,end:j.z}).transform(t=>new e(t.start,t.end)),l.z.instanceof(e)]);static boundedZ=e.z.refine(({isValid:e})=>e,{message:`Time range start time must be before or equal to time range end time`}).refine(({end:e})=>e.valueOf()<=al,{message:`Time range end time must be less than or equal to the maximum value of an int64`}).refine(({start:e})=>e.valueOf()>=il,{message:`Time range start time must be greater than or equal to the minimum value of an int64`});static sort(e,t){return j.sort(e.start,t.start)||j.sort(e.end,t.end)}static merge(...t){return e.max(...t.map(t=>new e(t).makeValid()))}},P=class e extends jc{hash(){return this.value}constructor(t){if(Ac(t)&&(t=t.value),t instanceof e||typeof t==`string`||typeof t.valueOf()==`string`)super(t.valueOf());else{let n=e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){let t=e.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(e=>this.equals(e))}toString(t=!1){return t?e.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(e.JSON)||this.equals(e.STRING)||this.equals(e.BYTES)}get isNumeric(){return!this.isVariable&&!this.equals(e.UUID)}get isInteger(){let e=this.toString();return e.startsWith(`int`)||e.startsWith(`uint`)}get isFloat(){return this.toString().startsWith(`float`)}get density(){let t=e.DENSITIES.get(this.toString());if(t==null)throw Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(e.UINT8)||this.equals(e.UINT16)||this.equals(e.UINT32)||this.equals(e.UINT64)}get isSignedInteger(){return this.equals(e.INT8)||this.equals(e.INT16)||this.equals(e.INT32)||this.equals(e.INT64)}canSafelyCastTo(t){return this.equals(t)?!0:!this.isNumeric||!t.isNumeric||this.isVariable||t.isVariable||this.isUnsignedInteger&&t.isSignedInteger?!1:this.isFloat?t.isFloat&&this.density.valueOf()<=t.density.valueOf():this.equals(e.INT32)&&t.equals(e.FLOAT64)||this.equals(e.INT8)&&t.equals(e.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return e.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new e(`unknown`);static FLOAT64=new e(`float64`);static FLOAT32=new e(`float32`);static INT64=new e(`int64`);static INT32=new e(`int32`);static INT16=new e(`int16`);static INT8=new e(`int8`);static UINT64=new e(`uint64`);static UINT32=new e(`uint32`);static UINT16=new e(`uint16`);static UINT8=new e(`uint8`);static TIMESTAMP=new e(`timestamp`);static UUID=new e(`uuid`);static STRING=new e(`string`);static JSON=new e(`json`);static BYTES=new e(`bytes`);static ARRAY_CONSTRUCTORS=new Map([[e.UINT8.toString(),Uint8Array],[e.UINT16.toString(),Uint16Array],[e.UINT32.toString(),Uint32Array],[e.UINT64.toString(),BigUint64Array],[e.FLOAT32.toString(),Float32Array],[e.FLOAT64.toString(),Float64Array],[e.INT8.toString(),Int8Array],[e.INT16.toString(),Int16Array],[e.INT32.toString(),Int32Array],[e.INT64.toString(),BigInt64Array],[e.TIMESTAMP.toString(),BigInt64Array],[e.STRING.toString(),Uint8Array],[e.JSON.toString(),Uint8Array],[e.UUID.toString(),Uint8Array],[e.BYTES.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,e.UINT8],[Uint16Array.name,e.UINT16],[Uint32Array.name,e.UINT32],[BigUint64Array.name,e.UINT64],[Float32Array.name,e.FLOAT32],[Float64Array.name,e.FLOAT64],[Int8Array.name,e.INT8],[Int16Array.name,e.INT16],[Int32Array.name,e.INT32],[BigInt64Array.name,e.INT64]]);static DENSITIES=new Map([[e.UINT8.toString(),N.BIT8],[e.UINT16.toString(),N.BIT16],[e.UINT32.toString(),N.BIT32],[e.UINT64.toString(),N.BIT64],[e.FLOAT32.toString(),N.BIT32],[e.FLOAT64.toString(),N.BIT64],[e.INT8.toString(),N.BIT8],[e.INT16.toString(),N.BIT16],[e.INT32.toString(),N.BIT32],[e.INT64.toString(),N.BIT64],[e.TIMESTAMP.toString(),N.BIT64],[e.STRING.toString(),N.UNKNOWN],[e.JSON.toString(),N.UNKNOWN],[e.UUID.toString(),N.BIT128],[e.BYTES.toString(),N.UNKNOWN]]);static ALL=[e.UNKNOWN,e.UINT8,e.UINT16,e.UINT32,e.UINT64,e.INT8,e.INT16,e.INT32,e.INT64,e.FLOAT32,e.FLOAT64,e.TIMESTAMP,e.UUID,e.STRING,e.JSON,e.BYTES];static SHORT_STRINGS=new Map([[e.UINT8.toString(),`u8`],[e.UINT16.toString(),`u16`],[e.UINT32.toString(),`u32`],[e.UINT64.toString(),`u64`],[e.INT8.toString(),`i8`],[e.INT16.toString(),`i16`],[e.INT32.toString(),`i32`],[e.INT64.toString(),`i64`],[e.FLOAT32.toString(),`f32`],[e.FLOAT64.toString(),`f64`],[e.TIMESTAMP.toString(),`ts`],[e.UUID.toString(),`uuid`],[e.STRING.toString(),`str`],[e.JSON.toString(),`json`],[e.BYTES.toString(),`bytes`]]);static BIG_INT_TYPES=[e.INT64,e.UINT64,e.TIMESTAMP];static z=l.z.union([l.z.string().transform(t=>new e(t)),l.z.instanceof(e)])},Wl=class e extends jc{constructor(e){Ac(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return Ac(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return Ac(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(t){return Ac(t)&&(t=t.value),new e(ul(this.valueOf(),t.valueOf()))}sub(t){return Ac(t)&&(t=t.value),new e(ll(this.valueOf(),t.valueOf()))}mult(t){return new e(fl(this.valueOf(),t))}div(t){return new e(pl(this.valueOf(),t))}truncate(t){return new e(Math.trunc(this.valueOf()/new e(t).valueOf())*new e(t).valueOf())}remainder(t){return e.bytes(this.valueOf()%new e(t).valueOf())}get gigabytes(){return this.valueOf()/e.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/e.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/e.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/e.TERABYTE.valueOf()}toString(){let t=this.truncate(e.TERABYTE),n=this.truncate(e.GIGABYTE),r=this.truncate(e.MEGABYTE),i=this.truncate(e.KILOBYTE),a=this.truncate(e.BYTE),o=t,s=n.sub(t),c=r.sub(n),l=i.sub(r),u=a.sub(i),d=``;return o.isZero||(d+=`${o.terabytes}TB `),s.isZero||(d+=`${s.gigabytes}GB `),c.isZero||(d+=`${c.megabytes}MB `),l.isZero||(d+=`${l.kilobytes}KB `),(!u.isZero||d===``)&&(d+=`${u.valueOf()}B`),d.trim()}static bytes(t=1){return new e(t)}static BYTE=new e(1);static kilobytes(t=1){return e.bytes(new e(t).valueOf()*1e3)}static KILOBYTE=e.kilobytes(1);static megabytes(t=1){return e.kilobytes(new e(t).valueOf()*1e3)}static MEGABYTE=e.megabytes(1);static gigabytes(t=1){return e.megabytes(new e(t).valueOf()*1e3)}static GIGABYTE=e.gigabytes(1);static terabytes(t){return e.gigabytes(new e(t).valueOf()*1e3)}static TERABYTE=e.terabytes(1);static ZERO=new e(0);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)]);get isZero(){return this.valueOf()===0}};l.z.object({start:l.z.number(),end:l.z.number()}),l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]);var Gl=e=>{let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===`bigint`||e instanceof j||e instanceof M||e instanceof Date},Kl=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(BigInt(n.valueOf())-BigInt(r.valueOf())):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):ll(n,r);Ul.z,j.z,M.z,Hl.z,Wl.z,P.z,Ul.boundedZ;var ql=(e,t=!1)=>{let n=Mc(e)?`stringer`:typeof e,r;switch(n){case`string`:r=(e,t)=>e.localeCompare(t);break;case`stringer`:r=(e,t)=>e.toString().localeCompare(t.toString());break;case`number`:r=(e,t)=>Number(e)-Number(t);break;case`bigint`:r=(e,t)=>BigInt(e)-BigInt(t)>0n?1:-1;break;case`boolean`:r=(e,t)=>Number(e)-Number(t);break;case`undefined`:r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?Jl(r):r},Jl=e=>(t,n)=>e(n,t),Yl=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Xl=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Zl=`0123456789${Xl}`,Ql=Yl(Xl,1),$l=Yl(Zl,10),eu=()=>`${Ql()}${$l()}`,tu=(e,t)=>n=>n instanceof t||typeof n==`object`&&!!n&&`discriminator`in n&&n.discriminator===e;l.default.enum([`x`,`y`,...vl,...bl]);var nu=Cl;l.z.union([yl,l.z.enum([...vl,...bl]),l.z.instanceof(String)]),l.z.object({x:hl.or(xl),y:gl.or(xl)});var ru=Object.freeze({x:`left`,y:`top`}),iu=Object.freeze({x:`right`,y:`top`}),au=Object.freeze({x:`left`,y:`bottom`}),ou=Object.freeze({x:`right`,y:`bottom`}),su=Object.freeze({x:`center`,y:`center`}),cu=Object.freeze({x:`center`,y:`top`}),lu=Object.freeze({x:`center`,y:`bottom`}),uu=Object.freeze({x:`right`,y:`center`}),du=Object.freeze({x:`left`,y:`center`});Object.freeze([du,uu,cu,lu,ru,iu,au,ou,su]);var fu=(e,t)=>e.x===t.x&&e.y===t.y,pu=e=>[e.x,e.y],mu=l.z.union([l.z.number(),Sl,kl,Tl,El,Dl]),hu=(e,t)=>{if(typeof e==`string`){if(t===void 0)throw Error(`The y coordinate must be given.`);return e===`x`?{x:t,y:0}:{x:0,y:t}}return typeof e==`number`?{x:e,y:t??e}:Array.isArray(e)?{x:e[0],y:e[1]}:`signedWidth`in e?{x:e.signedWidth,y:e.signedHeight}:`clientX`in e?{x:e.clientX,y:e.clientY}:`width`in e?{x:e.width,y:e.height}:{x:e.x,y:e.y}},gu=Object.freeze({x:0,y:0});Object.freeze({x:1,y:1}),Object.freeze({x:1/0,y:1/0}),Object.freeze({x:NaN,y:NaN});var _u=(e,t)=>{let n=hu(e);return{x:n.x+t,y:n.y}},vu=(e,t)=>{let n=hu(e);return{x:n.x,y:n.y+t}},yu=(e,t,n,...r)=>{if(typeof t==`string`){if(typeof n!=`number`)throw Error(`The value must be a number.`);return t===`x`?_u(e,n):vu(e,n)}if(typeof t==`object`&&`x`in t&&typeof t.x==`string`){let r=hu(n),i=hu(e);return t.x===`left`?r.x=-r.x:t.x===`center`&&(r.x=0),t.y===`top`?r.y=-r.y:t.y===`center`&&(r.y=0),{x:i.x+r.x,y:i.y+r.y}}return[e,t,n??gu,...r].reduce((e,t)=>{let n=hu(t);return{x:e.x+n.x,y:e.y+n.y}},gu)},bu=l.z.union([l.z.number(),l.z.string()]);l.z.object({top:bu,left:bu,width:bu,height:bu}),l.z.object({left:l.z.number(),top:l.z.number(),right:l.z.number(),bottom:l.z.number()}),l.z.object({one:Sl,two:Sl,root:nu});var xu=(e,t,n=0,r=0,i)=>{let a={one:{...gu},two:{...gu},root:i??ru};if(typeof e==`number`){if(typeof t!=`number`)throw Error(`Box constructor called with invalid arguments`);return a.one={x:e,y:t},a.two={x:a.one.x+n,y:a.one.y+r},a}return`one`in e&&`two`in e&&`root`in e?{...e,root:i??e.root}:(`getBoundingClientRect`in e&&(e=e.getBoundingClientRect()),`left`in e?(a.one={x:e.left,y:e.top},a.two={x:e.right,y:e.bottom},a):(a.one=e,t==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof t==`number`?a.two={x:a.one.x+t,y:a.one.y+n}:`width`in t?a.two={x:a.one.x+t.width,y:a.one.y+t.height}:`signedWidth`in t?a.two={x:a.one.x+t.signedWidth,y:a.one.y+t.signedHeight}:a.two=t,a))},Su=(e,t)=>{let n=xu(e);return{x:t.x===`center`?Du(n).x:Cu(n,t.x),y:t.y===`center`?Du(n).y:Cu(n,t.y)}},Cu=(e,t)=>{let n=xu(e),r=pu(n.root).includes(t)?Math.min:Math.max;return ml.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},wu=e=>{let t=xu(e);return t.two.x-t.one.x},Tu=e=>{let t=xu(e);return t.two.y-t.one.y},Eu=e=>Su(e,ru),Du=e=>yu(Eu(e),{x:wu(e)/2,y:Tu(e)/2}),Ou=e=>{let t=xu(e);return{lower:t.one.x,upper:t.two.x}},ku=e=>{let t=xu(e);return{lower:t.one.y,upper:t.two.y}},Au=e=>typeof e!=`object`||!e?!1:`one`in e&&`two`in e&&`root`in e;l.z.union([Tl,El,Sl,kl]);var ju=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e;l.z.object({offset:mu,scale:mu}),l.z.object({offset:l.z.number(),scale:l.z.number()});var Mu=e=>(t,n,r,i)=>n===`dimension`?[t,r]:[t,i?r-e:r+e],Nu=e=>(t,n,r,i)=>[t,i?r/e:r*e],Pu=e=>(t,n,r)=>{if(t===null)return[e,r];let{lower:i,upper:a}=t,{lower:o,upper:s}=e,c=a-i,l=s-o;return n===`dimension`?[e,l/c*r]:[e,(r-i)*(l/c)+o]},Fu=e=>(t,n,r)=>[e,r],Iu=()=>(e,t,n)=>{if(e===null)throw Error(`cannot invert without bounds`);if(t===`dimension`)return[e,n];let{lower:r,upper:i}=e;return[e,i-(n-r)]},Lu=e=>(t,n,r)=>{let{lower:i,upper:a}=e;return r=ju(r,i,a),[t,r]},Ru=class e{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new e().translate(t)}static magnify(t){return new e().magnify(t)}static scale(t,n){return new e().scale(t,n)}translate(e){let t=this.new(),n=Mu(e);return n.type=`translate`,t.ops.push(n),t}magnify(e){let t=this.new(),n=Nu(e);return n.type=`magnify`,t.ops.push(n),t}scale(e,t){let n=Al(e,t),r=this.new(),i=Pu(n);return i.type=`scale`,r.ops.push(i),r}clamp(e,t){let n=Al(e,t),r=this.new(),i=Lu(n);return i.type=`clamp`,r.ops.push(i),r}reBound(e,t){let n=Al(e,t),r=this.new(),i=Fu(n);return i.type=`re-bound`,r.ops.push(i),r}invert(){let e=Iu();e.type=`invert`;let t=this.new();return t.ops.push(e),t}pos(e){return this.exec(`position`,e)}dim(e){return this.exec(`dimension`,e)}new(){let t=new e;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(e,t){return this.currBounds=null,this.ops.reduce(([t,n],r)=>r(t,e,n,this.reversed),[null,t])[1]}reverse(){let e=this.new();e.ops.reverse();let t=[];return e.ops.forEach((n,r)=>{if(n.type===`scale`||t.some(([e,t])=>r>=e&&r<=t))return;let i=e.ops.findIndex((e,t)=>e.type===`scale`&&t>r);i!==-1&&t.push([r,i])}),t.forEach(([t,n])=>{let r=e.ops.slice(t,n);r.unshift(e.ops[n]),e.ops.splice(t,n-t+1,...r)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new e};(class e{x;y;currRoot;constructor(e=new Ru,t=new Ru,n=null){this.x=e,this.y=t,this.currRoot=n}static translate(t,n){return new e().translate(t,n)}static translateX(t){return new e().translateX(t)}static translateY(t){return new e().translateY(t)}static clamp(t){return new e().clamp(t)}static magnify(t){return new e().magnify(t)}static scale(t){return new e().scale(t)}static reBound(t){return new e().reBound(t)}translate(e,t){let n=hu(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){let t=this.copy();return t.x=this.x.translate(e),t}translateY(e){let t=this.copy();return t.y=this.y.translate(e),t}magnify(e){let t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){let t=this.copy();if(Au(e)){let n=this.currRoot;return t.currRoot=e.root,n!=null&&!fu(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Ou(e)),t.y=t.y.scale(ku(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){let t=this.copy();return t.x=this.x.reBound(Ou(e)),t.y=this.y.reBound(ku(e)),t}clamp(e){let t=this.copy();return t.x=this.x.clamp(Ou(e)),t.y=this.y.clamp(ku(e)),t}copy(){let t=new e;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){let e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return xu(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new e}),Ol.required({root:!0,units:!0});var zu=l.z.enum([`static`,`dynamic`]),Bu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Vu(e){return typeof e==`string`&&Bu.test(e)}var F=[];for(let e=0;e<256;++e)F.push((e+256).toString(16).slice(1));function Hu(e,t=0){return(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+`-`+F[e[t+4]]+F[e[t+5]]+`-`+F[e[t+6]]+F[e[t+7]]+`-`+F[e[t+8]]+F[e[t+9]]+`-`+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase()}function Uu(e,t=0){let n=Hu(e,t);if(!Vu(n))throw TypeError(`Stringified UUID is invalid`);return n}var Wu=(e,t)=>Uu(e,t),Gu=e=>{let t=Math.fround(e);if(!Number.isFinite(t))return t.toString();for(let e=1;e<=9;e++){let n=parseFloat(t.toPrecision(e));if(Math.fround(n)===t)return n.toString()}return t.toString()},Ku=-1,qu={[Symbol.iterator]:()=>qu,next:()=>({done:!0,value:void 0})},Ju=l.z.string().transform(e=>new Uint8Array(atob(e).split(``).map(e=>e.charCodeAt(0))).buffer),Yu=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),I=4,Xu=(e,t)=>{if(e===`number`&&!t.isNumeric)throw Error(`cannot convert series of type ${t.toString()} to number`);if(e===`bigint`&&!t.usesBigInt)throw Error(`cannot convert series of type ${t.toString()} to bigint`)},Zu=`sy_x_telem_series`,Qu=class e{key;discriminator=Zu;dataType;sampleOffset;gl;_data;timeRange=Ul.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ku;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=l.z.object({timeRange:Ul.z.optional(),dataType:P.z,alignment:l.z.coerce.bigint().optional(),data:l.z.union([Ju,Yu,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]).default(()=>new Uint8Array().buffer),glBufferUsage:zu.default(`static`).optional()});static z=e.crudeZ.transform(t=>new e(t));constructor(e){$u(e)&&(e={data:e}),e.data??=[];let{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:i=`static`,alignment:a=0n,alignmentMultiple:o=1n,key:s=eu(),data:c}=e;if(ed(c)){let e=c;this.key=e.key,this.dataType=e.dataType,this.sampleOffset=e.sampleOffset,this.gl=e.gl,this._data=e._data,this.timeRange=e.timeRange,this.alignment=e.alignment,this.alignmentMultiple=e.alignmentMultiple,this.cachedMin=e.cachedMin,this.cachedMax=e.cachedMax,this.writePos=e.writePos,this._refCount=e._refCount,this.cachedLength=e.cachedLength;return}let l=Gl(c),u=Array.isArray(c);if(t!=null)this.dataType=new P(t);else if(c instanceof ArrayBuffer)throw Error(`cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.`);else if(u||l){let e=c;if(!l){if(c.length===0)throw Error(`cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.`);e=c[0]}if(typeof e==`string`)this.dataType=P.STRING;else if(typeof e==`number`)this.dataType=P.FLOAT64;else if(typeof e==`bigint`)this.dataType=P.INT64;else if(typeof e==`boolean`)this.dataType=P.UINT8;else if(e instanceof j||e instanceof Date||e instanceof j)this.dataType=P.TIMESTAMP;else if(typeof e==`object`)this.dataType=P.JSON;else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`)}else this.dataType=new P(c);if(!u&&!l)this._data=c;else if(u&&c.length===0)this._data=new this.dataType.Array([]).buffer;else{let e=l?[c]:c,t=e[0];if((t instanceof j||t instanceof Date||t instanceof M)&&(e=e.map(e=>new j(e).valueOf())),this.dataType.equals(P.STRING)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(e)),n=t.reduce((e,t)=>e+I+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=I,a.set(e,o),o+=e.byteLength;this._data=r}else if(this.dataType.equals(P.JSON)){this.cachedLength=e.length;let t=e.map(e=>new TextEncoder().encode(Ll.encodeString(e))),n=t.reduce((e,t)=>e+I+t.byteLength,0),r=new ArrayBuffer(n),i=new DataView(r),a=new Uint8Array(r),o=0;for(let e of t)i.setUint32(o,e.byteLength,!0),o+=I,a.set(e,o),o+=e.byteLength;this._data=r}else 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??Ul.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 P(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===Ku)return 0;let t=this.byteCapacity.valueOf()-this.writePos,n=e.buffer,r=e.byteLength.valueOf(),i=new DataView(n),a=0,o=0;for(;a+I<=r;){let e=I+i.getUint32(a,!0);if(a+e>t)break;a+=e,o++}if(a===0)return 0;let s=e.subBytes(0,a);return this.writeToUnderlyingData(s),this.writePos+=a,this.cachedLength=(this.cachedLength??0)+o,this._cachedIndexes=void 0,o}writeFixed(e){if(this.writePos===Ku)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===Ku?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(this.dataType.isVariable){let e=[],t=this.buffer,n=this.byteLength.valueOf(),r=new DataView(t),i=new TextDecoder,a=0;for(;a+I<=n;){let n=r.getUint32(a,!0);a+=I,e.push(i.decode(new Uint8Array(t,a,n))),a+=n}return e}return Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(P.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(Ll.decodeString(t)))}get byteCapacity(){return new Wl(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ku?this.byteCapacity:this.dataType.isVariable?new Wl(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ku?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=[],n=this.buffer,r=this.byteLength.valueOf(),i=new DataView(n),a=0;for(;a+I<=r;){let n=i.getUint32(a,!0);a+=I,t.push(a),a+=n,e++}return 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]=Kl(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(){if(this.length===0)return-1/0;if(this.dataType.equals(P.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}else{let e=this.data;this.cachedMax=e.reduce((e,t)=>e>t?e:t)}return 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(),this.applyOffset(this.cachedMax))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(P.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}else{let e=this.data;this.cachedMin=e.reduce((e,t)=>e<t?e:t)}return 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(),this.applyOffset(this.cachedMin))}get bounds(){return Al(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){let n=this.atVariable(e,t);return n==null?void 0:this.dataType.equals(P.STRING)?n:qs(JSON.parse(n))}if(this.dataType.equals(P.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 this.applyOffset(n)}applyOffset(e){return typeof this.sampleOffset==`bigint`&&typeof e==`number`?BigInt(Math.round(e))+this.sampleOffset:ul(e,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=Wu(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}asString(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t);if(this.dataType.equals(P.UUID))return this.atUUID(e,t);let n=this.at(e,t);if(n!=null)return this.dataType.equals(P.FLOAT32)?Gu(n):String(n)}atVariable(e,t){let n=0,r=0,i=this.buffer,a=new DataView(i);if(this._cachedIndexes!=null){if(e<0&&(e=this._cachedIndexes.length+e),e<0||e>=this._cachedIndexes.length){if(t)throw Error(`[series] - no value at index ${e}`);return}n=this._cachedIndexes[e],r=a.getUint32(n-I,!0)}else{e<0&&(e=this.length+e);let i=this.byteLength.valueOf(),o=0,s=!1;for(;o+I<=i;){let t=a.getUint32(o,!0);if(o+=I,e===0){n=o,r=t,s=!0;break}o+=t,e--}if(!s){if(t)throw Error(`[series] - no value at index ${e}`);return}}let o=new Uint8Array(i,n,r);return new TextDecoder().decode(o)}binarySearch(e){let t=0,n=this.length-1,r=ql(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(P.FLOAT32)&&!this.dataType.equals(P.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!==Ku){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=Ku}as(e){return Xu(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:od(this.alignmentBounds.lower),upper:od(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return Al(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 nd(this);return this.dataType.equals(P.JSON)?new rd(e):e}return this.dataType.equals(P.UUID)?new id(this):new ad(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new td(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 td(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:Ul.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}},$u=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof Qu?!0:Gl(e),ed=tu(Zu,Qu),td=class{series;end;index;constructor(e,t,n){this.series=e;let r=Al(0,e.length+1);this.end=Ml(r,n),this.index=Ml(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},nd=class{series;byteOffset;decoder;view;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.byteOffset=0,this.decoder=new TextDecoder,this.view=new DataView(e.buffer)}next(){let e=this.series.byteLength.valueOf();if(this.byteOffset+I>e)return{done:!0,value:void 0};let t=this.view.getUint32(this.byteOffset,!0);this.byteOffset+=I;let n=this.decoder.decode(new Uint8Array(this.series.buffer,this.byteOffset,t));return this.byteOffset+=t,{done:!1,value:n}}},rd=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:Ll.decodeString(t.value,e.schema)}}},id=class{series;index;data;density;constructor(e){if(!e.dataType.equals(P.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=P.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=Wu(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},ad=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)}}},od=e=>({domain:e>>32n,sample:e&4294967295n});l.z.enum([`ISO`,`ISODate`,`time`,`preciseTime`,`date`,`preciseDate`,`dateTime`]),l.z.enum([`local`,`UTC`]);var sd=async e=>await new Promise(t=>setTimeout(t,M.fromMilliseconds(e).milliseconds)),cd=Rs({Breaker:()=>ld,breakerConfigZ:()=>ud}),ld=class{config;retries;interval;constructor(e){this.config={baseInterval:new M(e?.baseInterval??M.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??sd},this.retries=0,this.interval=new M(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}},ud=l.z.object({baseInterval:M.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),dd=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),fd=Nl,pd=l.z.number().min(0).max(1),md=l.z.tuple([fd,fd,fd,pd]),hd=l.z.tuple([fd,fd,fd]),gd=l.z.object({rgba255:md}),_d=l.z.object({r:fd,g:fd,b:fd,a:pd}),vd=l.z.number().min(0).max(360),yd=l.z.number().min(0).max(100),bd=l.z.number().min(0).max(100),xd=l.z.tuple([vd,yd,bd,pd]),Sd=l.z.union([dd,hd,md,xd,gd,_d]),Cd=Sd.transform(e=>wd(e)),wd=(e,t=1)=>{if(e=Sd.parse(e),typeof e==`string`)return Td(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},Td=(e,t=1)=>(e=dd.parse(e),e=Dd(e),[Ed(e,0),Ed(e,2),Ed(e,4),e.length===8?Ed(e,6)/255:t]),Ed=(e,t)=>parseInt(e.slice(t,t+2),16),Dd=e=>e.startsWith(`#`)?e.slice(1):e;wd(`#000000`),wd(`#ffffff`);var Od=l.z.object({key:l.z.string(),color:Sd,position:l.z.number(),switched:l.z.boolean().optional()});l.z.array(Od);var kd=l.z.object({key:l.z.string(),name:l.z.string(),color:Cd});l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(kd)});var Ad=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({});l.z.enum(Ad),l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),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 jd=l.z.uuid();l.z.object({key:jd,name:l.z.string().min(1),color:Cd}).partial({key:!0}),l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),l.z.enum([`standard`,`scientific`,`engineering`]);var Md=l.z.union([l.z.string(),l.z.number()]),Nd=()=>l.z.record(Md,l.z.unknown());typeof process<`u`&&process.versions!=null&&process.versions.node!=null||typeof window>`u`||window.document;var Pd=[`macOS`,`Windows`,`Linux`],Fd=[`macos`,`windows`,`linux`],Id={macos:`macOS`,windows:`Windows`,linux:`Linux`};l.z.enum(Pd).or(l.z.enum(Fd).transform(e=>Id[e])),l.z.object({message:l.z.string().optional(),description:l.z.string().optional(),details:Nd().optional()}),l.z.object({stack:l.z.string(),error:l.z.instanceof(Error)}).and(Nd()),l.z.enum([`success`,`info`,`warning`,`error`,`loading`,`disabled`]),l.z.literal(`success`),l.z.literal(`info`),l.z.literal(`warning`),l.z.literal(`error`),l.z.literal(`loading`),l.z.literal(`disabled`),l.z.enum([`h1`,`h2`,`h3`,`h4`,`h5`,`p`,`small`]),l.z.union([l.z.number(),l.z.enum([`normal`,`bold`,`bolder`,`lighter`])]),l.z.object({size:l.z.number(),weight:l.z.union([l.z.number(),l.z.string()]),lineHeight:l.z.number(),textTransform:l.z.string().optional()});var Ld=(...e)=>e.map(Rd).join(``),Rd=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),zd=e=>e.endsWith(`/`)?e.slice(0,-1):e,Bd=(e,t=``)=>e===null?``:`?${Object.entries(e).filter(([,e])=>e==null?!1:Array.isArray(e)?e.length>0:!0).map(([e,n])=>`${t}${e}=${n}`).join(`&`)}`,Vd=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=Rd(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:Ld(this.path,t)})}toString(){return zd(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},Hd=class extends ac.createTyped(`freighter`){},Ud=class extends Hd.sub(`eof`){constructor(){super(`EOF`)}},Wd=class extends Hd.sub(`stream_closed`){constructor(){super(`StreamClosed`)}},Gd=class extends Hd.sub(`unreachable`){url;constructor(e={}){let{message:t=`Unreachable`,url:n=Vd.UNKNOWN,cause:r}=e;super(t,r===void 0?void 0:{cause:r}),this.url=n}};ac.register({encode:e=>{if(!e.type.startsWith(Hd.TYPE))return null;if(Ud.matches(e))return{type:Ud.TYPE,data:`EOF`};if(Wd.matches(e))return{type:Wd.TYPE,data:`StreamClosed`};if(Gd.matches(e))return{type:Gd.TYPE,data:`Unreachable`};throw Error(`Unknown error type: ${e.type}: ${e.message}`)},decode:e=>{if(!e.type.startsWith(Hd.TYPE))return null;switch(e.type){case Ud.TYPE:return new Ud;case Wd.TYPE:return new Wd;case Gd.TYPE:return new Gd;default:throw new ac.Unknown(`Unknown error type: ${e.data}`)}}});var Kd=class{middleware=[];use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0,r=async e=>{if(n===this.middleware.length)return await t(e);let i=this.middleware[n];return n++,await i(e,r)};return await r(e)}},qd=`Content-Type`,Jd=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`EPIPE`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_SOCKET`]),Yd=e=>{let t=e?.cause?.code??e?.code??e?.errno;if(typeof t==`string`&&Jd.has(t))return!0;if(e.name===`TypeError`){let t=String(e.message||``).toLowerCase();if(/load failed|failed to fetch|networkerror|network error/.test(t))return typeof navigator<`u`&&navigator.onLine,!0}return e?.name===`AbortError`||e?.code,!1},Xd=400,Zd=class extends Kd{endpoint;encoder;constructor(e,t,n=!1){return super(),this.endpoint=e.replace({protocol:n?`https`:`http`}),this.encoder=t,new Proxy(this,{get:(e,t,n)=>t===`endpoint`?this.endpoint:Reflect.get(e,t,n)})}get headers(){return{[qd]:this.encoder.contentType}}async send(e,t,n,r){let i=null,a=this.endpoint.child(e),o={};if(o.method=`POST`,o.body=this.encoder.encode(t,n),await this.executeMiddleware({target:a.toString(),protocol:this.endpoint.protocol,params:{},role:`client`},async e=>{let t={...e,params:{}};o.headers={...this.headers,...e.params};let n;try{n=await fetch(e.target,o)}catch(e){let t=ac.fromUnknown(e);throw Yd(t)?new Gd({url:a,cause:t}):t}let s=await n.arrayBuffer();if(n?.ok)return r!=null&&(i=this.encoder.decode(s,r)),t;if(n.status!==Xd)throw Error(`[freighter] HTTP ${n.status} from ${e.target}: ${n.statusText}`);let c;try{c=ac.decode(this.encoder.decode(s,ac.payloadZ))}catch(e){let t=ac.fromUnknown(e);throw Error(`[freighter] - failed to decode error: ${n.statusText}: ${t.message}`,{cause:e})}throw c??Error(`[freighter] HTTP ${n.status} from ${e.target}: ${n.statusText}`)}),i==null)throw Error(`Response must be defined`);return i}},Qd=(e,t)=>{class n{wrapped;constructor(e){this.wrapped=e}use(...e){this.wrapped.use(...e)}async send(e,n,r,i){let a=new cd.Breaker(t);do try{return await this.wrapped.send(e,n,r,i)}catch(e){let t=ac.fromUnknown(e);if(!Gd.matches(t)||(console.warn(`[freighter] ${a.retryMessage}`,t),!await a.wait()))throw t}while(!0)}}return new n(e)},$d=l.z.object({type:l.z.enum([`data`,`close`,`open`]),payload:l.z.unknown(),error:l.z.optional(ac.payloadZ)}),ef=class{codec;reqSchema;resSchema;ws;serverClosed;sendClosed;receiveDataQueue=[];receiveCallbacksQueue=[];constructor(e,t,n,r){this.codec=t,this.reqSchema=n,this.resSchema=r,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){let e=await this.receiveMsg();if(e.type!==`open`)throw e.error==null?Error(`Message error must be defined`):ac.decode(e.error)??Error(`Unexpected open-ack message type: ${e.type}`)}send(e){if(this.serverClosed!=null)throw new Ud;if(this.sendClosed)throw new Wd;this.ws.send(this.codec.encode({type:`data`,payload:e}))}async receive(){if(this.serverClosed!=null)throw this.serverClosed;let e=await this.receiveMsg();if(e.type===`close`)throw e.error==null||(this.serverClosed=ac.decode(e.error),this.serverClosed==null)?Error(`Message error must be defined`):this.serverClosed;return this.resSchema.parse(e.payload)}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;let e={type:`close`};try{this.ws.send(this.codec.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,t)=>this.receiveCallbacksQueue.push({resolve:e,reject:t}))}addMessage(e){let t=this.receiveCallbacksQueue.shift();t==null?this.receiveDataQueue.push(e):t.resolve(e)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(e){this.addMessage(this.codec.decode(e.data,$d))}onClose(e){this.addMessage({type:`close`,error:{type:e.code===nf?Ud.TYPE:Wd.TYPE,data:``}})}},tf=`freighterctx`,nf=1e3,rf=class e extends Kd{baseUrl;encoder;secure;static MESSAGE_TYPE=`arraybuffer`;constructor(e,t,n=!1){super(),this.secure=n,this.baseUrl=e.replace({protocol:n?`wss`:`ws`}),this.encoder=t}withCodec(t){let n=new e(this.baseUrl,t,this.secure);return n.use(...this.middleware),n}async stream(t,n,r){let i;return await this.executeMiddleware({target:t,protocol:`websocket`,params:{},role:`client`},async a=>{let o=new WebSocket(this.buildURL(t,a)),s={...a,params:{}};return o.binaryType=e.MESSAGE_TYPE,i=await this.wrapSocket(o,n,r),s}),i}buildURL(e,t){let n=Bd({[qd]:this.encoder.contentType,...t.params},tf);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise((r,i)=>{e.onopen=()=>{let a=new ef(e,this.encoder,t,n);a.receiveOpenAck().then(()=>r(a)).catch(e=>i(ac.fromUnknown(e)))},e.onerror=e=>{let t=e;i(Error(t.message??`websocket error`,{cause:t.error??e}))}})}},af=class extends v.createTyped(`sy`){},L=class extends af.sub(`validation`){},of=class e extends L.sub(`path`){path;error;static encodedSchema=l.z.object({path:l.z.string().array(),error:v.payloadZ});constructor(e,t){let n=_.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,v.decode(n.error))}},sf=class extends af.sub(`auth`){},cf=class extends sf.sub(`invalid_token`){},lf=class extends sf.sub(`expired_token`){};sf.sub(`access_denied`);var uf=class extends af.sub(`unexpected`){constructor(e){super(`
|
|
27
27
|
Unexpected error encountered:
|
|
28
28
|
|
|
29
29
|
${e}
|
|
30
30
|
|
|
31
31
|
Please report this to the Synnax team.
|
|
32
|
-
`)}},df=class extends af.sub(`query`){},ff=class extends df.sub(`not_found`){},pf=class extends df.sub(`multiple_results`){},mf=class extends af.sub(`route`){path;constructor(e,t){super(e),this.path=t}},hf=class extends af.sub(`control`){},gf=class extends hf.sub(`unauthorized`){},_f=class extends af.sub(`disconnected`){constructor(e=`Operation failed because no Core is connected.`){super(e)}},vf=class extends af.sub(`contiguity`){};je.register({encode:()=>{throw new je.NotImplemented},decode:e=>e.type.startsWith(af.TYPE)?e.type.startsWith(I.TYPE)?e.type===of.TYPE?of.decode(e):new I(e.data):e.type.startsWith(sf.TYPE)?e.type.startsWith(cf.TYPE)?new cf(e.data):e.type.startsWith(lf.TYPE)?new lf(e.data):new sf(e.data):e.type.startsWith(uf.TYPE)?new uf(e.data):e.type.startsWith(df.TYPE)?e.type.startsWith(ff.TYPE)?new ff(e.data):e.type.startsWith(pf.TYPE)?new pf(e.data):new df(e.data):e.type.startsWith(hf.TYPE)?e.type.startsWith(gf.TYPE)?new gf(e.data):new hf(e.data):e.type.startsWith(mf.TYPE)?new mf(e.data,e.data):new uf(e.data):null});var yf=async(e,t)=>{try{return await t(e)}catch(e){throw e instanceof Gd?new Gd({message:`Cannot reach Core at ${e.url.host}:${e.url.port}`,url:e.url}):e}},bf=[`arc`,`builtin`,`channel`,`device`,`framer`,`group`,`label`,`lineplot`,`log`,`node`,`policy`,`rack`,`range`,`range-alias`,`role`,`schematic`,`schematic_symbol`,`status`,`table`,`task`,`user`,`view`,`workspace`],xf=l.z.enum(bf),Sf=l.z.string().transform(e=>{let[t,n]=e.split(`:`);return{type:xf.parse(t),key:n??``}}),L=l.z.object({type:xf,key:l.z.string()}).or(Sf),Cf={type:`builtin`,key:`root`},R=e=>{let t=t=>({type:e,key:et.isZero(t)?``:t.toString()});return(e=>Array.isArray(e)?e.map(t):t(e))},wf=(e=>(typeof e==`string`&&(e=Sf.parse(e)),Array.isArray(e)?e.map(e=>wf(e)):`${e.type}:${e.key}`)),Tf=(e,t)=>e.type===t.type&&e.key===t.key,Ef=e=>{let t=_.toArray(e);return t.length===0?[]:typeof t[0]==`object`&&`id`in t[0]?t.map(({id:e})=>e):t.map(e=>L.parse(e))},Df=l.z.object({id:L,name:l.z.string(),data:k.unknownZ().optional().nullable()}).transform(e=>({key:wf(e.id),...e})),Of=e=>e===`to`?`from`:`to`,kf=l.z.object({from:L,type:l.z.string(),to:L}).or(l.z.string().transform(e=>{let[t,n,r]=e.split(`->`);return{from:L.parse(t),type:n,to:L.parse(r)}})),Af=e=>`${wf(e.from)}->${e.type}->${wf(e.to)}`,jf=`parent`,Mf=(e,t)=>!(t.type!=null&&t.type!==e.type||t.from?.type!=null&&t.from.type!==e.from.type||t.to?.type!=null&&t.to.type!==e.to.type||t.from?.key!=null&&t.from.key!==e.from.key||t.to?.key!=null&&t.to.key!==e.to.key),Nf=l.z.object({id:L,children:L.array()}),Pf=l.z.object({from:L,to:L,children:L.array()}),Ff=l.z.object({}),If=class{client;constructor(e){this.client=e}async addChildren(e,...t){await this.client.send(`/ontology/add-children`,{id:e,children:t},Nf,Ff)}async removeChildren(e,...t){await this.client.send(`/ontology/remove-children`,{id:e,children:t},Nf,Ff)}async moveChildren(e,t,...n){await this.client.send(`/ontology/move-children`,{from:e,to:t,children:n},Pf,Ff)}},Lf=l.z.object({ids:L.array().optional(),children:l.z.boolean().optional(),parents:l.z.boolean().optional(),excludeFieldData:l.z.boolean().optional(),types:xf.array().optional(),searchTerm:l.z.string().optional(),limit:l.z.int().optional(),offset:l.z.int().optional()}),Rf=l.z.object({resources:Df.array()}),zf=class{type=`ontology`;client;writer;constructor(e){this.client=e,this.writer=new If(e)}async retrieve(e,t){if(!Array.isArray(e)&&typeof e==`object`&&!(`key`in e))return this.execRetrieve(e);let n=Ef(e),r=await this.execRetrieve({ids:n,...t});if(Array.isArray(e))return r;if(r.length===0)throw new df(`No resource found with ID ${Ns.naturalLanguageJoin(n.map(e=>wf(e)))}`);return r[0]}async retrieveChildren(e,t){return await this.execRetrieve({ids:_.toArray(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:_.toArray(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async execRetrieve(e){let{resources:t}=await this.client.send(`/ontology/retrieve`,e,Lf,Rf);return t}},Bf=`sy_ontology_resource_set`,Vf=`sy_ontology_resource_delete`,Hf=`sy_ontology_relationship_set`,Uf=`sy_ontology_relationship_delete`,Wf=o({Client:()=>zf,PARENT_OF_RELATIONSHIP_TYPE:()=>jf,RELATIONSHIP_DELETE_CHANNEL_NAME:()=>Uf,RELATIONSHIP_SET_CHANNEL_NAME:()=>Hf,RESOURCE_DELETE_CHANNEL_NAME:()=>Vf,RESOURCE_SET_CHANNEL_NAME:()=>Bf,RESOURCE_TYPES:()=>bf,ROOT_ID:()=>Cf,createIDFactory:()=>R,idToString:()=>wf,idZ:()=>L,idsEqual:()=>Tf,matchRelationship:()=>Mf,oppositeRelationshipDirection:()=>Of,parseIDs:()=>Ef,relationshipToString:()=>Af,relationshipZ:()=>kf,resourceTypeZ:()=>xf,resourceZ:()=>Df}),Gf=l.z.uuid(),Kf=l.z.object({key:Gf,name:l.z.string(),objects:_.nullishToEmpty(L),actions:_.nullishToEmpty(d),internal:l.z.boolean().default(!1).optional()}),qf=Kf.partial({key:!0}),Jf=R(`policy`),Yf=Jf(``),Xf=`sy_policy_set`,Zf=`sy_policy_delete`,Qf=l.z.object({keys:Gf.array().optional(),subjects:L.array().optional(),limit:l.z.number().optional(),offset:l.z.number().optional(),internal:l.z.boolean().optional()}),$f=l.z.object({key:Gf}).transform(({key:e})=>({keys:[e]})),ep=l.z.union([l.z.object({for:L}).transform(({for:e})=>({subjects:[e]})),l.z.object({for:L.array()}).transform(({for:e})=>({subjects:e})),Qf]),tp=l.z.union([$f,ep]),np=l.z.object({policies:_.nullishToEmpty(Kf)}),rp=qf.transform(e=>({policies:[e]})),ip=qf.array().transform(e=>({policies:e})),ap=l.z.union([rp,ip]),op=l.z.object({policies:Kf.array()}),sp=l.z.object({keys:Gf.array()}),cp=l.z.object({}),lp=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/access/policy/create`,e,ap,op);return t?n.policies:n.policies[0]}async retrieve(e){let t=`key`in e,n=await this.client.send(`/access/policy/retrieve`,e,tp,np);return t?n.policies[0]:n.policies}async delete(e){await this.client.send(`/access/policy/delete`,{keys:_.toArray(e)},sp,cp)}},up=o({Client:()=>lp,DELETE_CHANNEL_NAME:()=>Zf,SET_CHANNEL_NAME:()=>Xf,TYPE_ONTOLOGY_ID:()=>Yf,createArgsZ:()=>ap,keyZ:()=>Gf,multipleCreateArgsZ:()=>ip,newZ:()=>qf,ontologyID:()=>Jf,policyZ:()=>Kf}),dp=l.z.uuid(),fp=l.z.object({key:dp,name:l.z.string(),description:l.z.string().optional(),internal:l.z.boolean().optional()}),pp=fp.partial({key:!0}),mp=R(`role`),hp=mp(``),gp=l.z.uuid(),_p=l.z.object({key:gp,username:l.z.string().min(1,`Username is required`),firstName:l.z.string(),lastName:l.z.string(),rootUser:l.z.boolean().default(!1)}),vp=_p.omit({rootUser:!0}).partial({key:!0,firstName:!0,lastName:!0}).extend({password:l.z.string().min(1)});R(`user`)(``);var yp=l.z.object({keys:gp.array().optional(),usernames:l.z.string().array().optional()}),bp=l.z.object({key:gp}).transform(({key:e})=>({keys:[e]})),xp=l.z.object({username:l.z.string()}).transform(({username:e})=>({usernames:[e]})),Sp=l.z.object({usernames:l.z.string().array()}).transform(({usernames:e})=>({usernames:e})),Cp=l.z.union([bp,xp,Sp,yp]),wp=l.z.object({users:_.nullishToEmpty(_p)}),Tp=l.z.object({users:vp.array()}),Ep=l.z.object({users:_p.array()}),Dp=l.z.object({key:gp,username:l.z.string().min(1)}),Op=l.z.object({}),kp=l.z.object({key:gp,firstName:l.z.string().optional(),lastName:l.z.string().optional()}),Ap=l.z.object({}),jp=l.z.object({keys:gp.array()}),Mp=l.z.object({}),Np=`sy_user_set`,Pp=`sy_user_delete`,Fp=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/user/create`,{users:_.toArray(e)},Tp,Ep);return t?n.users:n.users[0]}async changeUsername(e,t){await this.client.send(`/user/change-username`,{key:e,username:t},Dp,Op)}async retrieve(e){let t=`key`in e||`username`in e,n=await this.client.send(`/user/retrieve`,e,Cp,wp);if(!t)return n.users;if(n.users.length===0)throw new ff(`No user with ${`key`in e?`key ${e.key}`:`username ${e.username}`} found`);if(n.users.length>1)throw new pf(`Multiple users found with ${`key`in e?`key ${e.key}`:`username ${e.username}`}`);return n.users[0]}async rename(e,t,n){await this.client.send(`/user/rename`,{key:e,firstName:t,lastName:n},kp,Ap)}async delete(e){await this.client.send(`/user/delete`,{keys:_.toArray(e)},jp,Mp)}},Ip=R(`user`),Lp=Ip(``),Rp=o({Client:()=>Fp,DELETE_CHANNEL_NAME:()=>Pp,SET_CHANNEL_NAME:()=>Np,TYPE_ONTOLOGY_ID:()=>Lp,keyZ:()=>gp,newZ:()=>vp,ontologyID:()=>Ip,userZ:()=>_p}),zp=l.z.object({keys:dp.array().optional(),limit:l.z.number().optional(),offset:l.z.number().optional(),internal:l.z.boolean().optional()}),Bp=l.z.object({key:dp}).transform(({key:e})=>({keys:[e]})),Vp=pp.transform(e=>({roles:[e]})),Hp=pp.array().transform(e=>({roles:e})),Up=l.z.union([Vp,Hp]),Wp=l.z.object({roles:fp.array()}),Gp=l.z.object({roles:_.nullishToEmpty(fp)}),Kp=l.z.union([Bp,zp]),qp=l.z.object({}),Jp=dp.transform(e=>({keys:[e]})).or(dp.array().transform(e=>({keys:e}))),Yp=l.z.object({user:gp,role:dp}),Xp=l.z.object({}),Zp=l.z.object({user:gp,role:dp}),Qp=l.z.object({}),$p=`sy_role_set`,em=`sy_role_delete`,tm=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/access/role/create`,e,Up,Wp);return t?n.roles:n.roles[0]}async retrieve(e){let t=`key`in e,n=await this.client.send(`/access/role/retrieve`,e,Kp,Gp);return t?n.roles[0]:n.roles}async delete(e){await this.client.send(`/access/role/delete`,e,Jp,qp)}async assign(e){await this.client.send(`/access/role/assign`,e,Yp,Xp)}async unassign(e){await this.client.send(`/access/role/unassign`,e,Zp,Qp)}},nm=o({Client:()=>tm,DELETE_CHANNEL_NAME:()=>em,SET_CHANNEL_NAME:()=>$p,TYPE_ONTOLOGY_ID:()=>hp,createArgsZ:()=>Up,keyZ:()=>dp,multipleCreateArgsZ:()=>Hp,newZ:()=>pp,ontologyID:()=>mp,retrieveArgsZ:()=>Kp,roleZ:()=>fp}),rm=class{policies;roles;constructor(e){this.policies=new lp(e),this.roles=new tm(e)}},im=(e,t)=>{let n=_.toArray(e.objects),{action:r}=e;for(let e of n){let n=!1;for(let i of t)if(i.actions.includes(r)){for(let t of i.objects)if(t.key===``){if(t.type===e.type){n=!0;break}}else if(t.type===e.type&&t.key===e.key){n=!0;break}if(n)break}if(!n)return!1}return!0},am=o({ACTIONS:()=>u,Client:()=>rm,actionZ:()=>d,allowRequest:()=>im,policy:()=>up,role:()=>nm}),om=Symbol.for(`immer-nothing`),sm=Symbol.for(`immer-draftable`),z=Symbol.for(`immer-state`),cm=process.env.NODE_ENV===`production`?[]:[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},`This object has been frozen and should not be mutated`,function(e){return`Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? `+e},`An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.`,`Immer forbids circular references`,"The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},`Object.defineProperty() cannot be used on an Immer draft`,`Object.setPrototypeOf() cannot be used on an Immer draft`,`Immer only supports deleting array indices`,`Immer only supports setting array indices and the 'length' property`,function(e){return`'original' expects a draft, got: ${e}`}];function lm(e,...t){if(process.env.NODE_ENV!==`production`){let n=cm[e],r=Nm(n)?n.apply(null,t):n;throw Error(`[Immer] ${r}`)}throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var um=Object,dm=um.getPrototypeOf,fm=`constructor`,pm=`prototype`,mm=`configurable`,hm=`enumerable`,gm=`writable`,_m=`value`,vm=e=>!!e&&!!e[z];function ym(e){return e?Sm(e)||km(e)||!!e[sm]||!!e[fm]?.[sm]||Am(e)||jm(e):!1}var bm=um[pm][fm].toString(),xm=new WeakMap;function Sm(e){if(!e||!Mm(e))return!1;let t=dm(e);if(t===null||t===um[pm])return!0;let n=um.hasOwnProperty.call(t,fm)&&t[fm];if(n===Object)return!0;if(!Nm(n))return!1;let r=xm.get(n);return r===void 0&&(r=Function.toString.call(n),xm.set(n,r)),r===bm}function Cm(e,t,n=!0){wm(e)===0?(n?Reflect.ownKeys(e):um.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function wm(e){let t=e[z];return t?t.type_:km(e)?1:Am(e)?2:jm(e)?3:0}var Tm=(e,t,n=wm(e))=>n===2?e.has(t):um[pm].hasOwnProperty.call(e,t),Em=(e,t,n=wm(e))=>n===2?e.get(t):e[t],Dm=(e,t,n,r=wm(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Om(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var km=Array.isArray,Am=e=>e instanceof Map,jm=e=>e instanceof Set,Mm=e=>typeof e==`object`,Nm=e=>typeof e==`function`,Pm=e=>typeof e==`boolean`;function Fm(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Im=e=>e.copy_||e.base_,Lm=e=>e.modified_?e.copy_:e.base_;function Rm(e,t){if(Am(e))return new Map(e);if(jm(e))return new Set(e);if(km(e))return Array[pm].slice.call(e);let n=Sm(e);if(t===!0||t===`class_only`&&!n){let t=um.getOwnPropertyDescriptors(e);delete t[z];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[gm]===!1&&(a[gm]=!0,a[mm]=!0),(a.get||a.set)&&(t[i]={[mm]:!0,[gm]:!0,[hm]:a[hm],[_m]:e[i]})}return um.create(dm(e),t)}else{let t=dm(e);if(t!==null&&n)return{...e};let r=um.create(t);return um.assign(r,e)}}function zm(e,t=!1){return Hm(e)||vm(e)||!ym(e)?e:(wm(e)>1&&um.defineProperties(e,{set:Vm,add:Vm,clear:Vm,delete:Vm}),um.freeze(e),t&&Cm(e,(e,t)=>{zm(t,!0)},!1),e)}function Bm(){lm(2)}var Vm={[_m]:Bm};function Hm(e){return e===null||!Mm(e)?!0:um.isFrozen(e)}var Um=`MapSet`,Wm=`Patches`,Gm=`ArrayMethods`,Km={};function qm(e){let t=Km[e];return t||lm(0,e),t}var Jm=e=>!!Km[e],Ym,Xm=()=>Ym,Zm=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Jm(Um)?qm(Um):void 0,arrayMethodsPlugin_:Jm(Gm)?qm(Gm):void 0});function Qm(e,t){t&&(e.patchPlugin_=qm(Wm),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function $m(e){eh(e),e.drafts_.forEach(nh),e.drafts_=null}function eh(e){e===Ym&&(Ym=e.parent_)}var th=e=>Ym=Zm(Ym,e);function nh(e){let t=e[z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function rh(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[z].modified_&&($m(t),lm(4)),ym(e)&&(e=ih(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[z].base_,e,t)}else e=ih(t,n);return ah(t,e,!0),$m(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===om?void 0:e}function ih(e,t){if(Hm(t))return t;let n=t[z];if(!n)return ph(t,e.handledSet_,e);if(!sh(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);dh(n,e)}return n.copy_}function ah(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&zm(t,n)}function oh(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var sh=(e,t)=>e.scope_===t,ch=[];function lh(e,t,n,r){let i=Im(e),a=e.type_;if(r!==void 0&&Em(i,r,a)===t){Dm(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Cm(i,(e,n)=>{if(vm(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??ch;for(let e of o)Dm(i,e,n,a)}function uh(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!sh(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Lm(i);lh(e,i.draft_??i,a,n),dh(i,r)})}function dh(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}oh(e)}}function fh(e,t,n){let{scope_:r}=e;if(vm(n)){let i=n[z];sh(i,r)&&i.callbacks_.push(function(){xh(e),lh(e,n,Lm(i),t)})}else ym(n)&&e.callbacks_.push(function(){let i=Im(e);e.type_===3?i.has(n)&&ph(n,r.handledSet_,r):Em(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&ph(Em(e.copy_,t,e.type_),r.handledSet_,r)})}function ph(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||vm(e)||t.has(e)||!ym(e)||Hm(e)?e:(t.add(e),Cm(e,(r,i)=>{if(vm(i)){let t=i[z];sh(t,n)&&(Dm(e,r,Lm(t),e.type_),oh(t))}else ym(i)&&ph(i,t,n)}),e)}function mh(e,t){let n=km(e),r={type_:+!!n,scope_:t?t.scope_:Xm(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=hh;n&&(i=[r],a=gh);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var hh={get(e,t){if(t===z)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Im(e);if(!Tm(i,t,e.type_))return vh(e,i,t);let a=i[t];if(e.finalized_||!ym(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Fm(t))return a;if(a===_h(e.base_,t)){xh(e);let n=e.type_===1?+t:t,r=Ch(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Im(e)},ownKeys(e){return Reflect.ownKeys(Im(e))},set(e,t,n){let r=yh(Im(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=_h(Im(e),t),i=r?.[z];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Om(n,r)&&(n!==void 0||Tm(e.base_,t,e.type_)))return!0;xh(e),bh(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),fh(e,t,n),!0)},deleteProperty(e,t){return xh(e),_h(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),bh(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Im(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[gm]:!0,[mm]:e.type_!==1||t!==`length`,[hm]:r[hm],[_m]:n[t]}},defineProperty(){lm(11)},getPrototypeOf(e){return dm(e.base_)},setPrototypeOf(){lm(12)}},gh={};for(let e in hh){let t=hh[e];gh[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}gh.deleteProperty=function(e,t){return process.env.NODE_ENV!==`production`&&isNaN(parseInt(t))&&lm(13),gh.set.call(this,e,t,void 0)},gh.set=function(e,t,n){return process.env.NODE_ENV!==`production`&&t!==`length`&&isNaN(parseInt(t))&&lm(14),hh.set.call(this,e[0],t,n,e[0])};function _h(e,t){let n=e[z];return(n?Im(n):e)[t]}function vh(e,t,n){let r=yh(t,n);return r?_m in r?r[_m]:r.get?.call(e.draft_):void 0}function yh(e,t){if(!(t in e))return;let n=dm(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=dm(n)}}function bh(e){e.modified_||(e.modified_=!0,e.parent_&&bh(e.parent_))}function xh(e){e.copy_||=(e.assigned_=new Map,Rm(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Sh=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Nm(e)&&!Nm(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Nm(t)||lm(6),n!==void 0&&!Nm(n)&&lm(7);let r;if(ym(e)){let i=th(this),a=Ch(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?$m(i):eh(i)}return Qm(i,n),rh(r,i)}else if(!e||!Mm(e)){if(r=t(e),r===void 0&&(r=e),r===om&&(r=void 0),this.autoFreeze_&&zm(r,!0),n){let t=[],i=[];qm(Wm).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else lm(1,e)},this.produceWithPatches=(e,t)=>{if(Nm(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Pm(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Pm(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Pm(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ym(e)||lm(8),vm(e)&&(e=wh(e));let t=th(this),n=Ch(t,e,void 0);return n[z].isManual_=!0,eh(t),n}finishDraft(e,t){let n=e&&e[z];(!n||!n.isManual_)&&lm(9);let{scope_:r}=n;return Qm(r,t),rh(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=qm(Wm).applyPatches_;return vm(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Ch(e,t,n,r){let[i,a]=Am(t)?qm(Um).proxyMap_(t,n):jm(t)?qm(Um).proxySet_(t,n):mh(t,n);return(n?.scope_??Xm()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?uh(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function wh(e){return vm(e)||lm(10,e),Th(e)}function Th(e){if(!ym(e)||Hm(e))return e;let t=e[z],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Rm(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Rm(e,!0);return Cm(n,(e,t)=>{Dm(n,e,Th(t))},r),t&&(t.finalized_=!1),n}var Eh=new Sh().produce,Dh={inverse:[],targets:[]},Oh=e=>vm(e)?wh(e):e,kh=e=>(t,n)=>{let r=[],i=new Set;return{next:Eh(t,t=>{for(let a of n){let n=e(t,a);n.inverse.length>0&&r.unshift(...n.inverse);for(let e of n.targets)i.add(e)}}),inverse:r,targets:Array.from(i)}},Ah=(e,t)=>l.z.object({key:e,dispatchKey:l.z.string(),seq:l.z.number().int().nonnegative().default(0),actions:t.array()}),jh=(e,t)=>l.z.object({key:e,dispatchKey:l.z.string(),actions:t.array()}),Mh=o({NO_OP_RESULT:()=>Dh,createReduceAll:()=>kh,dispatchReqZ:()=>jh,scopedZ:()=>Ah,snapshotDraft:()=>Oh}),Nh;function B(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Ph=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Fh=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Nh=globalThis).__zod_globalConfig??(Nh.__zod_globalConfig={});var Ih=globalThis.__zod_globalConfig;function Lh(e){return e&&Object.assign(Ih,e),Ih}function Rh(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function zh(e,t){return typeof t==`bigint`?t.toString():t}function Bh(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Vh(e){return e==null}function Hh(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Uh(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Wh=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Wh)return r===void 0&&(r=Wh,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Gh(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Kh(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function qh(e){return JSON.stringify(e)}function Jh(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Yh=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Xh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Zh=Bh(()=>{if(Ih.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Qh(e){if(Xh(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Xh(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function $h(e){return Qh(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var eg=new Set([`string`,`number`,`symbol`]);function tg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ng(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function rg(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var ig={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ag(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return ng(e,Kh(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Gh(this,`shape`,e),e},checks:[]}))}function og(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return ng(e,Kh(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Gh(this,`shape`,r),r},checks:[]}))}function sg(e,t){if(!Qh(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ng(e,Kh(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Gh(this,`shape`,n),n}}))}function cg(e,t){if(!Qh(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ng(e,Kh(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Gh(this,`shape`,n),n}}))}function lg(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return ng(e,Kh(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Gh(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ug(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return ng(t,Kh(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Gh(this,`shape`,i),i},checks:[]}))}function dg(e,t,n){return ng(t,Kh(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Gh(this,`shape`,i),i}}))}function fg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function mg(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function hg(e){return typeof e==`string`?e:e?.message}function gg(e,t,n){let r=e.message?e.message:hg(e.inst?._zod.def?.error?.(e))??hg(t?.error?.(e))??hg(n.customError?.(e))??hg(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function _g(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function vg(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var yg=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,zh,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},bg=B(`$ZodError`,yg),xg=B(`$ZodError`,yg,{Parent:Error});function Sg(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Cg(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var wg=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Ph;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>gg(e,a,Lh())));throw Yh(t,i?.callee),t}return o.value},Tg=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>gg(e,a,Lh())));throw Yh(t,i?.callee),t}return o.value},Eg=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ph;return a.issues.length?{success:!1,error:new(e??bg)(a.issues.map(e=>gg(e,i,Lh())))}:{success:!0,data:a.value}},Dg=Eg(xg),Og=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>gg(e,i,Lh())))}:{success:!0,data:a.value}},kg=Og(xg),Ag=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return wg(e)(t,n,i)},jg=e=>(t,n,r)=>wg(e)(t,n,r),Mg=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Tg(e)(t,n,i)},Ng=e=>async(t,n,r)=>Tg(e)(t,n,r),Pg=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Eg(e)(t,n,i)},Fg=e=>(t,n,r)=>Eg(e)(t,n,r),Ig=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Og(e)(t,n,i)},Lg=e=>async(t,n,r)=>Og(e)(t,n,r),Rg=/^[cC][0-9a-z]{6,}$/,zg=/^[0-9a-z]+$/,Bg=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vg=/^[0-9a-vA-V]{20}$/,Hg=/^[A-Za-z0-9]{27}$/,Ug=/^[a-zA-Z0-9_-]{21}$/,Wg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kg=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Jg=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Yg(){return new RegExp(Jg,`u`)}var Xg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Zg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Qg=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$g=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,e_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,t_=/^[A-Za-z0-9_-]*$/,n_=/^https?$/,r_=/^\+[1-9]\d{6,14}$/,i_=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,a_=RegExp(`^${i_}$`);function o_(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function s_(e){return RegExp(`^${o_(e)}$`)}function c_(e){let t=o_({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${i_}T(?:${r})$`)}var l_=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},u_=/^-?\d+$/,d_=/^-?\d+(?:\.\d+)?$/,f_=/^(?:true|false)$/i,p_=/^[^A-Z]*$/,m_=/^[^a-z]*$/,U=B(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),h_={number:`number`,bigint:`bigint`,object:`date`},g_=B(`$ZodCheckLessThan`,(e,t)=>{U.init(e,t);let n=h_[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),__=B(`$ZodCheckGreaterThan`,(e,t)=>{U.init(e,t);let n=h_[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),v_=B(`$ZodCheckMultipleOf`,(e,t)=>{U.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Uh(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),y_=B(`$ZodCheckNumberFormat`,(e,t)=>{U.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ig[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=u_)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),b_=B(`$ZodCheckMaxLength`,(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Vh(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=_g(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),x_=B(`$ZodCheckMinLength`,(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Vh(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=_g(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),S_=B(`$ZodCheckLengthEquals`,(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Vh(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=_g(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),C_=B(`$ZodCheckStringFormat`,(e,t)=>{var n,r;U.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),w_=B(`$ZodCheckRegex`,(e,t)=>{C_.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),T_=B(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=p_,C_.init(e,t)}),E_=B(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=m_,C_.init(e,t)}),D_=B(`$ZodCheckIncludes`,(e,t)=>{U.init(e,t);let n=tg(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),O_=B(`$ZodCheckStartsWith`,(e,t)=>{U.init(e,t);let n=RegExp(`^${tg(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),k_=B(`$ZodCheckEndsWith`,(e,t)=>{U.init(e,t);let n=RegExp(`.*${tg(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),A_=B(`$ZodCheckOverwrite`,(e,t)=>{U.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),j_=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
32
|
+
`)}},df=class extends af.sub(`query`){},ff=class extends df.sub(`not_found`){},pf=class extends df.sub(`multiple_results`){},mf=class extends af.sub(`route`){path;constructor(e,t){super(e),this.path=t}},hf=class extends af.sub(`control`){},gf=class extends hf.sub(`unauthorized`){},_f=class extends af.sub(`disconnected`){constructor(e=`Operation failed because no Core is connected.`){super(e)}},vf=class extends af.sub(`contiguity`){};v.register({encode:()=>{throw new v.NotImplemented},decode:e=>e.type.startsWith(af.TYPE)?e.type.startsWith(L.TYPE)?e.type===of.TYPE?of.decode(e):new L(e.data):e.type.startsWith(sf.TYPE)?e.type.startsWith(cf.TYPE)?new cf(e.data):e.type.startsWith(lf.TYPE)?new lf(e.data):new sf(e.data):e.type.startsWith(uf.TYPE)?new uf(e.data):e.type.startsWith(df.TYPE)?e.type.startsWith(ff.TYPE)?new ff(e.data):e.type.startsWith(pf.TYPE)?new pf(e.data):new df(e.data):e.type.startsWith(hf.TYPE)?e.type.startsWith(gf.TYPE)?new gf(e.data):new hf(e.data):e.type.startsWith(mf.TYPE)?new mf(e.data,e.data):new uf(e.data):null});var yf=async(e,t)=>{try{return await t(e)}catch(e){throw e instanceof Gd?new Gd({message:`Cannot reach Core at ${e.url.host}:${e.url.port}`,url:e.url,cause:e.cause??e}):v.fromUnknown(e)}},bf=[`arc`,`builtin`,`channel`,`device`,`framer`,`group`,`label`,`lineplot`,`log`,`node`,`policy`,`rack`,`range`,`range-alias`,`role`,`schematic`,`schematic_symbol`,`status`,`table`,`task`,`user`,`view`,`workspace`],xf=l.z.enum(bf),Sf=l.z.string().transform(e=>{let[t,n]=e.split(`:`);return{type:xf.parse(t),key:n??``}}),R=l.z.object({type:xf,key:l.z.string()}).or(Sf),Cf={type:`builtin`,key:`root`},z=e=>{let t=t=>({type:e,key:et.isZero(t)?``:t.toString()});return(e=>Array.isArray(e)?e.map(t):t(e))},wf=(e=>(typeof e==`string`&&(e=Sf.parse(e)),Array.isArray(e)?e.map(e=>wf(e)):`${e.type}:${e.key}`)),Tf=(e,t)=>e.type===t.type&&e.key===t.key,Ef=e=>{let t=_.toArray(e);return t.length===0?[]:typeof t[0]==`object`&&`id`in t[0]?t.map(({id:e})=>e):t.map(e=>R.parse(e))},Df=l.z.object({id:R,name:l.z.string(),data:A.unknownZ().optional().nullable()}).transform(e=>({key:wf(e.id),...e})),Of=e=>e===`to`?`from`:`to`,kf=l.z.object({from:R,type:l.z.string(),to:R}).or(l.z.string().transform(e=>{let[t,n,r]=e.split(`->`);return{from:R.parse(t),type:n,to:R.parse(r)}})),Af=e=>`${wf(e.from)}->${e.type}->${wf(e.to)}`,jf=`parent`,Mf=(e,t)=>!(t.type!=null&&t.type!==e.type||t.from?.type!=null&&t.from.type!==e.from.type||t.to?.type!=null&&t.to.type!==e.to.type||t.from?.key!=null&&t.from.key!==e.from.key||t.to?.key!=null&&t.to.key!==e.to.key),Nf=l.z.object({id:R,children:R.array()}),Pf=l.z.object({from:R,to:R,children:R.array()}),Ff=l.z.object({}),If=class{client;constructor(e){this.client=e}async addChildren(e,...t){await this.client.send(`/ontology/add-children`,{id:e,children:t},Nf,Ff)}async removeChildren(e,...t){await this.client.send(`/ontology/remove-children`,{id:e,children:t},Nf,Ff)}async moveChildren(e,t,...n){await this.client.send(`/ontology/move-children`,{from:e,to:t,children:n},Pf,Ff)}},Lf=l.z.object({ids:R.array().optional(),children:l.z.boolean().optional(),parents:l.z.boolean().optional(),excludeFieldData:l.z.boolean().optional(),types:xf.array().optional(),searchTerm:l.z.string().optional(),limit:l.z.int().optional(),offset:l.z.int().optional()}),Rf=l.z.object({resources:Df.array()}),zf=class{type=`ontology`;client;writer;constructor(e){this.client=e,this.writer=new If(e)}async retrieve(e,t){if(!Array.isArray(e)&&typeof e==`object`&&!(`key`in e))return await this.execRetrieve(e);let n=Ef(e),r=await this.execRetrieve({ids:n,...t});if(Array.isArray(e))return r;if(r.length===0)throw new df(`No resource found with ID ${Ms.naturalLanguageJoin(n.map(e=>wf(e)))}`);return r[0]}async retrieveChildren(e,t){return await this.execRetrieve({ids:_.toArray(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:_.toArray(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async execRetrieve(e){let{resources:t}=await this.client.send(`/ontology/retrieve`,e,Lf,Rf);return t}},Bf=`sy_ontology_resource_set`,Vf=`sy_ontology_resource_delete`,Hf=`sy_ontology_relationship_set`,Uf=`sy_ontology_relationship_delete`,Wf=o({Client:()=>zf,PARENT_OF_RELATIONSHIP_TYPE:()=>jf,RELATIONSHIP_DELETE_CHANNEL_NAME:()=>Uf,RELATIONSHIP_SET_CHANNEL_NAME:()=>Hf,RESOURCE_DELETE_CHANNEL_NAME:()=>Vf,RESOURCE_SET_CHANNEL_NAME:()=>Bf,RESOURCE_TYPES:()=>bf,ROOT_ID:()=>Cf,createIDFactory:()=>z,idToString:()=>wf,idZ:()=>R,idsEqual:()=>Tf,matchRelationship:()=>Mf,oppositeRelationshipDirection:()=>Of,parseIDs:()=>Ef,relationshipToString:()=>Af,relationshipZ:()=>kf,resourceTypeZ:()=>xf,resourceZ:()=>Df}),Gf=l.z.uuid(),Kf=l.z.object({key:Gf,name:l.z.string(),objects:_.nullishToEmpty(R),actions:_.nullishToEmpty(d),internal:l.z.boolean().default(!1).optional()}),qf=Kf.partial({key:!0}),Jf=z(`policy`),Yf=Jf(``),Xf=`sy_policy_set`,Zf=`sy_policy_delete`,Qf=l.z.object({keys:Gf.array().optional(),subjects:R.array().optional(),limit:l.z.number().optional(),offset:l.z.number().optional(),internal:l.z.boolean().optional()}),$f=l.z.object({key:Gf}).transform(({key:e})=>({keys:[e]})),ep=l.z.union([l.z.object({for:R}).transform(({for:e})=>({subjects:[e]})),l.z.object({for:R.array()}).transform(({for:e})=>({subjects:e})),Qf]),tp=l.z.union([$f,ep]),np=l.z.object({policies:_.nullishToEmpty(Kf)}),rp=qf.transform(e=>({policies:[e]})),ip=qf.array().transform(e=>({policies:e})),ap=l.z.union([rp,ip]),op=l.z.object({policies:Kf.array()}),sp=l.z.object({keys:Gf.array()}),cp=l.z.object({}),lp=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/access/policy/create`,e,ap,op);return t?n.policies:n.policies[0]}async retrieve(e){let t=`key`in e,n=await this.client.send(`/access/policy/retrieve`,e,tp,np);return t?n.policies[0]:n.policies}async delete(e){await this.client.send(`/access/policy/delete`,{keys:_.toArray(e)},sp,cp)}},up=o({Client:()=>lp,DELETE_CHANNEL_NAME:()=>Zf,SET_CHANNEL_NAME:()=>Xf,TYPE_ONTOLOGY_ID:()=>Yf,createArgsZ:()=>ap,keyZ:()=>Gf,multipleCreateArgsZ:()=>ip,newZ:()=>qf,ontologyID:()=>Jf,policyZ:()=>Kf}),dp=l.z.uuid(),fp=l.z.object({key:dp,name:l.z.string(),description:l.z.string().optional(),internal:l.z.boolean().optional()}),pp=fp.partial({key:!0}),mp=z(`role`),hp=mp(``),gp=l.z.uuid(),_p=l.z.object({key:gp,username:l.z.string().min(1,`Username is required`),firstName:l.z.string(),lastName:l.z.string(),rootUser:l.z.boolean().default(!1)}),vp=_p.omit({rootUser:!0}).partial({key:!0,firstName:!0,lastName:!0}).extend({password:l.z.string().min(1)});z(`user`)(``);var yp=l.z.object({keys:gp.array().optional(),usernames:l.z.string().array().optional()}),bp=l.z.object({key:gp}).transform(({key:e})=>({keys:[e]})),xp=l.z.object({username:l.z.string()}).transform(({username:e})=>({usernames:[e]})),Sp=l.z.object({usernames:l.z.string().array()}).transform(({usernames:e})=>({usernames:e})),Cp=l.z.union([bp,xp,Sp,yp]),wp=l.z.object({users:_.nullishToEmpty(_p)}),Tp=l.z.object({users:vp.array()}),Ep=l.z.object({users:_p.array()}),Dp=l.z.object({key:gp,username:l.z.string().min(1)}),Op=l.z.object({}),kp=l.z.object({key:gp,firstName:l.z.string().optional(),lastName:l.z.string().optional()}),Ap=l.z.object({}),jp=l.z.object({keys:gp.array()}),Mp=l.z.object({}),Np=`sy_user_set`,Pp=`sy_user_delete`,Fp=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/user/create`,{users:_.toArray(e)},Tp,Ep);return t?n.users:n.users[0]}async changeUsername(e,t){await this.client.send(`/user/change-username`,{key:e,username:t},Dp,Op)}async retrieve(e){let t=`key`in e||`username`in e,n=await this.client.send(`/user/retrieve`,e,Cp,wp);if(!t)return n.users;if(n.users.length===0)throw new ff(`No user with ${`key`in e?`key ${e.key}`:`username ${e.username}`} found`);if(n.users.length>1)throw new pf(`Multiple users found with ${`key`in e?`key ${e.key}`:`username ${e.username}`}`);return n.users[0]}async rename(e,t,n){await this.client.send(`/user/rename`,{key:e,firstName:t,lastName:n},kp,Ap)}async delete(e){await this.client.send(`/user/delete`,{keys:_.toArray(e)},jp,Mp)}},Ip=z(`user`),Lp=Ip(``),Rp=o({Client:()=>Fp,DELETE_CHANNEL_NAME:()=>Pp,SET_CHANNEL_NAME:()=>Np,TYPE_ONTOLOGY_ID:()=>Lp,keyZ:()=>gp,newZ:()=>vp,ontologyID:()=>Ip,userZ:()=>_p}),zp=l.z.object({keys:dp.array().optional(),limit:l.z.number().optional(),offset:l.z.number().optional(),internal:l.z.boolean().optional()}),Bp=l.z.object({key:dp}).transform(({key:e})=>({keys:[e]})),Vp=pp.transform(e=>({roles:[e]})),Hp=pp.array().transform(e=>({roles:e})),Up=l.z.union([Vp,Hp]),Wp=l.z.object({roles:fp.array()}),Gp=l.z.object({roles:_.nullishToEmpty(fp)}),Kp=l.z.union([Bp,zp]),qp=l.z.object({}),Jp=dp.transform(e=>({keys:[e]})).or(dp.array().transform(e=>({keys:e}))),Yp=l.z.object({user:gp,role:dp}),Xp=l.z.object({}),Zp=l.z.object({user:gp,role:dp}),Qp=l.z.object({}),$p=`sy_role_set`,em=`sy_role_delete`,tm=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/access/role/create`,e,Up,Wp);return t?n.roles:n.roles[0]}async retrieve(e){let t=`key`in e,n=await this.client.send(`/access/role/retrieve`,e,Kp,Gp);return t?n.roles[0]:n.roles}async delete(e){await this.client.send(`/access/role/delete`,e,Jp,qp)}async assign(e){await this.client.send(`/access/role/assign`,e,Yp,Xp)}async unassign(e){await this.client.send(`/access/role/unassign`,e,Zp,Qp)}},nm=o({Client:()=>tm,DELETE_CHANNEL_NAME:()=>em,SET_CHANNEL_NAME:()=>$p,TYPE_ONTOLOGY_ID:()=>hp,createArgsZ:()=>Up,keyZ:()=>dp,multipleCreateArgsZ:()=>Hp,newZ:()=>pp,ontologyID:()=>mp,retrieveArgsZ:()=>Kp,roleZ:()=>fp}),rm=class{policies;roles;constructor(e){this.policies=new lp(e),this.roles=new tm(e)}},im=(e,t)=>{let n=_.toArray(e.objects),{action:r}=e;for(let e of n){let n=!1;for(let i of t)if(i.actions.includes(r)){for(let t of i.objects)if(t.key===``){if(t.type===e.type){n=!0;break}}else if(t.type===e.type&&t.key===e.key){n=!0;break}if(n)break}if(!n)return!1}return!0},am=o({ACTIONS:()=>u,Client:()=>rm,actionZ:()=>d,allowRequest:()=>im,policy:()=>up,role:()=>nm}),om=Symbol.for(`immer-nothing`),sm=Symbol.for(`immer-draftable`),B=Symbol.for(`immer-state`),cm=process.env.NODE_ENV===`production`?[]:[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},`This object has been frozen and should not be mutated`,function(e){return`Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? `+e},`An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.`,`Immer forbids circular references`,"The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},`Object.defineProperty() cannot be used on an Immer draft`,`Object.setPrototypeOf() cannot be used on an Immer draft`,`Immer only supports deleting array indices`,`Immer only supports setting array indices and the 'length' property`,function(e){return`'original' expects a draft, got: ${e}`}];function lm(e,...t){if(process.env.NODE_ENV!==`production`){let n=cm[e],r=Nm(n)?n.apply(null,t):n;throw Error(`[Immer] ${r}`)}throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var um=Object,dm=um.getPrototypeOf,fm=`constructor`,pm=`prototype`,mm=`configurable`,hm=`enumerable`,gm=`writable`,_m=`value`,vm=e=>!!e&&!!e[B];function ym(e){return e?Sm(e)||km(e)||!!e[sm]||!!e[fm]?.[sm]||Am(e)||jm(e):!1}var bm=um[pm][fm].toString(),xm=new WeakMap;function Sm(e){if(!e||!Mm(e))return!1;let t=dm(e);if(t===null||t===um[pm])return!0;let n=um.hasOwnProperty.call(t,fm)&&t[fm];if(n===Object)return!0;if(!Nm(n))return!1;let r=xm.get(n);return r===void 0&&(r=Function.toString.call(n),xm.set(n,r)),r===bm}function Cm(e,t,n=!0){wm(e)===0?(n?Reflect.ownKeys(e):um.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function wm(e){let t=e[B];return t?t.type_:km(e)?1:Am(e)?2:jm(e)?3:0}var Tm=(e,t,n=wm(e))=>n===2?e.has(t):um[pm].hasOwnProperty.call(e,t),Em=(e,t,n=wm(e))=>n===2?e.get(t):e[t],Dm=(e,t,n,r=wm(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Om(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var km=Array.isArray,Am=e=>e instanceof Map,jm=e=>e instanceof Set,Mm=e=>typeof e==`object`,Nm=e=>typeof e==`function`,Pm=e=>typeof e==`boolean`;function Fm(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Im=e=>e.copy_||e.base_,Lm=e=>e.modified_?e.copy_:e.base_;function Rm(e,t){if(Am(e))return new Map(e);if(jm(e))return new Set(e);if(km(e))return Array[pm].slice.call(e);let n=Sm(e);if(t===!0||t===`class_only`&&!n){let t=um.getOwnPropertyDescriptors(e);delete t[B];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[gm]===!1&&(a[gm]=!0,a[mm]=!0),(a.get||a.set)&&(t[i]={[mm]:!0,[gm]:!0,[hm]:a[hm],[_m]:e[i]})}return um.create(dm(e),t)}else{let t=dm(e);if(t!==null&&n)return{...e};let r=um.create(t);return um.assign(r,e)}}function zm(e,t=!1){return Hm(e)||vm(e)||!ym(e)?e:(wm(e)>1&&um.defineProperties(e,{set:Vm,add:Vm,clear:Vm,delete:Vm}),um.freeze(e),t&&Cm(e,(e,t)=>{zm(t,!0)},!1),e)}function Bm(){lm(2)}var Vm={[_m]:Bm};function Hm(e){return e===null||!Mm(e)?!0:um.isFrozen(e)}var Um=`MapSet`,Wm=`Patches`,Gm=`ArrayMethods`,Km={};function qm(e){let t=Km[e];return t||lm(0,e),t}var Jm=e=>!!Km[e],Ym,Xm=()=>Ym,Zm=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Jm(Um)?qm(Um):void 0,arrayMethodsPlugin_:Jm(Gm)?qm(Gm):void 0});function Qm(e,t){t&&(e.patchPlugin_=qm(Wm),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function $m(e){eh(e),e.drafts_.forEach(nh),e.drafts_=null}function eh(e){e===Ym&&(Ym=e.parent_)}var th=e=>Ym=Zm(Ym,e);function nh(e){let t=e[B];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function rh(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[B].modified_&&($m(t),lm(4)),ym(e)&&(e=ih(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[B].base_,e,t)}else e=ih(t,n);return ah(t,e,!0),$m(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===om?void 0:e}function ih(e,t){if(Hm(t))return t;let n=t[B];if(!n)return ph(t,e.handledSet_,e);if(!sh(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);dh(n,e)}return n.copy_}function ah(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&zm(t,n)}function oh(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var sh=(e,t)=>e.scope_===t,ch=[];function lh(e,t,n,r){let i=Im(e),a=e.type_;if(r!==void 0&&Em(i,r,a)===t){Dm(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;Cm(i,(e,n)=>{if(vm(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??ch;for(let e of o)Dm(i,e,n,a)}function uh(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!sh(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Lm(i);lh(e,i.draft_??i,a,n),dh(i,r)})}function dh(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}oh(e)}}function fh(e,t,n){let{scope_:r}=e;if(vm(n)){let i=n[B];sh(i,r)&&i.callbacks_.push(function(){xh(e),lh(e,n,Lm(i),t)})}else ym(n)&&e.callbacks_.push(function(){let i=Im(e);e.type_===3?i.has(n)&&ph(n,r.handledSet_,r):Em(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&ph(Em(e.copy_,t,e.type_),r.handledSet_,r)})}function ph(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||vm(e)||t.has(e)||!ym(e)||Hm(e)?e:(t.add(e),Cm(e,(r,i)=>{if(vm(i)){let t=i[B];sh(t,n)&&(Dm(e,r,Lm(t),e.type_),oh(t))}else ym(i)&&ph(i,t,n)}),e)}function mh(e,t){let n=km(e),r={type_:+!!n,scope_:t?t.scope_:Xm(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=hh;n&&(i=[r],a=gh);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var hh={get(e,t){if(t===B)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Im(e);if(!Tm(i,t,e.type_))return vh(e,i,t);let a=i[t];if(e.finalized_||!ym(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Fm(t))return a;if(a===_h(e.base_,t)){xh(e);let n=e.type_===1?+t:t,r=Ch(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Im(e)},ownKeys(e){return Reflect.ownKeys(Im(e))},set(e,t,n){let r=yh(Im(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=_h(Im(e),t),i=r?.[B];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Om(n,r)&&(n!==void 0||Tm(e.base_,t,e.type_)))return!0;xh(e),bh(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),fh(e,t,n),!0)},deleteProperty(e,t){return xh(e),_h(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),bh(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Im(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[gm]:!0,[mm]:e.type_!==1||t!==`length`,[hm]:r[hm],[_m]:n[t]}},defineProperty(){lm(11)},getPrototypeOf(e){return dm(e.base_)},setPrototypeOf(){lm(12)}},gh={};for(let e in hh){let t=hh[e];gh[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}gh.deleteProperty=function(e,t){return process.env.NODE_ENV!==`production`&&isNaN(parseInt(t))&&lm(13),gh.set.call(this,e,t,void 0)},gh.set=function(e,t,n){return process.env.NODE_ENV!==`production`&&t!==`length`&&isNaN(parseInt(t))&&lm(14),hh.set.call(this,e[0],t,n,e[0])};function _h(e,t){let n=e[B];return(n?Im(n):e)[t]}function vh(e,t,n){let r=yh(t,n);return r?_m in r?r[_m]:r.get?.call(e.draft_):void 0}function yh(e,t){if(!(t in e))return;let n=dm(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=dm(n)}}function bh(e){e.modified_||(e.modified_=!0,e.parent_&&bh(e.parent_))}function xh(e){e.copy_||=(e.assigned_=new Map,Rm(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Sh=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Nm(e)&&!Nm(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Nm(t)||lm(6),n!==void 0&&!Nm(n)&&lm(7);let r;if(ym(e)){let i=th(this),a=Ch(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?$m(i):eh(i)}return Qm(i,n),rh(r,i)}else if(!e||!Mm(e)){if(r=t(e),r===void 0&&(r=e),r===om&&(r=void 0),this.autoFreeze_&&zm(r,!0),n){let t=[],i=[];qm(Wm).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else lm(1,e)},this.produceWithPatches=(e,t)=>{if(Nm(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Pm(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Pm(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Pm(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ym(e)||lm(8),vm(e)&&(e=wh(e));let t=th(this),n=Ch(t,e,void 0);return n[B].isManual_=!0,eh(t),n}finishDraft(e,t){let n=e&&e[B];(!n||!n.isManual_)&&lm(9);let{scope_:r}=n;return Qm(r,t),rh(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=qm(Wm).applyPatches_;return vm(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Ch(e,t,n,r){let[i,a]=Am(t)?qm(Um).proxyMap_(t,n):jm(t)?qm(Um).proxySet_(t,n):mh(t,n);return(n?.scope_??Xm()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?uh(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function wh(e){return vm(e)||lm(10,e),Th(e)}function Th(e){if(!ym(e)||Hm(e))return e;let t=e[B],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Rm(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Rm(e,!0);return Cm(n,(e,t)=>{Dm(n,e,Th(t))},r),t&&(t.finalized_=!1),n}var Eh=new Sh().produce,Dh={inverse:[],targets:[]},Oh=e=>vm(e)?wh(e):e,kh=e=>(t,n)=>{let r=[],i=new Set;return{next:Eh(t,t=>{for(let a of n){let n=e(t,a);n.inverse.length>0&&r.unshift(...n.inverse);for(let e of n.targets)i.add(e)}}),inverse:r,targets:Array.from(i)}},Ah=(e,t)=>l.z.object({key:e,dispatchKey:l.z.string(),seq:l.z.number().int().nonnegative().default(0),actions:t.array()}),jh=(e,t)=>l.z.object({key:e,dispatchKey:l.z.string(),actions:t.array()}),Mh=o({NO_OP_RESULT:()=>Dh,createReduceAll:()=>kh,dispatchReqZ:()=>jh,scopedZ:()=>Ah,snapshotDraft:()=>Oh}),Nh;function V(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Ph=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Fh=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Nh=globalThis).__zod_globalConfig??(Nh.__zod_globalConfig={});var Ih=globalThis.__zod_globalConfig;function Lh(e){return e&&Object.assign(Ih,e),Ih}function Rh(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function zh(e,t){return typeof t==`bigint`?t.toString():t}function Bh(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Vh(e){return e==null}function Hh(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Uh(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Wh=Symbol(`evaluating`);function H(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Wh)return r===void 0&&(r=Wh,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Gh(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Kh(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function qh(e){return JSON.stringify(e)}function Jh(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Yh=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Xh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Zh=Bh(()=>{if(Ih.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Qh(e){if(Xh(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Xh(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function $h(e){return Qh(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var eg=new Set([`string`,`number`,`symbol`]);function tg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ng(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function U(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function rg(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var ig={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ag(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return ng(e,Kh(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Gh(this,`shape`,e),e},checks:[]}))}function og(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return ng(e,Kh(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Gh(this,`shape`,r),r},checks:[]}))}function sg(e,t){if(!Qh(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ng(e,Kh(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Gh(this,`shape`,n),n}}))}function cg(e,t){if(!Qh(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ng(e,Kh(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Gh(this,`shape`,n),n}}))}function lg(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return ng(e,Kh(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Gh(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ug(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return ng(t,Kh(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Gh(this,`shape`,i),i},checks:[]}))}function dg(e,t,n){return ng(t,Kh(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Gh(this,`shape`,i),i}}))}function fg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function mg(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function hg(e){return typeof e==`string`?e:e?.message}function gg(e,t,n){let r=e.message?e.message:hg(e.inst?._zod.def?.error?.(e))??hg(t?.error?.(e))??hg(n.customError?.(e))??hg(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function _g(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function vg(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var yg=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,zh,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},bg=V(`$ZodError`,yg),xg=V(`$ZodError`,yg,{Parent:Error});function Sg(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Cg(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var wg=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Ph;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>gg(e,a,Lh())));throw Yh(t,i?.callee),t}return o.value},Tg=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>gg(e,a,Lh())));throw Yh(t,i?.callee),t}return o.value},Eg=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ph;return a.issues.length?{success:!1,error:new(e??bg)(a.issues.map(e=>gg(e,i,Lh())))}:{success:!0,data:a.value}},Dg=Eg(xg),Og=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>gg(e,i,Lh())))}:{success:!0,data:a.value}},kg=Og(xg),Ag=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return wg(e)(t,n,i)},jg=e=>(t,n,r)=>wg(e)(t,n,r),Mg=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Tg(e)(t,n,i)},Ng=e=>async(t,n,r)=>Tg(e)(t,n,r),Pg=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Eg(e)(t,n,i)},Fg=e=>(t,n,r)=>Eg(e)(t,n,r),Ig=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Og(e)(t,n,i)},Lg=e=>async(t,n,r)=>Og(e)(t,n,r),Rg=/^[cC][0-9a-z]{6,}$/,zg=/^[0-9a-z]+$/,Bg=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vg=/^[0-9a-vA-V]{20}$/,Hg=/^[A-Za-z0-9]{27}$/,Ug=/^[a-zA-Z0-9_-]{21}$/,Wg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kg=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Jg=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Yg(){return new RegExp(Jg,`u`)}var Xg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Zg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Qg=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$g=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,e_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,t_=/^[A-Za-z0-9_-]*$/,n_=/^https?$/,r_=/^\+[1-9]\d{6,14}$/,i_=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,a_=RegExp(`^${i_}$`);function o_(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function s_(e){return RegExp(`^${o_(e)}$`)}function c_(e){let t=o_({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${i_}T(?:${r})$`)}var l_=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},u_=/^-?\d+$/,d_=/^-?\d+(?:\.\d+)?$/,f_=/^(?:true|false)$/i,p_=/^[^A-Z]*$/,m_=/^[^a-z]*$/,W=V(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),h_={number:`number`,bigint:`bigint`,object:`date`},g_=V(`$ZodCheckLessThan`,(e,t)=>{W.init(e,t);let n=h_[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),__=V(`$ZodCheckGreaterThan`,(e,t)=>{W.init(e,t);let n=h_[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),v_=V(`$ZodCheckMultipleOf`,(e,t)=>{W.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Uh(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),y_=V(`$ZodCheckNumberFormat`,(e,t)=>{W.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ig[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=u_)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),b_=V(`$ZodCheckMaxLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Vh(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=_g(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),x_=V(`$ZodCheckMinLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Vh(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=_g(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),S_=V(`$ZodCheckLengthEquals`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Vh(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=_g(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),C_=V(`$ZodCheckStringFormat`,(e,t)=>{var n,r;W.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),w_=V(`$ZodCheckRegex`,(e,t)=>{C_.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),T_=V(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=p_,C_.init(e,t)}),E_=V(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=m_,C_.init(e,t)}),D_=V(`$ZodCheckIncludes`,(e,t)=>{W.init(e,t);let n=tg(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),O_=V(`$ZodCheckStartsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`^${tg(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),k_=V(`$ZodCheckEndsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`.*${tg(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),A_=V(`$ZodCheckOverwrite`,(e,t)=>{W.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),j_=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
33
33
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
34
|
-
`))}},M_={major:4,minor:4,patch:3},
|
|
34
|
+
`))}},M_={major:4,minor:4,patch:3},G=V(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=M_;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=fg(e),i;for(let a of t){if(a._zod.def.when){if(pg(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Ph;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=fg(e,t))});else{if(e.issues.length===t)continue;r||=fg(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(fg(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Ph;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Ph;return o.then(e=>t(e,r,a))}return t(o,r,a)}}H(e,`~standard`,()=>({validate:t=>{try{let n=Dg(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return kg(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),N_=V(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??l_(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),K=V(`$ZodStringFormat`,(e,t)=>{C_.init(e,t),N_.init(e,t)}),P_=V(`$ZodGUID`,(e,t)=>{t.pattern??=Gg,K.init(e,t)}),F_=V(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Kg(e)}else t.pattern??=Kg();K.init(e,t)}),I_=V(`$ZodEmail`,(e,t)=>{t.pattern??=qg,K.init(e,t)}),L_=V(`$ZodURL`,(e,t)=>{K.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===n_.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),R_=V(`$ZodEmoji`,(e,t)=>{t.pattern??=Yg(),K.init(e,t)}),z_=V(`$ZodNanoID`,(e,t)=>{t.pattern??=Ug,K.init(e,t)}),B_=V(`$ZodCUID`,(e,t)=>{t.pattern??=Rg,K.init(e,t)}),V_=V(`$ZodCUID2`,(e,t)=>{t.pattern??=zg,K.init(e,t)}),H_=V(`$ZodULID`,(e,t)=>{t.pattern??=Bg,K.init(e,t)}),U_=V(`$ZodXID`,(e,t)=>{t.pattern??=Vg,K.init(e,t)}),W_=V(`$ZodKSUID`,(e,t)=>{t.pattern??=Hg,K.init(e,t)}),G_=V(`$ZodISODateTime`,(e,t)=>{t.pattern??=c_(t),K.init(e,t)}),K_=V(`$ZodISODate`,(e,t)=>{t.pattern??=a_,K.init(e,t)}),q_=V(`$ZodISOTime`,(e,t)=>{t.pattern??=s_(t),K.init(e,t)}),J_=V(`$ZodISODuration`,(e,t)=>{t.pattern??=Wg,K.init(e,t)}),Y_=V(`$ZodIPv4`,(e,t)=>{t.pattern??=Xg,K.init(e,t),e._zod.bag.format=`ipv4`}),X_=V(`$ZodIPv6`,(e,t)=>{t.pattern??=Zg,K.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Z_=V(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Qg,K.init(e,t)}),Q_=V(`$ZodCIDRv6`,(e,t)=>{t.pattern??=$g,K.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function $_(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var ev=V(`$ZodBase64`,(e,t)=>{t.pattern??=e_,K.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{$_(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function tv(e){if(!t_.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return $_(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var nv=V(`$ZodBase64URL`,(e,t)=>{t.pattern??=t_,K.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{tv(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),rv=V(`$ZodE164`,(e,t)=>{t.pattern??=r_,K.init(e,t)});function iv(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var av=V(`$ZodJWT`,(e,t)=>{K.init(e,t),e._zod.check=n=>{iv(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ov=V(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=e._zod.bag.pattern??d_,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),sv=V(`$ZodNumberFormat`,(e,t)=>{y_.init(e,t),ov.init(e,t)}),cv=V(`$ZodBoolean`,(e,t)=>{G.init(e,t),e._zod.pattern=f_,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),lv=V(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),uv=V(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function dv(e,t,n){e.issues.length&&t.issues.push(...mg(n,e.issues)),t.value[n]=e.value}var fv=V(`$ZodArray`,(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>dv(t,n,e))):dv(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function pv(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...mg(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function mv(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=rg(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function hv(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>pv(e,n,i,t,u,d))):pv(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var gv=V(`$ZodObject`,(e,t)=>{if(G.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=Bh(()=>mv(t));H(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Xh,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>pv(n,t,e,s,r,i))):pv(a,t,e,s,r,i)}return i?hv(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),_v=V(`$ZodObjectJIT`,(e,t)=>{gv.init(e,t);let n=e._zod.parse,r=Bh(()=>mv(t)),i=e=>{let t=new j_([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=qh(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=qh(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
35
35
|
if (${n}.issues.length) {
|
|
36
36
|
if (${o} in input) {
|
|
37
37
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
@@ -90,29 +90,29 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Xh,s=!Ih.jitless,c=s&&Zh.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?hv([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function vv(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=>!fg(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=>gg(e,r,Lh())))}),t)}var yv=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=>Hh(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>vv(t,r,e,i)):vv(o,r,e,i)}}),bv=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])=>Sv(e,t,n)):Sv(e,i,a)}});function xv(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Qh(e)&&Qh(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=xv(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=xv(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 Sv(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}),fg(e))return e;let o=xv(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Cv=B(`$ZodEnum`,(e,t)=>{W.init(e,t);let n=Rh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>eg.has(typeof e)).map(e=>typeof e==`string`?tg(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}}),wv=B(`$ZodTransform`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fh(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.fallback=!0,n));if(i instanceof Promise)throw new Ph;return n.value=i,n.fallback=!0,n}});function Tv(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ev=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(`^(${Hh(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Tv(e,r)):Tv(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Dv=B(`$ZodExactOptional`,(e,t)=>{Ev.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)}),Ov=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(`^(${Hh(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)}),kv=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=>Av(e,t)):Av(r,t)}});function Av(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var jv=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))}),Mv=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=>Nv(t,e)):Nv(i,e)}});function Nv(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 Pv=B(`$ZodCatch`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,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=>gg(e,n,Lh()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>gg(e,n,Lh()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Fv=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=>Iv(e,t.in,n)):Iv(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Iv(e,t.out,n)):Iv(r,t.out,n)}});function Iv(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Lv=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(Rv):Rv(r)}});function Rv(e){return e.value=Object.freeze(e.value),e}var zv=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=>Bv(t,n,r,e));Bv(i,n,r,e)}});function Bv(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(vg(e))}}var Vv,Hv=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 Uv(){return new Hv}(Vv=globalThis).__zod_globalRegistry??(Vv.__zod_globalRegistry=Uv());var Wv=globalThis.__zod_globalRegistry;function Gv(e,t){return new e({type:`string`,...H(t)})}function Kv(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...H(t)})}function qv(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...H(t)})}function Jv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...H(t)})}function Yv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...H(t)})}function Xv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...H(t)})}function Zv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...H(t)})}function Qv(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function $v(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...H(t)})}function ey(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...H(t)})}function ty(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...H(t)})}function ny(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...H(t)})}function ry(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...H(t)})}function iy(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...H(t)})}function ay(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...H(t)})}function oy(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...H(t)})}function sy(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...H(t)})}function cy(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...H(t)})}function ly(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...H(t)})}function uy(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...H(t)})}function dy(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...H(t)})}function fy(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...H(t)})}function py(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...H(t)})}function my(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function hy(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...H(t)})}function gy(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...H(t)})}function _y(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...H(t)})}function vy(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function yy(e,t){return new e({type:`boolean`,...H(t)})}function by(e){return new e({type:`unknown`})}function xy(e,t){return new e({type:`never`,...H(t)})}function Sy(e,t){return new g_({check:`less_than`,...H(t),value:e,inclusive:!1})}function Cy(e,t){return new g_({check:`less_than`,...H(t),value:e,inclusive:!0})}function wy(e,t){return new __({check:`greater_than`,...H(t),value:e,inclusive:!1})}function Ty(e,t){return new __({check:`greater_than`,...H(t),value:e,inclusive:!0})}function Ey(e,t){return new v_({check:`multiple_of`,...H(t),value:e})}function Dy(e,t){return new b_({check:`max_length`,...H(t),maximum:e})}function Oy(e,t){return new x_({check:`min_length`,...H(t),minimum:e})}function ky(e,t){return new S_({check:`length_equals`,...H(t),length:e})}function Ay(e,t){return new w_({check:`string_format`,format:`regex`,...H(t),pattern:e})}function jy(e){return new T_({check:`string_format`,format:`lowercase`,...H(e)})}function My(e){return new E_({check:`string_format`,format:`uppercase`,...H(e)})}function Ny(e,t){return new D_({check:`string_format`,format:`includes`,...H(t),includes:e})}function Py(e,t){return new O_({check:`string_format`,format:`starts_with`,...H(t),prefix:e})}function Fy(e,t){return new k_({check:`string_format`,format:`ends_with`,...H(t),suffix:e})}function Iy(e){return new A_({check:`overwrite`,tx:e})}function Ly(e){return Iy(t=>t.normalize(e))}function Ry(){return Iy(e=>e.trim())}function zy(){return Iy(e=>e.toLowerCase())}function By(){return Iy(e=>e.toUpperCase())}function Vy(){return Iy(e=>Jh(e))}function Hy(e,t,n){return new e({type:`array`,element:t,...H(n)})}function Uy(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...H(n)})}function Wy(e,t){let n=Gy(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(vg(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(vg(r))}},e(t.value,t)),t);return n}function Gy(e,t){let n=new U({check:`custom`,...H(t)});return n._zod.check=e,n}function Ky(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??Wv,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`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function qy(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>
|
|
93
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Xh,s=!Ih.jitless,c=s&&Zh.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?hv([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function vv(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=>!fg(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=>gg(e,r,Lh())))}),t)}var yv=V(`$ZodUnion`,(e,t)=>{G.init(e,t),H(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),H(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),H(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),H(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=>Hh(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>vv(t,r,e,i)):vv(o,r,e,i)}}),bv=V(`$ZodIntersection`,(e,t)=>{G.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])=>Sv(e,t,n)):Sv(e,i,a)}});function xv(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Qh(e)&&Qh(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=xv(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=xv(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 Sv(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}),fg(e))return e;let o=xv(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Cv=V(`$ZodEnum`,(e,t)=>{G.init(e,t);let n=Rh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>eg.has(typeof e)).map(e=>typeof e==`string`?tg(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}}),wv=V(`$ZodTransform`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fh(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.fallback=!0,n));if(i instanceof Promise)throw new Ph;return n.value=i,n.fallback=!0,n}});function Tv(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ev=V(`$ZodOptional`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,H(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),H(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Hh(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Tv(e,r)):Tv(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Dv=V(`$ZodExactOptional`,(e,t)=>{Ev.init(e,t),H(e._zod,`values`,()=>t.innerType._zod.values),H(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ov=V(`$ZodNullable`,(e,t)=>{G.init(e,t),H(e._zod,`optin`,()=>t.innerType._zod.optin),H(e._zod,`optout`,()=>t.innerType._zod.optout),H(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Hh(e.source)}|null)$`):void 0}),H(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)}),kv=V(`$ZodDefault`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,H(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=>Av(e,t)):Av(r,t)}});function Av(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var jv=V(`$ZodPrefault`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,H(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))}),Mv=V(`$ZodNonOptional`,(e,t)=>{G.init(e,t),H(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=>Nv(t,e)):Nv(i,e)}});function Nv(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 Pv=V(`$ZodCatch`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,H(e._zod,`optout`,()=>t.innerType._zod.optout),H(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=>gg(e,n,Lh()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>gg(e,n,Lh()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Fv=V(`$ZodPipe`,(e,t)=>{G.init(e,t),H(e._zod,`values`,()=>t.in._zod.values),H(e._zod,`optin`,()=>t.in._zod.optin),H(e._zod,`optout`,()=>t.out._zod.optout),H(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=>Iv(e,t.in,n)):Iv(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Iv(e,t.out,n)):Iv(r,t.out,n)}});function Iv(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Lv=V(`$ZodReadonly`,(e,t)=>{G.init(e,t),H(e._zod,`propValues`,()=>t.innerType._zod.propValues),H(e._zod,`values`,()=>t.innerType._zod.values),H(e._zod,`optin`,()=>t.innerType?._zod?.optin),H(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(Rv):Rv(r)}});function Rv(e){return e.value=Object.freeze(e.value),e}var zv=V(`$ZodCustom`,(e,t)=>{W.init(e,t),G.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=>Bv(t,n,r,e));Bv(i,n,r,e)}});function Bv(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(vg(e))}}var Vv,Hv=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 Uv(){return new Hv}(Vv=globalThis).__zod_globalRegistry??(Vv.__zod_globalRegistry=Uv());var Wv=globalThis.__zod_globalRegistry;function Gv(e,t){return new e({type:`string`,...U(t)})}function Kv(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...U(t)})}function qv(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...U(t)})}function Jv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...U(t)})}function Yv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...U(t)})}function Xv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...U(t)})}function Zv(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...U(t)})}function Qv(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...U(t)})}function $v(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...U(t)})}function ey(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...U(t)})}function ty(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...U(t)})}function ny(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...U(t)})}function ry(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...U(t)})}function iy(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...U(t)})}function ay(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...U(t)})}function oy(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...U(t)})}function sy(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...U(t)})}function cy(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...U(t)})}function ly(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...U(t)})}function uy(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...U(t)})}function dy(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...U(t)})}function fy(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...U(t)})}function py(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...U(t)})}function my(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...U(t)})}function hy(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...U(t)})}function gy(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...U(t)})}function _y(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...U(t)})}function vy(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...U(t)})}function yy(e,t){return new e({type:`boolean`,...U(t)})}function by(e){return new e({type:`unknown`})}function xy(e,t){return new e({type:`never`,...U(t)})}function Sy(e,t){return new g_({check:`less_than`,...U(t),value:e,inclusive:!1})}function Cy(e,t){return new g_({check:`less_than`,...U(t),value:e,inclusive:!0})}function wy(e,t){return new __({check:`greater_than`,...U(t),value:e,inclusive:!1})}function Ty(e,t){return new __({check:`greater_than`,...U(t),value:e,inclusive:!0})}function Ey(e,t){return new v_({check:`multiple_of`,...U(t),value:e})}function Dy(e,t){return new b_({check:`max_length`,...U(t),maximum:e})}function Oy(e,t){return new x_({check:`min_length`,...U(t),minimum:e})}function ky(e,t){return new S_({check:`length_equals`,...U(t),length:e})}function Ay(e,t){return new w_({check:`string_format`,format:`regex`,...U(t),pattern:e})}function jy(e){return new T_({check:`string_format`,format:`lowercase`,...U(e)})}function My(e){return new E_({check:`string_format`,format:`uppercase`,...U(e)})}function Ny(e,t){return new D_({check:`string_format`,format:`includes`,...U(t),includes:e})}function Py(e,t){return new O_({check:`string_format`,format:`starts_with`,...U(t),prefix:e})}function Fy(e,t){return new k_({check:`string_format`,format:`ends_with`,...U(t),suffix:e})}function Iy(e){return new A_({check:`overwrite`,tx:e})}function Ly(e){return Iy(t=>t.normalize(e))}function Ry(){return Iy(e=>e.trim())}function zy(){return Iy(e=>e.toLowerCase())}function By(){return Iy(e=>e.toUpperCase())}function Vy(){return Iy(e=>Jh(e))}function Hy(e,t,n){return new e({type:`array`,element:t,...U(n)})}function Uy(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...U(n)})}function Wy(e,t){let n=Gy(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(vg(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(vg(r))}},e(t.value,t)),t);return n}function Gy(e,t){let n=new W({check:`custom`,...U(t)});return n._zod.check=e,n}function Ky(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??Wv,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 q(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,q(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`&&J(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function qy(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>
|
|
94
94
|
|
|
95
|
-
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 Jy(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.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Xy(t,`input`,e.processors),output:Xy(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 e._zod.traits.has(`$ZodCodec`)?!0: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 Yy=(e,t={})=>n=>{let r=Ky({...n,processors:t});return K(e,r),qy(r,e),Jy(r,e)},Xy=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ky({...i??{},target:a,io:t,processors:n});return K(e,o),qy(o,e),Jy(o,e)},Zy={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Qy=(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=Zy[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}))])}},$y=(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`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},eb=(e,t,n,r)=>{n.type=`boolean`},tb=(e,t,n,r)=>{n.not={}},nb=(e,t,n,r)=>{let i=e._zod.def,a=Rh(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},rb=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ib=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ab=(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`]})},ob=(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)},sb=(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},cb=(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]]},lb=(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`}]},ub=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},db=(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))},fb=(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)))},pb=(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},mb=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;K(o,t,r);let s=t.seen.get(e);s.ref=o},hb=(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},gb=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_b=B(`ZodISODateTime`,(e,t)=>{G_.init(e,t),Y.init(e,t)});function vb(e){return my(_b,e)}var yb=B(`ZodISODate`,(e,t)=>{K_.init(e,t),Y.init(e,t)});function bb(e){return hy(yb,e)}var xb=B(`ZodISOTime`,(e,t)=>{q_.init(e,t),Y.init(e,t)});function Sb(e){return gy(xb,e)}var Cb=B(`ZodISODuration`,(e,t)=>{J_.init(e,t),Y.init(e,t)});function wb(e){return _y(Cb,e)}var Tb=B(`ZodError`,(e,t)=>{bg.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Cg(e,t)},flatten:{value:t=>Sg(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,zh,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,zh,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Eb=wg(Tb),Db=Tg(Tb),Ob=Eg(Tb),kb=Og(Tb),Ab=Ag(Tb),jb=jg(Tb),Mb=Mg(Tb),Nb=Ng(Tb),Pb=Pg(Tb),Fb=Fg(Tb),Ib=Ig(Tb),Lb=Lg(Tb),Rb=new WeakMap;function zb(e,t,n){let r=Object.getPrototypeOf(e),i=Rb.get(r);if(i||(i=new Set,Rb.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var J=B(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Xy(e,`input`),output:Xy(e,`output`)}}),e.toJSONSchema=Yy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Eb(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ob(e,t,n),e.parseAsync=async(t,n)=>Db(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>kb(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ab(e,t,n),e.decode=(t,n)=>jb(e,t,n),e.encodeAsync=async(t,n)=>Mb(e,t,n),e.decodeAsync=async(t,n)=>Nb(e,t,n),e.safeEncode=(t,n)=>Pb(e,t,n),e.safeDecode=(t,n)=>Fb(e,t,n),e.safeEncodeAsync=async(t,n)=>Ib(e,t,n),e.safeDecodeAsync=async(t,n)=>Lb(e,t,n),zb(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Kh(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ng(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Jx(e,t))},superRefine(e,t){return this.check(Yx(e,t))},overwrite(e){return this.check(Iy(e))},optional(){return Ax(this)},exactOptional(){return Mx(this)},nullable(){return Px(this)},nullish(){return Ax(Px(this))},nonoptional(e){return Bx(this,e)},array(){return vx(this)},or(e){return Sx([this,e])},and(e){return wx(this,e)},transform(e){return Wx(this,Ox(e))},default(e){return Ix(this,e)},prefault(e){return Rx(this,e)},catch(e){return Hx(this,e)},pipe(e){return Wx(this,e)},readonly(){return Kx(this)},describe(e){let t=this.clone();return Wv.add(t,{description:e}),t},meta(...e){if(e.length===0)return Wv.get(this);let t=this.clone();return Wv.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return Wv.get(e)?.description},configurable:!0}),e)),Bb=B(`_ZodString`,(e,t)=>{N_.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qy(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,zb(e,`_ZodString`,{regex(...e){return this.check(Ay(...e))},includes(...e){return this.check(Ny(...e))},startsWith(...e){return this.check(Py(...e))},endsWith(...e){return this.check(Fy(...e))},min(...e){return this.check(Oy(...e))},max(...e){return this.check(Dy(...e))},length(...e){return this.check(ky(...e))},nonempty(...e){return this.check(Oy(1,...e))},lowercase(e){return this.check(jy(e))},uppercase(e){return this.check(My(e))},trim(){return this.check(Ry())},normalize(...e){return this.check(Ly(...e))},toLowerCase(){return this.check(zy())},toUpperCase(){return this.check(By())},slugify(){return this.check(Vy())}})}),Vb=B(`ZodString`,(e,t)=>{N_.init(e,t),Bb.init(e,t),e.email=t=>e.check(Kv(Ub,t)),e.url=t=>e.check(Qv(Kb,t)),e.jwt=t=>e.check(py(sx,t)),e.emoji=t=>e.check($v(qb,t)),e.guid=t=>e.check(qv(Wb,t)),e.uuid=t=>e.check(Jv(Gb,t)),e.uuidv4=t=>e.check(Yv(Gb,t)),e.uuidv6=t=>e.check(Xv(Gb,t)),e.uuidv7=t=>e.check(Zv(Gb,t)),e.nanoid=t=>e.check(ey(Jb,t)),e.guid=t=>e.check(qv(Wb,t)),e.cuid=t=>e.check(ty(Yb,t)),e.cuid2=t=>e.check(ny(Xb,t)),e.ulid=t=>e.check(ry(Zb,t)),e.base64=t=>e.check(uy(ix,t)),e.base64url=t=>e.check(dy(ax,t)),e.xid=t=>e.check(iy(Qb,t)),e.ksuid=t=>e.check(ay($b,t)),e.ipv4=t=>e.check(oy(ex,t)),e.ipv6=t=>e.check(sy(tx,t)),e.cidrv4=t=>e.check(cy(nx,t)),e.cidrv6=t=>e.check(ly(rx,t)),e.e164=t=>e.check(fy(ox,t)),e.datetime=t=>e.check(vb(t)),e.date=t=>e.check(bb(t)),e.time=t=>e.check(Sb(t)),e.duration=t=>e.check(wb(t))});function Hb(e){return Gv(Vb,e)}var Y=B(`ZodStringFormat`,(e,t)=>{G.init(e,t),Bb.init(e,t)}),Ub=B(`ZodEmail`,(e,t)=>{I_.init(e,t),Y.init(e,t)}),Wb=B(`ZodGUID`,(e,t)=>{P_.init(e,t),Y.init(e,t)}),Gb=B(`ZodUUID`,(e,t)=>{F_.init(e,t),Y.init(e,t)}),Kb=B(`ZodURL`,(e,t)=>{L_.init(e,t),Y.init(e,t)}),qb=B(`ZodEmoji`,(e,t)=>{R_.init(e,t),Y.init(e,t)}),Jb=B(`ZodNanoID`,(e,t)=>{z_.init(e,t),Y.init(e,t)}),Yb=B(`ZodCUID`,(e,t)=>{B_.init(e,t),Y.init(e,t)}),Xb=B(`ZodCUID2`,(e,t)=>{V_.init(e,t),Y.init(e,t)}),Zb=B(`ZodULID`,(e,t)=>{H_.init(e,t),Y.init(e,t)}),Qb=B(`ZodXID`,(e,t)=>{U_.init(e,t),Y.init(e,t)}),$b=B(`ZodKSUID`,(e,t)=>{W_.init(e,t),Y.init(e,t)}),ex=B(`ZodIPv4`,(e,t)=>{Y_.init(e,t),Y.init(e,t)}),tx=B(`ZodIPv6`,(e,t)=>{X_.init(e,t),Y.init(e,t)}),nx=B(`ZodCIDRv4`,(e,t)=>{Z_.init(e,t),Y.init(e,t)}),rx=B(`ZodCIDRv6`,(e,t)=>{Q_.init(e,t),Y.init(e,t)}),ix=B(`ZodBase64`,(e,t)=>{ev.init(e,t),Y.init(e,t)}),ax=B(`ZodBase64URL`,(e,t)=>{nv.init(e,t),Y.init(e,t)}),ox=B(`ZodE164`,(e,t)=>{rv.init(e,t),Y.init(e,t)}),sx=B(`ZodJWT`,(e,t)=>{av.init(e,t),Y.init(e,t)}),cx=B(`ZodNumber`,(e,t)=>{ov.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$y(e,t,n,r),zb(e,`ZodNumber`,{gt(e,t){return this.check(wy(e,t))},gte(e,t){return this.check(Ty(e,t))},min(e,t){return this.check(Ty(e,t))},lt(e,t){return this.check(Sy(e,t))},lte(e,t){return this.check(Cy(e,t))},max(e,t){return this.check(Cy(e,t))},int(e){return this.check(ux(e))},safe(e){return this.check(ux(e))},positive(e){return this.check(wy(0,e))},nonnegative(e){return this.check(Ty(0,e))},negative(e){return this.check(Sy(0,e))},nonpositive(e){return this.check(Cy(0,e))},multipleOf(e,t){return this.check(Ey(e,t))},step(e,t){return this.check(Ey(e,t))},finite(){return this}});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}),lx=B(`ZodNumberFormat`,(e,t)=>{sv.init(e,t),cx.init(e,t)});function ux(e){return vy(lx,e)}var dx=B(`ZodBoolean`,(e,t)=>{cv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eb(e,t,n,r)});function fx(e){return yy(dx,e)}var px=B(`ZodUnknown`,(e,t)=>{lv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mx(){return by(px)}var hx=B(`ZodNever`,(e,t)=>{uv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tb(e,t,n,r)});function gx(e){return xy(hx,e)}var _x=B(`ZodArray`,(e,t)=>{fv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ab(e,t,n,r),e.element=t.element,zb(e,`ZodArray`,{min(e,t){return this.check(Oy(e,t))},nonempty(e){return this.check(Oy(1,e))},max(e,t){return this.check(Dy(e,t))},length(e,t){return this.check(ky(e,t))},unwrap(){return this.element}})});function vx(e,t){return Hy(_x,e,t)}var yx=B(`ZodObject`,(e,t)=>{_v.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ob(e,t,n,r),V(e,`shape`,()=>t.shape),zb(e,`ZodObject`,{keyof(){return Ex(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mx()})},loose(){return this.clone({...this._zod.def,catchall:mx()})},strict(){return this.clone({...this._zod.def,catchall:gx()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return sg(this,e)},safeExtend(e){return cg(this,e)},merge(e){return lg(this,e)},pick(e){return ag(this,e)},omit(e){return og(this,e)},partial(...e){return ug(kx,this,e[0])},required(...e){return dg(zx,this,e[0])}})});function bx(e,t){return new yx({type:`object`,shape:e??{},...H(t)})}var xx=B(`ZodUnion`,(e,t)=>{yv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sb(e,t,n,r),e.options=t.options});function Sx(e,t){return new xx({type:`union`,options:e,...H(t)})}var Cx=B(`ZodIntersection`,(e,t)=>{bv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cb(e,t,n,r)});function wx(e,t){return new Cx({type:`intersection`,left:e,right:t})}var Tx=B(`ZodEnum`,(e,t)=>{Cv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nb(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 Tx({...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 Tx({...t,checks:[],...H(r),entries:i})}});function Ex(e,t){return new Tx({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var Dx=B(`ZodTransform`,(e,t)=>{wv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ib(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fh(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(vg(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(vg(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ox(e){return new Dx({type:`transform`,transform:e})}var kx=B(`ZodOptional`,(e,t)=>{Ev.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ax(e){return new kx({type:`optional`,innerType:e})}var jx=B(`ZodExactOptional`,(e,t)=>{Dv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mx(e){return new jx({type:`optional`,innerType:e})}var Nx=B(`ZodNullable`,(e,t)=>{Ov.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Px(e){return new Nx({type:`nullable`,innerType:e})}var Fx=B(`ZodDefault`,(e,t)=>{kv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>db(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ix(e,t){return new Fx({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():$h(t)}})}var Lx=B(`ZodPrefault`,(e,t)=>{jv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rx(e,t){return new Lx({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():$h(t)}})}var zx=B(`ZodNonOptional`,(e,t)=>{Mv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ub(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bx(e,t){return new zx({type:`nonoptional`,innerType:e,...H(t)})}var Vx=B(`ZodCatch`,(e,t)=>{Pv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hx(e,t){return new Vx({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ux=B(`ZodPipe`,(e,t)=>{Fv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mb(e,t,n,r),e.in=t.in,e.out=t.out});function Wx(e,t){return new Ux({type:`pipe`,in:e,out:t})}var Gx=B(`ZodReadonly`,(e,t)=>{Lv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kx(e){return new Gx({type:`readonly`,innerType:e})}var qx=B(`ZodCustom`,(e,t)=>{zv.init(e,t),J.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rb(e,t,n,r)});function Jx(e,t={}){return Uy(qx,e,t)}function Yx(e,t){return Wy(e,t)}var Xx=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}({}),Zx=l.z.enum(Xx),Qx=function(e){return e[e.none=0]=`none`,e[e.read=1]=`read`,e[e.write=2]=`write`,e}({}),$x=l.z.enum(Qx),eS=l.z.object({read:k.nullishToEmpty(l.z.uint32(),l.z.string()),write:k.nullishToEmpty(l.z.uint32(),l.z.string())}),tS=l.z.object({length:y.int8,mass:y.int8,time:y.int8,current:y.int8,temperature:y.int8,angle:y.int8,count:y.int8,data:y.int8}),nS=l.z.object({dimensions:tS,scale:l.z.number(),name:l.z.string()}),rS=l.z.object({get inputs(){return aS.optional()},get outputs(){return aS.optional()},get config(){return aS.optional()}}).extend({kind:Zx,name:l.z.string(),get elem(){return rS.optional()},unit:nS.optional(),get constraint(){return rS.optional()},chanDirection:$x.optional()}),iS=l.z.object({name:l.z.string(),type:rS,value:l.z.unknown().optional()}),aS=_.nullishToEmpty(iS),oS=o({EdgeKind:()=>sS,Liveness:()=>dS,ScopeMode:()=>lS,authoritiesZ:()=>gS,bodyZ:()=>mS,edgeKindZ:()=>cS,edgeZ:()=>_S,edgesZ:()=>xS,functionZ:()=>yS,functionsZ:()=>SS,handleZ:()=>pS,irZ:()=>TS,livenessZ:()=>fS,memberZ:()=>CS,membersZ:()=>ES,nodeZ:()=>hS,nodesZ:()=>bS,scopeModeZ:()=>uS,scopeZ:()=>wS,transitionZ:()=>vS}),sS=function(e){return e[e.unspecified=0]=`unspecified`,e[e.continuous=1]=`continuous`,e[e.conditional=2]=`conditional`,e}({}),cS=l.z.enum(sS),lS=function(e){return e[e.unspecified=0]=`unspecified`,e[e.parallel=1]=`parallel`,e[e.sequential=2]=`sequential`,e}({}),uS=l.z.enum(lS),dS=function(e){return e[e.unspecified=0]=`unspecified`,e[e.always=1]=`always`,e[e.gated=2]=`gated`,e}({}),fS=l.z.enum(dS),pS=l.z.object({node:l.z.string(),param:l.z.string()}),mS=l.z.object({raw:l.z.string()}),hS=l.z.object({key:l.z.string(),type:l.z.string(),config:aS,inputs:aS,outputs:aS,channels:eS}),gS=l.z.object({default:y.uint8.optional(),channels:k.nullishToEmpty(l.z.uint32(),y.uint8)}),_S=l.z.object({source:pS,target:pS,kind:cS}),vS=l.z.object({on:pS,targetKey:l.z.string().optional()}),yS=l.z.object({key:l.z.string(),body:mS.optional(),config:aS,inputs:aS,outputs:aS,channels:eS}),bS=_.nullishToEmpty(hS),xS=_.nullishToEmpty(_S),SS=_.nullishToEmpty(yS),CS=l.z.object({nodeKey:l.z.string().optional(),get scope(){return wS.optional()}}),wS=l.z.object({key:l.z.string(),mode:uS,liveness:fS,activation:pS.optional(),get strata(){return _.nullishToEmpty(ES)},get steps(){return ES},transitions:_.nullishToEmpty(vS)}),TS=l.z.object({functions:SS,nodes:bS,edges:xS,authorities:gS,root:wS}),ES=_.nullishToEmpty(CS),DS=o({graphZ:()=>jS,nodeZ:()=>OS,nodesZ:()=>AS,viewportZ:()=>kS}),OS=l.z.object({key:l.z.string(),type:l.z.string(),config:k.nullishToEmpty(),position:Gt.xyZ}),kS=l.z.object({position:Gt.xyZ,zoom:l.z.number()}),AS=_.nullishToEmpty(OS),jS=l.z.object({viewport:kS,functions:SS,edges:xS,nodes:AS}),MS=o({outputZ:()=>NS}),NS=l.z.object({wasm:l.z.instanceof(Uint8Array),outputMemoryBases:k.nullishToEmpty(l.z.string(),l.z.uint32())}),PS=TS.extend(NS.shape),FS=o({textZ:()=>IS}),IS=l.z.object({raw:l.z.string()}),LS=[`text`,`graph`],RS=l.z.enum(LS),zS=l.z.object({running:l.z.boolean()}),BS=l.z.uuid(),VS=Es.statusZ({details:zS}),HS=l.z.object({key:BS.optional(),name:l.z.string(),mode:RS,graph:jS,text:IS}),US=l.z.object({key:BS,name:l.z.string(),mode:RS,graph:jS,text:IS,program:PS.optional(),status:VS.optional()}),WS=R(`arc`),GS=WS(``),KS=(e,t,{convertNumericStrings:n=!0}={})=>{let r=!Array.isArray(e),i=_.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 ff(`${e} not found matching ${JSON.stringify(t)}`);if(n.length>1)throw new pf(`Expected one ${e} matching ${JSON.stringify(t)}, but found ${n.length}`)}},qS=`sy_arc_set`,JS=`sy_arc_delete`,YS=bx({keys:BS.array().optional(),names:Hb().array().optional(),searchTerm:Hb().optional(),limit:ux().optional(),offset:ux().optional(),includeStatus:fx().optional()}),XS=bx({arcs:HS.array()}),ZS=bx({keys:BS.array()}),QS=bx({arcs:_.nullishToEmpty(US)}),$S=bx({arcs:US.array()}),eC=bx({}),tC=bx({content:Hb()}),nC=Sx([bx({key:BS,includeStatus:fx().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),bx({name:Hb(),includeStatus:fx().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t}))]),rC=Sx([nC,YS]),iC=class{client;streamClient;constructor(e,t){this.client=e,this.streamClient=t}async create(e){let t=Array.isArray(e),n=await this.client.send(`/arc/create`,{arcs:_.toArray(e)},XS,$S);return t?n.arcs:n.arcs[0]}async retrieve(e){let t=`key`in e||`name`in e,n=await this.client.send(`/arc/retrieve`,e,rC,QS);return X(`Arc`,e,n.arcs,t),t?n.arcs[0]:n.arcs}async delete(e){await this.client.send(`/arc/delete`,{keys:_.toArray(e)},ZS,eC)}async openLSP(){return await this.streamClient.stream(`/arc/lsp`,tC,tC)}},aC=o({moduleZ:()=>oC}),oC=TS.extend(NS.shape),sC=o({Client:()=>iC,DELETE_CHANNEL_NAME:()=>JS,MODES:()=>LS,SET_CHANNEL_NAME:()=>qS,TYPE_ONTOLOGY_ID:()=>GS,arcZ:()=>US,compiler:()=>MS,graph:()=>DS,ir:()=>oS,keyZ:()=>BS,lspMessageZ:()=>tC,modeZ:()=>RS,module:()=>aC,newZ:()=>HS,ontologyID:()=>WS,singleRetrieveArgsZ:()=>nC,statusDetailsZ:()=>zS,statusZ:()=>VS,text:()=>FS}),cC=Error(`request for lock canceled`),lC=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())})},uC=class{constructor(e,t=cC){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=fC(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return lC(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]=[]),dC(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 dC(e,t){let n=fC(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function fC(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var pC=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())})},mC=class{constructor(e){this._semaphore=new uC(1,e)}acquire(){return pC(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()}},hC=y.uint12,Z=l.z.uint32().or(l.z.string().refine(e=>!isNaN(Number(e))).transform(Number)),gC=y.uint20,_C=[`min`,`max`,`avg`,`none`,`derivative`],vC=l.z.enum(_C),yC=l.z.object({type:vC,resetChannel:Z.default(0),duration:ra.timeSpanZ.default(x.ZERO)}),bC=l.z.string().min(1,`Name is required`),xC=Es.statusZ(),SC=l.z.object({key:Z,name:bC,leaseholder:hC,dataType:ra.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:y.nullToUndefined(yC.array()),concurrency:O.concurrencyZ.default(O.Concurrency.exclusive).optional(),status:xC.optional()}),CC=SC.omit({leaseholder:!0}).partial({key:!0,index:!0,isIndex:!0,internal:!0,virtual:!0,expression:!0}).extend({leaseholder:y.uint12.optional()}),wC=R(`channel`),TC=wC(0),Q=l.z.uuid(),EC=l.z.object({key:Q,name:l.z.string().min(1),timeRange:ra.timeRangeZ,color:so.colorZ.optional()}),DC=EC.extend({labels:y.nullToUndefined(To.labelZ.array()),get parent(){return DC.optional()}}),OC=EC.omit({timeRange:!0}).extend({labels:y.nullToUndefined(To.labelZ.array()),get parent(){return OC.optional()},timeRange:ra.timeRangeBoundedZ}),kC=OC.omit({parent:!0,labels:!0}).partial({key:!0}),AC=R(`range`),jC=AC(``),MC=l.z.object({nodeKey:y.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:w.z.array().optional(),notDataTypes:w.z.array().optional(),virtual:l.z.boolean().optional(),isIndex:l.z.boolean().optional(),internal:l.z.boolean().optional(),legacyCalculated:l.z.boolean().optional()}),NC=l.z.object({channels:_.nullishToEmpty(SC)}),PC=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]),KS(e,{number:`keys`,string:`names`})),FC=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=PC(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 this.client.send(`/channel/retrieve`,e,MC,NC)).channels}},IC=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}=PC(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}=PC(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}},LC=class{mu=new mC;requests=new Map;wrapped;debouncedRun;constructor(e,t){this.wrapped=e,this.debouncedRun=wo(()=>{this.run()},t)}async retrieve(e){if(!Array.isArray(e)&&typeof e==`object`)return await this.wrapped.retrieve(e);let{normalized:t,variant:n}=PC(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()}})}},RC=async(e,t)=>{let{normalized:n}=PC(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 df(`Could not find channels: ${JSON.stringify(i)}`);return r},zC=l.z.uuid(),BC=l.z.object({key:zC,name:l.z.string()}),VC=R(`group`),HC=VC(``),UC=`sy_group_set`,WC=`sy_group_delete`,GC=l.default.object({group:BC}),KC=l.default.object({parent:L,key:zC.optional(),name:l.default.string()}),qC=l.default.object({key:zC,name:l.default.string()}),JC=l.default.object({keys:l.default.array(zC)}),YC=class{client;constructor(e){this.client=e}async create(e){return(await this.client.send(`/ontology/create-group`,e,KC,GC)).group}async rename(e,t){await this.client.send(`/ontology/rename-group`,{key:e,name:t},qC,l.default.object({}))}async delete(e){await this.client.send(`/ontology/delete-group`,{keys:_.toArray(e)},JC,l.default.object({}))}},XC=o({Client:()=>YC,DELETE_CHANNEL_NAME:()=>WC,SET_CHANNEL_NAME:()=>UC,TYPE_ONTOLOGY_ID:()=>HC,groupZ:()=>BC,keyZ:()=>zC,ontologyID:()=>VC}),ZC=`sy_channel_set`,QC=`sy_channel_delete`,$C=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 w(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=Es.create(u)),this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new I(`cannot read from a channel that has not been created`);return this._frameClient}get payload(){return SC.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 rw(this.payload)}get ontologyID(){return wC(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)}},ew=l.z.object({}),tw=l.z.object({group:BC}),nw=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=_.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}=PC(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(_.toArray(e),_.toArray(t))}createDebouncedBatchRetriever(e=x.milliseconds(10)){return new IC(new LC(new FC(this.client),e))}sugar(e){let{frameClient:t}=this;return Array.isArray(e)?e.map(e=>new $C({...e,frameClient:t})):new $C({...e,frameClient:t})}async retrieveGroup(){return(await this.client.send(`/channel/retrieve-group`,{},ew,tw)).group}},rw=({virtual:e,expression:t})=>e&&t!==``,iw=l.z.union([y.toArray(Z),y.toArray(bC),y.toArray(SC).transform(e=>e.map(e=>e.key))]),aw=/[a-zA-Z0-9_]/,ow=/^[a-zA-Z_][a-zA-Z0-9_]*$/,sw=(e,t=!1)=>{if(e===``)return t?`_`:``;if(e.match(ow))return e;let n=``;for(let t of e)t.match(aw)?n+=t:n+=`_`;return n[0].match(/^\d/)&&(n=`_${n}`),n},cw=e=>wf(wC(e)),lw=l.z.object({channels:CC.array()}),uw=l.z.object({channels:SC.array()}),dw=l.z.object({keys:Z.array().optional(),names:bC.array().optional()}),fw=l.z.object({}),pw=l.z.object({keys:Z.array(),names:bC.array()}),mw=l.z.object({}),hw=class{client;cache;constructor(e,t){this.client=e,this.cache=t}async create(e){let{channels:t}=await this.client.send(`/channel/create`,{channels:e.map(e=>({...e,dataType:e.dataType}))},lw,uw);return this.cache.set(t),t}async delete(e){let t=Z.array().parse(e.keys??[]);await this.client.send(`/channel/delete`,e,dw,fw),t.length>0&&this.cache.delete(t),e.names!=null&&this.cache.delete(e.names)}async rename(e,t){await this.client.send(`/channel/rename`,{keys:e,names:t},pw,mw),this.cache.rename(e,t)}},gw=o({CacheRetriever:()=>IC,Channel:()=>$C,Client:()=>nw,ClusterRetriever:()=>FC,DELETE_CHANNEL_NAME:()=>QC,DebouncedBatchRetriever:()=>LC,OPERATION_TYPES:()=>_C,SET_CHANNEL_NAME:()=>ZC,TYPE_ONTOLOGY_ID:()=>TC,Writer:()=>hw,analyzeParams:()=>PC,escapeInvalidName:()=>sw,isCalculated:()=>rw,keyZ:()=>Z,localKeyZ:()=>gC,nameZ:()=>bC,newZ:()=>CC,ontologyID:()=>wC,operationTypeZ:()=>vC,operationZ:()=>yC,paramsZ:()=>iw,payloadZ:()=>SC,retrieveRequired:()=>RC,statusKey:()=>cw,statusZ:()=>xC}),_w=l.z.object({username:l.z.string(),password:l.z.string()}),vw=l.z.object({clusterKey:l.z.string(),nodeVersion:l.z.string().optional(),nodeKey:l.z.number().optional(),nodeTime:b.z}),yw=l.z.object({token:l.z.string(),user:_p,clusterInfo:vw.optional()}),bw=`/auth/login`,xw=3,Sw=l.z.object({username:l.z.string(),password:l.z.string(),newPassword:l.z.string().min(1)}),Cw=l.z.object({}),ww=[cf,lf],Tw=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 this.client.send(`/auth/change-password`,{username:this.credentials.username,password:this.credentials.password,newPassword:e},Sw,Cw),this.credentials.password=e}middleware(){let e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(bw)){this.authenticating??=(async()=>{try{let e=await this.client.send(bw,this.credentials,_w,yw);return this.authState={authenticated:!0,user:e.user,token:e.token},null}catch(e){return e instanceof Error?e:Error(String(e))}})();let e=await this.authenticating;if(e!=null)throw e}t.params.Authorization=`Bearer ${this.token}`;try{let e=await n(t);return this.retryCount=0,e}catch(r){if(ww.some(e=>e.matches(r))&&this.retryCount<xw)return this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,e(t,n);throw this.retryCount=0,r}};return e}},Ew=o({Checker:()=>Nw,stateZ:()=>Ow,statusZ:()=>Dw}),Dw=l.z.enum([`disconnected`,`connecting`,`connected`,`failed`]),Ow=l.z.object({status:Dw,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(),clockSkew:x.z.default(x.ZERO),clockSkewExceeded:l.z.boolean().default(!1)}),kw=l.z.object({clusterKey:l.z.string(),nodeVersion:l.z.string().optional(),nodeTime:b.z}),Aw=l.z.void(),jw={clusterKey:``,status:`disconnected`,error:void 0,message:`Disconnected`,clientServerCompatible:!1,clientVersion:`0.56.0`,clockSkew:x.ZERO,clockSkewExceeded:!1},Mw=(e,t,n)=>{let r=n?`Core`:`client`;return`The Synnax Core version ${e==null?``:`${e} `}is too ${n?`old`:`new`} for client version ${t}.
|
|
95
|
+
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 Jy(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.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Xy(t,`input`,e.processors),output:Xy(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function J(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 J(r.element,n);if(r.type===`set`)return J(r.valueType,n);if(r.type===`lazy`)return J(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 J(r.innerType,n);if(r.type===`intersection`)return J(r.left,n)||J(r.right,n);if(r.type===`record`||r.type===`map`)return J(r.keyType,n)||J(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:J(r.in,n)||J(r.out,n);if(r.type===`object`){for(let e in r.shape)if(J(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(J(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(J(e,n))return!0;return!!(r.rest&&J(r.rest,n))}return!1}var Yy=(e,t={})=>n=>{let r=Ky({...n,processors:t});return q(e,r),qy(r,e),Jy(r,e)},Xy=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ky({...i??{},target:a,io:t,processors:n});return q(e,o),qy(o,e),Jy(o,e)},Zy={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Qy=(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=Zy[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}))])}},$y=(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`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},eb=(e,t,n,r)=>{n.type=`boolean`},tb=(e,t,n,r)=>{n.not={}},nb=(e,t,n,r)=>{let i=e._zod.def,a=Rh(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},rb=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ib=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ab=(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=q(a.element,t,{...r,path:[...r.path,`items`]})},ob=(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]=q(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=q(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},sb=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>q(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},cb=(e,t,n,r)=>{let i=e._zod.def,a=q(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=q(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]]},lb=(e,t,n,r)=>{let i=e._zod.def,a=q(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`}]},ub=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},db=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},fb=(e,t,n,r)=>{let i=e._zod.def;q(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)))},pb=(e,t,n,r)=>{let i=e._zod.def;q(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},mb=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;q(o,t,r);let s=t.seen.get(e);s.ref=o},hb=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},gb=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_b=V(`ZodISODateTime`,(e,t)=>{G_.init(e,t),X.init(e,t)});function vb(e){return my(_b,e)}var yb=V(`ZodISODate`,(e,t)=>{K_.init(e,t),X.init(e,t)});function bb(e){return hy(yb,e)}var xb=V(`ZodISOTime`,(e,t)=>{q_.init(e,t),X.init(e,t)});function Sb(e){return gy(xb,e)}var Cb=V(`ZodISODuration`,(e,t)=>{J_.init(e,t),X.init(e,t)});function wb(e){return _y(Cb,e)}var Tb=V(`ZodError`,(e,t)=>{bg.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Cg(e,t)},flatten:{value:t=>Sg(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,zh,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,zh,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Eb=wg(Tb),Db=Tg(Tb),Ob=Eg(Tb),kb=Og(Tb),Ab=Ag(Tb),jb=jg(Tb),Mb=Mg(Tb),Nb=Ng(Tb),Pb=Pg(Tb),Fb=Fg(Tb),Ib=Ig(Tb),Lb=Lg(Tb),Rb=new WeakMap;function zb(e,t,n){let r=Object.getPrototypeOf(e),i=Rb.get(r);if(i||(i=new Set,Rb.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=V(`ZodType`,(e,t)=>(G.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Xy(e,`input`),output:Xy(e,`output`)}}),e.toJSONSchema=Yy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Eb(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ob(e,t,n),e.parseAsync=async(t,n)=>Db(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>kb(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ab(e,t,n),e.decode=(t,n)=>jb(e,t,n),e.encodeAsync=async(t,n)=>Mb(e,t,n),e.decodeAsync=async(t,n)=>Nb(e,t,n),e.safeEncode=(t,n)=>Pb(e,t,n),e.safeDecode=(t,n)=>Fb(e,t,n),e.safeEncodeAsync=async(t,n)=>Ib(e,t,n),e.safeDecodeAsync=async(t,n)=>Lb(e,t,n),zb(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Kh(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ng(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Jx(e,t))},superRefine(e,t){return this.check(Yx(e,t))},overwrite(e){return this.check(Iy(e))},optional(){return Ax(this)},exactOptional(){return Mx(this)},nullable(){return Px(this)},nullish(){return Ax(Px(this))},nonoptional(e){return Bx(this,e)},array(){return vx(this)},or(e){return Sx([this,e])},and(e){return wx(this,e)},transform(e){return Wx(this,Ox(e))},default(e){return Ix(this,e)},prefault(e){return Rx(this,e)},catch(e){return Hx(this,e)},pipe(e){return Wx(this,e)},readonly(){return Kx(this)},describe(e){let t=this.clone();return Wv.add(t,{description:e}),t},meta(...e){if(e.length===0)return Wv.get(this);let t=this.clone();return Wv.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return Wv.get(e)?.description},configurable:!0}),e)),Bb=V(`_ZodString`,(e,t)=>{N_.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qy(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,zb(e,`_ZodString`,{regex(...e){return this.check(Ay(...e))},includes(...e){return this.check(Ny(...e))},startsWith(...e){return this.check(Py(...e))},endsWith(...e){return this.check(Fy(...e))},min(...e){return this.check(Oy(...e))},max(...e){return this.check(Dy(...e))},length(...e){return this.check(ky(...e))},nonempty(...e){return this.check(Oy(1,...e))},lowercase(e){return this.check(jy(e))},uppercase(e){return this.check(My(e))},trim(){return this.check(Ry())},normalize(...e){return this.check(Ly(...e))},toLowerCase(){return this.check(zy())},toUpperCase(){return this.check(By())},slugify(){return this.check(Vy())}})}),Vb=V(`ZodString`,(e,t)=>{N_.init(e,t),Bb.init(e,t),e.email=t=>e.check(Kv(Ub,t)),e.url=t=>e.check(Qv(Kb,t)),e.jwt=t=>e.check(py(sx,t)),e.emoji=t=>e.check($v(qb,t)),e.guid=t=>e.check(qv(Wb,t)),e.uuid=t=>e.check(Jv(Gb,t)),e.uuidv4=t=>e.check(Yv(Gb,t)),e.uuidv6=t=>e.check(Xv(Gb,t)),e.uuidv7=t=>e.check(Zv(Gb,t)),e.nanoid=t=>e.check(ey(Jb,t)),e.guid=t=>e.check(qv(Wb,t)),e.cuid=t=>e.check(ty(Yb,t)),e.cuid2=t=>e.check(ny(Xb,t)),e.ulid=t=>e.check(ry(Zb,t)),e.base64=t=>e.check(uy(ix,t)),e.base64url=t=>e.check(dy(ax,t)),e.xid=t=>e.check(iy(Qb,t)),e.ksuid=t=>e.check(ay($b,t)),e.ipv4=t=>e.check(oy(ex,t)),e.ipv6=t=>e.check(sy(tx,t)),e.cidrv4=t=>e.check(cy(nx,t)),e.cidrv6=t=>e.check(ly(rx,t)),e.e164=t=>e.check(fy(ox,t)),e.datetime=t=>e.check(vb(t)),e.date=t=>e.check(bb(t)),e.time=t=>e.check(Sb(t)),e.duration=t=>e.check(wb(t))});function Hb(e){return Gv(Vb,e)}var X=V(`ZodStringFormat`,(e,t)=>{K.init(e,t),Bb.init(e,t)}),Ub=V(`ZodEmail`,(e,t)=>{I_.init(e,t),X.init(e,t)}),Wb=V(`ZodGUID`,(e,t)=>{P_.init(e,t),X.init(e,t)}),Gb=V(`ZodUUID`,(e,t)=>{F_.init(e,t),X.init(e,t)}),Kb=V(`ZodURL`,(e,t)=>{L_.init(e,t),X.init(e,t)}),qb=V(`ZodEmoji`,(e,t)=>{R_.init(e,t),X.init(e,t)}),Jb=V(`ZodNanoID`,(e,t)=>{z_.init(e,t),X.init(e,t)}),Yb=V(`ZodCUID`,(e,t)=>{B_.init(e,t),X.init(e,t)}),Xb=V(`ZodCUID2`,(e,t)=>{V_.init(e,t),X.init(e,t)}),Zb=V(`ZodULID`,(e,t)=>{H_.init(e,t),X.init(e,t)}),Qb=V(`ZodXID`,(e,t)=>{U_.init(e,t),X.init(e,t)}),$b=V(`ZodKSUID`,(e,t)=>{W_.init(e,t),X.init(e,t)}),ex=V(`ZodIPv4`,(e,t)=>{Y_.init(e,t),X.init(e,t)}),tx=V(`ZodIPv6`,(e,t)=>{X_.init(e,t),X.init(e,t)}),nx=V(`ZodCIDRv4`,(e,t)=>{Z_.init(e,t),X.init(e,t)}),rx=V(`ZodCIDRv6`,(e,t)=>{Q_.init(e,t),X.init(e,t)}),ix=V(`ZodBase64`,(e,t)=>{ev.init(e,t),X.init(e,t)}),ax=V(`ZodBase64URL`,(e,t)=>{nv.init(e,t),X.init(e,t)}),ox=V(`ZodE164`,(e,t)=>{rv.init(e,t),X.init(e,t)}),sx=V(`ZodJWT`,(e,t)=>{av.init(e,t),X.init(e,t)}),cx=V(`ZodNumber`,(e,t)=>{ov.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$y(e,t,n,r),zb(e,`ZodNumber`,{gt(e,t){return this.check(wy(e,t))},gte(e,t){return this.check(Ty(e,t))},min(e,t){return this.check(Ty(e,t))},lt(e,t){return this.check(Sy(e,t))},lte(e,t){return this.check(Cy(e,t))},max(e,t){return this.check(Cy(e,t))},int(e){return this.check(ux(e))},safe(e){return this.check(ux(e))},positive(e){return this.check(wy(0,e))},nonnegative(e){return this.check(Ty(0,e))},negative(e){return this.check(Sy(0,e))},nonpositive(e){return this.check(Cy(0,e))},multipleOf(e,t){return this.check(Ey(e,t))},step(e,t){return this.check(Ey(e,t))},finite(){return this}});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}),lx=V(`ZodNumberFormat`,(e,t)=>{sv.init(e,t),cx.init(e,t)});function ux(e){return vy(lx,e)}var dx=V(`ZodBoolean`,(e,t)=>{cv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eb(e,t,n,r)});function fx(e){return yy(dx,e)}var px=V(`ZodUnknown`,(e,t)=>{lv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mx(){return by(px)}var hx=V(`ZodNever`,(e,t)=>{uv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tb(e,t,n,r)});function gx(e){return xy(hx,e)}var _x=V(`ZodArray`,(e,t)=>{fv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ab(e,t,n,r),e.element=t.element,zb(e,`ZodArray`,{min(e,t){return this.check(Oy(e,t))},nonempty(e){return this.check(Oy(1,e))},max(e,t){return this.check(Dy(e,t))},length(e,t){return this.check(ky(e,t))},unwrap(){return this.element}})});function vx(e,t){return Hy(_x,e,t)}var yx=V(`ZodObject`,(e,t)=>{_v.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ob(e,t,n,r),H(e,`shape`,()=>t.shape),zb(e,`ZodObject`,{keyof(){return Ex(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mx()})},loose(){return this.clone({...this._zod.def,catchall:mx()})},strict(){return this.clone({...this._zod.def,catchall:gx()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return sg(this,e)},safeExtend(e){return cg(this,e)},merge(e){return lg(this,e)},pick(e){return ag(this,e)},omit(e){return og(this,e)},partial(...e){return ug(kx,this,e[0])},required(...e){return dg(zx,this,e[0])}})});function bx(e,t){return new yx({type:`object`,shape:e??{},...U(t)})}var xx=V(`ZodUnion`,(e,t)=>{yv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sb(e,t,n,r),e.options=t.options});function Sx(e,t){return new xx({type:`union`,options:e,...U(t)})}var Cx=V(`ZodIntersection`,(e,t)=>{bv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cb(e,t,n,r)});function wx(e,t){return new Cx({type:`intersection`,left:e,right:t})}var Tx=V(`ZodEnum`,(e,t)=>{Cv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nb(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 Tx({...t,checks:[],...U(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 Tx({...t,checks:[],...U(r),entries:i})}});function Ex(e,t){return new Tx({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...U(t)})}var Dx=V(`ZodTransform`,(e,t)=>{wv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ib(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fh(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(vg(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(vg(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Ox(e){return new Dx({type:`transform`,transform:e})}var kx=V(`ZodOptional`,(e,t)=>{Ev.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ax(e){return new kx({type:`optional`,innerType:e})}var jx=V(`ZodExactOptional`,(e,t)=>{Dv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mx(e){return new jx({type:`optional`,innerType:e})}var Nx=V(`ZodNullable`,(e,t)=>{Ov.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Px(e){return new Nx({type:`nullable`,innerType:e})}var Fx=V(`ZodDefault`,(e,t)=>{kv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>db(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ix(e,t){return new Fx({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():$h(t)}})}var Lx=V(`ZodPrefault`,(e,t)=>{jv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rx(e,t){return new Lx({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():$h(t)}})}var zx=V(`ZodNonOptional`,(e,t)=>{Mv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ub(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bx(e,t){return new zx({type:`nonoptional`,innerType:e,...U(t)})}var Vx=V(`ZodCatch`,(e,t)=>{Pv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hx(e,t){return new Vx({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ux=V(`ZodPipe`,(e,t)=>{Fv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mb(e,t,n,r),e.in=t.in,e.out=t.out});function Wx(e,t){return new Ux({type:`pipe`,in:e,out:t})}var Gx=V(`ZodReadonly`,(e,t)=>{Lv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hb(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kx(e){return new Gx({type:`readonly`,innerType:e})}var qx=V(`ZodCustom`,(e,t)=>{zv.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rb(e,t,n,r)});function Jx(e,t={}){return Uy(qx,e,t)}function Yx(e,t){return Wy(e,t)}var Xx=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}({}),Zx=l.z.enum(Xx),Qx=function(e){return e[e.none=0]=`none`,e[e.read=1]=`read`,e[e.write=2]=`write`,e}({}),$x=l.z.enum(Qx),eS=l.z.object({read:A.nullishToEmpty(l.z.uint32(),l.z.string()),write:A.nullishToEmpty(l.z.uint32(),l.z.string())}),tS=l.z.object({length:b.int8,mass:b.int8,time:b.int8,current:b.int8,temperature:b.int8,angle:b.int8,count:b.int8,data:b.int8}),nS=l.z.object({dimensions:tS,scale:l.z.number(),name:l.z.string()}),rS=l.z.object({get inputs(){return aS.optional()},get outputs(){return aS.optional()},get config(){return aS.optional()}}).extend({kind:Zx,name:l.z.string(),get elem(){return rS.optional()},unit:nS.optional(),get constraint(){return rS.optional()},chanDirection:$x.optional()}),iS=l.z.object({name:l.z.string(),type:rS,value:l.z.unknown().optional()}),aS=_.nullishToEmpty(iS),oS=o({EdgeKind:()=>sS,Liveness:()=>dS,ScopeMode:()=>lS,authoritiesZ:()=>gS,bodyZ:()=>mS,edgeKindZ:()=>cS,edgeZ:()=>_S,edgesZ:()=>xS,functionZ:()=>yS,functionsZ:()=>SS,handleZ:()=>pS,irZ:()=>TS,livenessZ:()=>fS,memberZ:()=>CS,membersZ:()=>ES,nodeZ:()=>hS,nodesZ:()=>bS,scopeModeZ:()=>uS,scopeZ:()=>wS,transitionZ:()=>vS}),sS=function(e){return e[e.unspecified=0]=`unspecified`,e[e.continuous=1]=`continuous`,e[e.conditional=2]=`conditional`,e}({}),cS=l.z.enum(sS),lS=function(e){return e[e.unspecified=0]=`unspecified`,e[e.parallel=1]=`parallel`,e[e.sequential=2]=`sequential`,e}({}),uS=l.z.enum(lS),dS=function(e){return e[e.unspecified=0]=`unspecified`,e[e.always=1]=`always`,e[e.gated=2]=`gated`,e}({}),fS=l.z.enum(dS),pS=l.z.object({node:l.z.string(),param:l.z.string()}),mS=l.z.object({raw:l.z.string()}),hS=l.z.object({key:l.z.string(),type:l.z.string(),config:aS,inputs:aS,outputs:aS,channels:eS}),gS=l.z.object({default:b.uint8.optional(),channels:A.nullishToEmpty(l.z.uint32(),b.uint8)}),_S=l.z.object({source:pS,target:pS,kind:cS}),vS=l.z.object({on:pS,targetKey:l.z.string().optional()}),yS=l.z.object({key:l.z.string(),body:mS.optional(),config:aS,inputs:aS,outputs:aS,channels:eS}),bS=_.nullishToEmpty(hS),xS=_.nullishToEmpty(_S),SS=_.nullishToEmpty(yS),CS=l.z.object({nodeKey:l.z.string().optional(),get scope(){return wS.optional()}}),wS=l.z.object({key:l.z.string(),mode:uS,liveness:fS,activation:pS.optional(),get strata(){return _.nullishToEmpty(ES)},get steps(){return ES},transitions:_.nullishToEmpty(vS)}),TS=l.z.object({functions:SS,nodes:bS,edges:xS,authorities:gS,root:wS}),ES=_.nullishToEmpty(CS),DS=o({graphZ:()=>jS,nodeZ:()=>OS,nodesZ:()=>AS,viewportZ:()=>kS}),OS=l.z.object({key:l.z.string(),type:l.z.string(),config:A.nullishToEmpty(),position:Gt.xyZ}),kS=l.z.object({position:Gt.xyZ,zoom:l.z.number()}),AS=_.nullishToEmpty(OS),jS=l.z.object({viewport:kS,functions:SS,edges:xS,nodes:AS}),MS=o({outputZ:()=>NS}),NS=l.z.object({wasm:l.z.instanceof(Uint8Array),outputMemoryBases:A.nullishToEmpty(l.z.string(),l.z.uint32())}),PS=TS.extend(NS.shape),FS=o({textZ:()=>IS}),IS=l.z.object({raw:l.z.string()}),LS=[`text`,`graph`],RS=l.z.enum(LS),zS=l.z.object({running:l.z.boolean()}),BS=l.z.uuid(),VS=Ts.statusZ({details:zS}),HS=l.z.object({key:BS.optional(),name:l.z.string(),mode:RS,graph:jS,text:IS}),US=l.z.object({key:BS,name:l.z.string(),mode:RS,graph:jS,text:IS,program:PS.optional(),status:VS.optional()}),WS=z(`arc`),GS=WS(``),KS=(e,t,{convertNumericStrings:n=!0}={})=>{let r=!Array.isArray(e),i=_.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}},Z=(e,t,n,r)=>{if(r){if(n.length===0)throw new ff(`${e} not found matching ${JSON.stringify(t)}`);if(n.length>1)throw new pf(`Expected one ${e} matching ${JSON.stringify(t)}, but found ${n.length}`)}},qS=`sy_arc_set`,JS=`sy_arc_delete`,YS=bx({keys:BS.array().optional(),names:Hb().array().optional(),searchTerm:Hb().optional(),limit:ux().optional(),offset:ux().optional(),includeStatus:fx().optional()}),XS=bx({arcs:HS.array()}),ZS=bx({keys:BS.array()}),QS=bx({arcs:_.nullishToEmpty(US)}),$S=bx({arcs:US.array()}),eC=bx({}),tC=bx({content:Hb()}),nC=Sx([bx({key:BS,includeStatus:fx().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),bx({name:Hb(),includeStatus:fx().optional()}).transform(({name:e,includeStatus:t})=>({names:[e],includeStatus:t}))]),rC=Sx([nC,YS]),iC=class{client;streamClient;constructor(e,t){this.client=e,this.streamClient=t}async create(e){let t=Array.isArray(e),n=await this.client.send(`/arc/create`,{arcs:_.toArray(e)},XS,$S);return t?n.arcs:n.arcs[0]}async retrieve(e){let t=`key`in e||`name`in e,n=await this.client.send(`/arc/retrieve`,e,rC,QS);return Z(`Arc`,e,n.arcs,t),t?n.arcs[0]:n.arcs}async delete(e){await this.client.send(`/arc/delete`,{keys:_.toArray(e)},ZS,eC)}async openLSP(){return await this.streamClient.stream(`/arc/lsp`,tC,tC)}},aC=o({moduleZ:()=>oC}),oC=TS.extend(NS.shape),sC=o({Client:()=>iC,DELETE_CHANNEL_NAME:()=>JS,MODES:()=>LS,SET_CHANNEL_NAME:()=>qS,TYPE_ONTOLOGY_ID:()=>GS,arcZ:()=>US,compiler:()=>MS,graph:()=>DS,ir:()=>oS,keyZ:()=>BS,lspMessageZ:()=>tC,modeZ:()=>RS,module:()=>aC,newZ:()=>HS,ontologyID:()=>WS,singleRetrieveArgsZ:()=>nC,statusDetailsZ:()=>zS,statusZ:()=>VS,text:()=>FS}),cC=Error(`request for lock canceled`),lC=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())})},uC=class{constructor(e,t=cC){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=fC(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return lC(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]=[]),dC(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 dC(e,t){let n=fC(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function fC(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var pC=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())})},mC=class{constructor(e){this._semaphore=new uC(1,e)}acquire(){return pC(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()}},hC=b.uint12,Q=l.z.uint32().or(l.z.string().refine(e=>!isNaN(Number(e))).transform(Number)),gC=b.uint20,_C=[`min`,`max`,`avg`,`none`,`derivative`],vC=l.z.enum(_C),yC=l.z.object({type:vC,resetChannel:Q.default(0),duration:ra.timeSpanZ.default(S.ZERO)}),bC=l.z.string().min(1,`Name is required`),xC=Ts.statusZ(),SC=l.z.object({key:Q,name:bC,leaseholder:hC,dataType:ra.dataTypeZ,isIndex:l.z.boolean(),index:Q,alias:l.z.string().optional(),virtual:l.z.boolean().default(!1),internal:l.z.boolean().default(!1),expression:l.z.string().default(``),operations:b.nullToUndefined(yC.array()),concurrency:k.concurrencyZ.default(k.Concurrency.exclusive).optional(),status:xC.optional()}),CC=SC.omit({leaseholder:!0}).partial({key:!0,index:!0,isIndex:!0,internal:!0,virtual:!0,expression:!0}).extend({leaseholder:b.uint12.optional()}),wC=z(`channel`),TC=wC(0),$=l.z.uuid(),EC=l.z.object({key:$,name:l.z.string().min(1),timeRange:ra.timeRangeZ,color:so.colorZ.optional()}),DC=EC.extend({labels:b.nullToUndefined(To.labelZ.array()),get parent(){return DC.optional()}}),OC=EC.omit({timeRange:!0}).extend({labels:b.nullToUndefined(To.labelZ.array()),get parent(){return OC.optional()},timeRange:ra.timeRangeBoundedZ}),kC=OC.omit({parent:!0,labels:!0}).partial({key:!0}),AC=z(`range`),jC=AC(``),MC=l.z.object({nodeKey:b.uint12.optional(),keys:Q.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),rangeKey:$.optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),dataTypes:T.z.array().optional(),notDataTypes:T.z.array().optional(),virtual:l.z.boolean().optional(),isIndex:l.z.boolean().optional(),internal:l.z.boolean().optional(),legacyCalculated:l.z.boolean().optional()}),NC=l.z.object({channels:_.nullishToEmpty(SC)}),PC=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]),KS(e,{number:`keys`,string:`names`})),FC=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=PC(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 this.client.send(`/channel/retrieve`,e,MC,NC)).channels}},IC=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}=PC(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}=PC(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}},LC=class{mu=new mC;requests=new Map;wrapped;debouncedRun;constructor(e,t){this.wrapped=e,this.debouncedRun=wo(()=>{this.run()},t)}async retrieve(e){if(!Array.isArray(e)&&typeof e==`object`)return await this.wrapped.retrieve(e);let{normalized:t,variant:n}=PC(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()}})}},RC=async(e,t)=>{let{normalized:n}=PC(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 df(`Could not find channels: ${JSON.stringify(i)}`);return r},zC=l.z.uuid(),BC=l.z.object({key:zC,name:l.z.string()}),VC=z(`group`),HC=VC(``),UC=`sy_group_set`,WC=`sy_group_delete`,GC=l.default.object({group:BC}),KC=l.default.object({parent:R,key:zC.optional(),name:l.default.string()}),qC=l.default.object({key:zC,name:l.default.string()}),JC=l.default.object({keys:l.default.array(zC)}),YC=class{client;constructor(e){this.client=e}async create(e){return(await this.client.send(`/ontology/create-group`,e,KC,GC)).group}async rename(e,t){await this.client.send(`/ontology/rename-group`,{key:e,name:t},qC,l.default.object({}))}async delete(e){await this.client.send(`/ontology/delete-group`,{keys:_.toArray(e)},JC,l.default.object({}))}},XC=o({Client:()=>YC,DELETE_CHANNEL_NAME:()=>WC,SET_CHANNEL_NAME:()=>UC,TYPE_ONTOLOGY_ID:()=>HC,groupZ:()=>BC,keyZ:()=>zC,ontologyID:()=>VC}),ZC=`sy_channel_set`,QC=`sy_channel_delete`,$C=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=Q.parse(r),this.name=t,this.dataType=new T(e),this.leaseholder=n,this.index=Q.parse(a),this.isIndex=i,this.internal=o,this.alias=l,this.virtual=s,this.expression=d,this.operations=f,u!=null&&(this.status=Ts.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 SC.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 rw(this.payload)}get ontologyID(){return wC(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)}},ew=l.z.object({}),tw=l.z.object({group:BC}),nw=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=_.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 Z(`channel`,e,r,n),n?r[0]:r}async delete(e){let{normalized:t,variant:n}=PC(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(_.toArray(e),_.toArray(t))}createDebouncedBatchRetriever(e=S.milliseconds(10)){return new IC(new LC(new FC(this.client),e))}sugar(e){let{frameClient:t}=this;return Array.isArray(e)?e.map(e=>new $C({...e,frameClient:t})):new $C({...e,frameClient:t})}async retrieveGroup(){return(await this.client.send(`/channel/retrieve-group`,{},ew,tw)).group}},rw=({virtual:e,expression:t})=>e&&t!==``,iw=l.z.union([b.toArray(Q),b.toArray(bC),b.toArray(SC).transform(e=>e.map(e=>e.key))]),aw=/[a-zA-Z0-9_]/,ow=/^[a-zA-Z_][a-zA-Z0-9_]*$/,sw=(e,t=!1)=>{if(e===``)return t?`_`:``;if(e.match(ow))return e;let n=``;for(let t of e)t.match(aw)?n+=t:n+=`_`;return n[0].match(/^\d/)&&(n=`_${n}`),n},cw=e=>wf(wC(e)),lw=l.z.object({channels:CC.array()}),uw=l.z.object({channels:SC.array()}),dw=l.z.object({keys:Q.array().optional(),names:bC.array().optional()}),fw=l.z.object({}),pw=l.z.object({keys:Q.array(),names:bC.array()}),mw=l.z.object({}),hw=class{client;cache;constructor(e,t){this.client=e,this.cache=t}async create(e){let{channels:t}=await this.client.send(`/channel/create`,{channels:e.map(e=>({...e,dataType:e.dataType}))},lw,uw);return this.cache.set(t),t}async delete(e){let t=Q.array().parse(e.keys??[]);await this.client.send(`/channel/delete`,e,dw,fw),t.length>0&&this.cache.delete(t),e.names!=null&&this.cache.delete(e.names)}async rename(e,t){await this.client.send(`/channel/rename`,{keys:e,names:t},pw,mw),this.cache.rename(e,t)}},gw=o({CacheRetriever:()=>IC,Channel:()=>$C,Client:()=>nw,ClusterRetriever:()=>FC,DELETE_CHANNEL_NAME:()=>QC,DebouncedBatchRetriever:()=>LC,OPERATION_TYPES:()=>_C,SET_CHANNEL_NAME:()=>ZC,TYPE_ONTOLOGY_ID:()=>TC,Writer:()=>hw,analyzeParams:()=>PC,escapeInvalidName:()=>sw,isCalculated:()=>rw,keyZ:()=>Q,localKeyZ:()=>gC,nameZ:()=>bC,newZ:()=>CC,ontologyID:()=>wC,operationTypeZ:()=>vC,operationZ:()=>yC,paramsZ:()=>iw,payloadZ:()=>SC,retrieveRequired:()=>RC,statusKey:()=>cw,statusZ:()=>xC}),_w=l.z.object({username:l.z.string(),password:l.z.string()}),vw=l.z.object({clusterKey:l.z.string(),nodeVersion:l.z.string().optional(),nodeKey:l.z.number().optional(),nodeTime:x.z}),yw=l.z.object({token:l.z.string(),user:_p,clusterInfo:vw.optional()}),bw=`/auth/login`,xw=3,Sw=l.z.object({username:l.z.string(),password:l.z.string(),newPassword:l.z.string().min(1)}),Cw=l.z.object({}),ww=[cf,lf],Tw=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 this.client.send(`/auth/change-password`,{username:this.credentials.username,password:this.credentials.password,newPassword:e},Sw,Cw),this.credentials.password=e}middleware(){let e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(bw)){this.authenticating??=(async()=>{try{let e=await this.client.send(bw,this.credentials,_w,yw);return this.authState={authenticated:!0,user:e.user,token:e.token},null}catch(e){return v.fromUnknown(e)}})();let e=await this.authenticating;if(e!=null)throw e}t.params.Authorization=`Bearer ${this.token}`;try{let e=await n(t);return this.retryCount=0,e}catch(r){if(ww.some(e=>e.matches(r))&&this.retryCount<xw)return this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,await e(t,n);throw this.retryCount=0,v.fromUnknown(r)}};return e}},Ew=o({Checker:()=>Nw,stateZ:()=>Ow,statusZ:()=>Dw}),Dw=l.z.enum([`disconnected`,`connecting`,`connected`,`failed`]),Ow=l.z.object({status:Dw,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(),clockSkew:S.z.default(S.ZERO),clockSkewExceeded:l.z.boolean().default(!1)}),kw=l.z.object({clusterKey:l.z.string(),nodeVersion:l.z.string().optional(),nodeTime:x.z}),Aw=l.z.void(),jw={clusterKey:``,status:`disconnected`,error:void 0,message:`Disconnected`,clientServerCompatible:!1,clientVersion:`0.56.1`,clockSkew:S.ZERO,clockSkewExceeded:!1},Mw=(e,t,n)=>{let r=n?`Core`:`client`;return`The Synnax Core version ${e==null?``:`${e} `}is too ${n?`old`:`new`} for client version ${t}.
|
|
96
96
|
This may cause compatibility issues. We recommend updating the ${r}. For more information, see
|
|
97
|
-
https://docs.synnaxlabs.com/reference/client/resources/troubleshooting#old-${r.toLowerCase()}-version`},Nw=class{static DEFAULT=jw;_state;pollFrequency;client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=Ow;versionWarned=!1;skewCalc;clockSkewThreshold;checking=!1;constructor(e,t=
|
|
98
|
-
Got ${n.length} ${r}s and ${t.length} series.`)}
|
|
97
|
+
https://docs.synnaxlabs.com/reference/client/resources/troubleshooting#old-${r.toLowerCase()}-version`},Nw=class{static DEFAULT=jw;_state;pollFrequency;client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=Ow;versionWarned=!1;skewCalc;clockSkewThreshold;checking=!1;constructor(e,t=S.seconds(30),n,r,i=S.seconds(1)){this._state={...jw},this.client=e,this.pollFrequency=new S(t),this.clientVersion=n,this.name=r,this.skewCalc=new gr,this.clockSkewThreshold=new S(i).abs(),this.check(),this.start()}stop(){this.interval!=null&&clearInterval(this.interval)}async check(){let e=this._state.status,t=this._state.clockSkewExceeded,n=!this.checking;this.checking=!0;try{n&&this.skewCalc.start();let e=await this.client.send(`/connectivity/check`,void 0,Aw,kw);if(n&&(this.skewCalc.end(e.nodeTime),this._state.clockSkew=this.skewCalc.skew,this._state.clockSkewExceeded=this.skewCalc.exceeds(this.clockSkewThreshold),this._state.clockSkewExceeded)){let e=this.skewCalc.skew.valueOf()>0n?`ahead of`:`behind`;console.warn(`Measured excessive clock skew between this host and the Synnax Core. This host is ${e} the Synnax Core by approximately ${this.skewCalc.skew.abs().toString()}.`)}let t=e.nodeVersion,r=this.clientVersion,i=this.versionWarned;t==null?(this._state.clientServerCompatible=!1,i||(console.warn(Mw(null,r,!0)),this.versionWarned=!0)):ko.versionsEqual(r,t,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,i||(console.warn(Mw(t,r,ko.semVerNewer(r,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=v.fromUnknown(e),this._state.message=this.state.error?.message}finally{this.checking=!1}let r=e!==this._state.status||t!==this._state.clockSkewExceeded;return this.onChangeHandlers.length>0&&r&&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)}},Pw=l.z.object({keys:Q.array().optional(),bounds:w.z,names:bC.array().optional()}),Fw=l.z.object({}),Iw=class{client;constructor(e){this.client=e}async delete(e){await this.client.send(`/frame/delete`,e,Pw,Fw)}},Lw=e=>{let t=_.toArray(e);return t.length===0?null:typeof t[0]==`number`||!isNaN(parseInt(t[0],10))?`key`:`name`},Rw=(e,t)=>{let n=_.toArray(e);if(n.length===t.length)return;let r=Lw(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.
|
|
98
|
+
Got ${n.length} ${r}s and ${t.length} series.`)},zw=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,..._.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=>Vw(e));Rw(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,..._.toArray(t));this.push(e,..._.toArray(t))});return}if(Array.isArray(t)||[`string`,`number`].includes(typeof t)){let e=_.toArray(n),r=_.toArray(t);Rw(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
|
|
99
99
|
payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
|
|
100
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]==`string`?`name`:`key`}get keys(){if(this.colType===`name`)throw new uf(`colType is not key`);return this.columns??[]}get uniqueKeys(){return _r.unique(this.keys)}get names(){if(this.colType===`key`)throw new uf(`colType is not name`);return this.columns??[]}get uniqueNames(){return _r.unique(this.names)}get uniqueColumns(){return this.colType===`key`?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>
|
|
101
|
-
`;return this.uniqueColumns.forEach(t=>{e+=` ${t}: ${this.get(t).series.map(e=>e.toString()).join(`,`)}\n`}),e+=`}`,e}},
|
|
100
|
+
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]==`string`?`name`:`key`}get keys(){if(this.colType===`name`)throw new uf(`colType is not key`);return this.columns??[]}get uniqueKeys(){return _r.unique(this.keys)}get names(){if(this.colType===`key`)throw new uf(`colType is not name`);return this.columns??[]}get uniqueNames(){return _r.unique(this.names)}get uniqueColumns(){return this.colType===`key`?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Hw(e)),keys:[...this.keys]}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;let e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null)return this.columns.length===0?w.ZERO:new w(x.min(...this.series.map(e=>e.timeRange.start)),x.max(...this.series.map(e=>e.timeRange.end)));let t=this.get(e);return t==null?w.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Yi(this.series.filter((t,n)=>this.columns[n]===e))}push(t,...n){if(t instanceof e){if(t.colType!=null&&this.colType!==null&&t.colType!==this.colType)throw new L(`keyVariant must match`);this.series.push(...t.series),this.columns.push(...t.columns)}else{if(this.series.push(...n),typeof t==`string`&&this.colType===`key`||typeof t!=`string`&&this.colType===`name`)throw new L(`keyVariant must match`);this.columns.push(...Array.from({length:n.length},()=>t))}}concat(t){return new e([...this.columns,...t.columns],[...this.series,...t.series])}has(e){return typeof e==`string`&&this.colType===`key`||typeof e==`number`&&this.colType===`name`?!1:this.columns.includes(e)}map(t){let n=new e;return this.forEach((e,r,i)=>n.push(...t(e,r,i))),n}mapFilter(t){let n=new e;return this.forEach((e,r,i)=>{let[a,o,s]=t(e,r,i);s&&n.push(a,o)}),n}forEach(e){this.columns.forEach((t,n)=>{let r=this.series[n];e(t,r,n)})}forEachUnique(e){this.uniqueColumns.forEach((t,n)=>e(t,this.get(t),n))}at(e,t=!1){let n={};return this.uniqueColumns.forEach(r=>{n[r]=this.get(r).at(e,t)}),n}filter(t){let n=new e;return this.columns.forEach((e,r)=>{let i=this.series[r];t(e,i,r)&&n.push(e,i)}),n}get byteLength(){return new ir(this.series.reduce((e,t)=>e.add(t.byteLength),ir.ZERO))}get digest(){let e={};return this.keys.forEach((t,n)=>{let r=this.series[n].digest;t in e?e[t].push(r):e[t]=[r]}),e}get length(){return this.series.reduce((e,t)=>e+t.length,0)}toString(){let e=`Frame{
|
|
101
|
+
`;return this.uniqueColumns.forEach(t=>{e+=` ${t}: ${this.get(t).series.map(e=>e.toString()).join(`,`)}\n`}),e+=`}`,e}},Bw=l.z.object({keys:l.z.union([l.z.null().transform(()=>[]),l.z.number().array().default([])]),series:l.z.union([l.z.null().transform(()=>[]),Vi.crudeZ.array().default([])])}),Vw=e=>{let{dataType:t,data:n,timeRange:r,alignment:i}=e;return new Vi({data:n,dataType:t,timeRange:r,glBufferUsage:`static`,alignment:i})},Hw=e=>({timeRange:e.timeRange,dataType:e.dataType,data:new Uint8Array(e.data.buffer),alignment:e.alignment}),Uw=function(e){return e[e.Open=0]=`Open`,e[e.Write=1]=`Write`,e[e.Commit=2]=`Commit`,e[e.SetAuthority=3]=`SetAuthority`,e}({}),Ww=l.z.enum(Uw),Gw=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}({}),Kw=l.z.enum(Gw),qw=function(e){return e[e.None=0]=`None`,e[e.Ack=1]=`Ack`,e[e.Data=2]=`Data`,e}({}),Jw=l.z.enum(qw),Yw=e=>e.data.byteLength/e.dataType.density.valueOf(),Xw=e=>{let{keys:t,series:n}=e;t.forEach((e,t)=>{n[t].key=e}),n.sort((e,t)=>e.key-t.key),t.sort((e,t)=>e-t),n.forEach(e=>delete e.key)},Zw=5,Qw=4,$w=3,eT=2,tT=1,nT=0,rT=T.TIMESTAMP.density.valueOf(),iT=8,aT=4,oT=4,sT=4,cT=1,lT=class{contentType=fT;states=new Map;currState;seqNum=0;constructor(e=[],t=[]){(e.length>0||t.length>0)&&this.update(e,t)}update(e,t){this.seqNum++;let n={keys:e,keyDataTypes:new Map,hasVariableDataTypes:!1};e.forEach((e,r)=>{let i=t[r];n.keyDataTypes.set(e,i),i.isVariable&&(n.hasVariableDataTypes=!0)}),n.keys.sort(),this.states.set(this.seqNum,n),this.currState=n}throwIfNotUpdated(e){if(this.seqNum<1)throw new L(`
|
|
102
102
|
The codec has not been updated with a list of channels and data types.
|
|
103
103
|
Please call the update method before calling ${e}.
|
|
104
|
-
`)}encode(e,t=0){this.throwIfNotUpdated(`encode`);let n=e;typeof e==`object`&&e&&`toPayload`in e&&(n=e.toPayload()),
|
|
104
|
+
`)}encode(e,t=0){this.throwIfNotUpdated(`encode`);let n=e;typeof e==`object`&&e&&`toPayload`in e&&(n=e.toPayload()),Xw(n);let r=-1,i,a,o,s=t+cT+sT,c=!this.currState?.hasVariableDataTypes,l=!0,u=!0,d=!0,f=!0,p=!0;n.keys.length!==this.currState?.keys.length&&(d=!1,s+=n.keys.length*oT),n.series.forEach((e,t)=>{let u=Yw(e),d=n.keys[t],p=this.currState?.keyDataTypes.get(d);if(p==null)throw new L(`Channel ${d} was not provided in the list of channels when opening the writer`);if(!p.equals(e.dataType))throw new L(`Series data type of ${e.dataType.toString()} does not match the data type of ${p.toString()} for channel ${d}`);if(s+=e.data.byteLength,r===-1){r=u,i=e.timeRange?.start,a=e.timeRange?.end,o=BigInt(e.alignment??0n);return}r!==u&&(c=!1),(i?.valueOf()!==e.timeRange?.start.valueOf()||a?.valueOf()!==e.timeRange?.end.valueOf())&&(l=!1),o!==BigInt(e.alignment??0)&&(f=!1)}),u=l&&i==null&&a==null,p=f&&(o===void 0||o===0n),c?s+=aT:s+=n.keys.length*aT,u||(l?s+=rT*2:s+=n.keys.length*rT*2),p||(f?s+=iT:s+=n.keys.length*iT);let m=new Uint8Array(s),h=new DataView(m.buffer),g=t;return m[g]=Number(p)<<Zw|Number(f)<<Qw|Number(c)<<$w|Number(l)<<eT|Number(u)<<tT|Number(d)<<nT,g++,h.setUint32(g,this.seqNum,!0),g+=sT,c&&(h.setUint32(g,r,!0),g+=aT),l&&!u&&(h.setBigUint64(g,i?.valueOf()??0n,!0),g+=rT,h.setBigUint64(g,a?.valueOf()??0n,!0),g+=rT),f&&!p&&(h.setBigUint64(g,o??0n,!0),g+=iT),n.series.forEach((e,t)=>{if(d||(h.setUint32(g,n.keys[t],!0),g+=oT),!c){let t=e.data.byteLength;e.dataType.isVariable||(t=Yw(e)),h.setUint32(g,t,!0),g+=aT}m.set(new Uint8Array(e.data),g),g+=e.data.byteLength,!l&&!u&&(h.setBigUint64(g,e.timeRange?.start.valueOf()??0n,!0),g+=rT,h.setBigUint64(g,e.timeRange?.end.valueOf()??0n,!0),g+=rT),!f&&!p&&(h.setBigUint64(g,e.alignment??0n,!0),g+=iT)}),m}decode(e,t=0){this.throwIfNotUpdated(`decode`);let n=e instanceof Uint8Array?e:new Uint8Array(e),r={keys:[],series:[]},i=t,a=0,o=0,s,c,l,u=new DataView(n.buffer,n.byteOffset,n.byteLength),d=!!(n[i]>>Zw&1),f=!!(n[i]>>Qw&1),p=!!(n[i]>>$w&1),m=!!(n[i]>>eT&1),h=!!(n[i]>>tT&1),g=!!(n[i]>>nT&1);i++;let ee=u.getUint32(i,!0);i+=sT;let te=this.states.get(ee);if(te==null)return r;if(p){if(i+aT>u.byteLength)return r;a=u.getUint32(i,!0),i+=aT}if(m&&!h){if(i+rT>u.byteLength)return r;s=new x(u.getBigUint64(i,!0)),i+=rT,c=new x(u.getBigUint64(i,!0)),i+=rT}if(f&&!d){if(i+iT>u.byteLength)return r;l=u.getBigUint64(i,!0),i+=iT}let ne=e=>{let t=te.keyDataTypes.get(e);if(t==null)return!1;if(o=0,p)o=a;else{if(i+aT>u.byteLength)return!1;o=u.getUint32(i,!0),i+=aT}let g=o;if(t.isVariable||(g*=t.density.valueOf()),i+g>u.byteLength)return!1;let ee={dataType:t,data:n.slice(i,i+g).buffer};if(i+=g,!m&&!h){if(i+rT*2>u.byteLength)return!1;let e=u.getBigUint64(i,!0);i+=rT;let t=u.getBigUint64(i,!0);i+=rT,ee.timeRange=new w({start:e,end:t})}else h?ee.timeRange=new w({start:0n,end:0n}):ee.timeRange=new w({start:s?.valueOf()??0n,end:c?.valueOf()??0n});if(!f&&!d){if(i+iT>u.byteLength)return!1;l=u.getBigUint64(i,!0),i+=iT,ee.alignment=l}else d?ee.alignment=0n:ee.alignment=l;return r.series.push(ee),r.keys.push(e),!0};if(g)te.keys.forEach(e=>ne(e));else for(;i<u.byteLength&&!(i+oT>u.byteLength);){let e=u.getUint32(i,!0);if(i+=oT,!ne(e))break}return r}},uT=new Uint8Array([254]),dT=new Uint8Array([255]),fT=`application/vnd.synnax.frame`,pT=class{contentType=fT;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Gn.JSON_CODEC}encode(e){let t=e;if(t.type==`close`||t.payload?.command!=Uw.Write){let e=this.lowPerfCodec.encode(t),n=new Uint8Array({length:e.byteLength+1});return n.set(uT,0),n.set(new Uint8Array(e),1),n}let n=this.base.encode(t.payload?.frame,1);return n.set(dT,0),n}decode(e,t){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===254)return this.lowPerfCodec.decode(e.slice(1),t);let n={type:`data`},r=this.base.decode(e,1);return n.payload={command:Uw.Write,frame:r},n}},mT=class{contentType=fT;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Gn.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,t){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===254?this.lowPerfCodec.decode(e.slice(1),t):{type:`data`,payload:{frame:this.base.decode(e,1)}}}},hT=class{contentType=fT;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Gn.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,t){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===254?this.lowPerfCodec.decode(e.slice(1),t):{type:`data`,payload:{variant:qw.Data,ack:!1,command:0,frame:this.base.decode(e,1)}}}},gT=class e{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=new Set,this.codec=new lT}static async open(t,n){let r=new e(t);return await r.update(n),r}async update(e){let{variant:t,normalized:n}=PC(e),r=await this.retriever.retrieve(n),i=r.map(e=>e.key);if(Ir.uniqueUnorderedPrimitiveArrays(Array.from(this.keys),i)===Ir.EQUAL)return!1;if(this.codec.update(i,r.map(e=>e.dataType)),t===`keys`)return this.adapter=null,this.keys=new Set(n),!0;let a=new Map;return this.adapter=a,n.forEach(e=>{let t=r.find(t=>t.name===e);if(t==null)throw Error(`Channel ${e} not found`);a.set(t.key,t.name)}),this.keys=new Set(this.adapter.keys()),!0}adapt(e){if(this.adapter==null){let t=!1;return e.forEach(e=>{this.keys.has(e)||(t=!0)}),t?e.filter(e=>this.keys.has(e)):e}let t=this.adapter;return e.mapFilter((e,n)=>{if(typeof e==`number`){let r=t.get(e);return r==null?[e,n,!1]:[r,n,!0]}return[e,n,!0]})}},_T=class e{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new lT}static async open(t,n){let r=new e(t);return await r.update(n),r}async adaptParams(e){let t=iw.parse(e);return await Promise.all(t.map(async e=>await this.adaptToKey(e)))}async update(e){let t=await RC(this.retriever,e),n=t.map(e=>e.key),r=new Set(this.keys),i=new Set(n),a=!i.isSubsetOf(r),o=!r.isSubsetOf(i);return a||o?(this.adapter=new Map(t.map(e=>[e.name,e.key])),this.keys=n,this.codec.update(this.keys,t.map(e=>e.dataType)),!0):!1}async fetchChannel(e){let t=await this.retriever.retrieve(e);if(t.length===0)throw Error(`Channel ${JSON.stringify(e)} not found`);return t[0]}async adaptToKey(e){return typeof e==`number`?e:(await this.fetchChannel(e)).key}encode(e){return this.codec.encode(e.toPayload())}async adapt(e,t){if(typeof e==`string`||typeof e==`number`){if(t==null)throw new L(`
|
|
105
105
|
Received a single channel name or key but no series.
|
|
106
|
-
`);if(Array.isArray(t)&&t.some(e=>e instanceof Vi||Array.isArray(e)))throw new
|
|
106
|
+
`);if(Array.isArray(t)&&t.some(e=>e instanceof Vi||Array.isArray(e)))throw new L(`
|
|
107
107
|
Received a single channel name or key but multiple series.
|
|
108
|
-
`);let n=await this.fetchChannel(e),r=new Vi({data:t,dataType:n.dataType});return new
|
|
108
|
+
`);let n=await this.fetchChannel(e),r=new Vi({data:t,dataType:n.dataType});return new zw(n.key,r)}if(Array.isArray(e)){if(t==null)throw new L(`
|
|
109
109
|
Received an array of channel names or keys but no series.
|
|
110
|
-
`);if(!Array.isArray(t))throw new
|
|
110
|
+
`);if(!Array.isArray(t))throw new L(`
|
|
111
111
|
Received an array of channel names or keys but no array of series.
|
|
112
|
-
`);let n=[],r=[];for(let i=0;i<e.length;i++){let a=await this.fetchChannel(e[i]);if(i>=t.length)throw new
|
|
112
|
+
`);let n=[],r=[];for(let i=0;i<e.length;i++){let a=await this.fetchChannel(e[i]);if(i>=t.length)throw new L(`
|
|
113
113
|
Received an array of channel names or keys but not enough series.
|
|
114
|
-
`);let o=new Vi({data:t[i],dataType:a.dataType});n.push(a.key),r.push(o)}return new
|
|
114
|
+
`);let o=new Vi({data:t[i],dataType:a.dataType});n.push(a.key),r.push(o)}return new zw(n,r)}if(e instanceof zw||e instanceof Map){let t=new zw(e);return this.adapter==null?t:new zw(t.columns.map(e=>{let t=typeof e==`string`?this.adapter?.get(e):e;if(t==null)throw new L(`
|
|
115
115
|
Channel ${e} was not provided in the list of channels when opening the writer
|
|
116
|
-
`);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 Vi({data:a,dataType:o.dataType});n.push(o.key),r.push(s)}return new
|
|
116
|
+
`);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 Vi({data:a,dataType:o.dataType});n.push(o.key),r.push(s)}return new zw(n,r)}},vT=class{name;stream;constructor(e,t){this.stream=t,this.name=e}async receive(){return await this.stream.receive()}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){let e;try{e=await this.stream.receive()}catch(e){if(Ud.matches(e))return;throw v.fromUnknown(e)}throw new uf(`${this.name} received unexpected response ${JSON.stringify(e)} on closure.`)}}closeSend(){this.stream.closeSend()}send(e){this.stream.send(e)}},yT=new S(-1),bT=l.z.object({command:l.z.enum(Gw),span:S.z.optional(),bounds:w.z.optional(),stamp:x.z.optional(),keys:Q.array().optional(),chunkSize:l.z.number().optional(),downsampleFactor:l.z.int().optional()}),xT=l.z.object({variant:l.z.enum(qw),ack:l.z.boolean(),command:l.z.enum(Gw),error:v.payloadZ.optional().nullable(),frame:Bw.optional()}),ST=class e{stream;adapter;value;constructor(e,t){this.stream=new vT(`Iterator`,e),this.value=new zw,this.adapter=t}static async _open(t,n,r,i,a={}){let o=await gT.open(r,n);i=i.withCodec(new hT(o.codec));let s=new e(await i.stream(`/frame/iterate`,bT,xT),o);return await s.execute({command:Gw.Open,keys:Array.from(o.keys),bounds:new w(t),chunkSize:a.chunkSize??1e5,downsampleFactor:a.downsampleFactor??1}),s}async next(e=yT){return await this.execute({command:Gw.Next,span:new S(e)})}async prev(e=yT){return await this.execute({command:Gw.Prev,span:new S(e)})}async seekFirst(){return await this.execute({command:Gw.SeekFirst})}async seekLast(){return await this.execute({command:Gw.SeekLast})}async seekLE(e){return await this.execute({command:Gw.SeekLE,stamp:new x(e)})}async seekGE(e){return await this.execute({command:Gw.SeekGE,stamp:new x(e)})}async valid(){return await this.execute({command:Gw.Valid})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new CT(this)}async execute(e){for(this.stream.send(e),this.value=new zw;;){let e=await this.stream.receive();if(e.variant===qw.Ack)return e.ack;this.value.push(this.adapter.adapt(new zw(e.frame)))}}},CT=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(),v.fromUnknown(e)}}},wT=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 TT({iterator:await ST._open(n,Array.from(o),this.retriever,this.streamClient,i),channelPayloads:a,headers:r})}},TT=({iterator:e,channelPayloads:t,headers:n})=>{let r=rs.getOS()===`Windows`?`\r
|
|
117
117
|
`:`
|
|
118
|
-
`,i=new TextEncoder,a=!1,o=!1,s=TT(t),{columns:c,columnsByIndexKey:l,emptyGroupStrings:u}=ET(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=>yo.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=DT(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=>yo.formatValue(e.header)).join(`,`);t.enqueue(i.encode(`${e}${r}`)),a=!0}d.length-f+p.length<OT&&await e.next()&&m(e.value);let n=h(OT);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()}})},TT=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},ET=(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 uf(`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}},DT=(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},OT=1e3,kT=l.z.object({keys:l.z.number().array(),downsampleFactor:l.z.int(),throttleRate:rr.z.optional(),excludeGroups:l.z.uint32().array().optional()}),AT=l.z.object({frame:zw}),jT=l.z.object({channels:iw,downsampleFactor:l.z.int().default(1),throttleRate:rr.z.default(new rr(0)),excludeGroups:l.z.uint32().array().default([])}),MT=jT.or(iw.transform(e=>jT.parse({channels:e}))),NT=(e,t)=>async n=>{let r=MT.parse(n),i=await hT.open(e,r.channels);t=t.withCodec(new pT(i.codec));let a=await t.stream(`/frame/stream`,kT,AT),o=new FT(a,i,r.downsampleFactor,r.throttleRate,r.excludeGroups);return a.send({keys:Array.from(i.keys),downsampleFactor:r.downsampleFactor,throttleRate:r.throttleRate,excludeGroups:r.excludeGroups}),await a.receive(),o},PT=async(e,t,n)=>await NT(e,t)(n),FT=class{stream;adapter;downsampleFactor;throttleRate;excludeGroups;constructor(e,t,n=1,r=new rr(0),i=[]){this.stream=new _T(`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(Ud.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}},IT=class e{wrapped_=null;breaker;opener;config;constructor(e,t,n={}){this.opener=e,this.config=MT.parse(t);let{maxRetries:r=5e3,baseInterval:i=x.seconds(1),scale:a=1}=n??{};this.breaker=new aa.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=iw.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(Ud.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(Ud.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}},LT=class extends Ro.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)}},RT=function(e){return e[e.PersistStream=1]=`PersistStream`,e[e.Persist=2]=`Persist`,e[e.Stream=3]=`Stream`,e}({}),zT=new x(-1),BT=class extends af.sub(`writer_closed`){constructor(){super(`WriterClosed`)}},VT=l.z.enum(RT).or(l.z.enum([`persist`,`stream`,`persistStream`]).transform(e=>{switch(e){case`persist`:return 2;case`stream`:return 3;case`persistStream`:return 1}})),HT=l.z.object({start:b.z.optional(),controlSubject:O.subjectZ.optional(),authorities:l.z.union([O.authorityZ.transform(e=>[e]),O.authorityZ.array()]).default([O.ABSOLUTE_AUTHORITY]),mode:VT.default(1),errOnUnauthorized:l.z.boolean().default(!1),enableAutoCommit:l.z.boolean().default(!0),autoIndexPersistInterval:x.z.default(x.SECOND),autoIndex:l.z.boolean().default(!1)}),UT=HT.extend({keys:Z.array().optional()}),WT=HT.extend({channels:iw}),GT=WT.or(iw.transform(e=>WT.parse({channels:e,start:b.now()}))),KT=l.z.object({command:l.z.enum(Hw),config:UT.optional(),frame:zw.optional(),buffer:l.z.instanceof(Uint8Array).optional()}),qT=l.z.object({command:l.z.enum(Hw),end:b.z,err:je.payloadZ.optional()}),JT=l.z.tuple([l.z.union([l.z.record(Z.or(bC),O.authorityZ),Z.or(bC),O.authorityZ]),O.authorityZ.optional()]).transform(([e,t])=>{if(O.authorityZ.safeParse(e).success)return{keys:[],authorities:[e]};if(Z.or(bC).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)}}),YT=class e{stream;adapter;closeErr=null;constructor(e,t){this.stream=e,this.adapter=t}static async _open(t,n,r){let i=y.parse(GT,r),a=await gT.open(t,i.channels);n=n.withCodec(new fT(a.codec));let o=new e(await n.stream(`/frame/write`,KT,qT),a);return await o.execute({command:Hw.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);try{this.stream.send({command:Hw.Write,frame:n.toPayload()})}catch(e){if(!Ud.matches(e))throw e}}async setAuthority(e,t){if(this.closeErr!=null)throw this.closeErr;let n=JT.parse([e,t]),r={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Hw.SetAuthority,config:r})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),b.ZERO):(await this.execute({command:Hw.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(BT.matches(this.closeErr))return null;throw this.closeErr}try{let e=await this.stream.receive();this.closeErr=je.decode(e?.err)}catch(e){if(!(e instanceof Error))throw e;this.closeErr=Ud.matches(e)?new BT:e}}}async execute(e){try{this.stream.send(e)}catch(e){if(!(e instanceof Error))throw e;await this.closeInternal(e)}for(;;){let t;try{t=await this.stream.receive()}catch(e){if(!(e instanceof Error))throw e;await this.closeInternal(e);continue}let n=je.decode(t?.err);if(n!=null&&await this.closeInternal(n),t?.command==e.command)return t}}},XT=R(`framer`),ZT=XT(``),QT=class{streamClient;retriever;deleter;reader;constructor(e,t,n){this.streamClient=e,this.retriever=n,this.deleter=new Iw(t),this.reader=new CT(n,e)}async openIterator(e,t,n){return await xT._open(e,t,this.retriever,this.streamClient,n)}async openWriter(e){return await YT._open(this.retriever,this.streamClient,e)}async openStreamer(e){return await PT(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:RT.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:x.MAX});return await r.write(n),await r.close()}let r=await this.openWriter({start:e,channels:t,mode:RT.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:x.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}=PC(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}=PC(e),r=await this.readLatestNFrame(e,t);return n?r.get(e):r}async readLatestNFrame(e,t){let n=await this.openIterator(C.MAX,e,{chunkSize:t}),r=new $;if(t>0)try{await n.seekLast(),await n.prev(vT),r.push(n.value)}finally{await n.close()}return r}async delete(e,t){let{normalized:n,variant:r}=PC(e),i=new C(t);return r===`keys`?await this.deleter.delete({keys:n,bounds:i}):await this.deleter.delete({names:n,bounds:i})}},$T=o({ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:()=>zT,AUTO_SPAN:()=>vT,Client:()=>QT,Frame:()=>$,HardenedStreamer:()=>IT,Iterator:()=>xT,IteratorCommand:()=>Ww,IteratorResponseVariant:()=>Kw,ObservableStreamer:()=>LT,Reader:()=>CT,TYPE_ONTOLOGY_ID:()=>ZT,Writer:()=>YT,WriterClosedError:()=>BT,WriterCommand:()=>Hw,WriterMode:()=>RT,createStreamOpener:()=>NT,frameZ:()=>zw,iteratorCommandZ:()=>Gw,iteratorReqZ:()=>yT,iteratorResZ:()=>bT,iteratorResponseVariantZ:()=>qw,ontologyID:()=>XT,openStreamer:()=>PT,seriesFromPayload:()=>Bw,seriesToPayload:()=>Vw,streamerConfigZ:()=>MT,writerCommandZ:()=>Uw,writerConfigZ:()=>GT}),eE=O.ABSOLUTE_AUTHORITY,tE=O.ZERO_AUTHORITY,nE=O.stateZ(l.z.number()),rE=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()})`},iE=l.z.object({transfers:l.z.array(O.transferZ(Z))}),aE=class extends LT{states;codec;constructor(e){super(e,e=>{let t=Array.from(e.series[0].as(`string`)).map(e=>this.codec.decodeString(e,iE));return t.forEach(e=>this.merge(e)),[t.flatMap(e=>e.transfers),!0]}),this.states=new Map,this.codec=new Gn.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)})}},oE=`sy_node_1_control`,sE=class{framer;constructor(e){this.framer=e}async openStateTracker(){return new aE(await IT.open(async e=>await this.framer.openStreamer(e),oE))}},cE=o({ABSOLUTE_AUTHORITY:()=>eE,CONTROL_STATE_CHANNEL_NAME:()=>oE,Client:()=>sE,StateTracker:()=>aE,ZERO_AUTHORITY:()=>tE,stateZ:()=>nE,transferString:()=>rE}),lE=l.z.uint32(),uE=l.z.object({rack:lE}),dE=Es.statusZ({details:uE}),fE=l.z.object({key:lE,name:l.z.string().min(1,`Name is required`),taskCounter:l.z.uint32().optional(),embedded:l.z.boolean().optional(),status:dE.optional(),integrations:y.nullToUndefined(l.z.string().array())}),pE=fE.omit({taskCounter:!0,embedded:!0,key:!0}).extend({key:l.z.uint32().default(0)}),mE=R(`rack`),hE=mE(0),gE=`sy_rack_set`,_E=`sy_rack_delete`,vE=l.z.object({keys:lE.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()}),yE=l.z.object({racks:_.nullishToEmpty(fE)}),bE=fE,xE=l.z.union([l.z.object({key:lE,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}))]),SE=vE,CE=l.z.union([xE,SE]),wE=l.z.object({racks:pE.array()}),TE=l.z.object({racks:fE.array()}),EE=l.z.object({keys:lE.array()}),DE=l.z.object({}),OE=class{client;tasks;constructor(e,t){this.client=e,this.tasks=t}async delete(e){await this.client.send(`/rack/delete`,{keys:_.toArray(e)},EE,DE)}async create(e){let t=!Array.isArray(e),n=await this.client.send(`/rack/create`,{racks:_.toArray(e)},wE,TE),r=this.sugar(n.racks);return t?r[0]:r}async retrieve(e){let t=`key`in e||`name`in e,n=await this.client.send(`/rack/retrieve`,e,CE,yE),r=this.sugar(n.racks);return X(`Rack`,e,r,t),t?r[0]:r}sugar(e){let t=!Array.isArray(e),n=_.toArray(e).map(({key:e,name:t,status:n,integrations:r})=>new kE(e,t,this.tasks,n,r));return t?n[0]:n}},kE=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}}},AE=e=>wf(mE(e)),jE=o({Client:()=>OE,DELETE_CHANNEL_NAME:()=>_E,Rack:()=>kE,SET_CHANNEL_NAME:()=>gE,TYPE_ONTOLOGY_ID:()=>hE,keyZ:()=>lE,newZ:()=>pE,ontologyID:()=>mE,payloadZ:()=>fE,rackZ:()=>bE,statusDetailsZ:()=>uE,statusKey:()=>AE,statusZ:()=>dE}),ME=l.z.string(),NE=l.z.object({rack:lE,device:ME}),PE=Es.statusZ({details:NE}),FE=({properties:e,make:t,model:n}={})=>l.z.object({key:ME,rack:lE,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??k.nullishToEmpty(),status:PE.optional(),parent:L.optional()}),IE=({properties:e,make:t,model:n}={})=>FE({properties:e,make:t,model:n}).partial({key:!0,configured:!0}),LE=R(`device`),RE=LE(``),zE=`sy_device_set`,BE=`sy_device_delete`,VE=e=>l.z.object({devices:y.toArray(IE(e))}),HE=e=>l.z.object({devices:FE(e).array()}),UE=l.z.object({keys:ME.array()}),WE=l.z.object({}),GE=l.z.object({keys:ME.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:lE.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()}),KE=e=>l.z.object({devices:_.nullishToEmpty(FE(e))}),qE=l.z.object({key:ME,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),JE=l.z.union([qE,GE]),YE=class{client;constructor(e){this.client=e}async retrieve(e){let{schemas:t,...n}=e,r=typeof n==`object`&&`key`in n,i=await this.client.send(`/device/retrieve`,n,JE,KE(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 this.client.send(`/device/create`,{devices:_.toArray(e)},VE(t),HE(t));return n?r.devices[0]:r.devices}async delete(e){await this.client.send(`/device/delete`,{keys:_.toArray(e)},UE,WE)}},XE=e=>wf(LE(e)),ZE=o({Client:()=>YE,DELETE_CHANNEL_NAME:()=>BE,SET_CHANNEL_NAME:()=>zE,TYPE_ONTOLOGY_ID:()=>RE,deviceZ:()=>FE,keyZ:()=>ME,newZ:()=>IE,ontologyID:()=>LE,statusDetailsZ:()=>NE,statusKey:()=>XE,statusZ:()=>PE}),QE=To.keyZ,$E=To.labelZ,eD=To.newZ,tD=`labeled_by`,nD=`sy_label_set`,rD=`sy_label_delete`,iD=l.default.object({labels:eD.array()}),aD=l.default.object({labels:$E.array()}),oD=l.default.object({keys:QE.array()}),sD=l.default.object({id:L,labels:QE.array(),replace:l.default.boolean().optional()}),cD=sD.omit({replace:!0}),lD=l.default.object({}),uD=l.default.object({keys:QE.array().optional(),names:l.default.string().array().optional(),for:L.optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional()}),dD=l.default.object({key:QE}).transform(({key:e})=>({keys:[e]})),fD=l.default.union([dD,uD]),pD=l.default.object({labels:_.nullishToEmpty($E)}),mD=class{type=`label`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await this.client.send(`/label/retrieve`,e,fD,pD);return X(`Label`,e,n.labels,t),t?n.labels[0]:n.labels}async label(e,t,n={}){await this.client.send(`/label/set`,{id:e,labels:t,replace:n.replace},sD,lD)}async remove(e,t){await this.client.send(`/label/remove`,{id:e,labels:t},cD,lD)}async create(e){let t=Array.isArray(e),n=await this.client.send(`/label/create`,{labels:_.toArray(e)},iD,aD);return t?n.labels:n.labels[0]}async delete(e){await this.client.send(`/label/delete`,{keys:_.toArray(e)},oD,lD)}},hD=R(`label`),gD=hD(``),_D=o({Client:()=>mD,DELETE_CHANNEL_NAME:()=>rD,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:()=>tD,SET_CHANNEL_NAME:()=>nD,TYPE_ONTOLOGY_ID:()=>gD,keyZ:()=>QE,labelZ:()=>$E,newZ:()=>eD,ontologyID:()=>hD}),vD=l.z.uuid(),yD=l.z.object({key:vD,name:l.z.string(),data:re.preserveCase(k.nullishToEmpty())}),bD=yD.partial({key:!0}),xD=R(`lineplot`),SD=xD(``),CD=l.z.uuid(),wD=l.z.object({key:CD,name:l.z.string().min(1,`Name is required`),author:gp.optional(),layout:re.preserveCase(k.nullishToEmpty())}),TD=wD.omit({author:!0}).partial({key:!0}),ED=R(`workspace`),DD=ED(``),OD=l.z.object({keys:CD.array().optional(),searchTerm:l.z.string().optional(),author:gp.optional(),offset:l.z.int().optional(),limit:l.z.int().optional()}),kD=l.z.object({workspaces:TD.array()}),AD=l.z.object({key:CD,name:l.z.string()}),jD=l.z.object({key:CD,layout:re.preserveCase(k.unknownZ())}),MD=l.z.object({keys:CD.array()}),ND=l.z.object({workspaces:_.nullishToEmpty(wD)}),PD=l.z.object({workspaces:wD.array()}),FD=l.z.object({}),ID=`sy_workspace_set`,LD=`sy_workspace_delete`,RD=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/workspace/create`,{workspaces:_.toArray(e)},kD,PD);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await this.client.send(`/workspace/rename`,{key:e,name:t},AD,FD)}async setLayout(e,t){await this.client.send(`/workspace/set-layout`,{key:e,layout:t},jD,FD)}async retrieve(e){let t,n=typeof e!=`string`;t=typeof e==`string`||Array.isArray(e)?{keys:_.toArray(e)}:e;let r=await this.client.send(`/workspace/retrieve`,t,OD,ND);return n?r.workspaces:r.workspaces[0]}async delete(e){await this.client.send(`/workspace/delete`,{keys:_.toArray(e)},MD,FD)}},zD=o({Client:()=>RD,DELETE_CHANNEL_NAME:()=>LD,SET_CHANNEL_NAME:()=>ID,TYPE_ONTOLOGY_ID:()=>DD,keyZ:()=>CD,newZ:()=>TD,ontologyID:()=>ED,workspaceZ:()=>wD}),BD=l.z.object({key:vD,name:l.z.string()}),VD=l.z.object({key:vD,data:re.preserveCase(k.unknownZ())}),HD=l.z.object({keys:vD.array()}),UD=l.z.object({keys:vD.array()}),WD=l.z.object({key:vD}).transform(({key:e})=>({keys:[e]})),GD=l.z.union([WD,UD]),KD=l.z.object({linePlots:_.nullishToEmpty(yD)}),qD=l.z.object({workspace:CD,linePlots:bD.array()}),JD=l.z.object({linePlots:yD.array()}),YD=l.z.object({}),XD=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/lineplot/create`,{workspace:e,linePlots:_.toArray(t)},qD,JD);return n?r.linePlots:r.linePlots[0]}async rename(e,t){await this.client.send(`/lineplot/rename`,{key:e,name:t},BD,YD)}async setData(e,t){await this.client.send(`/lineplot/set-data`,{key:e,data:t},VD,YD)}async retrieve(e){let t=WD.safeParse(e).success,n=await this.client.send(`/lineplot/retrieve`,e,GD,KD);return X(`LinePlot`,e,n.linePlots,t),t?n.linePlots[0]:n.linePlots}async delete(e){await this.client.send(`/lineplot/delete`,{keys:_.toArray(e)},HD,YD)}},ZD=o({Client:()=>XD,TYPE_ONTOLOGY_ID:()=>SD,keyZ:()=>vD,linePlotZ:()=>yD,newZ:()=>bD,ontologyID:()=>xD,retrieveArgsZ:()=>GD}),QD=l.z.uuid(),$D=l.z.object({key:QD,name:l.z.string(),data:re.preserveCase(k.nullishToEmpty())}),eO=$D.partial({key:!0}),tO=R(`log`),nO=tO(``),rO=l.z.object({key:QD,name:l.z.string()}),iO=l.z.object({key:QD,data:re.preserveCase(k.unknownZ())}),aO=l.z.object({keys:QD.array()}),oO=l.z.object({keys:QD.array()}),sO=l.z.object({key:QD}).transform(({key:e})=>({keys:[e]})),cO=l.z.union([sO,oO]),lO=l.z.object({logs:_.nullishToEmpty($D)}),uO=l.z.object({workspace:CD,logs:eO.array()}),dO=l.z.object({logs:$D.array()}),fO=l.z.object({}),pO=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/log/create`,{workspace:e,logs:_.toArray(t)},uO,dO);return n?r.logs:r.logs[0]}async rename(e,t){await this.client.send(`/log/rename`,{key:e,name:t},rO,fO)}async setData(e,t){await this.client.send(`/log/set-data`,{key:e,data:t},iO,fO)}async retrieve(e){let t=sO.safeParse(e).success,n=await this.client.send(`/log/retrieve`,e,cO,lO);return X(`Log`,e,n.logs,t),t?n.logs[0]:n.logs}async delete(e){await this.client.send(`/log/delete`,{keys:_.toArray(e)},aO,fO)}},mO=o({Client:()=>pO,TYPE_ONTOLOGY_ID:()=>nO,keyZ:()=>QD,logZ:()=>$D,newZ:()=>eO,ontologyID:()=>tO,retrieveArgsZ:()=>cO}),hO=l.z.object({range:Q,aliases:l.z.string().array()}),gO=l.z.object({aliases:l.z.record(l.z.string(),Z)}),_O=l.z.object({range:Q,aliases:l.z.record(Z,l.z.string())}),vO=l.z.unknown(),yO=l.z.object({range:Q,channels:Z.array()}),bO=l.z.unknown(),xO=l.z.object({range:Q}),SO=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),CO=l.z.object({range:Q,channels:Z.array()}),wO=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),TO=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 this.client.send(`/range/alias/resolve`,{range:this.rangeKey,aliases:t},hO,gO);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 this.client.send(`/range/alias/set`,{range:this.rangeKey,aliases:e},_O,vO)}async list(){return(await this.client.send(`/range/alias/list`,{range:this.rangeKey},xO,SO)).aliases}async retrieve(e){let t=typeof e==`number`,n=await this.client.send(`/range/alias/retrieve`,{range:this.rangeKey,channels:_.toArray(e)},CO,wO);return t?n.aliases[e]:n.aliases}async delete(e){await this.client.send(`/range/alias/delete`,{range:this.rangeKey,channels:_.toArray(e)},yO,bO)}},EO=`sy_range_alias_set`,DO=`sy_range_alias_delete`,OO=`---`,kO=e=>`${e.range}${OO}${e.channel}`,AO=(e,t)=>({type:`range-alias`,key:kO({range:e,channel:t})}),jO={type:`range-alias`,key:``},MO=e=>{let[t,n]=e.split(OO);return{range:t,channel:Number(n)}},NO=EO,PO=DO,FO=kO,IO=MO,LO=l.z.object({range:Q,channel:Z,alias:l.z.string()}),RO=o({Client:()=>TO,DELETE_ALIAS_CHANNEL_NAME:()=>PO,DELETE_CHANNEL_NAME:()=>DO,SET_ALIAS_CHANNEL_NAME:()=>NO,SET_CHANNEL_NAME:()=>EO,TYPE_ONTOLOGY_ID:()=>jO,aliasKey:()=>FO,aliasZ:()=>LO,createKey:()=>kO,decodeDeleteAliasChange:()=>IO,decodeDeleteChange:()=>MO,ontologyID:()=>AO}),zO=`sy_range_set`,BO=`sy_range_delete`,VO=class{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:t=C.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 AC(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 df(`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:AC(this.key)})}async addLabel(...e){await this.labelClient.label(AC(this.key),e)}async removeLabel(...e){await this.labelClient.remove(AC(this.key),e)}static sort(e,t){return C.sort(e.timeRange,t.timeRange)}},HO=l.z.object({keys:Q.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),overlapsWith:C.z.optional(),hasLabels:QE.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(C.z.transform(e=>({overlapsWith:e}))),UO=l.z.object({ranges:_.nullishToEmpty(OC)}),WO=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(_.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(_.toArray(e))}async retrieve(e){let t=typeof e==`string`,{ranges:n}=await this.unaryClient.send(`/range/retrieve`,e,HO,UO);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(AC(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(KO(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 VO(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(KO(e))}},GO=e=>({type:`range-alias`,key:e}),KO=({data:e,id:{key:t},name:n})=>{let r=C.z.parse(e?.timeRange),i=so.colorZ.safeParse(e?.color);return{key:t,name:n,timeRange:r,color:i.success?i.data:void 0,labels:[],parent:void 0}},qO=l.z.object({range:Q,key:l.z.string(),value:l.z.string()}),JO=l.z.object({range:Q,keys:l.z.string().array()}),YO=l.z.object({pairs:_.nullishToEmpty(qO)}),XO=l.z.object({range:Q,pairs:qO.array()}),ZO=l.z.object({range:Q,keys:l.z.string().array()}),QO=class{rangeKey;client;constructor(e,t){this.rangeKey=e,this.client=t}async get(e){let t=await this.client.send(`/range/kv/get`,{range:this.rangeKey,keys:_.toArray(e)},JO,YO);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 this.client.send(`/range/kv/set`,{range:this.rangeKey,pairs:n},XO,l.z.unknown())}async delete(e){await this.client.send(`/range/kv/delete`,{range:this.rangeKey,keys:_.toArray(e)},ZO,l.z.unknown())}},$O=`sy_range_kv_set`,ek=`sy_range_kv_delete`,tk=({range:e,key:t})=>`${e}<--->${t}`,nk=$O,rk=ek,ik=qO,ak=tk,ok=o({Client:()=>QO,DELETE_CHANNEL_NAME:()=>ek,KV_DELETE_CHANNEL:()=>rk,KV_SET_CHANNEL:()=>nk,SET_CHANNEL_NAME:()=>$O,createPairKey:()=>tk,kvPairKey:()=>ak,kvPairZ:()=>ik,pairZ:()=>qO}),sk=l.z.string().min(1),ck=l.z.object({ranges:OC.array()}),lk=l.z.object({parent:L.optional(),ranges:kC.array()}),uk=l.z.object({keys:Q.array()}),dk=l.z.object({}),fk=l.z.object({key:Q,name:sk}),pk=l.z.object({}),mk=class{client;constructor(e){this.client=e}async rename(e,t){await this.client.send(`/range/rename`,{key:e,name:t},fk,pk)}async create(e,t){return(await this.client.send(`/range/create`,{ranges:e,...t},lk,ck)).ranges}async delete(e){await this.client.send(`/range/delete`,{keys:e},uk,dk)}},hk=o({Client:()=>WO,DELETE_ALIAS_CHANNEL_NAME:()=>DO,DELETE_CHANNEL_NAME:()=>BO,KV_DELETE_CHANNEL:()=>ek,KV_SET_CHANNEL:()=>$O,Range:()=>VO,SET_ALIAS_CHANNEL_NAME:()=>EO,SET_CHANNEL_NAME:()=>zO,TYPE_ONTOLOGY_ID:()=>jC,Writer:()=>mk,alias:()=>RO,aliasKey:()=>kO,aliasOntologyID:()=>GO,apiRangeZ:()=>DC,baseZ:()=>EC,convertOntologyResourceToPayload:()=>KO,decodeDeleteAliasChange:()=>MO,keyZ:()=>Q,kv:()=>ok,kvPairKey:()=>tk,nameZ:()=>sk,newZ:()=>kC,ontologyID:()=>AC,payloadZ:()=>OC}),gk=l.z.object({key:l.z.string(),position:Gt.xyZ,zIndex:y.int16.optional(),measured:Gt.dimensionsZ.optional()}),_k=l.z.object({node:l.z.string(),param:l.z.string()}),vk=l.z.uuid(),yk=l.z.object({key:l.z.string(),source:_k,target:_k}),bk=l.z.object({key:vk,name:l.z.string(),snapshot:l.z.boolean(),nodes:_.nullishToEmpty(gk),edges:_.nullishToEmpty(yk),configs:re.preserveCase(k.nullishToEmpty(l.z.string(),k.unknownZ()))}),xk=bk.partial({key:!0,snapshot:!0}),Sk=R(`schematic`),Ck=Sk(``),wk=l.z.object({name:l.z.string()}),Tk=l.z.object({key:l.z.string(),position:Gt.xyZ}),Ek=l.z.object({key:l.z.string(),measured:Gt.dimensionsZ}),Dk=l.z.object({node:gk,config:re.preserveCase(y.nullToUndefined(k.unknownZ()))}),Ok=l.z.object({key:l.z.string()}),kk=l.z.object({edge:yk}),Ak=l.z.object({key:l.z.string()}),jk=l.z.object({key:l.z.string(),config:re.preserveCase(k.nullishToEmpty())}),Mk=l.z.discriminatedUnion(`type`,[l.z.object({type:l.z.literal(`rename`),rename:wk}),l.z.object({type:l.z.literal(`set_node_position`),setNodePosition:Tk}),l.z.object({type:l.z.literal(`set_node_measured`),setNodeMeasured:Ek}),l.z.object({type:l.z.literal(`set_node`),setNode:Dk}),l.z.object({type:l.z.literal(`remove_node`),removeNode:Ok}),l.z.object({type:l.z.literal(`add_edge`),addEdge:kk}),l.z.object({type:l.z.literal(`remove_edge`),removeEdge:Ak}),l.z.object({type:l.z.literal(`set_config`),setConfig:jk})]),Nk=e=>({type:`rename`,rename:e}),Pk=e=>({type:`set_node_position`,setNodePosition:e}),Fk=e=>({type:`set_node_measured`,setNodeMeasured:e}),Ik=e=>({type:`set_node`,setNode:e}),Lk=e=>({type:`remove_node`,removeNode:e}),Rk=e=>({type:`add_edge`,addEdge:e}),zk=e=>({type:`remove_edge`,removeEdge:e}),Bk=e=>({type:`set_config`,setConfig:e}),Vk=e=>kh((t,n)=>{switch(n.type){case`rename`:return e.rename(t,n.rename);case`set_node_position`:return e.setNodePosition(t,n.setNodePosition);case`set_node_measured`:return e.setNodeMeasured(t,n.setNodeMeasured);case`set_node`:return e.setNode(t,n.setNode);case`remove_node`:return e.removeNode(t,n.removeNode);case`add_edge`:return e.addEdge(t,n.addEdge);case`remove_edge`:return e.removeEdge(t,n.removeEdge);case`set_config`:return e.setConfig(t,n.setConfig)}}),Hk=Ah(vk,Mk),Uk=jh(vk,Mk),Wk={inverse:[],targets:[]},Gk=e=>vm(e)?wh(e):e,Kk=Vk({rename:(e,t)=>{let n=e.name;return e.name=t.name,{inverse:[Nk({name:n})],targets:[e.key]}},setNodePosition:(e,t)=>{let n=e.nodes.find(e=>e.key===t.key);if(n==null)return Wk;let r={x:n.position.x,y:n.position.y};return n.position=t.position,{inverse:[Pk({key:t.key,position:r})],targets:[t.key]}},setNodeMeasured:(e,t)=>{let n=e.nodes.find(e=>e.key===t.key);return n==null?Wk:(n.measured=t.measured,{inverse:[],targets:[]})},setNode:(e,t)=>{let n=e.nodes.findIndex(e=>e.key===t.node.key);if(n===-1)return e.nodes.push(t.node),t.config!=null&&(e.configs[t.node.key]=t.config),{inverse:[Lk({key:t.node.key})],targets:[t.node.key]};let r=Gk(e.nodes[n]),i=e.configs[t.node.key],a=i==null?void 0:Gk(i);return e.nodes[n]=t.node,t.config!=null&&(e.configs[t.node.key]=t.config),{inverse:[Ik(a==null?{node:r,config:void 0}:{node:r,config:a})],targets:[t.node.key]}},removeNode:(e,t)=>{let n=e.nodes.findIndex(e=>e.key===t.key);if(n===-1)return Wk;let r=Gk(e.nodes[n]),i=e.configs[t.key],a=i==null?void 0:Gk(i);return e.nodes.splice(n,1),delete e.configs[t.key],{inverse:[Ik(a==null?{node:r,config:void 0}:{node:r,config:a})],targets:[t.key]}},addEdge:(e,t)=>e.edges.some(e=>e.key===t.edge.key)?Wk:(e.edges.push(t.edge),{inverse:[zk({key:t.edge.key})],targets:[t.edge.key]}),removeEdge:(e,t)=>{let n=e.edges.findIndex(e=>e.key===t.key);if(n===-1)return Wk;let r=Gk(e.edges[n]);return e.edges.splice(n,1),{inverse:[Rk({edge:r})],targets:[t.key]}},setConfig:(e,t)=>{let n=e.configs[t.key];if(n!=null){let r=Gk(n),i={};for(let e of Object.keys(t.config))r[e]!==void 0&&(i[e]=r[e]);return e.configs[t.key]={...r,...t.config},Object.keys(i).length===0?{inverse:[],targets:[t.key]}:{inverse:[Bk({key:t.key,config:i})],targets:[t.key]}}let r=t.config,i=e.edges.find(e=>e.key===t.key);if(i!=null){let t=e.configs[i.source.node];t?.color!=null&&!so.isZero(t.color)&&(r={...r,color:t.color})}return e.configs[t.key]=r,{inverse:[],targets:[t.key]}}}),qk=e=>e.type!==`set_node_measured`,Jk=l.z.object({key:l.z.string(),name:l.z.string(),selectors:_.nullishToEmpty(l.z.string()),strokeColor:l.z.string().optional(),fillColor:l.z.string().optional()}),Yk=l.z.object({key:l.z.string(),position:Gt.xyZ,orientation:Gt.outerLocationZ}),Xk=l.z.uuid(),Zk=l.z.object({key:l.z.string(),name:l.z.string(),regions:_.nullishToEmpty(Jk)}),Qk=l.z.object({svg:l.z.string().min(1),states:_.nullishToEmpty(Zk),variant:l.z.string().min(1),handles:_.nullishToEmpty(Yk),scale:l.z.number().default(1),scaleStroke:l.z.boolean().default(!1),previewViewport:Gt.viewportZ.optional()}),$k=l.z.object({key:Xk,version:l.z.uint32().default(1),name:l.z.string().min(1),data:Qk}),eA=l.z.object({key:Xk.optional(),version:l.z.uint32().default(1),name:l.z.string().min(1),data:Qk}),tA=R(`schematic_symbol`),nA=tA(``),rA=l.z.object({symbols:eA.array(),parent:L}),iA=l.z.object({key:Xk,name:l.z.string()}),aA=l.z.object({keys:Xk.array()}),oA=l.z.object({keys:Xk.array().optional(),searchTerm:l.z.string().optional()}),sA=l.z.object({key:Xk}).transform(({key:e})=>({keys:[e]})),cA=l.z.union([sA,oA]),lA=l.z.object({symbols:_.nullishToEmpty($k)}),uA=l.z.object({symbols:$k.array()}),dA=l.z.object({}),fA=l.z.object({}),pA=l.z.object({group:BC}),mA=`sy_schematic_symbol_set`,hA=`sy_schematic_symbol_delete`,gA=class{client;constructor(e){this.client=e}async create(e){let t=`symbols`in e,n=t?e.symbols:[e],r=await this.client.send(`/schematic/symbol/create`,{symbols:n,parent:e.parent},rA,uA);return t?r.symbols:r.symbols[0]}async rename(e,t){await this.client.send(`/schematic/symbol/rename`,{key:e,name:t},iA,dA)}async retrieve(e){let t=`key`in e,n=await this.client.send(`/schematic/symbol/retrieve`,e,cA,lA);return X(`Schematic Symbol`,e,n.symbols,t),t?n.symbols[0]:n.symbols}async delete(e){await this.client.send(`/schematic/symbol/delete`,{keys:_.toArray(e)},aA,dA)}async retrieveGroup(){return(await this.client.send(`/schematic/symbol/retrieve-group`,{},fA,pA)).group}},_A=o({Client:()=>gA,DELETE_CHANNEL_NAME:()=>hA,SET_CHANNEL_NAME:()=>mA,TYPE_ONTOLOGY_ID:()=>nA,handleZ:()=>Yk,keyZ:()=>Xk,newZ:()=>eA,ontologyID:()=>tA,regionZ:()=>Jk,specZ:()=>Qk,stateZ:()=>Zk,symbolZ:()=>$k}),vA=`sy_schematic_set`,yA=bk.omit({key:!0,name:!0,snapshot:!0}),bA=l.z.object({key:vk,data:yA}),xA=l.z.object({keys:vk.array()}),SA=l.z.object({key:vk,name:l.z.string(),snapshot:l.z.boolean()}),CA=l.z.object({keys:vk.array()}),wA=l.z.object({key:vk}).transform(({key:e})=>({keys:[e]})),TA=l.z.union([wA,CA]),EA=l.z.object({schematics:bk.array()}),DA=l.z.object({workspace:CD,schematics:xk.array()}),OA=l.z.object({schematics:bk.array()}),kA=l.z.object({schematic:bk}),AA=l.z.object({}),jA=class{symbols;client;constructor(e){this.client=e,this.symbols=new gA(e)}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/schematic/create`,{workspace:e,schematics:_.toArray(t)},DA,OA);return n?r.schematics:r.schematics[0]}async rename(e,t){await this.dispatch(e,``,[Nk({name:t})])}async setData(e,t){await this.client.send(`/schematic/set-data`,{key:e,data:t},bA,AA)}async dispatch(e,t,n){await this.client.send(`/schematic/dispatch`,{key:e,dispatchKey:t,actions:n},Uk,AA)}async retrieve(e){let t=wA.safeParse(e).success,n=await this.client.send(`/schematic/retrieve`,e,TA,EA);return X(`Schematic`,e,n.schematics,t),t?n.schematics[0]:n.schematics}async delete(e){await this.client.send(`/schematic/delete`,{keys:_.toArray(e)},xA,AA)}async copy(e){return(await this.client.send(`/schematic/copy`,e,SA,kA)).schematic}},MA={name:``,nodes:[],edges:[],configs:{}},NA=o({Client:()=>jA,SET_CHANNEL_NAME:()=>vA,TYPE_ONTOLOGY_ID:()=>Ck,ZERO_NEW:()=>MA,actionZ:()=>Mk,addEdge:()=>Rk,addEdgePayloadZ:()=>kk,createReduceAll:()=>Vk,dispatchReqZ:()=>Uk,edgeZ:()=>yk,handleZ:()=>_k,isUndoable:()=>qk,keyZ:()=>vk,newZ:()=>xk,nodeZ:()=>gk,ontologyID:()=>Sk,reduceAll:()=>Kk,removeEdge:()=>zk,removeEdgePayloadZ:()=>Ak,removeNode:()=>Lk,removeNodePayloadZ:()=>Ok,rename:()=>Nk,renamePayloadZ:()=>wk,retrieveArgsZ:()=>TA,schematicZ:()=>bk,scopedActionZ:()=>Hk,setConfig:()=>Bk,setConfigPayloadZ:()=>jk,setNode:()=>Ik,setNodeMeasured:()=>Fk,setNodeMeasuredPayloadZ:()=>Ek,setNodePayloadZ:()=>Dk,setNodePosition:()=>Pk,setNodePositionPayloadZ:()=>Tk,symbol:()=>_A}),PA=l.z.string(),FA=e=>Es.statusZ({details:e}),IA=e=>Es.newZ({details:e}).omit({labels:!0}),LA=`sy_status_set`,RA=`sy_status_delete`,zA=R(`status`),BA=zA(``),VA=e=>l.default.object({parent:L.optional(),statuses:IA(e).array()}),HA=e=>l.default.object({statuses:FA(e).array()}),UA=l.default.object({keys:PA.array()}),WA=l.default.object({}),GA=l.default.object({keys:PA.array().optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional(),includeLabels:l.default.boolean().optional(),hasLabels:QE.array().optional(),variants:l.default.string().array().optional()}),KA=l.default.object({key:PA,includeLabels:l.default.boolean().optional()}).transform(({key:e,includeLabels:t})=>({keys:[e],includeLabels:t})),qA=l.default.union([KA,GA]),JA=e=>l.default.object({statuses:_.nullishToEmpty(FA(e))}),YA=class{type=`status`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await this.client.send(`/status/retrieve`,e,qA,JA(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 this.client.send(`/status/set`,{statuses:_.toArray(e),parent:t.parent},VA(t.detailsSchema),HA(t.detailsSchema))).statuses;return n?r:r[0]}async delete(e){await this.client.send(`/status/delete`,{keys:_.toArray(e)},UA,WA)}},XA=o({Client:()=>YA,DELETE_CHANNEL_NAME:()=>RA,SET_CHANNEL_NAME:()=>LA,TYPE_ONTOLOGY_ID:()=>BA,keyZ:()=>PA,newZ:()=>IA,ontologyID:()=>zA,statusZ:()=>FA}),ZA=l.z.object({key:l.z.string(),variant:l.z.string(),props:re.preserveCase(k.nullishToEmpty())}),QA=l.z.object({size:l.z.number(),cells:_.nullishToEmpty(l.z.string())}),$A=l.z.object({size:l.z.number()}),ej=l.z.uuid(),tj=ZA.omit({key:!0}),nj=l.z.object({key:ej,name:l.z.string(),rows:_.nullishToEmpty(QA),columns:_.nullishToEmpty($A),cells:re.preserveCase(k.nullishToEmpty(l.z.string(),ZA))}),rj=nj.partial({key:!0,rows:!0,columns:!0,cells:!0}),ij=R(`table`),aj=ij(``),oj=l.z.object({name:l.z.string()}),sj=l.z.object({index:l.z.uint32(),size:l.z.number(),cells:_.nullishToEmpty(ZA),cellTemplate:ZA.optional()}),cj=l.z.object({index:l.z.uint32()}),lj=l.z.object({index:l.z.uint32(),size:l.z.number(),cells:_.nullishToEmpty(ZA),cellTemplate:ZA.optional()}),uj=l.z.object({index:l.z.uint32()}),dj=l.z.object({index:l.z.uint32(),size:l.z.number()}),fj=l.z.object({index:l.z.uint32(),size:l.z.number()}),pj=l.z.object({cell:ZA}),mj=l.z.object({cells:_.nullishToEmpty(l.z.string()),template:tj}),hj=l.z.discriminatedUnion(`type`,[l.z.object({type:l.z.literal(`rename`),rename:oj}),l.z.object({type:l.z.literal(`add_row`),addRow:sj}),l.z.object({type:l.z.literal(`remove_row`),removeRow:cj}),l.z.object({type:l.z.literal(`add_col`),addCol:lj}),l.z.object({type:l.z.literal(`remove_col`),removeCol:uj}),l.z.object({type:l.z.literal(`resize_row`),resizeRow:dj}),l.z.object({type:l.z.literal(`resize_col`),resizeCol:fj}),l.z.object({type:l.z.literal(`set_cell`),setCell:pj}),l.z.object({type:l.z.literal(`erase_cells`),eraseCells:mj})]),gj=e=>({type:`rename`,rename:e}),_j=e=>({type:`add_row`,addRow:e}),vj=e=>({type:`remove_row`,removeRow:e}),yj=e=>({type:`add_col`,addCol:e}),bj=e=>({type:`remove_col`,removeCol:e}),xj=e=>({type:`resize_row`,resizeRow:e}),Sj=e=>({type:`resize_col`,resizeCol:e}),Cj=e=>({type:`set_cell`,setCell:e}),wj=e=>({type:`erase_cells`,eraseCells:e}),Tj=e=>kh((t,n)=>{switch(n.type){case`rename`:return e.rename(t,n.rename);case`add_row`:return e.addRow(t,n.addRow);case`remove_row`:return e.removeRow(t,n.removeRow);case`add_col`:return e.addCol(t,n.addCol);case`remove_col`:return e.removeCol(t,n.removeCol);case`resize_row`:return e.resizeRow(t,n.resizeRow);case`resize_col`:return e.resizeCol(t,n.resizeCol);case`set_cell`:return e.setCell(t,n.setCell);case`erase_cells`:return e.eraseCells(t,n.eraseCells)}}),Ej=Ah(ej,hj),Dj=jh(ej,hj),Oj=32,kj=36,Aj=72,jj=(e,t)=>{let n=t.toString(16).padStart(4,`0`);return e.length<36?`${e}-${n}`:e.slice(0,32)+n},Mj=(e,t)=>Array.from({length:t},(t,n)=>({key:jj(e.key,n),variant:e.variant,props:e.props})),Nj=Tj({rename:(e,t)=>{let n=e.name;return e.name=t.name,{inverse:[gj({name:n})],targets:[e.key]}},addRow:(e,t)=>{let n=t.cellTemplate?Mj(t.cellTemplate,e.columns.length===0&&e.rows.length===0?1:e.columns.length):t.cells;if(e.columns.length===0&&n.length>0)for(let t=0;t<n.length;t++)e.columns.push({size:Aj});let r=Math.min(t.index,e.rows.length),i=n.map(e=>e.key);e.rows.splice(r,0,{size:Math.max(t.size,Oj),cells:i});for(let t of n)e.cells[t.key]=t;return{inverse:[vj({index:r})],targets:i}},removeRow:(e,t)=>{if(t.index>=e.rows.length)return Dh;let n=Oh(e.rows[t.index]),r=[];for(let t of n.cells){let n=e.cells[t];n!=null&&r.push(Oh(n))}e.rows.splice(t.index,1);for(let t of n.cells)delete e.cells[t];return{inverse:[_j({index:t.index,size:n.size,cells:r})],targets:n.cells}},addCol:(e,t)=>{let n=t.cellTemplate?Mj(t.cellTemplate,e.rows.length===0&&e.columns.length===0?1:e.rows.length):t.cells;if(e.rows.length===0&&n.length>0)for(let t=0;t<n.length;t++)e.rows.push({size:kj,cells:[]});let r=Math.min(t.index,e.columns.length);e.columns.splice(r,0,{size:Math.max(t.size,Oj)});for(let t=0;t<e.rows.length&&!(t>=n.length);t++){let i=Math.min(r,e.rows[t].cells.length);e.rows[t].cells.splice(i,0,n[t].key)}for(let t of n)e.cells[t.key]=t;return{inverse:[bj({index:r})],targets:n.map(e=>e.key)}},removeCol:(e,t)=>{if(t.index>=e.columns.length)return Dh;let n=e.columns[t.index].size,r=[];e.columns.splice(t.index,1);for(let n=0;n<e.rows.length;n++){if(t.index>=e.rows[n].cells.length)continue;let i=e.rows[n].cells[t.index],a=e.cells[i];a!=null&&r.push(Oh(a)),delete e.cells[i],e.rows[n].cells.splice(t.index,1)}return{inverse:[yj({index:t.index,size:n,cells:r})],targets:r.map(e=>e.key)}},resizeRow:(e,t)=>{if(t.index>=e.rows.length)return Dh;let n=e.rows[t.index].size;return e.rows[t.index].size=Math.max(t.size,Oj),{inverse:[xj({index:t.index,size:n})],targets:[...e.rows[t.index].cells]}},resizeCol:(e,t)=>{if(t.index>=e.columns.length)return Dh;let n=e.columns[t.index].size;e.columns[t.index].size=Math.max(t.size,Oj);let r=e.rows.map(e=>e.cells[t.index]).filter(e=>e!=null);return{inverse:[Sj({index:t.index,size:n})],targets:r}},setCell:(e,t)=>{let n=e.cells[t.cell.key];if(n==null)return Dh;let r=Oh(n);return e.cells[t.cell.key]=t.cell,{inverse:[Cj({cell:r})],targets:[t.cell.key]}},eraseCells:(e,t)=>{if(t.cells.length===0)return Dh;let n=new Set(t.cells),r=new Map;for(let t=0;t<e.rows.length;t++){let n=e.rows[t].cells;for(let e=0;e<n.length;e++)r.set(n[e],{row:t,col:e})}let i=new Map,a=new Map;for(let e of n){let t=r.get(e);t!=null&&(i.set(t.row,(i.get(t.row)??0)+1),a.set(t.col,(a.get(t.col)??0)+1))}let o=[];for(let[t,n]of i)n>0&&n===e.rows[t].cells.length&&o.push(t);o.sort((e,t)=>e-t);let s=[];for(let[t,n]of a)n===e.rows.length&&s.push(t);s.sort((e,t)=>e-t);let c=[],l=[];for(let t=o.length-1;t>=0;t--){let n=o[t],r=Oh(e.rows[n]),i=[];for(let t of r.cells){let n=e.cells[t];n!=null&&i.push(Oh(n))}e.rows.splice(n,1);for(let t of r.cells)delete e.cells[t];c.unshift(_j({index:n,size:r.size,cells:i})),l.push(...r.cells)}for(let t=s.length-1;t>=0;t--){let n=s[t],r=e.columns[n].size,i=[];e.columns.splice(n,1);for(let t=0;t<e.rows.length;t++){if(n>=e.rows[t].cells.length)continue;let r=e.rows[t].cells[n],a=e.cells[r];a!=null&&i.push(Oh(a)),delete e.cells[r],e.rows[t].cells.splice(n,1)}c.unshift(yj({index:n,size:r,cells:i})),l.push(...i.map(e=>e.key))}for(let r of n){let n=e.cells[r];if(n==null)continue;let i=Oh(n);e.cells[r]={key:r,variant:t.template.variant,props:t.template.props},c.push(Cj({cell:i})),l.push(r)}return{inverse:c,targets:l}}}),Pj=`sy_table_set`,Fj=l.z.object({key:ej,name:l.z.string()}),Ij=nj.omit({key:!0,name:!0}),Lj=l.z.object({key:ej,data:Ij}),Rj=l.z.object({keys:ej.array()}),zj=l.z.object({keys:ej.array()}),Bj=l.z.object({key:ej}).transform(({key:e})=>({keys:[e]})),Vj=l.z.union([Bj,zj]),Hj=l.z.object({tables:_.nullishToEmpty(nj)}),Uj=l.z.object({workspace:CD,tables:rj.array()}),Wj=l.z.object({tables:nj.array()}),Gj=l.z.object({}),Kj=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/table/create`,{workspace:e,tables:_.toArray(t)},Uj,Wj);return n?r.tables:r.tables[0]}async rename(e,t){await this.client.send(`/table/rename`,{key:e,name:t},Fj,Gj)}async setData(e,t){await this.client.send(`/table/set-data`,{key:e,data:t},Lj,Gj)}async dispatch(e,t,n){await this.client.send(`/table/dispatch`,{key:e,dispatchKey:t,actions:n},Dj,Gj)}async retrieve(e){let t=Bj.safeParse(e).success,n=await this.client.send(`/table/retrieve`,e,Vj,Hj);return X(`Table`,e,n.tables,t),t?n.tables[0]:n.tables}async delete(e){await this.client.send(`/table/delete`,{keys:_.toArray(e)},Rj,Gj)}},qj=o({Client:()=>Kj,SET_CHANNEL_NAME:()=>Pj,TYPE_ONTOLOGY_ID:()=>aj,actionZ:()=>hj,addCol:()=>yj,addColPayloadZ:()=>lj,addRow:()=>_j,addRowPayloadZ:()=>sj,cellTemplateZ:()=>tj,cellZ:()=>ZA,columnZ:()=>$A,createReduceAll:()=>Tj,dispatchReqZ:()=>Dj,eraseCells:()=>wj,eraseCellsPayloadZ:()=>mj,keyZ:()=>ej,newZ:()=>rj,ontologyID:()=>ij,reduceAll:()=>Nj,removeCol:()=>bj,removeColPayloadZ:()=>uj,removeRow:()=>vj,removeRowPayloadZ:()=>cj,rename:()=>gj,renamePayloadZ:()=>oj,resizeCol:()=>Sj,resizeColPayloadZ:()=>fj,resizeRow:()=>xj,resizeRowPayloadZ:()=>dj,retrieveArgsZ:()=>Vj,rowZ:()=>QA,scopedActionZ:()=>Ej,setCell:()=>Cj,setCellPayloadZ:()=>pj,tableZ:()=>nj}),Jj=l.z.string().or(l.z.number().transform(String).or(l.z.bigint().transform(String))),Yj=e=>l.z.object({task:Jj,running:l.z.boolean(),cmd:l.z.string().optional(),data:(e??l.z.unknown()).optional()}),Xj=e=>l.z.object({task:Jj.optional(),running:l.z.boolean(),cmd:l.z.string().optional(),data:(e??l.z.unknown()).optional()}),Zj=l.z.object({task:Jj,type:l.z.string(),key:l.z.string(),args:re.preserveCase(y.nullToUndefined(k.unknownZ()))}),Qj=e=>Es.statusZ({details:Yj(e)}),$j=e=>Es.newZ({details:Xj(e)}),eM=({type:e,config:t,statusData:n}={})=>l.z.object({key:Jj,name:l.z.string(),type:e??l.z.string(),config:t??k.nullishToEmpty(),internal:l.z.boolean().optional(),snapshot:l.z.boolean().optional(),status:Es.statusZ({details:Yj(n)}).optional()}),tM=({type:e,config:t,statusData:n}={})=>eM({type:e,config:t,statusData:n}).omit({internal:!0,snapshot:!0,status:!0}).partial({key:!0}).extend({status:Es.newZ({details:Xj(n)}).optional()}),nM=R(`task`),rM=nM(``),iM=`sy_task_cmd`,aM=`sy_task_set`,oM=`sy_task_delete`,sM=e=>Number(BigInt(e)>>32n),cM=(e,t=0)=>((BigInt(e)<<32n)+BigInt(t)).toString(),lM=async(e,t)=>{let n=await t.retrieveParents(nM(e));return n.length===0?null:n[0]},uM=class{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw Error(`Task not created`);return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw Error(`Task not created`);return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw Error(`Task not created`);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().optional()},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 nM(this.key)}async executeCommand(e){return await wM({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await EM({...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 Error(`Task not created`);return this.snapshot?await lM(this.key,this.ontologyClient):null}},dM=l.z.object({rack:lE.optional(),keys:Jj.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()}),fM=l.z.union([l.z.object({key:Jj,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:lE.optional()}).transform(({type:e,rack:t})=>({types:[e],rack:t}))]),pM=dM,mM=l.z.union([fM,pM]),hM=e=>l.z.object({tasks:_.nullishToEmpty(eM(e))}),gM=e=>l.z.object({tasks:tM(e).array()}),_M=e=>l.z.object({tasks:eM(e).array()}),vM=l.z.object({keys:Jj.array()}),yM=l.z.object({}),bM=l.z.object({key:Jj,name:l.z.string(),snapshot:l.z.boolean()}),xM=e=>l.z.object({task:eM(e)}),SM=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=gM(t),i=_M(t),a=await this.client.send(`/task/create`,{tasks:_.toArray(e)},r,i),o=this.sugar(a.tasks,t);return n?o[0]:o}async delete(e){await this.client.send(`/task/delete`,{keys:_.toArray(e)},vM,yM)}async retrieve({schemas:e,...t}){let n=fM.safeParse(t).success,r=(await this.client.send(`/task/retrieve`,t,mM,hM(e))).tasks,i=this.sugar(r,e);return X(`Task`,t,i,n),n?i[0]:i}async copy(e,t,n){let r=xM(),i=await this.client.send(`/task/copy`,{key:e,name:t,snapshot:n},bM,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 Error(`Task not created`);return await lM(e,this.ontologyClient)}sugar(e,t){let n=!Array.isArray(e),r=_.toArray(e).map(({key:e,name:n,type:r,config:i,status:a,internal:o,snapshot:s})=>new uM({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 TM({...e,frameClient:this.frameClient}):await wM({...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 DM({...e,frameClient:this.frameClient,name:t})}return await EM({frameClient:this.frameClient,name:async()=>{let{task:t}=e;return(await this.retrieve({key:t})).name},...e})}},CM=e=>wf(nM(e)),wM=async({frameClient:e,task:t,type:n,args:r})=>(await TM({frameClient:e,commands:[{args:r,task:t,type:n}]}))[0],TM=async({frameClient:e,commands:t})=>{if(e==null)throw Error(`Task not created`);let n=await e.openWriter(iM),r=t.map(e=>({...e,key:Rr.create()}));return await n.write(iM,r),await n.close(),r.map(e=>e.key)},EM=async({frameClient:e,task:t,type:n,timeout:r,name:i,statusDataZ:a,args:o})=>(await DM({frameClient:e,commands:[{args:o,task:t,type:n}],timeout:r,statusDataZ:a,name:i}))[0],DM=async({frameClient:e,commands:t,timeout:n=x.seconds(10),statusDataZ:r,name:i})=>{if(e==null)throw Error(`Task not created`);let a=await e.openStreamer(LA),o=await TM({frameClient:e,commands:t}),s=new x(n),c=[],l,u=new Promise((e,n)=>{l=setTimeout(()=>{(async()=>{n(await OM(`command`,i,s,t.map(e=>e.task)))})()},s.milliseconds)});try{for(;;){let e=await Promise.race([a.read(),u]),t=Qj(r).safeParse(e.at(-1)[LA]);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()}},OM=async(e,t,n,r)=>{let i=re.capitalize(e),a=n.toString();try{let e;e=typeof t==`string`?[t]:Array.isArray(t)?t:_.toArray(await t());let n=Ns.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 ${Ns.naturalLanguageJoin(_.toArray(r).map(e=>e.toString()))} timed out after ${a}`)}},kM=o({COMMAND_CHANNEL_NAME:()=>iM,Client:()=>SM,DELETE_CHANNEL_NAME:()=>oM,SET_CHANNEL_NAME:()=>aM,TYPE_ONTOLOGY_ID:()=>rM,Task:()=>uM,commandZ:()=>Zj,keyZ:()=>Jj,newKey:()=>cM,newStatusDetailsZ:()=>Xj,newStatusZ:()=>$j,newZ:()=>tM,ontologyID:()=>nM,payloadZ:()=>eM,rackKey:()=>sM,statusDetailsZ:()=>Yj,statusKey:()=>CM,statusZ:()=>Qj}),AM=class{url;unary;stream;secure;constructor(e,t={},n=!1){this.secure=n,this.url=e.child(`/api/v1/`);let r=new Gn.JSONCodec;this.unary=Qd(new Zd(this.url,r,this.secure),t),this.stream=new rf(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}},jM=l.z.uuid(),MM=l.z.object({key:jM,name:l.z.string(),type:l.z.string(),query:k.nullishToEmpty()}),NM=MM.partial({key:!0}),PM=R(`view`),FM=PM(``),IM=`sy_view_set`,LM=`sy_view_delete`,RM=l.z.object({views:NM.array()}),zM=l.z.object({views:MM.array()}),BM=l.z.object({keys:jM.array()}),VM=l.z.object({}),HM=l.z.object({keys:jM.array().optional(),types:l.z.string().array().optional(),searchTerm:l.z.string().optional(),offset:l.z.number().optional(),limit:l.z.number().optional()}),UM=l.z.object({key:jM}).transform(({key:e})=>({keys:[e]})),WM=l.z.union([UM,HM]),GM=l.z.object({views:_.nullishToEmpty(MM)}),KM=class{client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await this.client.send(`/view/retrieve`,e,WM,GM);return X(`View`,e,n.views,t),t?n.views[0]:n.views}async create(e){let t=Array.isArray(e),n=await this.client.send(`/view/create`,{views:_.toArray(e)},RM,zM);return t?n.views:n.views[0]}async delete(e){await this.client.send(`/view/delete`,{keys:_.toArray(e)},BM,VM)}},qM=o({Client:()=>KM,DELETE_CHANNEL_NAME:()=>LM,SET_CHANNEL_NAME:()=>IM,TYPE_ONTOLOGY_ID:()=>FM,keyZ:()=>jM,newZ:()=>NM,ontologyID:()=>PM,viewZ:()=>MM}),JM=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:x.z.default(x.seconds(30)),clockSkewThreshold:x.z.default(x.seconds(1)),secure:l.z.boolean().default(!1),name:l.z.string().optional(),retry:aa.breakerConfigZ.optional()}),YM=class extends QT{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=Nw;transport;clientVersion=`0.56.0`;constructor(e){let t=y.parse(JM,e),{host:n,port:r,username:i,password:a,connectivityPollFrequency:o,clockSkewThreshold:s,secure:c,retry:l}=t,u=new AM(new Ls({host:n,port:Number(r)}),l,c);u.use(yf);let d=new IC(new FC(u.unary));super(u.stream,u.unary,d),this.auth=new Tw(u.unary,{username:i,password:a}),u.use(this.auth.middleware());let f=new hw(u.unary,d);this.createdAt=b.now(),this.params=t,this.transport=u,this.channels=new nw(this,d,u.unary,f),this.connectivity=new Nw(u.unary,o,this.clientVersion,t.name,s),this.control=new sE(this),this.ontology=new zf(this.transport.unary);let p=new mk(this.transport.unary);this.labels=new mD(this.transport.unary),this.statuses=new YA(this.transport.unary),this.ranges=new WO(this,p,this.transport.unary,d,this.labels,this.ontology,e=>new TO(e,this.transport.unary),e=>new QO(e,this.transport.unary)),this.access=new rm(this.transport.unary),this.users=new Fp(this.transport.unary),this.workspaces=new RD(this.transport.unary),this.tasks=new SM(this.transport.unary,this,this.ontology,this.ranges),this.racks=new OE(this.transport.unary,this.tasks),this.devices=new YE(this.transport.unary),this.arcs=new iC(this.transport.unary,this.transport.stream),this.views=new KM(this.transport.unary),this.schematics=new jA(this.transport.unary),this.lineplots=new XD(this.transport.unary),this.logs=new pO(this.transport.unary),this.tables=new Kj(this.transport.unary),this.groups=new YC(this.transport.unary)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}},XM=async e=>await ZM(e).check(),ZM=e=>{let{host:t,port:n,secure:r,name:i,retry:a}=e,o=y.parse(aa.breakerConfigZ.optional(),a);return new Nw(new AM(new Ls({host:t,port:Number(n)}),o,r).unary,void 0,`0.56.0`,i)},QM={host:`localhost`,port:9090,username:`synnax`,password:`seldon`,retry:{maxRetries:4,baseInterval:x.seconds(1),scale:1.5}},$M=e=>new YM({...QM,...e}),eN=async(e,t)=>{let n=Rr.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(mp(a.key),Jf(i.key)),await e.access.roles.assign({user:r.key,role:a.key}),$M({username:n,password:`test`})};exports.AuthError=sf,exports.Channel=$C,exports.ContiguityError=vf,exports.DataType=w,exports.Density=S,exports.DisconnectedError=_f,exports.Frame=$,exports.MultiSeries=Yi,exports.MultipleFoundError=pf,exports.NotFoundError=ff,exports.QueryError=df,exports.Rate=rr,exports.RouteError=mf,exports.Series=Vi,exports.Synnax=YM,exports.TEST_CLIENT_PARAMS=QM,exports.TimeRange=C,exports.TimeSpan=x,exports.TimeStamp=b,exports.UnexpectedError=uf,exports.ValidationError=I,Object.defineProperty(exports,`access`,{enumerable:!0,get:function(){return am}}),Object.defineProperty(exports,`actions`,{enumerable:!0,get:function(){return Mh}}),Object.defineProperty(exports,`arc`,{enumerable:!0,get:function(){return sC}}),Object.defineProperty(exports,`channel`,{enumerable:!0,get:function(){return gw}}),exports.checkConnection=XM,Object.defineProperty(exports,`connection`,{enumerable:!0,get:function(){return Ew}}),Object.defineProperty(exports,`control`,{enumerable:!0,get:function(){return cE}}),exports.createTestClient=$M,exports.createTestClientWithPolicy=eN,Object.defineProperty(exports,`device`,{enumerable:!0,get:function(){return ZE}}),Object.defineProperty(exports,`framer`,{enumerable:!0,get:function(){return $T}}),Object.defineProperty(exports,`group`,{enumerable:!0,get:function(){return XC}}),exports.isCalculated=rw,Object.defineProperty(exports,`label`,{enumerable:!0,get:function(){return _D}}),Object.defineProperty(exports,`lineplot`,{enumerable:!0,get:function(){return ZD}}),Object.defineProperty(exports,`log`,{enumerable:!0,get:function(){return mO}}),exports.newConnectionChecker=ZM,Object.defineProperty(exports,`ontology`,{enumerable:!0,get:function(){return Wf}}),Object.defineProperty(exports,`rack`,{enumerable:!0,get:function(){return jE}}),Object.defineProperty(exports,`ranger`,{enumerable:!0,get:function(){return hk}}),Object.defineProperty(exports,`schematic`,{enumerable:!0,get:function(){return NA}}),Object.defineProperty(exports,`status`,{enumerable:!0,get:function(){return XA}}),exports.synnaxParamsZ=JM,Object.defineProperty(exports,`table`,{enumerable:!0,get:function(){return qj}}),Object.defineProperty(exports,`task`,{enumerable:!0,get:function(){return kM}}),Object.defineProperty(exports,`user`,{enumerable:!0,get:function(){return Rp}}),Object.defineProperty(exports,`view`,{enumerable:!0,get:function(){return qM}}),Object.defineProperty(exports,`workspace`,{enumerable:!0,get:function(){return zD}});
|
|
118
|
+
`,i=new TextEncoder,a=!1,o=!1,s=ET(t),{columns:c,columnsByIndexKey:l,emptyGroupStrings:u}=DT(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=>yo.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=OT(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=>yo.formatValue(e.header)).join(`,`);t.enqueue(i.encode(`${e}${r}`)),a=!0}d.length-f+p.length<kT&&await e.next()&&m(e.value);let n=h(kT);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()}})},ET=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},DT=(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 uf(`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}},OT=(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},kT=1e3,AT=l.z.object({keys:l.z.number().array(),downsampleFactor:l.z.int(),throttleRate:rr.z.optional(),excludeGroups:l.z.uint32().array().optional()}),jT=l.z.object({frame:Bw}),MT=l.z.object({channels:iw,downsampleFactor:l.z.int().default(1),throttleRate:rr.z.default(new rr(0)),excludeGroups:l.z.uint32().array().default([])}),NT=MT.or(iw.transform(e=>MT.parse({channels:e}))),PT=(e,t)=>async n=>{let r=NT.parse(n),i=await gT.open(e,r.channels);t=t.withCodec(new mT(i.codec));let a=await t.stream(`/frame/stream`,AT,jT),o=new IT(a,i,r.downsampleFactor,r.throttleRate,r.excludeGroups);return a.send({keys:Array.from(i.keys),downsampleFactor:r.downsampleFactor,throttleRate:r.throttleRate,excludeGroups:r.excludeGroups}),await a.receive(),o},FT=async(e,t,n)=>await PT(e,t)(n),IT=class{stream;adapter;downsampleFactor;throttleRate;excludeGroups;constructor(e,t,n=1,r=new rr(0),i=[]){this.stream=new vT(`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(Ud.matches(e))return{done:!0,value:void 0};throw v.fromUnknown(e)}}async read(){return this.adapter.adapt(new zw((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}},LT=class e{wrapped_=null;breaker;opener;config;constructor(e,t,n={}){this.opener=e,this.config=NT.parse(t);let{maxRetries:r=5e3,baseInterval:i=S.seconds(1),scale:a=1}=n??{};this.breaker=new aa.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 v.fromUnknown(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=iw.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(Ud.matches(e))return{done:!0,value:void 0};throw v.fromUnknown(e)}}async read(){try{let e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(Ud.matches(e))throw v.fromUnknown(e);return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}},RT=class extends Ro.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)}},zT=function(e){return e[e.PersistStream=1]=`PersistStream`,e[e.Persist=2]=`Persist`,e[e.Stream=3]=`Stream`,e}({}),BT=new S(-1),VT=class extends af.sub(`writer_closed`){constructor(){super(`WriterClosed`)}},HT=l.z.enum(zT).or(l.z.enum([`persist`,`stream`,`persistStream`]).transform(e=>{switch(e){case`persist`:return 2;case`stream`:return 3;case`persistStream`:return 1}})),UT=l.z.object({start:x.z.optional(),controlSubject:k.subjectZ.optional(),authorities:l.z.union([k.authorityZ.transform(e=>[e]),k.authorityZ.array()]).default([k.ABSOLUTE_AUTHORITY]),mode:HT.default(1),errOnUnauthorized:l.z.boolean().default(!1),enableAutoCommit:l.z.boolean().default(!0),autoIndexPersistInterval:S.z.default(S.SECOND),autoIndex:l.z.boolean().default(!1)}),WT=UT.extend({keys:Q.array().optional()}),GT=UT.extend({channels:iw}),KT=GT.or(iw.transform(e=>GT.parse({channels:e,start:x.now()}))),qT=l.z.object({command:l.z.enum(Uw),config:WT.optional(),frame:Bw.optional(),buffer:l.z.instanceof(Uint8Array).optional()}),JT=l.z.object({command:l.z.enum(Uw),end:x.z,err:v.payloadZ.optional()}),YT=l.z.tuple([l.z.union([l.z.record(Q.or(bC),k.authorityZ),Q.or(bC),k.authorityZ]),k.authorityZ.optional()]).transform(([e,t])=>{if(k.authorityZ.safeParse(e).success)return{keys:[],authorities:[e]};if(Q.or(bC).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)}}),XT=class e{stream;adapter;closeErr=null;constructor(e,t){this.stream=e,this.adapter=t}static async _open(t,n,r){let i=b.parse(KT,r),a=await _T.open(t,i.channels);n=n.withCodec(new pT(a.codec));let o=new e(await n.stream(`/frame/write`,qT,JT),a);return await o.execute({command:Uw.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);try{this.stream.send({command:Uw.Write,frame:n.toPayload()})}catch(e){if(!Ud.matches(e))throw v.fromUnknown(e)}}async setAuthority(e,t){if(this.closeErr!=null)throw this.closeErr;let n=YT.parse([e,t]),r={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Uw.SetAuthority,config:r})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),x.ZERO):(await this.execute({command:Uw.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(VT.matches(this.closeErr))return null;throw this.closeErr}try{let e=await this.stream.receive();this.closeErr=v.decode(e?.err)}catch(e){let t=v.fromUnknown(e);this.closeErr=Ud.matches(t)?new VT:t}}}async execute(e){try{this.stream.send(e)}catch(e){await this.closeInternal(v.fromUnknown(e))}for(;;){let t;try{t=await this.stream.receive()}catch(e){await this.closeInternal(v.fromUnknown(e));continue}let n=v.decode(t?.err);if(n!=null&&await this.closeInternal(n),t?.command==e.command)return t}}},ZT=z(`framer`),QT=ZT(``),$T=class{streamClient;retriever;deleter;reader;constructor(e,t,n){this.streamClient=e,this.retriever=n,this.deleter=new Iw(t),this.reader=new wT(n,e)}async openIterator(e,t,n){return await ST._open(e,t,this.retriever,this.streamClient,n)}async openWriter(e){return await XT._open(this.retriever,this.streamClient,e)}async openStreamer(e){return await FT(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:zT.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:S.MAX});return await r.write(n),await r.close()}let r=await this.openWriter({start:e,channels:t,mode:zT.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:S.MAX});await r.write(t,n),await r.close()}async read(e,t){if(!(`start`in e))return await this.reader.read(e);let{single:n}=PC(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 zw;try{for await(let e of n)r.push(e)}finally{await n.close()}return r}async readLatest(e,t=1){let{single:n}=PC(e),r=await this.readLatestNFrame(e,t);return n?r.get(e):r}async readLatestNFrame(e,t){let n=await this.openIterator(w.MAX,e,{chunkSize:t}),r=new zw;if(t>0)try{await n.seekLast(),await n.prev(yT),r.push(n.value)}finally{await n.close()}return r}async delete(e,t){let{normalized:n,variant:r}=PC(e),i=new w(t);return r===`keys`?await this.deleter.delete({keys:n,bounds:i}):await this.deleter.delete({names:n,bounds:i})}},eE=o({ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:()=>BT,AUTO_SPAN:()=>yT,Client:()=>$T,Frame:()=>zw,HardenedStreamer:()=>LT,Iterator:()=>ST,IteratorCommand:()=>Gw,IteratorResponseVariant:()=>qw,ObservableStreamer:()=>RT,Reader:()=>wT,TYPE_ONTOLOGY_ID:()=>QT,Writer:()=>XT,WriterClosedError:()=>VT,WriterCommand:()=>Uw,WriterMode:()=>zT,createStreamOpener:()=>PT,frameZ:()=>Bw,iteratorCommandZ:()=>Kw,iteratorReqZ:()=>bT,iteratorResZ:()=>xT,iteratorResponseVariantZ:()=>Jw,ontologyID:()=>ZT,openStreamer:()=>FT,seriesFromPayload:()=>Vw,seriesToPayload:()=>Hw,streamerConfigZ:()=>NT,writerCommandZ:()=>Ww,writerConfigZ:()=>KT}),tE=k.ABSOLUTE_AUTHORITY,nE=k.ZERO_AUTHORITY,rE=k.stateZ(l.z.number()),iE=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()})`},aE=l.z.object({transfers:l.z.array(k.transferZ(Q))}),oE=class extends RT{states;codec;constructor(e){super(e,e=>{let t=Array.from(e.series[0].as(`string`)).map(e=>this.codec.decodeString(e,aE));return t.forEach(e=>this.merge(e)),[t.flatMap(e=>e.transfers),!0]}),this.states=new Map,this.codec=new Gn.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)})}},sE=`sy_node_1_control`,cE=class{framer;constructor(e){this.framer=e}async openStateTracker(){return new oE(await LT.open(async e=>await this.framer.openStreamer(e),sE))}},lE=o({ABSOLUTE_AUTHORITY:()=>tE,CONTROL_STATE_CHANNEL_NAME:()=>sE,Client:()=>cE,StateTracker:()=>oE,ZERO_AUTHORITY:()=>nE,stateZ:()=>rE,transferString:()=>iE}),uE=l.z.uint32(),dE=l.z.object({rack:uE}),fE=Ts.statusZ({details:dE}),pE=l.z.object({key:uE,name:l.z.string().min(1,`Name is required`),taskCounter:l.z.uint32().optional(),embedded:l.z.boolean().optional(),status:fE.optional(),integrations:b.nullToUndefined(l.z.string().array())}),mE=pE.omit({taskCounter:!0,embedded:!0,key:!0}).extend({key:l.z.uint32().default(0)}),hE=z(`rack`),gE=hE(0),_E=`sy_rack_set`,vE=`sy_rack_delete`,yE=l.z.object({keys:uE.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()}),bE=l.z.object({racks:_.nullishToEmpty(pE)}),xE=pE,SE=l.z.union([l.z.object({key:uE,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}))]),CE=yE,wE=l.z.union([SE,CE]),TE=l.z.object({racks:mE.array()}),EE=l.z.object({racks:pE.array()}),DE=l.z.object({keys:uE.array()}),OE=l.z.object({}),kE=class{client;tasks;constructor(e,t){this.client=e,this.tasks=t}async delete(e){await this.client.send(`/rack/delete`,{keys:_.toArray(e)},DE,OE)}async create(e){let t=!Array.isArray(e),n=await this.client.send(`/rack/create`,{racks:_.toArray(e)},TE,EE),r=this.sugar(n.racks);return t?r[0]:r}async retrieve(e){let t=`key`in e||`name`in e,n=await this.client.send(`/rack/retrieve`,e,wE,bE),r=this.sugar(n.racks);return Z(`Rack`,e,r,t),t?r[0]:r}sugar(e){let t=!Array.isArray(e),n=_.toArray(e).map(({key:e,name:t,status:n,integrations:r})=>new AE(e,t,this.tasks,n,r));return t?n[0]:n}},AE=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}}},jE=e=>wf(hE(e)),ME=o({Client:()=>kE,DELETE_CHANNEL_NAME:()=>vE,Rack:()=>AE,SET_CHANNEL_NAME:()=>_E,TYPE_ONTOLOGY_ID:()=>gE,keyZ:()=>uE,newZ:()=>mE,ontologyID:()=>hE,payloadZ:()=>pE,rackZ:()=>xE,statusDetailsZ:()=>dE,statusKey:()=>jE,statusZ:()=>fE}),NE=l.z.string(),PE=l.z.object({rack:uE,device:NE}),FE=Ts.statusZ({details:PE}),IE=({properties:e,make:t,model:n}={})=>l.z.object({key:NE,rack:uE,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??A.nullishToEmpty(),status:FE.optional(),parent:R.optional()}),LE=({properties:e,make:t,model:n}={})=>IE({properties:e,make:t,model:n}).partial({key:!0,configured:!0}),RE=z(`device`),zE=RE(``),BE=`sy_device_set`,VE=`sy_device_delete`,HE=e=>l.z.object({devices:b.toArray(LE(e))}),UE=e=>l.z.object({devices:IE(e).array()}),WE=l.z.object({keys:NE.array()}),GE=l.z.object({}),KE=l.z.object({keys:NE.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:uE.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()}),qE=e=>l.z.object({devices:_.nullishToEmpty(IE(e))}),JE=l.z.object({key:NE,includeStatus:l.z.boolean().optional()}).transform(({key:e,includeStatus:t})=>({keys:[e],includeStatus:t})),YE=l.z.union([JE,KE]),XE=class{client;constructor(e){this.client=e}async retrieve(e){let{schemas:t,...n}=e,r=typeof n==`object`&&`key`in n,i=await this.client.send(`/device/retrieve`,n,YE,qE(t));return Z(`Device`,n,i.devices,r),r?i.devices[0]:i.devices}async create(e,t){let n=!Array.isArray(e),r=await this.client.send(`/device/create`,{devices:_.toArray(e)},HE(t),UE(t));return n?r.devices[0]:r.devices}async delete(e){await this.client.send(`/device/delete`,{keys:_.toArray(e)},WE,GE)}},ZE=e=>wf(RE(e)),QE=o({Client:()=>XE,DELETE_CHANNEL_NAME:()=>VE,SET_CHANNEL_NAME:()=>BE,TYPE_ONTOLOGY_ID:()=>zE,deviceZ:()=>IE,keyZ:()=>NE,newZ:()=>LE,ontologyID:()=>RE,statusDetailsZ:()=>PE,statusKey:()=>ZE,statusZ:()=>FE}),$E=To.keyZ,eD=To.labelZ,tD=To.newZ,nD=`labeled_by`,rD=`sy_label_set`,iD=`sy_label_delete`,aD=l.default.object({labels:tD.array()}),oD=l.default.object({labels:eD.array()}),sD=l.default.object({keys:$E.array()}),cD=l.default.object({id:R,labels:$E.array(),replace:l.default.boolean().optional()}),lD=cD.omit({replace:!0}),uD=l.default.object({}),dD=l.default.object({keys:$E.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()}),fD=l.default.object({key:$E}).transform(({key:e})=>({keys:[e]})),pD=l.default.union([fD,dD]),mD=l.default.object({labels:_.nullishToEmpty(eD)}),hD=class{type=`label`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await this.client.send(`/label/retrieve`,e,pD,mD);return Z(`Label`,e,n.labels,t),t?n.labels[0]:n.labels}async label(e,t,n={}){await this.client.send(`/label/set`,{id:e,labels:t,replace:n.replace},cD,uD)}async remove(e,t){await this.client.send(`/label/remove`,{id:e,labels:t},lD,uD)}async create(e){let t=Array.isArray(e),n=await this.client.send(`/label/create`,{labels:_.toArray(e)},aD,oD);return t?n.labels:n.labels[0]}async delete(e){await this.client.send(`/label/delete`,{keys:_.toArray(e)},sD,uD)}},gD=z(`label`),_D=gD(``),vD=o({Client:()=>hD,DELETE_CHANNEL_NAME:()=>iD,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:()=>nD,SET_CHANNEL_NAME:()=>rD,TYPE_ONTOLOGY_ID:()=>_D,keyZ:()=>$E,labelZ:()=>eD,newZ:()=>tD,ontologyID:()=>gD}),yD=l.z.uuid(),bD=l.z.object({key:yD,name:l.z.string(),data:re.preserveCase(A.nullishToEmpty())}),xD=bD.partial({key:!0}),SD=z(`lineplot`),CD=SD(``),wD=l.z.uuid(),TD=l.z.object({key:wD,name:l.z.string().min(1,`Name is required`),author:gp.optional(),layout:re.preserveCase(A.nullishToEmpty())}),ED=TD.omit({author:!0}).partial({key:!0}),DD=z(`workspace`),OD=DD(``),kD=l.z.object({keys:wD.array().optional(),searchTerm:l.z.string().optional(),author:gp.optional(),offset:l.z.int().optional(),limit:l.z.int().optional()}),AD=l.z.object({workspaces:ED.array()}),jD=l.z.object({key:wD,name:l.z.string()}),MD=l.z.object({key:wD,layout:re.preserveCase(A.unknownZ())}),ND=l.z.object({keys:wD.array()}),PD=l.z.object({workspaces:_.nullishToEmpty(TD)}),FD=l.z.object({workspaces:TD.array()}),ID=l.z.object({}),LD=`sy_workspace_set`,RD=`sy_workspace_delete`,zD=class{client;constructor(e){this.client=e}async create(e){let t=Array.isArray(e),n=await this.client.send(`/workspace/create`,{workspaces:_.toArray(e)},AD,FD);return t?n.workspaces:n.workspaces[0]}async rename(e,t){await this.client.send(`/workspace/rename`,{key:e,name:t},jD,ID)}async setLayout(e,t){await this.client.send(`/workspace/set-layout`,{key:e,layout:t},MD,ID)}async retrieve(e){let t,n=typeof e!=`string`;t=typeof e==`string`||Array.isArray(e)?{keys:_.toArray(e)}:e;let r=await this.client.send(`/workspace/retrieve`,t,kD,PD);return n?r.workspaces:r.workspaces[0]}async delete(e){await this.client.send(`/workspace/delete`,{keys:_.toArray(e)},ND,ID)}},BD=o({Client:()=>zD,DELETE_CHANNEL_NAME:()=>RD,SET_CHANNEL_NAME:()=>LD,TYPE_ONTOLOGY_ID:()=>OD,keyZ:()=>wD,newZ:()=>ED,ontologyID:()=>DD,workspaceZ:()=>TD}),VD=l.z.object({key:yD,name:l.z.string()}),HD=l.z.object({key:yD,data:re.preserveCase(A.unknownZ())}),UD=l.z.object({keys:yD.array()}),WD=l.z.object({keys:yD.array()}),GD=l.z.object({key:yD}).transform(({key:e})=>({keys:[e]})),KD=l.z.union([GD,WD]),qD=l.z.object({linePlots:_.nullishToEmpty(bD)}),JD=l.z.object({workspace:wD,linePlots:xD.array()}),YD=l.z.object({linePlots:bD.array()}),XD=l.z.object({}),ZD=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/lineplot/create`,{workspace:e,linePlots:_.toArray(t)},JD,YD);return n?r.linePlots:r.linePlots[0]}async rename(e,t){await this.client.send(`/lineplot/rename`,{key:e,name:t},VD,XD)}async setData(e,t){await this.client.send(`/lineplot/set-data`,{key:e,data:t},HD,XD)}async retrieve(e){let t=GD.safeParse(e).success,n=await this.client.send(`/lineplot/retrieve`,e,KD,qD);return Z(`LinePlot`,e,n.linePlots,t),t?n.linePlots[0]:n.linePlots}async delete(e){await this.client.send(`/lineplot/delete`,{keys:_.toArray(e)},UD,XD)}},QD=o({Client:()=>ZD,TYPE_ONTOLOGY_ID:()=>CD,keyZ:()=>yD,linePlotZ:()=>bD,newZ:()=>xD,ontologyID:()=>SD,retrieveArgsZ:()=>KD}),$D=l.z.uuid(),eO=l.z.object({key:$D,name:l.z.string(),data:re.preserveCase(A.nullishToEmpty())}),tO=eO.partial({key:!0}),nO=z(`log`),rO=nO(``),iO=l.z.object({key:$D,name:l.z.string()}),aO=l.z.object({key:$D,data:re.preserveCase(A.unknownZ())}),oO=l.z.object({keys:$D.array()}),sO=l.z.object({keys:$D.array()}),cO=l.z.object({key:$D}).transform(({key:e})=>({keys:[e]})),lO=l.z.union([cO,sO]),uO=l.z.object({logs:_.nullishToEmpty(eO)}),dO=l.z.object({workspace:wD,logs:tO.array()}),fO=l.z.object({logs:eO.array()}),pO=l.z.object({}),mO=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/log/create`,{workspace:e,logs:_.toArray(t)},dO,fO);return n?r.logs:r.logs[0]}async rename(e,t){await this.client.send(`/log/rename`,{key:e,name:t},iO,pO)}async setData(e,t){await this.client.send(`/log/set-data`,{key:e,data:t},aO,pO)}async retrieve(e){let t=cO.safeParse(e).success,n=await this.client.send(`/log/retrieve`,e,lO,uO);return Z(`Log`,e,n.logs,t),t?n.logs[0]:n.logs}async delete(e){await this.client.send(`/log/delete`,{keys:_.toArray(e)},oO,pO)}},hO=o({Client:()=>mO,TYPE_ONTOLOGY_ID:()=>rO,keyZ:()=>$D,logZ:()=>eO,newZ:()=>tO,ontologyID:()=>nO,retrieveArgsZ:()=>lO}),gO=l.z.object({range:$,aliases:l.z.string().array()}),_O=l.z.object({aliases:l.z.record(l.z.string(),Q)}),vO=l.z.object({range:$,aliases:l.z.record(Q,l.z.string())}),yO=l.z.unknown(),bO=l.z.object({range:$,channels:Q.array()}),xO=l.z.unknown(),SO=l.z.object({range:$}),CO=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),wO=l.z.object({range:$,channels:Q.array()}),TO=l.z.object({aliases:l.z.record(l.z.string(),l.z.string())}),EO=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 this.client.send(`/range/alias/resolve`,{range:this.rangeKey,aliases:t},gO,_O);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 this.client.send(`/range/alias/set`,{range:this.rangeKey,aliases:e},vO,yO)}async list(){return(await this.client.send(`/range/alias/list`,{range:this.rangeKey},SO,CO)).aliases}async retrieve(e){let t=typeof e==`number`,n=await this.client.send(`/range/alias/retrieve`,{range:this.rangeKey,channels:_.toArray(e)},wO,TO);return t?n.aliases[e]:n.aliases}async delete(e){await this.client.send(`/range/alias/delete`,{range:this.rangeKey,channels:_.toArray(e)},bO,xO)}},DO=`sy_range_alias_set`,OO=`sy_range_alias_delete`,kO=`---`,AO=e=>`${e.range}${kO}${e.channel}`,jO=(e,t)=>({type:`range-alias`,key:AO({range:e,channel:t})}),MO={type:`range-alias`,key:``},NO=e=>{let[t,n]=e.split(kO);return{range:t,channel:Number(n)}},PO=DO,FO=OO,IO=AO,LO=NO,RO=l.z.object({range:$,channel:Q,alias:l.z.string()}),zO=o({Client:()=>EO,DELETE_ALIAS_CHANNEL_NAME:()=>FO,DELETE_CHANNEL_NAME:()=>OO,SET_ALIAS_CHANNEL_NAME:()=>PO,SET_CHANNEL_NAME:()=>DO,TYPE_ONTOLOGY_ID:()=>MO,aliasKey:()=>IO,aliasZ:()=>RO,createKey:()=>AO,decodeDeleteAliasChange:()=>LO,decodeDeleteChange:()=>NO,ontologyID:()=>jO}),BO=`sy_range_set`,VO=`sy_range_delete`,HO=class{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:t=w.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 AC(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 df(`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 await 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:AC(this.key)})}async addLabel(...e){await this.labelClient.label(AC(this.key),e)}async removeLabel(...e){await this.labelClient.remove(AC(this.key),e)}static sort(e,t){return w.sort(e.timeRange,t.timeRange)}},UO=l.z.object({keys:$.array().optional(),names:l.z.string().array().optional(),searchTerm:l.z.string().optional(),overlapsWith:w.z.optional(),hasLabels:$E.array().optional(),limit:l.z.int().optional(),offset:l.z.int().optional(),includeLabels:l.z.boolean().optional(),includeParent:l.z.boolean().optional()}).or($.array().transform(e=>({keys:e}))).or($.transform(e=>({keys:[e]}))).or(l.z.string().transform(e=>({names:[e]}))).or(l.z.string().array().transform(e=>({names:e}))).or(w.z.transform(e=>({overlapsWith:e}))),WO=l.z.object({ranges:_.nullishToEmpty(OC)}),GO=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(_.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(_.toArray(e))}async retrieve(e){let t=typeof e==`string`,{ranges:n}=await this.unaryClient.send(`/range/retrieve`,e,UO,WO);return Z(`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(AC(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(qO(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 HO(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(qO(e))}},KO=e=>({type:`range-alias`,key:e}),qO=({data:e,id:{key:t},name:n})=>{let r=w.z.parse(e?.timeRange),i=so.colorZ.safeParse(e?.color);return{key:t,name:n,timeRange:r,color:i.success?i.data:void 0,labels:[],parent:void 0}},JO=l.z.object({range:$,key:l.z.string(),value:l.z.string()}),YO=l.z.object({range:$,keys:l.z.string().array()}),XO=l.z.object({pairs:_.nullishToEmpty(JO)}),ZO=l.z.object({range:$,pairs:JO.array()}),QO=l.z.object({range:$,keys:l.z.string().array()}),$O=class{rangeKey;client;constructor(e,t){this.rangeKey=e,this.client=t}async get(e){let t=await this.client.send(`/range/kv/get`,{range:this.rangeKey,keys:_.toArray(e)},YO,XO);return typeof e==`string`?t.pairs[0].value:Object.fromEntries(t.pairs.map(e=>[e.key,e.value]))}async list(){return await 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 this.client.send(`/range/kv/set`,{range:this.rangeKey,pairs:n},ZO,l.z.unknown())}async delete(e){await this.client.send(`/range/kv/delete`,{range:this.rangeKey,keys:_.toArray(e)},QO,l.z.unknown())}},ek=`sy_range_kv_set`,tk=`sy_range_kv_delete`,nk=({range:e,key:t})=>`${e}<--->${t}`,rk=ek,ik=tk,ak=JO,ok=nk,sk=o({Client:()=>$O,DELETE_CHANNEL_NAME:()=>tk,KV_DELETE_CHANNEL:()=>ik,KV_SET_CHANNEL:()=>rk,SET_CHANNEL_NAME:()=>ek,createPairKey:()=>nk,kvPairKey:()=>ok,kvPairZ:()=>ak,pairZ:()=>JO}),ck=l.z.string().min(1),lk=l.z.object({ranges:OC.array()}),uk=l.z.object({parent:R.optional(),ranges:kC.array()}),dk=l.z.object({keys:$.array()}),fk=l.z.object({}),pk=l.z.object({key:$,name:ck}),mk=l.z.object({}),hk=class{client;constructor(e){this.client=e}async rename(e,t){await this.client.send(`/range/rename`,{key:e,name:t},pk,mk)}async create(e,t){return(await this.client.send(`/range/create`,{ranges:e,...t},uk,lk)).ranges}async delete(e){await this.client.send(`/range/delete`,{keys:e},dk,fk)}},gk=o({Client:()=>GO,DELETE_ALIAS_CHANNEL_NAME:()=>OO,DELETE_CHANNEL_NAME:()=>VO,KV_DELETE_CHANNEL:()=>tk,KV_SET_CHANNEL:()=>ek,Range:()=>HO,SET_ALIAS_CHANNEL_NAME:()=>DO,SET_CHANNEL_NAME:()=>BO,TYPE_ONTOLOGY_ID:()=>jC,Writer:()=>hk,alias:()=>zO,aliasKey:()=>AO,aliasOntologyID:()=>KO,apiRangeZ:()=>DC,baseZ:()=>EC,convertOntologyResourceToPayload:()=>qO,decodeDeleteAliasChange:()=>NO,keyZ:()=>$,kv:()=>sk,kvPairKey:()=>nk,nameZ:()=>ck,newZ:()=>kC,ontologyID:()=>AC,payloadZ:()=>OC}),_k=l.z.object({key:l.z.string(),position:Gt.xyZ,zIndex:b.int16.optional(),measured:Gt.dimensionsZ.optional()}),vk=l.z.object({node:l.z.string(),param:l.z.string()}),yk=l.z.uuid(),bk=l.z.object({key:l.z.string(),source:vk,target:vk}),xk=l.z.object({key:yk,name:l.z.string(),snapshot:l.z.boolean(),nodes:_.nullishToEmpty(_k),edges:_.nullishToEmpty(bk),configs:re.preserveCase(A.nullishToEmpty(l.z.string(),A.unknownZ()))}),Sk=xk.partial({key:!0,snapshot:!0}),Ck=z(`schematic`),wk=Ck(``),Tk=l.z.object({name:l.z.string()}),Ek=l.z.object({key:l.z.string(),position:Gt.xyZ}),Dk=l.z.object({key:l.z.string(),measured:Gt.dimensionsZ}),Ok=l.z.object({node:_k,config:re.preserveCase(b.nullToUndefined(A.unknownZ()))}),kk=l.z.object({key:l.z.string()}),Ak=l.z.object({edge:bk}),jk=l.z.object({key:l.z.string()}),Mk=l.z.object({key:l.z.string(),config:re.preserveCase(A.nullishToEmpty())}),Nk=l.z.discriminatedUnion(`type`,[l.z.object({type:l.z.literal(`rename`),rename:Tk}),l.z.object({type:l.z.literal(`set_node_position`),setNodePosition:Ek}),l.z.object({type:l.z.literal(`set_node_measured`),setNodeMeasured:Dk}),l.z.object({type:l.z.literal(`set_node`),setNode:Ok}),l.z.object({type:l.z.literal(`remove_node`),removeNode:kk}),l.z.object({type:l.z.literal(`add_edge`),addEdge:Ak}),l.z.object({type:l.z.literal(`remove_edge`),removeEdge:jk}),l.z.object({type:l.z.literal(`set_config`),setConfig:Mk})]),Pk=e=>({type:`rename`,rename:e}),Fk=e=>({type:`set_node_position`,setNodePosition:e}),Ik=e=>({type:`set_node_measured`,setNodeMeasured:e}),Lk=e=>({type:`set_node`,setNode:e}),Rk=e=>({type:`remove_node`,removeNode:e}),zk=e=>({type:`add_edge`,addEdge:e}),Bk=e=>({type:`remove_edge`,removeEdge:e}),Vk=e=>({type:`set_config`,setConfig:e}),Hk=e=>kh((t,n)=>{switch(n.type){case`rename`:return e.rename(t,n.rename);case`set_node_position`:return e.setNodePosition(t,n.setNodePosition);case`set_node_measured`:return e.setNodeMeasured(t,n.setNodeMeasured);case`set_node`:return e.setNode(t,n.setNode);case`remove_node`:return e.removeNode(t,n.removeNode);case`add_edge`:return e.addEdge(t,n.addEdge);case`remove_edge`:return e.removeEdge(t,n.removeEdge);case`set_config`:return e.setConfig(t,n.setConfig)}}),Uk=Ah(yk,Nk),Wk=jh(yk,Nk),Gk={inverse:[],targets:[]},Kk=e=>vm(e)?wh(e):e,qk=Hk({rename:(e,t)=>{let n=e.name;return e.name=t.name,{inverse:[Pk({name:n})],targets:[e.key]}},setNodePosition:(e,t)=>{let n=e.nodes.find(e=>e.key===t.key);if(n==null)return Gk;let r={x:n.position.x,y:n.position.y};return n.position=t.position,{inverse:[Fk({key:t.key,position:r})],targets:[t.key]}},setNodeMeasured:(e,t)=>{let n=e.nodes.find(e=>e.key===t.key);return n==null?Gk:(n.measured=t.measured,{inverse:[],targets:[]})},setNode:(e,t)=>{let n=e.nodes.findIndex(e=>e.key===t.node.key);if(n===-1)return e.nodes.push(t.node),t.config!=null&&(e.configs[t.node.key]=t.config),{inverse:[Rk({key:t.node.key})],targets:[t.node.key]};let r=Kk(e.nodes[n]),i=e.configs[t.node.key],a=i==null?void 0:Kk(i);return e.nodes[n]=t.node,t.config!=null&&(e.configs[t.node.key]=t.config),{inverse:[Lk(a==null?{node:r,config:void 0}:{node:r,config:a})],targets:[t.node.key]}},removeNode:(e,t)=>{let n=e.nodes.findIndex(e=>e.key===t.key);if(n===-1)return Gk;let r=Kk(e.nodes[n]),i=e.configs[t.key],a=i==null?void 0:Kk(i);return e.nodes.splice(n,1),delete e.configs[t.key],{inverse:[Lk(a==null?{node:r,config:void 0}:{node:r,config:a})],targets:[t.key]}},addEdge:(e,t)=>e.edges.some(e=>e.key===t.edge.key)?Gk:(e.edges.push(t.edge),{inverse:[Bk({key:t.edge.key})],targets:[t.edge.key]}),removeEdge:(e,t)=>{let n=e.edges.findIndex(e=>e.key===t.key);if(n===-1)return Gk;let r=Kk(e.edges[n]);return e.edges.splice(n,1),{inverse:[zk({edge:r})],targets:[t.key]}},setConfig:(e,t)=>{let n=e.configs[t.key];if(n!=null){let r=Kk(n),i={};for(let e of Object.keys(t.config))r[e]!==void 0&&(i[e]=r[e]);return e.configs[t.key]={...r,...t.config},Object.keys(i).length===0?{inverse:[],targets:[t.key]}:{inverse:[Vk({key:t.key,config:i})],targets:[t.key]}}let r=t.config,i=e.edges.find(e=>e.key===t.key);if(i!=null){let t=e.configs[i.source.node];t?.color!=null&&!so.isZero(t.color)&&(r={...r,color:t.color})}return e.configs[t.key]=r,{inverse:[],targets:[t.key]}}}),Jk=e=>e.type!==`set_node_measured`,Yk=l.z.object({key:l.z.string(),name:l.z.string(),selectors:_.nullishToEmpty(l.z.string()),strokeColor:l.z.string().optional(),fillColor:l.z.string().optional()}),Xk=l.z.object({key:l.z.string(),position:Gt.xyZ,orientation:Gt.outerLocationZ}),Zk=l.z.uuid(),Qk=l.z.object({key:l.z.string(),name:l.z.string(),regions:_.nullishToEmpty(Yk)}),$k=l.z.object({svg:l.z.string().min(1),states:_.nullishToEmpty(Qk),variant:l.z.string().min(1),handles:_.nullishToEmpty(Xk),scale:l.z.number().default(1),scaleStroke:l.z.boolean().default(!1),previewViewport:Gt.viewportZ.optional()}),eA=l.z.object({key:Zk,version:l.z.uint32().default(1),name:l.z.string().min(1),data:$k}),tA=l.z.object({key:Zk.optional(),version:l.z.uint32().default(1),name:l.z.string().min(1),data:$k}),nA=z(`schematic_symbol`),rA=nA(``),iA=l.z.object({symbols:tA.array(),parent:R}),aA=l.z.object({key:Zk,name:l.z.string()}),oA=l.z.object({keys:Zk.array()}),sA=l.z.object({keys:Zk.array().optional(),searchTerm:l.z.string().optional()}),cA=l.z.object({key:Zk}).transform(({key:e})=>({keys:[e]})),lA=l.z.union([cA,sA]),uA=l.z.object({symbols:_.nullishToEmpty(eA)}),dA=l.z.object({symbols:eA.array()}),fA=l.z.object({}),pA=l.z.object({}),mA=l.z.object({group:BC}),hA=`sy_schematic_symbol_set`,gA=`sy_schematic_symbol_delete`,_A=class{client;constructor(e){this.client=e}async create(e){let t=`symbols`in e,n=t?e.symbols:[e],r=await this.client.send(`/schematic/symbol/create`,{symbols:n,parent:e.parent},iA,dA);return t?r.symbols:r.symbols[0]}async rename(e,t){await this.client.send(`/schematic/symbol/rename`,{key:e,name:t},aA,fA)}async retrieve(e){let t=`key`in e,n=await this.client.send(`/schematic/symbol/retrieve`,e,lA,uA);return Z(`Schematic Symbol`,e,n.symbols,t),t?n.symbols[0]:n.symbols}async delete(e){await this.client.send(`/schematic/symbol/delete`,{keys:_.toArray(e)},oA,fA)}async retrieveGroup(){return(await this.client.send(`/schematic/symbol/retrieve-group`,{},pA,mA)).group}},vA=o({Client:()=>_A,DELETE_CHANNEL_NAME:()=>gA,SET_CHANNEL_NAME:()=>hA,TYPE_ONTOLOGY_ID:()=>rA,handleZ:()=>Xk,keyZ:()=>Zk,newZ:()=>tA,ontologyID:()=>nA,regionZ:()=>Yk,specZ:()=>$k,stateZ:()=>Qk,symbolZ:()=>eA}),yA=`sy_schematic_set`,bA=xk.omit({key:!0,name:!0,snapshot:!0}),xA=l.z.object({key:yk,data:bA}),SA=l.z.object({keys:yk.array()}),CA=l.z.object({key:yk,name:l.z.string(),snapshot:l.z.boolean()}),wA=l.z.object({keys:yk.array()}),TA=l.z.object({key:yk}).transform(({key:e})=>({keys:[e]})),EA=l.z.union([TA,wA]),DA=l.z.object({schematics:xk.array()}),OA=l.z.object({workspace:wD,schematics:Sk.array()}),kA=l.z.object({schematics:xk.array()}),AA=l.z.object({schematic:xk}),jA=l.z.object({}),MA=class{symbols;client;constructor(e){this.client=e,this.symbols=new _A(e)}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/schematic/create`,{workspace:e,schematics:_.toArray(t)},OA,kA);return n?r.schematics:r.schematics[0]}async rename(e,t){await this.dispatch(e,``,[Pk({name:t})])}async setData(e,t){await this.client.send(`/schematic/set-data`,{key:e,data:t},xA,jA)}async dispatch(e,t,n){await this.client.send(`/schematic/dispatch`,{key:e,dispatchKey:t,actions:n},Wk,jA)}async retrieve(e){let t=TA.safeParse(e).success,n=await this.client.send(`/schematic/retrieve`,e,EA,DA);return Z(`Schematic`,e,n.schematics,t),t?n.schematics[0]:n.schematics}async delete(e){await this.client.send(`/schematic/delete`,{keys:_.toArray(e)},SA,jA)}async copy(e){return(await this.client.send(`/schematic/copy`,e,CA,AA)).schematic}},NA={name:``,nodes:[],edges:[],configs:{}},PA=o({Client:()=>MA,SET_CHANNEL_NAME:()=>yA,TYPE_ONTOLOGY_ID:()=>wk,ZERO_NEW:()=>NA,actionZ:()=>Nk,addEdge:()=>zk,addEdgePayloadZ:()=>Ak,createReduceAll:()=>Hk,dispatchReqZ:()=>Wk,edgeZ:()=>bk,handleZ:()=>vk,isUndoable:()=>Jk,keyZ:()=>yk,newZ:()=>Sk,nodeZ:()=>_k,ontologyID:()=>Ck,reduceAll:()=>qk,removeEdge:()=>Bk,removeEdgePayloadZ:()=>jk,removeNode:()=>Rk,removeNodePayloadZ:()=>kk,rename:()=>Pk,renamePayloadZ:()=>Tk,retrieveArgsZ:()=>EA,schematicZ:()=>xk,scopedActionZ:()=>Uk,setConfig:()=>Vk,setConfigPayloadZ:()=>Mk,setNode:()=>Lk,setNodeMeasured:()=>Ik,setNodeMeasuredPayloadZ:()=>Dk,setNodePayloadZ:()=>Ok,setNodePosition:()=>Fk,setNodePositionPayloadZ:()=>Ek,symbol:()=>vA}),FA=l.z.string(),IA=e=>Ts.statusZ({details:e}),LA=e=>Ts.newZ({details:e}).omit({labels:!0}),RA=`sy_status_set`,zA=`sy_status_delete`,BA=z(`status`),VA=BA(``),HA=e=>l.default.object({parent:R.optional(),statuses:LA(e).array()}),UA=e=>l.default.object({statuses:IA(e).array()}),WA=l.default.object({keys:FA.array()}),GA=l.default.object({}),KA=l.default.object({keys:FA.array().optional(),searchTerm:l.default.string().optional(),offset:l.default.int().optional(),limit:l.default.int().optional(),includeLabels:l.default.boolean().optional(),hasLabels:$E.array().optional(),variants:l.default.string().array().optional()}),qA=l.default.object({key:FA,includeLabels:l.default.boolean().optional()}).transform(({key:e,includeLabels:t})=>({keys:[e],includeLabels:t})),JA=l.default.union([qA,KA]),YA=e=>l.default.object({statuses:_.nullishToEmpty(IA(e))}),XA=class{type=`status`;client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await this.client.send(`/status/retrieve`,e,JA,YA(e.detailsSchema));Z(`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 this.client.send(`/status/set`,{statuses:_.toArray(e),parent:t.parent},HA(t.detailsSchema),UA(t.detailsSchema))).statuses;return n?r:r[0]}async delete(e){await this.client.send(`/status/delete`,{keys:_.toArray(e)},WA,GA)}},ZA=o({Client:()=>XA,DELETE_CHANNEL_NAME:()=>zA,SET_CHANNEL_NAME:()=>RA,TYPE_ONTOLOGY_ID:()=>VA,keyZ:()=>FA,newZ:()=>LA,ontologyID:()=>BA,statusZ:()=>IA}),QA=l.z.object({key:l.z.string(),variant:l.z.string(),props:re.preserveCase(A.nullishToEmpty())}),$A=l.z.object({size:l.z.number(),cells:_.nullishToEmpty(l.z.string())}),ej=l.z.object({size:l.z.number()}),tj=l.z.uuid(),nj=QA.omit({key:!0}),rj=l.z.object({key:tj,name:l.z.string(),rows:_.nullishToEmpty($A),columns:_.nullishToEmpty(ej),cells:re.preserveCase(A.nullishToEmpty(l.z.string(),QA))}),ij=rj.partial({key:!0,rows:!0,columns:!0,cells:!0}),aj=z(`table`),oj=aj(``),sj=l.z.object({name:l.z.string()}),cj=l.z.object({index:l.z.uint32(),size:l.z.number(),cells:_.nullishToEmpty(QA),cellTemplate:QA.optional()}),lj=l.z.object({index:l.z.uint32()}),uj=l.z.object({index:l.z.uint32(),size:l.z.number(),cells:_.nullishToEmpty(QA),cellTemplate:QA.optional()}),dj=l.z.object({index:l.z.uint32()}),fj=l.z.object({index:l.z.uint32(),size:l.z.number()}),pj=l.z.object({index:l.z.uint32(),size:l.z.number()}),mj=l.z.object({cell:QA}),hj=l.z.object({cells:_.nullishToEmpty(l.z.string()),template:nj}),gj=l.z.discriminatedUnion(`type`,[l.z.object({type:l.z.literal(`rename`),rename:sj}),l.z.object({type:l.z.literal(`add_row`),addRow:cj}),l.z.object({type:l.z.literal(`remove_row`),removeRow:lj}),l.z.object({type:l.z.literal(`add_col`),addCol:uj}),l.z.object({type:l.z.literal(`remove_col`),removeCol:dj}),l.z.object({type:l.z.literal(`resize_row`),resizeRow:fj}),l.z.object({type:l.z.literal(`resize_col`),resizeCol:pj}),l.z.object({type:l.z.literal(`set_cell`),setCell:mj}),l.z.object({type:l.z.literal(`erase_cells`),eraseCells:hj})]),_j=e=>({type:`rename`,rename:e}),vj=e=>({type:`add_row`,addRow:e}),yj=e=>({type:`remove_row`,removeRow:e}),bj=e=>({type:`add_col`,addCol:e}),xj=e=>({type:`remove_col`,removeCol:e}),Sj=e=>({type:`resize_row`,resizeRow:e}),Cj=e=>({type:`resize_col`,resizeCol:e}),wj=e=>({type:`set_cell`,setCell:e}),Tj=e=>({type:`erase_cells`,eraseCells:e}),Ej=e=>kh((t,n)=>{switch(n.type){case`rename`:return e.rename(t,n.rename);case`add_row`:return e.addRow(t,n.addRow);case`remove_row`:return e.removeRow(t,n.removeRow);case`add_col`:return e.addCol(t,n.addCol);case`remove_col`:return e.removeCol(t,n.removeCol);case`resize_row`:return e.resizeRow(t,n.resizeRow);case`resize_col`:return e.resizeCol(t,n.resizeCol);case`set_cell`:return e.setCell(t,n.setCell);case`erase_cells`:return e.eraseCells(t,n.eraseCells)}}),Dj=Ah(tj,gj),Oj=jh(tj,gj),kj=32,Aj=36,jj=72,Mj=(e,t)=>{let n=t.toString(16).padStart(4,`0`);return e.length<36?`${e}-${n}`:e.slice(0,32)+n},Nj=(e,t)=>Array.from({length:t},(t,n)=>({key:Mj(e.key,n),variant:e.variant,props:e.props})),Pj=Ej({rename:(e,t)=>{let n=e.name;return e.name=t.name,{inverse:[_j({name:n})],targets:[e.key]}},addRow:(e,t)=>{let n=t.cellTemplate?Nj(t.cellTemplate,e.columns.length===0&&e.rows.length===0?1:e.columns.length):t.cells;if(e.columns.length===0&&n.length>0)for(let t=0;t<n.length;t++)e.columns.push({size:jj});let r=Math.min(t.index,e.rows.length),i=n.map(e=>e.key);e.rows.splice(r,0,{size:Math.max(t.size,kj),cells:i});for(let t of n)e.cells[t.key]=t;return{inverse:[yj({index:r})],targets:i}},removeRow:(e,t)=>{if(t.index>=e.rows.length)return Dh;let n=Oh(e.rows[t.index]),r=[];for(let t of n.cells){let n=e.cells[t];n!=null&&r.push(Oh(n))}e.rows.splice(t.index,1);for(let t of n.cells)delete e.cells[t];return{inverse:[vj({index:t.index,size:n.size,cells:r})],targets:n.cells}},addCol:(e,t)=>{let n=t.cellTemplate?Nj(t.cellTemplate,e.rows.length===0&&e.columns.length===0?1:e.rows.length):t.cells;if(e.rows.length===0&&n.length>0)for(let t=0;t<n.length;t++)e.rows.push({size:Aj,cells:[]});let r=Math.min(t.index,e.columns.length);e.columns.splice(r,0,{size:Math.max(t.size,kj)});for(let t=0;t<e.rows.length&&!(t>=n.length);t++){let i=Math.min(r,e.rows[t].cells.length);e.rows[t].cells.splice(i,0,n[t].key)}for(let t of n)e.cells[t.key]=t;return{inverse:[xj({index:r})],targets:n.map(e=>e.key)}},removeCol:(e,t)=>{if(t.index>=e.columns.length)return Dh;let n=e.columns[t.index].size,r=[];e.columns.splice(t.index,1);for(let n=0;n<e.rows.length;n++){if(t.index>=e.rows[n].cells.length)continue;let i=e.rows[n].cells[t.index],a=e.cells[i];a!=null&&r.push(Oh(a)),delete e.cells[i],e.rows[n].cells.splice(t.index,1)}return{inverse:[bj({index:t.index,size:n,cells:r})],targets:r.map(e=>e.key)}},resizeRow:(e,t)=>{if(t.index>=e.rows.length)return Dh;let n=e.rows[t.index].size;return e.rows[t.index].size=Math.max(t.size,kj),{inverse:[Sj({index:t.index,size:n})],targets:[...e.rows[t.index].cells]}},resizeCol:(e,t)=>{if(t.index>=e.columns.length)return Dh;let n=e.columns[t.index].size;e.columns[t.index].size=Math.max(t.size,kj);let r=e.rows.map(e=>e.cells[t.index]).filter(e=>e!=null);return{inverse:[Cj({index:t.index,size:n})],targets:r}},setCell:(e,t)=>{let n=e.cells[t.cell.key];if(n==null)return Dh;let r=Oh(n);return e.cells[t.cell.key]=t.cell,{inverse:[wj({cell:r})],targets:[t.cell.key]}},eraseCells:(e,t)=>{if(t.cells.length===0)return Dh;let n=new Set(t.cells),r=new Map;for(let t=0;t<e.rows.length;t++){let n=e.rows[t].cells;for(let e=0;e<n.length;e++)r.set(n[e],{row:t,col:e})}let i=new Map,a=new Map;for(let e of n){let t=r.get(e);t!=null&&(i.set(t.row,(i.get(t.row)??0)+1),a.set(t.col,(a.get(t.col)??0)+1))}let o=[];for(let[t,n]of i)n>0&&n===e.rows[t].cells.length&&o.push(t);o.sort((e,t)=>e-t);let s=[];for(let[t,n]of a)n===e.rows.length&&s.push(t);s.sort((e,t)=>e-t);let c=[],l=[];for(let t=o.length-1;t>=0;t--){let n=o[t],r=Oh(e.rows[n]),i=[];for(let t of r.cells){let n=e.cells[t];n!=null&&i.push(Oh(n))}e.rows.splice(n,1);for(let t of r.cells)delete e.cells[t];c.unshift(vj({index:n,size:r.size,cells:i})),l.push(...r.cells)}for(let t=s.length-1;t>=0;t--){let n=s[t],r=e.columns[n].size,i=[];e.columns.splice(n,1);for(let t=0;t<e.rows.length;t++){if(n>=e.rows[t].cells.length)continue;let r=e.rows[t].cells[n],a=e.cells[r];a!=null&&i.push(Oh(a)),delete e.cells[r],e.rows[t].cells.splice(n,1)}c.unshift(bj({index:n,size:r,cells:i})),l.push(...i.map(e=>e.key))}for(let r of n){let n=e.cells[r];if(n==null)continue;let i=Oh(n);e.cells[r]={key:r,variant:t.template.variant,props:t.template.props},c.push(wj({cell:i})),l.push(r)}return{inverse:c,targets:l}}}),Fj=`sy_table_set`,Ij=l.z.object({key:tj,name:l.z.string()}),Lj=rj.omit({key:!0,name:!0}),Rj=l.z.object({key:tj,data:Lj}),zj=l.z.object({keys:tj.array()}),Bj=l.z.object({keys:tj.array()}),Vj=l.z.object({key:tj}).transform(({key:e})=>({keys:[e]})),Hj=l.z.union([Vj,Bj]),Uj=l.z.object({tables:_.nullishToEmpty(rj)}),Wj=l.z.object({workspace:wD,tables:ij.array()}),Gj=l.z.object({tables:rj.array()}),Kj=l.z.object({}),qj=class{client;constructor(e){this.client=e}async create(e,t){let n=Array.isArray(t),r=await this.client.send(`/table/create`,{workspace:e,tables:_.toArray(t)},Wj,Gj);return n?r.tables:r.tables[0]}async rename(e,t){await this.client.send(`/table/rename`,{key:e,name:t},Ij,Kj)}async setData(e,t){await this.client.send(`/table/set-data`,{key:e,data:t},Rj,Kj)}async dispatch(e,t,n){await this.client.send(`/table/dispatch`,{key:e,dispatchKey:t,actions:n},Oj,Kj)}async retrieve(e){let t=Vj.safeParse(e).success,n=await this.client.send(`/table/retrieve`,e,Hj,Uj);return Z(`Table`,e,n.tables,t),t?n.tables[0]:n.tables}async delete(e){await this.client.send(`/table/delete`,{keys:_.toArray(e)},zj,Kj)}},Jj=o({Client:()=>qj,SET_CHANNEL_NAME:()=>Fj,TYPE_ONTOLOGY_ID:()=>oj,actionZ:()=>gj,addCol:()=>bj,addColPayloadZ:()=>uj,addRow:()=>vj,addRowPayloadZ:()=>cj,cellTemplateZ:()=>nj,cellZ:()=>QA,columnZ:()=>ej,createReduceAll:()=>Ej,dispatchReqZ:()=>Oj,eraseCells:()=>Tj,eraseCellsPayloadZ:()=>hj,keyZ:()=>tj,newZ:()=>ij,ontologyID:()=>aj,reduceAll:()=>Pj,removeCol:()=>xj,removeColPayloadZ:()=>dj,removeRow:()=>yj,removeRowPayloadZ:()=>lj,rename:()=>_j,renamePayloadZ:()=>sj,resizeCol:()=>Cj,resizeColPayloadZ:()=>pj,resizeRow:()=>Sj,resizeRowPayloadZ:()=>fj,retrieveArgsZ:()=>Hj,rowZ:()=>$A,scopedActionZ:()=>Dj,setCell:()=>wj,setCellPayloadZ:()=>mj,tableZ:()=>rj}),Yj=l.z.string().or(l.z.number().transform(String).or(l.z.bigint().transform(String))),Xj=e=>l.z.object({task:Yj,running:l.z.boolean(),cmd:l.z.string().optional(),data:(e??l.z.unknown()).optional()}),Zj=e=>l.z.object({task:Yj.optional(),running:l.z.boolean(),cmd:l.z.string().optional(),data:(e??l.z.unknown()).optional()}),Qj=l.z.object({task:Yj,type:l.z.string(),key:l.z.string(),args:re.preserveCase(b.nullToUndefined(A.unknownZ()))}),$j=e=>Ts.statusZ({details:Xj(e)}),eM=e=>Ts.newZ({details:Zj(e)}),tM=({type:e,config:t,statusData:n}={})=>l.z.object({key:Yj,name:l.z.string(),type:e??l.z.string(),config:t??A.nullishToEmpty(),internal:l.z.boolean().optional(),snapshot:l.z.boolean().optional(),status:Ts.statusZ({details:Xj(n)}).optional()}),nM=({type:e,config:t,statusData:n}={})=>tM({type:e,config:t,statusData:n}).omit({internal:!0,snapshot:!0,status:!0}).partial({key:!0}).extend({status:Ts.newZ({details:Zj(n)}).optional()}),rM=z(`task`),iM=rM(``),aM=`sy_task_cmd`,oM=`sy_task_set`,sM=`sy_task_delete`,cM=e=>Number(BigInt(e)>>32n),lM=(e,t=0)=>((BigInt(e)<<32n)+BigInt(t)).toString(),uM=async(e,t)=>{let n=await t.retrieveParents(rM(e));return n.length===0?null:n[0]},dM=class{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw Error(`Task not created`);return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw Error(`Task not created`);return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw Error(`Task not created`);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().optional()},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 rM(this.key)}async executeCommand(e){return await TM({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await DM({...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 Error(`Task not created`);return this.snapshot?await uM(this.key,this.ontologyClient):null}},fM=l.z.object({rack:uE.optional(),keys:Yj.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()}),pM=l.z.union([l.z.object({key:Yj,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:uE.optional()}).transform(({type:e,rack:t})=>({types:[e],rack:t}))]),mM=fM,hM=l.z.union([pM,mM]),gM=e=>l.z.object({tasks:_.nullishToEmpty(tM(e))}),_M=e=>l.z.object({tasks:nM(e).array()}),vM=e=>l.z.object({tasks:tM(e).array()}),yM=l.z.object({keys:Yj.array()}),bM=l.z.object({}),xM=l.z.object({key:Yj,name:l.z.string(),snapshot:l.z.boolean()}),SM=e=>l.z.object({task:tM(e)}),CM=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=_M(t),i=vM(t),a=await this.client.send(`/task/create`,{tasks:_.toArray(e)},r,i),o=this.sugar(a.tasks,t);return n?o[0]:o}async delete(e){await this.client.send(`/task/delete`,{keys:_.toArray(e)},yM,bM)}async retrieve({schemas:e,...t}){let n=pM.safeParse(t).success,r=(await this.client.send(`/task/retrieve`,t,hM,gM(e))).tasks,i=this.sugar(r,e);return Z(`Task`,t,i,n),n?i[0]:i}async copy(e,t,n){let r=SM(),i=await this.client.send(`/task/copy`,{key:e,name:t,snapshot:n},xM,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 Error(`Task not created`);return await uM(e,this.ontologyClient)}sugar(e,t){let n=!Array.isArray(e),r=_.toArray(e).map(({key:e,name:n,type:r,config:i,status:a,internal:o,snapshot:s})=>new dM({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 EM({...e,frameClient:this.frameClient}):await TM({...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 OM({...e,frameClient:this.frameClient,name:t})}return await DM({frameClient:this.frameClient,name:async()=>{let{task:t}=e;return(await this.retrieve({key:t})).name},...e})}},wM=e=>wf(rM(e)),TM=async({frameClient:e,task:t,type:n,args:r})=>(await EM({frameClient:e,commands:[{args:r,task:t,type:n}]}))[0],EM=async({frameClient:e,commands:t})=>{if(e==null)throw Error(`Task not created`);let n=await e.openWriter(aM),r=t.map(e=>({...e,key:Rr.create()}));return await n.write(aM,r),await n.close(),r.map(e=>e.key)},DM=async({frameClient:e,task:t,type:n,timeout:r,name:i,statusDataZ:a,args:o})=>(await OM({frameClient:e,commands:[{args:o,task:t,type:n}],timeout:r,statusDataZ:a,name:i}))[0],OM=async({frameClient:e,commands:t,timeout:n=S.seconds(10),statusDataZ:r,name:i})=>{if(e==null)throw Error(`Task not created`);let a=await e.openStreamer(RA),o=await EM({frameClient:e,commands:t}),s=new S(n),c=[],l,u=new Promise((e,n)=>{l=setTimeout(()=>{(async()=>{n(await kM(`command`,i,s,t.map(e=>e.task)))})()},s.milliseconds)});try{for(;;){let e=await Promise.race([a.read(),u]),t=$j(r).safeParse(e.at(-1)[RA]);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()}},kM=async(e,t,n,r)=>{let i=re.capitalize(e),a=n.toString();try{let e;e=typeof t==`string`?[t]:Array.isArray(t)?t:_.toArray(await t());let n=Ms.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 ${Ms.naturalLanguageJoin(_.toArray(r).map(e=>e.toString()))} timed out after ${a}`)}},AM=o({COMMAND_CHANNEL_NAME:()=>aM,Client:()=>CM,DELETE_CHANNEL_NAME:()=>sM,SET_CHANNEL_NAME:()=>oM,TYPE_ONTOLOGY_ID:()=>iM,Task:()=>dM,commandZ:()=>Qj,keyZ:()=>Yj,newKey:()=>lM,newStatusDetailsZ:()=>Zj,newStatusZ:()=>eM,newZ:()=>nM,ontologyID:()=>rM,payloadZ:()=>tM,rackKey:()=>cM,statusDetailsZ:()=>Xj,statusKey:()=>wM,statusZ:()=>$j}),jM=class{url;unary;stream;secure;constructor(e,t={},n=!1){this.secure=n,this.url=e.child(`/api/v1/`);let r=new Gn.JSONCodec;this.unary=Qd(new Zd(this.url,r,this.secure),t),this.stream=new rf(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}},MM=l.z.uuid(),NM=l.z.object({key:MM,name:l.z.string(),type:l.z.string(),query:A.nullishToEmpty()}),PM=NM.partial({key:!0}),FM=z(`view`),IM=FM(``),LM=`sy_view_set`,RM=`sy_view_delete`,zM=l.z.object({views:PM.array()}),BM=l.z.object({views:NM.array()}),VM=l.z.object({keys:MM.array()}),HM=l.z.object({}),UM=l.z.object({keys:MM.array().optional(),types:l.z.string().array().optional(),searchTerm:l.z.string().optional(),offset:l.z.number().optional(),limit:l.z.number().optional()}),WM=l.z.object({key:MM}).transform(({key:e})=>({keys:[e]})),GM=l.z.union([WM,UM]),KM=l.z.object({views:_.nullishToEmpty(NM)}),qM=class{client;constructor(e){this.client=e}async retrieve(e){let t=`key`in e,n=await this.client.send(`/view/retrieve`,e,GM,KM);return Z(`View`,e,n.views,t),t?n.views[0]:n.views}async create(e){let t=Array.isArray(e),n=await this.client.send(`/view/create`,{views:_.toArray(e)},zM,BM);return t?n.views:n.views[0]}async delete(e){await this.client.send(`/view/delete`,{keys:_.toArray(e)},VM,HM)}},JM=o({Client:()=>qM,DELETE_CHANNEL_NAME:()=>RM,SET_CHANNEL_NAME:()=>LM,TYPE_ONTOLOGY_ID:()=>IM,keyZ:()=>MM,newZ:()=>PM,ontologyID:()=>FM,viewZ:()=>NM}),YM=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:S.z.default(S.seconds(30)),clockSkewThreshold:S.z.default(S.seconds(1)),secure:l.z.boolean().default(!1),name:l.z.string().optional(),retry:aa.breakerConfigZ.optional()}),XM=class extends $T{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=Nw;transport;clientVersion=`0.56.1`;constructor(e){let t=b.parse(YM,e),{host:n,port:r,username:i,password:a,connectivityPollFrequency:o,clockSkewThreshold:s,secure:c,retry:l}=t,u=new jM(new Is({host:n,port:Number(r)}),l,c);u.use(yf);let d=new IC(new FC(u.unary));super(u.stream,u.unary,d),this.auth=new Tw(u.unary,{username:i,password:a}),u.use(this.auth.middleware());let f=new hw(u.unary,d);this.createdAt=x.now(),this.params=t,this.transport=u,this.channels=new nw(this,d,u.unary,f),this.connectivity=new Nw(u.unary,o,this.clientVersion,t.name,s),this.control=new cE(this),this.ontology=new zf(this.transport.unary);let p=new hk(this.transport.unary);this.labels=new hD(this.transport.unary),this.statuses=new XA(this.transport.unary),this.ranges=new GO(this,p,this.transport.unary,d,this.labels,this.ontology,e=>new EO(e,this.transport.unary),e=>new $O(e,this.transport.unary)),this.access=new rm(this.transport.unary),this.users=new Fp(this.transport.unary),this.workspaces=new zD(this.transport.unary),this.tasks=new CM(this.transport.unary,this,this.ontology,this.ranges),this.racks=new kE(this.transport.unary,this.tasks),this.devices=new XE(this.transport.unary),this.arcs=new iC(this.transport.unary,this.transport.stream),this.views=new qM(this.transport.unary),this.schematics=new MA(this.transport.unary),this.lineplots=new ZD(this.transport.unary),this.logs=new mO(this.transport.unary),this.tables=new qj(this.transport.unary),this.groups=new YC(this.transport.unary)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}},ZM=async e=>await QM(e).check(),QM=e=>{let{host:t,port:n,secure:r,name:i,retry:a}=e,o=b.parse(aa.breakerConfigZ.optional(),a);return new Nw(new jM(new Is({host:t,port:Number(n)}),o,r).unary,void 0,`0.56.1`,i)},$M={host:`localhost`,port:9090,username:`synnax`,password:`seldon`,retry:{maxRetries:4,baseInterval:S.seconds(1),scale:1.5}},eN=e=>new XM({...$M,...e}),tN=async(e,t)=>{let n=Rr.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(mp(a.key),Jf(i.key)),await e.access.roles.assign({user:r.key,role:a.key}),eN({username:n,password:`test`})};exports.AuthError=sf,exports.Channel=$C,exports.ContiguityError=vf,exports.DataType=T,exports.Density=C,exports.DisconnectedError=_f,exports.Frame=zw,exports.MultiSeries=Yi,exports.MultipleFoundError=pf,exports.NotFoundError=ff,exports.QueryError=df,exports.Rate=rr,exports.RouteError=mf,exports.Series=Vi,exports.Synnax=XM,exports.TEST_CLIENT_PARAMS=$M,exports.TimeRange=w,exports.TimeSpan=S,exports.TimeStamp=x,exports.UnexpectedError=uf,exports.ValidationError=L,Object.defineProperty(exports,`access`,{enumerable:!0,get:function(){return am}}),Object.defineProperty(exports,`actions`,{enumerable:!0,get:function(){return Mh}}),Object.defineProperty(exports,`arc`,{enumerable:!0,get:function(){return sC}}),Object.defineProperty(exports,`channel`,{enumerable:!0,get:function(){return gw}}),exports.checkConnection=ZM,Object.defineProperty(exports,`connection`,{enumerable:!0,get:function(){return Ew}}),Object.defineProperty(exports,`control`,{enumerable:!0,get:function(){return lE}}),exports.createTestClient=eN,exports.createTestClientWithPolicy=tN,Object.defineProperty(exports,`device`,{enumerable:!0,get:function(){return QE}}),Object.defineProperty(exports,`framer`,{enumerable:!0,get:function(){return eE}}),Object.defineProperty(exports,`group`,{enumerable:!0,get:function(){return XC}}),exports.isCalculated=rw,Object.defineProperty(exports,`label`,{enumerable:!0,get:function(){return vD}}),Object.defineProperty(exports,`lineplot`,{enumerable:!0,get:function(){return QD}}),Object.defineProperty(exports,`log`,{enumerable:!0,get:function(){return hO}}),exports.newConnectionChecker=QM,Object.defineProperty(exports,`ontology`,{enumerable:!0,get:function(){return Wf}}),Object.defineProperty(exports,`rack`,{enumerable:!0,get:function(){return ME}}),Object.defineProperty(exports,`ranger`,{enumerable:!0,get:function(){return gk}}),Object.defineProperty(exports,`schematic`,{enumerable:!0,get:function(){return PA}}),Object.defineProperty(exports,`status`,{enumerable:!0,get:function(){return ZA}}),exports.synnaxParamsZ=YM,Object.defineProperty(exports,`table`,{enumerable:!0,get:function(){return Jj}}),Object.defineProperty(exports,`task`,{enumerable:!0,get:function(){return AM}}),Object.defineProperty(exports,`user`,{enumerable:!0,get:function(){return Rp}}),Object.defineProperty(exports,`view`,{enumerable:!0,get:function(){return JM}}),Object.defineProperty(exports,`workspace`,{enumerable:!0,get:function(){return BD}});
|