@synnaxlabs/x 0.49.0 → 0.49.2

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @synnaxlabs/x@0.49.0 build /home/runner/work/synnax/synnax/x/ts
2
+ > @synnaxlabs/x@0.49.2 build /home/runner/work/synnax/synnax/x/ts
3
3
  > tsc --noEmit && vite build
4
4
 
5
5
   Synnax - Production mode
@@ -10,8 +10,8 @@ rendering chunks...
10
10
 
11
11
  [vite:dts] Start generate declaration files...
12
12
  computing gzip size...
13
- dist/x.js 182.98 kB │ gzip: 45.19 kB
14
- [vite:dts] Declaration files built in 4247ms.
13
+ dist/x.js 183.33 kB │ gzip: 45.28 kB
14
+ [vite:dts] Declaration files built in 4252ms.
15
15
 
16
- dist/x.cjs 102.67 kB │ gzip: 32.07 kB
17
- ✓ built in 4.84s
16
+ dist/x.cjs 102.91 kB │ gzip: 32.14 kB
17
+ ✓ built in 4.87s
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Escapes a CSV field by wrapping it in double quotes if it contains a comma, double
3
- * quote, or newline. Also escapes any internal double quotes by doubling them. For
4
- * example, the field foo"bar,baz becomes "foo""bar,baz"
2
+ * formatValue correctly formats the given value into a string that is safe to use as a
3
+ * field in a CSV file.
5
4
  *
6
- * @param field - The string field to potentially escape for CSV output.
7
- * @returns The escaped CSV-safe field.
5
+ * @param value - The value to format.
6
+ * @returns The string to use as a field in a CSV file.
8
7
  */
9
- export declare const maybeEscapeField: (field: string) => string;
10
- export type RecordDelimiter = "\r\n" | "\n";
8
+ export declare const formatValue: (value: unknown) => string;
11
9
  //# sourceMappingURL=csv.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/csv/csv.ts"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAIhD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/csv/csv.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAiB5C,CAAC"}
package/dist/x.cjs CHANGED
@@ -1,12 +1,12 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod"),hn=e=>c.union([c.union([c.null(),c.undefined()]).transform(()=>[]),e.array()]),Gr=e=>Array.isArray(e)?e:e==null?[]:[e],dn=(e,t)=>{if(Array.isArray(t))return t.reduce((s,i)=>dn(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},Hr=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(n=>!t.includes(n)):e.filter(n=>n!=t)}),gn=(e,t)=>{if(Array.isArray(t))return t.reduce((s,i)=>gn(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},Dr=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(n=>!t.includes(n.key)):e.filter(n=>n.key!==t)}),Jr=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:hn,remove:Hr,removeKeyed:Dr,toArray:Gr,upsert:dn,upsertKeyed:gn},Symbol.toStringTag,{value:"Module"})),Xr=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)},Wt=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=ts(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)?sn(a)||(a=t(a,r)):r.recursiveInArray&&rn(a)&&(a=[...a].map(l=>{let h=l;return te(l)?sn(h)||(h=t(l,r)):rn(l)&&(h=t({key:l},r).key),h}))),s[u]=a}),s)};return t},Ae=Wt(Xr),Kr=e=>e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}_${r.toLowerCase()}`),yn=Wt(Kr),mn=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),Qr=[Number,String,Uint8Array],ie={recursive:!0,recursiveInArray:!0},ts=(e=ie)=>(e.recursive==null?e=ie:e.recursiveInArray??=!1,e),rn=e=>e!=null&&Array.isArray(e),te=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),sn=e=>Qr.some(t=>e instanceof t),es=e=>e.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`).toLowerCase(),ns=Wt(es),rs=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},ss=Wt(rs),is=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:yn,capitalize:mn,snakeToCamel:Ae,toKebab:ns,toProperNoun:ss},Symbol.toStringTag,{value:"Module"})),mt=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),os=Object.freeze(Object.defineProperty({__proto__:null,isObject:mt},Symbol.toStringTag,{value:"Module"}));class pn{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=yn(t);return JSON.stringify(n,(r,s)=>ArrayBuffer.isView(s)?Array.from(s):typeof s=="bigint"?s.toString():s)}}class bn{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||!mt(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(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod"),dn=e=>c.union([c.union([c.null(),c.undefined()]).transform(()=>[]),e.array()]),Hr=e=>Array.isArray(e)?e:e==null?[]:[e],gn=(e,t)=>{if(Array.isArray(t))return t.reduce((s,i)=>gn(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)}),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.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},Jr=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(n=>!t.includes(n.key)):e.filter(n=>n.key!==t)}),Xr=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:dn,remove:Dr,removeKeyed:Jr,toArray:Hr,upsert:gn,upsertKeyed:yn},Symbol.toStringTag,{value:"Module"})),Kr=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)},Wt=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=es(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)?sn(a)||(a=t(a,r)):r.recursiveInArray&&rn(a)&&(a=[...a].map(l=>{let h=l;return te(l)?sn(h)||(h=t(l,r)):rn(l)&&(h=t({key:l},r).key),h}))),s[u]=a}),s)};return t},Ae=Wt(Kr),Qr=e=>e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}_${r.toLowerCase()}`),mn=Wt(Qr),pn=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),ts=[Number,String,Uint8Array],ie={recursive:!0,recursiveInArray:!0},es=(e=ie)=>(e.recursive==null?e=ie:e.recursiveInArray??=!1,e),rn=e=>e!=null&&Array.isArray(e),te=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),sn=e=>ts.some(t=>e instanceof t),ns=e=>e.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`).toLowerCase(),rs=Wt(ns),ss=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},is=Wt(ss),os=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:mn,capitalize:pn,snakeToCamel:Ae,toKebab:rs,toProperNoun:is},Symbol.toStringTag,{value:"Module"})),mt=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),cs=Object.freeze(Object.defineProperty({__proto__:null,isObject:mt},Symbol.toStringTag,{value:"Module"}));class bn{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=mn(t);return JSON.stringify(n,(r,s)=>ArrayBuffer.isView(s)?Array.from(s):typeof s=="bigint"?s.toString():s)}}class wn{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||!mt(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(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,h)=>{const y=this.parseValue(u[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 wn{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 ct=new pn,cs=new bn,as=new wn,us=[ct],ls=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:bn,CSV_CODEC:cs,ENCODERS:us,JSONCodec:pn,JSON_CODEC:ct,TEXT_CODEC:as,TextCodec:wn},Symbol.toStringTag,{value:"Module"})),j=e=>e!=null&&typeof e=="object"&&"value"in e;class nt{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,On=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}},fs=e=>!On(e),hs=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:nt,isCrudeValueExtension:j,isNonZero:fs,isStringer:Se,isZero:On},Symbol.toStringTag,{value:"Module"})),oe=e=>[...new Set(e)],ds=(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())},gs=Object.freeze(Object.defineProperty({__proto__:null,by:ds,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?In(r):r},ys=(e,t,n)=>{const r=At(t[e],n);return(s,i)=>r(s[e],i[e])},ms=(e,t)=>e.length!==t.length?e.length-t.length:e.every((n,r)=>n===t[r])?0:-1,xn=(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},ps=(e,t)=>{const n=oe(e),r=oe(t);return xn(n,r)},bs=(e,t)=>e===t?0:e==="first"&&t==="last"?1:-1,In=e=>(t,n)=>e(n,t),rt=0,W=-1,V=1,Nn=e=>e<rt,vn=e=>e>rt,ws=e=>e>=rt,Mn=e=>e===rt,Os=(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},An=(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},xs=(e,t,n)=>{const r=An(e,t,n);e.splice(r,0,t)},Is=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:rt,GREATER_THAN:V,LESS_THAN:W,insert:xs,isEqualTo:Mn,isGreaterThan:vn,isGreaterThanEqual:ws,isLessThan:Nn,newF:At,newFieldF:ys,order:bs,primitiveArrays:ms,reverseF:In,search:An,stringsWithNumbers:Os,uniqueUnorderedPrimitiveArrays:ps,unorderedPrimitiveArrays:xn},Symbol.toStringTag,{value:"Module"}));let Sn=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const En="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ns=`0123456789${En}`,Tn=11,vs=Sn(En,1),Ms=Sn(Ns,Tn-1),Ee=()=>`${vs()}${Ms()}`,As=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:Tn,create:Ee},Symbol.toStringTag,{value:"Module"})),$n=(e,t)=>n=>n instanceof t||typeof n=="object"&&n!==null&&"discriminator"in n&&n.discriminator===e,Ss=Object.freeze(Object.defineProperty({__proto__:null,createMatcher:$n},Symbol.toStringTag,{value:"Module"})),Es=2**8-1,zn=2**12-1,Ts=2**16-1,$s=2**32-1,zs=2n**64n-1n,Us=2**64-1,js=-128,Cs=2**7-1,Bs=-32768,Rs=2**15-1,Ps=-2147483648,Ls=2**31-1,ks=-(2n**63n),kt=2n**63n-1n,Zs=-9223372036854776e3,Un=2**63-1,ut=e=>(t,n)=>{if(typeof t=="bigint"){if(Zt(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),_s=(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&&Zt(t)?e===BigInt(t):r&&Zt(e)?t===BigInt(e):e===t},qs=e=>{const t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t},jn=ut((e,t)=>e<=t?e:t),Zt=e=>typeof e=="bigint"?!0:Number.isInteger(e),Fs=ut((e,t)=>e>=t?e:t),Cn=e=>typeof e=="bigint"?e<0n?-e:e:e<0?-e:e,R=ut((e,t)=>e*t),St=ut((e,t)=>e/t),Bn=c.z.tuple([c.z.number(),c.z.number()]),Te=c.z.object({width:c.z.number(),height:c.z.number()}),Ws=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),Rn=["start","center","end"],at=c.z.object({x:c.z.number(),y:c.z.number()}),Pn=c.z.object({clientX:c.z.number(),clientY:c.z.number()}),Vt=["x","y"],$e=c.z.enum(Vt),ze=["top","right","bottom","left"],Vs=c.z.enum(ze),Yt=["left","right"],Ue=c.z.enum(Yt),Gt=["top","bottom"],je=c.z.enum(Gt),Ce=["center"],ae=c.z.enum(Ce),Ys=[...ze,...Ce],Be=c.z.enum(Ys),Gs=c.z.enum(Rn),Ln=["first","last"],Hs=c.z.enum(Ln),Ds=c.z.object({lower:c.z.number(),upper:c.z.number()}),Js=c.z.enum([...$e.options,...Be.options]),Xs=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?kn(r):r},Ks=Object.freeze({lower:0,upper:0}),Qs=Object.freeze({lower:-1/0,upper:1/0}),ti=Object.freeze({lower:0,upper:1}),ei=Object.freeze({lower:-1,upper:1}),ni=(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},kn=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},L=(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},ri=(e,t)=>{const n=w(e),r=w(t);return n.lower===r.lower?!0:r.upper===n.lower||r.lower===n.upper?!1:L(n,r.upper)||L(n,r.lower)||L(r,n.upper)||L(r,n.lower)},lt=e=>{const t=w(e);return t.upper-t.lower},si=e=>{const t=w(e);return typeof t.lower=="bigint"?t.lower===0n&&t.upper===0n:t.lower===0&&t.upper===0},ii=e=>{const t=lt(e);return typeof t=="number"?t===0:t===0n},oi=e=>{const t=w(e);return typeof t.lower=="bigint"?!0:Number.isFinite(t.lower)&&Number.isFinite(t.upper)},ci=e=>{const t=w(e);return(t.upper+t.lower)/2},Zn=e=>({lower:Math.min(...e.map(t=>w(t).lower)),upper:Math.max(...e.map(t=>w(t).upper))}),ai=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=>L(i,t)||t<i.lower);if(r===-1)return{index:e.length,position:0};const s=n[r];return L(s,t)?{index:r,position:Number(t-s.lower)}:{index:r,position:0}},ee={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},li=(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}},_n=(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 h=jn(Cn(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 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},qn=(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},fi=Object.freeze(Object.defineProperty({__proto__:null,CLIP:ei,DECIMAL:ti,INFINITE:Qs,ZERO:Ks,bounds:Ds,buildInsertionPlan:li,clamp:ue,construct:w,contains:L,distance:qn,equals:ni,findInsertPosition:le,isFinite:oi,isZero:si,linspace:ui,makeValid:kn,max:Zn,mean:ci,min:ai,overlapsWith:ri,span:lt,spanIsZero:ii,traverse:_n},Symbol.toStringTag,{value:"Module"})),fe=2,he=3,Fn=2,hi=(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))+Fn;const s=10**r;return Math.round(e*s)/s},di=5,gi=1e-10,yi=(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>gi}if(r){let u;s>=1e3?u=fe:s>=1?u=he:u=Math.ceil(-Math.log10(s))+Fn;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**(di-i-1);return Math.round(e*a)/a},mi=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Rs,MAX_INT32:Ls,MAX_INT64:kt,MAX_INT64_NUMBER:Un,MAX_INT8:Cs,MAX_UINT12:zn,MAX_UINT16:Ts,MAX_UINT32:$s,MAX_UINT64:zs,MAX_UINT64_NUMBER:Us,MAX_UINT8:Es,MIN_INT16:Bs,MIN_INT32:Ps,MIN_INT64:ks,MIN_INT64_NUMBER:Zs,MIN_INT8:js,abs:Cn,add:Y,closeTo:_s,div:St,equal:ce,isInteger:Zt,max:Fs,min:jn,mult:R,roundBySpan:hi,roundToNearestMagnitude:qs,smartRound:yi,sub:_},Symbol.toStringTag,{value:"Module"})),Wn=Js,Z=e=>Vt.includes(e)?e:Gt.includes(e)?"y":"x",pi=e=>Z(e)==="x"?"y":"x",bi=e=>Z(e)==="x"?"width":"height",wi=e=>Z(e)==="x"?"left":"top",Oi=e=>Wn.safeParse(e).success,xi=e=>Z(e)==="x"?"signedWidth":"signedHeight",Ii=e=>e==="center"?!1:Z(e)==="x",Ni=e=>Z(e)==="y",vi=Object.freeze(Object.defineProperty({__proto__:null,DIRECTIONS:Vt,construct:Z,crude:Wn,dimension:bi,direction:$e,isDirection:Oi,isX:Ii,isY:Ni,location:wi,signedDimension:xi,swap:pi},Symbol.toStringTag,{value:"Module"})),Mi=Ue,Ai=je,Si=ae,Ei={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},Ti={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},$i=Xs,tt=e=>e instanceof String||!Vt.includes(e)?e:e==="x"?"left":"top",zi=e=>Ei[tt(e)],Ui=(e,t)=>Ti[e][t],It=e=>{const t=tt(e);return t==="top"||t==="bottom"?"y":"x"},ji=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"}),Le=Object.freeze({x:"right",y:"bottom"}),ke=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"}),Ci=Object.freeze([Fe,qe,Ze,_e,ft,Pe,Ht,Le,ke]),We=(e,t)=>e.x===t.x&&e.y===t.y,Bi=(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},Vn=e=>[e.x,e.y],Bt=e=>It(tt(e))==="x",Ri=e=>It(tt(e))==="y",Pi=e=>`${e.x}${mn(e.y)}`,Li=(e,t)=>{let n,r;if(typeof e=="object"&&"x"in e?(n=e.x,r=e.y):(n=tt(e),r=tt(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={...ke};return n==="center"?Bt(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:r==="center"?Bt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:Bt(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:Le,CENTER:ke,CENTER_LEFT:Fe,CENTER_LOCATIONS:Ce,CENTER_RIGHT:qe,OUTER_LOCATIONS:ze,TOP_CENTER:Ze,TOP_LEFT:ft,TOP_RIGHT:Pe,XY_LOCATIONS:Ci,X_LOCATIONS:Yt,Y_LOCATIONS:Gt,center:Si,construct:tt,constructXY:Li,corner:Re,crude:$i,direction:It,isX:Bt,isY:Ri,location:Be,outer:Vs,rotate:Ui,swap:zi,x:Mi,xy:ji,xyCouple:Vn,xyEquals:We,xyMatches:Bi,xyToString:Pi,y:Ai},Symbol.toStringTag,{value:"Module"})),de=c.z.union([c.z.number(),at,Bn,Te,Ws,Pn]),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}),Yn=Object.freeze({x:1,y:1}),Zi=Object.freeze({x:1/0,y:1/0}),_i=Object.freeze({x:NaN,y:NaN}),_t=(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},qi=e=>_t(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}},Gn=(e,t)=>{const n=x(e);return{x:n.x+t,y:n.y}},Hn=(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"?Gn(e,n):Hn(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)},Fi=(e,t,n)=>{const r=x(e);return Z(t)==="x"?{x:n,y:r.y}:{x:r.x,y:n}},Wi=(e,t)=>{const n=x(e),r=x(t);return Math.sqrt((n.x-r.x)**2+(n.y-r.y)**2)},Vi=(e,t)=>{const n=x(e),r=x(t);return{x:r.x-n.x,y:r.y-n.y}},Yi=e=>{const t=x(e);return Number.isNaN(t.x)||Number.isNaN(t.y)},Gi=e=>{const t=x(e);return Number.isFinite(t.x)&&Number.isFinite(t.y)},Hi=e=>{const t=x(e);return[t.x,t.y]},Di=e=>{const t=x(e);return{left:t.x,top:t.y}},qt=(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}},Dn=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}},Jn=(...e)=>{const t=e.reduce((n,r)=>Nt(n,r),q);return Ve(t,1/e.length)},Ji=(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],h=dt(l,s);o=gt(h),a=o,u=t}else if(r===e.length-1){const l=e[r-1],h=dt(s,l);i=gt(h),a=i,u=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 M=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(M/2);E===0?u=t:u=t/E,a=Dn(Jn(i,o))}n.push(Ve(a,u))}return n},Xi=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)}},Ki=e=>{const t=x(e);return{x:1/t.x,y:1/t.y}},Qi=(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}},to=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Zi,NAN:_i,ONE:Yn,ZERO:q,average:Jn,calculateMiters:Ji,clientXY:Pn,construct:x,couple:Hi,crudeZ:de,css:Di,distance:Wi,equals:_t,isFinite:Gi,isNan:Yi,isZero:qi,normal:gt,normalize:Dn,reciprocal:Ki,rotate:Qi,round:ge,scale:Ve,set:Fi,sub:dt,swap:Xi,translate:Nt,translateX:Gn,translateY:Hn,translation:Vi,truncate:qt,xy:at},Symbol.toStringTag,{value:"Module"})),$t=c.z.union([c.z.number(),c.z.string()]),eo=c.z.object({top:$t,left:$t,width:$t,height:$t}),no=c.z.object({left:c.z.number(),top:c.z.number(),right:c.z.number(),bottom:c.z.number()}),ro=c.z.object({one:at,two:at,root:Re}),Xn={one:q,two:q,root:ft},so={one:q,two:Yn,root:Ht},Kn=(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))},io=(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)},oo=(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(D(r),D(t))&&s(K(t),K(r))&&s(J(r),J(t))&&s(Q(t),Q(r)):s(D(r),t.x)&&s(t.x,K(r))&&s(J(r),t.y)&&s(t.y,Q(r))},co=(e,t)=>_t(e.one,t.one)&&_t(e.two,t.two)&&We(e.root,t.root),Qn=e=>({width:$(e),height:z(e)}),ao=e=>({signedWidth:Dt(e),signedHeight:Jt(e)}),uo=e=>({top:J(e),left:D(e),width:$(e),height:z(e)}),Ye=(e,t,n=!1)=>{const r=Z(t)==="y"?Jt(e):Dt(e);return n?r:Math.abs(r)},G=(e,t)=>{const n=N(e);return{x:t.x==="center"?ye(n).x:et(n,t.x),y:t.y==="center"?ye(n).y:et(n,t.y)}},et=(e,t)=>{const n=N(e),r=Vn(n.root).includes(t)?Math.min:Math.max;return Yt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},lo=e=>nr(e)===0,$=e=>Ye(e,"x"),z=e=>Ye(e,"y"),Dt=e=>{const t=N(e);return t.two.x-t.one.x},Jt=e=>{const t=N(e);return t.two.y-t.one.y},tr=e=>G(e,ft),fo=e=>G(e,Ze),ho=e=>G(e,Pe),go=e=>G(e,Ht),yo=e=>G(e,_e),mo=e=>G(e,Le),po=e=>G(e,Fe),bo=e=>G(e,qe),K=e=>et(e,"right"),Q=e=>et(e,"bottom"),D=e=>et(e,"left"),J=e=>et(e,"top"),ye=e=>Nt(tr(e),{x:Dt(e)/2,y:Jt(e)/2}),Ge=e=>{const t=N(e);return t.root.x==="left"?D(t):K(t)},He=e=>{const t=N(e);return t.root.y==="top"?J(t):Q(t)},wo=e=>({x:Ge(e),y:He(e)}),Rt=e=>{const t=N(e);return{lower:t.one.x,upper:t.two.x}},Pt=e=>{const t=N(e);return{lower:t.one.y,upper:t.two.y}},Oo=(e,t)=>Kn(e,t),xo=(e,t)=>{const n=N(e),r=Yt.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]},Io=(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},Qn(n))},er=e=>typeof e!="object"||e==null?!1:"one"in e&&"two"in e&&"root"in e,No=e=>$(e)/z(e),vo=(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)},Mo=(e,t)=>{const n=Math.max(D(e),D(t)),r=Math.max(J(e),J(t)),s=Math.min(K(e),K(t)),i=Math.min(Q(e),Q(t));return n>s||r>i?Xn:N({x:n,y:r},{x:s,y:i},void 0,void 0,e.root)},nr=e=>$(e)*z(e),Ao=(e,t)=>{const n=N(e);return N(qt(n.one,t),qt(n.two,t),void 0,void 0,n.root)},So=(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)},Eo=e=>{const t=N(e);return N(ge(t.one),ge(t.two),void 0,void 0,t.root)},To=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:so,ZERO:Xn,area:nr,areaIsZero:lo,aspect:No,bottom:Q,bottomCenter:yo,bottomLeft:go,bottomRight:mo,box:ro,center:ye,centerLeft:po,centerRight:bo,construct:N,constructWithAlternateRoot:So,contains:oo,copy:Kn,css:uo,cssBox:eo,dim:Ye,dims:Qn,domRect:no,edgePoints:xo,equals:co,height:z,intersection:Mo,isBox:er,left:D,loc:et,positionInCenter:Io,reRoot:Oo,resize:io,right:K,root:wo,round:Eo,signedDims:ao,signedHeight:Jt,signedWidth:Dt,top:J,topCenter:fo,topLeft:tr,topRight:ho,translate:vo,truncate:Ao,width:$,x:Ge,xBounds:Rt,xyLoc:G,y:He,yBounds:Pt},Symbol.toStringTag,{value:"Module"})),rr=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),$o=c.z.union([Te,rr,at,Bn]),zo={width:0,height:0},Uo={width:1,height:1},k=(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},jo=(e,t)=>{if(t==null)return!1;const n=k(e),r=k(t);return n.width===r.width&&n.height===r.height},Co=e=>{const t=k(e);return{width:t.height,height:t.width}},Bo=e=>{const t=k(e);return`0 0 ${t.width} ${t.height}`},Ro=e=>{const t=k(e);return[t.width,t.height]},Po=e=>({width:Math.max(...e.map(t=>k(t).width)),height:Math.max(...e.map(t=>k(t).height))}),Lo=e=>({width:Math.min(...e.map(t=>k(t).width)),height:Math.min(...e.map(t=>k(t).height))}),ko=(e,t)=>{const n=k(e);return{width:n.width*t,height:n.height*t}},Zo=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:Uo,ZERO:zo,construct:k,couple:Ro,crude:$o,dimensions:Te,equals:jo,max:Po,min:Lo,scale:ko,signed:rr,svgViewBox:Bo,swap:Co},Symbol.toStringTag,{value:"Module"})),sr=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e,_o=c.z.object({offset:de,scale:de}),qo=c.z.object({offset:c.z.number(),scale:c.z.number()}),Fo=e=>(t,n,r,s)=>n==="dimension"?[t,r]:[t,s?r-e:r+e],Wo=e=>(t,n,r,s)=>[t,s?r/e:r*e],Vo=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 h=(r-s)*(l/u)+o;return[e,h]},Yo=e=>(t,n,r)=>[e,r],Go=()=>(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)]},Ho=e=>(t,n,r)=>{const{lower:s,upper:i}=e;return r=sr(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=Fo(t);return r.type="translate",n.ops.push(r),n}magnify(t){const n=this.new(),r=Wo(t);return r.type="magnify",n.ops.push(r),n}scale(t,n){const r=w(t,n),s=this.new(),i=Vo(r);return i.type="scale",s.ops.push(i),s}clamp(t,n){const r=w(t,n),s=this.new(),i=Ho(r);return i.type="clamp",s.ops.push(i),s}reBound(t,n){const r=w(t,n),s=this.new(),i=Yo(r);return i.type="re-bound",s.ops.push(i),s}invert(){const t=Go();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(er(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(Rt(t)),n.y=n.y.scale(Pt(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(Rt(t)),n.y=this.y.reBound(Pt(t)),n}clamp(t){const n=this.copy();return n.x=this.x.clamp(Rt(t)),n.y=this.y.clamp(Pt(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 Do=Object.freeze(Object.defineProperty({__proto__:null,Scale:F,XY:B,crudeXYTransform:_o,transform:qo},Symbol.toStringTag,{value:"Module"})),Jo=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:Rn,ORDERS:Ln,alignment:Gs,order:Hs},Symbol.toStringTag,{value:"Module"})),ir=at.extend({root:Re,units:c.object({x:c.enum(["px","decimal"]),y:c.enum(["px","decimal"])})}),Xo=ir.partial({root:!0,units:!0}),Ko=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},Qo=({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},tc=({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,...qt(i,3)}},ec=Object.freeze(Object.defineProperty({__proto__:null,calculate:tc,completeXY:ir,toCSS:Ko,toDecimal:Qo,xy:Xo},Symbol.toStringTag,{value:"Module"})),nc=c.z.enum(["static","dynamic"]),on=365,zt=30,rc=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)])]),or=(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 nt{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===Un?t=kt: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",a="00";i!=null&&([o,a]=i.split("."));let u=d.hours(parseInt(r??"00")).add(d.minutes(parseInt(s??"00"))).add(d.seconds(parseInt(o??"00"))).add(d.milliseconds(parseInt(a??"00")));return n==="local"&&(u=u.add(d.utcOffset)),u.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 a=n==="local"?new Date(i.replace("T"," ")):new Date(`${i}Z`),u=BigInt(a.getTime())*d.MILLISECOND.valueOf(),l=BigInt(o)*d.MILLISECOND.valueOf();return u+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 A(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 or(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(kt);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)),rc.transform(t=>new d(t))]);static sort(t,n){return Number(t.valueOf()-n.valueOf())}}class g extends nt{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 or(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,h=r.sub(n),y=s.sub(r),m=i.sub(s),M=o.sub(i),E=a.sub(o),C=u.sub(a);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 `),M.isZero||(O+=`${M.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/on),l=Math.floor(s/zt),h=Math.floor(s/7),y=Math.floor(s),m=Math.floor(i),M=Math.floor(o),E=Math.floor(a),C=r?"-":"";if(u>=1){let O=`${u}y`;if(u<2){const v=Math.floor(s%on/zt);v>0&&(O+=` ${v}mo`)}return C+O}if(h>=1&&s<zt&&s%7===0){let O=`${h}w`;const v=Math.floor(s%7),X=Math.floor(i-h*7*24);return h<2&&(v>0?O+=` ${v}d`:X>0&&X<24&&(O+=` ${X}h`)),C+O}if(l>=1){let O=`${l}mo`;if(l<3){const v=Math.floor(s%zt);v>0&&(O+=` ${v}d`)}return C+O}if(h>=1){let O=`${h}w`;const v=Math.floor(s%7),X=Math.floor(i-h*7*24);return h<2&&(v>0?O+=` ${v}d`:X>0&&X<24&&(O+=` ${X}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(M>=1){let O=`${M}m`;if(M<5){const v=Math.floor(a-M*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(kt);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 nt{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 nt{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 A{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 A(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 A?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const n=new A(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 A(d.min(...t.map(n=>n.start)),d.max(...t.map(n=>n.end)))}static MAX=new A(d.MIN,d.MAX);static ZERO=new A(d.ZERO,d.ZERO);static z=c.z.union([c.z.object({start:d.z,end:d.z}).transform(t=>new A(t.start,t.end)),c.z.instanceof(A)]);static sort(t,n){return d.sort(t.start,n.start)||d.sort(t.end,n.end)}static simplify(t){return t.map(n=>n.makeValid()).sort((n,r)=>A.sort(n,r)).reduce((n,r)=>{if(r.span.isZero)return n;if(n.length===0)return n.push(r),n;const s=n[n.length-1];return s.overlapsWith(r)||s.end.equals(r.start)?s.end=d.max(s.end,r.end):n.push(r),n},[])}}class f extends nt{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 nt{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),h=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 `),(!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 sc=c.z.object({start:c.z.number(),end:c.z.number()}),ic=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},cr=(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),oc="00000000-0000-0000-0000-000000000000",cc=/^(?:[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 ac(e){return typeof e=="string"&&cc.test(e)}const S=[];for(let e=0;e<256;++e)S.push((e+256).toString(16).slice(1));function ar(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=ar(e,t);if(!ac(n))throw TypeError("Stringified UUID is invalid");return n}let ne;const lc=new Uint8Array(16);function fc(){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(lc)}const hc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cn={randomUUID:hc};function dc(e,t,n){e=e||{};const r=e.random??e.rng?.()??fc();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,ar(r)}function gc(e,t,n){return cn.randomUUID&&!e?cn.randomUUID():dc(e)}const yc=()=>gc(),Je=(e,t)=>uc(e,t),mc=oc,pc=Object.freeze(Object.defineProperty({__proto__:null,ZERO:mc,create:yc,parse:Je},Symbol.toStringTag,{value:"Module"})),H=-1,me={[Symbol.iterator]:()=>me,next:()=>({done:!0,value:void 0})},bc=c.z.string().transform(e=>new Uint8Array(atob(e).split("").map(t=>t.charCodeAt(0))).buffer),wc=c.z.union([c.z.null(),c.z.undefined()]).transform(()=>new Uint8Array().buffer),pe=10,ur=(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`)},lr="sy_x_telem_series";class P{key;discriminator=lr;dataType;sampleOffset;gl;_data;timeRange=A.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=H;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=c.z.object({timeRange:A.z.optional(),dataType:f.z,alignment:c.z.coerce.bigint().optional(),data:c.z.union([bc,wc,c.z.instanceof(ArrayBuffer),c.z.instanceof(Uint8Array)]),glBufferUsage:nc.default("static").optional()});static z=P.crudeZ.transform(t=>new P(t));constructor(t){fr(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(hr(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 M=m[0];(M instanceof d||M instanceof Date||M 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,h)=>{const y=this.parseValue(u[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 On{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 ct=new bn,as=new wn,us=new On,ls=[ct],fs=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:wn,CSV_CODEC:as,ENCODERS:ls,JSONCodec:bn,JSON_CODEC:ct,TEXT_CODEC:us,TextCodec:On},Symbol.toStringTag,{value:"Module"})),j=e=>e!=null&&typeof e=="object"&&"value"in e;class nt{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,xn=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}},hs=e=>!xn(e),ds=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:nt,isCrudeValueExtension:j,isNonZero:hs,isStringer:Se,isZero:xn},Symbol.toStringTag,{value:"Module"})),oe=e=>[...new Set(e)],gs=(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())},ys=Object.freeze(Object.defineProperty({__proto__:null,by:gs,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?Nn(r):r},ms=(e,t,n)=>{const r=At(t[e],n);return(s,i)=>r(s[e],i[e])},ps=(e,t)=>e.length!==t.length?e.length-t.length:e.every((n,r)=>n===t[r])?0:-1,In=(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},bs=(e,t)=>{const n=oe(e),r=oe(t);return In(n,r)},ws=(e,t)=>e===t?0:e==="first"&&t==="last"?1:-1,Nn=e=>(t,n)=>e(n,t),rt=0,W=-1,V=1,vn=e=>e<rt,Mn=e=>e>rt,Os=e=>e>=rt,An=e=>e===rt,xs=(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},Sn=(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},Is=(e,t,n)=>{const r=Sn(e,t,n);e.splice(r,0,t)},Ns=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:rt,GREATER_THAN:V,LESS_THAN:W,insert:Is,isEqualTo:An,isGreaterThan:Mn,isGreaterThanEqual:Os,isLessThan:vn,newF:At,newFieldF:ms,order:ws,primitiveArrays:ps,reverseF:Nn,search:Sn,stringsWithNumbers:xs,uniqueUnorderedPrimitiveArrays:bs,unorderedPrimitiveArrays:In},Symbol.toStringTag,{value:"Module"}));let En=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};const Tn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",vs=`0123456789${Tn}`,$n=11,Ms=En(Tn,1),As=En(vs,$n-1),Ee=()=>`${Ms()}${As()}`,Ss=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:$n,create:Ee},Symbol.toStringTag,{value:"Module"})),zn=(e,t)=>n=>n instanceof t||typeof n=="object"&&n!==null&&"discriminator"in n&&n.discriminator===e,Es=Object.freeze(Object.defineProperty({__proto__:null,createMatcher:zn},Symbol.toStringTag,{value:"Module"})),Ts=2**8-1,Un=2**12-1,$s=2**16-1,zs=2**32-1,Us=2n**64n-1n,js=2**64-1,Cs=-128,Bs=2**7-1,Rs=-32768,Ps=2**15-1,Ls=-2147483648,ks=2**31-1,Zs=-(2n**63n),kt=2n**63n-1n,_s=-9223372036854776e3,jn=2**63-1,ut=e=>(t,n)=>{if(typeof t=="bigint"){if(Zt(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),qs=(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&&Zt(t)?e===BigInt(t):r&&Zt(e)?t===BigInt(e):e===t},Fs=e=>{const t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t},Cn=ut((e,t)=>e<=t?e:t),Zt=e=>typeof e=="bigint"?!0:Number.isInteger(e),Ws=ut((e,t)=>e>=t?e:t),Bn=e=>typeof e=="bigint"?e<0n?-e:e:e<0?-e:e,R=ut((e,t)=>e*t),St=ut((e,t)=>e/t),Rn=c.z.tuple([c.z.number(),c.z.number()]),Te=c.z.object({width:c.z.number(),height:c.z.number()}),Vs=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),Pn=["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()}),Vt=["x","y"],$e=c.z.enum(Vt),ze=["top","right","bottom","left"],Ys=c.z.enum(ze),Yt=["left","right"],Ue=c.z.enum(Yt),Gt=["top","bottom"],je=c.z.enum(Gt),Ce=["center"],ae=c.z.enum(Ce),Gs=[...ze,...Ce],Be=c.z.enum(Gs),Hs=c.z.enum(Pn),kn=["first","last"],Ds=c.z.enum(kn),Js=c.z.object({lower:c.z.number(),upper:c.z.number()}),Xs=c.z.enum([...$e.options,...Be.options]),Ks=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?Zn(r):r},Qs=Object.freeze({lower:0,upper:0}),ti=Object.freeze({lower:-1/0,upper:1/0}),ei=Object.freeze({lower:0,upper:1}),ni=Object.freeze({lower:-1,upper:1}),ri=(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},Zn=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},L=(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},si=(e,t)=>{const n=w(e),r=w(t);return n.lower===r.lower?!0:r.upper===n.lower||r.lower===n.upper?!1:L(n,r.upper)||L(n,r.lower)||L(r,n.upper)||L(r,n.lower)},lt=e=>{const t=w(e);return t.upper-t.lower},ii=e=>{const t=w(e);return typeof t.lower=="bigint"?t.lower===0n&&t.upper===0n:t.lower===0&&t.upper===0},oi=e=>{const t=lt(e);return typeof t=="number"?t===0:t===0n},ci=e=>{const t=w(e);return typeof t.lower=="bigint"?!0:Number.isFinite(t.lower)&&Number.isFinite(t.upper)},ai=e=>{const t=w(e);return(t.upper+t.lower)/2},_n=e=>({lower:Math.min(...e.map(t=>w(t).lower)),upper:Math.max(...e.map(t=>w(t).upper))}),ui=e=>({lower:Math.max(...e.map(t=>w(t).lower)),upper:Math.min(...e.map(t=>w(t).upper))}),li=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=>L(i,t)||t<i.lower);if(r===-1)return{index:e.length,position:0};const s=n[r];return L(s,t)?{index:r,position:Number(t-s.lower)}:{index:r,position:0}},ee={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},fi=(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}},qn=(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 h=Cn(Bn(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 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},Fn=(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},hi=Object.freeze(Object.defineProperty({__proto__:null,CLIP:ni,DECIMAL:ei,INFINITE:ti,ZERO:Qs,bounds:Js,buildInsertionPlan:fi,clamp:ue,construct:w,contains:L,distance:Fn,equals:ri,findInsertPosition:le,isFinite:ci,isZero:ii,linspace:li,makeValid:Zn,max:_n,mean:ai,min:ui,overlapsWith:si,span:lt,spanIsZero:oi,traverse:qn},Symbol.toStringTag,{value:"Module"})),fe=2,he=3,Wn=2,di=(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))+Wn;const s=10**r;return Math.round(e*s)/s},gi=5,yi=1e-10,mi=(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>yi}if(r){let u;s>=1e3?u=fe:s>=1?u=he:u=Math.ceil(-Math.log10(s))+Wn;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**(gi-i-1);return Math.round(e*a)/a},pi=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:Ps,MAX_INT32:ks,MAX_INT64:kt,MAX_INT64_NUMBER:jn,MAX_INT8:Bs,MAX_UINT12:Un,MAX_UINT16:$s,MAX_UINT32:zs,MAX_UINT64:Us,MAX_UINT64_NUMBER:js,MAX_UINT8:Ts,MIN_INT16:Rs,MIN_INT32:Ls,MIN_INT64:Zs,MIN_INT64_NUMBER:_s,MIN_INT8:Cs,abs:Bn,add:Y,closeTo:qs,div:St,equal:ce,isInteger:Zt,max:Ws,min:Cn,mult:R,roundBySpan:di,roundToNearestMagnitude:Fs,smartRound:mi,sub:_},Symbol.toStringTag,{value:"Module"})),Vn=Xs,Z=e=>Vt.includes(e)?e:Gt.includes(e)?"y":"x",bi=e=>Z(e)==="x"?"y":"x",wi=e=>Z(e)==="x"?"width":"height",Oi=e=>Z(e)==="x"?"left":"top",xi=e=>Vn.safeParse(e).success,Ii=e=>Z(e)==="x"?"signedWidth":"signedHeight",Ni=e=>e==="center"?!1:Z(e)==="x",vi=e=>Z(e)==="y",Mi=Object.freeze(Object.defineProperty({__proto__:null,DIRECTIONS:Vt,construct:Z,crude:Vn,dimension:wi,direction:$e,isDirection:xi,isX:Ni,isY:vi,location:Oi,signedDimension:Ii,swap:bi},Symbol.toStringTag,{value:"Module"})),Ai=Ue,Si=je,Ei=ae,Ti={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},$i={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},zi=Ks,tt=e=>e instanceof String||!Vt.includes(e)?e:e==="x"?"left":"top",Ui=e=>Ti[tt(e)],ji=(e,t)=>$i[e][t],It=e=>{const t=tt(e);return t==="top"||t==="bottom"?"y":"x"},Ci=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"}),Le=Object.freeze({x:"right",y:"bottom"}),ke=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"}),Bi=Object.freeze([Fe,qe,Ze,_e,ft,Pe,Ht,Le,ke]),We=(e,t)=>e.x===t.x&&e.y===t.y,Ri=(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},Yn=e=>[e.x,e.y],Bt=e=>It(tt(e))==="x",Pi=e=>It(tt(e))==="y",Li=e=>`${e.x}${pn(e.y)}`,ki=(e,t)=>{let n,r;if(typeof e=="object"&&"x"in e?(n=e.x,r=e.y):(n=tt(e),r=tt(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={...ke};return n==="center"?Bt(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:r==="center"?Bt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:Bt(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n],s},Zi=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:_e,BOTTOM_LEFT:Ht,BOTTOM_RIGHT:Le,CENTER:ke,CENTER_LEFT:Fe,CENTER_LOCATIONS:Ce,CENTER_RIGHT:qe,OUTER_LOCATIONS:ze,TOP_CENTER:Ze,TOP_LEFT:ft,TOP_RIGHT:Pe,XY_LOCATIONS:Bi,X_LOCATIONS:Yt,Y_LOCATIONS:Gt,center:Ei,construct:tt,constructXY:ki,corner:Re,crude:zi,direction:It,isX:Bt,isY:Pi,location:Be,outer:Ys,rotate:ji,swap:Ui,x:Ai,xy:Ci,xyCouple:Yn,xyEquals:We,xyMatches:Ri,xyToString:Li,y:Si},Symbol.toStringTag,{value:"Module"})),de=c.z.union([c.z.number(),at,Rn,Te,Vs,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}),_i=Object.freeze({x:1/0,y:1/0}),qi=Object.freeze({x:NaN,y:NaN}),_t=(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},Fi=e=>_t(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}},Dn=(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):Dn(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)},Wi=(e,t,n)=>{const r=x(e);return Z(t)==="x"?{x:n,y:r.y}:{x:r.x,y:n}},Vi=(e,t)=>{const n=x(e),r=x(t);return Math.sqrt((n.x-r.x)**2+(n.y-r.y)**2)},Yi=(e,t)=>{const n=x(e),r=x(t);return{x:r.x-n.x,y:r.y-n.y}},Gi=e=>{const t=x(e);return Number.isNaN(t.x)||Number.isNaN(t.y)},Hi=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]},Ji=e=>{const t=x(e);return{left:t.x,top:t.y}},qt=(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}},Jn=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}},Xn=(...e)=>{const t=e.reduce((n,r)=>Nt(n,r),q);return Ve(t,1/e.length)},Xi=(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],h=dt(l,s);o=gt(h),a=o,u=t}else if(r===e.length-1){const l=e[r-1],h=dt(s,l);i=gt(h),a=i,u=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 M=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(M/2);E===0?u=t:u=t/E,a=Jn(Xn(i,o))}n.push(Ve(a,u))}return n},Ki=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)}},Qi=e=>{const t=x(e);return{x:1/t.x,y:1/t.y}},to=(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}},eo=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:_i,NAN:qi,ONE:Gn,ZERO:q,average:Xn,calculateMiters:Xi,clientXY:Ln,construct:x,couple:Di,crudeZ:de,css:Ji,distance:Vi,equals:_t,isFinite:Hi,isNan:Gi,isZero:Fi,normal:gt,normalize:Jn,reciprocal:Qi,rotate:to,round:ge,scale:Ve,set:Wi,sub:dt,swap:Ki,translate:Nt,translateX:Hn,translateY:Dn,translation:Yi,truncate:qt,xy:at},Symbol.toStringTag,{value:"Module"})),$t=c.z.union([c.z.number(),c.z.string()]),no=c.z.object({top:$t,left:$t,width:$t,height:$t}),ro=c.z.object({left:c.z.number(),top:c.z.number(),right:c.z.number(),bottom:c.z.number()}),so=c.z.object({one:at,two:at,root:Re}),Kn={one:q,two:q,root:ft},io={one:q,two:Gn,root:Ht},Qn=(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))},oo=(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)},co=(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(D(r),D(t))&&s(K(t),K(r))&&s(J(r),J(t))&&s(Q(t),Q(r)):s(D(r),t.x)&&s(t.x,K(r))&&s(J(r),t.y)&&s(t.y,Q(r))},ao=(e,t)=>_t(e.one,t.one)&&_t(e.two,t.two)&&We(e.root,t.root),tr=e=>({width:$(e),height:z(e)}),uo=e=>({signedWidth:Dt(e),signedHeight:Jt(e)}),lo=e=>({top:J(e),left:D(e),width:$(e),height:z(e)}),Ye=(e,t,n=!1)=>{const r=Z(t)==="y"?Jt(e):Dt(e);return n?r:Math.abs(r)},G=(e,t)=>{const n=N(e);return{x:t.x==="center"?ye(n).x:et(n,t.x),y:t.y==="center"?ye(n).y:et(n,t.y)}},et=(e,t)=>{const n=N(e),r=Yn(n.root).includes(t)?Math.min:Math.max;return Yt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},fo=e=>rr(e)===0,$=e=>Ye(e,"x"),z=e=>Ye(e,"y"),Dt=e=>{const t=N(e);return t.two.x-t.one.x},Jt=e=>{const t=N(e);return t.two.y-t.one.y},er=e=>G(e,ft),ho=e=>G(e,Ze),go=e=>G(e,Pe),yo=e=>G(e,Ht),mo=e=>G(e,_e),po=e=>G(e,Le),bo=e=>G(e,Fe),wo=e=>G(e,qe),K=e=>et(e,"right"),Q=e=>et(e,"bottom"),D=e=>et(e,"left"),J=e=>et(e,"top"),ye=e=>Nt(er(e),{x:Dt(e)/2,y:Jt(e)/2}),Ge=e=>{const t=N(e);return t.root.x==="left"?D(t):K(t)},He=e=>{const t=N(e);return t.root.y==="top"?J(t):Q(t)},Oo=e=>({x:Ge(e),y:He(e)}),Rt=e=>{const t=N(e);return{lower:t.one.x,upper:t.two.x}},Pt=e=>{const t=N(e);return{lower:t.one.y,upper:t.two.y}},xo=(e,t)=>Qn(e,t),Io=(e,t)=>{const n=N(e),r=Yt.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]},No=(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},tr(n))},nr=e=>typeof e!="object"||e==null?!1:"one"in e&&"two"in e&&"root"in e,vo=e=>$(e)/z(e),Mo=(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)},Ao=(e,t)=>{const n=Math.max(D(e),D(t)),r=Math.max(J(e),J(t)),s=Math.min(K(e),K(t)),i=Math.min(Q(e),Q(t));return n>s||r>i?Kn:N({x:n,y:r},{x:s,y:i},void 0,void 0,e.root)},rr=e=>$(e)*z(e),So=(e,t)=>{const n=N(e);return N(qt(n.one,t),qt(n.two,t),void 0,void 0,n.root)},Eo=(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)},To=e=>{const t=N(e);return N(ge(t.one),ge(t.two),void 0,void 0,t.root)},$o=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:io,ZERO:Kn,area:rr,areaIsZero:fo,aspect:vo,bottom:Q,bottomCenter:mo,bottomLeft:yo,bottomRight:po,box:so,center:ye,centerLeft:bo,centerRight:wo,construct:N,constructWithAlternateRoot:Eo,contains:co,copy:Qn,css:lo,cssBox:no,dim:Ye,dims:tr,domRect:ro,edgePoints:Io,equals:ao,height:z,intersection:Ao,isBox:nr,left:D,loc:et,positionInCenter:No,reRoot:xo,resize:oo,right:K,root:Oo,round:To,signedDims:uo,signedHeight:Jt,signedWidth:Dt,top:J,topCenter:ho,topLeft:er,topRight:go,translate:Mo,truncate:So,width:$,x:Ge,xBounds:Rt,xyLoc:G,y:He,yBounds:Pt},Symbol.toStringTag,{value:"Module"})),sr=c.z.object({signedWidth:c.z.number(),signedHeight:c.z.number()}),zo=c.z.union([Te,sr,at,Rn]),Uo={width:0,height:0},jo={width:1,height:1},k=(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},Co=(e,t)=>{if(t==null)return!1;const n=k(e),r=k(t);return n.width===r.width&&n.height===r.height},Bo=e=>{const t=k(e);return{width:t.height,height:t.width}},Ro=e=>{const t=k(e);return`0 0 ${t.width} ${t.height}`},Po=e=>{const t=k(e);return[t.width,t.height]},Lo=e=>({width:Math.max(...e.map(t=>k(t).width)),height:Math.max(...e.map(t=>k(t).height))}),ko=e=>({width:Math.min(...e.map(t=>k(t).width)),height:Math.min(...e.map(t=>k(t).height))}),Zo=(e,t)=>{const n=k(e);return{width:n.width*t,height:n.height*t}},_o=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:jo,ZERO:Uo,construct:k,couple:Po,crude:zo,dimensions:Te,equals:Co,max:Lo,min:ko,scale:Zo,signed:sr,svgViewBox:Ro,swap:Bo},Symbol.toStringTag,{value:"Module"})),ir=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e,qo=c.z.object({offset:de,scale:de}),Fo=c.z.object({offset:c.z.number(),scale:c.z.number()}),Wo=e=>(t,n,r,s)=>n==="dimension"?[t,r]:[t,s?r-e:r+e],Vo=e=>(t,n,r,s)=>[t,s?r/e:r*e],Yo=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 h=(r-s)*(l/u)+o;return[e,h]},Go=e=>(t,n,r)=>[e,r],Ho=()=>(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=ir(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=Wo(t);return r.type="translate",n.ops.push(r),n}magnify(t){const n=this.new(),r=Vo(t);return r.type="magnify",n.ops.push(r),n}scale(t,n){const r=w(t,n),s=this.new(),i=Yo(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=Go(r);return i.type="re-bound",s.ops.push(i),s}invert(){const t=Ho();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(nr(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(Rt(t)),n.y=n.y.scale(Pt(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(Rt(t)),n.y=this.y.reBound(Pt(t)),n}clamp(t){const n=this.copy();return n.x=this.x.clamp(Rt(t)),n.y=this.y.clamp(Pt(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 Jo=Object.freeze(Object.defineProperty({__proto__:null,Scale:F,XY:B,crudeXYTransform:qo,transform:Fo},Symbol.toStringTag,{value:"Module"})),Xo=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:Pn,ORDERS:kn,alignment:Hs,order:Ds},Symbol.toStringTag,{value:"Module"})),or=at.extend({root:Re,units:c.object({x:c.enum(["px","decimal"]),y:c.enum(["px","decimal"])})}),Ko=or.partial({root:!0,units:!0}),Qo=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},tc=({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},ec=({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,...qt(i,3)}},nc=Object.freeze(Object.defineProperty({__proto__:null,calculate:ec,completeXY:or,toCSS:Qo,toDecimal:tc,xy:Ko},Symbol.toStringTag,{value:"Module"})),rc=c.z.enum(["static","dynamic"]),on=365,zt=30,sc=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)])]),cr=(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 nt{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===jn?t=kt: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",a="00";i!=null&&([o,a]=i.split("."));let u=d.hours(parseInt(r??"00")).add(d.minutes(parseInt(s??"00"))).add(d.seconds(parseInt(o??"00"))).add(d.milliseconds(parseInt(a??"00")));return n==="local"&&(u=u.add(d.utcOffset)),u.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 a=n==="local"?new Date(i.replace("T"," ")):new Date(`${i}Z`),u=BigInt(a.getTime())*d.MILLISECOND.valueOf(),l=BigInt(o)*d.MILLISECOND.valueOf();return u+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 A(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 cr(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(kt);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)),sc.transform(t=>new d(t))]);static sort(t,n){return Number(t.valueOf()-n.valueOf())}}class g extends nt{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 cr(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,h=r.sub(n),y=s.sub(r),m=i.sub(s),M=o.sub(i),E=a.sub(o),C=u.sub(a);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 `),M.isZero||(O+=`${M.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/on),l=Math.floor(s/zt),h=Math.floor(s/7),y=Math.floor(s),m=Math.floor(i),M=Math.floor(o),E=Math.floor(a),C=r?"-":"";if(u>=1){let O=`${u}y`;if(u<2){const v=Math.floor(s%on/zt);v>0&&(O+=` ${v}mo`)}return C+O}if(h>=1&&s<zt&&s%7===0){let O=`${h}w`;const v=Math.floor(s%7),X=Math.floor(i-h*7*24);return h<2&&(v>0?O+=` ${v}d`:X>0&&X<24&&(O+=` ${X}h`)),C+O}if(l>=1){let O=`${l}mo`;if(l<3){const v=Math.floor(s%zt);v>0&&(O+=` ${v}d`)}return C+O}if(h>=1){let O=`${h}w`;const v=Math.floor(s%7),X=Math.floor(i-h*7*24);return h<2&&(v>0?O+=` ${v}d`:X>0&&X<24&&(O+=` ${X}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(M>=1){let O=`${M}m`;if(M<5){const v=Math.floor(a-M*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(kt);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 nt{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 nt{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 A{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 A(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 A?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const n=new A(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 A(d.min(...t.map(n=>n.start)),d.max(...t.map(n=>n.end)))}static MAX=new A(d.MIN,d.MAX);static ZERO=new A(d.ZERO,d.ZERO);static z=c.z.union([c.z.object({start:d.z,end:d.z}).transform(t=>new A(t.start,t.end)),c.z.instanceof(A)]);static sort(t,n){return d.sort(t.start,n.start)||d.sort(t.end,n.end)}static simplify(t){return t.map(n=>n.makeValid()).sort((n,r)=>A.sort(n,r)).reduce((n,r)=>{if(r.span.isZero)return n;if(n.length===0)return n.push(r),n;const s=n[n.length-1];return s.overlapsWith(r)||s.end.equals(r.start)?s.end=d.max(s.end,r.end):n.push(r),n},[])}}class f extends nt{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 nt{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),h=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 `),(!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 ic=c.z.object({start:c.z.number(),end:c.z.number()}),oc=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),cc="00000000-0000-0000-0000-000000000000",ac=/^(?:[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 uc(e){return typeof e=="string"&&ac.test(e)}const S=[];for(let e=0;e<256;++e)S.push((e+256).toString(16).slice(1));function ur(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 lc(e,t=0){const n=ur(e,t);if(!uc(n))throw TypeError("Stringified UUID is invalid");return n}let ne;const fc=new Uint8Array(16);function hc(){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(fc)}const dc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cn={randomUUID:dc};function gc(e,t,n){e=e||{};const r=e.random??e.rng?.()??hc();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,ur(r)}function yc(e,t,n){return cn.randomUUID&&!e?cn.randomUUID():gc(e)}const mc=()=>yc(),Je=(e,t)=>lc(e,t),pc=cc,bc=Object.freeze(Object.defineProperty({__proto__:null,ZERO:pc,create:mc,parse:Je},Symbol.toStringTag,{value:"Module"})),H=-1,me={[Symbol.iterator]:()=>me,next:()=>({done:!0,value:void 0})},wc=c.z.string().transform(e=>new Uint8Array(atob(e).split("").map(t=>t.charCodeAt(0))).buffer),Oc=c.z.union([c.z.null(),c.z.undefined()]).transform(()=>new Uint8Array().buffer),pe=10,lr=(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`)},fr="sy_x_telem_series";class P{key;discriminator=fr;dataType;sampleOffset;gl;_data;timeRange=A.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=H;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=c.z.object({timeRange:A.z.optional(),dataType:f.z,alignment:c.z.coerce.bigint().optional(),data:c.z.union([wc,Oc,c.z.instanceof(ArrayBuffer),c.z.instanceof(Uint8Array)]),glBufferUsage:rc.default("static").optional()});static z=P.crudeZ.transform(t=>new P(t));constructor(t){hr(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(dr(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 M=m[0];(M instanceof d||M instanceof Date||M 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(`
4
4
  `)}
5
5
  `).buffer):this.dataType.equals(f.JSON)?(this.cachedLength=m.length,this._data=new TextEncoder().encode(`${m.map(E=>ct.encodeString(E)).join(`
6
6
  `)}
7
7
  `).buffer):this.dataType.usesBigInt&&typeof M=="number"?this._data=new this.dataType.Array(m.map(E=>BigInt(Math.round(E)))).buffer:!this.dataType.usesBigInt&&typeof M=="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??A.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(ct.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]=cr(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 ur(t,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:un(this.alignmentBounds.lower),upper:un(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 Oc(this);return this.dataType.equals(f.JSON)?new Xe(t):t}return this.dataType.equals(f.UUID)?new xc(this):new Ic(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:A.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 fr=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof P?!0:De(e),hr=$n(lr,P);class an{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 Oc{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:ct.decodeString(t.value,Xe.schema)}}}class xc{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 Ic{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 Nc{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 ur(t,this.dataType),this}get dataType(){return this.series.length===0?f.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?A.ZERO:new A(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?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(hr(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(L(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(L(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(L(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(L(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 Zn(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 _n(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 qn(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 vc(this.series)}toStrings(){return this.series.flatMap(t=>t.toStrings())}}class vc{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 un=e=>{const t=e>>32n,n=e&0xffffffffn;return{domain:t,sample:n}},dr=async e=>await new Promise(t=>setTimeout(t,g.fromMilliseconds(e).milliseconds)),Mc=Object.freeze(Object.defineProperty({__proto__:null,sleep:dr},Symbol.toStringTag,{value:"Module"}));class Ac{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??dr},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 Sc=c.z.object({baseInterval:g.z.optional(),maxRetries:c.z.number().optional(),scale:c.z.number().optional()}),Ec=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Ac,breakerConfigZ:Sc},Symbol.toStringTag,{value:"Module"})),Tc=e=>c.z.object({variant:c.z.enum(["set","delete"]),key:c.z.string(),value:e}),$c=Object.freeze(Object.defineProperty({__proto__:null,Z:Tc},Symbol.toStringTag,{value:"Module"})),zc=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Ft=c.z.string().regex(zc),ot=c.z.number().min(0).max(255),gr=c.z.number().min(0).max(1),Xt=c.z.tuple([ot,ot,ot,gr]),Uc=c.z.tuple([ot,ot,ot]),jc=c.z.object({rgba255:Xt}),Cc=c.z.number().min(0).max(360),Bc=c.z.number().min(0).max(100),Rc=c.z.number().min(0).max(100),yr=c.z.tuple([Cc,Bc,Rc,gr]),Kt=c.z.union([Ft,Uc,Xt,yr,jc]),Qt=Kt.transform(e=>I(e)),Pc=e=>Qt.safeParse(e).success,Lc=e=>Xt.safeParse(e).success,kc=(e=>{if(e==null)return;const t=Qt.safeParse(e);if(t.success)return pr(t.data);if(typeof e=="string")return e;throw t.error}),I=(e,t=1)=>{if(e=Kt.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 e.rgba255},mr=(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);return`#${Ut(t)}${Ut(n)}${Ut(r)}${s===1?"":Ut(s*255)}`}),pr=e=>{const[t,n,r,s]=I(e);return`rgba(${t}, ${n}, ${r}, ${s})`},_c=e=>`rgb(${br(e)})`,br=e=>{const[t,n,r]=I(e);return`${t}, ${n}, ${r}`},qc=e=>[...Ke(e),Ot(e)],Ke=e=>[pt(e)/255,bt(e)/255,wt(e)/255],pt=e=>I(e)[0],bt=e=>I(e)[1],wt=e=>I(e)[2],Ot=e=>I(e)[3],Fc=e=>mr(Qe,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]=Ke(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]=Ke(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=Ft.parse(e),e=Jc(e),[jt(e,0),jt(e,2),jt(e,4),e.length===8?jt(e,6)/255:t]),Qe=[0,0,0,0],Ut=e=>Math.floor(e).toString(16).padStart(2,"0"),jt=(e,t)=>parseInt(e.slice(t,t+2),16),Jc=e=>e.startsWith("#")?e.slice(1):e,ln={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(Ft.safeParse(i).success)return Lt(i)}return(t.length===7||t.length===9)&&Ft.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(ln[t])return Lt(ln[t])}},Kc=e=>{e=yr.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=Xt.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 h=i-o;u=l>.5?h/(2-i-o):h/(i+o),i===t?a=(n-r)/h+(n<r?6:0):i===n?a=(r-t)/h+2:a=(t-n)/h+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"),wr=c.z.object({key:c.z.string(),color:Kt,position:c.z.number(),switched:c.z.boolean().optional()}),na=c.z.array(wr),ra=(e,t)=>{if(e.length===0)return Qe;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(pt(o)+i*(pt(a)-pt(o))),l=Math.round(bt(o)+i*(bt(a)-bt(o))),h=Math.round(wt(o)+i*(wt(a)-wt(o))),y=Ot(o)+i*(Ot(a)-Ot(o));return I([u,l,h,y])}return I(e[e.length-1].color)},sa=c.z.object({key:c.z.string(),name:c.z.string(),color:Qt}),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:Qe,aValue:Ot,bValue:wt,colorZ:Qt,construct:I,contrast:be,crudeZ:Kt,cssString:kc,equals:mr,fromCSS:Xc,fromGradient:ra,fromHSLA:Kc,gValue:bt,gradientZ:na,grayness:Yc,hex:Zc,hsla:Wc,isColor:Lc,isCrude:Pc,isDark:Hc,isLight:Dc,isZero:Fc,luminance:vt,paletteZ:ia,pickByContrast:Gc,rValue:pt,rgbCSS:_c,rgbString:br,rgba1:qc,rgbaCSS:pr,setAlpha:Vc,stopZ:wr},Symbol.toStringTag,{value:"Module"})),Or=c.z.int().min(0).max(255),xr=255,Ir=0,ca={lower:Ir,upper:xr+1},Nr=c.z.object({name:c.z.string(),key:c.z.string()}),Mt=e=>c.z.object({subject:Nr,resource:e,authority:Or}),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}),vr=e=>c.z.object({from:Mt(e),to:c.z.null()}),Mr=e=>c.z.object({from:c.z.null(),to:Mt(e)}),ua=e=>c.z.union([vr(e),Mr(e),c.z.object({from:Mt(e),to:Mt(e)})]),la=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:xr,AUTHORITY_BOUNDS:ca,ZERO_AUTHORITY:Ir,acquireZ:Mr,authorityZ:Or,filterTransfersByChannelKey:aa,releaseZ:vr,stateZ:Mt,subjectZ:Nr,transferZ:ua},Symbol.toStringTag,{value:"Module"})),fa=/[",\n]/,ha=e=>fa.test(e)?`"${e.replace(/"/g,'""')}"`:e,da=Object.freeze(Object.defineProperty({__proto__:null,maybeEscapeField:ha},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},Ar=(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(!Ar(i,o))return!1}else if(i!==o)return!1}return!0},U=".",Sr=(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},st=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},tn=((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 h=i.slice(u,u+l).join(U),y=s(a,h);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. ${h} 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)=>tn(e,t,{optional:!0})!==null,xe=(e,...t)=>{if(t.length===0)return e;const n=t.shift();if(mt(e)&&mt(n))for(const r in n)try{mt(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 h=l[a].safeParse(u);if(h.success){s[a]=h.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(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 a=n.length-s;a>=1;a--){const u=n.slice(s,s+a).join(U),l=r.find(h=>h.key===u);if(l!=null){if(s+a===n.length){const h=r.findIndex(y=>y.key===u);h!==-1&&r.splice(h,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 h=st(l);h==null&&l.startsWith("-")&&st(l.substring(1))!=null&&(h=0),u=h!=null?[]:{},s[a]=u}s=u}try{const o=r[r.length-1];if(Array.isArray(s)){let u=st(o);if(u==null){if(o.startsWith("-")){const l=st(o.substring(1));l!=null&&(u=s.length-l)}if(u==null){if(s.length===0){const h=st(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[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:tn,getIndex:st,has:xa,override:xe,overrideValidItems:Ia,partialEqual:Ar,pathsMatch:Oa,remove:Na,resolvePath:ba,set:va,transformPath:Sr},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]},Er="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),Et=e=>class yt extends Error{static discriminator=Er;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 Et(`${e}.${n}`)}},Tr=e=>{if(e==null||typeof e!="object")return!1;const t=e;if(t.discriminator!==Er)return!1;if(!("type"in t))throw new Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},it="unknown",Ie="nil";class $a{providers=[];register(t){this.providers.push(t)}encode(t){if(t==null)return{type:Ie,data:""};if(Tr(t))for(const n of this.providers){const r=n.encode(t);if(r!=null)return r}if(t instanceof Error)return{type:it,data:t.message};if(typeof t=="string")return{type:it,data:t};try{return{type:it,data:JSON.stringify(t)}}catch{return{type:it,data:"unable to encode error information"}}}decode(t){if(t==null||t.type===Ie)return null;if(t.type===it)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 en=Ea("synnax-error-registry",()=>new $a),za=({encode:e,decode:t})=>en().register({encode:e,decode:t}),Ua=e=>en().encode(e),ja=e=>e==null?null:en().decode(e);class Ne extends Et("unknown"){}const Ca=c.z.object({type:c.z.string(),data:c.z.string()});class Ba extends Et("canceled"){}class Ra extends Et("not_implemented"){}const Pa=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Ba,NONE:Ie,NotImplemented:Ra,UNKNOWN:it,Unknown:Ne,createTyped:Et,decode:ja,encode:Ua,isTyped:Tr,payloadZ:Ca,register:za},Symbol.toStringTag,{value:"Module"})),$r=c.object({jsonrpc:c.literal("2.0"),method:c.string(),params:c.any().optional(),id:c.union([c.string(),c.number(),c.null()]).optional()}),zr=c.object({jsonrpc:c.literal("2.0"),id:c.union([c.string(),c.number(),c.null()])}),La=zr.extend({result:c.json()}),ka=zr.extend({error:c.object({code:c.number().int(),message:c.string().optional(),data:c.json().optional()})}),Ur=c.union([La,ka]),jr=c.union([$r,Ur]),Za=e=>{const t=new TextDecoder;let n=new Uint8Array(0),r=null;return s=>{let i;typeof s=="string"?i=new TextEncoder().encode(s):s instanceof ArrayBuffer?i=new Uint8Array(s):i=s;const o=new Uint8Array(n.length+i.length);for(o.set(n),o.set(i,n.length),n=o;n.length>0;){if(r===null){const u=t.decode(n).match(/^Content-Length: (\d+)\r?\n\r?\n/);if(!u)break;r=parseInt(u[1]);const l=new TextEncoder().encode(u[0]).length;n=n.slice(l)}if(r!==null&&n.length>=r){const a=n.slice(0,r);n=n.slice(r),r=null;const u=t.decode(a),l=ct.decodeString(u,jr);e(l)}else break}}},_a=e=>{const t=JSON.stringify(e);return`Content-Length: ${new TextEncoder().encode(t).length}\r
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(ct.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]=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!==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 lr(t,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:un(this.alignmentBounds.lower),upper:un(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 xc(this);return this.dataType.equals(f.JSON)?new Xe(t):t}return this.dataType.equals(f.UUID)?new Ic(this):new Nc(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:A.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 hr=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof P?!0:De(e),dr=zn(fr,P);class an{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 xc{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:ct.decodeString(t.value,Xe.schema)}}}class Ic{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 Nc{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 vc{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 lr(t,this.dataType),this}get dataType(){return this.series.length===0?f.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?A.ZERO:new A(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?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(dr(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(L(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(L(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(L(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(L(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 _n(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 qn(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 Fn(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 Mc(this.series)}toStrings(){return this.series.flatMap(t=>t.toStrings())}}class Mc{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 un=e=>{const t=e>>32n,n=e&0xffffffffn;return{domain:t,sample:n}},gr=async e=>await new Promise(t=>setTimeout(t,g.fromMilliseconds(e).milliseconds)),Ac=Object.freeze(Object.defineProperty({__proto__:null,sleep:gr},Symbol.toStringTag,{value:"Module"}));class Sc{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??gr},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 Ec=c.z.object({baseInterval:g.z.optional(),maxRetries:c.z.number().optional(),scale:c.z.number().optional()}),Tc=Object.freeze(Object.defineProperty({__proto__:null,Breaker:Sc,breakerConfigZ:Ec},Symbol.toStringTag,{value:"Module"})),$c=e=>c.z.object({variant:c.z.enum(["set","delete"]),key:c.z.string(),value:e}),zc=Object.freeze(Object.defineProperty({__proto__:null,Z:$c},Symbol.toStringTag,{value:"Module"})),Uc=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Ft=c.z.string().regex(Uc),ot=c.z.number().min(0).max(255),yr=c.z.number().min(0).max(1),Xt=c.z.tuple([ot,ot,ot,yr]),jc=c.z.tuple([ot,ot,ot]),Cc=c.z.object({rgba255:Xt}),Bc=c.z.number().min(0).max(360),Rc=c.z.number().min(0).max(100),Pc=c.z.number().min(0).max(100),mr=c.z.tuple([Bc,Rc,Pc,yr]),Kt=c.z.union([Ft,jc,Xt,mr,Cc]),Qt=Kt.transform(e=>I(e)),Lc=e=>Qt.safeParse(e).success,kc=e=>Xt.safeParse(e).success,Zc=(e=>{if(e==null)return;const t=Qt.safeParse(e);if(t.success)return br(t.data);if(typeof e=="string")return e;throw t.error}),I=(e,t=1)=>{if(e=Kt.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 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])},_c=(e=>{if(e==null)return;const[t,n,r,s]=I(e);return`#${Ut(t)}${Ut(n)}${Ut(r)}${s===1?"":Ut(s*255)}`}),br=e=>{const[t,n,r,s]=I(e);return`rgba(${t}, ${n}, ${r}, ${s})`},qc=e=>`rgb(${wr(e)})`,wr=e=>{const[t,n,r]=I(e);return`${t}, ${n}, ${r}`},Fc=e=>[...Ke(e),Ot(e)],Ke=e=>[pt(e)/255,bt(e)/255,wt(e)/255],pt=e=>I(e)[0],bt=e=>I(e)[1],wt=e=>I(e)[2],Ot=e=>I(e)[3],Wc=e=>pr(Qe,e),Vc=e=>ta(I(e)),Yc=(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]=Ke(e).map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},Gc=e=>{const[t,n,r]=Ke(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)},Hc=(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)},Dc=e=>vt(e)<.5,Jc=e=>vt(e)>.5,Lt=(e,t=1)=>(e=Ft.parse(e),e=Xc(e),[jt(e,0),jt(e,2),jt(e,4),e.length===8?jt(e,6)/255:t]),Qe=[0,0,0,0],Ut=e=>Math.floor(e).toString(16).padStart(2,"0"),jt=(e,t)=>parseInt(e.slice(t,t+2),16),Xc=e=>e.startsWith("#")?e.slice(1):e,ln={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"},Kc=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(Ft.safeParse(i).success)return Lt(i)}return(t.length===7||t.length===9)&&Ft.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(ln[t])return Lt(ln[t])}},Qc=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),ta=e=>{e=Xt.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 h=i-o;u=l>.5?h/(2-i-o):h/(i+o),i===t?a=(n-r)/h+(n<r?6:0):i===n?a=(r-t)/h+2:a=(t-n)/h+4,a/=6}return a*=360,u*=100,l*=100,[Math.round(a),Math.round(u),Math.round(l),s]},ea=I("#000000"),na=I("#ffffff"),Or=c.z.object({key:c.z.string(),color:Kt,position:c.z.number(),switched:c.z.boolean().optional()}),ra=c.z.array(Or),sa=(e,t)=>{if(e.length===0)return Qe;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(pt(o)+i*(pt(a)-pt(o))),l=Math.round(bt(o)+i*(bt(a)-bt(o))),h=Math.round(wt(o)+i*(wt(a)-wt(o))),y=Ot(o)+i*(Ot(a)-Ot(o));return I([u,l,h,y])}return I(e[e.length-1].color)},ia=c.z.object({key:c.z.string(),name:c.z.string(),color:Qt}),oa=c.z.object({key:c.z.string(),name:c.z.string(),swatches:c.z.array(ia)}),ca=Object.freeze(Object.defineProperty({__proto__:null,BLACK:ea,WHITE:na,ZERO:Qe,aValue:Ot,bValue:wt,colorZ:Qt,construct:I,contrast:be,crudeZ:Kt,cssString:Zc,equals:pr,fromCSS:Kc,fromGradient:sa,fromHSLA:Qc,gValue:bt,gradientZ:ra,grayness:Gc,hex:_c,hsla:Vc,isColor:kc,isCrude:Lc,isDark:Dc,isLight:Jc,isZero:Wc,luminance:vt,paletteZ:oa,pickByContrast:Hc,rValue:pt,rgbCSS:qc,rgbString:wr,rgba1:Fc,rgbaCSS:br,setAlpha:Yc,stopZ:Or},Symbol.toStringTag,{value:"Module"})),xr=c.z.int().min(0).max(255),Ir=255,Nr=0,aa={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}),ua=(...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)}),la=e=>c.z.union([Mr(e),Ar(e),c.z.object({from:Mt(e),to:Mt(e)})]),fa=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Ir,AUTHORITY_BOUNDS:aa,ZERO_AUTHORITY:Nr,acquireZ:Ar,authorityZ:xr,filterTransfersByChannelKey:ua,releaseZ:Mr,stateZ:Mt,subjectZ:vr,transferZ:la},Symbol.toStringTag,{value:"Module"})),ha=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 fn(e.toString());case"object":return e==null?"":fn(JSON.stringify(e))}},da=/[",\n]/,fn=e=>da.test(e)?`"${e.replace(/"/g,'""')}"`:e,ga=Object.freeze(Object.defineProperty({__proto__:null,formatValue:ha},Symbol.toStringTag,{value:"Module"})),ya=(e,t)=>{let n=null;return t===0?e:(...s)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>e(...s),t)}},ma=(e,t)=>{let n=null;return t===0?e:(...s)=>{n===null&&(n=setTimeout(()=>{e(...s),n=null},t))}},pa=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))}},ba=(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)},wa=(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)},Oa=(e,t)=>{const n=e.split(U);return t<0?n[n.length+t]:n[t]},xa=(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},st=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},tn=((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 h=i.slice(u,u+l).join(U),y=s(a,h);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. ${h} 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)}),Ia=(e,t)=>tn(e,t,{optional:!0})!==null,xe=(e,...t)=>{if(t.length===0)return e;const n=t.shift();if(mt(e)&&mt(n))for(const r in n)try{mt(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)},Na=(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 h=l[a].safeParse(u);if(h.success){s[a]=h.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)},va=(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(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 a=n.length-s;a>=1;a--){const u=n.slice(s,s+a).join(U),l=r.find(h=>h.key===u);if(l!=null){if(s+a===n.length){const h=r.findIndex(y=>y.key===u);h!==-1&&r.splice(h,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++}}},Ma=(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 h=st(l);h==null&&l.startsWith("-")&&st(l.substring(1))!=null&&(h=0),u=h!=null?[]:{},s[a]=u}s=u}try{const o=r[r.length-1];if(Array.isArray(s)){let u=st(o);if(u==null){if(o.startsWith("-")){const l=st(o.substring(1));l!=null&&(u=s.length-l)}if(u==null){if(s.length===0){const h=st(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[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}},Aa=Object.freeze(Object.defineProperty({__proto__:null,SEPARATOR:U,copy:pa,defaultGetter:ht,difference:ba,element:Oa,equal:we,findBestKey:Oe,get:tn,getIndex:st,has:Ia,override:xe,overrideValidItems:Na,partialEqual:Sr,pathsMatch:xa,remove:va,resolvePath:wa,set:Ma,transformPath:Er},Symbol.toStringTag,{value:"Module"})),Sa=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Ea=e=>Object.getOwnPropertySymbols(globalThis).includes(e),Ta=(e,t)=>{const n=Symbol.for(e);if(!Ea(n)){const r=t();Object.defineProperty(globalThis,n,{value:r})}return()=>globalThis[n]},Tr="sy_x_error",$a=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),Et=e=>class yt extends Error{static discriminator=Tr;discriminator=yt.discriminator;static TYPE=e;type=yt.TYPE;static matches=$a(e);matches=yt.matches;constructor(n,r){super(n,r),this.name=yt.TYPE}static sub(n){return Et(`${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},it="unknown",Ie="nil";class za{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:it,data:t.message};if(typeof t=="string")return{type:it,data:t};try{return{type:it,data:JSON.stringify(t)}}catch{return{type:it,data:"unable to encode error information"}}}decode(t){if(t==null||t.type===Ie)return null;if(t.type===it)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 en=Ta("synnax-error-registry",()=>new za),Ua=({encode:e,decode:t})=>en().register({encode:e,decode:t}),ja=e=>en().encode(e),Ca=e=>e==null?null:en().decode(e);class Ne extends Et("unknown"){}const Ba=c.z.object({type:c.z.string(),data:c.z.string()});class Ra extends Et("canceled"){}class Pa extends Et("not_implemented"){}const La=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Ra,NONE:Ie,NotImplemented:Pa,UNKNOWN:it,Unknown:Ne,createTyped:Et,decode:Ca,encode:ja,isTyped:$r,payloadZ:Ba,register:Ua},Symbol.toStringTag,{value:"Module"})),zr=c.object({jsonrpc:c.literal("2.0"),method:c.string(),params:c.any().optional(),id:c.union([c.string(),c.number(),c.null()]).optional()}),Ur=c.object({jsonrpc:c.literal("2.0"),id:c.union([c.string(),c.number(),c.null()])}),ka=Ur.extend({result:c.json()}),Za=Ur.extend({error:c.object({code:c.number().int(),message:c.string().optional(),data:c.json().optional()})}),jr=c.union([ka,Za]),Cr=c.union([zr,jr]),_a=e=>{const t=new TextDecoder;let n=new Uint8Array(0),r=null;return s=>{let i;typeof s=="string"?i=new TextEncoder().encode(s):s instanceof ArrayBuffer?i=new Uint8Array(s):i=s;const o=new Uint8Array(n.length+i.length);for(o.set(n),o.set(i,n.length),n=o;n.length>0;){if(r===null){const u=t.decode(n).match(/^Content-Length: (\d+)\r?\n\r?\n/);if(!u)break;r=parseInt(u[1]);const l=new TextEncoder().encode(u[0]).length;n=n.slice(l)}if(r!==null&&n.length>=r){const a=n.slice(0,r);n=n.slice(r),r=null;const u=t.decode(a),l=ct.decodeString(u,Cr);e(l)}else break}}},qa=e=>{const t=JSON.stringify(e);return`Content-Length: ${new TextEncoder().encode(t).length}\r
9
9
  \r
10
- `+t},qa=Object.freeze(Object.defineProperty({__proto__:null,encodeMessage:_a,messageZ:jr,requestZ:$r,responseZ:Ur,streamDecodeChunks:Za},Symbol.toStringTag,{value:"Module"}));class Fa{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 Wa{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 Va=c.z.object({key:c.z.string(),value:c.z.string()}),Ya=Object.freeze(Object.defineProperty({__proto__:null,MockAsync:Fa,MockSync:Wa,stringPairZ:Va},Symbol.toStringTag,{value:"Module"})),Cr=c.uuid(),Br=c.object({key:Cr,name:c.string().min(1),color:c.string()}),Ga=Object.freeze(Object.defineProperty({__proto__:null,keyZ:Cr,labelZ:Br},Symbol.toStringTag,{value:"Module"})),Ha=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_]*)?$"),Da=e=>Ha.test(e),Ja=Object.freeze(Object.defineProperty({__proto__:null,is:Da},Symbol.toStringTag,{value:"Module"})),Xa=(e,t,n)=>{const r=e.get(t);return r===void 0?(e.set(t,n),n):r},Ka=Object.freeze(Object.defineProperty({__proto__:null,getOrSetDefault:Xa},Symbol.toStringTag,{value:"Module"})),ve=c.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),Qa=(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 h=parseInt(o),y=parseInt(a);if(h<y)return W;if(h>y)return V}else{if(o<a)return W;if(o>a)return V}}return rt},Tt=((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,h,y]=i.split(".").map(Number),[m,M,E]=a.split(".").map(Number);if(n.checkMajor){if(l<m)return W;if(l>m)return V}if(n.checkMinor){if(h<M)return W;if(h>M)return V}if(n.checkPatch){if(y<E)return W;if(y>E)return V}return o===void 0&&u===void 0?rt:o===void 0?V:u===void 0?W:Qa(o,u)}),tu=(e,t,n={})=>Mn(Tt(e,t,n)),Rr=(e,t,n={})=>vn(Tt(e,t,n)),eu=(e,t,n={})=>Nn(Tt(e,t,n)),nu=({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}},ru=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:s})=>{const i=Object.keys(t).sort(Tt).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}.
10
+ `+t},Fa=Object.freeze(Object.defineProperty({__proto__:null,encodeMessage:qa,messageZ:Cr,requestZ:zr,responseZ:jr,streamDecodeChunks:_a},Symbol.toStringTag,{value:"Module"}));class Wa{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 Va{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 Ya=c.z.object({key:c.z.string(),value:c.z.string()}),Ga=Object.freeze(Object.defineProperty({__proto__:null,MockAsync:Wa,MockSync:Va,stringPairZ:Ya},Symbol.toStringTag,{value:"Module"})),Br=c.uuid(),Rr=c.object({key:Br,name:c.string().min(1),color:c.string()}),Ha=Object.freeze(Object.defineProperty({__proto__:null,keyZ:Br,labelZ:Rr},Symbol.toStringTag,{value:"Module"})),Da=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_]*)?$"),Ja=e=>Da.test(e),Xa=Object.freeze(Object.defineProperty({__proto__:null,is:Ja},Symbol.toStringTag,{value:"Module"})),Ka=(e,t,n)=>{const r=e.get(t);return r===void 0?(e.set(t,n),n):r},Qa=Object.freeze(Object.defineProperty({__proto__:null,getOrSetDefault:Ka},Symbol.toStringTag,{value:"Module"})),ve=c.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),tu=(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 h=parseInt(o),y=parseInt(a);if(h<y)return W;if(h>y)return V}else{if(o<a)return W;if(o>a)return V}}return rt},Tt=((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,h,y]=i.split(".").map(Number),[m,M,E]=a.split(".").map(Number);if(n.checkMajor){if(l<m)return W;if(l>m)return V}if(n.checkMinor){if(h<M)return W;if(h>M)return V}if(n.checkPatch){if(y<E)return W;if(y>E)return V}return o===void 0&&u===void 0?rt:o===void 0?V:u===void 0?W:tu(o,u)}),eu=(e,t,n={})=>An(Tt(e,t,n)),Pr=(e,t,n={})=>Mn(Tt(e,t,n)),nu=(e,t,n={})=>vn(Tt(e,t,n)),ru=({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}},su=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:s})=>{const i=Object.keys(t).sort(Tt).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}.
11
11
  Returning default instead.
12
- `),s;try{return n!=null?n.parse(l):l}catch(h){return console.log(`${e} failed to parse default. Exiting with default`),console.error(h),s}};const o=Object.keys(t).length;let a=!1;const u=l=>{try{if(o===0||Rr(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 h=l.version,y=t[h],m=y(l);return a=!0,u(m)}catch(h){return console.log(`${e} failed to migrate from ${l.version} to ${i}`),console.error(h),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(h){return console.log(`${e} failed to parse final result. Exiting with default`),console.error(h),s}}},su=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Tt,createMigration:nu,migrator:ru,semVerNewer:Rr,semVerOlder:eu,semVerZ:ve,versionsEqual:tu},Symbol.toStringTag,{value:"Module"})),Pr=["standard","scientific","engineering"],iu=c.z.enum(Pr),ou=(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}`},cu=Object.freeze(Object.defineProperty({__proto__:null,NOTATIONS:Pr,notationZ:iu,stringifyNumber:ou},Symbol.toStringTag,{value:"Module"}));class au{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 uu{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 lu=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:uu,Observer:au},Symbol.toStringTag,{value:"Module"})),fu=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),hu=c.z.record(c.z.union([c.z.number(),c.z.string(),c.z.symbol()]),c.z.unknown()),nn=e=>Object.entries(e),du=(e,t)=>Object.fromEntries(nn(e).map(([n,r])=>[n,t(r,n)])),gu=e=>Object.fromEntries(nn(e).filter(([t,n])=>n!==void 0)),yu=(e,...t)=>{const n={...e};for(const r of t)delete n[r];return n},mu=Object.freeze(Object.defineProperty({__proto__:null,entries:nn,map:du,omit:yu,purgeUndefined:gu,unknownZ:hu},Symbol.toStringTag,{value:"Module"})),Lr=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",pu=Lr(),kr=["macOS","Windows","Linux"],bu=["macos","windows","linux"],wu={macos:"macOS",windows:"Windows",linux:"Linux"},Ou=c.z.enum(kr).or(c.z.enum(bu).transform(e=>wu[e])),xu=()=>{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 Ct;const Iu=((e={})=>{const{force:t,default:n}=e;return t??Ct??(Ct=xu(),Ct??n)}),Nu=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:kr,RUNTIME:pu,detect:Lr,getOS:Iu,osZ:Ou},Symbol.toStringTag,{value:"Module"})),vu=()=>Promise.resolve(),Mu=()=>new Promise(e=>setTimeout(e,0)),Au=Object.freeze(Object.defineProperty({__proto__:null,flushMicrotasks:vu,flushTaskQueue:Mu},Symbol.toStringTag,{value:"Module"})),Su=e=>Array.isArray(e)?[...e]:typeof e=="object"&&e!==null?{...e}:e,Eu=Object.freeze(Object.defineProperty({__proto__:null,copy:Su},Symbol.toStringTag,{value:"Module"})),Zr=c.z.enum(["success","info","warning","error","loading","disabled"]),Tu=e=>c.z.object({key:c.z.string(),name:c.z.string().default(""),variant:Zr,message:c.z.string(),description:c.z.string().optional(),time:d.z,labels:hn(Br).optional(),details:e??c.z.unknown().optional()}),$u=c.z.object({stack:c.z.string(),error:c.z.instanceof(Error)}),zu=(e,t)=>{if(!(e instanceof Error))throw e;return _r({variant:"error",message:t??e.message,description:t!=null?e.message:void 0,details:{stack:e.stack??"",error:e}})},_r=e=>({key:Ee(),time:d.now(),name:"",...e}),Uu=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},ju=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},Cu=Object.freeze(Object.defineProperty({__proto__:null,create:_r,exceptionDetailsSchema:$u,fromException:zu,keepVariants:Uu,removeVariants:ju,statusZ:Tu,variantZ:Zr},Symbol.toStringTag,{value:"Module"})),Bu=(e,t)=>{if(!t.has(e))return e;let n=e,r=1,s=e;for(;t.has(s);){const i=s.match(Ru);i?(n=s.slice(0,i.index).trim(),r=parseInt(i[1])+1):(n=s,r=1),s=`${n} (${r})`}return s},Ru=/\((\d+)\)$/,Pu=(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]}`},Lu=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 h=t.map((y,m)=>m!==l?y.charAt(0).toLowerCase():y).join("");n.add(h.replace(/-/g,"_")),n.add(h.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))},ku=(e,t)=>e.startsWith(t)?e.slice(t.length):e,Zu=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Lu,deduplicateFileName:Bu,naturalLanguageJoin:Pu,trimPrefix:ku},Symbol.toStringTag,{value:"Module"})),_u=new Error("request for lock canceled");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(h){try{l(r.next(h))}catch(y){o(y)}}function u(h){try{l(r.throw(h))}catch(y){o(y)}}function l(h){h.done?i(h.value):s(h.value).then(a,u)}l((r=r.apply(e,t||[])).next())})};class Fu{constructor(t,n=_u){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=qr(this._queue,a=>n<=a.priority);o===-1&&t<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(t){return qu(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]=[]),Wu(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 Wu(e,t){const n=qr(e,r=>t.priority<=r.priority);e.splice(n+1,0,t)}function qr(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Vu=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(h){try{l(r.next(h))}catch(y){o(y)}}function u(h){try{l(r.throw(h))}catch(y){o(y)}}function l(h){h.done?i(h.value):s(h.value).then(a,u)}l((r=r.apply(e,t||[])).next())})};class Yu{constructor(t){this._semaphore=new Fu(1,t)}acquire(){return Vu(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 Fr extends Yu{constructor(t){super(),Object.assign(this,t)}}const Gu=e=>new Fr(e),Hu=Object.freeze(Object.defineProperty({__proto__:null,mutex:Fr,newMutex:Gu},Symbol.toStringTag,{value:"Module"})),Du=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),Ju=async(e,t=200,n=20)=>{const r=Date.now();for(;Date.now()-r<t;)await e(),await new Promise(s=>setTimeout(s,n))},Xu=Object.freeze(Object.defineProperty({__proto__:null,expectAlways:Ju,toString:Du},Symbol.toStringTag,{value:"Module"})),Ku=(...e)=>e.map(Wr).join(""),Wr=e=>(e.endsWith("/")||(e+="/"),e.startsWith("/")&&(e=e.slice(1)),e),Qu=e=>e.endsWith("/")?e.slice(0,-1):e,tl=(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 xt{protocol;host;port;path;constructor({host:t,port:n,protocol:r="",pathPrefix:s=""}){this.protocol=r,this.host=t,this.port=n,this.path=Wr(s)}replace(t){return new xt({host:t.host??this.host,port:t.port??this.port,protocol:t.protocol??this.protocol,pathPrefix:t.pathPrefix??this.path})}child(t){return new xt({...this,pathPrefix:Ku(this.path,t)})}toString(){return Qu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new xt({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=el(t,this.sender),r=new Vr(n);return this.handlers.set(t,r),r}}const el=(e,t)=>(n,r)=>t({type:e,payload:n},r);class Vr{_send;handler;constructor(t){this._send=t,this.handler=null}send(t,n=[]){this._send(t,n)}handle(t){this.handler=t}}const nl=()=>{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]},rl=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),sl=c.z.int().min(0).max(zn),il=e=>c.array(e).or(e.transform(t=>[t])),Yr=e=>Sr(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"]}),fn=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},ol=((e,t,n)=>t===""?e:tn(fn(e,"shape"),Yr(t),{...n,getter:fn})),cl=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:ol,getFieldSchemaPath:Yr,nullToUndefined:rl,toArray:il,uint12:sl},Symbol.toStringTag,{value:"Module"}));exports.DataType=f;exports.Density=b;exports.MultiSeries=Nc;exports.Rate=T;exports.RoutedWorker=Me;exports.Series=P;exports.Size=p;exports.TimeRange=A;exports.TimeSpan=g;exports.TimeStamp=d;exports.TypedWorker=Vr;exports.URL=xt;exports.array=Jr;exports.binary=ls;exports.bounds=fi;exports.box=To;exports.breaker=Ec;exports.buildQueryString=tl;exports.caseconv=is;exports.change=$c;exports.clamp=sr;exports.color=oa;exports.compare=Is;exports.control=la;exports.convertDataType=cr;exports.createMockWorkers=nl;exports.csv=da;exports.debounce=ga;exports.deep=Ma;exports.destructor=Aa;exports.dimensions=Zo;exports.direction=vi;exports.errors=Pa;exports.id=As;exports.instance=Ss;exports.isCrudeSeries=fr;exports.isTelemValue=De;exports.jsonRPC=qa;exports.kv=Ya;exports.label=Ga;exports.link=Ja;exports.location=ki;exports.map=Ka;exports.math=mi;exports.migrate=su;exports.narrow=os;exports.notation=cu;exports.numericTimeRangeZ=sc;exports.observe=lu;exports.optional=fu;exports.primitive=hs;exports.record=mu;exports.runtime=Nu;exports.scale=Do;exports.scheduler=Au;exports.shallow=Eu;exports.sleep=Mc;exports.spatial=Jo;exports.status=Cu;exports.sticky=ec;exports.strings=Zu;exports.sync=Hu;exports.testutil=Xu;exports.throttle=ya;exports.typedArrayZ=ic;exports.unique=gs;exports.uuid=pc;exports.xy=to;exports.zod=cl;
12
+ `),s;try{return n!=null?n.parse(l):l}catch(h){return console.log(`${e} failed to parse default. Exiting with default`),console.error(h),s}};const o=Object.keys(t).length;let a=!1;const u=l=>{try{if(o===0||Pr(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 h=l.version,y=t[h],m=y(l);return a=!0,u(m)}catch(h){return console.log(`${e} failed to migrate from ${l.version} to ${i}`),console.error(h),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(h){return console.log(`${e} failed to parse final result. Exiting with default`),console.error(h),s}}},iu=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:Tt,createMigration:ru,migrator:su,semVerNewer:Pr,semVerOlder:nu,semVerZ:ve,versionsEqual:eu},Symbol.toStringTag,{value:"Module"})),Lr=["standard","scientific","engineering"],ou=c.z.enum(Lr),cu=(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}`},au=Object.freeze(Object.defineProperty({__proto__:null,NOTATIONS:Lr,notationZ:ou,stringifyNumber:cu},Symbol.toStringTag,{value:"Module"}));class uu{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 lu{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 fu=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:lu,Observer:uu},Symbol.toStringTag,{value:"Module"})),hu=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),du=c.z.record(c.z.union([c.z.number(),c.z.string(),c.z.symbol()]),c.z.unknown()),nn=e=>Object.entries(e),gu=(e,t)=>Object.fromEntries(nn(e).map(([n,r])=>[n,t(r,n)])),yu=e=>Object.fromEntries(nn(e).filter(([t,n])=>n!==void 0)),mu=(e,...t)=>{const n={...e};for(const r of t)delete n[r];return n},pu=Object.freeze(Object.defineProperty({__proto__:null,entries:nn,map:gu,omit:mu,purgeUndefined:yu,unknownZ:du},Symbol.toStringTag,{value:"Module"})),kr=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",bu=kr(),Zr=["macOS","Windows","Linux"],wu=["macos","windows","linux"],Ou={macos:"macOS",windows:"Windows",linux:"Linux"},xu=c.z.enum(Zr).or(c.z.enum(wu).transform(e=>Ou[e])),Iu=()=>{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 Ct;const Nu=((e={})=>{const{force:t,default:n}=e;return t??Ct??(Ct=Iu(),Ct??n)}),vu=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Zr,RUNTIME:bu,detect:kr,getOS:Nu,osZ:xu},Symbol.toStringTag,{value:"Module"})),Mu=()=>Promise.resolve(),Au=()=>new Promise(e=>setTimeout(e,0)),Su=Object.freeze(Object.defineProperty({__proto__:null,flushMicrotasks:Mu,flushTaskQueue:Au},Symbol.toStringTag,{value:"Module"})),Eu=e=>Array.isArray(e)?[...e]:typeof e=="object"&&e!==null?{...e}:e,Tu=Object.freeze(Object.defineProperty({__proto__:null,copy:Eu},Symbol.toStringTag,{value:"Module"})),_r=c.z.enum(["success","info","warning","error","loading","disabled"]),$u=e=>c.z.object({key:c.z.string(),name:c.z.string().default(""),variant:_r,message:c.z.string(),description:c.z.string().optional(),time:d.z,labels:dn(Rr).optional(),details:e??c.z.unknown().optional()}),zu=c.z.object({stack:c.z.string(),error:c.z.instanceof(Error)}),Uu=(e,t)=>{if(!(e instanceof Error))throw e;return qr({variant:"error",message:t??e.message,description:t!=null?e.message:void 0,details:{stack:e.stack??"",error:e}})},qr=e=>({key:Ee(),time:d.now(),name:"",...e}),ju=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},Cu=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},Bu=Object.freeze(Object.defineProperty({__proto__:null,create:qr,exceptionDetailsSchema:zu,fromException:Uu,keepVariants:ju,removeVariants:Cu,statusZ:$u,variantZ:_r},Symbol.toStringTag,{value:"Module"})),Ru=(e,t)=>{if(!t.has(e))return e;let n=e,r=1,s=e;for(;t.has(s);){const i=s.match(Pu);i?(n=s.slice(0,i.index).trim(),r=parseInt(i[1])+1):(n=s,r=1),s=`${n} (${r})`}return s},Pu=/\((\d+)\)$/,Lu=(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]}`},ku=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 h=t.map((y,m)=>m!==l?y.charAt(0).toLowerCase():y).join("");n.add(h.replace(/-/g,"_")),n.add(h.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))},Zu=(e,t)=>e.startsWith(t)?e.slice(t.length):e,_u=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:ku,deduplicateFileName:Ru,naturalLanguageJoin:Lu,trimPrefix:Zu},Symbol.toStringTag,{value:"Module"})),qu=new Error("request for lock canceled");var Fu=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(h){try{l(r.next(h))}catch(y){o(y)}}function u(h){try{l(r.throw(h))}catch(y){o(y)}}function l(h){h.done?i(h.value):s(h.value).then(a,u)}l((r=r.apply(e,t||[])).next())})};class Wu{constructor(t,n=qu){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=Fr(this._queue,a=>n<=a.priority);o===-1&&t<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(t){return Fu(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]=[]),Vu(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 Vu(e,t){const n=Fr(e,r=>t.priority<=r.priority);e.splice(n+1,0,t)}function Fr(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Yu=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(h){try{l(r.next(h))}catch(y){o(y)}}function u(h){try{l(r.throw(h))}catch(y){o(y)}}function l(h){h.done?i(h.value):s(h.value).then(a,u)}l((r=r.apply(e,t||[])).next())})};class Gu{constructor(t){this._semaphore=new Wu(1,t)}acquire(){return Yu(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 Wr extends Gu{constructor(t){super(),Object.assign(this,t)}}const Hu=e=>new Wr(e),Du=Object.freeze(Object.defineProperty({__proto__:null,mutex:Wr,newMutex:Hu},Symbol.toStringTag,{value:"Module"})),Ju=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n),Xu=async(e,t=200,n=20)=>{const r=Date.now();for(;Date.now()-r<t;)await e(),await new Promise(s=>setTimeout(s,n))},Ku=Object.freeze(Object.defineProperty({__proto__:null,expectAlways:Xu,toString:Ju},Symbol.toStringTag,{value:"Module"})),Qu=(...e)=>e.map(Vr).join(""),Vr=e=>(e.endsWith("/")||(e+="/"),e.startsWith("/")&&(e=e.slice(1)),e),tl=e=>e.endsWith("/")?e.slice(0,-1):e,el=(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 xt{protocol;host;port;path;constructor({host:t,port:n,protocol:r="",pathPrefix:s=""}){this.protocol=r,this.host=t,this.port=n,this.path=Vr(s)}replace(t){return new xt({host:t.host??this.host,port:t.port??this.port,protocol:t.protocol??this.protocol,pathPrefix:t.pathPrefix??this.path})}child(t){return new xt({...this,pathPrefix:Qu(this.path,t)})}toString(){return tl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new xt({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=nl(t,this.sender),r=new Yr(n);return this.handlers.set(t,r),r}}const nl=(e,t)=>(n,r)=>t({type:e,payload:n},r);class Yr{_send;handler;constructor(t){this._send=t,this.handler=null}send(t,n=[]){this._send(t,n)}handle(t){this.handler=t}}const rl=()=>{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]},sl=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),il=c.z.int().min(0).max(Un),ol=e=>c.array(e).or(e.transform(t=>[t])),Gr=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"]}),hn=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},cl=((e,t,n)=>t===""?e:tn(hn(e,"shape"),Gr(t),{...n,getter:hn})),al=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:cl,getFieldSchemaPath:Gr,nullToUndefined:sl,toArray:ol,uint12:il},Symbol.toStringTag,{value:"Module"}));exports.DataType=f;exports.Density=b;exports.MultiSeries=vc;exports.Rate=T;exports.RoutedWorker=Me;exports.Series=P;exports.Size=p;exports.TimeRange=A;exports.TimeSpan=g;exports.TimeStamp=d;exports.TypedWorker=Yr;exports.URL=xt;exports.array=Xr;exports.binary=fs;exports.bounds=hi;exports.box=$o;exports.breaker=Tc;exports.buildQueryString=el;exports.caseconv=os;exports.change=zc;exports.clamp=ir;exports.color=ca;exports.compare=Ns;exports.control=fa;exports.convertDataType=ar;exports.createMockWorkers=rl;exports.csv=ga;exports.debounce=ya;exports.deep=Aa;exports.destructor=Sa;exports.dimensions=_o;exports.direction=Mi;exports.errors=La;exports.id=Ss;exports.instance=Es;exports.isCrudeSeries=hr;exports.isTelemValue=De;exports.jsonRPC=Fa;exports.kv=Ga;exports.label=Ha;exports.link=Xa;exports.location=Zi;exports.map=Qa;exports.math=pi;exports.migrate=iu;exports.narrow=cs;exports.notation=au;exports.numericTimeRangeZ=ic;exports.observe=fu;exports.optional=hu;exports.primitive=ds;exports.record=pu;exports.runtime=vu;exports.scale=Jo;exports.scheduler=Su;exports.shallow=Tu;exports.sleep=Ac;exports.spatial=Xo;exports.status=Bu;exports.sticky=nc;exports.strings=_u;exports.sync=Du;exports.testutil=Ku;exports.throttle=ma;exports.typedArrayZ=oc;exports.unique=ys;exports.uuid=bc;exports.xy=eo;exports.zod=al;