@synnaxlabs/x 0.52.3 → 0.52.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/src/telem/telem.d.ts +68 -13
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/x.cjs +7 -7
- package/dist/x.js +221 -136
- package/package.json +1 -1
- package/src/telem/telem.spec.ts +117 -1
- package/src/telem/telem.ts +116 -13
- package/tsconfig.tsbuildinfo +1 -1
package/dist/x.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod"),gn=e=>c.union([c.union([c.null(),c.undefined()]).transform(()=>[]),e.array()]),Yr=e=>Array.isArray(e)?e:e==null?[]:[e],yn=(e,t)=>{if(Array.isArray(t))return t.reduce((s,i)=>yn(s,i),e??[]);if(e==null)return[t];const n=e.findIndex(s=>s==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod"),gn=e=>c.union([c.union([c.null(),c.undefined()]).transform(()=>[]),e.array()]),Yr=e=>Array.isArray(e)?e:e==null?[]:[e],yn=(e,t)=>{if(Array.isArray(t))return t.reduce((s,i)=>yn(s,i),e??[]);if(e==null)return[t];const n=e.findIndex(s=>s==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},Dr=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(n=>!t.includes(n)):e.filter(n=>n!=t)}),mn=(e,t)=>{if(Array.isArray(t))return t.reduce((s,i)=>mn(s,i),e??[]);if(e==null)return[t];const n=e.findIndex(s=>s.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},Gr=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(n=>!t.includes(n.key)):e.filter(n=>n.key!==t)}),Hr=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:gn,remove:Dr,removeKeyed:Gr,toArray:Yr,upsert:yn,upsertKeyed:mn},Symbol.toStringTag,{value:"Module"})),Jr=e=>{const t=e.replace(/_[a-z]/g,n=>n[1].toUpperCase());return t.length>1&&t[0]===t[0].toUpperCase()&&t[1]===t[1].toUpperCase()||t.length===0?t:t[0].toLowerCase()+t.slice(1)},Vt=e=>{const t=(n,r=ie)=>{if(typeof n=="string")return e(n);if(Array.isArray(n))return n.map(o=>t(o,r));if(!te(n))return n;r=Qr(r);const s={},i=n;return"toJSON"in i&&typeof i.toJSON=="function"?t(i.toJSON(),r):(Object.keys(i).forEach(o=>{let a=i[o];const u=e(o);r.recursive&&(te(a)?on(a)||(a=t(a,r)):r.recursiveInArray&&sn(a)&&(a=[...a].map(l=>{let d=l;return te(l)?on(d)||(d=t(l,r)):sn(l)&&(d=t({key:l},r).key),d}))),s[u]=a}),s)};return t},Ae=Vt(Jr),Xr=e=>e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}_${r.toLowerCase()}`),pn=Vt(Xr),bn=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),Kr=[Number,String,Uint8Array],ie={recursive:!0,recursiveInArray:!0},Qr=(e=ie)=>(e.recursive==null?e=ie:e.recursiveInArray??=!1,e),sn=e=>e!=null&&Array.isArray(e),te=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),on=e=>Kr.some(t=>e instanceof t),ts=e=>e.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`).toLowerCase(),es=Vt(ts),ns=e=>{if(e.length===0)return e;let t=e.replace(/[_-]/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,(n,r,s)=>`${r} ${s}`),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,(n,r,s)=>`${r} ${s}`),t=t.replace(/\s+/g," ").trim(),t=t.replace(/\b\w/g,n=>n.toUpperCase()),t},rs=Vt(ns),ss=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:pn,capitalize:bn,snakeToCamel:Ae,toKebab:es,toProperNoun:rs},Symbol.toStringTag,{value:"Module"})),ct=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),is=Object.freeze(Object.defineProperty({__proto__:null,isObject:ct},Symbol.toStringTag,{value:"Module"}));class wn{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,n){return this.decodeString(this.decoder.decode(t),n)}decodeString(t,n){const r=JSON.parse(t),s=Ae(r);return n!=null?n.parse(s):s}encodeString(t){const n=pn(t);return JSON.stringify(n,(r,s)=>ArrayBuffer.isView(s)?Array.from(s):typeof s=="bigint"?s.toString():s)}}class On{contentType="text/csv";encode(t){const n=this.encodeString(t);return new TextEncoder().encode(n)}decode(t,n){const r=new TextDecoder().decode(t);return this.decodeString(r,n)}encodeString(t){if(!Array.isArray(t)||t.length===0||!ct(t[0]))throw new Error("Payload must be an array of objects");const n=Object.keys(t[0]),r=[n.join(",")];return t.forEach(s=>{const i=n.map(o=>JSON.stringify(s[o]??""));r.push(i.join(","))}),r.join(`
|
|
2
2
|
`)}decodeString(t,n){const[r,...s]=t.trim().split(`
|
|
3
|
-
`).map(u=>u.trim());if(r.length===0)return n!=null?n.parse({}):{};const i=r.split(",").map(u=>u.trim()),o={};return i.forEach(u=>{o[u]=[]}),s.forEach(u=>{const a=u.split(",").map(l=>l.trim());i.forEach((l,h)=>{const y=this.parseValue(a[h]);y!=null&&o[l].push(y)})}),n!=null?n.parse(o):o}parseValue(t){if(t==null||t.length===0)return null;const n=Number(t);return isNaN(n)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:n}}class xn{contentType="text/plain";encode(t){if(typeof t!="string")throw new Error("TextCodec.encode payload must be a string");return new TextEncoder().encode(t)}decode(t,n){const r=new TextDecoder().decode(t);return n!=null?n.parse(r):r}}const xt=new wn,os=new On,cs=new xn,us=[xt],as=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:On,CSV_CODEC:os,ENCODERS:us,JSONCodec:wn,JSON_CODEC:xt,TEXT_CODEC:cs,TextCodec:xn},Symbol.toStringTag,{value:"Module"})),j=e=>e!=null&&typeof e=="object"&&"value"in e;class rt{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const Se=e=>e!=null&&typeof e=="object"&&"toString"in e,In=e=>{if(Se(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}},ls=e=>!In(e),fs=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:rt,isCrudeValueExtension:j,isNonZero:ls,isStringer:Se,isZero:In},Symbol.toStringTag,{value:"Module"})),oe=e=>[...new Set(e)],hs=(e,t,n=!0)=>{const r=new Map;return e.forEach(s=>{const i=t(s);if(r.has(i)){if(n)return;r.delete(i)}r.set(i,s)}),Array.from(r.values())},ds=Object.freeze(Object.defineProperty({__proto__:null,by:hs,unique:oe},Symbol.toStringTag,{value:"Module"})),At=(e,t=!1)=>{const n=Se(e)?"stringer":typeof e;let r;switch(n){case"string":r=(s,i)=>s.localeCompare(i);break;case"stringer":r=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":r=(s,i)=>Number(s)-Number(i);break;case"bigint":r=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":r=(s,i)=>Number(s)-Number(i);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?vn(r):r},gs=(e,t,n)=>{const r=At(t[e],n);return(s,i)=>r(s[e],i[e])},ys=(e,t)=>e.length!==t.length?e.length-t.length:e.every((n,r)=>n===t[r])?0:-1,Nn=(e,t)=>{if(e.length!==t.length)return e.length-t.length;if(e.length===0)return 0;const n=At(e[0]),r=[...e].sort(n),s=[...t].sort(n);return r.every((i,o)=>i===s[o])?0:-1},ms=(e,t)=>{const n=oe(e),r=oe(t);return Nn(n,r)},ps=(e,t)=>e===t?0:e==="first"&&t==="last"?1:-1,vn=e=>(t,n)=>e(n,t),st=0,W=-1,V=1,Mn=e=>e<st,An=e=>e>st,bs=e=>e>=st,Sn=e=>e===st,ws=(e,t)=>{const n=/([a-zA-Z]+)|(\d+)/g,r=e.replace(/[\s_.-]+/g,"").match(n),s=t.replace(/[\s_.-]+/g,"").match(n);if(!r||!s)return 0;for(let i=0;i<Math.min(r.length,s.length);i++){const o=r[i],u=s[i];if(isNaN(Number(o))&&isNaN(Number(u))){const a=o.localeCompare(u);if(a!==0)return a}else if(!isNaN(Number(o))&&!isNaN(Number(u))){const a=Number(o)-Number(u);if(a!==0)return a}else return isNaN(Number(o))?-1:1}return r.length-s.length},En=(e,t,n)=>{let r=0,s=e.length;const i=n??At(t);for(;r<s;){const o=Math.floor((r+s)/2),u=i(e[o],t);if(u===0)return o;u<0?r=o+1:s=o}return r},Os=(e,t,n)=>{const r=En(e,t,n);e.splice(r,0,t)},xs=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:st,GREATER_THAN:V,LESS_THAN:W,insert:Os,isEqualTo:Sn,isGreaterThan:An,isGreaterThanEqual:bs,isLessThan:Mn,newF:At,newFieldF:gs,order:ps,primitiveArrays:ys,reverseF:vn,search:En,stringsWithNumbers:ws,uniqueUnorderedPrimitiveArrays:ms,unorderedPrimitiveArrays:Nn},Symbol.toStringTag,{value:"Module"}));let Tn=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Is=`0123456789${$n}`,zn=11,Ns=Tn($n,1),vs=Tn(Is,zn-1),Ee=()=>`${Ns()}${vs()}`,Ms=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:zn,create:Ee},Symbol.toStringTag,{value:"Module"})),Un=(e,t)=>n=>n instanceof t||typeof n=="object"&&n!==null&&"discriminator"in n&&n.discriminator===e,As=Object.freeze(Object.defineProperty({__proto__:null,createMatcher:Un},Symbol.toStringTag,{value:"Module"})),Ss=2**8-1,jn=2**12-1,Es=2**16-1,Ts=2**32-1,$s=2n**64n-1n,zs=2**64-1,Us=-128,js=2**7-1,Cs=-32768,Bs=2**15-1,Rs=-2147483648,Ps=2**31-1,ks=-(2n**63n),Zt=2n**63n-1n,Ls=-9223372036854776e3,Cn=2**63-1,at=e=>(t,n)=>{if(typeof t=="bigint"){if(_t(n))return e(t,BigInt(n));const r=e(Number(t),Number(n));return typeof r=="number"?BigInt(Math.round(r)):r}return e(Number(t),Number(n))},_=at((e,t)=>e-t),Y=at((e,t)=>e+t),Zs=(e,t,n=1e-4)=>Math.abs(e-t)<n,ce=(e,t)=>{const n=typeof e=="bigint",r=typeof t=="bigint";return n&&r?e===t:n&&_t(t)?e===BigInt(t):r&&_t(e)?t===BigInt(e):e===t},_s=e=>{const t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t},Bn=at((e,t)=>e<=t?e:t),_t=e=>typeof e=="bigint"?!0:Number.isInteger(e),qs=at((e,t)=>e>=t?e:t),Rn=e=>typeof e=="bigint"?e<0n?-e:e:e<0?-e:e,R=at((e,t)=>e*t),St=at((e,t)=>e/t),Pn=c.z.tuple([c.z.number(),c.z.number()]),Te=c.z.object({width:c.z.number(),height:c.z.number()}),Fs=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),kn=["start","center","end"],ut=c.z.object({x:c.z.number(),y:c.z.number()}),Ln=c.z.object({clientX:c.z.number(),clientY:c.z.number()}),Yt=["x","y"],$e=c.z.enum(Yt),ze=["top","right","bottom","left"],Ws=c.z.enum(ze),Gt=["left","right"],Ue=c.z.enum(Gt),Ht=["top","bottom"],je=c.z.enum(Ht),Ce=["center"],ue=c.z.enum(Ce),Vs=[...ze,...Ce],Be=c.z.enum(Vs),Ys=c.z.enum(kn),Zn=["first","last"],Gs=c.z.enum(Zn),Hs=c.z.object({lower:c.z.number(),upper:c.z.number()}),Ds=c.z.enum([...$e.options,...Be.options]),Js=c.z.union([$e,Be,c.z.instanceof(String)]),w=(e,t,n)=>{const r={};if(typeof t=="object"&&(n=t,t=void 0),n={makeValid:!0,...n},typeof e=="number"||typeof e=="bigint")t!=null?(r.lower=e,r.upper=t):(r.lower=typeof e=="bigint"?0n:0,r.upper=e);else if(Array.isArray(e)){if(e.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=e}else r.lower=e.lower,r.upper=e.upper;return n?.makeValid?_n(r):r},Xs=Object.freeze({lower:0,upper:0}),Ks=Object.freeze({lower:-1/0,upper:1/0}),Qs=Object.freeze({lower:0,upper:1}),ti=Object.freeze({lower:-1,upper:1}),ei=(e,t)=>{if(e==null&&t==null)return!0;if(e==null||t==null)return!1;const n=w(e),r=w(t);return n?.lower===r?.lower&&n?.upper===r?.upper},_n=e=>e.lower>e.upper?{lower:e.upper,upper:e.lower}:e,ae=(e,t)=>{const n=w(e);return t<n.lower?n.lower:t>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):t},k=(e,t)=>{const n=w(e);if(typeof t=="number"||typeof t=="bigint")return t>=n.lower&&t<n.upper;const r=w(t);return r.lower>=n.lower&&r.upper<=n.upper},ni=(e,t)=>{const n=w(e),r=w(t);return n.lower===r.lower?!0:r.upper===n.lower||r.lower===n.upper?!1:k(n,r.upper)||k(n,r.lower)||k(r,n.upper)||k(r,n.lower)},lt=e=>{const t=w(e);return t.upper-t.lower},ri=e=>{const t=w(e);return typeof t.lower=="bigint"?t.lower===0n&&t.upper===0n:t.lower===0&&t.upper===0},si=e=>{const t=lt(e);return typeof t=="number"?t===0:t===0n},ii=e=>{const t=w(e);return typeof t.lower=="bigint"?!0:Number.isFinite(t.lower)&&Number.isFinite(t.upper)},oi=e=>{const t=w(e);return(t.upper+t.lower)/2},qn=e=>({lower:Math.min(...e.map(t=>w(t).lower)),upper:Math.max(...e.map(t=>w(t).upper))}),ci=e=>({lower:Math.max(...e.map(t=>w(t).lower)),upper:Math.min(...e.map(t=>w(t).upper))}),ui=e=>{const t=w(e),n=typeof t.lower=="bigint";return Array.from({length:Number(lt(e))},(r,s)=>n?t.lower+BigInt(s):t.lower+s)},le=(e,t)=>{const n=e.map(i=>w(i)),r=n.findIndex(i=>k(i,t)||t<i.lower);if(r===-1)return{index:e.length,position:0};const s=n[r];return k(s,t)?{index:r,position:Number(t-s.lower)}:{index:r,position:0}},ee={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},ai=(e,t)=>{const n=e.map(l=>w(l)),r=w(t);if(n.length===0)return ee;const s=le(n,r.lower),i=le(n,r.upper);if(s.index===e.length)return{...ee,insertInto:e.length};if(i.index===0)return{...ee,removeAfter:i.position};if(s.index===i.index)return s.position!==0&&i.position!==0?null:{removeAfter:i.position,removeBefore:s.position,insertInto:s.index,deleteInBetween:0};let o=i.index-s.index,u=s.index,a=_(Number(lt(n[s.index])),s.position);return s.position!==0?(o-=1,u+=1):a=0,{removeBefore:a,removeAfter:i.position,insertInto:u,deleteInBetween:o}},Fn=(e,t,n)=>{const r=e.map(u=>w(u)),s=n>0?1:n<0?-1:0;if(s===0)return t;let i=n,o=t;for(;ce(i,0)===!1;){const u=r.findIndex(a=>s>0?o>=a.lower&&o<a.upper:o>a.lower&&o<=a.upper);if(u!==-1){const a=r[u];let l;if(s>0?l=_(a.upper,o):l=_(o,a.lower),l>0){const h=Bn(Rn(i),l);if(o=Y(o,s>0?h:-h),i=_(i,s>0?h:-h),ce(i,0))return o;continue}}if(s>0){const a=r.filter(l=>l.lower>o);if(a.length>0)o=a[0].lower;else return o}else{const a=r.filter(l=>l.upper<o);if(a.length>0)o=a[a.length-1].upper;else return o}}return o},Wn=(e,t,n)=>{const r=e.map(o=>w(o));if(t===n)return typeof t=="bigint"?0n:0;const s=t<n?w([t,n]):w([n,t]);let i=typeof t=="bigint"?0n:0;for(const o of r){const u=o.lower>s.lower?o.lower:s.lower,a=o.upper<s.upper?o.upper:s.upper;if(u<a){const l=a-u;i=i+l}}return i},li=Object.freeze(Object.defineProperty({__proto__:null,CLIP:ti,DECIMAL:Qs,INFINITE:Ks,ZERO:Xs,bounds:Hs,buildInsertionPlan:ai,clamp:ae,construct:w,contains:k,distance:Wn,equals:ei,findInsertPosition:le,isFinite:ii,isZero:ri,linspace:ui,makeValid:_n,max:qn,mean:oi,min:ci,overlapsWith:ni,span:lt,spanIsZero:si,traverse:Fn},Symbol.toStringTag,{value:"Module"})),fe=2,he=3,Vn=2,fi=(e,t)=>{if(Number.isNaN(e)||!Number.isFinite(e))return e;const n=lt(t);if(n==0)return e;let r;n>=1e3?r=fe:n>=1?r=he:r=Math.ceil(-Math.log10(n))+Vn;const s=10**r;return Math.round(e*s)/s},hi=5,di=1e-10,gi=(e,t)=>{if(Number.isNaN(e)||!Number.isFinite(e))return e;const n=Math.abs(e);if(n===0)return 0;let r=!1,s=0;if(t!=null){s=lt(t);const a=s/n;r=s>0&&a>di}if(r){let a;s>=1e3?a=fe:s>=1?a=he:a=Math.ceil(-Math.log10(s))+Vn;const l=10**a;return Math.round(e*l)/l}if(n>=1e3){const a=10**fe;return Math.round(e*a)/a}if(n>=1){const a=10**he;return Math.round(e*a)/a}const i=Math.floor(Math.log10(n)),u=10**(hi-i-1);return Math.round(e*u)/u},yi=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Bs,MAX_INT32:Ps,MAX_INT64:Zt,MAX_INT64_NUMBER:Cn,MAX_INT8:js,MAX_UINT12:jn,MAX_UINT16:Es,MAX_UINT32:Ts,MAX_UINT64:$s,MAX_UINT64_NUMBER:zs,MAX_UINT8:Ss,MIN_INT16:Cs,MIN_INT32:Rs,MIN_INT64:ks,MIN_INT64_NUMBER:Ls,MIN_INT8:Us,abs:Rn,add:Y,closeTo:Zs,div:St,equal:ce,isInteger:_t,max:qs,min:Bn,mult:R,roundBySpan:fi,roundToNearestMagnitude:_s,smartRound:gi,sub:_},Symbol.toStringTag,{value:"Module"})),Yn=Ds,Z=e=>Yt.includes(e)?e:Ht.includes(e)?"y":"x",mi=e=>Z(e)==="x"?"y":"x",pi=e=>Z(e)==="x"?"width":"height",bi=e=>Z(e)==="x"?"left":"top",wi=e=>Yn.safeParse(e).success,Oi=e=>Z(e)==="x"?"signedWidth":"signedHeight",xi=e=>e==="center"?!1:Z(e)==="x",Ii=e=>Z(e)==="y",Ni=Object.freeze(Object.defineProperty({__proto__:null,DIRECTIONS:Yt,construct:Z,crude:Yn,dimension:pi,direction:$e,isDirection:wi,isX:xi,isY:Ii,location:bi,signedDimension:Oi,swap:mi},Symbol.toStringTag,{value:"Module"})),vi=Ue,Mi=je,Ai=ue,Si={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},Ei={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},Ti=Js,et=e=>e instanceof String||!Yt.includes(e)?e:e==="x"?"left":"top",$i=e=>Si[et(e)],zi=(e,t)=>Ei[e][t],It=e=>{const t=et(e);return t==="top"||t==="bottom"?"y":"x"},Ui=c.z.object({x:Ue.or(ue),y:je.or(ue)}),Re=c.z.object({x:Ue,y:je}),ft=Object.freeze({x:"left",y:"top"}),Pe=Object.freeze({x:"right",y:"top"}),Dt=Object.freeze({x:"left",y:"bottom"}),ke=Object.freeze({x:"right",y:"bottom"}),Le=Object.freeze({x:"center",y:"center"}),Ze=Object.freeze({x:"center",y:"top"}),_e=Object.freeze({x:"center",y:"bottom"}),qe=Object.freeze({x:"right",y:"center"}),Fe=Object.freeze({x:"left",y:"center"}),ji=Object.freeze([Fe,qe,Ze,_e,ft,Pe,Dt,ke,Le]),We=(e,t)=>e.x===t.x&&e.y===t.y,Ci=(e,t)=>{if(typeof t=="object"){let n=!0;return"x"in t&&(e.x===t.x||(n=!1)),"y"in t&&(e.y===t.y||(n=!1)),n}return e.x===t||e.y===t},Gn=e=>[e.x,e.y],Rt=e=>It(et(e))==="x",Bi=e=>It(et(e))==="y",Ri=e=>`${e.x}${bn(e.y)}`,Pi=(e,t)=>{let n,r;if(typeof e=="object"&&"x"in e?(n=e.x,r=e.y):(n=et(e),r=et(t??e)),It(n)===It(r)&&n!=="center"&&r!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${n.toString()} - ${r.toString()}`);const s={...Le};return n==="center"?Rt(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:r==="center"?Rt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:Rt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n],s},ki=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:_e,BOTTOM_LEFT:Dt,BOTTOM_RIGHT:ke,CENTER:Le,CENTER_LEFT:Fe,CENTER_LOCATIONS:Ce,CENTER_RIGHT:qe,OUTER_LOCATIONS:ze,TOP_CENTER:Ze,TOP_LEFT:ft,TOP_RIGHT:Pe,XY_LOCATIONS:ji,X_LOCATIONS:Gt,Y_LOCATIONS:Ht,center:Ai,construct:et,constructXY:Pi,corner:Re,crude:Ti,direction:It,isX:Rt,isY:Bi,location:Be,outer:Ws,rotate:zi,swap:$i,x:vi,xy:Ui,xyCouple:Gn,xyEquals:We,xyMatches:Ci,xyToString:Ri,y:Mi},Symbol.toStringTag,{value:"Module"})),de=c.z.union([c.z.number(),ut,Pn,Te,Fs,Ln]),x=(e,t)=>{if(typeof e=="string"){if(t===void 0)throw new 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}},q=Object.freeze({x:0,y:0}),Hn=Object.freeze({x:1,y:1}),Li=Object.freeze({x:1/0,y:1/0}),Zi=Object.freeze({x:NaN,y:NaN}),qt=(e,t,n=0)=>{const r=x(e),s=x(t);return n===0?r.x===s.x&&r.y===s.y:Math.abs(r.x-s.x)<=n&&Math.abs(r.y-s.y)<=n},_i=e=>qt(e,q),Ve=(e,t,n)=>{const r=x(e),s=x(t,n);return{x:r.x*s.x,y:r.y*s.y}},Dn=(e,t)=>{const n=x(e);return{x:n.x+t,y:n.y}},Jn=(e,t)=>{const n=x(e);return{x:n.x,y:n.y+t}},Nt=(e,t,n,...r)=>{if(typeof t=="string"){if(typeof n!="number")throw new Error("The value must be a number.");return t==="x"?Dn(e,n):Jn(e,n)}if(typeof t=="object"&&"x"in t&&typeof t.x=="string"){const s=x(n),i=x(e);return t.x==="left"?s.x=-s.x:t.x==="center"&&(s.x=0),t.y==="top"?s.y=-s.y:t.y==="center"&&(s.y=0),{x:i.x+s.x,y:i.y+s.y}}return[e,t,n??q,...r].reduce((s,i)=>{const o=x(i);return{x:s.x+o.x,y:s.y+o.y}},q)},qi=(e,t,n)=>{const r=x(e);return Z(t)==="x"?{x:n,y:r.y}:{x:r.x,y:n}},Fi=(e,t)=>{const n=x(e),r=x(t);return Math.sqrt((n.x-r.x)**2+(n.y-r.y)**2)},Wi=(e,t)=>{const n=x(e),r=x(t);return{x:r.x-n.x,y:r.y-n.y}},Vi=e=>{const t=x(e);return Number.isNaN(t.x)||Number.isNaN(t.y)},Yi=e=>{const t=x(e);return Number.isFinite(t.x)&&Number.isFinite(t.y)},Gi=e=>{const t=x(e);return[t.x,t.y]},Hi=e=>{const t=x(e);return{left:t.x,top:t.y}},Ft=(e,t=0)=>{const n=x(e);return{x:Number(n.x.toFixed(t)),y:Number(n.y.toFixed(t))}},dt=(e,t)=>{const n=x(e),r=x(t);return{x:n.x-r.x,y:n.y-r.y}},gt=e=>{const t=x(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:-t.y/n,y:t.x/n}},Xn=e=>{const t=x(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:t.x/n,y:t.y/n}},Kn=(...e)=>{const t=e.reduce((n,r)=>Nt(n,r),q);return Ve(t,1/e.length)},Di=(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const s=e[r];let i,o,u,a;if(r===0){const l=e[r+1],h=dt(l,s);o=gt(h),u=o,a=t}else if(r===e.length-1){const l=e[r-1],h=dt(s,l);i=gt(h),u=i,a=t}else{const l=e[r-1],h=e[r+1],y=dt(s,l),m=dt(h,s);i=gt(y),o=gt(m);const A=Math.acos((y.x*m.x+y.y*m.y)/(Math.hypot(y.x,y.y)*Math.hypot(m.x,m.y))),E=Math.sin(A/2);E===0?a=t:a=t/E,u=Xn(Kn(i,o))}n.push(Ve(u,a))}return n},Ji=e=>{const t=x(e);return{x:t.y,y:t.x}},ge=e=>{const t=x(e);return{x:Math.round(t.x),y:Math.round(t.y)}},Xi=e=>{const t=x(e);return{x:1/t.x,y:1/t.y}},Ki=(e,t,n)=>{const r=x(e),s=x(t),i=n==="clockwise"?Math.PI/2:-Math.PI/2,o=r.x-s.x,u=r.y-s.y,a=o*Math.cos(i)-u*Math.sin(i),l=o*Math.sin(i)+u*Math.cos(i);return{x:a+s.x,y:l+s.y}},Qi=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Li,NAN:Zi,ONE:Hn,ZERO:q,average:Kn,calculateMiters:Di,clientXY:Ln,construct:x,couple:Gi,crudeZ:de,css:Hi,distance:Fi,equals:qt,isFinite:Yi,isNan:Vi,isZero:_i,normal:gt,normalize:Xn,reciprocal:Xi,rotate:Ki,round:ge,scale:Ve,set:qi,sub:dt,swap:Ji,translate:Nt,translateX:Dn,translateY:Jn,translation:Wi,truncate:Ft,xy:ut},Symbol.toStringTag,{value:"Module"})),zt=c.z.union([c.z.number(),c.z.string()]),to=c.z.object({top:zt,left:zt,width:zt,height:zt}),eo=c.z.object({left:c.z.number(),top:c.z.number(),right:c.z.number(),bottom:c.z.number()}),no=c.z.object({one:ut,two:ut,root:Re}),Qn={one:q,two:q,root:ft},ro={one:q,two:Hn,root:Dt},tr=(e,t)=>({one:e.one,two:e.two,root:t??e.root}),N=(e,t,n=0,r=0,s)=>{const i={one:{...q},two:{...q},root:s??ft};if(typeof e=="number"){if(typeof t!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:e,y:t},i.two={x:i.one.x+n,y:i.one.y+r},i}return"one"in e&&"two"in e&&"root"in e?{...e,root:s??e.root}:("getBoundingClientRect"in e&&(e=e.getBoundingClientRect()),"left"in e?(i.one={x:e.left,y:e.top},i.two={x:e.right,y:e.bottom},i):(i.one=e,t==null?i.two={x:i.one.x+n,y:i.one.y+r}:typeof t=="number"?i.two={x:i.one.x+t,y:i.one.y+n}:"width"in t?i.two={x:i.one.x+t.width,y:i.one.y+t.height}:"signedWidth"in t?i.two={x:i.one.x+t.signedWidth,y:i.one.y+t.signedHeight}:i.two=t,i))},so=(e,t,n)=>{const r=N(e);if(typeof t=="string"){if(n==null)throw new Error("Invalid arguments for resize");const s=Z(t);return N(r.one,void 0,s==="x"?n:$(r),s==="y"?n:z(r),r.root)}return N(r.one,t,void 0,void 0,r.root)},io=(e,t,n=!0)=>{const r=N(e);let s=(i,o)=>i<o;return n&&(s=(i,o)=>i<=o),"one"in t?s(J(r),J(t))&&s(Q(t),Q(r))&&s(X(r),X(t))&&s(tt(t),tt(r)):s(J(r),t.x)&&s(t.x,Q(r))&&s(X(r),t.y)&&s(t.y,tt(r))},oo=(e,t)=>qt(e.one,t.one)&&qt(e.two,t.two)&&We(e.root,t.root),er=e=>({width:$(e),height:z(e)}),co=e=>({signedWidth:Jt(e),signedHeight:Xt(e)}),uo=e=>({top:X(e),left:J(e),width:$(e),height:z(e)}),Ye=(e,t,n=!1)=>{const r=Z(t)==="y"?Xt(e):Jt(e);return n?r:Math.abs(r)},H=(e,t)=>{const n=N(e);return{x:t.x==="center"?ye(n).x:nt(n,t.x),y:t.y==="center"?ye(n).y:nt(n,t.y)}},nt=(e,t)=>{const n=N(e),r=Gn(n.root).includes(t)?Math.min:Math.max;return Gt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},ao=e=>sr(e)===0,$=e=>Ye(e,"x"),z=e=>Ye(e,"y"),Jt=e=>{const t=N(e);return t.two.x-t.one.x},Xt=e=>{const t=N(e);return t.two.y-t.one.y},nr=e=>H(e,ft),lo=e=>H(e,Ze),fo=e=>H(e,Pe),ho=e=>H(e,Dt),go=e=>H(e,_e),yo=e=>H(e,ke),mo=e=>H(e,Fe),po=e=>H(e,qe),Q=e=>nt(e,"right"),tt=e=>nt(e,"bottom"),J=e=>nt(e,"left"),X=e=>nt(e,"top"),ye=e=>Nt(nr(e),{x:Jt(e)/2,y:Xt(e)/2}),Ge=e=>{const t=N(e);return t.root.x==="left"?J(t):Q(t)},He=e=>{const t=N(e);return t.root.y==="top"?X(t):tt(t)},bo=e=>({x:Ge(e),y:He(e)}),Pt=e=>{const t=N(e);return{lower:t.one.x,upper:t.two.x}},kt=e=>{const t=N(e);return{lower:t.one.y,upper:t.two.y}},wo=(e,t)=>tr(e,t),Oo=(e,t)=>{const n=N(e),r=Gt.includes(t)?"x":Ht.includes(t)?"y":null;if(r===null)throw new Error(`Invalid location: ${t}`);const s=t==="top"||t==="left"?Math.min:Math.max,i={...n.one},o={...n.two};return i[r]=s(n.one[r],n.two[r]),o[r]=s(n.one[r],n.two[r]),[i,o]},xo=(e,t)=>{const n=N(e),r=N(t),s=Ge(r)+($(r)-$(n))/2,i=He(r)+(z(r)-z(n))/2;return N({x:s,y:i},er(n))},rr=e=>typeof e!="object"||e==null?!1:"one"in e&&"two"in e&&"root"in e,Io=e=>$(e)/z(e),No=(e,t,n)=>{if(typeof t=="string"){if(n==null)throw new Error("Undefined amount passed into box.translate");const s=Z(t);t=x(s,n)}const r=N(e);return N(Nt(r.one,t),Nt(r.two,t),void 0,void 0,r.root)},vo=(e,t)=>{const n=Math.max(J(e),J(t)),r=Math.max(X(e),X(t)),s=Math.min(Q(e),Q(t)),i=Math.min(tt(e),tt(t));return n>s||r>i?Qn:N({x:n,y:r},{x:s,y:i},void 0,void 0,e.root)},sr=e=>$(e)*z(e),Mo=(e,t)=>{const n=N(e);return N(Ft(n.one,t),Ft(n.two,t),void 0,void 0,n.root)},Ao=(e,t,n,r,s,i)=>{const o={x:e,y:t},u={x:e+n,y:t+r};return s.x!==i.x&&(s.x==="center"?(o.x-=n/2,u.x-=n/2):(o.x-=n,u.x-=n)),s.y!==i.y&&(s.y==="center"?(o.y-=r/2,u.y-=r/2):(o.y-=r,u.y-=r)),N(o,u,void 0,void 0,i)},So=e=>{const t=N(e);return N(ge(t.one),ge(t.two),void 0,void 0,t.root)},Eo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:ro,ZERO:Qn,area:sr,areaIsZero:ao,aspect:Io,bottom:tt,bottomCenter:go,bottomLeft:ho,bottomRight:yo,box:no,center:ye,centerLeft:mo,centerRight:po,construct:N,constructWithAlternateRoot:Ao,contains:io,copy:tr,css:uo,cssBox:to,dim:Ye,dims:er,domRect:eo,edgePoints:Oo,equals:oo,height:z,intersection:vo,isBox:rr,left:J,loc:nt,positionInCenter:xo,reRoot:wo,resize:so,right:Q,root:bo,round:So,signedDims:co,signedHeight:Xt,signedWidth:Jt,top:X,topCenter:lo,topLeft:nr,topRight:fo,translate:No,truncate:Mo,width:$,x:Ge,xBounds:Pt,xyLoc:H,y:He,yBounds:kt},Symbol.toStringTag,{value:"Module"})),ir=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),To=c.z.union([Te,ir,ut,Pn]),$o={width:0,height:0},zo={width:1,height:1},L=(e,t)=>typeof e=="number"?{width:e,height:t??e}:Array.isArray(e)?{width:e[0],height:e[1]}:"x"in e?{width:e.x,height:e.y}:"signedWidth"in e?{width:e.signedWidth,height:e.signedHeight}:{...e},Uo=(e,t)=>{if(t==null)return!1;const n=L(e),r=L(t);return n.width===r.width&&n.height===r.height},jo=e=>{const t=L(e);return{width:t.height,height:t.width}},Co=e=>{const t=L(e);return`0 0 ${t.width} ${t.height}`},Bo=e=>{const t=L(e);return[t.width,t.height]},Ro=e=>({width:Math.max(...e.map(t=>L(t).width)),height:Math.max(...e.map(t=>L(t).height))}),Po=e=>({width:Math.min(...e.map(t=>L(t).width)),height:Math.min(...e.map(t=>L(t).height))}),ko=(e,t)=>{const n=L(e);return{width:n.width*t,height:n.height*t}},Lo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:zo,ZERO:$o,construct:L,couple:Bo,crude:To,dimensions:Te,equals:Uo,max:Ro,min:Po,scale:ko,signed:ir,svgViewBox:Co,swap:jo},Symbol.toStringTag,{value:"Module"})),or=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e,Zo=c.z.object({offset:de,scale:de}),_o=c.z.object({offset:c.z.number(),scale:c.z.number()}),qo=e=>(t,n,r,s)=>n==="dimension"?[t,r]:[t,s?r-e:r+e],Fo=e=>(t,n,r,s)=>[t,s?r/e:r*e],Wo=e=>(t,n,r)=>{if(t===null)return[e,r];const{lower:s,upper:i}=t,{lower:o,upper:u}=e,a=i-s,l=u-o;if(n==="dimension")return[e,r*(l/a)];const h=(r-s)*(l/a)+o;return[e,h]},Vo=e=>(t,n,r)=>[e,r],Yo=()=>(e,t,n)=>{if(e===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[e,n];const{lower:r,upper:s}=e;return[e,s-(n-r)]},Go=e=>(t,n,r)=>{const{lower:s,upper:i}=e;return r=or(r,s,i),[t,r]};class F{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new F().translate(t)}static magnify(t){return new F().magnify(t)}static scale(t,n){return new F().scale(t,n)}translate(t){const n=this.new(),r=qo(t);return r.type="translate",n.ops.push(r),n}magnify(t){const n=this.new(),r=Fo(t);return r.type="magnify",n.ops.push(r),n}scale(t,n){const r=w(t,n),s=this.new(),i=Wo(r);return i.type="scale",s.ops.push(i),s}clamp(t,n){const r=w(t,n),s=this.new(),i=Go(r);return i.type="clamp",s.ops.push(i),s}reBound(t,n){const r=w(t,n),s=this.new(),i=Vo(r);return i.type="re-bound",s.ops.push(i),s}invert(){const t=Yo();t.type="invert";const n=this.new();return n.ops.push(t),n}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new F;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,n){return this.currBounds=null,this.ops.reduce(([r,s],i)=>i(r,t,s,this.reversed),[null,n])[1]}reverse(){const t=this.new();t.ops.reverse();const n=[];return t.ops.forEach((r,s)=>{if(r.type==="scale"||n.some(([o,u])=>s>=o&&s<=u))return;const i=t.ops.findIndex((o,u)=>o.type==="scale"&&u>s);i!==-1&&n.push([s,i])}),n.forEach(([r,s])=>{const i=t.ops.slice(r,s);i.unshift(t.ops[s]),t.ops.splice(r,s-r+1,...i)}),t.reversed=!t.reversed,t}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new F}class B{x;y;currRoot;constructor(t=new F,n=new F,r=null){this.x=t,this.y=n,this.currRoot=r}static translate(t,n){return new B().translate(t,n)}static translateX(t){return new B().translateX(t)}static translateY(t){return new B().translateY(t)}static clamp(t){return new B().clamp(t)}static magnify(t){return new B().magnify(t)}static scale(t){return new B().scale(t)}static reBound(t){return new B().reBound(t)}translate(t,n){const r=x(t,n),s=this.copy();return s.x=this.x.translate(r.x),s.y=this.y.translate(r.y),s}translateX(t){const n=this.copy();return n.x=this.x.translate(t),n}translateY(t){const n=this.copy();return n.y=this.y.translate(t),n}magnify(t){const n=this.copy();return n.x=this.x.magnify(t.x),n.y=this.y.magnify(t.y),n}scale(t){const n=this.copy();if(rr(t)){const r=this.currRoot;return n.currRoot=t.root,r!=null&&!We(r,t.root)&&(r.x!==t.root.x&&(n.x=n.x.invert()),r.y!==t.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(Pt(t)),n.y=n.y.scale(kt(t)),n}return n.x=n.x.scale(t.width),n.y=n.y.scale(t.height),n}reBound(t){const n=this.copy();return n.x=this.x.reBound(Pt(t)),n.y=this.y.reBound(kt(t)),n}clamp(t){const n=this.copy();return n.x=this.x.clamp(Pt(t)),n.y=this.y.clamp(kt(t)),n}copy(){const t=new B;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}dim(t){return{x:this.x.dim(t.x),y:this.y.dim(t.y)}}box(t){return N(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new B}const Ho=Object.freeze(Object.defineProperty({__proto__:null,Scale:F,XY:B,crudeXYTransform:Zo,transform:_o},Symbol.toStringTag,{value:"Module"})),Do=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:kn,ORDERS:Zn,alignment:Ys,order:Gs},Symbol.toStringTag,{value:"Module"})),cr=ut.extend({root:Re,units:c.object({x:c.enum(["px","decimal"]),y:c.enum(["px","decimal"])})}),Jo=cr.partial({root:!0,units:!0}),Xo=e=>{const t={};return t[e.root?.x??"left"]=e?.units?.x==="px"?`${e.x}px`:`${e.x*100}%`,t[e.root?.y??"top"]=e?.units?.y==="px"?`${e.y}px`:`${e.y*100}%`,t},Ko=({position:e,element:t,container:n})=>{const r={x:e.x,y:e.y};return e.units?.x==="decimal"?e.root?.x==="right"&&(r.x=1-e.x):e.root?.x==="right"?r.x=1-(e.x+$(t))/$(n):r.x/=$(n),e.units?.y==="decimal"?e.root?.y==="bottom"&&(r.y=1-e.y):e.root?.y==="bottom"?r.y=1-(e.y+z(t))/z(n):r.y/=z(n),r},Qo=({position:e,element:t,container:n,lowerThreshold:r=.2,upperThreshold:s=.8})=>{const i={x:e.x,y:e.y,root:{...ft},units:{x:"px",y:"px"}};return e.x>s?(i.x=(1-e.x)*$(n)-$(t),i.root.x="right"):e.x<r?i.x=e.x*$(n):i.units.x="decimal",e.y>s?(i.y=(1-e.y)*z(n)-z(t),i.root.y="bottom"):e.y<r?i.y=e.y*z(n):i.units.y="decimal",i.x=Math.round(i.x*100)/100,{...i,...Ft(i,3)}},tc=Object.freeze(Object.defineProperty({__proto__:null,calculate:Qo,completeXY:cr,toCSS:Xo,toDecimal:Ko,xy:Jo},Symbol.toStringTag,{value:"Module"})),ec=c.z.enum(["static","dynamic"]),cn=365,Ut=30,nc=c.z.union([c.z.tuple([c.z.int()]),c.z.tuple([c.z.int(),c.z.int().min(1).max(12)]),c.z.tuple([c.z.int(),c.z.int().min(1).max(12),c.z.int().min(1).max(31)])]),ur=(e,t)=>{const n=new d(t);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.NANOSECOND].some(s=>s.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=e.valueOf()%n.valueOf();return e instanceof d?new d(r):new g(r)};class d extends rt{constructor(t,n="UTC"){if(t==null)super(d.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*d.MILLISECOND.valueOf());else if(typeof t=="string")super(d.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(d.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n==="local"&&(r=d.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t===Cn?t=Zt:t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=d.MAX:t=d.MIN)),j(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){const s=new Date(t,n-1,r,0,0,0,0);return new d(BigInt(s.getTime())*d.MILLISECOND.valueOf()).truncate(d.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n="UTC"){const[r,s,i]=t.split(":");let o="00",u="00";i!=null&&([o,u]=i.split("."));let a=d.hours(parseInt(r??"00")).add(d.minutes(parseInt(s??"00"))).add(d.seconds(parseInt(o??"00"))).add(d.milliseconds(parseInt(u??"00")));return n==="local"&&(a=a.add(d.utcOffset)),a.valueOf()}static parseDateTimeString(t,n="UTC"){if(!t.includes("/")&&!t.includes("-"))return d.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let i=t,o=0;if(t.includes(".")){const h=t.split(".");i=h[0];const y=h[1]||"0";o=parseInt(y.padEnd(3,"0").slice(0,3))}const u=n==="local"?new Date(i.replace("T"," ")):new Date(`${i}Z`),a=BigInt(u.getTime())*d.MILLISECOND.valueOf(),l=BigInt(o)*d.MILLISECOND.valueOf();return a+l}const s=new Date(t);return t.includes(":")||s.setUTCHours(0,0,0,0),new d(BigInt(s.getTime())*d.MILLISECOND.valueOf(),n).valueOf()}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(d.utcOffset).date().toISOString()}timeString(t=!1,n="UTC"){const r=this.toISOString(n);return t?r.slice(11,23):r.slice(11,19)}dateString(){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new g(BigInt(new Date().getTimezoneOffset())*d.MINUTE.valueOf())}static since(t){return new d().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new d(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new d(t).valueOf()}afterEq(t){return this.valueOf()>=new d(t).valueOf()}before(t){return this.valueOf()<new d(t).valueOf()}beforeEq(t){return this.valueOf()<=new d(t).valueOf()}add(t){return new d(Y(this.valueOf(),new g(t).valueOf()))}sub(t){return new d(_(this.valueOf(),new g(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(d.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(d.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(t){const n=this.date();return n.setUTCFullYear(t),new d(n)}get month(){return this.date().getUTCMonth()}setMonth(t){const n=this.date();return n.setUTCMonth(t),new d(n)}get day(){return this.date().getUTCDate()}setDay(t){const n=this.date();return n.setUTCDate(t),new d(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){const n=this.date();return n.setHours(t),new d(n)}setHour(t){const n=this.date();return n.setUTCHours(t),new d(n)}get minute(){return this.date().getUTCMinutes()}setMinute(t){const n=this.date();return n.setUTCMinutes(t),new d(n)}get second(){return this.date().getUTCSeconds()}setSecond(t){const n=this.date();return n.setUTCSeconds(t),new d(n)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(t){const n=this.date();return n.setUTCMilliseconds(t),new d(n)}toString(t="ISO",n="UTC"){switch(t){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}remainder(t){return ur(this,t)}get isToday(){return this.truncate(g.DAY).equals(d.now().truncate(g.DAY))}truncate(t){return this.sub(this.remainder(t))}formatBySpan(t){return t.greaterThanOrEqual(g.days(30))?"shortDate":t.greaterThanOrEqual(g.DAY)?"dateTime":t.greaterThanOrEqual(g.HOUR)?"time":t.greaterThanOrEqual(g.SECOND)?"preciseTime":"ISOTime"}static now(){return new d(new Date)}static max(...t){let n=d.MIN;for(const r of t){const s=new d(r);s.after(n)&&(n=s)}return n}static min(...t){let n=d.MAX;for(const r of t){const s=new d(r);s.before(n)&&(n=s)}return n}static nanoseconds(t,n="UTC"){return new d(t,n)}static NANOSECOND=d.nanoseconds(1);static microseconds(t,n="UTC"){return d.nanoseconds(t*1e3,n)}static MICROSECOND=d.microseconds(1);static milliseconds(t,n="UTC"){return d.microseconds(t*1e3,n)}static MILLISECOND=d.milliseconds(1);static seconds(t,n="UTC"){return d.milliseconds(t*1e3,n)}static SECOND=d.seconds(1);static minutes(t,n="UTC"){return d.seconds(t*60,n)}static MINUTE=d.minutes(1);static hours(t,n="UTC"){return d.minutes(t*60,n)}static HOUR=d.hours(1);static days(t,n="UTC"){return d.hours(t*24,n)}static DAY=d.days(1);static MAX=new d(Zt);static MIN=new d(0);static ZERO=new d(0);static z=c.z.union([c.z.instanceof(d),c.z.object({value:c.z.bigint()}).transform(t=>new d(t.value)),c.z.string().transform(t=>new d(BigInt(t))),c.z.number().transform(t=>new d(t)),c.z.bigint().transform(t=>new d(t)),c.z.date().transform(t=>new d(t)),c.z.custom(t=>t instanceof g).transform(t=>new d(t)),nc.transform(t=>new d(t))]);static sort(t,n){return Number(t.valueOf()-n.valueOf())}}class g extends rt{constructor(t){typeof t=="number"&&(t=Math.trunc(t.valueOf())),j(t)&&(t=t.value),super(BigInt(t.valueOf()))}static fromSeconds(t){return t instanceof g?t:t instanceof T?t.period:t instanceof d?new g(t):(j(t)&&(t=t.value),["number","bigint"].includes(typeof t)?g.seconds(t):new g(t))}static fromMilliseconds(t){return t instanceof g?t:t instanceof T?t.period:t instanceof d?new g(t):(j(t)&&(t=t.value),["number","bigint"].includes(typeof t)?g.milliseconds(t):new g(t))}valueOf(){return this.value}lessThan(t){return this.valueOf()<new g(t).valueOf()}greaterThan(t){return this.valueOf()>new g(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new g(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new g(t).valueOf()}remainder(t){return ur(this,t)}truncate(t){return new g(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t="full"){if(t==="semantic")return this.toSemanticString();const n=this.truncate(g.DAY),r=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),u=this.truncate(g.MICROSECOND),a=this.truncate(g.NANOSECOND),l=n,h=r.sub(n),y=s.sub(r),m=i.sub(s),A=o.sub(i),E=u.sub(o),C=a.sub(u);let O="";return l.isZero||(O+=`${l.days}d `),h.isZero||(O+=`${h.hours}h `),y.isZero||(O+=`${y.minutes}m `),m.isZero||(O+=`${m.seconds}s `),A.isZero||(O+=`${A.milliseconds}ms `),E.isZero||(O+=`${E.microseconds}µs `),C.isZero||(O+=`${C.nanoseconds}ns`),O.trim()}toSemanticString(){const t=this.valueOf()<0n?-this.valueOf():this.valueOf(),n=new g(t),r=this.valueOf()<0n;if(n.valueOf()===0n)return"0s";if(n.lessThan(g.SECOND))return"< 1s";const s=n.days,i=n.hours,o=n.minutes,u=n.seconds,a=Math.floor(s/cn),l=Math.floor(s/Ut),h=Math.floor(s/7),y=Math.floor(s),m=Math.floor(i),A=Math.floor(o),E=Math.floor(u),C=r?"-":"";if(a>=1){let O=`${a}y`;if(a<2){const v=Math.floor(s%cn/Ut);v>0&&(O+=` ${v}mo`)}return C+O}if(h>=1&&s<Ut&&s%7===0){let O=`${h}w`;const v=Math.floor(s%7),K=Math.floor(i-h*7*24);return h<2&&(v>0?O+=` ${v}d`:K>0&&K<24&&(O+=` ${K}h`)),C+O}if(l>=1){let O=`${l}mo`;if(l<3){const v=Math.floor(s%Ut);v>0&&(O+=` ${v}d`)}return C+O}if(h>=1){let O=`${h}w`;const v=Math.floor(s%7),K=Math.floor(i-h*7*24);return h<2&&(v>0?O+=` ${v}d`:K>0&&K<24&&(O+=` ${K}h`)),C+O}if(y>=1){let O=`${y}d`;const v=Math.floor(i-y*24);return y<2&&v>0&&(O+=` ${v}h`),C+O}if(m>=1){let O=`${m}h`;if(m<3){const v=Math.floor(o-m*60);v>0&&(O+=` ${v}m`)}return C+O}if(A>=1){let O=`${A}m`;if(A<5){const v=Math.floor(u-A*60);v>0&&(O+=` ${v}s`)}return C+O}return`${C}${E}s`}mult(t){return new g(R(this.valueOf(),t))}div(t){return new g(St(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new g(t).valueOf()}add(t){return new g(this.valueOf()+new g(t).valueOf())}sub(t){return new g(this.valueOf()-new g(t).valueOf())}static nanoseconds(t=1){return new g(t)}static NANOSECOND=g.nanoseconds(1);static microseconds(t=1){return g.nanoseconds(R(t,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(t=1){return g.microseconds(R(t,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(t=1){return g.milliseconds(R(t,1e3))}static SECOND=g.seconds(1);static minutes(t=1){return g.seconds(R(t,60))}static MINUTE=g.minutes(1);static hours(t){return g.minutes(R(t,60))}static HOUR=g.hours(1);static days(t){return g.hours(R(t,24))}static DAY=g.days(1);static MAX=new g(Zt);static MIN=new g(0);static ZERO=new g(0);static z=c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new g(t.value)),c.z.string().transform(t=>new g(BigInt(t))),c.z.number().transform(t=>new g(t)),c.z.bigint().transform(t=>new g(t)),c.z.instanceof(g),c.z.instanceof(d).transform(t=>new g(t)),c.z.custom(t=>t instanceof T).transform(t=>new g(t))])}class T extends rt{constructor(t){j(t)&&(t=t.value),super(t.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new T(t).valueOf()}get period(){return g.seconds(1/this.valueOf())}sampleCount(t){return new g(t).seconds*this.valueOf()}byteCount(t,n){return this.sampleCount(t)*new b(n).valueOf()}span(t){return g.seconds(t/this.valueOf())}byteSpan(t,n){return this.span(t.valueOf()/new b(n).valueOf())}add(t){return new T(Y(this.valueOf(),new T(t).valueOf()))}sub(t){return new T(_(this.valueOf(),new T(t).valueOf()))}mult(t){return new T(R(this.valueOf(),t))}div(t){return new T(St(this.valueOf(),t))}static hz(t){return new T(t)}static khz(t){return T.hz(t*1e3)}static z=c.z.union([c.z.number().transform(t=>new T(t)),c.z.instanceof(T)])}class b extends rt{constructor(t){j(t)&&(t=t.value),super(t.valueOf())}length(t){return t.valueOf()/this.valueOf()}size(t){return new p(t*this.valueOf())}add(t){return new b(Y(this.valueOf(),new b(t).valueOf()))}sub(t){return new b(_(this.valueOf(),new b(t).valueOf()))}mult(t){return new b(R(this.valueOf(),t))}div(t){return new b(St(this.valueOf(),t))}static UNKNOWN=new b(0);static BIT128=new b(16);static BIT64=new b(8);static BIT32=new b(4);static BIT16=new b(2);static BIT8=new b(1);static z=c.z.union([c.z.number().transform(t=>new b(t)),c.z.instanceof(b)])}class M{start;end;constructor(t,n){typeof t=="object"&&"start"in t?(this.start=new d(t.start),this.end=new d(t.end)):(this.start=new d(t),this.end=new d(n))}get span(){return new g(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 M(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(t,n=g.ZERO){if(n.isZero)return this.start.equals(t.start)&&this.end.equals(t.end);let r=this.start.sub(t.start).valueOf(),s=this.end.sub(t.end).valueOf();return r<0&&(r=-r),s<0&&(s=-s),r<=n.valueOf()&&s<=n.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,n=g.ZERO){t=t.makeValid();const r=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(r.start)||r.end.equals(t.start))return!1;const s=d.max(r.start,t.start),i=d.min(r.end,t.end);return i.before(s)?!1:new g(i.sub(s)).greaterThanOrEqual(n)}contains(t){return t instanceof M?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const n=new M(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 M(d.min(...t.map(n=>n.start)),d.max(...t.map(n=>n.end)))}static MAX=new M(d.MIN,d.MAX);static ZERO=new M(d.ZERO,d.ZERO);static z=c.z.union([c.z.object({start:d.z,end:d.z}).transform(t=>new M(t.start,t.end)),c.z.instanceof(M)]);static sort(t,n){return d.sort(t.start,n.start)||d.sort(t.end,n.end)}static merge(...t){return M.max(...t.map(n=>new M(n).makeValid()))}}class f extends rt{constructor(t){if(j(t)&&(t=t.value),t instanceof f||typeof t=="string"||typeof t.valueOf()=="string")super(t.valueOf());else{const n=f.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw new Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){const t=f.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(n=>this.equals(n))}toString(t=!1){return t?f.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(f.JSON)||this.equals(f.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(f.UUID)}get isInteger(){const t=this.toString();return t.startsWith("int")||t.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=f.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(f.UINT8)||this.equals(f.UINT16)||this.equals(f.UINT32)||this.equals(f.UINT64)}get isSignedInteger(){return this.equals(f.INT8)||this.equals(f.INT16)||this.equals(f.INT32)||this.equals(f.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(f.INT32)&&t.equals(f.FLOAT64)||this.equals(f.INT8)&&t.equals(f.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}get usesBigInt(){return f.BIG_INT_TYPES.some(t=>t.equals(this))}static UNKNOWN=new f("unknown");static FLOAT64=new f("float64");static FLOAT32=new f("float32");static INT64=new f("int64");static INT32=new f("int32");static INT16=new f("int16");static INT8=new f("int8");static UINT64=new f("uint64");static UINT32=new f("uint32");static UINT16=new f("uint16");static UINT8=new f("uint8");static BOOLEAN=new f("boolean");static TIMESTAMP=new f("timestamp");static UUID=new f("uuid");static STRING=new f("string");static JSON=new f("json");static ARRAY_CONSTRUCTORS=new Map([[f.UINT8.toString(),Uint8Array],[f.UINT16.toString(),Uint16Array],[f.UINT32.toString(),Uint32Array],[f.UINT64.toString(),BigUint64Array],[f.FLOAT32.toString(),Float32Array],[f.FLOAT64.toString(),Float64Array],[f.INT8.toString(),Int8Array],[f.INT16.toString(),Int16Array],[f.INT32.toString(),Int32Array],[f.INT64.toString(),BigInt64Array],[f.TIMESTAMP.toString(),BigInt64Array],[f.STRING.toString(),Uint8Array],[f.JSON.toString(),Uint8Array],[f.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,f.UINT8],[Uint16Array.name,f.UINT16],[Uint32Array.name,f.UINT32],[BigUint64Array.name,f.UINT64],[Float32Array.name,f.FLOAT32],[Float64Array.name,f.FLOAT64],[Int8Array.name,f.INT8],[Int16Array.name,f.INT16],[Int32Array.name,f.INT32],[BigInt64Array.name,f.INT64]]);static DENSITIES=new Map([[f.UINT8.toString(),b.BIT8],[f.UINT16.toString(),b.BIT16],[f.UINT32.toString(),b.BIT32],[f.UINT64.toString(),b.BIT64],[f.FLOAT32.toString(),b.BIT32],[f.FLOAT64.toString(),b.BIT64],[f.INT8.toString(),b.BIT8],[f.INT16.toString(),b.BIT16],[f.INT32.toString(),b.BIT32],[f.INT64.toString(),b.BIT64],[f.TIMESTAMP.toString(),b.BIT64],[f.STRING.toString(),b.UNKNOWN],[f.JSON.toString(),b.UNKNOWN],[f.UUID.toString(),b.BIT128]]);static ALL=[f.UNKNOWN,f.FLOAT64,f.FLOAT32,f.INT64,f.INT32,f.INT16,f.INT8,f.UINT64,f.UINT32,f.UINT16,f.UINT8,f.TIMESTAMP,f.UUID,f.STRING,f.JSON];static SHORT_STRINGS=new Map([[f.UINT8.toString(),"u8"],[f.UINT16.toString(),"u16"],[f.UINT32.toString(),"u32"],[f.UINT64.toString(),"u64"],[f.INT8.toString(),"i8"],[f.INT16.toString(),"i16"],[f.INT32.toString(),"i32"],[f.INT64.toString(),"i64"],[f.FLOAT32.toString(),"f32"],[f.FLOAT64.toString(),"f64"],[f.BOOLEAN.toString(),"bool"],[f.TIMESTAMP.toString(),"ts"],[f.UUID.toString(),"uuid"],[f.STRING.toString(),"str"],[f.JSON.toString(),"json"]]);static BIG_INT_TYPES=[f.INT64,f.UINT64,f.TIMESTAMP];static z=c.z.union([c.z.string().transform(t=>new f(t)),c.z.instanceof(f)])}class p extends rt{constructor(t){j(t)&&(t=t.value),super(t.valueOf())}largerThan(t){return j(t)&&(t=t.value),this.valueOf()>t.valueOf()}smallerThan(t){return j(t)&&(t=t.value),this.valueOf()<t.valueOf()}add(t){return j(t)&&(t=t.value),new p(Y(this.valueOf(),t.valueOf()))}sub(t){return j(t)&&(t=t.value),new p(_(this.valueOf(),t.valueOf()))}mult(t){return new p(R(this.valueOf(),t))}div(t){return new p(St(this.valueOf(),t))}truncate(t){return new p(Math.trunc(this.valueOf()/new p(t).valueOf())*new p(t).valueOf())}remainder(t){return p.bytes(this.valueOf()%new p(t).valueOf())}get gigabytes(){return this.valueOf()/p.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/p.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/p.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/p.TERABYTE.valueOf()}toString(){const t=this.truncate(p.TERABYTE),n=this.truncate(p.GIGABYTE),r=this.truncate(p.MEGABYTE),s=this.truncate(p.KILOBYTE),i=this.truncate(p.BYTE),o=t,u=n.sub(t),a=r.sub(n),l=s.sub(r),h=i.sub(s);let y="";return o.isZero||(y+=`${o.terabytes}TB `),u.isZero||(y+=`${u.gigabytes}GB `),a.isZero||(y+=`${a.megabytes}MB `),l.isZero||(y+=`${l.kilobytes}KB `),(!h.isZero||y==="")&&(y+=`${h.valueOf()}B`),y.trim()}static bytes(t=1){return new p(t)}static BYTE=new p(1);static kilobytes(t=1){return p.bytes(new p(t).valueOf()*1e3)}static KILOBYTE=p.kilobytes(1);static megabytes(t=1){return p.kilobytes(new p(t).valueOf()*1e3)}static MEGABYTE=p.megabytes(1);static gigabytes(t=1){return p.megabytes(new p(t).valueOf()*1e3)}static GIGABYTE=p.gigabytes(1);static terabytes(t){return p.gigabytes(new p(t).valueOf()*1e3)}static TERABYTE=p.terabytes(1);static ZERO=new p(0);static z=c.z.union([c.z.number().transform(t=>new p(t)),c.z.instanceof(p)]);get isZero(){return this.valueOf()===0}}const rc=c.z.object({start:c.z.number(),end:c.z.number()}),sc=c.z.union([c.z.instanceof(Uint8Array),c.z.instanceof(Uint16Array),c.z.instanceof(Uint32Array),c.z.instanceof(BigUint64Array),c.z.instanceof(Float32Array),c.z.instanceof(Float64Array),c.z.instanceof(Int8Array),c.z.instanceof(Int16Array),c.z.instanceof(Int32Array),c.z.instanceof(BigInt64Array)]),De=e=>{const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||e instanceof d||e instanceof g||e instanceof Date},ar=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(n)-Number(r):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):_(n,r),ic="00000000-0000-0000-0000-000000000000",oc=/^(?:[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 cc(e){return typeof e=="string"&&oc.test(e)}const S=[];for(let e=0;e<256;++e)S.push((e+256).toString(16).slice(1));function lr(e,t=0){return(S[e[t+0]]+S[e[t+1]]+S[e[t+2]]+S[e[t+3]]+"-"+S[e[t+4]]+S[e[t+5]]+"-"+S[e[t+6]]+S[e[t+7]]+"-"+S[e[t+8]]+S[e[t+9]]+"-"+S[e[t+10]]+S[e[t+11]]+S[e[t+12]]+S[e[t+13]]+S[e[t+14]]+S[e[t+15]]).toLowerCase()}function uc(e,t=0){const n=lr(e,t);if(!cc(n))throw TypeError("Stringified UUID is invalid");return n}let ne;const ac=new Uint8Array(16);function lc(){if(!ne){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ne=crypto.getRandomValues.bind(crypto)}return ne(ac)}const fc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),un={randomUUID:fc};function hc(e,t,n){e=e||{};const r=e.random??e.rng?.()??lc();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,lr(r)}function dc(e,t,n){return un.randomUUID&&!e?un.randomUUID():hc(e)}const gc=()=>dc(),Je=(e,t)=>uc(e,t),yc=ic,mc=Object.freeze(Object.defineProperty({__proto__:null,ZERO:yc,create:gc,parse:Je},Symbol.toStringTag,{value:"Module"})),D=-1,me={[Symbol.iterator]:()=>me,next:()=>({done:!0,value:void 0})},pc=c.z.string().transform(e=>new Uint8Array(atob(e).split("").map(t=>t.charCodeAt(0))).buffer),bc=c.z.union([c.z.null(),c.z.undefined()]).transform(()=>new Uint8Array().buffer),pe=10,fr=(e,t)=>{if(e==="number"&&!t.isNumeric)throw new Error(`cannot convert series of type ${t.toString()} to number`);if(e==="bigint"&&!t.usesBigInt)throw new Error(`cannot convert series of type ${t.toString()} to bigint`)},hr="sy_x_telem_series";class P{key;discriminator=hr;dataType;sampleOffset;gl;_data;timeRange=M.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=D;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=c.z.object({timeRange:M.z.optional(),dataType:f.z,alignment:c.z.coerce.bigint().optional(),data:c.z.union([pc,bc,c.z.instanceof(ArrayBuffer),c.z.instanceof(Uint8Array)]),glBufferUsage:ec.default("static").optional()});static z=P.crudeZ.transform(t=>new P(t));constructor(t){dr(t)&&(t={data:t}),t.data??=[];const{dataType:n,timeRange:r,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:u=1n,key:a=Ee(),data:l}=t;if(gr(l)){const m=l;this.key=m.key,this.dataType=m.dataType,this.sampleOffset=m.sampleOffset,this.gl=m.gl,this._data=m._data,this.timeRange=m.timeRange,this.alignment=m.alignment,this.alignmentMultiple=m.alignmentMultiple,this.cachedMin=m.cachedMin,this.cachedMax=m.cachedMax,this.writePos=m.writePos,this._refCount=m._refCount,this.cachedLength=m.cachedLength;return}const h=De(l),y=Array.isArray(l);if(n!=null)this.dataType=new f(n);else{if(l instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(y||h){let m=l;if(!h){if(l.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");m=l[0]}if(typeof m=="string")this.dataType=f.STRING;else if(typeof m=="number")this.dataType=f.FLOAT64;else if(typeof m=="bigint")this.dataType=f.INT64;else if(typeof m=="boolean")this.dataType=f.BOOLEAN;else if(m instanceof d||m instanceof Date||m instanceof d)this.dataType=f.TIMESTAMP;else if(typeof m=="object")this.dataType=f.JSON;else throw new Error(`cannot infer data type of ${typeof m} when constructing a Series from a JS array`)}else this.dataType=new f(l)}if(!y&&!h)this._data=l;else if(y&&l.length===0)this._data=new this.dataType.Array([]).buffer;else{let m=h?[l]:l;const A=m[0];(A instanceof d||A instanceof Date||A instanceof g)&&(m=m.map(E=>new d(E).valueOf())),this.dataType.equals(f.STRING)?(this.cachedLength=m.length,this._data=new TextEncoder().encode(`${m.join(`
|
|
3
|
+
`).map(a=>a.trim());if(r.length===0)return n!=null?n.parse({}):{};const i=r.split(",").map(a=>a.trim()),o={};return i.forEach(a=>{o[a]=[]}),s.forEach(a=>{const u=a.split(",").map(l=>l.trim());i.forEach((l,d)=>{const y=this.parseValue(u[d]);y!=null&&o[l].push(y)})}),n!=null?n.parse(o):o}parseValue(t){if(t==null||t.length===0)return null;const n=Number(t);return isNaN(n)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:n}}class xn{contentType="text/plain";encode(t){if(typeof t!="string")throw new Error("TextCodec.encode payload must be a string");return new TextEncoder().encode(t)}decode(t,n){const r=new TextDecoder().decode(t);return n!=null?n.parse(r):r}}const xt=new wn,os=new On,cs=new xn,as=[xt],us=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:On,CSV_CODEC:os,ENCODERS:as,JSONCodec:wn,JSON_CODEC:xt,TEXT_CODEC:cs,TextCodec:xn},Symbol.toStringTag,{value:"Module"})),j=e=>e!=null&&typeof e=="object"&&"value"in e;class rt{value;constructor(t){this.value=t}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const Se=e=>e!=null&&typeof e=="object"&&"toString"in e,In=e=>{if(Se(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}},ls=e=>!In(e),fs=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:rt,isCrudeValueExtension:j,isNonZero:ls,isStringer:Se,isZero:In},Symbol.toStringTag,{value:"Module"})),oe=e=>[...new Set(e)],hs=(e,t,n=!0)=>{const r=new Map;return e.forEach(s=>{const i=t(s);if(r.has(i)){if(n)return;r.delete(i)}r.set(i,s)}),Array.from(r.values())},ds=Object.freeze(Object.defineProperty({__proto__:null,by:hs,unique:oe},Symbol.toStringTag,{value:"Module"})),At=(e,t=!1)=>{const n=Se(e)?"stringer":typeof e;let r;switch(n){case"string":r=(s,i)=>s.localeCompare(i);break;case"stringer":r=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":r=(s,i)=>Number(s)-Number(i);break;case"bigint":r=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":r=(s,i)=>Number(s)-Number(i);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?vn(r):r},gs=(e,t,n)=>{const r=At(t[e],n);return(s,i)=>r(s[e],i[e])},ys=(e,t)=>e.length!==t.length?e.length-t.length:e.every((n,r)=>n===t[r])?0:-1,Nn=(e,t)=>{if(e.length!==t.length)return e.length-t.length;if(e.length===0)return 0;const n=At(e[0]),r=[...e].sort(n),s=[...t].sort(n);return r.every((i,o)=>i===s[o])?0:-1},ms=(e,t)=>{const n=oe(e),r=oe(t);return Nn(n,r)},ps=(e,t)=>e===t?0:e==="first"&&t==="last"?1:-1,vn=e=>(t,n)=>e(n,t),st=0,W=-1,V=1,Mn=e=>e<st,An=e=>e>st,bs=e=>e>=st,Sn=e=>e===st,ws=(e,t)=>{const n=/([a-zA-Z]+)|(\d+)/g,r=e.replace(/[\s_.-]+/g,"").match(n),s=t.replace(/[\s_.-]+/g,"").match(n);if(!r||!s)return 0;for(let i=0;i<Math.min(r.length,s.length);i++){const o=r[i],a=s[i];if(isNaN(Number(o))&&isNaN(Number(a))){const u=o.localeCompare(a);if(u!==0)return u}else if(!isNaN(Number(o))&&!isNaN(Number(a))){const u=Number(o)-Number(a);if(u!==0)return u}else return isNaN(Number(o))?-1:1}return r.length-s.length},En=(e,t,n)=>{let r=0,s=e.length;const i=n??At(t);for(;r<s;){const o=Math.floor((r+s)/2),a=i(e[o],t);if(a===0)return o;a<0?r=o+1:s=o}return r},Os=(e,t,n)=>{const r=En(e,t,n);e.splice(r,0,t)},xs=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:st,GREATER_THAN:V,LESS_THAN:W,insert:Os,isEqualTo:Sn,isGreaterThan:An,isGreaterThanEqual:bs,isLessThan:Mn,newF:At,newFieldF:gs,order:ps,primitiveArrays:ys,reverseF:vn,search:En,stringsWithNumbers:ws,uniqueUnorderedPrimitiveArrays:ms,unorderedPrimitiveArrays:Nn},Symbol.toStringTag,{value:"Module"}));let Tn=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Is=`0123456789${$n}`,zn=11,Ns=Tn($n,1),vs=Tn(Is,zn-1),Ee=()=>`${Ns()}${vs()}`,Ms=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:zn,create:Ee},Symbol.toStringTag,{value:"Module"})),Un=(e,t)=>n=>n instanceof t||typeof n=="object"&&n!==null&&"discriminator"in n&&n.discriminator===e,As=Object.freeze(Object.defineProperty({__proto__:null,createMatcher:Un},Symbol.toStringTag,{value:"Module"})),Ss=2**8-1,jn=2**12-1,Es=2**16-1,Ts=2**32-1,$s=2n**64n-1n,zs=2**64-1,Us=-128,js=2**7-1,Cs=-32768,Bs=2**15-1,Rs=-2147483648,Ps=2**31-1,ks=-(2n**63n),Zt=2n**63n-1n,Ls=-9223372036854776e3,Cn=2**63-1,ut=e=>(t,n)=>{if(typeof t=="bigint"){if(_t(n))return e(t,BigInt(n));const r=e(Number(t),Number(n));return typeof r=="number"?BigInt(Math.round(r)):r}return e(Number(t),Number(n))},_=ut((e,t)=>e-t),Y=ut((e,t)=>e+t),Zs=(e,t,n=1e-4)=>Math.abs(e-t)<n,ce=(e,t)=>{const n=typeof e=="bigint",r=typeof t=="bigint";return n&&r?e===t:n&&_t(t)?e===BigInt(t):r&&_t(e)?t===BigInt(e):e===t},_s=e=>{const t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t},Bn=ut((e,t)=>e<=t?e:t),_t=e=>typeof e=="bigint"?!0:Number.isInteger(e),qs=ut((e,t)=>e>=t?e:t),Rn=e=>typeof e=="bigint"?e<0n?-e:e:e<0?-e:e,R=ut((e,t)=>e*t),St=ut((e,t)=>e/t),Pn=c.z.tuple([c.z.number(),c.z.number()]),Te=c.z.object({width:c.z.number(),height:c.z.number()}),Fs=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),kn=["start","center","end"],at=c.z.object({x:c.z.number(),y:c.z.number()}),Ln=c.z.object({clientX:c.z.number(),clientY:c.z.number()}),Yt=["x","y"],$e=c.z.enum(Yt),ze=["top","right","bottom","left"],Ws=c.z.enum(ze),Dt=["left","right"],Ue=c.z.enum(Dt),Gt=["top","bottom"],je=c.z.enum(Gt),Ce=["center"],ae=c.z.enum(Ce),Vs=[...ze,...Ce],Be=c.z.enum(Vs),Ys=c.z.enum(kn),Zn=["first","last"],Ds=c.z.enum(Zn),Gs=c.z.object({lower:c.z.number(),upper:c.z.number()}),Hs=c.z.enum([...$e.options,...Be.options]),Js=c.z.union([$e,Be,c.z.instanceof(String)]),w=(e,t,n)=>{const r={};if(typeof t=="object"&&(n=t,t=void 0),n={makeValid:!0,...n},typeof e=="number"||typeof e=="bigint")t!=null?(r.lower=e,r.upper=t):(r.lower=typeof e=="bigint"?0n:0,r.upper=e);else if(Array.isArray(e)){if(e.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=e}else r.lower=e.lower,r.upper=e.upper;return n?.makeValid?_n(r):r},Xs=Object.freeze({lower:0,upper:0}),Ks=Object.freeze({lower:-1/0,upper:1/0}),Qs=Object.freeze({lower:0,upper:1}),ti=Object.freeze({lower:-1,upper:1}),ei=(e,t)=>{if(e==null&&t==null)return!0;if(e==null||t==null)return!1;const n=w(e),r=w(t);return n?.lower===r?.lower&&n?.upper===r?.upper},_n=e=>e.lower>e.upper?{lower:e.upper,upper:e.lower}:e,ue=(e,t)=>{const n=w(e);return t<n.lower?n.lower:t>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):t},k=(e,t)=>{const n=w(e);if(typeof t=="number"||typeof t=="bigint")return t>=n.lower&&t<n.upper;const r=w(t);return r.lower>=n.lower&&r.upper<=n.upper},ni=(e,t)=>{const n=w(e),r=w(t);return n.lower===r.lower?!0:r.upper===n.lower||r.lower===n.upper?!1:k(n,r.upper)||k(n,r.lower)||k(r,n.upper)||k(r,n.lower)},lt=e=>{const t=w(e);return t.upper-t.lower},ri=e=>{const t=w(e);return typeof t.lower=="bigint"?t.lower===0n&&t.upper===0n:t.lower===0&&t.upper===0},si=e=>{const t=lt(e);return typeof t=="number"?t===0:t===0n},ii=e=>{const t=w(e);return typeof t.lower=="bigint"?!0:Number.isFinite(t.lower)&&Number.isFinite(t.upper)},oi=e=>{const t=w(e);return(t.upper+t.lower)/2},qn=e=>({lower:Math.min(...e.map(t=>w(t).lower)),upper:Math.max(...e.map(t=>w(t).upper))}),ci=e=>({lower:Math.max(...e.map(t=>w(t).lower)),upper:Math.min(...e.map(t=>w(t).upper))}),ai=e=>{const t=w(e),n=typeof t.lower=="bigint";return Array.from({length:Number(lt(e))},(r,s)=>n?t.lower+BigInt(s):t.lower+s)},le=(e,t)=>{const n=e.map(i=>w(i)),r=n.findIndex(i=>k(i,t)||t<i.lower);if(r===-1)return{index:e.length,position:0};const s=n[r];return k(s,t)?{index:r,position:Number(t-s.lower)}:{index:r,position:0}},ee={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},ui=(e,t)=>{const n=e.map(l=>w(l)),r=w(t);if(n.length===0)return ee;const s=le(n,r.lower),i=le(n,r.upper);if(s.index===e.length)return{...ee,insertInto:e.length};if(i.index===0)return{...ee,removeAfter:i.position};if(s.index===i.index)return s.position!==0&&i.position!==0?null:{removeAfter:i.position,removeBefore:s.position,insertInto:s.index,deleteInBetween:0};let o=i.index-s.index,a=s.index,u=_(Number(lt(n[s.index])),s.position);return s.position!==0?(o-=1,a+=1):u=0,{removeBefore:u,removeAfter:i.position,insertInto:a,deleteInBetween:o}},Fn=(e,t,n)=>{const r=e.map(a=>w(a)),s=n>0?1:n<0?-1:0;if(s===0)return t;let i=n,o=t;for(;ce(i,0)===!1;){const a=r.findIndex(u=>s>0?o>=u.lower&&o<u.upper:o>u.lower&&o<=u.upper);if(a!==-1){const u=r[a];let l;if(s>0?l=_(u.upper,o):l=_(o,u.lower),l>0){const d=Bn(Rn(i),l);if(o=Y(o,s>0?d:-d),i=_(i,s>0?d:-d),ce(i,0))return o;continue}}if(s>0){const u=r.filter(l=>l.lower>o);if(u.length>0)o=u[0].lower;else return o}else{const u=r.filter(l=>l.upper<o);if(u.length>0)o=u[u.length-1].upper;else return o}}return o},Wn=(e,t,n)=>{const r=e.map(o=>w(o));if(t===n)return typeof t=="bigint"?0n:0;const s=t<n?w([t,n]):w([n,t]);let i=typeof t=="bigint"?0n:0;for(const o of r){const a=o.lower>s.lower?o.lower:s.lower,u=o.upper<s.upper?o.upper:s.upper;if(a<u){const l=u-a;i=i+l}}return i},li=Object.freeze(Object.defineProperty({__proto__:null,CLIP:ti,DECIMAL:Qs,INFINITE:Ks,ZERO:Xs,bounds:Gs,buildInsertionPlan:ui,clamp:ue,construct:w,contains:k,distance:Wn,equals:ei,findInsertPosition:le,isFinite:ii,isZero:ri,linspace:ai,makeValid:_n,max:qn,mean:oi,min:ci,overlapsWith:ni,span:lt,spanIsZero:si,traverse:Fn},Symbol.toStringTag,{value:"Module"})),fe=2,he=3,Vn=2,fi=(e,t)=>{if(Number.isNaN(e)||!Number.isFinite(e))return e;const n=lt(t);if(n==0)return e;let r;n>=1e3?r=fe:n>=1?r=he:r=Math.ceil(-Math.log10(n))+Vn;const s=10**r;return Math.round(e*s)/s},hi=5,di=1e-10,gi=(e,t)=>{if(Number.isNaN(e)||!Number.isFinite(e))return e;const n=Math.abs(e);if(n===0)return 0;let r=!1,s=0;if(t!=null){s=lt(t);const u=s/n;r=s>0&&u>di}if(r){let u;s>=1e3?u=fe:s>=1?u=he:u=Math.ceil(-Math.log10(s))+Vn;const l=10**u;return Math.round(e*l)/l}if(n>=1e3){const u=10**fe;return Math.round(e*u)/u}if(n>=1){const u=10**he;return Math.round(e*u)/u}const i=Math.floor(Math.log10(n)),a=10**(hi-i-1);return Math.round(e*a)/a},yi=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Bs,MAX_INT32:Ps,MAX_INT64:Zt,MAX_INT64_NUMBER:Cn,MAX_INT8:js,MAX_UINT12:jn,MAX_UINT16:Es,MAX_UINT32:Ts,MAX_UINT64:$s,MAX_UINT64_NUMBER:zs,MAX_UINT8:Ss,MIN_INT16:Cs,MIN_INT32:Rs,MIN_INT64:ks,MIN_INT64_NUMBER:Ls,MIN_INT8:Us,abs:Rn,add:Y,closeTo:Zs,div:St,equal:ce,isInteger:_t,max:qs,min:Bn,mult:R,roundBySpan:fi,roundToNearestMagnitude:_s,smartRound:gi,sub:_},Symbol.toStringTag,{value:"Module"})),Yn=Hs,Z=e=>Yt.includes(e)?e:Gt.includes(e)?"y":"x",mi=e=>Z(e)==="x"?"y":"x",pi=e=>Z(e)==="x"?"width":"height",bi=e=>Z(e)==="x"?"left":"top",wi=e=>Yn.safeParse(e).success,Oi=e=>Z(e)==="x"?"signedWidth":"signedHeight",xi=e=>e==="center"?!1:Z(e)==="x",Ii=e=>Z(e)==="y",Ni=Object.freeze(Object.defineProperty({__proto__:null,DIRECTIONS:Yt,construct:Z,crude:Yn,dimension:pi,direction:$e,isDirection:wi,isX:xi,isY:Ii,location:bi,signedDimension:Oi,swap:mi},Symbol.toStringTag,{value:"Module"})),vi=Ue,Mi=je,Ai=ae,Si={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},Ei={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},Ti=Js,et=e=>e instanceof String||!Yt.includes(e)?e:e==="x"?"left":"top",$i=e=>Si[et(e)],zi=(e,t)=>Ei[e][t],It=e=>{const t=et(e);return t==="top"||t==="bottom"?"y":"x"},Ui=c.z.object({x:Ue.or(ae),y:je.or(ae)}),Re=c.z.object({x:Ue,y:je}),ft=Object.freeze({x:"left",y:"top"}),Pe=Object.freeze({x:"right",y:"top"}),Ht=Object.freeze({x:"left",y:"bottom"}),ke=Object.freeze({x:"right",y:"bottom"}),Le=Object.freeze({x:"center",y:"center"}),Ze=Object.freeze({x:"center",y:"top"}),_e=Object.freeze({x:"center",y:"bottom"}),qe=Object.freeze({x:"right",y:"center"}),Fe=Object.freeze({x:"left",y:"center"}),ji=Object.freeze([Fe,qe,Ze,_e,ft,Pe,Ht,ke,Le]),We=(e,t)=>e.x===t.x&&e.y===t.y,Ci=(e,t)=>{if(typeof t=="object"){let n=!0;return"x"in t&&(e.x===t.x||(n=!1)),"y"in t&&(e.y===t.y||(n=!1)),n}return e.x===t||e.y===t},Dn=e=>[e.x,e.y],Rt=e=>It(et(e))==="x",Bi=e=>It(et(e))==="y",Ri=e=>`${e.x}${bn(e.y)}`,Pi=(e,t)=>{let n,r;if(typeof e=="object"&&"x"in e?(n=e.x,r=e.y):(n=et(e),r=et(t??e)),It(n)===It(r)&&n!=="center"&&r!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${n.toString()} - ${r.toString()}`);const s={...Le};return n==="center"?Rt(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:r==="center"?Rt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:Rt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n],s},ki=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:_e,BOTTOM_LEFT:Ht,BOTTOM_RIGHT:ke,CENTER:Le,CENTER_LEFT:Fe,CENTER_LOCATIONS:Ce,CENTER_RIGHT:qe,OUTER_LOCATIONS:ze,TOP_CENTER:Ze,TOP_LEFT:ft,TOP_RIGHT:Pe,XY_LOCATIONS:ji,X_LOCATIONS:Dt,Y_LOCATIONS:Gt,center:Ai,construct:et,constructXY:Pi,corner:Re,crude:Ti,direction:It,isX:Rt,isY:Bi,location:Be,outer:Ws,rotate:zi,swap:$i,x:vi,xy:Ui,xyCouple:Dn,xyEquals:We,xyMatches:Ci,xyToString:Ri,y:Mi},Symbol.toStringTag,{value:"Module"})),de=c.z.union([c.z.number(),at,Pn,Te,Fs,Ln]),x=(e,t)=>{if(typeof e=="string"){if(t===void 0)throw new 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}},q=Object.freeze({x:0,y:0}),Gn=Object.freeze({x:1,y:1}),Li=Object.freeze({x:1/0,y:1/0}),Zi=Object.freeze({x:NaN,y:NaN}),qt=(e,t,n=0)=>{const r=x(e),s=x(t);return n===0?r.x===s.x&&r.y===s.y:Math.abs(r.x-s.x)<=n&&Math.abs(r.y-s.y)<=n},_i=e=>qt(e,q),Ve=(e,t,n)=>{const r=x(e),s=x(t,n);return{x:r.x*s.x,y:r.y*s.y}},Hn=(e,t)=>{const n=x(e);return{x:n.x+t,y:n.y}},Jn=(e,t)=>{const n=x(e);return{x:n.x,y:n.y+t}},Nt=(e,t,n,...r)=>{if(typeof t=="string"){if(typeof n!="number")throw new Error("The value must be a number.");return t==="x"?Hn(e,n):Jn(e,n)}if(typeof t=="object"&&"x"in t&&typeof t.x=="string"){const s=x(n),i=x(e);return t.x==="left"?s.x=-s.x:t.x==="center"&&(s.x=0),t.y==="top"?s.y=-s.y:t.y==="center"&&(s.y=0),{x:i.x+s.x,y:i.y+s.y}}return[e,t,n??q,...r].reduce((s,i)=>{const o=x(i);return{x:s.x+o.x,y:s.y+o.y}},q)},qi=(e,t,n)=>{const r=x(e);return Z(t)==="x"?{x:n,y:r.y}:{x:r.x,y:n}},Fi=(e,t)=>{const n=x(e),r=x(t);return Math.sqrt((n.x-r.x)**2+(n.y-r.y)**2)},Wi=(e,t)=>{const n=x(e),r=x(t);return{x:r.x-n.x,y:r.y-n.y}},Vi=e=>{const t=x(e);return Number.isNaN(t.x)||Number.isNaN(t.y)},Yi=e=>{const t=x(e);return Number.isFinite(t.x)&&Number.isFinite(t.y)},Di=e=>{const t=x(e);return[t.x,t.y]},Gi=e=>{const t=x(e);return{left:t.x,top:t.y}},Ft=(e,t=0)=>{const n=x(e);return{x:Number(n.x.toFixed(t)),y:Number(n.y.toFixed(t))}},dt=(e,t)=>{const n=x(e),r=x(t);return{x:n.x-r.x,y:n.y-r.y}},gt=e=>{const t=x(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:-t.y/n,y:t.x/n}},Xn=e=>{const t=x(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:t.x/n,y:t.y/n}},Kn=(...e)=>{const t=e.reduce((n,r)=>Nt(n,r),q);return Ve(t,1/e.length)},Hi=(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const s=e[r];let i,o,a,u;if(r===0){const l=e[r+1],d=dt(l,s);o=gt(d),a=o,u=t}else if(r===e.length-1){const l=e[r-1],d=dt(s,l);i=gt(d),a=i,u=t}else{const l=e[r-1],d=e[r+1],y=dt(s,l),m=dt(d,s);i=gt(y),o=gt(m);const A=Math.acos((y.x*m.x+y.y*m.y)/(Math.hypot(y.x,y.y)*Math.hypot(m.x,m.y))),E=Math.sin(A/2);E===0?u=t:u=t/E,a=Xn(Kn(i,o))}n.push(Ve(a,u))}return n},Ji=e=>{const t=x(e);return{x:t.y,y:t.x}},ge=e=>{const t=x(e);return{x:Math.round(t.x),y:Math.round(t.y)}},Xi=e=>{const t=x(e);return{x:1/t.x,y:1/t.y}},Ki=(e,t,n)=>{const r=x(e),s=x(t),i=n==="clockwise"?Math.PI/2:-Math.PI/2,o=r.x-s.x,a=r.y-s.y,u=o*Math.cos(i)-a*Math.sin(i),l=o*Math.sin(i)+a*Math.cos(i);return{x:u+s.x,y:l+s.y}},Qi=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Li,NAN:Zi,ONE:Gn,ZERO:q,average:Kn,calculateMiters:Hi,clientXY:Ln,construct:x,couple:Di,crudeZ:de,css:Gi,distance:Fi,equals:qt,isFinite:Yi,isNan:Vi,isZero:_i,normal:gt,normalize:Xn,reciprocal:Xi,rotate:Ki,round:ge,scale:Ve,set:qi,sub:dt,swap:Ji,translate:Nt,translateX:Hn,translateY:Jn,translation:Wi,truncate:Ft,xy:at},Symbol.toStringTag,{value:"Module"})),zt=c.z.union([c.z.number(),c.z.string()]),to=c.z.object({top:zt,left:zt,width:zt,height:zt}),eo=c.z.object({left:c.z.number(),top:c.z.number(),right:c.z.number(),bottom:c.z.number()}),no=c.z.object({one:at,two:at,root:Re}),Qn={one:q,two:q,root:ft},ro={one:q,two:Gn,root:Ht},tr=(e,t)=>({one:e.one,two:e.two,root:t??e.root}),N=(e,t,n=0,r=0,s)=>{const i={one:{...q},two:{...q},root:s??ft};if(typeof e=="number"){if(typeof t!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:e,y:t},i.two={x:i.one.x+n,y:i.one.y+r},i}return"one"in e&&"two"in e&&"root"in e?{...e,root:s??e.root}:("getBoundingClientRect"in e&&(e=e.getBoundingClientRect()),"left"in e?(i.one={x:e.left,y:e.top},i.two={x:e.right,y:e.bottom},i):(i.one=e,t==null?i.two={x:i.one.x+n,y:i.one.y+r}:typeof t=="number"?i.two={x:i.one.x+t,y:i.one.y+n}:"width"in t?i.two={x:i.one.x+t.width,y:i.one.y+t.height}:"signedWidth"in t?i.two={x:i.one.x+t.signedWidth,y:i.one.y+t.signedHeight}:i.two=t,i))},so=(e,t,n)=>{const r=N(e);if(typeof t=="string"){if(n==null)throw new Error("Invalid arguments for resize");const s=Z(t);return N(r.one,void 0,s==="x"?n:$(r),s==="y"?n:z(r),r.root)}return N(r.one,t,void 0,void 0,r.root)},io=(e,t,n=!0)=>{const r=N(e);let s=(i,o)=>i<o;return n&&(s=(i,o)=>i<=o),"one"in t?s(J(r),J(t))&&s(Q(t),Q(r))&&s(X(r),X(t))&&s(tt(t),tt(r)):s(J(r),t.x)&&s(t.x,Q(r))&&s(X(r),t.y)&&s(t.y,tt(r))},oo=(e,t)=>qt(e.one,t.one)&&qt(e.two,t.two)&&We(e.root,t.root),er=e=>({width:$(e),height:z(e)}),co=e=>({signedWidth:Jt(e),signedHeight:Xt(e)}),ao=e=>({top:X(e),left:J(e),width:$(e),height:z(e)}),Ye=(e,t,n=!1)=>{const r=Z(t)==="y"?Xt(e):Jt(e);return n?r:Math.abs(r)},G=(e,t)=>{const n=N(e);return{x:t.x==="center"?ye(n).x:nt(n,t.x),y:t.y==="center"?ye(n).y:nt(n,t.y)}},nt=(e,t)=>{const n=N(e),r=Dn(n.root).includes(t)?Math.min:Math.max;return Dt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},uo=e=>sr(e)===0,$=e=>Ye(e,"x"),z=e=>Ye(e,"y"),Jt=e=>{const t=N(e);return t.two.x-t.one.x},Xt=e=>{const t=N(e);return t.two.y-t.one.y},nr=e=>G(e,ft),lo=e=>G(e,Ze),fo=e=>G(e,Pe),ho=e=>G(e,Ht),go=e=>G(e,_e),yo=e=>G(e,ke),mo=e=>G(e,Fe),po=e=>G(e,qe),Q=e=>nt(e,"right"),tt=e=>nt(e,"bottom"),J=e=>nt(e,"left"),X=e=>nt(e,"top"),ye=e=>Nt(nr(e),{x:Jt(e)/2,y:Xt(e)/2}),De=e=>{const t=N(e);return t.root.x==="left"?J(t):Q(t)},Ge=e=>{const t=N(e);return t.root.y==="top"?X(t):tt(t)},bo=e=>({x:De(e),y:Ge(e)}),Pt=e=>{const t=N(e);return{lower:t.one.x,upper:t.two.x}},kt=e=>{const t=N(e);return{lower:t.one.y,upper:t.two.y}},wo=(e,t)=>tr(e,t),Oo=(e,t)=>{const n=N(e),r=Dt.includes(t)?"x":Gt.includes(t)?"y":null;if(r===null)throw new Error(`Invalid location: ${t}`);const s=t==="top"||t==="left"?Math.min:Math.max,i={...n.one},o={...n.two};return i[r]=s(n.one[r],n.two[r]),o[r]=s(n.one[r],n.two[r]),[i,o]},xo=(e,t)=>{const n=N(e),r=N(t),s=De(r)+($(r)-$(n))/2,i=Ge(r)+(z(r)-z(n))/2;return N({x:s,y:i},er(n))},rr=e=>typeof e!="object"||e==null?!1:"one"in e&&"two"in e&&"root"in e,Io=e=>$(e)/z(e),No=(e,t,n)=>{if(typeof t=="string"){if(n==null)throw new Error("Undefined amount passed into box.translate");const s=Z(t);t=x(s,n)}const r=N(e);return N(Nt(r.one,t),Nt(r.two,t),void 0,void 0,r.root)},vo=(e,t)=>{const n=Math.max(J(e),J(t)),r=Math.max(X(e),X(t)),s=Math.min(Q(e),Q(t)),i=Math.min(tt(e),tt(t));return n>s||r>i?Qn:N({x:n,y:r},{x:s,y:i},void 0,void 0,e.root)},sr=e=>$(e)*z(e),Mo=(e,t)=>{const n=N(e);return N(Ft(n.one,t),Ft(n.two,t),void 0,void 0,n.root)},Ao=(e,t,n,r,s,i)=>{const o={x:e,y:t},a={x:e+n,y:t+r};return s.x!==i.x&&(s.x==="center"?(o.x-=n/2,a.x-=n/2):(o.x-=n,a.x-=n)),s.y!==i.y&&(s.y==="center"?(o.y-=r/2,a.y-=r/2):(o.y-=r,a.y-=r)),N(o,a,void 0,void 0,i)},So=e=>{const t=N(e);return N(ge(t.one),ge(t.two),void 0,void 0,t.root)},Eo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:ro,ZERO:Qn,area:sr,areaIsZero:uo,aspect:Io,bottom:tt,bottomCenter:go,bottomLeft:ho,bottomRight:yo,box:no,center:ye,centerLeft:mo,centerRight:po,construct:N,constructWithAlternateRoot:Ao,contains:io,copy:tr,css:ao,cssBox:to,dim:Ye,dims:er,domRect:eo,edgePoints:Oo,equals:oo,height:z,intersection:vo,isBox:rr,left:J,loc:nt,positionInCenter:xo,reRoot:wo,resize:so,right:Q,root:bo,round:So,signedDims:co,signedHeight:Xt,signedWidth:Jt,top:X,topCenter:lo,topLeft:nr,topRight:fo,translate:No,truncate:Mo,width:$,x:De,xBounds:Pt,xyLoc:G,y:Ge,yBounds:kt},Symbol.toStringTag,{value:"Module"})),ir=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),To=c.z.union([Te,ir,at,Pn]),$o={width:0,height:0},zo={width:1,height:1},L=(e,t)=>typeof e=="number"?{width:e,height:t??e}:Array.isArray(e)?{width:e[0],height:e[1]}:"x"in e?{width:e.x,height:e.y}:"signedWidth"in e?{width:e.signedWidth,height:e.signedHeight}:{...e},Uo=(e,t)=>{if(t==null)return!1;const n=L(e),r=L(t);return n.width===r.width&&n.height===r.height},jo=e=>{const t=L(e);return{width:t.height,height:t.width}},Co=e=>{const t=L(e);return`0 0 ${t.width} ${t.height}`},Bo=e=>{const t=L(e);return[t.width,t.height]},Ro=e=>({width:Math.max(...e.map(t=>L(t).width)),height:Math.max(...e.map(t=>L(t).height))}),Po=e=>({width:Math.min(...e.map(t=>L(t).width)),height:Math.min(...e.map(t=>L(t).height))}),ko=(e,t)=>{const n=L(e);return{width:n.width*t,height:n.height*t}},Lo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:zo,ZERO:$o,construct:L,couple:Bo,crude:To,dimensions:Te,equals:Uo,max:Ro,min:Po,scale:ko,signed:ir,svgViewBox:Co,swap:jo},Symbol.toStringTag,{value:"Module"})),or=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e,Zo=c.z.object({offset:de,scale:de}),_o=c.z.object({offset:c.z.number(),scale:c.z.number()}),qo=e=>(t,n,r,s)=>n==="dimension"?[t,r]:[t,s?r-e:r+e],Fo=e=>(t,n,r,s)=>[t,s?r/e:r*e],Wo=e=>(t,n,r)=>{if(t===null)return[e,r];const{lower:s,upper:i}=t,{lower:o,upper:a}=e,u=i-s,l=a-o;if(n==="dimension")return[e,r*(l/u)];const d=(r-s)*(l/u)+o;return[e,d]},Vo=e=>(t,n,r)=>[e,r],Yo=()=>(e,t,n)=>{if(e===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[e,n];const{lower:r,upper:s}=e;return[e,s-(n-r)]},Do=e=>(t,n,r)=>{const{lower:s,upper:i}=e;return r=or(r,s,i),[t,r]};class F{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new F().translate(t)}static magnify(t){return new F().magnify(t)}static scale(t,n){return new F().scale(t,n)}translate(t){const n=this.new(),r=qo(t);return r.type="translate",n.ops.push(r),n}magnify(t){const n=this.new(),r=Fo(t);return r.type="magnify",n.ops.push(r),n}scale(t,n){const r=w(t,n),s=this.new(),i=Wo(r);return i.type="scale",s.ops.push(i),s}clamp(t,n){const r=w(t,n),s=this.new(),i=Do(r);return i.type="clamp",s.ops.push(i),s}reBound(t,n){const r=w(t,n),s=this.new(),i=Vo(r);return i.type="re-bound",s.ops.push(i),s}invert(){const t=Yo();t.type="invert";const n=this.new();return n.ops.push(t),n}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new F;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,n){return this.currBounds=null,this.ops.reduce(([r,s],i)=>i(r,t,s,this.reversed),[null,n])[1]}reverse(){const t=this.new();t.ops.reverse();const n=[];return t.ops.forEach((r,s)=>{if(r.type==="scale"||n.some(([o,a])=>s>=o&&s<=a))return;const i=t.ops.findIndex((o,a)=>o.type==="scale"&&a>s);i!==-1&&n.push([s,i])}),n.forEach(([r,s])=>{const i=t.ops.slice(r,s);i.unshift(t.ops[s]),t.ops.splice(r,s-r+1,...i)}),t.reversed=!t.reversed,t}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new F}class B{x;y;currRoot;constructor(t=new F,n=new F,r=null){this.x=t,this.y=n,this.currRoot=r}static translate(t,n){return new B().translate(t,n)}static translateX(t){return new B().translateX(t)}static translateY(t){return new B().translateY(t)}static clamp(t){return new B().clamp(t)}static magnify(t){return new B().magnify(t)}static scale(t){return new B().scale(t)}static reBound(t){return new B().reBound(t)}translate(t,n){const r=x(t,n),s=this.copy();return s.x=this.x.translate(r.x),s.y=this.y.translate(r.y),s}translateX(t){const n=this.copy();return n.x=this.x.translate(t),n}translateY(t){const n=this.copy();return n.y=this.y.translate(t),n}magnify(t){const n=this.copy();return n.x=this.x.magnify(t.x),n.y=this.y.magnify(t.y),n}scale(t){const n=this.copy();if(rr(t)){const r=this.currRoot;return n.currRoot=t.root,r!=null&&!We(r,t.root)&&(r.x!==t.root.x&&(n.x=n.x.invert()),r.y!==t.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(Pt(t)),n.y=n.y.scale(kt(t)),n}return n.x=n.x.scale(t.width),n.y=n.y.scale(t.height),n}reBound(t){const n=this.copy();return n.x=this.x.reBound(Pt(t)),n.y=this.y.reBound(kt(t)),n}clamp(t){const n=this.copy();return n.x=this.x.clamp(Pt(t)),n.y=this.y.clamp(kt(t)),n}copy(){const t=new B;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}dim(t){return{x:this.x.dim(t.x),y:this.y.dim(t.y)}}box(t){return N(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new B}const Go=Object.freeze(Object.defineProperty({__proto__:null,Scale:F,XY:B,crudeXYTransform:Zo,transform:_o},Symbol.toStringTag,{value:"Module"})),Ho=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:kn,ORDERS:Zn,alignment:Ys,order:Ds},Symbol.toStringTag,{value:"Module"})),cr=at.extend({root:Re,units:c.object({x:c.enum(["px","decimal"]),y:c.enum(["px","decimal"])})}),Jo=cr.partial({root:!0,units:!0}),Xo=e=>{const t={};return t[e.root?.x??"left"]=e?.units?.x==="px"?`${e.x}px`:`${e.x*100}%`,t[e.root?.y??"top"]=e?.units?.y==="px"?`${e.y}px`:`${e.y*100}%`,t},Ko=({position:e,element:t,container:n})=>{const r={x:e.x,y:e.y};return e.units?.x==="decimal"?e.root?.x==="right"&&(r.x=1-e.x):e.root?.x==="right"?r.x=1-(e.x+$(t))/$(n):r.x/=$(n),e.units?.y==="decimal"?e.root?.y==="bottom"&&(r.y=1-e.y):e.root?.y==="bottom"?r.y=1-(e.y+z(t))/z(n):r.y/=z(n),r},Qo=({position:e,element:t,container:n,lowerThreshold:r=.2,upperThreshold:s=.8})=>{const i={x:e.x,y:e.y,root:{...ft},units:{x:"px",y:"px"}};return e.x>s?(i.x=(1-e.x)*$(n)-$(t),i.root.x="right"):e.x<r?i.x=e.x*$(n):i.units.x="decimal",e.y>s?(i.y=(1-e.y)*z(n)-z(t),i.root.y="bottom"):e.y<r?i.y=e.y*z(n):i.units.y="decimal",i.x=Math.round(i.x*100)/100,{...i,...Ft(i,3)}},tc=Object.freeze(Object.defineProperty({__proto__:null,calculate:Qo,completeXY:cr,toCSS:Xo,toDecimal:Ko,xy:Jo},Symbol.toStringTag,{value:"Module"})),ec=c.z.enum(["static","dynamic"]),cn=365,Ut=30,nc=c.z.union([c.z.tuple([c.z.int()]),c.z.tuple([c.z.int(),c.z.int().min(1).max(12)]),c.z.tuple([c.z.int(),c.z.int().min(1).max(12),c.z.int().min(1).max(31)])]),ar=(e,t)=>{const n=new h(t);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.NANOSECOND].some(s=>s.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=e.valueOf()%n.valueOf();return e instanceof h?new h(r):new g(r)};class h extends rt{constructor(t,n="UTC"){if(t==null)super(h.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*h.MILLISECOND.valueOf());else if(typeof t=="string")super(h.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(h.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n==="local"&&(r=h.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t===Cn?t=Zt:t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=h.MAX:t=h.MIN)),j(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){const s=new Date(t,n-1,r,0,0,0,0);return new h(BigInt(s.getTime())*h.MILLISECOND.valueOf()).truncate(h.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n="UTC"){const[r,s,i]=t.split(":");let o="00",a="00";i!=null&&([o,a]=i.split("."));let u=h.hours(parseInt(r??"00")).add(h.minutes(parseInt(s??"00"))).add(h.seconds(parseInt(o??"00"))).add(h.milliseconds(parseInt(a??"00")));return n==="local"&&(u=u.add(h.utcOffset)),u.valueOf()}static parseDateTimeString(t,n="UTC"){if(!t.includes("/")&&!t.includes("-"))return h.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let i=t,o=0;if(t.includes(".")){const d=t.split(".");i=d[0];const y=d[1]||"0";o=parseInt(y.padEnd(3,"0").slice(0,3))}const a=n==="local"?new Date(i.replace("T"," ")):new Date(`${i}Z`),u=BigInt(a.getTime())*h.MILLISECOND.valueOf(),l=BigInt(o)*h.MILLISECOND.valueOf();return u+l}const s=new Date(t);return t.includes(":")||s.setUTCHours(0,0,0,0),new h(BigInt(s.getTime())*h.MILLISECOND.valueOf(),n).valueOf()}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(h.utcOffset).date().toISOString()}timeString(t=!1,n="UTC"){const r=this.toISOString(n);return t?r.slice(11,23):r.slice(11,19)}dateString(){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new g(BigInt(new Date().getTimezoneOffset())*h.MINUTE.valueOf())}static since(t){return new h().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new h(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new h(t).valueOf()}afterEq(t){return this.valueOf()>=new h(t).valueOf()}before(t){return this.valueOf()<new h(t).valueOf()}beforeEq(t){return this.valueOf()<=new h(t).valueOf()}add(t){return new h(Y(this.valueOf(),new g(t).valueOf()))}sub(t){return new h(_(this.valueOf(),new g(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(h.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(h.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){const n=this.date();return n.setUTCFullYear(t),new h(n)}setLocalYear(t){const n=this.date();return n.setFullYear(t),new h(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){const n=this.date();return n.setUTCMonth(t),new h(n)}setLocalMonth(t){const n=this.date();return n.setMonth(t),new h(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){const n=this.date();return n.setUTCDate(t),new h(n)}setLocalDay(t){const n=this.date();return n.setDate(t),new h(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){const n=this.date();return n.setHours(t),new h(n)}setHour(t){const n=this.date();return n.setUTCHours(t),new h(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){const n=this.date();return n.setUTCMinutes(t),new h(n)}setLocalMinute(t){const n=this.date();return n.setMinutes(t),new h(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){const n=this.date();return n.setUTCSeconds(t),new h(n)}setLocalSecond(t){const n=this.date();return n.setSeconds(t),new h(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){const n=this.date();return n.setUTCMilliseconds(t),new h(n)}setLocalMillisecond(t){const n=this.date();return n.setMilliseconds(t),new h(n)}toString(t="ISO",n="UTC"){switch(t){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}remainder(t){return ar(this,t)}get isToday(){return this.truncate(g.DAY).equals(h.now().truncate(g.DAY))}truncate(t){return this.sub(this.remainder(t))}formatBySpan(t){return t.greaterThanOrEqual(g.days(30))?"shortDate":t.greaterThanOrEqual(g.DAY)?"dateTime":t.greaterThanOrEqual(g.HOUR)?"time":t.greaterThanOrEqual(g.SECOND)?"preciseTime":"ISOTime"}static now(){return new h(new Date)}static max(...t){let n=h.MIN;for(const r of t){const s=new h(r);s.after(n)&&(n=s)}return n}static min(...t){let n=h.MAX;for(const r of t){const s=new h(r);s.before(n)&&(n=s)}return n}static nanoseconds(t,n="UTC"){return new h(t,n)}static NANOSECOND=h.nanoseconds(1);static microseconds(t,n="UTC"){return h.nanoseconds(t*1e3,n)}static MICROSECOND=h.microseconds(1);static milliseconds(t,n="UTC"){return h.microseconds(t*1e3,n)}static MILLISECOND=h.milliseconds(1);static seconds(t,n="UTC"){return h.milliseconds(t*1e3,n)}static SECOND=h.seconds(1);static minutes(t,n="UTC"){return h.seconds(t*60,n)}static MINUTE=h.minutes(1);static hours(t,n="UTC"){return h.minutes(t*60,n)}static HOUR=h.hours(1);static days(t,n="UTC"){return h.hours(t*24,n)}static DAY=h.days(1);static MAX=new h(Zt);static MIN=new h(0);static ZERO=new h(0);static z=c.z.union([c.z.instanceof(h),c.z.object({value:c.z.bigint()}).transform(t=>new h(t.value)),c.z.string().transform(t=>new h(BigInt(t))),c.z.number().transform(t=>new h(t)),c.z.bigint().transform(t=>new h(t)),c.z.date().transform(t=>new h(t)),c.z.custom(t=>t instanceof g).transform(t=>new h(t)),nc.transform(t=>new h(t))]);static sort(t,n){return Number(t.valueOf()-n.valueOf())}}class g extends rt{constructor(t){typeof t=="number"&&(t=Math.trunc(t.valueOf())),j(t)&&(t=t.value),super(BigInt(t.valueOf()))}static fromSeconds(t){return t instanceof g?t:t instanceof T?t.period:t instanceof h?new g(t):(j(t)&&(t=t.value),["number","bigint"].includes(typeof t)?g.seconds(t):new g(t))}static fromMilliseconds(t){return t instanceof g?t:t instanceof T?t.period:t instanceof h?new g(t):(j(t)&&(t=t.value),["number","bigint"].includes(typeof t)?g.milliseconds(t):new g(t))}valueOf(){return this.value}lessThan(t){return this.valueOf()<new g(t).valueOf()}greaterThan(t){return this.valueOf()>new g(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new g(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new g(t).valueOf()}remainder(t){return ar(this,t)}truncate(t){return new g(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t="full"){if(t==="semantic")return this.toSemanticString();const n=this.truncate(g.DAY),r=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),a=this.truncate(g.MICROSECOND),u=this.truncate(g.NANOSECOND),l=n,d=r.sub(n),y=s.sub(r),m=i.sub(s),A=o.sub(i),E=a.sub(o),C=u.sub(a);let O="";return l.isZero||(O+=`${l.days}d `),d.isZero||(O+=`${d.hours}h `),y.isZero||(O+=`${y.minutes}m `),m.isZero||(O+=`${m.seconds}s `),A.isZero||(O+=`${A.milliseconds}ms `),E.isZero||(O+=`${E.microseconds}µs `),C.isZero||(O+=`${C.nanoseconds}ns`),O.trim()}toSemanticString(){const t=this.valueOf()<0n?-this.valueOf():this.valueOf(),n=new g(t),r=this.valueOf()<0n;if(n.valueOf()===0n)return"0s";if(n.lessThan(g.SECOND))return"< 1s";const s=n.days,i=n.hours,o=n.minutes,a=n.seconds,u=Math.floor(s/cn),l=Math.floor(s/Ut),d=Math.floor(s/7),y=Math.floor(s),m=Math.floor(i),A=Math.floor(o),E=Math.floor(a),C=r?"-":"";if(u>=1){let O=`${u}y`;if(u<2){const v=Math.floor(s%cn/Ut);v>0&&(O+=` ${v}mo`)}return C+O}if(d>=1&&s<Ut&&s%7===0){let O=`${d}w`;const v=Math.floor(s%7),K=Math.floor(i-d*7*24);return d<2&&(v>0?O+=` ${v}d`:K>0&&K<24&&(O+=` ${K}h`)),C+O}if(l>=1){let O=`${l}mo`;if(l<3){const v=Math.floor(s%Ut);v>0&&(O+=` ${v}d`)}return C+O}if(d>=1){let O=`${d}w`;const v=Math.floor(s%7),K=Math.floor(i-d*7*24);return d<2&&(v>0?O+=` ${v}d`:K>0&&K<24&&(O+=` ${K}h`)),C+O}if(y>=1){let O=`${y}d`;const v=Math.floor(i-y*24);return y<2&&v>0&&(O+=` ${v}h`),C+O}if(m>=1){let O=`${m}h`;if(m<3){const v=Math.floor(o-m*60);v>0&&(O+=` ${v}m`)}return C+O}if(A>=1){let O=`${A}m`;if(A<5){const v=Math.floor(a-A*60);v>0&&(O+=` ${v}s`)}return C+O}return`${C}${E}s`}mult(t){return new g(R(this.valueOf(),t))}div(t){return new g(St(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new g(t).valueOf()}add(t){return new g(this.valueOf()+new g(t).valueOf())}sub(t){return new g(this.valueOf()-new g(t).valueOf())}static nanoseconds(t=1){return new g(t)}static NANOSECOND=g.nanoseconds(1);static microseconds(t=1){return g.nanoseconds(R(t,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(t=1){return g.microseconds(R(t,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(t=1){return g.milliseconds(R(t,1e3))}static SECOND=g.seconds(1);static minutes(t=1){return g.seconds(R(t,60))}static MINUTE=g.minutes(1);static hours(t){return g.minutes(R(t,60))}static HOUR=g.hours(1);static days(t){return g.hours(R(t,24))}static DAY=g.days(1);static MAX=new g(Zt);static MIN=new g(0);static ZERO=new g(0);static z=c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new g(t.value)),c.z.string().transform(t=>new g(BigInt(t))),c.z.number().transform(t=>new g(t)),c.z.bigint().transform(t=>new g(t)),c.z.instanceof(g),c.z.instanceof(h).transform(t=>new g(t)),c.z.custom(t=>t instanceof T).transform(t=>new g(t))])}class T extends rt{constructor(t){j(t)&&(t=t.value),super(t.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new T(t).valueOf()}get period(){return g.seconds(1/this.valueOf())}sampleCount(t){return new g(t).seconds*this.valueOf()}byteCount(t,n){return this.sampleCount(t)*new b(n).valueOf()}span(t){return g.seconds(t/this.valueOf())}byteSpan(t,n){return this.span(t.valueOf()/new b(n).valueOf())}add(t){return new T(Y(this.valueOf(),new T(t).valueOf()))}sub(t){return new T(_(this.valueOf(),new T(t).valueOf()))}mult(t){return new T(R(this.valueOf(),t))}div(t){return new T(St(this.valueOf(),t))}static hz(t){return new T(t)}static khz(t){return T.hz(t*1e3)}static z=c.z.union([c.z.number().transform(t=>new T(t)),c.z.instanceof(T)])}class b extends rt{constructor(t){j(t)&&(t=t.value),super(t.valueOf())}length(t){return t.valueOf()/this.valueOf()}size(t){return new p(t*this.valueOf())}add(t){return new b(Y(this.valueOf(),new b(t).valueOf()))}sub(t){return new b(_(this.valueOf(),new b(t).valueOf()))}mult(t){return new b(R(this.valueOf(),t))}div(t){return new b(St(this.valueOf(),t))}static UNKNOWN=new b(0);static BIT128=new b(16);static BIT64=new b(8);static BIT32=new b(4);static BIT16=new b(2);static BIT8=new b(1);static z=c.z.union([c.z.number().transform(t=>new b(t)),c.z.instanceof(b)])}class M{start;end;constructor(t,n){typeof t=="object"&&"start"in t?(this.start=new h(t.start),this.end=new h(t.end)):(this.start=new h(t),this.end=new h(n))}get span(){return new g(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 M(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(t,n=g.ZERO){if(n.isZero)return this.start.equals(t.start)&&this.end.equals(t.end);let r=this.start.sub(t.start).valueOf(),s=this.end.sub(t.end).valueOf();return r<0&&(r=-r),s<0&&(s=-s),r<=n.valueOf()&&s<=n.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,n=g.ZERO){t=t.makeValid();const r=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(r.start)||r.end.equals(t.start))return!1;const s=h.max(r.start,t.start),i=h.min(r.end,t.end);return i.before(s)?!1:new g(i.sub(s)).greaterThanOrEqual(n)}contains(t){return t instanceof M?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const n=new M(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 M(h.min(...t.map(n=>n.start)),h.max(...t.map(n=>n.end)))}static MAX=new M(h.MIN,h.MAX);static ZERO=new M(h.ZERO,h.ZERO);static z=c.z.union([c.z.object({start:h.z,end:h.z}).transform(t=>new M(t.start,t.end)),c.z.instanceof(M)]);static sort(t,n){return h.sort(t.start,n.start)||h.sort(t.end,n.end)}static merge(...t){return M.max(...t.map(n=>new M(n).makeValid()))}}class f extends rt{constructor(t){if(j(t)&&(t=t.value),t instanceof f||typeof t=="string"||typeof t.valueOf()=="string")super(t.valueOf());else{const n=f.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw new Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){const t=f.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(n=>this.equals(n))}toString(t=!1){return t?f.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(f.JSON)||this.equals(f.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(f.UUID)}get isInteger(){const t=this.toString();return t.startsWith("int")||t.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=f.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(f.UINT8)||this.equals(f.UINT16)||this.equals(f.UINT32)||this.equals(f.UINT64)}get isSignedInteger(){return this.equals(f.INT8)||this.equals(f.INT16)||this.equals(f.INT32)||this.equals(f.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(f.INT32)&&t.equals(f.FLOAT64)||this.equals(f.INT8)&&t.equals(f.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}get usesBigInt(){return f.BIG_INT_TYPES.some(t=>t.equals(this))}static UNKNOWN=new f("unknown");static FLOAT64=new f("float64");static FLOAT32=new f("float32");static INT64=new f("int64");static INT32=new f("int32");static INT16=new f("int16");static INT8=new f("int8");static UINT64=new f("uint64");static UINT32=new f("uint32");static UINT16=new f("uint16");static UINT8=new f("uint8");static BOOLEAN=new f("boolean");static TIMESTAMP=new f("timestamp");static UUID=new f("uuid");static STRING=new f("string");static JSON=new f("json");static ARRAY_CONSTRUCTORS=new Map([[f.UINT8.toString(),Uint8Array],[f.UINT16.toString(),Uint16Array],[f.UINT32.toString(),Uint32Array],[f.UINT64.toString(),BigUint64Array],[f.FLOAT32.toString(),Float32Array],[f.FLOAT64.toString(),Float64Array],[f.INT8.toString(),Int8Array],[f.INT16.toString(),Int16Array],[f.INT32.toString(),Int32Array],[f.INT64.toString(),BigInt64Array],[f.TIMESTAMP.toString(),BigInt64Array],[f.STRING.toString(),Uint8Array],[f.JSON.toString(),Uint8Array],[f.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,f.UINT8],[Uint16Array.name,f.UINT16],[Uint32Array.name,f.UINT32],[BigUint64Array.name,f.UINT64],[Float32Array.name,f.FLOAT32],[Float64Array.name,f.FLOAT64],[Int8Array.name,f.INT8],[Int16Array.name,f.INT16],[Int32Array.name,f.INT32],[BigInt64Array.name,f.INT64]]);static DENSITIES=new Map([[f.UINT8.toString(),b.BIT8],[f.UINT16.toString(),b.BIT16],[f.UINT32.toString(),b.BIT32],[f.UINT64.toString(),b.BIT64],[f.FLOAT32.toString(),b.BIT32],[f.FLOAT64.toString(),b.BIT64],[f.INT8.toString(),b.BIT8],[f.INT16.toString(),b.BIT16],[f.INT32.toString(),b.BIT32],[f.INT64.toString(),b.BIT64],[f.TIMESTAMP.toString(),b.BIT64],[f.STRING.toString(),b.UNKNOWN],[f.JSON.toString(),b.UNKNOWN],[f.UUID.toString(),b.BIT128]]);static ALL=[f.UNKNOWN,f.FLOAT64,f.FLOAT32,f.INT64,f.INT32,f.INT16,f.INT8,f.UINT64,f.UINT32,f.UINT16,f.UINT8,f.TIMESTAMP,f.UUID,f.STRING,f.JSON];static SHORT_STRINGS=new Map([[f.UINT8.toString(),"u8"],[f.UINT16.toString(),"u16"],[f.UINT32.toString(),"u32"],[f.UINT64.toString(),"u64"],[f.INT8.toString(),"i8"],[f.INT16.toString(),"i16"],[f.INT32.toString(),"i32"],[f.INT64.toString(),"i64"],[f.FLOAT32.toString(),"f32"],[f.FLOAT64.toString(),"f64"],[f.BOOLEAN.toString(),"bool"],[f.TIMESTAMP.toString(),"ts"],[f.UUID.toString(),"uuid"],[f.STRING.toString(),"str"],[f.JSON.toString(),"json"]]);static BIG_INT_TYPES=[f.INT64,f.UINT64,f.TIMESTAMP];static z=c.z.union([c.z.string().transform(t=>new f(t)),c.z.instanceof(f)])}class p extends rt{constructor(t){j(t)&&(t=t.value),super(t.valueOf())}largerThan(t){return j(t)&&(t=t.value),this.valueOf()>t.valueOf()}smallerThan(t){return j(t)&&(t=t.value),this.valueOf()<t.valueOf()}add(t){return j(t)&&(t=t.value),new p(Y(this.valueOf(),t.valueOf()))}sub(t){return j(t)&&(t=t.value),new p(_(this.valueOf(),t.valueOf()))}mult(t){return new p(R(this.valueOf(),t))}div(t){return new p(St(this.valueOf(),t))}truncate(t){return new p(Math.trunc(this.valueOf()/new p(t).valueOf())*new p(t).valueOf())}remainder(t){return p.bytes(this.valueOf()%new p(t).valueOf())}get gigabytes(){return this.valueOf()/p.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/p.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/p.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/p.TERABYTE.valueOf()}toString(){const t=this.truncate(p.TERABYTE),n=this.truncate(p.GIGABYTE),r=this.truncate(p.MEGABYTE),s=this.truncate(p.KILOBYTE),i=this.truncate(p.BYTE),o=t,a=n.sub(t),u=r.sub(n),l=s.sub(r),d=i.sub(s);let y="";return o.isZero||(y+=`${o.terabytes}TB `),a.isZero||(y+=`${a.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),l.isZero||(y+=`${l.kilobytes}KB `),(!d.isZero||y==="")&&(y+=`${d.valueOf()}B`),y.trim()}static bytes(t=1){return new p(t)}static BYTE=new p(1);static kilobytes(t=1){return p.bytes(new p(t).valueOf()*1e3)}static KILOBYTE=p.kilobytes(1);static megabytes(t=1){return p.kilobytes(new p(t).valueOf()*1e3)}static MEGABYTE=p.megabytes(1);static gigabytes(t=1){return p.megabytes(new p(t).valueOf()*1e3)}static GIGABYTE=p.gigabytes(1);static terabytes(t){return p.gigabytes(new p(t).valueOf()*1e3)}static TERABYTE=p.terabytes(1);static ZERO=new p(0);static z=c.z.union([c.z.number().transform(t=>new p(t)),c.z.instanceof(p)]);get isZero(){return this.valueOf()===0}}const rc=c.z.object({start:c.z.number(),end:c.z.number()}),sc=c.z.union([c.z.instanceof(Uint8Array),c.z.instanceof(Uint16Array),c.z.instanceof(Uint32Array),c.z.instanceof(BigUint64Array),c.z.instanceof(Float32Array),c.z.instanceof(Float64Array),c.z.instanceof(Int8Array),c.z.instanceof(Int16Array),c.z.instanceof(Int32Array),c.z.instanceof(BigInt64Array)]),He=e=>{const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||e instanceof h||e instanceof g||e instanceof Date},ur=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(n)-Number(r):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):_(n,r),ic="00000000-0000-0000-0000-000000000000",oc=/^(?:[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 cc(e){return typeof e=="string"&&oc.test(e)}const S=[];for(let e=0;e<256;++e)S.push((e+256).toString(16).slice(1));function lr(e,t=0){return(S[e[t+0]]+S[e[t+1]]+S[e[t+2]]+S[e[t+3]]+"-"+S[e[t+4]]+S[e[t+5]]+"-"+S[e[t+6]]+S[e[t+7]]+"-"+S[e[t+8]]+S[e[t+9]]+"-"+S[e[t+10]]+S[e[t+11]]+S[e[t+12]]+S[e[t+13]]+S[e[t+14]]+S[e[t+15]]).toLowerCase()}function ac(e,t=0){const n=lr(e,t);if(!cc(n))throw TypeError("Stringified UUID is invalid");return n}let ne;const uc=new Uint8Array(16);function lc(){if(!ne){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ne=crypto.getRandomValues.bind(crypto)}return ne(uc)}const fc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),an={randomUUID:fc};function hc(e,t,n){e=e||{};const r=e.random??e.rng?.()??lc();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,lr(r)}function dc(e,t,n){return an.randomUUID&&!e?an.randomUUID():hc(e)}const gc=()=>dc(),Je=(e,t)=>ac(e,t),yc=ic,mc=Object.freeze(Object.defineProperty({__proto__:null,ZERO:yc,create:gc,parse:Je},Symbol.toStringTag,{value:"Module"})),H=-1,me={[Symbol.iterator]:()=>me,next:()=>({done:!0,value:void 0})},pc=c.z.string().transform(e=>new Uint8Array(atob(e).split("").map(t=>t.charCodeAt(0))).buffer),bc=c.z.union([c.z.null(),c.z.undefined()]).transform(()=>new Uint8Array().buffer),pe=10,fr=(e,t)=>{if(e==="number"&&!t.isNumeric)throw new Error(`cannot convert series of type ${t.toString()} to number`);if(e==="bigint"&&!t.usesBigInt)throw new Error(`cannot convert series of type ${t.toString()} to bigint`)},hr="sy_x_telem_series";class P{key;discriminator=hr;dataType;sampleOffset;gl;_data;timeRange=M.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=H;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=c.z.object({timeRange:M.z.optional(),dataType:f.z,alignment:c.z.coerce.bigint().optional(),data:c.z.union([pc,bc,c.z.instanceof(ArrayBuffer),c.z.instanceof(Uint8Array)]),glBufferUsage:ec.default("static").optional()});static z=P.crudeZ.transform(t=>new P(t));constructor(t){dr(t)&&(t={data:t}),t.data??=[];const{dataType:n,timeRange:r,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:a=1n,key:u=Ee(),data:l}=t;if(gr(l)){const m=l;this.key=m.key,this.dataType=m.dataType,this.sampleOffset=m.sampleOffset,this.gl=m.gl,this._data=m._data,this.timeRange=m.timeRange,this.alignment=m.alignment,this.alignmentMultiple=m.alignmentMultiple,this.cachedMin=m.cachedMin,this.cachedMax=m.cachedMax,this.writePos=m.writePos,this._refCount=m._refCount,this.cachedLength=m.cachedLength;return}const d=He(l),y=Array.isArray(l);if(n!=null)this.dataType=new f(n);else{if(l instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(y||d){let m=l;if(!d){if(l.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");m=l[0]}if(typeof m=="string")this.dataType=f.STRING;else if(typeof m=="number")this.dataType=f.FLOAT64;else if(typeof m=="bigint")this.dataType=f.INT64;else if(typeof m=="boolean")this.dataType=f.BOOLEAN;else if(m instanceof h||m instanceof Date||m instanceof h)this.dataType=f.TIMESTAMP;else if(typeof m=="object")this.dataType=f.JSON;else throw new Error(`cannot infer data type of ${typeof m} when constructing a Series from a JS array`)}else this.dataType=new f(l)}if(!y&&!d)this._data=l;else if(y&&l.length===0)this._data=new this.dataType.Array([]).buffer;else{let m=d?[l]:l;const A=m[0];(A instanceof h||A instanceof Date||A instanceof g)&&(m=m.map(E=>new h(E).valueOf())),this.dataType.equals(f.STRING)?(this.cachedLength=m.length,this._data=new TextEncoder().encode(`${m.join(`
|
|
4
4
|
`)}
|
|
5
5
|
`).buffer):this.dataType.equals(f.JSON)?(this.cachedLength=m.length,this._data=new TextEncoder().encode(`${m.map(E=>xt.encodeString(E)).join(`
|
|
6
6
|
`)}
|
|
7
|
-
`).buffer):this.dataType.usesBigInt&&typeof A=="number"?this._data=new this.dataType.Array(m.map(E=>BigInt(Math.round(E)))).buffer:!this.dataType.usesBigInt&&typeof A=="bigint"?this._data=new this.dataType.Array(m.map(Number)).buffer:this._data=new this.dataType.Array(m).buffer}this.key=
|
|
8
|
-
`).slice(0,-1):Array.from(this).map(t=>t.toString())}parseJSON(t){if(!this.dataType.equals(f.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(n=>t.parse(xt.decodeString(n)))}get byteCapacity(){return new p(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===D?this.byteCapacity:this.dataType.isVariable?new p(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===D?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;const n=[0];return this.data.forEach((r,s)=>{r===pe&&(t++,n.push(s+1))}),this._cachedIndexes=n,this.cachedLength=t,t}convert(t,n=0){if(this.dataType.equals(t))return this;const r=new t.Array(this.length);for(let s=0;s<this.length;s++)r[s]=ar(this.dataType,t,this.data[s],n);return new P({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(f.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this.cachedMax=t.reduce((n,r)=>n>r?n:r)}else{const t=this.data;this.cachedMax=t.reduce((n,r)=>n>r?n:r)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),Y(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(f.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this.cachedMin=t.reduce((n,r)=>n<r?n:r)}else{const t=this.data;this.cachedMin=t.reduce((n,r)=>n<r?n:r)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),Y(this.cachedMin,this.sampleOffset))}get bounds(){return w(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(t){if(this.cachedMin!=null){const n=t.cachedMin??t.calcRawMin();n<this.cachedMin&&(this.cachedMin=n)}if(this.cachedMax!=null){const n=t.cachedMax??t.calcRawMax();n>this.cachedMax&&(this.cachedMax=n)}}atAlignment(t,n){const r=Number((t-this.alignment)/this.alignmentMultiple);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(t,n=!1){if(this.dataType.isVariable)return this.atVariable(t,n??!1);if(this.dataType.equals(f.UUID))return this.atUUID(t,n);t<0&&(t=this.length+t);const r=this.data[t];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${t}`);return}return Y(r,this.sampleOffset)}atUUID(t,n){t<0&&(t=this.length+t);const r=Je(new Uint8Array(this.buffer,t*this.dataType.density.valueOf()));if(r==null){if(n)throw new Error(`[series] - no value at index ${t}`);return}return r}atVariable(t,n){let r=0,s=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[t],s=this._cachedIndexes[t+1]-1;else{t<0&&(t=this.length+t);for(let o=0;o<this.data.length;o++)if(this.data[o]===pe){if(t===0){s=o;break}r=o+1,t--}if(s===0&&(s=this.data.length),r>=s||t>0){if(n)throw new Error(`[series] - no value at index ${t}`);return}}const i=this.data.slice(r,s);return this.dataType.equals(f.STRING)?new TextDecoder().decode(i):Ae(JSON.parse(new TextDecoder().decode(i)))}binarySearch(t){let n=0,r=this.length-1;const s=At(t);for(;n<=r;){const i=Math.floor((n+r)/2),o=s(this.at(i,!0),t);if(o===0)return i;o<0?n=i+1:r=i-1}return n}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(f.FLOAT32)&&!this.dataType.equals(f.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:s}=this.gl;if(n==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==s)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==D){s===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,r==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=D}as(t){return fr(t,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:ln(this.alignmentBounds.lower),upper:ln(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return w(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const t=new wc(this);return this.dataType.equals(f.JSON)?new Xe(t):t}return this.dataType.equals(f.UUID)?new Oc(this):new xc(this)}slice(t,n){return this.sliceSub(!1,t,n)}sub(t,n){return this.sliceSub(!0,t,n)}subIterator(t,n){return new an(this,t,n??this.length)}subAlignmentIterator(t,n){const r=Math.ceil(Number(t-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(n-this.alignment)/Number(this.alignmentMultiple));return new an(this,r,s)}subBytes(t,n){if(t>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(t,n);return new P({data:r,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 s;return t?s=this.data.subarray(n,r):s=this.data.slice(n,r),new P({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(t){return new P({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}toString(){let t=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)t+=Array.from(this).map(n=>n.toString());else{for(let n=0;n<5;n++)t+=`${this.at(n)?.toString()}`,t+=",";t+="...,";for(let n=-5;n<0;n++)t+=this.at(n)?.toString(),n<-1&&(t+=",")}return t+="])",t}}const dr=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof P?!0:De(e),gr=Un(hr,P);class an{series;end;index;constructor(t,n,r){this.series=t;const s=w(0,t.length+1);this.end=ae(s,r),this.index=ae(s,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class wc{series;index;decoder;constructor(t){if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==pe;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}}class Xe{wrapped;static schema=c.z.record(c.z.string(),c.z.unknown());constructor(t){this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:xt.decodeString(t.value,Xe.schema)}}}class Oc{series;index;data;density;constructor(t){if(!t.dataType.equals(f.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=f.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=Je(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}}class xc{series;index;constructor(t){this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class Ic{series;constructor(t=[]){if(t.length!==0){const n=t[0].dataType;for(let r=1;r<t.length;r++)if(!t[r].dataType.equals(n))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){return fr(t,this.dataType),this}get dataType(){return this.series.length===0?f.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?M.ZERO:new M(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?w(0n,0n):w(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(t){const n=()=>new Error(`cannot push a ${t.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),r=t.dataType.equals(this.dataType);if(gr(t)){if(this.series.length!==0&&!r)throw n();this.series.push(t)}else{if(this.series.length!==0&&t.series.length!==0&&!r)throw n();this.series.push(...t.series)}}get length(){return this.series.reduce((t,n)=>t+n.length,0)}atAlignment(t,n){for(const r of this.series)if(k(r.alignmentBounds,t))return r.atAlignment(t,n);if(n)throw new Error(`[series] - no value at alignment ${t}`)}at(t,n=!1){t<0&&(t=this.length+t);for(const r of this.series){if(t<r.length)return r.at(t,n);t-=r.length}if(n)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,n){return new re(this,t,n??this.length)}subAlignmentIterator(t,n){if(t>=this.alignmentBounds.upper||n<=this.alignmentBounds.lower)return me;let r=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(t<o.alignment)break;if(t>=o.alignmentBounds.upper)r+=o.length;else if(k(o.alignmentBounds,t)){r+=Math.ceil(Number(t-o.alignment)/Number(o.alignmentMultiple));break}}let s=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(n<o.alignment)break;if(n>=o.alignmentBounds.upper)s+=o.length;else if(k(o.alignmentBounds,n)){s+=Math.ceil(Number(n-o.alignment)/Number(o.alignmentMultiple));break}}return new re(this,r,s)}subAlignmentSpanIterator(t,n){if(t>=this.alignmentBounds.upper)return me;n=Math.min(n,Number(this.distance(t,this.alignmentBounds.upper)));let r=0;for(let s=0;s<this.series.length;s++){const i=this.series[s];if(t<i.alignment)break;if(t>=i.alignmentBounds.upper)r+=i.length;else if(k(i.alignmentBounds,t)){r+=Number(t-i.alignment);break}}return new re(this,r,r+n)}updateGLBuffer(t){this.series.forEach(n=>n.updateGLBuffer(t))}get bounds(){return qn(this.series.map(t=>t.bounds))}get byteLength(){return new p(this.series.reduce((t,n)=>t+n.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let n=0;for(const r of this.series)t.set(r.data,n),n+=r.length;return new this.dataType.Array(t.buffer)}traverseAlignment(t,n){const r=this.series.map(s=>s.alignmentBounds);return Fn(r,t,n)}acquire(t){this.series.forEach(n=>n.acquire(t))}release(){this.series.forEach(t=>t.release())}distance(t,n){const r=this.series.map(s=>s.alignmentBounds);return Wn(r,t,n)}parseJSON(t){if(!this.dataType.equals(f.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(n=>n.parseJSON(t))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Nc(this.series)}toStrings(){return this.series.flatMap(t=>t.toStrings())}}class Nc{series;seriesIndex;internal;constructor(t){this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t: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}}class re{series;index;end;constructor(t,n,r){this.series=t,this.end=r,this.index=n}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}const ln=e=>{const t=e>>32n,n=e&0xffffffffn;return{domain:t,sample:n}},yr=async e=>await new Promise(t=>setTimeout(t,g.fromMilliseconds(e).milliseconds)),vc=Object.freeze(Object.defineProperty({__proto__:null,sleep:yr},Symbol.toStringTag,{value:"Module"}));class Mc{config;retries;interval;constructor(t){this.config={baseInterval:new g(t?.baseInterval??g.seconds(1)),maxRetries:t?.maxRetries??5,scale:t?.scale??1,sleepFn:t?.sleepFn??yr},this.retries=0,this.interval=new g(this.config.baseInterval)}async wait(){const{maxRetries:t,scale:n,sleepFn:r}=this.config;return this.retries>=t?!1:(await r(this.interval),this.interval=this.interval.mult(n),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}}const Ac=c.z.object({baseInterval:g.z.optional(),maxRetries:c.z.number().optional(),scale:c.z.number().optional()}),Sc=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Mc,breakerConfigZ:Ac},Symbol.toStringTag,{value:"Module"})),Ec=e=>c.z.object({variant:c.z.enum(["set","delete"]),key:c.z.string(),value:e}),Tc=Object.freeze(Object.defineProperty({__proto__:null,Z:Ec},Symbol.toStringTag,{value:"Module"})),$c=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Wt=c.z.string().regex($c),G=c.z.number().min(0).max(255),Ke=c.z.number().min(0).max(1),Kt=c.z.tuple([G,G,G,Ke]),zc=c.z.tuple([G,G,G]),Uc=c.z.object({rgba255:Kt}),jc=c.z.object({r:G,g:G,b:G,a:Ke}),Cc=c.z.number().min(0).max(360),Bc=c.z.number().min(0).max(100),Rc=c.z.number().min(0).max(100),mr=c.z.tuple([Cc,Bc,Rc,Ke]),Qt=c.z.union([Wt,zc,Kt,mr,Uc,jc]),Et=Qt.transform(e=>I(e)),Pc=e=>Et.safeParse(e).success,kc=e=>Kt.safeParse(e).success,Lc=(e=>{if(e==null)return;const t=Et.safeParse(e);if(t.success)return br(t.data);if(typeof e=="string")return e;throw t.error}),I=(e,t=1)=>{if(e=Qt.parse(e),typeof e=="string")return Lt(e,t);if(Array.isArray(e)){if(e.length<3||e.length>4)throw new 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},pr=(e,t)=>{if(e==null||t==null)return e==t;const n=I(e),r=I(t);return n.every((s,i)=>s===r[i])},Zc=(e=>{if(e==null)return;const[t,n,r,s]=I(e),i=Math.round(s*255);return`#${jt(t)}${jt(n)}${jt(r)}${i===255?"":jt(i)}`}),br=e=>{const[t,n,r,s]=I(e);return`rgba(${t}, ${n}, ${r}, ${s})`},_c=e=>`rgb(${wr(e)})`,wr=e=>{const[t,n,r]=I(e);return`${t}, ${n}, ${r}`},qc=e=>[...Qe(e),wt(e)],Qe=e=>[mt(e)/255,pt(e)/255,bt(e)/255],mt=e=>I(e)[0],pt=e=>I(e)[1],bt=e=>I(e)[2],wt=e=>I(e)[3],Fc=e=>pr(tn,e),Wc=e=>Qc(I(e)),Vc=(e,t)=>{const[n,r,s]=I(e);if(t>100)throw new Error(`Color opacity must be between 0 and 100, got ${t}`);return t>1&&(t/=100),[n,r,s,t]},vt=e=>{const[t,n,r]=Qe(e).map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},Yc=e=>{const[t,n,r]=Qe(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},be=(e,t)=>{const n=I(e),r=I(t),s=vt(n),i=vt(r);return(Math.max(s,i)+.5)/(Math.min(s,i)+.5)},Gc=(e,...t)=>{if(t.length===0)throw new Error("[Color.pickByContrast] - must provide at least one color");const n=I(e),[r]=t.sort((s,i)=>be(n,i)-be(n,s));return I(r)},Hc=e=>vt(e)<.5,Dc=e=>vt(e)>.5,Lt=(e,t=1)=>(e=Wt.parse(e),e=Jc(e),[Ct(e,0),Ct(e,2),Ct(e,4),e.length===8?Ct(e,6)/255:t]),tn=[0,0,0,0],jt=e=>Math.floor(e).toString(16).padStart(2,"0"),Ct=(e,t)=>parseInt(e.slice(t,t+2),16),Jc=e=>e.startsWith("#")?e.slice(1):e,fn={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"},Xc=e=>{if(!e)return;const t=e.trim().toLowerCase();if(!(t==="transparent"||t==="none")){if(t.startsWith("#")){if(t.length===4){const n=t[1],r=t[2],s=t[3],i=`#${n}${n}${r}${r}${s}${s}`;if(Wt.safeParse(i).success)return Lt(i)}return(t.length===7||t.length===9)&&Wt.safeParse(t).success?Lt(t):void 0}if(t.startsWith("rgb")){const n=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(n){const[,r,s,i,o]=n;return[parseInt(r),parseInt(s),parseInt(i),o?parseFloat(o):1]}}if(fn[t])return Lt(fn[t])}},Kc=e=>{e=mr.parse(e);let[t,n,r]=e;const s=e[3];t/=360,n/=100,r/=100;let i,o,u;if(n===0)i=o=u=r;else{const a=r<.5?r*(1+n):r+n-r*n,l=2*r-a;i=se(l,a,t+1/3),o=se(l,a,t),u=se(l,a,t-1/3)}return[Math.round(i*255),Math.round(o*255),Math.round(u*255),s]},se=(e,t,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Qc=e=>{e=Kt.parse(e);let[t,n,r]=e;const s=e[3];t/=255,n/=255,r/=255;const i=Math.max(t,n,r),o=Math.min(t,n,r);let u,a,l=(i+o)/2;if(i===o)u=a=0;else{const h=i-o;a=l>.5?h/(2-i-o):h/(i+o),i===t?u=(n-r)/h+(n<r?6:0):i===n?u=(r-t)/h+2:u=(t-n)/h+4,u/=6}return u*=360,a*=100,l*=100,[Math.round(u),Math.round(a),Math.round(l),s]},tu=I("#000000"),eu=I("#ffffff"),Or=c.z.object({key:c.z.string(),color:Qt,position:c.z.number(),switched:c.z.boolean().optional()}),nu=c.z.array(Or),ru=(e,t)=>{if(e.length===0)return tn;if(e=e.slice().sort((n,r)=>n.position-r.position),t<=e[0].position)return I(e[0].color);if(t>=e[e.length-1].position)return I(e[e.length-1].color);for(let n=0;n<e.length-1;n++){const r=e[n],s=e[n+1];if(t<r.position||t>s.position)continue;if(t===r.position)return I(r.color);if(t===s.position)return I(s.color);const i=(t-r.position)/(s.position-r.position),o=I(r.color),u=I(s.color),a=Math.round(mt(o)+i*(mt(u)-mt(o))),l=Math.round(pt(o)+i*(pt(u)-pt(o))),h=Math.round(bt(o)+i*(bt(u)-bt(o))),y=wt(o)+i*(wt(u)-wt(o));return I([a,l,h,y])}return I(e[e.length-1].color)},su=c.z.object({key:c.z.string(),name:c.z.string(),color:Et}),iu=c.z.object({key:c.z.string(),name:c.z.string(),swatches:c.z.array(su)}),ou=Object.freeze(Object.defineProperty({__proto__:null,BLACK:tu,WHITE:eu,ZERO:tn,aValue:wt,bValue:bt,colorZ:Et,construct:I,contrast:be,crudeZ:Qt,cssString:Lc,equals:pr,fromCSS:Xc,fromGradient:ru,fromHSLA:Kc,gValue:pt,gradientZ:nu,grayness:Yc,hex:Zc,hsla:Wc,isColor:kc,isCrude:Pc,isDark:Hc,isLight:Dc,isZero:Fc,luminance:vt,paletteZ:iu,pickByContrast:Gc,rValue:mt,rgbCSS:_c,rgbString:wr,rgba1:qc,rgbaCSS:br,setAlpha:Vc,stopZ:Or},Symbol.toStringTag,{value:"Module"})),xr=c.z.int().min(0).max(255),Ir=255,Nr=0,cu={lower:Nr,upper:Ir+1},vr=c.z.object({name:c.z.string(),key:c.z.string()}),Mt=e=>c.z.object({subject:vr,resource:e,authority:xr}),uu=(...e)=>t=>t.filter(n=>{let r=!1;return n.to!=null&&(r=e.includes(n.to.resource)),n.from!=null&&!r&&(r=e.includes(n.from.resource)),r}),Mr=e=>c.z.object({from:Mt(e),to:c.z.null()}),Ar=e=>c.z.object({from:c.z.null(),to:Mt(e)}),au=e=>c.z.union([Mr(e),Ar(e),c.z.object({from:Mt(e),to:Mt(e)})]),lu=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Ir,AUTHORITY_BOUNDS:cu,ZERO_AUTHORITY:Nr,acquireZ:Ar,authorityZ:xr,filterTransfersByChannelKey:uu,releaseZ:Mr,stateZ:Mt,subjectZ:vr,transferZ:au},Symbol.toStringTag,{value:"Module"})),fu=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 hn(e.toString());case"object":return e==null?"":hn(JSON.stringify(e))}},hu=/[",\n]/,hn=e=>hu.test(e)?`"${e.replace(/"/g,'""')}"`:e,du=Object.freeze(Object.defineProperty({__proto__:null,formatValue:fu},Symbol.toStringTag,{value:"Module"})),gu=(e,t)=>{let n=null;return t===0?e:(...s)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>e(...s),t)}},yu=(e,t)=>{let n=null;return t===0?e:(...s)=>{n===null&&(n=setTimeout(()=>{e(...s),n=null},t))}},mu=e=>{try{return structuredClone(e)}catch{return console.warn("Failed to deep copy object, falling back to JSON.parse(JSON.stringify)",e),console.trace(),JSON.parse(JSON.stringify(e))}},pu=(e,t,n="")=>{const r={},s=(i,o,u)=>{if(typeof i!=typeof o||i===null||o===null){r[u]=[i,o];return}if(typeof i=="object"&&typeof o=="object")if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length){r[u]=[i,o];return}for(let a=0;a<i.length;a++)s(i[a],o[a],`${u}[${a}]`)}else new Set([...Object.keys(i),...Object.keys(o)]).forEach(l=>{s(i[l],o[l],u!==""?`${u}.${l}`:l)});else i!==o&&(r[u]=[i,o])};return s(e,t,n),r},we=(e,t)=>{const n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r){const o=e,u=t;if(o.length!==u.length)return!1;for(let a=0;a<o.length;a++)if(!we(o[a],u[a]))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);const s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(const o of s){const u=e[o],a=t[o];if(typeof u=="object"&&typeof a=="object"){if(!we(u,a))return!1}else if(u!==a)return!1}return!0},Sr=(e,t)=>{if(typeof e!="object"||e==null)return e===t;const n=Object.keys(e),r=Object.keys(t);if(r.length>n.length)return!1;for(const s of r){const i=e[s],o=t[s];if(typeof i=="object"&&typeof o=="object"){if(!Sr(i,o))return!1}else if(i!==o)return!1}return!0},U=".",Er=(e,t,n=U)=>{const r=e.split(n);return r.map((i,o)=>{const u=t(i,o,r);return u==null?null:typeof u=="string"?u:u.join(n)}).filter(i=>i!=null).join(n)},ht=(e,t)=>{if(!Array.isArray(e))return e[t];const n=e[t];if(n!=null||e.length==0)return n;const r=e[0];if(typeof r=="object"&&"key"in r)return e.find(s=>s.key===t)},bu=(e,t)=>{const n=e.split(U);return n.forEach((r,s)=>{t=ht(t,r),t!=null&&typeof t=="object"&&"key"in t&&(n[s]=t.key)}),n.join(U)},wu=(e,t)=>{const n=e.split(U);return t<0?n[n.length+t]:n[t]},Ou=(e,t)=>{if(t.length===0)return!0;const n=e.split(U),r=t.split(U);if(r.length>n.length)return!1;for(let s=0;s<r.length;s++){const i=n[s],o=r[s];if(o!=="*"&&i!==o)return!1}return!0},it=e=>{const t=parseInt(e);return isNaN(t)||t<0||t.toString()!==e?null:t},Oe=(e,t)=>{for(let n=1;n<=t.length;n++){const r=t.slice(0,n).join(U);if(ht(e,r)!=null)return[r,n]}return null},en=((e,t,n={optional:!1})=>{const{optional:r,getter:s=ht}=n;if(t==="")return e;const i=t.split(U);if(i.length===1){const u=s(e,i[0]);if(u===void 0){if(r)return null;throw new Error(`Path ${t} does not exist. ${i[0]} is undefined`)}return u}const o=(u,a)=>{if(a>=i.length)return u;for(let l=i.length-a;l>=1;l--){const h=i.slice(a,a+l).join(U),y=s(u,h);if(y!==void 0){if(a+l===i.length)return y;if(y===null){if(r)return null;throw new Error(`Path ${t} does not exist. ${h} is null`)}return o(y,a+l)}}if(r)return null;throw new Error(`Path ${t} does not exist. ${i[a]} is undefined`)};return o(e,0)}),xu=(e,t)=>en(e,t,{optional:!0})!==null,xe=(e,...t)=>{if(t.length===0)return e;const n=t.shift();if(ct(e)&&ct(n))for(const r in n)try{ct(n[r])?(r in e||Object.assign(e,{[r]:{}}),xe(e[r],n[r])):Object.assign(e,{[r]:n[r]})}catch(s){throw s instanceof TypeError?new TypeError(`.${r}: ${s.message}`):s}return xe(e,...t)},Iu=(e,t,n)=>{const r=(s,i,o)=>{if(o.def?.type==="union")return o.def.options.reduce((u,a)=>r(u,i,a),s);if(o.def?.type==="intersection"){const u=r(s,i,o.def.left);return r(u,i,o.def.right)}for(const u in i){const a=i[u];let l=o?.shape;if(l!=null)for(;l!=null;){if(l[u]!=null){const h=l[u].safeParse(a);if(h.success){s[u]=h.data;break}}l=l.def?.shape}typeof a=="object"&&!Array.isArray(a)&&a!==null&&o&&o.shape&&o.shape[u]&&(s[u]||={},r(s[u],a,o.shape[u]))}return s};return r({...e},t,n)},Nu=(e,t)=>{const n=t.split(U);let r=e,s=0;for(;s<n.length;){if(s===n.length-1){const o=n[s];if(Array.isArray(r)){const u=parseInt(o);if(!isNaN(u)&&u<r.length){r.splice(u,1);return}const a=r[0];if(typeof a=="object"&&"key"in a){const l=r.findIndex(h=>h.key===o);if(l!==-1){r.splice(l,1);return}}return}delete r[o];return}let i=!1;if(Array.isArray(r)&&r.length>0){const o=r[0];if(typeof o=="object"&&"key"in o)for(let u=n.length-s;u>=1;u--){const a=n.slice(s,s+u).join(U),l=r.find(h=>h.key===a);if(l!=null){if(s+u===n.length){const h=r.findIndex(y=>y.key===a);h!==-1&&r.splice(h,1);return}r=l,s+=u,i=!0;break}}}if(!i)for(let o=n.length-s;o>=1;o--){const u=n.slice(s,s+o).join(U);if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&u in r){if(s+o===n.length){delete r[u];return}r=r[u],s+=o,i=!0;break}}if(!i){const o=ht(r,n[s]);if(o==null)return;r=o,s++}}},vu=(e,t,n)=>{const r=t.split(U);let s=e,i=0;for(;i<r.length-1;){const o=Oe(s,r.slice(i,r.length-1));let u;o!=null?[u,i]=[o[0],i+o[1]]:(u=r[i],i++);let a=ht(s,u);if(a==null){const l=r[i];let h=it(l);h==null&&l.startsWith("-")&&it(l.substring(1))!=null&&(h=0),a=h!=null?[]:{},s[u]=a}s=a}try{const o=r[r.length-1];if(Array.isArray(s)){let a=it(o);if(a==null){if(o.startsWith("-")){const l=it(o.substring(1));l!=null&&(a=s.length-l)}if(a==null){if(s.length===0){const h=it(o);if(h!=null){s[h]=n;return}}const l=s[0];if(typeof l=="object"&&"key"in l){const h=s.findIndex(y=>y.key===o);if(h!==-1){s[h]=n;return}}return}}s[a]=n;return}const u=Oe(s,[o]);if(u!=null){s[u[0]]=n;return}s[o]=n}catch(o){throw console.error("failed to set value",n,"at path",t,"on object",e),o}},Mu=Object.freeze(Object.defineProperty({__proto__:null,SEPARATOR:U,copy:mu,defaultGetter:ht,difference:pu,element:wu,equal:we,findBestKey:Oe,get:en,getIndex:it,has:xu,override:xe,overrideValidItems:Iu,partialEqual:Sr,pathsMatch:Ou,remove:Nu,resolvePath:bu,set:vu,transformPath:Er},Symbol.toStringTag,{value:"Module"})),Au=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Su=e=>Object.getOwnPropertySymbols(globalThis).includes(e),Eu=(e,t)=>{const n=Symbol.for(e);if(!Su(n)){const r=t();Object.defineProperty(globalThis,n,{value:r})}return()=>globalThis[n]},Tr="sy_x_error",Tu=e=>t=>t!=null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"?t.type.startsWith(e):t instanceof Error?t.message.startsWith(e):typeof t!="string"?!1:t.startsWith(e),Tt=e=>class yt extends Error{static discriminator=Tr;discriminator=yt.discriminator;static TYPE=e;type=yt.TYPE;static matches=Tu(e);matches=yt.matches;constructor(n,r){super(n,r),this.name=yt.TYPE}static sub(n){return Tt(`${e}.${n}`)}},$r=e=>{if(e==null||typeof e!="object")return!1;const t=e;if(t.discriminator!==Tr)return!1;if(!("type"in t))throw new Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},ot="unknown",Ie="nil";class $u{providers=[];register(t){this.providers.push(t)}encode(t){if(t==null)return{type:Ie,data:""};if($r(t))for(const n of this.providers){const r=n.encode(t);if(r!=null)return r}if(t instanceof Error)return{type:ot,data:t.message};if(typeof t=="string")return{type:ot,data:t};try{return{type:ot,data:JSON.stringify(t)}}catch{return{type:ot,data:"unable to encode error information"}}}decode(t){if(t==null||t.type===Ie)return null;if(t.type===ot)return new Ne(t.data);for(const n of this.providers){const r=n.decode(t);if(r!=null)return r}return new Ne(t.data)}}const nn=Eu("synnax-error-registry",()=>new $u),zu=({encode:e,decode:t})=>nn().register({encode:e,decode:t}),Uu=e=>nn().encode(e),ju=e=>e==null?null:nn().decode(e);class Ne extends Tt("unknown"){}const Cu=c.z.object({type:c.z.string(),data:c.z.string()});class Bu extends Tt("canceled"){}class Ru extends Tt("not_implemented"){}const Pu=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Bu,NONE:Ie,NotImplemented:Ru,UNKNOWN:ot,Unknown:Ne,createTyped:Tt,decode:ju,encode:Uu,isTyped:$r,payloadZ:Cu,register:zu},Symbol.toStringTag,{value:"Module"}));class ku{store=new Map;async get(t){return this.store.get(t)??null}async set(t,n){this.store.set(t,n)}async delete(t){this.store.delete(t)}async length(){return this.store.size}async clear(){this.store.clear()}}class Lu{store=new Map;get(t){return this.store.get(t)??null}set(t,n){this.store.set(t,n)}delete(t){this.store.delete(t)}}const Zu=c.z.object({key:c.z.string(),value:c.z.string()}),_u=Object.freeze(Object.defineProperty({__proto__:null,MockAsync:ku,MockSync:Lu,stringPairZ:Zu},Symbol.toStringTag,{value:"Module"})),zr=c.uuid(),Ur=c.object({key:zr,name:c.string().min(1),color:Et}),qu=Object.freeze(Object.defineProperty({__proto__:null,keyZ:zr,labelZ:Ur},Symbol.toStringTag,{value:"Module"})),Fu=new RegExp("^(https?:\\/\\/)?((([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,})|localhost|(\\d{1,3}\\.){3}\\d{1,3})(\\:\\d+)?(\\/[-a-zA-Z0-9@:%._\\+~#=]*)*(\\?[;&a-zA-Z0-9%_.,~+=-]*)?(#[-a-zA-Z0-9_]*)?$"),Wu=e=>Fu.test(e),Vu=Object.freeze(Object.defineProperty({__proto__:null,is:Wu},Symbol.toStringTag,{value:"Module"})),Yu=(e,t,n)=>{const r=e.get(t);return r===void 0?(e.set(t,n),n):r},Gu=Object.freeze(Object.defineProperty({__proto__:null,getOrSetDefault:Yu},Symbol.toStringTag,{value:"Module"})),ve=c.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),Hu=(e,t)=>{const n=e.split("."),r=t.split("."),s=Math.max(n.length,r.length);for(let i=0;i<s;i++){const o=n[i],u=r[i];if(o===void 0)return W;if(u===void 0)return V;const a=/^\d+$/.test(o),l=/^\d+$/.test(u);if(a&&!l)return W;if(!a&&l)return V;if(a&&l){const h=parseInt(o),y=parseInt(u);if(h<y)return W;if(h>y)return V}else{if(o<u)return W;if(o>u)return V}}return st},$t=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;const r=ve.parse(e),s=ve.parse(t),[i,o]=r.split("-"),[u,a]=s.split("-"),[l,h,y]=i.split(".").map(Number),[m,A,E]=u.split(".").map(Number);if(n.checkMajor){if(l<m)return W;if(l>m)return V}if(n.checkMinor){if(h<A)return W;if(h>A)return V}if(n.checkPatch){if(y<E)return W;if(y>E)return V}return o===void 0&&a===void 0?st:o===void 0?V:a===void 0?W:Hu(o,a)}),Du=(e,t,n={})=>Sn($t(e,t,n)),jr=(e,t,n={})=>An($t(e,t,n)),Ju=(e,t,n={})=>Mn($t(e,t,n)),Xu=({name:e,migrate:t})=>n=>{try{const r=t(n);return console.log(`${e} migrated: ${n.version} -> ${r.version}`),r}catch(r){throw console.log(`${e} failed to migrate from ${n.version}`),console.error(r),r}},Ku=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:s})=>{const i=Object.keys(t).sort($t).pop();if(i==null)return l=>{if(l.version??=r,l.version!==s.version)return console.log(`${e} version ${l.version} is newer than latest version of ${s.version}.
|
|
7
|
+
`).buffer):this.dataType.usesBigInt&&typeof A=="number"?this._data=new this.dataType.Array(m.map(E=>BigInt(Math.round(E)))).buffer:!this.dataType.usesBigInt&&typeof A=="bigint"?this._data=new this.dataType.Array(m.map(Number)).buffer:this._data=new this.dataType.Array(m).buffer}this.key=u,this.alignment=o,this.alignmentMultiple=a,this.sampleOffset=s??0,this.timeRange=r??M.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:t,dataType:n,...r}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new f(n).Array(t),i=new P({data:s.buffer,dataType:n,...r});return i.writePos=0,i}get refCount(){return this._refCount}acquire(t){this._refCount++,t!=null&&this.updateGLBuffer(t)}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(t){if(!t.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(t):this.writeFixed(t)}writeVariable(t){if(this.writePos===H)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=t.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(t){if(this.writePos===H)return 0;const n=this.capacity-this.writePos,r=t.sub(0,n);return this.writeToUnderlyingData(r),this.cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(t){this.underlyingData.set(t.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===H?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
|
|
8
|
+
`).slice(0,-1):Array.from(this).map(t=>t.toString())}parseJSON(t){if(!this.dataType.equals(f.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(n=>t.parse(xt.decodeString(n)))}get byteCapacity(){return new p(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===H?this.byteCapacity:this.dataType.isVariable?new p(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===H?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;const n=[0];return this.data.forEach((r,s)=>{r===pe&&(t++,n.push(s+1))}),this._cachedIndexes=n,this.cachedLength=t,t}convert(t,n=0){if(this.dataType.equals(t))return this;const r=new t.Array(this.length);for(let s=0;s<this.length;s++)r[s]=ur(this.dataType,t,this.data[s],n);return new P({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(f.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this.cachedMax=t.reduce((n,r)=>n>r?n:r)}else{const t=this.data;this.cachedMax=t.reduce((n,r)=>n>r?n:r)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),Y(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(f.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this.cachedMin=t.reduce((n,r)=>n<r?n:r)}else{const t=this.data;this.cachedMin=t.reduce((n,r)=>n<r?n:r)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),Y(this.cachedMin,this.sampleOffset))}get bounds(){return w(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(t){if(this.cachedMin!=null){const n=t.cachedMin??t.calcRawMin();n<this.cachedMin&&(this.cachedMin=n)}if(this.cachedMax!=null){const n=t.cachedMax??t.calcRawMax();n>this.cachedMax&&(this.cachedMax=n)}}atAlignment(t,n){const r=Number((t-this.alignment)/this.alignmentMultiple);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(t,n=!1){if(this.dataType.isVariable)return this.atVariable(t,n??!1);if(this.dataType.equals(f.UUID))return this.atUUID(t,n);t<0&&(t=this.length+t);const r=this.data[t];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${t}`);return}return Y(r,this.sampleOffset)}atUUID(t,n){t<0&&(t=this.length+t);const r=Je(new Uint8Array(this.buffer,t*this.dataType.density.valueOf()));if(r==null){if(n)throw new Error(`[series] - no value at index ${t}`);return}return r}atVariable(t,n){let r=0,s=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[t],s=this._cachedIndexes[t+1]-1;else{t<0&&(t=this.length+t);for(let o=0;o<this.data.length;o++)if(this.data[o]===pe){if(t===0){s=o;break}r=o+1,t--}if(s===0&&(s=this.data.length),r>=s||t>0){if(n)throw new Error(`[series] - no value at index ${t}`);return}}const i=this.data.slice(r,s);return this.dataType.equals(f.STRING)?new TextDecoder().decode(i):Ae(JSON.parse(new TextDecoder().decode(i)))}binarySearch(t){let n=0,r=this.length-1;const s=At(t);for(;n<=r;){const i=Math.floor((n+r)/2),o=s(this.at(i,!0),t);if(o===0)return i;o<0?n=i+1:r=i-1}return n}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(f.FLOAT32)&&!this.dataType.equals(f.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:s}=this.gl;if(n==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==s)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==H){s===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,r==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=H}as(t){return fr(t,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:ln(this.alignmentBounds.lower),upper:ln(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return w(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const t=new wc(this);return this.dataType.equals(f.JSON)?new Xe(t):t}return this.dataType.equals(f.UUID)?new Oc(this):new xc(this)}slice(t,n){return this.sliceSub(!1,t,n)}sub(t,n){return this.sliceSub(!0,t,n)}subIterator(t,n){return new un(this,t,n??this.length)}subAlignmentIterator(t,n){const r=Math.ceil(Number(t-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(n-this.alignment)/Number(this.alignmentMultiple));return new un(this,r,s)}subBytes(t,n){if(t>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(t,n);return new P({data:r,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 s;return t?s=this.data.subarray(n,r):s=this.data.slice(n,r),new P({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(t){return new P({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}toString(){let t=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)t+=Array.from(this).map(n=>n.toString());else{for(let n=0;n<5;n++)t+=`${this.at(n)?.toString()}`,t+=",";t+="...,";for(let n=-5;n<0;n++)t+=this.at(n)?.toString(),n<-1&&(t+=",")}return t+="])",t}}const dr=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof P?!0:He(e),gr=Un(hr,P);class un{series;end;index;constructor(t,n,r){this.series=t;const s=w(0,t.length+1);this.end=ue(s,r),this.index=ue(s,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class wc{series;index;decoder;constructor(t){if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==pe;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}}class Xe{wrapped;static schema=c.z.record(c.z.string(),c.z.unknown());constructor(t){this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:xt.decodeString(t.value,Xe.schema)}}}class Oc{series;index;data;density;constructor(t){if(!t.dataType.equals(f.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=f.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=Je(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}}class xc{series;index;constructor(t){this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class Ic{series;constructor(t=[]){if(t.length!==0){const n=t[0].dataType;for(let r=1;r<t.length;r++)if(!t[r].dataType.equals(n))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){return fr(t,this.dataType),this}get dataType(){return this.series.length===0?f.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?M.ZERO:new M(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?w(0n,0n):w(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(t){const n=()=>new Error(`cannot push a ${t.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),r=t.dataType.equals(this.dataType);if(gr(t)){if(this.series.length!==0&&!r)throw n();this.series.push(t)}else{if(this.series.length!==0&&t.series.length!==0&&!r)throw n();this.series.push(...t.series)}}get length(){return this.series.reduce((t,n)=>t+n.length,0)}atAlignment(t,n){for(const r of this.series)if(k(r.alignmentBounds,t))return r.atAlignment(t,n);if(n)throw new Error(`[series] - no value at alignment ${t}`)}at(t,n=!1){t<0&&(t=this.length+t);for(const r of this.series){if(t<r.length)return r.at(t,n);t-=r.length}if(n)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,n){return new re(this,t,n??this.length)}subAlignmentIterator(t,n){if(t>=this.alignmentBounds.upper||n<=this.alignmentBounds.lower)return me;let r=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(t<o.alignment)break;if(t>=o.alignmentBounds.upper)r+=o.length;else if(k(o.alignmentBounds,t)){r+=Math.ceil(Number(t-o.alignment)/Number(o.alignmentMultiple));break}}let s=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(n<o.alignment)break;if(n>=o.alignmentBounds.upper)s+=o.length;else if(k(o.alignmentBounds,n)){s+=Math.ceil(Number(n-o.alignment)/Number(o.alignmentMultiple));break}}return new re(this,r,s)}subAlignmentSpanIterator(t,n){if(t>=this.alignmentBounds.upper)return me;n=Math.min(n,Number(this.distance(t,this.alignmentBounds.upper)));let r=0;for(let s=0;s<this.series.length;s++){const i=this.series[s];if(t<i.alignment)break;if(t>=i.alignmentBounds.upper)r+=i.length;else if(k(i.alignmentBounds,t)){r+=Number(t-i.alignment);break}}return new re(this,r,r+n)}updateGLBuffer(t){this.series.forEach(n=>n.updateGLBuffer(t))}get bounds(){return qn(this.series.map(t=>t.bounds))}get byteLength(){return new p(this.series.reduce((t,n)=>t+n.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let n=0;for(const r of this.series)t.set(r.data,n),n+=r.length;return new this.dataType.Array(t.buffer)}traverseAlignment(t,n){const r=this.series.map(s=>s.alignmentBounds);return Fn(r,t,n)}acquire(t){this.series.forEach(n=>n.acquire(t))}release(){this.series.forEach(t=>t.release())}distance(t,n){const r=this.series.map(s=>s.alignmentBounds);return Wn(r,t,n)}parseJSON(t){if(!this.dataType.equals(f.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(n=>n.parseJSON(t))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Nc(this.series)}toStrings(){return this.series.flatMap(t=>t.toStrings())}}class Nc{series;seriesIndex;internal;constructor(t){this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t: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}}class re{series;index;end;constructor(t,n,r){this.series=t,this.end=r,this.index=n}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}const ln=e=>{const t=e>>32n,n=e&0xffffffffn;return{domain:t,sample:n}},yr=async e=>await new Promise(t=>setTimeout(t,g.fromMilliseconds(e).milliseconds)),vc=Object.freeze(Object.defineProperty({__proto__:null,sleep:yr},Symbol.toStringTag,{value:"Module"}));class Mc{config;retries;interval;constructor(t){this.config={baseInterval:new g(t?.baseInterval??g.seconds(1)),maxRetries:t?.maxRetries??5,scale:t?.scale??1,sleepFn:t?.sleepFn??yr},this.retries=0,this.interval=new g(this.config.baseInterval)}async wait(){const{maxRetries:t,scale:n,sleepFn:r}=this.config;return this.retries>=t?!1:(await r(this.interval),this.interval=this.interval.mult(n),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}}const Ac=c.z.object({baseInterval:g.z.optional(),maxRetries:c.z.number().optional(),scale:c.z.number().optional()}),Sc=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Mc,breakerConfigZ:Ac},Symbol.toStringTag,{value:"Module"})),Ec=e=>c.z.object({variant:c.z.enum(["set","delete"]),key:c.z.string(),value:e}),Tc=Object.freeze(Object.defineProperty({__proto__:null,Z:Ec},Symbol.toStringTag,{value:"Module"})),$c=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Wt=c.z.string().regex($c),D=c.z.number().min(0).max(255),Ke=c.z.number().min(0).max(1),Kt=c.z.tuple([D,D,D,Ke]),zc=c.z.tuple([D,D,D]),Uc=c.z.object({rgba255:Kt}),jc=c.z.object({r:D,g:D,b:D,a:Ke}),Cc=c.z.number().min(0).max(360),Bc=c.z.number().min(0).max(100),Rc=c.z.number().min(0).max(100),mr=c.z.tuple([Cc,Bc,Rc,Ke]),Qt=c.z.union([Wt,zc,Kt,mr,Uc,jc]),Et=Qt.transform(e=>I(e)),Pc=e=>Et.safeParse(e).success,kc=e=>Kt.safeParse(e).success,Lc=(e=>{if(e==null)return;const t=Et.safeParse(e);if(t.success)return br(t.data);if(typeof e=="string")return e;throw t.error}),I=(e,t=1)=>{if(e=Qt.parse(e),typeof e=="string")return Lt(e,t);if(Array.isArray(e)){if(e.length<3||e.length>4)throw new 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},pr=(e,t)=>{if(e==null||t==null)return e==t;const n=I(e),r=I(t);return n.every((s,i)=>s===r[i])},Zc=(e=>{if(e==null)return;const[t,n,r,s]=I(e),i=Math.round(s*255);return`#${jt(t)}${jt(n)}${jt(r)}${i===255?"":jt(i)}`}),br=e=>{const[t,n,r,s]=I(e);return`rgba(${t}, ${n}, ${r}, ${s})`},_c=e=>`rgb(${wr(e)})`,wr=e=>{const[t,n,r]=I(e);return`${t}, ${n}, ${r}`},qc=e=>[...Qe(e),wt(e)],Qe=e=>[mt(e)/255,pt(e)/255,bt(e)/255],mt=e=>I(e)[0],pt=e=>I(e)[1],bt=e=>I(e)[2],wt=e=>I(e)[3],Fc=e=>pr(tn,e),Wc=e=>Qc(I(e)),Vc=(e,t)=>{const[n,r,s]=I(e);if(t>100)throw new Error(`Color opacity must be between 0 and 100, got ${t}`);return t>1&&(t/=100),[n,r,s,t]},vt=e=>{const[t,n,r]=Qe(e).map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},Yc=e=>{const[t,n,r]=Qe(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},be=(e,t)=>{const n=I(e),r=I(t),s=vt(n),i=vt(r);return(Math.max(s,i)+.5)/(Math.min(s,i)+.5)},Dc=(e,...t)=>{if(t.length===0)throw new Error("[Color.pickByContrast] - must provide at least one color");const n=I(e),[r]=t.sort((s,i)=>be(n,i)-be(n,s));return I(r)},Gc=e=>vt(e)<.5,Hc=e=>vt(e)>.5,Lt=(e,t=1)=>(e=Wt.parse(e),e=Jc(e),[Ct(e,0),Ct(e,2),Ct(e,4),e.length===8?Ct(e,6)/255:t]),tn=[0,0,0,0],jt=e=>Math.floor(e).toString(16).padStart(2,"0"),Ct=(e,t)=>parseInt(e.slice(t,t+2),16),Jc=e=>e.startsWith("#")?e.slice(1):e,fn={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"},Xc=e=>{if(!e)return;const t=e.trim().toLowerCase();if(!(t==="transparent"||t==="none")){if(t.startsWith("#")){if(t.length===4){const n=t[1],r=t[2],s=t[3],i=`#${n}${n}${r}${r}${s}${s}`;if(Wt.safeParse(i).success)return Lt(i)}return(t.length===7||t.length===9)&&Wt.safeParse(t).success?Lt(t):void 0}if(t.startsWith("rgb")){const n=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(n){const[,r,s,i,o]=n;return[parseInt(r),parseInt(s),parseInt(i),o?parseFloat(o):1]}}if(fn[t])return Lt(fn[t])}},Kc=e=>{e=mr.parse(e);let[t,n,r]=e;const s=e[3];t/=360,n/=100,r/=100;let i,o,a;if(n===0)i=o=a=r;else{const u=r<.5?r*(1+n):r+n-r*n,l=2*r-u;i=se(l,u,t+1/3),o=se(l,u,t),a=se(l,u,t-1/3)}return[Math.round(i*255),Math.round(o*255),Math.round(a*255),s]},se=(e,t,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Qc=e=>{e=Kt.parse(e);let[t,n,r]=e;const s=e[3];t/=255,n/=255,r/=255;const i=Math.max(t,n,r),o=Math.min(t,n,r);let a,u,l=(i+o)/2;if(i===o)a=u=0;else{const d=i-o;u=l>.5?d/(2-i-o):d/(i+o),i===t?a=(n-r)/d+(n<r?6:0):i===n?a=(r-t)/d+2:a=(t-n)/d+4,a/=6}return a*=360,u*=100,l*=100,[Math.round(a),Math.round(u),Math.round(l),s]},ta=I("#000000"),ea=I("#ffffff"),Or=c.z.object({key:c.z.string(),color:Qt,position:c.z.number(),switched:c.z.boolean().optional()}),na=c.z.array(Or),ra=(e,t)=>{if(e.length===0)return tn;if(e=e.slice().sort((n,r)=>n.position-r.position),t<=e[0].position)return I(e[0].color);if(t>=e[e.length-1].position)return I(e[e.length-1].color);for(let n=0;n<e.length-1;n++){const r=e[n],s=e[n+1];if(t<r.position||t>s.position)continue;if(t===r.position)return I(r.color);if(t===s.position)return I(s.color);const i=(t-r.position)/(s.position-r.position),o=I(r.color),a=I(s.color),u=Math.round(mt(o)+i*(mt(a)-mt(o))),l=Math.round(pt(o)+i*(pt(a)-pt(o))),d=Math.round(bt(o)+i*(bt(a)-bt(o))),y=wt(o)+i*(wt(a)-wt(o));return I([u,l,d,y])}return I(e[e.length-1].color)},sa=c.z.object({key:c.z.string(),name:c.z.string(),color:Et}),ia=c.z.object({key:c.z.string(),name:c.z.string(),swatches:c.z.array(sa)}),oa=Object.freeze(Object.defineProperty({__proto__:null,BLACK:ta,WHITE:ea,ZERO:tn,aValue:wt,bValue:bt,colorZ:Et,construct:I,contrast:be,crudeZ:Qt,cssString:Lc,equals:pr,fromCSS:Xc,fromGradient:ra,fromHSLA:Kc,gValue:pt,gradientZ:na,grayness:Yc,hex:Zc,hsla:Wc,isColor:kc,isCrude:Pc,isDark:Gc,isLight:Hc,isZero:Fc,luminance:vt,paletteZ:ia,pickByContrast:Dc,rValue:mt,rgbCSS:_c,rgbString:wr,rgba1:qc,rgbaCSS:br,setAlpha:Vc,stopZ:Or},Symbol.toStringTag,{value:"Module"})),xr=c.z.int().min(0).max(255),Ir=255,Nr=0,ca={lower:Nr,upper:Ir+1},vr=c.z.object({name:c.z.string(),key:c.z.string()}),Mt=e=>c.z.object({subject:vr,resource:e,authority:xr}),aa=(...e)=>t=>t.filter(n=>{let r=!1;return n.to!=null&&(r=e.includes(n.to.resource)),n.from!=null&&!r&&(r=e.includes(n.from.resource)),r}),Mr=e=>c.z.object({from:Mt(e),to:c.z.null()}),Ar=e=>c.z.object({from:c.z.null(),to:Mt(e)}),ua=e=>c.z.union([Mr(e),Ar(e),c.z.object({from:Mt(e),to:Mt(e)})]),la=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Ir,AUTHORITY_BOUNDS:ca,ZERO_AUTHORITY:Nr,acquireZ:Ar,authorityZ:xr,filterTransfersByChannelKey:aa,releaseZ:Mr,stateZ:Mt,subjectZ:vr,transferZ:ua},Symbol.toStringTag,{value:"Module"})),fa=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 hn(e.toString());case"object":return e==null?"":hn(JSON.stringify(e))}},ha=/[",\n]/,hn=e=>ha.test(e)?`"${e.replace(/"/g,'""')}"`:e,da=Object.freeze(Object.defineProperty({__proto__:null,formatValue:fa},Symbol.toStringTag,{value:"Module"})),ga=(e,t)=>{let n=null;return t===0?e:(...s)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>e(...s),t)}},ya=(e,t)=>{let n=null;return t===0?e:(...s)=>{n===null&&(n=setTimeout(()=>{e(...s),n=null},t))}},ma=e=>{try{return structuredClone(e)}catch{return console.warn("Failed to deep copy object, falling back to JSON.parse(JSON.stringify)",e),console.trace(),JSON.parse(JSON.stringify(e))}},pa=(e,t,n="")=>{const r={},s=(i,o,a)=>{if(typeof i!=typeof o||i===null||o===null){r[a]=[i,o];return}if(typeof i=="object"&&typeof o=="object")if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length){r[a]=[i,o];return}for(let u=0;u<i.length;u++)s(i[u],o[u],`${a}[${u}]`)}else new Set([...Object.keys(i),...Object.keys(o)]).forEach(l=>{s(i[l],o[l],a!==""?`${a}.${l}`:l)});else i!==o&&(r[a]=[i,o])};return s(e,t,n),r},we=(e,t)=>{const n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r){const o=e,a=t;if(o.length!==a.length)return!1;for(let u=0;u<o.length;u++)if(!we(o[u],a[u]))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);const s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(const o of s){const a=e[o],u=t[o];if(typeof a=="object"&&typeof u=="object"){if(!we(a,u))return!1}else if(a!==u)return!1}return!0},Sr=(e,t)=>{if(typeof e!="object"||e==null)return e===t;const n=Object.keys(e),r=Object.keys(t);if(r.length>n.length)return!1;for(const s of r){const i=e[s],o=t[s];if(typeof i=="object"&&typeof o=="object"){if(!Sr(i,o))return!1}else if(i!==o)return!1}return!0},U=".",Er=(e,t,n=U)=>{const r=e.split(n);return r.map((i,o)=>{const a=t(i,o,r);return a==null?null:typeof a=="string"?a:a.join(n)}).filter(i=>i!=null).join(n)},ht=(e,t)=>{if(!Array.isArray(e))return e[t];const n=e[t];if(n!=null||e.length==0)return n;const r=e[0];if(typeof r=="object"&&"key"in r)return e.find(s=>s.key===t)},ba=(e,t)=>{const n=e.split(U);return n.forEach((r,s)=>{t=ht(t,r),t!=null&&typeof t=="object"&&"key"in t&&(n[s]=t.key)}),n.join(U)},wa=(e,t)=>{const n=e.split(U);return t<0?n[n.length+t]:n[t]},Oa=(e,t)=>{if(t.length===0)return!0;const n=e.split(U),r=t.split(U);if(r.length>n.length)return!1;for(let s=0;s<r.length;s++){const i=n[s],o=r[s];if(o!=="*"&&i!==o)return!1}return!0},it=e=>{const t=parseInt(e);return isNaN(t)||t<0||t.toString()!==e?null:t},Oe=(e,t)=>{for(let n=1;n<=t.length;n++){const r=t.slice(0,n).join(U);if(ht(e,r)!=null)return[r,n]}return null},en=((e,t,n={optional:!1})=>{const{optional:r,getter:s=ht}=n;if(t==="")return e;const i=t.split(U);if(i.length===1){const a=s(e,i[0]);if(a===void 0){if(r)return null;throw new Error(`Path ${t} does not exist. ${i[0]} is undefined`)}return a}const o=(a,u)=>{if(u>=i.length)return a;for(let l=i.length-u;l>=1;l--){const d=i.slice(u,u+l).join(U),y=s(a,d);if(y!==void 0){if(u+l===i.length)return y;if(y===null){if(r)return null;throw new Error(`Path ${t} does not exist. ${d} is null`)}return o(y,u+l)}}if(r)return null;throw new Error(`Path ${t} does not exist. ${i[u]} is undefined`)};return o(e,0)}),xa=(e,t)=>en(e,t,{optional:!0})!==null,xe=(e,...t)=>{if(t.length===0)return e;const n=t.shift();if(ct(e)&&ct(n))for(const r in n)try{ct(n[r])?(r in e||Object.assign(e,{[r]:{}}),xe(e[r],n[r])):Object.assign(e,{[r]:n[r]})}catch(s){throw s instanceof TypeError?new TypeError(`.${r}: ${s.message}`):s}return xe(e,...t)},Ia=(e,t,n)=>{const r=(s,i,o)=>{if(o.def?.type==="union")return o.def.options.reduce((a,u)=>r(a,i,u),s);if(o.def?.type==="intersection"){const a=r(s,i,o.def.left);return r(a,i,o.def.right)}for(const a in i){const u=i[a];let l=o?.shape;if(l!=null)for(;l!=null;){if(l[a]!=null){const d=l[a].safeParse(u);if(d.success){s[a]=d.data;break}}l=l.def?.shape}typeof u=="object"&&!Array.isArray(u)&&u!==null&&o&&o.shape&&o.shape[a]&&(s[a]||={},r(s[a],u,o.shape[a]))}return s};return r({...e},t,n)},Na=(e,t)=>{const n=t.split(U);let r=e,s=0;for(;s<n.length;){if(s===n.length-1){const o=n[s];if(Array.isArray(r)){const a=parseInt(o);if(!isNaN(a)&&a<r.length){r.splice(a,1);return}const u=r[0];if(typeof u=="object"&&"key"in u){const l=r.findIndex(d=>d.key===o);if(l!==-1){r.splice(l,1);return}}return}delete r[o];return}let i=!1;if(Array.isArray(r)&&r.length>0){const o=r[0];if(typeof o=="object"&&"key"in o)for(let a=n.length-s;a>=1;a--){const u=n.slice(s,s+a).join(U),l=r.find(d=>d.key===u);if(l!=null){if(s+a===n.length){const d=r.findIndex(y=>y.key===u);d!==-1&&r.splice(d,1);return}r=l,s+=a,i=!0;break}}}if(!i)for(let o=n.length-s;o>=1;o--){const a=n.slice(s,s+o).join(U);if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&a in r){if(s+o===n.length){delete r[a];return}r=r[a],s+=o,i=!0;break}}if(!i){const o=ht(r,n[s]);if(o==null)return;r=o,s++}}},va=(e,t,n)=>{const r=t.split(U);let s=e,i=0;for(;i<r.length-1;){const o=Oe(s,r.slice(i,r.length-1));let a;o!=null?[a,i]=[o[0],i+o[1]]:(a=r[i],i++);let u=ht(s,a);if(u==null){const l=r[i];let d=it(l);d==null&&l.startsWith("-")&&it(l.substring(1))!=null&&(d=0),u=d!=null?[]:{},s[a]=u}s=u}try{const o=r[r.length-1];if(Array.isArray(s)){let u=it(o);if(u==null){if(o.startsWith("-")){const l=it(o.substring(1));l!=null&&(u=s.length-l)}if(u==null){if(s.length===0){const d=it(o);if(d!=null){s[d]=n;return}}const l=s[0];if(typeof l=="object"&&"key"in l){const d=s.findIndex(y=>y.key===o);if(d!==-1){s[d]=n;return}}return}}s[u]=n;return}const a=Oe(s,[o]);if(a!=null){s[a[0]]=n;return}s[o]=n}catch(o){throw console.error("failed to set value",n,"at path",t,"on object",e),o}},Ma=Object.freeze(Object.defineProperty({__proto__:null,SEPARATOR:U,copy:ma,defaultGetter:ht,difference:pa,element:wa,equal:we,findBestKey:Oe,get:en,getIndex:it,has:xa,override:xe,overrideValidItems:Ia,partialEqual:Sr,pathsMatch:Oa,remove:Na,resolvePath:ba,set:va,transformPath:Er},Symbol.toStringTag,{value:"Module"})),Aa=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Sa=e=>Object.getOwnPropertySymbols(globalThis).includes(e),Ea=(e,t)=>{const n=Symbol.for(e);if(!Sa(n)){const r=t();Object.defineProperty(globalThis,n,{value:r})}return()=>globalThis[n]},Tr="sy_x_error",Ta=e=>t=>t!=null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"?t.type.startsWith(e):t instanceof Error?t.message.startsWith(e):typeof t!="string"?!1:t.startsWith(e),Tt=e=>class yt extends Error{static discriminator=Tr;discriminator=yt.discriminator;static TYPE=e;type=yt.TYPE;static matches=Ta(e);matches=yt.matches;constructor(n,r){super(n,r),this.name=yt.TYPE}static sub(n){return Tt(`${e}.${n}`)}},$r=e=>{if(e==null||typeof e!="object")return!1;const t=e;if(t.discriminator!==Tr)return!1;if(!("type"in t))throw new Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},ot="unknown",Ie="nil";class $a{providers=[];register(t){this.providers.push(t)}encode(t){if(t==null)return{type:Ie,data:""};if($r(t))for(const n of this.providers){const r=n.encode(t);if(r!=null)return r}if(t instanceof Error)return{type:ot,data:t.message};if(typeof t=="string")return{type:ot,data:t};try{return{type:ot,data:JSON.stringify(t)}}catch{return{type:ot,data:"unable to encode error information"}}}decode(t){if(t==null||t.type===Ie)return null;if(t.type===ot)return new Ne(t.data);for(const n of this.providers){const r=n.decode(t);if(r!=null)return r}return new Ne(t.data)}}const nn=Ea("synnax-error-registry",()=>new $a),za=({encode:e,decode:t})=>nn().register({encode:e,decode:t}),Ua=e=>nn().encode(e),ja=e=>e==null?null:nn().decode(e);class Ne extends Tt("unknown"){}const Ca=c.z.object({type:c.z.string(),data:c.z.string()});class Ba extends Tt("canceled"){}class Ra extends Tt("not_implemented"){}const Pa=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Ba,NONE:Ie,NotImplemented:Ra,UNKNOWN:ot,Unknown:Ne,createTyped:Tt,decode:ja,encode:Ua,isTyped:$r,payloadZ:Ca,register:za},Symbol.toStringTag,{value:"Module"}));class ka{store=new Map;async get(t){return this.store.get(t)??null}async set(t,n){this.store.set(t,n)}async delete(t){this.store.delete(t)}async length(){return this.store.size}async clear(){this.store.clear()}}class La{store=new Map;get(t){return this.store.get(t)??null}set(t,n){this.store.set(t,n)}delete(t){this.store.delete(t)}}const Za=c.z.object({key:c.z.string(),value:c.z.string()}),_a=Object.freeze(Object.defineProperty({__proto__:null,MockAsync:ka,MockSync:La,stringPairZ:Za},Symbol.toStringTag,{value:"Module"})),zr=c.uuid(),Ur=c.object({key:zr,name:c.string().min(1),color:Et}),qa=Object.freeze(Object.defineProperty({__proto__:null,keyZ:zr,labelZ:Ur},Symbol.toStringTag,{value:"Module"})),Fa=new RegExp("^(https?:\\/\\/)?((([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,})|localhost|(\\d{1,3}\\.){3}\\d{1,3})(\\:\\d+)?(\\/[-a-zA-Z0-9@:%._\\+~#=]*)*(\\?[;&a-zA-Z0-9%_.,~+=-]*)?(#[-a-zA-Z0-9_]*)?$"),Wa=e=>Fa.test(e),Va=Object.freeze(Object.defineProperty({__proto__:null,is:Wa},Symbol.toStringTag,{value:"Module"})),Ya=(e,t,n)=>{const r=e.get(t);return r===void 0?(e.set(t,n),n):r},Da=Object.freeze(Object.defineProperty({__proto__:null,getOrSetDefault:Ya},Symbol.toStringTag,{value:"Module"})),ve=c.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),Ga=(e,t)=>{const n=e.split("."),r=t.split("."),s=Math.max(n.length,r.length);for(let i=0;i<s;i++){const o=n[i],a=r[i];if(o===void 0)return W;if(a===void 0)return V;const u=/^\d+$/.test(o),l=/^\d+$/.test(a);if(u&&!l)return W;if(!u&&l)return V;if(u&&l){const d=parseInt(o),y=parseInt(a);if(d<y)return W;if(d>y)return V}else{if(o<a)return W;if(o>a)return V}}return st},$t=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;const r=ve.parse(e),s=ve.parse(t),[i,o]=r.split("-"),[a,u]=s.split("-"),[l,d,y]=i.split(".").map(Number),[m,A,E]=a.split(".").map(Number);if(n.checkMajor){if(l<m)return W;if(l>m)return V}if(n.checkMinor){if(d<A)return W;if(d>A)return V}if(n.checkPatch){if(y<E)return W;if(y>E)return V}return o===void 0&&u===void 0?st:o===void 0?V:u===void 0?W:Ga(o,u)}),Ha=(e,t,n={})=>Sn($t(e,t,n)),jr=(e,t,n={})=>An($t(e,t,n)),Ja=(e,t,n={})=>Mn($t(e,t,n)),Xa=({name:e,migrate:t})=>n=>{try{const r=t(n);return console.log(`${e} migrated: ${n.version} -> ${r.version}`),r}catch(r){throw console.log(`${e} failed to migrate from ${n.version}`),console.error(r),r}},Ka=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:s})=>{const i=Object.keys(t).sort($t).pop();if(i==null)return l=>{if(l.version??=r,l.version!==s.version)return console.log(`${e} version ${l.version} is newer than latest version of ${s.version}.
|
|
9
9
|
Returning default instead.
|
|
10
|
-
`),s;try{return n!=null?n.parse(l):l}catch(
|
|
10
|
+
`),s;try{return n!=null?n.parse(l):l}catch(d){return console.log(`${e} failed to parse default. Exiting with default`),console.error(d),s}};const o=Object.keys(t).length;let a=!1;const u=l=>{try{if(o===0||jr(l.version,i))return console.log(a?`${e} ${l.version} now up to date`:`${e} version ${l.version} is up to date with target version ${s.version}`),l;const d=l.version,y=t[d],m=y(l);return a=!0,u(m)}catch(d){return console.log(`${e} failed to migrate from ${l.version} to ${i}`),console.error(d),s}};return l=>{try{if(l.version==null)if(r!=null)console.log(`${e} version is null. Setting version to default of ${r}`),l.version=r;else return console.log(`${e} version is null and no default version set. Exiting with default`),s;return u(l)}catch(d){return console.log(`${e} failed to parse final result. Exiting with default`),console.error(d),s}}},Qa=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:$t,createMigration:Xa,migrator:Ka,semVerNewer:jr,semVerOlder:Ja,semVerZ:ve,versionsEqual:Ha},Symbol.toStringTag,{value:"Module"})),Cr=["standard","scientific","engineering"],tu=c.z.enum(Cr),eu=(e,t,n)=>{if(Number.isNaN(e))return"NaN";if(e===1/0)return"∞";if(e===-1/0)return"-∞";if(n==="standard")return e.toFixed(t);if(e===0)return t===0?"0ᴇ0":`0.${"0".repeat(t)}ᴇ0`;let r;return n==="scientific"?r=Math.floor(Math.log10(Math.abs(e))):r=Math.floor(Math.log10(Math.abs(e))/3)*3,`${(e/10**r).toFixed(t)}ᴇ${r}`},nu=Object.freeze(Object.defineProperty({__proto__:null,NOTATIONS:Cr,notationZ:tu,stringifyNumber:eu},Symbol.toStringTag,{value:"Module"}));class ru{handlers;transform;closer;constructor(t,n){this.transform=t,this.handlers=n??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let n=t;if(this.transform!=null){const[r,s]=this.transform(t);if(!s)return;n=r}this.handlers.forEach((r,s)=>s(n))}setCloser(t){this.closer=t}async close(){return await this.closer?.()}}class su{handlers;constructor(t){this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((n,r)=>r(t))}}const iu=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:su,Observer:ru},Symbol.toStringTag,{value:"Module"})),ou=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Br=c.z.union([c.z.string(),c.z.number()]),Rr=c.z.record(Br,c.z.unknown()),cu=()=>c.z.union([c.z.union([c.z.null(),c.z.undefined()]).transform(()=>({})),Rr]),rn=e=>Object.entries(e),au=(e,t)=>Object.fromEntries(rn(e).map(([n,r])=>[n,t(r,n)])),uu=e=>Object.fromEntries(rn(e).filter(([t,n])=>n!==void 0)),lu=(e,...t)=>{const n={...e};for(const r of t)delete n[r];return n},fu=Object.freeze(Object.defineProperty({__proto__:null,entries:rn,keyZ:Br,map:au,nullishToEmpty:cu,omit:lu,purgeUndefined:uu,unknownZ:Rr},Symbol.toStringTag,{value:"Module"})),Pr=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",hu=Pr(),kr=["macOS","Windows","Linux"],du=["macos","windows","linux"],gu={macos:"macOS",windows:"Windows",linux:"Linux"},yu=c.z.enum(kr).or(c.z.enum(du).transform(e=>gu[e])),mu=()=>{if(typeof window>"u")return;const e=window.navigator.userAgent.toLowerCase();if(e.includes("mac"))return"macOS";if(e.includes("win"))return"Windows";if(e.includes("linux"))return"Linux"};let Bt;const pu=((e={})=>{const{force:t,default:n}=e;return t??Bt??(Bt=mu(),Bt??n)}),bu=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:kr,RUNTIME:hu,detect:Pr,getOS:pu,osZ:yu},Symbol.toStringTag,{value:"Module"})),wu=()=>Promise.resolve(),Ou=()=>new Promise(e=>setTimeout(e,0)),xu=Object.freeze(Object.defineProperty({__proto__:null,flushMicrotasks:wu,flushTaskQueue:Ou},Symbol.toStringTag,{value:"Module"})),Iu=e=>Array.isArray(e)?[...e]:typeof e=="object"&&e!==null?{...e}:e,Nu=Object.freeze(Object.defineProperty({__proto__:null,copy:Iu},Symbol.toStringTag,{value:"Module"})),Lr=c.z.enum(["success","info","warning","error","loading","disabled"]),vu=e=>c.z.object({key:c.z.string(),name:c.z.string().default(""),variant:Lr,message:c.z.string(),description:c.z.string().optional(),time:h.z,labels:gn(Ur).optional(),details:e??c.z.unknown().optional()}),Mu=c.z.object({stack:c.z.string(),error:c.z.instanceof(Error)}),Au=(e,t)=>{if(!(e instanceof Error))throw e;return Zr({variant:"error",message:t??e.message,description:t!=null?e.message:void 0,details:{stack:e.stack??"",error:e}})},Zr=e=>({key:Ee(),time:h.now(),name:"",...e}),Su=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},Eu=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},Tu={includeTimestamp:!1,includeName:!0},$u=(e,t={})=>{const n={...Tu,...t},r=[];let s=e.variant.toUpperCase();if(n.includeName&&e.name.length>0&&(s+=` [${e.name}]`),s+=`: ${e.message}`,n.includeTimestamp&&(s+=` (${e.time.toString("dateTime","local")})`),r.push(s),e.description!=null){let i;try{const o=JSON.parse(e.description);i=`Description:
|
|
11
11
|
${JSON.stringify(o,null,2)}`}catch{i=`Description: ${e.description}`}r.push(i)}if("details"in e&&ct(e.details)){const i=e.details;"stack"in i&&r.push(`Stack Trace:
|
|
12
|
-
${String(i.stack)}`);const o=Object.fromEntries(Object.entries(i).filter(([
|
|
12
|
+
${String(i.stack)}`);const o=Object.fromEntries(Object.entries(i).filter(([a])=>a!=="stack"&&a!=="error"));Object.keys(o).length>0&&r.push(`Details:
|
|
13
13
|
${JSON.stringify(o,null,2)}`)}return r.join(`
|
|
14
14
|
|
|
15
|
-
`)},
|
|
15
|
+
`)},zu=Object.freeze(Object.defineProperty({__proto__:null,create:Zr,exceptionDetailsSchema:Mu,fromException:Au,keepVariants:Su,removeVariants:Eu,statusZ:vu,toString:$u,variantZ:Lr},Symbol.toStringTag,{value:"Module"})),Uu=(e,t)=>{if(!t.has(e))return e;let n=e,r=1,s=e;for(;t.has(s);){const i=s.match(ju);i?(n=s.slice(0,i.index).trim(),r=parseInt(i[1])+1):(n=s,r=1),s=`${n} (${r})`}return s},ju=/\((\d+)\)$/,Cu=(e,t="")=>{if(typeof e=="string")return e;const 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]}`},Bu=e=>{const t=e.split(" "),n=new Set,r=t.map(u=>u.charAt(0).toLowerCase()).join("");n.add(r.replace(/-/g,"_")),n.add(r.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const s=/\d+/g;e.match(s)&&t.forEach((u,l)=>{if(s.test(u)){const d=t.map((y,m)=>m!==l?y.charAt(0).toLowerCase():y).join("");n.add(d.replace(/-/g,"_")),n.add(d.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const o=t.map(u=>(u.length>3?u.substring(0,3):u).toLowerCase());return n.add(o.join("").replace(/-/g,"_")),n.add(o.join("_").replace(/-/g,"_")),Array.from(n).filter(u=>u.length>=2&&u.length<=12&&!/^\d/.test(u))},Ru=(e,t)=>e.startsWith(t)?e.slice(t.length):e,Pu=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Bu,deduplicateFileName:Uu,naturalLanguageJoin:Cu,trimPrefix:Ru},Symbol.toStringTag,{value:"Module"})),ku=new Error("request for lock canceled");var Lu=function(e,t,n,r){function s(i){return i instanceof n?i:new n(function(o){o(i)})}return new(n||(n=Promise))(function(i,o){function a(d){try{l(r.next(d))}catch(y){o(y)}}function u(d){try{l(r.throw(d))}catch(y){o(y)}}function l(d){d.done?i(d.value):s(d.value).then(a,u)}l((r=r.apply(e,t||[])).next())})};class Zu{constructor(t,n=ku){this._value=t,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(t=1,n=0){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return new Promise((r,s)=>{const i={resolve:r,reject:s,weight:t,priority:n},o=_r(this._queue,a=>n<=a.priority);o===-1&&t<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(t){return Lu(this,arguments,void 0,function*(n,r=1,s=0){const[i,o]=yield this.acquire(r,s);try{return yield n(i)}finally{o()}})}waitForUnlock(t=1,n=0){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);return this._couldLockImmediately(t,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[t-1]||(this._weightedWaiters[t-1]=[]),_u(this._weightedWaiters[t-1],{resolve:r,priority:n})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(t){this._value=t,this._dispatchQueue()}release(t=1){if(t<=0)throw new Error(`invalid weight ${t}: must be positive`);this._value+=t,this._dispatchQueue()}cancel(){this._queue.forEach(t=>t.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(t){const n=this._value;this._value-=t.weight,t.resolve([n,this._newReleaser(t.weight)])}_newReleaser(t){let n=!1;return()=>{n||(n=!0,this.release(t))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[t-1]=[])}else{const t=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const s=r.findIndex(i=>i.priority<=t);(s===-1?r:r.splice(0,s)).forEach((i=>i.resolve()))}}}_couldLockImmediately(t,n){return(this._queue.length===0||this._queue[0].priority<n)&&t<=this._value}}function _u(e,t){const n=_r(e,r=>t.priority<=r.priority);e.splice(n+1,0,t)}function _r(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var qu=function(e,t,n,r){function s(i){return i instanceof n?i:new n(function(o){o(i)})}return new(n||(n=Promise))(function(i,o){function a(d){try{l(r.next(d))}catch(y){o(y)}}function u(d){try{l(r.throw(d))}catch(y){o(y)}}function l(d){d.done?i(d.value):s(d.value).then(a,u)}l((r=r.apply(e,t||[])).next())})};class Fu{constructor(t){this._semaphore=new Zu(1,t)}acquire(){return qu(this,arguments,void 0,function*(t=0){const[,n]=yield this._semaphore.acquire(1,t);return n})}runExclusive(t,n=0){return this._semaphore.runExclusive(()=>t(),1,n)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(t=0){return this._semaphore.waitForUnlock(1,t)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class qr extends Fu{constructor(t){super(),Object.assign(this,t)}}const Wu=e=>new qr(e),Vu=Object.freeze(Object.defineProperty({__proto__:null,mutex:qr,newMutex:Wu},Symbol.toStringTag,{value:"Module"})),Yu=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),Du=async(e,t=200,n=20)=>{const r=Date.now();for(;Date.now()-r<t;)await e(),await new Promise(s=>setTimeout(s,n))},Gu=Object.freeze(Object.defineProperty({__proto__:null,expectAlways:Du,toString:Yu},Symbol.toStringTag,{value:"Module"})),Hu=(...e)=>e.map(Fr).join(""),Fr=e=>(e.endsWith("/")||(e+="/"),e.startsWith("/")&&(e=e.slice(1)),e),Ju=e=>e.endsWith("/")?e.slice(0,-1):e,Xu=(e,t="")=>e===null?"":`?${Object.entries(e).filter(([,n])=>n==null?!1:Array.isArray(n)?n.length>0:!0).map(([n,r])=>`${t}${n}=${r}`).join("&")}`;class Ot{protocol;host;port;path;constructor({host:t,port:n,protocol:r="",pathPrefix:s=""}){this.protocol=r,this.host=t,this.port=n,this.path=Fr(s)}replace(t){return new Ot({host:t.host??this.host,port:t.port??this.port,protocol:t.protocol??this.protocol,pathPrefix:t.pathPrefix??this.path})}child(t){return new Ot({...this,pathPrefix:Hu(this.path,t)})}toString(){return Ju(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Ot({host:"unknown",port:0})}class Me{sender;handlers;constructor(t){this.sender=t,this.handlers=new Map}handle({data:t}){const n=this.handlers.get(t.type)?.handler;n==null?console.warn(`No handler for ${t.type}`):n(t.payload)}route(t){const n=Ku(t,this.sender),r=new Wr(n);return this.handlers.set(t,r),r}}const Ku=(e,t)=>(n,r)=>t({type:e,payload:n},r);class Wr{_send;handler;constructor(t){this._send=t,this.handler=null}send(t,n=[]){this._send(t,n)}handle(t){this.handler=t}}const Qu=()=>{let e,t;const n=s=>{t.handle({data:s})},r=s=>{e.handle({data:s})};return e=new Me(n),t=new Me(r),[e,t]},tl=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),el=c.z.int().min(0).max(jn),nl=e=>c.array(e).or(e.transform(t=>[t])),rl=e=>e._zod.def.output,Vr=e=>Er(e,(t,n,r)=>{const s=n===r.length-1,i=!isNaN(parseInt(t)),o=!isNaN(parseInt(r[n+1]));return i&&(t="element"),s||o?t:[t,"shape"]}),dn=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},sl=((e,t,n)=>t===""?e:en(dn(e,"shape"),Vr(t),{...n,getter:dn})),il=Object.freeze(Object.defineProperty({__proto__:null,functionOutput:rl,getFieldSchema:sl,getFieldSchemaPath:Vr,nullToUndefined:tl,toArray:nl,uint12:el},Symbol.toStringTag,{value:"Module"}));exports.DataType=f;exports.Density=b;exports.MultiSeries=Ic;exports.Rate=T;exports.RoutedWorker=Me;exports.Series=P;exports.Size=p;exports.TimeRange=M;exports.TimeSpan=g;exports.TimeStamp=h;exports.TypedWorker=Wr;exports.URL=Ot;exports.array=Hr;exports.binary=us;exports.bounds=li;exports.box=Eo;exports.breaker=Sc;exports.buildQueryString=Xu;exports.caseconv=ss;exports.change=Tc;exports.clamp=or;exports.color=oa;exports.compare=xs;exports.control=la;exports.convertDataType=ur;exports.createMockWorkers=Qu;exports.csv=da;exports.debounce=ga;exports.deep=Ma;exports.destructor=Aa;exports.dimensions=Lo;exports.direction=Ni;exports.errors=Pa;exports.id=Ms;exports.instance=As;exports.isCrudeSeries=dr;exports.isTelemValue=He;exports.kv=_a;exports.label=qa;exports.link=Va;exports.location=ki;exports.map=Da;exports.math=yi;exports.migrate=Qa;exports.narrow=is;exports.notation=nu;exports.numericTimeRangeZ=rc;exports.observe=iu;exports.optional=ou;exports.primitive=fs;exports.record=fu;exports.runtime=bu;exports.scale=Go;exports.scheduler=xu;exports.shallow=Nu;exports.sleep=vc;exports.spatial=Ho;exports.status=zu;exports.sticky=tc;exports.strings=Pu;exports.sync=Vu;exports.testutil=Gu;exports.throttle=ya;exports.typedArrayZ=sc;exports.unique=ds;exports.uuid=mc;exports.xy=Qi;exports.zod=il;
|